mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: command: use qemuDomainDiskGetBackendAlias in commandline building
Use the proper backend for the block device both when using -drive and when -blockdev will be used for disk drives and floppy disks. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
8abbc72bd2
commit
f78033c4f2
@ -1821,7 +1821,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
|
|||||||
virBuffer opt = VIR_BUFFER_INITIALIZER;
|
virBuffer opt = VIR_BUFFER_INITIALIZER;
|
||||||
const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
|
const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
|
||||||
const char *contAlias;
|
const char *contAlias;
|
||||||
char *drivealias;
|
char *backendAlias = NULL;
|
||||||
int controllerModel;
|
int controllerModel;
|
||||||
|
|
||||||
if (qemuCheckDiskConfig(disk, qemuCaps) < 0)
|
if (qemuCheckDiskConfig(disk, qemuCaps) < 0)
|
||||||
@ -2080,10 +2080,14 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
|
|||||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISK_SHARE_RW))
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISK_SHARE_RW))
|
||||||
virBufferAddLit(&opt, ",share-rw=on");
|
virBufferAddLit(&opt, ",share-rw=on");
|
||||||
|
|
||||||
if (!(drivealias = qemuAliasDiskDriveFromDisk(disk)))
|
if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, &backendAlias) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
virBufferAsprintf(&opt, ",drive=%s,id=%s", drivealias, disk->info.alias);
|
|
||||||
VIR_FREE(drivealias);
|
if (backendAlias)
|
||||||
|
virBufferAsprintf(&opt, ",drive=%s", backendAlias);
|
||||||
|
VIR_FREE(backendAlias);
|
||||||
|
|
||||||
|
virBufferAsprintf(&opt, ",id=%s", disk->info.alias);
|
||||||
if (bootindex && virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX))
|
if (bootindex && virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX))
|
||||||
virBufferAsprintf(&opt, ",bootindex=%u", bootindex);
|
virBufferAsprintf(&opt, ",bootindex=%u", bootindex);
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKIO)) {
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKIO)) {
|
||||||
@ -2142,6 +2146,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
|
|||||||
return virBufferContentAndReset(&opt);
|
return virBufferContentAndReset(&opt);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
VIR_FREE(backendAlias);
|
||||||
virBufferFreeAndReset(&opt);
|
virBufferFreeAndReset(&opt);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2151,8 +2156,8 @@ static int
|
|||||||
qemuBuildFloppyCommandLineOptions(virCommandPtr cmd,
|
qemuBuildFloppyCommandLineOptions(virCommandPtr cmd,
|
||||||
const virDomainDef *def,
|
const virDomainDef *def,
|
||||||
virDomainDiskDefPtr disk,
|
virDomainDiskDefPtr disk,
|
||||||
|
virQEMUCapsPtr qemuCaps,
|
||||||
unsigned int bootindex)
|
unsigned int bootindex)
|
||||||
|
|
||||||
{
|
{
|
||||||
virBuffer fdc_opts = VIR_BUFFER_INITIALIZER;
|
virBuffer fdc_opts = VIR_BUFFER_INITIALIZER;
|
||||||
char driveLetter;
|
char driveLetter;
|
||||||
@ -2166,10 +2171,11 @@ qemuBuildFloppyCommandLineOptions(virCommandPtr cmd,
|
|||||||
else
|
else
|
||||||
driveLetter = 'A';
|
driveLetter = 'A';
|
||||||
|
|
||||||
if (!(backendAlias = qemuAliasDiskDriveFromDisk(disk)))
|
if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, &backendAlias) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
if (virAsprintf(&backendStr, "drive%c=%s", driveLetter, backendAlias) < 0)
|
if (backendAlias &&
|
||||||
|
virAsprintf(&backendStr, "drive%c=%s", driveLetter, backendAlias) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (bootindex &&
|
if (bootindex &&
|
||||||
@ -2284,7 +2290,7 @@ qemuBuildDiskCommandLine(virCommandPtr cmd,
|
|||||||
|
|
||||||
if (!qemuDiskBusNeedsDriveArg(disk->bus)) {
|
if (!qemuDiskBusNeedsDriveArg(disk->bus)) {
|
||||||
if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC) {
|
if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC) {
|
||||||
if (qemuBuildFloppyCommandLineOptions(cmd, def, disk,
|
if (qemuBuildFloppyCommandLineOptions(cmd, def, disk, qemuCaps,
|
||||||
bootindex) < 0)
|
bootindex) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user