qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [patch 04/11] qemu: introduce main_loop_break


From: Anthony Liguori
Subject: [Qemu-devel] Re: [patch 04/11] qemu: introduce main_loop_break
Date: Fri, 17 Apr 2009 08:57:43 -0500
User-agent: Thunderbird 2.0.0.21 (X11/20090320)

address@hidden wrote:
Use a pipe to signal pending work for the iothread.

Signed-off-by: Marcelo Tosatti <address@hidden>

Index: trunk/qemu-common.h
===================================================================
--- trunk.orig/qemu-common.h
+++ trunk/qemu-common.h
@@ -186,6 +186,8 @@ int cpu_load(QEMUFile *f, void *opaque, /* Force QEMU to stop what it's doing and service IO */
 void qemu_service_io(void);

+void main_loop_break(void);
+
 /* Force QEMU to process pending events */
 void qemu_notify_event(void);

Index: trunk/vl.c
===================================================================
--- trunk.orig/vl.c
+++ trunk/vl.c
@@ -276,6 +276,8 @@ static QEMUTimer *nographic_timer;

 uint8_t qemu_uuid[16];

+static int io_thread_fd = -1;
+
 /***********************************************************/
 /* x86 ISA bus support */

@@ -3632,6 +3634,55 @@ void qemu_notify_event(void)
      }
 }

+void main_loop_break(void)
+{
+    uint64_t value = 1;
+    char buffer[8];
+    size_t offset = 0;
+
+    if (io_thread_fd == -1)
+        return;
+
+    memcpy(buffer, &value, sizeof(value));
+
+    while (offset < 8) {
+        ssize_t len;
+
+        len = write(io_thread_fd, buffer + offset, 8 - offset);
+        if (len == -1 && errno == EINTR)
+            continue;
+
+        if (len <= 0)
+            break;
+
+        offset += len;
+    }
+
+    if (offset != 8)
+        fprintf(stderr, "failed to notify io thread\n");
+}

I'd like to see a higher level abstraction here. This is trying to be eventfd compatible which is great, but we should have something like:

qemu_event_increment();
qemu_event_read();

It'll simplify this code a lot. We can also switch some of the other existing code to use this too later.

Regards,

Anthony Liguori




reply via email to

[Prev in Thread] Current Thread [Next in Thread]