Qemu native GlusterFS integration

From stoney cloud
Revision as of 12:45, 4 August 2013 by Tiziano (Talk | contribs)


Jump to: navigation, search

Starting with GlusterFS 3.4.0 there is a an API which can be used to access files on a GlusterFS volume directly without the FUSE-mount. Qemu supports this starting from version 1.2.0.

GlusterFS

Since we run Qemu as unprivileged user we have to permit access to GlusterFS from an unprivileged port as well as an unprivileged user.

To achieve that, add the following line to the volume management in /etc/glusterfs/glusterd.vol on all involved storage nodes:

option rpc-auth-allow-insecure on

and run the following command on a gluster node:

gluster volume set virtualization server.allow-insecure On

After that you should at least restart glusterd:

/etc/init.d/glusterd restart

But it seems that one also has to restart all glusterfsd daemons by restarting the volume. So, do the following on a GlusterFS node:

gluster volume stop virtualization
gluster volume start virtualization

Libvirt

The XML has to be changed only slightly. Following is an example:

    <disk type='network' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source protocol='gluster' name='virtualization/vm-templates/5b77d2f6-061f-410c-8ee7-9e61da6f1927/f3d87cf9-f7d8-4224-b908-cc9fc6c8fcd4.qcow2'>
        <host name='10.1.120.11'/>
      </source>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>

What changes:

disk-type
has to be network instead of file
source
has now a protocol and a name instead of a file attribute as well as a new subelement host, where the name is the filename without /var/

Test

qemu-img info

foss-cloud-node-01 ~ # qemu-img info gluster://10.1.120.11:24007/virtualization/vm-templates/5b77d2f6-061f-410c-8ee7-9e61da6f1927/f3d87cf9-f7d8-4224-b908-cc9fc6c8fcd4.qcow2
image: gluster://10.1.120.11:24007/virtualization/vm-templates/5b77d2f6-061f-410c-8ee7-9e61da6f1927/f3d87cf9-f7d8-4224-b908-cc9fc6c8fcd4.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 874M
cluster_size: 65536

qemu-img create

foss-cloud-node-01 ~ # qemu-img create -f qcow2 gluster://10.1.120.11/virtualization/foo.qcow2 20G
Formatting 'gluster://10.1.120.11/virtualization/foo.qcow2', fmt=qcow2 size=21474836480 encryption=off cluster_size=65536 lazy_refcounts=off 
foss-cloud-node-01 ~ # stat /var/virtualization/foo.qcow2 
  File: ‘/var/virtualization/foo.qcow2’
  Size: 197120    	Blocks: 385        IO Block: 131072 regular file
Device: 1ch/28d	Inode: 11101537565691465327  Links: 1
Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-08-04 07:37:01.814422718 +0200
Modify: 2013-08-04 08:31:51.968884606 +0200
Change: 2013-08-04 08:31:51.968884606 +0200
 Birth: -