[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt PATCH] conf: Add support for GlusterFS volumes as disk



On Thu, Sep 03, 2020 at 20:28:47 +0200, Vincent Vanlaer wrote:
> While libvirt has support for GlusterFS pools and volumes, they cannot
> be added to a domain. This commit adds the necessary translation between
> the pool definition and the disk definition, allowing volumes in a domain
> to be backed by a gluster pool.
> 
> Signed-off-by: Vincent Vanlaer <libvirt volkihar be>
> ---
>  src/conf/domain_conf.c | 32 +++++++++++++++++++++++++++++++-
>  1 file changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 72ac4f4191..c872d02200 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -32620,6 +32620,32 @@ virDomainDiskTranslateISCSIDirect(virStorageSourcePtr src,
>  }
>  
>  
> +static int
> +virDomainDiskTranslateGluster(virStorageSourcePtr src,
> +                              virStoragePoolDefPtr pooldef)
> +{
> +    size_t i;
> +
> +    src->srcpool->actualtype = VIR_STORAGE_TYPE_NETWORK;
> +    src->protocol = VIR_STORAGE_NET_PROTOCOL_GLUSTER;
> +
> +    src->nhosts = pooldef->source.nhost;
> +    src->hosts = g_new0(virStorageNetHostDef, src->nhosts);
> +
> +    for (i = 0; i < src->nhosts; i++) {
> +        src->hosts[i].socket = NULL;

This is not required as g_new0 initializes memory to 0.

> +        src->hosts[i].transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
> +        src->hosts[i].name = g_strdup(pooldef->source.hosts[i].name);
> +        src->hosts[i].port = pooldef->source.hosts[i].port;
> +    }
> +
> +    src->volume = g_strdup(pooldef->source.name);
> +    src->path = g_strdup_printf("%s/%s", pooldef->source.dir, src->srcpool->volume);

The source dir seems to be '/' in case when it's not configured, which
would format a wrong path of "//blah.img" if you don't configure it
properly, so you'll probably need to do some special-casing here.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]