[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 18/50] multi-process: configure remote side devices
From: |
Jagannathan Raman |
Subject: |
[PATCH v5 18/50] multi-process: configure remote side devices |
Date: |
Mon, 24 Feb 2020 15:55:09 -0500 |
From: Elena Ufimtseva <address@hidden>
Add functions to configure remote devices.
Signed-off-by: Elena Ufimtseva <address@hidden>
Signed-off-by: John G Johnson <address@hidden>
Signed-off-by: Jagannathan Raman <address@hidden>
---
v4 -> v5:
- Fixed qstr leak issue
hw/proxy/qemu-proxy.c | 56 ++++++++++++++++++++++++++++++++++++++++++-
include/hw/proxy/qemu-proxy.h | 3 +++
include/io/mpqemu-link.h | 9 +++++++
3 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c
index 0cf7dcc..3ba05d9 100644
--- a/hw/proxy/qemu-proxy.c
+++ b/hw/proxy/qemu-proxy.c
@@ -21,8 +21,60 @@
#include "qemu/event_notifier.h"
#include "sysemu/kvm.h"
#include "util/event_notifier-posix.c"
+#include "hw/boards.h"
+#include "include/qemu/log.h"
static void pci_proxy_dev_realize(PCIDevice *dev, Error **errp);
+static void setup_irqfd(PCIProxyDev *dev);
+
+static void proxy_ready(PCIDevice *dev)
+{
+ PCIProxyDev *pdev = PCI_PROXY_DEV(dev);
+
+ setup_irqfd(pdev);
+}
+
+static int set_remote_opts(PCIDevice *dev, QDict *qdict, unsigned int cmd)
+{
+ QString *qstr;
+ MPQemuMsg msg;
+ PCIProxyDev *pdev;
+ const char *str;
+ uint32_t reply = 0;
+ int rc = -EINVAL;
+ int wait;
+
+ pdev = PCI_PROXY_DEV(dev);
+
+ qstr = qobject_to_json(QOBJECT(qdict));
+ str = qstring_get_str(qstr);
+
+ memset(&msg, 0, sizeof(MPQemuMsg));
+
+ msg.data2 = (uint8_t *)(str);
+ msg.cmd = cmd;
+ msg.bytestream = 1;
+ msg.size = qstring_get_length(qstr) + 1;
+
+
+ wait = eventfd(0, EFD_NONBLOCK);
+ msg.num_fds = 1;
+ msg.fds[0] = wait;
+
+ mpqemu_msg_send(&msg, pdev->mpqemu_link->com);
+
+ reply = (uint32_t)wait_for_remote(wait);
+ close(wait);
+
+ /* TODO: Add proper handling if remote did not set options. */
+ if (reply == REMOTE_OK) {
+ rc = 0;
+ }
+
+ qobject_unref(qstr);
+
+ return rc;
+}
static int add_argv(char *opts_str, char **argv, int argc)
{
@@ -297,7 +349,6 @@ static void init_proxy(PCIDevice *dev, char *command, char
*exec_name,
pdev->socket);
configure_memory_sync(pdev->sync, pdev->mpqemu_link);
- setup_irqfd(pdev);
}
static void pci_proxy_dev_realize(PCIDevice *device, Error **errp)
@@ -317,6 +368,9 @@ static void pci_proxy_dev_realize(PCIDevice *device, Error
**errp)
dev->get_proxy_sock = get_proxy_sock;
dev->init_proxy = init_proxy;
dev->sync = REMOTE_MEM_SYNC(object_new(TYPE_MEMORY_LISTENER));
+
+ dev->set_remote_opts = set_remote_opts;
+ dev->proxy_ready = proxy_ready;
}
static void send_bar_access_msg(PCIProxyDev *dev, MemoryRegion *mr,
diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h
index 56aec0e..cd8505a 100644
--- a/include/hw/proxy/qemu-proxy.h
+++ b/include/hw/proxy/qemu-proxy.h
@@ -14,6 +14,8 @@
#include "io/mpqemu-link.h"
#include "hw/proxy/memory-sync.h"
#include "qemu/event_notifier.h"
+#include "hw/pci/pci.h"
+#include "block/qdict.h"
#define TYPE_PCI_PROXY_DEV "pci-proxy-dev"
@@ -62,6 +64,7 @@ struct PCIProxyDev {
void (*set_proxy_sock) (PCIDevice *dev, int socket);
int (*get_proxy_sock) (PCIDevice *dev);
+ int (*set_remote_opts) (PCIDevice *dev, QDict *qdict, unsigned int cmd);
void (*proxy_ready) (PCIDevice *dev);
void (*init_proxy) (PCIDevice *dev, char *command, char *exec_name,
bool need_spawn, Error **errp);
diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h
index 13c4b80..90a8437 100644
--- a/include/io/mpqemu-link.h
+++ b/include/io/mpqemu-link.h
@@ -54,9 +54,18 @@ typedef enum {
BAR_WRITE,
BAR_READ,
SET_IRQFD,
+ DEV_OPTS,
+ DRIVE_OPTS,
+ DEVICE_ADD,
+ DEVICE_DEL,
MAX,
} mpqemu_cmd_t;
+typedef enum {
+ REMOTE_OK = 0,
+ REMOTE_FAIL,
+} mpqemu_reply_t;
+
/**
* MPQemuMsg:
* @cmd: The remote command
--
1.8.3.1
- [PATCH v5 09/50] multi-process: setup PCI host bridge for remote device, (continued)
- [PATCH v5 09/50] multi-process: setup PCI host bridge for remote device, Jagannathan Raman, 2020/02/24
- [PATCH v5 06/50] multi-process: build system for remote device process, Jagannathan Raman, 2020/02/24
- [PATCH v5 08/50] multi-process: add functions to synchronize proxy and remote endpoints, Jagannathan Raman, 2020/02/24
- [PATCH v5 11/50] multi-process: setup memory manager for remote device, Jagannathan Raman, 2020/02/24
- [PATCH v5 10/50] multi-process: setup a machine object for remote device process, Jagannathan Raman, 2020/02/24
- [PATCH v5 12/50] multi-process: remote process initialization, Jagannathan Raman, 2020/02/24
- [PATCH v5 14/50] mutli-process: build remote command line args, Jagannathan Raman, 2020/02/24
- [PATCH v5 13/50] multi-process: introduce proxy object, Jagannathan Raman, 2020/02/24
- [PATCH v5 15/50] multi-process: PCI BAR read/write handling for proxy & remote endpoints, Jagannathan Raman, 2020/02/24
- [PATCH v5 16/50] multi-process: Synchronize remote memory, Jagannathan Raman, 2020/02/24
- [PATCH v5 18/50] multi-process: configure remote side devices,
Jagannathan Raman <=
- [PATCH v5 17/50] multi-process: create IOHUB object to handle irq, Jagannathan Raman, 2020/02/24
- [PATCH v5 20/50] multi-process: add qdev_proxy_add to create proxy devices, Jagannathan Raman, 2020/02/24
- [PATCH v5 19/50] multi-process: Retrieve PCI info from remote process, Jagannathan Raman, 2020/02/24
- [PATCH v5 21/50] multi-process: remote: add setup_devices msg processing, Jagannathan Raman, 2020/02/24
- [PATCH v5 23/50] multi-process: remote: add create_done condition, Jagannathan Raman, 2020/02/24
- [PATCH v5 25/50] multi-process: Introduce build flags to separate remote process code, Jagannathan Raman, 2020/02/24
- [PATCH v5 24/50] multi-process: add processing of remote device command line, Jagannathan Raman, 2020/02/24
- [PATCH v5 26/50] multi-process: refractor vl.c code, Jagannathan Raman, 2020/02/24
- [PATCH v5 22/50] multi-process: remote: use fd for socket from parent process, Jagannathan Raman, 2020/02/24
- [PATCH v5 27/50] multi-process: add remote option, Jagannathan Raman, 2020/02/24