]>
git.proxmox.com Git - qemu.git/blob - fsdev/qemu-fsdev.c
4 * Copyright IBM, Corp. 2010
7 * Gautham R Shenoy <ego@in.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
15 #include "qemu-fsdev.h"
16 #include "qemu-queue.h"
18 #include "qemu-common.h"
19 #include "qemu-config.h"
21 static QTAILQ_HEAD(FsDriverEntry_head
, FsDriverListEntry
) fsdriver_entries
=
22 QTAILQ_HEAD_INITIALIZER(fsdriver_entries
);
24 static FsDriverTable FsDrivers
[] = {
25 { .name
= "local", .ops
= &local_ops
},
26 { .name
= "handle", .ops
= &handle_ops
},
29 int qemu_fsdev_add(QemuOpts
*opts
)
31 struct FsDriverListEntry
*fsle
;
33 const char *fsdev_id
= qemu_opts_id(opts
);
34 const char *fsdriver
= qemu_opt_get(opts
, "fsdriver");
35 const char *path
= qemu_opt_get(opts
, "path");
36 const char *sec_model
= qemu_opt_get(opts
, "security_model");
37 const char *writeout
= qemu_opt_get(opts
, "writeout");
41 fprintf(stderr
, "fsdev: No id specified\n");
46 for (i
= 0; i
< ARRAY_SIZE(FsDrivers
); i
++) {
47 if (strcmp(FsDrivers
[i
].name
, fsdriver
) == 0) {
52 if (i
== ARRAY_SIZE(FsDrivers
)) {
53 fprintf(stderr
, "fsdev: fsdriver %s not found\n", fsdriver
);
57 fprintf(stderr
, "fsdev: No fsdriver specified\n");
62 fprintf(stderr
, "fsdev: No security_model specified.\n");
67 fprintf(stderr
, "fsdev: No path specified.\n");
71 fsle
= g_malloc(sizeof(*fsle
));
73 fsle
->fse
.fsdev_id
= g_strdup(fsdev_id
);
74 fsle
->fse
.path
= g_strdup(path
);
75 fsle
->fse
.ops
= FsDrivers
[i
].ops
;
76 fsle
->fse
.export_flags
= 0;
78 if (!strcmp(writeout
, "immediate")) {
79 fsle
->fse
.export_flags
|= V9FS_IMMEDIATE_WRITEOUT
;
83 if (!strcmp(sec_model
, "passthrough")) {
84 fsle
->fse
.export_flags
|= V9FS_SM_PASSTHROUGH
;
85 } else if (!strcmp(sec_model
, "mapped")) {
86 fsle
->fse
.export_flags
|= V9FS_SM_MAPPED
;
87 } else if (!strcmp(sec_model
, "none")) {
88 fsle
->fse
.export_flags
|= V9FS_SM_NONE
;
90 fprintf(stderr
, "Default to security_model=none. You may want"
91 " enable advanced security model using "
92 "security option:\n\t security_model=passthrough\n\t "
93 "security_model=mapped\n");
95 fsle
->fse
.export_flags
|= V9FS_SM_NONE
;
98 QTAILQ_INSERT_TAIL(&fsdriver_entries
, fsle
, next
);
102 FsDriverEntry
*get_fsdev_fsentry(char *id
)
105 struct FsDriverListEntry
*fsle
;
107 QTAILQ_FOREACH(fsle
, &fsdriver_entries
, next
) {
108 if (strcmp(fsle
->fse
.fsdev_id
, id
) == 0) {
116 static void fsdev_register_config(void)
118 qemu_add_opts(&qemu_fsdev_opts
);
119 qemu_add_opts(&qemu_virtfs_opts
);
121 machine_init(fsdev_register_config
);