mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 13:05:27 +00:00
qemu: Add qemuAssignDeviceShmemAlias and use it
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
a0c99e1a0a
commit
a9996a4599
@ -352,6 +352,36 @@ qemuAssignDeviceMemoryAlias(virDomainDefPtr def,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuAssignDeviceShmemAlias(virDomainDefPtr def,
|
||||
virDomainShmemDefPtr shmem,
|
||||
int idx)
|
||||
{
|
||||
if (idx == -1) {
|
||||
size_t i;
|
||||
idx = 0;
|
||||
for (i = 0; i < def->nshmems; i++) {
|
||||
int thisidx;
|
||||
|
||||
if ((thisidx = qemuDomainDeviceAliasIndex(&def->shmems[i]->info,
|
||||
"shmem")) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Unable to determine device index "
|
||||
"for shmem device"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (thisidx >= idx)
|
||||
idx = thisidx + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (virAsprintf(&shmem->info.alias, "shmem%d", idx) < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
@ -421,7 +451,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < def->nshmems; i++) {
|
||||
if (virAsprintf(&def->shmems[i]->info.alias, "shmem%zu", i) < 0)
|
||||
if (qemuAssignDeviceShmemAlias(def, def->shmems[i], i) < 0)
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < def->nsmartcards; i++) {
|
||||
|
@ -60,6 +60,10 @@ int qemuAssignDeviceRNGAlias(virDomainDefPtr def,
|
||||
int qemuAssignDeviceMemoryAlias(virDomainDefPtr def,
|
||||
virDomainMemoryDefPtr mems);
|
||||
|
||||
int qemuAssignDeviceShmemAlias(virDomainDefPtr def,
|
||||
virDomainShmemDefPtr shmem,
|
||||
int idx);
|
||||
|
||||
int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps);
|
||||
|
||||
int qemuDomainDeviceAliasIndex(const virDomainDeviceInfo *info,
|
||||
|
Loading…
x
Reference in New Issue
Block a user