@@ -35,6 +35,9 @@ net-nested-$(CONFIG_SLIRP) += slirp.o
net-nested-$(CONFIG_VDE) += vde.o
net-obj-y += $(addprefix net/, $(net-nested-y))
+fsdev-nested-y = qemu-fsdev.o
+fsdev-obj-y += $(addprefix fsdev/, $(fsdev-nested-y))
+
######################################################################
# libqemu_common.a: Target independent part of system emulation. The
# long term path is to suppress *all* target specific code in case of
@@ -44,8 +47,8 @@ net-obj-y += $(addprefix net/, $(net-nested-y))
common-obj-y = $(block-obj-y)
common-obj-y += $(net-obj-y)
common-obj-y += $(qobject-obj-y)
+common-obj-y += $(fsdev-obj-y)
common-obj-y += readline.o console.o async.o qemu-error.o
-
common-obj-y += tcg-runtime.o host-utils.o
common-obj-y += irq.o ioport.o input.o
common-obj-$(CONFIG_PTIMER) += ptimer.o
new file mode 100644
@@ -0,0 +1,70 @@
+/*
+ * Virtio 9p
+ *
+ * Copyright IBM, Corp. 2010
+ *
+ * Authors:
+ * Gautham R Shenoy <ego@in.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2. See
+ * the COPYING file in the top-level directory.
+ *
+ */
+#include <stdio.h>
+#include <string.h>
+#include "qemu-fsdev.h"
+#include "qemu-queue.h"
+#include "osdep.h"
+#include "qemu-common.h"
+
+static QTAILQ_HEAD(FsTypeEntry_head, FsTypeListEntry) fstype_entries =
+ QTAILQ_HEAD_INITIALIZER(fstype_entries);
+
+extern FileOperations local_ops;
+static FsTypeTable FsTypes[] = {
+ { .name ="local", .ops = &local_ops},
+};
+
+int qemu_fsdev_add(QemuOpts *opts)
+{
+ struct FsTypeListEntry *fsle;
+ int i;
+
+ if (qemu_opts_id(opts) == NULL) {
+ fprintf(stderr, "fsdev: No id specified\n");
+ return -1;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(FsTypes); i++) {
+ if (strcmp(FsTypes[i].name, qemu_opt_get(opts, "fstype")) == 0)
+ break;
+ }
+
+ if (i == ARRAY_SIZE(FsTypes)) {
+ fprintf(stderr, "fsdev: fstype %s not found\n",
+ qemu_opt_get(opts, "fstype"));
+ return -1;
+ }
+
+ fsle =qemu_malloc(sizeof(*fsle));
+
+ fsle->fse.fsdev_id = qemu_strdup(qemu_opts_id(opts));
+ fsle->fse.path = qemu_strdup(qemu_opt_get(opts, "path"));
+ fsle->fse.ops = FsTypes[i].ops;
+
+ QTAILQ_INSERT_TAIL(&fstype_entries, fsle, next);
+ return 0;
+
+}
+
+FsTypeEntry * get_fsdev_fsentry(char *id)
+{
+ struct FsTypeListEntry *fsle;
+
+ QTAILQ_FOREACH(fsle, &fstype_entries, next) {
+ if (strcmp(fsle->fse.fsdev_id, id) == 0) {
+ return &fsle->fse;
+ }
+ }
+ return NULL;
+}
new file mode 100644
@@ -0,0 +1,53 @@
+/*
+ * Virtio 9p
+ *
+ * Copyright IBM, Corp. 2010
+ *
+ * Authors:
+ * Gautham R Shenoy <ego@in.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2. See
+ * the COPYING file in the top-level directory.
+ *
+ */
+#ifndef QEMU_FSDEV_H
+#define QEMU_FSDEV_H
+#include "qemu-option.h"
+#include "hw/file-op.h"
+
+
+/*
+ * A table to store the various file systems and their callback operations.
+ * -----------------
+ * fstype | ops
+ * -----------------
+ * local | local_ops
+ * . |
+ * . |
+ * . |
+ * . |
+ * -----------------
+ * etc
+ */
+typedef struct FsTypeTable {
+ const char *name;
+ FileOperations *ops;
+} FsTypeTable;
+
+/*
+ * Structure to store the various fsdev's passed through command line.
+ */
+typedef struct FsTypeEntry {
+ char *fsdev_id;
+ char *path;
+ FileOperations *ops;
+} FsTypeEntry;
+
+typedef struct FsTypeListEntry {
+ FsTypeEntry fse;
+ QTAILQ_ENTRY(FsTypeListEntry) next;
+} FsTypeListEntry;
+
+extern int qemu_fsdev_add(QemuOpts *opts);
+extern FsTypeEntry *get_fsdev_fsentry(char *id);
+#endif
@@ -254,7 +254,7 @@ static int local_fsync(FsContext *s, int fd)
return fsync(fd);
}
-static FileOperations ops = {
+FileOperations local_ops = {
.lstat = local_lstat,
.setuid = local_setuid,
.readlink = local_readlink,
@@ -287,5 +287,5 @@ static FileOperations ops = {
FileOperations *virtio_9p_init_local(const char *path)
{
- return &ops;
+ return &local_ops;
}
@@ -150,6 +150,7 @@ int main(int argc, char **argv)
#include "qemu-option.h"
#include "qemu-config.h"
#include "qemu-objects.h"
+#include "fsdev/qemu-fsdev.h"
#include "disas.h"
@@ -3461,6 +3462,14 @@ static int chardev_init_func(QemuOpts *opts, void *opaque)
return 0;
}
+static int fsdev_init_func(QemuOpts *opts, void *opaque)
+{
+ int ret;
+ ret = qemu_fsdev_add(opts);
+
+ return ret;
+}
+
static int mon_init_func(QemuOpts *opts, void *opaque)
{
CharDriverState *chr;
@@ -4256,6 +4265,13 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
break;
+ case QEMU_OPTION_fsdev:
+ opts = qemu_opts_parse(&qemu_fsdev_opts, optarg, 1);
+ if (!opts) {
+ fprintf(stderr, "parse error: %s\n", optarg);
+ exit(1);
+ }
+ break;
case QEMU_OPTION_serial:
add_device_config(DEV_SERIAL, optarg);
default_serial = 0;
@@ -4625,6 +4641,8 @@ int main(int argc, char **argv, char **envp)
if (qemu_opts_foreach(&qemu_chardev_opts, chardev_init_func, NULL, 1) != 0)
exit(1);
+ if (qemu_opts_foreach(&qemu_fsdev_opts, fsdev_init_func, NULL, 1) != 0)
+ exit(1);
#ifndef _WIN32
if (daemonize) {