Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
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..57b56b9ded 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -868,3 +868,9 @@ qemuDomainGetDBusVMStateAlias(void)
{
return "dbus-vmstate0";
}
+
+char *
+qemuDomainGetVhostUserAlias(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..7c5b1ec929 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 *qemuDomainGetVhostUserAlias(const char *devalias);
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f613aa0201..5101e5d74c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2172,7 +2172,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 = qemuDomainGetVhostUserAlias(fs->info.alias);
virCommandAddArg(cmd, "-chardev");
virBufferAddLit(&opt, "socket");
@@ -4166,9 +4166,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 = qemuDomainGetVhostUserAlias(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)
@@ -4288,6 +4289,7 @@ qemuBuildVhostUserChardevStr(const char *alias,
int *fd,
virCommandPtr cmd)
{
+ g_autofree char *chardev_alias = qemuDomainGetVhostUserAlias(alias);
char *chardev = NULL;
if (*fd == -1) {
@@ -4296,7 +4298,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