Change libxlMakeDomainCapabilities() to void, since all
checks, which results in returning -1, are, in fact, not
possible.
libxlMakeDomainOSCaps(),
libxlMakeDomainDeviceDiskCaps(),
libxlMakeDomainDeviceGraphicsCaps(),
libxlMakeDomainDeviceVideoCaps(),
libxlMakeDomainDeviceHostdevCaps() also changing to void,
because they are invariant.
Test fillXenCaps() at moment is useless,
so it could be removed or changed in the future.
Signed-off-by: Artem Chernyshev <artem.chernyshev(a)red-soft.ru>
---
src/libxl/libxl_capabilities.c | 40 ++++++++++++----------------------
src/libxl/libxl_capabilities.h | 2 +-
src/libxl/libxl_driver.c | 5 +----
tests/domaincapstest.c | 3 +--
4 files changed, 17 insertions(+), 33 deletions(-)
diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 177e8b988e..3753cb256e 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -518,7 +518,7 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCaps *caps)
return 0;
}
-static int
+static void
libxlMakeDomainOSCaps(const char *machine,
virDomainCapsOS *os,
virFirmware **firmwares,
@@ -533,7 +533,7 @@ libxlMakeDomainOSCaps(const char *machine,
capsLoader->readonly.report = true;
if (STREQ(machine, "xenpv") || STREQ(machine, "xenpvh"))
- return 0;
+ return;
capsLoader->supported = VIR_TRISTATE_BOOL_YES;
capsLoader->values.values = g_new0(char *, nfirmwares);
@@ -548,11 +548,9 @@ libxlMakeDomainOSCaps(const char *machine,
VIR_DOMAIN_LOADER_TYPE_PFLASH);
VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->readonly,
VIR_TRISTATE_BOOL_YES);
-
- return 0;
}
-static int
+static void
libxlMakeDomainDeviceDiskCaps(virDomainCapsDeviceDisk *dev)
{
dev->supported = VIR_TRISTATE_BOOL_YES;
@@ -568,11 +566,9 @@ libxlMakeDomainDeviceDiskCaps(virDomainCapsDeviceDisk *dev)
VIR_DOMAIN_DISK_BUS_IDE,
VIR_DOMAIN_DISK_BUS_SCSI,
VIR_DOMAIN_DISK_BUS_XEN);
-
- return 0;
}
-static int
+static void
libxlMakeDomainDeviceGraphicsCaps(virDomainCapsDeviceGraphics *dev)
{
dev->supported = VIR_TRISTATE_BOOL_YES;
@@ -582,11 +578,9 @@ libxlMakeDomainDeviceGraphicsCaps(virDomainCapsDeviceGraphics *dev)
VIR_DOMAIN_GRAPHICS_TYPE_SDL,
VIR_DOMAIN_GRAPHICS_TYPE_VNC,
VIR_DOMAIN_GRAPHICS_TYPE_SPICE);
-
- return 0;
}
-static int
+static void
libxlMakeDomainDeviceVideoCaps(virDomainCapsDeviceVideo *dev)
{
dev->supported = VIR_TRISTATE_BOOL_YES;
@@ -596,11 +590,9 @@ libxlMakeDomainDeviceVideoCaps(virDomainCapsDeviceVideo *dev)
VIR_DOMAIN_VIDEO_TYPE_VGA,
VIR_DOMAIN_VIDEO_TYPE_CIRRUS,
VIR_DOMAIN_VIDEO_TYPE_XEN);
-
- return 0;
}
-static int
+static void
libxlMakeDomainDeviceHostdevCaps(virDomainCapsDeviceHostdev *dev)
{
dev->supported = VIR_TRISTATE_BOOL_YES;
@@ -632,7 +624,6 @@ libxlMakeDomainDeviceHostdevCaps(virDomainCapsDeviceHostdev *dev)
virDomainCapsEnumClear(&dev->pciBackend);
VIR_DOMAIN_CAPS_ENUM_SET(dev->pciBackend,
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN);
- return 0;
}
virCaps *
@@ -669,7 +660,7 @@ libxlMakeCapabilities(libxl_ctx *ctx)
#define HVM_MAX_VCPUS 128
#define PV_MAX_VCPUS 512
-int
+void
libxlMakeDomainCapabilities(virDomainCaps *domCaps,
virFirmware **firmwares,
size_t nfirmwares)
@@ -685,21 +676,18 @@ libxlMakeDomainCapabilities(virDomainCaps *domCaps,
else
domCaps->maxvcpus = PV_MAX_VCPUS;
- if (libxlMakeDomainOSCaps(domCaps->machine, os, firmwares, nfirmwares) < 0 ||
- libxlMakeDomainDeviceDiskCaps(disk) < 0 ||
- libxlMakeDomainDeviceGraphicsCaps(graphics) < 0 ||
- libxlMakeDomainDeviceVideoCaps(video) < 0)
- return -1;
- if (STRNEQ(domCaps->machine, "xenpvh") &&
- libxlMakeDomainDeviceHostdevCaps(hostdev) < 0)
- return -1;
+ libxlMakeDomainOSCaps(domCaps->machine, os, firmwares, nfirmwares);
+ libxlMakeDomainDeviceDiskCaps(disk);
+ libxlMakeDomainDeviceGraphicsCaps(graphics);
+ libxlMakeDomainDeviceVideoCaps(video);
+
+ if (STRNEQ(domCaps->machine, "xenpvh")
+ libxlMakeDomainDeviceHostdevCaps(hostdev);
domCaps->features[VIR_DOMAIN_CAPS_FEATURE_IOTHREADS] = VIR_TRISTATE_BOOL_NO;
domCaps->features[VIR_DOMAIN_CAPS_FEATURE_VMCOREINFO] = VIR_TRISTATE_BOOL_NO;
domCaps->features[VIR_DOMAIN_CAPS_FEATURE_GENID] = VIR_TRISTATE_BOOL_NO;
domCaps->gic.supported = VIR_TRISTATE_BOOL_NO;
-
- return 0;
}
#define LIBXL_QEMU_DM_STR "Options specific to the Xen version:"
diff --git a/src/libxl/libxl_capabilities.h b/src/libxl/libxl_capabilities.h
index fd6332b63e..16ac3ed034 100644
--- a/src/libxl/libxl_capabilities.h
+++ b/src/libxl/libxl_capabilities.h
@@ -40,7 +40,7 @@
virCaps *
libxlMakeCapabilities(libxl_ctx *ctx);
-int
+void
libxlMakeDomainCapabilities(virDomainCaps *domCaps,
virFirmware **firmwares,
size_t nfirmwares);
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 691e9b3517..11a96233bd 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -6409,10 +6409,7 @@ libxlConnectGetDomainCapabilities(virConnectPtr conn,
if (!(domCaps = virDomainCapsNew(emulatorbin, machine, arch, virttype)))
goto cleanup;
- if (libxlMakeDomainCapabilities(domCaps, cfg->firmwares,
- cfg->nfirmwares) < 0)
- goto cleanup;
-
+ libxlMakeDomainCapabilities(domCaps, cfg->firmwares, cfg->nfirmwares);
ret = virDomainCapsFormat(domCaps);
cleanup:
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index c4a4508430..958469fcfb 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -143,8 +143,7 @@ fillXenCaps(virDomainCaps *domCaps)
firmwares[0]->name = g_strdup("/usr/lib/xen/boot/hvmloader");
firmwares[1]->name = g_strdup("/usr/lib/xen/boot/ovmf.bin");
- if (libxlMakeDomainCapabilities(domCaps, firmwares, 2) < 0)
- return -1;
+ libxlMakeDomainCapabilities(domCaps, firmwares, 2);
return 0;
}
--
2.43.0