From nobody Sun Feb 8 16:36:13 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 1498148524149834.999837010634; Thu, 22 Jun 2017 09:22:04 -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 8C206C0005B8; Thu, 22 Jun 2017 16:21:58 +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 5E00E5D967; Thu, 22 Jun 2017 16:21:58 +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 131071853E32; Thu, 22 Jun 2017 16:21:58 +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 v5MGIq58023642 for ; Thu, 22 Jun 2017 12:18:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id BB58360608; Thu, 22 Jun 2017 16:18:52 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36D0E60607 for ; Thu, 22 Jun 2017 16:18:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8C206C0005B8 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 8C206C0005B8 From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 22 Jun 2017 18:18:35 +0200 Message-Id: <4ee26afa9c6476a9b0f02c65dbacbae81a1a8331.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 8/8] qemu ns: Create chardev backends more frequently 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:21:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Currently, the only type of chardev that we create the backend for in the namespace is type=3D'dev'. This is not enough, other backends might have files under /dev too. For instance channels might have a unix socket under /dev (well, bind mounted under /dev from a different place). Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- src/qemu/qemu_domain.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 51779c535..65eec26dd 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7732,7 +7732,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); - isReg =3D S_ISREG(sb.st_mode); + isReg =3D S_ISREG(sb.st_mode) || S_ISFIFO(sb.st_mode) || S_ISSOCK(sb.s= t_mode); =20 /* Here, @device might be whatever path in the system. We * should create the path in the namespace iff it's "/dev" @@ -8129,11 +8129,17 @@ qemuDomainSetupChardev(virDomainDefPtr def ATTRIBUT= E_UNUSED, void *opaque) { const struct qemuDomainCreateDeviceData *data =3D opaque; + const char *path =3D NULL; =20 - if (dev->source->type !=3D VIR_DOMAIN_CHR_TYPE_DEV) + if (!(path =3D virDomainChrSourceDefPath(dev->source))) return 0; =20 - return qemuDomainCreateDevice(dev->source->data.file.path, data, false= ); + /* Socket created by qemu. It doesn't exist upfront. */ + if (dev->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_UNIX && + dev->source->data.nix.listen) + return 0; + + return qemuDomainCreateDevice(path, data, true); } =20 =20 @@ -8531,7 +8537,7 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE= _UNUSED, bool delDevice =3D false; bool isLink =3D S_ISLNK(data->sb.st_mode); bool isDev =3D S_ISCHR(data->sb.st_mode) || S_ISBLK(data->sb.st_mode); - bool isReg =3D S_ISREG(data->sb.st_mode); + bool isReg =3D S_ISREG(data->sb.st_mode) || S_ISFIFO(data->sb.st_mode)= || S_ISSOCK(data->sb.st_mode); =20 qemuSecurityPostFork(data->driver->securityManager); =20 @@ -8576,7 +8582,7 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE= _UNUSED, * as its backing chain. This might however clash here. * Therefore do the cleanup here. */ if (umount(data->file) < 0 && - errno !=3D ENOENT) { + errno !=3D ENOENT && errno !=3D EINVAL) { virReportSystemError(errno, _("Unable to umount %s"), data->file); @@ -8685,7 +8691,7 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr= driver, } =20 isLink =3D S_ISLNK(data.sb.st_mode); - isReg =3D S_ISREG(data.sb.st_mode); + isReg =3D S_ISREG(data.sb.st_mode) || S_ISFIFO(data.sb.st_mode) || S_I= SSOCK(data.sb.st_mode); =20 if (isReg && STRPREFIX(file, DEVPREFIX)) { cfg =3D virQEMUDriverGetConfig(driver); @@ -9077,10 +9083,13 @@ qemuDomainNamespaceSetupChardev(virQEMUDriverPtr dr= iver, if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) return 0; =20 - if (chr->source->type !=3D VIR_DOMAIN_CHR_TYPE_DEV) + if (!(path =3D virDomainChrSourceDefPath(chr->source))) return 0; =20 - path =3D chr->source->data.file.path; + /* Socket created by qemu. It doesn't exist upfront. */ + if (chr->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_UNIX && + chr->source->data.nix.listen) + return 0; =20 cfg =3D virQEMUDriverGetConfig(driver); if (qemuDomainGetPreservedMounts(cfg, vm, --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list