]> git.proxmox.com Git - mirror_qemu.git/blobdiff - fsdev/qemu-fsdev.c
Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190204' into staging
[mirror_qemu.git] / fsdev / qemu-fsdev.c
index 4cc04d4fde49622e54e01df158c27e6f829981d0..54cb36a2124bfb0da969ef1a0547f185a53dbb72 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Virtio 9p
+ * 9p
  *
  * Copyright IBM, Corp. 2010
  *
@@ -8,29 +8,26 @@
  *
  * 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/osdep.h"
+#include "qapi/error.h"
 #include "qemu-fsdev.h"
 #include "qemu/queue.h"
-#include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "qemu/config-file.h"
+#include "qemu/error-report.h"
+#include "qemu/option.h"
 
-static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries =
+static QTAILQ_HEAD(, FsDriverListEntry) fsdriver_entries =
     QTAILQ_HEAD_INITIALIZER(fsdriver_entries);
 
 static FsDriverTable FsDrivers[] = {
     { .name = "local", .ops = &local_ops},
-#ifdef CONFIG_OPEN_BY_HANDLE
-    { .name = "handle", .ops = &handle_ops},
-#endif
     { .name = "synth", .ops = &synth_ops},
     { .name = "proxy", .ops = &proxy_ops},
 };
 
-int qemu_fsdev_add(QemuOpts *opts)
+int qemu_fsdev_add(QemuOpts *opts, Error **errp)
 {
     int i;
     struct FsDriverListEntry *fsle;
@@ -40,7 +37,7 @@ int qemu_fsdev_add(QemuOpts *opts)
     bool ro = qemu_opt_get_bool(opts, "readonly", 0);
 
     if (!fsdev_id) {
-        fprintf(stderr, "fsdev: No id specified\n");
+        error_setg(errp, "fsdev: No id specified");
         return -1;
     }
 
@@ -52,11 +49,11 @@ int qemu_fsdev_add(QemuOpts *opts)
         }
 
         if (i == ARRAY_SIZE(FsDrivers)) {
-            fprintf(stderr, "fsdev: fsdriver %s not found\n", fsdriver);
+            error_setg(errp, "fsdev: fsdriver %s not found", fsdriver);
             return -1;
         }
     } else {
-        fprintf(stderr, "fsdev: No fsdriver specified\n");
+        error_setg(errp, "fsdev: No fsdriver specified");
         return -1;
     }
 
@@ -75,7 +72,9 @@ int qemu_fsdev_add(QemuOpts *opts)
     }
 
     if (fsle->fse.ops->parse_opts) {
-        if (fsle->fse.ops->parse_opts(opts, &fsle->fse)) {
+        if (fsle->fse.ops->parse_opts(opts, &fsle->fse, errp)) {
+            g_free(fsle->fse.fsdev_id);
+            g_free(fsle);
             return -1;
         }
     }
@@ -97,11 +96,3 @@ FsDriverEntry *get_fsdev_fsentry(char *id)
     }
     return NULL;
 }
-
-static void fsdev_register_config(void)
-{
-    qemu_add_opts(&qemu_fsdev_opts);
-    qemu_add_opts(&qemu_virtfs_opts);
-}
-machine_init(fsdev_register_config);
-