[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 22/42] hostmem: simplify the code for merge and dump properties
From: |
Paolo Bonzini |
Subject: |
[PULL 22/42] hostmem: simplify the code for merge and dump properties |
Date: |
Sat, 8 Jun 2024 10:33:55 +0200 |
No semantic change, just simpler control flow.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
backends/hostmem.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 6da3d7383e3..4e5576a4ada 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -178,19 +178,16 @@ static void host_memory_backend_set_merge(Object *obj,
bool value, Error **errp)
return;
}
- if (!host_memory_backend_mr_inited(backend)) {
- backend->merge = value;
- return;
- }
-
- if (value != backend->merge) {
+ if (!host_memory_backend_mr_inited(backend) &&
+ value != backend->merge) {
void *ptr = memory_region_get_ram_ptr(&backend->mr);
uint64_t sz = memory_region_size(&backend->mr);
qemu_madvise(ptr, sz,
value ? QEMU_MADV_MERGEABLE : QEMU_MADV_UNMERGEABLE);
- backend->merge = value;
}
+
+ backend->merge = value;
}
static bool host_memory_backend_get_dump(Object *obj, Error **errp)
@@ -212,19 +209,16 @@ static void host_memory_backend_set_dump(Object *obj,
bool value, Error **errp)
return;
}
- if (!host_memory_backend_mr_inited(backend)) {
- backend->dump = value;
- return;
- }
-
- if (value != backend->dump) {
+ if (host_memory_backend_mr_inited(backend) &&
+ value != backend->dump) {
void *ptr = memory_region_get_ram_ptr(&backend->mr);
uint64_t sz = memory_region_size(&backend->mr);
qemu_madvise(ptr, sz,
value ? QEMU_MADV_DODUMP : QEMU_MADV_DONTDUMP);
- backend->dump = value;
}
+
+ backend->dump = value;
}
static bool host_memory_backend_get_prealloc(Object *obj, Error **errp)
--
2.45.1
- [PULL 10/42] target/i386: document incorrect semantics of watchpoint following MOV/POP SS, (continued)
- [PULL 10/42] target/i386: document incorrect semantics of watchpoint following MOV/POP SS, Paolo Bonzini, 2024/06/08
- [PULL 12/42] target/i386: use local X86DecodedOp in gen_POP(), Paolo Bonzini, 2024/06/08
- [PULL 13/42] target/i386: use gen_writeback() within gen_POP(), Paolo Bonzini, 2024/06/08
- [PULL 14/42] target/i386: fix SP when taking a memory fault during POP, Paolo Bonzini, 2024/06/08
- [PULL 15/42] target/i386: fix size of EBP writeback in gen_enter(), Paolo Bonzini, 2024/06/08
- [PULL 16/42] machine: default -M mem-merge to off is QEMU_MADV_MERGEABLE is not available, Paolo Bonzini, 2024/06/08
- [PULL 17/42] meson: Don't even detect posix_madvise() on Darwin, Paolo Bonzini, 2024/06/08
- [PULL 18/42] osdep: Make qemu_madvise() to set errno in all cases, Paolo Bonzini, 2024/06/08
- [PULL 20/42] backends/hostmem: Report error when memory size is unaligned, Paolo Bonzini, 2024/06/08
- [PULL 21/42] machine, hostmem: improve error messages for unsupported features, Paolo Bonzini, 2024/06/08
- [PULL 22/42] hostmem: simplify the code for merge and dump properties,
Paolo Bonzini <=
- [PULL 19/42] osdep: Make qemu_madvise() return ENOSYS on unsupported OSes, Paolo Bonzini, 2024/06/08
- [PULL 23/42] scsi-disk: Don't silently truncate serial number, Paolo Bonzini, 2024/06/08
- [PULL 24/42] stubs/meson: Fix qemuutil build when --disable-system, Paolo Bonzini, 2024/06/08
- [PULL 25/42] i386/hvf: Adds support for INVTSC cpuid bit, Paolo Bonzini, 2024/06/08
- [PULL 27/42] hvf: Consistent types for vCPU handles, Paolo Bonzini, 2024/06/08
- [PULL 26/42] i386/hvf: Fixes some compilation warnings, Paolo Bonzini, 2024/06/08
- [PULL 28/42] i386/hvf: Fixes dirty memory tracking by page granularity RX->RWX change, Paolo Bonzini, 2024/06/08
- [PULL 29/42] i386/hvf: In kick_vcpu use hv_vcpu_interrupt to force exit, Paolo Bonzini, 2024/06/08
- [PULL 31/42] hvf: Makes assert_hvf_ok report failed expression, Paolo Bonzini, 2024/06/08
- [PULL 30/42] i386/hvf: Updates API usage to use modern vCPU run function, Paolo Bonzini, 2024/06/08