[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/9] qxl: set only off-screen surfaces dirty instead
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 3/9] qxl: set only off-screen surfaces dirty instead of the whole vram |
Date: |
Tue, 21 Feb 2012 11:59:07 +0100 |
From: Yonit Halperin <address@hidden>
We used to assure the guest surfaces were saved before migration by
setting the whole vram dirty. This patch sets dirty only the areas
that are actually used in the vram.
Signed-off-by: Yonit Halperin <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/qxl.c | 53 ++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/hw/qxl.c b/hw/qxl.c
index f421a45..b544f31 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1007,7 +1007,7 @@ static void qxl_reset_surfaces(PCIQXLDevice *d)
qxl_spice_destroy_surfaces(d, QXL_SYNC);
}
-/* called from spice server thread context only */
+/* can be also called from spice server thread context */
void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id)
{
uint64_t phys = le64_to_cpu(pqxl);
@@ -1466,6 +1466,46 @@ static void qxl_hw_text_update(void *opaque,
console_ch_t *chardata)
}
}
+static void qxl_dirty_surfaces(PCIQXLDevice *qxl)
+{
+ intptr_t vram_start;
+ int i;
+
+ if (qxl->mode != QXL_MODE_NATIVE) {
+ return;
+ }
+
+ /* dirty the primary surface */
+ qxl_set_dirty(&qxl->vga.vram, qxl->shadow_rom.draw_area_offset,
+ qxl->shadow_rom.surface0_area_size);
+
+ vram_start = (intptr_t)memory_region_get_ram_ptr(&qxl->vram_bar);
+
+ /* dirty the off-screen surfaces */
+ for (i = 0; i < NUM_SURFACES; i++) {
+ QXLSurfaceCmd *cmd;
+ intptr_t surface_offset;
+ int surface_size;
+
+ if (qxl->guest_surfaces.cmds[i] == 0) {
+ continue;
+ }
+
+ cmd = qxl_phys2virt(qxl, qxl->guest_surfaces.cmds[i],
+ MEMSLOT_GROUP_GUEST);
+ assert(cmd->type == QXL_SURFACE_CMD_CREATE);
+ surface_offset = (intptr_t)qxl_phys2virt(qxl,
+ cmd->u.surface_create.data,
+ MEMSLOT_GROUP_GUEST);
+ surface_offset -= vram_start;
+ surface_size = cmd->u.surface_create.height *
+ abs(cmd->u.surface_create.stride);
+ dprint(qxl, 3, "%s: dirty surface %d, offset %d, size %d\n", __func__,
+ i, (int)surface_offset, surface_size);
+ qxl_set_dirty(&qxl->vram_bar, surface_offset, surface_size);
+ }
+}
+
static void qxl_vm_change_state_handler(void *opaque, int running,
RunState state)
{
@@ -1479,14 +1519,9 @@ static void qxl_vm_change_state_handler(void *opaque,
int running,
* called
*/
qxl_update_irq(qxl);
- } else if (qxl->mode == QXL_MODE_NATIVE) {
- /* dirty all vram (which holds surfaces) and devram (primary surface)
- * to make sure they are saved */
- /* FIXME #1: should go out during "live" stage */
- /* FIXME #2: we only need to save the areas which are actually used */
- qxl_set_dirty(&qxl->vram_bar, 0, qxl->vram_size);
- qxl_set_dirty(&qxl->vga.vram, qxl->shadow_rom.draw_area_offset,
- qxl->shadow_rom.surface0_area_size);
+ } else {
+ /* make sure surfaces are saved before migration */
+ qxl_dirty_surfaces(qxl);
}
}
--
1.7.1
- [Qemu-devel] [PULL] spice patch queue, Gerd Hoffmann, 2012/02/21
- [Qemu-devel] [PATCH 6/9] spice: support ipv6 channel address in monitor events and in spice info, Gerd Hoffmann, 2012/02/21
- [Qemu-devel] [PATCH 1/9] qxl: fix warnings on 32bit, Gerd Hoffmann, 2012/02/21
- [Qemu-devel] [PATCH 2/9] qxl: don't render stuff when the vm is stopped., Gerd Hoffmann, 2012/02/21
- [Qemu-devel] [PATCH 5/9] Add SPICE support to add_client monitor command, Gerd Hoffmann, 2012/02/21
- [Qemu-devel] [PATCH 3/9] qxl: set only off-screen surfaces dirty instead of the whole vram,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 4/9] qxl: make sure primary surface is saved on migration also in compat mode, Gerd Hoffmann, 2012/02/21
- [Qemu-devel] [PATCH 7/9] qxl: drop vram bar minimum size, Gerd Hoffmann, 2012/02/21
- [Qemu-devel] [PATCH 8/9] qxl: move ram size init to new function, Gerd Hoffmann, 2012/02/21
- [Qemu-devel] [PATCH 9/9] qxl: add user-friendly bar size properties, Gerd Hoffmann, 2012/02/21
- Re: [Qemu-devel] [PULL] spice patch queue, Anthony Liguori, 2012/02/22