[Spice-devel] [PATCH 2/2] server: support listening on a UNIX socket
Daniel P. Berrange
berrange at redhat.com
Fri Mar 9 08:26:47 PST 2012
On Fri, Mar 09, 2012 at 10:39:22AM -0500, Nahum Shalman wrote:
> We leave all the hard work of setting up the socket to qemu.
> This will cause all of the TCP setsockopt calls to return ENOSUP
> but that is okay.
> ---
> server/reds.c | 21 +++++++++++++++++++++
> server/spice-server.syms | 1 +
> server/spice.h | 1 +
> 3 files changed, 23 insertions(+), 0 deletions(-)
>
> diff --git a/server/reds.c b/server/reds.c
> index 5fc03ea..7f9ffcc 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_unix_socket = -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_unix_socket != -1 ) {
> + reds->listen_socket = spice_unix_socket;
> + 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_unix_socket(SpiceServer *s, int unix_socket)
> +{
> + ASSERT(reds == s);
> + spice_unix_socket = unix_socket;
> + return 0;
> +}
> +
> SPICE_GNUC_VISIBLE int spice_server_set_noauth(SpiceServer *s)
> {
> ASSERT(reds == s);
> diff --git a/server/spice-server.syms b/server/spice-server.syms
> index 272548e..51c6ffa 100644
> --- a/server/spice-server.syms
> +++ b/server/spice-server.syms
> @@ -106,4 +106,5 @@ SPICE_SERVER_0.10.2 {
> global:
> spice_server_set_name;
> spice_server_set_uuid;
> + spice_server_set_unix_socket;
> } SPICE_SERVER_0.10.1;
> diff --git a/server/spice.h b/server/spice.h
> index 151b3db..7ace03b 100644
> --- a/server/spice.h
> +++ b/server/spice.h
> @@ -421,6 +421,7 @@ int spice_server_set_compat_version(SpiceServer *s,
> spice_compat_version_t version);
> int spice_server_set_port(SpiceServer *s, int port);
> void spice_server_set_addr(SpiceServer *s, const char *addr, int flags);
> +int spice_server_set_unix_socket(SpiceServer *s, int unix_socket);
If you're going to just pass in a pre-opened file descriptor, then
there is no reason to presume it will be a UNIX socket. You could
easily let an app pass in a TCP socket it has pre-opened. So this
method is better named
int spice_server_set_listen_socket_fd(SpiceServer *s, int listen_fd);
Leaving the name spice_server_set_unix_addr() for a method that takes
a real unix socket path string.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the Spice-devel
mailing list