[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 13/48] ivshmem: allocate eventfds in resize_peers
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH v5 13/48] ivshmem: allocate eventfds in resize_peers() |
Date: |
Fri, 2 Oct 2015 21:09:16 +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>
Reviewed-by: Claudio Fontana <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 v5 06/48] ivshmem: remove unnecessary dup(), (continued)
- [Qemu-devel] [PATCH v5 06/48] ivshmem: remove unnecessary dup(), marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 14/48] ivshmem: remove useless ivshmem_update_irq() val argument, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 03/48] ivhsmem: read do not accept more than sizeof(long), marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 08/48] ivshmem: remove useless doorbell field, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v5 27/48] ivshmem: fix pci_ivshmem_exit(), marcandre . lureau, 2015/10/08
- [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 <=
- [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, 2015/10/08
- [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