cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From weiz...@apache.org
Subject git commit: updated refs/heads/disk_io_throttling to 4c04bc7
Date Wed, 29 May 2013 09:32:06 GMT
Updated Branches:
  refs/heads/disk_io_throttling [created] 4c04bc7b9


CLOUDSTACK-1301: VM Disk I/O Throttling


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4c04bc7b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4c04bc7b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4c04bc7b

Branch: refs/heads/disk_io_throttling
Commit: 4c04bc7b933852acbecbb61e22b4f0b3d96986b9
Parents: c300576
Author: Wei Zhou <w.zhou@leaseweb.com>
Authored: Wed May 29 11:31:00 2013 +0200
Committer: Wei Zhou <w.zhou@leaseweb.com>
Committed: Wed May 29 11:31:00 2013 +0200

----------------------------------------------------------------------
 api/src/com/cloud/agent/api/to/VolumeTO.java       |   18 +++
 api/src/com/cloud/offering/DiskOffering.java       |    8 ++
 api/src/com/cloud/vm/DiskProfile.java              |   18 +++
 .../admin/offering/CreateDiskOfferingCmd.java      |   16 +++-
 .../admin/offering/CreateServiceOfferingCmd.java   |   14 +++
 .../api/response/DiskOfferingResponse.java         |   14 +++
 .../api/response/ServiceOfferingResponse.java      |   14 +++
 .../cloudstack/api/response/VolumeResponse.java    |   14 +++
 .../WEB-INF/classes/resources/messages.properties  |    2 +
 .../com/cloud/agent/api/AttachVolumeCommand.java   |   18 +++
 .../src/com/cloud/storage/DiskOfferingVO.java      |   24 ++++
 .../kvm/resource/LibvirtComputingResource.java     |   15 +++-
 .../kvm/resource/LibvirtDomainXMLParser.java       |   15 +++
 .../hypervisor/kvm/resource/LibvirtVMDef.java      |   34 ++++++
 .../api/query/dao/DiskOfferingJoinDaoImpl.java     |    2 +
 .../api/query/dao/ServiceOfferingJoinDaoImpl.java  |    2 +
 .../com/cloud/api/query/dao/VolumeJoinDaoImpl.java |    2 +
 .../com/cloud/api/query/vo/DiskOfferingJoinVO.java |   21 ++++
 .../cloud/api/query/vo/ServiceOfferingJoinVO.java  |   20 ++++
 .../src/com/cloud/api/query/vo/VolumeJoinVO.java   |   22 ++++
 server/src/com/cloud/configuration/Config.java     |    2 +
 .../cloud/configuration/ConfigurationManager.java  |    4 +-
 .../configuration/ConfigurationManagerImpl.java    |   20 +++-
 server/src/com/cloud/storage/StorageManager.java   |    6 +
 .../src/com/cloud/storage/StorageManagerImpl.java  |   34 ++++++
 .../src/com/cloud/storage/VolumeManagerImpl.java   |   24 ++++-
 server/src/com/cloud/test/DatabaseConfig.java      |    6 +
 .../com/cloud/vm/VirtualMachineManagerImpl.java    |    2 +-
 .../cloud/vpc/MockConfigurationManagerImpl.java    |    4 +-
 setup/db/db/schema-410to420.sql                    |   12 ++
 ui/dictionary.jsp                                  |    2 +
 ui/scripts/configuration.js                        |   82 +++++++++++++++
 32 files changed, 477 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/api/src/com/cloud/agent/api/to/VolumeTO.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/to/VolumeTO.java b/api/src/com/cloud/agent/api/to/VolumeTO.java
index 4cbe82b..8b3a6be 100644
--- a/api/src/com/cloud/agent/api/to/VolumeTO.java
+++ b/api/src/com/cloud/agent/api/to/VolumeTO.java
@@ -37,6 +37,8 @@ public class VolumeTO implements InternalIdentity {
     private long deviceId;
     private String chainInfo;
     private String guestOsType;
+    private long bytesRate;
+    private long iopsRate;
 
     public VolumeTO(long id, Volume.Type type, StoragePoolType poolType, String poolUuid, String name, String mountPoint, String path, long size, String chainInfo) {
         this.id = id;
@@ -133,4 +135,20 @@ public class VolumeTO implements InternalIdentity {
     public String toString() {
         return new StringBuilder("Vol[").append(id).append("|").append(type).append("|").append(path).append("|").append(size).append("]").toString();
     }
+    
+    public void setBytesRate(long bytesRate) {
+        this.bytesRate = bytesRate;
+    }
+    
+    public long getBytesRate() {
+        return bytesRate;
+    }
+    
+    public void setIopsRate(long iopsRate) {
+        this.iopsRate = iopsRate;
+    }
+    
+    public long getIopsRate() {
+        return iopsRate;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/api/src/com/cloud/offering/DiskOffering.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/offering/DiskOffering.java b/api/src/com/cloud/offering/DiskOffering.java
index dd77c70..1618db9 100644
--- a/api/src/com/cloud/offering/DiskOffering.java
+++ b/api/src/com/cloud/offering/DiskOffering.java
@@ -52,4 +52,12 @@ public interface DiskOffering extends InfrastructureEntity, Identity, InternalId
     boolean isCustomized();
 
     void setDiskSize(long diskSize);
+    
+    void setBytesRate(long bytesRate);
+    
+    long getBytesRate();
+    
+    void setIopsRate(long iopsRate);
+    
+    long getIopsRate();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/api/src/com/cloud/vm/DiskProfile.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/DiskProfile.java b/api/src/com/cloud/vm/DiskProfile.java
index e3a3386..2c77006 100644
--- a/api/src/com/cloud/vm/DiskProfile.java
+++ b/api/src/com/cloud/vm/DiskProfile.java
@@ -35,6 +35,8 @@ public class DiskProfile {
     private Long templateId;
     private long volumeId;
     private String path;
+    private long bytesRate;
+    private long iopsRate;
 
     private HypervisorType hyperType;
 
@@ -154,4 +156,20 @@ public class DiskProfile {
     public void setSize(long size) {
     	this.size = size;
     }
+    
+    public void setBytesRate(long bytesRate) {
+        this.bytesRate = bytesRate;
+    }
+    
+    public long getBytesRate() {
+        return bytesRate;
+    }
+    
+    public void setIopsRate(long iopsRate) {
+        this.iopsRate = iopsRate;
+    }
+    
+    public long getIopsRate() {
+        return iopsRate;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java
index aa11599..848d158 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java
@@ -61,6 +61,12 @@ public class CreateDiskOfferingCmd extends BaseCmd {
 
     @Parameter(name=ApiConstants.STORAGE_TYPE, type=CommandType.STRING, description="the storage type of the disk offering. Values are local and shared.")
     private String storageType = ServiceOffering.StorageType.shared.toString();
+    
+    @Parameter(name="bytesRate", type=CommandType.LONG, required=false, description="bytes rate of the disk offering")
+    private Long bytesRate;
+
+    @Parameter(name="iopsRate", type=CommandType.LONG, required=false, description="io requests rate of the disk offering")
+    private Long iopsRate;
 
     @Parameter(name=ApiConstants.DISPLAY_OFFERING, type=CommandType.BOOLEAN, description="an optional field, whether to display the offering to the end user or not.")
     private Boolean displayOffering;
@@ -92,6 +98,14 @@ public class CreateDiskOfferingCmd extends BaseCmd {
     public Long getDomainId(){
         return domainId;
     }
+    
+    public Long getBytesRate() {
+        return bytesRate;
+    }
+    
+    public Long getIopsRate() {
+        return iopsRate;
+    }
 
     public String getStorageType() {
         return storageType;
@@ -114,7 +128,7 @@ public class CreateDiskOfferingCmd extends BaseCmd {
     public long getEntityOwnerId() {
         return Account.ACCOUNT_ID_SYSTEM;
     }
-
+    
     @Override
     public void execute(){
         DiskOffering offering = _configService.createDiskOffering(this);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java
index 4c54a4e..28f1a68 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java
@@ -93,6 +93,12 @@ public class CreateServiceOfferingCmd extends BaseCmd {
     @Parameter(name = ApiConstants.SERVICE_OFFERING_DETAILS, type = CommandType.MAP, description = "details for planner, used to store specific parameters")
     private Map<String, String> details;
 
+    @Parameter(name="bytesRate", type=CommandType.LONG, required=false, description="bytes rate of the disk offering")
+    private Long bytesRate;
+
+    @Parameter(name="iopsRate", type=CommandType.LONG, required=false, description="io requests rate of the disk offering")
+    private Long iopsRate;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -171,6 +177,14 @@ public class CreateServiceOfferingCmd extends BaseCmd {
         return params;
     }
 
+    public long getBytesRate() {
+       return bytesRate;
+    }
+
+    public long getIopsRate() {
+        return iopsRate;
+    }
+
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java b/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java
index 377e66e..8d4bec3 100644
--- a/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java
@@ -57,6 +57,12 @@ public class DiskOfferingResponse extends BaseResponse {
 
     @SerializedName("storagetype") @Param(description="the storage type for this disk offering")
     private String storageType;
+    
+    @SerializedName("diskBytesRate") @Param(description="bytes rate of the disk offering")
+    private Long bytesRate;
+
+    @SerializedName("diskIORate") @Param(description="io requests rate of the disk offering")
+    private Long iopsRate;
 
     @SerializedName("displayoffering") @Param(description="whether to display the offering to the end user or not.")
     private Boolean displayOffering;
@@ -149,4 +155,12 @@ public class DiskOfferingResponse extends BaseResponse {
     public void setStorageType(String storageType) {
         this.storageType = storageType;
     }
+    
+    public void setBytesRate(long bytesRate) {
+        this.bytesRate = bytesRate;
+    }
+    
+    public void setIopsRate(long iopsRate) {
+        this.iopsRate = iopsRate;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java b/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java
index 31533f8..b98fd4d 100644
--- a/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java
@@ -86,6 +86,12 @@ public class ServiceOfferingResponse extends BaseResponse {
 
     @SerializedName(ApiConstants.NETWORKRATE) @Param(description="data transfer rate in megabits per second allowed.")
     private Integer networkRate;
+    
+    @SerializedName("diskBytesRate") @Param(description="bytes rate of the service offering")
+    private Long bytesRate;
+
+    @SerializedName("diskIORate") @Param(description="io requests rate of the service offering")
+    private Long iopsRate;
 
     @SerializedName(ApiConstants.DEPLOYMENT_PLANNER) @Param(description="deployment strategy used to deploy VM.")
     private String deploymentPlanner;
@@ -248,4 +254,12 @@ public class ServiceOfferingResponse extends BaseResponse {
     public void setVolatileVm(boolean isVolatile) {
         this.isVolatile = isVolatile;
     }
+    
+    public void setBytesRate(long bytesRate) {
+        this.bytesRate = bytesRate;
+    }
+    
+    public void setIopsRate(long iopsRate) {
+        this.iopsRate = iopsRate;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/VolumeResponse.java b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
index 21d7d1a..8e38d85 100644
--- a/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
@@ -110,6 +110,12 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity
     @Param(description = "shared or local storage")
     private String storageType;
 
+    @SerializedName("diskBytesRate") @Param(description="bytes rate of the disk offering")
+    private Long bytesRate;
+
+    @SerializedName("diskIORate") @Param(description="io requests rate of the disk offering")
+    private Long iopsRate;
+
     @SerializedName(ApiConstants.HYPERVISOR)
     @Param(description = "Hypervisor the volume belongs to")
     private String hypervisor;
@@ -258,6 +264,14 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity
         this.storageType = storageType;
     }
 
+    public void setBytesRate(long bytesRate) {
+        this.bytesRate = bytesRate;
+    }
+
+    public void setIopsRate(long iopsRate) {
+        this.iopsRate = iopsRate;
+    }
+
     public void setHypervisor(String hypervisor) {
         this.hypervisor = hypervisor;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/client/WEB-INF/classes/resources/messages.properties
----------------------------------------------------------------------
diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties
index ce20fa4..fc7715d 100644
--- a/client/WEB-INF/classes/resources/messages.properties
+++ b/client/WEB-INF/classes/resources/messages.properties
@@ -463,6 +463,8 @@ label.disable.vpn=Disable VPN
 label.disabled=Disabled
 label.disabling.vpn.access=Disabling VPN Access
 label.disk.allocated=Disk Allocated
+label.disk.bytes.rate=Disk Rate (BPS)
+label.disk.iops.rate=Disk Rate (IOPS)
 label.disk.offering=Disk Offering
 label.disk.read.bytes=Disk Read (Bytes)
 label.disk.read.io=Disk Read (IO)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/core/src/com/cloud/agent/api/AttachVolumeCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/AttachVolumeCommand.java b/core/src/com/cloud/agent/api/AttachVolumeCommand.java
index 302b8f8..101c254 100644
--- a/core/src/com/cloud/agent/api/AttachVolumeCommand.java
+++ b/core/src/com/cloud/agent/api/AttachVolumeCommand.java
@@ -29,6 +29,8 @@ public class AttachVolumeCommand extends Command {
 	String volumeName;
 	Long deviceId;
 	String chainInfo;
+    long bytesRate;
+    long iopsRate;
 
 	protected AttachVolumeCommand() {
 	}
@@ -96,4 +98,20 @@ public class AttachVolumeCommand extends Command {
     public String getChainInfo() {
     	return chainInfo;
     }
+    
+    public void setBytesRate(long bytesRate) {
+        this.bytesRate = bytesRate;
+    }
+    
+    public long getBytesRate() {
+        return bytesRate;
+    }
+    
+    public void setIopsRate(long iopsRate) {
+        this.iopsRate = iopsRate;
+    }
+    
+    public long getIopsRate() {
+        return iopsRate;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/DiskOfferingVO.java b/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
index 909d7fe..239ddb0 100755
--- a/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
+++ b/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
@@ -99,6 +99,13 @@ public class DiskOfferingVO implements DiskOffering {
 
     @Column(name="sort_key")
     int sortKey;
+    
+    @Column(name="bytes_rate")
+    long bytesRate;
+
+    @Column(name="iops_rate")
+    long iopsRate;
+
 
     @Column(name="display_offering")
     boolean displayOffering;
@@ -327,4 +334,21 @@ public class DiskOfferingVO implements DiskOffering {
     public void setDisplayOffering(boolean displayOffering) {
         this.displayOffering = displayOffering;
     }
+
+    public void setBytesRate(long bytesRate) {
+       this.bytesRate = bytesRate;
+    }
+
+    public long getBytesRate() {
+       return bytesRate;
+    }
+
+    public void setIopsRate(long iopsRate) {
+        this.iopsRate = iopsRate;
+    }
+
+    public long getIopsRate() {
+        return iopsRate;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index 46fce24..9b26ef2 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -1393,6 +1393,8 @@ ServerResource {
             VolumeTO volume = new VolumeTO(cmd.getVolumeId(), dskch.getType(),
                     pool.getType(), pool.getUuid(), pool.getPath(),
                     vol.getName(), vol.getName(), disksize, null);
+            volume.setBytesRate(dskch.getBytesRate());
+            volume.setIopsRate(dskch.getIopsRate());
             return new CreateAnswer(cmd, volume);
         } catch (CloudRuntimeException e) {
             s_logger.debug("Failed to create volume: " + e.toString());
@@ -2608,7 +2610,7 @@ ServerResource {
                     cmd.getPoolUuid());
             KVMPhysicalDisk disk = primary.getPhysicalDisk(cmd.getVolumePath());
             attachOrDetachDisk(conn, cmd.getAttach(), cmd.getVmName(), disk,
-                    cmd.getDeviceId().intValue());
+                    cmd.getDeviceId().intValue(), cmd.getBytesRate(), cmd.getIopsRate());
         } catch (LibvirtException e) {
             return new AttachVolumeAnswer(cmd, e.toString());
         } catch (InternalErrorException e) {
@@ -3476,6 +3478,11 @@ ServerResource {
                 }
 
             }
+            
+            if (volume.getBytesRate() > 0)
+                disk.setBytesRate(volume.getBytesRate());
+            if (volume.getIopsRate() > 0)
+                disk.setIopsRate(volume.getIopsRate());
 
             vm.getDevices().addDevice(disk);
         }
@@ -3610,7 +3617,7 @@ ServerResource {
 
     protected synchronized String attachOrDetachDisk(Connect conn,
             boolean attach, String vmName, KVMPhysicalDisk attachingDisk,
-            int devId) throws LibvirtException, InternalErrorException {
+            int devId, long bytesRate, long iopsRate) throws LibvirtException, InternalErrorException {
         List<DiskDef> disks = null;
         Domain dm = null;
         DiskDef diskdef = null;
@@ -3650,6 +3657,10 @@ ServerResource {
                     diskdef.defBlockBasedDisk(attachingDisk.getPath(), devId,
                             DiskDef.diskBus.VIRTIO);
                 }
+                if (bytesRate > 0)
+                    diskdef.setBytesRate(bytesRate);
+                if (iopsRate > 0)
+                    diskdef.setIopsRate(iopsRate);
             }
 
             String xml = diskdef.toString();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
index b8645e1..cccdc39 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
@@ -105,6 +105,21 @@ public class LibvirtDomainXMLParser {
                                 DiskDef.diskBus.valueOf(bus.toUpperCase()));
                     }
                 }
+                
+                NodeList iotune = disk.getElementsByTagName("iotune");
+                if ((iotune != null) && (iotune.getLength() !=0)) {
+                    String bytesRateStr = getTagValue("total_bytes_sec", (Element)iotune.item(0));
+                    if (bytesRateStr != null) {
+                        Long bytesRate = Long.parseLong(bytesRateStr);
+                        def.setBytesRate(bytesRate);
+                    }
+                    String iopsRateStr = getTagValue("total_iops_sec", (Element)iotune.item(0));
+                    if (iopsRateStr != null) {
+                        Long iopsRate = Long.parseLong(iopsRateStr);
+                        def.setIopsRate(iopsRate);
+                    }
+                }
+
                 diskDefs.add(def);
             }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
index 9cddb2e..2959821 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
@@ -22,6 +22,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import com.cloud.utils.script.Script;
+
 public class LibvirtVMDef {
     private String _hvsType;
     private String _domName;
@@ -439,6 +441,8 @@ public class LibvirtVMDef {
         private boolean _readonly = false;
         private boolean _shareable = false;
         private boolean _deferAttach = false;
+        private Long _bytesRate;
+        private Long _iopsRate;
 
         public void setDeviceType(deviceType deviceType) {
             _deviceType = deviceType;
@@ -583,6 +587,14 @@ public class LibvirtVMDef {
             char suffix = this._diskLabel.charAt(this._diskLabel.length() - 1);
             return suffix - 'a';
         }
+        
+        public void setBytesRate(Long bytesRate) {
+            _bytesRate = bytesRate;
+        }
+        
+        public void setIopsRate(Long iopsRate) {
+            _iopsRate = iopsRate;
+        }
 
         @Override
         public String toString() {
@@ -627,6 +639,28 @@ public class LibvirtVMDef {
                 diskBuilder.append(" bus='" + _bus + "'");
             }
             diskBuilder.append("/>\n");
+            
+            String libvirtVersion = Script.runSimpleBashScript("virsh version |grep API | awk '{print $4}'");
+            String qemuVersion = Script.runSimpleBashScript("virsh version |grep hypervisor | awk '{print $4}'");
+            if ((_deviceType != deviceType.CDROM) && (libvirtVersion != null) && (qemuVersion != null) 
+                    && (((_bytesRate != null) && (_bytesRate > 0)) || ((_iopsRate != null) && (_iopsRate > 0)))) { // not CDROM, from libvirt 0.9.8 and QEMU 1.1.0
+                String[] libvirtVersions = libvirtVersion.split("\\.");
+                String[] qemuVersions = qemuVersion.split("\\.");
+                if (((libvirtVersions != null) && (libvirtVersions.length == 3) && ((Integer.valueOf(libvirtVersions[0]) > 0)
+                        || ((Integer.valueOf(libvirtVersions[0]) == 0) && (Integer.valueOf(libvirtVersions[1]) > 9))
+                        || ((Integer.valueOf(libvirtVersions[0]) == 0) && (Integer.valueOf(libvirtVersions[1]) == 9) && (Integer.valueOf(libvirtVersions[1]) >= 8))))
+                        && ((qemuVersions != null) && (qemuVersions.length == 3) && ((Integer.valueOf(qemuVersions[0]) > 1)
+                        || ((Integer.valueOf(qemuVersions[0]) == 1) && (Integer.valueOf(qemuVersions[1]) > 1))
+                        || ((Integer.valueOf(qemuVersions[0]) == 1) && (Integer.valueOf(qemuVersions[1]) == 1) && (Integer.valueOf(qemuVersions[1]) >= 0))))) {
+                    diskBuilder.append("<iotune>\n");
+                    if ((_bytesRate != null) && (_bytesRate > 0))
+                        diskBuilder.append("<total_bytes_sec>" + _bytesRate + "</total_bytes_sec>\n");
+                    if ((_iopsRate != null) && (_iopsRate > 0))
+                        diskBuilder.append("<total_iops_sec>" + _iopsRate + "</total_iops_sec>\n");
+                    diskBuilder.append("</iotune>\n");
+                }
+            }
+            
             diskBuilder.append("</disk>\n");
             return diskBuilder.toString();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
index 283181f..bfae58b 100644
--- a/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java
@@ -76,6 +76,8 @@ public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO,
         diskOfferingResponse.setCustomized(offering.isCustomized());
         diskOfferingResponse.setStorageType(offering.isUseLocalStorage() ? ServiceOffering.StorageType.local.toString() : ServiceOffering.StorageType.shared.toString());
         diskOfferingResponse.setObjectName("diskoffering");
+        diskOfferingResponse.setBytesRate(offering.getBytesRate());
+        diskOfferingResponse.setIopsRate(offering.getIopsRate());
         return diskOfferingResponse;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/src/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java
index 56e4d0a..ec67175 100644
--- a/server/src/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java
@@ -76,6 +76,8 @@ public class ServiceOfferingJoinDaoImpl extends GenericDaoBase<ServiceOfferingJo
         offeringResponse.setHostTag(offering.getHostTag());
         offeringResponse.setDeploymentPlanner(offering.getDeploymentPlanner());
         offeringResponse.setObjectName("serviceoffering");
+        offeringResponse.setBytesRate(offering.getBytesRate());
+        offeringResponse.setIopsRate(offering.getIopsRate());
 
         return offeringResponse;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
index e27e2d9..e65f78a 100644
--- a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
@@ -160,6 +160,8 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
             }
             volResponse.setStorageType(volume.isUseLocalStorage() ? ServiceOffering.StorageType.local.toString() : ServiceOffering.StorageType.shared
                     .toString());
+            volResponse.setBytesRate(volume.getBytesRate());
+            volResponse.setIopsRate(volume.getIopsRate());
         }
         Long poolId = volume.getPoolId();
         String poolName = (poolId == null) ? "none" : volume.getPoolName();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java b/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java
index 6d3cdcb..c44c171 100644
--- a/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/DiskOfferingJoinVO.java
@@ -64,6 +64,12 @@ public class DiskOfferingJoinVO extends BaseViewVO implements InternalIdentity,
     @Column(name="sort_key")
     int sortKey;
 
+    @Column(name="bytes_rate")
+    long bytesRate;
+
+    @Column(name="iops_rate")
+    long iopsRate;
+
     @Column(name="type")
     Type type;
 
@@ -239,6 +245,21 @@ public class DiskOfferingJoinVO extends BaseViewVO implements InternalIdentity,
         this.type = type;
     }
 
+    public void setBytesRate(long bytesRate) {
+       this.bytesRate = bytesRate;
+    }
+
+    public long getBytesRate() {
+       return bytesRate;
+    }
+
+    public void setIopsRate(long iopsRate) {
+        this.iopsRate = iopsRate;
+    }
+
+    public long getIopsRate() {
+        return iopsRate;
+    }
 
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/src/com/cloud/api/query/vo/ServiceOfferingJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/ServiceOfferingJoinVO.java b/server/src/com/cloud/api/query/vo/ServiceOfferingJoinVO.java
index e87a101..89c665e 100644
--- a/server/src/com/cloud/api/query/vo/ServiceOfferingJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/ServiceOfferingJoinVO.java
@@ -90,6 +90,11 @@ public class ServiceOfferingJoinVO extends BaseViewVO implements InternalIdentit
     @Column(name="sort_key")
     int sortKey;
 
+    @Column(name="bytes_rate")
+    long bytesRate;
+
+    @Column(name="iops_rate")
+    long iopsRate;
 
     @Column(name=GenericDao.CREATED_COLUMN)
     private Date created;
@@ -329,5 +334,20 @@ public class ServiceOfferingJoinVO extends BaseViewVO implements InternalIdentit
         this.volatileVm = volatileVm;
     }
 
+    public void setBytesRate(long bytesRate) {
+        this.bytesRate = bytesRate;
+    }
+
+    public long getBytesRate() {
+        return bytesRate;
+    }
+
+    public void setIopsRate(long iopsRate) {
+        this.iopsRate = iopsRate;
+    }
+
+    public long getIopsRate() {
+        return iopsRate;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/src/com/cloud/api/query/vo/VolumeJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/VolumeJoinVO.java b/server/src/com/cloud/api/query/vo/VolumeJoinVO.java
index 6ef8c91..5831659 100644
--- a/server/src/com/cloud/api/query/vo/VolumeJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/VolumeJoinVO.java
@@ -184,6 +184,12 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity {
     @Column(name="use_local_storage")
     private boolean useLocalStorage;
 
+    @Column(name="bytes_rate")
+    long bytesRate;
+
+    @Column(name="iops_rate")
+    long iopsRate;
+
     @Column(name="pool_id")
     private long poolId;
 
@@ -742,6 +748,22 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity {
     }
 
 
+    public void setBytesRate(long bytesRate) {
+       this.bytesRate = bytesRate;
+    }
+
+    public long getBytesRate() {
+       return bytesRate;
+    }
+
+    public void setIopsRate(long iopsRate) {
+        this.iopsRate = iopsRate;
+    }
+
+    public long getIopsRate() {
+        return iopsRate;
+    }
+
 
     public long getPoolId() {
         return poolId;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index 75d5367..df8a6a5 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -231,6 +231,8 @@ public enum Config {
 	VmDiskStatsInterval("Advanced", ManagementServer.class, Integer.class, "vm.disk.stats.interval", "0", "Interval (in seconds) to report vm disk statistics.", null),
 	VmTransitionWaitInterval("Advanced", ManagementServer.class, Integer.class, "vm.tranisition.wait.interval", "3600", "Time (in seconds) to wait before taking over a VM in transition state", null),
 	VmDestroyForcestop("Advanced", ManagementServer.class, Boolean.class, "vm.destroy.forcestop", "false", "On destroy, force-stop takes this value ", null),
+        VmDiskThrottlingIORate("Advanced", ManagementServer.class, Integer.class, "vm.disk.throttling.iops_rate", "0", "Default disk I/O rate in requests per second allowed in User vm's disk.", null),
+        VmDiskThrottlingBytesRate("Advanced", ManagementServer.class, Integer.class, "vm.disk.throttling.bytes_rate", "0", "Default disk I/O rate in bytes per second allowed in User vm's disk.", null),
 
 	ControlCidr("Advanced", ManagementServer.class, String.class, "control.cidr", "169.254.0.0/16", "Changes the cidr for the control network traffic.  Defaults to using link local.  Must be unique within pods", null),
 	ControlGateway("Advanced", ManagementServer.class, String.class, "control.gateway", "169.254.0.1", "gateway for the control network traffic", null),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/src/com/cloud/configuration/ConfigurationManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java
index 8db037b..975fad1 100755
--- a/server/src/com/cloud/configuration/ConfigurationManager.java
+++ b/server/src/com/cloud/configuration/ConfigurationManager.java
@@ -84,7 +84,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
      * @return ID
      */
     ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vm_typeType, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired,
-            boolean offerHA, boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate, String deploymentPlanner, Map<String, String> details);
+            boolean offerHA, boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate, String deploymentPlanner, Map<String, String> details, Long bytesRate, Long iopsRate);
 
     /**
      * Creates a new disk offering
@@ -99,7 +99,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
      * @param isDisplayOfferingEnabled
      * @return newly created disk offering
      */
-    DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled);
+    DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled, Long bytesRate, Long iopsRate);
 
     /**
      * Creates a new pod

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 79375f9..c51d701 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -2013,7 +2013,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         return createServiceOffering(userId, cmd.getIsSystem(), vmType, cmd.getServiceOfferingName(),
                 cpuNumber.intValue(), memory.intValue(), cpuSpeed.intValue(), cmd.getDisplayText(),
                 localStorageRequired, offerHA, limitCpuUse, volatileVm, cmd.getTags(), cmd.getDomainId(),
-                cmd.getHostTag(), cmd.getNetworkRate(), cmd.getDeploymentPlanner(), cmd.getDetails());
+                cmd.getHostTag(), cmd.getNetworkRate(), cmd.getDeploymentPlanner(), cmd.getDetails(),
+                cmd.getBytesRate(), cmd.getIopsRate());
     }
 
     @Override
@@ -2021,11 +2022,16 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
     public ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vm_type,
             String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired,
             boolean offerHA, boolean limitResourceUse, boolean volatileVm,  String tags, Long domainId, String hostTag,
-            Integer networkRate, String deploymentPlanner, Map<String, String> details) {
+            Integer networkRate, String deploymentPlanner, Map<String, String> details, Long bytesRate, Long iopsRate) {
         tags = cleanupTags(tags);
         ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, null, offerHA, limitResourceUse, volatileVm, displayText, localStorageRequired, false, tags, isSystem, vm_type,
                 domainId, hostTag, deploymentPlanner);
 
+        if ((bytesRate != null) && (bytesRate > 0))
+            offering.setBytesRate(bytesRate);
+        if ((iopsRate != null) && (iopsRate > 0))
+            offering.setIopsRate(iopsRate);
+
         if ((offering = _serviceOfferingDao.persist(offering)) != null) {
             if (details != null) {
                 _serviceOfferingDetailsDao.persist(offering.getId(), details);
@@ -2111,7 +2117,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_DISK_OFFERING_CREATE, eventDescription = "creating disk offering")
-    public DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled) {
+    public DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled, Long bytesRate, Long iopsRate) {
         long diskSize = 0;// special case for custom disk offerings
         if (numGibibytes != null && (numGibibytes <= 0)) {
             throw new InvalidParameterValueException("Please specify a disk size of at least 1 Gb.");
@@ -2131,6 +2137,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         DiskOfferingVO newDiskOffering = new DiskOfferingVO(domainId, name, description, diskSize, tags, isCustomized);
         newDiskOffering.setUseLocalStorage(localStorageRequired);
         newDiskOffering.setDisplayOffering(isDisplayOfferingEnabled);
+        if (bytesRate != null && (bytesRate > 0))
+            newDiskOffering.setBytesRate(bytesRate);
+        if (iopsRate != null && (iopsRate > 0))
+            newDiskOffering.setIopsRate(iopsRate);
         UserContext.current().setEventDetails("Disk offering id=" + newDiskOffering.getId());
         DiskOfferingVO offering = _diskOfferingDao.persist(newDiskOffering);
         if (offering != null) {
@@ -2171,7 +2181,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
             }
         }
 
-        return createDiskOffering(domainId, name, description, numGibibytes, tags, isCustomized, localStorageRequired, isDisplayOfferingEnabled);
+        Long bytesRate = cmd.getBytesRate();
+        Long iopsRate = cmd.getIopsRate();
+        return createDiskOffering(domainId, name, description, numGibibytes, tags, isCustomized, localStorageRequired, isDisplayOfferingEnabled, bytesRate, iopsRate);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/src/com/cloud/storage/StorageManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManager.java b/server/src/com/cloud/storage/StorageManager.java
index d49a7f8..7f5b3ff 100755
--- a/server/src/com/cloud/storage/StorageManager.java
+++ b/server/src/com/cloud/storage/StorageManager.java
@@ -35,6 +35,8 @@ import com.cloud.exception.ConnectionException;
 import com.cloud.exception.StorageUnavailableException;
 import com.cloud.host.Host;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.service.ServiceOfferingVO;
+import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.utils.Pair;
 import com.cloud.vm.DiskProfile;
@@ -122,4 +124,8 @@ public interface StorageManager extends StorageService {
     DataStore createLocalStorage(Host host, StoragePoolInfo poolInfo) throws ConnectionException;
 
     BigDecimal getStorageOverProvisioningFactor(Long dcId);
+
+    Long getDiskBytesRate(ServiceOfferingVO offering, DiskOfferingVO diskOffering);
+
+    Long getDiskIORate(ServiceOfferingVO offering, DiskOfferingVO diskOffering);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index a67397e..1f121ed 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -127,6 +127,7 @@ import com.cloud.resource.ResourceState;
 import com.cloud.server.ManagementServer;
 import com.cloud.server.StatsCollector;
 import com.cloud.service.dao.ServiceOfferingDao;
+import com.cloud.service.ServiceOfferingVO;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.Volume.Type;
@@ -142,6 +143,7 @@ import com.cloud.storage.dao.VMTemplateS3Dao;
 import com.cloud.storage.dao.VMTemplateSwiftDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.dao.VolumeHostDao;
+import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.download.DownloadMonitor;
 import com.cloud.storage.listener.StoragePoolMonitor;
 import com.cloud.storage.listener.VolumeStateListener;
@@ -1864,4 +1866,36 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
         return null;
     }
 
+    // get bytesRate from disk_offering and vm.disk.throttling.bytes_rate
+    @Override
+    public Long getDiskBytesRate(ServiceOfferingVO offering, DiskOfferingVO diskOffering) {
+        if ((offering != null) && (offering.getBytesRate() > 0)) {
+            return offering.getBytesRate();
+        } else if ((diskOffering != null) && (diskOffering.getBytesRate() > 0)) {
+            return diskOffering.getBytesRate();
+        } else {
+            Long bytesRate = Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingBytesRate.key()));
+            if (bytesRate > 0)  {
+                return bytesRate;
+            }
+        }
+        return 0L;
+    }
+
+    // get iopsRate from disk_offering and vm.disk.throttling.io_rate
+    @Override
+    public Long getDiskIORate(ServiceOfferingVO offering, DiskOfferingVO diskOffering) {
+        if ((offering != null) && (offering.getIopsRate() > 0)) {
+            return offering.getIopsRate();
+        } else if ((diskOffering != null) && (diskOffering.getIopsRate() > 0)) {
+            return diskOffering.getIopsRate();
+        } else {
+            Long iopsRate = Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingIORate.key()));
+            if (iopsRate > 0)  {
+                return iopsRate;
+            }
+        }
+        return 0L;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java
index bec4720..c260fc5 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -115,6 +115,7 @@ import com.cloud.server.ManagementServer;
 import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.storage.Storage.ImageFormat;
+import com.cloud.storage.StorageManager;
 import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.Volume.Event;
 import com.cloud.storage.Volume.Type;
@@ -336,6 +337,9 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
                 diskOffering.getUseLocalStorage(),
                 diskOffering.isRecreatable(), null);
         dskCh.setHyperType(dataDiskHyperType);
+        dskCh.setBytesRate(storageMgr.getDiskBytesRate(null, diskOffering));
+        dskCh.setIopsRate(storageMgr.getDiskIORate(null, diskOffering));
+
         DataCenterVO destPoolDataCenter = _dcDao.findById(destPoolDcId);
         HostPodVO destPoolPod = _podDao.findById(destPoolPodId);
         
@@ -510,6 +514,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
         DataCenterVO dc = _dcDao.findById(volume.getDataCenterId());
         DiskProfile dskCh = new DiskProfile(volume, diskOffering,
                 snapshot.getHypervisorType());
+        dskCh.setBytesRate(storageMgr.getDiskBytesRate(null, diskOffering));
+        dskCh.setIopsRate(storageMgr.getDiskIORate(null, diskOffering));
 
         // Determine what pod to store the volume in
         while ((pod = _resourceMgr.findPod(null, null, dc, account.getId(),
@@ -610,6 +616,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
         DiskProfile dskCh = createDiskCharacteristics(volume, template, dc,
                 diskOffering);
         dskCh.setHyperType(vm.getHypervisorType());
+        dskCh.setBytesRate(storageMgr.getDiskBytesRate(offering, diskOffering));
+        dskCh.setIopsRate(storageMgr.getDiskIORate(offering, diskOffering));
         // Find a suitable storage to create volume on
         StoragePool destPool = storageMgr.findStoragePool(dskCh, dc, pod,
                 clusterId, null, vm, avoidPools);
@@ -654,6 +662,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
         }
 
         dskCh.setHyperType(hyperType);
+        dskCh.setBytesRate(storageMgr.getDiskBytesRate(offering, diskOffering));
+        dskCh.setIopsRate(storageMgr.getDiskIORate(offering, diskOffering));
         
         final HashSet<StoragePool> avoidPools = new HashSet<StoragePool>(
                 avoids);
@@ -2232,7 +2242,12 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
 
         for (VolumeVO vol : vols) {
             PrimaryDataStoreInfo pool = (PrimaryDataStoreInfo)this.dataStoreMgr.getDataStore(vol.getPoolId(), DataStoreRole.Primary);
-            vm.addDisk(new VolumeTO(vol, pool));
+            ServiceOfferingVO offering = _offeringDao.findById(vm.getServiceOfferingId());
+            DiskOfferingVO diskOffering = _diskOfferingDao.findById(vol.getDiskOfferingId());
+            VolumeTO newVolume = new VolumeTO(vol, pool);
+            newVolume.setBytesRate(storageMgr.getDiskBytesRate(offering, diskOffering));
+            newVolume.setIopsRate(storageMgr.getDiskIORate(offering, diskOffering));
+            vm.addDisk(newVolume);
         }
 
         if (vm.getType() == VirtualMachine.Type.User) {
@@ -2462,7 +2477,12 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
                 pool = (StoragePool)dataStoreMgr.getDataStore(result.second().getId(), DataStoreRole.Primary);
                 vol = result.first();
             }
-            vm.addDisk(new VolumeTO(vol, pool));
+            ServiceOfferingVO offering = _offeringDao.findById(vm.getServiceOfferingId());
+            DiskOfferingVO diskOffering = _diskOfferingDao.findById(vol.getDiskOfferingId());
+            VolumeTO newVolume = new VolumeTO(vol, pool);
+            newVolume.setBytesRate(storageMgr.getDiskBytesRate(offering, diskOffering));
+            newVolume.setIopsRate(storageMgr.getDiskIORate(offering, diskOffering));
+            vm.addDisk(newVolume);
         }
     }
     

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/src/com/cloud/test/DatabaseConfig.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/test/DatabaseConfig.java b/server/src/com/cloud/test/DatabaseConfig.java
index 70c8178..16829f8 100755
--- a/server/src/com/cloud/test/DatabaseConfig.java
+++ b/server/src/com/cloud/test/DatabaseConfig.java
@@ -967,6 +967,12 @@ public class DatabaseConfig {
         }
         DiskOfferingVO diskOffering = new DiskOfferingVO(domainId, name, displayText, diskSpace , tags, false);
         diskOffering.setUseLocalStorage(local);
+        Long bytesRate = Long.parseLong(_currentObjectParams.get("bytesRate"));
+        if (bytesRate != null && (bytesRate > 0))
+            diskOffering.setBytesRate(bytesRate);
+        Long iopsRate = Long.parseLong(_currentObjectParams.get("iopsRate"));
+        if (iopsRate != null && (iopsRate > 0))
+            diskOffering.setIopsRate(iopsRate);
         DiskOfferingDaoImpl offering = ComponentContext.inject(DiskOfferingDaoImpl.class);
         try {
             offering.persist(diskOffering);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index c65514b..115431a 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -1328,7 +1328,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
             throw new CloudRuntimeException("Unable to migrate vm: " + e.toString());
         }
 
-        VirtualMachineProfile<VMInstanceVO> profile = new VirtualMachineProfileImpl<VMInstanceVO>(vm);
+        VirtualMachineProfile<T> profile = new VirtualMachineProfileImpl<T>(vm);
         boolean migrationResult = false;
         try {
             migrationResult = this.volumeMgr.storageMigration(profile, destPool);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
index 21b3590..686040b 100755
--- a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
@@ -489,7 +489,7 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
      */
     @Override
     public ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, Type vm_typeType, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA,
-            boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate, String deploymentPlanner, Map<String, String> details) {
+            boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate, String deploymentPlanner, Map<String, String> details, Long bytesRate, Long iopsRate) {
         // TODO Auto-generated method stub
         return null;
     }
@@ -654,7 +654,7 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
      * @see com.cloud.configuration.ConfigurationManager#createDiskOffering(java.lang.Long, java.lang.String, java.lang.String, java.lang.Long, java.lang.String, boolean, boolean, boolean)
      */
     @Override
-    public DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled) {
+    public DiskOfferingVO createDiskOffering(Long domainId, String name, String description, Long numGibibytes, String tags, boolean isCustomized, boolean localStorageRequired, boolean isDisplayOfferingEnabled, Long bytesRate, Long iopsRate) {
         // TODO Auto-generated method stub
         return null;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index cfb8c57..7684a7c 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -733,6 +733,8 @@ CREATE VIEW `cloud`.`volume_view` AS
         disk_offering.display_text disk_offering_display_text,
         disk_offering.use_local_storage,
         disk_offering.system_use,
+        disk_offering.bytes_rate,
+        disk_offering.iops_rate,
         storage_pool.id pool_id,
         storage_pool.uuid pool_uuid,
         storage_pool.name pool_name,
@@ -1015,6 +1017,8 @@ CREATE VIEW `cloud`.`service_offering_view` AS
         disk_offering.removed,
         disk_offering.use_local_storage,
         disk_offering.system_use,
+        disk_offering.bytes_rate,
+        disk_offering.iops_rate,
         service_offering.cpu,
         service_offering.speed,
         service_offering.ram_size,
@@ -1321,6 +1325,8 @@ CREATE VIEW `cloud`.`disk_offering_view` AS
         disk_offering.removed,
         disk_offering.use_local_storage,
         disk_offering.system_use,
+        disk_offering.bytes_rate,
+        disk_offering.iops_rate,
         disk_offering.sort_key,
         disk_offering.type,
 	disk_offering.display_offering,
@@ -1561,6 +1567,8 @@ CREATE VIEW `cloud`.`volume_view` AS
         disk_offering.display_text disk_offering_display_text,
         disk_offering.use_local_storage,
         disk_offering.system_use,
+        disk_offering.bytes_rate,
+        disk_offering.iops_rate,
         storage_pool.id pool_id,
         storage_pool.uuid pool_uuid,
         storage_pool.name pool_name,
@@ -1788,6 +1796,10 @@ CREATE TABLE `cloud_usage`.`usage_vm_disk` (
 
 INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.disk.stats.interval', 0, 'Interval (in seconds) to report vm disk statistics.');
 
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.disk.throttling.iops_rate', 0, 'Default disk I/O rate in requests per second allowed in User vm\'s disk. ');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.disk.throttling.bytes_rate', 0, 'Default disk I/O rate in bytes per second allowed in User vm\'s disk. ');
+ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `bytes_rate` bigint(20) unsigned DEFAULT 0;
+ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `iops_rate` bigint(20) unsigned DEFAULT 0;
 
 -- Re-enable foreign key checking, at the end of the upgrade path
 SET foreign_key_checks = 1;			

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/ui/dictionary.jsp
----------------------------------------------------------------------
diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp
index d7f7dd5..13206c3 100644
--- a/ui/dictionary.jsp
+++ b/ui/dictionary.jsp
@@ -469,6 +469,8 @@ dictionary = {
 'label.disable.vpn': '<fmt:message key="label.disable.vpn" />',
 'label.disabling.vpn.access': '<fmt:message key="label.disabling.vpn.access" />',
 'label.disk.allocated': '<fmt:message key="label.disk.allocated" />',
+'label.disk.bytes.rate': '<fmt:message key="label.disk.bytes.rate" />',
+'label.disk.iops.rate': '<fmt:message key="label.disk.iops.rate" />',
 'label.disk.read.bytes': '<fmt:message key="label.disk.read.bytes" />',
 'label.disk.read.io': '<fmt:message key="label.disk.read.io" />',
 'label.disk.offering': '<fmt:message key="label.disk.offering" />',

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4c04bc7b/ui/scripts/configuration.js
----------------------------------------------------------------------
diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js
index 211d7b7..6af7477 100644
--- a/ui/scripts/configuration.js
+++ b/ui/scripts/configuration.js
@@ -109,6 +109,20 @@
                       number: true
                     }
                   },
+                  diskBytesRate: {
+                	  label: 'label.disk.bytes.rate',
+                      validation: {
+                        required: false, //optional
+                        number: true
+                      }
+                  },
+                  diskIORate: {
+                	  label: 'label.disk.iops.rate',
+                      validation: {
+                        required: false, //optional
+                        number: true
+                      }
+                  },
                   offerHA: {
                     label: 'label.offer.ha',
                     docID: 'helpComputeOfferingHA',
@@ -222,6 +236,16 @@
 									  networkrate: args.data.networkRate
 									});
 								}
+                if(args.data.diskBytesRate != null && args.data.diskBytesRate.length > 0) {
+                                                                  $.extend(data, {
+                                                                          bytesRate: args.data.diskBytesRate
+                                                                        });
+                                                                }
+                if(args.data.diskIORate != null && args.data.diskIORate.length > 0) {
+                                                                  $.extend(data, {
+                                                                          iopsRate: args.data.diskIORate
+                                                                        });
+                                                                }
 
                 $.extend(data, {
                   offerha: (args.data.offerHA == "on")
@@ -391,6 +415,8 @@
                       }
                     },
                     networkrate: { label: 'label.network.rate' },
+                    diskBytesRate: { label: 'label.disk.bytes.rate' },
+                    diskIORate: { label: 'label.disk.iops.rate' },
                     offerha: {
                       label: 'label.offer.ha',
                       converter: cloudStack.converters.toBooleanText
@@ -529,6 +555,20 @@
                       number: true
                     }
                   },
+                  diskBytesRate: {
+                	  label: 'label.disk.bytes.rate',
+                      validation: {
+                        required: false, //optional
+                        number: true
+                      }
+                  },
+                  diskIORate: {
+                	  label: 'label.disk.iops.rate',
+                      validation: {
+                        required: false, //optional
+                        number: true
+                      }
+                  },
                   offerHA: {
                     label: 'label.offer.ha',
                     docID: 'helpSystemOfferingHA',
@@ -597,6 +637,16 @@
 									  networkrate: args.data.networkRate
 									});								
 								}
+                if(args.data.diskBytesRate != null && args.data.diskBytesRate.length > 0) {
+                                                                  $.extend(data, {
+                                                                          bytesRate: args.data.diskBytesRate
+                                                                        });
+                                                                }
+                if(args.data.diskIORate != null && args.data.diskIORate.length > 0) {
+                                                                  $.extend(data, {
+                                                                          iopsRate: args.data.diskIORate
+                                                                        });
+                                                                }
 
 								$.extend(data, {
 								  offerha: (args.data.offerHA == "on")
@@ -776,6 +826,8 @@
                       }
                     },
                     networkrate: { label: 'label.network.rate' },
+                    diskBytesRate: { label: 'label.disk.bytes.rate' },
+                    diskIORate: { label: 'label.disk.iops.rate' },
                     offerha: {
                       label: 'label.offer.ha',
                       converter: cloudStack.converters.toBooleanText
@@ -835,6 +887,20 @@
                 else
                   return "N/A";
               }
+            },
+            diskBytesRate: {
+          	  label: 'label.disk.bytes.rate',
+                validation: {
+                  required: false, //optional
+                  number: true
+                }
+            },
+            diskIORate: {
+          	  label: 'label.disk.iops.rate',
+                validation: {
+                  required: false, //optional
+                  number: true
+                }
             }
           },
 
@@ -906,6 +972,20 @@
                     dependsOn: 'isCustomized',
                     validation: { required: true, number: true }
                   },
+                  diskBytesRate: {
+                	  label: 'label.disk.bytes.rate',
+                      validation: {
+                        required: false, //optional
+                        number: true
+                      }
+                  },
+                  diskIORate: {
+                	  label: 'label.disk.iops.rate',
+                      validation: {
+                        required: false, //optional
+                        number: true
+                      }
+                  },
                   tags: {
                     label: 'label.storage.tags',
                     docID: 'helpDiskOfferingStorageTags'
@@ -1079,6 +1159,8 @@
                           return "N/A";
                       }
                     },
+                    diskBytesRate: { label: 'label.disk.bytes.rate' },
+                    diskIORate: { label: 'label.disk.iops.rate' },
                     tags: { label: 'label.storage.tags' },
                     domain: { label: 'label.domain' },
                     storagetype: { label: 'label.storage.type' }


Mime
View raw message