[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v4 PATCH 29/49] multi-process: add parse_cmdline in remote process
From: |
Jagannathan Raman |
Subject: |
[RFC v4 PATCH 29/49] multi-process: add parse_cmdline in remote process |
Date: |
Thu, 24 Oct 2019 05:09:10 -0400 |
From: Elena Ufimtseva <address@hidden>
Signed-off-by: Elena Ufimtseva <address@hidden>
Signed-off-by: Jagannathan Raman <address@hidden>
Signed-off-by: John G Johnson <address@hidden>
---
New patch in v3
remote/Makefile.objs | 1 +
remote/remote-main.c | 11 +++++
remote/remote-opts.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++
remote/remote-opts.h | 31 ++++++++++++++
4 files changed, 158 insertions(+)
create mode 100644 remote/remote-opts.c
create mode 100644 remote/remote-opts.h
diff --git a/remote/Makefile.objs b/remote/Makefile.objs
index c1349ad..a677fce 100644
--- a/remote/Makefile.objs
+++ b/remote/Makefile.objs
@@ -1,4 +1,5 @@
remote-pci-obj-$(CONFIG_MPQEMU) += remote-main.o
+remote-pci-obj-$(CONFIG_MPQEMU) += remote-opts.o
remote-pci-obj-$(CONFIG_MPQEMU) += pcihost.o
remote-pci-obj-$(CONFIG_MPQEMU) += machine.o
remote-pci-obj-$(CONFIG_MPQEMU) += iohub.o
diff --git a/remote/remote-main.c b/remote/remote-main.c
index 80d8c02..729f7e9 100644
--- a/remote/remote-main.c
+++ b/remote/remote-main.c
@@ -65,6 +65,7 @@
#include "qapi/qmp/qlist.h"
#include "qemu/log.h"
#include "qemu/cutils.h"
+#include "remote-opts.h"
static MPQemuLinkState *mpqemu_link;
PCIDevice *remote_pci_dev;
@@ -469,6 +470,13 @@ int main(int argc, char *argv[])
current_machine = MACHINE(REMOTE_MACHINE(object_new(TYPE_REMOTE_MACHINE)));
+ qemu_add_opts(&qemu_device_opts);
+ qemu_add_opts(&qemu_drive_opts);
+ qemu_add_drive_opts(&qemu_legacy_drive_opts);
+ qemu_add_drive_opts(&qemu_common_drive_opts);
+ qemu_add_drive_opts(&qemu_drive_opts);
+ qemu_add_drive_opts(&bdrv_runtime_opts);
+
mpqemu_link = mpqemu_link_create();
if (!mpqemu_link) {
printf("Could not create MPQemu link\n");
@@ -482,6 +490,9 @@ int main(int argc, char *argv[])
}
mpqemu_init_channel(mpqemu_link, &mpqemu_link->com, fd);
+
+ parse_cmdline(argc - 2, argv + 2, NULL);
+
mpqemu_link_set_callback(mpqemu_link, process_msg);
mpqemu_start_coms(mpqemu_link);
diff --git a/remote/remote-opts.c b/remote/remote-opts.c
new file mode 100644
index 0000000..0ebe6b1
--- /dev/null
+++ b/remote/remote-opts.c
@@ -0,0 +1,115 @@
+/*
+ * Remote device initialization
+ *
+ * Copyright 2019, Oracle and/or its affiliates.
+ *
+ * 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-common.h"
+
+#include <stdio.h>
+#include <unistd.h>
+
+#include "qemu/module.h"
+#include "qapi/error.h"
+#include "qemu/error-report.h"
+#include "qemu-common.h"
+
+#include "remote/pcihost.h"
+#include "remote/machine.h"
+#include "hw/boards.h"
+#include "hw/qdev-core.h"
+#include "qemu/main-loop.h"
+#include "remote/memory.h"
+#include "io/mpqemu-link.h"
+#include "qapi/error.h"
+#include "qemu-options.h"
+#include "sysemu/arch_init.h"
+
+#include "qapi/qmp/qjson.h"
+#include "qapi/qmp/qobject.h"
+#include "qemu/option.h"
+#include "qemu/config-file.h"
+#include "monitor/qdev.h"
+#include "qapi/qmp/qdict.h"
+#include "sysemu/sysemu.h"
+#include "sysemu/blockdev.h"
+#include "block/block.h"
+#include "remote/remote-opts.h"
+#include "include/qemu-common.h"
+
+#include "vl.h"
+/*
+ * In remote process, we parse only subset of options. The code
+ * taken from vl.c to re-use in remote command line parser.
+ */
+void parse_cmdline(int argc, char **argv, char **envp)
+{
+ int optind;
+ const char *optarg;
+ MachineClass *mc;
+
+ /* from vl.c */
+ optind = 0;
+
+ /* second pass of option parsing */
+
+ for (;;) {
+ if (optind >= argc) {
+ break;
+ }
+ if (argv[optind][0] != '-') {
+ loc_set_cmdline(argv, optind, 1);
+ drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
+ } else {
+ const QEMUOption *popt;
+
+ popt = lookup_opt(argc, argv, &optarg, &optind);
+ #ifndef REMOTE_PROCESS
+ if (!(popt->arch_mask & arch_type)) {
+ error_report("Option not supported for this target, %x
arch_mask, %x arch_type",
+ popt->arch_mask, arch_type);
+ exit(1);
+ }
+ #endif
+ switch (popt->index) {
+ case QEMU_OPTION_drive:
+ if (drive_def(optarg) == NULL) {
+ fprintf(stderr, "Could not init drive\n");
+ exit(1);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ mc = MACHINE_GET_CLASS(current_machine);
+
+ mc->block_default_type = IF_IDE;
+ if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func,
+ &mc->block_default_type, &error_fatal)) {
+ /* We printed help */
+ exit(0);
+ }
+
+ return;
+}
diff --git a/remote/remote-opts.h b/remote/remote-opts.h
new file mode 100644
index 0000000..e15c29b
--- /dev/null
+++ b/remote/remote-opts.h
@@ -0,0 +1,31 @@
+/*
+ * Remote device initialization
+ *
+ * Copyright 2019, Oracle and/or its affiliates.
+ *
+ * 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 REMOTE_OPTS_H
+#define REMOTE_OPTS_H
+
+void parse_cmdline(int argc, char **argv, char **envp);
+
+#endif
+
--
1.8.3.1
- [RFC v4 PATCH 44/49] multi-process/mig: refactor runstate_check into common file, (continued)
- [RFC v4 PATCH 44/49] multi-process/mig: refactor runstate_check into common file, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 45/49] multi-process/mig: Synchronize runstate of remote process, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 47/49] multi-process: Enable support for multiple devices in remote, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 08/49] multi-process: add functions to synchronize proxy and remote endpoints, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 07/49] multi-process: define mpqemu-link object, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 49/49] multi-process: add configure and usage information, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 48/49] multi-process: add the concept description to docs/devel/qemu-multiprocess, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 12/49] multi-process: remote process initialization, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 17/49] multi-process: Synchronize remote memory, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 25/49] multi-process: Introduce build flags to separate remote process code, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 29/49] multi-process: add parse_cmdline in remote process,
Jagannathan Raman <=
- [RFC v4 PATCH 33/49] multi-process: perform device reset in the remote process, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 43/49] multi-process/mig: Load VMSD in the proxy object, Jagannathan Raman, 2019/10/24
- [RFC v4 PATCH 46/49] multi-process/mig: Restore the VMSD in remote process, Jagannathan Raman, 2019/10/24
- Re: [RFC v4 PATCH 00/49] Initial support of multi-process qemu, no-reply, 2019/10/24
- Re: [RFC v4 PATCH 00/49] Initial support of multi-process qemu, no-reply, 2019/10/24
- Re: [RFC v4 PATCH 00/49] Initial support of multi-process qemu, no-reply, 2019/10/24