mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
qemu: command: Split out geometry frontend attribute formatting from -drive
Historically we've formatted a lot of the attributes of a disk (disk geometry, etc) with -drive. Since we use -device now, they should be formatted there. Extract them to a separate function for keeping compatibility with SDcards which still use only -drive. Start this by moving the geometry into a separate function.
This commit is contained in:
parent
3746a38e7b
commit
401ddfa4e8
@ -1623,6 +1623,26 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
|
||||
virBufferPtr buf)
|
||||
{
|
||||
/* generate geometry command string */
|
||||
if (disk->geometry.cylinders > 0 &&
|
||||
disk->geometry.heads > 0 &&
|
||||
disk->geometry.sectors > 0) {
|
||||
virBufferAsprintf(buf, ",cyls=%u,heads=%u,secs=%u",
|
||||
disk->geometry.cylinders,
|
||||
disk->geometry.heads,
|
||||
disk->geometry.sectors);
|
||||
|
||||
if (disk->geometry.trans != VIR_DOMAIN_DISK_TRANS_DEFAULT)
|
||||
virBufferAsprintf(buf, ",trans=%s",
|
||||
virDomainDiskGeometryTransTypeToString(disk->geometry.trans));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
qemuBuildDriveStr(virDomainDiskDefPtr disk,
|
||||
virQEMUDriverConfigPtr cfg,
|
||||
@ -1630,8 +1650,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
virBuffer opt = VIR_BUFFER_INITIALIZER;
|
||||
const char *trans =
|
||||
virDomainDiskGeometryTransTypeToString(disk->geometry.trans);
|
||||
bool emitDeviceSyntax = qemuDiskBusNeedsDeviceArg(disk->bus);
|
||||
|
||||
/* if we are using -device this will be checked elsewhere */
|
||||
@ -1685,19 +1703,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
|
||||
if (disk->src->readonly)
|
||||
virBufferAddLit(&opt, ",readonly=on");
|
||||
|
||||
/* generate geometry command string */
|
||||
if (disk->geometry.cylinders > 0 &&
|
||||
disk->geometry.heads > 0 &&
|
||||
disk->geometry.sectors > 0) {
|
||||
|
||||
virBufferAsprintf(&opt, ",cyls=%u,heads=%u,secs=%u",
|
||||
disk->geometry.cylinders,
|
||||
disk->geometry.heads,
|
||||
disk->geometry.sectors);
|
||||
|
||||
if (disk->geometry.trans != VIR_DOMAIN_DISK_TRANS_DEFAULT)
|
||||
virBufferAsprintf(&opt, ",trans=%s", trans);
|
||||
}
|
||||
qemuBuildDiskFrontendAttributes(disk, &opt);
|
||||
|
||||
if (disk->serial &&
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user