mirror of https://gitee.com/openkylin/libvirt.git
Xen: Add support for qemu commandline passthrough to config converter
Support qemu commandline passthrough in the domXML to native config converter. Add tests to check the conversion. Signed-off-by: Jim Fehlig <jfehlig@suse.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
b0cad42ef2
commit
3d76f4fceb
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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" ]
|
|
@ -0,0 +1,53 @@
|
|||
<domain type='xen' xmlns:xen='http://libvirt.org/schemas/domain/xen/1.0'>
|
||||
<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>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu' type='raw'/>
|
||||
<source file='/var/lib/libvirt/images/XenGuest2'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='xenbus' index='0'/>
|
||||
<controller type='ide' index='0'/>
|
||||
<interface type='bridge'>
|
||||
<mac address='00:16:3e:66:92:9c'/>
|
||||
<source bridge='xenbr1'/>
|
||||
<script path='vif-bridge'/>
|
||||
<model type='e1000'/>
|
||||
</interface>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<input type='keyboard' bus='ps2'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'>
|
||||
<listen type='address' address='127.0.0.1'/>
|
||||
</graphics>
|
||||
<video>
|
||||
<model type='cirrus' vram='8192' heads='1' primary='yes'/>
|
||||
</video>
|
||||
<memballoon model='xen'/>
|
||||
</devices>
|
||||
<xen:commandline>
|
||||
<xen:arg value='-debugcon'/>
|
||||
<xen:arg value='file:/tmp/debug.log'/>
|
||||
<xen:arg value='-global'/>
|
||||
<xen:arg value='isa-debugcon.iobase=0x402'/>
|
||||
</xen:commandline>
|
||||
</domain>
|
|
@ -304,6 +304,7 @@ mymain(void)
|
|||
#ifdef LIBXL_HAVE_CREATEINFO_PASSTHROUGH
|
||||
DO_TEST("fullvirt-hypervisor-features");
|
||||
#endif
|
||||
DO_TEST("qemu-passthrough");
|
||||
|
||||
testXLFreeDriver(driver);
|
||||
|
||||
|
|
Loading…
Reference in New Issue