From: Peter Krempa Date: Fri, 1 Oct 2021 20:18:39 +0000 (+0200) Subject: qemu: command: Introduce JSON variant of qemuBuildRomProps X-Git-Tag: v7.9.0-rc1~178 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab92e9decb1f0c75e18011dcabb0af841e8047a1;p=thirdparty%2Flibvirt.git qemu: command: Introduce JSON variant of qemuBuildRomProps 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 --- 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) {