diff options
author | Nahum Shalman <nshalman@elys.com> | 2012-03-12 12:33:20 +0100 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2012-03-12 12:33:20 +0100 |
commit | 198ffb92d482fd01af8a774788afa3931721b714 (patch) | |
tree | 272664fa822be7290afe149cb2382ca588cdf15d /server/reds.c | |
parent | 20c7323c9efb22c1aae37557814f21cf58c2a322 (diff) | |
download | spice-198ffb92d482fd01af8a774788afa3931721b714.tar.gz spice-198ffb92d482fd01af8a774788afa3931721b714.tar.xz spice-198ffb92d482fd01af8a774788afa3931721b714.zip |
server: listen on a pre-opened file descriptor
Allow applications to pre-open a file descriptor and have spice listen
on it.
Thanks to Daniel Berrange for his comments
Diffstat (limited to 'server/reds.c')
-rw-r--r-- | server/reds.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/server/reds.c b/server/reds.c index 5fc03ea2..dc009f4b 100644 --- a/server/reds.c +++ b/server/reds.c @@ -94,6 +94,7 @@ static SpiceMigrateInstance *migration_interface = NULL; static int spice_port = -1; static int spice_secure_port = -1; +static int spice_listen_socket_fd = -1; static char spice_addr[256]; static int spice_family = PF_UNSPEC; static char *default_renderer = "sw"; @@ -2995,6 +2996,19 @@ static int reds_init_net(void) red_error("set fd handle failed"); } } + + if (spice_listen_socket_fd != -1 ) { + reds->listen_socket = spice_listen_socket_fd; + if (-1 == reds->listen_socket) { + return -1; + } + reds->listen_watch = core->watch_add(reds->listen_socket, + SPICE_WATCH_EVENT_READ, + reds_accept, NULL); + if (reds->listen_watch == NULL) { + red_error("set fd handle failed"); + } + } return 0; } @@ -3787,6 +3801,13 @@ SPICE_GNUC_VISIBLE void spice_server_set_addr(SpiceServer *s, const char *addr, } } +SPICE_GNUC_VISIBLE int spice_server_set_listen_socket_fd(SpiceServer *s, int listen_fd) +{ + ASSERT(reds == s); + spice_listen_socket_fd = listen_fd; + return 0; +} + SPICE_GNUC_VISIBLE int spice_server_set_noauth(SpiceServer *s) { ASSERT(reds == s); |