VMware VGA: Only enable dirty log tracking when fifo is disabled

This patch enables dirty log tracking whenever it's needed and disables it
when it is not.

We unconditionally enable dirty log tracking on reset, restart dirty log
tracking when PCI IO regions are remapped, and disable/enable it based on
commands from the guest.

Rebased-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index ae91327..e3d5706 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -771,8 +771,12 @@
         s->height = -1;
         s->invalidated = 1;
         s->vga.invalidate(&s->vga);
-        if (s->enable)
-            s->fb_size = ((s->depth + 7) >> 3) * s->new_width * s->new_height;
+        if (s->enable) {
+	  s->fb_size = ((s->depth + 7) >> 3) * s->new_width * s->new_height;
+	  vga_dirty_log_stop(&s->vga);
+	} else {
+	  vga_dirty_log_start(&s->vga);
+	}
         break;
 
     case SVGA_REG_WIDTH:
@@ -948,6 +952,8 @@
         break;
     }
     s->syncing = 0;
+
+    vga_dirty_log_start(&s->vga);
 }
 
 static void vmsvga_invalidate_display(void *opaque)
@@ -1119,7 +1125,6 @@
                                      vmsvga_screen_dump,
                                      vmsvga_text_update, s);
 
-    vmsvga_reset(s);
 
     s->fifo_size = SVGA_FIFO_SIZE;
     s->fifo_offset = qemu_ram_alloc(s->fifo_size);
@@ -1130,7 +1135,10 @@
     vmstate_register(0, &vmstate_vga_common, &s->vga);
 
     vga_init_vbe(&s->vga);
+
     rom_add_vga(VGABIOS_FILENAME);
+
+    vmsvga_reset(s);
 }
 
 static void pci_vmsvga_map_ioport(PCIDevice *pci_dev, int region_num,
@@ -1172,7 +1180,7 @@
 
     s->vga.map_addr = addr;
     s->vga.map_end = addr + s->vga.vram_size;
-    vga_dirty_log_start(&s->vga);
+    vga_dirty_log_restart(&s->vga);
 }
 
 static void pci_vmsvga_map_fifo(PCIDevice *pci_dev, int region_num,