mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 04:55:18 +00:00
qemuBuildDiskCommandLine: Clarify logic around building -device for disks
For 'SD' disks and floppies in the pre-blockdev era we don't format -device. Extract the logic so that it's more clear and add comments. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
cc4a277db2
commit
10f5ad9b58
@ -2158,20 +2158,26 @@ qemuBuildDiskCommandLine(virCommandPtr cmd,
|
|||||||
if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps) < 0)
|
if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!qemuDiskBusIsSD(disk->bus)) {
|
/* SD cards are currently instantiated via -drive if=sd, so the -device
|
||||||
if (disk->bus != VIR_DOMAIN_DISK_BUS_FDC ||
|
* part must be skipped */
|
||||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
|
if (qemuDiskBusIsSD(disk->bus))
|
||||||
if (qemuCommandAddExtDevice(cmd, &disk->info) < 0)
|
return 0;
|
||||||
return -1;
|
|
||||||
|
|
||||||
virCommandAddArg(cmd, "-device");
|
/* floppy devices are instantiated via -drive ...,if=none and bound to the
|
||||||
|
* controller via -global isa-fdc.driveA/B options in the pre-blockdev era */
|
||||||
|
if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC &&
|
||||||
|
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (!(optstr = qemuBuildDiskDeviceStr(def, disk, bootindex,
|
if (qemuCommandAddExtDevice(cmd, &disk->info) < 0)
|
||||||
qemuCaps)))
|
return -1;
|
||||||
return -1;
|
|
||||||
virCommandAddArg(cmd, optstr);
|
virCommandAddArg(cmd, "-device");
|
||||||
}
|
|
||||||
}
|
if (!(optstr = qemuBuildDiskDeviceStr(def, disk, bootindex,
|
||||||
|
qemuCaps)))
|
||||||
|
return -1;
|
||||||
|
virCommandAddArg(cmd, optstr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user