From nobody Sun Feb 8 20:13:10 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 1549295288229263.61705111800507; Mon, 4 Feb 2019 07:48:08 -0800 (PST) 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 1F97C8F4E5; Mon, 4 Feb 2019 15:48: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 C30496EA09; Mon, 4 Feb 2019 15:48: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 684593F60A; Mon, 4 Feb 2019 15:48:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x14FlUCf009081 for ; Mon, 4 Feb 2019 10:47:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 37F4888F9C; Mon, 4 Feb 2019 15:47:30 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id B173A88F98 for ; Mon, 4 Feb 2019 15:47:29 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 4 Feb 2019 16:46:59 +0100 Message-Id: <1a380e9c7c8a2dfaa32698995961ea59903ce40a.1549295166.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 04 Feb 2019 15:48:07 +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 Reviewed-by: J=C3=A1n Tomko --- 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 e2b0bd87b4..f27ba9b740 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5078,6 +5078,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 9dd45133fc..a64da3edd6 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,readonly=3Don \ -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,readonly=3Don \ --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,readonly=3Don \ -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