From patchwork Fri Jun 26 11:06:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 488746 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D47981401E7 for ; Fri, 26 Jun 2015 21:15:26 +1000 (AEST) Received: from localhost ([::1]:59478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8RbP-0002cw-ME for incoming@patchwork.ozlabs.org; Fri, 26 Jun 2015 07:15:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8Rav-00026H-T1 for qemu-devel@nongnu.org; Fri, 26 Jun 2015 07:14:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z8Ras-0003II-Nw for qemu-devel@nongnu.org; Fri, 26 Jun 2015 07:14:53 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:55038 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8Ras-0003Hd-CU for qemu-devel@nongnu.org; Fri, 26 Jun 2015 07:14:50 -0400 Received: (qmail 17896 invoked by uid 89); 26 Jun 2015 11:14:48 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.7/20613. hbedv: 8.3.32.6/7.11.242.250. spamassassin: 3.4.0. Clear:RC:1(82.141.1.145):SA:0(-1.2/5.0):. Processed in 1.633572 secs); 26 Jun 2015 11:14:48 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 26 Jun 2015 11:14:46 -0000 X-GL_Whitelist: yes Received: from lieven-vm-neu (lieven-vm.kamp-intra.net [172.21.12.69]) by dns.kamp-intra.net (Postfix) with ESMTP id E2523E0060; Fri, 26 Jun 2015 13:14:06 +0200 (CEST) Received: by lieven-vm-neu (Postfix, from userid 1000) id 7021120791; Fri, 26 Jun 2015 13:06:12 +0200 (CEST) From: Peter Lieven To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Fri, 26 Jun 2015 13:06:09 +0200 Message-Id: <1435316769-25381-1-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.7.9.5 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, stefanha@gmail.com, jcody@redhat.com, Peter Lieven , ronniesahlberg@gmail.com Subject: [Qemu-devel] [PATCH V2] block/nfs: add support for setting debug level 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 upcoming libnfs versions will support logging debug messages. Add support for it in qemu through a cmdline parameter. Example qemu -nfs debug=99 -cdrom nfs://... Signed-off-by: Peter Lieven --- v1->v2: reworked patch to accept the debug level as a cmdline parameter instead of an URI parameter [Stefan] block/nfs.c | 40 ++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 21 +++++++++++++++++++++ vl.c | 8 ++++++++ 3 files changed, 69 insertions(+) diff --git a/block/nfs.c b/block/nfs.c index ca9e24e..43d48ae 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -274,6 +274,30 @@ static void nfs_file_close(BlockDriverState *bs) nfs_client_close(client); } +static void nfs_parse_options(NFSClient *client) +{ + QemuOptsList *list; + QemuOpts *opts; + const char *debug; + + list = qemu_find_opts("nfs"); + if (list) { + opts = QTAILQ_FIRST(&list->head); + if (opts) { + debug = qemu_opt_get(opts, "debug"); + if (debug) { +#ifdef LIBNFS_FEATURE_DEBUG + nfs_set_debug(client->context, atoi(debug)); +#else + error_report("NFS Warning: The linked version of libnfs does" + " not support setting debug levels"); +#endif + } + } + } +} + + static int64_t nfs_client_open(NFSClient *client, const char *filename, int flags, Error **errp) { @@ -336,6 +360,8 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename, } } + nfs_parse_options(client); + ret = nfs_mount(client->context, uri->server, uri->path); if (ret < 0) { error_setg(errp, "Failed to mount nfs share: %s", @@ -501,9 +527,23 @@ static BlockDriver bdrv_nfs = { .bdrv_attach_aio_context = nfs_attach_aio_context, }; +static QemuOptsList qemu_nfs_opts = { + .name = "nfs", + .head = QTAILQ_HEAD_INITIALIZER(qemu_nfs_opts.head), + .desc = { + { + .name = "debug", + .type = QEMU_OPT_NUMBER, + .help = "Set libnfs debug level (default 0 = no debug)", + }, + { /* end of list */ } + }, +}; + static void nfs_block_init(void) { bdrv_register(&bdrv_nfs); + qemu_add_opts(&qemu_nfs_opts); } block_init(nfs_block_init); diff --git a/qemu-options.hx b/qemu-options.hx index 389cf64..63c60e7 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2329,6 +2329,26 @@ 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 NFS +NFS support allows QEMU to access NFS shares directly and use as +images for the guest storage. Both disk and cdrom images are supported. + +Syntax for specifying NFS shares is +``nfs:////'' + +Example (setting deubg level to 2 and use ISO from NFS share as CDROM): +@example +qemu-system-i386 -nfs debug=2 -cdrom nfs://127.0.0.1/isos/cdimage.iso +@end example + +NFS support is an optional feature of QEMU and only available when +compiled and linked against libnfs. +ETEXI +DEF("nfs", HAS_ARG, QEMU_OPTION_nfs, + "-nfs [debug=debug]\n" + " NFS connection parameters\n", QEMU_ARCH_ALL) +STEXI + @item NBD QEMU supports NBD (Network Block Devices) both using TCP protocol as well as Unix Domain Sockets. @@ -2480,6 +2500,7 @@ ETEXI STEXI @end table ETEXI +DEFHEADING() DEFHEADING(Bluetooth(R) options:) STEXI diff --git a/vl.c b/vl.c index 9542095..4317572 100644 --- a/vl.c +++ b/vl.c @@ -3141,6 +3141,14 @@ int main(int argc, char **argv, char **envp) } break; #endif +#ifdef CONFIG_LIBNFS + case QEMU_OPTION_nfs: + opts = qemu_opts_parse(qemu_find_opts("nfs"), optarg, 0); + if (!opts) { + exit(1); + } + break; +#endif #ifdef CONFIG_SLIRP case QEMU_OPTION_tftp: legacy_tftp_prefix = optarg;