[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/48] ivshmem: remove unnecessary dup()
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PULL 06/48] ivshmem: remove unnecessary dup() |
Date: |
Tue, 6 Oct 2015 21:19:02 +0200 |
From: Marc-André Lureau <address@hidden>
qemu_chr_fe_get_msgfd() transfers ownership, there is no need to dup the
fd.
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Claudio Fontana <address@hidden>
---
hw/misc/ivshmem.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index dd15f0e..fbeb731 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -480,7 +480,7 @@ static bool fifo_update_and_get(IVShmemState *s, const
uint8_t *buf, int size,
static void ivshmem_read(void *opaque, const uint8_t *buf, int size)
{
IVShmemState *s = opaque;
- int incoming_fd, tmp_fd;
+ int incoming_fd;
int guest_max_eventfd;
long incoming_posn;
@@ -495,21 +495,21 @@ static void ivshmem_read(void *opaque, const uint8_t
*buf, int size)
}
/* pick off s->server_chr->msgfd and store it, posn should accompany msg */
- tmp_fd = qemu_chr_fe_get_msgfd(s->server_chr);
- IVSHMEM_DPRINTF("posn is %ld, fd is %d\n", incoming_posn, tmp_fd);
+ incoming_fd = qemu_chr_fe_get_msgfd(s->server_chr);
+ IVSHMEM_DPRINTF("posn is %ld, fd is %d\n", incoming_posn, incoming_fd);
/* make sure we have enough space for this guest */
if (incoming_posn >= s->nb_peers) {
if (increase_dynamic_storage(s, incoming_posn) < 0) {
error_report("increase_dynamic_storage() failed");
- if (tmp_fd != -1) {
- close(tmp_fd);
+ if (incoming_fd != -1) {
+ close(incoming_fd);
}
return;
}
}
- if (tmp_fd == -1) {
+ 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)) {
@@ -524,15 +524,6 @@ static void ivshmem_read(void *opaque, const uint8_t *buf,
int size)
}
}
- /* because of the implementation of get_msgfd, we need a dup */
- incoming_fd = dup(tmp_fd);
-
- if (incoming_fd == -1) {
- error_report("could not allocate file descriptor %s", strerror(errno));
- close(tmp_fd);
- return;
- }
-
/* if the position is -1, then it's shared memory region fd */
if (incoming_posn == -1) {
--
2.4.3
- [Qemu-devel] [PULL 05/48] ivshmem: factor out the incoming fifo handling, (continued)
- [Qemu-devel] [PULL 05/48] ivshmem: factor out the incoming fifo handling, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 08/48] ivshmem: remove useless doorbell field, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 14/48] ivshmem: remove useless ivshmem_update_irq() val argument, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 28/48] ivshmem: replace 'guest' for 'peer' appropriately, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 33/48] ivshmem-server: use a uint16 for client ID, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 07/48] ivshmem: remove superflous ivshmem_attr field, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 17/48] ivshmem: improve debug messages, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 21/48] ivshmem: use common return, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 09/48] ivshmem: more qdev conversion, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 48/48] ivshmem: use little-endian int64_t for the protocol, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 06/48] ivshmem: remove unnecessary dup(),
marcandre . lureau <=
- [Qemu-devel] [PULL 02/48] msix: add VMSTATE_MSIX_TEST, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 15/48] ivshmem: initialize max_peer to -1, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 18/48] ivshmem: improve error handling, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 25/48] ivshmem: check shm isn't already initialized, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 37/48] contrib: remove unnecessary strdup(), marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 47/48] ivshmem: use kvm irqfd for msi notifications, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 29/48] ivshmem: error on too many eventfd received, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 38/48] msix: implement pba write (but read-only), marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 23/48] ivshmem: migrate with VMStateDescription, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PULL 31/48] contrib: add ivshmem client and server, marcandre . lureau, 2015/10/08