kvm_physical_sync_dirty_bitmap: ignore ENOENT from kvm_vm_ioctl
PATCH 1/1 kvm_physical_sync_dirty_bitmap: ignore ENOENT from kvm_vm_ioctl
ENOENT means the kernel has an empty dirty bitmap for this slot. Don't abort in that case. This appears to solve the bug reported at
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1303926
which first showed up with commit b533f658a98325d: fix return check for KVM_GET_DIRTY_LOG ioctl
--- kvm-all.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
kvm-all.c +8 -2
@@ -441,13 +441,19 @@ static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section) d.slot = mem->slot; -if (kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d) <0 ) { + ret =kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d); +if (ret >=0 ) { +/* regular case, process returned bitmap */ +kvm_get_dirty_pages_log_range (section, d.dirty_bitmap); + }else if (ret == -ENOENT ) { +/* kernel does not have dirty bitmap in this slot */ + ret =0 ; + }else {DPRINTF ("ioctl failed %d\n" , errno); ret =-1 ;break ; } -kvm_get_dirty_pages_log_range (section, d.dirty_bitmap); start_addr = mem->start_addr + mem->memory_size; }g_free (d.dirty_bitmap);
Signature · 1 line
1.7.10.4
Quoted 11 lines · Michael Tokarev
ENOENT means the kernel has an empty dirty bitmap for this slot. Don't abort in that case. This appears to solve the bug reported at
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1303926
which first showed up with commit
b533f658a98325d: fix return check forKVM_GET_DIRTY_LOGioctlCc Serge Hallyn <[email protected]>Signed-off-by Michael Tokarev <[email protected]>
This does look better than my version, thanks. As you say my version was closer to the old behavior, but if the kernel has no dirty bitmap we shouldn't be acting on it, so this looks better imo.
(I've not tested yet, but it looks right and works for you :)
Quoted 33 lines
--- kvm-all.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)kvm-all.c +8
-2@@ -441,13 +441,19 @@ static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section) d.slot = mem->slot; -if (kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d) <0 ) { + ret =kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d); +if (ret >=0 ) { +/* regular case, process returned bitmap */ +kvm_get_dirty_pages_log_range (section, d.dirty_bitmap); + }else if (ret == -ENOENT ) { +/* kernel does not have dirty bitmap in this slot */ + ret =0 ; + }else {DPRINTF ("ioctl failed %d\n" , errno); ret =-1 ;break ; } -kvm_get_dirty_pages_log_range (section, d.dirty_bitmap); start_addr = mem->start_addr + mem->memory_size; }g_free (d.dirty_bitmap);Signature · 1 line
1.7.10.4
Il 11/04/2014 04:31, Michael Tokarev ha scritto:
Quoted 32 lines
ENOENT means the kernel has an empty dirty bitmap for this slot. Don't abort in that case. This appears to solve the bug reported at
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1303926
which first showed up with commit
b533f658a98325d: fix return check forKVM_GET_DIRTY_LOGioctlCc Serge Hallyn <[email protected]>Signed-off-by Michael Tokarev <[email protected]>--- kvm-all.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)kvm-all.c +7
-1@@ -441,13 +441,19 @@ static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section) d.slot = mem->slot; -if (kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d) <0 ) { + ret =kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d); +if (ret >=0 ) { +/* regular case, process returned bitmap */ +kvm_get_dirty_pages_log_range (section, d.dirty_bitmap); + }else if (ret == -ENOENT ) { +/* kernel does not have dirty bitmap in this slot */ + ret =0 ;
kvm-all.c static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section) · line 459
Quoted 10 lines
kvm-all.c +1
-1+ }else {DPRINTF ("ioctl failed %d\n" , errno); ret =-1 ;break ; } -kvm_get_dirty_pages_log_range (section, d.dirty_bitmap); start_addr = mem->start_addr + mem->memory_size; }g_free (d.dirty_bitmap);
I'd rather revert b533f658a98325d instead.
Paolo
Quoted 38 lines · Paolo Bonzini
Il 11/04/2014 04:31, Michael Tokarev ha scritto:
Quoted 37 lines
ENOENT means the kernel has an empty dirty bitmap for this slot. Don't abort in that case. This appears to solve the bug reported at
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1303926
which first showed up with commit
b533f658a98325d: fix return check forKVM_GET_DIRTY_LOGioctlCc Serge Hallyn <[email protected]>Signed-off-by Michael Tokarev <[email protected]>---
kvm-all.c| 10 ++++++++--1 file changed, 8 insertions(+), 2 deletions(-)kvm-all.c +8
-1@@ -441,13 +441,19 @@ static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section) d.slot = mem->slot; -if (kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d) <0 ) { + ret =kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d); +if (ret >=0 ) { +/* regular case, process returned bitmap */ +kvm_get_dirty_pages_log_range (section, d.dirty_bitmap); + }else if (ret == -ENOENT ) { +/* kernel does not have dirty bitmap in this slot */ + ret =0 ; + }else {DPRINTF ("ioctl failed %d\n" , errno); ret =-1 ;break ; }
Quoted 7 lines
kvm-all.c static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section) · line 459
Quoted 5 lines
kvm-all.c +0
-1-kvm_get_dirty_pages_log_range (section, d.dirty_bitmap); start_addr = mem->start_addr + mem->memory_size; }g_free (d.dirty_bitmap);I'd rather revert
b533f658a98325dinstead.
That seems wrong though. If we want to ignore all errors that's one thing, but before that commit we just ignored all errors other than EPERM.