[PATCH v4 3/4] qemu: add support for Direct Mode for Hyper-V Synthetic timers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



QEMU-4.1 supports 'Direct Mode' for Hyper-V synthetic timers
(hv-stimer-direct CPU flag): Windows guests can request that timer
expiration notifications are delivered as normal interrupts (and not
VMBus messages). This is used by Hyper-V on KVM.

Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
---
 src/qemu/qemu_command.c                       |  3 ++
 src/qemu/qemu_process.c                       | 20 +++++++++--
 .../hyperv-stimer-direct.x86_64-latest.args   | 32 +++++++++++++++++
 .../qemuxml2argvdata/hyperv-stimer-direct.xml | 33 +++++++++++++++++
 tests/qemuxml2argvtest.c                      |  1 +
 .../hyperv-stimer-direct.xml                  | 35 +++++++++++++++++++
 tests/qemuxml2xmltest.c                       |  1 +
 7 files changed, 123 insertions(+), 2 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/hyperv-stimer-direct.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/hyperv-stimer-direct.xml
 create mode 100644 tests/qemuxml2xmloutdata/hyperv-stimer-direct.xml

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 71a36ff63a..9add21b929 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7175,6 +7175,9 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
                     virBufferAsprintf(&buf, ",%s%s",
                                       hvPrefix,
                                       virDomainHypervTypeToString(i));
+                if ((i == VIR_DOMAIN_HYPERV_STIMER) &&
+                    (def->hyperv_stimer_direct == VIR_TRISTATE_SWITCH_ON))
+                    virBufferAsprintf(&buf, ",%s", VIR_CPU_x86_HV_STIMER_DIRECT);
                 break;
 
             case VIR_DOMAIN_HYPERV_SPINLOCKS:
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1ed56457b1..7c6428ea75 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4112,10 +4112,26 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def,
         rc = virCPUDataCheckFeature(cpu, cpuFeature);
         VIR_FREE(cpuFeature);
 
-        if (rc < 0)
+        if (rc < 0) {
             return -1;
-        else if (rc == 1)
+        } else if (rc == 1) {
+            if (i == VIR_DOMAIN_HYPERV_STIMER) {
+                if (def->hyperv_stimer_direct != VIR_TRISTATE_SWITCH_ON)
+                    continue;
+
+                rc = virCPUDataCheckFeature(cpu, VIR_CPU_x86_HV_STIMER_DIRECT);
+                if (rc < 0)
+                    return -1;
+                else if (rc == 1)
+                    continue;
+
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("host doesn't support hyperv stimer '%s' feature"),
+                               "direct");
+                return -1;
+            }
             continue;
+        }
 
         switch ((virDomainHyperv) i) {
         case VIR_DOMAIN_HYPERV_RELAXED:
diff --git a/tests/qemuxml2argvdata/hyperv-stimer-direct.x86_64-latest.args b/tests/qemuxml2argvdata/hyperv-stimer-direct.x86_64-latest.args
new file mode 100644
index 0000000000..34e27c75f0
--- /dev/null
+++ b/tests/qemuxml2argvdata/hyperv-stimer-direct.x86_64-latest.args
@@ -0,0 +1,32 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,\
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-cpu qemu32,hv-vpindex,hv-synic,hv-stimer,hv-stimer-direct \
+-m 214 \
+-overcommit mem-lock=off \
+-smp 6,sockets=6,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
+resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/hyperv-stimer-direct.xml b/tests/qemuxml2argvdata/hyperv-stimer-direct.xml
new file mode 100644
index 0000000000..9c865f5746
--- /dev/null
+++ b/tests/qemuxml2argvdata/hyperv-stimer-direct.xml
@@ -0,0 +1,33 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>6</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='network'/>
+  </os>
+  <features>
+    <acpi/>
+    <hyperv>
+      <vpindex state='on'/>
+      <synic state='on'/>
+      <stimer state='on'>
+        <direct state='on'/>
+      </stimer>
+    </hyperv>
+  </features>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 4c3aeffe76..235efe0b06 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -914,6 +914,7 @@ mymain(void)
     DO_TEST_CAPS_LATEST("hyperv");
     DO_TEST_CAPS_LATEST("hyperv-off");
     DO_TEST_CAPS_LATEST("hyperv-panic");
+    DO_TEST_CAPS_LATEST("hyperv-stimer-direct");
 
     DO_TEST("kvm-features", NONE);
     DO_TEST("kvm-features-off", NONE);
diff --git a/tests/qemuxml2xmloutdata/hyperv-stimer-direct.xml b/tests/qemuxml2xmloutdata/hyperv-stimer-direct.xml
new file mode 100644
index 0000000000..806164beea
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/hyperv-stimer-direct.xml
@@ -0,0 +1,35 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>6</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='network'/>
+  </os>
+  <features>
+    <acpi/>
+    <hyperv>
+      <vpindex state='on'/>
+      <synic state='on'/>
+      <stimer state='on'>
+        <direct state='on'/>
+      </stimer>
+    </hyperv>
+  </features>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 525eb9a740..7e14125f97 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -289,6 +289,7 @@ mymain(void)
     DO_TEST("hyperv", NONE);
     DO_TEST("hyperv-off", NONE);
     DO_TEST("hyperv-panic", NONE);
+    DO_TEST("hyperv-stimer-direct", NONE);
 
     DO_TEST("kvm-features", NONE);
     DO_TEST("kvm-features-off", NONE);
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux