From 63a1376f7f4e6e2811d3eb15f6e969dc1576d4cb Mon Sep 17 00:00:00 2001 Message-Id: <63a1376f7f4e6e2811d3eb15f6e969dc1576d4cb@dist-git> From: Roman Bogorodskiy Date: Wed, 19 Nov 2014 18:59:13 +0100 Subject: [PATCH] Fix build in qemu_capabilities https://bugzilla.redhat.com/show_bug.cgi?id=1165782 Commit f05b6a91 added virQEMUDriverConfigPtr argument to the virQEMUCapsFillDomainCaps function and it uses forward declaration of virQEMUDriverConfig and virQEMUDriverConfigPtr that casues clang build to fail: gmake[3]: Entering directory `/usr/home/novel/code/libvirt/src' CC qemu/libvirt_driver_qemu_impl_la-qemu_capabilities.lo In file included from qemu/qemu_capabilities.c:43: In file included from qemu/qemu_hostdev.h:27: qemu/qemu_conf.h:63:37: error: redefinition of typedef 'virQEMUDriverConfig' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct _virQEMUDriverConfig virQEMUDriverConfig; ^ qemu/qemu_capabilities.h:328:37: note: previous definition is here typedef struct _virQEMUDriverConfig virQEMUDriverConfig; ^ Fix that by passing loader and nloader config attributes directly instead of passing complete config. (cherry picked from commit 3b3947ea3740d0713f04dcf178a08945b544ce47) Signed-off-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 37 +++++++++++++++++++++---------------- src/qemu/qemu_capabilities.h | 7 ++----- src/qemu/qemu_driver.c | 3 ++- tests/domaincapstest.c | 3 ++- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 683b882..a10bc8c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3615,43 +3615,44 @@ virQEMUCapsGetDefaultMachine(virQEMUCapsPtr qemuCaps) static int virQEMUCapsFillDomainLoaderCaps(virQEMUCapsPtr qemuCaps, - virDomainCapsLoaderPtr loader, + virDomainCapsLoaderPtr capsLoader, virArch arch, - virQEMUDriverConfigPtr cfg) + char **loader, + size_t nloader) { size_t i; - loader->device.supported = true; + capsLoader->device.supported = true; - if (VIR_ALLOC_N(loader->values.values, cfg->nloader) < 0) + if (VIR_ALLOC_N(capsLoader->values.values, nloader) < 0) return -1; - for (i = 0; i < cfg->nloader; i++) { - const char *filename = cfg->loader[i]; + for (i = 0; i < nloader; i++) { + const char *filename = loader[i]; if (!virFileExists(filename)) { VIR_DEBUG("loader filename=%s does not exist", filename); continue; } - if (VIR_STRDUP(loader->values.values[loader->values.nvalues], + if (VIR_STRDUP(capsLoader->values.values[capsLoader->values.nvalues], filename) < 0) return -1; - loader->values.nvalues++; + capsLoader->values.nvalues++; } - VIR_DOMAIN_CAPS_ENUM_SET(loader->type, + VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->type, VIR_DOMAIN_LOADER_TYPE_ROM); if (arch == VIR_ARCH_X86_64 && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_FORMAT)) - VIR_DOMAIN_CAPS_ENUM_SET(loader->type, + VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->type, VIR_DOMAIN_LOADER_TYPE_PFLASH); if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_READONLY)) - VIR_DOMAIN_CAPS_ENUM_SET(loader->readonly, + VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->readonly, VIR_TRISTATE_BOOL_YES, VIR_TRISTATE_BOOL_NO); return 0; @@ -3662,12 +3663,14 @@ static int virQEMUCapsFillDomainOSCaps(virQEMUCapsPtr qemuCaps, virDomainCapsOSPtr os, virArch arch, - virQEMUDriverConfigPtr cfg) + char **loader, + size_t nloader) { - virDomainCapsLoaderPtr loader = &os->loader; + virDomainCapsLoaderPtr capsLoader = &os->loader; os->device.supported = true; - if (virQEMUCapsFillDomainLoaderCaps(qemuCaps, loader, arch, cfg) < 0) + if (virQEMUCapsFillDomainLoaderCaps(qemuCaps, capsLoader, arch, + loader, nloader) < 0) return -1; return 0; } @@ -3752,7 +3755,8 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps, int virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps, virQEMUCapsPtr qemuCaps, - virQEMUDriverConfigPtr cfg) + char **loader, + size_t nloader) { virDomainCapsOSPtr os = &domCaps->os; virDomainCapsDeviceDiskPtr disk = &domCaps->disk; @@ -3761,7 +3765,8 @@ virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps, domCaps->maxvcpus = maxvcpus; - if (virQEMUCapsFillDomainOSCaps(qemuCaps, os, domCaps->arch, cfg) < 0 || + if (virQEMUCapsFillDomainOSCaps(qemuCaps, os, domCaps->arch, + loader, nloader) < 0 || virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps, disk) < 0 || virQEMUCapsFillDomainDeviceHostdevCaps(qemuCaps, hostdev) < 0) return -1; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 08c531d..c0e2172 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -326,12 +326,9 @@ int virQEMUCapsInitGuestFromBinary(virCapsPtr caps, virQEMUCapsPtr kvmbinCaps, virArch guestarch); -/* Forward declaration */ -typedef struct _virQEMUDriverConfig virQEMUDriverConfig; -typedef virQEMUDriverConfig *virQEMUDriverConfigPtr; - int virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps, virQEMUCapsPtr qemuCaps, - virQEMUDriverConfigPtr cfg); + char **loader, + size_t nloader); #endif /* __QEMU_CAPABILITIES_H__*/ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ea45d89..8e6ef1e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17668,7 +17668,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, if (!(domCaps = virDomainCapsNew(emulatorbin, machine, arch, virttype))) goto cleanup; - if (virQEMUCapsFillDomainCaps(domCaps, qemuCaps, cfg) < 0) + if (virQEMUCapsFillDomainCaps(domCaps, qemuCaps, + cfg->loader, cfg->nloader) < 0) goto cleanup; ret = virDomainCapsFormat(domCaps); diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 067ad4d..70d2ef3 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -106,7 +106,8 @@ fillQemuCaps(virDomainCapsPtr domCaps, virQEMUCapsPtr qemuCaps = data->qemuCaps; virQEMUDriverConfigPtr cfg = data->cfg; - if (virQEMUCapsFillDomainCaps(domCaps, qemuCaps, cfg) < 0) + if (virQEMUCapsFillDomainCaps(domCaps, qemuCaps, + cfg->loader, cfg->nloader) < 0) return -1; /* The function above tries to query host's KVM & VFIO capabilities by -- 2.1.3