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

[libvirt] [PATCH v2 5/7] qemu: pass only host arch instead of the whole virCaps



This is a preparation for following patches where we switch to
virFileCache for QEMU capabilities cache

The host arch will always remain the same but virCaps may change.  Now
the host arch is stored while creating new qemu capabilities cache.
It removes the need to pass virCaps into virQEMUCapsCache*() functions.

Signed-off-by: Pavel Hrdina <phrdina redhat com>
---

Notes:
    New in v2

 src/qemu/qemu_capabilities.c | 61 +++++++++++++++++++++-----------------------
 src/qemu/qemu_capabilities.h |  9 +++----
 src/qemu/qemu_capspriv.h     | 11 +++++---
 src/qemu/qemu_domain.c       | 17 +++++-------
 src/qemu/qemu_driver.c       |  8 +++---
 src/qemu/qemu_process.c      |  9 +++----
 tests/qemucapsprobe.c        |  3 ++-
 tests/qemucpumock.c          |  3 ++-
 tests/qemuxml2argvtest.c     |  9 +++++--
 tests/testutilsqemu.c        |  5 +++-
 10 files changed, 67 insertions(+), 68 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index c310e97f61..603ce18ac3 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -972,7 +972,7 @@ virQEMUCapsInitGuest(virCapsPtr caps,
 
     /* Ignore binary if extracting version info fails */
     if (binary) {
-        if (!(qemubinCaps = virQEMUCapsCacheLookup(caps, cache, binary))) {
+        if (!(qemubinCaps = virQEMUCapsCacheLookup(cache, binary))) {
             virResetLastError();
             VIR_FREE(binary);
         }
@@ -1012,7 +1012,7 @@ virQEMUCapsInitGuest(virCapsPtr caps,
             if (!kvmbin)
                 continue;
 
-            if (!(kvmbinCaps = virQEMUCapsCacheLookup(caps, cache, kvmbin))) {
+            if (!(kvmbinCaps = virQEMUCapsCacheLookup(cache, kvmbin))) {
                 virResetLastError();
                 VIR_FREE(kvmbin);
                 continue;
@@ -1152,7 +1152,7 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
 
 
 virCPUDefPtr
-virQEMUCapsProbeHostCPUForEmulator(virCapsPtr caps,
+virQEMUCapsProbeHostCPUForEmulator(virArch hostArch,
                                    virQEMUCapsPtr qemuCaps,
                                    virDomainVirtType type)
 {
@@ -1163,7 +1163,7 @@ virQEMUCapsProbeHostCPUForEmulator(virCapsPtr caps,
     if (virQEMUCapsGetCPUDefinitions(qemuCaps, type, &models, &nmodels) < 0)
         return NULL;
 
-    cpu = virCPUGetHost(caps->host.arch, VIR_CPU_TYPE_GUEST, NULL,
+    cpu = virCPUGetHost(hostArch, VIR_CPU_TYPE_GUEST, NULL,
                         (const char **) models, nmodels);
 
     virStringListFreeCount(models, nmodels);
@@ -2182,7 +2182,7 @@ int virQEMUCapsGetDefaultVersion(virCapsPtr caps,
         return -1;
     }
 
-    qemucaps = virQEMUCapsCacheLookup(caps, capsCache, capsdata->emulator);
+    qemucaps = virQEMUCapsCacheLookup(capsCache, capsdata->emulator);
     VIR_FREE(capsdata);
     if (!qemucaps)
         return -1;
@@ -3484,7 +3484,7 @@ virQEMUCapsNewHostCPUModel(void)
 
 void
 virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
-                            virCapsPtr caps,
+                            virArch hostArch,
                             virDomainVirtType type)
 {
     virCPUDefPtr cpu = NULL;
@@ -3494,7 +3494,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
     size_t i;
     int rc;
 
-    if (!caps || !virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch))
+    if (!virQEMUCapsGuestIsNative(hostArch, qemuCaps->arch))
         return;
 
     if (!(cpu = virQEMUCapsNewHostCPUModel()))
@@ -3505,7 +3505,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
     } else if (rc == 1) {
         VIR_DEBUG("No host CPU model info from QEMU; probing host CPU directly");
 
-        hostCPU = virQEMUCapsProbeHostCPUForEmulator(caps, qemuCaps, type);
+        hostCPU = virQEMUCapsProbeHostCPUForEmulator(hostArch, qemuCaps, type);
         if (!hostCPU ||
             virCPUDefCopyModelFilter(cpu, hostCPU, true,
                                      virQEMUCapsCPUFilterFeatures,
@@ -3790,7 +3790,7 @@ virQEMUCapsCachePrivFree(virQEMUCapsCachePrivPtr priv)
  * </qemuCaps>
  */
 int
-virQEMUCapsLoadCache(virCapsPtr caps,
+virQEMUCapsLoadCache(virArch hostArch,
                      virQEMUCapsPtr qemuCaps,
                      const char *filename)
 {
@@ -4007,8 +4007,8 @@ virQEMUCapsLoadCache(virCapsPtr caps,
     }
     VIR_FREE(nodes);
 
-    virQEMUCapsInitHostCPUModel(qemuCaps, caps, VIR_DOMAIN_VIRT_KVM);
-    virQEMUCapsInitHostCPUModel(qemuCaps, caps, VIR_DOMAIN_VIRT_QEMU);
+    virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM);
+    virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU);
 
     ret = 0;
  cleanup:
@@ -4321,8 +4321,7 @@ virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps,
 
 
 static int
-virQEMUCapsInitCached(virCapsPtr caps,
-                      virQEMUCapsPtr *qemuCaps,
+virQEMUCapsInitCached(virQEMUCapsPtr *qemuCaps,
                       const char *binary,
                       const char *cacheDir,
                       virQEMUCapsCachePrivPtr priv)
@@ -4369,7 +4368,7 @@ virQEMUCapsInitCached(virCapsPtr caps,
     if (VIR_STRDUP(qemuCapsNew->binary, binary) < 0)
         goto discard;
 
-    if (virQEMUCapsLoadCache(caps, qemuCapsNew, capsfile) < 0) {
+    if (virQEMUCapsLoadCache(priv->hostArch, qemuCapsNew, capsfile) < 0) {
         VIR_WARN("Failed to load cached caps from '%s' for '%s': %s",
                  capsfile, qemuCapsNew->binary, virGetLastErrorMessage());
         virResetLastError();
@@ -5207,7 +5206,7 @@ virQEMUCapsLogProbeFailure(const char *binary)
 
 
 virQEMUCapsPtr
-virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
+virQEMUCapsNewForBinaryInternal(virArch hostArch,
                                 const char *binary,
                                 const char *libDir,
                                 uid_t runUid,
@@ -5265,8 +5264,8 @@ virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
     qemuCaps->libvirtCtime = virGetSelfLastChanged();
     qemuCaps->libvirtVersion = LIBVIR_VERSION_NUMBER;
 
-    virQEMUCapsInitHostCPUModel(qemuCaps, caps, VIR_DOMAIN_VIRT_KVM);
-    virQEMUCapsInitHostCPUModel(qemuCaps, caps, VIR_DOMAIN_VIRT_QEMU);
+    virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM);
+    virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU);
 
  cleanup:
     VIR_FREE(qmperr);
@@ -5279,19 +5278,19 @@ virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
 }
 
 static virQEMUCapsPtr
-virQEMUCapsNewForBinary(virCapsPtr caps,
-                        const char *binary,
+virQEMUCapsNewForBinary(const char *binary,
                         const char *cacheDir,
                         virQEMUCapsCachePrivPtr priv)
 {
     int rv;
     virQEMUCapsPtr qemuCaps = NULL;
 
-    if ((rv = virQEMUCapsInitCached(caps, &qemuCaps, binary, cacheDir, priv)) < 0)
+    if ((rv = virQEMUCapsInitCached(&qemuCaps, binary, cacheDir, priv)) < 0)
         goto error;
 
     if (rv == 0) {
-        if (!(qemuCaps = virQEMUCapsNewForBinaryInternal(caps, binary,
+        if (!(qemuCaps = virQEMUCapsNewForBinaryInternal(priv->hostArch,
+                                                         binary,
                                                          priv->libDir,
                                                          priv->runUid,
                                                          priv->runGid,
@@ -5378,6 +5377,8 @@ virQEMUCapsCacheNew(const char *libDir,
     if (VIR_STRDUP(cache->priv->libDir, libDir) < 0)
         goto error;
 
+    cache->priv->hostArch = virArchFromHost();
+
     cache->priv->runUid = runUid;
     cache->priv->runGid = runGid;
 
@@ -5392,7 +5393,6 @@ virQEMUCapsCacheNew(const char *libDir,
 static void ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
 virQEMUCapsCacheValidate(virQEMUCapsCachePtr cache,
                          const char *binary,
-                         virCapsPtr caps,
                          virQEMUCapsPtr *qemuCaps)
 {
     if (*qemuCaps &&
@@ -5405,7 +5405,7 @@ virQEMUCapsCacheValidate(virQEMUCapsCachePtr cache,
 
     if (!*qemuCaps) {
         VIR_DEBUG("Creating capabilities for %s", binary);
-        *qemuCaps = virQEMUCapsNewForBinary(caps, binary,
+        *qemuCaps = virQEMUCapsNewForBinary(binary,
                                             cache->cacheDir,
                                             cache->priv);
         if (*qemuCaps) {
@@ -5420,8 +5420,7 @@ virQEMUCapsCacheValidate(virQEMUCapsCachePtr cache,
 
 
 virQEMUCapsPtr
-virQEMUCapsCacheLookup(virCapsPtr caps,
-                       virQEMUCapsCachePtr cache,
+virQEMUCapsCacheLookup(virQEMUCapsCachePtr cache,
                        const char *binary)
 {
     virQEMUCapsPtr ret = NULL;
@@ -5429,7 +5428,7 @@ virQEMUCapsCacheLookup(virCapsPtr caps,
     virMutexLock(&cache->lock);
 
     ret = virHashLookup(cache->binaries, binary);
-    virQEMUCapsCacheValidate(cache, binary, caps, &ret);
+    virQEMUCapsCacheValidate(cache, binary, &ret);
     virObjectRef(ret);
 
     virMutexUnlock(&cache->lock);
@@ -5440,12 +5439,11 @@ virQEMUCapsCacheLookup(virCapsPtr caps,
 
 
 virQEMUCapsPtr
-virQEMUCapsCacheLookupCopy(virCapsPtr caps,
-                           virQEMUCapsCachePtr cache,
+virQEMUCapsCacheLookupCopy(virQEMUCapsCachePtr cache,
                            const char *binary,
                            const char *machineType)
 {
-    virQEMUCapsPtr qemuCaps = virQEMUCapsCacheLookup(caps, cache, binary);
+    virQEMUCapsPtr qemuCaps = virQEMUCapsCacheLookup(cache, binary);
     virQEMUCapsPtr ret;
 
     if (!qemuCaps)
@@ -5475,8 +5473,7 @@ virQEMUCapsCompareArch(const void *payload,
 
 
 virQEMUCapsPtr
-virQEMUCapsCacheLookupByArch(virCapsPtr caps,
-                             virQEMUCapsCachePtr cache,
+virQEMUCapsCacheLookupByArch(virQEMUCapsCachePtr cache,
                              virArch arch)
 {
     virQEMUCapsPtr ret = NULL;
@@ -5502,7 +5499,7 @@ virQEMUCapsCacheLookupByArch(virCapsPtr caps,
         if (VIR_STRDUP(binary, ret->binary) < 0) {
             ret = NULL;
         } else {
-            virQEMUCapsCacheValidate(cache, binary, caps, &ret);
+            virQEMUCapsCacheValidate(cache, binary, &ret);
             VIR_FREE(binary);
         }
     } else {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index bd44b90002..0aa8106191 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -501,15 +501,12 @@ void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
 virQEMUCapsCachePtr virQEMUCapsCacheNew(const char *libDir,
                                         const char *cacheDir,
                                         uid_t uid, gid_t gid);
-virQEMUCapsPtr virQEMUCapsCacheLookup(virCapsPtr caps,
-                                      virQEMUCapsCachePtr cache,
+virQEMUCapsPtr virQEMUCapsCacheLookup(virQEMUCapsCachePtr cache,
                                       const char *binary);
-virQEMUCapsPtr virQEMUCapsCacheLookupCopy(virCapsPtr caps,
-                                          virQEMUCapsCachePtr cache,
+virQEMUCapsPtr virQEMUCapsCacheLookupCopy(virQEMUCapsCachePtr cache,
                                           const char *binary,
                                           const char *machineType);
-virQEMUCapsPtr virQEMUCapsCacheLookupByArch(virCapsPtr caps,
-                                            virQEMUCapsCachePtr cache,
+virQEMUCapsPtr virQEMUCapsCacheLookupByArch(virQEMUCapsCachePtr cache,
                                             virArch arch);
 void virQEMUCapsCacheFree(virQEMUCapsCachePtr cache);
 
diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
index 61e7c34d12..5b7d544806 100644
--- a/src/qemu/qemu_capspriv.h
+++ b/src/qemu/qemu_capspriv.h
@@ -28,10 +28,13 @@
 #ifndef __QEMU_CAPSPRIV_H__
 # define __QEMU_CAPSPRIV_H__
 
+# include "virarch.h"
+
 struct _virQEMUCapsCachePriv {
     char *libDir;
     uid_t runUid;
     gid_t runGid;
+    virArch hostArch;
 };
 typedef struct _virQEMUCapsCachePriv virQEMUCapsCachePriv;
 typedef virQEMUCapsCachePriv *virQEMUCapsCachePrivPtr;
@@ -46,14 +49,14 @@ struct _virQEMUCapsCache {
 virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps);
 
 virQEMUCapsPtr
-virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
+virQEMUCapsNewForBinaryInternal(virArch hostArch,
                                 const char *binary,
                                 const char *libDir,
                                 uid_t runUid,
                                 gid_t runGid,
                                 bool qmpOnly);
 
-int virQEMUCapsLoadCache(virCapsPtr caps,
+int virQEMUCapsLoadCache(virArch hostArch,
                          virQEMUCapsPtr qemuCaps,
                          const char *filename);
 char *virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps);
@@ -76,7 +79,7 @@ virQEMUCapsSetVersion(virQEMUCapsPtr qemuCaps,
 
 void
 virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
-                            virCapsPtr caps,
+                            virArch hostArch,
                             virDomainVirtType type);
 
 int
@@ -94,7 +97,7 @@ virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps,
                            qemuMonitorCPUModelInfoPtr modelInfo);
 
 virCPUDefPtr
-virQEMUCapsProbeHostCPUForEmulator(virCapsPtr caps,
+virQEMUCapsProbeHostCPUForEmulator(virArch hostArch,
                                    virQEMUCapsPtr qemuCaps,
                                    virDomainVirtType type) ATTRIBUTE_NOINLINE;
 
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index ede761e6ef..4412ba629a 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2962,8 +2962,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,
     if (qemuCaps) {
         virObjectRef(qemuCaps);
     } else {
-        if (!(qemuCaps = virQEMUCapsCacheLookup(caps,
-                                                driver->qemuCapsCache,
+        if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
                                                 def->emulator)))
             goto cleanup;
     }
@@ -3076,7 +3075,7 @@ qemuDomainDefValidateVideo(const virDomainDef *def)
 
 static int
 qemuDomainDefValidate(const virDomainDef *def,
-                      virCapsPtr caps,
+                      virCapsPtr caps ATTRIBUTE_UNUSED,
                       void *opaque)
 {
     virQEMUDriverPtr driver = opaque;
@@ -3084,8 +3083,7 @@ qemuDomainDefValidate(const virDomainDef *def,
     unsigned int topologycpus;
     int ret = -1;
 
-    if (!(qemuCaps = virQEMUCapsCacheLookup(caps,
-                                            driver->qemuCapsCache,
+    if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
                                             def->emulator)))
         goto cleanup;
 
@@ -3548,7 +3546,7 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
 static int
 qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
                              const virDomainDef *def,
-                             virCapsPtr caps,
+                             virCapsPtr caps ATTRIBUTE_UNUSED,
                              unsigned int parseFlags,
                              void *opaque,
                              void *parseOpaque)
@@ -3561,7 +3559,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
     if (qemuCaps) {
         virObjectRef(qemuCaps);
     } else {
-        qemuCaps = virQEMUCapsCacheLookup(caps, driver->qemuCapsCache,
+        qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
                                           def->emulator);
     }
 
@@ -3681,7 +3679,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
 
 static int
 qemuDomainDefAssignAddresses(virDomainDef *def,
-                             virCapsPtr caps,
+                             virCapsPtr caps ATTRIBUTE_UNUSED,
                              unsigned int parseFlags ATTRIBUTE_UNUSED,
                              void *opaque,
                              void *parseOpaque)
@@ -3694,8 +3692,7 @@ qemuDomainDefAssignAddresses(virDomainDef *def,
     if (qemuCaps) {
         virObjectRef(qemuCaps);
     } else {
-        if (!(qemuCaps = virQEMUCapsCacheLookup(caps,
-                                                driver->qemuCapsCache,
+        if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
                                                 def->emulator)))
             goto cleanup;
     }
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6568def156..c5839e5cb5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15929,7 +15929,7 @@ static virDomainPtr qemuDomainQemuAttach(virConnectPtr conn,
         virAsprintf(&def->name, "attach-pid-%u", pid_value) < 0)
         goto cleanup;
 
-    if (!(qemuCaps = virQEMUCapsCacheLookup(caps, driver->qemuCapsCache,
+    if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
                                             def->emulator)))
         goto cleanup;
 
@@ -18979,8 +18979,7 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
     if (emulatorbin) {
         virArch arch_from_caps;
 
-        if (!(qemuCaps = virQEMUCapsCacheLookup(caps,
-                                                driver->qemuCapsCache,
+        if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
                                                 emulatorbin)))
             goto cleanup;
 
@@ -18999,8 +18998,7 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
             goto cleanup;
         }
     } else {
-        if (!(qemuCaps = virQEMUCapsCacheLookupByArch(caps,
-                                                      driver->qemuCapsCache,
+        if (!(qemuCaps = virQEMUCapsCacheLookupByArch(driver->qemuCapsCache,
                                                       arch)))
             goto cleanup;
 
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 525521aaf0..095c781bd7 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4696,8 +4696,7 @@ qemuProcessInit(virQEMUDriverPtr driver,
 
     VIR_DEBUG("Determining emulator version");
     virObjectUnref(priv->qemuCaps);
-    if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(caps,
-                                                      driver->qemuCapsCache,
+    if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
                                                       vm->def->emulator,
                                                       vm->def->os.machine)))
         goto cleanup;
@@ -6478,8 +6477,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     VIR_DEBUG("Determining emulator version");
     virObjectUnref(priv->qemuCaps);
-    if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(caps,
-                                                      driver->qemuCapsCache,
+    if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
                                                       vm->def->emulator,
                                                       vm->def->os.machine)))
         goto error;
@@ -6863,8 +6861,7 @@ qemuProcessReconnect(void *opaque)
      * caps in the domain status, so re-query them
      */
     if (!priv->qemuCaps &&
-        !(priv->qemuCaps = virQEMUCapsCacheLookupCopy(caps,
-                                                      driver->qemuCapsCache,
+        !(priv->qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
                                                       obj->def->emulator,
                                                       obj->def->os.machine)))
         goto error;
diff --git a/tests/qemucapsprobe.c b/tests/qemucapsprobe.c
index 581ac38465..4b8d6229b4 100644
--- a/tests/qemucapsprobe.c
+++ b/tests/qemucapsprobe.c
@@ -22,6 +22,7 @@
 
 #include "testutils.h"
 #include "internal.h"
+#include "virarch.h"
 #include "virthread.h"
 #include "qemu/qemu_capabilities.h"
 #define __QEMU_CAPSPRIV_H_ALLOW__ 1
@@ -70,7 +71,7 @@ main(int argc, char **argv)
     if (virThreadCreate(&thread, false, eventLoop, NULL) < 0)
         return EXIT_FAILURE;
 
-    if (!(caps = virQEMUCapsNewForBinaryInternal(NULL, argv[1], "/tmp",
+    if (!(caps = virQEMUCapsNewForBinaryInternal(VIR_ARCH_NONE, argv[1], "/tmp",
                                                  -1, -1, true)))
         return EXIT_FAILURE;
 
diff --git a/tests/qemucpumock.c b/tests/qemucpumock.c
index 38827584ea..74dcfa6291 100644
--- a/tests/qemucpumock.c
+++ b/tests/qemucpumock.c
@@ -25,10 +25,11 @@
 #include "qemu/qemu_capspriv.h"
 #undef __QEMU_CAPSPRIV_H_ALLOW__
 #include "testutilshostcpus.h"
+#include "virarch.h"
 
 
 virCPUDefPtr
-virQEMUCapsProbeHostCPUForEmulator(virCapsPtr caps ATTRIBUTE_UNUSED,
+virQEMUCapsProbeHostCPUForEmulator(virArch hostArch ATTRIBUTE_UNUSED,
                                    virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
                                    virDomainVirtType type ATTRIBUTE_UNUSED)
 {
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index b95ea46be0..ef59b364f0 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -377,6 +377,9 @@ testUpdateQEMUCaps(const struct testInfo *info,
 {
     int ret = -1;
 
+    if (!caps)
+        goto cleanup;
+
     virQEMUCapsSetArch(info->qemuCaps, vm->def->os.arch);
 
     virQEMUCapsInitQMPBasicArch(info->qemuCaps);
@@ -389,8 +392,10 @@ testUpdateQEMUCaps(const struct testInfo *info,
     if (testAddCPUModels(info->qemuCaps, info->skipLegacyCPUs) < 0)
         goto cleanup;
 
-    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps, VIR_DOMAIN_VIRT_KVM);
-    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps, VIR_DOMAIN_VIRT_QEMU);
+    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
+                                VIR_DOMAIN_VIRT_KVM);
+    virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
+                                VIR_DOMAIN_VIRT_QEMU);
 
     virQEMUCapsFilterByMachineType(info->qemuCaps, vm->def->os.machine);
 
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 67b21c9893..5766e183df 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -490,8 +490,11 @@ qemuTestParseCapabilities(virCapsPtr caps,
 {
     virQEMUCapsPtr qemuCaps = NULL;
 
+    if (!caps)
+        return NULL;
+
     if (!(qemuCaps = virQEMUCapsNew()) ||
-        virQEMUCapsLoadCache(caps, qemuCaps, capsFile) < 0)
+        virQEMUCapsLoadCache(caps->host.arch, qemuCaps, capsFile) < 0)
         goto error;
 
     return qemuCaps;
-- 
2.13.3


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