Jim Fehlig wrote:
Add domain capabilities for PV and HVM domains.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
V3:
- Change introduction of connectGetDomainCapabilities to 1.3.6
src/libxl/libxl_capabilities.c | 140 +++++++++++++++++++++++++++++
src/libxl/libxl_capabilities.h | 7 ++
src/libxl/libxl_driver.c | 74 +++++++++++++++
tests/Makefile.am | 5 ++
tests/domaincapsschemadata/libxl-xenfv.xml | 68 ++++++++++++++
tests/domaincapsschemadata/libxl-xenpv.xml | 58 ++++++++++++
tests/domaincapstest.c | 61 +++++++++++++
tests/testutilsxen.h | 1 +
8 files changed, 414 insertions(+)
...
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -162,10 +162,41 @@ fillQemuCaps(virDomainCapsPtr domCaps,
#endif /* WITH_QEMU */
+#ifdef WITH_LIBXL
+# include "testutilsxen.h"
+
+static int
+fillXenCaps(virDomainCapsPtr domCaps)
+{
+ virFirmwarePtr *firmwares;
+ int ret = -1;
+
+ if (VIR_ALLOC_N(firmwares, 2) < 0)
+ return ret;
+
+ if (VIR_ALLOC(firmwares[0]) < 0 || VIR_ALLOC(firmwares[1]) < 0)
+ goto cleanup;
+ if (VIR_STRDUP(firmwares[0]->name, "/usr/lib/xen/boot/hvmloader") <
0 ||
+ VIR_STRDUP(firmwares[1]->name, "/usr/lib/xen/boot/ovmf.bin") <
0)
+ goto cleanup;
+
+ if (libxlMakeDomainCapabilities(domCaps, firmwares, 2) < 0)
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+ virFirmwareFreeList(firmwares, 2);
+ return ret;
+}
+#endif /* WITH_LIBXL */
+
+
enum testCapsType {
CAPS_NONE,
CAPS_ALL,
CAPS_QEMU,
+ CAPS_LIBXL,
};
struct testData {
@@ -213,6 +244,13 @@ test_virDomainCapsFormat(const void *opaque)
goto cleanup;
#endif
break;
+
+ case CAPS_LIBXL:
+#if WITH_LIBXL
+ if (fillXenCaps(domCaps) < 0)
+ goto cleanup;
+#endif
+ break;
}
if (!(domCapsXML = virDomainCapsFormat(domCaps)))
@@ -280,6 +318,20 @@ mymain(void)
VIR_FREE(name); \
} while (0)
+#define DO_TEST_LIBXL(Name, Emulator, Machine, Arch, Type) \
+ do { \
+ struct testData data = { \
+ .name = Name, \
+ .emulator = Emulator, \
+ .machine = Machine, \
+ .arch = Arch, \
+ .type = Type, \
+ .capsType = CAPS_LIBXL, \
+ }; \
+ if (virTestRun(Name, test_virDomainCapsFormat, &data) < 0) \
+ ret = -1; \
+ } while (0)
+
DO_TEST("basic", "/bin/emulatorbin",
"my-machine-type",
"x86_64", VIR_DOMAIN_VIRT_UML, CAPS_NONE);
DO_TEST("full", "/bin/emulatorbin",
"my-machine-type",
@@ -313,6 +365,15 @@ mymain(void)
#endif /* WITH_QEMU */
+#if WITH_LIBXL
+
+ DO_TEST_LIBXL("libxl-xenpv", "/usr/bin/qemu-system-x86_64",
+ "xenpv", "x86_64", VIR_DOMAIN_VIRT_XEN);
+ DO_TEST_LIBXL("libxl-xenfv", "/usr/bin/qemu-system-x86_64",
+ "xenfv", "x86_64", VIR_DOMAIN_VIRT_XEN);
+
+#endif /* WITH_LIBXL */
+
return ret;
}
diff --git a/tests/testutilsxen.h b/tests/testutilsxen.h
index c78350d..8b997c3 100644
--- a/tests/testutilsxen.h
+++ b/tests/testutilsxen.h
@@ -2,6 +2,7 @@
# define _TESTUTILSXEN_H_
# include "capabilities.h"
+# include "libxl/libxl_capabilities.h"
virCapsPtr testXenCapsInit(void);
This breaks build without xl:
gmake[2]: Entering directory '/usr/home/novel/code/libvirt/tests'
CC vircapstest.o
In file included from vircapstest.c:25:
In file included from ./testutilsxen.h:5:
../src/libxl/libxl_capabilities.h:26:11: fatal error: 'libxl.h' file not found
# include <libxl.h>
^
1 error generated.
Makefile:4935: recipe for target 'vircapstest.o' failed
Probably it would be easier to just include "libxl/libxl_capabilities.h" in
tests/domaincapstest.c directly? Something like this:
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index 9fb2c97..b3ab662 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -163,7 +163,7 @@ fillQemuCaps(virDomainCapsPtr domCaps,
#ifdef WITH_LIBXL
-# include "testutilsxen.h"
+# include "libxl/libxl_capabilities.h"
static int
fillXenCaps(virDomainCapsPtr domCaps)
diff --git a/tests/testutilsxen.h b/tests/testutilsxen.h
index 8b997c3..c78350d 100644
--- a/tests/testutilsxen.h
+++ b/tests/testutilsxen.h
@@ -2,7 +2,6 @@
# define _TESTUTILSXEN_H_
# include "capabilities.h"
-# include "libxl/libxl_capabilities.h"
virCapsPtr testXenCapsInit(void);
Roman Bogorodskiy