Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 Red Hat, Inc. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License as |
| 6 | * published by the Free Software Foundation; either version 2 or |
| 7 | * (at your option) version 3 of the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #include <spice.h> |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 19 | |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 20 | #include <netdb.h> |
Paolo Bonzini | 9c17d61 | 2012-12-17 18:20:04 +0100 | [diff] [blame] | 21 | #include "sysemu/sysemu.h" |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 22 | |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 23 | #include "qemu-common.h" |
Paolo Bonzini | 28ecbae | 2012-11-28 12:06:30 +0100 | [diff] [blame] | 24 | #include "ui/qemu-spice.h" |
Paolo Bonzini | 1de7afc | 2012-12-17 18:20:00 +0100 | [diff] [blame] | 25 | #include "qemu/thread.h" |
| 26 | #include "qemu/timer.h" |
| 27 | #include "qemu/queue.h" |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 28 | #include "qemu-x509.h" |
Paolo Bonzini | 1de7afc | 2012-12-17 18:20:00 +0100 | [diff] [blame] | 29 | #include "qemu/sockets.h" |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 30 | #include "qmp-commands.h" |
Paolo Bonzini | 7b1b5d1 | 2012-12-17 18:19:43 +0100 | [diff] [blame] | 31 | #include "qapi/qmp/qint.h" |
| 32 | #include "qapi/qmp/qbool.h" |
| 33 | #include "qapi/qmp/qstring.h" |
| 34 | #include "qapi/qmp/qjson.h" |
Paolo Bonzini | 1de7afc | 2012-12-17 18:20:00 +0100 | [diff] [blame] | 35 | #include "qemu/notify.h" |
Paolo Bonzini | caf71f8 | 2012-12-17 18:19:50 +0100 | [diff] [blame] | 36 | #include "migration/migration.h" |
Gerd Hoffmann | e866e23 | 2010-04-23 13:28:21 +0200 | [diff] [blame] | 37 | #include "hw/hw.h" |
Paolo Bonzini | 28ecbae | 2012-11-28 12:06:30 +0100 | [diff] [blame] | 38 | #include "ui/spice-display.h" |
Wenchao Xia | 7cfadb6 | 2014-06-18 08:43:50 +0200 | [diff] [blame] | 39 | #include "qapi-event.h" |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 40 | |
| 41 | /* core bits */ |
| 42 | |
| 43 | static SpiceServer *spice_server; |
Gerd Hoffmann | e866e23 | 2010-04-23 13:28:21 +0200 | [diff] [blame] | 44 | static Notifier migration_state; |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 45 | static const char *auth = "spice"; |
Gerd Hoffmann | 7572150 | 2010-10-07 12:22:54 +0200 | [diff] [blame] | 46 | static char *auth_passwd; |
| 47 | static time_t auth_expires = TIME_MAX; |
Yonit Halperin | 61c4efe | 2012-08-21 11:51:58 +0300 | [diff] [blame] | 48 | static int spice_migration_completed; |
Gerd Hoffmann | 7cc6a25 | 2013-12-09 15:54:46 +0100 | [diff] [blame] | 49 | static int spice_display_is_running; |
Gerd Hoffmann | a76a2f7 | 2014-04-29 09:27:31 +0200 | [diff] [blame] | 50 | static int spice_have_target_host; |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 51 | int using_spice = 0; |
| 52 | |
Jan Kiszka | f9ab609 | 2011-09-20 17:14:33 +0200 | [diff] [blame] | 53 | static QemuThread me; |
Gerd Hoffmann | 22b626e | 2011-09-02 15:03:28 +0200 | [diff] [blame] | 54 | |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 55 | struct SpiceTimer { |
| 56 | QEMUTimer *timer; |
| 57 | QTAILQ_ENTRY(SpiceTimer) next; |
| 58 | }; |
| 59 | static QTAILQ_HEAD(, SpiceTimer) timers = QTAILQ_HEAD_INITIALIZER(timers); |
| 60 | |
| 61 | static SpiceTimer *timer_add(SpiceTimerFunc func, void *opaque) |
| 62 | { |
| 63 | SpiceTimer *timer; |
| 64 | |
Anthony Liguori | 7267c09 | 2011-08-20 22:09:37 -0500 | [diff] [blame] | 65 | timer = g_malloc0(sizeof(*timer)); |
Alex Bligh | bc72ad6 | 2013-08-21 16:03:08 +0100 | [diff] [blame] | 66 | timer->timer = timer_new_ms(QEMU_CLOCK_REALTIME, func, opaque); |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 67 | QTAILQ_INSERT_TAIL(&timers, timer, next); |
| 68 | return timer; |
| 69 | } |
| 70 | |
| 71 | static void timer_start(SpiceTimer *timer, uint32_t ms) |
| 72 | { |
Alex Bligh | bc72ad6 | 2013-08-21 16:03:08 +0100 | [diff] [blame] | 73 | timer_mod(timer->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + ms); |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | static void timer_cancel(SpiceTimer *timer) |
| 77 | { |
Alex Bligh | bc72ad6 | 2013-08-21 16:03:08 +0100 | [diff] [blame] | 78 | timer_del(timer->timer); |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | static void timer_remove(SpiceTimer *timer) |
| 82 | { |
Alex Bligh | bc72ad6 | 2013-08-21 16:03:08 +0100 | [diff] [blame] | 83 | timer_del(timer->timer); |
| 84 | timer_free(timer->timer); |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 85 | QTAILQ_REMOVE(&timers, timer, next); |
Anthony Liguori | 7267c09 | 2011-08-20 22:09:37 -0500 | [diff] [blame] | 86 | g_free(timer); |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | struct SpiceWatch { |
| 90 | int fd; |
| 91 | int event_mask; |
| 92 | SpiceWatchFunc func; |
| 93 | void *opaque; |
| 94 | QTAILQ_ENTRY(SpiceWatch) next; |
| 95 | }; |
| 96 | static QTAILQ_HEAD(, SpiceWatch) watches = QTAILQ_HEAD_INITIALIZER(watches); |
| 97 | |
| 98 | static void watch_read(void *opaque) |
| 99 | { |
| 100 | SpiceWatch *watch = opaque; |
| 101 | watch->func(watch->fd, SPICE_WATCH_EVENT_READ, watch->opaque); |
| 102 | } |
| 103 | |
| 104 | static void watch_write(void *opaque) |
| 105 | { |
| 106 | SpiceWatch *watch = opaque; |
| 107 | watch->func(watch->fd, SPICE_WATCH_EVENT_WRITE, watch->opaque); |
| 108 | } |
| 109 | |
| 110 | static void watch_update_mask(SpiceWatch *watch, int event_mask) |
| 111 | { |
| 112 | IOHandler *on_read = NULL; |
| 113 | IOHandler *on_write = NULL; |
| 114 | |
| 115 | watch->event_mask = event_mask; |
| 116 | if (watch->event_mask & SPICE_WATCH_EVENT_READ) { |
| 117 | on_read = watch_read; |
| 118 | } |
| 119 | if (watch->event_mask & SPICE_WATCH_EVENT_WRITE) { |
Hans de Goede | 3d6d306 | 2010-10-15 09:47:53 +0200 | [diff] [blame] | 120 | on_write = watch_write; |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 121 | } |
| 122 | qemu_set_fd_handler(watch->fd, on_read, on_write, watch); |
| 123 | } |
| 124 | |
| 125 | static SpiceWatch *watch_add(int fd, int event_mask, SpiceWatchFunc func, void *opaque) |
| 126 | { |
| 127 | SpiceWatch *watch; |
| 128 | |
Anthony Liguori | 7267c09 | 2011-08-20 22:09:37 -0500 | [diff] [blame] | 129 | watch = g_malloc0(sizeof(*watch)); |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 130 | watch->fd = fd; |
| 131 | watch->func = func; |
| 132 | watch->opaque = opaque; |
| 133 | QTAILQ_INSERT_TAIL(&watches, watch, next); |
| 134 | |
| 135 | watch_update_mask(watch, event_mask); |
| 136 | return watch; |
| 137 | } |
| 138 | |
| 139 | static void watch_remove(SpiceWatch *watch) |
| 140 | { |
Gerd Hoffmann | 08cc67f | 2011-10-21 15:56:21 +0200 | [diff] [blame] | 141 | qemu_set_fd_handler(watch->fd, NULL, NULL, NULL); |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 142 | QTAILQ_REMOVE(&watches, watch, next); |
Anthony Liguori | 7267c09 | 2011-08-20 22:09:37 -0500 | [diff] [blame] | 143 | g_free(watch); |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 144 | } |
| 145 | |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 146 | typedef struct ChannelList ChannelList; |
| 147 | struct ChannelList { |
| 148 | SpiceChannelEventInfo *info; |
| 149 | QTAILQ_ENTRY(ChannelList) link; |
| 150 | }; |
| 151 | static QTAILQ_HEAD(, ChannelList) channel_list = QTAILQ_HEAD_INITIALIZER(channel_list); |
| 152 | |
| 153 | static void channel_list_add(SpiceChannelEventInfo *info) |
| 154 | { |
| 155 | ChannelList *item; |
| 156 | |
Anthony Liguori | 7267c09 | 2011-08-20 22:09:37 -0500 | [diff] [blame] | 157 | item = g_malloc0(sizeof(*item)); |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 158 | item->info = info; |
| 159 | QTAILQ_INSERT_TAIL(&channel_list, item, link); |
| 160 | } |
| 161 | |
| 162 | static void channel_list_del(SpiceChannelEventInfo *info) |
| 163 | { |
| 164 | ChannelList *item; |
| 165 | |
| 166 | QTAILQ_FOREACH(item, &channel_list, link) { |
| 167 | if (item->info != info) { |
| 168 | continue; |
| 169 | } |
| 170 | QTAILQ_REMOVE(&channel_list, item, link); |
Anthony Liguori | 7267c09 | 2011-08-20 22:09:37 -0500 | [diff] [blame] | 171 | g_free(item); |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 172 | return; |
| 173 | } |
| 174 | } |
| 175 | |
Wenchao Xia | 7cfadb6 | 2014-06-18 08:43:50 +0200 | [diff] [blame] | 176 | static void add_addr_info(SpiceBasicInfo *info, struct sockaddr *addr, int len) |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 177 | { |
| 178 | char host[NI_MAXHOST], port[NI_MAXSERV]; |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 179 | |
| 180 | getnameinfo(addr, len, host, sizeof(host), port, sizeof(port), |
| 181 | NI_NUMERICHOST | NI_NUMERICSERV); |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 182 | |
Wenchao Xia | 7cfadb6 | 2014-06-18 08:43:50 +0200 | [diff] [blame] | 183 | info->host = g_strdup(host); |
| 184 | info->port = g_strdup(port); |
| 185 | info->family = inet_netfamily(addr->sa_family); |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 186 | } |
| 187 | |
Wenchao Xia | 7cfadb6 | 2014-06-18 08:43:50 +0200 | [diff] [blame] | 188 | static void add_channel_info(SpiceChannel *sc, SpiceChannelEventInfo *info) |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 189 | { |
| 190 | int tls = info->flags & SPICE_CHANNEL_EVENT_FLAG_TLS; |
| 191 | |
Wenchao Xia | 7cfadb6 | 2014-06-18 08:43:50 +0200 | [diff] [blame] | 192 | sc->connection_id = info->connection_id; |
| 193 | sc->channel_type = info->type; |
| 194 | sc->channel_id = info->id; |
| 195 | sc->tls = !!tls; |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | static void channel_event(int event, SpiceChannelEventInfo *info) |
| 199 | { |
Wenchao Xia | 7cfadb6 | 2014-06-18 08:43:50 +0200 | [diff] [blame] | 200 | SpiceServerInfo *server = g_malloc0(sizeof(*server)); |
| 201 | SpiceChannel *client = g_malloc0(sizeof(*client)); |
| 202 | server->base = g_malloc0(sizeof(*server->base)); |
| 203 | client->base = g_malloc0(sizeof(*client->base)); |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 204 | |
Gerd Hoffmann | 22b626e | 2011-09-02 15:03:28 +0200 | [diff] [blame] | 205 | /* |
| 206 | * Spice server might have called us from spice worker thread |
| 207 | * context (happens on display channel disconnects). Spice should |
| 208 | * not do that. It isn't that easy to fix it in spice and even |
| 209 | * when it is fixed we still should cover the already released |
| 210 | * spice versions. So detect that we've been called from another |
| 211 | * thread and grab the iothread lock if so before calling qemu |
| 212 | * functions. |
| 213 | */ |
Jan Kiszka | f9ab609 | 2011-09-20 17:14:33 +0200 | [diff] [blame] | 214 | bool need_lock = !qemu_thread_is_self(&me); |
Gerd Hoffmann | 22b626e | 2011-09-02 15:03:28 +0200 | [diff] [blame] | 215 | if (need_lock) { |
| 216 | qemu_mutex_lock_iothread(); |
| 217 | } |
| 218 | |
Yonit Halperin | faa9822 | 2012-02-08 15:40:15 +0200 | [diff] [blame] | 219 | if (info->flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT) { |
Wenchao Xia | 7cfadb6 | 2014-06-18 08:43:50 +0200 | [diff] [blame] | 220 | add_addr_info(client->base, (struct sockaddr *)&info->paddr_ext, |
Yonit Halperin | faa9822 | 2012-02-08 15:40:15 +0200 | [diff] [blame] | 221 | info->plen_ext); |
Wenchao Xia | 7cfadb6 | 2014-06-18 08:43:50 +0200 | [diff] [blame] | 222 | add_addr_info(server->base, (struct sockaddr *)&info->laddr_ext, |
Yonit Halperin | faa9822 | 2012-02-08 15:40:15 +0200 | [diff] [blame] | 223 | info->llen_ext); |
| 224 | } else { |
Christophe Fergeau | 339a475 | 2012-02-24 18:13:12 +0100 | [diff] [blame] | 225 | error_report("spice: %s, extended address is expected", |
| 226 | __func__); |
Yonit Halperin | faa9822 | 2012-02-08 15:40:15 +0200 | [diff] [blame] | 227 | } |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 228 | |
Wenchao Xia | 7cfadb6 | 2014-06-18 08:43:50 +0200 | [diff] [blame] | 229 | switch (event) { |
| 230 | case SPICE_CHANNEL_EVENT_CONNECTED: |
| 231 | qapi_event_send_spice_connected(server->base, client->base, &error_abort); |
| 232 | break; |
| 233 | case SPICE_CHANNEL_EVENT_INITIALIZED: |
| 234 | if (auth) { |
| 235 | server->has_auth = true; |
| 236 | server->auth = g_strdup(auth); |
| 237 | } |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 238 | add_channel_info(client, info); |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 239 | channel_list_add(info); |
Wenchao Xia | 7cfadb6 | 2014-06-18 08:43:50 +0200 | [diff] [blame] | 240 | qapi_event_send_spice_initialized(server, client, &error_abort); |
| 241 | break; |
| 242 | case SPICE_CHANNEL_EVENT_DISCONNECTED: |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 243 | channel_list_del(info); |
Wenchao Xia | 7cfadb6 | 2014-06-18 08:43:50 +0200 | [diff] [blame] | 244 | qapi_event_send_spice_disconnected(server->base, client->base, &error_abort); |
| 245 | break; |
| 246 | default: |
| 247 | break; |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 248 | } |
| 249 | |
Gerd Hoffmann | 22b626e | 2011-09-02 15:03:28 +0200 | [diff] [blame] | 250 | if (need_lock) { |
| 251 | qemu_mutex_unlock_iothread(); |
| 252 | } |
Wenchao Xia | 7cfadb6 | 2014-06-18 08:43:50 +0200 | [diff] [blame] | 253 | |
| 254 | qapi_free_SpiceServerInfo(server); |
| 255 | qapi_free_SpiceChannel(client); |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 256 | } |
| 257 | |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 258 | static SpiceCoreInterface core_interface = { |
| 259 | .base.type = SPICE_INTERFACE_CORE, |
| 260 | .base.description = "qemu core services", |
| 261 | .base.major_version = SPICE_INTERFACE_CORE_MAJOR, |
| 262 | .base.minor_version = SPICE_INTERFACE_CORE_MINOR, |
| 263 | |
| 264 | .timer_add = timer_add, |
| 265 | .timer_start = timer_start, |
| 266 | .timer_cancel = timer_cancel, |
| 267 | .timer_remove = timer_remove, |
| 268 | |
| 269 | .watch_add = watch_add, |
| 270 | .watch_update_mask = watch_update_mask, |
| 271 | .watch_remove = watch_remove, |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 272 | |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 273 | .channel_event = channel_event, |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 274 | }; |
| 275 | |
Yonit Halperin | 026f773 | 2011-10-17 10:03:19 +0200 | [diff] [blame] | 276 | typedef struct SpiceMigration { |
| 277 | SpiceMigrateInstance sin; |
| 278 | struct { |
| 279 | MonitorCompletion *cb; |
| 280 | void *opaque; |
| 281 | } connect_complete; |
| 282 | } SpiceMigration; |
| 283 | |
| 284 | static void migrate_connect_complete_cb(SpiceMigrateInstance *sin); |
Yonit Halperin | 2fdd16e | 2012-08-21 11:51:57 +0300 | [diff] [blame] | 285 | static void migrate_end_complete_cb(SpiceMigrateInstance *sin); |
Yonit Halperin | 026f773 | 2011-10-17 10:03:19 +0200 | [diff] [blame] | 286 | |
| 287 | static const SpiceMigrateInterface migrate_interface = { |
| 288 | .base.type = SPICE_INTERFACE_MIGRATION, |
| 289 | .base.description = "migration", |
| 290 | .base.major_version = SPICE_INTERFACE_MIGRATION_MAJOR, |
| 291 | .base.minor_version = SPICE_INTERFACE_MIGRATION_MINOR, |
| 292 | .migrate_connect_complete = migrate_connect_complete_cb, |
Yonit Halperin | 2fdd16e | 2012-08-21 11:51:57 +0300 | [diff] [blame] | 293 | .migrate_end_complete = migrate_end_complete_cb, |
Yonit Halperin | 026f773 | 2011-10-17 10:03:19 +0200 | [diff] [blame] | 294 | }; |
| 295 | |
| 296 | static SpiceMigration spice_migrate; |
| 297 | |
| 298 | static void migrate_connect_complete_cb(SpiceMigrateInstance *sin) |
| 299 | { |
| 300 | SpiceMigration *sm = container_of(sin, SpiceMigration, sin); |
| 301 | if (sm->connect_complete.cb) { |
| 302 | sm->connect_complete.cb(sm->connect_complete.opaque, NULL); |
| 303 | } |
| 304 | sm->connect_complete.cb = NULL; |
| 305 | } |
Yonit Halperin | 2fdd16e | 2012-08-21 11:51:57 +0300 | [diff] [blame] | 306 | |
| 307 | static void migrate_end_complete_cb(SpiceMigrateInstance *sin) |
| 308 | { |
Wenchao Xia | 7cfadb6 | 2014-06-18 08:43:50 +0200 | [diff] [blame] | 309 | qapi_event_send_spice_migrate_completed(&error_abort); |
Yonit Halperin | 61c4efe | 2012-08-21 11:51:58 +0300 | [diff] [blame] | 310 | spice_migration_completed = true; |
Yonit Halperin | 2fdd16e | 2012-08-21 11:51:57 +0300 | [diff] [blame] | 311 | } |
Yonit Halperin | 026f773 | 2011-10-17 10:03:19 +0200 | [diff] [blame] | 312 | |
Yonit Halperin | 9f04e09 | 2010-07-14 13:26:34 +0300 | [diff] [blame] | 313 | /* config string parsing */ |
| 314 | |
| 315 | static int name2enum(const char *string, const char *table[], int entries) |
| 316 | { |
| 317 | int i; |
| 318 | |
| 319 | if (string) { |
| 320 | for (i = 0; i < entries; i++) { |
| 321 | if (!table[i]) { |
| 322 | continue; |
| 323 | } |
| 324 | if (strcmp(string, table[i]) != 0) { |
| 325 | continue; |
| 326 | } |
| 327 | return i; |
| 328 | } |
| 329 | } |
| 330 | return -1; |
| 331 | } |
| 332 | |
| 333 | static int parse_name(const char *string, const char *optname, |
| 334 | const char *table[], int entries) |
| 335 | { |
| 336 | int value = name2enum(string, table, entries); |
| 337 | |
| 338 | if (value != -1) { |
| 339 | return value; |
| 340 | } |
Christophe Fergeau | 339a475 | 2012-02-24 18:13:12 +0100 | [diff] [blame] | 341 | error_report("spice: invalid %s: %s", optname, string); |
Yonit Halperin | 9f04e09 | 2010-07-14 13:26:34 +0300 | [diff] [blame] | 342 | exit(1); |
| 343 | } |
| 344 | |
Gerd Hoffmann | 84a23f2 | 2010-08-30 16:36:53 +0200 | [diff] [blame] | 345 | static const char *stream_video_names[] = { |
| 346 | [ SPICE_STREAM_VIDEO_OFF ] = "off", |
| 347 | [ SPICE_STREAM_VIDEO_ALL ] = "all", |
| 348 | [ SPICE_STREAM_VIDEO_FILTER ] = "filter", |
| 349 | }; |
| 350 | #define parse_stream_video(_name) \ |
Christophe Fergeau | 835cab8 | 2012-08-13 10:32:32 +0200 | [diff] [blame] | 351 | parse_name(_name, "stream video control", \ |
| 352 | stream_video_names, ARRAY_SIZE(stream_video_names)) |
Gerd Hoffmann | 84a23f2 | 2010-08-30 16:36:53 +0200 | [diff] [blame] | 353 | |
Yonit Halperin | 9f04e09 | 2010-07-14 13:26:34 +0300 | [diff] [blame] | 354 | static const char *compression_names[] = { |
| 355 | [ SPICE_IMAGE_COMPRESS_OFF ] = "off", |
| 356 | [ SPICE_IMAGE_COMPRESS_AUTO_GLZ ] = "auto_glz", |
| 357 | [ SPICE_IMAGE_COMPRESS_AUTO_LZ ] = "auto_lz", |
| 358 | [ SPICE_IMAGE_COMPRESS_QUIC ] = "quic", |
| 359 | [ SPICE_IMAGE_COMPRESS_GLZ ] = "glz", |
| 360 | [ SPICE_IMAGE_COMPRESS_LZ ] = "lz", |
| 361 | }; |
| 362 | #define parse_compression(_name) \ |
| 363 | parse_name(_name, "image compression", \ |
| 364 | compression_names, ARRAY_SIZE(compression_names)) |
| 365 | |
| 366 | static const char *wan_compression_names[] = { |
| 367 | [ SPICE_WAN_COMPRESSION_AUTO ] = "auto", |
| 368 | [ SPICE_WAN_COMPRESSION_NEVER ] = "never", |
| 369 | [ SPICE_WAN_COMPRESSION_ALWAYS ] = "always", |
| 370 | }; |
| 371 | #define parse_wan_compression(_name) \ |
| 372 | parse_name(_name, "wan compression", \ |
| 373 | wan_compression_names, ARRAY_SIZE(wan_compression_names)) |
| 374 | |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 375 | /* functions for the rest of qemu */ |
| 376 | |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 377 | static SpiceChannelList *qmp_query_spice_channels(void) |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 378 | { |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 379 | SpiceChannelList *cur_item = NULL, *head = NULL; |
| 380 | ChannelList *item; |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 381 | |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 382 | QTAILQ_FOREACH(item, &channel_list, link) { |
| 383 | SpiceChannelList *chan; |
| 384 | char host[NI_MAXHOST], port[NI_MAXSERV]; |
Yonit Halperin | faa9822 | 2012-02-08 15:40:15 +0200 | [diff] [blame] | 385 | struct sockaddr *paddr; |
| 386 | socklen_t plen; |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 387 | |
Gonglei | a416427 | 2014-12-05 16:30:10 +0800 | [diff] [blame] | 388 | assert(item->info->flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT); |
Marc-André Lureau | 26defe8 | 2013-10-04 13:10:46 +0200 | [diff] [blame] | 389 | |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 390 | chan = g_malloc0(sizeof(*chan)); |
| 391 | chan->value = g_malloc0(sizeof(*chan->value)); |
Wenchao Xia | a589569 | 2014-06-18 08:43:30 +0200 | [diff] [blame] | 392 | chan->value->base = g_malloc0(sizeof(*chan->value->base)); |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 393 | |
Marc-André Lureau | 26defe8 | 2013-10-04 13:10:46 +0200 | [diff] [blame] | 394 | paddr = (struct sockaddr *)&item->info->paddr_ext; |
| 395 | plen = item->info->plen_ext; |
Yonit Halperin | faa9822 | 2012-02-08 15:40:15 +0200 | [diff] [blame] | 396 | getnameinfo(paddr, plen, |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 397 | host, sizeof(host), port, sizeof(port), |
| 398 | NI_NUMERICHOST | NI_NUMERICSERV); |
Wenchao Xia | a589569 | 2014-06-18 08:43:30 +0200 | [diff] [blame] | 399 | chan->value->base->host = g_strdup(host); |
| 400 | chan->value->base->port = g_strdup(port); |
| 401 | chan->value->base->family = inet_netfamily(paddr->sa_family); |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 402 | |
| 403 | chan->value->connection_id = item->info->connection_id; |
| 404 | chan->value->channel_type = item->info->type; |
| 405 | chan->value->channel_id = item->info->id; |
| 406 | chan->value->tls = item->info->flags & SPICE_CHANNEL_EVENT_FLAG_TLS; |
| 407 | |
| 408 | /* XXX: waiting for the qapi to support GSList */ |
| 409 | if (!cur_item) { |
| 410 | head = cur_item = chan; |
| 411 | } else { |
| 412 | cur_item->next = chan; |
| 413 | cur_item = chan; |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | return head; |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 418 | } |
| 419 | |
Paolo Bonzini | 4d45457 | 2012-11-26 16:03:42 +0100 | [diff] [blame] | 420 | static QemuOptsList qemu_spice_opts = { |
| 421 | .name = "spice", |
| 422 | .head = QTAILQ_HEAD_INITIALIZER(qemu_spice_opts.head), |
| 423 | .desc = { |
| 424 | { |
| 425 | .name = "port", |
| 426 | .type = QEMU_OPT_NUMBER, |
| 427 | },{ |
| 428 | .name = "tls-port", |
| 429 | .type = QEMU_OPT_NUMBER, |
| 430 | },{ |
| 431 | .name = "addr", |
| 432 | .type = QEMU_OPT_STRING, |
| 433 | },{ |
| 434 | .name = "ipv4", |
| 435 | .type = QEMU_OPT_BOOL, |
| 436 | },{ |
| 437 | .name = "ipv6", |
| 438 | .type = QEMU_OPT_BOOL, |
Marc-André Lureau | fe4831b | 2015-01-13 17:57:51 +0100 | [diff] [blame] | 439 | #ifdef SPICE_ADDR_FLAG_UNIX_ONLY |
| 440 | },{ |
| 441 | .name = "unix", |
| 442 | .type = QEMU_OPT_BOOL, |
| 443 | #endif |
Paolo Bonzini | 4d45457 | 2012-11-26 16:03:42 +0100 | [diff] [blame] | 444 | },{ |
| 445 | .name = "password", |
| 446 | .type = QEMU_OPT_STRING, |
| 447 | },{ |
| 448 | .name = "disable-ticketing", |
| 449 | .type = QEMU_OPT_BOOL, |
| 450 | },{ |
| 451 | .name = "disable-copy-paste", |
| 452 | .type = QEMU_OPT_BOOL, |
| 453 | },{ |
Hans de Goede | 5ad24e5 | 2013-06-08 15:37:27 +0200 | [diff] [blame] | 454 | .name = "disable-agent-file-xfer", |
| 455 | .type = QEMU_OPT_BOOL, |
| 456 | },{ |
Paolo Bonzini | 4d45457 | 2012-11-26 16:03:42 +0100 | [diff] [blame] | 457 | .name = "sasl", |
| 458 | .type = QEMU_OPT_BOOL, |
| 459 | },{ |
| 460 | .name = "x509-dir", |
| 461 | .type = QEMU_OPT_STRING, |
| 462 | },{ |
| 463 | .name = "x509-key-file", |
| 464 | .type = QEMU_OPT_STRING, |
| 465 | },{ |
| 466 | .name = "x509-key-password", |
| 467 | .type = QEMU_OPT_STRING, |
| 468 | },{ |
| 469 | .name = "x509-cert-file", |
| 470 | .type = QEMU_OPT_STRING, |
| 471 | },{ |
| 472 | .name = "x509-cacert-file", |
| 473 | .type = QEMU_OPT_STRING, |
| 474 | },{ |
| 475 | .name = "x509-dh-key-file", |
| 476 | .type = QEMU_OPT_STRING, |
| 477 | },{ |
| 478 | .name = "tls-ciphers", |
| 479 | .type = QEMU_OPT_STRING, |
| 480 | },{ |
| 481 | .name = "tls-channel", |
| 482 | .type = QEMU_OPT_STRING, |
| 483 | },{ |
| 484 | .name = "plaintext-channel", |
| 485 | .type = QEMU_OPT_STRING, |
| 486 | },{ |
| 487 | .name = "image-compression", |
| 488 | .type = QEMU_OPT_STRING, |
| 489 | },{ |
| 490 | .name = "jpeg-wan-compression", |
| 491 | .type = QEMU_OPT_STRING, |
| 492 | },{ |
| 493 | .name = "zlib-glz-wan-compression", |
| 494 | .type = QEMU_OPT_STRING, |
| 495 | },{ |
| 496 | .name = "streaming-video", |
| 497 | .type = QEMU_OPT_STRING, |
| 498 | },{ |
| 499 | .name = "agent-mouse", |
| 500 | .type = QEMU_OPT_BOOL, |
| 501 | },{ |
| 502 | .name = "playback-compression", |
| 503 | .type = QEMU_OPT_BOOL, |
| 504 | }, { |
| 505 | .name = "seamless-migration", |
| 506 | .type = QEMU_OPT_BOOL, |
| 507 | }, |
| 508 | { /* end of list */ } |
| 509 | }, |
| 510 | }; |
| 511 | |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 512 | SpiceInfo *qmp_query_spice(Error **errp) |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 513 | { |
| 514 | QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head); |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 515 | int port, tls_port; |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 516 | const char *addr; |
| 517 | SpiceInfo *info; |
Christophe Fergeau | 6735aa9 | 2013-09-02 15:41:32 +0200 | [diff] [blame] | 518 | unsigned int major; |
| 519 | unsigned int minor; |
| 520 | unsigned int micro; |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 521 | |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 522 | info = g_malloc0(sizeof(*info)); |
| 523 | |
Alon Levy | 3bb781f | 2011-10-04 13:25:53 +0200 | [diff] [blame] | 524 | if (!spice_server || !opts) { |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 525 | info->enabled = false; |
| 526 | return info; |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 527 | } |
| 528 | |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 529 | info->enabled = true; |
Yonit Halperin | 61c4efe | 2012-08-21 11:51:58 +0300 | [diff] [blame] | 530 | info->migrated = spice_migration_completed; |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 531 | |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 532 | addr = qemu_opt_get(opts, "addr"); |
| 533 | port = qemu_opt_get_number(opts, "port", 0); |
| 534 | tls_port = qemu_opt_get_number(opts, "tls-port", 0); |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 535 | |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 536 | info->has_auth = true; |
| 537 | info->auth = g_strdup(auth); |
| 538 | |
| 539 | info->has_host = true; |
Gerd Hoffmann | 4f60af9 | 2014-04-15 08:55:44 +0200 | [diff] [blame] | 540 | info->host = g_strdup(addr ? addr : "*"); |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 541 | |
| 542 | info->has_compiled_version = true; |
Christophe Fergeau | 6735aa9 | 2013-09-02 15:41:32 +0200 | [diff] [blame] | 543 | major = (SPICE_SERVER_VERSION & 0xff0000) >> 16; |
| 544 | minor = (SPICE_SERVER_VERSION & 0xff00) >> 8; |
| 545 | micro = SPICE_SERVER_VERSION & 0xff; |
| 546 | info->compiled_version = g_strdup_printf("%d.%d.%d", major, minor, micro); |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 547 | |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 548 | if (port) { |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 549 | info->has_port = true; |
| 550 | info->port = port; |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 551 | } |
| 552 | if (tls_port) { |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 553 | info->has_tls_port = true; |
| 554 | info->tls_port = tls_port; |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 555 | } |
| 556 | |
Alon Levy | 4efee02 | 2012-03-29 23:23:14 +0200 | [diff] [blame] | 557 | info->mouse_mode = spice_server_is_server_mouse(spice_server) ? |
| 558 | SPICE_QUERY_MOUSE_MODE_SERVER : |
| 559 | SPICE_QUERY_MOUSE_MODE_CLIENT; |
Gerd Hoffmann | 67be672 | 2012-09-24 10:23:40 +0200 | [diff] [blame] | 560 | |
Luiz Capitulino | d1f2964 | 2011-10-20 17:01:33 -0200 | [diff] [blame] | 561 | /* for compatibility with the original command */ |
| 562 | info->has_channels = true; |
| 563 | info->channels = qmp_query_spice_channels(); |
| 564 | |
| 565 | return info; |
Gerd Hoffmann | cb42a87 | 2010-11-30 11:02:51 +0100 | [diff] [blame] | 566 | } |
| 567 | |
Jan Kiszka | 9e8dd45 | 2011-06-20 14:06:26 +0200 | [diff] [blame] | 568 | static void migration_state_notifier(Notifier *notifier, void *data) |
Gerd Hoffmann | e866e23 | 2010-04-23 13:28:21 +0200 | [diff] [blame] | 569 | { |
Juan Quintela | 7073693 | 2011-02-23 00:43:59 +0100 | [diff] [blame] | 570 | MigrationState *s = data; |
Gerd Hoffmann | e866e23 | 2010-04-23 13:28:21 +0200 | [diff] [blame] | 571 | |
Gerd Hoffmann | a76a2f7 | 2014-04-29 09:27:31 +0200 | [diff] [blame] | 572 | if (!spice_have_target_host) { |
| 573 | return; |
| 574 | } |
| 575 | |
Stefan Hajnoczi | 02edd2e | 2013-07-29 15:01:58 +0200 | [diff] [blame] | 576 | if (migration_in_setup(s)) { |
Yonit Halperin | 026f773 | 2011-10-17 10:03:19 +0200 | [diff] [blame] | 577 | spice_server_migrate_start(spice_server); |
Yonit Halperin | 026f773 | 2011-10-17 10:03:19 +0200 | [diff] [blame] | 578 | } else if (migration_has_finished(s)) { |
Yonit Halperin | 026f773 | 2011-10-17 10:03:19 +0200 | [diff] [blame] | 579 | spice_server_migrate_end(spice_server, true); |
Gerd Hoffmann | a76a2f7 | 2014-04-29 09:27:31 +0200 | [diff] [blame] | 580 | spice_have_target_host = false; |
Yonit Halperin | 026f773 | 2011-10-17 10:03:19 +0200 | [diff] [blame] | 581 | } else if (migration_has_failed(s)) { |
| 582 | spice_server_migrate_end(spice_server, false); |
Gerd Hoffmann | a76a2f7 | 2014-04-29 09:27:31 +0200 | [diff] [blame] | 583 | spice_have_target_host = false; |
Gerd Hoffmann | e866e23 | 2010-04-23 13:28:21 +0200 | [diff] [blame] | 584 | } |
| 585 | } |
| 586 | |
| 587 | int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, |
Yonit Halperin | edc5cb1 | 2011-10-17 10:03:18 +0200 | [diff] [blame] | 588 | const char *subject, |
| 589 | MonitorCompletion *cb, void *opaque) |
Gerd Hoffmann | e866e23 | 2010-04-23 13:28:21 +0200 | [diff] [blame] | 590 | { |
Yonit Halperin | edc5cb1 | 2011-10-17 10:03:18 +0200 | [diff] [blame] | 591 | int ret; |
Gerd Hoffmann | 67be672 | 2012-09-24 10:23:40 +0200 | [diff] [blame] | 592 | |
Yonit Halperin | 026f773 | 2011-10-17 10:03:19 +0200 | [diff] [blame] | 593 | spice_migrate.connect_complete.cb = cb; |
| 594 | spice_migrate.connect_complete.opaque = opaque; |
| 595 | ret = spice_server_migrate_connect(spice_server, hostname, |
| 596 | port, tls_port, subject); |
Gerd Hoffmann | a76a2f7 | 2014-04-29 09:27:31 +0200 | [diff] [blame] | 597 | spice_have_target_host = true; |
Yonit Halperin | edc5cb1 | 2011-10-17 10:03:18 +0200 | [diff] [blame] | 598 | return ret; |
Gerd Hoffmann | e866e23 | 2010-04-23 13:28:21 +0200 | [diff] [blame] | 599 | } |
| 600 | |
Gerd Hoffmann | 17b6dea | 2010-08-27 14:09:56 +0200 | [diff] [blame] | 601 | static int add_channel(const char *name, const char *value, void *opaque) |
| 602 | { |
| 603 | int security = 0; |
| 604 | int rc; |
| 605 | |
| 606 | if (strcmp(name, "tls-channel") == 0) { |
Christophe Fergeau | 35c6332 | 2012-02-24 18:28:32 +0100 | [diff] [blame] | 607 | int *tls_port = opaque; |
| 608 | if (!*tls_port) { |
| 609 | error_report("spice: tried to setup tls-channel" |
| 610 | " without specifying a TLS port"); |
| 611 | exit(1); |
| 612 | } |
Gerd Hoffmann | 17b6dea | 2010-08-27 14:09:56 +0200 | [diff] [blame] | 613 | security = SPICE_CHANNEL_SECURITY_SSL; |
| 614 | } |
| 615 | if (strcmp(name, "plaintext-channel") == 0) { |
| 616 | security = SPICE_CHANNEL_SECURITY_NONE; |
| 617 | } |
| 618 | if (security == 0) { |
| 619 | return 0; |
| 620 | } |
| 621 | if (strcmp(value, "default") == 0) { |
| 622 | rc = spice_server_set_channel_security(spice_server, NULL, security); |
| 623 | } else { |
| 624 | rc = spice_server_set_channel_security(spice_server, value, security); |
| 625 | } |
| 626 | if (rc != 0) { |
Christophe Fergeau | 339a475 | 2012-02-24 18:13:12 +0100 | [diff] [blame] | 627 | error_report("spice: failed to set channel security for %s", value); |
Gerd Hoffmann | 17b6dea | 2010-08-27 14:09:56 +0200 | [diff] [blame] | 628 | exit(1); |
| 629 | } |
| 630 | return 0; |
| 631 | } |
| 632 | |
Yonit Halperin | f5bb039 | 2012-08-21 11:51:55 +0300 | [diff] [blame] | 633 | static void vm_change_state_handler(void *opaque, int running, |
| 634 | RunState state) |
| 635 | { |
Yonit Halperin | f5bb039 | 2012-08-21 11:51:55 +0300 | [diff] [blame] | 636 | if (running) { |
Yonit Halperin | 71d388d | 2012-08-21 11:51:56 +0300 | [diff] [blame] | 637 | qemu_spice_display_start(); |
Yonit Halperin | f5bb039 | 2012-08-21 11:51:55 +0300 | [diff] [blame] | 638 | } else { |
Yonit Halperin | 71d388d | 2012-08-21 11:51:56 +0300 | [diff] [blame] | 639 | qemu_spice_display_stop(); |
Yonit Halperin | f5bb039 | 2012-08-21 11:51:55 +0300 | [diff] [blame] | 640 | } |
Yonit Halperin | f5bb039 | 2012-08-21 11:51:55 +0300 | [diff] [blame] | 641 | } |
| 642 | |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 643 | void qemu_spice_init(void) |
| 644 | { |
| 645 | QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head); |
Gerd Hoffmann | 333b0ee | 2010-08-27 14:29:16 +0200 | [diff] [blame] | 646 | const char *password, *str, *x509_dir, *addr, |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 647 | *x509_key_password = NULL, |
| 648 | *x509_dh_file = NULL, |
| 649 | *tls_ciphers = NULL; |
| 650 | char *x509_key_file = NULL, |
| 651 | *x509_cert_file = NULL, |
| 652 | *x509_cacert_file = NULL; |
Christophe Fergeau | 6735aa9 | 2013-09-02 15:41:32 +0200 | [diff] [blame] | 653 | int port, tls_port, addr_flags; |
Yonit Halperin | 9f04e09 | 2010-07-14 13:26:34 +0300 | [diff] [blame] | 654 | spice_image_compression_t compression; |
| 655 | spice_wan_compression_t wan_compr; |
Yonit Halperin | 8c95705 | 2012-08-21 11:51:59 +0300 | [diff] [blame] | 656 | bool seamless_migration; |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 657 | |
Jan Kiszka | f9ab609 | 2011-09-20 17:14:33 +0200 | [diff] [blame] | 658 | qemu_thread_get_self(&me); |
Gerd Hoffmann | 22b626e | 2011-09-02 15:03:28 +0200 | [diff] [blame] | 659 | |
Alon Levy | ad1be89 | 2012-03-14 20:33:37 +0200 | [diff] [blame] | 660 | if (!opts) { |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 661 | return; |
| 662 | } |
| 663 | port = qemu_opt_get_number(opts, "port", 0); |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 664 | tls_port = qemu_opt_get_number(opts, "tls-port", 0); |
Gerd Hoffmann | df9cb66 | 2011-07-07 17:04:17 +0200 | [diff] [blame] | 665 | if (port < 0 || port > 65535) { |
Christophe Fergeau | 339a475 | 2012-02-24 18:13:12 +0100 | [diff] [blame] | 666 | error_report("spice port is out of range"); |
Gerd Hoffmann | df9cb66 | 2011-07-07 17:04:17 +0200 | [diff] [blame] | 667 | exit(1); |
| 668 | } |
| 669 | if (tls_port < 0 || tls_port > 65535) { |
Christophe Fergeau | 339a475 | 2012-02-24 18:13:12 +0100 | [diff] [blame] | 670 | error_report("spice tls-port is out of range"); |
Gerd Hoffmann | df9cb66 | 2011-07-07 17:04:17 +0200 | [diff] [blame] | 671 | exit(1); |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 672 | } |
| 673 | password = qemu_opt_get(opts, "password"); |
| 674 | |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 675 | if (tls_port) { |
| 676 | x509_dir = qemu_opt_get(opts, "x509-dir"); |
Gonglei | fe8e832 | 2014-08-11 21:00:56 +0800 | [diff] [blame] | 677 | if (!x509_dir) { |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 678 | x509_dir = "."; |
| 679 | } |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 680 | |
| 681 | str = qemu_opt_get(opts, "x509-key-file"); |
| 682 | if (str) { |
Anthony Liguori | 7267c09 | 2011-08-20 22:09:37 -0500 | [diff] [blame] | 683 | x509_key_file = g_strdup(str); |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 684 | } else { |
Christophe Fergeau | 6735aa9 | 2013-09-02 15:41:32 +0200 | [diff] [blame] | 685 | x509_key_file = g_strdup_printf("%s/%s", x509_dir, |
| 686 | X509_SERVER_KEY_FILE); |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 687 | } |
| 688 | |
| 689 | str = qemu_opt_get(opts, "x509-cert-file"); |
| 690 | if (str) { |
Anthony Liguori | 7267c09 | 2011-08-20 22:09:37 -0500 | [diff] [blame] | 691 | x509_cert_file = g_strdup(str); |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 692 | } else { |
Christophe Fergeau | 6735aa9 | 2013-09-02 15:41:32 +0200 | [diff] [blame] | 693 | x509_cert_file = g_strdup_printf("%s/%s", x509_dir, |
| 694 | X509_SERVER_CERT_FILE); |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | str = qemu_opt_get(opts, "x509-cacert-file"); |
| 698 | if (str) { |
Anthony Liguori | 7267c09 | 2011-08-20 22:09:37 -0500 | [diff] [blame] | 699 | x509_cacert_file = g_strdup(str); |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 700 | } else { |
Christophe Fergeau | 6735aa9 | 2013-09-02 15:41:32 +0200 | [diff] [blame] | 701 | x509_cacert_file = g_strdup_printf("%s/%s", x509_dir, |
| 702 | X509_CA_CERT_FILE); |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | x509_key_password = qemu_opt_get(opts, "x509-key-password"); |
Lei Li | 9995c0b | 2012-11-19 17:15:08 +0800 | [diff] [blame] | 706 | x509_dh_file = qemu_opt_get(opts, "x509-dh-key-file"); |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 707 | tls_ciphers = qemu_opt_get(opts, "tls-ciphers"); |
| 708 | } |
| 709 | |
Gerd Hoffmann | 333b0ee | 2010-08-27 14:29:16 +0200 | [diff] [blame] | 710 | addr = qemu_opt_get(opts, "addr"); |
| 711 | addr_flags = 0; |
| 712 | if (qemu_opt_get_bool(opts, "ipv4", 0)) { |
| 713 | addr_flags |= SPICE_ADDR_FLAG_IPV4_ONLY; |
| 714 | } else if (qemu_opt_get_bool(opts, "ipv6", 0)) { |
| 715 | addr_flags |= SPICE_ADDR_FLAG_IPV6_ONLY; |
Marc-André Lureau | fe4831b | 2015-01-13 17:57:51 +0100 | [diff] [blame] | 716 | #ifdef SPICE_ADDR_FLAG_UNIX_ONLY |
| 717 | } else if (qemu_opt_get_bool(opts, "unix", 0)) { |
| 718 | addr_flags |= SPICE_ADDR_FLAG_UNIX_ONLY; |
| 719 | #endif |
Gerd Hoffmann | 333b0ee | 2010-08-27 14:29:16 +0200 | [diff] [blame] | 720 | } |
| 721 | |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 722 | spice_server = spice_server_new(); |
Gerd Hoffmann | 333b0ee | 2010-08-27 14:29:16 +0200 | [diff] [blame] | 723 | spice_server_set_addr(spice_server, addr ? addr : "", addr_flags); |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 724 | if (port) { |
| 725 | spice_server_set_port(spice_server, port); |
| 726 | } |
| 727 | if (tls_port) { |
| 728 | spice_server_set_tls(spice_server, tls_port, |
| 729 | x509_cacert_file, |
| 730 | x509_cert_file, |
| 731 | x509_key_file, |
| 732 | x509_key_password, |
| 733 | x509_dh_file, |
| 734 | tls_ciphers); |
| 735 | } |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 736 | if (password) { |
Marc-André Lureau | 07d49a5 | 2014-09-05 14:08:48 +0200 | [diff] [blame] | 737 | qemu_spice_set_passwd(password, false, false); |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 738 | } |
Marc-André Lureau | 48b3ed0 | 2011-05-17 10:40:33 +0200 | [diff] [blame] | 739 | if (qemu_opt_get_bool(opts, "sasl", 0)) { |
Marc-André Lureau | 48b3ed0 | 2011-05-17 10:40:33 +0200 | [diff] [blame] | 740 | if (spice_server_set_sasl_appname(spice_server, "qemu") == -1 || |
| 741 | spice_server_set_sasl(spice_server, 1) == -1) { |
Christophe Fergeau | 339a475 | 2012-02-24 18:13:12 +0100 | [diff] [blame] | 742 | error_report("spice: failed to enable sasl"); |
Marc-André Lureau | 48b3ed0 | 2011-05-17 10:40:33 +0200 | [diff] [blame] | 743 | exit(1); |
| 744 | } |
Gerd Hoffmann | b1ea7b7 | 2014-07-02 12:56:42 +0200 | [diff] [blame] | 745 | auth = "sasl"; |
Marc-André Lureau | 48b3ed0 | 2011-05-17 10:40:33 +0200 | [diff] [blame] | 746 | } |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 747 | if (qemu_opt_get_bool(opts, "disable-ticketing", 0)) { |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 748 | auth = "none"; |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 749 | spice_server_set_noauth(spice_server); |
| 750 | } |
| 751 | |
Hans de Goede | d4970b0 | 2011-03-27 16:43:54 +0200 | [diff] [blame] | 752 | if (qemu_opt_get_bool(opts, "disable-copy-paste", 0)) { |
| 753 | spice_server_set_agent_copypaste(spice_server, false); |
| 754 | } |
Hans de Goede | d4970b0 | 2011-03-27 16:43:54 +0200 | [diff] [blame] | 755 | |
Hans de Goede | 5ad24e5 | 2013-06-08 15:37:27 +0200 | [diff] [blame] | 756 | if (qemu_opt_get_bool(opts, "disable-agent-file-xfer", 0)) { |
| 757 | #if SPICE_SERVER_VERSION >= 0x000c04 |
| 758 | spice_server_set_agent_file_xfer(spice_server, false); |
| 759 | #else |
| 760 | error_report("this qemu build does not support the " |
| 761 | "\"disable-agent-file-xfer\" option"); |
| 762 | exit(1); |
| 763 | #endif |
| 764 | } |
| 765 | |
Yonit Halperin | 9f04e09 | 2010-07-14 13:26:34 +0300 | [diff] [blame] | 766 | compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ; |
| 767 | str = qemu_opt_get(opts, "image-compression"); |
| 768 | if (str) { |
| 769 | compression = parse_compression(str); |
| 770 | } |
| 771 | spice_server_set_image_compression(spice_server, compression); |
| 772 | |
| 773 | wan_compr = SPICE_WAN_COMPRESSION_AUTO; |
| 774 | str = qemu_opt_get(opts, "jpeg-wan-compression"); |
| 775 | if (str) { |
| 776 | wan_compr = parse_wan_compression(str); |
| 777 | } |
| 778 | spice_server_set_jpeg_compression(spice_server, wan_compr); |
| 779 | |
| 780 | wan_compr = SPICE_WAN_COMPRESSION_AUTO; |
| 781 | str = qemu_opt_get(opts, "zlib-glz-wan-compression"); |
| 782 | if (str) { |
| 783 | wan_compr = parse_wan_compression(str); |
| 784 | } |
| 785 | spice_server_set_zlib_glz_compression(spice_server, wan_compr); |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 786 | |
Gerd Hoffmann | 84a23f2 | 2010-08-30 16:36:53 +0200 | [diff] [blame] | 787 | str = qemu_opt_get(opts, "streaming-video"); |
| 788 | if (str) { |
Gerd Hoffmann | f61d696 | 2010-11-02 12:21:50 +0100 | [diff] [blame] | 789 | int streaming_video = parse_stream_video(str); |
Gerd Hoffmann | 84a23f2 | 2010-08-30 16:36:53 +0200 | [diff] [blame] | 790 | spice_server_set_streaming_video(spice_server, streaming_video); |
Gerd Hoffmann | f1d3e58 | 2013-12-02 11:17:04 +0100 | [diff] [blame] | 791 | } else { |
| 792 | spice_server_set_streaming_video(spice_server, SPICE_STREAM_VIDEO_OFF); |
Gerd Hoffmann | 84a23f2 | 2010-08-30 16:36:53 +0200 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | spice_server_set_agent_mouse |
| 796 | (spice_server, qemu_opt_get_bool(opts, "agent-mouse", 1)); |
| 797 | spice_server_set_playback_compression |
| 798 | (spice_server, qemu_opt_get_bool(opts, "playback-compression", 1)); |
| 799 | |
Christophe Fergeau | 35c6332 | 2012-02-24 18:28:32 +0100 | [diff] [blame] | 800 | qemu_opt_foreach(opts, add_channel, &tls_port, 0); |
Gerd Hoffmann | 17b6dea | 2010-08-27 14:09:56 +0200 | [diff] [blame] | 801 | |
Marc-André Lureau | d0638b1 | 2012-03-05 18:22:26 +0100 | [diff] [blame] | 802 | spice_server_set_name(spice_server, qemu_name); |
| 803 | spice_server_set_uuid(spice_server, qemu_uuid); |
Marc-André Lureau | d0638b1 | 2012-03-05 18:22:26 +0100 | [diff] [blame] | 804 | |
Yonit Halperin | 8c95705 | 2012-08-21 11:51:59 +0300 | [diff] [blame] | 805 | seamless_migration = qemu_opt_get_bool(opts, "seamless-migration", 0); |
| 806 | spice_server_set_seamless_migration(spice_server, seamless_migration); |
Gonglei | fe8e832 | 2014-08-11 21:00:56 +0800 | [diff] [blame] | 807 | if (spice_server_init(spice_server, &core_interface) != 0) { |
Christophe Fergeau | 339a475 | 2012-02-24 18:13:12 +0100 | [diff] [blame] | 808 | error_report("failed to initialize spice server"); |
Gerd Hoffmann | fba810f | 2011-06-15 13:11:33 +0200 | [diff] [blame] | 809 | exit(1); |
| 810 | }; |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 811 | using_spice = 1; |
Gerd Hoffmann | 864401c | 2010-03-11 11:13:28 -0300 | [diff] [blame] | 812 | |
Gerd Hoffmann | e866e23 | 2010-04-23 13:28:21 +0200 | [diff] [blame] | 813 | migration_state.notify = migration_state_notifier; |
| 814 | add_migration_state_change_notifier(&migration_state); |
Yonit Halperin | 026f773 | 2011-10-17 10:03:19 +0200 | [diff] [blame] | 815 | spice_migrate.sin.base.sif = &migrate_interface.base; |
| 816 | spice_migrate.connect_complete.cb = NULL; |
| 817 | qemu_spice_add_interface(&spice_migrate.sin.base); |
Gerd Hoffmann | e866e23 | 2010-04-23 13:28:21 +0200 | [diff] [blame] | 818 | |
Gerd Hoffmann | 864401c | 2010-03-11 11:13:28 -0300 | [diff] [blame] | 819 | qemu_spice_input_init(); |
Gerd Hoffmann | 3e31375 | 2010-11-09 17:29:46 +0100 | [diff] [blame] | 820 | qemu_spice_audio_init(); |
Gerd Hoffmann | c448e85 | 2010-03-11 11:13:32 -0300 | [diff] [blame] | 821 | |
Stefan Hajnoczi | bfb82a2 | 2012-12-19 14:07:16 +0100 | [diff] [blame] | 822 | qemu_add_vm_change_state_handler(vm_change_state_handler, NULL); |
Yonit Halperin | f5bb039 | 2012-08-21 11:51:55 +0300 | [diff] [blame] | 823 | |
Anthony Liguori | 7267c09 | 2011-08-20 22:09:37 -0500 | [diff] [blame] | 824 | g_free(x509_key_file); |
| 825 | g_free(x509_cert_file); |
| 826 | g_free(x509_cacert_file); |
Marc-André Lureau | afd0b40 | 2012-12-05 16:15:36 +0100 | [diff] [blame] | 827 | |
| 828 | #if SPICE_SERVER_VERSION >= 0x000c02 |
| 829 | qemu_spice_register_ports(); |
| 830 | #endif |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 831 | } |
| 832 | |
| 833 | int qemu_spice_add_interface(SpiceBaseInstance *sin) |
| 834 | { |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 835 | if (!spice_server) { |
| 836 | if (QTAILQ_FIRST(&qemu_spice_opts.head) != NULL) { |
Christophe Fergeau | 339a475 | 2012-02-24 18:13:12 +0100 | [diff] [blame] | 837 | error_report("Oops: spice configured but not active"); |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 838 | exit(1); |
| 839 | } |
| 840 | /* |
| 841 | * Create a spice server instance. |
| 842 | * It does *not* listen on the network. |
| 843 | * It handles QXL local rendering only. |
| 844 | * |
| 845 | * With a command line like '-vnc :0 -vga qxl' you'll end up here. |
| 846 | */ |
| 847 | spice_server = spice_server_new(); |
Christophe Fergeau | 764eb39 | 2013-10-16 17:52:33 +0200 | [diff] [blame] | 848 | spice_server_set_sasl_appname(spice_server, "qemu"); |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 849 | spice_server_init(spice_server, &core_interface); |
Stefan Hajnoczi | bfb82a2 | 2012-12-19 14:07:16 +0100 | [diff] [blame] | 850 | qemu_add_vm_change_state_handler(vm_change_state_handler, NULL); |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 851 | } |
Yonit Halperin | 71d388d | 2012-08-21 11:51:56 +0300 | [diff] [blame] | 852 | |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 853 | return spice_server_add_interface(spice_server, sin); |
| 854 | } |
| 855 | |
Gerd Hoffmann | 9fa0328 | 2013-10-11 22:39:59 +0200 | [diff] [blame] | 856 | static GSList *spice_consoles; |
Gerd Hoffmann | 9fa0328 | 2013-10-11 22:39:59 +0200 | [diff] [blame] | 857 | |
| 858 | bool qemu_spice_have_display_interface(QemuConsole *con) |
| 859 | { |
| 860 | if (g_slist_find(spice_consoles, con)) { |
| 861 | return true; |
| 862 | } |
| 863 | return false; |
| 864 | } |
| 865 | |
| 866 | int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con) |
| 867 | { |
| 868 | if (g_slist_find(spice_consoles, con)) { |
| 869 | return -1; |
| 870 | } |
Gerd Hoffmann | cd56cc6 | 2014-08-29 10:13:28 +0200 | [diff] [blame] | 871 | qxlin->id = qemu_console_get_index(con); |
Gerd Hoffmann | 9fa0328 | 2013-10-11 22:39:59 +0200 | [diff] [blame] | 872 | spice_consoles = g_slist_append(spice_consoles, con); |
| 873 | return qemu_spice_add_interface(&qxlin->base); |
| 874 | } |
| 875 | |
Gerd Hoffmann | 7572150 | 2010-10-07 12:22:54 +0200 | [diff] [blame] | 876 | static int qemu_spice_set_ticket(bool fail_if_conn, bool disconnect_if_conn) |
| 877 | { |
| 878 | time_t lifetime, now = time(NULL); |
| 879 | char *passwd; |
| 880 | |
| 881 | if (now < auth_expires) { |
| 882 | passwd = auth_passwd; |
| 883 | lifetime = (auth_expires - now); |
| 884 | if (lifetime > INT_MAX) { |
| 885 | lifetime = INT_MAX; |
| 886 | } |
| 887 | } else { |
| 888 | passwd = NULL; |
| 889 | lifetime = 1; |
| 890 | } |
| 891 | return spice_server_set_ticket(spice_server, passwd, lifetime, |
| 892 | fail_if_conn, disconnect_if_conn); |
| 893 | } |
| 894 | |
| 895 | int qemu_spice_set_passwd(const char *passwd, |
| 896 | bool fail_if_conn, bool disconnect_if_conn) |
| 897 | { |
Gerd Hoffmann | b1ea7b7 | 2014-07-02 12:56:42 +0200 | [diff] [blame] | 898 | if (strcmp(auth, "spice") != 0) { |
| 899 | return -1; |
| 900 | } |
| 901 | |
Markus Armbruster | fd3bea3 | 2013-01-22 11:08:00 +0100 | [diff] [blame] | 902 | g_free(auth_passwd); |
| 903 | auth_passwd = g_strdup(passwd); |
Gerd Hoffmann | 7572150 | 2010-10-07 12:22:54 +0200 | [diff] [blame] | 904 | return qemu_spice_set_ticket(fail_if_conn, disconnect_if_conn); |
| 905 | } |
| 906 | |
| 907 | int qemu_spice_set_pw_expire(time_t expires) |
| 908 | { |
| 909 | auth_expires = expires; |
| 910 | return qemu_spice_set_ticket(false, false); |
| 911 | } |
| 912 | |
Daniel P. Berrange | f1f5f40 | 2012-02-13 13:43:08 +0000 | [diff] [blame] | 913 | int qemu_spice_display_add_client(int csock, int skipauth, int tls) |
| 914 | { |
Daniel P. Berrange | f1f5f40 | 2012-02-13 13:43:08 +0000 | [diff] [blame] | 915 | if (tls) { |
| 916 | return spice_server_add_ssl_client(spice_server, csock, skipauth); |
| 917 | } else { |
| 918 | return spice_server_add_client(spice_server, csock, skipauth); |
| 919 | } |
Daniel P. Berrange | f1f5f40 | 2012-02-13 13:43:08 +0000 | [diff] [blame] | 920 | } |
| 921 | |
Gerd Hoffmann | 7cc6a25 | 2013-12-09 15:54:46 +0100 | [diff] [blame] | 922 | void qemu_spice_display_start(void) |
| 923 | { |
| 924 | spice_display_is_running = true; |
Gerd Hoffmann | b50f3e4 | 2013-12-09 16:00:15 +0100 | [diff] [blame] | 925 | spice_server_vm_start(spice_server); |
Gerd Hoffmann | 7cc6a25 | 2013-12-09 15:54:46 +0100 | [diff] [blame] | 926 | } |
| 927 | |
| 928 | void qemu_spice_display_stop(void) |
| 929 | { |
Gerd Hoffmann | b50f3e4 | 2013-12-09 16:00:15 +0100 | [diff] [blame] | 930 | spice_server_vm_stop(spice_server); |
Gerd Hoffmann | 7cc6a25 | 2013-12-09 15:54:46 +0100 | [diff] [blame] | 931 | spice_display_is_running = false; |
| 932 | } |
| 933 | |
| 934 | int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd) |
| 935 | { |
| 936 | return spice_display_is_running; |
| 937 | } |
| 938 | |
Gerd Hoffmann | 29b0040 | 2010-03-11 11:13:27 -0300 | [diff] [blame] | 939 | static void spice_register_config(void) |
| 940 | { |
| 941 | qemu_add_opts(&qemu_spice_opts); |
| 942 | } |
| 943 | machine_init(spice_register_config); |