Received: from eggs.gnu.org ([2001:4830:134:3::10]:43405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beNCr-0003uT-Mv for qemu-devel@nongnu.org; Mon, 29 Aug 2016 10:06:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1beNCn-000169-Dz for qemu-devel@nongnu.org; Mon, 29 Aug 2016 10:06:32 -0400 References: <1460473063-18305-1-git-send-email-ptoscano@redhat.com> <1460473063-18305-2-git-send-email-ptoscano@redhat.com> From: Max Reitz Message-ID: <953704d0-afe1-30c4-de42-1b21e737f199@redhat.com> Date: Mon, 29 Aug 2016 16:06:14 +0200 MIME-Version: 1.0 In-Reply-To: <1460473063-18305-2-git-send-email-ptoscano@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="3DrH1k9TlIVvI6A27Q2EXd9n8KKR8wXVG" Subject: Re: [Qemu-devel] [PATCH] iscsi: allow "initiator-name" as block option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pino Toscano , qemu-devel@nongnu.org, qemu-block@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --3DrH1k9TlIVvI6A27Q2EXd9n8KKR8wXVG From: Max Reitz To: Pino Toscano , qemu-devel@nongnu.org, qemu-block@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, pl@kamp.de, ronniesahlberg@gmail.com Message-ID: <953704d0-afe1-30c4-de42-1b21e737f199@redhat.com> Subject: Re: [Qemu-devel] [PATCH] iscsi: allow "initiator-name" as block option References: <1460473063-18305-1-git-send-email-ptoscano@redhat.com> <1460473063-18305-2-git-send-email-ptoscano@redhat.com> In-Reply-To: <1460473063-18305-2-git-send-email-ptoscano@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 12.04.2016 16:57, Pino Toscano wrote: > Allow the "initiator-name" for both the -iscsi and the block options: > this way it is possible to set it directly as option in the -drive > specification. > The current way to specify the initiator name for a certain iSCSI > target is: > -iscsi id=3DTARGET,initiator-name=3DIQN > which cannot be actually done when TARGET has the optional part, as > colon is not accepted as id for QemuOpts [1]. >=20 > Hence, allow the "initiator-name" also in block options: this way > it is possible to set it directly as option in -drive, e.g.: > -drive file=3DURI,driver=3Discsi,initiator-name=3DIQN >=20 > [1] http://lists.nongnu.org/archive/html/qemu-devel/2015-11/msg06501.ht= ml >=20 > Signed-off-by: Pino Toscano > --- > block/iscsi.c | 22 ++++++++++++++++------ > 1 file changed, 16 insertions(+), 6 deletions(-) >=20 > diff --git a/block/iscsi.c b/block/iscsi.c > index 302baf8..4a1c300 100644 > --- a/block/iscsi.c > +++ b/block/iscsi.c > @@ -1161,7 +1161,7 @@ static void parse_header_digest(struct iscsi_cont= ext *iscsi, const char *target, > } > } > =20 > -static char *parse_initiator_name(const char *target) > +static char *parse_initiator_name(QDict *options, const char *target) > { > QemuOptsList *list; > QemuOpts *opts; > @@ -1169,6 +1169,11 @@ static char *parse_initiator_name(const char *ta= rget) > char *iscsi_name; > UuidInfo *uuid_info; > =20 > + name =3D qdict_get_try_str(options, "initiator-name"); > + if (name !=3D NULL) { > + return g_strdup(name); > + } You should not be using the "options" QDict here but the already parsed QemuOpts ("opts" in the caller). That is, the caller should either pass said @opts or use qemu_opt_get(opts, "initiator-name") to get the name and pass that then. > + > list =3D qemu_find_opts("iscsi"); > if (list) { > opts =3D qemu_opts_find(list, target); > @@ -1304,11 +1309,19 @@ static void iscsi_readcapacity_sync(IscsiLun *i= scsilun, Error **errp) > } > } > =20 > +#define COMMON_ISCSI_OPTS \ > + { \ > + .name =3D "initiator-name", \ > + .type =3D QEMU_OPT_STRING, \ > + .help =3D "Initiator iqn name to use when connecting", \ > + } > + > /* TODO Convert to fine grained options */ > static QemuOptsList runtime_opts =3D { > .name =3D "iscsi", > .head =3D QTAILQ_HEAD_INITIALIZER(runtime_opts.head), > .desc =3D { > + COMMON_ISCSI_OPTS, > { > .name =3D "filename", > .type =3D QEMU_OPT_STRING, > @@ -1473,7 +1486,7 @@ static int iscsi_open(BlockDriverState *bs, QDict= *options, int flags, > =20 > memset(iscsilun, 0, sizeof(IscsiLun)); > =20 > - initiator_name =3D parse_initiator_name(iscsi_url->target); > + initiator_name =3D parse_initiator_name(bs->options, iscsi_url->ta= rget); > =20 > iscsi =3D iscsi_create_context(initiator_name); > if (iscsi =3D=3D NULL) { > @@ -1864,6 +1877,7 @@ static QemuOptsList qemu_iscsi_opts =3D { > .name =3D "iscsi", > .head =3D QTAILQ_HEAD_INITIALIZER(qemu_iscsi_opts.head), > .desc =3D { > + COMMON_ISCSI_OPTS, > { > .name =3D "user", > .type =3D QEMU_OPT_STRING, > @@ -1883,10 +1897,6 @@ static QemuOptsList qemu_iscsi_opts =3D { > .help =3D "HeaderDigest setting. " > "{CRC32C|CRC32C-NONE|NONE-CRC32C|NONE}", > },{ > - .name =3D "initiator-name", > - .type =3D QEMU_OPT_STRING, > - .help =3D "Initiator iqn name to use when connecting", > - },{ > .name =3D "timeout", > .type =3D QEMU_OPT_NUMBER, > .help =3D "Request timeout in seconds (default 0 =3D no ti= meout)", >=20 This needs to be rebased on block-next (which will be merged to master once the 2.8 window is open), because these options are now in vl.c. Max --3DrH1k9TlIVvI6A27Q2EXd9n8KKR8wXVG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEvBAEBCAAZBQJXxEFWEhxtcmVpdHpAcmVkaGF0LmNvbQAKCRD0B9sAYdXPQJXV B/9YsClj3x4sO+qr9biDCPjY5W83oENQjfyh7GJkNgrqsJX5EmHGtdJMRxjdQz3s 9gdZJQRblE0xIlSGf6bdBYgwOv9SWaV9xNkP//CDQ+u9PA+8axj8Rh29b2JlF+Kf Nr5LQTla4KrIIcFHGuYHwmYi8dLH10g5sF/YAVlZiPrDL94NIyWIeB0zDDUDARuX am/W5Gl004fMpVFqGqTSkOnrsBdbUV3uQIbvDeAHQnYmvubiqF2TLn+qisTTiTO1 dWLkL4NiqCWod7V3QEo+B4knYzdT9NSMegga9YOzY23cfNWY6oneqg7FF3ylFmFv T9folN749kj2xD0np4h2S494 =ZsZO -----END PGP SIGNATURE----- --3DrH1k9TlIVvI6A27Q2EXd9n8KKR8wXVG--