Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
Reviewed-by: Ján Tomko <jtomko(a)redhat.com>
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>
---
Changes in v2:
- qemuDomainGetVhostUserAlias renamed to qemuDomainGetVhostUserChrAlias
src/qemu/qemu_alias.c | 6 ++++++
src/qemu/qemu_alias.h | 2 ++
src/qemu/qemu_command.c | 8 +++++---
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index b3492d6e85..1c6f04c0ba 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -868,3 +868,9 @@ qemuDomainGetDBusVMStateAlias(void)
{
return "dbus-vmstate0";
}
+
+char *
+qemuDomainGetVhostUserChrAlias(const char *devalias)
+{
+ return g_strdup_printf("chr-vu-%s", devalias);
+}
diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h
index 239747beb1..fc4bdf35fa 100644
--- a/src/qemu/qemu_alias.h
+++ b/src/qemu/qemu_alias.h
@@ -97,3 +97,5 @@ const char *qemuDomainGetManagedPRAlias(void);
char *qemuDomainGetUnmanagedPRAlias(const char *parentalias);
const char *qemuDomainGetDBusVMStateAlias(void);
+
+char *qemuDomainGetVhostUserChrAlias(const char *devalias);
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f742379919..c30e5a6c83 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2174,7 +2174,7 @@ qemuBuildVHostUserFsCommandLine(virCommandPtr cmd,
g_autofree char *chardev_alias = NULL;
g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
- chardev_alias = g_strdup_printf("chr-vu-%s", fs->info.alias);
+ chardev_alias = qemuDomainGetVhostUserChrAlias(fs->info.alias);
virCommandAddArg(cmd, "-chardev");
virBufferAddLit(&opt, "socket");
@@ -4168,9 +4168,10 @@ qemuBuildDeviceVideoStr(const virDomainDef *def,
virBufferAsprintf(&buf, ",max_outputs=%u",
video->heads);
}
} else if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
+ g_autofree char *alias = qemuDomainGetVhostUserChrAlias(video->info.alias);
if (video->heads)
virBufferAsprintf(&buf, ",max_outputs=%u", video->heads);
- virBufferAsprintf(&buf, ",chardev=chr-vu-%s",
video->info.alias);
+ virBufferAsprintf(&buf, ",chardev=%s", alias);
} else if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO) {
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS)) {
if (video->heads)
@@ -4290,6 +4291,7 @@ qemuBuildVhostUserChardevStr(const char *alias,
int *fd,
virCommandPtr cmd)
{
+ g_autofree char *chardev_alias = qemuDomainGetVhostUserChrAlias(alias);
char *chardev = NULL;
if (*fd == -1) {
@@ -4298,7 +4300,7 @@ qemuBuildVhostUserChardevStr(const char *alias,
return NULL;
}
- chardev = g_strdup_printf("socket,id=chr-vu-%s,fd=%d", alias, *fd);
+ chardev = g_strdup_printf("socket,id=%s,fd=%d", chardev_alias, *fd);
virCommandPassFD(cmd, *fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
*fd = -1;
--
2.29.2