[libvirt] [PATCH 3/3] lib: Check conditions for VIR_DOMAIN_BLOCK_REBASE_RELATIVE right away

Eric Blake eblake at redhat.com
Tue Jul 8 15:53:43 UTC 2014


On 07/08/2014 09:29 AM, Peter Krempa wrote:
> VIR_DOMAIN_BLOCK_REBASE_RELATIVE works only when @base is specified.
> Check it right in libvirt.c as it's not expected to change across
> hypervisors.
> ---
>  src/libvirt.c          | 7 +++++++
>  src/qemu/qemu_driver.c | 7 -------
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/src/libvirt.c b/src/libvirt.c
> index 6bf260a..edf2f8b 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -19817,6 +19817,13 @@ virDomainBlockRebase(virDomainPtr dom, const char *disk,
>          goto error;
>      }
> 
> +    if (flags & VIR_DOMAIN_BLOCK_REBASE_RELATIVE && !base) {
> +        virReportInvalidArg(base, "%s",
> +                            _("flag VIR_DOMAIN_BLOCK_REBASE_RELATIVE is valid "
> +                              "only with non-null base"));
> +        goto error;
> +    }

I'd shorten this to:

if (flags & VIR_DOMAIN_BLOCK_REBASE_RELATIVE)
    virCheckNonNullArgGoto(params, error);

for consistency with other validity checks in this file.

I'd also like to see this restriction mentioned in the libvirt.c docs.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140708/e9e3a689/attachment-0001.sig>


More information about the libvir-list mailing list