cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From weiz...@apache.org
Subject [8/8] git commit: updated refs/heads/disk_io_throttling to 9b88582
Date Wed, 12 Jun 2013 09:12:54 GMT
replace 'virsh version' command with conn.getVersion/getLibvirVersion


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

Branch: refs/heads/disk_io_throttling
Commit: 9b88582b29688bd6fe79e45f7915d5ced5e1f8d1
Parents: 0f2c59a
Author: Wei Zhou <w.zhou@leaseweb.com>
Authored: Wed Jun 12 11:12:24 2013 +0200
Committer: Wei Zhou <w.zhou@leaseweb.com>
Committed: Wed Jun 12 11:12:24 2013 +0200

----------------------------------------------------------------------
 api/src/com/cloud/offering/DiskOffering.java    |  2 +-
 api/src/com/cloud/vm/DiskProfile.java           |  2 +-
 .../kvm/resource/LibvirtComputingResource.java  |  6 +++
 .../hypervisor/kvm/resource/LibvirtVMDef.java   | 43 ++++++++++----------
 4 files changed, 29 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b88582b/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 4f87dc5..f4cd7b7 100644
--- a/api/src/com/cloud/offering/DiskOffering.java
+++ b/api/src/com/cloud/offering/DiskOffering.java
@@ -52,7 +52,7 @@ public interface DiskOffering extends InfrastructureEntity, Identity, InternalId
     boolean isCustomized();
 
     void setDiskSize(long diskSize);
- 
+
     void setBytesReadRate(long bytesReadRate);
 
     long getBytesReadRate();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b88582b/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 90fb71e..4e3de7b 100644
--- a/api/src/com/cloud/vm/DiskProfile.java
+++ b/api/src/com/cloud/vm/DiskProfile.java
@@ -158,7 +158,7 @@ public class DiskProfile {
     public void setSize(long size) {
     	this.size = size;
     }
-    
+
     public void setBytesReadRate(long bytesReadRate) {
         this.bytesReadRate = bytesReadRate;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b88582b/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 02e0a88..6a0032f 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
@@ -336,6 +336,8 @@ ServerResource {
 
     protected HypervisorType _hypervisorType;
     protected String _hypervisorURI;
+    protected long _hypervisorLibvirtVersion;
+    protected long _hypervisorQemuVersion;
     protected String _hypervisorPath;
     protected String _networkDirectSourceMode;
     protected String _networkDirectDevice;
@@ -735,6 +737,8 @@ ServerResource {
         try {
             _hvVersion = conn.getVersion();
             _hvVersion = (_hvVersion % 1000000) / 1000;
+            _hypervisorLibvirtVersion = conn.getLibVirVersion();
+            _hypervisorQemuVersion = conn.getVersion();
         } catch (LibvirtException e) {
             s_logger.trace("Ignoring libvirt error.", e);
         }
@@ -3228,6 +3232,8 @@ ServerResource {
         } else {
             guest.setGuestType(GuestDef.guestType.KVM);
             vm.setHvsType(HypervisorType.KVM.toString().toLowerCase());
+            vm.setLibvirtVersion(_hypervisorLibvirtVersion);
+            vm.setQemuVersion(_hypervisorQemuVersion);
         }
         guest.setGuestArch(vmTO.getArch());
         guest.setMachineType("pc");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9b88582b/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 aee1409..afa183f 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
@@ -26,6 +26,8 @@ import com.cloud.utils.script.Script;
 
 public class LibvirtVMDef {
     private String _hvsType;
+    private static long _libvirtVersion;
+    private static long _qemuVersion;
     private String _domName;
     private String _domUUID;
     private String _desc;
@@ -650,30 +652,19 @@ public class LibvirtVMDef {
             }
             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) 
+            if ((_deviceType != deviceType.CDROM) && (_libvirtVersion >= 9008)
&& (_qemuVersion >= 1001000)
                     && (((_bytesReadRate != null) && (_bytesReadRate >
0)) || ((_bytesWriteRate != null) && (_bytesWriteRate > 0))
                     || ((_iopsReadRate != null) && (_iopsReadRate > 0)) || ((_iopsWriteRate
!= null) && (_iopsWriteRate > 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 ((_bytesReadRate != null) && (_bytesReadRate > 0))
-                        diskBuilder.append("<read_bytes_sec>" + _bytesReadRate + "</read_bytes_sec>\n");
-                    if ((_bytesWriteRate != null) && (_bytesWriteRate > 0))
-                        diskBuilder.append("<write_bytes_sec>" + _bytesWriteRate +
"</write_bytes_sec>\n");
-                    if ((_iopsReadRate != null) && (_iopsReadRate > 0))
-                        diskBuilder.append("<read_iops_sec>" + _iopsReadRate + "</read_iops_sec>\n");
-                    if ((_iopsWriteRate != null) && (_iopsWriteRate > 0))
-                        diskBuilder.append("<write_iops_sec>" + _iopsWriteRate + "</write_iops_sec>\n");
-                    diskBuilder.append("</iotune>\n");
-                }
+                diskBuilder.append("<iotune>\n");
+                if ((_bytesReadRate != null) && (_bytesReadRate > 0))
+                    diskBuilder.append("<read_bytes_sec>" + _bytesReadRate + "</read_bytes_sec>\n");
+                if ((_bytesWriteRate != null) && (_bytesWriteRate > 0))
+                    diskBuilder.append("<write_bytes_sec>" + _bytesWriteRate + "</write_bytes_sec>\n");
+                if ((_iopsReadRate != null) && (_iopsReadRate > 0))
+                    diskBuilder.append("<read_iops_sec>" + _iopsReadRate + "</read_iops_sec>\n");
+                if ((_iopsWriteRate != null) && (_iopsWriteRate > 0))
+                    diskBuilder.append("<write_iops_sec>" + _iopsWriteRate + "</write_iops_sec>\n");
+                diskBuilder.append("</iotune>\n");
             }
 
             diskBuilder.append("</disk>\n");
@@ -1061,6 +1052,14 @@ public class LibvirtVMDef {
         return _hvsType;
     }
 
+    public void setLibvirtVersion(long libvirtVersion) {
+        _libvirtVersion = libvirtVersion;
+    }
+
+    public void setQemuVersion(long qemuVersion) {
+        _qemuVersion = qemuVersion;
+    }
+
     public void setDomainName(String domainName) {
         _domName = domainName;
     }


Mime
View raw message