[virt-tools-list] [virt-manager PATCH] support: enable hv_time since qemu-kvm 1.5.3 from RHEL

Pavel Hrdina phrdina at redhat.com
Mon Jul 20 17:06:34 UTC 2015


This feature is available in upstream Qemu since 2.0.0 but it was also
back-ported to downstream Qemu into qemu-kvm-1.5.3 released in RHEL-7.
Add a new check and enable hv_time also in RHEL systems if qemu new
enough.

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 tests/xmlconfig-xml/install-hyperv-clock.xml   | 66 ++++++++++++++++++++++++++
 tests/xmlconfig-xml/install-hyperv-noclock.xml | 65 +++++++++++++++++++++++++
 tests/xmlconfig.py                             | 25 ++++++++++
 virtinst/guest.py                              |  8 ++--
 virtinst/support.py                            |  2 +
 5 files changed, 163 insertions(+), 3 deletions(-)
 create mode 100644 tests/xmlconfig-xml/install-hyperv-clock.xml
 create mode 100644 tests/xmlconfig-xml/install-hyperv-noclock.xml

diff --git a/tests/xmlconfig-xml/install-hyperv-clock.xml b/tests/xmlconfig-xml/install-hyperv-clock.xml
new file mode 100644
index 0000000..9a30ffc
--- /dev/null
+++ b/tests/xmlconfig-xml/install-hyperv-clock.xml
@@ -0,0 +1,66 @@
+<domain type="kvm">
+  <name>TestGuest</name>
+  <uuid>12345678-1234-1234-1234-123456789012</uuid>
+  <memory>409600</memory>
+  <currentMemory>204800</currentMemory>
+  <vcpu>5</vcpu>
+  <os>
+    <type arch="i686">hvm</type>
+    <boot dev="cdrom"/>
+    <boot dev="hd"/>
+  </os>
+  <features>
+    <acpi/>
+    <apic/>
+    <hyperv>
+      <relaxed state="on"/>
+      <vapic state="on"/>
+      <spinlocks state="on" retries="8191"/>
+    </hyperv>
+  </features>
+  <clock offset="localtime">
+    <timer name="rtc" tickpolicy="catchup"/>
+    <timer name="pit" tickpolicy="delay"/>
+    <timer name="hpet" present="no"/>
+    <timer name="hypervclock" present="yes"/>
+  </clock>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>destroy</on_reboot>
+  <on_crash>destroy</on_crash>
+  <pm>
+    <suspend-to-mem enabled="no"/>
+    <suspend-to-disk enabled="no"/>
+  </pm>
+  <devices>
+    <emulator>/usr/libexec/qemu-kvm</emulator>
+    <disk type="file" device="floppy">
+      <driver name="qemu" type="qcow2"/>
+      <source file="/dev/default-pool/testvol1.img"/>
+      <target dev="fda" bus="fdc"/>
+    </disk>
+    <disk type="file" device="disk">
+      <driver name="qemu" type="raw"/>
+      <source file="/dev/default-pool/new-test-suite.img"/>
+      <target dev="hda" bus="ide"/>
+    </disk>
+    <disk type="block" device="disk">
+      <driver name="qemu" type="raw" cache="none" io="native"/>
+      <source dev="/dev/disk-pool/diskvol1"/>
+      <target dev="hdb" bus="ide"/>
+    </disk>
+    <disk type="file" device="cdrom">
+      <driver name="qemu"/>
+      <source file="/dev/null"/>
+      <target dev="hdc" bus="ide"/>
+      <readonly/>
+    </disk>
+    <interface type="network">
+      <source network="default"/>
+      <mac address="22:22:33:44:55:66"/>
+    </interface>
+    <input type="tablet" bus="usb"/>
+    <graphics type="vnc" port="-1" keymap="ja"/>
+    <console type="pty"/>
+    <sound model="ich6"/>
+  </devices>
+</domain>
diff --git a/tests/xmlconfig-xml/install-hyperv-noclock.xml b/tests/xmlconfig-xml/install-hyperv-noclock.xml
new file mode 100644
index 0000000..25356d2
--- /dev/null
+++ b/tests/xmlconfig-xml/install-hyperv-noclock.xml
@@ -0,0 +1,65 @@
+<domain type="kvm">
+  <name>TestGuest</name>
+  <uuid>12345678-1234-1234-1234-123456789012</uuid>
+  <memory>409600</memory>
+  <currentMemory>204800</currentMemory>
+  <vcpu>5</vcpu>
+  <os>
+    <type arch="i686">hvm</type>
+    <boot dev="cdrom"/>
+    <boot dev="hd"/>
+  </os>
+  <features>
+    <acpi/>
+    <apic/>
+    <hyperv>
+      <relaxed state="on"/>
+      <vapic state="on"/>
+      <spinlocks state="on" retries="8191"/>
+    </hyperv>
+  </features>
+  <clock offset="localtime">
+    <timer name="rtc" tickpolicy="catchup"/>
+    <timer name="pit" tickpolicy="delay"/>
+    <timer name="hpet" present="no"/>
+  </clock>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>destroy</on_reboot>
+  <on_crash>destroy</on_crash>
+  <pm>
+    <suspend-to-mem enabled="no"/>
+    <suspend-to-disk enabled="no"/>
+  </pm>
+  <devices>
+    <emulator>/usr/libexec/qemu-kvm</emulator>
+    <disk type="file" device="floppy">
+      <driver name="qemu" type="qcow2"/>
+      <source file="/dev/default-pool/testvol1.img"/>
+      <target dev="fda" bus="fdc"/>
+    </disk>
+    <disk type="file" device="disk">
+      <driver name="qemu" type="raw"/>
+      <source file="/dev/default-pool/new-test-suite.img"/>
+      <target dev="hda" bus="ide"/>
+    </disk>
+    <disk type="block" device="disk">
+      <driver name="qemu" type="raw" cache="none" io="native"/>
+      <source dev="/dev/disk-pool/diskvol1"/>
+      <target dev="hdb" bus="ide"/>
+    </disk>
+    <disk type="file" device="cdrom">
+      <driver name="qemu"/>
+      <source file="/dev/null"/>
+      <target dev="hdc" bus="ide"/>
+      <readonly/>
+    </disk>
+    <interface type="network">
+      <source network="default"/>
+      <mac address="22:22:33:44:55:66"/>
+    </interface>
+    <input type="tablet" bus="usb"/>
+    <graphics type="vnc" port="-1" keymap="ja"/>
+    <console type="pty"/>
+    <sound model="ich6"/>
+  </devices>
+</domain>
diff --git a/tests/xmlconfig.py b/tests/xmlconfig.py
index 8665086..6204e90 100644
--- a/tests/xmlconfig.py
+++ b/tests/xmlconfig.py
@@ -326,3 +326,28 @@ class TestXMLMisc(unittest.TestCase):
             self._compare(g, "install-novmvga-rhel", True)
         finally:
             CLIConfig.stable_defaults = False
+
+    def test_hyperv_clock(self):
+        def _make(connver):
+            conn = utils.open_kvm(libver=1002002, connver=connver)
+            g = _make_guest(conn=conn)
+            g.os_variant = "win7"
+            g.emulator = "/usr/libexec/qemu-kvm"
+            return g
+
+        try:
+            g = _make(2000000)
+            self._compare(g, "install-hyperv-clock", True)
+
+            g = _make(1009000)
+            self._compare(g, "install-hyperv-noclock", True)
+
+            CLIConfig.stable_defaults = True
+
+            g = _make(1005003)
+            self._compare(g, "install-hyperv-clock", True)
+
+            g = _make(1005002)
+            self._compare(g, "install-hyperv-noclock", True)
+        finally:
+            CLIConfig.stable_defaults = False
diff --git a/virtinst/guest.py b/virtinst/guest.py
index 7647bbd..06a9719 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -764,9 +764,11 @@ class Guest(XMLBuilder):
         hpet.name = "hpet"
         hpet.present = False
 
-        if (self._os_object.is_windows() and
-            self.conn.check_support(self.conn.SUPPORT_CONN_HYPERV_CLOCK) and
-            self._hv_supported()):
+        hv_clock = self.conn.check_support(self.conn.SUPPORT_CONN_HYPERV_CLOCK)
+        hv_clock_rhel = self.conn.check_support(self.conn.SUPPORT_CONN_HYPERV_CLOCK_RHEL)
+
+        if (self._os_object.is_windows() and self._hv_supported() and
+            (hv_clock or (self.stable_defaults() and hv_clock_rhel))):
             hyperv = self.clock.add_timer()
             hyperv.name = "hypervclock"
             hyperv.present = True
diff --git a/virtinst/support.py b/virtinst/support.py
index 7f6c333..68c7629 100644
--- a/virtinst/support.py
+++ b/virtinst/support.py
@@ -298,6 +298,8 @@ SUPPORT_CONN_HYPERV_VAPIC = _make(
     version="1.1.0", hv_version={"qemu": "1.1.0", "test": 0})
 SUPPORT_CONN_HYPERV_CLOCK = _make(
     version="1.2.2", hv_version={"qemu": "2.0.0", "test": 0})
+SUPPORT_CONN_HYPERV_CLOCK_RHEL = _make(
+    version="1.2.2", hv_version={"qemu": "1.5.3", "test": 0})
 SUPPORT_CONN_LOADER_ROM = _make(version="1.2.9")
 SUPPORT_CONN_DOMAIN_CAPABILITIES = _make(
     function="virConnect.getDomainCapabilities",
-- 
2.4.5




More information about the virt-tools-list mailing list