[PATCH 3/3] qemu: Add support for HyperV Enlightenment feature "relaxed"

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

 



This patch adds support for the "relaxed" feature implemented by
previous patch.
---
 src/qemu/qemu_command.c                         | 38 +++++++++++++++++++++++++
 tests/qemuxml2argvdata/qemuxml2argv-hyperv.args |  4 +++
 tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml  | 28 ++++++++++++++++++
 tests/qemuxml2argvtest.c                        |  2 ++
 tests/qemuxml2xmltest.c                         |  2 ++
 5 files changed, 74 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 93aae55..50e95c4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4238,6 +4238,26 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
         have_cpu = true;
     }

+    if (def->features & (1 << VIR_DOMAIN_FEATURE_HYPERV)) {
+        if (!have_cpu) {
+            virBufferAdd(&buf, default_model, -1);
+            have_cpu = true;
+        }
+
+        for (i = 0; i < VIR_DOMAIN_HYPERV_LAST; i++) {
+            switch ((enum virDomainHyperv) i) {
+            case VIR_DOMAIN_HYPERV_RELAXED:
+                if (def->hyperv_features[i] == VIR_DOMAIN_FEATURE_STATE_ON)
+                    virBufferAsprintf(&buf, ",hv_%s",
+                                      virDomainHypervTypeToString(i));
+                break;
+
+            case VIR_DOMAIN_HYPERV_LAST:
+                break;
+            }
+        }
+    }
+
     if (virBufferError(&buf))
         goto no_memory;

@@ -7764,6 +7784,24 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
                     dom->apic_eoi = VIR_DOMAIN_FEATURE_STATE_ON;
                 else
                     dom->apic_eoi = VIR_DOMAIN_FEATURE_STATE_OFF;
+            } else if (STRPREFIX(feature, "hv_")) {
+                int f = virDomainHypervTypeFromString(feature + 3);
+                if (f < 0) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                                   _("unsupported HyperV Enlightenment feature "
+                                     "'%s'"), feature);
+                    goto error;
+                }
+
+                switch ((enum virDomainHyperv) f) {
+                case VIR_DOMAIN_HYPERV_RELAXED:
+                    if (policy == VIR_CPU_FEATURE_REQUIRE)
+                        dom->hyperv_features[f] = VIR_DOMAIN_FEATURE_STATE_ON;
+                    break;
+
+                case VIR_DOMAIN_HYPERV_LAST:
+                    break;
+                }
             } else {
                 if (!cpu) {
                     if (!(cpu = qemuInitGuestCPU(dom)))
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hyperv.args b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.args
new file mode 100644
index 0000000..a414da0
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.args
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc \
+-cpu qemu32,hv_relaxed -m 214 -smp 6 -nographic -monitor \
+unix:/tmp/test-monitor,server,nowait -boot n -net none -serial none \
+-parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml
new file mode 100644
index 0000000..175c69f
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hyperv.xml
@@ -0,0 +1,28 @@
+<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/>
+    <apic/>
+    <pae/>
+    <hyperv>
+      <relaxed state='on'/>
+    </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</emulator>
+    <controller type='usb' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 3ecd957..7403a8f 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -412,6 +412,8 @@ mymain(void)
     DO_TEST("eoi-enabled", NONE);
     DO_TEST("kvmclock+eoi-disabled", QEMU_CAPS_ENABLE_KVM);

+    DO_TEST("hyperv", NONE);
+
     DO_TEST("hugepages", QEMU_CAPS_MEM_PATH);
     DO_TEST("disk-cdrom", NONE);
     DO_TEST("disk-cdrom-empty", QEMU_CAPS_DRIVE);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 21db5a4..1d366f1 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -150,6 +150,8 @@ mymain(void)
     DO_TEST("eoi-disabled");
     DO_TEST("eoi-enabled");

+    DO_TEST("hyperv");
+
     DO_TEST("hugepages");
     DO_TEST("disk-aio");
     DO_TEST("disk-cdrom");
-- 
1.7.12.3

--
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]