Use the proper backend for the block device both when using -drive and when using -blockdev for disk drives and floppy disks. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_command.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 44ae8dcef7..6e550cf951 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1818,7 +1818,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, virBuffer opt = VIR_BUFFER_INITIALIZER; const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus); const char *contAlias; - char *drivealias; + char *backendAlias = NULL; int controllerModel; if (qemuCheckDiskConfig(disk, qemuCaps) < 0) @@ -2077,10 +2077,14 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISK_SHARE_RW)) virBufferAddLit(&opt, ",share-rw=on"); - if (!(drivealias = qemuAliasDiskDriveFromDisk(disk))) + if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, &backendAlias) < 0) 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)) virBufferAsprintf(&opt, ",bootindex=%u", bootindex); if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKIO)) { @@ -2139,6 +2143,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, return virBufferContentAndReset(&opt); error: + VIR_FREE(backendAlias); virBufferFreeAndReset(&opt); return NULL; } @@ -2148,8 +2153,8 @@ static int qemuBuildFloppyCommandLineOptions(virCommandPtr cmd, const virDomainDef *def, virDomainDiskDefPtr disk, + virQEMUCapsPtr qemuCaps, unsigned int bootindex) - { virBuffer fdc_opts = VIR_BUFFER_INITIALIZER; char driveLetter; @@ -2163,10 +2168,11 @@ qemuBuildFloppyCommandLineOptions(virCommandPtr cmd, else driveLetter = 'A'; - if (!(backendAlias = qemuAliasDiskDriveFromDisk(disk))) - return -1; + if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, &backendAlias) < 0) + goto cleanup; - if (virAsprintf(&backendStr, "drive%c=%s", driveLetter, backendAlias) < 0) + if (backendAlias && + virAsprintf(&backendStr, "drive%c=%s", driveLetter, backendAlias) < 0) goto cleanup; if (bootindex && @@ -2281,7 +2287,7 @@ qemuBuildDiskCommandLine(virCommandPtr cmd, if (!qemuDiskBusNeedsDriveArg(disk->bus)) { if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC) { - if (qemuBuildFloppyCommandLineOptions(cmd, def, disk, + if (qemuBuildFloppyCommandLineOptions(cmd, def, disk, qemuCaps, bootindex) < 0) return -1; } else { -- 2.16.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list