From patchwork Fri Oct 12 11:45:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 983001 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=2001:4830:134:3::11; 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 [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42WmK54rqcz9s3Z for ; Fri, 12 Oct 2018 22:47:05 +1100 (AEDT) Received: from localhost ([::1]:39618 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAvuJ-0001C4-AA for incoming@patchwork.ozlabs.org; Fri, 12 Oct 2018 07:47:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAvtL-0001An-BQ for qemu-devel@nongnu.org; Fri, 12 Oct 2018 07:46:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAvtI-0003y0-4q for qemu-devel@nongnu.org; Fri, 12 Oct 2018 07:46:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48536) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gAvtH-0003tT-SA for qemu-devel@nongnu.org; Fri, 12 Oct 2018 07:46:00 -0400 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 CD93730014CA; Fri, 12 Oct 2018 11:45:58 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-238.ams2.redhat.com [10.36.116.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94E767A51C; Fri, 12 Oct 2018 11:45:56 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E5C0B241; Fri, 12 Oct 2018 13:45:55 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 12 Oct 2018 13:45:51 +0200 Message-Id: <20181012114551.28809-1-kraxel@redhat.com> 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.40]); Fri, 12 Oct 2018 11:45:58 +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] spice: prepare for upcoming spice-server change 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: spice-devel@lists.freedesktop.org, Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Future spice-server versions will call the client_monitors_config callback with the monitors list filtered to only include the monitors of the given display channel (aka QXLInstance). Luckily this is easily detectable at runtime, so we can prepare for that in advance and also make qemu compatible with both old and new spice-server versions. While being at it also use the console index instead of head number as array index. The later doesn't work correctly in case multiple display devices are present. Cc: spice-devel@lists.freedesktop.org Signed-off-by: Gerd Hoffmann Reviewed-by: Lukáš Hrázký --- ui/spice-display.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/ui/spice-display.c b/ui/spice-display.c index 2f8adb6b9f..52f8cb5ae1 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -674,10 +674,28 @@ static int interface_client_monitors_config(QXLInstance *sin, memset(&info, 0, sizeof(info)); - head = qemu_console_get_head(ssd->dcl.con); - if (mc->num_of_monitors > head) { - info.width = mc->monitors[head].width; - info.height = mc->monitors[head].height; + if (mc->num_of_monitors == 1) { + /* + * New spice-server version which filters the list of monitors + * to only include those that belong to our display channel. + * + * single-head configuration (where filtering doesn't matter) + * takes this code path too. + */ + info.width = mc->monitors[0].width; + info.height = mc->monitors[0].height; + } else { + /* + * Old spice-server which gives us all monitors, so we have to + * figure ourself which entry we need. Array index is the + * channel_id, which is the qemu console index, see + * qemu_spice_add_display_interface(). + */ + head = qemu_console_get_index(ssd->dcl.con); + if (mc->num_of_monitors > head) { + info.width = mc->monitors[head].width; + info.height = mc->monitors[head].height; + } } trace_qemu_spice_ui_info(ssd->qxl.id, info.width, info.height);