mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
qemuBuildSmartcardCommandLine: Replace qemuBuildSmartcardFindCCIDController
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>
This commit is contained in:
parent
43d48eebf9
commit
b4026d9509
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user