[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 2/3] Fix build in qemu_capabilities



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.
---
 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 9246813..d0b19c8 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3610,43 +3610,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;
@@ -3657,12 +3658,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;
 }
@@ -3747,7 +3750,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;
@@ -3756,7 +3760,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 cf69e59..483b397 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -324,12 +324,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 5fd89a3..702d3cc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17373,7 +17373,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.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]