summaryrefslogtreecommitdiff
path: root/qemu-ga.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-07-23 17:57:47 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2011-07-23 18:24:14 -0500
commit1fc7bd4a86a2bfeafcec29445871eb97469a2699 (patch)
tree1a084171090114c87821b085db2cf5defa776801 /qemu-ga.c
parent4eb36d40da8062400a2e7e27f1038e1252df9ede (diff)
qemu-ga: remove dependency on gio and gthread
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>
Diffstat (limited to 'qemu-ga.c')
-rw-r--r--qemu-ga.c35
1 files changed, 9 insertions, 26 deletions
diff --git a/qemu-ga.c b/qemu-ga.c
index 6e2f61fe3c..869ee3709b 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;