[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 11/21] multi-process: introduce proxy object
From: |
elena . ufimtseva |
Subject: |
[PATCH v7 11/21] multi-process: introduce proxy object |
Date: |
Sat, 27 Jun 2020 10:09:33 -0700 |
From: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Defines a PCI Device proxy object as a child of TYPE_PCI_DEVICE.
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
---
MAINTAINERS | 2 ++
hw/pci/Makefile.objs | 1 +
hw/pci/proxy.c | 70 ++++++++++++++++++++++++++++++++++++++++++
include/hw/pci/proxy.h | 43 ++++++++++++++++++++++++++
4 files changed, 116 insertions(+)
create mode 100644 hw/pci/proxy.c
create mode 100644 include/hw/pci/proxy.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 017c96eace..b48c3114c1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2952,6 +2952,8 @@ F: include/io/mpqemu-link.h
F: hw/i386/remote-msg.c
F: include/hw/i386/remote-memory.h
F: hw/i386/remote-memory.c
+F: hw/pci/proxy.c
+F: include/hw/pci/proxy.h
Build and test automation
-------------------------
diff --git a/hw/pci/Makefile.objs b/hw/pci/Makefile.objs
index c78f2fb24b..515dda506c 100644
--- a/hw/pci/Makefile.objs
+++ b/hw/pci/Makefile.objs
@@ -12,3 +12,4 @@ common-obj-$(CONFIG_PCI_EXPRESS) += pcie_port.o pcie_host.o
common-obj-$(call lnot,$(CONFIG_PCI)) += pci-stub.o
common-obj-$(CONFIG_ALL) += pci-stub.o
+obj-$(CONFIG_MPQEMU) += proxy.o
diff --git a/hw/pci/proxy.c b/hw/pci/proxy.c
new file mode 100644
index 0000000000..6d62399c52
--- /dev/null
+++ b/hw/pci/proxy.c
@@ -0,0 +1,70 @@
+/*
+ * 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 "hw/pci/proxy.h"
+#include "hw/pci/pci.h"
+#include "qapi/error.h"
+#include "io/channel-util.h"
+#include "hw/qdev-properties.h"
+#include "monitor/monitor.h"
+
+static void proxy_set_socket(PCIProxyDev *pdev, int fd, Error **errp)
+{
+ pdev->com = qio_channel_new_fd(fd, errp);
+}
+
+static Property proxy_properties[] = {
+ DEFINE_PROP_STRING("fd", PCIProxyDev, fd),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void pci_proxy_dev_realize(PCIDevice *device, Error **errp)
+{
+ PCIProxyDev *dev = PCI_PROXY_DEV(device);
+ int proxyfd;
+
+ if (dev->fd) {
+ proxyfd = monitor_fd_param(cur_mon, dev->fd, errp);
+ if (proxyfd == -1) {
+ error_prepend(errp, "proxy: unable to parse proxyfd: ");
+ return;
+ }
+ proxy_set_socket(dev, proxyfd, errp);
+ }
+}
+
+static void pci_proxy_dev_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+ k->realize = pci_proxy_dev_realize;
+ device_class_set_props(dc, proxy_properties);
+}
+
+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/pci/proxy.h b/include/hw/pci/proxy.h
new file mode 100644
index 0000000000..c1c7142fa2
--- /dev/null
+++ b/include/hw/pci/proxy.h
@@ -0,0 +1,43 @@
+/*
+ * 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 PROXY_H
+#define PROXY_H
+
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+
+#include "hw/pci/pci.h"
+#include "io/channel.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;
+ char *fd;
+ QIOChannel *com;
+} PCIProxyDev;
+
+typedef struct PCIProxyDevClass {
+ PCIDeviceClass parent_class;
+
+ void (*realize)(PCIProxyDev *dev, Error **errp);
+
+ char *command;
+} PCIProxyDevClass;
+
+#endif /* PROXY_H */
--
2.25.GIT
- [PATCH v7 00/21] Initial support for multi-process qemu, elena . ufimtseva, 2020/06/27
- [PATCH v7 06/21] multi-process: define MPQemuMsg format and transmission functions, elena . ufimtseva, 2020/06/27
- [PATCH v7 01/21] memory: alloc RAM from file at offset, elena . ufimtseva, 2020/06/27
- [PATCH v7 10/21] multi-process: setup memory manager for remote device, elena . ufimtseva, 2020/06/27
- [PATCH v7 07/21] multi-process: add co-routines to communicate with remote, elena . ufimtseva, 2020/06/27
- [PATCH v7 11/21] multi-process: introduce proxy object,
elena . ufimtseva <=
- [PATCH v7 12/21] multi-process: Connect Proxy Object with device in the remote process, elena . ufimtseva, 2020/06/27
- [PATCH v7 13/21] multi-process: Forward PCI config space acceses to the remote process, elena . ufimtseva, 2020/06/27
- [PATCH v7 16/21] multi-process: create IOHUB object to handle irq, elena . ufimtseva, 2020/06/27
- [PATCH v7 18/21] multi-process: heartbeat messages to remote, elena . ufimtseva, 2020/06/27
- [PATCH v7 19/21] multi-process: perform device reset in the remote process, elena . ufimtseva, 2020/06/27
- [PATCH v7 21/21] multi-process: add configure and usage information, elena . ufimtseva, 2020/06/27
- [PATCH v7 20/21] multi-process: add the concept description to docs/devel/qemu-multiprocess, elena . ufimtseva, 2020/06/27
- [PATCH v7 14/21] multi-process: PCI BAR read/write handling for proxy & remote endpoints, elena . ufimtseva, 2020/06/27
- [PATCH v7 02/21] multi-process: Add config option for multi-process QEMU, elena . ufimtseva, 2020/06/27