From nobody Fri May 10 03:20:43 2024 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 1530520006795198.21774631630296; Mon, 2 Jul 2018 01:26:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50E21307D85F; Mon, 2 Jul 2018 08:26:45 +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 84894608E0; Mon, 2 Jul 2018 08:26:43 +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 C9F3118037ED; Mon, 2 Jul 2018 08:26:41 +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 w628Qeao025624 for ; Mon, 2 Jul 2018 04:26:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9CF3D215688A; Mon, 2 Jul 2018 08:26:40 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEA342166B5D; Mon, 2 Jul 2018 08:26:39 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 2 Jul 2018 09:26:38 +0100 Message-Id: <20180702082638.29844-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] qemu: format serial and geometry on frontend disk device 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: , Content-Type: text/plain; charset="utf-8" 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 02 Jul 2018 08:26:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Currently we format the serial, geometry and error policy on the -drive backend argument. QEMU added the ability to set serial and geometry on the frontend in the 1.2 release deprecating use of -drive, with support being deleted from -drive in 3.0. We keep formatting error policy on -drive for now, because we don't ahve support for that with -device for usb-storage just yet. Note that some disk buses (sd) still don't support -device. Although QEMU allowed these properties to be set on -drive for if=3Dsd, they have been ignored so we now report an error in this case. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_command.c | 26 +++++++++++++++---- .../disk-drive-network-tlsx509.args | 12 ++++----- .../disk-drive-network-vxhs.args | 4 +-- tests/qemuxml2argvdata/disk-drive-shared.args | 5 ++-- tests/qemuxml2argvdata/disk-geometry.args | 6 ++--- tests/qemuxml2argvdata/disk-ide-wwn.args | 5 ++-- .../qemuxml2argvdata/disk-scsi-disk-wwn.args | 4 +-- tests/qemuxml2argvdata/disk-serial.args | 10 +++---- tests/qemuxml2argvdata/disk-serial.xml | 1 - tests/qemuxml2xmloutdata/disk-serial.xml | 1 - 10 files changed, 44 insertions(+), 30 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 4fc3176ad3..86d4b10f74 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1621,8 +1621,6 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr d= isk, virBufferAddLit(buf, ",serial=3D"); virBufferEscape(buf, '\\', " ", "%s", disk->serial); } - - qemuBuildDiskFrontendAttributeErrorPolicy(disk, buf); } =20 =20 @@ -1662,11 +1660,27 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virBufferAsprintf(&opt, "if=3D%s", virDomainDiskQEMUBusTypeToString(disk->bus)); virBufferAsprintf(&opt, ",index=3D%d", idx); + + if (disk->serial) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Serial property not supported for drive bus = '%s'"), + virDomainDiskBusTypeToString(disk->bus)); + goto error; + } + if (disk->geometry.cylinders > 0 && + disk->geometry.heads > 0 && + disk->geometry.sectors > 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Geometry not supported for drive bus '%s'"), + virDomainDiskBusTypeToString(disk->bus)); + goto error; + } } =20 - /* Format attributes for the drive itself (not the storage backing it)= which - * we've formatted historically with -drive */ - qemuBuildDiskFrontendAttributes(disk, &opt); + /* werror/rerror are really frontend attributes, but older + * qemu requires them on -drive instead of -device */ + qemuBuildDiskFrontendAttributeErrorPolicy(disk, &opt); + =20 /* While this is a frontend attribute, it only makes sense to be used = when * legacy -drive is used. In modern qemu the 'ide-cd' or 'scsi-cd' are= used. @@ -2125,6 +2139,8 @@ qemuBuildDriveDevStr(const virDomainDef *def, if (qemuBuildDriveDevCacheStr(disk, &opt, qemuCaps) < 0) goto error; =20 + qemuBuildDiskFrontendAttributes(disk, &opt); + if (virBufferCheckError(&opt) < 0) goto error; =20 diff --git a/tests/qemuxml2argvdata/disk-drive-network-tlsx509.args b/tests= /qemuxml2argvdata/disk-drive-network-tlsx509.args index e25f45742c..b5e73064c0 100644 --- a/tests/qemuxml2argvdata/disk-drive-network-tlsx509.args +++ b/tests/qemuxml2argvdata/disk-drive-network-tlsx509.args @@ -28,22 +28,22 @@ server,nowait \ -drive file.driver=3Dvxhs,file.tls-creds=3Dobjvirtio-disk0_tls0,\ file.vdisk-id=3Deb90327c-8302-4725-9e1b-4e85ed4dc251,\ file.server.host=3D192.168.0.1,file.server.port=3D9999,format=3Draw,if=3Dn= one,\ -id=3Ddrive-virtio-disk0,serial=3Deb90327c-8302-4725-9e1b-4e85ed4dc251,cach= e=3Dnone \ +id=3Ddrive-virtio-disk0,cache=3Dnone \ -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x4,drive=3Ddrive-virtio-disk0,\ -id=3Dvirtio-disk0 \ +id=3Dvirtio-disk0,serial=3Deb90327c-8302-4725-9e1b-4e85ed4dc251 \ -object tls-creds-x509,id=3Dobjvirtio-disk1_tls0,dir=3D/etc/pki/libvirt-vx= hs/dummy,\ ,path,endpoint=3Dclient,verify-peer=3Dyes \ -drive file.driver=3Dvxhs,file.tls-creds=3Dobjvirtio-disk1_tls0,\ file.vdisk-id=3Deb90327c-8302-4725-9e1b-4e85ed4dc252,\ file.server.host=3D192.168.0.2,file.server.port=3D9999,format=3Draw,if=3Dn= one,\ -id=3Ddrive-virtio-disk1,serial=3Deb90327c-8302-4725-9e1b-4e85ed4dc252,cach= e=3Dnone \ +id=3Ddrive-virtio-disk1,cache=3Dnone \ -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x5,drive=3Ddrive-virtio-disk1,\ -id=3Dvirtio-disk1 \ +id=3Dvirtio-disk1,serial=3Deb90327c-8302-4725-9e1b-4e85ed4dc252 \ -drive file.driver=3Dvxhs,file.vdisk-id=3Deb90327c-8302-4725-9e1b-4e85ed4d= c253,\ file.server.host=3D192.168.0.3,file.server.port=3D9999,format=3Draw,if=3Dn= one,\ -id=3Ddrive-virtio-disk2,serial=3Deb90327c-8302-4725-9e1b-4e85ed4dc252,cach= e=3Dnone \ +id=3Ddrive-virtio-disk2,cache=3Dnone \ -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x6,drive=3Ddrive-virtio-disk2,\ -id=3Dvirtio-disk2 \ +id=3Dvirtio-disk2,serial=3Deb90327c-8302-4725-9e1b-4e85ed4dc252 \ -object tls-creds-x509,id=3Dobjvirtio-disk3_tls0,dir=3D/etc/pki/libvirt-nb= d/dummy,,\ path,endpoint=3Dclient,verify-peer=3Dyes \ -drive file.driver=3Dnbd,file.server.type=3Dinet,file.server.host=3Dexampl= e.com,\ diff --git a/tests/qemuxml2argvdata/disk-drive-network-vxhs.args b/tests/qe= muxml2argvdata/disk-drive-network-vxhs.args index c2a1d4681f..fad4dfd942 100644 --- a/tests/qemuxml2argvdata/disk-drive-network-vxhs.args +++ b/tests/qemuxml2argvdata/disk-drive-network-vxhs.args @@ -25,6 +25,6 @@ server,nowait \ -usb \ -drive file.driver=3Dvxhs,file.vdisk-id=3Deb90327c-8302-4725-9e1b-4e85ed4d= c251,\ file.server.host=3D192.168.0.1,file.server.port=3D9999,format=3Draw,if=3Dn= one,\ -id=3Ddrive-virtio-disk0,serial=3Deb90327c-8302-4725-9e1b-4e85ed4dc251,cach= e=3Dnone \ +id=3Ddrive-virtio-disk0,cache=3Dnone \ -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x4,drive=3Ddrive-virtio-disk0,\ -id=3Dvirtio-disk0 +id=3Dvirtio-disk0,serial=3Deb90327c-8302-4725-9e1b-4e85ed4dc251 diff --git a/tests/qemuxml2argvdata/disk-drive-shared.args b/tests/qemuxml2= argvdata/disk-drive-shared.args index 5306fdf750..032e86e291 100644 --- a/tests/qemuxml2argvdata/disk-drive-shared.args +++ b/tests/qemuxml2argvdata/disk-drive-shared.args @@ -23,8 +23,9 @@ server,nowait \ -boot c \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0,\ -serial=3DXYZXYZXYZYXXYZYZYXYZY,cache=3Dnone \ --device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ +cache=3Dnone \ +-device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0,\ +serial=3DXYZXYZXYZYXXYZYZYXYZY \ -drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-1-0,\ media=3Dcdrom,readonly=3Don \ -device ide-drive,bus=3Dide.1,unit=3D0,drive=3Ddrive-ide0-1-0,id=3Dide0-1-= 0 \ diff --git a/tests/qemuxml2argvdata/disk-geometry.args b/tests/qemuxml2argv= data/disk-geometry.args index b173ab6407..db0c7fb561 100644 --- a/tests/qemuxml2argvdata/disk-geometry.args +++ b/tests/qemuxml2argvdata/disk-geometry.args @@ -22,7 +22,7 @@ server,nowait \ -no-acpi \ -boot c \ -usb \ --drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0,\ -cyls=3D16383,heads=3D16,secs=3D63,trans=3Dlba \ --device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ +-drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ +-device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0,cyls=3D16383,\ +heads=3D16,secs=3D63,trans=3Dlba \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/disk-ide-wwn.args b/tests/qemuxml2argvd= ata/disk-ide-wwn.args index e6d2758ec3..a0e3f06b68 100644 --- a/tests/qemuxml2argvdata/disk-ide-wwn.args +++ b/tests/qemuxml2argvdata/disk-ide-wwn.args @@ -22,8 +22,7 @@ server,nowait \ -no-acpi \ -boot c \ -usb \ --drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-1,\ -serial=3DWD-WMAP9A966149 \ +-drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-1 \ -device ide-hd,bus=3Dide.0,unit=3D1,drive=3Ddrive-ide0-0-1,id=3Dide0-0-1,\ -wwn=3D0x5000c50015ea71ad \ +wwn=3D0x5000c50015ea71ad,serial=3DWD-WMAP9A966149 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/disk-scsi-disk-wwn.args b/tests/qemuxml= 2argvdata/disk-scsi-disk-wwn.args index 29607e8927..6407fd002d 100644 --- a/tests/qemuxml2argvdata/disk-scsi-disk-wwn.args +++ b/tests/qemuxml2argvdata/disk-scsi-disk-wwn.args @@ -25,9 +25,9 @@ server,nowait \ -device lsi,id=3Dscsi1,bus=3Dpci.0,addr=3D0x4 \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-scs= i0-0-1-0,\ -serial=3DWD-WMAP9A966149,readonly=3Don \ +readonly=3Don \ -device scsi-cd,bus=3Dscsi0.0,channel=3D0,scsi-id=3D1,lun=3D0,drive=3Ddriv= e-scsi0-0-1-0,\ -id=3Dscsi0-0-1-0,wwn=3D0x5000c50015ea71ac \ +id=3Dscsi0-0-1-0,wwn=3D0x5000c50015ea71ac,serial=3DWD-WMAP9A966149 \ -drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,id=3Ddrive-scs= i0-0-0-0 \ -device scsi-hd,bus=3Dscsi0.0,channel=3D0,scsi-id=3D0,lun=3D0,drive=3Ddriv= e-scsi0-0-0-0,\ id=3Dscsi0-0-0-0,wwn=3D0x5000c50015ea71ad \ diff --git a/tests/qemuxml2argvdata/disk-serial.args b/tests/qemuxml2argvda= ta/disk-serial.args index 88310b009f..5892f64c29 100644 --- a/tests/qemuxml2argvdata/disk-serial.args +++ b/tests/qemuxml2argvdata/disk-serial.args @@ -22,11 +22,11 @@ server,nowait \ -no-acpi \ -boot c \ -usb \ --drive 'file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-id= e0-0-1,\ +-drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-1 \ +-device 'ide-drive,bus=3Dide.0,unit=3D1,drive=3Ddrive-ide0-0-1,id=3Dide0-0= -1,\ serial=3D\ \ WD-WMAP9A966149' \ --device ide-drive,bus=3Dide.0,unit=3D1,drive=3Ddrive-ide0-0-1,id=3Dide0-0-= 1 \ --drive 'file=3D/dev/HostVG/AllSerialChars,format=3Draw,if=3Dnone,id=3Ddriv= e-ide0-0-2,\ +-drive file=3D/dev/HostVG/AllSerialChars,format=3Draw,if=3Dnone,id=3Ddrive= -ide0-0-2 \ +-device 'ide-drive,bus=3Dide.0,unit=3D2,drive=3Ddrive-ide0-0-2,id=3Dide0-0= -2,\ serial=3DabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_\= .+' \ --device ide-drive,bus=3Dide.0,unit=3D2,drive=3Ddrive-ide0-0-2,id=3Dide0-0-= 2 \ --drive file=3D/some/file,format=3Draw,if=3Dsd,index=3D0,serial=3Dsdserial \ +-drive file=3D/some/file,format=3Draw,if=3Dsd,index=3D0 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/disk-serial.xml b/tests/qemuxml2argvdat= a/disk-serial.xml index ea71f2c339..18e72bb4ba 100644 --- a/tests/qemuxml2argvdata/disk-serial.xml +++ b/tests/qemuxml2argvdata/disk-serial.xml @@ -29,7 +29,6 @@ - sdserial diff --git a/tests/qemuxml2xmloutdata/disk-serial.xml b/tests/qemuxml2xmlou= tdata/disk-serial.xml index 9313c699b6..a803cd959c 100644 --- a/tests/qemuxml2xmloutdata/disk-serial.xml +++ b/tests/qemuxml2xmloutdata/disk-serial.xml @@ -32,7 +32,6 @@ - sdserial
--=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list