render / rpms / libvirt

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