diff mbox

[5/9] Introduce qemu_set_fd_rw_handler()

Message ID 50a0e2ca9f4733a1ce896cb1da4a0d65c35d5882.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, read, write, o)/
  qemu_set_fd_rw_handler(fd, read, write, o)/

s/qemu_set_fd_handler2(fd, NULL, read, write, o)/
  qemu_set_fd_rw_handler(fd, read, write, o)/

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 aio.c               |    2 +-
 qemu-aio.h          |    4 ++--
 qemu-char.h         |    8 ++++----
 qemu-tool.c         |    9 ++++-----
 vl.c                |   16 ++++++++++++----
 vnc-auth-vencrypt.c |    2 +-
 vnc.c               |    2 +-
 7 files changed, 25 insertions(+), 18 deletions(-)
diff mbox

Patch

diff --git a/aio.c b/aio.c
index f164a47..4185233 100644
--- a/aio.c
+++ b/aio.c
@@ -93,7 +93,7 @@  int qemu_aio_set_fd_handler(int fd,
         node->opaque = opaque;
     }

-    qemu_set_fd_handler2(fd, NULL, io_read, io_write, opaque);
+    qemu_set_fd_rw_handler(fd, io_read, io_write, opaque);

     return 0;
 }
diff --git a/qemu-aio.h b/qemu-aio.h
index 3bdd749..1d2b423 100644
--- a/qemu-aio.h
+++ b/qemu-aio.h
@@ -43,11 +43,11 @@  void qemu_aio_wait(void);
 int qemu_aio_process_queue(void);

 /* Register a file descriptor and associated callbacks.  Behaves very similarly
- * to qemu_set_fd_handler2.  Unlike qemu_set_fd_handler2, these callbacks will
+ * to qemu_set_fd_rw_handler.  Unlike qemu_set_fd_rw_handler, these callbacks will
  * be invoked when using either qemu_aio_wait() or qemu_aio_flush().
  *
  * Code that invokes AIO completion functions should rely on this function
- * instead of qemu_set_fd_handler[2].
+ * instead of qemu_set_fd_rw_handler.
  */
 int qemu_aio_set_fd_handler(int fd,
                             IOHandler *io_read,
diff --git a/qemu-char.h b/qemu-char.h
index 76cacd9..8d7da54 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -103,10 +103,10 @@  int qemu_set_fd_handler2(int fd,
                          IOHandler *fd_read,
                          IOHandler *fd_write,
                          void *opaque);
-int qemu_set_fd_handler(int fd,
-                        IOHandler *fd_read,
-                        IOHandler *fd_write,
-                        void *opaque);
+int qemu_set_fd_rw_handler(int fd,
+                           IOHandler *fd_read,
+                           IOHandler *fd_write,
+                           void *opaque);
 int qemu_set_fd_read_handler(int fd,
                              IOHandler *fd_read,
                              void *opaque);
diff --git a/qemu-tool.c b/qemu-tool.c
index 18b48af..25d644f 100644
--- a/qemu-tool.c
+++ b/qemu-tool.c
@@ -90,11 +90,10 @@  void qemu_bh_delete(QEMUBH *bh)
     qemu_free(bh);
 }

-int qemu_set_fd_handler2(int fd,
-                         IOCanRWHandler *fd_read_poll,
-                         IOHandler *fd_read,
-                         IOHandler *fd_write,
-                         void *opaque)
+int qemu_set_fd_rw_handler(int fd,
+                           IOHandler *fd_read,
+                           IOHandler *fd_write,
+                           void *opaque)
 {
     return 0;
 }
diff --git a/vl.c b/vl.c
index 6e75347..c061732 100644
--- a/vl.c
+++ b/vl.c
@@ -2646,11 +2646,19 @@  int qemu_set_fd_handler2(int fd,
     return 0;
 }

-int qemu_set_fd_handler(int fd,
-                        IOHandler *fd_read,
-                        IOHandler *fd_write,
-                        void *opaque)
+int qemu_set_fd_rw_handler(int fd,
+                           IOHandler *fd_read,
+                           IOHandler *fd_write,
+                           void *opaque)
 {
+    if(fd_read == NULL) {
+        fprintf(stderr, "qemu_set_fd_rw_handler: NULL read handler\n");
+        exit(1);
+    }
+    if(fd_write == NULL) {
+        fprintf(stderr, "qemu_set_fd_rw_handler: NULL write handler\n");
+        exit(1);
+    }
     return qemu_set_fd_handler2(fd, NULL, fd_read, fd_write, opaque);
 }

diff --git a/vnc-auth-vencrypt.c b/vnc-auth-vencrypt.c
index 7b3fd57..22f5980 100644
--- a/vnc-auth-vencrypt.c
+++ b/vnc-auth-vencrypt.c
@@ -93,7 +93,7 @@  static int vnc_start_vencrypt_handshake(struct VncState *vs) {

     VNC_DEBUG("Handshake done, switching to TLS data mode\n");
     vs->tls.wiremode = VNC_WIREMODE_TLS;
-    qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, vnc_client_write, vs);
+    qemu_set_fd_rw_handler(vs->csock, vnc_client_read, vnc_client_write, vs);

     start_auth_vencrypt_subauth(vs);

diff --git a/vnc.c b/vnc.c
index 2634dc8..c945cb9 100644
--- a/vnc.c
+++ b/vnc.c
@@ -1356,7 +1356,7 @@  void vnc_write(VncState *vs, const void *data, size_t len)
     buffer_reserve(&vs->output, len);

     if (vs->csock != -1 && buffer_empty(&vs->output)) {
-        qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, vnc_client_write, vs);
+        qemu_set_fd_rw_handler(vs->csock, vnc_client_read, vnc_client_write, vs);
     }

     buffer_append(&vs->output, data, len);