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