Richard W.M. Jones
2016-Mar-24 15:46 UTC
[Libguestfs] Malformed XML if LIBGUESTFS_HV is defined.
I was going to post this as a patch, but I realize the patch is just working around an actual bug in the libvirt backend [not in libvirt]. Anyway, posting it here so we don't forget about it. Rich.
Richard W.M. Jones
2016-Mar-24 15:46 UTC
[Libguestfs] [PATCH] python: Skip 820 test if LIBGUESTFS_HV is defined.
This test fails under these conditions, for rather obscure reasons: - if LIBGUESTFS_HV is set, launch-libvirt.c:is_custom_hv returns true - this disables SELinux labelling in launch-libvirt.c - the test fails because the XML is malformed: XML error: label overrides require relabeling to be enabled at the domain level The XML is: <?xml version="1.0"?> <domain type="kvm" xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0"> ... </os> <seclabel type="none"/> ... <devices> <emulator>/home/rjones/d/qemu/x86_64-softmmu/qemu-system-x86_64</emulator> ... <disk device="disk" type="file"> <source file="/home/rjones/d/libguestfs/tmp/libguestfsgcFyFy/overlay1"> <seclabel model="selinux" relabel="no"/> </source> <target dev="sda" bus="scsi"/> <driver name="qemu" type="qcow2" cache="unsafe"/> <address type="drive" controller="0" bus="0" target="0" unit="0"/> </disk> ... --- python/t/test820RHBZ912499.py | 1 + python/t/tests_helper.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/python/t/test820RHBZ912499.py b/python/t/test820RHBZ912499.py index ac381d0..1efed6b 100644 --- a/python/t/test820RHBZ912499.py +++ b/python/t/test820RHBZ912499.py @@ -31,6 +31,7 @@ from .tests_helper import * @skipUnlessArchMatches ("(i.86|x86_64)") # If the architecture doesn't support IDE, skip the test. @skipUnlessGuestfsBackendIs ('libvirt') @skipUnlessLibvirtHasCPointer () +@skipIfCustomHV () class Test820RHBZ912499 (unittest.TestCase): def setUp (self): # Create a test disk. diff --git a/python/t/tests_helper.py b/python/t/tests_helper.py index c32e231..89acd93 100644 --- a/python/t/tests_helper.py +++ b/python/t/tests_helper.py @@ -18,6 +18,7 @@ # Utilities for the tests of the Python bindings. import sys +import os import unittest @@ -68,3 +69,9 @@ def skipUnlessArchMatches (arch_re): if not rex.match (machine): return unittest.skip ("the current architecture (%s) does not match '%s'" % (machine, arch_re)) return lambda func: func + + +def skipIfCustomHV (): + if "LIBGUESTFS_HV" in os.environ: + return unittest.skip ("$LIBGUESTFS_HV is set") + return lambda func: func -- 2.7.4