From nobody Mon Feb 9 07:38:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1533818953794541.1165456917629; Thu, 9 Aug 2018 05:49:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 88D343082A40; Thu, 9 Aug 2018 12:49:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 509CF62929; Thu, 9 Aug 2018 12:49:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 06DB518363F7; Thu, 9 Aug 2018 12:49:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79Cn8e5004723 for ; Thu, 9 Aug 2018 08:49:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 48D742156712; Thu, 9 Aug 2018 12:49:08 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAFCF2156711; Thu, 9 Aug 2018 12:49:07 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 14:48:58 +0200 Message-Id: <0047e59dfb937b22db0c9c6c4b1c10a3d187cf09.1533818732.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 5/6] qemu: command: Don't format -device isa-fdc, ... twice with two floppy drives X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 09 Aug 2018 12:49:12 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Fix regression introduced in 42fd5a58adb. With q35 machine type which requires the explicitly specified FDC we'd format two isa-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 Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_command.c | 100 +++++++++++++----= ---- tests/qemuxml2argvdata/boot-complex-bootindex.args | 2 +- tests/qemuxml2argvdata/boot-complex.args | 2 +- tests/qemuxml2argvdata/boot-strict.args | 2 +- .../disk-floppy-q35-2_11.x86_64-latest.args | 2 +- .../disk-floppy-q35-2_9.x86_64-latest.args | 3 +- tests/qemuxml2argvdata/disk-floppy-tray.args | 2 +- tests/qemuxml2argvdata/disk-floppy.args | 2 +- .../disk-floppy.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/user-aliases.args | 2 +- 10 files changed, 71 insertions(+), 48 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index daf037328f..1169164a39 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2143,50 +2143,78 @@ 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 =3D VIR_BUFFER_INITIALIZER; + bool explicitfdc =3D qemuDomainNeedsFDC(def); + bool hasfloppy =3D false; + unsigned int bootindex; char driveLetter; char *backendAlias =3D NULL; char *backendStr =3D NULL; char *bootindexStr =3D NULL; + size_t i; int ret =3D -1; - if (disk->info.addr.drive.unit) - driveLetter =3D 'B'; - else - driveLetter =3D 'A'; + virBufferAddLit(&fdc_opts, "isa-fdc,"); - if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, &backendAlias) < 0) - goto cleanup; + for (i =3D 0; i < def->ndisks; i++) { + virDomainDiskDefPtr disk =3D def->disks[i]; - if (backendAlias && - virAsprintf(&backendStr, "drive%c=3D%s", driveLetter, backendAlias= ) < 0) - goto cleanup; + if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_FDC) + continue; - if (bootindex && - virAsprintf(&bootindexStr, "bootindex%c=3D%u", driveLetter, bootin= dex) < 0) - goto cleanup; + hasfloppy =3D true; - if (!qemuDomainNeedsFDC(def)) { - if (backendStr) { - virCommandAddArg(cmd, "-global"); - virCommandAddArgFormat(cmd, "isa-fdc.%s", backendStr); - } + if (disk->info.bootIndex) + bootindex =3D disk->info.bootIndex; + else + bootindex =3D bootFloppy; - if (bootindexStr) { - virCommandAddArg(cmd, "-global"); - virCommandAddArgFormat(cmd, "isa-fdc.%s", bootindexStr); + bootFloppy =3D 0; + + if (disk->info.addr.drive.unit) + driveLetter =3D 'B'; + else + driveLetter =3D 'A'; + + if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, &backendAlias) <= 0) + goto cleanup; + + if (backendAlias && + virAsprintf(&backendStr, "drive%c=3D%s", driveLetter, backendA= lias) < 0) + goto cleanup; + + if (bootindex && + virAsprintf(&bootindexStr, "bootindex%c=3D%u", driveLetter, bo= otindex) < 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 +2304,7 @@ qemuBuildDiskCommandLine(virCommandPtr cmd, return -1; if (!qemuDiskBusNeedsDriveArg(disk->bus)) { - if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_FDC) { - if (qemuBuildFloppyCommandLineOptions(cmd, def, disk, qemuCaps, - bootindex) < 0) - return -1; - } else { + if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_FDC) { virCommandAddArg(cmd, "-device"); if (!(optstr =3D qemuBuildDiskDeviceStr(def, disk, bootindex, @@ -2331,10 +2355,6 @@ qemuBuildDisksCommandLine(virCommandPtr cmd, bootindex =3D bootCD; bootCD =3D 0; break; - case VIR_DOMAIN_DISK_DEVICE_FLOPPY: - bootindex =3D bootFloppy; - bootFloppy =3D 0; - break; case VIR_DOMAIN_DISK_DEVICE_DISK: case VIR_DOMAIN_DISK_DEVICE_LUN: bootindex =3D bootDisk; @@ -2348,6 +2368,10 @@ qemuBuildDisksCommandLine(virCommandPtr cmd, return -1; } + if (qemuBuildFloppyCommandLineControllerOptions(cmd, def, qemuCaps, bo= otFloppy) < 0) + return -1; + + return 0; } diff --git a/tests/qemuxml2argvdata/boot-complex-bootindex.args b/tests/qem= uxml2argvdata/boot-complex-bootindex.args index cae9a42c0c..56cefb60a5 100644 --- a/tests/qemuxml2argvdata/boot-complex-bootindex.args +++ b/tests/qemuxml2argvdata/boot-complex-bootindex.args @@ -36,9 +36,9 @@ readonly=3Don \ -device ide-drive,bus=3Dide.1,unit=3D0,drive=3Ddrive-ide0-1-0,id=3Dide0-1-= 0,\ bootindex=3D1 \ -drive file=3D/dev/fd0,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-0 \ +-drive file=3D/dev/fd1,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-1 \ -global isa-fdc.driveA=3Ddrive-fdc0-0-0 \ -global isa-fdc.bootindexA=3D4 \ --drive file=3D/dev/fd1,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-1 \ -global isa-fdc.driveB=3Ddrive-fdc0-0-1 \ -netdev user,id=3Dhostnet0 \ -device virtio-net-pci,netdev=3Dhostnet0,id=3Dnet0,mac=3D00:11:22:33:44:11= ,bus=3Dpci.0,\ diff --git a/tests/qemuxml2argvdata/boot-complex.args b/tests/qemuxml2argvd= ata/boot-complex.args index cae9a42c0c..56cefb60a5 100644 --- a/tests/qemuxml2argvdata/boot-complex.args +++ b/tests/qemuxml2argvdata/boot-complex.args @@ -36,9 +36,9 @@ readonly=3Don \ -device ide-drive,bus=3Dide.1,unit=3D0,drive=3Ddrive-ide0-1-0,id=3Dide0-1-= 0,\ bootindex=3D1 \ -drive file=3D/dev/fd0,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-0 \ +-drive file=3D/dev/fd1,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-1 \ -global isa-fdc.driveA=3Ddrive-fdc0-0-0 \ -global isa-fdc.bootindexA=3D4 \ --drive file=3D/dev/fd1,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-1 \ -global isa-fdc.driveB=3Ddrive-fdc0-0-1 \ -netdev user,id=3Dhostnet0 \ -device virtio-net-pci,netdev=3Dhostnet0,id=3Dnet0,mac=3D00:11:22:33:44:11= ,bus=3Dpci.0,\ diff --git a/tests/qemuxml2argvdata/boot-strict.args b/tests/qemuxml2argvda= ta/boot-strict.args index 11bac4ec79..9dc90454fd 100644 --- a/tests/qemuxml2argvdata/boot-strict.args +++ b/tests/qemuxml2argvdata/boot-strict.args @@ -37,9 +37,9 @@ readonly=3Don \ -device ide-drive,bus=3Dide.1,unit=3D0,drive=3Ddrive-ide0-1-0,id=3Dide0-1-= 0,\ bootindex=3D1 \ -drive file=3D/dev/fd0,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-0 \ +-drive file=3D/dev/fd1,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-1 \ -global isa-fdc.driveA=3Ddrive-fdc0-0-0 \ -global isa-fdc.bootindexA=3D4 \ --drive file=3D/dev/fd1,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-1 \ -global isa-fdc.driveB=3Ddrive-fdc0-0-1 \ -netdev user,id=3Dhostnet0 \ -device virtio-net-pci,netdev=3Dhostnet0,id=3Dnet0,mac=3D00:11:22:33:44:11= ,bus=3Dpci.0,\ diff --git a/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args= b/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args index 3c3d99f1d5..e38f7040ec 100644 --- a/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args @@ -28,9 +28,9 @@ addr=3D0x1 \ -device pcie-root-port,port=3D0x9,chassis=3D2,id=3Dpci.2,bus=3Dpcie.0,addr= =3D0x1.0x1 \ -device qemu-xhci,id=3Dusb,bus=3Dpci.1,addr=3D0x0 \ -drive file=3D/tmp/firmware.img,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-0= \ +-drive file=3D/tmp/data.img,format=3Dqcow2,if=3Dnone,id=3Ddrive-fdc0-0-1 \ -global isa-fdc.driveA=3Ddrive-fdc0-0-0 \ -global isa-fdc.bootindexA=3D1 \ --drive file=3D/tmp/data.img,format=3Dqcow2,if=3Dnone,id=3Ddrive-fdc0-0-1 \ -global isa-fdc.driveB=3Ddrive-fdc0-0-1 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ resourcecontrol=3Ddeny \ diff --git a/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args = b/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args index 69be8616de..e4ece864fe 100644 --- a/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args @@ -28,9 +28,8 @@ addr=3D0x1 \ -device pcie-root-port,port=3D0x9,chassis=3D2,id=3Dpci.2,bus=3Dpcie.0,addr= =3D0x1.0x1 \ -device qemu-xhci,id=3Dusb,bus=3Dpci.1,addr=3D0x0 \ -drive file=3D/tmp/firmware.img,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-0= \ --device isa-fdc,driveA=3Ddrive-fdc0-0-0,bootindexA=3D1 \ -drive file=3D/tmp/data.img,format=3Dqcow2,if=3Dnone,id=3Ddrive-fdc0-0-1 \ --device isa-fdc,driveB=3Ddrive-fdc0-0-1 \ +-device isa-fdc,driveA=3Ddrive-fdc0-0-0,bootindexA=3D1,driveB=3Ddrive-fdc0= -0-1 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ resourcecontrol=3Ddeny \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/disk-floppy-tray.args b/tests/qemuxml2a= rgvdata/disk-floppy-tray.args index d50a01871d..25138661e2 100644 --- a/tests/qemuxml2argvdata/disk-floppy-tray.args +++ b/tests/qemuxml2argvdata/disk-floppy-tray.args @@ -25,7 +25,7 @@ server,nowait \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0,\ bootindex=3D1 \ -drive file=3D/dev/fd0,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-0 \ --global isa-fdc.driveA=3Ddrive-fdc0-0-0 \ -drive if=3Dnone,id=3Ddrive-fdc0-0-1 \ +-global isa-fdc.driveA=3Ddrive-fdc0-0-0 \ -global isa-fdc.driveB=3Ddrive-fdc0-0-1 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/disk-floppy.args b/tests/qemuxml2argvda= ta/disk-floppy.args index 3c3177c510..a7cd66af42 100644 --- a/tests/qemuxml2argvdata/disk-floppy.args +++ b/tests/qemuxml2argvdata/disk-floppy.args @@ -25,6 +25,6 @@ server,nowait \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0,\ bootindex=3D1 \ -drive file=3D/dev/fd0,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-0 \ --global isa-fdc.driveA=3Ddrive-fdc0-0-0 \ -drive file=3D/tmp/firmware.img,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-1= \ +-global isa-fdc.driveA=3Ddrive-fdc0-0-0 \ -global isa-fdc.driveB=3Ddrive-fdc0-0-1 diff --git a/tests/qemuxml2argvdata/disk-floppy.x86_64-latest.args b/tests/= qemuxml2argvdata/disk-floppy.x86_64-latest.args index 302e19b36a..8f10c980c9 100644 --- a/tests/qemuxml2argvdata/disk-floppy.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-floppy.x86_64-latest.args @@ -27,8 +27,8 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ -drive file=3D/dev/fd0,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-0 \ --global isa-fdc.driveA=3Ddrive-fdc0-0-0 \ -drive file=3D/tmp/firmware.img,format=3Draw,if=3Dnone,id=3Ddrive-fdc0-0-1= \ +-global isa-fdc.driveA=3Ddrive-fdc0-0-0 \ -global isa-fdc.driveB=3Ddrive-fdc0-0-1 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ resourcecontrol=3Ddeny \ diff --git a/tests/qemuxml2argvdata/user-aliases.args b/tests/qemuxml2argvd= ata/user-aliases.args index c2d93fb7b7..089a7d8d4b 100644 --- a/tests/qemuxml2argvdata/user-aliases.args +++ b/tests/qemuxml2argvdata/user-aliases.args @@ -40,7 +40,6 @@ server,nowait \ -usb \ -drive file=3D/var/lib/libvirt/images/fd.img,format=3Draw,if=3Dnone,\ id=3Ddrive-ua-myDisk1,cache=3Dnone \ --global isa-fdc.driveA=3Ddrive-ua-myDisk1 \ -drive file=3D/var/lib/libvirt/images/gentoo.qcow2,format=3Dqcow2,if=3Dnon= e,\ id=3Ddrive-ua-myDisk2 \ -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x5,drive=3Ddrive-ua-myDisk2,id= =3Dua-myDisk2,\ @@ -57,6 +56,7 @@ id=3Dua-myEncryptedDisk1 \ if=3Dnone,id=3Ddrive-ua-WhatAnAwesomeCDROM,media=3Dcdrom,readonly=3Don,cac= he=3Dnone \ -device ide-drive,bus=3Dide.1,unit=3D0,drive=3Ddrive-ua-WhatAnAwesomeCDROM= ,\ id=3Dua-WhatAnAwesomeCDROM,bootindex=3D2 \ +-global isa-fdc.driveA=3Ddrive-ua-myDisk1 \ -netdev tap,fd=3D3,id=3Dhostua-CheckoutThisNIC,vhost=3Don,vhostfd=3D44 \ -device virtio-net-pci,netdev=3Dhostua-CheckoutThisNIC,id=3Dua-CheckoutThi= sNIC,\ mac=3D52:54:00:d6:c0:0b,bus=3Dpci.0,addr=3D0x3 \ --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list