* Sharing variables/memory between host and guest ?
@ 2008-07-12 0:16 Arn
2008-07-12 12:33 ` Dor Laor
2008-07-13 10:10 ` Avi Kivity
0 siblings, 2 replies; 9+ messages in thread
From: Arn @ 2008-07-12 0:16 UTC (permalink / raw)
To: kvm
How can one share memory (a few variables not necessarily a page)
between host/hypervisor and guest VM ?
Since the guest is just a process within the host, there should be
existing ways to do this.
What about using something like debugfs or sysfs, is it possible to
share variables this way ? Note, I want a system that
is fast, i.e. changes to shared variable/memory should be visible instantly.
I search the kvm-devel archives and found emails referring to "kshmem"
but a search on the kvm-70 code turns up nothing.
There are also some emails on sharing a page but no final outcome or
what exactly to do.
Thanks
Arn
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Sharing variables/memory between host and guest ?
2008-07-12 0:16 Sharing variables/memory between host and guest ? Arn
@ 2008-07-12 12:33 ` Dor Laor
2008-07-12 21:03 ` Arn
2008-07-13 10:10 ` Avi Kivity
1 sibling, 1 reply; 9+ messages in thread
From: Dor Laor @ 2008-07-12 12:33 UTC (permalink / raw)
To: Arn; +Cc: kvm
Arn wrote:
> How can one share memory (a few variables not necessarily a page)
> between host/hypervisor and guest VM ?
> Since the guest is just a process within the host, there should be
> existing ways to do this.
>
It's not that straight forward since the host has its pfn (page frame
number) while the guest has gfn (guest frame number) and also use
virtual memory.
> What about using something like debugfs or sysfs, is it possible to
> share variables this way ? Note, I want a system that
> is fast, i.e. changes to shared variable/memory should be visible instantly.
>
>
A paravirtualized driver can take care of that with driver in the guest
and device side in qemu/host kernel.
You can use 9p virtio solution in Linux that implements a shared file
system.
> I search the kvm-devel archives and found emails referring to "kshmem"
> but a search on the kvm-70 code turns up nothing.
> There are also some emails on sharing a page but no final outcome or
> what exactly to do.
>
> Thanks
> Arn
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Sharing variables/memory between host and guest ?
2008-07-12 12:33 ` Dor Laor
@ 2008-07-12 21:03 ` Arn
2008-07-12 21:15 ` Eric Van Hensbergen
0 siblings, 1 reply; 9+ messages in thread
From: Arn @ 2008-07-12 21:03 UTC (permalink / raw)
To: Dor Laor; +Cc: kvm
Thanks Dor. More below.
>> How can one share memory (a few variables not necessarily a page)
>> between host/hypervisor and guest VM ?
>> Since the guest is just a process within the host, there should be
>> existing ways to do this.
>>
> It's not that straight forward since the host has its pfn (page frame
> number) while the guest has gfn (guest frame number) and also use virtual
> memory.
So does this mean that there is no way to share a page between host
and guest like
can be done in Xen ? Wouldn't such a feature be useful ?
>
>> What about using something like debugfs or sysfs, is it possible to
>> share variables this way ? Note, I want a system that
>> is fast, i.e. changes to shared variable/memory should be visible
>> instantly.
>
> A paravirtualized driver can take care of that with driver in the guest and
> device side in qemu/host kernel.
> You can use 9p virtio solution in Linux that implements a shared file
> system.
I had a look at the 9p related slides on the KVMForum 2008 page on the
wiki and it may serve my purpose but I need to investigate more.
According to the slides 9p has been in Linux since 2.6.14 . I'm
currently using linux kernel 2.6.22-14 (ubuntu 7.10) with a downloaded
kvm-70 . Is this enough for using 9p with KVM or do i need a newer
linux kernel ?
While on this topic I'd like to point out that its a bit difficult to
understand which version of kvm maps to which linux kernel. The page
on the wiki is dated. Is it ok to use a kvm-70 module with a slightly
older linux kernel ?
thanks for you help
arn
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Sharing variables/memory between host and guest ?
2008-07-12 21:03 ` Arn
@ 2008-07-12 21:15 ` Eric Van Hensbergen
2008-07-12 21:59 ` Arn
0 siblings, 1 reply; 9+ messages in thread
From: Eric Van Hensbergen @ 2008-07-12 21:15 UTC (permalink / raw)
To: Arn; +Cc: Dor Laor, kvm
On Sat, Jul 12, 2008 at 4:03 PM, Arn <cse.syslab@gmail.com> wrote:
>>
>> A paravirtualized driver can take care of that with driver in the guest and
>> device side in qemu/host kernel.
>> You can use 9p virtio solution in Linux that implements a shared file
>> system.
>
> I had a look at the 9p related slides on the KVMForum 2008 page on the
> wiki and it may serve my purpose but I need to investigate more.
>
> According to the slides 9p has been in Linux since 2.6.14 . I'm
> currently using linux kernel 2.6.22-14 (ubuntu 7.10) with a downloaded
> kvm-70 . Is this enough for using 9p with KVM or do i need a newer
> linux kernel ?
>
The virtio portions of the kernel were just added in 2.6.24, the
server portion has not yet been integrated into the kvm-qemu mainline,
but is fairly trivial to merge. You can also use the TCP/IP version
of the 9p transport to get access to synthetic file systems until all
the virtio stuff gets merged.
If you really want to stick with the 2.6.22 kernel, it may be possible
to build 9p modules with the back ported virtio changes (in fact we
were doing just that for a bit).
-eric
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: Sharing variables/memory between host and guest ?
2008-07-12 21:15 ` Eric Van Hensbergen
@ 2008-07-12 21:59 ` Arn
2008-07-12 22:06 ` Eric Van Hensbergen
0 siblings, 1 reply; 9+ messages in thread
From: Arn @ 2008-07-12 21:59 UTC (permalink / raw)
To: Eric Van Hensbergen; +Cc: Dor Laor, kvm
Eric, thanks for the prompt response, a few more questions:
> The virtio portions of the kernel were just added in 2.6.24, the
> server portion has not yet been integrated into the kvm-qemu mainline,
> but is fairly trivial to merge. You can also use the TCP/IP version
> of the 9p transport to get access to synthetic file systems until all
> the virtio stuff gets merged.
What exactly is "kvm-qemu mainline" ? Is it the qemu parts of KVM that
have been merged into the kernel ? Could you point to which directory
of the kernel code this refers to (also kernel version) ?
Also would this be a fast way to share a few variables between guest and host ?
> If you really want to stick with the 2.6.22 kernel, it may be possible
> to build 9p modules with the back ported virtio changes (in fact we
> were doing just that for a bit).
No, I can upgrade my kernel. I just need to know which one I should
use. Should I just go with the latest stable 2.6.25.10 kernel with
kvm-70 module ?
Thanks
arn
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Sharing variables/memory between host and guest ?
2008-07-12 21:59 ` Arn
@ 2008-07-12 22:06 ` Eric Van Hensbergen
0 siblings, 0 replies; 9+ messages in thread
From: Eric Van Hensbergen @ 2008-07-12 22:06 UTC (permalink / raw)
To: Arn; +Cc: Dor Laor, kvm
On Sat, Jul 12, 2008 at 4:59 PM, Arn <cse.syslab@gmail.com> wrote:
> Eric, thanks for the prompt response, a few more questions:
>
>> The virtio portions of the kernel were just added in 2.6.24, the
>> server portion has not yet been integrated into the kvm-qemu mainline,
>> but is fairly trivial to merge. You can also use the TCP/IP version
>> of the 9p transport to get access to synthetic file systems until all
>> the virtio stuff gets merged.
>
> What exactly is "kvm-qemu mainline" ? Is it the qemu parts of KVM that
> have been merged into the kernel ? Could you point to which directory
> of the kernel code this refers to (also kernel version) ?
>
I'm talking about the kvm-userspace pieces, not kernel pieces.
-eric
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Sharing variables/memory between host and guest ?
2008-07-12 0:16 Sharing variables/memory between host and guest ? Arn
2008-07-12 12:33 ` Dor Laor
@ 2008-07-13 10:10 ` Avi Kivity
2008-07-14 21:43 ` Arn
1 sibling, 1 reply; 9+ messages in thread
From: Avi Kivity @ 2008-07-13 10:10 UTC (permalink / raw)
To: Arn; +Cc: kvm
Arn wrote:
> How can one share memory (a few variables not necessarily a page)
> between host/hypervisor and guest VM ?
> Since the guest is just a process within the host, there should be
> existing ways to do this.
> What about using something like debugfs or sysfs, is it possible to
> share variables this way ? Note, I want a system that
> is fast, i.e. changes to shared variable/memory should be visible instantly.
>
> I search the kvm-devel archives and found emails referring to "kshmem"
> but a search on the kvm-70 code turns up nothing.
> There are also some emails on sharing a page but no final outcome or
> what exactly to do.
>
>
If you use the -mem-path qemu option, all guest memory will be in a file
on tmpfs. You can mmap that file and access all guest memory. Of
course, this is hitting the problem with a fairly bit hammer; more
refined approaches are possible.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Sharing variables/memory between host and guest ?
2008-07-13 10:10 ` Avi Kivity
@ 2008-07-14 21:43 ` Arn
2008-07-19 8:29 ` Avi Kivity
0 siblings, 1 reply; 9+ messages in thread
From: Arn @ 2008-07-14 21:43 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm
>> How can one share memory (a few variables not necessarily a page)
>> between host/hypervisor and guest VM ?
>>
> If you use the -mem-path qemu option, all guest memory will be in a file on
> tmpfs. You can mmap that file and access all guest memory. Of course, this
> is hitting the problem with a fairly bit hammer; more refined approaches are
> possible.
Could you outline the other approaches ?
Thanks
arn
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Sharing variables/memory between host and guest ?
2008-07-14 21:43 ` Arn
@ 2008-07-19 8:29 ` Avi Kivity
0 siblings, 0 replies; 9+ messages in thread
From: Avi Kivity @ 2008-07-19 8:29 UTC (permalink / raw)
To: Arn; +Cc: kvm
Arn wrote:
>>> How can one share memory (a few variables not necessarily a page)
>>> between host/hypervisor and guest VM ?
>>>
>>>
>> If you use the -mem-path qemu option, all guest memory will be in a file on
>> tmpfs. You can mmap that file and access all guest memory. Of course, this
>> is hitting the problem with a fairly bit hammer; more refined approaches are
>> possible.
>>
>
> Could you outline the other approaches ?
>
>
Have qemu expose the shared memory as a pci device, and write a guest
driver to exploit it. This is what the vga emulation does.
--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-07-19 8:29 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-12 0:16 Sharing variables/memory between host and guest ? Arn
2008-07-12 12:33 ` Dor Laor
2008-07-12 21:03 ` Arn
2008-07-12 21:15 ` Eric Van Hensbergen
2008-07-12 21:59 ` Arn
2008-07-12 22:06 ` Eric Van Hensbergen
2008-07-13 10:10 ` Avi Kivity
2008-07-14 21:43 ` Arn
2008-07-19 8:29 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox