[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 32/46] accel/kvm/kvm-all: Fix wrong return code handling in dirty
From: |
Paolo Bonzini |
Subject: |
[PULL 32/46] accel/kvm/kvm-all: Fix wrong return code handling in dirty log code |
Date: |
Mon, 8 Feb 2021 19:23:17 +0100 |
From: Thomas Huth <thuth@redhat.com>
The kvm_vm_ioctl() wrapper already returns -errno if the ioctl itself
returned -1, so the callers of kvm_vm_ioctl() should not check for -1
but for a value < 0 instead.
This problem has been fixed once already in commit b533f658a98325d0e4
but that commit missed that the ENOENT error code is not fatal for
this ioctl, so the commit has been reverted in commit 50212d6346f33d6e
since the problem occurred close to a pending release at that point
in time. The plan was to fix it properly after the release, but it
seems like this has been forgotten. So let's do it now finally instead.
Resolves: https://bugs.launchpad.net/qemu/+bug/1294227
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210129084354.42928-1-thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
accel/kvm/kvm-all.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index e72a19aaf8..47516913b7 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -644,16 +644,19 @@ static int
kvm_physical_sync_dirty_bitmap(KVMMemoryListener *kml,
d.dirty_bitmap = mem->dirty_bmap;
d.slot = mem->slot | (kml->as_id << 16);
- if (kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d) == -1) {
- DPRINTF("ioctl failed %d\n", errno);
- ret = -1;
+ ret = kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d);
+ if (ret == -ENOENT) {
+ /* kernel does not have dirty bitmap in this slot */
+ ret = 0;
+ } else if (ret < 0) {
+ error_report("ioctl KVM_GET_DIRTY_LOG failed: %d", errno);
goto out;
+ } else {
+ subsection.offset_within_region += slot_offset;
+ subsection.size = int128_make64(slot_size);
+ kvm_get_dirty_pages_log_range(&subsection, d.dirty_bitmap);
}
- subsection.offset_within_region += slot_offset;
- subsection.size = int128_make64(slot_size);
- kvm_get_dirty_pages_log_range(&subsection, d.dirty_bitmap);
-
slot_offset += slot_size;
start_addr += slot_size;
size -= slot_size;
@@ -750,8 +753,8 @@ static int kvm_log_clear_one_slot(KVMSlot *mem, int as_id,
uint64_t start,
d.num_pages = bmap_npages;
d.slot = mem->slot | (as_id << 16);
- if (kvm_vm_ioctl(s, KVM_CLEAR_DIRTY_LOG, &d) == -1) {
- ret = -errno;
+ ret = kvm_vm_ioctl(s, KVM_CLEAR_DIRTY_LOG, &d);
+ if (ret < 0 && ret != -ENOENT) {
error_report("%s: KVM_CLEAR_DIRTY_LOG failed, slot=%d, "
"start=0x%"PRIx64", size=0x%"PRIx32", errno=%d",
__func__, d.slot, (uint64_t)d.first_page,
--
2.29.2
- [PULL 27/46] meson: Restrict emulation code, (continued)
- [PULL 27/46] meson: Restrict emulation code, Paolo Bonzini, 2021/02/08
- [PULL 28/46] qapi/meson: Restrict qdev code to system-mode emulation, Paolo Bonzini, 2021/02/08
- [PULL 35/46] replay: rng-builtin support, Paolo Bonzini, 2021/02/08
- [PULL 25/46] meson: Merge trace_events_subdirs array, Paolo Bonzini, 2021/02/08
- [PULL 37/46] hw/pci-host: add pci-intack write method, Paolo Bonzini, 2021/02/08
- [PULL 43/46] tz-ppc: add dummy read/write methods, Paolo Bonzini, 2021/02/08
- [PULL 42/46] spapr_pci: add spapr msi read method, Paolo Bonzini, 2021/02/08
- [PULL 31/46] qapi/meson: Restrict UI module to system emulation and tools, Paolo Bonzini, 2021/02/08
- [PULL 26/46] meson: Restrict some trace event directories to user/system emulation, Paolo Bonzini, 2021/02/08
- [PULL 30/46] qapi/meson: Restrict system-mode specific modules, Paolo Bonzini, 2021/02/08
- [PULL 32/46] accel/kvm/kvm-all: Fix wrong return code handling in dirty log code,
Paolo Bonzini <=
- [PULL 33/46] replay: fix replay of the interrupts, Paolo Bonzini, 2021/02/08
- [PULL 36/46] cpu-throttle: Remove timer_mod() from cpu_throttle_set(), Paolo Bonzini, 2021/02/08
- [PULL 34/46] pc-bios/descriptors: fix paths in json files, Paolo Bonzini, 2021/02/08
- [PULL 38/46] pci-host: designware: add pcie-msi read method, Paolo Bonzini, 2021/02/08
- [PULL 39/46] vfio: add quirk device write method, Paolo Bonzini, 2021/02/08
- [PULL 41/46] nvram: add nrf51_soc flash read method, Paolo Bonzini, 2021/02/08
- [PULL 44/46] imx7-ccm: add digprog mmio write method, Paolo Bonzini, 2021/02/08
- [PULL 40/46] prep: add ppc-parity write method, Paolo Bonzini, 2021/02/08
- [PULL 46/46] target/i386: Expose VMX entry/exit load pkrs control bits, Paolo Bonzini, 2021/02/08
- [PULL 45/46] target/i386: Add support for save/load IA32_PKRS MSR, Paolo Bonzini, 2021/02/08