]>
Commit | Line | Data |
---|---|---|
74db920c GS |
1 | /* |
2 | * Virtio 9p | |
3 | * | |
4 | * Copyright IBM, Corp. 2010 | |
5 | * | |
6 | * Authors: | |
7 | * Gautham R Shenoy <ego@in.ibm.com> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU GPL, version 2. See | |
10 | * the COPYING file in the top-level directory. | |
11 | * | |
12 | */ | |
13 | #include <stdio.h> | |
14 | #include <string.h> | |
15 | #include "qemu-fsdev.h" | |
16 | #include "qemu-queue.h" | |
17 | #include "osdep.h" | |
18 | #include "qemu-common.h" | |
526c5237 | 19 | #include "qemu-config.h" |
74db920c GS |
20 | |
21 | static QTAILQ_HEAD(FsTypeEntry_head, FsTypeListEntry) fstype_entries = | |
22 | QTAILQ_HEAD_INITIALIZER(fstype_entries); | |
23 | ||
24 | static FsTypeTable FsTypes[] = { | |
9f107513 | 25 | { .name = "local", .ops = &local_ops}, |
74db920c GS |
26 | }; |
27 | ||
28 | int qemu_fsdev_add(QemuOpts *opts) | |
29 | { | |
30 | struct FsTypeListEntry *fsle; | |
31 | int i; | |
32 | ||
33 | if (qemu_opts_id(opts) == NULL) { | |
34 | fprintf(stderr, "fsdev: No id specified\n"); | |
35 | return -1; | |
36 | } | |
37 | ||
9ce56db6 | 38 | for (i = 0; i < ARRAY_SIZE(FsTypes); i++) { |
74db920c GS |
39 | if (strcmp(FsTypes[i].name, qemu_opt_get(opts, "fstype")) == 0) { |
40 | break; | |
41 | } | |
42 | } | |
43 | ||
44 | if (i == ARRAY_SIZE(FsTypes)) { | |
45 | fprintf(stderr, "fsdev: fstype %s not found\n", | |
46 | qemu_opt_get(opts, "fstype")); | |
47 | return -1; | |
48 | } | |
49 | ||
9ce56db6 VJ |
50 | if (qemu_opt_get(opts, "security_model") == NULL) { |
51 | fprintf(stderr, "fsdev: No security_model specified.\n"); | |
52 | return -1; | |
53 | } | |
54 | ||
74db920c GS |
55 | fsle = qemu_malloc(sizeof(*fsle)); |
56 | ||
57 | fsle->fse.fsdev_id = qemu_strdup(qemu_opts_id(opts)); | |
58 | fsle->fse.path = qemu_strdup(qemu_opt_get(opts, "path")); | |
9ce56db6 VJ |
59 | fsle->fse.security_model = qemu_strdup(qemu_opt_get(opts, |
60 | "security_model")); | |
74db920c GS |
61 | fsle->fse.ops = FsTypes[i].ops; |
62 | ||
63 | QTAILQ_INSERT_TAIL(&fstype_entries, fsle, next); | |
64 | return 0; | |
65 | ||
66 | } | |
67 | ||
68 | FsTypeEntry *get_fsdev_fsentry(char *id) | |
69 | { | |
70 | struct FsTypeListEntry *fsle; | |
71 | ||
72 | QTAILQ_FOREACH(fsle, &fstype_entries, next) { | |
73 | if (strcmp(fsle->fse.fsdev_id, id) == 0) { | |
74 | return &fsle->fse; | |
75 | } | |
76 | } | |
77 | return NULL; | |
78 | } | |
526c5237 GH |
79 | |
80 | static void fsdev_register_config(void) | |
81 | { | |
82 | qemu_add_opts(&qemu_fsdev_opts); | |
83 | qemu_add_opts(&qemu_virtfs_opts); | |
84 | } | |
85 | machine_init(fsdev_register_config); | |
86 |