[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 13/47] ivshmem: allocate eventfds in resize_peers
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH v4 13/47] ivshmem: allocate eventfds in resize_peers() |
Date: |
Thu, 24 Sep 2015 13:37:15 +0200 |
From: Marc-André Lureau <address@hidden>
It simplifies a bit the code to allocate the array when setting the
number of peers instead of lazily when receiving the first vector.
Signed-off-by: Marc-André Lureau <address@hidden>
---
hw/misc/ivshmem.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 6f41960..19640bb 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -437,9 +437,8 @@ static int resize_peers(IVShmemState *s, int new_min_size)
s->peers = g_realloc(s->peers, s->nb_peers * sizeof(Peer));
- /* zero out new pointers */
for (j = old_size; j < s->nb_peers; j++) {
- s->peers[j].eventfds = NULL;
+ s->peers[j].eventfds = g_new0(EventNotifier, s->vectors);
s->peers[j].nb_eventfds = 0;
}
@@ -517,8 +516,7 @@ static void ivshmem_read(void *opaque, const uint8_t *buf,
int size)
if (incoming_fd == -1) {
/* if posn is positive and unseen before then this is our posn*/
- if ((incoming_posn >= 0) &&
- (s->peers[incoming_posn].eventfds == NULL)) {
+ if (incoming_posn >= 0 && s->vm_id == -1) {
/* receive our posn */
s->vm_id = incoming_posn;
return;
@@ -569,11 +567,6 @@ static void ivshmem_read(void *opaque, const uint8_t *buf,
int size)
* guests for each VM */
guest_max_eventfd = s->peers[incoming_posn].nb_eventfds;
- if (guest_max_eventfd == 0) {
- /* one eventfd per MSI vector */
- s->peers[incoming_posn].eventfds = g_new(EventNotifier, s->vectors);
- }
-
/* this is an eventfd for a particular guest VM */
IVSHMEM_DPRINTF("eventfds[%ld][%d] = %d\n", incoming_posn,
guest_max_eventfd, incoming_fd);
--
2.4.3
- [Qemu-devel] [PATCH v4 05/47] ivshmem: factor out the incoming fifo handling, (continued)
- [Qemu-devel] [PATCH v4 05/47] ivshmem: factor out the incoming fifo handling, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 04/47] ivshmem: fix number of bytes to push to fifo, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 06/47] ivshmem: remove unnecessary dup(), marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 07/47] ivshmem: remove superflous ivshmem_attr field, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 08/47] ivshmem: remove useless doorbell field, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 10/47] ivshmem: remove last exit(1), marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 09/47] ivshmem: more qdev conversion, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 11/47] ivshmem: limit maximum number of peers to G_MAXUINT16, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 12/47] ivshmem: simplify around increase_dynamic_storage(), marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 14/47] ivshmem: remove useless ivshmem_update_irq() val argument, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 13/47] ivshmem: allocate eventfds in resize_peers(),
marcandre . lureau <=
- [Qemu-devel] [PATCH v4 16/47] ivshmem: remove max_peer field, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 15/47] ivshmem: initialize max_peer to -1, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 17/47] ivshmem: improve debug messages, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 18/47] ivshmem: improve error handling, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 19/47] ivshmem: print error on invalid peer id, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 20/47] ivshmem: simplify a bit the code, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 21/47] ivshmem: use common return, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 22/47] ivshmem: use common is_power_of_2(), marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 23/47] ivshmem: migrate with VMStateDescription, marcandre . lureau, 2015/09/24
- [Qemu-devel] [PATCH v4 25/47] ivshmem: check shm isn't already initialized, marcandre . lureau, 2015/09/24