From nobody Fri Nov 7 01:56:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545316824550185.25258641000585; Thu, 20 Dec 2018 06:40:24 -0800 (PST) Received: from localhost ([::1]:37840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzUt-0007II-5c for importer@patchew.org; Thu, 20 Dec 2018 09:40:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzLf-0007mK-8s for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:30:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZz7S-0000GU-D2 for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:16:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44596) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZz7S-0000Fn-3u for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:16:10 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7742F8E587 for ; Thu, 20 Dec 2018 14:16:09 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 036DB605CB; Thu, 20 Dec 2018 14:16:07 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 20 Dec 2018 18:15:42 +0400 Message-Id: <20181220141553.24098-2-marcandre.lureau@redhat.com> In-Reply-To: <20181220141553.24098-1-marcandre.lureau@redhat.com> References: <20181220141553.24098-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 20 Dec 2018 14:16:09 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 01/12] configure: bump spice-server required version to 0.12.5 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Looking at chardev/spice.c code, I realize compilation was broken for a while with spice-server < 0.12.3. Let's bump required version to 0.12.5, released May 19 2014, instead of adding more #ifdef. (this patch combines changes from an early version and some of Frediano "[PATCH 2/2] spice: Bump required spice-server version to 0.12.6") According to repology, all the distros that are build target platforms for QEMU include it: RHEL-7: 0.14.0 Debian (Stretch): 0.12.8 Debian (Jessie): 0.12.5 FreeBSD (ports): 0.14.0 OpenSUSE Leap 15: 0.14.0 Ubuntu (Xenial): 0.12.6 Note that a previous version of this patch was bumping version to 0.12.6. Unfortunately, Debian Jessie (oldstable) is stuck with spice server 0.12.5, and QEMU should keep building until after 2y of current stable (Stretch), which will be around June 17th 2019. Qemu 4.1 should thus be free of bumping to spice-server 0.12.6 during 4.1 development cycle. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 Tested-by: Victor Toso --- include/ui/qemu-spice.h | 6 ------ chardev/spice.c | 10 ---------- hw/display/qxl.c | 2 -- ui/spice-core.c | 8 -------- configure | 4 ++-- 5 files changed, 2 insertions(+), 28 deletions(-) diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index c6d50eb87a..8c23dfe717 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -46,13 +46,7 @@ int qemu_spice_migrate_info(const char *hostname, int po= rt, int tls_port, #else #define SPICE_NEEDS_SET_MM_TIME 0 #endif - -#if SPICE_SERVER_VERSION >=3D 0x000c02 void qemu_spice_register_ports(void); -#else -static inline Chardev *qemu_chr_open_spice_port(const char *name) -{ return NULL; } -#endif =20 #else /* CONFIG_SPICE */ =20 diff --git a/chardev/spice.c b/chardev/spice.c index e66e3ad568..173c257949 100644 --- a/chardev/spice.c +++ b/chardev/spice.c @@ -77,7 +77,6 @@ static int vmc_read(SpiceCharDeviceInstance *sin, uint8_t= *buf, int len) return bytes; } =20 -#if SPICE_SERVER_VERSION >=3D 0x000c02 static void vmc_event(SpiceCharDeviceInstance *sin, uint8_t event) { SpiceChardev *scd =3D container_of(sin, SpiceChardev, sin); @@ -95,7 +94,6 @@ static void vmc_event(SpiceCharDeviceInstance *sin, uint8= _t event) trace_spice_vmc_event(chr_event); qemu_chr_be_event(chr, chr_event); } -#endif =20 static void vmc_state(SpiceCharDeviceInstance *sin, int connected) { @@ -119,9 +117,7 @@ static SpiceCharDeviceInterface vmc_interface =3D { .state =3D vmc_state, .write =3D vmc_write, .read =3D vmc_read, -#if SPICE_SERVER_VERSION >=3D 0x000c02 .event =3D vmc_event, -#endif #if SPICE_SERVER_VERSION >=3D 0x000c06 .flags =3D SPICE_CHAR_DEVICE_NOTIFY_WRITABLE, #endif @@ -223,9 +219,7 @@ static void char_spice_finalize(Object *obj) } =20 g_free((char *)s->sin.subtype); -#if SPICE_SERVER_VERSION >=3D 0x000c02 g_free((char *)s->sin.portname); -#endif } =20 static void spice_vmc_set_fe_open(struct Chardev *chr, int fe_open) @@ -240,7 +234,6 @@ static void spice_vmc_set_fe_open(struct Chardev *chr, = int fe_open) =20 static void spice_port_set_fe_open(struct Chardev *chr, int fe_open) { -#if SPICE_SERVER_VERSION >=3D 0x000c02 SpiceChardev *s =3D SPICE_CHARDEV(chr); =20 if (fe_open) { @@ -248,7 +241,6 @@ static void spice_port_set_fe_open(struct Chardev *chr,= int fe_open) } else { spice_server_port_event(&s->sin, SPICE_PORT_EVENT_CLOSED); } -#endif } =20 static void spice_chr_accept_input(struct Chardev *chr) @@ -298,7 +290,6 @@ static void qemu_chr_open_spice_vmc(Chardev *chr, chr_open(chr, type); } =20 -#if SPICE_SERVER_VERSION >=3D 0x000c02 static void qemu_chr_open_spice_port(Chardev *chr, ChardevBackend *backend, bool *be_opened, @@ -331,7 +322,6 @@ void qemu_spice_register_ports(void) vmc_register_interface(s); } } -#endif =20 static void qemu_chr_parse_spice_vmc(QemuOpts *opts, ChardevBackend *backe= nd, Error **errp) diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 9087db5dee..8e9a65e75b 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -1189,9 +1189,7 @@ static void qxl_enter_vga_mode(PCIQXLDevice *d) return; } trace_qxl_enter_vga_mode(d->id); -#if SPICE_SERVER_VERSION >=3D 0x000c03 /* release 0.12.3 */ spice_qxl_driver_unload(&d->ssd.qxl); -#endif graphic_console_set_hwops(d->ssd.dcl.con, d->vga.hw_ops, &d->vga); update_displaychangelistener(&d->ssd.dcl, GUI_REFRESH_INTERVAL_DEFAULT= ); qemu_spice_create_host_primary(&d->ssd); diff --git a/ui/spice-core.c b/ui/spice-core.c index ebaae24643..fc850b3f50 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -745,13 +745,7 @@ void qemu_spice_init(void) } =20 if (qemu_opt_get_bool(opts, "disable-agent-file-xfer", 0)) { -#if SPICE_SERVER_VERSION >=3D 0x000c04 spice_server_set_agent_file_xfer(spice_server, false); -#else - error_report("this qemu build does not support the " - "\"disable-agent-file-xfer\" option"); - exit(1); -#endif } =20 compression =3D SPICE_IMAGE_COMPRESS_AUTO_GLZ; @@ -817,9 +811,7 @@ void qemu_spice_init(void) g_free(x509_cert_file); g_free(x509_cacert_file); =20 -#if SPICE_SERVER_VERSION >=3D 0x000c02 qemu_spice_register_ports(); -#endif =20 #ifdef HAVE_SPICE_GL if (qemu_opt_get_bool(opts, "gl", 0)) { diff --git a/configure b/configure index 224d3071ac..b0927b882a 100755 --- a/configure +++ b/configure @@ -4599,7 +4599,7 @@ int main(void) { spice_server_new(); return 0; } EOF spice_cflags=3D$($pkg_config --cflags spice-protocol spice-server 2>/dev= /null) spice_libs=3D$($pkg_config --libs spice-protocol spice-server 2>/dev/nul= l) - if $pkg_config --atleast-version=3D0.12.0 spice-server && \ + if $pkg_config --atleast-version=3D0.12.5 spice-server && \ $pkg_config --atleast-version=3D0.12.3 spice-protocol && \ compile_prog "$spice_cflags" "$spice_libs" ; then spice=3D"yes" @@ -4610,7 +4610,7 @@ EOF else if test "$spice" =3D "yes" ; then feature_not_found "spice" \ - "Install spice-server(>=3D0.12.0) and spice-protocol(>=3D0.12.3)= devel" + "Install spice-server(>=3D0.12.5) and spice-protocol(>=3D0.12.3)= devel" fi spice=3D"no" fi --=20 2.20.1.2.gb21ebb671b From nobody Fri Nov 7 01:56:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545316814180850.8511103155297; Thu, 20 Dec 2018 06:40:14 -0800 (PST) Received: from localhost ([::1]:37839 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzUi-00078g-Qw for importer@patchew.org; Thu, 20 Dec 2018 09:40:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzLf-00077D-6x for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:30:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZz7a-0000Mt-8F for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:16:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40274) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZz7a-0000MC-2d for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:16:18 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66728A4058 for ; Thu, 20 Dec 2018 14:16:17 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5545917D1D; Thu, 20 Dec 2018 14:16:13 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 20 Dec 2018 18:15:43 +0400 Message-Id: <20181220141553.24098-3-marcandre.lureau@redhat.com> In-Reply-To: <20181220141553.24098-1-marcandre.lureau@redhat.com> References: <20181220141553.24098-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 20 Dec 2018 14:16:17 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 02/12] char/spice: trigger HUP event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Inform the front-end of disconnected state (spice client disconnected). This will wakeup the source handler immediately, so it can detect the disconnection asap. Signed-off-by: Marc-Andr=C3=A9 Lureau Tested-by: Victor Toso --- chardev/spice.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/chardev/spice.c b/chardev/spice.c index 173c257949..c2baeb5461 100644 --- a/chardev/spice.c +++ b/chardev/spice.c @@ -148,15 +148,25 @@ static void vmc_unregister_interface(SpiceChardev *sc= d) static gboolean spice_char_source_prepare(GSource *source, gint *timeout) { SpiceCharSource *src =3D (SpiceCharSource *)source; + Chardev *chr =3D CHARDEV(src->scd); =20 *timeout =3D -1; =20 + if (!chr->be_open) { + return true; + } + return !src->scd->blocked; } =20 static gboolean spice_char_source_check(GSource *source) { SpiceCharSource *src =3D (SpiceCharSource *)source; + Chardev *chr =3D CHARDEV(src->scd); + + if (!chr->be_open) { + return true; + } =20 return !src->scd->blocked; } @@ -164,9 +174,12 @@ static gboolean spice_char_source_check(GSource *sourc= e) static gboolean spice_char_source_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { + SpiceCharSource *src =3D (SpiceCharSource *)source; + Chardev *chr =3D CHARDEV(src->scd); GIOFunc func =3D (GIOFunc)callback; + GIOCondition cond =3D chr->be_open ? G_IO_OUT : G_IO_HUP; =20 - return func(NULL, G_IO_OUT, user_data); + return func(NULL, cond, user_data); } =20 static GSourceFuncs SpiceCharSourceFuncs =3D { --=20 2.20.1.2.gb21ebb671b From nobody Fri Nov 7 01:56:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545316925392320.96380803905845; Thu, 20 Dec 2018 06:42:05 -0800 (PST) Received: from localhost ([::1]:37853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzWW-0008Vy-2J for importer@patchew.org; Thu, 20 Dec 2018 09:42:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzLf-0007gN-6e for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:30:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZz7i-0000TO-Bv for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:16:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38104) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZz7i-0000ST-2f for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:16:26 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 655B93D957 for ; Thu, 20 Dec 2018 14:16:25 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22CE05EDEB; Thu, 20 Dec 2018 14:16:21 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 20 Dec 2018 18:15:44 +0400 Message-Id: <20181220141553.24098-4-marcandre.lureau@redhat.com> In-Reply-To: <20181220141553.24098-1-marcandre.lureau@redhat.com> References: <20181220141553.24098-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 20 Dec 2018 14:16:25 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 03/12] char/spice: discard write() if backend is disconnected X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Most chardev backend handle write() as discarded data if underlying system is disconnected. For unknown historical reasons, the Spice backend has "reliable" write: it will wait until the client end is reconnected to do further successful write(). To decide whether it make sense to wait until the client is reconnected (or queue the writes), let's review Spice chardev usage and handling of a disconnected client: * spice vdagent The agents reopen the virtio port on disconnect. In qemu side, virtio_serial_close() will also discard pending data. * usb redirection A disconnect creates a device disconnection. * smartcard emulation Data is discarded in passthru_apdu_from_guest(). (Spice doesn't explicitly open the smartcard char device until upcoming 0.14.2, commit 69a5cfc74131ec0459f2eb5a231139f5a69a8037) * spice webdavd The daemon will restart the service, and reopen the virtio port. * spice ports (serial console, qemu monitor..) Depends on the associated device or usage. - serial, may be throttled or discarded on write, depending on device - QMP/HMP monitor have some CLOSED event handling, but want to flush the write, which will finish when a new client connects. On disconnect/reconnect, the client starts with fresh sessions. If it is a seamless migration, the client disconnects after the source migrated. The handling of source disconnect in qemu is thus irrelevant for the Spice session migration. For all these use cases, it is better to discard writes when the client is disconnected, and require the vm-side device/agent to behave correctly on CHR_EVENT_CLOSED, to stop reading and writing from the spice chardev. Signed-off-by: Marc-Andr=C3=A9 Lureau Tested-by: Victor Toso --- chardev/spice.c | 12 ++++++++++++ chardev/trace-events | 1 + 2 files changed, 13 insertions(+) diff --git a/chardev/spice.c b/chardev/spice.c index c2baeb5461..c68e60115b 100644 --- a/chardev/spice.c +++ b/chardev/spice.c @@ -208,6 +208,12 @@ static int spice_chr_write(Chardev *chr, const uint8_t= *buf, int len) int read_bytes; =20 assert(s->datalen =3D=3D 0); + + if (!chr->be_open) { + trace_spice_chr_discard_write(len); + return len; + } + s->datapos =3D buf; s->datalen =3D len; spice_server_char_device_wakeup(&s->sin); @@ -300,6 +306,12 @@ static void qemu_chr_open_spice_vmc(Chardev *chr, } =20 *be_opened =3D false; +#if SPICE_SERVER_VERSION < 0x000e02 + /* Spice < 0.14.2 doesn't explicitly open smartcard chardev */ + if (strcmp(type, "smartcard") =3D=3D 0) { + *be_opened =3D true; + } +#endif chr_open(chr, type); } =20 diff --git a/chardev/trace-events b/chardev/trace-events index d0e5f3bbc1..b8a7596344 100644 --- a/chardev/trace-events +++ b/chardev/trace-events @@ -10,6 +10,7 @@ wct_cmd_other(const char *cmd) "%s" wct_speed(int speed) "%d" =20 # chardev/spice.c +spice_chr_discard_write(int len) "spice chr write discarded %d" spice_vmc_write(ssize_t out, int len) "spice wrote %zd of requested %d" spice_vmc_read(int bytes, int len) "spice read %d of requested %d" spice_vmc_register_interface(void *scd) "spice vmc registered interface %p" --=20 2.20.1.2.gb21ebb671b From nobody Fri Nov 7 01:56:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545317028435193.1302400711653; Thu, 20 Dec 2018 06:43:48 -0800 (PST) Received: from localhost ([::1]:37863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzY5-0001YL-VV for importer@patchew.org; Thu, 20 Dec 2018 09:43:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzLf-0007ba-53 for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:30:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZz7z-0000lA-VU for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:16:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42390) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZz7w-0000dy-3g for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:16:42 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2B1E288E55 for ; Thu, 20 Dec 2018 14:16:34 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AF451019635; Thu, 20 Dec 2018 14:16:29 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 20 Dec 2018 18:15:45 +0400 Message-Id: <20181220141553.24098-5-marcandre.lureau@redhat.com> In-Reply-To: <20181220141553.24098-1-marcandre.lureau@redhat.com> References: <20181220141553.24098-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 20 Dec 2018 14:16:34 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 04/12] spice: avoid spice runtime assert X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The Spice server doesn't like to be started or stopped twice . It aborts with: (process:6191): Spice-ERROR **: 19:29:35.912: red-worker.c:623:handle_dev_s= tart: assertion `!worker->running' failed It's easy to avoid that situation since qemu spice_display_is_running tracks the server state. After the commit "spice: do not stop spice if VM is paused", it will be possible to pause and resume the VM, and this will call qemu_spice_display_start() twice. The easiest is to add a check for spice_display_is_running with this patch to avoid the assert. Signed-off-by: Marc-Andr=C3=A9 Lureau Tested-by: Victor Toso --- ui/spice-core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/spice-core.c b/ui/spice-core.c index fc850b3f50..1f1501de78 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -922,12 +922,20 @@ int qemu_spice_display_add_client(int csock, int skip= auth, int tls) =20 void qemu_spice_display_start(void) { + if (spice_display_is_running) { + return; + } + spice_display_is_running =3D true; spice_server_vm_start(spice_server); } =20 void qemu_spice_display_stop(void) { + if (!spice_display_is_running) { + return; + } + spice_server_vm_stop(spice_server); spice_display_is_running =3D false; } --=20 2.20.1.2.gb21ebb671b From nobody Fri Nov 7 01:56:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545316523030209.25019736796366; Thu, 20 Dec 2018 06:35:23 -0800 (PST) Received: from localhost ([::1]:37805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzQ1-0002We-5W for importer@patchew.org; Thu, 20 Dec 2018 09:35:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzLf-0007ZB-2R for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:30:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZz84-0000oi-D2 for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:16:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33234) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZz84-0000jq-4W for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:16:48 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D96B980F9B for ; Thu, 20 Dec 2018 14:16:41 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82D216B649; Thu, 20 Dec 2018 14:16:38 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 20 Dec 2018 18:15:46 +0400 Message-Id: <20181220141553.24098-6-marcandre.lureau@redhat.com> In-Reply-To: <20181220141553.24098-1-marcandre.lureau@redhat.com> References: <20181220141553.24098-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 20 Dec 2018 14:16:41 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 05/12] spice: merge options lists X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Passing several -spice options to qemu command line, or calling several time qemu_opts_set() will ignore all but the first option list. Since the spice server is a singleton, it makes sense to merge all the options, the last value being the one taken into account. This changes the behaviour from, for ex: $ qemu... -spice port=3D5900 -spice port=3D5901 -> port: 5900 to: $ qemu... -spice port=3D5900 -spice port=3D5901 -> port: 5901 (if necessary we could instead produce an error when an option is given twice, although this makes handling default values and such more complicated) Signed-off-by: Marc-Andr=C3=A9 Lureau Tested-by: Victor Toso --- ui/spice-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/spice-core.c b/ui/spice-core.c index 1f1501de78..6fefd95cea 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -398,6 +398,7 @@ static SpiceChannelList *qmp_query_spice_channels(void) static QemuOptsList qemu_spice_opts =3D { .name =3D "spice", .head =3D QTAILQ_HEAD_INITIALIZER(qemu_spice_opts.head), + .merge_lists =3D true, .desc =3D { { .name =3D "port", --=20 2.20.1.2.gb21ebb671b From nobody Fri Nov 7 01:56:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545316545271839.353270894067; Thu, 20 Dec 2018 06:35:45 -0800 (PST) Received: from localhost ([::1]:37811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzQN-0002p8-O7 for importer@patchew.org; Thu, 20 Dec 2018 09:35:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzLf-00078Y-29 for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:30:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZz84-0000oW-Bt for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:16:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33320) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZz84-0000nC-3O for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:16:48 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D7C0804E5 for ; Thu, 20 Dec 2018 14:16:46 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7E8A104C529; Thu, 20 Dec 2018 14:16:45 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 20 Dec 2018 18:15:47 +0400 Message-Id: <20181220141553.24098-7-marcandre.lureau@redhat.com> In-Reply-To: <20181220141553.24098-1-marcandre.lureau@redhat.com> References: <20181220141553.24098-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 20 Dec 2018 14:16:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 06/12] spice: do not stop spice if VM is paused X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" spice_server_vm_start/stop() was added to help migration state (commit f5bb039c6d97ef3e664094eab3c9a4dc1824ed73). However, a paused VM could keep running the spice server. This will allow a Spice client to keep sending commands to a spice chardev. This allows to stop/cont a VM from a Spice monitor port. Character devices (vdagent/usb/smartcard/..) should not read from Spice when the VM is paused. Signed-off-by: Marc-Andr=C3=A9 Lureau Tested-by: Victor Toso --- ui/spice-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/spice-core.c b/ui/spice-core.c index 6fefd95cea..9627f07cd8 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -628,7 +628,7 @@ static void vm_change_state_handler(void *opaque, int r= unning, { if (running) { qemu_spice_display_start(); - } else { + } else if (state !=3D RUN_STATE_PAUSED) { qemu_spice_display_stop(); } } --=20 2.20.1.2.gb21ebb671b From nobody Fri Nov 7 01:56:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545316349218910.427506327362; Thu, 20 Dec 2018 06:32:29 -0800 (PST) Received: from localhost ([::1]:37788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzNB-00007r-UI for importer@patchew.org; Thu, 20 Dec 2018 09:32:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzKr-0007CF-Fp for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:30:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZz87-0000rX-Gp for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:16:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43934) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZz87-0000r0-79 for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:16:51 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 834B0C0495B0 for ; Thu, 20 Dec 2018 14:16:50 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E05E17C5B; Thu, 20 Dec 2018 14:16:49 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 20 Dec 2018 18:15:48 +0400 Message-Id: <20181220141553.24098-8-marcandre.lureau@redhat.com> In-Reply-To: <20181220141553.24098-1-marcandre.lureau@redhat.com> References: <20181220141553.24098-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 20 Dec 2018 14:16:50 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 07/12] char: move SpiceChardev and open_spice_port() to spice.h header X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This will allow easier subclassing of SpiceChardev, in upcoming "display: add -display app launching external application" patch. Signed-off-by: Marc-Andr=C3=A9 Lureau Tested-by: Victor Toso --- include/chardev/spice.h | 27 +++++++++++++++++++++++++++ chardev/spice.c | 28 +++++----------------------- 2 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 include/chardev/spice.h diff --git a/include/chardev/spice.h b/include/chardev/spice.h new file mode 100644 index 0000000000..6431da3205 --- /dev/null +++ b/include/chardev/spice.h @@ -0,0 +1,27 @@ +#ifndef CHARDEV_SPICE_H_ +#define CHARDEV_SPICE_H_ + +#include +#include "chardev/char-fe.h" + +typedef struct SpiceChardev { + Chardev parent; + + SpiceCharDeviceInstance sin; + bool active; + bool blocked; + const uint8_t *datapos; + int datalen; + QLIST_ENTRY(SpiceChardev) next; +} SpiceChardev; + +#define TYPE_CHARDEV_SPICE "chardev-spice" +#define TYPE_CHARDEV_SPICEVMC "chardev-spicevmc" +#define TYPE_CHARDEV_SPICEPORT "chardev-spiceport" + +#define SPICE_CHARDEV(obj) OBJECT_CHECK(SpiceChardev, (obj), TYPE_CHARDEV_= SPICE) + +void qemu_chr_open_spice_port(Chardev *chr, ChardevBackend *backend, + bool *be_opened, Error **errp); + +#endif diff --git a/chardev/spice.c b/chardev/spice.c index c68e60115b..2202d50eee 100644 --- a/chardev/spice.c +++ b/chardev/spice.c @@ -2,30 +2,12 @@ #include "trace.h" #include "ui/qemu-spice.h" #include "chardev/char.h" +#include "chardev/spice.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/option.h" -#include #include =20 - -typedef struct SpiceChardev { - Chardev parent; - - SpiceCharDeviceInstance sin; - bool active; - bool blocked; - const uint8_t *datapos; - int datalen; - QLIST_ENTRY(SpiceChardev) next; -} SpiceChardev; - -#define TYPE_CHARDEV_SPICE "chardev-spice" -#define TYPE_CHARDEV_SPICEVMC "chardev-spicevmc" -#define TYPE_CHARDEV_SPICEPORT "chardev-spiceport" - -#define SPICE_CHARDEV(obj) OBJECT_CHECK(SpiceChardev, (obj), TYPE_CHARDEV_= SPICE) - typedef struct SpiceCharSource { GSource source; SpiceChardev *scd; @@ -315,10 +297,10 @@ static void qemu_chr_open_spice_vmc(Chardev *chr, chr_open(chr, type); } =20 -static void qemu_chr_open_spice_port(Chardev *chr, - ChardevBackend *backend, - bool *be_opened, - Error **errp) +void qemu_chr_open_spice_port(Chardev *chr, + ChardevBackend *backend, + bool *be_opened, + Error **errp) { ChardevSpicePort *spiceport =3D backend->u.spiceport.data; const char *name =3D spiceport->fqdn; --=20 2.20.1.2.gb21ebb671b From nobody Fri Nov 7 01:56:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545316527789468.59290066648964; Thu, 20 Dec 2018 06:35:27 -0800 (PST) Received: from localhost ([::1]:37806 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzQ6-0002Xh-9D for importer@patchew.org; Thu, 20 Dec 2018 09:35:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzLc-000770-Cs for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:30:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZz8I-00011k-VW for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:17:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33534) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZz8I-00011L-Pt for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:17:02 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A52F804E5 for ; Thu, 20 Dec 2018 14:17:02 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27D376063D; Thu, 20 Dec 2018 14:16:56 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 20 Dec 2018 18:15:49 +0400 Message-Id: <20181220141553.24098-9-marcandre.lureau@redhat.com> In-Reply-To: <20181220141553.24098-1-marcandre.lureau@redhat.com> References: <20181220141553.24098-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 20 Dec 2018 14:17:02 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 08/12] char: register spice ports after spice started X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Spice port registration is delayed until the server is started. But ports created after are not being registered. If the server is already started, do vmc_register_interface() to register it from qemu_chr_open_spice_port(). Signed-off-by: Marc-Andr=C3=A9 Lureau Tested-by: Victor Toso --- chardev/spice.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chardev/spice.c b/chardev/spice.c index 2202d50eee..22c30ae833 100644 --- a/chardev/spice.c +++ b/chardev/spice.c @@ -316,6 +316,11 @@ void qemu_chr_open_spice_port(Chardev *chr, *be_opened =3D false; s =3D SPICE_CHARDEV(chr); s->sin.portname =3D g_strdup(name); + + if (using_spice) { + /* spice server already created */ + vmc_register_interface(s); + } } =20 void qemu_spice_register_ports(void) --=20 2.20.1.2.gb21ebb671b From nobody Fri Nov 7 01:56:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545316701231351.61582074075966; Thu, 20 Dec 2018 06:38:21 -0800 (PST) Received: from localhost ([::1]:37826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzSn-0005Nd-5T for importer@patchew.org; Thu, 20 Dec 2018 09:38:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzLc-0007mK-BP for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:30:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZz8Q-00015K-OH for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:17:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33994) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZz8Q-00014i-IW for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:17:10 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1981D3C2CDB for ; Thu, 20 Dec 2018 14:17:09 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DB0E1823F; Thu, 20 Dec 2018 14:17:06 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 20 Dec 2018 18:15:50 +0400 Message-Id: <20181220141553.24098-10-marcandre.lureau@redhat.com> In-Reply-To: <20181220141553.24098-1-marcandre.lureau@redhat.com> References: <20181220141553.24098-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 20 Dec 2018 14:17:09 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 09/12] build-sys: add gio-2.0 check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" GIO is required for the -display app backend. Signed-off-by: Marc-Andr=C3=A9 Lureau Tested-by: Victor Toso --- configure | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/configure b/configure index b0927b882a..dd0bcc2a10 100755 --- a/configure +++ b/configure @@ -3518,6 +3518,14 @@ for i in $glib_modules; do fi done =20 +if $pkg_config --atleast-version=3D$glib_req_ver gio-2.0; then + gio=3Dyes + gio_cflags=3D$($pkg_config --cflags gio-2.0) + gio_libs=3D$($pkg_config --libs gio-2.0) +else + gio=3Dno +fi + # Sanity check that the current size_t matches the # size that glib thinks it should be. This catches # problems on multi-arch where people try to build @@ -6472,6 +6480,11 @@ if test "$gtk" =3D "yes" ; then echo "CONFIG_GTK_GL=3Dy" >> $config_host_mak fi fi +if test "$gio" =3D "yes" ; then + echo "CONFIG_GIO=3Dy" >> $config_host_mak + echo "GIO_CFLAGS=3D$gio_cflags" >> $config_host_mak + echo "GIO_LIBS=3D$gio_libs" >> $config_host_mak +fi echo "CONFIG_TLS_PRIORITY=3D\"$tls_priority\"" >> $config_host_mak if test "$gnutls" =3D "yes" ; then echo "CONFIG_GNUTLS=3Dy" >> $config_host_mak --=20 2.20.1.2.gb21ebb671b From nobody Fri Nov 7 01:56:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545316342267923.8745019885267; Thu, 20 Dec 2018 06:32:22 -0800 (PST) Received: from localhost ([::1]:37786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzN0-0008Rm-71 for importer@patchew.org; Thu, 20 Dec 2018 09:32:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzKj-00078E-Lx for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:29:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZz8X-00018b-Qg for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:17:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33728) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZz8X-00018H-Kx for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:17:17 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 058D3811C0 for ; Thu, 20 Dec 2018 14:17:17 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 614956889C; Thu, 20 Dec 2018 14:17:12 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 20 Dec 2018 18:15:51 +0400 Message-Id: <20181220141553.24098-11-marcandre.lureau@redhat.com> In-Reply-To: <20181220141553.24098-1-marcandre.lureau@redhat.com> References: <20181220141553.24098-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 20 Dec 2018 14:17:17 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 10/12] qapi: document DisplayType enum X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau Tested-by: Victor Toso --- qapi/ui.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/qapi/ui.json b/qapi/ui.json index 5ad13248d5..3f2f662dca 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1075,6 +1075,30 @@ # # Display (user interface) type. # +# @default: The default user interface. +# +# @none: No user interface or video output display. The guest will +# still see an emulated graphics card, but its output will not +# be displayed to the QEMU user. +# +# @gtk: The GTK user interface. +# +# @sdl: The SDL user interface. +# +# @egl-headless: No user interface, offload GL operations to a local +# DRI device. Graphical display need to be paired with +# VNC or Spice. (Since 3.1) +# +# @curses: Display video output via curses. For graphics device +# models which support a text mode, QEMU can display this +# output using a curses/ncurses interface. Nothing is +# displayed when the graphics device is in graphical mode or +# if the graphics device does not support a text +# mode. Generally only the VGA device models support text +# mode. +# +# @cocoa: The Cocoa user interface. +# # Since: 2.12 # ## --=20 2.20.1.2.gb21ebb671b From nobody Fri Nov 7 01:56:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545316693188566.8652804736697; Thu, 20 Dec 2018 06:38:13 -0800 (PST) Received: from localhost ([::1]:37825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzSj-0005K3-87 for importer@patchew.org; Thu, 20 Dec 2018 09:38:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzLc-0007jL-1w for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:30:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZz8f-0001CU-Sh for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:17:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34140) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZz8c-0001AP-Ht for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:17:24 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A483737E60 for ; Thu, 20 Dec 2018 14:17:21 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id A56596889C; Thu, 20 Dec 2018 14:17:20 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 20 Dec 2018 18:15:52 +0400 Message-Id: <20181220141553.24098-12-marcandre.lureau@redhat.com> In-Reply-To: <20181220141553.24098-1-marcandre.lureau@redhat.com> References: <20181220141553.24098-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 20 Dec 2018 14:17:21 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 11/12] spice: use a default name for the server X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" If no -name is given, let's use a friendly "QEMU version" server name. This is sometime exposed on spice client side, for example on remote-viewer title. Signed-off-by: Marc-Andr=C3=A9 Lureau Tested-by: Victor Toso --- ui/spice-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/spice-core.c b/ui/spice-core.c index 9627f07cd8..71ff34c927 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -785,7 +785,7 @@ void qemu_spice_init(void) =20 qemu_opt_foreach(opts, add_channel, &tls_port, &error_fatal); =20 - spice_server_set_name(spice_server, qemu_name); + spice_server_set_name(spice_server, qemu_name ?: "QEMU " QEMU_VERSION); spice_server_set_uuid(spice_server, (unsigned char *)&qemu_uuid); =20 seamless_migration =3D qemu_opt_get_bool(opts, "seamless-migration", 0= ); --=20 2.20.1.2.gb21ebb671b From nobody Fri Nov 7 01:56:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545316703019537.4212093640463; Thu, 20 Dec 2018 06:38:23 -0800 (PST) Received: from localhost ([::1]:37827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzSv-0005UB-Ax for importer@patchew.org; Thu, 20 Dec 2018 09:38:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZzLb-0007jJ-Od for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:30:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZz8n-0001Hg-Or for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:17:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39104) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZz8m-0001ES-Bg for qemu-devel@nongnu.org; Thu, 20 Dec 2018 09:17:33 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 859681E339 for ; Thu, 20 Dec 2018 14:17:29 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D7A31054FD7; Thu, 20 Dec 2018 14:17:25 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 20 Dec 2018 18:15:53 +0400 Message-Id: <20181220141553.24098-13-marcandre.lureau@redhat.com> In-Reply-To: <20181220141553.24098-1-marcandre.lureau@redhat.com> References: <20181220141553.24098-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 20 Dec 2018 14:17:29 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 12/12] display: add -display spice-app launching a Spice client X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add a new display backend that will configure Spice to allow a remote client to control QEMU in a similar fashion as other QEMU display backend/UI like GTK. For this to work, it will set up Spice server with a unix socket, and register a VC chardev that will be exposed as Spice ports. A QMP monitor is also exposed as a Spice port, this allows the remote client fuller qemu control and state handling. - doesn't handle VC set_echo() - this doesn't seem a strong requirement, very few front-end use it - spice options can be tweaked with other -spice arguments - Windows support shouldn't be hard to do, but will probably use a TCP port instead - we may want to watch the child process to quit automatically if it crashed Signed-off-by: Marc-Andr=C3=A9 Lureau Tested-by: Victor Toso --- qapi/ui.json | 7 +- ui/spice-app.c | 200 +++++++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 5 ++ ui/Makefile.objs | 5 ++ 4 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 ui/spice-app.c diff --git a/qapi/ui.json b/qapi/ui.json index 3f2f662dca..56092706dd 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1099,12 +1099,17 @@ # # @cocoa: The Cocoa user interface. # +# @spice-app: Set up a Spice server and run the default associated +# application to connect to it. The server will redirect +# the serial console and QEMU monitors. (Since 4.0) +# # Since: 2.12 # ## { 'enum' : 'DisplayType', 'data' : [ 'default', 'none', 'gtk', 'sdl', - 'egl-headless', 'curses', 'cocoa' ] } + 'egl-headless', 'curses', 'cocoa', + 'spice-app'] } =20 ## # @DisplayOptions: diff --git a/ui/spice-app.c b/ui/spice-app.c new file mode 100644 index 0000000000..1d283d7ba3 --- /dev/null +++ b/ui/spice-app.c @@ -0,0 +1,200 @@ +/* + * QEMU external Spice client display driver + * + * Copyright (c) 2018 Marc-Andr=C3=A9 Lureau + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ +#include "qemu/osdep.h" + +#include + +#include "qemu-common.h" +#include "ui/console.h" +#include "qemu/config-file.h" +#include "qemu/option.h" +#include "qemu/cutils.h" +#include "qapi/error.h" +#include "io/channel-command.h" +#include "chardev/spice.h" +#include "sysemu/sysemu.h" + +static const char *tmp_dir; +static char *app_dir; +static char *sock_path; + +typedef struct VCChardev { + SpiceChardev parent; +} VCChardev; + +#define TYPE_CHARDEV_VC "chardev-vc" +#define VC_CHARDEV(obj) OBJECT_CHECK(VCChardev, (obj), TYPE_CHARDEV_VC) + +static ChardevBackend * +chr_spice_backend_new(void) +{ + ChardevBackend *be =3D g_new0(ChardevBackend, 1); + + be->type =3D CHARDEV_BACKEND_KIND_SPICEPORT; + be->u.spiceport.data =3D g_new0(ChardevSpicePort, 1); + + return be; +} + +static void vc_chr_open(Chardev *chr, + ChardevBackend *backend, + bool *be_opened, + Error **errp) +{ + ChardevBackend *be; + const char *fqdn =3D NULL; + + if (strstart(chr->label, "serial", NULL)) { + fqdn =3D "org.qemu.console.serial.0"; + } else if (strstart(chr->label, "parallel", NULL)) { + fqdn =3D "org.qemu.console.parallel.0"; + } else if (strstart(chr->label, "compat_monitor", NULL)) { + fqdn =3D "org.qemu.monitor.hmp.0"; + } + + be =3D chr_spice_backend_new(); + be->u.spiceport.data->fqdn =3D fqdn ? + g_strdup(fqdn) : g_strdup_printf("org.qemu.console.%s", chr->label= ); + qemu_chr_open_spice_port(chr, be, be_opened, errp); + qapi_free_ChardevBackend(be); +} + +static void vc_chr_set_echo(Chardev *chr, bool echo) +{ + /* TODO: set echo for frontends QMP and qtest */ +} + +static void char_vc_class_init(ObjectClass *oc, void *data) +{ + ChardevClass *cc =3D CHARDEV_CLASS(oc); + + cc->parse =3D qemu_chr_parse_vc; + cc->open =3D vc_chr_open; + cc->chr_set_echo =3D vc_chr_set_echo; +} + +static const TypeInfo char_vc_type_info =3D { + .name =3D TYPE_CHARDEV_VC, + .parent =3D TYPE_CHARDEV_SPICEPORT, + .instance_size =3D sizeof(VCChardev), + .class_init =3D char_vc_class_init, +}; + +static void spice_app_atexit(void) +{ + if (sock_path) { + unlink(sock_path); + } + if (tmp_dir) { + rmdir(tmp_dir); + } + g_free(sock_path); + g_free(app_dir); +} + +static void spice_app_display_early_init(DisplayOptions *opts) +{ + QemuOpts *qopts; + ChardevBackend *be =3D chr_spice_backend_new(); + GError *err =3D NULL; + + if (opts->has_full_screen) { + error_report("spice-app full-screen isn't supported yet."); + exit(1); + } + if (opts->has_window_close) { + error_report("spice-app window-close isn't supported yet."); + exit(1); + } + + atexit(spice_app_atexit); + + if (qemu_name) { + app_dir =3D g_build_filename(g_get_user_runtime_dir(), + "qemu", qemu_name, NULL); + if (g_mkdir_with_parents(app_dir, S_IRWXU) < -1) { + error_report("Failed to create directory %s: %s", + app_dir, strerror(errno)); + exit(1); + } + } else { + app_dir =3D g_dir_make_tmp(NULL, &err); + tmp_dir =3D app_dir; + if (err) { + error_report("Failed to create temporary directory: %s", + err->message); + exit(1); + } + } + + type_register(&char_vc_type_info); + + sock_path =3D g_strjoin("", app_dir, "/", "spice.sock", NULL); + qopts =3D qemu_opts_create(qemu_find_opts("spice"), NULL, 0, &error_ab= ort); + qemu_opt_set(qopts, "disable-ticketing", "on", &error_abort); + qemu_opt_set(qopts, "unix", "on", &error_abort); + qemu_opt_set(qopts, "addr", sock_path, &error_abort); + qemu_opt_set(qopts, "image-compression", "off", &error_abort); + qemu_opt_set(qopts, "streaming-video", "off", &error_abort); + qemu_opt_set(qopts, "gl", opts->has_gl ? "on" : "off", &error_abort); + display_opengl =3D opts->has_gl; + + be->u.spiceport.data->fqdn =3D g_strdup("org.qemu.monitor.qmp.0"); + qemu_chardev_new("org.qemu.monitor.qmp", TYPE_CHARDEV_SPICEPORT, + be, &error_abort); + qopts =3D qemu_opts_create(qemu_find_opts("mon"), + NULL, 0, &error_fatal); + qemu_opt_set(qopts, "chardev", "org.qemu.monitor.qmp", &error_abort); + qemu_opt_set(qopts, "mode", "control", &error_abort); + + qapi_free_ChardevBackend(be); +} + +static void spice_app_display_init(DisplayState *ds, DisplayOptions *opts) +{ + GError *err =3D NULL; + gchar *uri; + + uri =3D g_strjoin("", "spice+unix://", app_dir, "/", "spice.sock", NUL= L); + info_report("Launching display with URI: %s", uri); + g_app_info_launch_default_for_uri(uri, NULL, &err); + if (err) { + error_report("Failed to launch %s URI: %s", uri, err->message); + exit(1); + } + g_free(uri); +} + +static QemuDisplay qemu_display_spice_app =3D { + .type =3D DISPLAY_TYPE_SPICE_APP, + .early_init =3D spice_app_display_early_init, + .init =3D spice_app_display_init, +}; + +static void register_spice_app(void) +{ + qemu_display_register(&qemu_display_spice_app); +} + +type_init(register_spice_app); diff --git a/qemu-options.hx b/qemu-options.hx index df42116ecc..e13425fbc2 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1211,6 +1211,7 @@ STEXI ETEXI =20 DEF("display", HAS_ARG, QEMU_OPTION_display, + "-display spice-app[,gl=3Don|off]\n" "-display sdl[,frame=3Don|off][,alt_grab=3Don|off][,ctrl_grab=3Don|off= ]\n" " [,window_close=3Don|off][,gl=3Don|core|es|off]\n" "-display gtk[,grab_on_hover=3Don|off][,gl=3Don|off]|\n" @@ -1262,6 +1263,10 @@ Start a VNC server on display @item egl-headless Offload all OpenGL operations to a local DRI device. For any graphical dis= play, this display needs to be paired with either VNC or SPICE displays. +@item spice-app +Start QEMU as a Spice server and launch the default Spice client +application. The Spice server will redirect the serial consoles and +QEMU monitors. (Since 4.0) @end table ETEXI =20 diff --git a/ui/Makefile.objs b/ui/Makefile.objs index 00f6976c30..5b155d2292 100644 --- a/ui/Makefile.objs +++ b/ui/Makefile.objs @@ -54,6 +54,11 @@ curses.mo-objs :=3D curses.o curses.mo-cflags :=3D $(CURSES_CFLAGS) curses.mo-libs :=3D $(CURSES_LIBS) =20 +common-obj-$(call land,$(CONFIG_SPICE),$(CONFIG_GIO)) +=3D spice-app.mo +spice-app.mo-objs :=3D spice-app.o +spice-app.mo-cflags :=3D $(GIO_CFLAGS) +spice-app.mo-libs :=3D $(GIO_LIBS) + common-obj-$(CONFIG_OPENGL) +=3D shader.o common-obj-$(CONFIG_OPENGL) +=3D console-gl.o common-obj-$(CONFIG_OPENGL) +=3D egl-helpers.o --=20 2.20.1.2.gb21ebb671b