From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:51858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REgXt-0004W2-03 for qemu-devel@nongnu.org; Fri, 14 Oct 2011 08:07:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1REgXo-00046Q-Bj for qemu-devel@nongnu.org; Fri, 14 Oct 2011 08:07:24 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:48606) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REgXn-000469-NP for qemu-devel@nongnu.org; Fri, 14 Oct 2011 08:07:20 -0400 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [202.81.31.247]) by e23smtp07.au.ibm.com (8.14.4/8.13.1) with ESMTP id p9EC7Ecu008862 for ; Fri, 14 Oct 2011 23:07:14 +1100 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9EC4fwk1781812 for ; Fri, 14 Oct 2011 23:04:47 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9EC77k9024693 for ; Fri, 14 Oct 2011 23:07:08 +1100 From: "M. Mohan Kumar" Date: Fri, 14 Oct 2011 17:36:17 +0530 Message-Id: <1318593977-30626-1-git-send-email-mohan@in.ibm.com> Subject: [Qemu-devel] [PATCH] hw/9pfs: Handle Security model parsing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, aneesh.kumar@linux.vnet.ibm.com Except local fs driver other fs drivers (handle) don't need security model. Update fsdev parameter parsing accordingly. Signed-off-by: M. Mohan Kumar --- fsdev/qemu-fsdev.c | 26 +++++++++++++++++--------- qemu-options.hx | 12 ++++++++---- vl.c | 6 ++---- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index ce920d6..5977bcc 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -58,8 +58,15 @@ int qemu_fsdev_add(QemuOpts *opts) return -1; } - if (!sec_model) { - fprintf(stderr, "fsdev: No security_model specified.\n"); + if (!strcmp(fsdriver, "local") && !sec_model) { + fprintf(stderr, "security model not specified, " + "local fs needs security model\nvalid options are:" + "\tsecurity_model=[passthrough|mapped|none]\n"); + return -1; + } + + if (strcmp(fsdriver, "local") && sec_model) { + fprintf(stderr, "only local fs driver needs security model\n"); return -1; } @@ -80,6 +87,10 @@ int qemu_fsdev_add(QemuOpts *opts) } } + if (strcmp(fsdriver, "local")) { + goto done; + } + if (!strcmp(sec_model, "passthrough")) { fsle->fse.export_flags |= V9FS_SM_PASSTHROUGH; } else if (!strcmp(sec_model, "mapped")) { @@ -87,14 +98,11 @@ int qemu_fsdev_add(QemuOpts *opts) } else if (!strcmp(sec_model, "none")) { fsle->fse.export_flags |= V9FS_SM_NONE; } else { - fprintf(stderr, "Default to security_model=none. You may want" - " enable advanced security model using " - "security option:\n\t security_model=passthrough\n\t " - "security_model=mapped\n"); - - fsle->fse.export_flags |= V9FS_SM_NONE; + fprintf(stderr, "Invalid security model %s specified, valid options are" + "\n\t [passthrough|mapped|none]\n", sec_model); + return -1; } - +done: QTAILQ_INSERT_TAIL(&fsdriver_entries, fsle, next); return 0; } diff --git a/qemu-options.hx b/qemu-options.hx index 518a1f1..f05be30 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -527,13 +527,13 @@ DEFHEADING() DEFHEADING(File system options:) DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev, - "-fsdev fsdriver,id=id,path=path,security_model=[mapped|passthrough|none]\n" + "-fsdev fsdriver,id=id,path=path,[security_model={mapped|passthrough|none}]\n" " [,writeout=immediate]\n", QEMU_ARCH_ALL) STEXI -@item -fsdev @var{fsdriver},id=@var{id},path=@var{path},security_model=@var{security_model}[,writeout=@var{writeout}] +@item -fsdev @var{fsdriver},id=@var{id},path=@var{path},[security_model=@var{security_model}][,writeout=@var{writeout}] @findex -fsdev Define a new file system device. Valid options are: @table @option @@ -555,7 +555,9 @@ attributes like uid, gid, mode bits and link target are stored as file attributes. Directories exported by this security model cannot interact with other unix tools. "none" security model is same as passthrough except the sever won't report failures if it fails to -set file attributes like ownership. +set file attributes like ownership. Security model is mandatory +only for local fsdriver. Other fsdrivers (like handle) don't take +security model as a parameter. @item writeout=@var{writeout} This is an optional argument. The only supported value is "immediate". This means that host page cache will be used to read and write data but @@ -609,7 +611,9 @@ attributes like uid, gid, mode bits and link target are stored as file attributes. Directories exported by this security model cannot interact with other unix tools. "none" security model is same as passthrough except the sever won't report failures if it fails to -set file attributes like ownership. +set file attributes like ownership. Security model is mandatory only +for local fsdriver. Other fsdrivers (like handle) don't take security +model as a parameter. @item writeout=@var{writeout} This is an optional argument. The only supported value is "immediate". This means that host page cache will be used to read and write data but diff --git a/vl.c b/vl.c index 3b8199f..d672268 100644 --- a/vl.c +++ b/vl.c @@ -2800,14 +2800,12 @@ int main(int argc, char **argv, char **envp) if (qemu_opt_get(opts, "fsdriver") == NULL || qemu_opt_get(opts, "mount_tag") == NULL || - qemu_opt_get(opts, "path") == NULL || - qemu_opt_get(opts, "security_model") == NULL) { + qemu_opt_get(opts, "path") == NULL) { fprintf(stderr, "Usage: -virtfs fsdriver,path=/share_path/," - "security_model=[mapped|passthrough|none]," + "[security_model={mapped|passthrough|none}]," "mount_tag=tag.\n"); exit(1); } - fsdev = qemu_opts_create(qemu_find_opts("fsdev"), qemu_opt_get(opts, "mount_tag"), 1); if (!fsdev) { -- 1.7.6