Skip to content

Commit e743664

Browse files
zhoujianjay6bonzini
authored andcommitted
kvm: selftests: Support dirty log initial-all-set test
Since the new capability KVM_DIRTY_LOG_INITIALLY_SET of KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 has been introduced, tweak the clear_dirty_log_test to use it. Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent a1c77ab commit e743664

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
#define USE_CLEAR_DIRTY_LOG
2+
#define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
3+
#define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
4+
#define KVM_DIRTY_LOG_MANUAL_CAPS (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE | \
5+
KVM_DIRTY_LOG_INITIALLY_SET)
26
#include "dirty_log_test.c"

tools/testing/selftests/kvm/dirty_log_test.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ static struct kvm_vm *create_vm(enum vm_guest_mode mode, uint32_t vcpuid,
265265
#define DIRTY_MEM_BITS 30 /* 1G */
266266
#define PAGE_SHIFT_4K 12
267267

268+
#ifdef USE_CLEAR_DIRTY_LOG
269+
static u64 dirty_log_manual_caps;
270+
#endif
271+
268272
static void run_test(enum vm_guest_mode mode, unsigned long iterations,
269273
unsigned long interval, uint64_t phys_offset)
270274
{
@@ -321,7 +325,7 @@ static void run_test(enum vm_guest_mode mode, unsigned long iterations,
321325
struct kvm_enable_cap cap = {};
322326

323327
cap.cap = KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2;
324-
cap.args[0] = 1;
328+
cap.args[0] = dirty_log_manual_caps;
325329
vm_enable_cap(vm, &cap);
326330
#endif
327331

@@ -433,10 +437,15 @@ int main(int argc, char *argv[])
433437
int opt, i;
434438

435439
#ifdef USE_CLEAR_DIRTY_LOG
436-
if (!kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2)) {
437-
fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not available, skipping tests\n");
440+
dirty_log_manual_caps =
441+
kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
442+
if (!dirty_log_manual_caps) {
443+
fprintf(stderr, "KVM_CLEAR_DIRTY_LOG not available, "
444+
"skipping tests\n");
438445
exit(KSFT_SKIP);
439446
}
447+
dirty_log_manual_caps &= (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE |
448+
KVM_DIRTY_LOG_INITIALLY_SET);
440449
#endif
441450

442451
#ifdef __x86_64__

0 commit comments

Comments
 (0)