From: Peter Krempa Date: Mon, 11 Oct 2021 19:45:25 +0000 (+0200) Subject: qemuBuildFloppyCommandLineControllerOptionsExplicit: Generate via JSON X-Git-Tag: v7.9.0-rc1~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=926864ba453b23286f4a90c5ed57c74ce95d97dc;p=thirdparty%2Flibvirt.git qemuBuildFloppyCommandLineControllerOptionsExplicit: Generate via JSON QEMU declares the bootindex types as: bootindexA= bootindexB= The driveA/driveB parameters were deprecated and removed in qemu-6.0. We'll keep them for compatibility, but they are not used with -blockdev. 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 665cd739ec..3b2f88bcb9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2183,32 +2183,29 @@ qemuBuildFloppyCommandLineControllerOptionsImplicit(virCommand *cmd, } -static void +static int qemuBuildFloppyCommandLineControllerOptionsExplicit(virCommand *cmd, unsigned int bootindexA, unsigned int bootindexB, const char *backendA, - const char *backendB) + const char *backendB, + virQEMUCaps *qemuCaps) { - g_auto(virBuffer) fdc_opts = VIR_BUFFER_INITIALIZER; - - virBufferAddLit(&fdc_opts, "isa-fdc,"); - - if (backendA) - virBufferAsprintf(&fdc_opts, "driveA=%s,", backendA); - - if (bootindexA > 0) - virBufferAsprintf(&fdc_opts, "bootindexA=%u,", bootindexA); + g_autoptr(virJSONValue) props = NULL; - if (backendB) - virBufferAsprintf(&fdc_opts, "driveB=%s,", backendB); + if (virJSONValueObjectCreate(&props, + "s:driver", "isa-fdc", + "S:driveA", backendA, + "p:bootindexA", bootindexA, + "S:driveB", backendB, + "p:bootindexB", bootindexB, + NULL) < 0) + return -1; - if (bootindexB > 0) - virBufferAsprintf(&fdc_opts, "bootindexB=%u,", bootindexB); + if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0) + return -1; - virBufferTrim(&fdc_opts, ","); - virCommandAddArg(cmd, "-device"); - virCommandAddArgBuffer(cmd, &fdc_opts); + return 0; } @@ -2251,11 +2248,13 @@ qemuBuildFloppyCommandLineControllerOptions(virCommand *cmd, return 0; if (qemuDomainNeedsFDC(def)) { - qemuBuildFloppyCommandLineControllerOptionsExplicit(cmd, - bootindexA, - bootindexB, - backendA, - backendB); + if (qemuBuildFloppyCommandLineControllerOptionsExplicit(cmd, + bootindexA, + bootindexB, + backendA, + backendB, + qemuCaps) < 0) + return -1; } else { qemuBuildFloppyCommandLineControllerOptionsImplicit(cmd, bootindexA,