aboutsummaryrefslogtreecommitdiff
path: root/ui/spice-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui/spice-core.c')
-rw-r--r--ui/spice-core.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 0326c63..8a6050f 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -50,12 +50,12 @@ static int spice_migration_completed;
static int spice_display_is_running;
static int spice_have_target_host;
-static QemuThread me;
-
struct SpiceTimer {
QEMUTimer *timer;
};
+#define DEFAULT_MAX_REFRESH_RATE 30
+
static SpiceTimer *timer_add(SpiceTimerFunc func, void *opaque)
{
SpiceTimer *timer;
@@ -126,11 +126,13 @@ static void watch_update_mask(SpiceWatch *watch, int event_mask)
static SpiceWatch *watch_add(int fd, int event_mask, SpiceWatchFunc func, void *opaque)
{
SpiceWatch *watch;
-
#ifdef WIN32
+ g_autofree char *msg = NULL;
+
fd = _open_osfhandle(fd, _O_BINARY);
if (fd < 0) {
- error_setg_win32(&error_warn, WSAGetLastError(), "Couldn't associate a FD with the SOCKET");
+ msg = g_win32_error_message(WSAGetLastError());
+ warn_report("Couldn't associate a FD with the SOCKET: %s", msg);
return NULL;
}
#endif
@@ -220,7 +222,7 @@ static void channel_event(int event, SpiceChannelEventInfo *info)
* thread and grab the BQL if so before calling qemu
* functions.
*/
- bool need_lock = !qemu_thread_is_self(&me);
+ bool need_lock = !bql_locked();
if (need_lock) {
bql_lock();
}
@@ -489,6 +491,12 @@ static QemuOptsList qemu_spice_opts = {
.name = "streaming-video",
.type = QEMU_OPT_STRING,
},{
+ .name = "video-codec",
+ .type = QEMU_OPT_STRING,
+ },{
+ .name = "max-refresh-rate",
+ .type = QEMU_OPT_NUMBER,
+ },{
.name = "agent-mouse",
.type = QEMU_OPT_BOOL,
},{
@@ -667,8 +675,6 @@ static void qemu_spice_init(void)
spice_wan_compression_t wan_compr;
bool seamless_migration;
- qemu_thread_get_self(&me);
-
if (!opts) {
return;
}
@@ -801,6 +807,13 @@ static void qemu_spice_init(void)
spice_server_set_streaming_video(spice_server, SPICE_STREAM_VIDEO_OFF);
}
+ spice_max_refresh_rate = qemu_opt_get_number(opts, "max-refresh-rate",
+ DEFAULT_MAX_REFRESH_RATE);
+ if (spice_max_refresh_rate <= 0) {
+ error_report("max refresh rate/fps is invalid");
+ exit(1);
+ }
+
spice_server_set_agent_mouse
(spice_server, qemu_opt_get_bool(opts, "agent-mouse", 1));
spice_server_set_playback_compression
@@ -836,9 +849,26 @@ static void qemu_spice_init(void)
#ifdef HAVE_SPICE_GL
if (qemu_opt_get_bool(opts, "gl", 0)) {
if ((port != 0) || (tls_port != 0)) {
+#if SPICE_SERVER_VERSION >= 0x000f03 /* release 0.15.3 */
+ const char *video_codec = NULL;
+ g_autofree char *enc_codec = NULL;
+
+ spice_remote_client = 1;
+
+ video_codec = qemu_opt_get(opts, "video-codec");
+ if (video_codec) {
+ enc_codec = g_strconcat("gstreamer:", video_codec, NULL);
+ }
+ if (spice_server_set_video_codecs(spice_server,
+ enc_codec ?: "gstreamer:h264")) {
+ error_report("invalid video codec");
+ exit(1);
+ }
+#else
error_report("SPICE GL support is local-only for now and "
"incompatible with -spice port/tls-port");
exit(1);
+#endif
}
egl_init(qemu_opt_get(opts, "rendernode"), DISPLAY_GL_MODE_ON, &error_fatal);
spice_opengl = 1;