[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RESEND v6 17/36] multi-process: introduce proxy object
From: |
elena . ufimtseva |
Subject: |
[PATCH RESEND v6 17/36] multi-process: introduce proxy object |
Date: |
Wed, 22 Apr 2020 21:13:52 -0700 |
From: Elena Ufimtseva <address@hidden>
Defines a PCI Device proxy object as a parent of TYPE_PCI_DEVICE.
PCI Proxy Object registers as a PCI device with QEMU and forwards all
PCI accesses to the remote process using the communication channel.
Signed-off-by: Elena Ufimtseva <address@hidden>
Signed-off-by: Jagannathan Raman <address@hidden>
Signed-off-by: John G Johnson <address@hidden>
---
MAINTAINERS | 3 ++
hw/Makefile.objs | 2 ++
hw/proxy/Makefile.objs | 1 +
hw/proxy/qemu-proxy.c | 56 +++++++++++++++++++++++++++++++++++
include/hw/proxy/qemu-proxy.h | 46 ++++++++++++++++++++++++++++
include/io/mpqemu-link.h | 1 +
6 files changed, 109 insertions(+)
create mode 100644 hw/proxy/Makefile.objs
create mode 100644 hw/proxy/qemu-proxy.c
create mode 100644 include/hw/proxy/qemu-proxy.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 96f8d7ff19..3da3dcd311 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2866,6 +2866,9 @@ F: include/remote/machine.h
F: remote/machine.c
F: include/remote/memory.h
F: remote/memory.c
+F: hw/proxy/Makefile.objs
+F: hw/proxy/qemu-proxy.c
+F: include/hw/proxy/qemu-proxy.h
Build and test automation
-------------------------
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index af9235b6f2..7b489b12a5 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -45,6 +45,8 @@ endif
common-obj-y += $(devices-dirs-y)
obj-y += $(devices-dirs-y)
+common-obj-$(CONFIG_MPQEMU) += proxy/
+
remote-pci-obj-$(CONFIG_MPQEMU) += core/
remote-pci-obj-$(CONFIG_MPQEMU) += block/
remote-pci-obj-$(CONFIG_MPQEMU) += pci/
diff --git a/hw/proxy/Makefile.objs b/hw/proxy/Makefile.objs
new file mode 100644
index 0000000000..eb81624cf8
--- /dev/null
+++ b/hw/proxy/Makefile.objs
@@ -0,0 +1 @@
+common-obj-$(CONFIG_MPQEMU) += qemu-proxy.o
diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c
new file mode 100644
index 0000000000..bf6c4117ef
--- /dev/null
+++ b/hw/proxy/qemu-proxy.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2018, 2020 Oracle and/or its affiliates.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+
+#include "qapi/error.h"
+#include "io/mpqemu-link.h"
+#include "hw/proxy/qemu-proxy.h"
+#include "hw/pci/pci.h"
+
+static void pci_proxy_dev_realize(PCIDevice *device, Error **errp)
+{
+ PCIProxyDev *dev = PCI_PROXY_DEV(device);
+ PCIProxyDevClass *k = PCI_PROXY_DEV_GET_CLASS(dev);
+ Error *local_err = NULL;
+
+ if (k->realize) {
+ k->realize(dev, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ }
+ }
+}
+
+static void pci_proxy_dev_class_init(ObjectClass *klass, void *data)
+{
+ PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+ k->realize = pci_proxy_dev_realize;
+}
+
+static const TypeInfo pci_proxy_dev_type_info = {
+ .name = TYPE_PCI_PROXY_DEV,
+ .parent = TYPE_PCI_DEVICE,
+ .instance_size = sizeof(PCIProxyDev),
+ .class_size = sizeof(PCIProxyDevClass),
+ .class_init = pci_proxy_dev_class_init,
+ .interfaces = (InterfaceInfo[]) {
+ { INTERFACE_CONVENTIONAL_PCI_DEVICE },
+ { },
+ },
+};
+
+static void pci_proxy_dev_register_types(void)
+{
+ type_register_static(&pci_proxy_dev_type_info);
+}
+
+type_init(pci_proxy_dev_register_types)
+
diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h
new file mode 100644
index 0000000000..d7eaf26f29
--- /dev/null
+++ b/include/hw/proxy/qemu-proxy.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2018, 2020 Oracle and/or its affiliates.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_PROXY_H
+#define QEMU_PROXY_H
+
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+
+#include "io/mpqemu-link.h"
+#include "hw/pci/pci.h"
+
+#define TYPE_PCI_PROXY_DEV "pci-proxy-dev"
+
+#define PCI_PROXY_DEV(obj) \
+ OBJECT_CHECK(PCIProxyDev, (obj), TYPE_PCI_PROXY_DEV)
+
+#define PCI_PROXY_DEV_CLASS(klass) \
+ OBJECT_CLASS_CHECK(PCIProxyDevClass, (klass), TYPE_PCI_PROXY_DEV)
+
+#define PCI_PROXY_DEV_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(PCIProxyDevClass, (obj), TYPE_PCI_PROXY_DEV)
+
+typedef struct PCIProxyDev {
+ PCIDevice parent_dev;
+
+ MPQemuLinkState *mpqemu_link;
+
+ int socket;
+
+} PCIProxyDev;
+
+typedef struct PCIProxyDevClass {
+ PCIDeviceClass parent_class;
+
+ void (*realize)(PCIProxyDev *dev, Error **errp);
+
+ char *command;
+} PCIProxyDevClass;
+
+#endif /* QEMU_PROXY_H */
diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h
index d46cb81058..73cc59b874 100644
--- a/include/io/mpqemu-link.h
+++ b/include/io/mpqemu-link.h
@@ -14,6 +14,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
+#include "sys/eventfd.h"
#include "qom/object.h"
#include "qemu/thread.h"
#include "exec/cpu-common.h"
--
2.25.GIT
- [PATCH RESEND v6 34/36] multi-process/mon: Initialize QMP module for remote processes, (continued)
- [PATCH RESEND v6 34/36] multi-process/mon: Initialize QMP module for remote processes, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 32/36] multi-process/mon: stub functions to enable QMP module for remote process, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 35/36] multi-process: add the concept description to docs/devel/qemu-multiprocess, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 02/36] multi-process: Refactor machine_init and exit notifiers, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 08/36] multi-process: Add stub functions to facilitate build of multi-process, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 10/36] multi-process: build system for remote device process, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 11/36] multi-process: define mpqemu-link object, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 12/36] multi-process: add functions to synchronize proxy and remote endpoints, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 14/36] multi-process: setup a machine object for remote device process, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 17/36] multi-process: introduce proxy object,
elena . ufimtseva <=
- [PATCH RESEND v6 24/36] multi-process: Retrieve PCI info from remote process, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 26/36] multi-process: add parse_cmdline in remote process, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 28/36] multi-process: send heartbeat messages to remote, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 33/36] multi-process/mon: enable QMP module support in the remote process, elena . ufimtseva, 2020/04/23
- [PATCH RESEND v6 36/36] multi-process: add configure and usage information, elena . ufimtseva, 2020/04/23
- Re: [PATCH RESEND v6 00/36] Initial support for multi-process qemu, Stefan Hajnoczi, 2020/04/24