代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/libvirt 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 2626cba5134d81501f0fcc138c0f6d3427f7656e Mon Sep 17 00:00:00 2001
From: Yan Wang <[email protected]>
Date: Thu, 24 Mar 2022 12:37:24 +0800
Subject: [PATCH 08/16] qemu: command: Generate commandline of 'sev0' sev-guest
object via JSON MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
While the 'sev0' sev-guest object will never be hotplugged, but we want
to generate it through JSON so that we'll be able to validate all
parameters of '-object' against the QAPI schema once 'object-add' is
qapified in qemu.
Signed-off-by: Peter Krempa <[email protected]>
Reviewed-by: Ján Tomko <[email protected]>
Signed-off-by: Yan Wang <[email protected]>
---
src/qemu/qemu_command.c | 32 +++++++++++--------
.../launch-security-sev.x86_64-2.12.0.args | 2 +-
2 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 6a861f3c8f..4ec661e4b5 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9392,9 +9392,11 @@ static int
qemuBuildSEVCommandLine(virDomainObjPtr vm, virCommandPtr cmd,
virDomainSEVDefPtr sev)
{
+ g_autoptr(virJSONValue) props = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
qemuDomainObjPrivatePtr priv = vm->privateData;
- char *path = NULL;
+ g_autofree char *dhpath = NULL;
+ g_autofree char *sessionpath = NULL;
if (!sev)
return 0;
@@ -9402,21 +9404,23 @@ qemuBuildSEVCommandLine(virDomainObjPtr vm, virCommandPtr cmd,
VIR_DEBUG("policy=0x%x cbitpos=%d reduced_phys_bits=%d",
sev->policy, sev->cbitpos, sev->reduced_phys_bits);
- virBufferAsprintf(&buf, "sev-guest,id=sev0,cbitpos=%d", sev->cbitpos);
- virBufferAsprintf(&buf, ",reduced-phys-bits=%d", sev->reduced_phys_bits);
- virBufferAsprintf(&buf, ",policy=0x%x", sev->policy);
+ if (sev->dh_cert)
+ dhpath = g_strdup_printf("%s/dh_cert.base64", priv->libDir);
- if (sev->dh_cert) {
- path = g_strdup_printf("%s/dh_cert.base64", priv->libDir);
- virBufferAsprintf(&buf, ",dh-cert-file=%s", path);
- VIR_FREE(path);
- }
+ if (sev->session)
+ sessionpath = g_strdup_printf("%s/session.base64", priv->libDir);
- if (sev->session) {
- path = g_strdup_printf("%s/session.base64", priv->libDir);
- virBufferAsprintf(&buf, ",session-file=%s", path);
- VIR_FREE(path);
- }
+ if (qemuMonitorCreateObjectProps(&props, "sev-guest", "sev0",
+ "u:cbitpos", sev->cbitpos,
+ "u:reduced-phys-bits", sev->reduced_phys_bits,
+ "u:policy", sev->policy,
+ "S:dh-cert-file", dhpath,
+ "S:session-file", sessionpath,
+ NULL) < 0)
+ return -1;
+
+ if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ return -1;
virCommandAddArg(cmd, "-object");
virCommandAddArgBuffer(cmd, &buf);
diff --git a/tests/qemuxml2argvdata/launch-security-sev.x86_64-2.12.0.args b/tests/qemuxml2argvdata/launch-security-sev.x86_64-2.12.0.args
index 378c3b681c..9fad85737a 100644
--- a/tests/qemuxml2argvdata/launch-security-sev.x86_64-2.12.0.args
+++ b/tests/qemuxml2argvdata/launch-security-sev.x86_64-2.12.0.args
@@ -29,7 +29,7 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--object sev-guest,id=sev0,cbitpos=47,reduced-phys-bits=1,policy=0x1,\
+-object sev-guest,id=sev0,cbitpos=47,reduced-phys-bits=1,policy=1,\
dh-cert-file=/tmp/lib/domain--1-QEMUGuest1/dh_cert.base64,\
session-file=/tmp/lib/domain--1-QEMUGuest1/session.base64 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。