From patchwork Mon Oct 7 21:49:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175428 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4848551ill; Mon, 7 Oct 2019 14:52:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgR57hi45is2rnxtaPyzRBL5EXDDalc7fMa1RG5NW2GYW4hIv+JTKm8PrMP0dlVGCxR/XW X-Received: by 2002:a02:683:: with SMTP id 125mr29315582jav.132.1570485176967; Mon, 07 Oct 2019 14:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485176; cv=none; d=google.com; s=arc-20160816; b=yfKDBO9cnQl7H5+S1Op5jUXtX68elM3Caidx/BQxO7hQTmx3LndJb4SO7xXXvogbUC XRqx1CmrZMJJfufmAT7N4Ru706liREYnN5Z0aMdTsuqYl/kp2wWSBtGaNVndtu//Mty0 p0i6MtBhVQLv+8ua+kUH5efTlSs47JaUbbewkDy9kCevAdKWLzIYMZfA3+qjgDiYydhv kA7IZNklHEm7yM4qRr5mGnasITE+AyJqgKXL3rTLIG+BoJklNO++5vmMt8/ivyVgMU7l h2McF3r+QU9PtpMDc7djG5PScJ/H+eRLaIckjAbsyULXHjfAO6dqf2zjfLiznwhLywk/ SjaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=/SDGbiUQRTjd7zaxMk87iIwTMBUvqVmNG7EFO/uTLWA=; b=HIYziA21YHISN+0gKN1Cd0F8AgpJ3LGgs7/ZoREtgSOEmr7qhM8xqU1eOB1DZ4990B KvVGg3VuKcRL3+BeNALKIT/4U+a2sBiMGqqRe1buPVe13KfbcaZqR+wP/92PuQgNzADA ADAppR74tGDAWKXbP6m/pSgB6nvX+0uBiV3dqm0nqtgAIaG4Hz9C+Hxgz/O5+99fuC2e mSYvdcy4bLlhQyPIaTjqaBXEqZtymv/FcP53E3w3zt35j+5/kKOcpOt/23OSp+fKDFTX cXiB2iAmjv+9nNHp/bOTKQRwYEOoX5eTW5EYNTJmRj68bonvSH402K8UyShgX91eUUbR NFqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id l12si18393397jaa.6.2019.10.07.14.52.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:52:56 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 DC79585362; Mon, 7 Oct 2019 21:52:55 +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 BEBEC5D9C9; Mon, 7 Oct 2019 21:52:55 +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 7F6024EEB7; Mon, 7 Oct 2019 21:52:55 +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 x97LnwTc014877 for ; Mon, 7 Oct 2019 17:49:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7E2015C231; Mon, 7 Oct 2019 21:49:58 +0000 (UTC) Delivered-To: libvir-list@redhat.com Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id A07175C224; Mon, 7 Oct 2019 21:49:53 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:31 -0400 Message-Id: <024031653c027c12a7cc627493aa93c83eceb87d.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 17/30] storagefile: Split out virStorageSourceNewFromChild 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: , 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.25]); Mon, 07 Oct 2019 21:52:56 +0000 (UTC) Future patches will use this for external data file handling Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 47 ++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index c47df6c200..7ae6719dd6 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3716,38 +3716,38 @@ virStorageSourceNewFromBackingAbsolute(const char *path, /** - * virStorageSourceNewFromBacking: + * virStorageSourceNewFromChild: * @parent: storage source parent - * @backing: returned backing store definition + * @child: returned child/backing store definition + * @parentRaw: raw child string (backingStoreRaw) * * Creates a storage source which describes the backing image of @parent and - * fills it into @backing depending on the 'backingStoreRaw' property of @parent + * fills it into @backing depending on the passed parentRaw (backingStoreRaw) * and other data. Note that for local storage this function accesses the file - * to update the actual type of the backing store. + * to update the actual type of the child store. * - * Returns 0 on success, 1 if we could parse all location data but the backinig + * Returns 0 on success, 1 if we could parse all location data but the child * store specification contained other data unrepresentable by libvirt (e.g. * inline authentication). * In both cases @src is filled. On error -1 is returned @src is NULL and an * error is reported. */ -int -virStorageSourceNewFromBacking(virStorageSourcePtr parent, - virStorageSourcePtr *backing) +static int +virStorageSourceNewFromChild(virStorageSourcePtr parent, + const char *parentRaw, + virStorageSourcePtr *child) { struct stat st; VIR_AUTOUNREF(virStorageSourcePtr) def = NULL; int rc = 0; - *backing = NULL; + *child = NULL; - if (virStorageIsRelative(parent->backingStoreRaw)) { - if (!(def = virStorageSourceNewFromBackingRelative(parent, - parent->backingStoreRaw))) + if (virStorageIsRelative(parentRaw)) { + if (!(def = virStorageSourceNewFromBackingRelative(parent, parentRaw))) return -1; } else { - if ((rc = virStorageSourceNewFromBackingAbsolute(parent->backingStoreRaw, - &def)) < 0) + if ((rc = virStorageSourceNewFromBackingAbsolute(parentRaw, &def)) < 0) return -1; } @@ -3767,10 +3767,25 @@ virStorageSourceNewFromBacking(virStorageSourcePtr parent, if (virStorageSourceInitChainElement(def, parent, true) < 0) return -1; - def->readonly = true; def->detected = true; - VIR_STEAL_PTR(*backing, def); + VIR_STEAL_PTR(*child, def); + return rc; +} + + +int +virStorageSourceNewFromBacking(virStorageSourcePtr parent, + virStorageSourcePtr *backing) +{ + int rc; + + if ((rc = virStorageSourceNewFromChild(parent, + parent->backingStoreRaw, + backing)) < 0) + return rc; + + (*backing)->readonly = true; return rc; }