[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v3 PATCH 32/45] multi-process: add parse_cmdline in re
From: |
Jagannathan Raman |
Subject: |
[Qemu-devel] [RFC v3 PATCH 32/45] multi-process: add parse_cmdline in remote process |
Date: |
Tue, 3 Sep 2019 16:37:58 -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 | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++
remote/remote-opts.h | 31 ++++++++++++++
4 files changed, 156 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 0c0e085..416b8a1 100644
--- a/remote/remote-main.c
+++ b/remote/remote-main.c
@@ -64,6 +64,7 @@
#include "qapi/qmp/qlist.h"
#include "qemu/log.h"
#include "qemu/cutils.h"
+#include "remote-opts.h"
static ProxyLinkState *proxy_link;
PCIDevice *remote_pci_dev;
@@ -468,6 +469,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);
+
proxy_link = proxy_link_create();
if (!proxy_link) {
printf("Could not create proxy link\n");
@@ -481,6 +489,9 @@ int main(int argc, char *argv[])
}
proxy_link_init_channel(proxy_link, &proxy_link->com, fd);
+
+ parse_cmdline(argc - 2, argv + 2, NULL);
+
proxy_link_set_callback(proxy_link, process_msg);
start_handler(proxy_link);
diff --git a/remote/remote-opts.c b/remote/remote-opts.c
new file mode 100644
index 0000000..416ff59
--- /dev/null
+++ b/remote/remote-opts.c
@@ -0,0 +1,113 @@
+/*
+ * 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 <stdio.h>
+#include <glib.h>
+#include <unistd.h>
+#include "qemu/osdep.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/proxy-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
- [Qemu-devel] [RFC v3 PATCH 20/45] multi-process: Synchronize remote memory, (continued)
- [Qemu-devel] [RFC v3 PATCH 20/45] multi-process: Synchronize remote memory, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 21/45] multi-process: create IOHUB object to handle irq, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 25/45] multi-process: remote: use fd for socket from parent process, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 24/45] multi-process: remote: add setup_devices and setup_drive msg processing, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 27/45] multi-process: add processing of remote drive and device command line, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 26/45] multi-process: remote: add create_done condition, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 23/45] multi-process: add qdev_proxy_add to create proxy devices, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 29/45] multi-process: refractor vl.c code to re-use in remote, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 28/45] multi-process: Introduce build flags to separate remote process code, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 30/45] multi-process: add remote option, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 32/45] multi-process: add parse_cmdline in remote process,
Jagannathan Raman <=
- [Qemu-devel] [RFC v3 PATCH 31/45] multi-process: add remote options parser, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 34/45] multi-process: add heartbeat timer and signal handler, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 33/45] multi-process: add support for multiple devices, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 35/45] multi-process: handle heartbeat messages in remote process, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 37/45] multi-process: perform device reset in the remote process, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 38/45] multi-process/mon: stub functions to enable QMP module for remote process, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 39/45] multi-process/mon: build system for QMP module in remote process, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 36/45] multi-process: Use separate MMIO communication channel, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 40/45] multi-process/mon: Refactor monitor/chardev functions out of vl.c, Jagannathan Raman, 2019/09/03