From a84fce355e7a2cf8f7146ace54e3165a7b1e45ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Thu, 19 May 2016 19:25:33 +0200 Subject: [PATCH] Do not mask QEMU_CAPS_DEVICE in qemuBuildDriveStr For some disk types (SD), we want to emit the syntax we used for disks before -device was available even if QEMU supports -device. Use the qemuDiskBusNeedsDeviceArg helper to figure out whether to use the old or new syntax. --- src/qemu/qemu_command.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 75bd4b7608..55326c37e0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1106,6 +1106,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, char *source = NULL; int actualType = virStorageSourceGetActualType(disk->src); qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); + bool emitDeviceSyntax = qemuDiskBusNeedsDeviceArg(disk->bus); if (idx < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1246,7 +1247,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, } VIR_FREE(source); - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) + if (emitDeviceSyntax) virBufferAddLit(&opt, "if=none"); else virBufferAsprintf(&opt, "if=%s", bus); @@ -1263,7 +1264,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, } } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { + if (emitDeviceSyntax) { virBufferAsprintf(&opt, ",id=%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias); } else { if (busid == -1 && unitid == -1) { @@ -1916,7 +1917,6 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, char *optstr; unsigned int bootindex = 0; virDomainDiskDefPtr disk = def->disks[i]; - bool deviceFlagMasked = false; /* PowerPC pseries based VMs do not support floppy device */ if ((disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) && @@ -1945,15 +1945,9 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, virCommandAddArg(cmd, "-drive"); - if (!qemuDiskBusNeedsDeviceArg(disk->bus)) { - virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE); - deviceFlagMasked = true; - } optstr = qemuBuildDriveStr(disk, emitBootindex ? false : !!bootindex, qemuCaps); - if (deviceFlagMasked) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE); if (!optstr) return -1; virCommandAddArg(cmd, optstr); -- GitLab