Gilad Chaplik has uploaded a new change for review.

Change subject: core: attach device ioTune map
......................................................................

core: attach device ioTune map

Provide vdsm with device's ioTune data, when a disk has
disk profile and qos object.

for more info see: http://libvirt.org/formatdomain.html#elementsDisks

Change-Id: I515caa7ff8996711610a77a57d6683d2655545de
Signed-off-by: Gilad Chaplik <gchap...@redhat.com>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
2 files changed, 73 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/18/31818/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
index 0e9129c..4a75cb4 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
@@ -324,6 +324,14 @@
     public static final String Fdc = "fdc";
     public static final String Guid = "GUID";
     public static final String Disk = "disk";
+    // iotune
+    public static final String Iotune = "ioTune";
+    public static final String TotalBytesSec = "total_bytes_sec";
+    public static final String ReadBytesSec = "read_bytes_sec";
+    public static final String WriteBytesSec = "write_bytes_sec";
+    public static final String TotalIopsSec = "total_iops_sec";
+    public static final String ReadIopsSec = "read_iops_sec";
+    public static final String WriteIopsSec = "write_iops_sec";
     // USB controller
     public static final String Model = "model";
     // USB slot
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
index 8908966..ece32f7 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
@@ -30,6 +30,7 @@
 import org.ovirt.engine.core.common.businessentities.network.VmInterfaceType;
 import org.ovirt.engine.core.common.businessentities.network.VmNic;
 import org.ovirt.engine.core.common.businessentities.network.VnicProfile;
+import org.ovirt.engine.core.common.businessentities.qos.StorageQos;
 import org.ovirt.engine.core.common.config.Config;
 import org.ovirt.engine.core.common.config.ConfigValues;
 import org.ovirt.engine.core.common.osinfo.OsRepository;
@@ -262,6 +263,9 @@
 
         int virtioScsiIndex = 
controllerIndexMap.get(DiskInterface.VirtIO_SCSI);
         int sPaprVscsiIndex = 
controllerIndexMap.get(DiskInterface.SPAPR_VSCSI);
+        // map to avoid fetching qos object for same disk profile id
+        Map<Guid, Guid> diskProfileStorageQosMap = new HashMap<>();
+        Map<Guid, Map<String, Integer>> storageQosIoTuneMap = new HashMap<>();
 
         for (Disk disk : disks) {
             Map<String, Object> struct = new HashMap<String, Object>();
@@ -327,6 +331,16 @@
                             .toLowerCase());
                     struct.put(VdsProperties.PropagateErrors, 
disk.getPropagateErrors().toString()
                             .toLowerCase());
+                    if 
(FeatureSupported.storageQoS(vm.getVdsGroupCompatibilityVersion())) {
+                        Map<String, Integer> ioTune =
+                                buildIoTune(diskImage, 
diskProfileStorageQosMap, storageQosIoTuneMap);
+                        if (ioTune != null) {
+                            if (vmDevice.getSpecParams() == null) {
+                                vmDevice.setSpecParams(new HashMap<String, 
Object>());
+                            }
+                            vmDevice.getSpecParams().put(VdsProperties.Iotune, 
ioTune);
+                        }
+                    }
                 } else {
                     LunDisk lunDisk = (LunDisk) disk;
                     struct.put(VdsProperties.Guid, 
lunDisk.getLun().getLUN_id());
@@ -351,6 +365,57 @@
         ArchStrategyFactory.getStrategy(vm.getClusterArch()).run(new 
CreateAdditionalControllers(devices));
     }
 
+    private Map<String, Integer> buildIoTune(DiskImage diskImage,
+            Map<Guid, Guid> diskProfileStorageQosMap,
+            Map<Guid, Map<String, Integer>> storageQosIoTuneMap) {
+        Guid diskProfileId = diskImage.getDiskProfileId();
+        if (diskProfileId == null) {
+            return null;
+        }
+        Guid storageQosId = diskProfileStorageQosMap.get(diskProfileId);
+        if (storageQosId == null) {
+            StorageQos storageQos = 
DbFacade.getInstance().getStorageQosDao().getQosByDiskProfileId(diskProfileId);
+            if (storageQos == null) {
+                return null;
+            }
+            storageQosId = storageQos.getId();
+            diskProfileStorageQosMap.put(diskProfileId, storageQosId);
+            storageQosIoTuneMap.put(storageQosId, buildIoTuneMap(storageQos));
+        }
+
+        Map<String, Integer> ioTuneMap = storageQosIoTuneMap.get(storageQosId);
+        // return map with values
+        if (!ioTuneMap.isEmpty()) {
+            return ioTuneMap;
+        }
+        return null;
+    }
+
+    private Map<String, Integer> buildIoTuneMap(StorageQos storageQos) {
+        // build map
+        Map<String, Integer> ioTuneMap = new HashMap<>();
+        if (storageQos.getMaxThroughput() != null) {
+            ioTuneMap.put(VdsProperties.TotalBytesSec, 
storageQos.getMaxThroughput());
+        }
+        if (storageQos.getMaxReadThroughput() != null) {
+            ioTuneMap.put(VdsProperties.ReadBytesSec, 
storageQos.getMaxReadThroughput());
+        }
+        if (storageQos.getMaxWriteThroughput() != null) {
+            ioTuneMap.put(VdsProperties.WriteBytesSec, 
storageQos.getMaxWriteThroughput());
+        }
+        if (storageQos.getMaxIops() != null) {
+            ioTuneMap.put(VdsProperties.TotalIopsSec, storageQos.getMaxIops());
+        }
+        if (storageQos.getMaxReadIops() != null) {
+            ioTuneMap.put(VdsProperties.ReadIopsSec, 
storageQos.getMaxReadIops());
+        }
+        if (storageQos.getMaxWriteIops() != null) {
+            ioTuneMap.put(VdsProperties.WriteIopsSec, 
storageQos.getMaxWriteIops());
+        }
+
+        return ioTuneMap;
+    }
+
     @Override
     protected void buildVmNetworkInterfaces() {
         Map<VmDeviceId, VmDevice> devicesByDeviceId =


-- 
To view, visit http://gerrit.ovirt.org/31818
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I515caa7ff8996711610a77a57d6683d2655545de
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Gilad Chaplik <gchap...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to