summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2010-08-27 14:09:56 +0200
committerGerd Hoffmann <kraxel@redhat.com>2010-10-08 12:49:51 +0200
commit33deca4830a2a77f60b4bf45ad6f8b4568a57541 (patch)
treeef2480486fd983d21a1d78d200c06fa09bfbbc20 /ui
parent04adc0c42c1370a235a079b4f1169eb7ab7dc8af (diff)
downloadqemu-33deca4830a2a77f60b4bf45ad6f8b4568a57541.tar.gz
qemu-33deca4830a2a77f60b4bf45ad6f8b4568a57541.tar.bz2
qemu-33deca4830a2a77f60b4bf45ad6f8b4568a57541.zip
spice: add config options for channel security.
This allows to enforce tls or plaintext usage for certain spice channels. [ v2: code style fixup ]
Diffstat (limited to 'ui')
-rw-r--r--ui/spice-core.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 156704681c..7664ef7700 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -192,6 +192,32 @@ static const char *wan_compression_names[] = {
/* functions for the rest of qemu */
+static int add_channel(const char *name, const char *value, void *opaque)
+{
+ int security = 0;
+ int rc;
+
+ if (strcmp(name, "tls-channel") == 0) {
+ security = SPICE_CHANNEL_SECURITY_SSL;
+ }
+ if (strcmp(name, "plaintext-channel") == 0) {
+ security = SPICE_CHANNEL_SECURITY_NONE;
+ }
+ if (security == 0) {
+ return 0;
+ }
+ if (strcmp(value, "default") == 0) {
+ rc = spice_server_set_channel_security(spice_server, NULL, security);
+ } else {
+ rc = spice_server_set_channel_security(spice_server, value, security);
+ }
+ if (rc != 0) {
+ fprintf(stderr, "spice: failed to set channel security for %s\n", value);
+ exit(1);
+ }
+ return 0;
+}
+
void qemu_spice_init(void)
{
QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);
@@ -293,6 +319,8 @@ void qemu_spice_init(void)
}
spice_server_set_zlib_glz_compression(spice_server, wan_compr);
+ qemu_opt_foreach(opts, add_channel, NULL, 0);
+
spice_server_init(spice_server, &core_interface);
using_spice = 1;