From patchwork Thu Feb 21 11:06:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1046087 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 444slY3fmJz9s7h for ; Thu, 21 Feb 2019 22:32:41 +1100 (AEDT) Received: from localhost ([127.0.0.1]:58656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmal-0006mi-9Q for incoming@patchwork.ozlabs.org; Thu, 21 Feb 2019 06:32:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmCC-0001sr-CJ for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwmC9-0006kp-Cd for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54185) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwmC8-0006jK-BJ for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:12 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0CBF683F4C for ; Thu, 21 Feb 2019 11:07:11 +0000 (UTC) Received: from localhost (ovpn-112-68.ams2.redhat.com [10.36.112.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85E6D1A8F3; Thu, 21 Feb 2019 11:07:08 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 12:06:53 +0100 Message-Id: <20190221110703.5775-2-marcandre.lureau@redhat.com> In-Reply-To: <20190221110703.5775-1-marcandre.lureau@redhat.com> References: <20190221110703.5775-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 21 Feb 2019 11:07:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 01/11] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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é 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 *scd) static gboolean spice_char_source_prepare(GSource *source, gint *timeout) { SpiceCharSource *src = (SpiceCharSource *)source; + Chardev *chr = CHARDEV(src->scd); *timeout = -1; + if (!chr->be_open) { + return true; + } + return !src->scd->blocked; } static gboolean spice_char_source_check(GSource *source) { SpiceCharSource *src = (SpiceCharSource *)source; + Chardev *chr = CHARDEV(src->scd); + + if (!chr->be_open) { + return true; + } return !src->scd->blocked; } @@ -164,9 +174,12 @@ static gboolean spice_char_source_check(GSource *source) static gboolean spice_char_source_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { + SpiceCharSource *src = (SpiceCharSource *)source; + Chardev *chr = CHARDEV(src->scd); GIOFunc func = (GIOFunc)callback; + GIOCondition cond = chr->be_open ? G_IO_OUT : G_IO_HUP; - return func(NULL, G_IO_OUT, user_data); + return func(NULL, cond, user_data); } static GSourceFuncs SpiceCharSourceFuncs = { From patchwork Thu Feb 21 11:06:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1046073 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 444sVb1b3Mz9s5c for ; Thu, 21 Feb 2019 22:21:27 +1100 (AEDT) Received: from localhost ([127.0.0.1]:58507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmPt-0005em-5U for incoming@patchwork.ozlabs.org; Thu, 21 Feb 2019 06:21:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmCG-0001wx-LE for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwmCE-0006nn-8U for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47524) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwmCC-0006lz-Bg for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:16 -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 D877F5AFE3 for ; Thu, 21 Feb 2019 11:07:14 +0000 (UTC) Received: from localhost (ovpn-112-68.ams2.redhat.com [10.36.112.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B7D260163; Thu, 21 Feb 2019 11:07:12 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 12:06:54 +0100 Message-Id: <20190221110703.5775-3-marcandre.lureau@redhat.com> In-Reply-To: <20190221110703.5775-1-marcandre.lureau@redhat.com> References: <20190221110703.5775-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.39]); Thu, 21 Feb 2019 11:07:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 02/11] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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é 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; assert(s->datalen == 0); + + if (!chr->be_open) { + trace_spice_chr_discard_write(len); + return len; + } + s->datapos = buf; s->datalen = len; spice_server_char_device_wakeup(&s->sin); @@ -300,6 +306,12 @@ static void qemu_chr_open_spice_vmc(Chardev *chr, } *be_opened = false; +#if SPICE_SERVER_VERSION < 0x000e02 + /* Spice < 0.14.2 doesn't explicitly open smartcard chardev */ + if (strcmp(type, "smartcard") == 0) { + *be_opened = true; + } +#endif chr_open(chr, type); } 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" # 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" From patchwork Thu Feb 21 11:06:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1046076 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 444sYT32kxz9s7h for ; Thu, 21 Feb 2019 22:23:57 +1100 (AEDT) Received: from localhost ([127.0.0.1]:58524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmSJ-0007Mv-E9 for incoming@patchwork.ozlabs.org; Thu, 21 Feb 2019 06:23:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmCH-0001xV-8D for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwmCG-0006p2-DJ for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51342) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwmCE-0006n1-7R for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:18 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7D2C81F10 for ; Thu, 21 Feb 2019 11:07:16 +0000 (UTC) Received: from localhost (ovpn-112-68.ams2.redhat.com [10.36.112.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38B921A8F3; Thu, 21 Feb 2019 11:07:15 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 12:06:55 +0100 Message-Id: <20190221110703.5775-4-marcandre.lureau@redhat.com> In-Reply-To: <20190221110703.5775-1-marcandre.lureau@redhat.com> References: <20190221110703.5775-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 21 Feb 2019 11:07:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 03/11] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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_start: 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é 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 a40fb2c00d..94b31ce3ad 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -921,12 +921,20 @@ int qemu_spice_display_add_client(int csock, int skipauth, int tls) void qemu_spice_display_start(void) { + if (spice_display_is_running) { + return; + } + spice_display_is_running = true; spice_server_vm_start(spice_server); } void qemu_spice_display_stop(void) { + if (!spice_display_is_running) { + return; + } + spice_server_vm_stop(spice_server); spice_display_is_running = false; } From patchwork Thu Feb 21 11:06:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1046078 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 444sZN5wNQz9s5c for ; Thu, 21 Feb 2019 22:24:44 +1100 (AEDT) Received: from localhost ([127.0.0.1]:58533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmT4-000801-Ok for incoming@patchwork.ozlabs.org; Thu, 21 Feb 2019 06:24:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmCK-00020u-LS for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwmCH-0006pc-0Z for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43304) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwmCG-0006o3-M6 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:20 -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 7F8A9C057F3D for ; Thu, 21 Feb 2019 11:07:18 +0000 (UTC) Received: from localhost (ovpn-112-68.ams2.redhat.com [10.36.112.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 116E66014E; Thu, 21 Feb 2019 11:07:17 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 12:06:56 +0100 Message-Id: <20190221110703.5775-5-marcandre.lureau@redhat.com> In-Reply-To: <20190221110703.5775-1-marcandre.lureau@redhat.com> References: <20190221110703.5775-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.32]); Thu, 21 Feb 2019 11:07:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 04/11] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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=5900 -spice port=5901 -> port: 5900 to: $ qemu... -spice port=5900 -spice port=5901 -> 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é 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 94b31ce3ad..91d0960522 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -397,6 +397,7 @@ static SpiceChannelList *qmp_query_spice_channels(void) static QemuOptsList qemu_spice_opts = { .name = "spice", .head = QTAILQ_HEAD_INITIALIZER(qemu_spice_opts.head), + .merge_lists = true, .desc = { { .name = "port", From patchwork Thu Feb 21 11:06:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1046082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 444sf03kxGz9s5c for ; Thu, 21 Feb 2019 22:27:52 +1100 (AEDT) Received: from localhost ([127.0.0.1]:58589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmW6-0002Xk-EM for incoming@patchwork.ozlabs.org; Thu, 21 Feb 2019 06:27:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmCS-00025e-3g for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwmCO-0006u9-IC for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34736) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwmCL-0006qf-1E for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:26 -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 4D1DC308FC22 for ; Thu, 21 Feb 2019 11:07:22 +0000 (UTC) Received: from localhost (ovpn-112-68.ams2.redhat.com [10.36.112.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id E00871001DD1; Thu, 21 Feb 2019 11:07:19 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 12:06:57 +0100 Message-Id: <20190221110703.5775-6-marcandre.lureau@redhat.com> In-Reply-To: <20190221110703.5775-1-marcandre.lureau@redhat.com> References: <20190221110703.5775-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.43]); Thu, 21 Feb 2019 11:07:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 05/11] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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é 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 91d0960522..92eebe5f0e 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -627,7 +627,7 @@ static void vm_change_state_handler(void *opaque, int running, { if (running) { qemu_spice_display_start(); - } else { + } else if (state != RUN_STATE_PAUSED) { qemu_spice_display_stop(); } } From patchwork Thu Feb 21 11:06:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1046080 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 444sd5094bz9s7h for ; Thu, 21 Feb 2019 22:27:05 +1100 (AEDT) Received: from localhost ([127.0.0.1]:58579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmVK-0001vz-VU for incoming@patchwork.ozlabs.org; Thu, 21 Feb 2019 06:27:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmCV-00028O-Ag for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwmCS-0006wV-5X for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45700) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwmCO-0006sp-H6 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:30 -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 15B898665D for ; Thu, 21 Feb 2019 11:07:26 +0000 (UTC) Received: from localhost (ovpn-112-68.ams2.redhat.com [10.36.112.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC33560851; Thu, 21 Feb 2019 11:07:23 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 12:06:58 +0100 Message-Id: <20190221110703.5775-7-marcandre.lureau@redhat.com> In-Reply-To: <20190221110703.5775-1-marcandre.lureau@redhat.com> References: <20190221110703.5775-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.26]); Thu, 21 Feb 2019 11:07:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 06/11] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This will allow easier subclassing of SpiceChardev, in upcoming "display: add -display spice-app launching external application" patch. Signed-off-by: Marc-André 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 - -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); } -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 = backend->u.spiceport.data; const char *name = spiceport->fqdn; From patchwork Thu Feb 21 11:06:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1046084 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 444shS4l0tz9sCH for ; Thu, 21 Feb 2019 22:30:00 +1100 (AEDT) Received: from localhost ([127.0.0.1]:58606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmYA-0004Vn-JP for incoming@patchwork.ozlabs.org; Thu, 21 Feb 2019 06:29:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmCW-00029D-5i for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwmCV-0006yd-DO for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:7977) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwmCS-0006to-6m for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:34 -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 E63C286663 for ; Thu, 21 Feb 2019 11:07:27 +0000 (UTC) Received: from localhost (ovpn-112-68.ams2.redhat.com [10.36.112.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7815160139; Thu, 21 Feb 2019 11:07:27 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 12:06:59 +0100 Message-Id: <20190221110703.5775-8-marcandre.lureau@redhat.com> In-Reply-To: <20190221110703.5775-1-marcandre.lureau@redhat.com> References: <20190221110703.5775-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.26]); Thu, 21 Feb 2019 11:07:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 07/11] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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é 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 = false; s = SPICE_CHARDEV(chr); s->sin.portname = g_strdup(name); + + if (using_spice) { + /* spice server already created */ + vmc_register_interface(s); + } } void qemu_spice_register_ports(void) From patchwork Thu Feb 21 11:07:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1046085 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 444sjC2QpZz9s7h for ; Thu, 21 Feb 2019 22:30:39 +1100 (AEDT) Received: from localhost ([127.0.0.1]:58610 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmYn-0005Ls-6k for incoming@patchwork.ozlabs.org; Thu, 21 Feb 2019 06:30:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmCW-00029C-5a for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwmCV-0006yo-Hf for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47662) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwmCV-0006wH-As for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:35 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E78995944D for ; Thu, 21 Feb 2019 11:07:31 +0000 (UTC) Received: from localhost (ovpn-112-68.ams2.redhat.com [10.36.112.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 521C227BAC; Thu, 21 Feb 2019 11:07:29 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 12:07:00 +0100 Message-Id: <20190221110703.5775-9-marcandre.lureau@redhat.com> In-Reply-To: <20190221110703.5775-1-marcandre.lureau@redhat.com> References: <20190221110703.5775-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 21 Feb 2019 11:07:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 08/11] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" GIO is required for the "-display spice-app" backend. Signed-off-by: Marc-André Lureau Tested-by: Victor Toso --- configure | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/configure b/configure index a61682c3c7..05d72f1c56 100755 --- a/configure +++ b/configure @@ -3503,6 +3503,14 @@ for i in $glib_modules; do fi done +if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then + gio=yes + gio_cflags=$($pkg_config --cflags gio-2.0) + gio_libs=$($pkg_config --libs gio-2.0) +else + gio=no +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 @@ -6520,6 +6528,11 @@ if test "$gtk" = "yes" ; then echo "CONFIG_GTK_GL=y" >> $config_host_mak fi fi +if test "$gio" = "yes" ; then + echo "CONFIG_GIO=y" >> $config_host_mak + echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak + echo "GIO_LIBS=$gio_libs" >> $config_host_mak +fi echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak if test "$gnutls" = "yes" ; then echo "CONFIG_GNUTLS=y" >> $config_host_mak From patchwork Thu Feb 21 11:07:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1046089 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 444snD4N7jz9s5c for ; Thu, 21 Feb 2019 22:34:08 +1100 (AEDT) Received: from localhost ([127.0.0.1]:58664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmcA-0007o9-Eo for incoming@patchwork.ozlabs.org; Thu, 21 Feb 2019 06:34:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmCX-0002Av-Sj for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwmCW-00070J-OL for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51622) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwmCW-0006zR-IJ for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:36 -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 D1D8330833C0 for ; Thu, 21 Feb 2019 11:07:35 +0000 (UTC) Received: from localhost (ovpn-112-68.ams2.redhat.com [10.36.112.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50FF660139; Thu, 21 Feb 2019 11:07:33 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 12:07:01 +0100 Message-Id: <20190221110703.5775-10-marcandre.lureau@redhat.com> In-Reply-To: <20190221110703.5775-1-marcandre.lureau@redhat.com> References: <20190221110703.5775-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.44]); Thu, 21 Feb 2019 11:07:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 09/11] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Marc-André Lureau Tested-by: Victor Toso --- qapi/ui.json | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/qapi/ui.json b/qapi/ui.json index 7d9c4bddaf..7702ddf583 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1085,6 +1085,31 @@ # # Display (user interface) type. # +# @default: The default user interface, selecting from the first available +# of gtk, sdl, cocoa, and vnc. +# +# @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 # ## From patchwork Thu Feb 21 11:07:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1046092 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 444srv14wDz9s5c for ; Thu, 21 Feb 2019 22:37:19 +1100 (AEDT) Received: from localhost ([127.0.0.1]:58729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmfF-0002Nm-2t for incoming@patchwork.ozlabs.org; Thu, 21 Feb 2019 06:37:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmCb-0002Eq-JP for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwmCa-00072u-HQ for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47724) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwmCa-00072L-9W for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:40 -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 962955AFE3 for ; Thu, 21 Feb 2019 11:07:39 +0000 (UTC) Received: from localhost (ovpn-112-68.ams2.redhat.com [10.36.112.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 361045D9D3; Thu, 21 Feb 2019 11:07:36 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 12:07:02 +0100 Message-Id: <20190221110703.5775-11-marcandre.lureau@redhat.com> In-Reply-To: <20190221110703.5775-1-marcandre.lureau@redhat.com> References: <20190221110703.5775-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.39]); Thu, 21 Feb 2019 11:07:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 10/11] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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é 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 92eebe5f0e..2ac81129e5 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -784,7 +784,7 @@ void qemu_spice_init(void) qemu_opt_foreach(opts, add_channel, &tls_port, &error_fatal); - 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); seamless_migration = qemu_opt_get_bool(opts, "seamless-migration", 0); From patchwork Thu Feb 21 11:07:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 1046088 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 444smP19MFz9s5c for ; Thu, 21 Feb 2019 22:33:25 +1100 (AEDT) Received: from localhost ([127.0.0.1]:58660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmbT-0007HT-3s for incoming@patchwork.ozlabs.org; Thu, 21 Feb 2019 06:33:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwmCh-0002JZ-9K for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwmCd-00074h-FD for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45842) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwmCc-00073c-JW for qemu-devel@nongnu.org; Thu, 21 Feb 2019 06:07:43 -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 858178666E for ; Thu, 21 Feb 2019 11:07:41 +0000 (UTC) Received: from localhost (ovpn-112-68.ams2.redhat.com [10.36.112.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 027EB5D9D3; Thu, 21 Feb 2019 11:07:40 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 12:07:03 +0100 Message-Id: <20190221110703.5775-12-marcandre.lureau@redhat.com> In-Reply-To: <20190221110703.5775-1-marcandre.lureau@redhat.com> References: <20190221110703.5775-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.26]); Thu, 21 Feb 2019 11:07:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 11/11] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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é 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 7702ddf583..c5d1d7f099 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1110,12 +1110,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'] } ## # @DisplayOptions: diff --git a/ui/spice-app.c b/ui/spice-app.c new file mode 100644 index 0000000000..4f5229f3ee --- /dev/null +++ b/ui/spice-app.c @@ -0,0 +1,200 @@ +/* + * QEMU external Spice client display driver + * + * Copyright (c) 2018 Marc-André Lureau + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 = g_new0(ChardevBackend, 1); + + be->type = CHARDEV_BACKEND_KIND_SPICEPORT; + be->u.spiceport.data = 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 = NULL; + + if (strstart(chr->label, "serial", NULL)) { + fqdn = "org.qemu.console.serial.0"; + } else if (strstart(chr->label, "parallel", NULL)) { + fqdn = "org.qemu.console.parallel.0"; + } else if (strstart(chr->label, "compat_monitor", NULL)) { + fqdn = "org.qemu.monitor.hmp.0"; + } + + be = chr_spice_backend_new(); + be->u.spiceport.data->fqdn = 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 = CHARDEV_CLASS(oc); + + cc->parse = qemu_chr_parse_vc; + cc->open = vc_chr_open; + cc->chr_set_echo = vc_chr_set_echo; +} + +static const TypeInfo char_vc_type_info = { + .name = TYPE_CHARDEV_VC, + .parent = TYPE_CHARDEV_SPICEPORT, + .instance_size = sizeof(VCChardev), + .class_init = 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 = chr_spice_backend_new(); + GError *err = 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 = 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 = g_dir_make_tmp(NULL, &err); + tmp_dir = app_dir; + if (err) { + error_report("Failed to create temporary directory: %s", + err->message); + exit(1); + } + } + + type_register(&char_vc_type_info); + + sock_path = g_strjoin("", app_dir, "/", "spice.sock", NULL); + qopts = qemu_opts_create(qemu_find_opts("spice"), NULL, 0, &error_abort); + 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 = opts->has_gl; + + be->u.spiceport.data->fqdn = g_strdup("org.qemu.monitor.qmp.0"); + qemu_chardev_new("org.qemu.monitor.qmp", TYPE_CHARDEV_SPICEPORT, + be, NULL, &error_abort); + qopts = 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 = NULL; + gchar *uri; + + uri = g_strjoin("", "spice+unix://", app_dir, "/", "spice.sock", NULL); + 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 = { + .type = DISPLAY_TYPE_SPICE_APP, + .early_init = spice_app_display_early_init, + .init = 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 77bd98e20b..c843126ebd 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1211,6 +1211,7 @@ STEXI ETEXI DEF("display", HAS_ARG, QEMU_OPTION_display, + "-display spice-app[,gl=on|off]\n" "-display sdl[,frame=on|off][,alt_grab=on|off][,ctrl_grab=on|off]\n" " [,window_close=on|off][,gl=on|core|es|off]\n" "-display gtk[,grab_on_hover=on|off][,gl=on|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 display, 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 diff --git a/ui/Makefile.objs b/ui/Makefile.objs index 7f8b3da791..fe1a7aed97 100644 --- a/ui/Makefile.objs +++ b/ui/Makefile.objs @@ -49,6 +49,11 @@ curses.mo-objs := curses.o curses.mo-cflags := $(CURSES_CFLAGS) curses.mo-libs := $(CURSES_LIBS) +common-obj-$(call land,$(CONFIG_SPICE),$(CONFIG_GIO)) += spice-app.mo +spice-app.mo-objs := spice-app.o +spice-app.mo-cflags := $(GIO_CFLAGS) +spice-app.mo-libs := $(GIO_LIBS) + common-obj-$(CONFIG_OPENGL) += shader.o common-obj-$(CONFIG_OPENGL) += console-gl.o common-obj-$(CONFIG_OPENGL) += egl-helpers.o