From nobody Sun Apr 28 07:47:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1598327457; cv=none; d=zohomail.com; s=zohoarc; b=DhT+Qq6Ik0He0ZuVwdvPWvVrcjGRwyeYkoBa7GNT2ifqkwULpgY1d0IstX5fI0krM8VH7jiVILQeq+cK/rpVHpxmhKjhDEfNW2y71qrthcuHDCMU64Fu8r8oFKDt0J9bAab7pgNYWijoAdXIlDlrVVVS+gv9g0PbmjA6hYuBcJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598327457; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=xgK1SgCikq7O1bzczazQi/7L3e2gVo6nbK5glWNQbKk=; b=Hk2E4cQOLSH6EzX9mdEQgF2klxIPJ5GHRY/w+WlPcxDOUEq+sG8q9lM4wtgCRJQhZxQwutq9Ph08v7XBC9GFq4jxdv042xccS/tilF5u47ZNDuLwoF149SaudLus9455Q7srLvBXcTMP8FDR0sS/9pG7O7Zzfsn9bz0//VtQOVU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1598327457297434.65330887750576; Mon, 24 Aug 2020 20:50:57 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-499-AwtHO2N7NYeuGItloe0dDQ-1; Mon, 24 Aug 2020 23:50:52 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D8A4C1DDFC; Tue, 25 Aug 2020 03:50: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 7D2F360C05; Tue, 25 Aug 2020 03:50: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 1B6FC180B656; Tue, 25 Aug 2020 03:50:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07P3od1W024916 for ; Mon, 24 Aug 2020 23:50:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id EABCC62A13; Tue, 25 Aug 2020 03:50:39 +0000 (UTC) Received: from hansolo.redhat.com (ovpn-13-50.pek2.redhat.com [10.72.13.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D0D75BAC3; Tue, 25 Aug 2020 03:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598327454; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xgK1SgCikq7O1bzczazQi/7L3e2gVo6nbK5glWNQbKk=; b=VGrwgSb41CECnmC6pYrX1SAZyeaBgRCe4WzLnMTBbglYEqvIQ8FSx7rhXwB4We8yLiY94X FI/F8nlTHXxy27BmDBmuhqwR+Wh6AJsBsA2lM6lqQm2hR1N3wCSyuXg5UFs16Cim2Sh9hl XEnqiwzI/afB+9ZFO6u/DwVfOCw8L8M= X-MC-Unique: AwtHO2N7NYeuGItloe0dDQ-1 From: Han Han To: libvir-list@redhat.com Subject: [PATCH] virsh: Add source-initiator opt to build the initiator of pool XML Date: Tue, 25 Aug 2020 11:50:33 +0800 Message-Id: <20200825035033.547105-1-hhan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Han Han X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" For iscsi-direct pool, the initiator is necessary for pool defining: ... ... Add --source-initiator to fill the initiator iqn for pool-create-as/pool-define-as subcommands. https://bugzilla.redhat.com/show_bug.cgi?id=3D1658082 Signed-off-by: Han Han Reviewed-by: Michal Privoznik --- docs/manpages/virsh.rst | 5 +++++ tools/virsh-pool.c | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 9187037a56..0482fe8b26 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5732,6 +5732,7 @@ pool-create-as pool-create-as name type [--source-host hostname] [--source-path path] [--source-dev path] [--source-name name] [--target path] [--source-format format] + [--source-initiator initiator-iqn] [--auth-type authtype --auth-username username [--secret-usage usage | --secret-uuid uuid]] [--source-protocol-ver ver] @@ -5769,6 +5770,9 @@ the host file system. [*--source-format format*] provides information about the format of the pool (pool types fs, netfs, disk, logical). =20 +[*--source-initiator initiator-iqn*] provides the initiator iqn for iscsi +connection of the pool (pool type iscsi-direct). + [*--auth-type authtype* *--auth-username username* [*--secret-usage usage* | *--secret-uuid uuid*]] provides the elements required to generate authentication credentials for @@ -5831,6 +5835,7 @@ pool-define-as pool-define-as name type [--source-host hostname] [--source-path path] [--source-dev path] [*--source-name name*] [*--target path*] [*--source-format format*] + [--source-initiator initiator-iqn] [*--auth-type authtype* *--auth-username username* [*--secret-usage usage* | *--secret-uuid uuid*]] [*--source-protocol-ver ver*] diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index fd43d3bb62..a7e0aa3010 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -141,6 +141,10 @@ {.name =3D "source-protocol-ver", \ .type =3D VSH_OT_STRING, \ .help =3D N_("nfsvers value for NFS pool mount option") \ + }, \ + {.name =3D "source-initiator", \ + .type =3D VSH_OT_STRING, \ + .help =3D N_("initiator iqn for underlying storage") \ } =20 virStoragePoolPtr @@ -324,7 +328,8 @@ virshBuildPoolXML(vshControl *ctl, *secretUsage =3D NULL, *adapterName =3D NULL, *adapterParen= t =3D NULL, *adapterWwnn =3D NULL, *adapterWwpn =3D NULL, *secretUUID = =3D NULL, *adapterParentWwnn =3D NULL, *adapterParentWwpn =3D NULL, - *adapterParentFabricWwn =3D NULL, *protoVer =3D NULL; + *adapterParentFabricWwn =3D NULL, *protoVer =3D NULL, + *srcInitiator =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 VSH_EXCLUSIVE_OPTIONS("secret-usage", "secret-uuid"); @@ -352,7 +357,8 @@ virshBuildPoolXML(vshControl *ctl, vshCommandOptStringReq(ctl, cmd, "adapter-parent-wwnn", &adapterPa= rentWwnn) < 0 || vshCommandOptStringReq(ctl, cmd, "adapter-parent-wwpn", &adapterPa= rentWwpn) < 0 || vshCommandOptStringReq(ctl, cmd, "adapter-parent-fabric-wwn", &ada= pterParentFabricWwn) < 0 || - vshCommandOptStringReq(ctl, cmd, "source-protocol-ver", &protoVer)= < 0) { + vshCommandOptStringReq(ctl, cmd, "source-protocol-ver", &protoVer)= < 0 || + vshCommandOptStringReq(ctl, cmd, "source-initiator", &srcInitiator= ) < 0) { return false; } =20 @@ -370,6 +376,13 @@ virshBuildPoolXML(vshControl *ctl, virBufferAsprintf(&buf, "\n", srcPath); if (srcDev) virBufferAsprintf(&buf, "\n", srcDev); + if (srcInitiator) { + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, 2); + virBufferAsprintf(&buf, "\n", srcInitiator); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "\n"); + } if (adapterWwnn && adapterWwpn) { virBufferAddLit(&buf, "