@@ -104,6 +104,8 @@ qemu-seccomp.o-libs := $(SECCOMP_LIBS)
common-obj-$(CONFIG_FDT) += device_tree.o
+common-obj-y += vl-parse.o
+
######################################################################
# qapi
@@ -2,3 +2,4 @@ remote-pci-obj-$(CONFIG_MPQEMU) += remote-main.o
remote-pci-obj-$(CONFIG_MPQEMU) += pcihost.o
remote-pci-obj-$(CONFIG_MPQEMU) += machine.o
remote-pci-obj-$(CONFIG_MPQEMU) += iohub.o
+remote-pci-obj-$(CONFIG_MPQEMU) +=../vl-parse.o
new file mode 100644
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/units.h"
+#include "qapi/error.h"
+#include "qemu/cutils.h"
+#include "qemu/error-report.h"
+#include "hw/qdev.h"
+#include "monitor/qdev.h"
+#include "sysemu/sysemu.h"
+#include "qemu/option.h"
+#include "qemu-options.h"
+#include "sysemu/blockdev.h"
+
+#include "chardev/char.h"
+#include "monitor/monitor.h"
+#include "qemu/config-file.h"
+
+#include "sysemu/arch_init.h"
+
+#include "vl.h"
+
+/***********************************************************/
+/* QEMU Block devices */
+
+static const QEMUOption qemu_options[] = {
+ { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL },
+#define QEMU_OPTIONS_GENERATE_OPTIONS
+#include "qemu-options-wrapper.h"
+ { NULL },
+};
+
+const QEMUOption *lookup_opt(int argc, char **argv,
+ const char **poptarg, int *poptind)
+{
+ const QEMUOption *popt;
+ int optind = *poptind;
+ char *r = argv[optind];
+ const char *optarg;
+
+ loc_set_cmdline(argv, optind, 1);
+ optind++;
+ /* Treat --foo the same as -foo. */
+ if (r[1] == '-') {
+ r++;
+ }
+ popt = qemu_options;
+ if (!popt) {
+ error_report("No valide qemu_options");
+ }
+ for (;;) {
+ if (!popt->name) {
+ error_report("invalid option*");
+ exit(1);
+ popt++;
+ continue;
+ }
+ if (!strcmp(popt->name, r + 1)) {
+ break;
+ }
+ popt++;
+ }
+ if (popt->flags & HAS_ARG) {
+ if (optind >= argc) {
+ error_report("optind %d, argc %d", optind, argc);
+ error_report("requires an argument");
+ exit(1);
+ }
+ optarg = argv[optind++];
+ loc_set_cmdline(argv, optind - 2, 2);
+ } else {
+ optarg = NULL;
+ }
+
+ *poptarg = optarg;
+ *poptind = optind;
+
+ return popt;
+}
+
+int drive_init_func(void *opaque, QemuOpts *opts, Error **errp)
+{
+ BlockInterfaceType *block_default_type = opaque;
+
+ if (!drive_new(opts, *block_default_type, errp)) {
+ error_report_err(*errp);
+ }
+
+ return 0;
+}
+
+#if defined(CONFIG_MPQEMU)
+int rdrive_init_func(void *opaque, QemuOpts *opts, Error **errp)
+{
+ DeviceState *dev;
+
+ dev = qdev_remote_add(opts, false /* this is drive */, errp);
+ if (!dev) {
+ error_setg(errp, "qdev_remote_add failed for drive.");
+ return -1;
+ }
+ object_unref(OBJECT(dev));
+ return 0;
+}
+#endif
+
+#if defined(CONFIG_MPQEMU)
+int rdevice_init_func(void *opaque, QemuOpts *opts, Error **errp)
+{
+ DeviceState *dev;
+
+ dev = qdev_remote_add(opts, true /* this is device */, errp);
+ if (!dev) {
+ error_setg(errp, "qdev_remote_add failed for device.");
+ return -1;
+ }
+ return 0;
+}
+#endif
+
+int device_init_func(void *opaque, QemuOpts *opts, Error **errp)
+{
+ DeviceState *dev;
+ const char *remote = NULL;
+
+ remote = qemu_opt_get(opts, "rid");
+ if (remote) {
+ return 0;
+ }
+
+ dev = qdev_device_add(opts, errp);
+ if (!dev) {
+ return -1;
+ }
+ object_unref(OBJECT(dev));
+ return 0;
+}
@@ -37,6 +37,7 @@
#include "qapi/qmp/qstring.h"
#include "qapi/qmp/qjson.h"
#include "qapi/qmp/qlist.h"
+#include "vl.h"
#ifdef CONFIG_SDL
#if defined(__APPLE__) || defined(main)
@@ -1133,52 +1134,6 @@ static int cleanup_add_fd(void *opaque, QemuOpts *opts, Error **errp)
/***********************************************************/
/* QEMU Block devices */
-#define HD_OPTS "media=disk"
-#define CDROM_OPTS "media=cdrom"
-#define FD_OPTS ""
-#define PFLASH_OPTS ""
-#define MTD_OPTS ""
-#define SD_OPTS ""
-
-#if defined(CONFIG_MPQEMU)
-static int rdrive_init_func(void *opaque, QemuOpts *opts, Error **errp)
-{
- DeviceState *dev;
-
- dev = qdev_remote_add(opts, false /* this is drive */, errp);
- if (!dev) {
- error_setg(errp, "qdev_remote_add failed for drive.");
- return -1;
- }
- object_unref(OBJECT(dev));
- return 0;
-}
-#endif
-
-static int pass;
-
-static int drive_init_func(void *opaque, QemuOpts *opts, Error **errp)
-{
- BlockInterfaceType *block_default_type = opaque;
-
-#if defined(CONFIG_MPQEMU)
- const char *remote;
-
- remote = qemu_opt_get(opts, "remote");
- if (pass && remote) {
- return rdrive_init_func(opaque, opts, errp);
- } else {
- if (!remote && !pass) {
- drive_new(opts, *block_default_type, errp);
- }
- }
-
- return 0;
-#else
- return drive_new(opts, *block_default_type, errp) == NULL;
-#endif
-}
-
static int drive_enable_snapshot(void *opaque, QemuOpts *opts, Error **errp)
{
if (qemu_opt_get(opts, "snapshot") == NULL) {
@@ -1860,21 +1815,6 @@ static void help(int exitcode)
exit(exitcode);
}
-#define HAS_ARG 0x0001
-
-typedef struct QEMUOption {
- const char *name;
- int flags;
- int index;
- uint32_t arch_mask;
-} QEMUOption;
-
-static const QEMUOption qemu_options[] = {
- { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL },
-#define QEMU_OPTIONS_GENERATE_OPTIONS
-#include "qemu-options-wrapper.h"
- { NULL },
-};
typedef struct VGAInterfaceInfo {
const char *opt_name; /* option name */
@@ -2221,43 +2161,6 @@ static int device_help_func(void *opaque, QemuOpts *opts, Error **errp)
return qdev_device_help(opts);
}
-#if defined(CONFIG_MPQEMU)
-static int rdevice_init_func(void *opaque, QemuOpts *opts, Error **errp)
-{
- DeviceState *dev;
-
- dev = qdev_remote_add(opts, true /* this is device */, errp);
- if (!dev) {
- error_setg(errp, "qdev_remote_add failed for device.");
- return -1;
- }
- object_unref(OBJECT(dev));
- return 0;
-}
-#endif
-
-static int device_init_func(void *opaque, QemuOpts *opts, Error **errp)
-{
- DeviceState *dev;
-
-#if defined(CONFIG_MPQEMU)
- const char *remote;
-
- remote = qemu_opt_get(opts, "remote");
- if (remote) {
- /* This will be a remote process */
- return rdevice_init_func(opaque, opts, errp);
- }
-#endif
-
- dev = qdev_device_add(opts, errp);
- if (!dev) {
- return -1;
- }
- object_unref(OBJECT(dev));
- return 0;
-}
-
static int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp)
{
Error *local_err = NULL;
@@ -2587,46 +2490,6 @@ static void qemu_run_machine_init_done_notifiers(void)
notifier_list_notify(&machine_init_done_notifiers, NULL);
}
-static const QEMUOption *lookup_opt(int argc, char **argv,
- const char **poptarg, int *poptind)
-{
- const QEMUOption *popt;
- int optind = *poptind;
- char *r = argv[optind];
- const char *optarg;
-
- loc_set_cmdline(argv, optind, 1);
- optind++;
- /* Treat --foo the same as -foo. */
- if (r[1] == '-')
- r++;
- popt = qemu_options;
- for(;;) {
- if (!popt->name) {
- error_report("invalid option");
- exit(1);
- }
- if (!strcmp(popt->name, r + 1))
- break;
- popt++;
- }
- if (popt->flags & HAS_ARG) {
- if (optind >= argc) {
- error_report("requires an argument");
- exit(1);
- }
- optarg = argv[optind++];
- loc_set_cmdline(argv, optind - 2, 2);
- } else {
- optarg = NULL;
- }
-
- *poptarg = optarg;
- *poptind = optind;
-
- return popt;
-}
-
static MachineClass *select_machine(void)
{
GSList *machines = object_class_get_list(TYPE_MACHINE, false);
@@ -4429,17 +4292,6 @@ int main(int argc, char **argv, char **envp)
/* Check if IGD GFX passthrough. */
igd_gfx_passthru();
-#if defined(CONFIG_MPQEMU)
- /*
- * Parse the list for remote drives here as we launch PCIProxyDev here and
- * need PCI host initialized. As a TODO: could defer init of PCIProxyDev instead.
- */
- if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func,
- &machine_class->block_default_type, &error_fatal)) {
- exit(0);
- }
-#endif
-
/* init generic devices */
rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE);
qemu_opts_foreach(qemu_find_opts("device"),
new file mode 100644
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef VL_H
+#define VL_H
+
+/***********************************************************/
+/* QEMU Block devices */
+
+#define HD_OPTS "media=disk"
+#define CDROM_OPTS "media=cdrom"
+#define FD_OPTS ""
+#define PFLASH_OPTS ""
+#define MTD_OPTS ""
+#define SD_OPTS ""
+
+
+#define HAS_ARG 0x0001
+typedef struct QEMUOption {
+ const char *name;
+ int flags;
+ int index;
+ uint32_t arch_mask;
+} QEMUOption;
+
+const QEMUOption *lookup_opt(int argc, char **argv,
+ const char **poptarg, int *poptind);
+
+int drive_init_func(void *opaque, QemuOpts *opts, Error **errp);
+int device_init_func(void *opaque, QemuOpts *opts, Error **errp);
+int rdrive_init_func(void *opaque, QemuOpts *opts, Error **errp);
+int rdevice_init_func(void *opaque, QemuOpts *opts, Error **errp);
+
+#endif /* VL_H */
+