Testing libvirt XML -> libxl_domain_config conversion
v3 cover Testing libvirt XML -> libxl_domain_config conversion
This is version 3 of the work started by danpb:
https://www.redhat.com/archives/libvir-list/2014-May/msg01102.html
This series tests the conversion of libvirt XML to libxl_domain_config objects by the libvirt libxl driver.
Changed in v3:
- Change virJSONStringCompare to accept a list of context paths to ignore
- Report error in virJSONStringCompare in libyajl is not available
- Fix a bug (4/5) exposed by the new tests
- Add tests for conversion of both PV and HVM config
- Define json context paths to ignore based on features defined in libxl.h
Daniel P. Berrange (4):
util: Introduce virJSONStringCompare for JSON doc comparisons
util: Allow port allocator to skip bind() check
tests: Add more test suite mock helpers
libxl: Add a test suite for libxl option generator
Jim Fehlig (1):
libxl: fix mapping of libvirt and libxl lifecycle actions
configure.ac | 2 + src/libvirt_private.syms | 1 + src/libxl/libxl_conf.c | 62 +++++++- src/libxl/libxl_driver.c | 5 +- src/qemu/qemu_driver.c | 9 +- src/util/virjson.c | 242 +++++++++++++++++++++++++++++++ src/util/virjson.h | 16 +++ src/util/virportallocator.c | 14 +- src/util/virportallocator.h | 7 +- tests/Makefile.am | 25 +++- tests/libxlxml2jsondata/basic-hvm.json | 217 ++++++++++++++++++++++++++++ tests/libxlxml2jsondata/basic-hvm.xml | 36 +++++ tests/libxlxml2jsondata/basic-pv.json | 163 +++++++++++++++++++++ tests/libxlxml2jsondata/basic-pv.xml | 28 ++++ tests/libxlxml2jsontest.c | 251 +++++++++++++++++++++++++++++++++ tests/virfirewalltest.c | 4 +- tests/virmock.h | 54 +++++-- tests/virmocklibxl.c | 87 ++++++++++++ tests/virportallocatortest.c | 4 +- tests/virsystemdtest.c | 4 +- 20 files changed, 1198 insertions(+), 33 deletions(-) create mode 100644 tests/libxlxml2jsondata/basic-hvm.json create mode 100644 tests/libxlxml2jsondata/basic-hvm.xml create mode 100644 tests/libxlxml2jsondata/basic-pv.json create mode 100644 tests/libxlxml2jsondata/basic-pv.xml create mode 100644 tests/libxlxml2jsontest.c create mode 100644 tests/virmocklibxl.c
Signature · 1 line
1.8.4.5
PATCH v3 1/5 util: Introduce virJSONStringCompare for JSON doc comparisons
From: "Daniel P. Berrange" <[email protected]>
Comparing JSON docs using strcmp is simple, but is not flexible as it is sensitive to whitespace used in the doc generation. When comparing objects it may also be desirable to treat the existance of keys in the actual object but not expected object as non-fatal. Introduce a virJSONStringCompare function which takes two strings representing expected and actual JSON docs and then does a DOM comparison. Comparison is controled with the ignore_contexts and flags parameters. No comparison is done on context paths specified in ignore_contexts. The VIR_JSON_COMPARE_IGNORE_EXPECTED_NULL flag can be used to ignore actual values that have changed from an expected value of null.
--- src/libvirt_private.syms | 1 + src/util/virjson.c | 242 +++++++++++++++++++++++++++++++++++++++++++++++ src/util/virjson.h | 16 ++++ 3 files changed, 259 insertions(+)
src/libvirt_private.syms +1 -0
@@ -1442,6 +1442,7 @@ virISCSIScanTargets; # util/virjson.h +virJSONStringCompare; virJSONValueArrayAppend; virJSONValueArrayGet; virJSONValueArraySize;
src/util/virjson.c +242 -0
270 lines not on this page · raw message
src/util/virjson.h +16 -0
@@ -34,6 +34,8 @@ typedef enum {VIR_JSON_TYPE_NUMBER ,VIR_JSON_TYPE_BOOLEAN ,VIR_JSON_TYPE_NULL , + +VIR_JSON_TYPE_LAST , } virJSONType;typedef struct _virJSONValue virJSONValue ;
@@ -141,4 +143,18 @@ virJSONValuePtr virJSONValueFromString(const char *jsonstring);char *virJSONValueToString (virJSONValuePtr object,bool pretty); +typedef enum { +/* +* when comparing two values, if their types are different, +* and the 'expected' value type is 'null', then this will +* be considered non-fatal. +*/ +VIR_JSON_COMPARE_IGNORE_EXPECTED_NULL = (1 <<0 ), +}virJSONCompareFlags ; + +bool virJSONStringCompare (const char *expect, +const char *actual, +const char **ignore_contexts, +unsigned int flags); +#endif /* __VIR_JSON_H_ */
Signature · 1 line
1.8.4.5
PATCH v3 2/5 util: Allow port allocator to skip bind() check
In reply to Jim FehligFrom: "Daniel P. Berrange" <[email protected]>
Test suites using the port allocator don't want to have different behaviour depending on whether a port is in use on the host. Add a VIR_PORT_ALLOCATOR_SKIP_BIND_CHECK which test suites can use to skip the bind() test. The port allocator will thus only track ports in use by the test suite process itself. This is fine when using the port allocator to generate guest configs which won't actually be launched
--- src/libxl/libxl_driver.c | 5 +++-- src/qemu/qemu_driver.c | 9 ++++++--- src/util/virportallocator.c | 14 ++++++++++---- src/util/virportallocator.h | 7 ++++++- tests/virportallocatortest.c | 4 ++-- 5 files changed, 27 insertions(+), 12 deletions(-)
src/libxl/libxl_driver.c +3 -2
@@ -301,14 +301,15 @@ libxlStateInitialize(bool privileged,if (!(libxl_driver->reservedVNCPorts =virPortAllocatorNew (_ ("VNC" ),LIBXL_VNC_PORT_MIN , -LIBXL_VNC_PORT_MAX ))) +LIBXL_VNC_PORT_MAX , +0 ))) goto error;/* Allocate bitmap for migration port reservation */ if (!(libxl_driver->migrationPorts =virPortAllocatorNew (_ ("migration" ),LIBXL_MIGRATION_PORT_MIN , -LIBXL_MIGRATION_PORT_MAX ))) +LIBXL_MIGRATION_PORT_MAX ,0 ))) goto error;if (!(libxl_driver->domains =virDomainObjListNew ()))
src/qemu/qemu_driver.c +6 -3
@@ -731,19 +731,22 @@ qemuStateInitialize(bool privileged,if ((qemu_driver->remotePorts =virPortAllocatorNew (_ ("display" ), cfg->remotePortMin, - cfg->remotePortMax)) ==NULL ) + cfg->remotePortMax, +0 )) ==NULL ) goto error;if ((qemu_driver->webSocketPorts =virPortAllocatorNew (_ ("webSocket" ), cfg->webSocketPortMin, - cfg->webSocketPortMax)) ==NULL ) + cfg->webSocketPortMax, +0 )) ==NULL ) goto error;if ((qemu_driver->migrationPorts =virPortAllocatorNew (_ ("migration" ), cfg->migrationPortMin, - cfg->migrationPortMax)) ==NULL ) + cfg->migrationPortMax, +0 )) ==NULL ) goto error;if (qemuSecurityInit (qemu_driver) <0 )
src/util/virportallocator.c +10 -4
@@ -43,6 +43,8 @@ struct _virPortAllocator {unsigned short start;unsigned short end; + +unsigned int flags; };static virClassPtr virPortAllocatorClass;
@@ -71,7 +73,8 @@ VIR_ONCE_GLOBAL_INIT(virPortAllocator)virPortAllocatorPtr virPortAllocatorNew (const char *name,unsigned short start, -unsigned short end) +unsigned short end, +unsigned int flags) {virPortAllocatorPtr pa;
@@ -87,6 +90,7 @@ virPortAllocatorPtr virPortAllocatorNew(const char *name,if (!(pa =virObjectLockableNew (virPortAllocatorClass)))return NULL ; + pa->flags = flags; pa->start = start; pa->end = end;
@@ -193,9 +197,11 @@ int virPortAllocatorAcquire(virPortAllocatorPtr pa,if (used)continue ; -if (virPortAllocatorBindToPort (&v6used, i,AF_INET6 ) <0 || -virPortAllocatorBindToPort (&used, i,AF_INET ) <0 ) - goto cleanup; +if (!(pa->flags &VIR_PORT_ALLOCATOR_SKIP_BIND_CHECK )) { +if (virPortAllocatorBindToPort (&v6used, i,AF_INET6 ) <0 || +virPortAllocatorBindToPort (&used, i,AF_INET ) <0 ) + goto cleanup; + }if (!used && !v6used) {/* Add port to bitmap of reserved ports */
src/util/virportallocator.h +6 -1
@@ -28,9 +28,14 @@typedef struct _virPortAllocator virPortAllocator ;typedef virPortAllocator *virPortAllocatorPtr ; +typedef enum { +VIR_PORT_ALLOCATOR_SKIP_BIND_CHECK = (1 <<0 ), +}virPortAllocatorFlags ; +virPortAllocatorPtr virPortAllocatorNew (const char *name,unsigned short start, -unsigned short end); +unsigned short end, +unsigned int flags);int virPortAllocatorAcquire (virPortAllocatorPtr pa,unsigned short *port);
tests/virportallocatortest.c +2 -2
@@ -122,7 +122,7 @@ VIR_LOG_INIT("tests.portallocatortest"); static int testAllocAll(const void *args ATTRIBUTE_UNUSED) { -virPortAllocatorPtr alloc =virPortAllocatorNew ("test" ,5900 ,5909 ); +virPortAllocatorPtr alloc =virPortAllocatorNew ("test" ,5900 ,5909 ,0 );int ret =-1 ;unsigned short p1, p2, p3, p4, p5, p6, p7;
@@ -193,7 +193,7 @@ static int testAllocAll(const void *args ATTRIBUTE_UNUSED) static int testAllocReuse(const void *args ATTRIBUTE_UNUSED) { -virPortAllocatorPtr alloc =virPortAllocatorNew ("test" ,5900 ,5910 ); +virPortAllocatorPtr alloc =virPortAllocatorNew ("test" ,5900 ,5910 ,0 );int ret =-1 ;unsigned short p1, p2, p3, p4;
Signature · 1 line
1.8.4.5
Re: [PATCH V3 2/5] util: Allow port allocator to skip bind() check
Quoted 12 lines · Jim Fehlig
From: "Daniel P. Berrange" <[email protected]>
Test suites using the port allocator don't want to have different behaviour depending on whether a port is in use on the host. Add a
VIR_PORT_ALLOCATOR_SKIP_BIND_CHECKwhich test suites can use to skip thebind()test. The port allocator will thus only track ports in use by the test suite process itself. This is fine when using the port allocator to generate guest configs which won't actually be launchedSigned-off-by Daniel P. Berrange <[email protected]>Signed-off-by Jim Fehlig <[email protected]>
Quoted 7 lines
--- src/libxl/libxl_driver.c | 5 +++-- src/qemu/qemu_driver.c | 9 ++++++--- src/util/virportallocator.c | 14 ++++++++++---- src/util/virportallocator.h | 7 ++++++- tests/virportallocatortest.c | 4 ++-- 5 files changed, 27 insertions(+), 12 deletions(-)
ACK, can push this independant of the rest
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
PATCH v3 3/5 tests: Add more test suite mock helpers
In reply to Jim FehligFrom: "Daniel P. Berrange" <[email protected]>
Rename the VIR_MOCK_IMPL* macros to VIR_MOCK_WRAP* and add new VIR_MOCK_IMPL macros which let you directly implement overrides in the preloaded source.
--- tests/virfirewalltest.c | 4 ++-- tests/virmock.h | 54 +++++++++++++++++++++++++++++++++++++------------ tests/virsystemdtest.c | 4 ++-- 3 files changed, 45 insertions(+), 17 deletions(-)
tests/virfirewalltest.c +2 -2
@@ -67,7 +67,7 @@ static bool fwError;"target prot opt source destination\n" # if WITH_DBUS -VIR_MOCK_IMPL_RET_ARGS(dbus_connection_send_with_reply_and_block, +VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_reply_and_block, DBusMessage *, DBusConnection *, connection, DBusMessage *, message,
@@ -82,7 +82,7 @@ VIR_MOCK_IMPL_RET_ARGS(dbus_connection_send_with_reply_and_block,char **args =NULL ;char *type =NULL ; -VIR_MOCK_IMPL_INIT_REAL (dbus_connection_send_with_reply_and_block); +VIR_MOCK_REAL_INIT (dbus_connection_send_with_reply_and_block);if (STREQ (service,"org.freedesktop.DBus" ) &&STREQ (member,"ListNames" )) {
tests/virmock.h +41 -13
74 lines not on this page · raw message
tests/virsystemdtest.c +2 -2
@@ -34,7 +34,7 @@VIR_LOG_INIT ("tests.systemdtest" ); -VIR_MOCK_IMPL_RET_ARGS(dbus_connection_send_with_reply_and_block, +VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_reply_and_block, DBusMessage *, DBusConnection *, connection, DBusMessage *, message,
@@ -45,7 +45,7 @@ VIR_MOCK_IMPL_RET_ARGS(dbus_connection_send_with_reply_and_block,const char *service =dbus_message_get_destination (message);const char *member =dbus_message_get_member (message); -VIR_MOCK_IMPL_INIT_REAL (dbus_connection_send_with_reply_and_block); +VIR_MOCK_REAL_INIT (dbus_connection_send_with_reply_and_block);if (STREQ (service,"org.freedesktop.machine1" )) {if (getenv ("FAIL_BAD_SERVICE" )) {
Signature · 1 line
1.8.4.5
Re: [PATCH V3 3/5] tests: Add more test suite mock helpers
Quoted 6 lines · Jim Fehlig
From: "Daniel P. Berrange" <[email protected]>
Rename the VIR_MOCK_IMPL* macros to VIR_MOCK_WRAP* and add new
VIR_MOCK_IMPLmacros which let you directly implement overrides in the preloaded source.
Quoted 7 lines
Signed-off-by Daniel P. Berrange <[email protected]>Signed-off-by Jim Fehlig <[email protected]>--- tests/virfirewalltest.c | 4 ++-- tests/virmock.h | 54 +++++++++++++++++++++++++++++++++++++------------ tests/virsystemdtest.c | 4 ++-- 3 files changed, 45 insertions(+), 17 deletions(-)
ACK, might as well push this now too.
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
PATCH v3 4/5 libxl: fix mapping of lifecycle actions
In reply to Jim FehligThe libxl driver was blindly assigning libvirt's virDomainLifecycleAction to libxl's libxl_action_on_shutdown, when in fact the various actions take on different values in these enums.
Introduce helpers to properly map the enum values.
--- src/libxl/libxl_conf.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-)
src/libxl/libxl_conf.c +59 -3
@@ -102,6 +102,62 @@ libxlDriverConfigDispose(void *obj)VIR_FREE (cfg->autoDumpDir); } + +static libxl_action_on_shutdown +libxlActionFromVirLifecycle (virDomainLifecycleAction action) +{ +switch (action) { +case VIR_DOMAIN_LIFECYCLE_DESTROY : +return LIBXL_ACTION_ON_SHUTDOWN_DESTROY ; + +case VIR_DOMAIN_LIFECYCLE_RESTART : +return LIBXL_ACTION_ON_SHUTDOWN_RESTART ; + +case VIR_DOMAIN_LIFECYCLE_RESTART_RENAME : +return LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME ; + +case VIR_DOMAIN_LIFECYCLE_PRESERVE : +return LIBXL_ACTION_ON_SHUTDOWN_PRESERVE ; + +case VIR_DOMAIN_LIFECYCLE_LAST : +break ; + } + +return 0 ; +} + + +static libxl_action_on_shutdown +libxlActionFromVirLifecycleCrash (virDomainLifecycleCrashAction action) +{ + +switch (action) { +case VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY : +return LIBXL_ACTION_ON_SHUTDOWN_DESTROY ; + +case VIR_DOMAIN_LIFECYCLE_CRASH_RESTART : +return LIBXL_ACTION_ON_SHUTDOWN_RESTART ; + +case VIR_DOMAIN_LIFECYCLE_CRASH_RESTART_RENAME : +return LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME ; + +case VIR_DOMAIN_LIFECYCLE_CRASH_PRESERVE : +return LIBXL_ACTION_ON_SHUTDOWN_PRESERVE ; + +case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY : +return LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY ; + +case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART : +return LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART ; + +case VIR_DOMAIN_LIFECYCLE_CRASH_LAST : +break ; + } + +return 0 ; +} + +static int libxlCapsInitHost (libxl_ctx *ctx,virCapsPtr caps) {
@@ -1436,9 +1492,9 @@ libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,if (libxlMakePCIList (def, d_config) <0 )return -1 ; - d_config->on_reboot = def->onReboot; - d_config->on_poweroff = def->onPoweroff; - d_config->on_crash = def->onCrash; + d_config->on_reboot =libxlActionFromVirLifecycle (def->onReboot); + d_config->on_poweroff =libxlActionFromVirLifecycle (def->onPoweroff); + d_config->on_crash =libxlActionFromVirLifecycleCrash (def->onCrash);return 0 ; }
Signature · 1 line
1.8.4.5
PATCH v3 5/5 libxl: Add a test suite for libxl option generator
In reply to Jim FehligFrom: "Daniel P. Berrange" <[email protected]>
The libxl library allows a libxl_domain_config object to be serialized to a JSON string. Use this to allow testing of the XML -> libxl_domain_config conversion process
--- configure.ac | 2 + tests/Makefile.am | 25 +++- tests/libxlxml2jsondata/basic-hvm.json | 217 ++++++++++++++++++++++++++++ tests/libxlxml2jsondata/basic-hvm.xml | 36 +++++ tests/libxlxml2jsondata/basic-pv.json | 163 +++++++++++++++++++++ tests/libxlxml2jsondata/basic-pv.xml | 28 ++++ tests/libxlxml2jsontest.c | 251 +++++++++++++++++++++++++++++++++ tests/virmocklibxl.c | 87 ++++++++++++ 8 files changed, 808 insertions(+), 1 deletion(-)
configure.ac +2 -0
@@ -875,6 +875,8 @@ if test "$with_libxl" != "no" ; then AC_CHECK_LIB([xenlight], [libxl_ctx_alloc], [ with_libxl=yes LIBXL_LIBS="$LIBXL_LIBS -lxenlight -lxenctrl" + LIBS="$LIBS -lxenlight -lxenctrl" + AC_CHECK_FUNCS([libxl_domain_config_to_json]) ],[ if test "$with_libxl" = "yes"; then fail=1
tests/Makefile.am +24 -1
@@ -84,6 +84,7 @@ EXTRA_DIST = \ domainsnapshotxml2xmlout \ fchostdata \ interfaceschemadata \ + libxlxml2jsondata \ lxcconf2xmldata \ lxcxml2xmldata \ lxcxml2xmloutdata \
@@ -222,6 +223,9 @@ if WITH_XEN test_programs += xml2sexprtest sexpr2xmltest \ xmconfigtest xencapstest statstest reconnect endif WITH_XEN +if WITH_LIBXL +test_programs += libxlxml2jsontest +endif WITH_LIBXL if WITH_QEMU test_programs += qemuxml2argvtest qemuxml2xmltest qemuxmlnstest \ qemuargv2xmltest qemuhelptest domainsnapshotxml2xmltest \
@@ -393,7 +397,9 @@ test_libraries += libqemumonitortestutils.la \ qemuxml2argvmock.la \ $(NULL) endif WITH_QEMU - +if WITH_LIBXL +test_libraries += virmocklibxl.la +endif WITH_LIBXL if WITH_BHYVE test_libraries += bhyvexml2argvmock.la endif WITH_BHYVE
@@ -593,6 +599,23 @@ EXTRA_DIST += qemuxml2argvtest.c qemuxml2xmltest.c qemuargv2xmltest.c \ $(QEMUMONITORTESTUTILS_SOURCES) endif ! WITH_QEMU +if WITH_LIBXL +libxl_LDADDS = ../src/libvirt_driver_libxl_impl.la +libxl_LDADDS += $(LDADDS) + +libxlxml2jsontest_SOURCES = \ + libxlxml2jsontest.c testutilsxen.c testutilsxen.h \ + testutils.c testutils.h +libxlxml2jsontest_LDADD = $(libxl_LDADDS) $(LIBXML_LIBS) + +virmocklibxl_la_SOURCES = \ + virmocklibxl.c +virmocklibxl_la_CFLAGS = $(AM_CFLAGS) +virmocklibxl_la_LDFLAGS = -module -avoid-version \ + -rpath /evil/libtool/hack/to/force/shared/lib/creation + +endif WITH_LIBXL + if WITH_LXC lxc_LDADDS = ../src/libvirt_driver_lxc_impl.la
tests/libxlxml2jsondata/basic-hvm.json new file +217 -0
217 lines not on this page · raw message
tests/libxlxml2jsondata/basic-hvm.xml new file +36 -0
@@ -0,0 +1,36 @@ +<domain type='xen'> + <name>sles-hvm</name> + <description>None</description> + <uuid>2147d599-9cc6-c0dc-92ab-4064b5446e9b</uuid> + <memory>1048576</memory> + <currentMemory>1048576</currentMemory> + <vcpu>4</vcpu> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <clock sync='utc'/> + <os> + <type>hvm</type> + <loader>/usr/lib/xen/boot/hvmloader</loader> + <boot dev='hd'/> + </os> + <features> + <apic/> + <acpi/> + <pae/> + </features> + <devices> + <emulator>/usr/lib/xen/bin/qemu-system-i386</emulator> + <disk type='file' device='disk'> + <driver name='qemu'/> + <source file='/var/lib/xen/images/sles-hvm.img'/> + <target dev='hda'/> + </disk> + <interface type='bridge'> + <source bridge='br0'/> + <mac address='00:16:3e:66:12:b4'/> + <script path='/etc/xen/scripts/vif-bridge'/> + </interface> + <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'/> + </devices> +</domain>
tests/libxlxml2jsondata/basic-pv.json new file +163 -0
163 lines not on this page · raw message
tests/libxlxml2jsondata/basic-pv.xml new file +28 -0
@@ -0,0 +1,28 @@ +<domain type='xen'> + <name>sles11-pv</name> + <uuid>039e9ee6-4a84-3055-4c81-8ba426ae2656</uuid> + <memory>524288</memory> + <currentMemory>524288</currentMemory> + <vcpu>4</vcpu> + <bootloader>pygrub</bootloader> + <os> + <type arch='i686' machine='xenpv'>linux</type> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='file' device='disk'> + <driver name='qemu'/> + <source file='/var/lib/xen/images/sles11-pv.img'/> + <target dev='xvda'/> + </disk> + <interface type='bridge'> + <source bridge='br0'/> + <mac address='00:16:3e:3e:86:60'/> + <script path='/etc/xen/scripts/vif-bridge'/> + </interface> + <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'/> + </devices> +</domain>
tests/libxlxml2jsontest.c new file +251 -0
251 lines not on this page · raw message
tests/virmocklibxl.c new file +87 -0
87 lines not on this page · raw message
Signature · 1 line
1.8.4.5
Re: [PATCH V3 5/5] libxl: Add a test suite for libxl option generator
Quoted 79 lines · Jim Fehlig
From: "Daniel P. Berrange" <[email protected]>
The libxl library allows a
libxl_domain_configobject to be serialized to a JSON string. Use this to allow testing of the XML ->libxl_domain_configconversion processSigned-off-by Daniel P. Berrange <[email protected]>Signed-off-by Jim Fehlig <[email protected]>--- configure.ac | 2 + tests/Makefile.am | 25 +++- tests/libxlxml2jsondata/basic-hvm.json | 217 ++++++++++++++++++++++++++++ tests/libxlxml2jsondata/basic-hvm.xml | 36 +++++ tests/libxlxml2jsondata/basic-pv.json | 163 +++++++++++++++++++++ tests/libxlxml2jsondata/basic-pv.xml | 28 ++++ tests/libxlxml2jsontest.c | 251 +++++++++++++++++++++++++++++++++ tests/virmocklibxl.c | 87 ++++++++++++ 8 files changed, 808 insertions(+), 1 deletion(-)tests/libxlxml2jsontest.c new file +53
-0+#if definedLIBXL_HAVE_BUILDINFO_HVM_VENDOR_DEVICE +/* +* Currently no paths ignored on Xen 4.4 +*/ +static const char **ignore_paths =NULL ; +#elif definedLIBXL_HAVE_DOMAIN_NODEAFFINITY +/* +* These paths must be ignored if running on Xen 4.3 +*/ +static const char *ignore_paths[] = { +"/c_info/pvh" , +"/c_info/driver_domain" , +"/b_info/device_model_version" , +"/b_info/event_channels" , +"/b_info/u/kernel" , +"/b_info/u/cmdline" , +"/b_info/u/ramdisk" , +"/b_info/u/bios" , +"/b_info/u/timer_mode" , +"/b_info/u/vga/kind" , +"/b_info/u/spice/vdagent" , +"/b_info/u/spice/clipboard_sharing" , +"/b_info/u/spice/usbredirection" , +"/b_info/u/usbversion" , +"/b_info/u/vendor_device" , +"/on_watchdog" , +NULL +}; +#else +/* +* These paths must be ignored if running on Xen 4.2 +*/ +static const char *ignore_paths[] = { +"/c_info/pvh" , +"/c_info/driver_domain" , +"/b_info/nodemap" , +"/b_info/exec_ssidref" , +"/b_info/iomem" , +"/b_info/claim_mode" , +"/b_info/device_model_version" , +"/b_info/event_channels" , +"/b_info/u/usbdevice_list" , +"/b_info/u/kernel" , +"/b_info/u/cmdline" , +"/b_info/u/ramdisk" , +"/b_info/u/bios" , +"/b_info/u/timer_mode" , +"/b_info/u/vga/kind" , +"/b_info/u/spice/vdagent" , +"/b_info/u/spice/clipboard_sharing" , +"/b_info/u/spice/usbredirection" , +"/b_info/u/usbversion" , + "/b_info/u/vendor_device",
tests/libxlxml2jsontest.c line 111
Quoted 10 lines
tests/libxlxml2jsontest.c new file +10
-0+"/disks/backend_domname" , +"/nics/backend_domname" , +"/nics/gatewaydev" , +"/vfbs/backend_domname" , +"/vkbs/backend_domname" , +"/vtpms" , +"/on_watchdog" , +NULL +}; +#endif
As more & more versions of Xen are released I think we might end up with quite alot of duplication between these lists. Could we structure it a little differently to avoid this perhaps in this way:
#if defined LIBXL_HAVE_BUILDINFO_HVM_VENDOR_DEVICE
# define LIBXL_VERSION 4004
#elif define LIBXL_HAVE_DOMAIN_NODEAFFINITY
# define LIBXL_VERSION 4003
#else
# define LIBXL_VERSION 4002
#endif
static const char *ignore_paths[] = {
#if LIBXL_VERSION < 4004
"/c_info/pvh",
"/c_info/driver_domain",
"/b_info/device_model_version",
"/b_info/event_channels",
"/b_info/u/kernel",
"/b_info/u/cmdline",
"/b_info/u/ramdisk",
"/b_info/u/bios",
"/b_info/u/timer_mode",
"/b_info/u/vga/kind",
"/b_info/u/spice/vdagent",
"/b_info/u/spice/clipboard_sharing",
"/b_info/u/spice/usbredirection",
"/b_info/u/usbversion",
"/b_info/u/vendor_device",
"/on_watchdog",
#endif
#if LIBXL_VERSION < 4003
"/b_info/nodemap",
"/b_info/exec_ssidref",
"/b_info/iomem",
"/b_info/claim_mode",
"/b_info/u/usbdevice_list",
"/disks/backend_domname",
"/nics/backend_domname",
"/nics/gatewaydev",
"/vfbs/backend_domname",
"/vkbs/backend_domname",
"/vtpms",
#endif
NULL
};Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH V3 5/5] libxl: Add a test suite for libxl option generator
Quoted 93 lines · Daniel P. Berrange
Quoted 91 lines · Jim Fehlig
From: "Daniel P. Berrange" <[email protected]>
The libxl library allows a
libxl_domain_configobject to be serialized to a JSON string. Use this to allow testing of the XML ->libxl_domain_configconversion processSigned-off-by Daniel P. Berrange <[email protected]>Signed-off-by Jim Fehlig <[email protected]>--- configure.ac | 2 + tests/Makefile.am | 25 +++- tests/libxlxml2jsondata/basic-hvm.json | 217 ++++++++++++++++++++++++++++ tests/libxlxml2jsondata/basic-hvm.xml | 36 +++++ tests/libxlxml2jsondata/basic-pv.json | 163 +++++++++++++++++++++ tests/libxlxml2jsondata/basic-pv.xml | 28 ++++ tests/libxlxml2jsontest.c | 251 +++++++++++++++++++++++++++++++++ tests/virmocklibxl.c | 87 ++++++++++++ 8 files changed, 808 insertions(+), 1 deletion(-)tests/libxlxml2jsontest.c new file +61
-0+#if definedLIBXL_HAVE_BUILDINFO_HVM_VENDOR_DEVICE +/* +* Currently no paths ignored on Xen 4.4 +*/ +static const char **ignore_paths =NULL ; +#elif definedLIBXL_HAVE_DOMAIN_NODEAFFINITY +/* +* These paths must be ignored if running on Xen 4.3 +*/ +static const char *ignore_paths[] = { +"/c_info/pvh" , +"/c_info/driver_domain" , +"/b_info/device_model_version" , +"/b_info/event_channels" , +"/b_info/u/kernel" , +"/b_info/u/cmdline" , +"/b_info/u/ramdisk" , +"/b_info/u/bios" , +"/b_info/u/timer_mode" , +"/b_info/u/vga/kind" , +"/b_info/u/spice/vdagent" , +"/b_info/u/spice/clipboard_sharing" , +"/b_info/u/spice/usbredirection" , +"/b_info/u/usbversion" , +"/b_info/u/vendor_device" , +"/on_watchdog" , +NULL +}; +#else +/* +* These paths must be ignored if running on Xen 4.2 +*/ +static const char *ignore_paths[] = { +"/c_info/pvh" , +"/c_info/driver_domain" , +"/b_info/nodemap" , +"/b_info/exec_ssidref" , +"/b_info/iomem" , +"/b_info/claim_mode" , +"/b_info/device_model_version" , +"/b_info/event_channels" , +"/b_info/u/usbdevice_list" , +"/b_info/u/kernel" , +"/b_info/u/cmdline" , +"/b_info/u/ramdisk" , +"/b_info/u/bios" , +"/b_info/u/timer_mode" , +"/b_info/u/vga/kind" , +"/b_info/u/spice/vdagent" , +"/b_info/u/spice/clipboard_sharing" , +"/b_info/u/spice/usbredirection" , +"/b_info/u/usbversion" , +"/b_info/u/vendor_device" , +"/disks/backend_domname" , +"/nics/backend_domname" , +"/nics/gatewaydev" , +"/vfbs/backend_domname" , +"/vkbs/backend_domname" , +"/vtpms" , +"/on_watchdog" , + NULL
Quoted 9 lines
tests/libxlxml2jsontest.c
Quoted 3 lines
tests/libxlxml2jsontest.c new file +2
-0+}; +#endif As more & more versions of Xen are released I think we might end up with quite alot of duplication between these lists. Could we structure it a little differently to avoid this perhaps in this way:
Yes, your suggestion is much better. I meant to make a similar change before sending this patch...
Regards,
Jim
Quoted 49 lines
#if defined LIBXL_HAVE_BUILDINFO_HVM_VENDOR_DEVICE # define LIBXL_VERSION 4004 #elif define LIBXL_HAVE_DOMAIN_NODEAFFINITY # define LIBXL_VERSION 4003 #else # define LIBXL_VERSION 4002 #endif static const char *ignore_paths[] = { #if LIBXL_VERSION < 4004 "/c_info/pvh", "/c_info/driver_domain", "/b_info/device_model_version", "/b_info/event_channels", "/b_info/u/kernel", "/b_info/u/cmdline", "/b_info/u/ramdisk", "/b_info/u/bios", "/b_info/u/timer_mode", "/b_info/u/vga/kind", "/b_info/u/spice/vdagent", "/b_info/u/spice/clipboard_sharing", "/b_info/u/spice/usbredirection", "/b_info/u/usbversion", "/b_info/u/vendor_device", "/on_watchdog", #endif #if LIBXL_VERSION < 4003 "/b_info/nodemap", "/b_info/exec_ssidref", "/b_info/iomem", "/b_info/claim_mode", "/b_info/u/usbdevice_list", "/disks/backend_domname", "/nics/backend_domname", "/nics/gatewaydev", "/vfbs/backend_domname", "/vkbs/backend_domname", "/vtpms", #endif NULL };Regards,
Daniel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH V3 1/5] util: Introduce virJSONStringCompare for JSON doc comparisons
Quoted 15 lines · Jim Fehlig
From: "Daniel P. Berrange" <[email protected]>
Comparing JSON docs using strcmp is simple, but is not flexible as it is sensitive to whitespace used in the doc generation. When comparing objects it may also be desirable to treat the existance of keys in the actual object but not expected object as non-fatal. Introduce a virJSONStringCompare function which takes two strings representing expected and actual JSON docs and then does a DOM comparison. Comparison is controled with the
ignore_contextsand flags parameters. No comparison is done on context paths specified inignore_contexts. TheVIR_JSON_COMPARE_IGNORE_EXPECTED_NULLflag can be used to ignore actual values that have changed from an expected value of null.
Quoted 7 lines
Signed-off-by Daniel P. Berrange <[email protected]>Signed-off-by Jim Fehlig <[email protected]>--- src/libvirt_private.syms | 1 + src/util/virjson.c | 242 +++++++++++++++++++++++++++++++++++++++++++++++ src/util/virjson.h | 16 ++++ 3 files changed, 259 insertions(+)
Looks good, but perhaps we should also add to tests/virjsontest.c to verify the ignore context support is working as intended
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH V3 1/5] util: Introduce virJSONStringCompare for JSON doc comparisons
Quoted 26 lines · Daniel P. Berrange
Quoted 15 lines · Jim Fehlig
From: "Daniel P. Berrange" <[email protected]>
Comparing JSON docs using strcmp is simple, but is not flexible as it is sensitive to whitespace used in the doc generation. When comparing objects it may also be desirable to treat the existance of keys in the actual object but not expected object as non-fatal. Introduce a virJSONStringCompare function which takes two strings representing expected and actual JSON docs and then does a DOM comparison. Comparison is controled with the
ignore_contextsand flags parameters. No comparison is done on context paths specified inignore_contexts. TheVIR_JSON_COMPARE_IGNORE_EXPECTED_NULLflag can be used to ignore actual values that have changed from an expected value of null.Quoted 8 lines
Signed-off-by Daniel P. Berrange <[email protected]>Signed-off-by Jim Fehlig <[email protected]>--- src/libvirt_private.syms | 1 + src/util/virjson.c | 242 +++++++++++++++++++++++++++++++++++++++++++++++ src/util/virjson.h | 16 ++++ 3 files changed, 259 insertions(+)
Quoted 3 lines
Looks good, but perhaps we should also add to
tests/virjsontest.cto verify the ignore context support is working as intended
Yes, good idea. I'll include that in V4.
Regards,
Jim
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [libvirt] [PATCH V3 4/5] libxl: fix mapping of lifecycle actions
Quoted 10 lines · Jim Fehlig
The libxl driver was blindly assigning libvirt's virDomainLifecycleAction to libxl's
libxl_action_on_shutdown, when in fact the various actions take on different values in these enums.Introduce helpers to properly map the enum values.
Signed-off-by Jim Fehlig <[email protected]>--- src/libxl/libxl_conf.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-)
ACK
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [libvirt] [PATCH V3 4/5] libxl: fix mapping of lifecycle actions
Quoted 8 lines · Daniel P. Berrange
Quoted 6 lines · Jim Fehlig
The libxl driver was blindly assigning libvirt's virDomainLifecycleAction to libxl's
libxl_action_on_shutdown, when in fact the various actions take on different values in these enums.Introduce helpers to properly map the enum values.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Jim Fehlig <[email protected]>--- src/libxl/libxl_conf.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-)ACK
Thanks. I've pushed 2-4.
Regards,
Jim
Re: [PATCH V3 4/5] libxl: fix mapping of lifecycle actions
In reply to a message not in the archiveQuoted 6 lines · Jim Fehlig
The libxl driver was blindly assigning libvirt's virDomainLifecycleAction to libxl's
libxl_action_on_shutdown, when in fact the various actions take on different values in these enums.Introduce helpers to properly map the enum values.
BTW, forgot to mention that this is the first bug found by the proposed unit tests :-).
Regards,
Jim