Skip to contentSkip to conversation

selftests: kvm: Simplify loop in kvm_create_max_vcpus test

PATCH Applied Wainer dos Santos Moschetta 3 participants 3 messages Nov 12, 2019 – Nov 14, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: kvm: Simplify loop in kvm_create_max_vcpus test

On kvm_create_max_vcpus test remove unneeded local variable in the loop that add vcpus to the VM.

---
 tools/testing/selftests/kvm/kvm_create_max_vcpus.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
tools/testing/selftests/kvm/kvm_create_max_vcpus.c +2 -5
index 231d79e57774..6f38c3dc0d56 100644
@@ -29,12 +29,9 @@ void test_vcpu_creation(int first_vcpu_id, int num_vcpus)
 
 	vm = vm_create(VM_MODE_DEFAULT, DEFAULT_GUEST_PHY_PAGES, O_RDWR);
 
-	for (i = 0; i < num_vcpus; i++) {
-		int vcpu_id = first_vcpu_id + i;
-
+	for (i = first_vcpu_id; i < first_vcpu_id + num_vcpus; i++)
 		/* This asserts that the vCPU was created. */
-		vm_vcpu_add(vm, vcpu_id);
-	}
+		vm_vcpu_add(vm, i);
 
 	kvm_vm_free(vm);
 }
Signature · 1 line
2.18.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Wainer dos Santos Moschetta

On kvm_create_max_vcpus test remove unneeded local variable in the loop that add vcpus to the VM.

---
  tools/testing/selftests/kvm/kvm_create_max_vcpus.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)
tools/testing/selftests/kvm/kvm_create_max_vcpus.c +0 -1
index 231d79e57774..6f38c3dc0d56 100644
@@ -29,12 +29,9 @@ void test_vcpu_creation(int first_vcpu_id, int num_vcpus)
 
  	vm = vm_create(VM_MODE_DEFAULT, DEFAULT_GUEST_PHY_PAGES, O_RDWR);
 
-	for (i = 0; i < num_vcpus; i++) {

tools/testing/selftests/kvm/kvm_create_max_vcpus.c void test_vcpu_creation(int first_vcpu_id, int num_vcpus) · line 37

Quoted 10 lines
tools/testing/selftests/kvm/kvm_create_max_vcpus.c +2 -4
-		int vcpu_id = first_vcpu_id + i;
-
+	for (i = first_vcpu_id; i < first_vcpu_id + num_vcpus; i++)
  		/* This asserts that the vCPU was created. */
-		vm_vcpu_add(vm, vcpu_id);
-	}
+		vm_vcpu_add(vm, i);
 
  	kvm_vm_free(vm);
  }
maintainer Applied
#2 lore raw
In reply to Wainer dos Santos Moschetta
Quoted 18 lines · Wainer dos Santos Moschetta

On kvm_create_max_vcpus test remove unneeded local variable in the loop that add vcpus to the VM.

---
 tools/testing/selftests/kvm/kvm_create_max_vcpus.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
tools/testing/selftests/kvm/kvm_create_max_vcpus.c +0 -1
index 231d79e57774..6f38c3dc0d56 100644
@@ -29,12 +29,9 @@ void test_vcpu_creation(int first_vcpu_id, int num_vcpus)
 
 	vm = vm_create(VM_MODE_DEFAULT, DEFAULT_GUEST_PHY_PAGES, O_RDWR);
 
-	for (i = 0; i < num_vcpus; i++) {

tools/testing/selftests/kvm/kvm_create_max_vcpus.c void test_vcpu_creation(int first_vcpu_id, int num_vcpus) · line 37

Quoted 10 lines
tools/testing/selftests/kvm/kvm_create_max_vcpus.c +2 -4
-		int vcpu_id = first_vcpu_id + i;
-
+	for (i = first_vcpu_id; i < first_vcpu_id + num_vcpus; i++)
 		/* This asserts that the vCPU was created. */
-		vm_vcpu_add(vm, vcpu_id);
-	}
+		vm_vcpu_add(vm, i);
 
 	kvm_vm_free(vm);
 }

Queued, thanks.

Paolo