>From 659e9f7657e9c6e2944f4eecb1381c940a6cc51e Mon Sep 17 00:00:00 2001 From: Uri Lublin Date: Sun, 13 Mar 2011 19:45:46 +0200 Subject: [PATCH 2/3] qxl: read_pipe: keep reading as long as there are things in the queue --- hw/qxl.c | 39 ++++++++++++++++++++++++--------------- 1 files changed, 24 insertions(+), 15 deletions(-) diff --git a/hw/qxl.c b/hw/qxl.c index 927a625..1ea66a2 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -1104,24 +1104,33 @@ static void pipe_read(void *opaque) { PCIQXLDevice *d = opaque; unsigned char cmd; - int len; + int len, again = 1, set_irq_done = 0; do { + cmd = 0; len = read(d->pipe[0], &cmd, sizeof(cmd)); - } while (len == sizeof(cmd)); - switch (cmd) { - case QXL_SERVER_SET_IRQ: - qxl_set_irq(d); - break; - case QXL_SERVER_CREATE_UPDATE: - d->ssd.update = qemu_spice_create_update(&d->ssd); - len = write(d->pipe_out[1], &cmd, 1); - ASSERT(len == 1); - break; - default: - fprintf(stderr, "%s: unknown cmd %u\n", __FUNCTION__, cmd); - abort(); - } + if ((len < 0) && (errno == EINTR)) { + continue; + } + switch (cmd) { + case QXL_SERVER_SET_IRQ: + if (set_irq_done == 0) { + /* no need to do it more than once */ + set_irq_done = 1; + qxl_set_irq(d); + } + break; + case QXL_SERVER_CREATE_UPDATE: + again = 0; + d->ssd.update = qemu_spice_create_update(&d->ssd); + len = write(d->pipe_out[1], &cmd, 1); + ASSERT(len == 1); + break; + default: + fprintf(stderr, "%s: unknown cmd %u\n", __FUNCTION__, cmd); + abort(); + } + } while (again); } static void qxl_send_events(PCIQXLDevice *d, uint32_t events) -- 1.7.4.1