diff mbox

[4/9] Introduce qemu_set_fd_write_handler()

Message ID e13f03c0a7cae0ec0a0047b705c45f9a59f7dce2.1268173345.git.quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela March 9, 2010, 10:25 p.m. UTC
Patch consist:

    s/qemu_set_fd_handler(fd, NULL, write, o)/
      qemu_set_fd_write_handler(fd, write, o)/

    s/qemu_set_fd_handler2(fd, NULL, NULL, write, o)/
      qemu_set_fd_write_handler(fd, write, o)/

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 audio/alsaaudio.c   |    4 ++--
 audio/ossaudio.c    |    2 +-
 migration-tcp.c     |    2 +-
 migration-unix.c    |    2 +-
 migration.c         |    2 +-
 net/socket.c        |    2 +-
 qemu-char.h         |    4 +++-
 usb-linux.c         |    2 +-
 vl.c                |   11 +++++++++++
 vnc-auth-vencrypt.c |    2 +-
 10 files changed, 23 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index 2455ee4..894f02b 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -273,8 +273,8 @@  static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask)
             if (conf.verbose) {
                 dolog ("POLLOUT %d %d\n", i, pfds[i].fd);
             }
-            err = qemu_set_fd_handler (pfds[i].fd, NULL,
-                                       alsa_poll_handler, hlp);
+            err = qemu_set_fd_write_handler (pfds[i].fd, alsa_poll_handler,
+                                             hlp);
         }
         if (conf.verbose) {
             dolog ("Set handler events=%#x index=%d fd=%d err=%d\n",
diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index 4c91a46..4d0cd36 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -146,7 +146,7 @@  static int oss_poll_out (HWVoiceOut *hw)
 {
     OSSVoiceOut *oss = (OSSVoiceOut *) hw;

-    return qemu_set_fd_handler (oss->fd, NULL, oss_helper_poll_out, NULL);
+    return qemu_set_fd_write_handler (oss->fd, oss_helper_poll_out, NULL);
 }

 static int oss_poll_in (HWVoiceIn *hw)
diff --git a/migration-tcp.c b/migration-tcp.c
index 66f126f..c141322 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -123,7 +123,7 @@  MigrationState *tcp_start_outgoing_migration(Monitor *mon,
             ret = -(s->get_error(s));

         if (ret == -EINPROGRESS || ret == -EWOULDBLOCK)
-            qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s);
+            qemu_set_fd_write_handler(s->fd, tcp_wait_for_connect, s);
     } while (ret == -EINTR);

     if (ret < 0 && ret != -EINPROGRESS && ret != -EWOULDBLOCK) {
diff --git a/migration-unix.c b/migration-unix.c
index fe9a820..b50ccb2 100644
--- a/migration-unix.c
+++ b/migration-unix.c
@@ -118,7 +118,7 @@  MigrationState *unix_start_outgoing_migration(Monitor *mon,
 	    ret = -(s->get_error(s));

         if (ret == -EINPROGRESS || ret == -EWOULDBLOCK)
-	    qemu_set_fd_handler2(s->fd, NULL, NULL, unix_wait_for_connect, s);
+	    qemu_set_fd_write_handler(s->fd, unix_wait_for_connect, s);
     } while (ret == -EINTR);

     if (ret < 0 && ret != -EINPROGRESS && ret != -EWOULDBLOCK) {
diff --git a/migration.c b/migration.c
index 787147a..c310e4b 100644
--- a/migration.c
+++ b/migration.c
@@ -332,7 +332,7 @@  ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size)
         ret = -(s->get_error(s));

     if (ret == -EAGAIN)
-        qemu_set_fd_handler2(s->fd, NULL, NULL, migrate_fd_put_notify, s);
+        qemu_set_fd_write_handler(s->fd, migrate_fd_put_notify, s);

     return ret;
 }
diff --git a/net/socket.c b/net/socket.c
index 5772202..e746b19 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -316,7 +316,7 @@  static NetSocketState *net_socket_fd_init_stream(VLANState *vlan,
     if (is_connected) {
         net_socket_connect(s);
     } else {
-        qemu_set_fd_handler(s->fd, NULL, net_socket_connect, s);
+        qemu_set_fd_write_handler(s->fd, net_socket_connect, s);
     }
     return s;
 }
diff --git a/qemu-char.h b/qemu-char.h
index 70e4bf9..76cacd9 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -110,6 +110,8 @@  int qemu_set_fd_handler(int fd,
 int qemu_set_fd_read_handler(int fd,
                              IOHandler *fd_read,
                              void *opaque);
-
+int qemu_set_fd_write_handler(int fd,
+                              IOHandler *fd_read,
+                              void *opaque);

 #endif
diff --git a/usb-linux.c b/usb-linux.c
index b7ac3e9..9c871ce 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -940,7 +940,7 @@  static int usb_host_open(USBHostDevice *dev, int bus_num,
                 prod_name);

     /* USB devio uses 'write' flag to check for async completions */
-    qemu_set_fd_handler(dev->fd, NULL, async_complete, dev);
+    qemu_set_fd_write_handler(dev->fd, async_complete, dev);

     usb_device_attach(&dev->dev);
     return 0;
diff --git a/vl.c b/vl.c
index c855167..6e75347 100644
--- a/vl.c
+++ b/vl.c
@@ -2665,6 +2665,17 @@  int qemu_set_fd_read_handler(int fd,
     return qemu_set_fd_handler2(fd, NULL, fd_read, NULL, opaque);
 }

+int qemu_set_fd_write_handler(int fd,
+                              IOHandler *fd_write,
+                              void *opaque)
+{
+    if(fd_write == NULL) {
+        fprintf(stderr, "qemu_set_fd_write_handler: NULL write handler\n");
+        exit(1);
+    }
+    return qemu_set_fd_handler2(fd, NULL, NULL, fd_write, opaque);
+}
+
 #ifdef _WIN32
 /***********************************************************/
 /* Polling handling */
diff --git a/vnc-auth-vencrypt.c b/vnc-auth-vencrypt.c
index 2999c2d..7b3fd57 100644
--- a/vnc-auth-vencrypt.c
+++ b/vnc-auth-vencrypt.c
@@ -73,7 +73,7 @@  static int vnc_start_vencrypt_handshake(struct VncState *vs) {
            if (!gnutls_record_get_direction(vs->tls.session))
                qemu_set_fd_read_handler(vs->csock, vnc_tls_handshake_io, vs);
            else
-               qemu_set_fd_handler(vs->csock, NULL, vnc_tls_handshake_io, vs);
+               qemu_set_fd_write_handler(vs->csock, vnc_tls_handshake_io, vs);
            return 0;
        }
        VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(ret));