From: Paolo Bonzini <pbonzini@redhat.com>
To: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] ISCSI: Pick default initiator-name based on the name of the VM
Date: Mon, 30 Jul 2012 09:41:58 +0200 [thread overview]
Message-ID: <50163AC6.2050000@redhat.com> (raw)
In-Reply-To: <1343436248-10646-2-git-send-email-ronniesahlberg@gmail.com>
Il 28/07/2012 02:44, Ronnie Sahlberg ha scritto:
> This patch updates the iscsi layer to automatically pick a
> 'unique' initiator-name based on the name of the vm in case the user
> has not set an explicit iqn-name to use.
>
> Save the -name of the vm so that we can use it in the default iscsi name.
>
> Add a new variable that holds the name for the vm as specified by -name
> and assign this name to the iscsi_name pointer gtom block/iscsi.c
>
> This way we can thus create default names to use as the initiator name
> based on the guest session.
>
> If -name is not specified, iscsi will use a default initiator-name of
> iqn.2008-11.org.linux-kvm
>
> If -name is specified, then iscsi will use a default initiatorname of
> iqn.2008-11.org.linux-kvm:<name>
>
> Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> ---
> block/iscsi.c | 16 +++++++++++++---
> qemu-doc.texi | 5 +++++
> qemu-options.hx | 8 ++++++++
> vl.c | 7 +++++++
> 4 files changed, 33 insertions(+), 3 deletions(-)
>
> diff --git a/block/iscsi.c b/block/iscsi.c
> index 993a86d..abf60ee 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -28,6 +28,7 @@
> #include <arpa/inet.h>
> #include "qemu-common.h"
> #include "qemu-error.h"
> +#include "sysemu.h"
> #include "block_int.h"
> #include "trace.h"
> #include "hw/scsi-defs.h"
> @@ -40,6 +41,8 @@
> #include <hw/scsi-defs.h>
> #endif
>
> +const char *iscsi_name;
As a rule of thumb, every #ifdef CONFIG_* increases the chances that
your patch is rejected. :)
Please add instead a qemu_get_vm_name() function and make it return NULL
in qemu-tool.c.
Paolo
> typedef struct IscsiLun {
> struct iscsi_context *iscsi;
> int lun;
> @@ -896,23 +899,30 @@ static char *parse_initiator_name(const char *target)
> QemuOptsList *list;
> QemuOpts *opts;
> const char *name = NULL;
> + char *default_name;
> +
> + if (asprintf(&default_name, "iqn.2008-11.org.linux-kvm%s%s",
> + iscsi_name ? ":" : "",
> + iscsi_name ? iscsi_name : "") == -1) {
> + default_name = (char *)"iqn.2008-11.org.linux-kvm";
> + }
>
> list = qemu_find_opts("iscsi");
> if (!list) {
> - return g_strdup("iqn.2008-11.org.linux-kvm");
> + return g_strdup(default_name);
> }
>
> opts = qemu_opts_find(list, target);
> if (opts == NULL) {
> opts = QTAILQ_FIRST(&list->head);
> if (!opts) {
> - return g_strdup("iqn.2008-11.org.linux-kvm");
> + return g_strdup(default_name);
> }
> }
>
> name = qemu_opt_get(opts, "initiator-name");
> if (!name) {
> - return g_strdup("iqn.2008-11.org.linux-kvm");
> + return g_strdup(default_name);
> }
>
> return g_strdup(name);
> diff --git a/qemu-doc.texi b/qemu-doc.texi
> index 84dad19..2360f7b 100644
> --- a/qemu-doc.texi
> +++ b/qemu-doc.texi
> @@ -734,6 +734,11 @@ Various session related parameters can be set via special options, either
> in a configuration file provided via '-readconfig' or directly on the
> command line.
>
> +If the initiator-name is not specified qemu will use a default name
> +of 'iqn.2008-11.org.linux-kvm[:<name>'] where <name> is the name of the
> +virtual machine.
> +
> +
> @example
> Setting a specific initiator name to use when logging in to the target
> -iscsi initiator-name=iqn.qemu.test:my-initiator
> diff --git a/qemu-options.hx b/qemu-options.hx
> index dc68e15..3335bcc 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -1893,6 +1893,11 @@ images for the guest storage. Both disk and cdrom images are supported.
> Syntax for specifying iSCSI LUNs is
> ``iscsi://<target-ip>[:<port>]/<target-iqn>/<lun>''
>
> +By default qemu will use the iSCSI initiator-name
> +'iqn.2008-11.org.linux-kvm[:<name>]' but this can also be set from the command
> +line or a configuration file.
> +
> +
> Example (without authentication):
> @example
> qemu-system-i386 -iscsi initiator-name=iqn.2001-04.com.example:my-initiator \
> @@ -1922,6 +1927,9 @@ DEF("iscsi", HAS_ARG, QEMU_OPTION_iscsi,
> " iSCSI session parameters\n", QEMU_ARCH_ALL)
> STEXI
>
> +iSCSI parameters such as username and password can also be specified via
> +a configuration file. See qemu-doc for more information and examples.
> +
> @item NBD
> QEMU supports NBD (Network Block Devices) both using TCP protocol as well
> as Unix Domain Sockets.
> diff --git a/vl.c b/vl.c
> index 8904db1..3320b7a 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -169,6 +169,10 @@ int main(int argc, char **argv)
>
> #define MAX_VIRTIO_CONSOLES 1
>
> +#ifdef CONFIG_LIBISCSI
> +extern const char *iscsi_name;
> +#endif
> +
> static const char *data_dir;
> const char *bios_name = NULL;
> enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
> @@ -3074,6 +3078,9 @@ int main(int argc, char **argv, char **envp)
> os_set_proc_name(p);
> }
> }
> +#ifdef CONFIG_LIBISCSI
> + iscsi_name = qemu_name;
> +#endif
> break;
> case QEMU_OPTION_prom_env:
> if (nb_prom_envs >= MAX_PROM_ENVS) {
>
next prev parent reply other threads:[~2012-07-30 7:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-28 0:44 [Qemu-devel] [PATCH] iSCSI: generate default initiator-name from vm-name Ronnie Sahlberg
2012-07-28 0:44 ` [Qemu-devel] [PATCH] ISCSI: Pick default initiator-name based on the name of the VM Ronnie Sahlberg
2012-07-30 7:41 ` Paolo Bonzini [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-07-30 9:03 [Qemu-devel] [PATCH] Set iscsi initiator name based on vm name. version 2 Ronnie Sahlberg
2012-07-30 9:03 ` [Qemu-devel] [PATCH] ISCSI: Pick default initiator-name based on the name of the VM Ronnie Sahlberg
2012-07-30 9:21 ` Paolo Bonzini
2012-08-06 8:24 ronniesahlberg
2012-08-06 8:51 ` Paolo Bonzini
2012-08-09 1:34 ` ronnie sahlberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50163AC6.2050000@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=ronniesahlberg@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.