From nobody Tue May 7 17:01:55 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; dkim=fail; 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 1513144404399991.9778875473684; Tue, 12 Dec 2017 21:53:24 -0800 (PST) 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 F08E864049; Wed, 13 Dec 2017 05:53:21 +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 42EC07D893; Wed, 13 Dec 2017 05:53:20 +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 77C10180474A; Wed, 13 Dec 2017 05:53:17 +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 vBD5rFfD028543 for ; Wed, 13 Dec 2017 00:53:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id E1E0E52FCD; Wed, 13 Dec 2017 05:53:15 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D9C397BA34 for ; Wed, 13 Dec 2017 05:53:14 +0000 (UTC) Received: from mail-it0-f47.google.com (mail-it0-f47.google.com [209.85.214.47]) (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 C35B6C0587C9 for ; Wed, 13 Dec 2017 05:53:12 +0000 (UTC) Received: by mail-it0-f47.google.com with SMTP id 68so2257795ite.4 for ; Tue, 12 Dec 2017 21:53:12 -0800 (PST) Received: from localhost.localdomain ([210.12.16.251]) by smtp.gmail.com with ESMTPSA id f206sm433505ioa.32.2017.12.12.21.53.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Dec 2017 21:53:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iRd2L34wF8KxksGFnz1LzS7phrDuITRhZhnqrHBYT54=; b=dLtndDBUBuypWHsyviUBqGKfPhmm+oh6zOrHws++eujqOaHzF6sp6GTRojgNk5ln/Y o7lPrWst6/swZJjbamaxFE1fwSPrRgZ9lHo5QunmFY7+RAGN0qp2uzJHHOhIHkYK56Zx sbyGTzBrGK3wSTfXMABkVhsJ+cMFk7rb+OAntWy4fbLipuurXw3B/i9YAItnIYi3bkdm cRIsHExa5Bv19ds6AlQDsWmdLBiq5OR16Jaxcke0rfaYDLZYCy3Dx571U78FahjozbP7 UeM0FzRusE23Tza/ZLo14DWokyGDSRxtuMl3+Mi2hlf3p3n2+jxCnwtwWMgVs+szo6WR p35Q== 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=iRd2L34wF8KxksGFnz1LzS7phrDuITRhZhnqrHBYT54=; b=C6euSqItFZldR+5cXJdXAygVBCAzjI59vsYpYnagKTTfwFUCZqqsODmbMGDDhmkrrq FH2veU/ZaiQfphJw8cUlv4lqHrkALuGNBd3lLDLD1y7A1xs8ohHnu+/+U+GoDMRVVMUB dtjuib9BggV6+Tk9PmkaK0ZRjJvLXGbnv87CH19UB6I0OlMtZcBw8+INH42cZKLCV8jw ABuUh0Mril8sTifEUx1BDskoc0c7C5kBGO3rrVE4pYiw62HHuFSve3RE9kypZibornHB IomosYtwNL+XycaYWfUmRb+frRxcNyDRRIwwqgUK7MyyVXC7GohVjaG3OyhxS7kWOzIe zciA== X-Gm-Message-State: AKGB3mKxvtSK9CCpcFuMSDUTqbgGHuvpF3vzxmmqMR9RyqJCOJq9VA/r q3o63pkX1uQOdBSJY/IBxO//1oan7b0= X-Google-Smtp-Source: ACJfBosNKBMpIP8Ns5QUkcmGXQrd9BgKgLDFZuoBSOnmX9ncwjqAzuC7ZkbbCsHSYNk4JlXkNG49Rw== X-Received: by 10.36.125.129 with SMTP id b123mr1649892itc.142.1513144391950; Tue, 12 Dec 2017 21:53:11 -0800 (PST) From: lichstor@gmail.com To: libvir-list@redhat.com Date: Wed, 13 Dec 2017 13:52:55 +0800 Message-Id: <20171213055255.41083-2-lichstor@gmail.com> In-Reply-To: <20171213055255.41083-1-lichstor@gmail.com> References: <20171213055255.41083-1-lichstor@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 13 Dec 2017 05:53:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 13 Dec 2017 05:53:13 +0000 (UTC) for IP:'209.85.214.47' DOMAIN:'mail-it0-f47.google.com' HELO:'mail-it0-f47.google.com' FROM:'lichstor@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.214.47 mail-it0-f47.google.com 209.85.214.47 mail-it0-f47.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: zhangshengyu Subject: [libvirt] [PATCH 1/1] add support for iSER block type. 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.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.25]); Wed, 13 Dec 2017 05:53:23 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: zhangshengyu --- src/conf/domain_conf.c | 8 ++++- src/qemu/qemu_block.c | 3 +- src/qemu/qemu_command.c | 3 +- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_driver.c | 3 ++ src/qemu/qemu_parse_command.c | 7 ++++ src/util/virstoragefile.c | 75 +++++++++++++++++++++++++++++++++++++++= ++++ src/util/virstoragefile.h | 1 + 8 files changed, 98 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 66e21c4bd..c83ce5718 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4554,6 +4554,11 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDef= Ptr dev, disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI && virDomainPostParseCheckISCSIPath(&disk->src->path) < 0) return -1; +=09 + if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && + disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISER && + virDomainPostParseCheckISCSIPath(&disk->src->path) < 0) + return -1; =20 if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO && virDomainCheckVirtioOptions(disk->virtio) < 0) @@ -5160,7 +5165,8 @@ virDomainDiskDefValidate(const virDomainDiskDef *disk) if (!(disk->src->type =3D=3D VIR_STORAGE_TYPE_BLOCK || disk->src->type =3D=3D VIR_STORAGE_TYPE_VOLUME || (disk->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && - disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI))= ) { + (disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI = || + disk->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISER)))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk '%s' improperly configured for a " "device=3D'lun'"), disk->dst); diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 585f0255e..a9543293d 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -831,7 +831,7 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr= src) "s:portal", portal, "s:target", target, "u:lun", lun, - "s:transport", "tcp", + "s:transport", src->protocol =3D= =3D VIR_STORAGE_NET_PROTOCOL_ISER? "iser":"tcp", "S:user", username, "S:password-secret", objalias, NULL)); @@ -1030,6 +1030,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourc= ePtr src) break; =20 case VIR_STORAGE_NET_PROTOCOL_ISCSI: + case VIR_STORAGE_NET_PROTOCOL_ISER: if (!(fileprops =3D qemuBlockStorageSourceGetISCSIProps(src))) return NULL; break; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 645802795..a21ba0ae4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -932,6 +932,7 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src, case VIR_STORAGE_NET_PROTOCOL_FTPS: case VIR_STORAGE_NET_PROTOCOL_TFTP: case VIR_STORAGE_NET_PROTOCOL_ISCSI: + case VIR_STORAGE_NET_PROTOCOL_ISER: case VIR_STORAGE_NET_PROTOCOL_GLUSTER: ret =3D qemuBuildNetworkDriveURI(src, secinfo); break; @@ -1482,7 +1483,7 @@ qemuDiskSourceNeedsProps(virStorageSourcePtr src, return true; =20 if (actualType =3D=3D VIR_STORAGE_TYPE_NETWORK && - src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI && + (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI || src->proto= col =3D=3D VIR_STORAGE_NET_PROTOCOL_ISER) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_ISCSI_PASSWORD_SECRET)) return true; =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d7150cae1..76b2a6cc9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8133,7 +8133,7 @@ int qemuDomainDefValidateDiskLunSource(const virStorageSource *src) { if (virStorageSourceGetActualType(src) =3D=3D VIR_STORAGE_TYPE_NETWORK= ) { - if (src->protocol !=3D VIR_STORAGE_NET_PROTOCOL_ISCSI) { + if (src->protocol !=3D VIR_STORAGE_NET_PROTOCOL_ISCSI && src->prot= ocol !=3D VIR_STORAGE_NET_PROTOCOL_ISER) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk device=3D'lun' is not supported " "for protocol=3D'%s'"), diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index aa30b119a..104b73ebe 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13983,6 +13983,7 @@ qemuDomainSnapshotPrepareDiskExternalInactive(virDo= mainSnapshotDiskDefPtr snapdi case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: case VIR_STORAGE_NET_PROTOCOL_GLUSTER: case VIR_STORAGE_NET_PROTOCOL_ISCSI: + case VIR_STORAGE_NET_PROTOCOL_ISER: case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: case VIR_STORAGE_NET_PROTOCOL_FTP: @@ -14060,6 +14061,7 @@ qemuDomainSnapshotPrepareDiskExternalActive(virDoma= inSnapshotDiskDefPtr snapdisk case VIR_STORAGE_NET_PROTOCOL_RBD: case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: case VIR_STORAGE_NET_PROTOCOL_ISCSI: + case VIR_STORAGE_NET_PROTOCOL_ISER: case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: case VIR_STORAGE_NET_PROTOCOL_FTP: @@ -14178,6 +14180,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr= conn, case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: case VIR_STORAGE_NET_PROTOCOL_GLUSTER: case VIR_STORAGE_NET_PROTOCOL_ISCSI: + case VIR_STORAGE_NET_PROTOCOL_ISER: case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: case VIR_STORAGE_NET_PROTOCOL_FTP: diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index 5fe3f97d0..72e137ce4 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -709,6 +709,12 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, =20 if (qemuParseISCSIString(def) < 0) goto error; + } else if (STRPREFIX(def->src->path, "iser:")) { + def->src->type =3D VIR_STORAGE_TYPE_NETWORK; + def->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISER; + + if (qemuParseISCSIString(def) < 0) + goto error; } else if (STRPREFIX(def->src->path, "sheepdog:")) { char *p =3D def->src->path; char *port, *vdi; @@ -2157,6 +2163,7 @@ qemuParseCommandLine(virCapsPtr caps, goto error; =20 break; + case VIR_STORAGE_NET_PROTOCOL_ISER: case VIR_STORAGE_NET_PROTOCOL_ISCSI: if (qemuParseISCSIString(disk) < 0) goto error; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 6594715e5..cf5c2904e 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -81,6 +81,7 @@ VIR_ENUM_IMPL(virStorageNetProtocol, VIR_STORAGE_NET_PROT= OCOL_LAST, "sheepdog", "gluster", "iscsi", + "iser", "http", "https", "ftp", @@ -2750,6 +2751,7 @@ virStorageSourceParseBackingColon(virStorageSourcePtr= src, case VIR_STORAGE_NET_PROTOCOL_FTPS: case VIR_STORAGE_NET_PROTOCOL_TFTP: case VIR_STORAGE_NET_PROTOCOL_ISCSI: + case VIR_STORAGE_NET_PROTOCOL_ISER: case VIR_STORAGE_NET_PROTOCOL_GLUSTER: case VIR_STORAGE_NET_PROTOCOL_SSH: case VIR_STORAGE_NET_PROTOCOL_VXHS: @@ -3040,6 +3042,77 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSour= cePtr src, return ret; } =20 +static int=20 +virStorageSourceParseBackingJSONiSER(virStorageSourcePtr src, + virJSONValuePtr json, + int opaque ATTRIBUTE_UNUSED) +{ + const char *transport =3D virJSONValueObjectGetString(json, "transport= "); + const char *portal =3D virJSONValueObjectGetString(json, "portal"); + const char *target =3D virJSONValueObjectGetString(json, "target"); + const char *uri; + char *port; + unsigned int lun =3D 0; + char *fulltarget =3D NULL; + int ret =3D -1; + + /* legacy URI based syntax passed via 'filename' option */ + if ((uri =3D virJSONValueObjectGetString(json, "filename"))) + return virStorageSourceParseBackingJSONUriStr(src, uri, + VIR_STORAGE_NET_PROT= OCOL_ISER); + + src->type =3D VIR_STORAGE_TYPE_NETWORK; + src->protocol =3D VIR_STORAGE_NET_PROTOCOL_ISER; + + if (VIR_ALLOC(src->hosts) < 0) + goto cleanup; + + src->nhosts =3D 1; + + if (STRNEQ_NULLABLE(transport, "iser")) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("only ISER transport is supported for iSER volume= s")); + goto cleanup; + } + + src->hosts->transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; + + if (!portal) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing 'portal' address in iSER backing definit= ion")); + goto cleanup; + } + + if (!target) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing 'target' in iSER backing definition")); + goto cleanup; + } + + if (VIR_STRDUP(src->hosts->name, portal) < 0) + goto cleanup; + + if ((port =3D strrchr(src->hosts->name, ':')) && + !strchr(port, ']')) { + if (virStringParsePort(port + 1, &src->hosts->port) < 0) + goto cleanup; + + *port =3D '\0'; + } + + ignore_value(virJSONValueObjectGetNumberUint(json, "lun", &lun)); + + if (virAsprintf(&fulltarget, "%s/%u", target, lun) < 0) + goto cleanup; + + VIR_STEAL_PTR(src->path, fulltarget); + + ret =3D 0; + + cleanup: + VIR_FREE(fulltarget); + return ret; +} =20 static int virStorageSourceParseBackingJSONNbd(virStorageSourcePtr src, @@ -3295,6 +3368,7 @@ static const struct virStorageSourceJSONDriverParser = jsonParsers[] =3D { {"tftp", virStorageSourceParseBackingJSONUri, VIR_STORAGE_NET_PROTOCOL= _TFTP}, {"gluster", virStorageSourceParseBackingJSONGluster, 0}, {"iscsi", virStorageSourceParseBackingJSONiSCSI, 0}, + {"iser", virStorageSourceParseBackingJSONiSER, 0}, {"nbd", virStorageSourceParseBackingJSONNbd, 0}, {"sheepdog", virStorageSourceParseBackingJSONSheepdog, 0}, {"ssh", virStorageSourceParseBackingJSONSSH, 0}, @@ -4054,6 +4128,7 @@ virStorageSourceNetworkDefaultPort(virStorageNetProto= col protocol) return 22; =20 case VIR_STORAGE_NET_PROTOCOL_ISCSI: + case VIR_STORAGE_NET_PROTOCOL_ISER: return 3260; =20 case VIR_STORAGE_NET_PROTOCOL_GLUSTER: diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 24382a0a6..33771ddaf 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -129,6 +129,7 @@ typedef enum { VIR_STORAGE_NET_PROTOCOL_SHEEPDOG, VIR_STORAGE_NET_PROTOCOL_GLUSTER, VIR_STORAGE_NET_PROTOCOL_ISCSI, + VIR_STORAGE_NET_PROTOCOL_ISER, VIR_STORAGE_NET_PROTOCOL_HTTP, VIR_STORAGE_NET_PROTOCOL_HTTPS, VIR_STORAGE_NET_PROTOCOL_FTP, --=20 2.13.6 (Apple Git-96) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list