mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
split out qemuAssignDeviceInputAlias
Move assignment of input device alias into a separate function, for reuse on hotplug.
This commit is contained in:
parent
513a8d4588
commit
d059b24aea
@ -412,6 +412,28 @@ qemuAssignDeviceWatchdogAlias(virDomainWatchdogDefPtr watchdog)
|
|||||||
|
|
||||||
if (VIR_STRDUP(watchdog->info.alias, "watchdog0") < 0)
|
if (VIR_STRDUP(watchdog->info.alias, "watchdog0") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuAssignDeviceInputAlias(virDomainDefPtr def,
|
||||||
|
virDomainInputDefPtr input,
|
||||||
|
int idx)
|
||||||
|
{
|
||||||
|
if (idx == -1) {
|
||||||
|
int thisidx;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < def->ninputs; i++) {
|
||||||
|
if ((thisidx = qemuDomainDeviceAliasIndex(&def->inputs[i]->info, "input")) >= idx)
|
||||||
|
idx = thisidx + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virAsprintf(&input->info.alias, "input%d", idx) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,7 +483,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (i = 0; i < def->ninputs; i++) {
|
for (i = 0; i < def->ninputs; i++) {
|
||||||
if (virAsprintf(&def->inputs[i]->info.alias, "input%zu", i) < 0)
|
if (qemuAssignDeviceInputAlias(def, def->inputs[i], i) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (i = 0; i < def->nparallels; i++) {
|
for (i = 0; i < def->nparallels; i++) {
|
||||||
|
@ -67,6 +67,10 @@ int qemuAssignDeviceShmemAlias(virDomainDefPtr def,
|
|||||||
|
|
||||||
int qemuAssignDeviceWatchdogAlias(virDomainWatchdogDefPtr watchdog);
|
int qemuAssignDeviceWatchdogAlias(virDomainWatchdogDefPtr watchdog);
|
||||||
|
|
||||||
|
int qemuAssignDeviceInputAlias(virDomainDefPtr def,
|
||||||
|
virDomainInputDefPtr input,
|
||||||
|
int idx);
|
||||||
|
|
||||||
int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps);
|
int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps);
|
||||||
|
|
||||||
int qemuDomainDeviceAliasIndex(const virDomainDeviceInfo *info,
|
int qemuDomainDeviceAliasIndex(const virDomainDeviceInfo *info,
|
||||||
|
Loading…
Reference in New Issue
Block a user