qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] qemu-ga: remove dependency on gio and gthread
@ 2011-07-23 21:26 Anthony Liguori
  2011-07-23 21:26 ` [Qemu-devel] [PATCH 2/2] guest-agent: only enable FSFREEZE when it's supported by the kernel Anthony Liguori
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Anthony Liguori @ 2011-07-23 21:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony Liguori, Mike Roth, Alex Graf

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 <aliguori@us.ibm.com>
---
 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 <stdio.h>
 #include <stdbool.h>
 #include <glib.h>
-#include <gio/gio.h>
 #include <getopt.h>
 #include <termios.h>
 #include <syslog.h>
@@ -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;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 2/2] guest-agent: only enable FSFREEZE when it's supported by the kernel
  2011-07-23 21:26 [Qemu-devel] [PATCH 1/2] qemu-ga: remove dependency on gio and gthread Anthony Liguori
@ 2011-07-23 21:26 ` Anthony Liguori
  2011-07-23 23:01   ` Michael Roth
  2011-07-23 22:57 ` [Qemu-devel] [PATCH] qemu-ga: remove dependency on gio and gthread Michael Roth
  2011-07-23 23:00 ` [Qemu-devel] [PATCH 1/2] " Michael Roth
  2 siblings, 1 reply; 5+ messages in thread
From: Anthony Liguori @ 2011-07-23 21:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony Liguori, Mike Roth, Alex Graf

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 qga/guest-agent-commands.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/qga/guest-agent-commands.c b/qga/guest-agent-commands.c
index 624972e..30c4068 100644
--- a/qga/guest-agent-commands.c
+++ b/qga/guest-agent-commands.c
@@ -10,15 +10,17 @@
  * See the COPYING file in the top-level directory.
  */
 
-#if defined(__linux__)
-#define CONFIG_FSFREEZE
-#endif
-
 #include <glib.h>
-#if defined(CONFIG_FSFREEZE)
+
+#if defined(__linux__)
 #include <mntent.h>
 #include <linux/fs.h>
+
+#if defined(__linux__) && defined(FIFREEZE)
+#define CONFIG_FSFREEZE
 #endif
+#endif
+
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include "qga/guest-agent-core.h"
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH] qemu-ga: remove dependency on gio and gthread
  2011-07-23 21:26 [Qemu-devel] [PATCH 1/2] qemu-ga: remove dependency on gio and gthread Anthony Liguori
  2011-07-23 21:26 ` [Qemu-devel] [PATCH 2/2] guest-agent: only enable FSFREEZE when it's supported by the kernel Anthony Liguori
@ 2011-07-23 22:57 ` Michael Roth
  2011-07-23 23:00 ` [Qemu-devel] [PATCH 1/2] " Michael Roth
  2 siblings, 0 replies; 5+ messages in thread
From: Michael Roth @ 2011-07-23 22:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, agraf

From: Anthony Liguori <aliguori@us.ibm.com>

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 <aliguori@us.ibm.com>
---
 configure |    6 +++---
 qemu-ga.c |   35 +++++++++--------------------------
 2 files changed, 12 insertions(+), 29 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..869ee37 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -14,7 +14,6 @@
 #include <stdio.h>
 #include <stdbool.h>
 #include <glib.h>
-#include <gio/gio.h>
 #include <getopt.h>
 #include <termios.h>
 #include <syslog.h>
@@ -37,9 +36,7 @@
 struct GAState {
     JSONMessageParser parser;
     GMainLoop *main_loop;
-    GSocket *conn_sock;
     GIOChannel *conn_channel;
-    GSocket *listen_sock;
     GIOChannel *listen_channel;
     const char *path;
     const char *method;
@@ -412,18 +409,20 @@ static gboolean listen_channel_accept(GIOChannel *channel,
                                       GIOCondition condition, gpointer data)
 {
     GAState *s = data;
-    GError *err = NULL;
     g_assert(channel != NULL);
-    int ret;
+    int ret, conn_fd;
     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);
+    conn_fd = qemu_accept(g_io_channel_unix_get_fd(s->listen_channel),
+                             (struct sockaddr *)&addr, &addrlen);
+    if (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));
+    fcntl(conn_fd, F_SETFL, O_NONBLOCK);
+    ret = conn_channel_add(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,6 @@ 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;
         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 +610,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;
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] qemu-ga: remove dependency on gio and gthread
  2011-07-23 21:26 [Qemu-devel] [PATCH 1/2] qemu-ga: remove dependency on gio and gthread Anthony Liguori
  2011-07-23 21:26 ` [Qemu-devel] [PATCH 2/2] guest-agent: only enable FSFREEZE when it's supported by the kernel Anthony Liguori
  2011-07-23 22:57 ` [Qemu-devel] [PATCH] qemu-ga: remove dependency on gio and gthread Michael Roth
@ 2011-07-23 23:00 ` Michael Roth
  2 siblings, 0 replies; 5+ messages in thread
From: Michael Roth @ 2011-07-23 23:00 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, 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<aliguori@us.ibm.com>
> ---
>   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<stdio.h>
>   #include<stdbool.h>
>   #include<glib.h>
> -#include<gio/gio.h>
>   #include<getopt.h>
>   #include<termios.h>
>   #include<syslog.h>
> @@ -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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] guest-agent: only enable FSFREEZE when it's supported by the kernel
  2011-07-23 21:26 ` [Qemu-devel] [PATCH 2/2] guest-agent: only enable FSFREEZE when it's supported by the kernel Anthony Liguori
@ 2011-07-23 23:01   ` Michael Roth
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Roth @ 2011-07-23 23:01 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, Alex Graf

On 07/23/2011 04:26 PM, Anthony Liguori wrote:
> Signed-off-by: Anthony Liguori<aliguori@us.ibm.com>
> ---
>   qga/guest-agent-commands.c |   12 +++++++-----
>   1 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/qga/guest-agent-commands.c b/qga/guest-agent-commands.c
> index 624972e..30c4068 100644
> --- a/qga/guest-agent-commands.c
> +++ b/qga/guest-agent-commands.c
> @@ -10,15 +10,17 @@
>    * See the COPYING file in the top-level directory.
>    */
>
> -#if defined(__linux__)
> -#define CONFIG_FSFREEZE
> -#endif
> -
>   #include<glib.h>
> -#if defined(CONFIG_FSFREEZE)
> +
> +#if defined(__linux__)
>   #include<mntent.h>
>   #include<linux/fs.h>
> +
> +#if defined(__linux__)&&  defined(FIFREEZE)
> +#define CONFIG_FSFREEZE
>   #endif
> +#endif
> +
>   #include<sys/types.h>
>   #include<sys/ioctl.h>
>   #include "qga/guest-agent-core.h"

Much more sensible that the compile test I was doing :)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-07-23 23:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-23 21:26 [Qemu-devel] [PATCH 1/2] qemu-ga: remove dependency on gio and gthread Anthony Liguori
2011-07-23 21:26 ` [Qemu-devel] [PATCH 2/2] guest-agent: only enable FSFREEZE when it's supported by the kernel Anthony Liguori
2011-07-23 23:01   ` Michael Roth
2011-07-23 22:57 ` [Qemu-devel] [PATCH] qemu-ga: remove dependency on gio and gthread Michael Roth
2011-07-23 23:00 ` [Qemu-devel] [PATCH 1/2] " Michael Roth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).