]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuBuildSmartcardCommandLine: Replace qemuBuildSmartcardFindCCIDController
authorPeter Krempa <pkrempa@redhat.com>
Mon, 11 Oct 2021 15:01:53 +0000 (17:01 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 12 Oct 2021 18:54:53 +0000 (20:54 +0200)
We have a commonly used helper virDomainControllerAliasFind, which does
the same thing and also reports errors internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_command.c

index 2d7a6ebde7d9d13525e723a4a03f96dc81cba7bc..e41c7dfaaa81b45c41e3133d8f4b7a76dee41d88 100644 (file)
@@ -9048,32 +9048,6 @@ qemuBuildNetCommandLine(virQEMUDriver *driver,
 }
 
 
-static const char *
-qemuBuildSmartcardFindCCIDController(const virDomainDef *def,
-                                     const virDomainSmartcardDef *smartcard)
-{
-    size_t i;
-
-    /* Should never happen. But doesn't hurt to check. */
-    if (smartcard->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID)
-        return NULL;
-
-    for (i = 0; i < def->ncontrollers; i++) {
-        const virDomainControllerDef *tmp = def->controllers[i];
-
-        if (tmp->type != VIR_DOMAIN_CONTROLLER_TYPE_CCID)
-            continue;
-
-        if (tmp->idx != smartcard->info.addr.ccid.controller)
-            continue;
-
-        return tmp->info.alias;
-    }
-
-    return NULL;
-}
-
-
 static int
 qemuBuildSmartcardCommandLine(virLogManager *logManager,
                               virSecurityManager *secManager,
@@ -9152,13 +9126,10 @@ qemuBuildSmartcardCommandLine(virLogManager *logManager,
         return -1;
     }
 
-    if (!(contAlias = qemuBuildSmartcardFindCCIDController(def,
-                                                           smartcard))) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Unable to find controller for %s"),
-                       smartcard->info.alias);
+    if (!(contAlias = virDomainControllerAliasFind(def,
+                                                   VIR_DOMAIN_CONTROLLER_TYPE_CCID,
+                                                   smartcard->info.addr.ccid.controller)))
         return -1;
-    }
 
     virCommandAddArg(cmd, "-device");
     virBufferAsprintf(&opt, ",id=%s,bus=%s.0", smartcard->info.alias, contAlias);