]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_capabilities: Put only unique FW images into domcaps
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 12 Sep 2019 11:07:31 +0000 (13:07 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 1 Oct 2019 07:19:23 +0000 (09:19 +0200)
In the domain capabilities XML there are FW image paths printed.
There are two sources for the image paths (in order of
preference):

  1) firmware descriptor files - as returned by
  qemuFirmwareGetSupported()

  2) a compile time list of FW:NRAM pairs which can be overridden
  in qemu.conf

If either of those contains a duplicate FW image path (which is
a valid use case) it is printed twice in the capabilities XML.
While it's technically not a bug, it doesn't look good.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
src/qemu/qemu_capabilities.c

index 2edbb3fdfe417919248d2a35ce2c5879b89a776b..3b50576a2b1d1eddc5f0154e4e15e67a81eb7383 100644 (file)
@@ -5136,12 +5136,22 @@ virQEMUCapsFillDomainLoaderCaps(virDomainCapsLoaderPtr capsLoader,
 
     for (i = 0; i < nfirmwares; i++) {
         const char *filename = firmwares[i]->name;
+        size_t j;
 
         if (!virFileExists(filename)) {
             VIR_DEBUG("loader filename=%s does not exist", filename);
             continue;
         }
 
+        /* Put only unique FW images onto the list */
+        for (j = 0; j < capsLoader->values.nvalues; j++) {
+            if (STREQ(filename, capsLoader->values.values[j]))
+                break;
+        }
+
+        if (j != capsLoader->values.nvalues)
+            continue;
+
         if (VIR_STRDUP(capsLoader->values.values[capsLoader->values.nvalues],
                        filename) < 0)
             return -1;