1 Star 0 Fork 71

梓瑶/libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
qemuBuildChannelsCommandLine-Extract-common-formatti.patch 3.04 KB
一键复制 编辑 原始数据 按行查看 历史
imxcc 提交于 2022-02-22 00:16 . update patch with openeuler !54
From 31c32f8d76a447899ff4a5c551c06a2888814111 Mon Sep 17 00:00:00 2001
From: Peter Krempa <pkrempa@redhat.com>
Date: Thu, 14 May 2020 12:51:21 +0200
Subject: [PATCH 06/18] qemuBuildChannelsCommandLine: Extract common formatting
of 'chardev'
Both active branches create the same backend chardev. Since there is no
other case, extract it before the switch so that we don't have to
duplicate it.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
src/qemu/qemu_command.c | 32 +++++++++++---------------------
1 file changed, 11 insertions(+), 21 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7c4db11ae2..579e78ea75 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8857,37 +8857,27 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager,
for (i = 0; i < def->nchannels; i++) {
virDomainChrDefPtr channel = def->channels[i];
- char *devstr;
+ g_autofree char *chardevstr = NULL;
+ g_autofree char *netdevstr = NULL;
- switch ((virDomainChrChannelTargetType) channel->targetType) {
- case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD:
- if (!(devstr = qemuBuildChrChardevStr(logManager, secManager,
+ if (!(chardevstr = qemuBuildChrChardevStr(logManager, secManager,
cmd, cfg, def,
channel->source,
channel->info.alias,
qemuCaps, cdevflags)))
- return -1;
- virCommandAddArg(cmd, "-chardev");
- virCommandAddArg(cmd, devstr);
- VIR_FREE(devstr);
+ return -1;
- if (qemuBuildChrDeviceStr(&devstr, def, channel, qemuCaps) < 0)
+ virCommandAddArg(cmd, "-chardev");
+ virCommandAddArg(cmd, chardevstr);
+
+ switch ((virDomainChrChannelTargetType) channel->targetType) {
+ case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD:
+ if (qemuBuildChrDeviceStr(&netdevstr, def, channel, qemuCaps) < 0)
return -1;
- virCommandAddArgList(cmd, "-netdev", devstr, NULL);
- VIR_FREE(devstr);
+ virCommandAddArgList(cmd, "-netdev", netdevstr, NULL);
break;
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO:
- if (!(devstr = qemuBuildChrChardevStr(logManager, secManager,
- cmd, cfg, def,
- channel->source,
- channel->info.alias,
- qemuCaps, cdevflags)))
- return -1;
- virCommandAddArg(cmd, "-chardev");
- virCommandAddArg(cmd, devstr);
- VIR_FREE(devstr);
-
if (qemuBuildChrDeviceCommandLine(cmd, def, channel, qemuCaps) < 0)
return -1;
break;
--
2.23.0.windows.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ziyao233/libvirt.git
git@gitee.com:ziyao233/libvirt.git
ziyao233
libvirt
libvirt
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385