From nobody Mon Apr 29 04:15:51 2024 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 1508420083358942.999606660112; Thu, 19 Oct 2017 06:34:43 -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 53E5CA0B57; Thu, 19 Oct 2017 13:34:42 +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 0E68AB19C3; Thu, 19 Oct 2017 13:34:42 +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 9B150410B7; Thu, 19 Oct 2017 13:34:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9JDYd2t026425 for ; Thu, 19 Oct 2017 09:34:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 77704AAFC4; Thu, 19 Oct 2017 13:34:39 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0AFDA4479 for ; Thu, 19 Oct 2017 13:34:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 53E5CA0B57 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 15:34:34 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu-ns: Detect /dev/* mount point duplicates better 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.25]); Thu, 19 Oct 2017 13:34:42 +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=3D1495511 When creating new /dev for domain ran in namespace we try to preserve all sub-mounts of /dev. Well, not quite all. For instance if /dev/foo/bar and /dev/foo are both mount points, only /dev/foo needs preserving. /dev/foo/bar is preserved with it too. Now, to identify such cases like this one STRPREFIX() is used. That is not good enough. While it works for [/dev/foo/bar; /dev/foo] case, it fails for [/dev/prefix; /dev/prefix2] where the strings share the same prefix but are in fact two different paths. The solution is to use STRSKIP(). Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/qemu/qemu_domain.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 05e8b96aa..8aa66c69c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8182,7 +8182,9 @@ qemuDomainGetPreservedMounts(virQEMUDriverConfigPtr c= fg, for (i =3D 1; i < nmounts; i++) { j =3D i + 1; while (j < nmounts) { - if (STRPREFIX(mounts[j], mounts[i])) { + char *c =3D STRSKIP(mounts[j], mounts[i]); + + if (c && *c =3D=3D '/') { VIR_DEBUG("Dropping path %s because of %s", mounts[j], mou= nts[i]); VIR_DELETE_ELEMENT(mounts, j, nmounts); } else { --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list