From nobody Mon Dec 15 01:52:39 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534112847584124.79211484699329; Sun, 12 Aug 2018 15:27:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62DD681DE9; Sun, 12 Aug 2018 22:27:25 +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 33066A0B43; Sun, 12 Aug 2018 22:27:25 +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 D5DD218052EA; Sun, 12 Aug 2018 22:27:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7CMRNuG008541 for ; Sun, 12 Aug 2018 18:27:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 84C1D765C4; Sun, 12 Aug 2018 22:27:23 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7CD06765C3 for ; Sun, 12 Aug 2018 22:27:18 +0000 (UTC) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 37EA5C015C24 for ; Sun, 12 Aug 2018 22:27:17 +0000 (UTC) Received: by mail-wr1-f51.google.com with SMTP id h15-v6so12672630wrs.7 for ; Sun, 12 Aug 2018 15:27:17 -0700 (PDT) Received: from clem.localdomain ([2a01:e34:ec25:e330:f2d5:bfff:fe6e:3278]) by smtp.gmail.com with ESMTPSA id l5-v6sm5120340wmh.0.2018.08.12.15.27.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Aug 2018 15:27:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PaZStQDo06mO1iHnkybMt6lFBp0g5IUyUf3ERxq4QrY=; b=TpumbNde1u3d4rbzK5mt8ZcMq1QssSCrSKHKXFC/nS+dX9VAewzYe2VvsDa0+xedF7 PoD7F03euAaGMJfi71DiVr8Z2a+ECaT1DWCdJO98sHdZlYq73vL2GIwNtuuJu22YkhDh wZwiPCGdbUzlblAO5JFOf8UfXwTZITuEssLwtTNWkVC23YplAd72VVoOHPrd/p0bsWgm UMRgDMOIwu6hSCx3ElCTMioiOX4J4kSldkgnEEHbGuNzil+ULZKj/UcpxLyiggXUzS1S vEbPw8Fsgr+NSDed/OK0746jSLA5TGZiZ8Q7P98X9NtQcYvxn63Zwf6IhKvCAmP7x1fh /0aQ== X-Gm-Message-State: AOUpUlEEwBTTzLdO87QCvU2VWZ8HyNMpBMaWxbX+cLCqiYi04gZzqXbI tGvePVuRiCCnwedVTwBm6+Oijhbh X-Google-Smtp-Source: AA+uWPyOXNrvgAEypO43LCJyowGvIvClWJZIdbODScGg8t1Yv+Ec3HoeboG7dbEIXENWi09rX8K92A== X-Received: by 2002:adf:d1cf:: with SMTP id m15-v6mr9962446wri.138.1534112835525; Sun, 12 Aug 2018 15:27:15 -0700 (PDT) From: clem@lse.epita.fr To: libvir-list@redhat.com Date: Mon, 13 Aug 2018 00:26:17 +0200 Message-Id: <20180812222618.13625-3-clem@lse.epita.fr> In-Reply-To: <20180812222618.13625-1-clem@lse.epita.fr> References: <20180812222618.13625-1-clem@lse.epita.fr> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 12 Aug 2018 22:27:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 12 Aug 2018 22:27:17 +0000 (UTC) for IP:'209.85.221.51' DOMAIN:'mail-wr1-f51.google.com' HELO:'mail-wr1-f51.google.com' FROM:'clementinehayat@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.008 (FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.221.51 mail-wr1-f51.google.com 209.85.221.51 mail-wr1-f51.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Clementine Hayat Subject: [libvirt] [PATCH v3 2/3] storage: add SetConnection to iscsi-direct backend X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 12 Aug 2018 22:27:25 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Clementine Hayat The code to set the connection and connect using libiscsi will always be the same. Add function to avoid code duplication. Signed-off-by: Clementine Hayat --- src/storage/storage_backend_iscsi_direct.c | 38 +++++++++++++++------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/stora= ge_backend_iscsi_direct.c index 62b7e0d8bc..7bdd39582b 100644 --- a/src/storage/storage_backend_iscsi_direct.c +++ b/src/storage/storage_backend_iscsi_direct.c @@ -557,23 +557,37 @@ virStorageBackendISCSIDirectFindPoolSources(const cha= r *srcSpec, return ret; } =20 +struct iscsi_context * +virStorageBackendISCSIDirectSetConnection(virStoragePoolObjPtr pool, + char **portal) +{ + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + struct iscsi_context *iscsi =3D NULL; + + if (!(*iscsi =3D virISCSIDirectCreateContext(def->source.initiator.iqn= ))) + return iscsi; + if (!(*portal =3D virStorageBackendISCSIDirectPortal(&def->source))) + goto error ; + if (virStorageBackendISCSIDirectSetAuth(*iscsi, &def->source) < 0) + goto error ; + if (virISCSIDirectSetContext(*iscsi, def->source.devices[0].path, ISCS= I_SESSION_NORMAL) < 0) + goto error ; + if (virISCSIDirectConnect(*iscsi, *portal) < 0) + goto error ; + return iscsi; + + error: + iscsi_destroy_context(iscsi); + return iscsi; +} + static int virStorageBackendISCSIDirectRefreshPool(virStoragePoolObjPtr pool) { - virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); struct iscsi_context *iscsi =3D NULL; char *portal =3D NULL; int ret =3D -1; - - if (!(iscsi =3D virISCSIDirectCreateContext(def->source.initiator.iqn)= )) - goto cleanup; - if (!(portal =3D virStorageBackendISCSIDirectPortal(&def->source))) - goto cleanup; - if (virStorageBackendISCSIDirectSetAuth(iscsi, &def->source) < 0) - goto cleanup; - if (virISCSIDirectSetContext(iscsi, def->source.devices[0].path, ISCSI= _SESSION_NORMAL) < 0) - goto cleanup; - if (virISCSIDirectConnect(iscsi, portal) < 0) + if (!(iscsi =3D virStorageBackendISCSIDirectSetConnection(pool, &porta= l))) goto cleanup; if (virISCSIDirectReportLuns(pool, iscsi, portal) < 0) goto disconect; @@ -581,9 +595,9 @@ virStorageBackendISCSIDirectRefreshPool(virStoragePoolO= bjPtr pool) ret =3D 0; disconect: virISCSIDirectDisconnect(iscsi); + iscsi_destroy_context(iscsi); cleanup: VIR_FREE(portal); - iscsi_destroy_context(iscsi); return ret; } =20 --=20 2.18.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list