From nobody Thu Apr 25 23:23:17 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565951986; cv=none; d=zoho.com; s=zohoarc; b=k/vzrz9qCIitoTYoZNV2tnhIjusXF3uLf+1DeXQFueyn7B1f9C6Ys0mjnf9Nzfp+XcitzpsLz6N56wWx64sFZ2fiHqUz1/dUM/U1VpGHMz0eOqKP6+L5RCbLElX/4cE4pQTL6tVtz3rdAnISrsIw75XAjVcCGvip+awyFRinru4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565951986; 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=afxuBhSskYle4SDx3cRGT3O7pagZt8wiGhK6kqpTLFA=; b=EYglgIBFr10IrgdDT1OINJpDAuz4oFNhMDSSnMI69/CNRkHGk5OrPho6bAPh7nH/1/q9gwXfusfbdIWGsEpw+s+QM9BSDnx81rk0xxk1xQ/e19zPksfgaIdm5nTUMQycVZDaiTDsNtqRtuErZIvwLwZbObVT8EeDHTG/WlY7XdQ= 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 1565951986456531.6353577455676; Fri, 16 Aug 2019 03:39:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0CEFE300D20C; Fri, 16 Aug 2019 10:39:45 +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 B1055100197A; Fri, 16 Aug 2019 10:39:44 +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 90CC218005B9; Fri, 16 Aug 2019 10:39:43 +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 x7GAdgqQ021501 for ; Fri, 16 Aug 2019 06:39:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1382CA4F86; Fri, 16 Aug 2019 10:39:42 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 930349654D for ; Fri, 16 Aug 2019 10:39:39 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:22 +0200 Message-Id: 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 01/14] util: storage: Simplify cleanup path handling in virStorageSourceParseBackingJSONInternal 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 16 Aug 2019 10:39:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Automatically free the intermediate JSON data to get rid of the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index ba56f452e9..520f531088 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3590,22 +3590,21 @@ static int virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src, virJSONValuePtr json) { - virJSONValuePtr deflattened =3D NULL; + VIR_AUTOPTR(virJSONValue) deflattened =3D NULL; virJSONValuePtr file; const char *drvname; size_t i; - int ret =3D -1; VIR_AUTOFREE(char *) str =3D NULL; if (!(deflattened =3D virJSONValueObjectDeflatten(json))) - goto cleanup; + return -1; if (!(file =3D virJSONValueObjectGetObject(deflattened, "file"))) { str =3D virJSONValueToString(json, false); virReportError(VIR_ERR_INVALID_ARG, _("JSON backing volume definition '%s' lacks 'file'= object"), NULLSTR(str)); - goto cleanup; + return -1; } if (!(drvname =3D virJSONValueObjectGetString(file, "driver"))) { @@ -3613,23 +3612,18 @@ virStorageSourceParseBackingJSONInternal(virStorage= SourcePtr src, virReportError(VIR_ERR_INVALID_ARG, _("JSON backing volume definition '%s' lacks driver= name"), NULLSTR(str)); - goto cleanup; + return -1; } for (i =3D 0; i < ARRAY_CARDINALITY(jsonParsers); i++) { - if (STREQ(drvname, jsonParsers[i].drvname)) { - ret =3D jsonParsers[i].func(src, file, jsonParsers[i].opaque); - goto cleanup; - } + if (STREQ(drvname, jsonParsers[i].drvname)) + return jsonParsers[i].func(src, file, jsonParsers[i].opaque); } virReportError(VIR_ERR_INTERNAL_ERROR, _("missing parser implementation for JSON backing volum= e " "driver '%s'"), drvname); - - cleanup: - virJSONValueFree(deflattened); - return ret; + return -1; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:23:17 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565951986; cv=none; d=zoho.com; s=zohoarc; b=eFpkVcTWQUW5kpOSnbz/ONj4MtvsoLsTD1sv1B5agERC5GvdXsPUfsKge3cI/0YNyXk6B5+GiG/0XU+6W+sNHdUuxUhcVGduGJTAAPiouUzJVTRapBf8ZFvw+esxj7c1/CmjfJPngW/3PpPhqp0kSFywnIpXY4ubzldmRwW6bPE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565951986; 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=9kUGxcvxh0AnUfb8B/ExBT84j7vyhF87i+ILiacdJOY=; b=citiTC6xFg9oVym8gGJ/J55wfgHpHjlATCTpOo4c/AIGjZyGylI8XesJVfQgWzn+DSusOv+LDmWH/tLA31V+VHsUGyfRZkSQYb6nD1TOOsFY2mBCZGoDb1ChmLZAxkEBhHlTs0zCkwX2J3Hs1f/SBcRbiL2QPQmZr5fi2MXLI94= 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 1565951986447278.512380174089; Fri, 16 Aug 2019 03:39:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1996C308212F; Fri, 16 Aug 2019 10:39:45 +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 B54867DA35; Fri, 16 Aug 2019 10:39:44 +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 1D8EF180BA9A; Fri, 16 Aug 2019 10:39:44 +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 x7GAdg3B021506 for ; Fri, 16 Aug 2019 06:39:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id D36F19654D; Fri, 16 Aug 2019 10:39:42 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EEBFA4F9A for ; Fri, 16 Aug 2019 10:39:42 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:23 +0200 Message-Id: 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 02/14] util: storagefile: Remove cleanup label from virStorageSourceParseBackingJSONiSCSI 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 16 Aug 2019 10:39:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" There is no cleanup code. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 520f531088..8af45bfbd2 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3263,7 +3263,6 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSourc= ePtr src, const char *lun =3D virJSONValueObjectGetStringOrNumber(json, "lun"); const char *uri; char *port; - int ret =3D -1; /* legacy URI based syntax passed via 'filename' option */ if ((uri =3D virJSONValueObjectGetString(json, "filename"))) @@ -3277,14 +3276,14 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSou= rcePtr src, lun =3D "0"; if (VIR_ALLOC(src->hosts) < 0) - goto cleanup; + return -1; src->nhosts =3D 1; if (STRNEQ_NULLABLE(transport, "tcp")) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("only TCP transport is supported for iSCSI volume= s")); - goto cleanup; + return -1; } src->hosts->transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; @@ -3292,33 +3291,30 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSou= rcePtr src, if (!portal) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing 'portal' address in iSCSI backing defini= tion")); - goto cleanup; + return -1; } if (!target) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing 'target' in iSCSI backing definition")); - goto cleanup; + return -1; } if (VIR_STRDUP(src->hosts->name, portal) < 0) - goto cleanup; + return -1; if ((port =3D strrchr(src->hosts->name, ':')) && !strchr(port, ']')) { if (virStringParsePort(port + 1, &src->hosts->port) < 0) - goto cleanup; + return -1; *port =3D '\0'; } if (virAsprintf(&src->path, "%s/%s", target, lun) < 0) - goto cleanup; - - ret =3D 0; + return -1; - cleanup: - return ret; + return 0; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:23:17 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565952000; cv=none; d=zoho.com; s=zohoarc; b=hvzL9IvtIw3tgSbaEvW/UIZxQkyXx2ttEYxfASNMkMnbxqv1g06llMLpKFN3MOgP/1AJgB6TCY/rILsQneLurrU1fE3CW/h3Sd1H/FNIcbA/1UIkYbHLqfXvCg8H/tHTAOQ59q/4G4avLGvzncMTDjgeVAd/vd/nxbri9SqkHYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565952000; 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=zjCviZEpwlDCgN1kFXk1oWIo2+s7SzYdkK5GSNg8H7s=; b=WB9QACV2KIOUSL7tHXeZWFkrWG+gNClfeZ/cxyzK97jJOLHfnN3zndH9lyURTpR3dZcoBTaEMcZsNZac34gHFCNcPs7wlnUq3ihSuOBz4eyt7+57WccUHygSgoQhXiKGLsG+EhOs55dAhUX6ZFkQoEx2VTTgvFi97cswby6IXz0= 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 1565952000596783.0625912415389; Fri, 16 Aug 2019 03:40:00 -0700 (PDT) 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 2610686662; Fri, 16 Aug 2019 10:39:59 +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 026538F6C1; Fri, 16 Aug 2019 10:39:59 +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 C11E619722; Fri, 16 Aug 2019 10:39:58 +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 x7GAdhgO021512 for ; Fri, 16 Aug 2019 06:39:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9EBA4A4F96; Fri, 16 Aug 2019 10:39:43 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A653A4F86 for ; Fri, 16 Aug 2019 10:39:43 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:24 +0200 Message-Id: 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 03/14] util: storagefile: Simplify cleanup handling in virStorageSourceParseBackingURI 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 16 Aug 2019 10:39:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Automatically clean the 'uri' variable and get rid of the 'cleanup' label. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 8af45bfbd2..e93f6285b0 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2664,32 +2664,31 @@ static int virStorageSourceParseBackingURI(virStorageSourcePtr src, const char *uristr) { - virURIPtr uri =3D NULL; + VIR_AUTOPTR(virURI)uri =3D NULL; const char *path =3D NULL; - int ret =3D -1; VIR_AUTOSTRINGLIST scheme =3D NULL; if (!(uri =3D virURIParse(uristr))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse backing file location '%s'"), uristr); - goto cleanup; + return -1; } if (VIR_ALLOC(src->hosts) < 0) - goto cleanup; + return -1; src->nhosts =3D 1; if (!(scheme =3D virStringSplit(uri->scheme, "+", 2))) - goto cleanup; + return -1; if (!scheme[0] || (src->protocol =3D virStorageNetProtocolTypeFromString(scheme[0]))= < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid backing protocol '%s'"), NULLSTR(scheme[0])); - goto cleanup; + return -1; } if (scheme[1] && @@ -2697,13 +2696,13 @@ virStorageSourceParseBackingURI(virStorageSourcePtr= src, virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid protocol transport type '%s'"), scheme[1]); - goto cleanup; + return -1; } /* handle socket stored as a query */ if (uri->query) { if (VIR_STRDUP(src->hosts->socket, STRSKIP(uri->query, "socket=3D"= )) < 0) - goto cleanup; + return -1; } /* XXX We currently don't support auth, so don't bother parsing it */ @@ -2725,7 +2724,7 @@ virStorageSourceParseBackingURI(virStorageSourcePtr s= rc, path =3D NULL; if (VIR_STRDUP(src->path, path) < 0) - goto cleanup; + return -1; if (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER) { char *tmp; @@ -2733,7 +2732,7 @@ virStorageSourceParseBackingURI(virStorageSourcePtr s= rc, if (!src->path) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("missing volume name and path for gluster vol= ume")); - goto cleanup; + return -1; } if (!(tmp =3D strchr(src->path, '/')) || @@ -2741,13 +2740,13 @@ virStorageSourceParseBackingURI(virStorageSourcePtr= src, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("missing volume name or file name in " "gluster source path '%s'"), src->path); - goto cleanup; + return -1; } src->volume =3D src->path; if (VIR_STRDUP(src->path, tmp + 1) < 0) - goto cleanup; + return -1; tmp[0] =3D '\0'; } @@ -2755,13 +2754,9 @@ virStorageSourceParseBackingURI(virStorageSourcePtr = src, src->hosts->port =3D uri->port; if (VIR_STRDUP(src->hosts->name, uri->server) < 0) - goto cleanup; - - ret =3D 0; + return -1; - cleanup: - virURIFree(uri); - return ret; + return 0; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:23:17 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565952004; cv=none; d=zoho.com; s=zohoarc; b=dm+m7tOeviLAL3Dznj2cGcIseaMTfXqedAkayNTkocEGSigUgKckuga0RiImeEKkltLhPvMMpwuTgPwtEDm+kfh19j21eB+pN/WfHbNA8SIDRH47rl06PWfRfLdjr1a7GQv26g0PQLbZPo8G8+xvgk71d1gco+fKP5I19bwkWvI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565952004; 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=61gxDQGtYQXAL+NBJZCIVjjNu2fnELRfb31V5pM6zMs=; b=SEcZyPIVAquuZ3JmbqcoE29ES2nHA4+EMaJBisv+Hu6HbwujXOLh51yxC76RRn6nWbB5qXuJfvP0HhqtrtZAxbjb1YZ62yacvZT/cwCL3BqJ31WK6lq2gM3g30uugHaBOwb/AxcS2I12vU3GVMc3xq2IXDUUxnqegdCh9ruwfsc= 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 156595200471112.647856936917606; Fri, 16 Aug 2019 03:40:04 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 907598E22B; Fri, 16 Aug 2019 10:40:03 +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 558B3100197A; Fri, 16 Aug 2019 10:40:03 +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 E4225180BA9E; Fri, 16 Aug 2019 10:40:02 +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 x7GAdifS021525 for ; Fri, 16 Aug 2019 06:39:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6B6D260C5D; Fri, 16 Aug 2019 10:39:44 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA9B7A4F86 for ; Fri, 16 Aug 2019 10:39:43 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:25 +0200 Message-Id: <0a9345c4d4bdaea1a04bacdaf583c9a0692a918d.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 04/14] util: storagefile: Simplify cleanup in virStorageSourceParseBackingJSON 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 16 Aug 2019 10:40:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Automatically free the 'root' temporary variable to get rid fo some complexity. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index e93f6285b0..6fff013e3a 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3622,16 +3622,12 @@ static int virStorageSourceParseBackingJSON(virStorageSourcePtr src, const char *json) { - virJSONValuePtr root =3D NULL; - int ret =3D -1; + VIR_AUTOPTR(virJSONValue) root =3D NULL; if (!(root =3D virJSONValueFromString(json))) return -1; - ret =3D virStorageSourceParseBackingJSONInternal(src, root); - - virJSONValueFree(root); - return ret; + return virStorageSourceParseBackingJSONInternal(src, root); } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:23:17 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565951998; cv=none; d=zoho.com; s=zohoarc; b=mCyqNHjiuPh0F9+qRV0ClEYLyF9qN7r6Fkcjqxssc+hU0kZ63KhwDNXJNJGlJ67bDlwoNmITaytvydwkeni5pbYV+mUBNq0IinM4mcMrzpURWH1Rb0Y3n5b/k4R58ZvMlNTNdgMPraJzSHzuaYGSU67CuEbS8y5uNIrn4UjkGK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565951998; 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=fV0WmSVagfugMAwltIWQNnruVXsq0oldOVCjjzH3gRc=; b=mrcS5TMv/xSjgaZ94wa4fZwgExh6lrg9ge56xYdea0KErvi7GEh/DA5ShrP4nnPohJu2wR3ndyXBr7ls8PF2reSpyVMibHbiHemgLPpEVMAl+kKQdS+UlZT109WpuQcc15pIsG3oXniatbU6QZAPhZFNvkiW4bYEIpTxyhdMiCI= 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 1565951998969567.7799003966766; Fri, 16 Aug 2019 03:39:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 93C4530013AF; Fri, 16 Aug 2019 10:39:57 +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 714E97DA4B; Fri, 16 Aug 2019 10:39:57 +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 0C18B244FB; Fri, 16 Aug 2019 10:39:57 +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 x7GAdj21021532 for ; Fri, 16 Aug 2019 06:39:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 366B59F6B; Fri, 16 Aug 2019 10:39:45 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id B63B860C5D for ; Fri, 16 Aug 2019 10:39:44 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:26 +0200 Message-Id: <0414a9c5b7864e331d81feb3ddb7ab1c6147c537.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 05/14] tests: viruri: Add test for password in URI userinfo 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 16 Aug 2019 10:39:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" While it's a bad idea to use userinfo to pass credentials via an URI add a test that we at least do the correct thing. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/viruritest.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/viruritest.c b/tests/viruritest.c index d419711135..3255e2333a 100644 --- a/tests/viruritest.c +++ b/tests/viruritest.c @@ -171,6 +171,7 @@ mymain(void) TEST_PARSE("test://example.com", "test", "example.com", 0, NULL, NULL,= NULL, NULL, NULL); TEST_PARSE("test://foo@example.com", "test", "example.com", 0, NULL, N= ULL, NULL, "foo", NULL); + TEST_PARSE("test://foo:pass@example.com", "test", "example.com", 0, NU= LL, NULL, NULL, "foo:pass", NULL); TEST_PARSE("test://example.com:123", "test", "example.com", 123, NULL,= NULL, NULL, NULL, NULL); TEST_PARSE("test://example.com:123/system?name=3Dvalue#foo", "test", "= example.com", 123, "/system", "name=3Dvalue", "foo", NULL, params); TEST_PARSE("test://127.0.0.1:123/system", "test", "127.0.0.1", 123, "/= system", NULL, NULL, NULL, NULL); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:23:17 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565952003; cv=none; d=zoho.com; s=zohoarc; b=R10Kr3dOj77aFcNg8Ka84mmsG970MEKr0ZSMf6q3EeXOwY7Hit3t0kFYD+kqP1s/a5eAWwzh6rNyHXsEV1OU8RPsuUHtsXQAxL6EyUoIsHXlAIBxVJoZErIUJxNQJRhab9BVz8uKej7mLLXB6WGSp2kesHAzJqJPA+xXfiGGPko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565952003; 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=0jgmtRvI9WEBFJUNEGGbguezFGQ3ph+PiDoZ/1rkdNA=; b=Fzus5rGkd6UYYBwzCKoBR7mF43PSFgvVzX1NvhzP+QiL8Z8q+1ur4++gzGOzMQN8BMWt+EYTxqFioTVc7ecItXQRtFuYzQ/90M6XZ2FEkquQmixV+f+OuVKDZh9BG4tYKgA+K5mgy6dJlSse1u7BTfP08dNGL2BzhZpid6rWKn4= 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 1565952003009989.531037234629; Fri, 16 Aug 2019 03:40:03 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 020ED2A09DA; Fri, 16 Aug 2019 10:40:01 +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 C57741001B17; Fri, 16 Aug 2019 10:40:00 +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 84604149FB; Fri, 16 Aug 2019 10:40:00 +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 x7GAdkiN021540 for ; Fri, 16 Aug 2019 06:39:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 019F660C5D; Fri, 16 Aug 2019 10:39:46 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81BA39F6B for ; Fri, 16 Aug 2019 10:39:45 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:27 +0200 Message-Id: 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 06/14] tests: storage: Refactor cleanup in testBackingParse 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 16 Aug 2019 10:40:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Automatically clean the temporary buffer and get rid of the cleanup label. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virstoragetest.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index ef16b3c6e0..1c7ba466f1 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -609,28 +609,27 @@ static int testBackingParse(const void *args) { const struct testBackingParseData *data =3D args; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; - int ret =3D -1; + VIR_AUTOCLEAN(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; VIR_AUTOFREE(char *) xml =3D NULL; VIR_AUTOUNREF(virStorageSourcePtr) src =3D NULL; if (!(src =3D virStorageSourceNewFromBackingAbsolute(data->backing))) { if (!data->expect) - ret =3D 0; - - goto cleanup; + return 0; + else + return -1; } if (src && !data->expect) { fprintf(stderr, "parsing of backing store string '%s' should " "have failed\n", data->backing); - goto cleanup; + return -1; } if (virDomainDiskSourceFormat(&buf, src, "source", 0, false, 0, NULL) = < 0 || !(xml =3D virBufferContentAndReset(&buf))) { fprintf(stderr, "failed to format disk source xml\n"); - goto cleanup; + return -1; } if (STRNEQ(xml, data->expect)) { @@ -638,15 +637,10 @@ testBackingParse(const void *args) "expected storage source xml:\n%s\n" "actual storage source xml:\n%s\n", data->backing, data->expect, xml); - goto cleanup; + return -1; } - ret =3D 0; - - cleanup: - virBufferFreeAndReset(&buf); - - return ret; + return 0; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:23:17 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565952007; cv=none; d=zoho.com; s=zohoarc; b=X/jZ34xZdQrsqfwt0VPWoTsSe0dqM4dTNQRPQP0381CSesWGZklJ/d+mK3xZzJZRLQQ8cWvpdzz1T8bziw8ROCLSul4cjfDFMrTDtfa2EUSv0ndwlIuFCiEH5SLh3dQX1+8zBbc9/PCSqLaagwCz+emjuPPxDYE/bdKec2TtFzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565952007; 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=FXHPK/5VwRH7+tCN1NJ542oMAHjZEUJRlRAnAZRndfY=; b=eRrWCMoD+CM0t0AIjejv7ZJJw52HujA3ZWJcJTNl8DmY7lPtjsV9VL5ESXuKkDGQXqGpHjc+wE5UTgs3NX7E05hXH1qx8RZWHROWscdKtjMbWIVOjJSkaXvGh/QTSkr2MZZ2CcKF7NcH5BApK/XXr+fIJTGf+FmcXItsC6Sx0Q8= 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 156595200766566.49854330355936; Fri, 16 Aug 2019 03:40: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 227DB301A62E; Fri, 16 Aug 2019 10:40:06 +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 E216C173C5; Fri, 16 Aug 2019 10:40:05 +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 83C0B180BAA1; Fri, 16 Aug 2019 10:40:05 +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 x7GAdmtN021553 for ; Fri, 16 Aug 2019 06:39:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id A33E060C5D; Fri, 16 Aug 2019 10:39:48 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DC669F6B for ; Fri, 16 Aug 2019 10:39:46 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:28 +0200 Message-Id: <48920eb4cddf99012dd814b40316ab87ec6d8036.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 07/14] util: storage: Modify return value of virStorageSourceNewFromBacking 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 16 Aug 2019 10:40:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Return the storage source definition via a pointer in the arguments and document the returned values. This will simplify the possibility to ignore certain backing store types which are not representable by libvirt. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/storage/storage_util.c | 2 +- src/util/virstoragefile.c | 59 ++++++++++++++++++++++++-------------- src/util/virstoragefile.h | 4 ++- 3 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 62f857f9ea..24c5918aa3 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -3391,7 +3391,7 @@ storageBackendProbeTarget(virStorageSourcePtr target, return -1; if (meta->backingStoreRaw) { - if (!(target->backingStore =3D virStorageSourceNewFromBacking(meta= ))) + if (virStorageSourceNewFromBacking(meta, &target->backingStore) < = 0) return -1; target->backingStore->format =3D backingStoreFormat; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 6fff013e3a..4e57a0438e 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3679,42 +3679,57 @@ virStorageSourceNewFromBackingAbsolute(const char *= path) } -virStorageSourcePtr -virStorageSourceNewFromBacking(virStorageSourcePtr parent) +/** + * virStorageSourceNewFromBacking: + * @parent: storage source parent + * @backing: returned backing store definition + * + * Creates a storage source which describes the backing image of @parent a= nd + * fills it into @backing depending on the 'backingStoreRaw' property of @= parent + * and other data. Note that for local storage this function interrogates = the + * actual type of the backing store. + * + * Returns 0 and fills @backing, or -1 on error (with appropriate error re= ported). + */ +int +virStorageSourceNewFromBacking(virStorageSourcePtr parent, + virStorageSourcePtr *backing) { struct stat st; - virStorageSourcePtr ret =3D NULL; VIR_AUTOUNREF(virStorageSourcePtr) def =3D NULL; + *backing =3D NULL; + if (virStorageIsRelative(parent->backingStoreRaw)) def =3D virStorageSourceNewFromBackingRelative(parent, parent->backingStoreR= aw); else def =3D virStorageSourceNewFromBackingAbsolute(parent->backingStor= eRaw); - if (def) { - /* possibly update local type */ - if (def->type =3D=3D VIR_STORAGE_TYPE_FILE) { - if (stat(def->path, &st) =3D=3D 0) { - if (S_ISDIR(st.st_mode)) { - def->type =3D VIR_STORAGE_TYPE_DIR; - def->format =3D VIR_STORAGE_FILE_DIR; - } else if (S_ISBLK(st.st_mode)) { - def->type =3D VIR_STORAGE_TYPE_BLOCK; - } + if (!def) + return -1; + + /* possibly update local type */ + if (def->type =3D=3D VIR_STORAGE_TYPE_FILE) { + if (stat(def->path, &st) =3D=3D 0) { + if (S_ISDIR(st.st_mode)) { + def->type =3D VIR_STORAGE_TYPE_DIR; + def->format =3D VIR_STORAGE_FILE_DIR; + } else if (S_ISBLK(st.st_mode)) { + def->type =3D VIR_STORAGE_TYPE_BLOCK; } } + } - /* copy parent's labelling and other top level stuff */ - if (virStorageSourceInitChainElement(def, parent, true) < 0) - return NULL; + /* copy parent's labelling and other top level stuff */ + if (virStorageSourceInitChainElement(def, parent, true) < 0) + return -1; - def->readonly =3D true; - def->detected =3D true; - } + def->readonly =3D true; + def->detected =3D true; - VIR_STEAL_PTR(ret, def); - return ret; + VIR_STEAL_PTR(*backing, def); + return 0; } @@ -4899,7 +4914,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr = src, goto cleanup; if (src->backingStoreRaw) { - if (!(backingStore =3D virStorageSourceNewFromBacking(src))) + if (virStorageSourceNewFromBacking(src, &backingStore) < 0) goto cleanup; if (backingFormat =3D=3D VIR_STORAGE_FILE_AUTO) diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 2882bacf3e..3a72c62ad7 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -444,7 +444,9 @@ int virStorageSourceUpdateCapacity(virStorageSourcePtr = src, char *buf, ssize_t len, bool probe); -virStorageSourcePtr virStorageSourceNewFromBacking(virStorageSourcePtr par= ent); +int virStorageSourceNewFromBacking(virStorageSourcePtr parent, + virStorageSourcePtr *backing); + virStorageSourcePtr virStorageSourceCopy(const virStorageSource *src, bool backingChain) ATTRIBUTE_NONNULL(1); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:23:17 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565952009; cv=none; d=zoho.com; s=zohoarc; b=NPUTMEB/IBs2ijKYbrGQG/i59LSBPxwXjI7/E3Gi91SKohahTcNxffOVV2hdGPscfYgoSweEy+xxlVeQeTBVcwY+s/TZ5b2OV0K2ZOs6rpTr2/JaTPmWldEqWTArReoDP14GRHjBYfTqXM/jZjFYmszMJh1nCN/ooe9RdsBf4GI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565952009; 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=jwZJkmYZl4jflD/WlU4I33jFBqMmyghfnWyC5cfsfc8=; b=I+ttcvk2ZCGz0y5bNBzat45NKBcm+9HloeOgpmY5nfjLBaQFnJYl77peA+mLKajt8n0ZxNMCpiUh7FSoG+YrKFWp2PxaeiCz5Ad1szWJ3fJw9sXs3Fx1XZqEkTIedSMcgcCrspL1Fhjc7/c5IQDaQMA2kM/EVmfh8Y/aBhiOwq8= 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 1565952009385209.94051745093498; Fri, 16 Aug 2019 03:40:09 -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 0ACE63066F04; Fri, 16 Aug 2019 10:40:08 +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 D1892173C5; Fri, 16 Aug 2019 10:40:07 +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 87ABB1C8A; Fri, 16 Aug 2019 10:40:07 +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 x7GAdnr2021564 for ; Fri, 16 Aug 2019 06:39:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6F8589F6B; Fri, 16 Aug 2019 10:39:49 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEC6560C5D for ; Fri, 16 Aug 2019 10:39:48 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:29 +0200 Message-Id: <78a5ddab21d76175a60f05b34b0a9a791f18bef9.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 08/14] util: storagefile: Preserve return value in virStorageSourceParseBackingJSONUriStr 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 16 Aug 2019 10:40:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" virStorageSourceParseBackingURI will report special return values in some cases. Preserve it in virStorageSourceParseBackingJSONUriStr. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 4e57a0438e..192a79c025 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3073,7 +3073,9 @@ virStorageSourceParseBackingJSONUriStr(virStorageSour= cePtr src, const char *uri, int protocol) { - if (virStorageSourceParseBackingURI(src, uri) < 0) + int rc; + + if ((rc =3D virStorageSourceParseBackingURI(src, uri)) < 0) return -1; if (src->protocol !=3D protocol) { @@ -3085,7 +3087,7 @@ virStorageSourceParseBackingJSONUriStr(virStorageSour= cePtr src, return -1; } - return 0; + return rc; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:23:17 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; 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 From nobody Thu Apr 25 23:23:17 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565951999; cv=none; d=zoho.com; s=zohoarc; b=iyUmTyV8Qt4ttBalzomN61NdKnwt7QROYPKNNlyDVqav46O7mWNSkJV92odyJMLOVN3GJb2ZY8JCFfJwTDHjmWfb/wf2OaMR73HrCiVDk8Up6JBukj7NTApgOP4n3Hv1w9nlh/mtHcJ3gQ6Gwvqhp/55y63MBJaXVQkaM7ia9qQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565951999; 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=loK8DsLnhnYI1Kg97On6Cn89O+YKCLkTVCf6i2C6ns8=; b=lz+Dg1FZ5FGRUqLJ4AtMnxrdB3Jx1kvJe+64iV0PjgBPBfuVHIByrJoc7bfLajCifL/M2DjndwA6XDiXlFZTW3E32zu+JK9LRreBQVpST2Jokun8mlbhmTvBDx+PiMFtfbhmCYUre5ua8muYXa97XbNPDYXwCSlrHiCXIRiF1qw= 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 1565951999239429.5930465386016; Fri, 16 Aug 2019 03:39:59 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 985228666C; Fri, 16 Aug 2019 10:39:57 +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 7194317CCF; Fri, 16 Aug 2019 10:39:57 +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 1651F244A5; Fri, 16 Aug 2019 10:39:57 +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 x7GAdrCT021594 for ; Fri, 16 Aug 2019 06:39:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 29A8C9654D; Fri, 16 Aug 2019 10:39:53 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA028A4F9A for ; Fri, 16 Aug 2019 10:39:50 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:31 +0200 Message-Id: <4ea2e234c5855e8ff528bd3f731df098ffe33f21.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 10/14] tests: virstorage: Allow testing return value of virStorageSourceNewFromBackingAbsolute 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 16 Aug 2019 10:39:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Modiy testBackingParse to allow testing other return values of the backing store string parser. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virstoragetest.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 0495308318..be5cb98262 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -603,6 +603,7 @@ testPathRelative(const void *args) struct testBackingParseData { const char *backing; const char *expect; + int rv; }; static int @@ -612,14 +613,21 @@ testBackingParse(const void *args) VIR_AUTOCLEAN(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; VIR_AUTOFREE(char *) xml =3D NULL; VIR_AUTOUNREF(virStorageSourcePtr) src =3D NULL; + int rc; + int erc =3D data->rv; - if (virStorageSourceNewFromBackingAbsolute(data->backing, &src) < 0) { - if (!data->expect) - return 0; - else - return -1; + /* expect failure return code with NULL expected data */ + if (!data->expect) + erc =3D -1; + + if ((rc =3D virStorageSourceNewFromBackingAbsolute(data->backing, &src= )) !=3D erc) { + fprintf(stderr, "expected return value '%d' actual '%d'\n", erc, r= c); + return -1; } + if (!src) + return 0; + if (src && !data->expect) { fprintf(stderr, "parsing of backing store string '%s' should " "have failed\n", data->backing); @@ -1225,15 +1233,19 @@ mymain(void) virTestCounterReset("Backing store parse "); -#define TEST_BACKING_PARSE(bck, xml) \ +#define TEST_BACKING_PARSE_FULL(bck, xml, rc) \ do { \ data5.backing =3D bck; \ data5.expect =3D xml; \ + data5.rv =3D rc; \ if (virTestRun(virTestCounterNext(), \ testBackingParse, &data5) < 0) \ ret =3D -1; \ } while (0) +#define TEST_BACKING_PARSE(bck, xml) \ + TEST_BACKING_PARSE_FULL(bck, xml, 0) + TEST_BACKING_PARSE("path", "\n"); TEST_BACKING_PARSE("://", NULL); TEST_BACKING_PARSE("http://example.com", --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:23:17 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565952016; cv=none; d=zoho.com; s=zohoarc; b=HIVjvBOFONyWkPHmF6SqMWLXeSUkyLy+5F2MkzpBVKhP3wrjgNHsbo6TcJn5dZHcoMI1mllQftZT56v2MzOUiiPh9Li8ZeOZMmvfOAUcyfaMSiK9zL/Xr+yTZS1H2016j3axQ7Nx47aXBbF9OjkVTQHghUrB5KeaAnvD7e340Tw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565952016; 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=C4TdYFTYIdhplYHcf7+eshdWSYEaBYxi6Lh8AmtBXzs=; b=Ay4WW40fBxYJNwEmhhoDQmFf1RiN9THhI/z91mNrpegU2x7Cb5v4rPlKAGeh8hTFMuIt6guLA9i+NB5rzNjbv5/J0FZA6S3ewZf6ozQ5aKcE7VGQ68830Sl9zXJKIXnSCrh8ba2YtThm0m1dL0QIMHZ/Qqp3IGdMLcHTgcZ0kas= 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 1565952016088931.8351137737899; Fri, 16 Aug 2019 03:40:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF7C34FCD9; Fri, 16 Aug 2019 10:40:14 +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 A58A11001B17; Fri, 16 Aug 2019 10:40:14 +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 5C26AEEFD; Fri, 16 Aug 2019 10:40:14 +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 x7GAdrCN021601 for ; Fri, 16 Aug 2019 06:39:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id E9F75A4FA0; Fri, 16 Aug 2019 10:39:53 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 750829654D for ; Fri, 16 Aug 2019 10:39:53 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:32 +0200 Message-Id: <211d8f702f21c605e9bcad9817319019f75a583e.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 11/14] util: storagefile: Add handling of unusable storage sources 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 16 Aug 2019 10:40:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Introduce new semantics to virStorageSourceNewFromBacking and some of the helpers used by it which propagate the return value from the callers. The new return value introduced by this patch allows to notify the calller that the parsed virStorageSource correctly describes the source but contains data such as inline authentication which libvirt does not want to support directly. This means that such file would e.g. unusable as a storage source (e.g. when actively commiting the overlay to it) or would not work with blockdev. The caller will then be able to decide whether to consider this backing file as viable or just fall back to qemu dealing with it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 8447c014f0..fa0233376b 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3554,6 +3554,13 @@ virStorageSourceParseBackingJSONVxHS(virStorageSourc= ePtr src, struct virStorageSourceJSONDriverParser { const char *drvname; + /** + * The callback gets a pre-allocated storage source @src and the JSON + * object to parse. The callback shall return -1 on error and report e= rror + * 0 on success and 1 in cases when the configuration itself is valid,= but + * can't be converted to libvirt's configuration (e.g. inline authenti= cation + * credentials are present). + */ int (*func)(virStorageSourcePtr src, virJSONValuePtr json, int opaque); int opaque; }; @@ -3638,15 +3645,17 @@ virStorageSourceParseBackingJSON(virStorageSourcePt= r src, * @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. + * Returns 0 on success, 1 if we could parse all location data but @path + * specified other data unrepresentable by libvirt (e.g. inline authentica= tion). + * In both cases @src is filled. On error -1 is returned @src is NULL and = an + * error is reported. */ int virStorageSourceNewFromBackingAbsolute(const char *path, virStorageSourcePtr *src) { const char *json; - int rc; + int rc =3D 0; VIR_AUTOUNREF(virStorageSourcePtr) def =3D NULL; *src =3D NULL; @@ -3687,7 +3696,7 @@ virStorageSourceNewFromBackingAbsolute(const char *pa= th, } VIR_STEAL_PTR(*src, def); - return 0; + return rc; } @@ -3701,7 +3710,11 @@ virStorageSourceNewFromBackingAbsolute(const char *p= ath, * and other data. Note that for local storage this function interrogates = the * actual type of the backing store. * - * Returns 0 and fills @backing, or -1 on error (with appropriate error re= ported). + * Returns 0 on success, 1 if we could parse all location data but the bac= kinig + * 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, @@ -3709,6 +3722,7 @@ virStorageSourceNewFromBacking(virStorageSourcePtr pa= rent, { struct stat st; VIR_AUTOUNREF(virStorageSourcePtr) def =3D NULL; + int rc =3D 0; *backing =3D NULL; @@ -3717,8 +3731,8 @@ virStorageSourceNewFromBacking(virStorageSourcePtr pa= rent, parent->backing= StoreRaw))) return -1; } else { - if (virStorageSourceNewFromBackingAbsolute(parent->backingStoreRaw, - &def) < 0) + if ((rc =3D virStorageSourceNewFromBackingAbsolute(parent->backing= StoreRaw, + &def)) < 0) return -1; } @@ -3742,7 +3756,7 @@ virStorageSourceNewFromBacking(virStorageSourcePtr pa= rent, def->detected =3D true; VIR_STEAL_PTR(*backing, def); - return 0; + return rc; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:23:17 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565952002; cv=none; d=zoho.com; s=zohoarc; b=PRaC9GvH2l5NaHYiKlDcW4RhwPubcRmapnF/CKRsJm9PUGZEyQYQfiFk88fua7mqDMzx232rhWyT7ywEWU5qeY5bFZb/ugrEBKY9Vqb/m68sfY9JzCGSYXtRSueB8iwZbIdMElUweyQNcQX2YZak2w1toou35CGGhD0REGeRbTE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565952002; 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=sNeLMyE119q0F6nNVycbVXeIl75oA6RV/t62pFEHYEg=; b=Y9u4/vh4m2iY0Jbr0umgmoaBOsdVVac32U498e3zUxqBJZG3x2XrUia+tF7j/lqE41k0pPfpcR5TpPyD8pH5cKAYZCP9ItlmBytsLXhWyB3nbvDyqz8z6pb+BbLpvEWjGAs+YvuXvyeXWWy9BU06D8z1koWZsNlnKTNGx43D8Xo= 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 1565952002295204.69174665941114; Fri, 16 Aug 2019 03:40:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED9933091753; Fri, 16 Aug 2019 10:40:00 +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 B843C43FF7; Fri, 16 Aug 2019 10:40:00 +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 74EF5180BA9B; Fri, 16 Aug 2019 10:40:00 +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 x7GAdsWI021609 for ; Fri, 16 Aug 2019 06:39:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id B5578A4F96; Fri, 16 Aug 2019 10:39:54 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4151D9654D for ; Fri, 16 Aug 2019 10:39:54 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:33 +0200 Message-Id: <815f80a444257a2737ee69850c8ddfb5a0479abf.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 12/14] util: storagefile: Clarify docs for '@report_broken' of virStorageFileGetMetadata 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 16 Aug 2019 10:40:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" virStorageFileGetMetadata does not report error if we can't interrogate the file somehow. Clarify this in the description of the @report_broken flag as it implies we should report an error in that case. The problem is that we don't know whether there's a problem and unforntnately just offload it to qemu. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index fa0233376b..32afee1ca7 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4996,7 +4996,8 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr = src, * other non-raw format at will. * * If @report_broken is true, the whole function fails with a possibly sane - * error instead of just returning a broken chain. + * error instead of just returning a broken chain. Note that the inability= for + * libvirt to traverse a given source is not considered an error. * * Caller MUST free result after use via virObjectUnref. */ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:23:17 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565952014; cv=none; d=zoho.com; s=zohoarc; b=Sbqt+PIkmnfLbXlotda6O1rn5FT+0Tsln8ByDh+lgURiCQ1wTyte06fXAR6KOuzuiNuQs7Yq58L+7+np8PyPcG1DjxypyTtTCMfkxHRF6IaPl5CVs7uIG+FaQ4lUj5vW3bsNmvu4iYjV1Doro29Q9iNn9u9mQ3I+7IDLmjGIsMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565952014; 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=jZUFvBtFOsaDNXcZbJYn+IKKQ3J8rSuribn7M7aGq3Q=; b=PrSROQrFJm9oIMuoXDiJQPQekjiQ9zYq7EdX4nc0wV7dAJOZpAjIQM8/8aHyY7GsQUr/lOrQH4tU4hCLL6d+OIc7yfxWlRwT9tk/fVIVzrjBnBg6ymdTHuUYj6H+1ehIJHsKxaEPeYa+vEs11VCzxJKS1pc58Fs9Ya7zOy2xKAs= 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 15659520145121.5457698336044814; Fri, 16 Aug 2019 03:40:14 -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 117A5796EF; Fri, 16 Aug 2019 10:40:13 +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 D431160C5D; Fri, 16 Aug 2019 10:40:12 +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 83BF5180BAA6; Fri, 16 Aug 2019 10:40:12 +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 x7GAe04u021636 for ; Fri, 16 Aug 2019 06:40:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 966BDA4F9C; Fri, 16 Aug 2019 10:40:00 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 224049654D for ; Fri, 16 Aug 2019 10:39:54 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:34 +0200 Message-Id: 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 13/14] util: storagefile: Don't traverse storage sources unusable by VM 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.25]); Fri, 16 Aug 2019 10:40:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" virStorageFileGetMetadataRecurse would include in the backing chain files which would not really be usable by libvirt directly e.g. when such file would be promoted to the top layer by a active block commit as for example inline authentication data can't be represented in the VM xml file. The idea is to use secrets for this. With the changes to the backing store string parsers we can report and propagate if such a thing is present in the configuration and thus start skipping those files in the backing chain traversal code. This approach still allows to report the appropriate backing store string in the storage driver which doesn't directly use the backing file. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 32afee1ca7..efc1d84048 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4941,9 +4941,15 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr= src, goto cleanup; if (src->backingStoreRaw) { - if (virStorageSourceNewFromBacking(src, &backingStore) < 0) + if ((rv =3D virStorageSourceNewFromBacking(src, &backingStore)) < = 0) goto cleanup; + if (rv =3D=3D 1) { + /* the backing file would not be usable for VM usage */ + ret =3D 0; + goto cleanup; + } + if (backingFormat =3D=3D VIR_STORAGE_FILE_AUTO) backingStore->format =3D VIR_STORAGE_FILE_RAW; else if (backingFormat =3D=3D VIR_STORAGE_FILE_AUTO_SAFE) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:23:17 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565952018; cv=none; d=zoho.com; s=zohoarc; b=T4VwC2fR+9+R9EbrgMbCj87r5lx8gRzWvxbUPZOQv70kXlG+dBgKw7apVRfCpszosp2erxJgRVV1PGPcyft1GXhBQ4mOef/Z3j+cSta7lXl69s7cttcS8qckOOQVM5sxGIFSV7XQD4uycVRGCPzhw6sXKDOCAUFe9edMfTxF4rQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565952018; 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=K5+vADlCY03Sgtgy5o9bfQUiz+qSYq7/GuFFwVOmPDk=; b=d/jbEMQZoY1THOu4yLNpaO1vuS8C0DzdpoDn9s+paOBPzW73oOIzVh5ZLMxjKwkRghH0OSJIfUwPoe0DQGE23WibTvzpJpRS/7wOrpbrmMqLr+xHFy+9RBVPPRinZdGZg76UEt3eUFUAYAwIaYikbjLPDS10fdPvnNG7WpGjkIg= 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 156595201847579.32648533594045; Fri, 16 Aug 2019 03:40:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D13FB300177F; Fri, 16 Aug 2019 10:40:16 +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 A6B00100197A; Fri, 16 Aug 2019 10:40:16 +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 5C5C6E203; Fri, 16 Aug 2019 10:40:16 +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 x7GAe3Wu021652 for ; Fri, 16 Aug 2019 06:40:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id C62F6A4FA6; Fri, 16 Aug 2019 10:40:03 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DAB1A4FA4 for ; Fri, 16 Aug 2019 10:40:00 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 12:39:35 +0200 Message-Id: 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 14/14] util: storagefile: Flag backing store strings with authentication 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 16 Aug 2019 10:40:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Using inline authentication for storage volumes will not work properly as libvirt requires use of the secret driver for the auth data and thus would not be able to represent the passwords stored in the backing store string. Make sure that the backing store parsers return 1 which is a sign for the caller to not use the file in certain cases. The test data include iscsi via a json pseudo-protocol string and URIs with the userinfo part being present. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 11 +++++++++-- tests/virstoragetest.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index efc1d84048..437dcc015d 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2705,8 +2705,6 @@ virStorageSourceParseBackingURI(virStorageSourcePtr s= rc, return -1; } - /* XXX We currently don't support auth, so don't bother parsing it */ - /* uri->path is NULL if the URI does not contain slash after host: * transport://host:port */ if (uri->path) @@ -2756,6 +2754,10 @@ virStorageSourceParseBackingURI(virStorageSourcePtr = src, if (VIR_STRDUP(src->hosts->name, uri->server) < 0) return -1; + /* Libvirt doesn't handle inline authentication. Make the caller aware= . */ + if (uri->user) + return 1; + return 0; } @@ -3311,6 +3313,11 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSour= cePtr src, if (virAsprintf(&src->path, "%s/%s", target, lun) < 0) return -1; + /* Libvirt doesn't handle inline authentication. Make the caller aware= . */ + if (virJSONValueObjectGetString(json, "user") || + virJSONValueObjectGetString(json, "password")) + return 1; + return 0; } diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index be5cb98262..1d06abe8b6 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1260,6 +1260,10 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE_FULL("http://user:pass@example.com/file", + "\n" + " \n" + "\n", 1); TEST_BACKING_PARSE("rbd:testshare:id=3Dasdf:mon_host=3Dexample.com", "\n" " \n" @@ -1280,6 +1284,10 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE_FULL("iscsi://testuser:testpass@example.org:1234/ex= portname", + "\n" + " \= n" + "\n", 1); #ifdef WITH_YAJL TEST_BACKING_PARSE("json:", NULL); @@ -1484,6 +1492,26 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE_FULL("json:{\"file\":{\"driver\":\"iscsi\"," + "\"transport\":\"tcp\"," + "\"portal\":\"test.org\"," + "\"user\":\"testuser\"," + "\"target\":\"iqn.2016-12.com.= virttest:emulated-iscsi-auth.target\"" + "}" + "}", + "\n" + " \n" + "\n", 1); + TEST_BACKING_PARSE_FULL("json:{\"file\":{\"driver\":\"iscsi\"," + "\"transport\":\"tcp\"," + "\"portal\":\"test.org\"," + "\"password\":\"testpass\"," + "\"target\":\"iqn.2016-12.com.= virttest:emulated-iscsi-auth.target\"" + "}" + "}", + "\n" + " \n" + "\n", 1); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\"," "\"transport\":\"tcp\"," "\"portal\":\"test.org:1234\"," --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list