qemu: command: Split out formatting of disk source commandline

Further split qemuBuildDiskCommandLine to separate formatting of the
source part.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2018-06-07 12:25:02 +02:00
parent 48c643f47c
commit 35582d1125

View File

@ -2230,6 +2230,31 @@ qemuBuildBlockStorageSourceAttachDataCommandline(virCommandPtr cmd,
}
static int
qemuBuildDiskSourceCommandLine(virCommandPtr cmd,
virDomainDiskDefPtr disk,
virQEMUCapsPtr qemuCaps,
bool driveBoot)
{
qemuBlockStorageSourceAttachDataPtr data = NULL;
int ret = -1;
if (!(data = qemuBuildStorageSourceAttachPrepareDrive(disk, qemuCaps,
driveBoot)))
return -1;
if (qemuBuildStorageSourceAttachPrepareCommon(disk->src, data, qemuCaps) < 0 ||
qemuBuildBlockStorageSourceAttachDataCommandline(cmd, data) < 0)
goto cleanup;
ret = 0;
cleanup:
qemuBlockStorageSourceAttachDataFree(data);
return ret;
}
static int
qemuBuildDiskCommandLine(virCommandPtr cmd,
const virDomainDef *def,
@ -2238,21 +2263,11 @@ qemuBuildDiskCommandLine(virCommandPtr cmd,
unsigned int bootindex,
bool driveBoot)
{
qemuBlockStorageSourceAttachDataPtr data = NULL;
char *optstr;
if (!(data = qemuBuildStorageSourceAttachPrepareDrive(disk, qemuCaps,
driveBoot)))
if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps, driveBoot) < 0)
return -1;
if (qemuBuildStorageSourceAttachPrepareCommon(disk->src, data, qemuCaps) < 0 ||
qemuBuildBlockStorageSourceAttachDataCommandline(cmd, data) < 0) {
qemuBlockStorageSourceAttachDataFree(data);
return -1;
}
qemuBlockStorageSourceAttachDataFree(data);
if (!qemuDiskBusNeedsDriveArg(disk->bus)) {
if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC) {
if (qemuBuildFloppyCommandLineOptions(cmd, def, disk,