[libvirt] [PATCH V4 3/3] Add support for file descriptor sets

Daniel P. Berrange berrange at redhat.com
Mon Feb 11 12:47:07 UTC 2013


On Thu, Feb 07, 2013 at 10:35:16PM -0500, Stefan Berger wrote:
> Add support for file descriptor sets by converting some of the 
> command line parameters to use /dev/fdset/%d if -add-fd is found
> to be supported by QEMU. For those devices libvirt now open()s
> the device to obtain the file descriptor and 'transfers' the 
> fd using virCommand.
> 
> For the following fragments of domain XML
> 
> 
>     <disk type='file' device='disk'>
>       <driver name='qemu' type='raw'/>
>       <source file='/var/lib/libvirt/images/fc14-x86_64.img'/>
>       <target dev='hda' bus='ide'/>
>       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
>     </disk>
> 
>    <serial type='dev'>
>       <source path='/dev/ttyS0'/>
>       <target port='0'/>
>     </serial>
>     <serial type='pipe'>
>       <source path='/tmp/testpipe'/>
>       <target port='1'/>
>     </serial>
> 
> libvirt now creates the following parts for the QEMU command line:
> 
> old: -drive file=/var/lib/libvirt/images/fc14-x86_64.img,if=none,id=drive-ide0-0-0,format=raw
> new: -add-fd set=1,fd=23,opaque=RDONLY:/var/lib/libvirt/images/fc14-x86_64.img
>      -add-fd set=1,fd=24,opaque=RDWR:/var/lib/libvirt/images/fc14-x86_64.img
>      -drive file=/dev/fdset/1,if=none,id=drive-ide0-0-0,format=raw
> 
> old: -chardev tty,id=charserial0,path=/dev/ttyS0
> new: -add-fd set=1,fd=30,opaque=/dev/ttyS0
>      -chardev tty,id=charserial0,path=/dev/fdset/1
> 
> old: -chardev pipe,id=charserial1,path=/tmp/testpipe
> new: -add-fd set=2,fd=32,opaque=/tmp/testpipe
>      -chardev pipe,id=charserial1,path=/dev/fdset/2
> 
> Test cases are part of this patch now.
> 
> Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
> 

> @@ -201,6 +206,7 @@ out:
>      virCommandFree(cmd);
>      virDomainDefFree(vmdef);
>      virObjectUnref(conn);
> +    virFdsetClear(&fdset);
>      return ret;
>  }
>  
> @@ -875,6 +881,11 @@ mymain(void)
>              QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
>              QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_QXL_VGA);
>  
> +    DO_TEST("no-add-fd",
> +            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE);

Do we really need this test case - don't all existing test cases
already validate correct CLI args in the non-fdset case ?

> +    DO_TEST("add-fd", QEMU_CAPS_ADD_FD,
> +            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE);

Thanks for adding this.


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 :|




More information about the libvir-list mailing list