diff mbox series

KVM: selftests: Rename vm_open() to __vm_create()

Message ID 20211012174026.147040-1-krish.sadhukhan@oracle.com (mailing list archive)
State New, archived
Headers show
Series KVM: selftests: Rename vm_open() to __vm_create() | expand

Commit Message

Krish Sadhukhan Oct. 12, 2021, 5:40 p.m. UTC
vm_open() actually creates the VM by opening the KVM device and calling
KVM_CREATE_VM ioctl, so it is semantically more correct to call it
__vm_create().

Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
---
 tools/testing/selftests/kvm/lib/kvm_util.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Jim Mattson Oct. 12, 2021, 9:14 p.m. UTC | #1
On Tue, Oct 12, 2021 at 1:43 PM Krish Sadhukhan
<krish.sadhukhan@oracle.com> wrote:
>
> vm_open() actually creates the VM by opening the KVM device and calling
> KVM_CREATE_VM ioctl, so it is semantically more correct to call it
> __vm_create().

I see no problem with the current semantics, since the KVM_CREATE_VM
ioctl *opens* a new VM file descriptor.
Krish Sadhukhan Oct. 12, 2021, 11:17 p.m. UTC | #2
On 10/12/21 2:14 PM, Jim Mattson wrote:
> On Tue, Oct 12, 2021 at 1:43 PM Krish Sadhukhan
> <krish.sadhukhan@oracle.com> wrote:
>> vm_open() actually creates the VM by opening the KVM device and calling
>> KVM_CREATE_VM ioctl, so it is semantically more correct to call it
>> __vm_create().
> I see no problem with the current semantics, since the KVM_CREATE_VM
> ioctl *opens* a new VM file descriptor.

Agreed. But the KVM device is also opened for many purposes. For 
example, in kvm_get_supported_cpuid() it is opened for getting CPUID 
stuff.  The purpose of opening the KVM device in this context is to 
create a VM and hence I thought it would be semantically correct to 
rename the function.
Jim Mattson Oct. 13, 2021, 12:08 a.m. UTC | #3
On Tue, Oct 12, 2021 at 4:17 PM Krish Sadhukhan
<krish.sadhukhan@oracle.com> wrote:
>
>
> On 10/12/21 2:14 PM, Jim Mattson wrote:
> > On Tue, Oct 12, 2021 at 1:43 PM Krish Sadhukhan
> > <krish.sadhukhan@oracle.com> wrote:
> >> vm_open() actually creates the VM by opening the KVM device and calling
> >> KVM_CREATE_VM ioctl, so it is semantically more correct to call it
> >> __vm_create().
> > I see no problem with the current semantics, since the KVM_CREATE_VM
> > ioctl *opens* a new VM file descriptor.
>
> Agreed. But the KVM device is also opened for many purposes. For
> example, in kvm_get_supported_cpuid() it is opened for getting CPUID
> stuff.  The purpose of opening the KVM device in this context is to
> create a VM and hence I thought it would be semantically correct to
> rename the function.

You are misinterpreting my response. I said nothing about the  KVM device.

The KVM_CREATE_VM ioctl *opens* a brand-new VM file descriptor. In that sense,
vm_open makes perfect sense.
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 10a8ed691c66..91603c9b8078 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -151,7 +151,7 @@  void vm_enable_dirty_ring(struct kvm_vm *vm, uint32_t ring_size)
 	vm->dirty_ring_size = ring_size;
 }
 
-static void vm_open(struct kvm_vm *vm, int perm)
+static void __vm_create(struct kvm_vm *vm, int perm)
 {
 	vm->kvm_fd = _open_kvm_dev_path_or_exit(perm);
 
@@ -296,7 +296,7 @@  struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm)
 		vm->type = KVM_VM_TYPE_ARM_IPA_SIZE(vm->pa_bits);
 #endif
 
-	vm_open(vm, perm);
+	__vm_create(vm, perm);
 
 	/* Limit to VA-bit canonical virtual addresses. */
 	vm->vpages_valid = sparsebit_alloc();
@@ -418,7 +418,7 @@  void kvm_vm_restart(struct kvm_vm *vmp, int perm)
 	int ctr;
 	struct userspace_mem_region *region;
 
-	vm_open(vmp, perm);
+	__vm_create(vmp, perm);
 	if (vmp->has_irqchip)
 		vm_create_irqchip(vmp);