On Fri, Jul 22, 2016 at 01:50:30PM +0530, Prasanna Kumar Kalever wrote:
> This patch adds support for gluster specific JSON formatter functionality
> 
> currently libvirt has the capability to parse only one host and convert that
> into URI formatted string, with the help of this patch libvirt will be able
> to parse multiple hosts from the domain xml and can convert that into JSON
> formatted string
> 
> if the number of hosts supplied is only one, then we use existing URI format
> for backward compatibility and if number of hosts is greater than one we 
> switch
> to the new JSON format
> 
> before:
> ------
> example.xml:
> ...
>     <disk type='network' device='disk'>
>       <driver name='qemu' type='qcow2' cache='none'/>
>       <source protocol='gluster' name='testvol/a.qcow2'>
>         <host name='1.2.3.4' port='24007' transport="tcp"/>
>       </source>
>        <target dev='vda' bus='virtio'/>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' 
> function='0x0'/>
>     </disk>
> ...
> 
> resultant string:
> file=gluster://1.2.3.4:24007/testvol/a.qcow2, \
>                            
> if=none,id=drive-virtio-disk0,format=qcow2,cache=none
> 
> after:
> -----
> example.xml:
> ...
>     <disk type='network' device='disk'>
>       <driver name='qemu' type='qcow2' cache='none'/>
>       <source protocol='gluster' name='testvol/a.qcow2'>
>         <host name='1.2.3.4' port='24009' transport="tcp"/>
>         <host socket='/var/run/glusterd.socket' transport="unix"/>
>       </source>
>        <target dev='vda' bus='virtio'/>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' 
> function='0x0'/>
>     </disk>
> ...
> 
> resultant string:
> -drive file=json:{
>     "file": {
>         "driver": "gluster",,
>         "volume": "testvol",,
>         "path": "/a.qcow2",,
>         "server": [
>             {
>                 "type": "tcp"
>                 "host": "1.2.3.4",,
>                 "port": 24009,,
>             },,
>             {
>                 "transport": "unix"
>                 "socket": "/var/run/glusterd.socket",
>             }
>         ]
>     },,
>     "driver": "qcow2"
> }
> ,if=none,id=drive-virtio-disk0,cache=none

Ewww, we really don't want to be using the json syntax on the
command line. Please use the normal property syntax instead.
The JSON syntax is only appropriate for use with QMPP for
hotplug.

> 
> credits: sincere thanks to all the supporters
> 
> Signed-off-by: Prasanna Kumar Kalever <prasanna.kale...@redhat.com>
> ---
>  src/qemu/qemu_command.c | 219 
> ++++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 174 insertions(+), 45 deletions(-)

This is missing test cases to validate the new syntax.
See tests/qemuxml2argvtest.c & related data files.


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

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

Reply via email to