mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
qemu: alias: prepare qemuAssignDeviceFSAlias for disjunct ranges
Iterate through the array to find the first free index. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
0b2a2e84e4
commit
c172a3733e
@ -336,13 +336,23 @@ qemuAssignDeviceNetAlias(virDomainDef *def,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuAssignDeviceFSAlias(virDomainFSDef *fss,
|
qemuAssignDeviceFSAlias(virDomainDef *def,
|
||||||
int idx)
|
virDomainFSDef *fss)
|
||||||
{
|
{
|
||||||
|
size_t i;
|
||||||
|
int maxidx = 0;
|
||||||
|
|
||||||
if (fss->info.alias)
|
if (fss->info.alias)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fss->info.alias = g_strdup_printf("fs%d", idx);
|
for (i = 0; i < def->nfss; i++) {
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
if ((idx = qemuDomainDeviceAliasIndex(&def->fss[i]->info, "fs")) >= maxidx)
|
||||||
|
maxidx = idx + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fss->info.alias = g_strdup_printf("fs%d", maxidx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,7 +644,7 @@ qemuAssignDeviceAliases(virDomainDef *def, virQEMUCaps *qemuCaps)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < def->nfss; i++) {
|
for (i = 0; i < def->nfss; i++) {
|
||||||
if (qemuAssignDeviceFSAlias(def->fss[i], i) < 0)
|
if (qemuAssignDeviceFSAlias(def, def->fss[i]) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (i = 0; i < def->nsounds; i++) {
|
for (i = 0; i < def->nsounds; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user