提交 b8936d26 编写于 作者: P Peter Krempa

qemu: command: Don't format -device isa-fdc,... twice with two floppy drives

Fix regression introduced in <42fd5a58>. 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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 d61da421
......@@ -2143,50 +2143,77 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
static int
qemuBuildFloppyCommandLineOptions(virCommandPtr cmd,
const virDomainDef *def,
virDomainDiskDefPtr disk,
virQEMUCapsPtr qemuCaps,
unsigned int bootindex)
qemuBuildFloppyCommandLineControllerOptions(virCommandPtr cmd,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps,
unsigned int bootFloppy)
{
virBuffer fdc_opts = VIR_BUFFER_INITIALIZER;
bool explicitfdc = qemuDomainNeedsFDC(def);
bool hasfloppy = false;
unsigned int bootindex;
char driveLetter;
char *backendAlias = NULL;
char *backendStr = NULL;
char *bootindexStr = NULL;
size_t i;
int ret = -1;
if (disk->info.addr.drive.unit)
driveLetter = 'B';
else
driveLetter = 'A';
virBufferAddLit(&fdc_opts, "isa-fdc,");
if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, &backendAlias) < 0)
goto cleanup;
for (i = 0; i < def->ndisks; i++) {
virDomainDiskDefPtr disk = def->disks[i];
if (backendAlias &&
virAsprintf(&backendStr, "drive%c=%s", driveLetter, backendAlias) < 0)
goto cleanup;
if (disk->bus != VIR_DOMAIN_DISK_BUS_FDC)
continue;
if (bootindex &&
virAsprintf(&bootindexStr, "bootindex%c=%u", driveLetter, bootindex) < 0)
goto cleanup;
hasfloppy = true;
if (!qemuDomainNeedsFDC(def)) {
if (backendStr) {
virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "isa-fdc.%s", backendStr);
if (disk->info.bootIndex) {
bootindex = disk->info.bootIndex;
} else {
bootindex = bootFloppy;
bootFloppy = 0;
}
if (bootindexStr) {
virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "isa-fdc.%s", bootindexStr);
if (disk->info.addr.drive.unit)
driveLetter = 'B';
else
driveLetter = 'A';
if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, &backendAlias) < 0)
goto cleanup;
if (backendAlias &&
virAsprintf(&backendStr, "drive%c=%s", driveLetter, backendAlias) < 0)
goto cleanup;
if (bootindex &&
virAsprintf(&bootindexStr, "bootindex%c=%u", driveLetter, bootindex) < 0)
goto cleanup;
if (!explicitfdc) {
if (backendStr) {
virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "isa-fdc.%s", backendStr);
}
if (bootindexStr) {
virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "isa-fdc.%s", bootindexStr);
}
} else {
virBufferStrcat(&fdc_opts, backendStr, ",", NULL);
virBufferStrcat(&fdc_opts, bootindexStr, ",", NULL);
}
} else {
VIR_FREE(backendAlias);
VIR_FREE(backendStr);
VIR_FREE(bootindexStr);
}
if (explicitfdc && hasfloppy) {
/* Newer Q35 machine types require an explicit FDC controller */
virBufferAddLit(&fdc_opts, "isa-fdc,");
virBufferStrcat(&fdc_opts, backendStr, ",", NULL);
virBufferStrcat(&fdc_opts, bootindexStr, NULL);
virBufferTrim(&fdc_opts, ",", -1);
virCommandAddArg(cmd, "-device");
virCommandAddArgBuffer(cmd, &fdc_opts);
......@@ -2276,11 +2303,7 @@ qemuBuildDiskCommandLine(virCommandPtr cmd,
return -1;
if (!qemuDiskBusNeedsDriveArg(disk->bus)) {
if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC) {
if (qemuBuildFloppyCommandLineOptions(cmd, def, disk, qemuCaps,
bootindex) < 0)
return -1;
} else {
if (disk->bus != VIR_DOMAIN_DISK_BUS_FDC) {
virCommandAddArg(cmd, "-device");
if (!(optstr = qemuBuildDiskDeviceStr(def, disk, bootindex,
......@@ -2331,10 +2354,6 @@ qemuBuildDisksCommandLine(virCommandPtr cmd,
bootindex = bootCD;
bootCD = 0;
break;
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
bootindex = bootFloppy;
bootFloppy = 0;
break;
case VIR_DOMAIN_DISK_DEVICE_DISK:
case VIR_DOMAIN_DISK_DEVICE_LUN:
bootindex = bootDisk;
......@@ -2348,6 +2367,9 @@ qemuBuildDisksCommandLine(virCommandPtr cmd,
return -1;
}
if (qemuBuildFloppyCommandLineControllerOptions(cmd, def, qemuCaps, bootFloppy) < 0)
return -1;
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,\
bootindex=1 \
-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.bootindexA=4 \
-drive file=/dev/fd1,format=raw,if=none,id=drive-fdc0-0-1 \
-global isa-fdc.driveB=drive-fdc0-0-1 \
-netdev user,id=hostnet0 \
-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,\
bootindex=1 \
-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.bootindexA=4 \
-drive file=/dev/fd1,format=raw,if=none,id=drive-fdc0-0-1 \
-global isa-fdc.driveB=drive-fdc0-0-1 \
-netdev user,id=hostnet0 \
-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 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/data.img,format=qcow2,if=none,id=drive-fdc0-0-1 \
-global isa-fdc.driveA=drive-fdc0-0-0 \
-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 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=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 qemu-xhci,id=usb,bus=pci.1,addr=0x0 \
-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 \
-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,\
resourcecontrol=deny \
-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,\
bootindex=1 \
-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 \
-global isa-fdc.driveA=drive-fdc0-0-0 \
-global isa-fdc.driveB=drive-fdc0-0-1 \
-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,\
bootindex=1 \
-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 \
-global isa-fdc.driveA=drive-fdc0-0-0 \
-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 \
-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 \
-global isa-fdc.driveA=drive-fdc0-0-0 \
-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 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
resourcecontrol=deny \
......
......@@ -40,7 +40,6 @@ server,nowait \
-usb \
-drive file=/var/lib/libvirt/images/fd.img,format=raw,if=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,\
id=drive-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 \
-device ide-drive,bus=ide.1,unit=0,drive=drive-ua-WhatAnAwesomeCDROM,\
id=ua-WhatAnAwesomeCDROM,bootindex=2 \
-global isa-fdc.driveA=drive-ua-myDisk1 \
-netdev tap,fd=3,id=hostua-CheckoutThisNIC,vhost=on,vhostfd=44 \
-device virtio-net-pci,netdev=hostua-CheckoutThisNIC,id=ua-CheckoutThisNIC,\
mac=52:54:00:d6:c0:0b,bus=pci.0,addr=0x3 \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册