From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:38847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QklBD-0004C9-G2 for qemu-devel@nongnu.org; Sat, 23 Jul 2011 19:00:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QklBC-0006yt-GQ for qemu-devel@nongnu.org; Sat, 23 Jul 2011 19:00:19 -0400 Received: from e38.co.us.ibm.com ([32.97.110.159]:36034) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QklBC-0006yj-Ay for qemu-devel@nongnu.org; Sat, 23 Jul 2011 19:00:18 -0400 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e38.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p6NFNGZ3014584 for ; Sat, 23 Jul 2011 09:23:16 -0600 Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p6NN0FRK105836 for ; Sat, 23 Jul 2011 17:00:15 -0600 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p6NN5maX022781 for ; Sat, 23 Jul 2011 17:05:48 -0600 Message-ID: <4E2B527D.80508@linux.vnet.ibm.com> Date: Sat, 23 Jul 2011 18:00:13 -0500 From: Michael Roth MIME-Version: 1.0 References: <1311456361-14162-1-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1311456361-14162-1-git-send-email-aliguori@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-ga: remove dependency on gio and gthread List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org, Alex Graf On 07/23/2011 04:26 PM, Anthony Liguori wrote: > As far as I can tell, there isn't a dependency on gthread. Also, the only use > of gio was to enable GSocket to accept a unix domain socket. > > Since GSocket isn't available on OpenSuSE 11.1, let's just remove that > dependency. > > Signed-off-by: Anthony Liguori > --- > configure | 6 +++--- > qemu-ga.c | 34 +++++++++------------------------- > 2 files changed, 12 insertions(+), 28 deletions(-) > > diff --git a/configure b/configure > index 6911c3b..600da9b 100755 > --- a/configure > +++ b/configure > @@ -1811,9 +1811,9 @@ fi > > ########################################## > # glib support probe > -if $pkg_config --modversion gthread-2.0 gio-2.0> /dev/null 2>&1 ; then > - glib_cflags=`$pkg_config --cflags gthread-2.0 gio-2.0 2>/dev/null` > - glib_libs=`$pkg_config --libs gthread-2.0 gio-2.0 2>/dev/null` > +if $pkg_config --modversion glib-2.0> /dev/null 2>&1 ; then > + glib_cflags=`$pkg_config --cflags glib-2.0 2>/dev/null` > + glib_libs=`$pkg_config --libs glib-2.0 2>/dev/null` > libs_softmmu="$glib_libs $libs_softmmu" > libs_tools="$glib_libs $libs_tools" > else > diff --git a/qemu-ga.c b/qemu-ga.c > index 6e2f61f..5d8b7cf 100644 > --- a/qemu-ga.c > +++ b/qemu-ga.c > @@ -14,7 +14,6 @@ > #include > #include > #include > -#include > #include > #include > #include > @@ -37,9 +36,8 @@ > struct GAState { > JSONMessageParser parser; > GMainLoop *main_loop; > - GSocket *conn_sock; > + int conn_fd; > GIOChannel *conn_channel; > - GSocket *listen_sock; > GIOChannel *listen_channel; > const char *path; > const char *method; > @@ -412,18 +410,19 @@ static gboolean listen_channel_accept(GIOChannel *channel, > GIOCondition condition, gpointer data) > { > GAState *s = data; > - GError *err = NULL; > g_assert(channel != NULL); > int ret; > bool accepted = false; > + struct sockaddr_un addr; > + socklen_t addrlen = sizeof(addr); > > - s->conn_sock = g_socket_accept(s->listen_sock, NULL,&err); > - if (err != NULL) { > - g_warning("error converting fd to gsocket: %s", err->message); > - g_error_free(err); > + s->conn_fd = qemu_accept(g_io_channel_unix_get_fd(s->listen_channel), > + (struct sockaddr *)&addr,&addrlen); > + if (s->conn_fd == -1) { > + g_warning("error converting fd to gsocket: %s", strerror(errno)); > goto out; > } > - ret = conn_channel_add(s, g_socket_get_fd(s->conn_sock)); > + ret = conn_channel_add(s, s->conn_fd); > if (ret) { > g_warning("error setting up connection"); > goto out; > @@ -440,19 +439,8 @@ out: > */ > static int listen_channel_add(GAState *s, int listen_fd, bool new) > { > - GError *err = NULL; > - > if (new) { > s->listen_channel = g_io_channel_unix_new(listen_fd); > - if (s->listen_sock) { > - g_object_unref(s->listen_sock); > - } > - s->listen_sock = g_socket_new_from_fd(listen_fd,&err); > - if (err != NULL) { > - g_warning("error converting fd to gsocket: %s", err->message); > - g_error_free(err); > - return -1; > - } > } > g_io_add_watch(s->listen_channel, G_IO_IN, > listen_channel_accept, s); > @@ -466,8 +454,7 @@ static void conn_channel_close(GAState *s) > { > if (strcmp(s->method, "unix-listen") == 0) { > g_io_channel_shutdown(s->conn_channel, true, NULL); > - g_object_unref(s->conn_sock); > - s->conn_sock = NULL; > + s->conn_fd = -1; > listen_channel_add(s, 0, false); > } else if (strcmp(s->method, "virtio-serial") == 0) { > /* we spin on EOF for virtio-serial, so back off a bit. also, > @@ -624,9 +611,6 @@ int main(int argc, char **argv) > become_daemon(pidfile); > } > > - g_type_init(); > - g_thread_init(NULL); > - > s = qemu_mallocz(sizeof(GAState)); > s->conn_channel = NULL; > s->path = path; Was getting hangs when using -m unix-listen. Looks like GSocket must've been setting O_NONBLOCK on new connections. Also the conn_sock was only part of GAState for cleanup purposes, so we can lose conn_fd. I sent a re-spin with these changes as a reply to this patch.