]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
xenconfig: add support for parsing type= xl config entry
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Mon, 26 Nov 2018 19:34:39 +0000 (20:34 +0100)
committerJim Fehlig <jfehlig@suse.com>
Mon, 26 Nov 2018 23:34:55 +0000 (16:34 -0700)
builder="hvm" is deprecated since Xen 4.10, new syntax is type="hvm" (or
type="pv", which is default). Since the old one is still supported,
still use it when writing native config, so the config will work on
older Xen too (and will also not complicate tests).

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
src/xenconfig/xen_common.c
tests/xlconfigdata/test-fullvirt-type.cfg [new file with mode: 0644]
tests/xlconfigdata/test-fullvirt-type.xml [new file with mode: 0644]
tests/xlconfigdata/test-paravirt-type.cfg [new file with mode: 0644]
tests/xlconfigdata/test-paravirt-type.xml [new file with mode: 0644]
tests/xlconfigtest.c

index 0a9958711fb4ce8b567c938e73c4dba8ef0e0312..6c27936f71c37c87d577860e6522e25c5f7603f1 100644 (file)
@@ -1098,9 +1098,21 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
     if (xenConfigGetUUID(conf, "uuid", def->uuid) < 0)
         goto out;
 
-    if ((xenConfigGetString(conf, "builder", &str, "linux") == 0) &&
-        STREQ(str, "hvm"))
-        hvm = 1;
+    if (xenConfigGetString(conf, "type", &str, NULL) == 0 && str) {
+        if (STREQ(str, "pv")) {
+            hvm = 0;
+        } else if (STREQ(str, "hvm")) {
+            hvm = 1;
+        } else {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("type %s is not supported"), str);
+            return -1;
+        }
+    } else {
+        if ((xenConfigGetString(conf, "builder", &str, "linux") == 0) &&
+            STREQ(str, "hvm"))
+            hvm = 1;
+    }
 
     def->os.type = (hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_XEN);
 
diff --git a/tests/xlconfigdata/test-fullvirt-type.cfg b/tests/xlconfigdata/test-fullvirt-type.cfg
new file mode 100644 (file)
index 0000000..f8ecc2e
--- /dev/null
@@ -0,0 +1,21 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+pae = 1
+acpi = 1
+apic = 1
+viridian = 0
+rtc_timeoffset = 0
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-system-i386"
+sdl = 0
+vnc = 0
+parallel = "none"
+serial = "none"
+type = "hvm"
+boot = "d"
diff --git a/tests/xlconfigdata/test-fullvirt-type.xml b/tests/xlconfigdata/test-fullvirt-type.xml
new file mode 100644 (file)
index 0000000..da8e360
--- /dev/null
@@ -0,0 +1,27 @@
+<domain type='xen'>
+  <name>XenGuest2</name>
+  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>592896</memory>
+  <currentMemory unit='KiB'>403456</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='xenfv'>hvm</type>
+    <loader type='rom'>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='cdrom'/>
+  </os>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='variable' adjustment='0' basis='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <emulator>/usr/lib/xen/bin/qemu-system-i386</emulator>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <memballoon model='xen'/>
+  </devices>
+</domain>
diff --git a/tests/xlconfigdata/test-paravirt-type.cfg b/tests/xlconfigdata/test-paravirt-type.cfg
new file mode 100644 (file)
index 0000000..078db99
--- /dev/null
@@ -0,0 +1,13 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+type = "pv"
+maxmem = 579
+memory = 394
+vcpus = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+kernel = "/tmp/vmlinuz"
+ramdisk = "/tmp/initrd"
+cmdline = "root=/dev/xvda1 console=hvc0"
diff --git a/tests/xlconfigdata/test-paravirt-type.xml b/tests/xlconfigdata/test-paravirt-type.xml
new file mode 100644 (file)
index 0000000..4357640
--- /dev/null
@@ -0,0 +1,25 @@
+<domain type='xen'>
+  <name>XenGuest2</name>
+  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>592896</memory>
+  <currentMemory unit='KiB'>403456</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='xenpv'>linux</type>
+    <kernel>/tmp/vmlinuz</kernel>
+    <initrd>/tmp/initrd</initrd>
+    <cmdline>root=/dev/xvda1 console=hvc0</cmdline>
+  </os>
+  <clock offset='utc' adjustment='reset'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <console type='pty'>
+      <target type='xen' port='0'/>
+    </console>
+    <input type='mouse' bus='xen'/>
+    <input type='keyboard' bus='xen'/>
+    <memballoon model='xen'/>
+  </devices>
+</domain>
index b2e4591c3bc43cc7200c3e2123f801c0c8b444a7..6e3267ebc9e1b02d7253b685df23152b8329e027 100644 (file)
@@ -279,6 +279,8 @@ mymain(void)
     DO_TEST_FORMAT("paravirt-cmdline-extra-root", false);
     DO_TEST_FORMAT("paravirt-cmdline-bogus-extra-root", false);
     DO_TEST("rbd-multihost-noauth");
+    DO_TEST_FORMAT("paravirt-type", false);
+    DO_TEST_FORMAT("fullvirt-type", false);
 
 #ifdef LIBXL_HAVE_DEVICE_CHANNEL
     DO_TEST("channel-pty");