Re: [PATCH 07/12] qemu: block: Add JSON props generator for NBD storage backing

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

 




On 11/03/2017 10:29 AM, Peter Krempa wrote:
> ---
>  src/qemu/qemu_block.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
> index 4e588c724..451d04694 100644
> --- a/src/qemu/qemu_block.c
> +++ b/src/qemu/qemu_block.c
> @@ -767,6 +767,34 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src)
>  }
> 
> 
> +static virJSONValuePtr
> +qemuBlockStorageSourceGetNBDProps(virStorageSourcePtr src)
> +{
> +    virJSONValuePtr serverprops;
> +    virJSONValuePtr ret = NULL;
> +
> +    if (src->nhosts != 1) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("nbd protocol accepts only one host"));
> +        return NULL;
> +    }
> +
> +    serverprops = qemuBlockStorageSourceBuildJSONSocketAddress(&src->hosts[0],
> +                                                               false);
> +    if (!serverprops)
> +        return NULL;
> +
> +    ignore_value(virJSONValueObjectCreate(&ret,
> +                                          "s:driver", "nbd",
> +                                          "a:server", serverprops,
> +                                          "S:export", src->path,
> +                                          "S:tls-creds", src->tlsAlias,
> +                                          NULL));

Coverity notes that serverprops will be leaked on failure

Actually it REALLY doesn't like the "a:server" consumption, but I
already have quite a few of those in my false positive list.

John

> +
> +    return ret;
> +}
> +
> +
>  /**
>   * qemuBlockStorageSourceGetBackendProps:
>   * @src: disk source
> @@ -822,6 +850,10 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
>              break;
> 
>          case VIR_STORAGE_NET_PROTOCOL_NBD:
> +            if (!(fileprops = qemuBlockStorageSourceGetNBDProps(src)))
> +                return NULL;
> +            break;
> +
>          case VIR_STORAGE_NET_PROTOCOL_RBD:
>          case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG:
>          case VIR_STORAGE_NET_PROTOCOL_SSH:
> 

--
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]
  Powered by Linux