From nobody Fri Dec 19 20:54:44 2025 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 15486924140678.022009910253132; Mon, 28 Jan 2019 08:20:14 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 12B0D8830E; Mon, 28 Jan 2019 16:20:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AFEEA5DEB4; Mon, 28 Jan 2019 16:20:04 +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 3A1C83F60C; Mon, 28 Jan 2019 16:20:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0SGJYer018255 for ; Mon, 28 Jan 2019 11:19:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9281F82ED3; Mon, 28 Jan 2019 16:19:34 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1510C82EDF for ; Mon, 28 Jan 2019 16:19:33 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 28 Jan 2019 17:18:55 +0100 Message-Id: <887551c8c8c88a822ac64c184d9a49f336a12874.1548692131.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 26/32] qemu: Forbid cdroms on virtio bus 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-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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 28 Jan 2019 16:20:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Attempting to create an empty virtio-blk drive results into: -device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0xc,drive=3Ddrive-virt= io-disk1,id=3Dvirtio-disk1: Device needs media, but drive is empty Attempting to eject media from virtio-blk based drive results into: error: internal error: unable to execute QEMU command 'eject': Device 'driv= e-virtio-disk0' is not removable Forbid configurations where users would attempt to use cdroms in virtio bus. Test fallout apart from the recently added case contains one more wrong example which is not really relevant to the tested code, thus I've changed the type. Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 8 ++++++++ .../disk-cdrom-bus-other.x86_64-latest.args | 7 ------- tests/qemuxml2argvdata/disk-cdrom-bus-other.xml | 11 ----------- .../disk-scsi-disk-vpd-build-error.xml | 2 +- tests/qemuxml2argvdata/pci-autofill-addr.args | 4 ++-- tests/qemuxml2argvdata/pci-autofill-addr.xml | 2 +- tests/qemuxml2xmloutdata/disk-cdrom-bus-other.xml | 13 ------------- tests/qemuxml2xmloutdata/pci-autofill-addr.xml | 2 +- 8 files changed, 13 insertions(+), 36 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index f42903a343..560abf5291 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5075,6 +5075,14 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskD= ef *disk, return -1; } + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM && + disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_VIRTIO) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk type 'virtio' of '%s' does not support ejec= table media"), + disk->dst); + return -1; + } + return 0; } diff --git a/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args= b/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args index c38819fac0..34849c2e96 100644 --- a/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args @@ -31,13 +31,6 @@ removable=3Doff \ -drive if=3Dnone,id=3Ddrive-usb-disk1,media=3Dcdrom \ -device usb-storage,bus=3Dusb.0,port=3D2,drive=3Ddrive-usb-disk1,id=3Dusb-= disk1,\ removable=3Doff \ --drive file=3D/root/boot1.iso,format=3Draw,if=3Dnone,id=3Ddrive-virtio-dis= k0,\ -media=3Dcdrom,readonly=3Don,cache=3Dnone \ --device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x2,drive=3Ddrive-vir= tio-disk0,\ -id=3Dvirtio-disk0,write-cache=3Don \ --drive if=3Dnone,id=3Ddrive-virtio-disk1,media=3Dcdrom \ --device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x3,drive=3Ddrive-vir= tio-disk1,\ -id=3Dvirtio-disk1,write-cache=3Don \ -drive file=3D/root/boot2.iso,format=3Draw,if=3Dsd,index=3D2,media=3Dcdrom= ,readonly=3Don \ -drive if=3Dsd,index=3D3,media=3Dcdrom \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ diff --git a/tests/qemuxml2argvdata/disk-cdrom-bus-other.xml b/tests/qemuxm= l2argvdata/disk-cdrom-bus-other.xml index 2ed86b0900..a142373afb 100644 --- a/tests/qemuxml2argvdata/disk-cdrom-bus-other.xml +++ b/tests/qemuxml2argvdata/disk-cdrom-bus-other.xml @@ -26,17 +26,6 @@ - - - - - - - - - - - diff --git a/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.xml b/te= sts/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.xml index e116aff114..6c83715be2 100644 --- a/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.xml +++ b/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.xml @@ -14,7 +14,7 @@ destroy /usr/bin/qemu-system-i686 - + SEAGATE diff --git a/tests/qemuxml2argvdata/pci-autofill-addr.args b/tests/qemuxml2= argvdata/pci-autofill-addr.args index b546443db3..1508787f8b 100644 --- a/tests/qemuxml2argvdata/pci-autofill-addr.args +++ b/tests/qemuxml2argvdata/pci-autofill-addr.args @@ -22,8 +22,8 @@ server,nowait \ -no-acpi \ -usb \ -drive file=3D/var/iso/f18kde.iso,format=3Draw,if=3Dnone,id=3Ddrive-virtio= -disk0,\ -media=3Dcdrom,readonly=3Don \ +readonly=3Don \ -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x3,drive=3Ddrive-virtio-disk0,\ -id=3Dvirtio-disk0 \ +id=3Dvirtio-disk0,bootindex=3D1 \ -vga cirrus \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 diff --git a/tests/qemuxml2argvdata/pci-autofill-addr.xml b/tests/qemuxml2a= rgvdata/pci-autofill-addr.xml index 0d10ec8635..a601c50ab9 100644 --- a/tests/qemuxml2argvdata/pci-autofill-addr.xml +++ b/tests/qemuxml2argvdata/pci-autofill-addr.xml @@ -10,7 +10,7 @@ /usr/bin/qemu-system-x86_64 - + diff --git a/tests/qemuxml2xmloutdata/disk-cdrom-bus-other.xml b/tests/qemu= xml2xmloutdata/disk-cdrom-bus-other.xml index a9f2806777..e5eb7d6a98 100644 --- a/tests/qemuxml2xmloutdata/disk-cdrom-bus-other.xml +++ b/tests/qemuxml2xmloutdata/disk-cdrom-bus-other.xml @@ -26,19 +26,6 @@ - - - - - -
- - - - - -
- diff --git a/tests/qemuxml2xmloutdata/pci-autofill-addr.xml b/tests/qemuxml= 2xmloutdata/pci-autofill-addr.xml index 581d42f11e..84cf1043e3 100644 --- a/tests/qemuxml2xmloutdata/pci-autofill-addr.xml +++ b/tests/qemuxml2xmloutdata/pci-autofill-addr.xml @@ -14,7 +14,7 @@ destroy /usr/bin/qemu-system-x86_64 - + --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list