From: Luyao Huang <lhuang(a)redhat.com>
This function is used to assign an alias for a RNG device. It will be
later reused when hotplugging RNGs.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 13 ++++++++++++-
src/qemu/qemu_command.h | 1 +
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3b6eddc..4447b9b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1025,6 +1025,17 @@ qemuGetNextChrDevIndex(virDomainDefPtr def,
int
+qemuAssignDeviceRNGAlias(virDomainRNGDefPtr rng,
+ size_t idx)
+{
+ if (virAsprintf(&rng->info.alias, "rng%zu", idx) < 0)
+ return -1;
+
+ return 0;
+}
+
+
+int
qemuAssignDeviceChrAlias(virDomainDefPtr def,
virDomainChrDefPtr chr,
ssize_t idx)
@@ -1149,7 +1160,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr
qemuCaps)
return -1;
}
for (i = 0; i < def->nrngs; i++) {
- if (virAsprintf(&def->rngs[i]->info.alias, "rng%zu", i) <
0)
+ if (qemuAssignDeviceRNGAlias(def->rngs[i], i) < 0)
return -1;
}
if (def->tpm) {
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index ae36bd8..d8fea65 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -269,6 +269,7 @@ int qemuAssignDeviceRedirdevAlias(virDomainDefPtr def,
virDomainRedirdevDefPtr r
int qemuAssignDeviceChrAlias(virDomainDefPtr def,
virDomainChrDefPtr chr,
ssize_t idx);
+int qemuAssignDeviceRNGAlias(virDomainRNGDefPtr rng, size_t idx);
int
qemuParseKeywords(const char *str,
--
2.2.2