diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index c6aac16de5..258aca5c73 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -32,6 +32,7 @@ #include "virstoragefile.h" #include "xen_xl.h" #include "libxl_capabilities.h" +#include "libxl_conf.h" #include "cpu/cpu.h" #define VIR_FROM_THIS VIR_FROM_XENXL @@ -1158,6 +1159,42 @@ xenParseXLChannel(virConfPtr conf, virDomainDefPtr def) return -1; } +static int +xenParseXLNamespaceData(virConfPtr conf, virDomainDefPtr def) +{ + virConfValuePtr list = virConfGetValue(conf, "device_model_args"); + VIR_AUTOSTRINGLIST args = NULL; + size_t nargs; + libxlDomainXmlNsDefPtr nsdata = NULL; + + if (list && list->type == VIR_CONF_LIST) { + list = list->list; + while (list) { + if ((list->type != VIR_CONF_STRING) || (list->str == NULL)) { + list = list->next; + continue; + } + + virStringListAdd(&args, list->str); + list = list->next; + } + } + + if (!args) + return 0; + + nargs = g_strv_length(args); + if (nargs > 0) { + nsdata = g_new0(libxlDomainXmlNsDef, 1); + + nsdata->args = g_steal_pointer(&args); + nsdata->num_args = nargs; + def->namespaceData = nsdata; + } + + return 0; +} + virDomainDefPtr xenParseXL(virConfPtr conf, virCapsPtr caps, @@ -1170,6 +1207,7 @@ xenParseXL(virConfPtr conf, def->virtType = VIR_DOMAIN_VIRT_XEN; def->id = -1; + def->ns = *(virDomainXMLOptionGetNamespace(xmlopt)); if (xenParseConfigCommon(conf, def, caps, XEN_CONFIG_FORMAT_XL, xmlopt) < 0) @@ -1207,6 +1245,9 @@ xenParseXL(virConfPtr conf, if (xenParseXLChannel(conf, def) < 0) goto cleanup; + if (xenParseXLNamespaceData(conf, def) < 0) + goto cleanup; + if (virDomainDefPostParse(def, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, xmlopt, NULL) < 0) goto cleanup; @@ -2165,6 +2206,53 @@ xenFormatXLDomainChannels(virConfPtr conf, virDomainDefPtr def) return -1; } +static int +xenFormatXLDomainNamespaceData(virConfPtr conf, virDomainDefPtr def) +{ + libxlDomainXmlNsDefPtr nsdata = def->namespaceData; + virConfValuePtr args = NULL; + size_t i; + + if (!nsdata) + return 0; + + if (nsdata->num_args == 0) + return 0; + + if (VIR_ALLOC(args) < 0) + return -1; + + args->type = VIR_CONF_LIST; + args->list = NULL; + + for (i = 0; i < nsdata->num_args; i++) { + virConfValuePtr val, tmp; + + if (VIR_ALLOC(val) < 0) + goto error; + + val->type = VIR_CONF_STRING; + val->str = g_strdup(nsdata->args[i]); + tmp = args->list; + while (tmp && tmp->next) + tmp = tmp->next; + if (tmp) + tmp->next = val; + else + args->list = val; + } + + if (args->list != NULL) + if (virConfSetValue(conf, "device_model_args", args) < 0) + goto error; + + return 0; + + error: + virConfFreeValue(args); + return -1; +} + virConfPtr xenFormatXL(virDomainDefPtr def, virConnectPtr conn) { @@ -2208,5 +2296,8 @@ xenFormatXL(virDomainDefPtr def, virConnectPtr conn) if (xenFormatXLDomainChannels(conf, def) < 0) return NULL; + if (xenFormatXLDomainNamespaceData(conf, def) < 0) + return NULL; + return g_steal_pointer(&conf); } diff --git a/tests/xlconfigdata/test-qemu-passthrough.cfg b/tests/xlconfigdata/test-qemu-passthrough.cfg new file mode 100644 index 0000000000..42aad92205 --- /dev/null +++ b/tests/xlconfigdata/test-qemu-passthrough.cfg @@ -0,0 +1,26 @@ +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 = 1 +vncunused = 1 +vnclisten = "127.0.0.1" +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000" ] +parallel = "none" +serial = "none" +builder = "hvm" +boot = "d" +disk = [ "format=raw,vdev=hda,access=rw,backendtype=qdisk,target=/var/lib/libvirt/images/XenGuest2" ] +device_model_args = [ "-debugcon", "file:/tmp/debug.log", "-global", "isa-debugcon.iobase=0x402" ] diff --git a/tests/xlconfigdata/test-qemu-passthrough.xml b/tests/xlconfigdata/test-qemu-passthrough.xml new file mode 100644 index 0000000000..5de35143c0 --- /dev/null +++ b/tests/xlconfigdata/test-qemu-passthrough.xml @@ -0,0 +1,53 @@ + + XenGuest2 + c7a5fdb2-cdaf-9455-926a-d65c16db1809 + 592896 + 403456 + 1 + + hvm + /usr/lib/xen/boot/hvmloader + + + + + + + + + destroy + restart + restart + + /usr/lib/xen/bin/qemu-system-i386 + + + + +
+ + + + + + +