trace: Relax trace-events parsing regex in simpletrace.py
[qemu/mdroth.git] / fsdev / qemu-fsdev.c
blob280b8f57b9dce28063d745b8ab9e5c15ce88577e
1 /*
2 * Virtio 9p
4 * Copyright IBM, Corp. 2010
6 * Authors:
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.
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"
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;
31 int i;
33 if (qemu_opts_id(opts) == NULL) {
34 fprintf(stderr, "fsdev: No id specified\n");
35 return -1;
38 for (i = 0; i < ARRAY_SIZE(FsTypes); i++) {
39 if (strcmp(FsTypes[i].name, qemu_opt_get(opts, "fstype")) == 0) {
40 break;
44 if (i == ARRAY_SIZE(FsTypes)) {
45 fprintf(stderr, "fsdev: fstype %s not found\n",
46 qemu_opt_get(opts, "fstype"));
47 return -1;
50 if (qemu_opt_get(opts, "security_model") == NULL) {
51 fprintf(stderr, "fsdev: No security_model specified.\n");
52 return -1;
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,
60 "security_model"));
61 fsle->fse.ops = FsTypes[i].ops;
63 QTAILQ_INSERT_TAIL(&fstype_entries, fsle, next);
64 return 0;
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) {
74 return &fsle->fse;
77 return NULL;
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);