Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/qemu/qemu_alias.c | 32 +++++++++++++++++++++++++++++++-
src/qemu/qemu_alias.h | 4 ++++
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index 9094f3b137ef..cc83fec26862 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -353,6 +353,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)
{
size_t i;
@@ -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++) {
diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h
index c366d28afc47..11d9fde2ccc2 100644
--- a/src/qemu/qemu_alias.h
+++ b/src/qemu/qemu_alias.h
@@ -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,
--
2.10.0