From d38f32cb4eb082e302583b800a6f63a3371724f4 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 18 Oct 2023 09:34:27 +0200 Subject: [PATCH] qemuBuildDriveSourceStr: Absorb only use of qemuDiskSourceGetProps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'qemuBuildDriveSourceStr' used to build the legacy -drive commandline for SD cards is the only user of qemuDiskSourceGetProps. Move the helper directly inline. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_command.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ba21976956..dbef8d0068 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1572,30 +1572,6 @@ qemuDiskBusIsSD(int bus) } -/** - * qemuDiskSourceGetProps: - * @src: disk source struct - * - * Returns the disk source struct wrapped so that it can be used as disk source - * directly by converting it from json. - */ -static virJSONValue * -qemuDiskSourceGetProps(virStorageSource *src) -{ - g_autoptr(virJSONValue) props = NULL; - virJSONValue *ret = NULL; - - if (!(props = qemuBlockStorageSourceGetBackendProps(src, - QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_LEGACY))) - return NULL; - - if (virJSONValueObjectAdd(&ret, "a:file", &props, NULL) < 0) - return NULL; - - return ret; -} - - static int qemuBuildDriveSourceStr(virDomainDiskDef *disk, virBuffer *buf) @@ -1603,7 +1579,6 @@ qemuBuildDriveSourceStr(virDomainDiskDef *disk, virStorageType actualType = virStorageSourceGetActualType(disk->src); qemuDomainStorageSourcePrivate *srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src); qemuDomainSecretInfo **encinfo = NULL; - g_autoptr(virJSONValue) srcprops = NULL; bool rawluks = false; if (srcpriv) @@ -1624,14 +1599,22 @@ qemuBuildDriveSourceStr(virDomainDiskDef *disk, virQEMUBuildBufferEscapeComma(buf, disk->src->path); break; - case VIR_STORAGE_TYPE_NETWORK: - if (!(srcprops = qemuDiskSourceGetProps(disk->src))) + case VIR_STORAGE_TYPE_NETWORK: { + g_autoptr(virJSONValue) props = NULL; + g_autoptr(virJSONValue) wrap = NULL; + + if (!(props = qemuBlockStorageSourceGetBackendProps(disk->src, + QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_LEGACY))) return -1; - if (virQEMUBuildCommandLineJSON(srcprops, buf, NULL, + if (virJSONValueObjectAdd(&wrap, "a:file", &props, NULL) < 0) + return -1; + + if (virQEMUBuildCommandLineJSON(wrap, buf, NULL, virQEMUBuildCommandLineJSONArrayNumbered) < 0) return -1; break; + } case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_NVME: