summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>2018-11-26 20:34:40 +0100
committerJim Fehlig <jfehlig@suse.com>2018-11-26 16:38:26 -0700
commit6262ea71487d1f3ff7a9321872af371a6a506cd6 (patch)
treef591d2c15c18af6dfb4b472f9b22829c32f75224
parent494fa1fd1bbfe2ff7cdb5e1eccb1712aa6128dcf (diff)
downloadlibvirt-6262ea71487d1f3ff7a9321872af371a6a506cd6.tar.gz
xenconfig: add support for type="pvh"
Handle PVH domain type in both directions (xen-xl->xml, xml->xen-xl). And add a test for it. Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> Reviewed-by: Jim Fehlig <jfehlig@suse.com>
-rw-r--r--src/xenconfig/xen_common.c17
-rw-r--r--src/xenconfig/xen_xl.c5
-rw-r--r--tests/testutilsxen.c20
-rw-r--r--tests/xlconfigdata/test-pvh-type.cfg13
-rw-r--r--tests/xlconfigdata/test-pvh-type.xml25
-rw-r--r--tests/xlconfigtest.c1
6 files changed, 73 insertions, 8 deletions
diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 6c27936f71..13646dffb4 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -1090,7 +1090,7 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
{
virCapsDomainDataPtr capsdata = NULL;
VIR_AUTOFREE(char *) str = NULL;
- int hvm = 0, ret = -1;
+ int ret = -1;
if (xenConfigCopyString(conf, "name", &def->name) < 0)
goto out;
@@ -1098,11 +1098,15 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
if (xenConfigGetUUID(conf, "uuid", def->uuid) < 0)
goto out;
+ def->os.type = VIR_DOMAIN_OSTYPE_XEN;
+
if (xenConfigGetString(conf, "type", &str, NULL) == 0 && str) {
if (STREQ(str, "pv")) {
- hvm = 0;
+ def->os.type = VIR_DOMAIN_OSTYPE_XEN;
+ } else if (STREQ(str, "pvh")) {
+ def->os.type = VIR_DOMAIN_OSTYPE_XENPVH;
} else if (STREQ(str, "hvm")) {
- hvm = 1;
+ def->os.type = VIR_DOMAIN_OSTYPE_HVM;
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("type %s is not supported"), str);
@@ -1110,12 +1114,11 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
}
} else {
if ((xenConfigGetString(conf, "builder", &str, "linux") == 0) &&
- STREQ(str, "hvm"))
- hvm = 1;
+ STREQ(str, "hvm")) {
+ def->os.type = VIR_DOMAIN_OSTYPE_HVM;
+ }
}
- def->os.type = (hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_XEN);
-
if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type,
VIR_ARCH_NONE, def->virtType, NULL, NULL)))
goto out;
diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index 7250e5735d..70059df667 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -1287,6 +1287,11 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def)
/* XXX floppy disks */
} else {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_XENPVH) {
+ if (xenConfigSetString(conf, "type", "pvh") < 0)
+ return -1;
+ }
+
if (def->os.bootloader &&
xenConfigSetString(conf, "bootloader", def->os.bootloader) < 0)
return -1;
diff --git a/tests/testutilsxen.c b/tests/testutilsxen.c
index d34be72296..2c347a7f3f 100644
--- a/tests/testutilsxen.c
+++ b/tests/testutilsxen.c
@@ -17,7 +17,10 @@ testXLInitCaps(void)
"xenfv"
};
static const char *const xen_machines[] = {
- "xenpv"
+ "xenpv",
+ };
+ static const char *const pvh_machines[] = {
+ "xenpvh",
};
if ((caps = virCapabilitiesNew(virArchFromHost(),
@@ -54,6 +57,21 @@ testXLInitCaps(void)
if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL,
NULL, 0, NULL) == NULL)
goto cleanup;
+ nmachines = ARRAY_CARDINALITY(pvh_machines);
+ if ((machines = virCapabilitiesAllocMachines(pvh_machines, nmachines)) == NULL)
+ goto cleanup;
+
+ if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XENPVH,
+ VIR_ARCH_X86_64,
+ "/usr/lib/xen/bin/qemu-system-i386",
+ NULL,
+ nmachines, machines)) == NULL)
+ goto cleanup;
+ machines = NULL;
+
+ if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL,
+ NULL, 0, NULL) == NULL)
+ goto cleanup;
return caps;
cleanup:
diff --git a/tests/xlconfigdata/test-pvh-type.cfg b/tests/xlconfigdata/test-pvh-type.cfg
new file mode 100644
index 0000000000..24935350ef
--- /dev/null
+++ b/tests/xlconfigdata/test-pvh-type.cfg
@@ -0,0 +1,13 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+type = "pvh"
+kernel = "/tmp/vmlinuz"
+ramdisk = "/tmp/initrd"
+cmdline = "root=/dev/xvda1 console=hvc0"
diff --git a/tests/xlconfigdata/test-pvh-type.xml b/tests/xlconfigdata/test-pvh-type.xml
new file mode 100644
index 0000000000..dc5f452f10
--- /dev/null
+++ b/tests/xlconfigdata/test-pvh-type.xml
@@ -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='xenpvh'>xenpvh</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>
diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c
index 6e3267ebc9..5159182d83 100644
--- a/tests/xlconfigtest.c
+++ b/tests/xlconfigtest.c
@@ -281,6 +281,7 @@ mymain(void)
DO_TEST("rbd-multihost-noauth");
DO_TEST_FORMAT("paravirt-type", false);
DO_TEST_FORMAT("fullvirt-type", false);
+ DO_TEST("pvh-type");
#ifdef LIBXL_HAVE_DEVICE_CHANNEL
DO_TEST("channel-pty");