render / rpms / qemu

Forked from rpms/qemu 10 months ago
Clone

Blame 0001-qxl-spice-display-move-pipe-to-ssd.patch

Justin M. Forbes da9298
>From fd04276a00b172e6fbba3e3c72b1d13a0f179414 Mon Sep 17 00:00:00 2001
Justin M. Forbes da9298
From: Alon Levy <alevy@redhat.com>
Justin M. Forbes da9298
Date: Wed, 16 Mar 2011 15:21:03 +0100
Justin M. Forbes da9298
Subject: [PATCH 1/4] qxl/spice-display: move pipe to ssd
Justin M. Forbes da9298
Justin M. Forbes da9298
This moves the int pipe[2] and pthread_t main data from the
Justin M. Forbes da9298
PCIQXLDevice struct to the SimpleSpiceDisplay. This will let us
Justin M. Forbes da9298
reuse it in the next patch for both -spice with no -qxl usage and
Justin M. Forbes da9298
for vga mode from qxl.
Justin M. Forbes da9298
Justin M. Forbes da9298
Also move the pipe creation function (which is effectively completely rewritten
Justin M. Forbes da9298
by this patch anyways) from hw/qxl.c to ui/spice-display.c, since
Justin M. Forbes da9298
spice-display will depend on it after the next patch and qemu can be build
Justin M. Forbes da9298
with ui/spice-display.c in combination with no hw/qxl.c.
Justin M. Forbes da9298
---
Justin M. Forbes da9298
 hw/qxl.c           |   22 +++++-----------------
Justin M. Forbes da9298
 hw/qxl.h           |    4 ----
Justin M. Forbes da9298
 ui/spice-display.c |   21 +++++++++++++++++++++
Justin M. Forbes da9298
 ui/spice-display.h |    8 ++++++++
Justin M. Forbes da9298
 4 files changed, 34 insertions(+), 21 deletions(-)
Justin M. Forbes da9298
Justin M. Forbes da9298
diff --git a/hw/qxl.c b/hw/qxl.c
Justin M. Forbes da9298
index fe4212b..201698f 100644
Justin M. Forbes da9298
--- a/hw/qxl.c
Justin M. Forbes da9298
+++ b/hw/qxl.c
Justin M. Forbes da9298
@@ -1062,7 +1062,7 @@ static void pipe_read(void *opaque)
Justin M. Forbes da9298
     int len;
Justin M. Forbes da9298
 
Justin M. Forbes da9298
     do {
Justin M. Forbes da9298
-        len = read(d->pipe[0], &dummy, sizeof(dummy));
Justin M. Forbes da9298
+        len = read(d->ssd.pipe[0], &dummy, sizeof(dummy));
Justin M. Forbes da9298
     } while (len == sizeof(dummy));
Justin M. Forbes da9298
     qxl_set_irq(d);
Justin M. Forbes da9298
 }
Justin M. Forbes da9298
@@ -1078,10 +1078,11 @@ static void qxl_send_events(PCIQXLDevice *d, uint32_t events)
Justin M. Forbes da9298
     if ((old_pending & le_events) == le_events) {
Justin M. Forbes da9298
         return;
Justin M. Forbes da9298
     }
Justin M. Forbes da9298
-    if (pthread_self() == d->main) {
Justin M. Forbes da9298
+    if (pthread_self() == d->ssd.main) {
Justin M. Forbes da9298
+        /* running in io_thread thread */
Justin M. Forbes da9298
         qxl_set_irq(d);
Justin M. Forbes da9298
     } else {
Justin M. Forbes da9298
-        if (write(d->pipe[1], d, 1) != 1) {
Justin M. Forbes da9298
+        if (write(d->ssd.pipe[1], d, 1) != 1) {
Justin M. Forbes da9298
             dprint(d, 1, "%s: write to pipe failed\n", __FUNCTION__);
Justin M. Forbes da9298
         }
Justin M. Forbes da9298
     }
Justin M. Forbes da9298
@@ -1089,20 +1090,7 @@ static void qxl_send_events(PCIQXLDevice *d, uint32_t events)
Justin M. Forbes da9298
 
Justin M. Forbes da9298
 static void init_pipe_signaling(PCIQXLDevice *d)
Justin M. Forbes da9298
 {
Justin M. Forbes da9298
-   if (pipe(d->pipe) < 0) {
Justin M. Forbes da9298
-       dprint(d, 1, "%s: pipe creation failed\n", __FUNCTION__);
Justin M. Forbes da9298
-       return;
Justin M. Forbes da9298
-   }
Justin M. Forbes da9298
-#ifdef CONFIG_IOTHREAD
Justin M. Forbes da9298
-   fcntl(d->pipe[0], F_SETFL, O_NONBLOCK);
Justin M. Forbes da9298
-#else
Justin M. Forbes da9298
-   fcntl(d->pipe[0], F_SETFL, O_NONBLOCK /* | O_ASYNC */);
Justin M. Forbes da9298
-#endif
Justin M. Forbes da9298
-   fcntl(d->pipe[1], F_SETFL, O_NONBLOCK);
Justin M. Forbes da9298
-   fcntl(d->pipe[0], F_SETOWN, getpid());
Justin M. Forbes da9298
-
Justin M. Forbes da9298
-   d->main = pthread_self();
Justin M. Forbes da9298
-   qemu_set_fd_handler(d->pipe[0], pipe_read, NULL, d);
Justin M. Forbes da9298
+   qxl_create_server_to_iothread_pipe(&d->ssd, pipe_read);
Justin M. Forbes da9298
 }
Justin M. Forbes da9298
 
Justin M. Forbes da9298
 /* graphics console */
Justin M. Forbes da9298
diff --git a/hw/qxl.h b/hw/qxl.h
Justin M. Forbes da9298
index f6c450d..701245f 100644
Justin M. Forbes da9298
--- a/hw/qxl.h
Justin M. Forbes da9298
+++ b/hw/qxl.h
Justin M. Forbes da9298
@@ -55,10 +55,6 @@ typedef struct PCIQXLDevice {
Justin M. Forbes da9298
     } guest_surfaces;
Justin M. Forbes da9298
     QXLPHYSICAL        guest_cursor;
Justin M. Forbes da9298
 
Justin M. Forbes da9298
-    /* thread signaling */
Justin M. Forbes da9298
-    pthread_t          main;
Justin M. Forbes da9298
-    int                pipe[2];
Justin M. Forbes da9298
-
Justin M. Forbes da9298
     /* ram pci bar */
Justin M. Forbes da9298
     QXLRam             *ram;
Justin M. Forbes da9298
     VGACommonState     vga;
Justin M. Forbes da9298
diff --git a/ui/spice-display.c b/ui/spice-display.c
Justin M. Forbes da9298
index 020b423..ec6e0cb 100644
Justin M. Forbes da9298
--- a/ui/spice-display.c
Justin M. Forbes da9298
+++ b/ui/spice-display.c
Justin M. Forbes da9298
@@ -394,6 +394,27 @@ static DisplayChangeListener display_listener = {
Justin M. Forbes da9298
     .dpy_refresh = display_refresh,
Justin M. Forbes da9298
 };
Justin M. Forbes da9298
 
Justin M. Forbes da9298
+void qxl_create_server_to_iothread_pipe(SimpleSpiceDisplay *ssd,
Justin M. Forbes da9298
+    IOHandler *pipe_read)
Justin M. Forbes da9298
+{
Justin M. Forbes da9298
+    if (pipe(ssd->pipe) < 0) {
Justin M. Forbes da9298
+        fprintf(stderr, "%s: pipe creation failed\n", __FUNCTION__);
Justin M. Forbes da9298
+        return;
Justin M. Forbes da9298
+    }
Justin M. Forbes da9298
+
Justin M. Forbes da9298
+#ifdef CONFIG_IOTHREAD
Justin M. Forbes da9298
+    fcntl(ssd->pipe[0], F_SETFL, O_NONBLOCK);
Justin M. Forbes da9298
+#else
Justin M. Forbes da9298
+    fcntl(ssd->pipe[0], F_SETFL, O_NONBLOCK /* | O_ASYNC */);
Justin M. Forbes da9298
+#endif
Justin M. Forbes da9298
+    fcntl(ssd->pipe[1], F_SETFL, O_NONBLOCK);
Justin M. Forbes da9298
+
Justin M. Forbes da9298
+    fcntl(ssd->pipe[0], F_SETOWN, getpid());
Justin M. Forbes da9298
+
Justin M. Forbes da9298
+    qemu_set_fd_handler(ssd->pipe[0], pipe_read, NULL, ssd);
Justin M. Forbes da9298
+    ssd->main = pthread_self();
Justin M. Forbes da9298
+}
Justin M. Forbes da9298
+
Justin M. Forbes da9298
 void qemu_spice_display_init(DisplayState *ds)
Justin M. Forbes da9298
 {
Justin M. Forbes da9298
     assert(sdpy.ds == NULL);
Justin M. Forbes da9298
diff --git a/ui/spice-display.h b/ui/spice-display.h
Justin M. Forbes da9298
index aef0464..3e6cf7c 100644
Justin M. Forbes da9298
--- a/ui/spice-display.h
Justin M. Forbes da9298
+++ b/ui/spice-display.h
Justin M. Forbes da9298
@@ -43,6 +43,11 @@ typedef struct SimpleSpiceDisplay {
Justin M. Forbes da9298
     QXLRect dirty;
Justin M. Forbes da9298
     int notify;
Justin M. Forbes da9298
     int running;
Justin M. Forbes da9298
+
Justin M. Forbes da9298
+    /* thread signaling - used both in qxl (in vga mode
Justin M. Forbes da9298
+     * and in native mode) and without qxl */
Justin M. Forbes da9298
+    pthread_t          main;
Justin M. Forbes da9298
+    int                pipe[2];     /* to iothread */
Justin M. Forbes da9298
 } SimpleSpiceDisplay;
Justin M. Forbes da9298
 
Justin M. Forbes da9298
 typedef struct SimpleSpiceUpdate {
Justin M. Forbes da9298
@@ -66,3 +71,6 @@ void qemu_spice_display_update(SimpleSpiceDisplay *ssd,
Justin M. Forbes da9298
                                int x, int y, int w, int h);
Justin M. Forbes da9298
 void qemu_spice_display_resize(SimpleSpiceDisplay *ssd);
Justin M. Forbes da9298
 void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd);
Justin M. Forbes da9298
+/* used by both qxl and spice-display */
Justin M. Forbes da9298
+void qxl_create_server_to_iothread_pipe(SimpleSpiceDisplay *ssd,
Justin M. Forbes da9298
+    IOHandler *pipe_read);
Justin M. Forbes da9298
-- 
Justin M. Forbes da9298
1.7.3.2
Justin M. Forbes da9298