diff mbox series

[RFC,v3,17/45] multi-process: modify BARs read/write to support dev_id

Message ID 41b228aa6e1cd78146ac23d59f06060dcd4c7bfc.1567534653.git.jag.raman@oracle.com (mailing list archive)
State New, archived
Headers show
Series Initial support of multi-process qemu | expand

Commit Message

Jag Raman Sept. 3, 2019, 8:37 p.m. UTC
From: Elena Ufimtseva <elena.ufimtseva@oracle.com>

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>
Reviewed-by: Liam Merwick <liam.merwick@oracle.com>
---
 New patch in v3

 hw/proxy/qemu-proxy.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c
index 44668bf..1021045 100644
--- a/hw/proxy/qemu-proxy.c
+++ b/hw/proxy/qemu-proxy.c
@@ -288,13 +288,16 @@  static void pci_proxy_dev_realize(PCIDevice *device, Error **errp)
     dev->init_proxy = init_proxy;
 }
 
-static void send_bar_access_msg(ProxyLinkState *proxy_link, MemoryRegion *mr,
+static void send_bar_access_msg(PCIProxyDev *dev, MemoryRegion *mr,
                                 bool write, hwaddr addr, uint64_t *val,
                                 unsigned size, bool memory)
 {
+    ProxyLinkState *proxy_link;
     ProcMsg msg;
     int wait;
 
+    proxy_link = dev->proxy_link;
+
     memset(&msg, 0, sizeof(ProcMsg));
 
     msg.bytestream = 0;
@@ -314,18 +317,31 @@  static void send_bar_access_msg(ProxyLinkState *proxy_link, MemoryRegion *mr,
         msg.fds[0] = wait;
     }
 
+    if (dev->dev_id) {
+        msg.size_id = strlen(dev->dev_id) + 1;
+        msg.id = calloc(1, msg.size_id);
+        memcpy(msg.id, dev->dev_id, msg.size_id);
+    } else {
+        msg.size_id = 0;
+    }
+
     proxy_proc_send(proxy_link, &msg, proxy_link->com);
 
     if (!write) {
         *val = wait_for_remote(wait);
         PUT_REMOTE_WAIT(wait);
     }
+
+    if (msg.id) {
+        free(msg.id);
+    }
+
 }
 
 void proxy_default_bar_write(PCIProxyDev *dev, MemoryRegion *mr, hwaddr addr,
                              uint64_t val, unsigned size, bool memory)
 {
-    send_bar_access_msg(dev->proxy_link, mr, true, addr, &val, size, memory);
+    send_bar_access_msg(dev, mr, true, addr, &val, size, memory);
 }
 
 uint64_t proxy_default_bar_read(PCIProxyDev *dev, MemoryRegion *mr, hwaddr addr,
@@ -333,7 +349,7 @@  uint64_t proxy_default_bar_read(PCIProxyDev *dev, MemoryRegion *mr, hwaddr addr,
 {
     uint64_t val;
 
-    send_bar_access_msg(dev->proxy_link, mr, false, addr, &val, size, memory);
+    send_bar_access_msg(dev, mr, false, addr, &val, size, memory);
 
     return val;
 }