Use the guest architecture to decide whether to format
'aes-key-wrap'/'dea-key-wrap' rather than
QEMU_CAPS_AES_KEY_WRAP/QEMU_CAPS_DEA_KEY_WRAP which were set based on
architecture.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 50 ++++++++++++++++++-----------------------
1 file changed, 22 insertions(+), 28 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 41abecdb05..34ce27bb79 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6534,38 +6534,33 @@ qemuBuildCpuCommandLine(virCommand *cmd,
}
-static bool
-qemuAppendKeyWrapMachineParm(virBuffer *buf, virQEMUCaps *qemuCaps,
- virQEMUCapsFlags flag, const char *pname,
- virTristateSwitch pstate)
+static int
+qemuAppendKeyWrapMachineParms(virBuffer *buf,
+ const virDomainDef *def)
{
- if (pstate != VIR_TRISTATE_SWITCH_ABSENT) {
- if (!virQEMUCapsGet(qemuCaps, flag)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("%s is not available with this QEMU binary"),
pname);
- return false;
- }
+ if (!def->keywrap)
+ return 0;
- virBufferAsprintf(buf, ",%s=%s", pname,
- virTristateSwitchTypeToString(pstate));
- }
+ if (def->keywrap->aes == VIR_TRISTATE_SWITCH_ABSENT &&
+ def->keywrap->dea == VIR_TRISTATE_SWITCH_ABSENT)
+ return 0;
- return true;
-}
+ if (def->os.arch != VIR_ARCH_S390 &&
+ def->os.arch != VIR_ARCH_S390X) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("'aes-key-wrap'/'dea-key-wrap' is not
available on this architecture"));
+ return -1;
+ }
-static bool
-qemuAppendKeyWrapMachineParms(virBuffer *buf, virQEMUCaps *qemuCaps,
- const virDomainKeyWrapDef *keywrap)
-{
- if (!qemuAppendKeyWrapMachineParm(buf, qemuCaps, QEMU_CAPS_AES_KEY_WRAP,
- "aes-key-wrap", keywrap->aes))
- return false;
+ if (def->keywrap->aes != VIR_TRISTATE_SWITCH_ABSENT)
+ virBufferAsprintf(buf, ",aes-key-wrap=%s",
+ virTristateSwitchTypeToString(def->keywrap->aes));
- if (!qemuAppendKeyWrapMachineParm(buf, qemuCaps, QEMU_CAPS_DEA_KEY_WRAP,
- "dea-key-wrap", keywrap->dea))
- return false;
+ if (def->keywrap->dea != VIR_TRISTATE_SWITCH_ABSENT)
+ virBufferAsprintf(buf, ",dea-key-wrap=%s",
+ virTristateSwitchTypeToString(def->keywrap->dea));
- return true;
+ return 0;
}
@@ -6865,8 +6860,7 @@ qemuBuildMachineCommandLine(virCommand *cmd,
*/
virBufferAddLit(&buf, ",usb=off");
- if (def->keywrap &&
- !qemuAppendKeyWrapMachineParms(&buf, qemuCaps, def->keywrap))
+ if (qemuAppendKeyWrapMachineParms(&buf, def) < 0)
return -1;
if (qemuAppendDomainFeaturesMachineParam(&buf, def, qemuCaps) < 0)
--
2.39.2