]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: add support for Direct Mode for Hyper-V Synthetic timers
authorVitaly Kuznetsov <vkuznets@redhat.com>
Fri, 9 Aug 2019 14:31:40 +0000 (16:31 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 19 Aug 2019 09:38:28 +0000 (11:38 +0200)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_process.c
tests/qemuxml2argvdata/hyperv-stimer-direct.x86_64-latest.args [new file with mode: 0644]
tests/qemuxml2argvdata/hyperv-stimer-direct.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/hyperv-stimer-direct.xml [new file with mode: 0644]
tests/qemuxml2xmltest.c

index f096e8f27e583379dad1e66a5277376c937e4f54..e3f4ef624bd51087c8072341acca6ffbc16d6cc7 100644 (file)
@@ -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:
index 22ff4c42af053e7f9f1a44d77f9555096eabaec6..c9921646e9523dba3b4f3534e457c068d09d9cc9 100644 (file)
@@ -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 (file)
index 0000000..34e27c7
--- /dev/null
@@ -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 (file)
index 0000000..9c865f5
--- /dev/null
@@ -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>
index 784316e816035426de304fa421d6033056a80e66..2554d848cfa947f64a6038630b2b89e4d880ff40 100644 (file)
@@ -917,6 +917,7 @@ mymain(void)
     DO_TEST_CAPS_LATEST("hyperv-off");
     DO_TEST_CAPS_VER("hyperv-panic", "4.0.0");
     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 (file)
index 0000000..806164b
--- /dev/null
@@ -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>
index e67f1c7460766a1a7c91b972881b14a185649a2f..d7850a89d3cc2f0b079c1fadb9799cf15eec7a4e 100644 (file)
@@ -300,6 +300,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);