diff mbox

[07/22] ui/console: check memory_region_is_logging

Message ID 1427391520-29497-8-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini March 26, 2015, 5:38 p.m. UTC
dpy_gfx_update_dirty expects DIRTY_MEMORY_VGA logging to be always on,
but that will not be the case soon.  Because it computes the memory
region on the fly for every update (with memory_region_find), it cannot
enable/disable logging by itself.

Instead, always treat updates as invalidations if dirty logging is
not enabled, assuming that the board will enable logging on the
RAM region that includes the framebuffer.

To simplify the code, replace memory_region_get_dirty with
memory_region_test_and_clear_dirty.  Then memory_region_reset_dirty
is only needed in the invalidate case.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 ui/console.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/ui/console.c b/ui/console.c
index b15ca87..2241b32 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1627,14 +1627,22 @@  void dpy_gfx_update_dirty(QemuConsole *con,
     }
     assert(mem);
 
-    memory_region_sync_dirty_bitmap(mem);
+    if (memory_region_is_logging(mem)) {
+        memory_region_sync_dirty_bitmap(mem);
+        if (invalidate) {
+            memory_region_reset_dirty(mem, mem_section.offset_within_region, size,
+                                      DIRTY_MEMORY_VGA);
+        }
+    } else {
+        invalidate = true;
+    }
     addr = mem_section.offset_within_region;
 
     first = -1;
     last = -1;
     for (i = 0; i < height; i++, addr += width) {
         dirty = invalidate ||
-            memory_region_get_dirty(mem, addr, width, DIRTY_MEMORY_VGA);
+            memory_region_test_and_clear_dirty(mem, addr, width, DIRTY_MEMORY_VGA);
         if (dirty) {
             if (first == -1) {
                 first = i;
@@ -1654,8 +1662,6 @@  void dpy_gfx_update_dirty(QemuConsole *con,
                        last - first + 1);
     }
 
-    memory_region_reset_dirty(mem, mem_section.offset_within_region, size,
-                              DIRTY_MEMORY_VGA);
 out:
     memory_region_unref(mem);
 }