Further split qemuBuildDiskCommandLine to separate formatting of the source part. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_command.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8f5303ed95..48e463c3c9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2231,27 +2231,42 @@ qemuBuildBlockStorageSourceAttachDataCommandline(virCommandPtr cmd, static int -qemuBuildDiskCommandLine(virCommandPtr cmd, - const virDomainDef *def, - virDomainDiskDefPtr disk, - virQEMUCapsPtr qemuCaps, - unsigned int bootindex, - bool driveBoot) +qemuBuildDiskSourceCommandLine(virCommandPtr cmd, + virDomainDiskDefPtr disk, + virQEMUCapsPtr qemuCaps, + bool driveBoot) { qemuBlockStorageSourceAttachDataPtr data = NULL; - char *optstr; + int ret = -1; if (!(data = qemuBuildStorageSourceAttachPrepareDrive(disk, qemuCaps, driveBoot))) return -1; if (qemuBuildStorageSourceAttachPrepareCommon(disk->src, data, qemuCaps) < 0 || - qemuBuildBlockStorageSourceAttachDataCommandline(cmd, data) < 0) { - qemuBlockStorageSourceAttachDataFree(data); - return -1; - } + qemuBuildBlockStorageSourceAttachDataCommandline(cmd, data) < 0) + goto cleanup; + ret = 0; + + cleanup: qemuBlockStorageSourceAttachDataFree(data); + return ret; +} + + +static int +qemuBuildDiskCommandLine(virCommandPtr cmd, + const virDomainDef *def, + virDomainDiskDefPtr disk, + virQEMUCapsPtr qemuCaps, + unsigned int bootindex, + bool driveBoot) +{ + char *optstr; + + if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps, driveBoot) < 0) + return -1; if (!qemuDiskBusNeedsDriveArg(disk->bus)) { if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC) { -- 2.16.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list