From nobody Wed Jul 9 23:52:41 2025 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 1497283077527964.4381163978777; Mon, 12 Jun 2017 08:57:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7538761B85; Mon, 12 Jun 2017 15:57:54 +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 401C280F6E; Mon, 12 Jun 2017 15:57:54 +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 F25DA4A48E; Mon, 12 Jun 2017 15:57:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5CFvOXb015230 for ; Mon, 12 Jun 2017 11:57:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id B8F3C842A8; Mon, 12 Jun 2017 15:57:24 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FB59842AB for ; Mon, 12 Jun 2017 15:57:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7538761B85 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.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 7538761B85 From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 12 Jun 2017 17:57:17 +0200 Message-Id: <351744dd3fb1e72693247d73b0174b3b8b437298.1497282963.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] qemuDomainGetPreservedMounts: Fix suffixes for corner cases 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 12 Jun 2017 15:57:55 +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=3D1431112 Imagine a FS mounted on /dev/blah/blah2. Our process of creating suffix for temporary location where all the mounted filesystems are moved is very simplistic. We want: /var/run/libvirt/qemu/$domName.$suffix\ were $suffix is just the mount point path stripped of the "/dev/" preffix. For instance: /var/run/libvirt/qemu/fedora.mqueue for /dev/mqueue /var/run/libvirt/qemu/fedora.pts for /dev/pts and so on. Now if we plug /dev/blah/blah2 into the example we see some misbehaviour: /var/run/libvirt/qemu/fedora.blah/blah2 Well, misbehaviour if /dev/blah/blah2 is a file, because in that case we call virFileTouch() instead of virFileMakePath(). Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index accf05a6f..547c9fbfb 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7570,7 +7570,9 @@ qemuDomainGetPreservedMounts(virQEMUDriverConfigPtr c= fg, goto error; =20 for (i =3D 0; i < nmounts; i++) { + char *tmp; const char *suffix =3D mounts[i] + strlen(DEVPREFIX); + size_t off; =20 if (STREQ(mounts[i], "/dev")) suffix =3D "dev"; @@ -7578,6 +7580,20 @@ qemuDomainGetPreservedMounts(virQEMUDriverConfigPtr = cfg, if (virAsprintf(&paths[i], "%s/%s.%s", cfg->stateDir, vm->def->name, suffix) < 0) goto error; + + /* Now consider that mounts[i] is "/dev/blah/blah2". + * @suffix then points to "blah/blah2". However, caller + * expects all the @paths to be the same depth. The + * caller doesn't always do `mkdir -p` but sometimes bare + * `touch`. Therefore fix all the suffixes. */ + off =3D strlen(paths[i]) - strlen(suffix); + + tmp =3D paths[i] + off; + while (*tmp) { + if (*tmp =3D=3D '/') + *tmp =3D '.'; + tmp++; + } } =20 if (devPath) --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list