mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-24 04:12:20 +00:00
qemu: command: Refactor logic when formatting -drive
Move all logic depending on whether we are solely formatting -drive (no -device along with it) into one block.
This commit is contained in:
parent
b9dfed787d
commit
55a5d71825
@ -1657,26 +1657,16 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
|
|||||||
virQEMUCapsPtr qemuCaps)
|
virQEMUCapsPtr qemuCaps)
|
||||||
{
|
{
|
||||||
virBuffer opt = VIR_BUFFER_INITIALIZER;
|
virBuffer opt = VIR_BUFFER_INITIALIZER;
|
||||||
bool emitDeviceSyntax = qemuDiskBusNeedsDeviceArg(disk->bus);
|
|
||||||
|
|
||||||
/* if we are using -device this will be checked elsewhere */
|
|
||||||
if (!emitDeviceSyntax &&
|
|
||||||
qemuCheckDiskConfig(disk, qemuCaps) < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (qemuBuildDriveSourceStr(disk, cfg, &opt, qemuCaps) < 0)
|
if (qemuBuildDriveSourceStr(disk, cfg, &opt, qemuCaps) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (emitDeviceSyntax)
|
if (qemuDiskBusNeedsDeviceArg(disk->bus)) {
|
||||||
virBufferAddLit(&opt, "if=none");
|
|
||||||
else
|
|
||||||
virBufferAsprintf(&opt, "if=%s",
|
|
||||||
virDomainDiskQEMUBusTypeToString(disk->bus));
|
|
||||||
|
|
||||||
if (emitDeviceSyntax) {
|
|
||||||
char *drivealias = qemuAliasFromDisk(disk);
|
char *drivealias = qemuAliasFromDisk(disk);
|
||||||
if (!drivealias)
|
if (!drivealias)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
virBufferAddLit(&opt, "if=none");
|
||||||
virBufferAsprintf(&opt, ",id=%s", drivealias);
|
virBufferAsprintf(&opt, ",id=%s", drivealias);
|
||||||
VIR_FREE(drivealias);
|
VIR_FREE(drivealias);
|
||||||
} else {
|
} else {
|
||||||
@ -1687,6 +1677,13 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
|
|||||||
_("unsupported disk type '%s'"), disk->dst);
|
_("unsupported disk type '%s'"), disk->dst);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if we are using -device this will be checked elsewhere */
|
||||||
|
if (qemuCheckDiskConfig(disk, qemuCaps) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
virBufferAsprintf(&opt, "if=%s",
|
||||||
|
virDomainDiskQEMUBusTypeToString(disk->bus));
|
||||||
virBufferAsprintf(&opt, ",index=%d", idx);
|
virBufferAsprintf(&opt, ",index=%d", idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user