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);
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,
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;
return -1;
}
+ if (qemuBuildFloppyCommandLineControllerOptions(cmd, def, qemuCaps, bootFloppy) < 0)
+ return -1;
+
return 0;
}
-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,\
-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,\
-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 \
-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
-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
-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
-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 \
-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,\
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 \