mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-12 22:51:29 +00:00
qemu: command: Don't format -device isa-fdc,... twice with two floppy drives
Fix regression introduced in <42fd5a58adb>. With q35 machine type which requires the explicitly specified FDC we'd format twoisa-fdc controllers to the command line as the code was moved to a place where it's called per-disk. Move the call back after formatting all disks and reiterate the disks to find the floppy controllers. This also moves the '-global' directive which sets up the default ISA-FDC to the end after all the disks but since we are modifying the properties it is safe to do so. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d61da421ab
commit
b8936d2655
@ -2143,19 +2143,39 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuBuildFloppyCommandLineOptions(virCommandPtr cmd,
|
qemuBuildFloppyCommandLineControllerOptions(virCommandPtr cmd,
|
||||||
const virDomainDef *def,
|
const virDomainDef *def,
|
||||||
virDomainDiskDefPtr disk,
|
|
||||||
virQEMUCapsPtr qemuCaps,
|
virQEMUCapsPtr qemuCaps,
|
||||||
unsigned int bootindex)
|
unsigned int bootFloppy)
|
||||||
{
|
{
|
||||||
virBuffer fdc_opts = VIR_BUFFER_INITIALIZER;
|
virBuffer fdc_opts = VIR_BUFFER_INITIALIZER;
|
||||||
|
bool explicitfdc = qemuDomainNeedsFDC(def);
|
||||||
|
bool hasfloppy = false;
|
||||||
|
unsigned int bootindex;
|
||||||
char driveLetter;
|
char driveLetter;
|
||||||
char *backendAlias = NULL;
|
char *backendAlias = NULL;
|
||||||
char *backendStr = NULL;
|
char *backendStr = NULL;
|
||||||
char *bootindexStr = NULL;
|
char *bootindexStr = NULL;
|
||||||
|
size_t i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
|
virBufferAddLit(&fdc_opts, "isa-fdc,");
|
||||||
|
|
||||||
|
for (i = 0; i < def->ndisks; i++) {
|
||||||
|
virDomainDiskDefPtr disk = def->disks[i];
|
||||||
|
|
||||||
|
if (disk->bus != VIR_DOMAIN_DISK_BUS_FDC)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
hasfloppy = true;
|
||||||
|
|
||||||
|
if (disk->info.bootIndex) {
|
||||||
|
bootindex = disk->info.bootIndex;
|
||||||
|
} else {
|
||||||
|
bootindex = bootFloppy;
|
||||||
|
bootFloppy = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (disk->info.addr.drive.unit)
|
if (disk->info.addr.drive.unit)
|
||||||
driveLetter = 'B';
|
driveLetter = 'B';
|
||||||
else
|
else
|
||||||
@ -2172,7 +2192,7 @@ qemuBuildFloppyCommandLineOptions(virCommandPtr cmd,
|
|||||||
virAsprintf(&bootindexStr, "bootindex%c=%u", driveLetter, bootindex) < 0)
|
virAsprintf(&bootindexStr, "bootindex%c=%u", driveLetter, bootindex) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!qemuDomainNeedsFDC(def)) {
|
if (!explicitfdc) {
|
||||||
if (backendStr) {
|
if (backendStr) {
|
||||||
virCommandAddArg(cmd, "-global");
|
virCommandAddArg(cmd, "-global");
|
||||||
virCommandAddArgFormat(cmd, "isa-fdc.%s", backendStr);
|
virCommandAddArgFormat(cmd, "isa-fdc.%s", backendStr);
|
||||||
@ -2183,10 +2203,17 @@ qemuBuildFloppyCommandLineOptions(virCommandPtr cmd,
|
|||||||
virCommandAddArgFormat(cmd, "isa-fdc.%s", bootindexStr);
|
virCommandAddArgFormat(cmd, "isa-fdc.%s", bootindexStr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Newer Q35 machine types require an explicit FDC controller */
|
|
||||||
virBufferAddLit(&fdc_opts, "isa-fdc,");
|
|
||||||
virBufferStrcat(&fdc_opts, backendStr, ",", NULL);
|
virBufferStrcat(&fdc_opts, backendStr, ",", NULL);
|
||||||
virBufferStrcat(&fdc_opts, bootindexStr, NULL);
|
virBufferStrcat(&fdc_opts, bootindexStr, ",", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
VIR_FREE(backendAlias);
|
||||||
|
VIR_FREE(backendStr);
|
||||||
|
VIR_FREE(bootindexStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (explicitfdc && hasfloppy) {
|
||||||
|
/* Newer Q35 machine types require an explicit FDC controller */
|
||||||
virBufferTrim(&fdc_opts, ",", -1);
|
virBufferTrim(&fdc_opts, ",", -1);
|
||||||
virCommandAddArg(cmd, "-device");
|
virCommandAddArg(cmd, "-device");
|
||||||
virCommandAddArgBuffer(cmd, &fdc_opts);
|
virCommandAddArgBuffer(cmd, &fdc_opts);
|
||||||
@ -2276,11 +2303,7 @@ qemuBuildDiskCommandLine(virCommandPtr cmd,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
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, qemuCaps,
|
|
||||||
bootindex) < 0)
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
virCommandAddArg(cmd, "-device");
|
virCommandAddArg(cmd, "-device");
|
||||||
|
|
||||||
if (!(optstr = qemuBuildDiskDeviceStr(def, disk, bootindex,
|
if (!(optstr = qemuBuildDiskDeviceStr(def, disk, bootindex,
|
||||||
@ -2331,10 +2354,6 @@ qemuBuildDisksCommandLine(virCommandPtr cmd,
|
|||||||
bootindex = bootCD;
|
bootindex = bootCD;
|
||||||
bootCD = 0;
|
bootCD = 0;
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
|
||||||
bootindex = bootFloppy;
|
|
||||||
bootFloppy = 0;
|
|
||||||
break;
|
|
||||||
case VIR_DOMAIN_DISK_DEVICE_DISK:
|
case VIR_DOMAIN_DISK_DEVICE_DISK:
|
||||||
case VIR_DOMAIN_DISK_DEVICE_LUN:
|
case VIR_DOMAIN_DISK_DEVICE_LUN:
|
||||||
bootindex = bootDisk;
|
bootindex = bootDisk;
|
||||||
@ -2348,6 +2367,9 @@ qemuBuildDisksCommandLine(virCommandPtr cmd,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qemuBuildFloppyCommandLineControllerOptions(cmd, def, qemuCaps, bootFloppy) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ readonly=on \
|
|||||||
-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,\
|
-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,\
|
||||||
bootindex=1 \
|
bootindex=1 \
|
||||||
-drive file=/dev/fd0,format=raw,if=none,id=drive-fdc0-0-0 \
|
-drive file=/dev/fd0,format=raw,if=none,id=drive-fdc0-0-0 \
|
||||||
|
-drive file=/dev/fd1,format=raw,if=none,id=drive-fdc0-0-1 \
|
||||||
-global isa-fdc.driveA=drive-fdc0-0-0 \
|
-global isa-fdc.driveA=drive-fdc0-0-0 \
|
||||||
-global isa-fdc.bootindexA=4 \
|
-global isa-fdc.bootindexA=4 \
|
||||||
-drive file=/dev/fd1,format=raw,if=none,id=drive-fdc0-0-1 \
|
|
||||||
-global isa-fdc.driveB=drive-fdc0-0-1 \
|
-global isa-fdc.driveB=drive-fdc0-0-1 \
|
||||||
-netdev user,id=hostnet0 \
|
-netdev user,id=hostnet0 \
|
||||||
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:11,bus=pci.0,\
|
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:11,bus=pci.0,\
|
||||||
|
@ -37,9 +37,9 @@ readonly=on \
|
|||||||
-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,\
|
-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,\
|
||||||
bootindex=1 \
|
bootindex=1 \
|
||||||
-drive file=/dev/fd0,format=raw,if=none,id=drive-fdc0-0-0 \
|
-drive file=/dev/fd0,format=raw,if=none,id=drive-fdc0-0-0 \
|
||||||
|
-drive file=/dev/fd1,format=raw,if=none,id=drive-fdc0-0-1 \
|
||||||
-global isa-fdc.driveA=drive-fdc0-0-0 \
|
-global isa-fdc.driveA=drive-fdc0-0-0 \
|
||||||
-global isa-fdc.bootindexA=4 \
|
-global isa-fdc.bootindexA=4 \
|
||||||
-drive file=/dev/fd1,format=raw,if=none,id=drive-fdc0-0-1 \
|
|
||||||
-global isa-fdc.driveB=drive-fdc0-0-1 \
|
-global isa-fdc.driveB=drive-fdc0-0-1 \
|
||||||
-netdev user,id=hostnet0 \
|
-netdev user,id=hostnet0 \
|
||||||
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:11,bus=pci.0,\
|
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:11,bus=pci.0,\
|
||||||
|
@ -28,9 +28,9 @@ addr=0x1 \
|
|||||||
-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \
|
-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \
|
||||||
-device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \
|
-device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \
|
||||||
-drive file=/tmp/firmware.img,format=raw,if=none,id=drive-fdc0-0-0 \
|
-drive file=/tmp/firmware.img,format=raw,if=none,id=drive-fdc0-0-0 \
|
||||||
|
-drive file=/tmp/data.img,format=qcow2,if=none,id=drive-fdc0-0-1 \
|
||||||
-global isa-fdc.driveA=drive-fdc0-0-0 \
|
-global isa-fdc.driveA=drive-fdc0-0-0 \
|
||||||
-global isa-fdc.bootindexA=1 \
|
-global isa-fdc.bootindexA=1 \
|
||||||
-drive file=/tmp/data.img,format=qcow2,if=none,id=drive-fdc0-0-1 \
|
|
||||||
-global isa-fdc.driveB=drive-fdc0-0-1 \
|
-global isa-fdc.driveB=drive-fdc0-0-1 \
|
||||||
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
||||||
resourcecontrol=deny \
|
resourcecontrol=deny \
|
||||||
|
@ -28,9 +28,8 @@ addr=0x1 \
|
|||||||
-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \
|
-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \
|
||||||
-device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \
|
-device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \
|
||||||
-drive file=/tmp/firmware.img,format=raw,if=none,id=drive-fdc0-0-0 \
|
-drive file=/tmp/firmware.img,format=raw,if=none,id=drive-fdc0-0-0 \
|
||||||
-device isa-fdc,driveA=drive-fdc0-0-0,bootindexA=1 \
|
|
||||||
-drive file=/tmp/data.img,format=qcow2,if=none,id=drive-fdc0-0-1 \
|
-drive file=/tmp/data.img,format=qcow2,if=none,id=drive-fdc0-0-1 \
|
||||||
-device isa-fdc,driveB=drive-fdc0-0-1 \
|
-device isa-fdc,driveA=drive-fdc0-0-0,bootindexA=1,driveB=drive-fdc0-0-1 \
|
||||||
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
||||||
resourcecontrol=deny \
|
resourcecontrol=deny \
|
||||||
-msg timestamp=on
|
-msg timestamp=on
|
||||||
|
@ -25,7 +25,7 @@ server,nowait \
|
|||||||
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\
|
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\
|
||||||
bootindex=1 \
|
bootindex=1 \
|
||||||
-drive file=/dev/fd0,format=raw,if=none,id=drive-fdc0-0-0 \
|
-drive file=/dev/fd0,format=raw,if=none,id=drive-fdc0-0-0 \
|
||||||
-global isa-fdc.driveA=drive-fdc0-0-0 \
|
|
||||||
-drive if=none,id=drive-fdc0-0-1 \
|
-drive if=none,id=drive-fdc0-0-1 \
|
||||||
|
-global isa-fdc.driveA=drive-fdc0-0-0 \
|
||||||
-global isa-fdc.driveB=drive-fdc0-0-1 \
|
-global isa-fdc.driveB=drive-fdc0-0-1 \
|
||||||
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
|
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
|
||||||
|
@ -25,6 +25,6 @@ server,nowait \
|
|||||||
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\
|
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\
|
||||||
bootindex=1 \
|
bootindex=1 \
|
||||||
-drive file=/dev/fd0,format=raw,if=none,id=drive-fdc0-0-0 \
|
-drive file=/dev/fd0,format=raw,if=none,id=drive-fdc0-0-0 \
|
||||||
-global isa-fdc.driveA=drive-fdc0-0-0 \
|
|
||||||
-drive file=/tmp/firmware.img,format=raw,if=none,id=drive-fdc0-0-1 \
|
-drive file=/tmp/firmware.img,format=raw,if=none,id=drive-fdc0-0-1 \
|
||||||
|
-global isa-fdc.driveA=drive-fdc0-0-0 \
|
||||||
-global isa-fdc.driveB=drive-fdc0-0-1
|
-global isa-fdc.driveB=drive-fdc0-0-1
|
||||||
|
@ -27,8 +27,8 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
|
|||||||
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
|
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
|
||||||
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
|
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
|
||||||
-drive file=/dev/fd0,format=raw,if=none,id=drive-fdc0-0-0 \
|
-drive file=/dev/fd0,format=raw,if=none,id=drive-fdc0-0-0 \
|
||||||
-global isa-fdc.driveA=drive-fdc0-0-0 \
|
|
||||||
-drive file=/tmp/firmware.img,format=raw,if=none,id=drive-fdc0-0-1 \
|
-drive file=/tmp/firmware.img,format=raw,if=none,id=drive-fdc0-0-1 \
|
||||||
|
-global isa-fdc.driveA=drive-fdc0-0-0 \
|
||||||
-global isa-fdc.driveB=drive-fdc0-0-1 \
|
-global isa-fdc.driveB=drive-fdc0-0-1 \
|
||||||
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
||||||
resourcecontrol=deny \
|
resourcecontrol=deny \
|
||||||
|
@ -40,7 +40,6 @@ server,nowait \
|
|||||||
-usb \
|
-usb \
|
||||||
-drive file=/var/lib/libvirt/images/fd.img,format=raw,if=none,\
|
-drive file=/var/lib/libvirt/images/fd.img,format=raw,if=none,\
|
||||||
id=drive-ua-myDisk1,cache=none \
|
id=drive-ua-myDisk1,cache=none \
|
||||||
-global isa-fdc.driveA=drive-ua-myDisk1 \
|
|
||||||
-drive file=/var/lib/libvirt/images/gentoo.qcow2,format=qcow2,if=none,\
|
-drive file=/var/lib/libvirt/images/gentoo.qcow2,format=qcow2,if=none,\
|
||||||
id=drive-ua-myDisk2 \
|
id=drive-ua-myDisk2 \
|
||||||
-device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-ua-myDisk2,id=ua-myDisk2,\
|
-device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-ua-myDisk2,id=ua-myDisk2,\
|
||||||
@ -57,6 +56,7 @@ id=ua-myEncryptedDisk1 \
|
|||||||
if=none,id=drive-ua-WhatAnAwesomeCDROM,media=cdrom,readonly=on,cache=none \
|
if=none,id=drive-ua-WhatAnAwesomeCDROM,media=cdrom,readonly=on,cache=none \
|
||||||
-device ide-drive,bus=ide.1,unit=0,drive=drive-ua-WhatAnAwesomeCDROM,\
|
-device ide-drive,bus=ide.1,unit=0,drive=drive-ua-WhatAnAwesomeCDROM,\
|
||||||
id=ua-WhatAnAwesomeCDROM,bootindex=2 \
|
id=ua-WhatAnAwesomeCDROM,bootindex=2 \
|
||||||
|
-global isa-fdc.driveA=drive-ua-myDisk1 \
|
||||||
-netdev tap,fd=3,id=hostua-CheckoutThisNIC,vhost=on,vhostfd=44 \
|
-netdev tap,fd=3,id=hostua-CheckoutThisNIC,vhost=on,vhostfd=44 \
|
||||||
-device virtio-net-pci,netdev=hostua-CheckoutThisNIC,id=ua-CheckoutThisNIC,\
|
-device virtio-net-pci,netdev=hostua-CheckoutThisNIC,id=ua-CheckoutThisNIC,\
|
||||||
mac=52:54:00:d6:c0:0b,bus=pci.0,addr=0x3 \
|
mac=52:54:00:d6:c0:0b,bus=pci.0,addr=0x3 \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user