|
|
aff97e |
From b9471c6a4ad05bdd7d5a3e69da357fb5ced0d704 Mon Sep 17 00:00:00 2001
|
|
|
3ec523 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
3ec523 |
Date: Wed, 17 Sep 2014 11:33:35 +0200
|
|
|
3ec523 |
Subject: [PATCH] qemu_capabilities: Change virQEMUCapsFillDomainCaps signature
|
|
|
3ec523 |
|
|
|
3ec523 |
Up till now the virQEMUCapsFillDomainCaps() was type of void as
|
|
|
3ec523 |
there was no way for it to fail. This is, however, going to
|
|
|
3ec523 |
change in the next commit.
|
|
|
3ec523 |
|
|
|
3ec523 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
3ec523 |
(cherry picked from commit 2b2e4a7acff5574dd82bfbd61a638270f6be54ef)
|
|
|
3ec523 |
---
|
|
|
3ec523 |
src/qemu/qemu_capabilities.c | 25 ++++++++++++++++---------
|
|
|
3ec523 |
src/qemu/qemu_capabilities.h | 4 ++--
|
|
|
3ec523 |
src/qemu/qemu_driver.c | 3 ++-
|
|
|
3ec523 |
tests/domaincapstest.c | 19 ++++++++++++-------
|
|
|
3ec523 |
4 files changed, 32 insertions(+), 19 deletions(-)
|
|
|
3ec523 |
|
|
|
3ec523 |
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
|
|
|
3ec523 |
index c999ee4..d2e5f47 100644
|
|
|
3ec523 |
--- a/src/qemu/qemu_capabilities.c
|
|
|
3ec523 |
+++ b/src/qemu/qemu_capabilities.c
|
|
|
3ec523 |
@@ -3608,7 +3608,7 @@ virQEMUCapsGetDefaultMachine(virQEMUCapsPtr qemuCaps)
|
|
|
3ec523 |
}
|
|
|
3ec523 |
|
|
|
3ec523 |
|
|
|
3ec523 |
-static void
|
|
|
3ec523 |
+static int
|
|
|
3ec523 |
virQEMUCapsFillDomainLoaderCaps(virQEMUCapsPtr qemuCaps,
|
|
|
3ec523 |
virDomainCapsLoaderPtr loader,
|
|
|
3ec523 |
virArch arch)
|
|
|
3ec523 |
@@ -3629,10 +3629,11 @@ virQEMUCapsFillDomainLoaderCaps(virQEMUCapsPtr qemuCaps,
|
|
|
3ec523 |
VIR_DOMAIN_CAPS_ENUM_SET(loader->readonly,
|
|
|
3ec523 |
VIR_TRISTATE_BOOL_YES,
|
|
|
3ec523 |
VIR_TRISTATE_BOOL_NO);
|
|
|
3ec523 |
+ return 0;
|
|
|
3ec523 |
}
|
|
|
3ec523 |
|
|
|
3ec523 |
|
|
|
3ec523 |
-static void
|
|
|
3ec523 |
+static int
|
|
|
3ec523 |
virQEMUCapsFillDomainOSCaps(virQEMUCapsPtr qemuCaps,
|
|
|
3ec523 |
virDomainCapsOSPtr os,
|
|
|
3ec523 |
virArch arch)
|
|
|
3ec523 |
@@ -3640,11 +3641,13 @@ virQEMUCapsFillDomainOSCaps(virQEMUCapsPtr qemuCaps,
|
|
|
3ec523 |
virDomainCapsLoaderPtr loader = &os->loader;
|
|
|
3ec523 |
|
|
|
3ec523 |
os->device.supported = true;
|
|
|
3ec523 |
- virQEMUCapsFillDomainLoaderCaps(qemuCaps, loader, arch);
|
|
|
3ec523 |
+ if (virQEMUCapsFillDomainLoaderCaps(qemuCaps, loader, arch) < 0)
|
|
|
3ec523 |
+ return -1;
|
|
|
3ec523 |
+ return 0;
|
|
|
3ec523 |
}
|
|
|
3ec523 |
|
|
|
3ec523 |
|
|
|
3ec523 |
-static void
|
|
|
3ec523 |
+static int
|
|
|
3ec523 |
virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps,
|
|
|
3ec523 |
virDomainCapsDeviceDiskPtr disk)
|
|
|
3ec523 |
{
|
|
|
3ec523 |
@@ -3667,10 +3670,11 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps,
|
|
|
3ec523 |
|
|
|
3ec523 |
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE))
|
|
|
3ec523 |
VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_USB);
|
|
|
3ec523 |
+ return 0;
|
|
|
3ec523 |
}
|
|
|
3ec523 |
|
|
|
3ec523 |
|
|
|
3ec523 |
-static void
|
|
|
3ec523 |
+static int
|
|
|
3ec523 |
virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
|
|
|
3ec523 |
virDomainCapsDeviceHostdevPtr hostdev)
|
|
|
3ec523 |
{
|
|
|
3ec523 |
@@ -3715,10 +3719,11 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
|
|
|
3ec523 |
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT,
|
|
|
3ec523 |
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM);
|
|
|
3ec523 |
}
|
|
|
3ec523 |
+ return 0;
|
|
|
3ec523 |
}
|
|
|
3ec523 |
|
|
|
3ec523 |
|
|
|
3ec523 |
-void
|
|
|
3ec523 |
+int
|
|
|
3ec523 |
virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps,
|
|
|
3ec523 |
virQEMUCapsPtr qemuCaps)
|
|
|
3ec523 |
{
|
|
|
3ec523 |
@@ -3729,7 +3734,9 @@ virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps,
|
|
|
3ec523 |
|
|
|
3ec523 |
domCaps->maxvcpus = maxvcpus;
|
|
|
3ec523 |
|
|
|
3ec523 |
- virQEMUCapsFillDomainOSCaps(qemuCaps, os, domCaps->arch);
|
|
|
3ec523 |
- virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps, disk);
|
|
|
3ec523 |
- virQEMUCapsFillDomainDeviceHostdevCaps(qemuCaps, hostdev);
|
|
|
3ec523 |
+ if (virQEMUCapsFillDomainOSCaps(qemuCaps, os, domCaps->arch) < 0 ||
|
|
|
3ec523 |
+ virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps, disk) < 0 ||
|
|
|
3ec523 |
+ virQEMUCapsFillDomainDeviceHostdevCaps(qemuCaps, hostdev) < 0)
|
|
|
3ec523 |
+ return -1;
|
|
|
3ec523 |
+ return 0;
|
|
|
3ec523 |
}
|
|
|
3ec523 |
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
|
|
|
3ec523 |
index 0980c00..828bba3 100644
|
|
|
3ec523 |
--- a/src/qemu/qemu_capabilities.h
|
|
|
3ec523 |
+++ b/src/qemu/qemu_capabilities.h
|
|
|
3ec523 |
@@ -324,7 +324,7 @@ int virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
|
|
|
3ec523 |
virQEMUCapsPtr kvmbinCaps,
|
|
|
3ec523 |
virArch guestarch);
|
|
|
3ec523 |
|
|
|
3ec523 |
-void virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps,
|
|
|
3ec523 |
- virQEMUCapsPtr qemuCaps);
|
|
|
3ec523 |
+int virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps,
|
|
|
3ec523 |
+ virQEMUCapsPtr qemuCaps);
|
|
|
3ec523 |
|
|
|
3ec523 |
#endif /* __QEMU_CAPABILITIES_H__*/
|
|
|
3ec523 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
3ec523 |
index 588eba4..9c1644c 100644
|
|
|
3ec523 |
--- a/src/qemu/qemu_driver.c
|
|
|
3ec523 |
+++ b/src/qemu/qemu_driver.c
|
|
|
3ec523 |
@@ -17205,7 +17205,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
|
|
|
3ec523 |
if (!(domCaps = virDomainCapsNew(emulatorbin, machine, arch, virttype)))
|
|
|
3ec523 |
goto cleanup;
|
|
|
3ec523 |
|
|
|
3ec523 |
- virQEMUCapsFillDomainCaps(domCaps, qemuCaps);
|
|
|
3ec523 |
+ if (virQEMUCapsFillDomainCaps(domCaps, qemuCaps) < 0)
|
|
|
3ec523 |
+ goto cleanup;
|
|
|
3ec523 |
|
|
|
3ec523 |
ret = virDomainCapsFormat(domCaps);
|
|
|
3ec523 |
cleanup:
|
|
|
3ec523 |
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
|
|
|
3ec523 |
index f240643..0c4b09f 100644
|
|
|
3ec523 |
--- a/tests/domaincapstest.c
|
|
|
3ec523 |
+++ b/tests/domaincapstest.c
|
|
|
3ec523 |
@@ -28,13 +28,13 @@
|
|
|
3ec523 |
|
|
|
3ec523 |
#define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
3ec523 |
|
|
|
3ec523 |
-typedef void (*virDomainCapsFill)(virDomainCapsPtr domCaps,
|
|
|
3ec523 |
- void *opaque);
|
|
|
3ec523 |
+typedef int (*virDomainCapsFill)(virDomainCapsPtr domCaps,
|
|
|
3ec523 |
+ void *opaque);
|
|
|
3ec523 |
|
|
|
3ec523 |
#define SET_ALL_BITS(x) \
|
|
|
3ec523 |
memset(&(x.values), 0xff, sizeof(x.values))
|
|
|
3ec523 |
|
|
|
3ec523 |
-static void
|
|
|
3ec523 |
+static int
|
|
|
3ec523 |
fillAll(virDomainCapsPtr domCaps,
|
|
|
3ec523 |
void *opaque ATTRIBUTE_UNUSED)
|
|
|
3ec523 |
{
|
|
|
3ec523 |
@@ -60,18 +60,20 @@ fillAll(virDomainCapsPtr domCaps,
|
|
|
3ec523 |
SET_ALL_BITS(hostdev->subsysType);
|
|
|
3ec523 |
SET_ALL_BITS(hostdev->capsType);
|
|
|
3ec523 |
SET_ALL_BITS(hostdev->pciBackend);
|
|
|
3ec523 |
+ return 0;
|
|
|
3ec523 |
}
|
|
|
3ec523 |
|
|
|
3ec523 |
|
|
|
3ec523 |
#ifdef WITH_QEMU
|
|
|
3ec523 |
# include "testutilsqemu.h"
|
|
|
3ec523 |
-static void
|
|
|
3ec523 |
+static int
|
|
|
3ec523 |
fillQemuCaps(virDomainCapsPtr domCaps,
|
|
|
3ec523 |
void *opaque)
|
|
|
3ec523 |
{
|
|
|
3ec523 |
virQEMUCapsPtr qemuCaps = (virQEMUCapsPtr) opaque;
|
|
|
3ec523 |
|
|
|
3ec523 |
- virQEMUCapsFillDomainCaps(domCaps, qemuCaps);
|
|
|
3ec523 |
+ if (virQEMUCapsFillDomainCaps(domCaps, qemuCaps) < 0)
|
|
|
3ec523 |
+ return -1;
|
|
|
3ec523 |
|
|
|
3ec523 |
/* The function above tries to query host's KVM & VFIO capabilities by
|
|
|
3ec523 |
* calling qemuHostdevHostSupportsPassthroughLegacy() and
|
|
|
3ec523 |
@@ -82,6 +84,7 @@ fillQemuCaps(virDomainCapsPtr domCaps,
|
|
|
3ec523 |
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT,
|
|
|
3ec523 |
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM,
|
|
|
3ec523 |
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO);
|
|
|
3ec523 |
+ return 0;
|
|
|
3ec523 |
}
|
|
|
3ec523 |
#endif /* WITH_QEMU */
|
|
|
3ec523 |
|
|
|
3ec523 |
@@ -99,8 +102,10 @@ buildVirDomainCaps(const char *emulatorbin,
|
|
|
3ec523 |
if (!(domCaps = virDomainCapsNew(emulatorbin, machine, arch, type)))
|
|
|
3ec523 |
goto cleanup;
|
|
|
3ec523 |
|
|
|
3ec523 |
- if (fillFunc)
|
|
|
3ec523 |
- fillFunc(domCaps, opaque);
|
|
|
3ec523 |
+ if (fillFunc && fillFunc(domCaps, opaque) < 0) {
|
|
|
3ec523 |
+ virObjectUnref(domCaps);
|
|
|
3ec523 |
+ domCaps = NULL;
|
|
|
3ec523 |
+ }
|
|
|
3ec523 |
|
|
|
3ec523 |
cleanup:
|
|
|
3ec523 |
return domCaps;
|