<div dir="ltr">Thank you for bringing this up.  I'm not experienced with the inner workings of libvirt, but I'm happy to help in anyway I can in terms of clarifying ivshmem's behaviour.<br><br>Cheers,<br>Cam<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 14, 2014 at 2:23 AM, Wangrui (K) <span dir="ltr"><<a href="mailto:moon.wangrui@huawei.com" target="_blank">moon.wangrui@huawei.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Libvirt does not support ivshmem(Inter-VM Shared Memory) device recently,<br>
thus, I would like to know if there's any plan to support it in the future?<br>
If not, I would like to contribute a serial of patches to do so.<br>
<br>
On Jan 28, Wangyufei (James) asked about this question, and Daniel replied with 2 suggestions:<br>
1. Libvirt should be capable of configuring the guest's xml on ivshmem.<br>
2.An ivshmem daemon is needed to run on the host to support it, libvirt is recommended to provide such a daemon.<br>
Please refer to  <a href="https://www.redhat.com/archives/libvir-list/2014-January/msg01335.html" target="_blank">https://www.redhat.com/archives/libvir-list/2014-January/msg01335.html</a> for details.<br>
<br>
What I'll do later is the 1st suggestion, the 2nd one is left to be accomplished by someone else.<br>
<br>
Here is the detailed work I'll do to support configuration of the guest in libvirt:<br>
virDomainDefParseXML:                 parse ivshmem device xml when defining dom.xml<br>
virDomainDeviceInfoIterateInternal:       iterate ivshmem devices<br>
qemuAssignDevicePCISlots:              assign ivshmem device pci slots<br>
virDomainDefFormatInternal:             format ivshmem device xml (Eg. virsh edit dom)<br>
virDomainDefFree:                     free ivshmem device def<br>
<br>
qemuBuildCommandLine:               build ivshmem device command line when vm starts<br>
qemuAssignDeviceAliases:              assign ivshmem device aliases when vm starts<br>
<br>
virDomainDeviceDefParse:               attach and parse ivshmem device xml<br>
qemuDomainAttachDeviceConfig:         attach ivshmem device xml persistently<br>
qemuDomainAttachDeviceLive:           attach ivshmem device online<br>
<br>
qemuDomainDetachDeviceConfig:         detach ivshmem device xml persistently<br>
qemuDomainDetachDeviceLive:           detach ivshmem device online<br>
<br>
<br>
There are two ways to use ivshmem with qemu<br>
(please refer to <a href="http://qemu.weilnetz.de/qemu-doc.html#pcsys_005fother_005fdevs" target="_blank">http://qemu.weilnetz.de/qemu-doc.html#pcsys_005fother_005fdevs</a> ):<br>
1.Guests map a POSIX shared memory region into the guest as a PCI device<br>
that enables zero-copy communication to the application level of the guests, The basic syntax is:<br>
<br>
  qemu-system-i386-device ivshmem, size = <size in format accepted by -m> [, shm = <shm name>]<br>
<br>
2.If desired, interrupts can be sent between guest VMs accessing the same shared memory region.<br>
Interrupt support requires using a shared memory server and using a chardev socket to connect to it.<br>
An example syntax when using the shared memory server is:<br>
<br>
  qemu-system-i386-device ivshmem, size = <size in format accepted by -m> [, chardev = <id>] [, msi = on]<br>
                               [, ioeventfd = on] [, vectors = n] [, role = peer | master]<br>
  qemu-system-i386-chardev socket, path = <path>, id = <id><br>
<br>
The respective xml configuration for the above 2 qemu command lines are shown as below:<br>
<br>
Example1: automatically attach device with KVM<br>
<br>
  <devices><br>
    <ivshmem role='master'><br>
      <memory name='dom-ivshmem' size='2'/><br>
    </ivshmem><br>
  </devices><br>
<br>
NOTE: "size" means ivshmem size in unit MB, "name" means shm name<br>
      "role" is optional, it may be set to "master" or "peer", the default one is "master"<br>
<br>
Example2: manually attach device with static PCI slot 4 requested<br>
<br>
  <devices><br>
    <ivshmem role='master'><br>
      <memory name='dom-ivshmem' size='2'/><br>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/><br>
    </ivshmem><br>
  </devices><br>
<br>
Example3: automatically attach device with KVM<br>
<br>
  <devices><br>
    <ivshmem role='master' type='unix'><br>
      <source mode='connect' path='/tmp/ivshmem'/><br>
      <memory name='dom-ivshmem' size='2'/><br>
    </ivshmem><br>
  </devices><br>
<br>
NOTE: "path" means shared memory socket path which is set by the daemon.<br>
      " source mode " and "type" is similar with vmchannel.<br>
<br>
<br>
I'm looking forward to your suggestions, thank you very much.<br>
<br>
--<br>
libvir-list mailing list<br>
<a href="mailto:libvir-list@redhat.com">libvir-list@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/libvir-list" target="_blank">https://www.redhat.com/mailman/listinfo/libvir-list</a><br>
<br>
</blockquote></div><br></div>