Received: from eggs.gnu.org ([140.186.70.92]:38446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIgZZ-00013J-A5 for qemu-devel@nongnu.org; Tue, 25 Oct 2011 08:57:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RIgNi-0004MG-C3 for qemu-devel@nongnu.org; Tue, 25 Oct 2011 08:45:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RIgNh-0004Ly-S2 for qemu-devel@nongnu.org; Tue, 25 Oct 2011 08:45:26 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9PCjPSG001973 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 25 Oct 2011 08:45:25 -0400 From: Gerd Hoffmann Date: Tue, 25 Oct 2011 14:25:48 +0200 Message-Id: <1319545550-24203-10-git-send-email-kraxel@redhat.com> In-Reply-To: <1319545550-24203-1-git-send-email-kraxel@redhat.com> References: <1319545550-24203-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 09/11] qxl: fix guest cursor tracking List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Yonit Halperin , Gerd Hoffmann From: Yonit Halperin (1) If the guest cursor command is empty, don't reload it after migration. (2) Cleaning the guest cursor when it is released by the spice server. In addition, explicitly reset the cursor in spice upon destroying the primary surface (was done by spice-server implicitly). This will prevent access to pci memory that was released. RHBZ: 744518 Signed-off-by: Yonit Halperin Signed-off-by: Gerd Hoffmann --- hw/qxl.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/qxl.c b/hw/qxl.c index 2ca1b04..3a3b3a4 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -236,6 +236,9 @@ void qxl_spice_reset_image_cache(PCIQXLDevice *qxl) void qxl_spice_reset_cursor(PCIQXLDevice *qxl) { qxl->ssd.worker->reset_cursor(qxl->ssd.worker); + qemu_mutex_lock(&qxl->track_lock); + qxl->guest_cursor = 0; + qemu_mutex_unlock(&qxl->track_lock); } @@ -400,7 +403,9 @@ static void qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext) { QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id); if (cmd->type == QXL_CURSOR_SET) { + qemu_mutex_lock(&qxl->track_lock); qxl->guest_cursor = ext->cmd.data; + qemu_mutex_unlock(&qxl->track_lock); } break; } @@ -1065,6 +1070,7 @@ static int qxl_destroy_primary(PCIQXLDevice *d, qxl_async_io async) d->mode = QXL_MODE_UNDEFINED; qemu_spice_destroy_primary_surface(&d->ssd, 0, async); + qxl_spice_reset_cursor(d); return 1; } @@ -1704,10 +1710,12 @@ static int qxl_post_load(void *opaque, int version) cmds[out].group_id = MEMSLOT_GROUP_GUEST; out++; } - cmds[out].cmd.data = d->guest_cursor; - cmds[out].cmd.type = QXL_CMD_CURSOR; - cmds[out].group_id = MEMSLOT_GROUP_GUEST; - out++; + if (d->guest_cursor) { + cmds[out].cmd.data = d->guest_cursor; + cmds[out].cmd.type = QXL_CMD_CURSOR; + cmds[out].group_id = MEMSLOT_GROUP_GUEST; + out++; + } qxl_spice_loadvm_commands(d, cmds, out); g_free(cmds); -- 1.7.1