mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-14 09:23:45 -06:00
Add tests for the new Qemu namespace XML.
Thanks to DV for knocking together the Relax-NG changes quickly for me. Changes since v1: - Change the domain.rng to correspond to the new schema - Don't allocate caps->ns in testQemuCapsInit since it is a static table Changes since v2: - Change domain.rng to add restrictions on allowed environment names Changes since v3: - Remove a bogus comment in the tests Signed-off-by: Chris Lalancette <clalance@redhat.com>
This commit is contained in:
parent
337d201ef2
commit
a71be01f04
@ -41,6 +41,9 @@
|
||||
<optional>
|
||||
<ref name="seclabel"/>
|
||||
</optional>
|
||||
<optional>
|
||||
<ref name='qemucmdline'/>
|
||||
</optional>
|
||||
</interleave>
|
||||
</element>
|
||||
</define>
|
||||
@ -1680,6 +1683,31 @@
|
||||
</optional>
|
||||
</define>
|
||||
|
||||
<!--
|
||||
Optional hypervisor extensions in their own namespace:
|
||||
QEmu
|
||||
-->
|
||||
<define name="qemucmdline">
|
||||
<element name="commandline" ns="http://libvirt.org/schemas/domain/qemu/1.0">
|
||||
<zeroOrMore>
|
||||
<element name="arg">
|
||||
<attribute name='value'/>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
<zeroOrMore>
|
||||
<element name="env">
|
||||
<attribute name='name'>
|
||||
<ref name="filter-param-name"/>
|
||||
</attribute>
|
||||
<optional>
|
||||
<attribute name='value'/>
|
||||
</optional>
|
||||
<empty/>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
<!--
|
||||
Type library
|
||||
|
||||
|
@ -552,7 +552,7 @@ static void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver,
|
||||
virDomainObjUnref(obj);
|
||||
}
|
||||
|
||||
static void qemuDomainDefNamespaceFree(void *nsdata)
|
||||
void qemuDomainDefNamespaceFree(void *nsdata)
|
||||
{
|
||||
qemuDomainCmdlineDefPtr cmd = nsdata;
|
||||
unsigned int i;
|
||||
@ -572,10 +572,10 @@ static void qemuDomainDefNamespaceFree(void *nsdata)
|
||||
VIR_FREE(cmd);
|
||||
}
|
||||
|
||||
static int qemuDomainDefNamespaceParse(xmlDocPtr xml,
|
||||
xmlNodePtr root,
|
||||
xmlXPathContextPtr ctxt,
|
||||
void **data)
|
||||
int qemuDomainDefNamespaceParse(xmlDocPtr xml,
|
||||
xmlNodePtr root,
|
||||
xmlXPathContextPtr ctxt,
|
||||
void **data)
|
||||
{
|
||||
qemuDomainCmdlineDefPtr cmd = NULL;
|
||||
xmlNsPtr ns;
|
||||
@ -685,8 +685,8 @@ error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int qemuDomainDefNamespaceFormatXML(virBufferPtr buf,
|
||||
void *nsdata)
|
||||
int qemuDomainDefNamespaceFormatXML(virBufferPtr buf,
|
||||
void *nsdata)
|
||||
{
|
||||
qemuDomainCmdlineDefPtr cmd = nsdata;
|
||||
unsigned int i;
|
||||
@ -709,7 +709,7 @@ static int qemuDomainDefNamespaceFormatXML(virBufferPtr buf,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *qemuDomainDefNamespaceHref(void)
|
||||
const char *qemuDomainDefNamespaceHref(void)
|
||||
{
|
||||
return "xmlns:qemu='" QEMU_NAMESPACE_HREF "'";
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
# include <config.h>
|
||||
|
||||
# include <libxml/xpath.h>
|
||||
|
||||
# include "internal.h"
|
||||
|
||||
# if HAVE_LINUX_KVM_H
|
||||
@ -49,4 +51,13 @@
|
||||
|
||||
int qemuRegister(void);
|
||||
|
||||
void qemuDomainDefNamespaceFree(void *nsdata);
|
||||
int qemuDomainDefNamespaceParse(xmlDocPtr xml,
|
||||
xmlNodePtr root,
|
||||
xmlXPathContextPtr ctxt,
|
||||
void **data);
|
||||
int qemuDomainDefNamespaceFormatXML(virBufferPtr buf,
|
||||
void *nsdata);
|
||||
const char *qemuDomainDefNamespaceHref(void);
|
||||
|
||||
#endif /* QEMUD_DRIVER_H */
|
||||
|
@ -228,6 +228,8 @@ mymain(int argc, char **argv)
|
||||
DO_TEST_FULL("restore-v2", QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC, "exec:cat");
|
||||
DO_TEST_FULL("migrate", QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP, "tcp:10.0.0.1:5000");
|
||||
|
||||
DO_TEST("qemu-ns-no-env", 0);
|
||||
|
||||
free(driver.stateDir);
|
||||
virCapabilitiesFree(driver.caps);
|
||||
|
||||
|
1
tests/qemuxml2argvdata/qemuxml2argv-qemu-ns-no-env.args
Normal file
1
tests/qemuxml2argvdata/qemuxml2argv-qemu-ns-no-env.args
Normal file
@ -0,0 +1 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -unknown parameter
|
29
tests/qemuxml2argvdata/qemuxml2argv-qemu-ns-no-env.xml
Normal file
29
tests/qemuxml2argvdata/qemuxml2argv-qemu-ns-no-env.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<domain type='qemu' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory>219200</memory>
|
||||
<currentMemory>219200</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<address type='drive' controller='0' bus='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='ide' index='0'/>
|
||||
<memballoon model='virtio'/>
|
||||
</devices>
|
||||
<qemu:commandline>
|
||||
<qemu:arg value='-unknown'/>
|
||||
<qemu:arg value='parameter'/>
|
||||
</qemu:commandline>
|
||||
</domain>
|
1
tests/qemuxml2argvdata/qemuxml2argv-qemu-ns.args
Normal file
1
tests/qemuxml2argvdata/qemuxml2argv-qemu-ns.args
Normal file
@ -0,0 +1 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test NS=ns BAR= /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -unknown parameter
|
30
tests/qemuxml2argvdata/qemuxml2argv-qemu-ns.xml
Normal file
30
tests/qemuxml2argvdata/qemuxml2argv-qemu-ns.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<domain type='qemu' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory>219200</memory>
|
||||
<currentMemory>219200</currentMemory>
|
||||
<vcpu>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<address type='drive' controller='0' bus='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='ide' index='0'/>
|
||||
</devices>
|
||||
<qemu:commandline>
|
||||
<qemu:arg value='-unknown'/>
|
||||
<qemu:arg value='parameter'/>
|
||||
<qemu:env name='NS' value='ns'/>
|
||||
<qemu:env name='BAR'/>
|
||||
</qemu:commandline>
|
||||
</domain>
|
@ -370,6 +370,8 @@ mymain(int argc, char **argv)
|
||||
DO_TEST_FULL("restore-v2", QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC, "exec:cat");
|
||||
DO_TEST_FULL("migrate", QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP, "tcp:10.0.0.1:5000");
|
||||
|
||||
DO_TEST("qemu-ns", 0);
|
||||
|
||||
free(driver.stateDir);
|
||||
virCapabilitiesFree(driver.caps);
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
# include "testutils.h"
|
||||
# include "memory.h"
|
||||
# include "cpu_conf.h"
|
||||
# include "qemu/qemu_driver.h"
|
||||
|
||||
static virCapsGuestMachinePtr *testQemuAllocMachines(int *nmachines)
|
||||
{
|
||||
@ -100,6 +101,11 @@ virCapsPtr testQemuCapsInit(void) {
|
||||
(machines = testQemuAllocMachines(&nmachines)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
caps->ns.parse = qemuDomainDefNamespaceParse;
|
||||
caps->ns.free = qemuDomainDefNamespaceFree;
|
||||
caps->ns.format = qemuDomainDefNamespaceFormatXML;
|
||||
caps->ns.href = qemuDomainDefNamespaceHref;
|
||||
|
||||
if ((guest = virCapabilitiesAddGuest(caps, "hvm", "i686", 32,
|
||||
"/usr/bin/qemu", NULL,
|
||||
nmachines, machines)) == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user