yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From bf9b8d36996ecbe78f1561404a355af6f7c5d4f6 Mon Sep 17 00:00:00 2001
0a122b
From: Gerd Hoffmann <kraxel@redhat.com>
0a122b
Date: Tue, 21 Jan 2014 11:25:17 -0500
0a122b
Subject: [PATCH 6/6] qxl: replace pipe signaling with bottom half
0a122b
0a122b
Message-id: <1390303517-20167-3-git-send-email-kraxel@redhat.com>
0a122b
Patchwork-id: 56865
0a122b
O-Subject: [RHEL-7 qemu-kvm PATCH 2/2] qxl: replace pipe signaling with bottom half
0a122b
Bugzilla: 1009297
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
0a122b
qxl creates a pipe, then writes something to it to wake up the iothread
0a122b
from the spice server thread to raise an irq.  These days qemu bottom
0a122b
halves can be scheduled from threads and signals, so there is no reason
0a122b
to do this any more.  Time to clean it up.
0a122b
0a122b
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
0a122b
(cherry picked from commit 4a46c99c8118586f19894fe66fc6e353f159d4d9)
0a122b
---
0a122b
 hw/display/qxl.c | 33 +++------------------------------
0a122b
 hw/display/qxl.h |  3 +--
0a122b
 2 files changed, 4 insertions(+), 32 deletions(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 hw/display/qxl.c | 33 +++------------------------------
0a122b
 hw/display/qxl.h |  3 +--
0a122b
 2 files changed, 4 insertions(+), 32 deletions(-)
0a122b
0a122b
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
0a122b
index 830b3c5..4381d97 100644
0a122b
--- a/hw/display/qxl.c
0a122b
+++ b/hw/display/qxl.c
0a122b
@@ -1702,15 +1702,9 @@ static const MemoryRegionOps qxl_io_ops = {
0a122b
     },
0a122b
 };
0a122b
 
0a122b
-static void pipe_read(void *opaque)
0a122b
+static void qxl_update_irq_bh(void *opaque)
0a122b
 {
0a122b
     PCIQXLDevice *d = opaque;
0a122b
-    char dummy;
0a122b
-    int len;
0a122b
-
0a122b
-    do {
0a122b
-        len = read(d->pipe[0], &dummy, sizeof(dummy));
0a122b
-    } while (len == sizeof(dummy));
0a122b
     qxl_update_irq(d);
0a122b
 }
0a122b
 
0a122b
@@ -1731,28 +1725,7 @@ static void qxl_send_events(PCIQXLDevice *d, uint32_t events)
0a122b
     if ((old_pending & le_events) == le_events) {
0a122b
         return;
0a122b
     }
0a122b
-    if (qemu_thread_is_self(&d->main)) {
0a122b
-        qxl_update_irq(d);
0a122b
-    } else {
0a122b
-        if (write(d->pipe[1], d, 1) != 1) {
0a122b
-            dprint(d, 1, "%s: write to pipe failed\n", __func__);
0a122b
-        }
0a122b
-    }
0a122b
-}
0a122b
-
0a122b
-static void init_pipe_signaling(PCIQXLDevice *d)
0a122b
-{
0a122b
-    if (pipe(d->pipe) < 0) {
0a122b
-        fprintf(stderr, "%s:%s: qxl pipe creation failed\n",
0a122b
-                __FILE__, __func__);
0a122b
-        exit(1);
0a122b
-    }
0a122b
-    fcntl(d->pipe[0], F_SETFL, O_NONBLOCK);
0a122b
-    fcntl(d->pipe[1], F_SETFL, O_NONBLOCK);
0a122b
-    fcntl(d->pipe[0], F_SETOWN, getpid());
0a122b
-
0a122b
-    qemu_thread_get_self(&d->main);
0a122b
-    qemu_set_fd_handler(d->pipe[0], pipe_read, NULL, d);
0a122b
+    qemu_bh_schedule(d->update_irq);
0a122b
 }
0a122b
 
0a122b
 /* graphics console */
0a122b
@@ -2044,7 +2017,7 @@ static int qxl_init_common(PCIQXLDevice *qxl)
0a122b
     }
0a122b
     qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, qxl);
0a122b
 
0a122b
-    init_pipe_signaling(qxl);
0a122b
+    qxl->update_irq = qemu_bh_new(qxl_update_irq_bh, qxl);
0a122b
     qxl_reset_state(qxl);
0a122b
 
0a122b
     qxl->update_area_bh = qemu_bh_new(qxl_render_update_area_bh, qxl);
0a122b
diff --git a/hw/display/qxl.h b/hw/display/qxl.h
0a122b
index 8e9b0c2..5da33e2 100644
0a122b
--- a/hw/display/qxl.h
0a122b
+++ b/hw/display/qxl.h
0a122b
@@ -78,8 +78,7 @@ typedef struct PCIQXLDevice {
0a122b
     QemuMutex          track_lock;
0a122b
 
0a122b
     /* thread signaling */
0a122b
-    QemuThread         main;
0a122b
-    int                pipe[2];
0a122b
+    QEMUBH             *update_irq;
0a122b
 
0a122b
     /* ram pci bar */
0a122b
     QXLRam             *ram;
0a122b
-- 
0a122b
1.8.3.1
0a122b