Re: [libvirt] [PATCH 0/4] Add support for vhost-user with multi-queue

2015-06-04 Thread Maxime Leroy
Hi Martin,

On Thu, Jun 4, 2015 at 3:43 PM, Martin Kletzander  wrote:
> Also some tiny clean-up.
>
> Martin Kletzander (2):
>   conf: Ignore multiqueue with one queue.
>   qemu: Add capability for vhost-user multiqueue
>
> Maxime Leroy (2):
>   docs: Clarify that attribute name is not used for vhostuser
>   qemu: add multiqueue vhost-user support
>
>  docs/formatdomain.html.in| 16 
> ++--
>  src/conf/domain_conf.c   |  3 ++-
>  src/qemu/qemu_capabilities.c |  6 ++
>  src/qemu/qemu_capabilities.h |  1 +
>  src/qemu/qemu_command.c  | 15 ++-
>  ...tuser.args => qemuxml2argv-net-vhostuser-multiq.args} |  6 +-
>  ...ostuser.xml => qemuxml2argv-net-vhostuser-multiq.xml} |  6 ++
>  .../qemuxml2argv-tap-vhost-incorrect.xml |  6 ++
>  tests/qemuxml2argvtest.c |  3 +++
>  .../qemuxml2xmlout-tap-vhost-incorrect.xml   |  6 ++
>  10 files changed, 63 insertions(+), 5 deletions(-)
>  copy tests/qemuxml2argvdata/{qemuxml2argv-net-vhostuser.args => 
> qemuxml2argv-net-vhostuser-multiq.args} (75%)
>  copy tests/qemuxml2argvdata/{qemuxml2argv-net-vhostuser.xml => 
> qemuxml2argv-net-vhostuser-multiq.xml} (87%)
>
> --
> 2.4.2

Thanks to send theses patches on the mailing list. Except few
comments, it looks good for me.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 3/4] qemu: Add capability for vhost-user multiqueue

2015-06-04 Thread Maxime Leroy
On Thu, Jun 4, 2015 at 3:43 PM, Martin Kletzander  wrote:
> The support for this was added in QEMU with commit
> 830d70db692e374b5f4407f96a1ceefdcc97.  Unfortunately we have to do
> another ugly version-based capability check.  The other option would be
> not to check for the capability at all and leave that to qemu as it's
> doen with multiqueue tap devices.

typo: doen --> done

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 4/4] qemu: add multiqueue vhost-user support

2015-06-04 Thread Maxime Leroy
On Thu, Jun 4, 2015 at 3:43 PM, Martin Kletzander  wrote:
> From: Maxime Leroy 
>
> This patch adds the support of queues attribute of the driver element
> for vhost-user interface type. Example:
>
> 
>   
>   
>   
>   
> 
>
> Signed-off-by: Maxime Leroy 
> Signed-off-by: Martin Kletzander 
> ---
>  docs/formatdomain.html.in | 11 +--
>  src/qemu/qemu_command.c   | 15 
> ++-
>  ...stuser.args => qemuxml2argv-net-vhostuser-multiq.args} |  6 +-
>  ...hostuser.xml => qemuxml2argv-net-vhostuser-multiq.xml} |  6 ++
>  tests/qemuxml2argvtest.c  |  3 +++
>  5 files changed, 37 insertions(+), 4 deletions(-)
>  copy tests/qemuxml2argvdata/{qemuxml2argv-net-vhostuser.args => 
> qemuxml2argv-net-vhostuser-multiq.args} (75%)
>  copy tests/qemuxml2argvdata/{qemuxml2argv-net-vhostuser.xml => 
> qemuxml2argv-net-vhostuser-multiq.xml} (87%)
>
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index 72ad54cee188..85238a16af8d 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -4260,7 +4260,8 @@ qemu-kvm -net nic,model=? /dev/null
>  type='virtio'/>, multiple packet processing queues can be
>  created; each queue will potentially be handled by a different
>  processor, resulting in much higher throughput.
> -Since 1.0.6 (QEMU and KVM only)
> +Since 1.0.6 (QEMU and KVM only) and for 
> vhost-user
> +  since 1.2.17
>
>host offloading options
>
> @@ -4581,9 +4582,15 @@ qemu-kvm -net nic,model=? /dev/null
><devices>
>  <interface type='vhostuser'>
><mac address='52:54:00:3b:83:1a'/>
> -  <source type='unix' path='/tmp/vhost.sock' mode='server'/>
> +  <source type='unix' path='/tmp/vhost1.sock' mode='server'/>
><model type='virtio'/>
>  </interface>
> +<interface type='vhostuser'>
> +  <mac address='52:54:00:3b:83:1b'/>
> +  <source type='unix' path='/tmp/vhost2.sock' mode='client'/>
> +  <model type='virtio'/>
> +  <driver queues='5'/>
> +</interface>
></devices>
>...
>
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 61faa576e11b..f805f6700e71 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -8089,6 +8089,7 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd,
>  {
>  virBuffer chardev_buf = VIR_BUFFER_INITIALIZER;
>  virBuffer netdev_buf = VIR_BUFFER_INITIALIZER;
> +unsigned int queues = 1;

Why setting queues to 1 and not to net->driver.virtio.queues directly ?

>  char *nic = NULL;
>
>  if (!qemuDomainSupportsNetdev(def, qemuCaps, net)) {
> @@ -8126,13 +8127,25 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd,
>  virBufferAsprintf(&netdev_buf, 
> "type=vhost-user,id=host%s,chardev=char%s",
>net->info.alias, net->info.alias);
>
> +queues = net->driver.virtio.queues;
> +if (queues) {

I know it's never set to 1 thanks to your patch: "conf: Ignore
multiqueue with one queue."

Anyway I think we should check if queues is superior to 1 for
improving code readability.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] conf: tests: fix virDomainNetDefFormat for vhost-user in client mode

2014-10-17 Thread Maxime Leroy
The mode attribute is required for the source element of vhost-user. Thus
virDomainNetDefFormat should always generate a xml with it, and
not only when the mode is server.

The commit fixes the issue. And it adds a vhostuser interface in 'client' mode
to qemuxml2argv-net-vhostuser.(args|xml) to test this usecase.

Signed-off-by: Maxime Leroy 
---
 src/conf/domain_conf.c | 5 +++--
 tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args | 7 +--
 tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml  | 7 ++-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 42c0223..73c199e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17082,8 +17082,9 @@ virDomainNetDefFormat(virBufferPtr buf,
 virBufferAddLit(buf, "data.vhostuser->data.nix.path);
-if (def->data.vhostuser->data.nix.listen)
-virBufferAddLit(buf, " mode='server'");
+virBufferAsprintf(buf, " mode='%s'",
+  def->data.vhostuser->data.nix.listen ?
+  "server"  : "client");
 virBufferAddLit(buf, "/>\n");
 }
 break;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args 
b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args
index cc66ec3..26daac3 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args
@@ -2,6 +2,9 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test 
QEMU_AUDIO_DRV=none \
 /usr/bin/qemu -S -M \
 pc -m 214 -smp 1 -nographic -nodefaults -monitor 
unix:/tmp/test-monitor,server,nowait \
 -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 \
--chardev socket,id=charnet0,path=/tmp/vhost.sock,server \
+-chardev socket,id=charnet0,path=/tmp/vhost0.sock,server \
 -netdev type=vhost-user,id=hostnet0,chardev=charnet0 \
--device 
virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,addr=0x3
+-device 
virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,addr=0x3 
\
+-chardev socket,id=charnet1,path=/tmp/vhost1.sock \
+-netdev type=vhost-user,id=hostnet1,chardev=charnet1 \
+-device 
virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:ee:96:6c,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml
index b49d48e..e5b6242 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml
@@ -25,7 +25,12 @@
 
 
   
-  
+  
+  
+
+
+  
+  
   
 
 
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] tests: fix incorrect caps for shmem-invalid-size, shmem-small-size

2014-10-17 Thread Maxime Leroy
VIR_TEST_DEBUG=2 ./qemuxml2argvtest generates the following output:

409) QEMU XML-2-ARGV shmem-invalid-size
... Got expected error: unsupported configuration: ivshmem device is not \
 supported with this QEMU binary
OK
410) QEMU XML-2-ARGV shmem-small-size
... Got expected error: unsupported configuration: ivshmem device is not \
supported with this QEMU binary
OK

We should have:

409) QEMU XML-2-ARGV shmem-invalid-size
... Got expected error: XML error: shmem size must be a power of two
OK
410) QEMU XML-2-ARGV shmem-small-size
... Got expected error: XML error: shmem size must be at least 1 MiB
OK

This commit fixes the issue by providing QEMU_CAPS_DEVICE_IVSHMEM caps
for shmem-invalid-size, shmem-small-size test.

Signed-off-by: Maxime Leroy 
---
 tests/qemuxml2argvtest.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c13aa99..0e9fab9 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1469,8 +1469,10 @@ mymain(void)
 DO_TEST("shmem", QEMU_CAPS_PCIDEVICE,
 QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_IVSHMEM);
 DO_TEST_FAILURE("shmem", NONE);
-DO_TEST_FAILURE("shmem-invalid-size", NONE);
-DO_TEST_FAILURE("shmem-small-size", NONE);
+DO_TEST_FAILURE("shmem-invalid-size", QEMU_CAPS_PCIDEVICE,
+QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_IVSHMEM);
+DO_TEST_FAILURE("shmem-small-size", QEMU_CAPS_PCIDEVICE,
+QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_IVSHMEM);
 DO_TEST_PARSE_ERROR("shmem-msi-only", NONE);
 
 virObjectUnref(driver.config);
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v3 1/3] docs, conf, schema: add support for shmem device

2014-10-08 Thread Maxime Leroy
Hi Martin,

On Fri, Oct 3, 2014 at 10:45 PM, Martin Kletzander  wrote:
> On Thu, Oct 02, 2014 at 09:42:36AM +0200, Michal Privoznik wrote:
>>
>> On 26.09.2014 12:43, Martin Kletzander wrote:
>>>
>>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>>> index b114737..51bdd31 100644
>>> --- a/src/conf/domain_conf.c
>>> +++ b/src/conf/domain_conf.c
>>
>>
[..]
>>
>
> Nice catch.
>
> Since we are past the release anyway, I'm going to push this in a
> while and whoever wants (e.g. Maxime) have the whole release cycle to
> test this.
>

Thanks for pushing/cleaning the shmem patches support (i.e
http://www.redhat.com/archives/libvir-list/2014-August/msg01032.html)

But you did miss the following:

1. the ivshmem server autostart feature: you wanted me to develop it
into the v1. (i.e.
http://www.redhat.com/archives/libvir-list/2014-August/msg01432.html)

2. You did not wait for my tests. Why should I ask you to wait for my tests?
Lucky enough, now I have the results of the tests, everything works fine ;)

I don't understand why it became so urgent to push these patches.

Anyway, I am glad that libvirt supports ivshmem.

Since now you pushed these patches, do you plan to provide the ivshmem
autostart feature like you requested previously ?

I'll be glad to review it and to provide feedbacks based on my tests.

Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v2 0/3] Add support for shared memory devices

2014-09-26 Thread Maxime Leroy
I will test this v3 instead.

Please, wait for my feedback.

Thank you.

Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v2 0/3] Add support for shared memory devices

2014-09-26 Thread Maxime Leroy
Hi Martin,

On Thu, Sep 25, 2014 at 11:45 AM, Martin Kletzander  wrote:
> This is based on Maxime's patches, but leaving out the last one with
> server starting, the last version was here:
>
> https://www.redhat.com/archives/libvir-list/2014-August/msg01032.html
>

As my original patches have been modified, I want to test it on my
plateform to check there is no regression.

Nack until that.

So, please, wait for this serie.

Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v2 1/3] docs, conf, schema: add support for shmem device

2014-09-26 Thread Maxime Leroy
On Thu, Sep 25, 2014 at 11:45 AM, Martin Kletzander  wrote:
> This patch adds parsing/formatting code as well as documentation for
> shared memory devices.  This will currently be only accessible in QEMU
> using it's ivshmem device, but is designed as generic as possible to
> allow future expansion for other hypervisors.
>
> In the devices section in the domain XML users may specify:
>
> - For shmem device using a server:
>
>  
>
>32
>
>  

I would prefer:


   
  
   
   32


[..]
> +if ((server = virXPathNode("./server", ctxt))) {
> +def->server.enabled = true;
> +
> +if ((tmp = virXMLPropString(server, "path")))
> +def->server.path = virFileSanitizePath(tmp);
> +VIR_FREE(tmp);
> +

The server path is mandatory if the ivshmem server is not started by libvirt.

If the user needs to start manually the ivshmem server, having a
default path doesn't make sense anymore.

> +/*
> + * We can always safely remove this check, but until the
> + * server starting part is in it is better to directly disable
> + * it rather then just ignoring it.
> + */
> +if ((tmp = virXMLPropString(server, "start"))) {
> +virReportError(VIR_ERR_XML_ERROR, "%s",
> +   _("Unsupported start attribute for "
> + "shmem server element"));

If an autostart ivshmem server is implemented, as we agree to
implement for the V2 (see
http://www.redhat.com/archives/libvir-list/2014-September/msg00124.html),
there is no need for a "start" attribute in the server node.

Why this 'dead' code ?

> +goto cleanup;
> +}
> +}
> +
> +if ((msi = virXPathNode("./msi", ctxt))) {
> +def->msi.enabled = true;
> +
> +if ((tmp = virXMLPropString(msi, "vectors")) &&
> +virStrToLong_uip(tmp, NULL, 0, &def->msi.vectors) < 0) {
> +virReportError(VIR_ERR_XML_ERROR,
> +   _("invalid number of vectors for shmem: '%s'"),
> +   tmp);
> +goto cleanup;
> +}
> +VIR_FREE(tmp);
> +
> +if ((tmp = virXMLPropString(msi, "ioeventfd")) &&
> +(def->msi.ioeventfd = virTristateSwitchTypeFromString(tmp)) <= 
> 0) {
> +virReportError(VIR_ERR_XML_ERROR,
> +   _("invalid msi ioeventfd setting for shmem: 
> '%s'"),
> +   tmp);
> +goto cleanup;
> +}
> +VIR_FREE(tmp);
> +}
> +
> +/* msi option is only relevant with a server */
> +if (def->msi.enabled && !def->server.enabled) {
> +virReportError(VIR_ERR_XML_ERROR, "%s",
> +   _("msi option is only supported with a server"));
> +goto cleanup;

If the msi node is inside the server node, i.e:

  

Then, this test can be removed.


Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v2 1/3] docs, conf, schema: add support for shmem device

2014-09-25 Thread Maxime Leroy
Hi Martin,

I am going to test it on my platform before to review/ack it.

Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v1 0/6] ivshmem support

2014-09-03 Thread Maxime Leroy
Hello Martin,

Let me summarize the points we need for the next patchset version:

1) merge patches
  - doc: schema, conf: Parse and format and tests ( for xml2xml ) into
doc: schema: conf: Add shmem node
  - qemu: Build comand, qemu: Add cap flag CAPS_IVSHMEM, and tests
(for xml2argv) into qemu: add ivshmem support

2) parsing shmem
  - remove  'model' attribute
  - use _uip instand of ui
  - check size >= 1M
  - remove loop to parse childreen nodes
  - path attribute is optional, default path is
/var/run/libvirt/ivshmem-server/-sock

3) tests:
 - add pci addresses in the XML

4) xml format

- no ivshmem server:

   (name is a mandatory attribute)
32 (optionnal, default value: 4MB, size >=
1M and power of 2)
  

- ivshmem server with no path to the socket file

   (name is a mandatory attribute)

(optionnal)

32 (optionnal)
  

  default path is : /var/run/libvirt/ivshmem-server/-sock

- ivshmem server with path to a specific socket file

  

(optionnal)

32 (optionnal)
  

The name attribute is only needed if libvirt starts the ivshmem server.
In the case of the ivshmem-server is already running, the path
attribute is enough.
To simplify, I think the name attribute should be always mandatory ?

What do you think about this new xml format ?

5) ivshmem server

 - remame virStartIvshmemServer to virIvshmemServerStart
 - call virIvshmemServerStart in qemuProcessStart instead to
qemuBuild*CommandLine
 - rename IVSHMEMSERVER to IVSHMEM_SERVER
 - autostart/stop ivshmem server

I really like the idea to use the new option '-q' to stop
automatically the server and the new option to pass the fd to
ivshmem-server and qemu. It's an elegant solution. ;)

Anyway, I need to wait to see if theses options can be integrated in
qemu before to submit a new patchset for libvirt.

--
Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v1 6/6] ivshmem: add start param to server attribute

2014-08-27 Thread Maxime Leroy
On Tue, Aug 26, 2014 at 11:58 AM, Wang Rui  wrote:
> On 2014/8/22 18:47, Maxime Leroy wrote:
>
>> +# util/virivshmemserver.h
>> +virStartIvshmemServer;
>> +virStopIvshmemServer;
>
> I think function name virIvshmemStartServer is better.
> So is the stop function.
>

What about virIvshmemServerStart ?

>> @@ -5120,6 +5121,12 @@ qemuBuildIvshmemCommandLine(virCommandPtr cmd,
>>  return -1;
>>  virCommandAddArg(cmd, devstr);
>>  VIR_FREE(devstr);
>> +
>> +if (ivshmem->server.start == VIR_TRISTATE_BOOL_YES) {
>> +if (virStartIvshmemServer(dev->name, ivshmem->server.path,
>> +  ivshmem->size, 
>> ivshmem->msi.vectors))
>> +return -1;
>> +}
>>  }
>
> I'm not sure that calling virStartIvshmemServer in qemuBuildIvshmemCommandLine
> is the best way. Maybe qemuBuild*CommandLine() usually only build commandline.
>

Calling virStartIvshmemServer in qemuProcessStart should be better ?

Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v1 4/6] qemu: Build command line for ivshmem device

2014-08-27 Thread Maxime Leroy
On Tue, Aug 26, 2014 at 11:23 AM, Wang Rui  wrote:
> On 2014/8/22 18:47, Maxime Leroy wrote:
[...]
>> +if (!(devstr = qemuBuildIvshmemDevStr(def, dev, qemuCaps)))
>> +return -1;
>> +virCommandAddArg(cmd, devstr);
>> +VIR_FREE(devstr);
>> +
>> +if (ivshmem->server.enabled) {
>> +virDomainChrSourceDef source;
>> +
>> +source.type = VIR_DOMAIN_CHR_TYPE_UNIX;
>> +source.data.nix.path = ivshmem->server.path;
>> +source.data.nix.listen = false;
>> +
>> +virCommandAddArg(cmd, "-chardev");
>> +if (!(devstr = qemuBuildChrChardevStr(&source, dev->info.alias,
>> +  qemuCaps)))
>> +return -1;
>> +virCommandAddArg(cmd, devstr);
>> +VIR_FREE(devstr);
>
> indentation
>

Ok. Thanks.

Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v1 2/6] conf: Parse and format shmem device XML

2014-08-27 Thread Maxime Leroy
On Tue, Aug 26, 2014 at 11:02 AM, Wang Rui  wrote:
> On 2014/8/22 18:47, Maxime Leroy wrote:
>> This patch adds configuration support for the shmem device
>> as described in the schema in the previous patch.
[..]
>> +if (model) {
>> +if ((def->model == virDomainShmemModelTypeFromString(model)) < 0) {
>
> I guess you intend 'def->modle = ...' not 'def->model == ...' .
>

Thanks. Anyway model attribute will be removed.

Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v1 5/6] tests: Add tests for ivshmem device handling

2014-08-27 Thread Maxime Leroy
On Tue, Aug 26, 2014 at 11:02 AM, Martin Kletzander  wrote:
> On Fri, Aug 22, 2014 at 12:47:04PM +0200, Maxime Leroy wrote:
>>
[...]
>> +
>> +  
>> +  
>> +
>> +
>> +  
>> +  32
>> +  
>
>
> The qemuxml2xmltest didn't faile with this xml, which means we are not
> allocating addresses for shmem devices.  We have to do that and put it
> in the XML so (a) the address won't change and (b) that we know which
> address is occupied by that in case we'll want to attach something to
> the VM.
>

Ok. Thanks.

> And xml2xml (and PARSE_ERROR xml2argv) tests can be squashed into the patch
> with documentation and parsing.  Other xml2argv tests can be squashed
> into the patch where qemu formats the command-line.
>

Ok.

I also should merge the documentation and parsing commit ?

Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v1 4/6] qemu: Build command line for ivshmem device

2014-08-27 Thread Maxime Leroy
On Tue, Aug 26, 2014 at 10:58 AM, Martin Kletzander  wrote:
> On Fri, Aug 22, 2014 at 12:47:03PM +0200, Maxime Leroy wrote:
>>
[..]
>
> It will sometimes format the command-line parameter to size=0m, which
> will terribly fail.  We should add it to the command-line with the
> smallest scale possible, so it can be configured to the tiniest bit
> (and it will also get rid of this error).
>

As explain in my previous email, Ivshmem in qemu only accepts size in MB or GB.

To prevent this error, we should not accept size under 1MB, in
virDomainIvshmemDefParseXML:

 if (virDomainParseScaledValue("./size[1]", ctxt,
 - &def->size, 1,
 +&def->size, 1024x1024,
   ULLONG_MAX, true) < 0)

Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v1 2/6] conf: Parse and format shmem device XML

2014-08-27 Thread Maxime Leroy
On Tue, Aug 26, 2014 at 10:42 AM, Martin Kletzander  wrote:
> On Fri, Aug 22, 2014 at 12:47:01PM +0200, Maxime Leroy wrote:
>>
>> This patch adds configuration support for the shmem device
>> as described in the schema in the previous patch.
>>
[...]
>
> This parsing using loop over children does not readably (and in this
> case neither reliably) check whether required options are present.

For example, I could use: servernode = virXPathNode("./server", ctxt))
instead of having a loop ?

> Currently it parses  as valid, but not specifying
> the size is probably not what you want on qemu command-line ... [1]

Size is an optional parameter of ivshmem in qemu. By default, the size is 4MB.
Thus  is valid.

[...]
>> +if (vectors &&
>> +virStrToLong_ui(vectors, NULL, 10, &def->msi.vectors)
>> < 0) {
>
>
> Use *_uip() if you don't want to accept negative values.
>

Ok. Thanks.

[...]
>> +static int virDomainIvshmemDefFormat(virBufferPtr buf,
>> + virDomainIvshmemDefPtr def)
>> +{
>> +if (def->server.enabled)
>> +virBufferAsprintf(buf, "\n",
>> +  def->server.path);
>
>
> One general idea while looking through the code; could we make the
> path optional or even better, leave the "server" out somehow and
> generalize it even more.  The path could be for example
> "/var/run/libvirt/ivshmem--sock" since we are starting it
> anyway, and permissions on that would be easier to set then (whole
> path is prepared already).  The name would then be enough to get
> either the shmem name or the server socket path.

If libvirt starts the ivshmem server, then we can use a default path.

If libvirt did not start the server, then we should still let the path
as an optional field for cases where the user wants to start the
server himself with a custom path.

We can have an optional path field to handle both cases.

> Question is whether
> we can get the information whether server needs to be started from
> somewhere else.  E.g. does server make sense with no msi vectors and
> without ioeventfd?

The server handles eventfds distribution across ivshmem clients.

These eventfds are used to trigger interrupts (with or without msi) in
the "guests" clients.

So you can imagine starting a server without msi to only trigger
interrupts in the guests.

I would say that the server can be seen as a "support interrupt"
property of the shmem object but calling it server is more explicit.

>
>> +if (def->size)
>> +virBufferAsprintf(buf, "%llu\n",
>> +  def->size  / (1024 * 1024));
>> +
>
>
> If anyone specifies size < 1M, this won't be properly formatted
> (another idea for a test case).

Ivshmem in qemu only accepts size in MB or GB.

To prevent this error, we should not accept size under 1MB, in
virDomainIvshmemDefParseXML:

 if (virDomainParseScaledValue("./size[1]", ctxt,
 - &def->size, 1,
 + &def->size, 1024x1024,
   ULLONG_MAX, true) < 0)

Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v1 1/6] doc: schema: Add documentation for the shmem support

2014-08-27 Thread Maxime Leroy
On Tue, Aug 26, 2014 at 8:22 AM, Martin Kletzander  wrote:
> On Fri, Aug 22, 2014 at 12:47:00PM +0200, Maxime Leroy wrote:
>>
[..]
>> Considering there could be other shared memory related devices,
>> this patch introduces a general device model, called shmem device.
>> Currenly "ivshmem" is the only shared memory model supported.
>>
>
> Automatically adding model='ivshmem' takes away the generality gained
> by renaming the device.  Especially if it is the only model supported
> we don't have to put "model" in there.

Model is an optional attribute. You can still use this xml: 

> If we expand this to another
> device/hypervisor, we then might separate the setting by a model and
> automatically add model='ivshmem', but we might keep it the same if
> the options will compatible.  Until then the model specification just
> adds unnecessary code.
>

It's the same concept from this first implementation of ivshmem:
https://www.redhat.com/archives/libvir-list/2012-November/msg00341.html

Having a model attribute allow to split properly the code specific to
a generic shared memory concept and the code specific to ivshmem.

There are pros and cons to have or not a model attribute.

Anyway, let keep the code simple by removing the model attribute.

>> About ivshmem, please see the following documentation:
>>
>> http://git.qemu.org/?p=qemu.git;a=blob;f=docs/specs/ivshmem_device_spec.txt
>> (Ivshmem documentation for qemu will be updated soon:
>> http://lists.gnu.org/archive/html/qemu-devel/2014-08/msg01244.html)
>>
>> In the devices section in the domain XML users may specify:
>>
>> - For ivshmem device using an ivshmem server:
>>
>> 
>>   
>>   32
>>   
>> 
>
>
> From the documentation you've linked I understand it that either the
> ivshmem has a name *or* it uses a server; and then it doesn't need a
> name because the server sends an FD to the shared memory using
> SCM_RIGHTS.

The name is not needed if libvirt doesn't start the ivshmem server. In
this case, it could be optional.

Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v1 3/6] qemu: Add cap flag QEMU_CAPS_IVSHMEM

2014-08-22 Thread Maxime Leroy
Ivshmem is supported by QEMU since 0.13 release.

Signed-off-by: Maxime Leroy 
---
 src/qemu/qemu_capabilities.c  |  3 +++
 src/qemu/qemu_capabilities.h  |  1 +
 tests/qemucapabilitiesdata/caps_1.2.2-1.caps  |  1 +
 tests/qemucapabilitiesdata/caps_1.3.1-1.caps  |  1 +
 tests/qemucapabilitiesdata/caps_1.4.2-1.caps  |  1 +
 tests/qemucapabilitiesdata/caps_1.5.3-1.caps  |  1 +
 tests/qemucapabilitiesdata/caps_1.6.0-1.caps  |  1 +
 tests/qemucapabilitiesdata/caps_1.6.50-1.caps |  1 +
 tests/qemuhelptest.c  | 17 -
 9 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b758b5a..49e0f0d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -266,6 +266,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
   "memory-backend-file",
   "usb-audio",
   "rtc-reset-reinjection",
+
+  "ivshmem", /* 175 */
 );
 
 
@@ -1487,6 +1489,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
 { "memory-backend-ram", QEMU_CAPS_OBJECT_MEMORY_RAM },
 { "memory-backend-file", QEMU_CAPS_OBJECT_MEMORY_FILE },
 { "usb-audio", QEMU_CAPS_OBJECT_USB_AUDIO },
+{ "ivshmem", QEMU_CAPS_DEVICE_IVSHMEM },
 };
 
 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index cbd3646..1005a4e 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -214,6 +214,7 @@ typedef enum {
 QEMU_CAPS_OBJECT_MEMORY_FILE = 172, /* -object memory-backend-file */
 QEMU_CAPS_OBJECT_USB_AUDIO   = 173, /* usb-audio device support */
 QEMU_CAPS_RTC_RESET_REINJECTION = 174, /* rtc-reset-reinjection monitor 
command */
+QEMU_CAPS_DEVICE_IVSHMEM = 175, /* -device ivshmem */
 
 QEMU_CAPS_LAST,   /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps 
b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
index c8a379a..f32bc27 100644
--- a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
@@ -116,4 +116,5 @@
 
 
 
+
   
diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps 
b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
index 4b7651e..f4f0397 100644
--- a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
@@ -129,4 +129,5 @@
 
 
 
+
   
diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps 
b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
index d146bf9..e6659e4 100644
--- a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
@@ -130,4 +130,5 @@
 
 
 
+
   
diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps 
b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
index 5fa30aa..591cde6 100644
--- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
@@ -138,4 +138,5 @@
 
 
 
+
   
diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps 
b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
index f364bbf..538a16e 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
@@ -145,4 +145,5 @@
 
 
 
+
   
diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps 
b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
index 10ce1b5..b814e8a 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
@@ -144,4 +144,5 @@
 
 
 
+
   
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 366e36d..ba12cdb 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -518,7 +518,8 @@ mymain(void)
 QEMU_CAPS_DEVICE_SCSI_GENERIC,
 QEMU_CAPS_DEVICE_USB_KBD,
 QEMU_CAPS_DEVICE_USB_STORAGE,
-QEMU_CAPS_HOST_PCI_MULTIDOMAIN);
+QEMU_CAPS_HOST_PCI_MULTIDOMAIN,
+QEMU_CAPS_DEVICE_IVSHMEM);
 DO_TEST("qemu-kvm-0.12.1.2-rhel61", 12001, 1, 0,
 QEMU_CAPS_VNC_COLON,
 QEMU_CAPS_NO_REBOOT,
@@ -745,7 +746,8 @@ mymain(void)
 QEMU_CAPS_DEVICE_SCSI_GENERIC,
 QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX,
 QEMU_CAPS_DEVICE_USB_KBD,
-QEMU_CAPS_DEVICE_USB_STORAGE);
+QEMU_CAPS_DEVICE_USB_STORAGE,
+QEMU_CAPS_DEVICE_IVSHMEM);
 DO_TEST("qemu-1.1.0", 1001000, 0, 0,
 QEMU_CAPS_VNC_COLON,
 QEMU_CAPS_NO_REBOOT,
@@ -843,7 +845,9 @@ mymain(void)
 QEMU_CAPS_VNC_SHARE_POLICY,
 QEMU_CAPS_DEVICE_USB_KBD,
 QEMU_CAPS_DEVICE_USB_STORAGE,
-QEMU_CAPS_OBJECT_USB_AUD

[libvirt] [PATCH v1 4/6] qemu: Build command line for ivshmem device

2014-08-22 Thread Maxime Leroy
This patch implements support for the ivshmem device
in QEMU.

Example from this xml:


  
  32
  


The following QEMU line is built:

   -device ivshmem,size=32m,vectors=32,chardev=charshmem0,msi=on,
ioeventfd=on,role=master
   -chardev socket,path=/tmp/socket-ivshmem0,id=charshmem0

Note: PCI hotpluging is not implemented.

Signed-off-by: Maxime Leroy 
---
 src/qemu/qemu_command.c | 105 +++-
 src/qemu/qemu_command.h |   4 ++
 src/qemu/qemu_hotplug.c |   1 +
 3 files changed, 109 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0d7b12d..9fcceae 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1019,6 +1019,10 @@ qemuAssignDeviceAliases(virDomainDefPtr def, 
virQEMUCapsPtr qemuCaps)
 if (virAsprintf(&def->hubs[i]->info.alias, "hub%zu", i) < 0)
 return -1;
 }
+for (i = 0; i < def->nshmems; i++) {
+if (virAsprintf(&def->shmems[i]->info.alias, "shmem%zu", i) < 0)
+return -1;
+}
 for (i = 0; i < def->nsmartcards; i++) {
 if (virAsprintf(&def->smartcards[i]->info.alias, "smartcard%zu", i) < 
0)
 return -1;
@@ -5043,6 +5047,100 @@ qemuBuildRedirdevDevStr(virDomainDefPtr def,
 return NULL;
 }
 
+static char *
+qemuBuildIvshmemDevStr(virDomainDefPtr def,
+   virDomainShmemDefPtr dev,
+   virQEMUCapsPtr qemuCaps)
+{
+virBuffer buf = VIR_BUFFER_INITIALIZER;
+virDomainIvshmemDefPtr ivshmem = &dev->data.ivshmem;
+
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("ivshmem device is not supported by QEMU"));
+goto error;
+}
+
+virBufferAddLit(&buf, "ivshmem");
+if (ivshmem->size)
+virBufferAsprintf(&buf, ",size=%llum", ivshmem->size / (1024 * 1024));
+
+if (!ivshmem->server.enabled)
+virBufferAsprintf(&buf, ",shm=%s", dev->name);
+else {
+virBufferAsprintf(&buf, ",chardev=char%s", dev->info.alias);
+if (ivshmem->msi.enabled) {
+virBufferAddLit(&buf, ",msi=on");
+if (ivshmem->msi.vectors)
+virBufferAsprintf(&buf, ",vectors=%u", ivshmem->msi.vectors);
+if (ivshmem->msi.ioeventfd)
+virBufferAsprintf(&buf, ",ioeventfd=%s",
+  
virTristateSwitchTypeToString(ivshmem->msi.ioeventfd));
+}
+}
+
+if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
+goto error;
+
+if (virBufferCheckError(&buf) < 0)
+goto error;
+
+return virBufferContentAndReset(&buf);
+
+ error:
+virBufferFreeAndReset(&buf);
+return NULL;
+}
+
+static int
+qemuBuildIvshmemCommandLine(virCommandPtr cmd,
+virDomainDefPtr def,
+virDomainShmemDefPtr dev,
+virQEMUCapsPtr qemuCaps)
+{
+char *devstr;
+virDomainIvshmemDefPtr ivshmem = &dev->data.ivshmem;
+
+virCommandAddArg(cmd, "-device");
+if (!(devstr = qemuBuildIvshmemDevStr(def, dev, qemuCaps)))
+return -1;
+virCommandAddArg(cmd, devstr);
+VIR_FREE(devstr);
+
+if (ivshmem->server.enabled) {
+virDomainChrSourceDef source;
+
+source.type = VIR_DOMAIN_CHR_TYPE_UNIX;
+source.data.nix.path = ivshmem->server.path;
+source.data.nix.listen = false;
+
+virCommandAddArg(cmd, "-chardev");
+if (!(devstr = qemuBuildChrChardevStr(&source, dev->info.alias,
+  qemuCaps)))
+return -1;
+virCommandAddArg(cmd, devstr);
+VIR_FREE(devstr);
+}
+
+return 0;
+}
+
+static int
+qemuBuildShmemCommandLine(virCommandPtr cmd,
+  virDomainDefPtr def,
+  virDomainShmemDefPtr dev,
+  virQEMUCapsPtr qemuCaps)
+{
+switch (dev->model) {
+case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM:
+return qemuBuildIvshmemCommandLine(cmd, def, dev, qemuCaps);
+default:
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Unexpected shem model %d"), dev->model);
+}
+return -1;
+}
+
 char *
 qemuBuildUSBHostdevDevStr(virDomainDefPtr def,
   virDomainHostdevDefPtr dev,
@@ -5299,7 +5397,7 @@ qemuBuildSCSIHostdevDevStr(virDomainDefPtr def,
 
 /* This function outputs a -chardev command line option which describes only 
the
  * host side of the character d

[libvirt] [PATCH v1 5/6] tests: Add tests for ivshmem device handling

2014-08-22 Thread Maxime Leroy
Add XML parsing and qemu command line tests for the ivshmem
device support.

Signed-off-by: Maxime Leroy 
---
 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args | 10 +++
 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml  | 35 
 tests/qemuxml2argvtest.c |  3 ++
 tests/qemuxml2xmltest.c  |  2 ++
 4 files changed, 50 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args 
b/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args
new file mode 100644
index 000..8a5cc0f
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args
@@ -0,0 +1,10 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S \
+-M pc -m 214 -smp 1 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
+-device ivshmem,chardev=charshmem0,msi=on,vectors=32,ioeventfd=on \
+-chardev socket,id=charshmem0,path=/tmp/socket-shmem0 \
+-device ivshmem,size=32m,chardev=charshmem1,msi=on,vectors=32 \
+-chardev socket,id=charshmem1,path=/tmp/socket-shmem1 \
+-device ivshmem,size=32m,shm=shmem2,bus=pci.0,addr=0x8
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml
new file mode 100644
index 000..7177612
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml
@@ -0,0 +1,35 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219100
+  219100
+  1
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu
+
+
+
+
+
+  
+  
+
+
+  
+  32
+  
+
+
+  32
+  
+
+  
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 65dc9c7..f91ac36 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1431,6 +1431,9 @@ mymain(void)
 DO_TEST("panic", QEMU_CAPS_DEVICE_PANIC,
 QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
 
+DO_TEST("ivshmem", QEMU_CAPS_PCIDEVICE,
+QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_IVSHMEM);
+
 virObjectUnref(driver.config);
 virObjectUnref(driver.caps);
 virObjectUnref(driver.xmlopt);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 5941323..4e62fe9 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -388,6 +388,8 @@ mymain(void)
 DO_TEST_DIFFERENT("numatune-memnode");
 DO_TEST("numatune-memnode-no-memory");
 
+DO_TEST("ivshmem");
+
 virObjectUnref(driver.caps);
 virObjectUnref(driver.xmlopt);
 
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v1 1/6] doc: schema: Add documentation for the shmem support

2014-08-22 Thread Maxime Leroy
This patch documents XML elements used for support of shmem
devices.

Considering there could be other shared memory related devices,
this patch introduces a general device model, called shmem device.
Currenly "ivshmem" is the only shared memory model supported.

About ivshmem, please see the following documentation:
http://git.qemu.org/?p=qemu.git;a=blob;f=docs/specs/ivshmem_device_spec.txt
(Ivshmem documentation for qemu will be updated soon:
http://lists.gnu.org/archive/html/qemu-devel/2014-08/msg01244.html)

In the devices section in the domain XML users may specify:

- For ivshmem device using an ivshmem server:

 
   
   32
   
 

- For ivshmem device not using an ivshmem server:

 
   32
 

Signed-off-by: Maxime Leroy 
---
 docs/formatdomain.html.in | 68 +++
 docs/schemas/domaincommon.rng | 49 +++
 2 files changed, 117 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index ed17389..c7644bc 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5422,6 +5422,74 @@ qemu-kvm -net nic,model=? /dev/null
 
   
 
+Shmem device
+
+
+  A shmem (i.e. shared memory) device allows to share a memory
+  region between different virtual machines and the host.
+
+
+
+  ...
+  <devices>
+<shmem name='shmem0' model='ivshmem'/>
+<shmem name='shmem1' model='ivshmem'/>
+  </devices>
+  ...
+
+
+   shmem
+   
+ The shmem element has one mandatory attribute,
+ name to identify the shared memory. The optional element
+ model specify the type of shared memory. Only one mode of
+ shared-memory is currently supported: ivshmem.
+   
+
+
+Ivshmem model
+
+
+  An ivshmem (i.e. Inter-VM shared memory) device allows to share a memory
+  region (created on the host via the POSIX shared memory API) between
+  multiple QEMU processes running different guests.
+  For more information, please see the
+  http://git.qemu.org/?p=qemu.git;a=blob;f=docs/specs/ivshmem_device_spec.txt";>
+ivshmem documentation of qemu.
+
+
+
+  ...
+  <devices>
+<shmem name='shmem0' model='ivshmem'>
+  <server path='/tmp/socket-shmem0'/>
+  <size unit='M'>32</size>
+  <msi vectors='32' ioeventfd='on'/>
+</shmem>
+<shmem name='shmem1' model='ivshmem'>
+  <size unit='M'>32</size>
+</shmem>
+  </devices>
+  ...
+
+  
+server
+The optional server element can be used to configure an
+  ivshmem device connected to the ivshmem server via a unix socket. The
+  path attribute specifies the path to the unix socket.
+
+size
+The optional size element specifies the size of the 
shared memory.
+
+msi
+The optional msi element allows to enable MSI interrupts.
+  This option can only be used with the server attribute.
+  The vectors attribute can be used to specify the number of
+  interrupt vectors. The ioeventd attribute allows to enable
+  ioeventfd.
+
+  
+
 Security label
 
 
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 033f2f6..64abf2b 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3221,6 +3221,54 @@
   
 
   
+
+  
+
+  
+  
+
+  
+  
+
+  
+  
+
+  
+
+  
+
+ 
+   
+ 
+   ivshmem
+ 
+ 
+   
+ 
+   
+ 
+   
+   
+ 
+   
+ 
+   
+   
+ 
+   
+ 
+   
+ 
+   
+   
+ 
+   
+ 
+   
+ 
+   
+ 
+
   
 
   
@@ -3807,6 +3855,7 @@
 
 
 
+
   
 
 
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v1 6/6] ivshmem: add start param to server attribute

2014-08-22 Thread Maxime Leroy
With the new start param, we are able to start the
ivshmem-server.

With this xml:

  
 
 32
 
  

Libvirt will execute an ivshmem-server:

  /usr/bin/ivshmem-server -m ivshmem0 -S /tmp/ivshmem0.sock  \
-p /var/run/libvirt/ivshmem-server/ivshd-ivshmem0.pid  -n 32

Signed-off-by: Maxime Leroy 
---
 configure.ac|   4 +
 docs/formatdomain.html.in   |   5 +-
 docs/schemas/domaincommon.rng   |   3 +
 po/POTFILES.in  |   1 +
 src/Makefile.am |   1 +
 src/conf/domain_conf.c  |  19 +++-
 src/conf/domain_conf.h  |   1 +
 src/libvirt_private.syms|   5 +
 src/qemu/qemu_command.c |   7 ++
 src/qemu/qemu_process.c |  10 ++
 src/util/virivshmemserver.c | 141 
 src/util/virivshmemserver.h |  28 +
 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml |   2 +-
 13 files changed, 223 insertions(+), 4 deletions(-)
 create mode 100644 src/util/virivshmemserver.c
 create mode 100644 src/util/virivshmemserver.h

diff --git a/configure.ac b/configure.ac
index f93c6c2..6b525b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -431,6 +431,8 @@ AC_PATH_PROG([SCRUB], [scrub], [scrub],
[/sbin:/usr/sbin:/usr/local/sbin:$PATH])
 AC_PATH_PROG([ADDR2LINE], [addr2line], [addr2line],
 [/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:$PATH])
+AC_PATH_PROG([IVSHMEMSERVER], [ivshmem-server], [ivshmem-server],
+   [/usr/bin:/usr/local/bin:$PATH])
 
 AC_DEFINE_UNQUOTED([DMIDECODE],["$DMIDECODE"],
 [Location or name of the dmidecode program])
@@ -463,6 +465,8 @@ AC_DEFINE_UNQUOTED([SCRUB],["$SCRUB"],
 [Location or name of the scrub program (for wiping algorithms)])
 AC_DEFINE_UNQUOTED([ADDR2LINE],["$ADDR2LINE"],
 [Location of addr2line program])
+AC_DEFINE_UNQUOTED([IVSHMEMSERVER], ["$IVSHMEMSERVER"],
+   [Location or name of ivshmem-server program])
 
 dnl Specific dir for HTML output ?
 AC_ARG_WITH([html-dir], [AS_HELP_STRING([--with-html-dir=path],
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index c7644bc..df231d8 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5462,7 +5462,7 @@ qemu-kvm -net nic,model=? /dev/null
   ...
   <devices>
 <shmem name='shmem0' model='ivshmem'>
-  <server path='/tmp/socket-shmem0'/>
+  <server path='/tmp/socket-shmem0' start='yes'/>
   <size unit='M'>32</size>
   <msi vectors='32' ioeventfd='on'/>
 </shmem>
@@ -5477,6 +5477,9 @@ qemu-kvm -net nic,model=? /dev/null
 The optional server element can be used to configure an
   ivshmem device connected to the ivshmem server via a unix socket. The
   path attribute specifies the path to the unix socket.
+  The start attribute specifies if the libvirt must start
+  the ivshmem-server. By default, libvirt expects that the ivshmem-server 
is
+  already running on the host.
 
 size
 The optional size element specifies the size of the 
shared memory.
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 64abf2b..a601747 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3246,6 +3246,9 @@

  

+ 
+   
+ 
  


diff --git a/po/POTFILES.in b/po/POTFILES.in
index f17b35f..7d90517 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -177,6 +177,7 @@ src/util/viridentity.c
 src/util/virinitctl.c
 src/util/viriptables.c
 src/util/viriscsi.c
+src/util/virivshmemserver.c
 src/util/virjson.c
 src/util/virkeyfile.c
 src/util/virlockspace.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 538530e..00e1ccf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -118,6 +118,7 @@ UTIL_SOURCES =  
\
util/virinitctl.c util/virinitctl.h \
util/viriptables.c util/viriptables.h   \
util/viriscsi.c util/viriscsi.h \
+   util/virivshmemserver.c util/virivshmemserver.h \
util/virjson.c util/virjson.h   \
util/virkeycode.c util/virkeycode.h \
util/virkeyfile.c util/virkeyfile.h \
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 08d653a..224b367 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9509,6 +9509,7 @@ virDomainIvshmemDefParseXML(xmlNodePtr node,
 {
 char *ioeventfd = NULL;
 char *vectors = NULL;
+char *start = NULL;
 xmlNodePtr cur;

[libvirt] [PATCH v1 2/6] conf: Parse and format shmem device XML

2014-08-22 Thread Maxime Leroy
This patch adds configuration support for the shmem device
as described in the schema in the previous patch.

Signed-off-by: Maxime Leroy 
---
 src/conf/domain_conf.c   | 249 ++-
 src/conf/domain_conf.h   |  41 
 src/libvirt_private.syms |   2 +
 3 files changed, 291 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9557020..08d653a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -234,7 +234,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
   "chr",
   "memballoon",
   "nvram",
-  "rng")
+  "rng",
+  "shmem")
 
 VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
   "none",
@@ -759,6 +760,9 @@ VIR_ENUM_IMPL(virDomainDiskMirrorState, 
VIR_DOMAIN_DISK_MIRROR_STATE_LAST,
   "abort",
   "pivot")
 
+VIR_ENUM_IMPL(virDomainShmemModel, VIR_DOMAIN_SHMEM_MODEL_LAST,
+  "ivshmem")
+
 /* Internal mapping: subset of block job types that can be present in
  *  XML (remaining types are not two-phase). */
 VIR_ENUM_DECL(virDomainBlockJob)
@@ -1692,6 +1696,26 @@ void virDomainWatchdogDefFree(virDomainWatchdogDefPtr 
def)
 VIR_FREE(def);
 }
 
+void virDomainShmemDefFree(virDomainShmemDefPtr def)
+{
+if (!def)
+return;
+
+switch (def->model) {
+case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM:
+VIR_FREE(def->data.ivshmem.server.path);
+break;
+default:
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Unexpected shmem model %d"), def->model);
+}
+
+virDomainDeviceInfoClear(&def->info);
+
+VIR_FREE(def->name);
+VIR_FREE(def);
+}
+
 void virDomainVideoDefFree(virDomainVideoDefPtr def)
 {
 if (!def)
@@ -1893,6 +1917,9 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def)
 case VIR_DOMAIN_DEVICE_NVRAM:
 virDomainNVRAMDefFree(def->data.nvram);
 break;
+case VIR_DOMAIN_DEVICE_SHMEM:
+virDomainShmemDefFree(def->data.shmem);
+break;
 case VIR_DOMAIN_DEVICE_LAST:
 case VIR_DOMAIN_DEVICE_NONE:
 break;
@@ -2134,6 +2161,10 @@ void virDomainDefFree(virDomainDefPtr def)
 
 virDomainRedirFilterDefFree(def->redirfilter);
 
+for (i = 0; i < def->nshmems; i++)
+virDomainShmemDefFree(def->shmems[i]);
+VIR_FREE(def->shmems);
+
 if (def->namespaceData && def->ns.free)
 (def->ns.free)(def->namespaceData);
 
@@ -2568,6 +2599,8 @@ virDomainDeviceGetInfo(virDomainDeviceDefPtr device)
 return &device->data.memballoon->info;
 case VIR_DOMAIN_DEVICE_NVRAM:
 return &device->data.nvram->info;
+case VIR_DOMAIN_DEVICE_SHMEM:
+return &device->data.shmem->info;
 case VIR_DOMAIN_DEVICE_RNG:
 return &device->data.rng->info;
 
@@ -2783,6 +2816,12 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
 if (cb(def, &device, &def->hubs[i]->info, opaque) < 0)
 return -1;
 }
+device.type = VIR_DOMAIN_DEVICE_SHMEM;
+for (i = 0; i < def->nshmems; i++) {
+device.data.shmem = def->shmems[i];
+if (cb(def, &device, &def->shmems[i]->info, opaque) < 0)
+return -1;
+}
 
 /* This switch statement is here to trigger compiler warning when adding
  * a new device type. When you are adding a new field to the switch you
@@ -2809,6 +2848,7 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
 case VIR_DOMAIN_DEVICE_CHR:
 case VIR_DOMAIN_DEVICE_MEMBALLOON:
 case VIR_DOMAIN_DEVICE_NVRAM:
+case VIR_DOMAIN_DEVICE_SHMEM:
 case VIR_DOMAIN_DEVICE_LAST:
 case VIR_DOMAIN_DEVICE_RNG:
 break;
@@ -9462,6 +9502,135 @@ virDomainNVRAMDefParseXML(xmlNodePtr node,
 return NULL;
 }
 
+static int
+virDomainIvshmemDefParseXML(xmlNodePtr node,
+xmlXPathContextPtr ctxt,
+virDomainIvshmemDefPtr def)
+{
+char *ioeventfd = NULL;
+char *vectors = NULL;
+xmlNodePtr cur;
+xmlNodePtr save = ctxt->node;
+int ret;
+
+cur = node->children;
+while (cur != NULL) {
+if (cur->type == XML_ELEMENT_NODE) {
+if (xmlStrEqual(cur->name, BAD_CAST "server")) {
+def->server.enabled = true;
+if (!(def->server.path = virXMLPropString(cur, "path"))) {
+virReportError(VIR_ERR_XML_ERROR, "%s",
+   _("cannot parse  'path' 
attribute"));
+goto error;
+}
+   

[libvirt] [PATCH v1 0/6] ivshmem support

2014-08-22 Thread Maxime Leroy
The following patches are an implementation of
a new shmem device to support ivshmem in libvirt.

Any feedback is welcome.

Changes since RFC:
- replace  by a more generic term 
- remove role attribute
- libvirt is able to start and stop an ivshmem server
- update xml format from:
 
   
   32
   
 
 to:
 
   
   32
   
 

Maxime Leroy (6):
  doc: schema: Add documentation for the shmem support
  conf: Parse and format shmem device XML
  qemu: Add cap flag QEMU_CAPS_IVSHMEM
  qemu: Build command line for ivshmem device
  tests: Add tests for ivshmem device handling
  ivshmem: add start param to server attribute

 configure.ac |   4 +
 docs/formatdomain.html.in|  71 ++
 docs/schemas/domaincommon.rng|  52 +
 po/POTFILES.in   |   1 +
 src/Makefile.am  |   1 +
 src/conf/domain_conf.c   | 264 ++-
 src/conf/domain_conf.h   |  42 
 src/libvirt_private.syms |   7 +
 src/qemu/qemu_capabilities.c |   3 +
 src/qemu/qemu_capabilities.h |   1 +
 src/qemu/qemu_command.c  | 112 +-
 src/qemu/qemu_command.h  |   4 +
 src/qemu/qemu_hotplug.c  |   1 +
 src/qemu/qemu_process.c  |  10 +
 src/util/virivshmemserver.c  | 141 
 src/util/virivshmemserver.h  |  28 +++
 tests/qemucapabilitiesdata/caps_1.2.2-1.caps |   1 +
 tests/qemucapabilitiesdata/caps_1.3.1-1.caps |   1 +
 tests/qemucapabilitiesdata/caps_1.4.2-1.caps |   1 +
 tests/qemucapabilitiesdata/caps_1.5.3-1.caps |   1 +
 tests/qemucapabilitiesdata/caps_1.6.0-1.caps |   1 +
 tests/qemucapabilitiesdata/caps_1.6.50-1.caps|   1 +
 tests/qemuhelptest.c |  17 +-
 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args |  10 +
 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml  |  35 +++
 tests/qemuxml2argvtest.c |   3 +
 tests/qemuxml2xmltest.c  |   2 +
 27 files changed, 808 insertions(+), 7 deletions(-)
 create mode 100644 src/util/virivshmemserver.c
 create mode 100644 src/util/virivshmemserver.h
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml

-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [RFC PATCH 1/5] doc: schema: Add basic documentation for the ivshmem support

2014-08-08 Thread Maxime Leroy
On Fri, Aug 8, 2014 at 11:21 AM, Martin Kletzander  wrote:
> On Thu, Aug 07, 2014 at 05:34:35PM +0200, Maxime Leroy wrote:
>>
>> On Thu, Aug 7, 2014 at 12:33 PM, Martin Kletzander 
>> wrote:
>>>
>>> On Tue, Aug 05, 2014 at 06:48:01PM +0200, Maxime Leroy wrote:
>>>>
[...]
>>>
>>>> Note: the ivshmem server needs to be launched before
>>>>   creating the VM. It's not done by libvirt.
>>>>
>>>
>>> This is a good temporary workaround, but keep in mind that libvirt
>>> works remotely as well and for remote machines libvirt should be able
>>> to do everything for you to be able to run the machine if necessary.
>>> So even if it might not start the server now, it should in the future.
>>> That should be at least differentiable by some parameter (maybe you do
>>> it somewhere in the code somehow, I haven't got into that).
>>>
>>
>> The new version of ivshmem server has not been accepted yet in QEMU.
>> I think it's too early to have an option to launch an ivshmem server or
>> not.
>>
>> I will prefer to focus on integrating these patches in libvirt first,
>> before adding a new feature to launch an ivhsmem server.
>>
>> Are you ok with that ?
>>
>
> There was a suggestion of implementing the non-server variant first
> and expand it to the variant with server afterwards.  That might be
> the best solution because we'll have bit more time to see the
> re-factoring differences in QEMU as well.  And we can concentrate on
> other details.
>

I would prefer to have ivshmen server and non-server mode supported in
libvirt with these patches; because the XML format need to be designed
with both at the same time.

The new XML format supporting a start or not of ivshmem server could be:


  
  
  32
  


Note: This new XML format can support different types of shmem.

After my holiday, I am going to check how to implement this feature.
What do you think about this XML format?

Any hints to develop this feature (i.e. starting ivshmen server in
libvirt) is welcomed.

I assume I need to add a new file: src/util/virivshmemserver.c to add
a new function virIvshmemServerRun() and to use it in qemu_command.c.

How can I check whether an ivshmem-server application is installed or
not on the host ? Are there other equivalent behaviors into libvirt?

Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [RFC PATCH 1/5] doc: schema: Add basic documentation for the ivshmem support

2014-08-07 Thread Maxime Leroy
On Thu, Aug 7, 2014 at 12:33 PM, Martin Kletzander  wrote:
> On Tue, Aug 05, 2014 at 06:48:01PM +0200, Maxime Leroy wrote:
>>
>> This patch documents XML elements used for support of ivshmem
>> devices.
>>
>
> At first, I'd like to thank you for the proposal.  There were numerous
> requests for this, but since ivshmem is not known much, it's not easy
> to get it in.  I'll get to the details later.
>

You welcome. ;) Thanks for the review.

[...]
> At first, we should be more generic about the name if we want other
> hypervisors to benefit from it.  The idea is that ivshmem is not
> something new that nobody else than qemu can do.  It's just a shared
> memory, every other hypervisor out there can come up with something
> similar to this, so we don't want this to be called ivshmem.  One more
> reason for that is that it doesn't just share memory between VMs, but
> between host <-> guest too.  Something like a 'shmem' should be fine,
> I guess.
>

I agree with you, shmem is a better name for ivshmem.

In such a case, should ivshmem be renamed in QEMU ?

This would break compatibility with older versions of QEMU.

If we change ivshmem name in QEMU, we need to manage this case in libvirt.

So, I am not sure about this point.

> I prolonged the paragraph to stress out this is not qemu-only feature
> (or might not be in the future) and we should be prepared for that.
> Because of that, we should be more generic about more things than just
> the name.
>
> Another thing that bothers me (and bothered me with earlier
> ivshmem-related proposals as well) is that role='(master|peer)' thing.
> That thing does not mean squat for qemu and should be removed
> completely.  Looking at the code the only thing that role=peer
> (non-default, by the way) does is that it disables migration...
> That's it.  That's another sign of the ivshmem code maturity inside
> QEMU that we should keep in mind when designing the XML schema.
>
>

Ok. I added this role to be coherent with the initial proposals.

I agree with you, we should wait that live migration is properly
supported in ivshmem QEMU before adding any options related to that in
libvirt.

So I will remove this role to avoid adding confusions.

>
>
>> Note: the ivshmem server needs to be launched before
>>   creating the VM. It's not done by libvirt.
>>
>
> This is a good temporary workaround, but keep in mind that libvirt
> works remotely as well and for remote machines libvirt should be able
> to do everything for you to be able to run the machine if necessary.
> So even if it might not start the server now, it should in the future.
> That should be at least differentiable by some parameter (maybe you do
> it somewhere in the code somehow, I haven't got into that).
>

The new version of ivshmem server has not been accepted yet in QEMU.
I think it's too early to have an option to launch an ivshmem server or not.

I will prefer to focus on integrating these patches in libvirt first,
before adding a new feature to launch an ivhsmem server.

Are you ok with that ?

>> - For ivshmem device not using an ivshmem server:
>>
>> 
>>   
>>   32
>> 
>>
>> Note: the ivshmem shm needs to be created before
>>   creating the VM. It's not done by libvirt.
>>
>
> Isn't it done by qemu automatically?  If it's not, the same as for the
> ivshmem server applies.

Just checked the QEMU code, QEMU creates the file if it doesn't exist yet.
So my mistake ;)

> I had one idea to deal with most of the problems (but adding a lot of
> code); let me outline that.  From the global POV, we want something
> that will fully work remotely, we want to be able to start it, stop
> it, assign it to domains, etc.  We might even migrate it in the
> future, but that's another storyline.  It must be generic enough, as
> it can change a lot in the future.  And so on.  One way out of this
> mess is to have yet another driver, let's call it shmem driver.  That
> driver would have APIs to define, undefine, ..., start and stop shared
> memory regions.  Those would have their own XML, and domain XML would
> only have a device  or 
> that would mean the domain will be started with a shared memory
> region defined in the shmem driver.  That way it could be shared even
> between hypervisors.

It seems a nice idea to have a more generic way to share memory
between guests or host.
When can you share a spec or a RFC patch about it?

> At first it seemed like an unreasonable solution, but the more I think
> about it the more I like it.  It's not a requirement to get your
> patches it, though, I just wanted to share this in case you (or anyone
> else) find it compelling enough to try it.

I will keep focusing about ivshmem support as QEMU is supporting it for now.
I will be on holiday next week. Based on the the comments, I will send
a new version after my holidays.


Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [RFC PATCH 2/5] conf: Parse and format ivshmem device XML

2014-08-07 Thread Maxime Leroy
On Wed, Aug 6, 2014 at 11:30 AM, Wang Rui  wrote:
> On 2014/8/6 0:48, Maxime Leroy wrote:
[..]
>> @@ -2805,6 +2841,7 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
>>  case VIR_DOMAIN_DEVICE_NVRAM:
>>  case VIR_DOMAIN_DEVICE_LAST:
>>  case VIR_DOMAIN_DEVICE_RNG:
>> +case VIR_DOMAIN_DEVICE_IVSHMEM:
>>  break;
>
> The function is good in logic. But I think it's better to keep 
> VIR_DOMAIN_DEVICE_LAST
> the last case. (Also case VIR_DOMAIN_DEVICE_RNG should be moved ahead of
> case VIR_DOMAIN_DEVICE_LAST)
>

Good catch ;) I will fix it.

[...]
>> +/* analysis of the ivshmem devices */
>> +if ((n = virXPathNodeSet("./devices/ivshmem", ctxt, &nodes)) < 0) {
>> +goto error;
>> +}
>> +if (n && VIR_ALLOC_N(def->ivshmems, n) < 0)
>> +goto error;
>> +
>> +node = ctxt->node;
>> +for (i = 0; i < n; i++) {
>> +virDomainIvshmemDefPtr ivshmem;
>> +ctxt->node = nodes[i];
>> +ivshmem = virDomainIvshmemDefParseXML(nodes[i], ctxt, flags);
>> +if (!ivshmem)
>> +goto error;
>> +
>> +def->ivshmems[def->nivshmems++] = ivshmem;
>> +}
>> +ctxt->node = node;
>> +VIR_FREE(nodes);
>>
> Here actions: node = ctxt->node; ctxt->node = nodes[i]; ctxt->node = node;
> I see other devices' xml parsing function virDomainXXXParseXML (such as 
> virDomainRNGDefParseXML).
> These actions are in the function virDomainXXXparesXML().
> So are the actions here are redundant? Or should be moved into 
> virDomainIvshmemDefParseXML.
>

The action is not redundant. The virDomainDefParseXML can parse multi
ivshmem devices.
It's why we loop here on the different ivshmem nodes.

In virDomainIvshmemDefParseXML, we iterate on the different nodes of
one ivshmem device
(like msi node, size node, source node).

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [RFC PATCH 4/5] qemu: Build command line for ivshmem device

2014-08-07 Thread Maxime Leroy
On Wed, Aug 6, 2014 at 12:04 PM, Wang Rui  wrote:
> On 2014/8/6 0:48, Maxime Leroy wrote:
>> This patch implements support for the ivshmem device
>> in QEMU.
>>
>> Example from this xml:
>>
>> 
>
> s/'yes''/'yes'
>
[..]
>> +virCommandAddArg(cmd, "-device");
>> +if (!(devstr = qemuBuildIvshmemDevStr(def, ivshmem, qemuCaps)))
>> +goto error;
>> +virCommandAddArg(cmd, devstr);
>> +VIR_FREE(devstr);
>> +
>> +if (ivshmem->use_server == VIR_DOMAIN_IVSHMEM_SERVER_ENABLED) {
>> +virDomainChrSourceDef source;
>> +
>> +source.type = VIR_DOMAIN_CHR_TYPE_UNIX;
>> +source.data.nix.path = ivshmem->file;
>> +source.data.nix.listen = false;
>> +
>> +virCommandAddArg(cmd, "-chardev");
>
> In qemuBuildCommandLine() , "-device" and "-chardev" capabilities are checked
> before most(not all) of virCommandAddArg for devices. I think that will be
> nicer.
>

ok, I will update accordingly.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [RFC PATCH 1/5] doc: schema: Add basic documentation for the ivshmem support

2014-08-07 Thread Maxime Leroy
On Wed, Aug 6, 2014 at 11:41 AM, Wang Rui  wrote:
> On 2014/8/6 0:48, Maxime Leroy wrote:
>> This patch documents XML elements used for support of ivshmem
>> devices.
>>
>> About ivshmem, please see the following documentation:
>> http://git.qemu.org/?p=qemu.git;a=blob;f=docs/specs/ivshmem_device_spec.txt
>> (Ivshmem documentation for qemu will be updated soon:
>> https://lists.nongnu.org/archive/html/qemu-devel/2014-07/msg02974.html)
>>
>> In the devices section in the domain XML users may specify:
>>
>> - For ivshmem device using an ivshmem server:
>>
>>  
>>
>
> I prefer to use  .
> So when ParesXML and Format functions are needed, we can use
> virDomainChrSourceDef*(), like vmchannel device.
> What do you think about it ?

First, thanks for the review.

I was thinking of using virDomainChrSourceDef to
improve this patch.

So the format of the xml needs to be updated accordingly:

- For ivshmem device using an ivshmem server:


  
  32
  


- For ivshmem device using directly a shared memory


  
  32


Thus, 'use_server' attribute will be replaced  by 'type' attribute
(unix or file).
Are you ok with that ?

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [RFC PATCH 1/5] doc: schema: Add basic documentation for the ivshmem support

2014-08-05 Thread Maxime Leroy
This patch documents XML elements used for support of ivshmem
devices.

About ivshmem, please see the following documentation:
http://git.qemu.org/?p=qemu.git;a=blob;f=docs/specs/ivshmem_device_spec.txt
(Ivshmem documentation for qemu will be updated soon:
https://lists.nongnu.org/archive/html/qemu-devel/2014-07/msg02974.html)

In the devices section in the domain XML users may specify:

- For ivshmem device using an ivshmem server:

 
   
   32
   
 

 Note: the ivshmem server needs to be launched before
   creating the VM. It's not done by libvirt.

- For ivshmem device not using an ivshmem server:

 
   
   32
 

 Note: the ivshmem shm needs to be created before
   creating the VM. It's not done by libvirt.

Signed-off-by: Maxime Leroy 
---
 docs/formatdomain.html.in | 72 +++
 docs/schemas/domaincommon.rng | 57 ++
 2 files changed, 129 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index e5b1adb..9a9a6fa 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4035,6 +4035,78 @@ qemu-kvm -net nic,model=? /dev/null
   <model> element is mandatory.
 
 
+Ivshmem device
+
+
+  An ivshmem (i.e. Inter-VM shared memory) device allows to share a memory
+  region (created on the host via the POSIX shared memory API) between
+  multiple QEMU processes running different guests.
+  For more information, please see the
+  http://git.qemu.org/?p=qemu.git;a=blob;f=docs/specs/ivshmem_device_spec.txt";>
+  ivshmem documentation of qemu.
+
+
+
+  ...
+  <devices>
+<ivshmem use_server='yes' role='master'/>
+  <source file='/tmp/socket-ivshmem0'/>
+  <size unit='M'>32</size>
+  <msi vectors='32' ioeventfd='on'/>
+</ivshmem>
+<ivshmem use_server='no' role='peer'/>
+  <source file='ivshmem1'/>
+  <size unit='M'>32</size>
+</ivshmem>
+  </devices>
+  ...
+
+
+  ivshmem
+  The ivshmem element has a mandatory 
use_server
+attribute which takes the value "yes" or "no":
+
+  "yes"
+  
+Configure the ivshmen device to connect to the ivshmem server via 
a unix socket.
+  
+  "no"
+  
+Configure the ivshmen device with a shared memory file.
+  
+
+  
+  role
+  The role attribute is optional. It takes the value 
"master" or "peer":
+
+  "master"
+  
+On migration, the guest will copy the shared memory to the 
destination host.
+  
+  "peer"
+  
+The device should be detached and then reattached after migration 
using
+the PCI hotplug support.
+  
+
+Note: PCI hotplug is not supported for ivshmem device in libvirt.
+  
+  size
+  The optional size element specifies the size of the 
shared memory file.
+  
+  source
+  The source element is mandatory.
+The file attribute specifies the ivshmem server socket 
file in server mode.
+In non server mode, it specifies the shared memory file.
+  
+  msi
+  The optional msi element allows to enable MSI 
interrupts. This option
+can only be used in server mode. The vectors attribute
+allows to specify the number of interrupt vectors. The 
ioeventd attribute
+allows to enable ioeventfd.
+  
+
+
 Input devices
 
 
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 11f0fd0..8229921 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3220,6 +3220,62 @@
   
 
   
+
+  
+
+  
+
+  
+
+  yes
+
+
+  
+
+  
+
+
+  
+
+  
+
+  
+
+  
+  
+
+  no
+
+  
+
+
+  
+
+  
+
+
+  
+
+  master
+  peer
+
+  
+
+
+  
+
+  
+
+
+  
+
+
+  
+
+  
+
+  
+
   
 
   
@@ -3767,6 +3823,7 @@
 
 
 
+
   
 
 
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [RFC PATCH 5/5] tests: Add tests for ivshmem device handling

2014-08-05 Thread Maxime Leroy
Add XML parsing and qemu command line tests for the ivshmem
device support.

Signed-off-by: Maxime Leroy 
---
 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args | 10 +++
 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml  | 36 
 tests/qemuxml2argvtest.c |  3 ++
 tests/qemuxml2xmltest.c  |  2 ++
 4 files changed, 51 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args 
b/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args
new file mode 100644
index 000..c707ba2
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args
@@ -0,0 +1,10 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S \
+-M pc -m 214 -smp 1 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
+-device ivshmem,chardev=charivshmem0,msi=on,vectors=32,ioeventfd=on \
+-chardev socket,id=charivshmem0,path=/tmp/socket-ivshmem0 \
+-device ivshmem,size=32m,role=master,chardev=charivshmem1,msi=on,vectors=32 \
+-chardev socket,id=charivshmem1,path=/tmp/socket-ivshmem1 \
+-device ivshmem,size=32m,role=peer,shm=ivshmem2,bus=pci.0,addr=0x8
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml
new file mode 100644
index 000..8214869
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml
@@ -0,0 +1,36 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219100
+  219100
+  1
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu
+
+
+
+
+
+  
+  
+
+
+  
+  32
+  
+
+
+  
+  32
+  
+
+  
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 12ecabc..b2a2bc4 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1412,6 +1412,9 @@ mymain(void)
 DO_TEST("panic", QEMU_CAPS_DEVICE_PANIC,
 QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
 
+DO_TEST("ivshmem", QEMU_CAPS_PCIDEVICE,
+QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_IVSHMEM);
+
 virObjectUnref(driver.config);
 virObjectUnref(driver.caps);
 virObjectUnref(driver.xmlopt);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 451dedc..9bb692a 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -382,6 +382,8 @@ mymain(void)
 DO_TEST_DIFFERENT("numatune-memnode");
 DO_TEST("numatune-memnode-no-memory");
 
+DO_TEST("ivshmem");
+
 virObjectUnref(driver.caps);
 virObjectUnref(driver.xmlopt);
 
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [RFC PATCH 3/5] qemu: Add cap flag QEMU_CAPS_IVSHMEM

2014-08-05 Thread Maxime Leroy
Ivshmem is supported by QEMU since 0.13 release.

Signed-off-by: Maxime Leroy 
---
 src/qemu/qemu_capabilities.c  |  2 ++
 src/qemu/qemu_capabilities.h  |  1 +
 tests/qemucapabilitiesdata/caps_1.2.2-1.caps  |  1 +
 tests/qemucapabilitiesdata/caps_1.3.1-1.caps  |  1 +
 tests/qemucapabilitiesdata/caps_1.4.2-1.caps  |  1 +
 tests/qemucapabilitiesdata/caps_1.5.3-1.caps  |  1 +
 tests/qemucapabilitiesdata/caps_1.6.0-1.caps  |  1 +
 tests/qemucapabilitiesdata/caps_1.6.50-1.caps |  1 +
 tests/qemuhelptest.c  | 15 ++-
 9 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index f69c4d0..f573cb5 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -264,6 +264,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
   "memory-backend-ram", /* 170 */
   "numa",
   "memory-backend-file",
+  "ivshmem",
 );
 
 
@@ -1483,6 +1484,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
 { "usb-kbd", QEMU_CAPS_DEVICE_USB_KBD },
 { "memory-backend-ram", QEMU_CAPS_OBJECT_MEMORY_RAM },
 { "memory-backend-file", QEMU_CAPS_OBJECT_MEMORY_FILE },
+{ "ivshmem", QEMU_CAPS_DEVICE_IVSHMEM },
 };
 
 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index e80a377..39079cb 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -212,6 +212,7 @@ typedef enum {
 QEMU_CAPS_OBJECT_MEMORY_RAM  = 170, /* -object memory-backend-ram */
 QEMU_CAPS_NUMA   = 171, /* newer -numa handling with disjoint 
cpu ranges */
 QEMU_CAPS_OBJECT_MEMORY_FILE = 172, /* -object memory-backend-file */
+QEMU_CAPS_DEVICE_IVSHMEM = 173, /* -device ivshmem */
 
 QEMU_CAPS_LAST,   /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps 
b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
index ebbfb82..951685e 100644
--- a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
@@ -115,4 +115,5 @@
 
 
 
+
   
diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps 
b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
index ab631a2..b26e30e 100644
--- a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
@@ -128,4 +128,5 @@
 
 
 
+
   
diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps 
b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
index e710b60..6d267ac 100644
--- a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
@@ -129,4 +129,5 @@
 
 
 
+
   
diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps 
b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
index 36758c8..5751465 100644
--- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
@@ -137,4 +137,5 @@
 
 
 
+
   
diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps 
b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
index ca2c236..4b18b68 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
@@ -144,4 +144,5 @@
 
 
 
+
   
diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps 
b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
index 4b9f693..4b07df1 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
@@ -143,4 +143,5 @@
 
 
 
+
   
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 105a563..5b4cce6 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -518,7 +518,8 @@ mymain(void)
 QEMU_CAPS_DEVICE_SCSI_GENERIC,
 QEMU_CAPS_DEVICE_USB_KBD,
 QEMU_CAPS_DEVICE_USB_STORAGE,
-QEMU_CAPS_HOST_PCI_MULTIDOMAIN);
+QEMU_CAPS_HOST_PCI_MULTIDOMAIN,
+QEMU_CAPS_DEVICE_IVSHMEM);
 DO_TEST("qemu-kvm-0.12.1.2-rhel61", 12001, 1, 0,
 QEMU_CAPS_VNC_COLON,
 QEMU_CAPS_NO_REBOOT,
@@ -745,7 +746,8 @@ mymain(void)
 QEMU_CAPS_DEVICE_SCSI_GENERIC,
 QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX,
 QEMU_CAPS_DEVICE_USB_KBD,
-QEMU_CAPS_DEVICE_USB_STORAGE);
+QEMU_CAPS_DEVICE_USB_STORAGE,
+QEMU_CAPS_DEVICE_IVSHMEM);
 DO_TEST("qemu-1.1.0", 1001000, 0, 0,
 QEMU_CAPS_VNC_COLON,
 QEMU_CAPS_NO_REBOOT,
@@ -842,7 +844,8 @@ mymain(void)
 QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX,
 QEMU_CAPS_VNC_SHARE_POLICY,
 QEMU_CAPS_DEVICE_USB_KBD,
-QEMU_CAPS_DEVICE_USB_STORA

[libvirt] [RFC PATCH 4/5] qemu: Build command line for ivshmem device

2014-08-05 Thread Maxime Leroy
This patch implements support for the ivshmem device
in QEMU.

Example from this xml:


  
  32
  


The following QEMU line is built:

   -device ivshmem,size=32m,vectors=32,chardev=charivshmem0,msi=on,
ioeventfd=on,role=master
   -chardev socket,path=/tmp/socket-ivshmem0,id=charivshmem0

Note: PCI hotpluging has not be implemented.

Signed-off-by: Maxime Leroy 
---
 src/qemu/qemu_command.c | 77 +
 src/qemu/qemu_command.h |  4 +++
 src/qemu/qemu_hotplug.c |  1 +
 3 files changed, 82 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a5ff10a..b434023 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1034,6 +1034,10 @@ qemuAssignDeviceAliases(virDomainDefPtr def, 
virQEMUCapsPtr qemuCaps)
 if (virAsprintf(&def->hubs[i]->info.alias, "hub%zu", i) < 0)
 return -1;
 }
+for (i = 0; i < def->nivshmems; i++) {
+if (virAsprintf(&def->ivshmems[i]->info.alias, "ivshmem%zu", i) < 0)
+return -1;
+}
 for (i = 0; i < def->nsmartcards; i++) {
 if (virAsprintf(&def->smartcards[i]->info.alias, "smartcard%zu", i) < 
0)
 return -1;
@@ -5032,6 +5036,53 @@ qemuBuildRedirdevDevStr(virDomainDefPtr def,
 }
 
 char *
+qemuBuildIvshmemDevStr(virDomainDefPtr def,
+   virDomainIvshmemDefPtr dev,
+   virQEMUCapsPtr qemuCaps)
+{
+virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("ivshmem device is not supported by QEMU"));
+goto error;
+}
+
+virBufferAddLit(&buf, "ivshmem");
+if (dev->size)
+virBufferAsprintf(&buf, ",size=%llum", dev->size / (1024 * 1024));
+if (dev->role)
+virBufferAsprintf(&buf, ",role=%s",
+  virDomainIvshmemRoleTypeToString(dev->role));
+
+if (dev->use_server == VIR_DOMAIN_IVSHMEM_SERVER_DISABLED)
+virBufferAsprintf(&buf, ",shm=%s", dev->file);
+else {
+virBufferAsprintf(&buf, ",chardev=char%s", dev->info.alias);
+if (dev->msi.enabled) {
+virBufferAddLit(&buf, ",msi=on");
+if (dev->msi.vectors)
+virBufferAsprintf(&buf, ",vectors=%u", dev->msi.vectors);
+if (dev->msi.ioeventfd)
+virBufferAsprintf(&buf, ",ioeventfd=%s",
+  
virTristateSwitchTypeToString(dev->msi.ioeventfd));
+}
+}
+
+if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
+goto error;
+
+if (virBufferCheckError(&buf) < 0)
+goto error;
+
+return virBufferContentAndReset(&buf);
+
+ error:
+virBufferFreeAndReset(&buf);
+return NULL;
+}
+
+char *
 qemuBuildUSBHostdevDevStr(virDomainDefPtr def,
   virDomainHostdevDefPtr dev,
   virQEMUCapsPtr qemuCaps)
@@ -9317,6 +9368,32 @@ qemuBuildCommandLine(virConnectPtr conn,
 }
 }
 
+for (i = 0; i < def->nivshmems; i++) {
+virDomainIvshmemDefPtr ivshmem = def->ivshmems[i];
+char *devstr;
+
+virCommandAddArg(cmd, "-device");
+if (!(devstr = qemuBuildIvshmemDevStr(def, ivshmem, qemuCaps)))
+goto error;
+virCommandAddArg(cmd, devstr);
+VIR_FREE(devstr);
+
+if (ivshmem->use_server == VIR_DOMAIN_IVSHMEM_SERVER_ENABLED) {
+virDomainChrSourceDef source;
+
+source.type = VIR_DOMAIN_CHR_TYPE_UNIX;
+source.data.nix.path = ivshmem->file;
+source.data.nix.listen = false;
+
+virCommandAddArg(cmd, "-chardev");
+if (!(devstr = qemuBuildChrChardevStr(&source, ivshmem->info.alias,
+  qemuCaps)))
+goto error;
+virCommandAddArg(cmd, devstr);
+VIR_FREE(devstr);
+}
+}
+
 if (mlock) {
 unsigned long long memKB;
 
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index b71e964..f3d301a 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -185,6 +185,10 @@ char * qemuBuildHubDevStr(virDomainDefPtr def,
 char * qemuBuildRedirdevDevStr(virDomainDefPtr def,
virDomainRedirdevDefPtr dev,
virQEMUCapsPtr qemuCaps);
+char * qemuBuildIvshmemDevStr(virDomainDefPtr def,
+  virDomainIvshmemDefPtr dev,
+  virQEMUCapsPtr qemuCaps);
+
 int

[libvirt] [RFC PATCH 2/5] conf: Parse and format ivshmem device XML

2014-08-05 Thread Maxime Leroy
This patch adds configuration support for the ivshmem device
as described in the schema in the previous patch.

Signed-off-by: Maxime Leroy 
---
 src/conf/domain_conf.c   | 234 ++-
 src/conf/domain_conf.h   |  40 
 src/libvirt_private.syms |   4 +
 3 files changed, 277 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c25c74b..829f1bf 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -234,7 +234,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
   "chr",
   "memballoon",
   "nvram",
-  "rng")
+  "rng",
+  "ivshmem")
 
 VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
   "none",
@@ -759,6 +760,15 @@ VIR_ENUM_DECL(virDomainBlockJob)
 VIR_ENUM_IMPL(virDomainBlockJob, VIR_DOMAIN_BLOCK_JOB_TYPE_LAST,
   "", "", "copy", "", "active-commit")
 
+VIR_ENUM_IMPL(virDomainIvshmemServer, VIR_DOMAIN_IVSHMEM_SERVER_LAST,
+  "yes",
+  "no");
+
+VIR_ENUM_IMPL(virDomainIvshmemRole, VIR_DOMAIN_IVSHMEM_ROLE_LAST,
+  "default",
+  "master",
+  "peer");
+
 #define VIR_DOMAIN_XML_WRITE_FLAGS  VIR_DOMAIN_XML_SECURE
 #define VIR_DOMAIN_XML_READ_FLAGS   VIR_DOMAIN_XML_INACTIVE
 
@@ -1686,6 +1696,17 @@ void virDomainWatchdogDefFree(virDomainWatchdogDefPtr 
def)
 VIR_FREE(def);
 }
 
+void virDomainIvshmemDefFree(virDomainIvshmemDefPtr def)
+{
+if (!def)
+return;
+
+virDomainDeviceInfoClear(&def->info);
+
+VIR_FREE(def->file);
+VIR_FREE(def);
+}
+
 void virDomainVideoDefFree(virDomainVideoDefPtr def)
 {
 if (!def)
@@ -1887,6 +1908,9 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def)
 case VIR_DOMAIN_DEVICE_NVRAM:
 virDomainNVRAMDefFree(def->data.nvram);
 break;
+case VIR_DOMAIN_DEVICE_IVSHMEM:
+virDomainIvshmemDefFree(def->data.ivshmem);
+break;
 case VIR_DOMAIN_DEVICE_LAST:
 case VIR_DOMAIN_DEVICE_NONE:
 break;
@@ -2128,6 +2152,10 @@ void virDomainDefFree(virDomainDefPtr def)
 
 virDomainRedirFilterDefFree(def->redirfilter);
 
+for (i = 0; i < def->nivshmems; i++)
+virDomainIvshmemDefFree(def->ivshmems[i]);
+VIR_FREE(def->ivshmems);
+
 if (def->namespaceData && def->ns.free)
 (def->ns.free)(def->namespaceData);
 
@@ -2562,6 +2590,8 @@ virDomainDeviceGetInfo(virDomainDeviceDefPtr device)
 return &device->data.memballoon->info;
 case VIR_DOMAIN_DEVICE_NVRAM:
 return &device->data.nvram->info;
+case VIR_DOMAIN_DEVICE_IVSHMEM:
+return &device->data.ivshmem->info;
 case VIR_DOMAIN_DEVICE_RNG:
 return &device->data.rng->info;
 
@@ -2777,6 +2807,12 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
 if (cb(def, &device, &def->hubs[i]->info, opaque) < 0)
 return -1;
 }
+device.type = VIR_DOMAIN_DEVICE_IVSHMEM;
+for (i = 0; i < def->nivshmems; i++) {
+device.data.ivshmem = def->ivshmems[i];
+if (cb(def, &device, &def->ivshmems[i]->info, opaque) < 0)
+return -1;
+}
 
 /* This switch statement is here to trigger compiler warning when adding
  * a new device type. When you are adding a new field to the switch you
@@ -2805,6 +2841,7 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
 case VIR_DOMAIN_DEVICE_NVRAM:
 case VIR_DOMAIN_DEVICE_LAST:
 case VIR_DOMAIN_DEVICE_RNG:
+case VIR_DOMAIN_DEVICE_IVSHMEM:
 break;
 }
 
@@ -9354,6 +9391,124 @@ virDomainNVRAMDefParseXML(xmlNodePtr node,
 return NULL;
 }
 
+static virDomainIvshmemDefPtr
+virDomainIvshmemDefParseXML(xmlNodePtr node,
+xmlXPathContextPtr ctxt,
+unsigned int flags)
+{
+virDomainIvshmemDefPtr def;
+char *use_server = NULL;
+char *role = NULL;
+char *ioeventfd = NULL;
+char *vectors = NULL;
+xmlNodePtr cur;
+xmlNodePtr save = ctxt->node;
+
+if (VIR_ALLOC(def) < 0)
+return NULL;
+
+use_server = virXMLPropString(node, "use_server");
+if (use_server !=  NULL) {
+if ((def->use_server
+ = virDomainIvshmemServerTypeFromString(use_server)) < 0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("unknown ivshmem use_server tyoe '%s'"), 
use_server);
+goto error;
+}
+} else {
+virReportError(VIR_ERR_XML_ERROR,
+   "%s", _(&quo

[libvirt] [RFC PATCH 0/5] ivshmem support

2014-08-05 Thread Maxime Leroy
The following patches are an implementation proposal
for the ivshmem device support in libvirt.

Any feedback is welcome.

Note:
   SELinux is not supported (need to be done for the next
   patchset version)

Maxime Leroy (5):
  doc: schema: Add basic documentation for the ivshmem support
  conf: Parse and format ivshmem device XML
  qemu: Add cap flag QEMU_CAPS_IVSHMEM
  qemu: Build command line for ivshmem device
  tests: Add tests for ivshmem device handling

 docs/formatdomain.html.in|  72 +++
 docs/schemas/domaincommon.rng|  57 ++
 src/conf/domain_conf.c   | 234 ++-
 src/conf/domain_conf.h   |  40 
 src/libvirt_private.syms |   4 +
 src/qemu/qemu_capabilities.c |   2 +
 src/qemu/qemu_capabilities.h |   1 +
 src/qemu/qemu_command.c  |  77 
 src/qemu/qemu_command.h  |   4 +
 src/qemu/qemu_hotplug.c  |   1 +
 tests/qemucapabilitiesdata/caps_1.2.2-1.caps |   1 +
 tests/qemucapabilitiesdata/caps_1.3.1-1.caps |   1 +
 tests/qemucapabilitiesdata/caps_1.4.2-1.caps |   1 +
 tests/qemucapabilitiesdata/caps_1.5.3-1.caps |   1 +
 tests/qemucapabilitiesdata/caps_1.6.0-1.caps |   1 +
 tests/qemucapabilitiesdata/caps_1.6.50-1.caps|   1 +
 tests/qemuhelptest.c |  15 +-
 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args |  10 +
 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml  |  36 
 tests/qemuxml2argvtest.c |   3 +
 tests/qemuxml2xmltest.c  |   2 +
 21 files changed, 558 insertions(+), 6 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ivshmem.xml

-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [RFC] require for suggestions on support for ivshmem device

2014-07-28 Thread Maxime LEROY

Hi all,

On 07/21/2014 04:38 AM, Wang Rui wrote:

On 2014/7/17 17:37, Martin Kletzander wrote:

On Tue, May 20, 2014 at 11:17:32AM +0200, Martin Kletzander wrote:

On Wed, May 14, 2014 at 08:23:21AM +, Wangrui (K) wrote:

Hi,

Libvirt does not support ivshmem(Inter-VM Shared Memory) device recently,
thus, I would like to know if there's any plan to support it in the future?
If not, I would like to contribute a serial of patches to do so.



I came back to this mail right now because I need to have this
implemented.  Is there any progress on your side with this or should I
try hitting this?



I am working right now on supporting ivshmem in libvirt.
Please, see my github:
https://github.com/6WIND/libvirt/commits/rfc_ivshmem_support

I will try to send RFC patches on the mailing list in the next days.

Maxime

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list