libvirt/qemu-command-Generate-commandline-of-masterKey0-secr.patch
yezengruan ab887478b0 update patch with openeuler !58
qemuMonitorJSONSetMigrationParams: Take double pointer for @params
qemuMonitorJSONAddObject: Take double pointer for @props
:qemuMonitorJSONMakeCommandInternal: Clear @arguments when stolen
qemuMonitorAddObject: Fix semantics of @alias
qemuMonitorAddObject: Refactor cleanup
util: json: Replace virJSONValueObjectSteal by virJSONValueObjectRemoveKey
qemu: command: Generate commandline of 'masterKey0' secret via JSON
qemu: command: Generate commandline of 'sev0' sev-guest object via JSON
qemu: command: Generate commandline of iothread objects JSON
qemu: capabilities: Introduce QEMU_CAPS_OBJECT_QAPIFIED
qemu: monitor: Make wrapping of 'props' of 'object-add' optional
qemuMonitorCreateObjectPropsWrap: Open-code in qemuBuildMemoryBackendProps
qemu: monitor: Don't add 'props' wrapper if qemu has QEMU_CAPS_OBJECT_QAPIFIED
qemu: command: Use JSON for QAPIfied -object directly
tests: qemuxml2argv: Validate generation of JSON props for object-add
qemu: capabilities: Enable detection of QEMU_CAPS_OBJECT_QAPIFIED

Signed-off-by: yezengruan <yezengruan@huawei.com>
(cherry picked from commit da25da87c49d1b576b48fd58614ff43833a04f37)
2022-03-24 16:20:58 +08:00

55 lines
2.0 KiB
Diff

From b1e1413077ee5bb9f0f5eed82cf6c629d7df4ebf Mon Sep 17 00:00:00 2001
From: Peter Krempa <pkrempa@redhat.com>
Date: Thu, 26 Nov 2020 19:07:03 +0100
Subject: [PATCH 07/16] qemu: command: Generate commandline of 'masterKey0'
secret via JSON
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
While the 'masterKey0' secret object will never be hotplugged 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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_command.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d5d46c0892..6a861f3c8f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -208,6 +208,7 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
g_autofree char *alias = NULL;
g_autofree char *path = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
+ g_autoptr(virJSONValue) props = NULL;
/* If the -object secret does not exist, then just return. This just
* means the domain won't be able to use a secret master key and is
@@ -229,9 +230,16 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
if (!(path = qemuDomainGetMasterKeyFilePath(priv->libDir)))
return -1;
+ if (qemuMonitorCreateObjectProps(&props, "secret", alias,
+ "s:format", "raw",
+ "s:file", path,
+ NULL) < 0)
+ return -1;
+
+ if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ return -1;
+
virCommandAddArg(cmd, "-object");
- virBufferAsprintf(&buf, "secret,id=%s,format=raw,file=", alias);
- virQEMUBuildBufferEscapeComma(&buf, path);
virCommandAddArgBuffer(cmd, &buf);
return 0;
--
2.27.0