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
},
28 int qemu_fsdev_add(QemuOpts
*opts
)
30 struct FsTypeListEntry
*fsle
;
33 if (qemu_opts_id(opts
) == NULL
) {
34 fprintf(stderr
, "fsdev: No id specified\n");
38 for (i
= 0; i
< ARRAY_SIZE(FsTypes
); i
++) {
39 if (strcmp(FsTypes
[i
].name
, qemu_opt_get(opts
, "fstype")) == 0) {
44 if (i
== ARRAY_SIZE(FsTypes
)) {
45 fprintf(stderr
, "fsdev: fstype %s not found\n",
46 qemu_opt_get(opts
, "fstype"));
50 if (qemu_opt_get(opts
, "security_model") == NULL
) {
51 fprintf(stderr
, "fsdev: No security_model specified.\n");
55 fsle
= qemu_malloc(sizeof(*fsle
));
57 fsle
->fse
.fsdev_id
= qemu_strdup(qemu_opts_id(opts
));
58 fsle
->fse
.path
= qemu_strdup(qemu_opt_get(opts
, "path"));
59 fsle
->fse
.security_model
= qemu_strdup(qemu_opt_get(opts
,
61 fsle
->fse
.ops
= FsTypes
[i
].ops
;
63 QTAILQ_INSERT_TAIL(&fstype_entries
, fsle
, next
);
68 FsTypeEntry
*get_fsdev_fsentry(char *id
)
70 struct FsTypeListEntry
*fsle
;
72 QTAILQ_FOREACH(fsle
, &fstype_entries
, next
) {
73 if (strcmp(fsle
->fse
.fsdev_id
, id
) == 0) {
80 static void fsdev_register_config(void)
82 qemu_add_opts(&qemu_fsdev_opts
);
83 qemu_add_opts(&qemu_virtfs_opts
);
85 machine_init(fsdev_register_config
);