Discussion:
Sharing variables/memory between host and guest ?
Arn
2008-07-12 00:16:46 UTC
Permalink
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
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Dor Laor
2008-07-12 12:33:48 UTC
Permalink
Post by Arn
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.
Post by Arn
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.
Post by Arn
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
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Arn
2008-07-12 21:03:49 UTC
Permalink
Thanks Dor. More below.
Post by Dor Laor
Post by Arn
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 ?
Post by Dor Laor
Post by Arn
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
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Eric Van Hensbergen
2008-07-12 21:15:35 UTC
Permalink
Post by Arn
Post by Dor Laor
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
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Arn
2008-07-12 21:59:30 UTC
Permalink
Post by Eric Van Hensbergen
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 ?
Post by Eric Van Hensbergen
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
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Eric Van Hensbergen
2008-07-12 22:06:47 UTC
Permalink
Post by Arn
Post by Eric Van Hensbergen
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
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Avi Kivity
2008-07-13 10:10:28 UTC
Permalink
Post by Arn
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

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Arn
2008-07-14 21:43:04 UTC
Permalink
Post by Arn
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
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Avi Kivity
2008-07-19 08:29:31 UTC
Permalink
Post by Arn
Post by Arn
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.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Loading...