From ab92e9decb1f0c75e18011dcabb0af841e8047a1 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 1 Oct 2021 22:18:39 +0200 Subject: [PATCH] qemu: command: Introduce JSON variant of qemuBuildRomProps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a JSON variant of the generator 'rom' properties. For convenience both the old and new are for now marked as unused, which will be removed once the conversion is complete. The formatted properties have following types according to QEMU. 'virtio-blk-pci' was used as an example: rombar= - (default: 1) romfile= Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_command.c | 42 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3bacb95090..cbca9d4698 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1133,7 +1133,47 @@ qemuBuildVirtioDevStr(virBuffer *buf, } -static int +static int G_GNUC_UNUSED +qemuBuildRomProps(virJSONValue *props, + virDomainDeviceInfo *info) +{ + const char *romfile = NULL; + int rombar = -1; + + if (info->romenabled == VIR_TRISTATE_BOOL_ABSENT && + info->rombar == VIR_TRISTATE_SWITCH_ABSENT && + !info->romfile) + return 0; + + if (info->romenabled == VIR_TRISTATE_BOOL_NO) { + romfile = ""; + } else { + romfile = info->romfile; + + switch (info->rombar) { + case VIR_TRISTATE_SWITCH_OFF: + rombar = 0; + break; + case VIR_TRISTATE_SWITCH_ON: + rombar = 1; + break; + case VIR_TRISTATE_SWITCH_ABSENT: + case VIR_TRISTATE_SWITCH_LAST: + break; + } + } + + if (virJSONValueObjectAdd(props, + "k:rombar", rombar, + "S:romfile", romfile, + NULL) < 0) + return -1; + + return 0; +} + + +static int G_GNUC_UNUSED qemuBuildRomStr(virBuffer *buf, virDomainDeviceInfo *info) {