Re: [PATCH 9/9] Support network pool for volume disk

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

 



On 01/30/2013 01:11 PM, Osier Yang wrote:
> The only two network pools we supported are "rbd" and "sheepdog",
> and attributes "socket", "transport" are not supported in storage
> pool conf yet, this uses the default setting (TCP for 'transport',
> and "socket" is not set) temporarily. Future patches will extend
> the storage pool conf to support 'transport' and 'socket'.
> ---
>  src/libvirt_private.syms     |    1 +
>  src/storage/storage_driver.c |   49 +++++++++++++++++++++++++++++++++++++----
>  2 files changed, 45 insertions(+), 5 deletions(-)
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index a44f3ff..4674bf9 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -1153,6 +1153,7 @@ virStoragePoolSourceFree;
>  virStoragePoolSourceListFormat;
>  virStoragePoolSourceListNewSource;
>  virStoragePoolTypeFromString;
> +virStoragePoolTypeToString;
>  virStorageVolDefFindByKey;
>  virStorageVolDefFindByName;
>  virStorageVolDefFindByPath;
> diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
> index f2ca310..115c7a0 100644
> --- a/src/storage/storage_driver.c
> +++ b/src/storage/storage_driver.c
> @@ -2406,12 +2406,15 @@ storageTranslateDomainDiskSourcePool(virConnectPtr conn,
>                                       virDomainDefPtr def)
>  {
>      virStoragePoolObjPtr pool = NULL;
> -    virStorageVolDefPtr vol = NULL;
>      int i;
>      int ret = -1;
>  
>      for (i = 0; i < def->ndisks; i++) {
> +        virStorageVolDefPtr vol = NULL;
>          virDomainDiskDefPtr disk = def->disks[i];
> +        virDomainDiskHostDefPtr hosts = NULL;
> +        int nhost;
> +        int n;
>  
>          if (disk->type != VIR_DOMAIN_DISK_TYPE_VOLUME)
>              continue;
> @@ -2449,10 +2452,46 @@ storageTranslateDomainDiskSourcePool(virConnectPtr conn,
>              disk->src = strdup(vol->target.path);
>              break;
>          case VIR_STORAGE_VOL_NETWORK:
> -            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> -                           _("Using network volume as disk source is not supported"));
> -            goto cleanup;
> -        }
> +            if (pool->def->type != VIR_STORAGE_POOL_RBD &&
> +                pool->def->type != VIR_STORAGE_POOL_SHEEPDOG) {
> +                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +                               _("Using '%s' pool as disk source is "
> +                                 "not supported"),
> +                               virStoragePoolTypeToString(pool->def->type));
> +                goto cleanup;
> +            }
> +
> +            if (VIR_ALLOC_N(hosts, pool->def->source.nhost) < 0) {
> +                virReportOOMError();
> +                goto cleanup;
> +            }
> +
> +            nhost = pool->def->source.nhost;
> +            for (n = 0; n < pool->def->source.nhost; n++) {
> +                hosts[n].name = strdup(pool->def->source.hosts[n].name);

What if hosts[n].name == NULL?

> +                if (virAsprintf(&hosts[n].port, "%d",
> +                    pool->def->source.hosts[n].port) < 0) {
> +                    virReportOOMError();
> +                    while (nhost > 0) {
> +                        virDomainDiskHostDefFree(&hosts[nhost - 1]);
> +                        nhost--;
> +                    }

Need a VIR_FREE(hosts);

> +                    goto cleanup;
> +                }
> +
> +
> +                /* XXX: Use the default, as storage pool have not supported
> +                 * 'transport' and 'socket' yet.
> +                 */
> +                hosts[n].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP;
> +                hosts[n].socket = NULL;
> +            }
> +
> +            disk->hosts = hosts;
> +            disk->nhosts = pool->def->source.nhost;
> +            disk->src = strdup(vol->name);

What happens if !disk->src here?

> +            break;
> +       }
>  
>          virStoragePoolObjUnlock(pool);
>          pool = NULL;
> 

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]