From patchwork Thu Aug 9 13:38:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 176102 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DE9FC2C00D1 for ; Thu, 9 Aug 2012 23:52:02 +1000 (EST) Received: from localhost ([::1]:33020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzSxm-0002ns-Pv for incoming@patchwork.ozlabs.org; Thu, 09 Aug 2012 09:39:46 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzSxV-0002Ch-O9 for qemu-devel@nongnu.org; Thu, 09 Aug 2012 09:39:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzSxR-0003rn-Qe for qemu-devel@nongnu.org; Thu, 09 Aug 2012 09:39:29 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:34613) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzSxR-0003qC-KM for qemu-devel@nongnu.org; Thu, 09 Aug 2012 09:39:25 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp12so868953pbb.4 for ; Thu, 09 Aug 2012 06:39:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=zQPgarVUTgnK6jFRb4tFfPtVPNA/slAyi8H+6QtdUeg=; b=b6QTt1HxDD4ReUY1TtfZ5UHrjlzRwa3L+d88/ZVnZ7hjxylPcdhQElPxsXuj01ixZg eg8MzQOTa84/HDymxyk6N82neLqNA5skIdossJy8Al4NX60Cb96beVvgXz3wl0dC0dL5 rQEXtHpVB0lHPf5rlSG2feUXlgZN7ofI1g1ncYqEg57tJEZe4aaq/rwrZJcPHhB7Cxol 0oNhcAkj9dYGVxBgxUQ6NWv/LaJPvxY+NItky+AnFPa9+G4UX5A/2y6YdrcCnZ/LwV+o xBbVqNWex/eWbVIiYogd/lvUKbuBTuPbOjnjLWne+bPVkS6EvO86p1F1S0jdwULGHju3 DXRQ== Received: by 10.68.200.138 with SMTP id js10mr4478631pbc.23.1344519565143; Thu, 09 Aug 2012 06:39:25 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id qa2sm788320pbb.21.2012.08.09.06.39.22 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Aug 2012 06:39:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2012 15:38:27 +0200 Message-Id: <1344519511-18147-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1344519511-18147-1-git-send-email-pbonzini@redhat.com> References: <1344519511-18147-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Ronnie Sahlberg Subject: [Qemu-devel] [PATCH 3/7] iscsi: Pick default initiator-name based on the name of the VM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Ronnie Sahlberg 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. Create a new function qemu_get_vm_name() that returns the name of the VM, if specified. This way we can thus create default names to use as the initiator name based on the guest session. If the VM is not named via the '-name' command line argument, the iscsi initiator-name used wiull simply be iqn.2008-11.org.linux-kvm If a name for the VM was specified with the '-name' option, iscsi will use a default initiatorname of iqn.2008-11.org.linux-kvm: These names are just the default iscsi initiator name that qemu will generate/use only when the user has not set an explicit initiator name via the commandlines or config files. Signed-off-by: Ronnie Sahlberg --- block/iscsi.c | 5 ++++- qemu-common.h | 1 + qemu-doc.texi | 5 +++++ qemu-options.hx | 8 ++++++++ qemu-tool.c | 5 +++++ vl.c | 5 +++++ 6 file modificati, 28 inserzioni(+). 1 rimozione(-) diff --git a/block/iscsi.c b/block/iscsi.c index fd954d4..219f927 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -896,6 +896,7 @@ static char *parse_initiator_name(const char *target) QemuOptsList *list; QemuOpts *opts; const char *name = NULL; + const char *iscsi_name = qemu_get_vm_name(); list = qemu_find_opts("iscsi"); if (list) { @@ -911,7 +912,9 @@ static char *parse_initiator_name(const char *target) if (name) { return g_strdup(name); } else { - return g_strdup("iqn.2008-11.org.linux-kvm"); + return g_strdup_printf("iqn.2008-11.org.linux-kvm%s%s", + iscsi_name ? ":" : "", + iscsi_name ? iscsi_name : ""); } } diff --git a/qemu-common.h b/qemu-common.h index f16079f..f9deca6 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -376,6 +376,7 @@ bool buffer_is_zero(const void *buf, size_t len); void qemu_progress_init(int enabled, float min_skip); void qemu_progress_end(void); void qemu_progress_print(float delta, int max); +const char *qemu_get_vm_name(void); #define QEMU_FILE_TYPE_BIOS 0 #define QEMU_FILE_TYPE_KEYMAP 1 diff --git a/qemu-doc.texi b/qemu-doc.texi index f32e9e2..35cabbc 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[:'] where 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 5e7d0dc..47cb5bd 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1897,6 +1897,11 @@ images for the guest storage. Both disk and cdrom images are supported. Syntax for specifying iSCSI LUNs is ``iscsi://[:]//'' +By default qemu will use the iSCSI initiator-name +'iqn.2008-11.org.linux-kvm[:]' 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 \ @@ -1926,6 +1931,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/qemu-tool.c b/qemu-tool.c index 318c5fc..64b5e88 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -30,6 +30,11 @@ struct QEMUBH void *opaque; }; +const char *qemu_get_vm_name(void) +{ + return NULL; +} + Monitor *cur_mon; int monitor_cur_is_qmp(void) diff --git a/vl.c b/vl.c index e71cb30..065aec2 100644 --- a/vl.c +++ b/vl.c @@ -293,6 +293,11 @@ static struct { { .driver = "qxl-vga", .flag = &default_vga }, }; +const char *qemu_get_vm_name(void) +{ + return qemu_name; +} + static void res_free(void) { if (boot_splash_filedata != NULL) {