[libvirt] [PATCH RFC 07/40] qemu: domain: Tolerate NULL @disk in qemuDomainPrepareDiskSourceData

Daniel Henrique Barboza danielhb413 at gmail.com
Fri Oct 18 19:08:13 UTC 2019



On 10/18/19 1:10 PM, Peter Krempa wrote:
> In some cases we want to prepare a @src which is not meant to belong to
> a disk and thus does not require us to copy the data. Allow passing in
> NULL @disk into qemuDomainPrepareDiskSourceData.
> 
> Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> ---

This is worth pushing as a bug fix IMO. Of all callers of
qemuDomainPrepareDiskSourceData, just qemuDomainPrepareDiskSourceLegacy
ensures that disk isn't NULL (and not explicitly, more like a side 
effect of qemuDomainValidateStorageSource being used with disk->src 
there). In all other places there is no guard of disk == NULL.

Or perhaps disk=NULL never happens in the current usage of this function 
and I'm being pendant.  Anyway ....



Reviewed-by: Daniel Henrique Barboza <danielhb413 at gmail.com>


>   src/qemu/qemu_domain.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 259cf51e2b..3deb69cb63 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -15095,6 +15095,9 @@ void
>   qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk,
>                                   virStorageSourcePtr src)
>   {
> +    if (!disk)
> +        return;
> +
>       /* transfer properties valid only for the top level image */
>       if (src == disk->src)
>           src->detect_zeroes = disk->detect_zeroes;
> 




More information about the libvir-list mailing list