From nobody Mon Feb 9 02:51:52 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.zoho.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 1498148549237181.84618389432114; Thu, 22 Jun 2017 09:22:29 -0700 (PDT) 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 8C86DC0587DB; Thu, 22 Jun 2017 16:22:27 +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 67F115D96E; Thu, 22 Jun 2017 16:22:27 +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 C27704E98B; Thu, 22 Jun 2017 16:22:26 +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 v5MGIiNu023591 for ; Thu, 22 Jun 2017 12:18:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id D5C0760619; Thu, 22 Jun 2017 16:18:44 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 541C260607 for ; Thu, 22 Jun 2017 16:18:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8C86DC0587DB Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8C86DC0587DB From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 22 Jun 2017 18:18:31 +0200 Message-Id: <551b4e1405ec5b250e825e7c47aee7217a59b040.1498147980.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/8] qemuDomainCreateDeviceRecursive: Fail on unsupported file type 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 22 Jun 2017 16:22:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Currently, we silently assume that file we are creating in the namespace is either a link or a device (character or block one). This is not always the case. Therefore instead of doing something wrong, claim about unsupported file type. Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- src/qemu/qemu_domain.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 286d60761..e6fb041de 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7707,6 +7707,7 @@ qemuDomainCreateDeviceRecursive(const char *device, struct stat sb; int ret =3D -1; bool isLink =3D false; + bool isDev =3D false; bool create =3D false; #ifdef WITH_SELINUX char *tcon =3D NULL; @@ -7729,6 +7730,7 @@ qemuDomainCreateDeviceRecursive(const char *device, } =20 isLink =3D S_ISLNK(sb.st_mode); + isDev =3D S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode); =20 /* Here, @device might be whatever path in the system. We * should create the path in the namespace iff it's "/dev" @@ -7828,7 +7830,7 @@ qemuDomainCreateDeviceRecursive(const char *device, if (qemuDomainCreateDeviceRecursive(target, data, allow_noent, ttl - 1) < 0) goto cleanup; - } else { + } else if (isDev) { if (create && mknod(devicePath, sb.st_mode, sb.st_rdev) < 0) { if (errno =3D=3D EEXIST) { @@ -7850,6 +7852,11 @@ qemuDomainCreateDeviceRecursive(const char *device, devicePath); goto cleanup; } + } else { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("unsupported device type %s %o"), + device, (int) sb.st_mode); + goto cleanup; } =20 if (!create) { --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list