[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 07/16] vhost-user: start and end the va_list
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH v3 07/16] vhost-user: start and end the va_list |
Date: |
Thu, 6 Aug 2015 14:40:43 +0200 |
From: Marc-André Lureau <address@hidden>
Use a common start and exit branch to open and cleanup the va_list.
Signed-off-by: Marc-André Lureau <address@hidden>
---
hw/virtio/vhost-user.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 8b6d7e7..21ecbcd 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -198,11 +198,13 @@ static int vhost_user_call(struct vhost_dev *dev,
struct vhost_vring_file *file = 0;
int need_reply = 0;
int fds[VHOST_MEMORY_MAX_NREGIONS];
- int i, fd;
+ int i, fd, ret = 0;
size_t fd_num = 0;
+ va_list ap;
assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
+ va_start(ap, arg);
msg_request = vhost_user_request_translate(request);
msg.request = msg_request;
msg.flags = VHOST_USER_VERSION;
@@ -247,7 +249,8 @@ static int vhost_user_call(struct vhost_dev *dev,
if (!fd_num) {
error_report("Failed initializing vhost-user memory map, "
"consider using -object memory-backend-file share=on");
- return -1;
+ ret = -1;
+ goto end;
}
msg.size = sizeof(m.memory.nregions);
@@ -291,48 +294,53 @@ static int vhost_user_call(struct vhost_dev *dev,
break;
default:
error_report("vhost-user trying to send unhandled ioctl");
- return -1;
- break;
+ ret = -1;
+ goto end;
}
if (vhost_user_write(dev, &msg, fds, fd_num) < 0) {
- return 0;
+ goto end;
}
if (need_reply) {
if (vhost_user_read(dev, &msg) < 0) {
- return 0;
+ goto end;
}
if (msg_request != msg.request) {
error_report("Received unexpected msg type."
" Expected %d received %d", msg_request, msg.request);
- return -1;
+ ret = -1;
+ goto end;
}
switch (msg_request) {
case VHOST_USER_GET_FEATURES:
if (msg.size != sizeof(m.u64)) {
error_report("Received bad msg size.");
- return -1;
+ ret = -1;
+ goto end;
}
*((__u64 *) arg) = msg.u64;
break;
case VHOST_USER_GET_VRING_BASE:
if (msg.size != sizeof(m.state)) {
error_report("Received bad msg size.");
- return -1;
+ ret = -1;
+ goto end;
}
memcpy(arg, &msg.state, sizeof(struct vhost_vring_state));
break;
default:
error_report("Received unexpected msg type.");
- return -1;
- break;
+ ret = -1;
+ goto end;
}
}
- return 0;
+end:
+ va_end(ap);
+ return ret;
}
static int vhost_user_init(struct vhost_dev *dev, void *opaque)
--
2.4.3
- [Qemu-devel] [PATCH v3 02/16] util: add linux-only memfd fallback, (continued)
- [Qemu-devel] [PATCH v3 02/16] util: add linux-only memfd fallback, marcandre . lureau, 2015/08/06
- [Qemu-devel] [PATCH v3 04/16] vhost: alloc shareable log, marcandre . lureau, 2015/08/06
- [Qemu-devel] [PATCH v3 05/16] vhost: document log resizing, marcandre . lureau, 2015/08/06
- [Qemu-devel] [PATCH v3 12/16] vhost-user-test: remove useless static check, marcandre . lureau, 2015/08/06
- [Qemu-devel] [PATCH v3 08/16] vhost-user: send log shm fd along with log_base, marcandre . lureau, 2015/08/06
- [Qemu-devel] [PATCH v3 11/16] vhost-user-test: move wait_for_fds() out, marcandre . lureau, 2015/08/06
- [Qemu-devel] [PATCH v3 14/16] vhost-user-test: learn to tweak various qemu arguments, marcandre . lureau, 2015/08/06
- [Qemu-devel] [PATCH v3 15/16] vhost-user-test: add live-migration test, marcandre . lureau, 2015/08/06
- [Qemu-devel] [PATCH v3 16/16] vhost-user-test: check ownership during migration, marcandre . lureau, 2015/08/06
- [Qemu-devel] [PATCH v3 10/16] net: add trace_vhost_user_event, marcandre . lureau, 2015/08/06
- [Qemu-devel] [PATCH v3 07/16] vhost-user: start and end the va_list,
marcandre . lureau <=
- [Qemu-devel] [PATCH v3 13/16] vhost-user-test: wrap server in TestServer struct, marcandre . lureau, 2015/08/06
- [Qemu-devel] [PATCH v3 06/16] vhost: use variable arguments for vhost_call(), marcandre . lureau, 2015/08/06
- [Qemu-devel] [PATCH v3 09/16] vhost-user: document migration log, marcandre . lureau, 2015/08/06