summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2012-03-02 13:45:15 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2012-05-28 13:09:20 +0200
commitb8c928ccd810a46794f77746377e614f90d37a5b (patch)
treeabaedab96d9845e46fc5c7202fe88dae8420e152
parente9a4832f2f82ac99468df60ea43da45e8fd8769f (diff)
downloadspice-b8c928ccd810a46794f77746377e614f90d37a5b.tar.gz
spice-b8c928ccd810a46794f77746377e614f90d37a5b.tar.xz
spice-b8c928ccd810a46794f77746377e614f90d37a5b.zip
Send name & uuid to capable clients
Add spice_server_set_name() and spice_server_set_uuid() that allows the client to identify a Spice server (useful to associate settings with a particular server) The SPICE_MSG_MAIN_NAME and SPICE_MSG_MAIN_UUID messages are only sent to capable clients, announcing SPICE_MAIN_CAP_NAME_AND_UUID. Conflicts: spice-protocol
-rw-r--r--common/messages.h9
-rw-r--r--configure.ac2
-rw-r--r--python_modules/demarshal.py2
-rw-r--r--server/main_channel.c65
-rw-r--r--server/main_channel.h3
-rw-r--r--server/reds.c20
-rw-r--r--server/reds.h1
-rw-r--r--server/spice-server.syms6
-rw-r--r--server/spice.h5
-rw-r--r--spice.proto10
10 files changed, 120 insertions, 3 deletions
diff --git a/common/messages.h b/common/messages.h
index a54190f3..ec58da55 100644
--- a/common/messages.h
+++ b/common/messages.h
@@ -149,6 +149,15 @@ typedef struct SpiceMsgChannels {
SpiceChannelId channels[0];
} SpiceMsgChannels;
+typedef struct SpiceMsgMainName {
+ uint32_t name_len;
+ uint8_t name[0];
+} SpiceMsgMainName;
+
+typedef struct SpiceMsgMainUuid {
+ uint8_t uuid[16];
+} SpiceMsgMainUuid;
+
typedef struct SpiceMsgMainMouseMode {
uint32_t supported_modes;
uint32_t current_mode;
diff --git a/configure.ac b/configure.ac
index 0f8ad7df..b92c1546 100644
--- a/configure.ac
+++ b/configure.ac
@@ -132,7 +132,7 @@ AM_CONDITIONAL(SUPPORT_CLIENT, test "x$enable_client" = "xyes")
dnl =========================================================================
dnl Check deps
-PKG_CHECK_MODULES(PROTOCOL, spice-protocol >= 0.10.1)
+PKG_CHECK_MODULES(PROTOCOL, spice-protocol >= 0.10.3)
AC_SUBST(PROTOCOL_CFLAGS)
AC_CHECK_LIBM
diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 3a0178ed..541735a5 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -664,7 +664,7 @@ def read_array_len(writer, prefix, array, dest, scope, is_ptr):
nelements = "%s__array__nelements" % prefix
else:
nelements = "%s__nelements" % prefix
- if dest.is_toplevel():
+ if dest.is_toplevel() and scope.variable_defined(nelements):
return nelements # Already there for toplevel, need not recalculate
element_type = array.element_type
scope.variable_def("uint32_t", nelements)
diff --git a/server/main_channel.c b/server/main_channel.c
index f7e1ab03..9998c9f7 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -105,6 +105,16 @@ typedef struct InitPipeItem {
int ram_hint;
} InitPipeItem;
+typedef struct NamePipeItem {
+ PipeItem base;
+ SpiceMsgMainName msg;
+} NamePipeItem;
+
+typedef struct UuidPipeItem {
+ PipeItem base;
+ SpiceMsgMainUuid msg;
+} UuidPipeItem;
+
typedef struct NotifyPipeItem {
PipeItem base;
uint8_t *mess;
@@ -269,6 +279,29 @@ static PipeItem *main_init_item_new(MainChannelClient *mcc,
return &item->base;
}
+static PipeItem *main_name_item_new(MainChannelClient *mcc, const char *name)
+{
+ NamePipeItem *item = spice_malloc(sizeof(NamePipeItem) + strlen(name) + 1);
+
+ red_channel_pipe_item_init(mcc->base.channel, &item->base,
+ SPICE_MSG_MAIN_NAME);
+ item->msg.name_len = strlen(name) + 1;
+ memcpy(&item->msg.name, name, item->msg.name_len);
+
+ return &item->base;
+}
+
+static PipeItem *main_uuid_item_new(MainChannelClient *mcc, const uint8_t uuid[16])
+{
+ UuidPipeItem *item = spice_malloc(sizeof(UuidPipeItem));
+
+ red_channel_pipe_item_init(mcc->base.channel, &item->base,
+ SPICE_MSG_MAIN_UUID);
+ memcpy(item->msg.uuid, uuid, sizeof(item->msg.uuid));
+
+ return &item->base;
+}
+
typedef struct NotifyPipeInfo {
uint8_t *mess;
int mess_len;
@@ -503,6 +536,30 @@ static void main_channel_marshall_init(SpiceMarshaller *m,
spice_marshall_msg_main_init(m, &init);
}
+void main_channel_push_name(MainChannelClient *mcc, const char *name)
+{
+ PipeItem *item;
+
+ if (!red_channel_client_test_remote_cap(&mcc->base,
+ SPICE_MAIN_CAP_NAME_AND_UUID))
+ return;
+
+ item = main_name_item_new(mcc, name);
+ red_channel_client_pipe_add_push(&mcc->base, item);
+}
+
+void main_channel_push_uuid(MainChannelClient *mcc, const uint8_t uuid[16])
+{
+ PipeItem *item;
+
+ if (!red_channel_client_test_remote_cap(&mcc->base,
+ SPICE_MAIN_CAP_NAME_AND_UUID))
+ return;
+
+ item = main_uuid_item_new(mcc, uuid);
+ red_channel_client_pipe_add_push(&mcc->base, item);
+}
+
// TODO - some notifications are new client only (like "keyboard is insecure" on startup)
void main_channel_push_notify(MainChannel *main_chan, uint8_t *mess, const int mess_len)
{
@@ -694,6 +751,14 @@ static void main_channel_send_item(RedChannelClient *rcc, PipeItem *base)
case SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST:
main_channel_marshall_migrate_switch(m, rcc);
break;
+ case SPICE_MSG_MAIN_NAME:
+ spice_marshall_msg_main_name(m, &SPICE_CONTAINEROF(base, NamePipeItem, base)->msg);
+ break;
+ case SPICE_MSG_MAIN_UUID:
+ spice_marshall_msg_main_uuid(m, &SPICE_CONTAINEROF(base, UuidPipeItem, base)->msg);
+ break;
+ default:
+ break;
};
red_channel_client_begin_send_message(rcc);
}
diff --git a/server/main_channel.h b/server/main_channel.h
index c5d407ec..afff3139 100644
--- a/server/main_channel.h
+++ b/server/main_channel.h
@@ -103,4 +103,7 @@ int main_channel_migrate_connect(MainChannel *main_channel, RedsMigSpice *mig_ta
void main_channel_migrate_cancel_wait(MainChannel *main_chan);
/* returns the number of clients for which SPICE_MSG_MAIN_MIGRATE_END was sent*/
int main_channel_migrate_complete(MainChannel *main_chan, int success);
+void main_channel_push_name(MainChannelClient *mcc, const char *name);
+void main_channel_push_uuid(MainChannelClient *mcc, const uint8_t uuid[16]);
+
#endif
diff --git a/server/reds.c b/server/reds.c
index 8cc87c25..d095370c 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -34,6 +34,7 @@
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
+#include <stdbool.h>
#include <openssl/bio.h>
#include <openssl/pem.h>
@@ -99,6 +100,9 @@ static int sasl_enabled = 0; // sasl disabled by default
#if HAVE_SASL
static char *sasl_appname = NULL; // default to "spice" if NULL
#endif
+static char *spice_name = NULL;
+static bool spice_uuid_is_set = FALSE;
+static uint8_t spice_uuid[16] = { 0, };
static int ticketing_enabled = 1; //Ticketing is enabled by default
static pthread_mutex_t *lock_cs;
@@ -1643,6 +1647,10 @@ static void reds_handle_main_link(RedLinkInfo *link)
reds->mouse_mode, reds->is_client_mouse_allowed,
reds_get_mm_time() - MM_TIME_DELTA,
red_dispatcher_qxl_ram_size());
+ if (spice_name)
+ main_channel_push_name(mcc, spice_name);
+ if (spice_uuid_is_set)
+ main_channel_push_uuid(mcc, spice_uuid);
main_channel_client_start_net_test(mcc);
/* Now that we have a client, forward any pending agent data */
@@ -3774,6 +3782,18 @@ SPICE_GNUC_VISIBLE int spice_server_set_sasl_appname(SpiceServer *s, const char
#endif
}
+SPICE_GNUC_VISIBLE void spice_server_set_name(SpiceServer *s, const char *name)
+{
+ free(spice_name);
+ spice_name = strdup(name);
+}
+
+SPICE_GNUC_VISIBLE void spice_server_set_uuid(SpiceServer *s, const uint8_t uuid[16])
+{
+ memcpy(spice_uuid, uuid, sizeof(spice_uuid));
+ spice_uuid_is_set = TRUE;
+}
+
SPICE_GNUC_VISIBLE int spice_server_set_ticket(SpiceServer *s,
const char *passwd, int lifetime,
int fail_if_connected,
diff --git a/server/reds.h b/server/reds.h
index 1fd18a70..1c59e689 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -152,4 +152,5 @@ void reds_on_main_migrate_connected(void); //should be called when all the clien
void reds_on_main_receive_migrate_data(MainMigrateData *data, uint8_t *end);
void reds_on_main_mouse_mode_request(void *message, size_t size);
void reds_on_client_migrate_complete(RedClient *client);
+
#endif
diff --git a/server/spice-server.syms b/server/spice-server.syms
index d9beec35..272548ed 100644
--- a/server/spice-server.syms
+++ b/server/spice-server.syms
@@ -101,3 +101,9 @@ global:
spice_server_add_client;
spice_server_add_ssl_client;
} SPICE_SERVER_0.10.0;
+
+SPICE_SERVER_0.10.2 {
+global:
+ spice_server_set_name;
+ spice_server_set_uuid;
+} SPICE_SERVER_0.10.1;
diff --git a/server/spice.h b/server/spice.h
index 73976557..151b3db0 100644
--- a/server/spice.h
+++ b/server/spice.h
@@ -22,7 +22,7 @@
#include <sys/socket.h>
#include <spice/qxl_dev.h>
-#define SPICE_SERVER_VERSION 0x000a01 /* release 0.10.1 */
+#define SPICE_SERVER_VERSION 0x000a02 /* release 0.10.2 */
/* interface base type */
@@ -519,4 +519,7 @@ int spice_server_migrate_connect(SpiceServer *s, const char* dest,
int spice_server_migrate_start(SpiceServer *s);
int spice_server_migrate_end(SpiceServer *s, int completed);
+void spice_server_set_name(SpiceServer *s, const char *name);
+void spice_server_set_uuid(SpiceServer *s, const uint8_t uuid[16]);
+
#endif
diff --git a/spice.proto b/spice.proto
index 0e15fe72..ae27c8d0 100644
--- a/spice.proto
+++ b/spice.proto
@@ -134,6 +134,7 @@ channel BaseChannel {
} notify;
Data list; /* the msg body is SpiceSubMessageList */
+
client:
message {
uint32 generation;
@@ -222,6 +223,15 @@ channel MainChannel : BaseChannel {
Empty migrate_end;
+ message {
+ uint32 name_len;
+ uint8 name[name_len];
+ } name;
+
+ message {
+ uint8 uuid[16];
+ } uuid;
+
client:
message {
uint64 cache_size;