From nobody Sun Feb 8 17:46:31 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 1498148347549264.12149203050046; Thu, 22 Jun 2017 09:19:07 -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 B82C0635C1; Thu, 22 Jun 2017 16:19:02 +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 665056FE48; Thu, 22 Jun 2017 16:19:02 +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 1D67F1853E2D; Thu, 22 Jun 2017 16:19:02 +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 v5MGIhGw023583 for ; Thu, 22 Jun 2017 12:18:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id F009060607; Thu, 22 Jun 2017 16:18:43 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C2686062A for ; Thu, 22 Jun 2017 16:18:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B82C0635C1 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 B82C0635C1 From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 22 Jun 2017 18:18:30 +0200 Message-Id: <409e430e6ecce542d13a43ea07f1ef36cbe5b524.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 3/8] qemu: Move preserved mount points path generation into a separate function 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.39]); Thu, 22 Jun 2017 16:19:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function is going to be used on other places, so instead of copying code we can just call the function. Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- src/qemu/qemu_domain.c | 59 ++++++++++++++++++++++++++++++----------------= ---- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 212717c80..286d60761 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7572,6 +7572,41 @@ qemuDomainGetHostdevPath(virDomainDefPtr def, } =20 =20 +static char * +qemuDomainGetPreservedMountPath(virQEMUDriverConfigPtr cfg, + virDomainObjPtr vm, + const char *mount) +{ + char *path =3D NULL; + char *tmp; + const char *suffix =3D mount + strlen(DEVPREFIX); + size_t off; + + if (STREQ(mount, "/dev")) + suffix =3D "dev"; + + if (virAsprintf(&path, "%s/%s.%s", + cfg->stateDir, vm->def->name, suffix) < 0) + return NULL; + + /* Now consider that @mount 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(path) - strlen(suffix); + + tmp =3D path + off; + while (*tmp) { + if (*tmp =3D=3D '/') + *tmp =3D '.'; + tmp++; + } + + return path; +} + + /** * qemuDomainGetPreservedMounts: * @@ -7628,30 +7663,8 @@ qemuDomainGetPreservedMounts(virQEMUDriverConfigPtr = cfg, goto error; =20 for (i =3D 0; i < nmounts; i++) { - char *tmp; - const char *suffix =3D mounts[i] + strlen(DEVPREFIX); - size_t off; - - if (STREQ(mounts[i], "/dev")) - suffix =3D "dev"; - - if (virAsprintf(&paths[i], "%s/%s.%s", - cfg->stateDir, vm->def->name, suffix) < 0) + if (!(paths[i] =3D qemuDomainGetPreservedMountPath(cfg, vm, mounts= [i]))) 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