computing-offload/generic_vdpa/libvirt/qemu_alias-introduce-qemuDomainGetVhostUserAlias-hel.patch
jiangdongxu 79c4324644 add generic_vdpa basecode
Change-Id: I2d302dda68298877c65c99147f5bf22186a59aac
2024-09-19 17:19:46 +08:00

90 lines
3.3 KiB
Diff

From 3c0064480e35b794992cb66ed904d60b5d143d9a Mon Sep 17 00:00:00 2001
From: Luo Yifan <luoyifan_yewu@cmss.chinamobile.com>
Date: Wed, 30 Nov 2022 18:13:36 +0800
Subject: [PATCH 13/24] qemu_alias: introduce qemuDomainGetVhostUserAlias
helper
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
(cherry picked from commit 6799cc3ada6830c5e4beac0cb770671466d7768a)
Signed-off-by: Luo Yifan <luoyifan_yewu@cmss.chinamobile.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 b0ea62af39..cfc6985c5a 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -836,3 +836,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 7bd24f042c..9157008b73 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2633,7 +2633,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");
@@ -4603,9 +4603,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)
@@ -4724,6 +4725,7 @@ qemuBuildVhostUserChardevStr(const char *alias,
int *fd,
virCommandPtr cmd)
{
+ g_autofree char *chardev_alias = qemuDomainGetVhostUserChrAlias(alias);
char *chardev = NULL;
if (*fd == -1) {
@@ -4732,7 +4734,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.27.0