@@ -32,6 +32,11 @@
#include "qemu/uuid.h"
#include "sysemu/seccomp.h"
#include "sysemu/tcg.h"
+#include "qapi/qmp/qdict.h"
+#include "block/qdict.h"
+#include "qapi/qmp/qstring.h"
+#include "qapi/qmp/qjson.h"
+#include "qapi/qmp/qlist.h"
#ifdef CONFIG_SDL
#if defined(__APPLE__) || defined(main)
@@ -1135,11 +1140,43 @@ static int cleanup_add_fd(void *opaque, QemuOpts *opts, Error **errp)
#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)
@@ -2184,10 +2221,35 @@ 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;
@@ -4367,6 +4429,17 @@ 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"),
@@ -4424,6 +4497,9 @@ int main(int argc, char **argv, char **envp)
qemu_register_reset(qbus_reset_all_fn, sysbus_get_default());
qemu_run_machine_init_done_notifiers();
+#if defined(CONFIG_MPQEMU)
+ qdev_proxy_fire();
+#endif
if (rom_check_and_register_reset() != 0) {
error_report("rom check and register reset failed");
exit(1);