From nobody Sun Feb 8 18:48:45 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1505140497158603.3512337088144; Mon, 11 Sep 2017 07:34:57 -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 EB6D822F2F6; Mon, 11 Sep 2017 14:34:55 +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 73BE06B569; Mon, 11 Sep 2017 14:34:55 +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 07C523FAD1; Mon, 11 Sep 2017 14:34:54 +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 v8BEWpjW024900 for ; Mon, 11 Sep 2017 10:32:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 936A36F99F; Mon, 11 Sep 2017 14:32:51 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-120.phx2.redhat.com [10.3.116.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B6601797F for ; Mon, 11 Sep 2017 14:32:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EB6D822F2F6 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Mon, 11 Sep 2017 10:32:45 -0400 Message-Id: <20170911143247.9636-2-jferlan@redhat.com> In-Reply-To: <20170911143247.9636-1-jferlan@redhat.com> References: <20170911143247.9636-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/3] qemu: Be more selective when determining cdrom for taint messaging 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.38]); Mon, 11 Sep 2017 14:34:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1471225 Commit id '99a2d6af2' was a bit too aggressive with determining whether the provided path was a "physical" cd-rom in order to generate a taint message due to the possibility of some guest and host trying to control the tray. For cd-rom guest devices backed to some VIR_STORAGE_TYPE_FILE storage, this wouldn't be a problem and as such it shouldn't be a problem for guest devices using some sort of block device on the host such as iSCSI, LVM, or a Disk pool would present. So before issuing a taint message, let's check if the provided path of the VIR_STORAGE_TYPE_BLOCK backed device is a "known" physical cdrom name by comparing the beginning of the path w/ "/dev/cdrom" and "/dev/sr". Also since it's possible the provided path could resolve to some /dev/srN device, let's get that path as well and perform the same check. Signed-off-by: John Ferlan --- src/qemu/qemu_domain.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 7203189..1b0c778 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4722,6 +4722,35 @@ qemuDomainDefFormatLive(virQEMUDriverPtr driver, } =20 =20 +/* qemuDomainFilePathIsHostCDROM + * @path: Supplied path. + * + * Determine if the path is a host CD-ROM path. Typically this is + * either /dev/cdrom[n] or /dev/srN, so those are easy checks, but + * it's also possible that @path resolves to /dev/srN, so check for + * those conditions on @path in order to emit the tainted message. + * + * Returns true if the path is a CDROM, false otherwise or on error. + */ +static bool +qemuDomainFilePathIsHostCDROM(const char *path) +{ + bool ret =3D false; + char *linkpath =3D NULL; + + if (virFileResolveLink(path, &linkpath) < 0) + goto cleanup; + + if (STRPREFIX(path, "/dev/cdrom") || STRPREFIX(path, "/dev/sr") || + STRPREFIX(linkpath, "/dev/sr")) + ret =3D true; + + cleanup: + VIR_FREE(linkpath); + return ret; +} + + void qemuDomainObjTaint(virQEMUDriverPtr driver, virDomainObjPtr obj, virDomainTaintFlags taint, @@ -4840,7 +4869,7 @@ void qemuDomainObjCheckDiskTaint(virQEMUDriverPtr dri= ver, =20 if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM && virStorageSourceGetActualType(disk->src) =3D=3D VIR_STORAGE_TYPE_B= LOCK && - disk->src->path) + disk->src->path && qemuDomainFilePathIsHostCDROM(disk->src->path)) qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_CDROM_PASSTHROUGH, logCtxt); =20 --=20 2.9.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list