[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v3 PATCH 15/45] multi-process: add support of device i
From: |
Jagannathan Raman |
Subject: |
[Qemu-devel] [RFC v3 PATCH 15/45] multi-process: add support of device id to communication channel |
Date: |
Tue, 3 Sep 2019 16:37:41 -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
include/io/proxy-link.h | 3 +++
io/proxy-link.c | 37 ++++++++++++++++++++++++++++++++-----
2 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h
index 159c787..0785394 100644
--- a/include/io/proxy-link.h
+++ b/include/io/proxy-link.h
@@ -88,6 +88,7 @@ typedef struct {
proc_cmd_t cmd;
int bytestream;
size_t size;
+ size_t size_id;
union {
uint64_t u64;
@@ -98,6 +99,8 @@ typedef struct {
int num_fds;
uint8_t *data2;
+ uint8_t *id;
+
} ProcMsg;
struct conf_data_msg {
diff --git a/io/proxy-link.c b/io/proxy-link.c
index 381a38e..6f60117 100644
--- a/io/proxy-link.c
+++ b/io/proxy-link.c
@@ -81,7 +81,7 @@ void proxy_link_finalize(ProxyLinkState *s)
void proxy_proc_send(ProxyLinkState *s, ProcMsg *msg, ProcChannel *chan)
{
int rc;
- uint8_t *data;
+ uint8_t *data, *buf = NULL;
union {
char control[CMSG_SPACE(REMOTE_MAX_FDS * sizeof(int))];
struct cmsghdr align;
@@ -140,10 +140,19 @@ void proxy_proc_send(ProxyLinkState *s, ProcMsg *msg,
ProcChannel *chan)
data = (uint8_t *)msg + PROC_HDR_SIZE;
}
+ if (msg->size_id > 0) {
+ buf = calloc(1, msg->size + msg->size_id);
+ assert(buf);
+ memcpy(buf, data, msg->size);
+ memcpy(buf + msg->size, msg->id, msg->size_id);
+ data = buf;
+ }
do {
- rc = write(sock, data, msg->size);
+ rc = write(sock, data, msg->size + msg->size_id);
} while (rc < 0 && (errno == EINTR || errno == EAGAIN));
+ free(buf);
+
qemu_mutex_unlock(lock);
}
@@ -151,7 +160,7 @@ void proxy_proc_send(ProxyLinkState *s, ProcMsg *msg,
ProcChannel *chan)
int proxy_proc_recv(ProxyLinkState *s, ProcMsg *msg, ProcChannel *chan)
{
int rc;
- uint8_t *data;
+ uint8_t *data, *buf = NULL;
union {
char control[CMSG_SPACE(REMOTE_MAX_FDS * sizeof(int))];
struct cmsghdr align;
@@ -207,10 +216,28 @@ int proxy_proc_recv(ProxyLinkState *s, ProcMsg *msg,
ProcChannel *chan)
data = (uint8_t *)&msg->data1;
}
- if (msg->size) {
+ if (msg->size) {
+ if (msg->size_id > 0) {
+ buf = calloc(1, msg->size + msg->size_id);
+ data = buf;
+ }
do {
- rc = read(sock, data, msg->size);
+ rc = read(sock, data, msg->size + msg->size_id);
} while (rc < 0 && (errno == EINTR || errno == EAGAIN));
+ if (rc < 0) {
+ fprintf(stderr, "Read sock is an error!\n");
+ return rc;
+ }
+ }
+ if (msg->size && msg->bytestream) {
+ memcpy(msg->data2, data, msg->size);
+ } else {
+ memcpy((uint8_t *)&msg->data1, data, msg->size);
+ }
+
+ if (msg->size_id > 0) {
+ msg->id = calloc(1, msg->size_id);
+ memcpy(msg->id, data + msg->size, msg->size_id);
}
qemu_mutex_unlock(lock);
--
1.8.3.1
- [Qemu-devel] [RFC v3 PATCH 07/45] multi-process: define proxy-link object, (continued)
- [Qemu-devel] [RFC v3 PATCH 06/45] multi-process: build system for remote device process, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 11/45] multi-process: setup memory manager for remote device, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 12/45] multi-process: remote process initialization, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 13/45] multi-process: introduce proxy object, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 14/45] mutli-process: build remote command line args, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 15/45] multi-process: add support of device id to communication channel,
Jagannathan Raman <=
- [Qemu-devel] [RFC v3 PATCH 16/45] multi-process: PCI BAR read/write handling for proxy & remote endpoints, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 09/45] multi-process: setup PCI host bridge for remote device, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 18/45] multi-process: support dev id in config read/write, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 17/45] multi-process: modify BARs read/write to support dev_id, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 19/45] multi-process: Add LSI device proxy object, Jagannathan Raman, 2019/09/03
- [Qemu-devel] [RFC v3 PATCH 22/45] multi-process: configure remote side devices, Jagannathan Raman, 2019/09/03
- [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