qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Does kvm_fd mean KVM or VCPU fd?
@ 2012-06-14  8:24 陳韋任 (Wei-Ren Chen)
  2012-06-14  9:15 ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: 陳韋任 (Wei-Ren Chen) @ 2012-06-14  8:24 UTC (permalink / raw)
  To: qemu-devel

Hi all,

  While reading KVM releated code in QEMU, I found the name of one
field in CPU_COMMON (cpu-defs.h), i.e. kvm_fd, might be misleading.
See the code below,

---
int kvm_init_vcpu(CPUArchState *env)
{
    ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, env->cpu_index);
    env->kvm_fd = ret; /* VCPU fd? */
}
---

  I think KVM_CREATE_VCPU should return VCPU fd, right? AFAIK, in KVM
world, kvm_fd usually means the fd we get after opening "/dev/kvm".
Just want to make sure I understand the code correcly. Thanks.

Regards,
chenwj

-- 
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] Does kvm_fd mean KVM or VCPU fd?
  2012-06-14  8:24 [Qemu-devel] Does kvm_fd mean KVM or VCPU fd? 陳韋任 (Wei-Ren Chen)
@ 2012-06-14  9:15 ` Paolo Bonzini
  2012-06-14 10:16   ` 陳韋任 (Wei-Ren Chen)
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2012-06-14  9:15 UTC (permalink / raw)
  To: "陳韋任 (Wei-Ren Chen)"; +Cc: qemu-devel

Il 14/06/2012 10:24, 陳韋任 (Wei-Ren Chen) ha scritto:
> Hi all,
> 
>   While reading KVM releated code in QEMU, I found the name of one
> field in CPU_COMMON (cpu-defs.h), i.e. kvm_fd, might be misleading.
> See the code below,
> 
> ---
> int kvm_init_vcpu(CPUArchState *env)
> {
>     ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, env->cpu_index);
>     env->kvm_fd = ret; /* VCPU fd? */
> }
> ---
> 
>   I think KVM_CREATE_VCPU should return VCPU fd, right? AFAIK, in KVM
> world, kvm_fd usually means the fd we get after opening "/dev/kvm".
> Just want to make sure I understand the code correcly. Thanks.

This is the kvm_fd inside struct CPUState, so it's per-CPU.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] Does kvm_fd mean KVM or VCPU fd?
  2012-06-14  9:15 ` Paolo Bonzini
@ 2012-06-14 10:16   ` 陳韋任 (Wei-Ren Chen)
  2012-06-14 14:49     ` Andreas Färber
  0 siblings, 1 reply; 4+ messages in thread
From: 陳韋任 (Wei-Ren Chen) @ 2012-06-14 10:16 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: qemu-devel, "陳韋任 (Wei-Ren Chen)"

> >   I think KVM_CREATE_VCPU should return VCPU fd, right? AFAIK, in KVM
> > world, kvm_fd usually means the fd we get after opening "/dev/kvm".
> > Just want to make sure I understand the code correcly. Thanks.
> 
> This is the kvm_fd inside struct CPUState, so it's per-CPU.

  Okay, then it's VCPU fd. Don't know rename it or add a comment to indicate
it's a VCPU fd is a good idea. ;)

Regards,
chenwj

-- 
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] Does kvm_fd mean KVM or VCPU fd?
  2012-06-14 10:16   ` 陳韋任 (Wei-Ren Chen)
@ 2012-06-14 14:49     ` Andreas Färber
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Färber @ 2012-06-14 14:49 UTC (permalink / raw)
  To: "陳韋任 (Wei-Ren Chen)"
  Cc: Paolo Bonzini, qemu-devel

Am 14.06.2012 12:16, schrieb 陳韋任 (Wei-Ren Chen):
>>>   I think KVM_CREATE_VCPU should return VCPU fd, right? AFAIK, in KVM
>>> world, kvm_fd usually means the fd we get after opening "/dev/kvm".
>>> Just want to make sure I understand the code correcly. Thanks.
>>
>> This is the kvm_fd inside struct CPUState, so it's per-CPU.
> 
>   Okay, then it's VCPU fd. Don't know rename it or add a comment to indicate
> it's a VCPU fd is a good idea. ;)

Not a good idea, those fields need to move from CPU*State to CPUState.
We can rename them then if someone has a good suggestion.

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-06-14 14:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-14  8:24 [Qemu-devel] Does kvm_fd mean KVM or VCPU fd? 陳韋任 (Wei-Ren Chen)
2012-06-14  9:15 ` Paolo Bonzini
2012-06-14 10:16   ` 陳韋任 (Wei-Ren Chen)
2012-06-14 14:49     ` Andreas Färber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).