*** SUBJECT HERE ***
Subsystems (2)
cover *** SUBJECT HERE ***
*** BLURB HERE ***
Juan Quintela (16):
migration: Clear fd also in error cases
migration: unix migration should obey autostart are the other ones Convert io handlers to QLIST
remove useless cast
rename IOCanRWHandler to IOCanReadHandler
bt: remove bt_host_read_poll()
Handle deleted IOHandlers in a single buffer
tap: insert tap_can_send() into tap_send() qemu-char:stdio insert poll call into read one qemu-char:tcp insert poll call into read one qemu-char:fd insert poll call into read one qemu-char:pty insert poll call into read one qemu-char:udp insert poll call into read one
Remove qemu_set_fd_handler2()
Remove now unused fd_read_poll and all its only left user Add qemu_remove_fd_handler()
aio.c | 2 +- audio/alsaaudio.c | 4 +- audio/ossaudio.c | 6 +- bt-host.c | 9 +---- hw/xen_backend.c | 4 +- migration-exec.c | 9 ++-- migration-fd.c | 7 +-- migration-tcp.c | 13 +++--- migration-unix.c | 15 ++++--- migration.c | 8 ++-- net/socket.c | 6 +- net/tap.c | 27 ++++-------- net/vde.c | 2 +- qemu-aio.h | 4 +- qemu-char.c | 112 ++++++++++++++++---------------------------------- qemu-char.h | 11 +---- qemu-common.h | 2 +- qemu-tool.c | 9 ++-- usb-linux.c | 2 +- vl.c | 92 +++++++++++++++++------------------------- vnc-auth-sasl.c | 2 +- vnc-auth-vencrypt.c | 2 +- vnc.c | 12 +++--- 23 files changed, 139 insertions(+), 221 deletions(-)
PATCH 1/16 migration: Clear fd also in error cases
Not clearing the fd and closing the file makes qemu spin using 100%CPU after incoming migration error.
See for instance bug:
https://bugzilla.redhat.com/show_bug.cgi?id=518032
--- migration-exec.c | 4 ++-- migration-fd.c | 4 ++-- migration-tcp.c | 5 ++--- migration-unix.c | 5 ++--- 4 files changed, 8 insertions(+), 10 deletions(-)
migration-exec.c +2 -2
@@ -120,12 +120,12 @@ static void exec_accept_incoming_migration(void *opaque) }qemu_announce_self ();DPRINTF ("successfully loaded vm state\n" ); -/* we've successfully migrated, close the fd */ -qemu_set_fd_handler2 (qemu_stdio_fd (f),NULL ,NULL ,NULL ,NULL ); +if (autostart)vm_start (); err: +qemu_set_fd_handler2 (qemu_stdio_fd (f),NULL ,NULL ,NULL ,NULL );qemu_fclose (f); }
migration-fd.c +2 -2
@@ -113,12 +113,12 @@ static void fd_accept_incoming_migration(void *opaque) }qemu_announce_self ();DPRINTF ("successfully loaded vm state\n" ); -/* we've successfully migrated, close the fd */ -qemu_set_fd_handler2 (qemu_stdio_fd (f),NULL ,NULL ,NULL ,NULL ); +if (autostart)vm_start (); err: +qemu_set_fd_handler2 (qemu_stdio_fd (f),NULL ,NULL ,NULL ,NULL );qemu_fclose (f); }
migration-tcp.c +2 -3
@@ -170,15 +170,14 @@ static void tcp_accept_incoming_migration(void *opaque)qemu_announce_self ();DPRINTF ("successfully loaded vm state\n" ); -/* we've successfully migrated, close the server socket */ -qemu_set_fd_handler2 (s,NULL ,NULL ,NULL ,NULL ); -close (s);if (autostart)vm_start (); out_fopen:qemu_fclose (f); out: +qemu_set_fd_handler2 (s,NULL ,NULL ,NULL ,NULL ); +close (s);close (c); }
migration-unix.c +2 -3
@@ -176,13 +176,12 @@ static void unix_accept_incoming_migration(void *opaque)qemu_announce_self ();DPRINTF ("successfully loaded vm state\n" ); -/* we've successfully migrated, close the server socket */ -qemu_set_fd_handler2 (s,NULL ,NULL ,NULL ,NULL ); -close (s); out_fopen:qemu_fclose (f); out: +qemu_set_fd_handler2 (s,NULL ,NULL ,NULL ,NULL ); +close (s);close (c); }
Signature · 1 line
1.6.6.1
PATCH 2/16 migration: unix migration should obey autostart are the other ones
In reply to Juan QuintelaThis was the only incoming migration without autostart check
--- migration-unix.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
migration-unix.c +2 -0
@@ -176,6 +176,8 @@ static void unix_accept_incoming_migration(void *opaque)qemu_announce_self ();DPRINTF ("successfully loaded vm state\n" ); +if (autostart) +vm_start (); out_fopen:qemu_fclose (f);
Signature · 1 line
1.6.6.1
PATCH 3/16 Convert io handlers to QLIST
In reply to Juan Quintela--- vl.c | 35 ++++++++++++++--------------------- 1 files changed, 14 insertions(+), 21 deletions(-)
vl.c +14 -21
@@ -2597,10 +2597,12 @@ typedef struct IOHandlerRecord {void *opaque;/* temporary data */ struct pollfd *ufd; -struct IOHandlerRecord *next; +QLIST_ENTRY (IOHandlerRecord) next; } IOHandlerRecord; -static IOHandlerRecord *first_io_handler; +static QLIST_HEAD(, IOHandlerRecord) io_handlers = +QLIST_HEAD_INITIALIZER (io_handlers); +/* XXX: fd_read_poll should be suppressed, but an API change is necessary in the character devices to suppress fd_can_read(). */
@@ -2610,28 +2612,22 @@ int qemu_set_fd_handler2(int fd, IOHandler *fd_write, void *opaque) { -IOHandlerRecord **pioh, *ioh; +IOHandlerRecord *ioh;if (!fd_read && !fd_write) { - pioh = &first_io_handler; -for (;;) { - ioh = *pioh; -if (ioh ==NULL ) -break ; + QLIST_FOREACH(ioh, &io_handlers, next) {if (ioh->fd == fd) { ioh->deleted =1 ;break ; } - pioh = &ioh->next; } }else { -for (ioh = first_io_handler; ioh !=NULL ; ioh = ioh->next) { + QLIST_FOREACH(ioh, &io_handlers, next) {if (ioh->fd == fd) goto found; } ioh =qemu_mallocz (sizeof (IOHandlerRecord)); - ioh->next = first_io_handler; - first_io_handler = ioh; +QLIST_INSERT_HEAD (&io_handlers, ioh, next); found: ioh->fd = fd; ioh->fd_read_poll = fd_read_poll;
@@ -3822,7 +3818,7 @@ void main_loop_wait(int timeout)FD_ZERO (&rfds);FD_ZERO (&wfds);FD_ZERO (&xfds); -for (ioh = first_io_handler; ioh !=NULL ; ioh = ioh->next) { + QLIST_FOREACH(ioh, &io_handlers, next) {if (ioh->deleted)continue ; if (ioh->fd_read &&
@@ -3848,9 +3844,9 @@ void main_loop_wait(int timeout) ret =select (nfds +1 , &rfds, &wfds, &xfds, &tv);qemu_mutex_lock_iothread ();if (ret >0 ) { -IOHandlerRecord **pioh; +IOHandlerRecord *pioh; -for (ioh = first_io_handler; ioh !=NULL ; ioh = ioh->next) { + QLIST_FOREACH(ioh, &io_handlers, next) {if (!ioh->deleted && ioh->fd_read &&FD_ISSET (ioh->fd, &rfds)) { ioh->fd_read (ioh->opaque); }
@@ -3860,14 +3856,11 @@ void main_loop_wait(int timeout) }/* remove deleted IO handlers */ - pioh = &first_io_handler; -while (*pioh) { - ioh = *pioh; + QLIST_FOREACH_SAFE(ioh, &io_handlers, next, pioh) {if (ioh->deleted) { - *pioh = ioh->next; +QLIST_REMOVE (ioh, next);qemu_free (ioh); - }else - pioh = &ioh->next; + } } }
Signature · 1 line
1.6.6.1
Re: [Qemu-devel] [PATCH 03/16] Convert io handlers to QLIST
Quoted 2 lines · Juan Quintela
Signed-off-by Juan Quintela<[email protected]>
Applied 3-7, thanks.
Regards,
Anthony Liguori
Quoted 96 lines
--- vl.c | 35 ++++++++++++++--------------------- 1 files changed, 14 insertions(+), 21 deletions(-)vl.c +14
-21@@ -2597,10 +2597,12 @@ typedef struct IOHandlerRecord {void *opaque;/* temporary data */ struct pollfd *ufd; -struct IOHandlerRecord *next; +QLIST_ENTRY (IOHandlerRecord) next; } IOHandlerRecord; -static IOHandlerRecord *first_io_handler; +static QLIST_HEAD(, IOHandlerRecord) io_handlers = +QLIST_HEAD_INITIALIZER (io_handlers); +/* XXX: fd_read_poll should be suppressed, but an API change is necessary in the character devices to suppress fd_can_read(). */ @@ -2610,28 +2612,22 @@ int qemu_set_fd_handler2(int fd, IOHandler *fd_write, void *opaque) { -IOHandlerRecord **pioh, *ioh; +IOHandlerRecord *ioh;if (!fd_read&& !fd_write) { - pioh =&first_io_handler; -for (;;) { - ioh = *pioh; -if (ioh ==NULL ) -break ; + QLIST_FOREACH(ioh,&io_handlers, next) {if (ioh->fd == fd) { ioh->deleted =1 ;break ; } - pioh =&ioh->next; } }else { -for (ioh = first_io_handler; ioh !=NULL ; ioh = ioh->next) { + QLIST_FOREACH(ioh,&io_handlers, next) {if (ioh->fd == fd) goto found; } ioh =qemu_mallocz (sizeof (IOHandlerRecord)); - ioh->next = first_io_handler; - first_io_handler = ioh; +QLIST_INSERT_HEAD (&io_handlers, ioh, next); found: ioh->fd = fd; ioh->fd_read_poll = fd_read_poll;@@ -3822,7 +3818,7 @@ void main_loop_wait(int timeout)FD_ZERO (&rfds);FD_ZERO (&wfds);FD_ZERO (&xfds); -for (ioh = first_io_handler; ioh !=NULL ; ioh = ioh->next) { + QLIST_FOREACH(ioh,&io_handlers, next) {if (ioh->deleted)continue ; if (ioh->fd_read&&@@ -3848,9 +3844,9 @@ void main_loop_wait(int timeout) ret =select (nfds +1 ,&rfds,&wfds,&xfds,&tv);qemu_mutex_lock_iothread ();if (ret>0 ) { -IOHandlerRecord **pioh; +IOHandlerRecord *pioh; -for (ioh = first_io_handler; ioh !=NULL ; ioh = ioh->next) { + QLIST_FOREACH(ioh,&io_handlers, next) {if (!ioh->deleted&& ioh->fd_read&&FD_ISSET (ioh->fd,&rfds)) { ioh->fd_read (ioh->opaque); }@@ -3860,14 +3856,11 @@ void main_loop_wait(int timeout) }/* remove deleted IO handlers */ - pioh =&first_io_handler; -while (*pioh) { - ioh = *pioh; + QLIST_FOREACH_SAFE(ioh,&io_handlers, next, pioh) {if (ioh->deleted) { - *pioh = ioh->next; +QLIST_REMOVE (ioh, next);qemu_free (ioh); - }else - pioh =&ioh->next; + } } }
PATCH 4/16 remove useless cast
In reply to Juan Quintelavalues are already pointers, no need to cast them to void *
--- migration-exec.c | 3 +-- migration-fd.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
migration-exec.c +1 -2
@@ -141,8 +141,7 @@ int exec_start_incoming_migration(const char *command) }qemu_set_fd_handler2 (qemu_stdio_fd (f),NULL , - exec_accept_incoming_migration,NULL , - (void *)(unsigned long )f); + exec_accept_incoming_migration,NULL , f);return 0 ; }
migration-fd.c +1 -2
@@ -136,8 +136,7 @@ int fd_start_incoming_migration(const char *infd)return -errno; } -qemu_set_fd_handler2 (fd,NULL , fd_accept_incoming_migration,NULL , - (void *)(unsigned long )f); +qemu_set_fd_handler2 (fd,NULL , fd_accept_incoming_migration,NULL , f);return 0 ; }
Signature · 1 line
1.6.6.1
PATCH 5/16 rename IOCanRWHandler to IOCanReadHandler
In reply to Juan QuintelaIt was always only used for reads
--- qemu-char.c | 4 ++-- qemu-char.h | 7 +++---- qemu-common.h | 2 +- qemu-tool.c | 2 +- vl.c | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-)
qemu-char.c +2 -2
@@ -182,7 +182,7 @@ void qemu_chr_send_event(CharDriverState *s, int event) }void qemu_chr_add_handlers (CharDriverState *s, -IOCanRWHandler *fd_can_read, +IOCanReadHandler *fd_can_read,IOReadHandler *fd_read,IOEventHandler *fd_event,void *opaque)
@@ -214,7 +214,7 @@ static CharDriverState *qemu_chr_open_null(QemuOpts *opts)#define MUX_BUFFER_SIZE 32/* Must be a power of 2. */ #define MUX_BUFFER_MASK (MUX_BUFFER_SIZE - 1) typedef struct { - IOCanRWHandler *chr_can_read[MAX_MUX]; + IOCanReadHandler *chr_can_read[MAX_MUX]; IOReadHandler *chr_read[MAX_MUX]; IOEventHandler *chr_event[MAX_MUX]; void *ext_opaque[MAX_MUX];
qemu-char.h +3 -4
@@ -57,7 +57,7 @@ struct CharDriverState {int (*chr_ioctl)(struct CharDriverState *s,int cmd,void *arg);int (*get_msgfd)(struct CharDriverState *s);IOEventHandler *chr_event; -IOCanRWHandler *chr_can_read; +IOCanReadHandler *chr_can_read;IOReadHandler *chr_read;void *handler_opaque;void (*chr_send_event)(struct CharDriverState *chr,int event);
@@ -79,7 +79,7 @@ void qemu_chr_printf(CharDriverState *s, const char *fmt, ...);int qemu_chr_write (CharDriverState *s,const uint8_t *buf,int len);void qemu_chr_send_event (CharDriverState *s,int event);void qemu_chr_add_handlers (CharDriverState *s, -IOCanRWHandler *fd_can_read, +IOCanReadHandler *fd_can_read,IOReadHandler *fd_read,IOEventHandler *fd_event,void *opaque);
@@ -98,7 +98,7 @@ extern int term_escape_char;/* async I/O support */ int qemu_set_fd_handler2 (int fd, -IOCanRWHandler *fd_read_poll, +IOCanReadHandler *fd_read_poll,IOHandler *fd_read,IOHandler *fd_write,void *opaque);
@@ -106,5 +106,4 @@ int qemu_set_fd_handler(int fd, IOHandler *fd_read, IOHandler *fd_write, void *opaque); -#endif
qemu-common.h +1 -1
@@ -183,7 +183,7 @@ void QEMU_NORETURN hw_error(const char *fmt, ...)/* IO callbacks. */ typedef void IOReadHandler (void *opaque,const uint8_t *buf,int size); -typedef int IOCanRWHandler (void *opaque); +typedef int IOCanReadHandler (void *opaque);typedef void IOHandler (void *opaque);struct ParallelIOArg {
qemu-tool.c +1 -1
@@ -91,7 +91,7 @@ void qemu_bh_delete(QEMUBH *bh) }int qemu_set_fd_handler2 (int fd, -IOCanRWHandler *fd_read_poll, +IOCanReadHandler *fd_read_poll,IOHandler *fd_read,IOHandler *fd_write,void *opaque)
vl.c +2 -2
@@ -2590,7 +2590,7 @@ void pcmcia_info(Monitor *mon) typedef struct IOHandlerRecord { int fd; - IOCanRWHandler *fd_read_poll; + IOCanReadHandler *fd_read_poll; IOHandler *fd_read; IOHandler *fd_write; int deleted;
@@ -2607,7 +2607,7 @@ static QLIST_HEAD(, IOHandlerRecord) io_handlers =/* XXX: fd_read_poll should be suppressed, but an API change is necessary in the character devices to suppress fd_can_read(). */ int qemu_set_fd_handler2 (int fd, -IOCanRWHandler *fd_read_poll, +IOCanReadHandler *fd_read_poll,IOHandler *fd_read,IOHandler *fd_write,void *opaque)
Signature · 1 line
1.6.6.1
PATCH 6/16 bt: remove bt_host_read_poll()
In reply to Juan QuintelaIt allways returned true, that is the equivalent of not having the callback.
--- bt-host.c | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-)
bt-host.c +1 -8
@@ -80,13 +80,6 @@ static void bt_host_sco(struct HCIInfo *hci, const uint8_t *data, int len)bt_host_send (hci,HCI_SCODATA_PKT , data, len); } -static int bt_host_read_poll (void *opaque) -{ -struct bt_host_hci_s *s = (struct bt_host_hci_s *) opaque; - -return !!s->hci.evt_recv; -} -static void bt_host_read (void *opaque) {struct bt_host_hci_s *s = (struct bt_host_hci_s *) opaque;
@@ -192,7 +185,7 @@ struct HCIInfo *bt_host_hci(const char *id) s->hci.acl_send = bt_host_acl; s->hci.bdaddr_set = bt_host_bdaddr_set; -qemu_set_fd_handler2 (s->fd, bt_host_read_poll, bt_host_read,NULL , s); +qemu_set_fd_handler (s->fd, bt_host_read,NULL , s);return &s->hci; }
Signature · 1 line
1.6.6.1
PATCH 7/16 Handle deleted IOHandlers in a single buffer
In reply to Juan Quintela--- vl.c | 17 +++++++---------- 1 files changed, 7 insertions(+), 10 deletions(-)
vl.c +7 -10
@@ -3846,20 +3846,17 @@ void main_loop_wait(int timeout)if (ret >0 ) {IOHandlerRecord *pioh; - QLIST_FOREACH(ioh, &io_handlers, next) { -if (!ioh->deleted && ioh->fd_read &&FD_ISSET (ioh->fd, &rfds)) { - ioh->fd_read (ioh->opaque); - } -if (!ioh->deleted && ioh->fd_write &&FD_ISSET (ioh->fd, &wfds)) { - ioh->fd_write (ioh->opaque); - } - } - -/* remove deleted IO handlers */ QLIST_FOREACH_SAFE(ioh, &io_handlers, next, pioh) {if (ioh->deleted) {QLIST_REMOVE (ioh, next);qemu_free (ioh); +continue ; + } +if (ioh->fd_read &&FD_ISSET (ioh->fd, &rfds)) { + ioh->fd_read (ioh->opaque); + } +if (ioh->fd_write &&FD_ISSET (ioh->fd, &wfds)) { + ioh->fd_write (ioh->opaque); } } }
Signature · 1 line
1.6.6.1
PATCH 8/16 tap: insert tap_can_send() into tap_send()
In reply to Juan QuintelaThis way we can remove the poll test
--- net/tap.c | 27 +++++++++------------------ 1 files changed, 9 insertions(+), 18 deletions(-)
net/tap.c +9 -18
@@ -61,17 +61,15 @@ typedef struct TAPState {static int launch_script (const char *setup_script,const char *ifname,int fd); -static int tap_can_send (void *opaque);static void tap_send (void *opaque);static void tap_writable (void *opaque);static void tap_update_fd_handler (TAPState *s) { -qemu_set_fd_handler2 (s->fd, - s->read_poll ? tap_can_send :NULL , - s->read_poll ? tap_send :NULL , - s->write_poll ? tap_writable :NULL , - s); +qemu_set_fd_handler (s->fd, + s->read_poll ? tap_send :NULL , + s->write_poll ? tap_writable :NULL , + s); }static void tap_read_poll (TAPState *s,int enable)
@@ -165,13 +163,6 @@ static ssize_t tap_receive(VLANClientState *nc, const uint8_t *buf, size_t size)return tap_write_packet (s, iov,1 ); } -static int tap_can_send (void *opaque) -{ -TAPState *s = opaque; - -return qemu_can_send_packet (&s->nc); -} -#ifndef __sun__ssize_t tap_read_packet (int tapfd,uint8_t *buf,int maxlen) {
@@ -188,12 +179,10 @@ static void tap_send_completed(VLANClientState *nc, ssize_t len)static void tap_send (void *opaque) {TAPState *s = opaque; -int size; - do { +while (qemu_can_send_packet (&s->nc) >0 ) {uint8_t *buf = s->buf; - - size = tap_read_packet(s->fd, s->buf, sizeof(s->buf)); +int size =tap_read_packet (s->fd, s->buf,sizeof (s->buf));if (size <=0 ) {break ; }
@@ -206,8 +195,10 @@ static void tap_send(void *opaque) size =qemu_send_packet_async (&s->nc, buf, size, tap_send_completed);if (size ==0 ) {tap_read_poll (s,0 ); + }else if (size <0 ) { +return ; } - }while (size >0 &&qemu_can_send_packet (&s->nc)); + } }int tap_has_ufo (VLANClientState *nc)
Signature · 1 line
1.6.6.1
Re: [Qemu-devel] [PATCH 08/16] tap: insert tap_can_send() into tap_send()
Quoted 4 lines · Juan Quintela
This way we can remove the poll test
Signed-off-by Juan Quintela<[email protected]>
Won't this cause unnecessary wake ups?
Right now, we use the can_read() poll function to determine whether to add an fd to a fdset. With this patch, we always add the fd to the fdset and then we just fail the read.
To eliminate the poll function, we need to change the handlers from polling, to noticing when they no longer can be read, and remove the read callback entirely.
Regards,
Anthony Liguori
Quoted 72 lines
--- net/tap.c | 27 +++++++++------------------ 1 files changed, 9 insertions(+), 18 deletions(-)net/tap.c +9
-18@@ -61,17 +61,15 @@ typedef struct TAPState {static int launch_script (const char *setup_script,const char *ifname,int fd); -static int tap_can_send (void *opaque);static void tap_send (void *opaque);static void tap_writable (void *opaque);static void tap_update_fd_handler (TAPState *s) { -qemu_set_fd_handler2 (s->fd, - s->read_poll ? tap_can_send :NULL , - s->read_poll ? tap_send :NULL , - s->write_poll ? tap_writable :NULL , - s); +qemu_set_fd_handler (s->fd, + s->read_poll ? tap_send :NULL , + s->write_poll ? tap_writable :NULL , + s); }static void tap_read_poll (TAPState *s,int enable)@@ -165,13 +163,6 @@ static ssize_t tap_receive(VLANClientState *nc, const uint8_t *buf, size_t size)return tap_write_packet (s, iov,1 ); } -static int tap_can_send (void *opaque) -{ -TAPState *s = opaque; - -return qemu_can_send_packet (&s->nc); -} -#ifndef __sun__ssize_t tap_read_packet (int tapfd,uint8_t *buf,int maxlen) {@@ -188,12 +179,10 @@ static void tap_send_completed(VLANClientState *nc, ssize_t len)static void tap_send (void *opaque) {TAPState *s = opaque; -int size; - do { +while (qemu_can_send_packet (&s->nc)>0 ) {uint8_t *buf = s->buf; - - size = tap_read_packet(s->fd, s->buf, sizeof(s->buf)); +int size =tap_read_packet (s->fd, s->buf,sizeof (s->buf));if (size<=0 ) {break ; }@@ -206,8 +195,10 @@ static void tap_send(void *opaque) size =qemu_send_packet_async (&s->nc, buf, size, tap_send_completed);if (size ==0 ) {tap_read_poll (s,0 ); + }else if (size<0 ) { +return ; } - }while (size>0 &&qemu_can_send_packet (&s->nc)); + } }int tap_has_ufo (VLANClientState *nc)
PATCH 9/16 qemu-char:stdio insert poll call into read one
In reply to Juan QuintelaThis way we can remove the poll test
--- qemu-char.c | 22 +++++++--------------- 1 files changed, 7 insertions(+), 15 deletions(-)
qemu-char.c +7 -15
@@ -664,8 +664,10 @@ static CharDriverState *qemu_chr_open_pipe(QemuOpts *opts)static uint8_t term_fifo[TERM_FIFO_MAX_SIZE ];static int term_fifo_size; -static int stdio_read_poll (void *opaque) +static void stdio_read (void *opaque) { +int size; +uint8_t buf[1 ];CharDriverState *chr = opaque;/* try to flush the queue if needed */
@@ -673,19 +675,9 @@ static int stdio_read_poll(void *opaque)qemu_chr_read (chr, term_fifo,1 ); term_fifo_size =0 ; } -/* see if we can absorb more chars */ -if (term_fifo_size ==0 ) -return 1 ; -else -return 0 ; -} - -static void stdio_read (void *opaque) -{ -int size; -uint8_t buf[1 ]; -CharDriverState *chr = opaque; - +if (term_fifo_size !=0 ) { +return ; + } size =read (0 , buf,1 );if (size ==0 ) {/* stdin has been closed. Remove it from the active list. */
@@ -757,7 +749,7 @@ static CharDriverState *qemu_chr_open_stdio(QemuOpts *opts)return NULL ; chr =qemu_chr_open_fd (0 ,1 ); chr->chr_close = qemu_chr_close_stdio; -qemu_set_fd_handler2 (0 , stdio_read_poll, stdio_read,NULL , chr); +qemu_set_fd_handler (0 , stdio_read,NULL , chr); stdio_nb_clients++;term_init (opts);
Signature · 1 line
1.6.6.1
PATCH 10/16 qemu-char:tcp insert poll call into read one
In reply to Juan QuintelaThis way we can remove the poll test
--- qemu-char.c | 18 +++++------------- 1 files changed, 5 insertions(+), 13 deletions(-)
qemu-char.c +5 -13
@@ -1899,16 +1899,6 @@ static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len) } } -static int tcp_chr_read_poll (void *opaque) -{ -CharDriverState *chr = opaque; -TCPCharDriver *s = chr->opaque; -if (!s->connected) -return 0 ; - s->max_size =qemu_chr_can_read (chr); -return s->max_size; -} -#define IAC 255#define IAC_BREAK 243 static void tcp_chr_process_IAC_bytes(CharDriverState *chr,
@@ -2030,7 +2020,10 @@ static void tcp_chr_read(void *opaque)uint8_t buf[READ_BUF_LEN ];int len, size; -if (!s->connected || s->max_size <=0 ) +if (!s->connected) +return ; + s->max_size =qemu_chr_can_read (chr); +if (s->max_size <=0 )return ; len =sizeof (buf);if (len > s->max_size)
@@ -2064,8 +2057,7 @@ static void tcp_chr_connect(void *opaque)TCPCharDriver *s = chr->opaque; s->connected =1 ; -qemu_set_fd_handler2 (s->fd, tcp_chr_read_poll, - tcp_chr_read,NULL , chr); +qemu_set_fd_handler (s->fd, tcp_chr_read,NULL , chr);qemu_chr_generic_open (chr); }
Signature · 1 line
1.6.6.1
PATCH 11/16 qemu-char:fd insert poll call into read one
In reply to Juan QuintelaThis way we can remove the poll test
--- qemu-char.c | 15 ++++----------- 1 files changed, 4 insertions(+), 11 deletions(-)
qemu-char.c +4 -11
@@ -536,15 +536,6 @@ static int fd_chr_write(CharDriverState *chr, const uint8_t *buf, int len)return send_all (s->fd_out, buf, len); } -static int fd_chr_read_poll (void *opaque) -{ -CharDriverState *chr = opaque; -FDCharDriver *s = chr->opaque; - - s->max_size =qemu_chr_can_read (chr); -return s->max_size; -} -static void fd_chr_read (void *opaque) {CharDriverState *chr = opaque;
@@ -552,6 +543,9 @@ static void fd_chr_read(void *opaque)int size, len;uint8_t buf[READ_BUF_LEN ]; + s->max_size =qemu_chr_can_read (chr); +if (s->max_size <=0 ) +return ; len =sizeof (buf);if (len > s->max_size) len = s->max_size;
@@ -576,8 +570,7 @@ static void fd_chr_update_read_handler(CharDriverState *chr)if (s->fd_in >=0 ) {if (display_type ==DT_NOGRAPHIC && s->fd_in ==0 ) { }else { -qemu_set_fd_handler2 (s->fd_in, fd_chr_read_poll, - fd_chr_read,NULL , chr); +qemu_set_fd_handler (s->fd_in, fd_chr_read,NULL , chr); } } }
Signature · 1 line
1.6.6.1
PATCH 12/16 qemu-char:pty insert poll call into read one
In reply to Juan QuintelaThis way we can remove the poll test
--- qemu-char.c | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-)
qemu-char.c +5 -11
@@ -833,15 +833,6 @@ static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len)return send_all (s->fd, buf, len); } -static int pty_chr_read_poll (void *opaque) -{ -CharDriverState *chr = opaque; -PtyCharDriver *s = chr->opaque; - - s->read_bytes =qemu_chr_can_read (chr); -return s->read_bytes; -} -static void pty_chr_read (void *opaque) {CharDriverState *chr = opaque;
@@ -849,6 +840,10 @@ static void pty_chr_read(void *opaque)int size, len;uint8_t buf[READ_BUF_LEN ]; + s->read_bytes =qemu_chr_can_read (chr); + +if (s->read_bytes <=0 ) +return ; len =sizeof (buf);if (len > s->read_bytes) len = s->read_bytes;
@@ -870,8 +865,7 @@ static void pty_chr_update_read_handler(CharDriverState *chr) {PtyCharDriver *s = chr->opaque; -qemu_set_fd_handler2 (s->fd, pty_chr_read_poll, - pty_chr_read,NULL , chr); +qemu_set_fd_handler (s->fd, pty_chr_read,NULL , chr); s->polling =1 ;/* * Short timeout here: just need wait long enougth that qemu makes
Signature · 1 line
1.6.6.1
PATCH 13/16 qemu-char:udp insert poll call into read one
In reply to Juan QuintelaThis way we can remove the poll test
--- qemu-char.c | 13 ++----------- 1 files changed, 2 insertions(+), 11 deletions(-)
qemu-char.c +2 -11
@@ -1767,7 +1767,7 @@ static int udp_chr_write(CharDriverState *chr, const uint8_t *buf, int len)return send (s->fd, (const void *)buf, len,0 ); } -static int udp_chr_read_poll (void *opaque) +static void udp_chr_read (void *opaque) {CharDriverState *chr = opaque;NetCharDriver *s = chr->opaque;
@@ -1782,14 +1782,6 @@ static int udp_chr_read_poll(void *opaque) s->bufptr++; s->max_size =qemu_chr_can_read (chr); } -return s->max_size; -} - -static void udp_chr_read (void *opaque) -{ -CharDriverState *chr = opaque; -NetCharDriver *s = chr->opaque; -if (s->max_size ==0 )return ; s->bufcnt =recv (s->fd, (void *)s->buf,sizeof (s->buf),0 );
@@ -1810,8 +1802,7 @@ static void udp_chr_update_read_handler(CharDriverState *chr)NetCharDriver *s = chr->opaque;if (s->fd >=0 ) { -qemu_set_fd_handler2 (s->fd, udp_chr_read_poll, - udp_chr_read,NULL , chr); +qemu_set_fd_handler (s->fd, udp_chr_read,NULL , chr); } }
Signature · 1 line
1.6.6.1
PATCH 14/16 Remove qemu_set_fd_handler2()
In reply to Juan QuintelaNow that there are no more poll_read users, we can remove it. Convert all users to qemu_set_fd_handler().
--- aio.c | 2 +- migration-exec.c | 6 +++--- migration-fd.c | 4 ++-- migration-tcp.c | 10 +++++----- migration-unix.c | 10 +++++----- migration.c | 8 ++++---- qemu-aio.h | 4 ++-- qemu-char.c | 12 ++++++------ qemu-char.h | 5 ----- qemu-tool.c | 9 ++++----- vl.c | 24 ++++++------------------ vnc-auth-sasl.c | 2 +- vnc-auth-vencrypt.c | 2 +- vnc.c | 12 ++++++------ 14 files changed, 46 insertions(+), 64 deletions(-)
aio.c +1 -1
@@ -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_handler (fd, io_read, io_write, opaque);return 0 ; }
migration-exec.c +3 -3
@@ -125,7 +125,7 @@ static void exec_accept_incoming_migration(void *opaque)vm_start (); err: -qemu_set_fd_handler2 (qemu_stdio_fd (f),NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (qemu_stdio_fd (f),NULL ,NULL ,NULL );qemu_fclose (f); }
@@ -140,8 +140,8 @@ int exec_start_incoming_migration(const char *command)return -errno; } -qemu_set_fd_handler2 (qemu_stdio_fd (f),NULL , - exec_accept_incoming_migration,NULL , f); +qemu_set_fd_handler (qemu_stdio_fd (f), + exec_accept_incoming_migration,NULL , f);return 0 ; }
migration-fd.c +2 -2
@@ -118,7 +118,7 @@ static void fd_accept_incoming_migration(void *opaque)vm_start (); err: -qemu_set_fd_handler2 (qemu_stdio_fd (f),NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (qemu_stdio_fd (f),NULL ,NULL ,NULL );qemu_fclose (f); }
@@ -136,7 +136,7 @@ int fd_start_incoming_migration(const char *infd)return -errno; } -qemu_set_fd_handler2 (fd,NULL , fd_accept_incoming_migration,NULL , f); +qemu_set_fd_handler (fd, fd_accept_incoming_migration,NULL , f);return 0 ; }
migration-tcp.c +5 -5
@@ -66,7 +66,7 @@ static void tcp_wait_for_connect(void *opaque)return ; } -qemu_set_fd_handler2 (s->fd,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL );if (val ==0 )migrate_fd_connect (s);
@@ -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_handler (s->fd,NULL , tcp_wait_for_connect, s); }while (ret == -EINTR );if (ret <0 && ret != -EINPROGRESS && ret != -EWOULDBLOCK ) {
@@ -176,7 +176,7 @@ static void tcp_accept_incoming_migration(void *opaque) out_fopen:qemu_fclose (f); out: -qemu_set_fd_handler2 (s,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (s,NULL ,NULL ,NULL );close (s);close (c); }
@@ -205,8 +205,8 @@ int tcp_start_incoming_migration(const char *host_port)if (listen (s,1 ) ==-1 ) goto err; -qemu_set_fd_handler2 (s,NULL , tcp_accept_incoming_migration,NULL , - (void *)(unsigned long )s); +qemu_set_fd_handler (s, tcp_accept_incoming_migration,NULL , + (void *)(unsigned long )s);return 0 ;
migration-unix.c +5 -5
@@ -65,7 +65,7 @@ static void unix_wait_for_connect(void *opaque)return ; } -qemu_set_fd_handler2 (s->fd,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL );if (val ==0 )migrate_fd_connect (s);
@@ -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_handler (s->fd,NULL , unix_wait_for_connect, s); }while (ret == -EINTR );if (ret <0 && ret != -EINPROGRESS && ret != -EWOULDBLOCK ) {
@@ -182,7 +182,7 @@ static void unix_accept_incoming_migration(void *opaque) out_fopen:qemu_fclose (f); out: -qemu_set_fd_handler2 (s,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (s,NULL ,NULL ,NULL );close (s);close (c); }
@@ -214,8 +214,8 @@ int unix_start_incoming_migration(const char *path) goto err; } -qemu_set_fd_handler2 (sock,NULL , unix_accept_incoming_migration,NULL , - (void *)(unsigned long )sock); +qemu_set_fd_handler (sock, unix_accept_incoming_migration,NULL , + (void *)(unsigned long )sock);return 0 ;
migration.c +4 -4
@@ -292,7 +292,7 @@ void migrate_fd_error(FdMigrationState *s)void migrate_fd_cleanup (FdMigrationState *s) { -qemu_set_fd_handler2 (s->fd,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL );if (s->file) {DPRINTF ("closing file\n" );
@@ -315,7 +315,7 @@ void migrate_fd_put_notify(void *opaque) {FdMigrationState *s = opaque; -qemu_set_fd_handler2 (s->fd,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL );qemu_file_put_notify (s->file); }
@@ -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_handler (s->fd,NULL , migrate_fd_put_notify, s);return ret; }
@@ -449,6 +449,6 @@ int migrate_fd_close(void *opaque) {FdMigrationState *s = opaque; -qemu_set_fd_handler2 (s->fd,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL );return s->close (s); }
qemu-aio.h +2 -2
@@ -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_handler. Unlike qemu_set_fd_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_handler. */ int qemu_aio_set_fd_handler(int fd, IOHandler *io_read,
qemu-char.c +6 -6
@@ -554,7 +554,7 @@ static void fd_chr_read(void *opaque) size =read (s->fd_in, buf, len);if (size ==0 ) {/* FD has been closed. Remove it from the active list. */ -qemu_set_fd_handler2 (s->fd_in,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (s->fd_in,NULL ,NULL ,NULL );qemu_chr_event (chr,CHR_EVENT_CLOSED );return ; }
@@ -582,7 +582,7 @@ static void fd_chr_close(struct CharDriverState *chr)if (s->fd_in >=0 ) {if (display_type ==DT_NOGRAPHIC && s->fd_in ==0 ) { }else { -qemu_set_fd_handler2 (s->fd_in,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (s->fd_in,NULL ,NULL ,NULL ); } }
@@ -674,7 +674,7 @@ static void stdio_read(void *opaque) size =read (0 , buf,1 );if (size ==0 ) {/* stdin has been closed. Remove it from the active list. */ -qemu_set_fd_handler2 (0 ,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (0 ,NULL ,NULL ,NULL );qemu_chr_event (chr,CHR_EVENT_CLOSED );return ; }
@@ -730,7 +730,7 @@ static void qemu_chr_close_stdio(struct CharDriverState *chr) {term_exit (); stdio_nb_clients--; -qemu_set_fd_handler2 (0 ,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (0 ,NULL ,NULL ,NULL );fd_chr_close (chr); }
@@ -883,7 +883,7 @@ static void pty_chr_state(CharDriverState *chr, int connected)PtyCharDriver *s = chr->opaque;if (!connected) { -qemu_set_fd_handler2 (s->fd,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL ); s->connected =0 ; s->polling =0 ;/* (re-)connect poll interval for idle guests: once per second.
@@ -919,7 +919,7 @@ static void pty_chr_close(struct CharDriverState *chr) {PtyCharDriver *s = chr->opaque; -qemu_set_fd_handler2 (s->fd,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL );close (s->fd);qemu_del_timer (s->timer);qemu_free_timer (s->timer);
qemu-char.h +0 -5
@@ -97,11 +97,6 @@ extern int term_escape_char;/* async I/O support */ -int qemu_set_fd_handler2 (int fd, -IOCanReadHandler *fd_read_poll, -IOHandler *fd_read, -IOHandler *fd_write, -void *opaque); int qemu_set_fd_handler(int fd, IOHandler *fd_read, IOHandler *fd_write,
qemu-tool.c +4 -5
@@ -90,11 +90,10 @@ void qemu_bh_delete(QEMUBH *bh)qemu_free (bh); } -int qemu_set_fd_handler2 (int fd, -IOCanReadHandler *fd_read_poll, -IOHandler *fd_read, -IOHandler *fd_write, -void *opaque) +int qemu_set_fd_handler (int fd, +IOHandler *fd_read, +IOHandler *fd_write, +void *opaque) {return 0 ; }
vl.c +6 -18
@@ -2604,13 +2604,10 @@ static QLIST_HEAD(, IOHandlerRecord) io_handlers =QLIST_HEAD_INITIALIZER (io_handlers); -/* XXX: fd_read_poll should be suppressed, but an API change is -necessary in the character devices to suppress fd_can_read(). */ -int qemu_set_fd_handler2 (int fd, -IOCanReadHandler *fd_read_poll, -IOHandler *fd_read, -IOHandler *fd_write, -void *opaque) +int qemu_set_fd_handler (int fd, +IOHandler *fd_read, +IOHandler *fd_write, +void *opaque) {IOHandlerRecord *ioh;
@@ -2630,7 +2627,6 @@ int qemu_set_fd_handler2(int fd,QLIST_INSERT_HEAD (&io_handlers, ioh, next); found: ioh->fd = fd; - ioh->fd_read_poll = fd_read_poll; ioh->fd_read = fd_read; ioh->fd_write = fd_write; ioh->opaque = opaque;
@@ -2639,14 +2635,6 @@ int qemu_set_fd_handler2(int fd,return 0 ; } -int qemu_set_fd_handler (int fd, -IOHandler *fd_read, -IOHandler *fd_write, -void *opaque) -{ -return qemu_set_fd_handler2 (fd,NULL , fd_read, fd_write, opaque); -} -#ifdef _WIN32/***********************************************************/ /* Polling handling */
@@ -3252,8 +3240,8 @@ static int qemu_event_init(void)if (err <0 ) goto fail; -qemu_set_fd_handler2 (fds[0 ],NULL , qemu_event_read,NULL , - (void *)(unsigned long )fds[0 ]); +qemu_set_fd_handler (fds[0 ], qemu_event_read,NULL , + (void *)(unsigned long )fds[0 ]); io_thread_fd = fds[1 ];return 0 ;
vnc-auth-sasl.c +1 -1
@@ -83,7 +83,7 @@ long vnc_client_write_sasl(VncState *vs)* SASL encoded output */ if (vs->output.offset ==0 ) { -qemu_set_fd_handler2 (vs->csock,NULL , vnc_client_read,NULL , vs); +qemu_set_fd_handler (vs->csock, vnc_client_read,NULL , vs); }return ret;
vnc-auth-vencrypt.c +1 -1
@@ -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_handler (vs->csock, vnc_client_read, vnc_client_write, vs);start_auth_vencrypt_subauth (vs);
vnc.c +6 -6
@@ -1076,7 +1076,7 @@ static void vnc_disconnect_start(VncState *vs) {if (vs->csock ==-1 )return ; -qemu_set_fd_handler2 (vs->csock,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (vs->csock,NULL ,NULL ,NULL );closesocket (vs->csock); vs->csock =-1 ; }
@@ -1218,7 +1218,7 @@ static long vnc_client_write_plain(VncState *vs) vs->output.offset -= ret;if (vs->output.offset ==0 ) { -qemu_set_fd_handler2 (vs->csock,NULL , vnc_client_read,NULL , vs); +qemu_set_fd_handler (vs->csock, vnc_client_read,NULL , vs); }return ret;
@@ -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_handler (vs->csock, vnc_client_read, vnc_client_write, vs); }buffer_append (&vs->output, data, len);
@@ -2389,7 +2389,7 @@ static void vnc_connect(VncDisplay *vd, int csock)VNC_DEBUG ("New client on socket %d\n" , csock); dcl->idle =0 ;socket_set_nonblock (vs->csock); -qemu_set_fd_handler2 (vs->csock,NULL , vnc_client_read,NULL , vs); +qemu_set_fd_handler (vs->csock, vnc_client_read,NULL , vs);vnc_client_cache_addr (vs);vnc_qmp_event (vs,QEVENT_VNC_CONNECTED );
@@ -2475,7 +2475,7 @@ void vnc_display_close(DisplayState *ds) vs->display =NULL ; }if (vs->lsock !=-1 ) { -qemu_set_fd_handler2 (vs->lsock,NULL ,NULL ,NULL ,NULL ); +qemu_set_fd_handler (vs->lsock,NULL ,NULL ,NULL );close (vs->lsock); vs->lsock =-1 ; }
@@ -2730,5 +2730,5 @@ int vnc_display_open(DisplayState *ds, const char *display) vs->display = dpy; } } -return qemu_set_fd_handler2 (vs->lsock,NULL , vnc_listen_read,NULL , vs); +return qemu_set_fd_handler (vs->lsock, vnc_listen_read,NULL , vs); }
Signature · 1 line
1.6.6.1
PATCH 15/16 Remove now unused fd_read_poll and all its only left user
In reply to Juan Quintela--- vl.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
vl.c +1 -4
@@ -2590,7 +2590,6 @@ void pcmcia_info(Monitor *mon) typedef struct IOHandlerRecord { int fd; - IOCanReadHandler *fd_read_poll; IOHandler *fd_read; IOHandler *fd_write; int deleted;
@@ -3809,9 +3808,7 @@ void main_loop_wait(int timeout) QLIST_FOREACH(ioh, &io_handlers, next) {if (ioh->deleted)continue ; -if (ioh->fd_read && - (!ioh->fd_read_poll || - ioh->fd_read_poll (ioh->opaque) !=0 )) { +if (ioh->fd_read) {FD_SET (ioh->fd, &rfds);if (ioh->fd > nfds) nfds = ioh->fd;
Signature · 1 line
1.6.6.1
PATCH 16/16 Add qemu_remove_fd_handler()
In reply to Juan QuintelaSwitch all users of qemu_set_fd_handler(fd, NULL, NULL, NULL) to this new function.
--- audio/alsaaudio.c | 4 ++-- audio/ossaudio.c | 6 +++--- hw/xen_backend.c | 4 ++-- migration-exec.c | 2 +- migration-fd.c | 2 +- migration-tcp.c | 4 ++-- migration-unix.c | 4 ++-- migration.c | 6 +++--- net/socket.c | 6 +++--- net/vde.c | 2 +- qemu-char.c | 24 +++++++++++------------- qemu-char.h | 1 + usb-linux.c | 2 +- vl.c | 19 +++++++++++++------ vnc.c | 4 ++-- 15 files changed, 48 insertions(+), 42 deletions(-)
audio/alsaaudio.c +2 -2
@@ -134,7 +134,7 @@ static void alsa_fini_poll (struct pollhlp *hlp)if (pfds) {for (i =0 ; i < hlp->count; ++i) { -qemu_set_fd_handler (pfds[i].fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (pfds[i].fd); }qemu_free (pfds); }
@@ -286,7 +286,7 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask) pfds[i].events, i, pfds[i].fd, err);while (i--) { -qemu_set_fd_handler (pfds[i].fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (pfds[i].fd); }qemu_free (pfds);return -1 ;
audio/ossaudio.c +3 -3
@@ -122,7 +122,7 @@ static void oss_anal_close (int *fdp) {int err; -qemu_set_fd_handler (*fdp,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (*fdp); err =close (*fdp);if (err) {oss_logerr (errno,"Failed to close file(fd=%d)\n" , *fdp);
@@ -651,7 +651,7 @@ static int oss_ctl_out (HWVoiceOut *hw, int cmd, ...)case VOICE_DISABLE :if (hw->poll_mode) { -qemu_set_fd_handler (oss->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (oss->fd); hw->poll_mode =0 ; }
@@ -835,7 +835,7 @@ static int oss_ctl_in (HWVoiceIn *hw, int cmd, ...)case VOICE_DISABLE :if (hw->poll_mode) { hw->poll_mode =0 ; -qemu_set_fd_handler (oss->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (oss->fd); }break ; }
hw/xen_backend.c +2 -2
@@ -635,7 +635,7 @@ int xen_be_init(void)return 0 ; err: -qemu_set_fd_handler (xs_fileno (xenstore),NULL ,NULL ,NULL ); +qemu_clear_fd_handler (xs_fileno (xenstore));xs_daemon_close (xenstore); xenstore =NULL ;
@@ -667,7 +667,7 @@ void xen_be_unbind_evtchn(struct XenDevice *xendev) {if (xendev->local_port ==-1 )return ; -qemu_set_fd_handler (xc_evtchn_fd (xendev->evtchndev),NULL ,NULL ,NULL ); +qemu_remove_fd_handler (xc_evtchn_fd (xendev->evtchndev));xc_evtchn_unbind (xendev->evtchndev, xendev->local_port);xen_be_printf (xendev,2 ,"unbind evtchn port %d\n" , xendev->local_port); xendev->local_port =-1 ;
migration-exec.c +1 -1
@@ -125,7 +125,7 @@ static void exec_accept_incoming_migration(void *opaque)vm_start (); err: -qemu_set_fd_handler (qemu_stdio_fd (f),NULL ,NULL ,NULL ); +qemu_remove_fd_handler (qemu_stdio_fd (f));qemu_fclose (f); }
migration-fd.c +1 -1
@@ -118,7 +118,7 @@ static void fd_accept_incoming_migration(void *opaque)vm_start (); err: -qemu_set_fd_handler (qemu_stdio_fd (f),NULL ,NULL ,NULL ); +qemu_remove_fd_handler (qemu_stdio_fd (f));qemu_fclose (f); }
migration-tcp.c +2 -2
@@ -66,7 +66,7 @@ static void tcp_wait_for_connect(void *opaque)return ; } -qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd);if (val ==0 )migrate_fd_connect (s);
@@ -176,7 +176,7 @@ static void tcp_accept_incoming_migration(void *opaque) out_fopen:qemu_fclose (f); out: -qemu_set_fd_handler (s,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s);close (s);close (c); }
migration-unix.c +2 -2
@@ -65,7 +65,7 @@ static void unix_wait_for_connect(void *opaque)return ; } -qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd);if (val ==0 )migrate_fd_connect (s);
@@ -182,7 +182,7 @@ static void unix_accept_incoming_migration(void *opaque) out_fopen:qemu_fclose (f); out: -qemu_set_fd_handler (s,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s);close (s);close (c); }
migration.c +3 -3
@@ -292,7 +292,7 @@ void migrate_fd_error(FdMigrationState *s)void migrate_fd_cleanup (FdMigrationState *s) { -qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd);if (s->file) {DPRINTF ("closing file\n" );
@@ -315,7 +315,7 @@ void migrate_fd_put_notify(void *opaque) {FdMigrationState *s = opaque; -qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd);qemu_file_put_notify (s->file); }
@@ -449,6 +449,6 @@ int migrate_fd_close(void *opaque) {FdMigrationState *s = opaque; -qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd);return s->close (s); }
net/socket.c +3 -3
@@ -84,7 +84,7 @@ static void net_socket_send(void *opaque) }else if (size ==0 ) {/* end of connection */ eoc: -qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd);closesocket (s->fd);return ; }
@@ -143,7 +143,7 @@ static void net_socket_send_dgram(void *opaque)return ;if (size ==0 ) {/* end of connection */ -qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd);return ; }qemu_send_packet (&s->nc, s->buf, size);
@@ -212,7 +212,7 @@ fail:static void net_socket_cleanup (VLANClientState *nc) {NetSocketState *s =DO_UPCAST (NetSocketState, nc, nc); -qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd);close (s->fd); }
net/vde.c +1 -1
@@ -65,7 +65,7 @@ static ssize_t vde_receive(VLANClientState *nc, const uint8_t *buf, size_t size)static void vde_cleanup (VLANClientState *nc) {VDEState *s =DO_UPCAST (VDEState, nc, nc); -qemu_set_fd_handler (vde_datafd (s->vde),NULL ,NULL ,NULL ); +qemu_remove_fd_handler (vde_datafd (s->vde));vde_close (s->vde); }
qemu-char.c +11 -13
@@ -553,8 +553,7 @@ static void fd_chr_read(void *opaque)return ; size =read (s->fd_in, buf, len);if (size ==0 ) { -/* FD has been closed. Remove it from the active list. */ -qemu_set_fd_handler (s->fd_in,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd_in);qemu_chr_event (chr,CHR_EVENT_CLOSED );return ; }
@@ -582,7 +581,7 @@ static void fd_chr_close(struct CharDriverState *chr)if (s->fd_in >=0 ) {if (display_type ==DT_NOGRAPHIC && s->fd_in ==0 ) { }else { -qemu_set_fd_handler (s->fd_in,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd_in); } }
@@ -673,8 +672,7 @@ static void stdio_read(void *opaque) } size =read (0 , buf,1 );if (size ==0 ) { -/* stdin has been closed. Remove it from the active list. */ -qemu_set_fd_handler (0 ,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (0 );qemu_chr_event (chr,CHR_EVENT_CLOSED );return ; }
@@ -730,7 +728,7 @@ static void qemu_chr_close_stdio(struct CharDriverState *chr) {term_exit (); stdio_nb_clients--; -qemu_set_fd_handler (0 ,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (0 );fd_chr_close (chr); }
@@ -883,7 +881,7 @@ static void pty_chr_state(CharDriverState *chr, int connected)PtyCharDriver *s = chr->opaque;if (!connected) { -qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd); s->connected =0 ; s->polling =0 ;/* (re-)connect poll interval for idle guests: once per second.
@@ -919,7 +917,7 @@ static void pty_chr_close(struct CharDriverState *chr) {PtyCharDriver *s = chr->opaque; -qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd);close (s->fd);qemu_del_timer (s->timer);qemu_free_timer (s->timer);
@@ -1810,7 +1808,7 @@ static void udp_chr_close(CharDriverState *chr) {NetCharDriver *s = chr->opaque;if (s->fd >=0 ) { -qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd);closesocket (s->fd); }qemu_free (s);
@@ -2013,7 +2011,7 @@ static void tcp_chr_read(void *opaque)if (s->listen_fd >=0 ) {qemu_set_fd_handler (s->listen_fd, tcp_chr_accept,NULL , chr); } -qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd);closesocket (s->fd); s->fd =-1 ;qemu_chr_event (chr,CHR_EVENT_CLOSED );
@@ -2096,7 +2094,7 @@ static void tcp_chr_accept(void *opaque)if (s->do_nodelay)socket_set_nodelay (fd); s->fd = fd; -qemu_set_fd_handler (s->listen_fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->listen_fd);tcp_chr_connect (chr); }
@@ -2104,11 +2102,11 @@ static void tcp_chr_close(CharDriverState *chr) {TCPCharDriver *s = chr->opaque;if (s->fd >=0 ) { -qemu_set_fd_handler (s->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->fd);closesocket (s->fd); }if (s->listen_fd >=0 ) { -qemu_set_fd_handler (s->listen_fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (s->listen_fd);closesocket (s->listen_fd); }qemu_free (s);
qemu-char.h +1 -0
@@ -101,4 +101,5 @@ int qemu_set_fd_handler(int fd, IOHandler *fd_read, IOHandler *fd_write, void *opaque); +int qemu_remove_fd_handler (int fd);#endif
usb-linux.c +1 -1
@@ -957,7 +957,7 @@ static int usb_host_close(USBHostDevice *dev)if (dev->fd ==-1 )return -1 ; -qemu_set_fd_handler (dev->fd,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (dev->fd); dev->closing =1 ;async_complete (dev); dev->closing =0 ;
vl.c +13 -6
@@ -2602,6 +2602,18 @@ typedef struct IOHandlerRecord { static QLIST_HEAD(, IOHandlerRecord) io_handlers =QLIST_HEAD_INITIALIZER (io_handlers); +int qemu_remove_fd_handler (int fd) +{ +IOHandlerRecord *ioh; + + QLIST_FOREACH(ioh, &io_handlers, next) { +if (ioh->fd == fd) { + ioh->deleted =1 ; +break ; + } + } +return 0 ; +} int qemu_set_fd_handler(int fd, IOHandler *fd_read,
@@ -2611,12 +2623,7 @@ int qemu_set_fd_handler(int fd,IOHandlerRecord *ioh;if (!fd_read && !fd_write) { - QLIST_FOREACH(ioh, &io_handlers, next) { -if (ioh->fd == fd) { - ioh->deleted =1 ; -break ; - } - } +qemu_remove_fd_handler (fd); }else { QLIST_FOREACH(ioh, &io_handlers, next) {if (ioh->fd == fd)
vnc.c +2 -2
@@ -1076,7 +1076,7 @@ static void vnc_disconnect_start(VncState *vs) {if (vs->csock ==-1 )return ; -qemu_set_fd_handler (vs->csock,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (vs->csock);closesocket (vs->csock); vs->csock =-1 ; }
@@ -2475,7 +2475,7 @@ void vnc_display_close(DisplayState *ds) vs->display =NULL ; }if (vs->lsock !=-1 ) { -qemu_set_fd_handler (vs->lsock,NULL ,NULL ,NULL ); +qemu_remove_fd_handler (vs->lsock);close (vs->lsock); vs->lsock =-1 ; }
Signature · 1 line
1.6.6.1