Commit e5896b12 authored by Anthony PERARD's avatar Anthony PERARD Committed by Marcelo Tosatti
Browse files

Introduce log_start/log_stop in CPUPhysMemoryClient



In order to use log_start/log_stop with Xen as well in the vga code,
this two operations have been put in CPUPhysMemoryClient.

The two new functions cpu_physical_log_start,cpu_physical_log_stop are
used in hw/vga.c and replace the kvm_log_start/stop. With this, vga does
no longer depends on kvm header.

[ Jan: rebasing and style fixlets ]

Signed-off-by: default avatarAnthony PERARD <anthony.perard@citrix.com>
Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent 8e045ac4
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -959,6 +959,12 @@ int cpu_physical_memory_get_dirty_tracking(void);
int cpu_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
                                   target_phys_addr_t end_addr);

int cpu_physical_log_start(target_phys_addr_t start_addr,
                           ram_addr_t size);

int cpu_physical_log_stop(target_phys_addr_t start_addr,
                          ram_addr_t size);

void dump_exec_info(FILE *f, fprintf_function cpu_fprintf);
#endif /* !CONFIG_USER_ONLY */

+4 −0
Original line number Diff line number Diff line
@@ -96,6 +96,10 @@ struct CPUPhysMemoryClient {
                             target_phys_addr_t end_addr);
    int (*migration_log)(struct CPUPhysMemoryClient *client,
                         int enable);
    int (*log_start)(struct CPUPhysMemoryClient *client,
                     target_phys_addr_t phys_addr, ram_addr_t size);
    int (*log_stop)(struct CPUPhysMemoryClient *client,
                    target_phys_addr_t phys_addr, ram_addr_t size);
    QLIST_ENTRY(CPUPhysMemoryClient) list;
};

+30 −0
Original line number Diff line number Diff line
@@ -2078,6 +2078,36 @@ int cpu_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
    return ret;
}

int cpu_physical_log_start(target_phys_addr_t start_addr,
                           ram_addr_t size)
{
    CPUPhysMemoryClient *client;
    QLIST_FOREACH(client, &memory_client_list, list) {
        if (client->log_start) {
            int r = client->log_start(client, start_addr, size);
            if (r < 0) {
                return r;
            }
        }
    }
    return 0;
}

int cpu_physical_log_stop(target_phys_addr_t start_addr,
                          ram_addr_t size)
{
    CPUPhysMemoryClient *client;
    QLIST_FOREACH(client, &memory_client_list, list) {
        if (client->log_stop) {
            int r = client->log_stop(client, start_addr, size);
            if (r < 0) {
                return r;
            }
        }
    }
    return 0;
}

static inline void tlb_update_dirty(CPUTLBEntry *tlb_entry)
{
    ram_addr_t ram_addr;
+16 −15
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@
#include "vga_int.h"
#include "pixel_ops.h"
#include "qemu-timer.h"
#include "kvm.h"

//#define DEBUG_VGA
//#define DEBUG_VGA_MEM
@@ -1573,34 +1572,36 @@ static void vga_sync_dirty_bitmap(VGACommonState *s)

void vga_dirty_log_start(VGACommonState *s)
{
    if (kvm_enabled() && s->map_addr)
        kvm_log_start(s->map_addr, s->map_end - s->map_addr);
    if (s->map_addr) {
        cpu_physical_log_start(s->map_addr, s->map_end - s->map_addr);
    }

    if (kvm_enabled() && s->lfb_vram_mapped) {
        kvm_log_start(isa_mem_base + 0xa0000, 0x8000);
        kvm_log_start(isa_mem_base + 0xa8000, 0x8000);
    if (s->lfb_vram_mapped) {
        cpu_physical_log_start(isa_mem_base + 0xa0000, 0x8000);
        cpu_physical_log_start(isa_mem_base + 0xa8000, 0x8000);
    }

#ifdef CONFIG_BOCHS_VBE
    if (kvm_enabled() && s->vbe_mapped) {
        kvm_log_start(VBE_DISPI_LFB_PHYSICAL_ADDRESS, s->vram_size);
    if (s->vbe_mapped) {
        cpu_physical_log_start(VBE_DISPI_LFB_PHYSICAL_ADDRESS, s->vram_size);
    }
#endif
}

void vga_dirty_log_stop(VGACommonState *s)
{
    if (kvm_enabled() && s->map_addr)
	kvm_log_stop(s->map_addr, s->map_end - s->map_addr);
    if (s->map_addr) {
        cpu_physical_log_stop(s->map_addr, s->map_end - s->map_addr);
    }

    if (kvm_enabled() && s->lfb_vram_mapped) {
	kvm_log_stop(isa_mem_base + 0xa0000, 0x8000);
	kvm_log_stop(isa_mem_base + 0xa8000, 0x8000);
    if (s->lfb_vram_mapped) {
        cpu_physical_log_stop(isa_mem_base + 0xa0000, 0x8000);
        cpu_physical_log_stop(isa_mem_base + 0xa8000, 0x8000);
    }

#ifdef CONFIG_BOCHS_VBE
    if (kvm_enabled() && s->vbe_mapped) {
	kvm_log_stop(VBE_DISPI_LFB_PHYSICAL_ADDRESS, s->vram_size);
    if (s->vbe_mapped) {
        cpu_physical_log_stop(VBE_DISPI_LFB_PHYSICAL_ADDRESS, s->vram_size);
    }
#endif
}
+2 −0
Original line number Diff line number Diff line
@@ -607,6 +607,8 @@ int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force)
    hdev->client.set_memory = vhost_client_set_memory;
    hdev->client.sync_dirty_bitmap = vhost_client_sync_dirty_bitmap;
    hdev->client.migration_log = vhost_client_migration_log;
    hdev->client.log_start = NULL;
    hdev->client.log_stop = NULL;
    hdev->mem = qemu_mallocz(offsetof(struct vhost_memory, regions));
    hdev->log = NULL;
    hdev->log_size = 0;
Loading