fix return check for KVM_GET_DIRTY_LOG ioctl
PATCH 1/1 fix return check for KVM_GET_DIRTY_LOG ioctl
Fix return condition check from kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d) to handle internal failures or no support for memory slot dirty bitmap. Otherwise the ioctl succeeds and continues with migration. Addresses BUG# 1294227
--- kvm-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kvm-all.c +1 -1
@@ -441,7 +441,7 @@ static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section) d.slot = mem->slot; -if (kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d) ==-1 ) { +if (kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d) <0 ) {DPRINTF ("ioctl failed %d\n" , errno); ret =-1 ;break ;
Signature · 1 line
1.7.9.5
Michael Tokarev
AppliedQuoted 5 lines · Mario Smarduch
Fix return condition check from
kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d)to handle internal failures or no support for memory slot dirty bitmap. Otherwise the ioctl succeeds and continues with migration. Addresses BUG# 1294227
Thanks, applied to -trivial.
[]
kvm-all.c static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section) · line 444
Quoted 2 lines
kvm-all.c +1
-1-if (kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d) ==-1 ) { +if (kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d) <0 ) {
Actually I'd make all error checks like this. Many checks compares return value with -1 for some reason, while actually, any <0 value should be treated as error in many many places... At the same time, comparison with 0 is cheaper than comparison with -1 ;)
/mjt
I agree. One thing I forgot to mention andother side effect of this bug was virtio VRing used, avail index error the Guest was 1,2,.. less then host.
I looked up that bug it happend on some architectures. This may or may not be related. Obviously if the dirty bitmap is not processed properly you may see issues like that.
- Mario
Quoted 20 lines · Michael Tokarev
Quoted 5 lines · Mario Smarduch
Fix return condition check from
kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d)to handle internal failures or no support for memory slot dirty bitmap. Otherwise the ioctl succeeds and continues with migration. Addresses BUG# 1294227Thanks, applied to -trivial.
[]
kvm-all.c static int kvm_physical_sync_dirty_bitmap(MemoryRegionSection *section) · line 444
Quoted 2 lines
kvm-all.c +1
-1-if (kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d) ==-1 ) { +if (kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d) <0 ) {Actually I'd make all error checks like this. Many checks compares return value with -1 for some reason, while actually, any <0 value should be treated as error in many many places... At the same time, comparison with 0 is cheaper than comparison with -1 ;)
/mjt