qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] use logging count for individual regions
@ 2009-07-28 20:02 Glauber Costa
  2009-07-29  8:30 ` [Qemu-devel] " Jan Kiszka
  0 siblings, 1 reply; 2+ messages in thread
From: Glauber Costa @ 2009-07-28 20:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jan Kiszka, aliguori

qemu-kvm use this scheme of logging count of individual regions,
which is, IMHO, more flexible which the one we have right now.
I'm proposing we use it.

Thanks!

Signed-off-by: Glauber Costa <glommer@redhat.com>
CC: Jan Kiszka <jan.kiszka@siemens.com>
---
 kvm-all.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index f669c3a..1f1da4c 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -46,6 +46,7 @@ typedef struct KVMSlot
     ram_addr_t phys_offset;
     int slot;
     int flags;
+    uint32_t logging_count;
 } KVMSlot;
 
 typedef struct kvm_dirty_log KVMDirtyLog;
@@ -59,7 +60,6 @@ struct KVMState
     int vmfd;
     int coalesced_mmio;
     int broken_set_mem_region;
-    int migration_log;
 #ifdef KVM_CAP_SET_GUEST_DEBUG
     struct kvm_sw_breakpoint_head kvm_sw_breakpoints;
 #endif
@@ -139,9 +139,7 @@ static int kvm_set_user_memory_region(KVMState *s, KVMSlot *slot)
     mem.memory_size = slot->memory_size;
     mem.userspace_addr = (unsigned long)qemu_get_ram_ptr(slot->phys_offset);
     mem.flags = slot->flags;
-    if (s->migration_log) {
-        mem.flags |= KVM_MEM_LOG_DIRTY_PAGES;
-    }
+
     return kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, &mem);
 }
 
@@ -243,15 +241,22 @@ static int kvm_dirty_pages_log_change(target_phys_addr_t phys_addr,
             return -EINVAL;
     }
 
+    if (flags & KVM_MEM_LOG_DIRTY_PAGES) {
+        if (mem->logging_count++) {
+            return 0;
+        }
+    } else {
+        if (--mem->logging_count) {
+            return 0;
+        }
+    }
+
     old_flags = mem->flags;
 
     flags = (mem->flags & ~mask) | flags;
     mem->flags = flags;
 
     /* If nothing changed effectively, no need to issue ioctl */
-    if (s->migration_log) {
-        flags |= KVM_MEM_LOG_DIRTY_PAGES;
-    }
     if (flags == old_flags) {
             return 0;
     }
@@ -279,8 +284,6 @@ int kvm_set_migration_log(int enable)
     KVMSlot *mem;
     int i, err;
 
-    s->migration_log = enable;
-
     for (i = 0; i < ARRAY_SIZE(s->slots); i++) {
         mem = &s->slots[i];
 
-- 
1.6.2.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Qemu-devel] Re: [PATCH] use logging count for individual regions
  2009-07-28 20:02 [Qemu-devel] [PATCH] use logging count for individual regions Glauber Costa
@ 2009-07-29  8:30 ` Jan Kiszka
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kiszka @ 2009-07-29  8:30 UTC (permalink / raw)
  To: Glauber Costa; +Cc: aliguori, qemu-devel

Glauber Costa wrote:
> qemu-kvm use this scheme of logging count of individual regions,
> which is, IMHO, more flexible which the one we have right now.
> I'm proposing we use it.
> 
> Thanks!
> 
> Signed-off-by: Glauber Costa <glommer@redhat.com>
> CC: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  kvm-all.c |   21 ++++++++++++---------
>  1 files changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/kvm-all.c b/kvm-all.c
> index f669c3a..1f1da4c 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -46,6 +46,7 @@ typedef struct KVMSlot
>      ram_addr_t phys_offset;
>      int slot;
>      int flags;
> +    uint32_t logging_count;

Any particular reason for this type? If not, just use 'int'.

>  } KVMSlot;
>  
>  typedef struct kvm_dirty_log KVMDirtyLog;
> @@ -59,7 +60,6 @@ struct KVMState
>      int vmfd;
>      int coalesced_mmio;
>      int broken_set_mem_region;
> -    int migration_log;
>  #ifdef KVM_CAP_SET_GUEST_DEBUG
>      struct kvm_sw_breakpoint_head kvm_sw_breakpoints;
>  #endif
> @@ -139,9 +139,7 @@ static int kvm_set_user_memory_region(KVMState *s, KVMSlot *slot)
>      mem.memory_size = slot->memory_size;
>      mem.userspace_addr = (unsigned long)qemu_get_ram_ptr(slot->phys_offset);
>      mem.flags = slot->flags;
> -    if (s->migration_log) {
> -        mem.flags |= KVM_MEM_LOG_DIRTY_PAGES;
> -    }
> +
>      return kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, &mem);
>  }
>  
> @@ -243,15 +241,22 @@ static int kvm_dirty_pages_log_change(target_phys_addr_t phys_addr,
>              return -EINVAL;
>      }
>  
> +    if (flags & KVM_MEM_LOG_DIRTY_PAGES) {
> +        if (mem->logging_count++) {
> +            return 0;
> +        }
> +    } else {
> +        if (--mem->logging_count) {
> +            return 0;
> +        }
> +    }
> +
>      old_flags = mem->flags;
>  
>      flags = (mem->flags & ~mask) | flags;
>      mem->flags = flags;
>  
>      /* If nothing changed effectively, no need to issue ioctl */
> -    if (s->migration_log) {
> -        flags |= KVM_MEM_LOG_DIRTY_PAGES;
> -    }
>      if (flags == old_flags) {
>              return 0;
>      }
> @@ -279,8 +284,6 @@ int kvm_set_migration_log(int enable)
>      KVMSlot *mem;
>      int i, err;
>  
> -    s->migration_log = enable;
> -
>      for (i = 0; i < ARRAY_SIZE(s->slots); i++) {
>          mem = &s->slots[i];
>  

Otherwise: Ack.

Jan

-- 
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-07-29  8:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-28 20:02 [Qemu-devel] [PATCH] use logging count for individual regions Glauber Costa
2009-07-29  8:30 ` [Qemu-devel] " Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).