[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 20/48] ivshmem: simplify a bit the code
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH v5 20/48] ivshmem: simplify a bit the code |
Date: |
Fri, 2 Oct 2015 21:09:23 +0200 |
From: Marc-André Lureau <address@hidden>
Use some more explicit variables to simplify the code.
Signed-off-by: Marc-André Lureau <address@hidden>
---
hw/misc/ivshmem.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 6ee4881..c054e52 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -488,9 +488,10 @@ static void ivshmem_read(void *opaque, const uint8_t *buf,
int size)
{
IVShmemState *s = opaque;
int incoming_fd;
- int guest_max_eventfd;
+ int new_eventfd;
long incoming_posn;
Error *err = NULL;
+ Peer *peer;
if (!fifo_update_and_get(s, buf, size,
&incoming_posn, sizeof(incoming_posn))) {
@@ -517,6 +518,8 @@ static void ivshmem_read(void *opaque, const uint8_t *buf,
int size)
}
}
+ peer = &s->peers[incoming_posn];
+
if (incoming_fd == -1) {
/* if posn is positive and unseen before then this is our posn*/
if (incoming_posn >= 0 && s->vm_id == -1) {
@@ -564,27 +567,24 @@ static void ivshmem_read(void *opaque, const uint8_t
*buf, int size)
return;
}
- /* each guest has an array of eventfds, and we keep track of how many
- * guests for each VM */
- guest_max_eventfd = s->peers[incoming_posn].nb_eventfds;
+ /* each peer has an associated array of eventfds, and we keep
+ * track of how many eventfds received so far */
+ /* get a new eventfd: */
+ new_eventfd = peer->nb_eventfds++;
/* this is an eventfd for a particular guest VM */
IVSHMEM_DPRINTF("eventfds[%ld][%d] = %d\n", incoming_posn,
- guest_max_eventfd, incoming_fd);
-
event_notifier_init_fd(&s->peers[incoming_posn].eventfds[guest_max_eventfd],
- incoming_fd);
-
- /* increment count for particular guest */
- s->peers[incoming_posn].nb_eventfds++;
+ new_eventfd, incoming_fd);
+ event_notifier_init_fd(&peer->eventfds[new_eventfd], incoming_fd);
if (incoming_posn == s->vm_id) {
- s->eventfd_chr[guest_max_eventfd] = create_eventfd_chr_device(s,
- &s->peers[s->vm_id].eventfds[guest_max_eventfd],
- guest_max_eventfd);
+ s->eventfd_chr[new_eventfd] = create_eventfd_chr_device(s,
+ &s->peers[s->vm_id].eventfds[new_eventfd],
+ new_eventfd);
}
if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {
- ivshmem_add_eventfd(s, incoming_posn, guest_max_eventfd);
+ ivshmem_add_eventfd(s, incoming_posn, new_eventfd);
}
}
--
2.4.3
- [Qemu-devel] [PATCH v5 41/48] tests: add ivshmem qtest, (continued)
- [Qemu-devel] [PATCH v5 41/48] tests: add ivshmem qtest, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 35/48] docs: update ivshmem device spec, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 12/48] ivshmem: simplify around increase_dynamic_storage(), marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 01/48] char: add qemu_chr_free(), marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 13/48] ivshmem: allocate eventfds in resize_peers(), marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 19/48] ivshmem: print error on invalid peer id, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 16/48] ivshmem: remove max_peer field, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 25/48] ivshmem: check shm isn't already initialized, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 18/48] ivshmem: improve error handling, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 20/48] ivshmem: simplify a bit the code,
marcandre . lureau <=
- [Qemu-devel] [PATCH v5 30/48] ivshmem: reset mask on device reset, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 28/48] ivshmem: replace 'guest' for 'peer' appropriately, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 37/48] contrib: remove unnecessary strdup(), marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 42/48] ivshmem: do not keep shm_fd open, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 38/48] msix: implement pba write (but read-only), marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 45/48] ivshmem: remove EventfdEntry.vector, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 48/48] ivshmem: use little-endian int64_t for the protocol, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 04/48] ivshmem: fix number of bytes to push to fifo, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 07/48] ivshmem: remove superflous ivshmem_attr field, marcandre . lureau, 2015/10/08