mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
RESEND: Inter-VM shared memory PCI device
resend for bug fix related to removal of irqfd
Support an inter-vm shared memory device that maps a shared-memory object as a
PCI device in the guest. This patch also supports interrupts between guest by
communicating over a unix domain socket. This patch applies to the qemu-kvm
repository.
-device ivshmem,size=<size in format accepted by -m>[,shm=<shm name>]
Interrupts are supported between multiple VMs by using a shared memory server
by using a chardev socket.
-device ivshmem,size=<size in format accepted by -m>[,shm=<shm name>]
[,chardev=<id>][,msi=on][,ioeventfd=on][,vectors=n][,role=peer|master]
-chardev socket,path=<path>,id=<id>
The shared memory server, sample programs and init scripts are in a git repo here:
www.gitorious.org/nahanni
Signed-off-by: Cam Macdonell <cam@cs.ualberta.ca>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
committed by
Anthony Liguori
parent
2431296806
commit
6cbf4c8c64
@@ -190,6 +190,9 @@ obj-$(CONFIG_USB_OHCI) += usb-ohci.o
|
||||
obj-y += rtl8139.o
|
||||
obj-y += e1000.o
|
||||
|
||||
# Inter-VM PCI shared memory
|
||||
obj-y += ivshmem.o
|
||||
|
||||
# Hardware support
|
||||
obj-i386-y += vga.o
|
||||
obj-i386-y += mc146818rtc.o i8259.o pc.o
|
||||
|
||||
+828
File diff suppressed because it is too large
Load Diff
@@ -2087,6 +2087,12 @@ static void tcp_chr_read(void *opaque)
|
||||
}
|
||||
}
|
||||
|
||||
CharDriverState *qemu_chr_open_eventfd(int eventfd){
|
||||
|
||||
return qemu_chr_open_fd(eventfd, eventfd);
|
||||
|
||||
}
|
||||
|
||||
static void tcp_chr_connect(void *opaque)
|
||||
{
|
||||
CharDriverState *chr = opaque;
|
||||
|
||||
@@ -94,6 +94,9 @@ void qemu_chr_info_print(Monitor *mon, const QObject *ret_data);
|
||||
void qemu_chr_info(Monitor *mon, QObject **ret_data);
|
||||
CharDriverState *qemu_chr_find(const char *name);
|
||||
|
||||
/* add an eventfd to the qemu devices that are polled */
|
||||
CharDriverState *qemu_chr_open_eventfd(int eventfd);
|
||||
|
||||
extern int term_escape_char;
|
||||
|
||||
/* async I/O support */
|
||||
|
||||
@@ -706,6 +706,49 @@ Using the @option{-net socket} option, it is possible to make VLANs
|
||||
that span several QEMU instances. See @ref{sec_invocation} to have a
|
||||
basic example.
|
||||
|
||||
@section Other Devices
|
||||
|
||||
@subsection Inter-VM Shared Memory device
|
||||
|
||||
With KVM enabled on a Linux host, a shared memory device is available. Guests
|
||||
map a POSIX shared memory region into the guest as a PCI device that enables
|
||||
zero-copy communication to the application level of the guests. The basic
|
||||
syntax is:
|
||||
|
||||
@example
|
||||
qemu -device ivshmem,size=<size in format accepted by -m>[,shm=<shm name>]
|
||||
@end example
|
||||
|
||||
If desired, interrupts can be sent between guest VMs accessing the same shared
|
||||
memory region. Interrupt support requires using a shared memory server and
|
||||
using a chardev socket to connect to it. The code for the shared memory server
|
||||
is qemu.git/contrib/ivshmem-server. An example syntax when using the shared
|
||||
memory server is:
|
||||
|
||||
@example
|
||||
qemu -device ivshmem,size=<size in format accepted by -m>[,chardev=<id>]
|
||||
[,msi=on][,ioeventfd=on][,vectors=n][,role=peer|master]
|
||||
qemu -chardev socket,path=<path>,id=<id>
|
||||
@end example
|
||||
|
||||
When using the server, the guest will be assigned a VM ID (>=0) that allows guests
|
||||
using the same server to communicate via interrupts. Guests can read their
|
||||
VM ID from a device register (see example code). Since receiving the shared
|
||||
memory region from the server is asynchronous, there is a (small) chance the
|
||||
guest may boot before the shared memory is attached. To allow an application
|
||||
to ensure shared memory is attached, the VM ID register will return -1 (an
|
||||
invalid VM ID) until the memory is attached. Once the shared memory is
|
||||
attached, the VM ID will return the guest's valid VM ID. With these semantics,
|
||||
the guest application can check to ensure the shared memory is attached to the
|
||||
guest before proceeding.
|
||||
|
||||
The @option{role} argument can be set to either master or peer and will affect
|
||||
how the shared memory is migrated. With @option{role=master}, the guest will
|
||||
copy the shared memory on migration to the destination host. With
|
||||
@option{role=peer}, the guest will not be able to migrate with the device attached.
|
||||
With the @option{peer} case, the device should be detached and then reattached
|
||||
after migration using the PCI hotplug support.
|
||||
|
||||
@node direct_linux_boot
|
||||
@section Direct Linux Boot
|
||||
|
||||
|
||||
Reference in New Issue
Block a user