From nobody Sun Feb 8 22:57:49 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.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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565952011; cv=none; d=zoho.com; s=zohoarc; b=TBMMhbWRtyCxqZOIDpqH2wrug48vhhN2/RdRqV2XOL6VQk2UrlOt828jqrHRDITLuvnjJ0BGXhbWsCtTNnw0obWP+4gRrO5ow6p6roBeOgQ+/XqBU/QSjOxQX+A2Kn3HTSnGW2VUtFNB9xIHrmvL+of02CT8xMaRRCod7s+o5pg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565952011; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=KeQzJSA8LT8YIbRF/BIYSkTknhZjy8WOhfCNytBTZ6M=; b=H+LNMc3dpO7uJ/DkeUgQhT/N3x9r7MWjqxRJF8+rjqZ3QIbrrgKARqiHybhyceH29mZpgnn687siJCslNSmMn5B/j+/LpbFM35I+4eDpTA0rmTBPnc2HqBs72T5gSTiDfXRU8RXP4gI8JXGcljEPEWAsHvqjV66FI4F49+fJKmY= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565952011970904.926137920838; Fri, 16 Aug 2019 03:40:11 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 916D2C0568FA; Fri, 16 Aug 2019 10:40:10 +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 5EA9DA4F9D; Fri, 16 Aug 2019 10:40:10 +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 113A3180BAA4; Fri, 16 Aug 2019 10:40:10 +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 x7GAdoiT021574 for ; Fri, 16 Aug 2019 06:39:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3B778A4F86; Fri, 16 Aug 2019 10:39:50 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAE8B9F6B for ; Fri, 16 Aug 2019 10:39:49 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:30 +0200 Message-Id: <3d0ee8dc59816e1b85a4c1ea9a921700fb120b1e.1565951850.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/14] util: storagefile: Modify arguments of virStorageSourceNewFromBackingAbsolue 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: , 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 16 Aug 2019 10:40:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Return the parsed storage source via an pointer in arguments and return an integer from the function. Describe the semantics with a comment for the function and adjust callers to the new semantics. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 43 ++++++++++++++++++++++++--------------- src/util/virstoragefile.h | 3 ++- tests/qemublocktest.c | 3 ++- tests/virstoragetest.c | 2 +- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 192a79c025..8447c014f0 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3633,22 +3633,32 @@ virStorageSourceParseBackingJSON(virStorageSourcePt= r src, } -virStorageSourcePtr -virStorageSourceNewFromBackingAbsolute(const char *path) +/** + * virStorageSourceNewFromBackingAbsolute + * @path: string representing absolute location of a storage source + * @src: filled with virStorageSource object representing @path + * + * Returns 0 on success and fills @src or -1 on error and reports appropri= ate + * error. + */ +int +virStorageSourceNewFromBackingAbsolute(const char *path, + virStorageSourcePtr *src) { const char *json; - virStorageSourcePtr ret =3D NULL; int rc; VIR_AUTOUNREF(virStorageSourcePtr) def =3D NULL; + *src =3D NULL; + if (!(def =3D virStorageSourceNew())) - return NULL; + return -1; if (virStorageIsFile(path)) { def->type =3D VIR_STORAGE_TYPE_FILE; if (VIR_STRDUP(def->path, path) < 0) - return NULL; + return -1; } else { def->type =3D VIR_STORAGE_TYPE_NETWORK; @@ -3663,7 +3673,7 @@ virStorageSourceNewFromBackingAbsolute(const char *pa= th) rc =3D virStorageSourceParseBackingColon(def, path); if (rc < 0) - return NULL; + return -1; virStorageSourceNetworkAssignDefaultPorts(def); @@ -3676,8 +3686,8 @@ virStorageSourceNewFromBackingAbsolute(const char *pa= th) } } - VIR_STEAL_PTR(ret, def); - return ret; + VIR_STEAL_PTR(*src, def); + return 0; } @@ -3702,14 +3712,15 @@ virStorageSourceNewFromBacking(virStorageSourcePtr = parent, *backing =3D NULL; - if (virStorageIsRelative(parent->backingStoreRaw)) - def =3D virStorageSourceNewFromBackingRelative(parent, - parent->backingStoreR= aw); - else - def =3D virStorageSourceNewFromBackingAbsolute(parent->backingStor= eRaw); - - if (!def) - return -1; + if (virStorageIsRelative(parent->backingStoreRaw)) { + if (!(def =3D virStorageSourceNewFromBackingRelative(parent, + parent->backing= StoreRaw))) + return -1; + } else { + if (virStorageSourceNewFromBackingAbsolute(parent->backingStoreRaw, + &def) < 0) + return -1; + } /* possibly update local type */ if (def->type =3D=3D VIR_STORAGE_TYPE_FILE) { diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 3a72c62ad7..2cceaf6954 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -473,7 +473,8 @@ int virStorageFileGetRelativeBackingPath(virStorageSour= cePtr from, int virStorageFileCheckCompat(const char *compat); -virStorageSourcePtr virStorageSourceNewFromBackingAbsolute(const char *pat= h); +int virStorageSourceNewFromBackingAbsolute(const char *path, + virStorageSourcePtr *src); bool virStorageSourceIsRelative(virStorageSourcePtr src); diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 9321531f6c..e5d77c423c 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -85,7 +85,8 @@ testBackingXMLjsonXML(const void *args) if (virAsprintf(&protocolwrapper, "json:%s", propsstr) < 0) return -1; - if (!(jsonsrc =3D virStorageSourceNewFromBackingAbsolute(protocolwrapp= er))) { + if (virStorageSourceNewFromBackingAbsolute(protocolwrapper, + &jsonsrc) < 0) { fprintf(stderr, "failed to parse disk json\n"); return -1; } diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 1c7ba466f1..0495308318 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -613,7 +613,7 @@ testBackingParse(const void *args) VIR_AUTOFREE(char *) xml =3D NULL; VIR_AUTOUNREF(virStorageSourcePtr) src =3D NULL; - if (!(src =3D virStorageSourceNewFromBackingAbsolute(data->backing))) { + if (virStorageSourceNewFromBackingAbsolute(data->backing, &src) < 0) { if (!data->expect) return 0; else --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list