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(FsTypeEntry_head
, FsTypeListEntry
) fstype_entries
=
22 QTAILQ_HEAD_INITIALIZER(fstype_entries
);
24 static FsTypeTable FsTypes
[] = {
25 { .name
= "local", .ops
= &local_ops
},
26 { .name
= "handle", .ops
= &handle_ops
},
29 int qemu_fsdev_add(QemuOpts
*opts
)
31 struct FsTypeListEntry
*fsle
;
33 const char *fsdev_id
= qemu_opts_id(opts
);
34 const char *fstype
= qemu_opt_get(opts
, "fstype");
35 const char *path
= qemu_opt_get(opts
, "path");
36 const char *sec_model
= qemu_opt_get(opts
, "security_model");
39 fprintf(stderr
, "fsdev: No id specified\n");
44 for (i
= 0; i
< ARRAY_SIZE(FsTypes
); i
++) {
45 if (strcmp(FsTypes
[i
].name
, fstype
) == 0) {
50 if (i
== ARRAY_SIZE(FsTypes
)) {
51 fprintf(stderr
, "fsdev: fstype %s not found\n", fstype
);
55 fprintf(stderr
, "fsdev: No fstype specified\n");
60 fprintf(stderr
, "fsdev: No security_model specified.\n");
65 fprintf(stderr
, "fsdev: No path specified.\n");
69 fsle
= g_malloc(sizeof(*fsle
));
71 fsle
->fse
.fsdev_id
= g_strdup(fsdev_id
);
72 fsle
->fse
.path
= g_strdup(path
);
73 fsle
->fse
.security_model
= g_strdup(sec_model
);
74 fsle
->fse
.ops
= FsTypes
[i
].ops
;
76 QTAILQ_INSERT_TAIL(&fstype_entries
, fsle
, next
);
81 FsTypeEntry
*get_fsdev_fsentry(char *id
)
84 struct FsTypeListEntry
*fsle
;
86 QTAILQ_FOREACH(fsle
, &fstype_entries
, next
) {
87 if (strcmp(fsle
->fse
.fsdev_id
, id
) == 0) {
95 static void fsdev_register_config(void)
97 qemu_add_opts(&qemu_fsdev_opts
);
98 qemu_add_opts(&qemu_virtfs_opts
);
100 machine_init(fsdev_register_config
);