mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 06:03:52 +03:00
qemu_capabilities: Change virQEMUCapsFillDomainCaps signature
Up till now the virQEMUCapsFillDomainCaps() was type of void as there was no way for it to fail. This is, however, going to change in the next commit. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
c7abf2c856
commit
2b2e4a7acf
@ -3608,7 +3608,7 @@ virQEMUCapsGetDefaultMachine(virQEMUCapsPtr qemuCaps)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
static int
|
||||
virQEMUCapsFillDomainLoaderCaps(virQEMUCapsPtr qemuCaps,
|
||||
virDomainCapsLoaderPtr loader,
|
||||
virArch arch)
|
||||
@ -3629,10 +3629,11 @@ virQEMUCapsFillDomainLoaderCaps(virQEMUCapsPtr qemuCaps,
|
||||
VIR_DOMAIN_CAPS_ENUM_SET(loader->readonly,
|
||||
VIR_TRISTATE_BOOL_YES,
|
||||
VIR_TRISTATE_BOOL_NO);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
static int
|
||||
virQEMUCapsFillDomainOSCaps(virQEMUCapsPtr qemuCaps,
|
||||
virDomainCapsOSPtr os,
|
||||
virArch arch)
|
||||
@ -3640,11 +3641,13 @@ virQEMUCapsFillDomainOSCaps(virQEMUCapsPtr qemuCaps,
|
||||
virDomainCapsLoaderPtr loader = &os->loader;
|
||||
|
||||
os->device.supported = true;
|
||||
virQEMUCapsFillDomainLoaderCaps(qemuCaps, loader, arch);
|
||||
if (virQEMUCapsFillDomainLoaderCaps(qemuCaps, loader, arch) < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
static int
|
||||
virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps,
|
||||
virDomainCapsDeviceDiskPtr disk)
|
||||
{
|
||||
@ -3667,10 +3670,11 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps,
|
||||
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE))
|
||||
VIR_DOMAIN_CAPS_ENUM_SET(disk->bus, VIR_DOMAIN_DISK_BUS_USB);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
static int
|
||||
virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
|
||||
virDomainCapsDeviceHostdevPtr hostdev)
|
||||
{
|
||||
@ -3715,10 +3719,11 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
|
||||
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT,
|
||||
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
int
|
||||
virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
@ -3729,7 +3734,9 @@ virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps,
|
||||
|
||||
domCaps->maxvcpus = maxvcpus;
|
||||
|
||||
virQEMUCapsFillDomainOSCaps(qemuCaps, os, domCaps->arch);
|
||||
virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps, disk);
|
||||
virQEMUCapsFillDomainDeviceHostdevCaps(qemuCaps, hostdev);
|
||||
if (virQEMUCapsFillDomainOSCaps(qemuCaps, os, domCaps->arch) < 0 ||
|
||||
virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps, disk) < 0 ||
|
||||
virQEMUCapsFillDomainDeviceHostdevCaps(qemuCaps, hostdev) < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ int virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
|
||||
virQEMUCapsPtr kvmbinCaps,
|
||||
virArch guestarch);
|
||||
|
||||
void virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps,
|
||||
virQEMUCapsPtr qemuCaps);
|
||||
int virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps,
|
||||
virQEMUCapsPtr qemuCaps);
|
||||
|
||||
#endif /* __QEMU_CAPABILITIES_H__*/
|
||||
|
@ -17357,7 +17357,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
|
||||
if (!(domCaps = virDomainCapsNew(emulatorbin, machine, arch, virttype)))
|
||||
goto cleanup;
|
||||
|
||||
virQEMUCapsFillDomainCaps(domCaps, qemuCaps);
|
||||
if (virQEMUCapsFillDomainCaps(domCaps, qemuCaps) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = virDomainCapsFormat(domCaps);
|
||||
cleanup:
|
||||
|
@ -28,13 +28,13 @@
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||
|
||||
typedef void (*virDomainCapsFill)(virDomainCapsPtr domCaps,
|
||||
void *opaque);
|
||||
typedef int (*virDomainCapsFill)(virDomainCapsPtr domCaps,
|
||||
void *opaque);
|
||||
|
||||
#define SET_ALL_BITS(x) \
|
||||
memset(&(x.values), 0xff, sizeof(x.values))
|
||||
|
||||
static void
|
||||
static int
|
||||
fillAll(virDomainCapsPtr domCaps,
|
||||
void *opaque ATTRIBUTE_UNUSED)
|
||||
{
|
||||
@ -60,18 +60,20 @@ fillAll(virDomainCapsPtr domCaps,
|
||||
SET_ALL_BITS(hostdev->subsysType);
|
||||
SET_ALL_BITS(hostdev->capsType);
|
||||
SET_ALL_BITS(hostdev->pciBackend);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef WITH_QEMU
|
||||
# include "testutilsqemu.h"
|
||||
static void
|
||||
static int
|
||||
fillQemuCaps(virDomainCapsPtr domCaps,
|
||||
void *opaque)
|
||||
{
|
||||
virQEMUCapsPtr qemuCaps = (virQEMUCapsPtr) opaque;
|
||||
|
||||
virQEMUCapsFillDomainCaps(domCaps, qemuCaps);
|
||||
if (virQEMUCapsFillDomainCaps(domCaps, qemuCaps) < 0)
|
||||
return -1;
|
||||
|
||||
/* The function above tries to query host's KVM & VFIO capabilities by
|
||||
* calling qemuHostdevHostSupportsPassthroughLegacy() and
|
||||
@ -82,6 +84,7 @@ fillQemuCaps(virDomainCapsPtr domCaps,
|
||||
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT,
|
||||
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM,
|
||||
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO);
|
||||
return 0;
|
||||
}
|
||||
#endif /* WITH_QEMU */
|
||||
|
||||
@ -99,8 +102,10 @@ buildVirDomainCaps(const char *emulatorbin,
|
||||
if (!(domCaps = virDomainCapsNew(emulatorbin, machine, arch, type)))
|
||||
goto cleanup;
|
||||
|
||||
if (fillFunc)
|
||||
fillFunc(domCaps, opaque);
|
||||
if (fillFunc && fillFunc(domCaps, opaque) < 0) {
|
||||
virObjectUnref(domCaps);
|
||||
domCaps = NULL;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
return domCaps;
|
||||
|
Loading…
x
Reference in New Issue
Block a user