From patchwork Sat Jun 5 01:08:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 104364 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5515Zpe028324 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 5 Jun 2010 01:06:10 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OKhp8-0006HM-6w; Sat, 05 Jun 2010 01:05:18 +0000 Received: from sfi-mx-3.v28.ch3.sourceforge.com ([172.29.28.123] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OKhp7-0006HF-50 for v9fs-developer@lists.sourceforge.net; Sat, 05 Jun 2010 01:05:17 +0000 X-ACL-Warn: Received: from e34.co.us.ibm.com ([32.97.110.152]) by sfi-mx-3.v28.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1OKhp4-000541-Rk for v9fs-developer@lists.sourceforge.net; Sat, 05 Jun 2010 01:05:17 +0000 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e34.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id o550vOlZ024021 for ; Fri, 4 Jun 2010 18:57:24 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o55158nE177938 for ; Fri, 4 Jun 2010 19:05:08 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o55158vI007653 for ; Fri, 4 Jun 2010 19:05:08 -0600 Received: from localhost.localdomain (elm9m80.beaverton.ibm.com [9.47.81.80]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o55156B9007599; Fri, 4 Jun 2010 19:05:07 -0600 From: "Venkateswararao Jujjuri (JV)" To: qemu-devel@nongnu.org Date: Fri, 4 Jun 2010 18:08:43 -0700 Message-Id: <1275700132-22823-2-git-send-email-jvrao@linux.vnet.ibm.com> X-Mailer: git-send-email 1.6.0.6 In-Reply-To: <1275700132-22823-1-git-send-email-jvrao@linux.vnet.ibm.com> References: <1275700132-22823-1-git-send-email-jvrao@linux.vnet.ibm.com> X-Spam-Score: -0.2 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.2 AWL AWL: From: address is in the auto white-list X-Headers-End: 1OKhp4-000541-Rk Cc: v9fs-developer@lists.sourceforge.net, aliguori@us.ibm.com Subject: [V9fs-developer] [PATCH-V5 01/10] virtio-9p: Introduces an option to specify the security model. X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 05 Jun 2010 01:06:11 +0000 (UTC) diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index 813e1f7..ad69b0e 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -34,7 +34,7 @@ int qemu_fsdev_add(QemuOpts *opts) return -1; } - for (i = 0; i < ARRAY_SIZE(FsTypes); i++) { + for (i = 0; i < ARRAY_SIZE(FsTypes); i++) { if (strcmp(FsTypes[i].name, qemu_opt_get(opts, "fstype")) == 0) { break; } @@ -46,10 +46,17 @@ int qemu_fsdev_add(QemuOpts *opts) return -1; } + if (qemu_opt_get(opts, "security_model") == NULL) { + fprintf(stderr, "fsdev: No security_model specified.\n"); + return -1; + } + fsle = qemu_malloc(sizeof(*fsle)); fsle->fse.fsdev_id = qemu_strdup(qemu_opts_id(opts)); fsle->fse.path = qemu_strdup(qemu_opt_get(opts, "path")); + fsle->fse.security_model = qemu_strdup(qemu_opt_get(opts, + "security_model")); fsle->fse.ops = FsTypes[i].ops; QTAILQ_INSERT_TAIL(&fstype_entries, fsle, next); diff --git a/fsdev/qemu-fsdev.h b/fsdev/qemu-fsdev.h index b50fbe0..6c27881 100644 --- a/fsdev/qemu-fsdev.h +++ b/fsdev/qemu-fsdev.h @@ -40,6 +40,7 @@ typedef struct FsTypeTable { typedef struct FsTypeEntry { char *fsdev_id; char *path; + char *security_model; FileOperations *ops; } FsTypeEntry; diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c index 038bb39..2530488 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -2253,6 +2253,15 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf) exit(1); } + if (!strcmp(fse->security_model, "passthrough") && + !strcmp(fse->security_model, "mapped")) { + /* user haven't specified a correct security option */ + fprintf(stderr, "one of the following must be specified as the" + "security option:\n\t security_model=passthrough \n\t " + "security_model=mapped\n"); + return NULL; + } + if (lstat(fse->path, &stat)) { fprintf(stderr, "share path %s does not exist\n", fse->path); exit(1); diff --git a/qemu-config.c b/qemu-config.c index 5a4e61b..95abe61 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -163,6 +163,9 @@ QemuOptsList qemu_fsdev_opts = { }, { .name = "path", .type = QEMU_OPT_STRING, + }, { + .name = "security_model", + .type = QEMU_OPT_STRING, }, { /*End of list */ } }, @@ -184,6 +187,9 @@ QemuOptsList qemu_virtfs_opts = { }, { .name = "mount_tag", .type = QEMU_OPT_STRING, + }, { + .name = "security_model", + .type = QEMU_OPT_STRING, }, { /*End of list */ } diff --git a/qemu-options.hx b/qemu-options.hx index a6928b7..d1d2272 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -486,7 +486,7 @@ ETEXI DEFHEADING(File system options:) DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev, - "-fsdev local,id=id,path=path\n", + "-fsdev local,id=id,path=path,security_model=[mapped|passthrough]\n", QEMU_ARCH_ALL) STEXI @@ -502,7 +502,7 @@ The specific Fstype will determine the applicable options. Options to each backend are described below. -@item -fsdev local ,id=@var{id} ,path=@var{path} +@item -fsdev local ,id=@var{id} ,path=@var{path} ,security_model=@var{security_model} Create a file-system-"device" for local-filesystem. @@ -510,6 +510,9 @@ Create a file-system-"device" for local-filesystem. @option{path} specifies the path to be exported. @option{path} is required. +@option{security_model} specifies the security model to be followed. +@option{security_model} is required. + @end table ETEXI #endif @@ -518,7 +521,7 @@ ETEXI DEFHEADING(Virtual File system pass-through options:) DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs, - "-virtfs local,path=path,mount_tag=tag\n", + "-virtfs local,path=path,mount_tag=tag,security_model=[mapped|passthrough]\n", QEMU_ARCH_ALL) STEXI @@ -534,7 +537,7 @@ The specific Fstype will determine the applicable options. Options to each backend are described below. -@item -virtfs local ,path=@var{path} ,mount_tag=@var{mount_tag} +@item -virtfs local ,path=@var{path} ,mount_tag=@var{mount_tag} ,security_model=@var{security_model} Create a Virtual file-system-pass through for local-filesystem. @@ -542,6 +545,10 @@ Create a Virtual file-system-pass through for local-filesystem. @option{path} specifies the path to be exported. @option{path} is required. +@option{security_model} specifies the security model to be followed. +@option{security_model} is required. + + @option{mount_tag} specifies the tag with which the exported file is mounted. @option{mount_tag} is required. diff --git a/vl.c b/vl.c index 7121cd0..98491ae 100644 --- a/vl.c +++ b/vl.c @@ -3094,10 +3094,21 @@ int main(int argc, char **argv, char **envp) exit(1); } - len = strlen(",id=,path="); + if (qemu_opt_get(opts, "fstype") == NULL || + qemu_opt_get(opts, "mount_tag") == NULL || + qemu_opt_get(opts, "path") == NULL || + qemu_opt_get(opts, "security_model") == NULL) { + fprintf(stderr, "Usage: -virtfs fstype,path=/share_path/," + "security_model=[mapped|passthrough]," + "mnt_tag=tag.\n"); + exit(1); + } + + len = strlen(",id=,path=,security_model="); len += strlen(qemu_opt_get(opts, "fstype")); len += strlen(qemu_opt_get(opts, "mount_tag")); len += strlen(qemu_opt_get(opts, "path")); + len += strlen(qemu_opt_get(opts, "security_model")); arg_fsdev = qemu_malloc((len + 1) * sizeof(*arg_fsdev)); if (!arg_fsdev) { @@ -3106,10 +3117,11 @@ int main(int argc, char **argv, char **envp) exit(1); } - sprintf(arg_fsdev, "%s,id=%s,path=%s", + sprintf(arg_fsdev, "%s,id=%s,path=%s,security_model=%s", qemu_opt_get(opts, "fstype"), qemu_opt_get(opts, "mount_tag"), - qemu_opt_get(opts, "path")); + qemu_opt_get(opts, "path"), + qemu_opt_get(opts, "security_model")); len = strlen("virtio-9p-pci,fsdev=,mount_tag="); len += 2*strlen(qemu_opt_get(opts, "mount_tag"));