[libvirt] [PATCH] conf: more useful error message when pci function is out of range

Ján Tomko jtomko at redhat.com
Thu Jul 23 09:04:26 UTC 2015


On Wed, Jul 22, 2015 at 12:04:41PM -0400, Laine Stump wrote:
> If a pci address had a function number out of range, the error message
> would be:
> 
>   Insufficient specification for PCI address
> 
> This was due to an unnecessary call to virDevicePCIAddressIsValid()
> during parse of the pci address - we will anyway check for validity of
> the PCI address later on.
> 
> With that extra check removed, the error message is the much more useful:
> 
>   Invalid PCI address 0000:02:06.8. function must be <= 7
> 

That error is reported by virDomainPCIAddressValidate, called when we
validate and assign guest PCI addresses.

Other code paths do not have that protection. After this patch, we
happily parse:
<hostdev mode='subsystem' type='pci' managed='yes'>
  <source>
    <address domain='0x0000' bus='0x02' slot='0x00' function='0x9'/>
  </source>
</hostdev>

A vague error message (and refusing to continue with invalid data)
is better than no error, I think we should keep the error here.

> This resolves:
> 
>   https://bugzilla.redhat.com/show_bug.cgi?id=1004596
> ---
>  src/conf/device_conf.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
> index e7b7957..09a7019 100644
> --- a/src/conf/device_conf.c
> +++ b/src/conf/device_conf.c
> @@ -1,7 +1,7 @@
>  /*
>   * device_conf.c: device XML handling
>   *
> - * Copyright (C) 2006-2012 Red Hat, Inc.
> + * Copyright (C) 2006-2015 Red Hat, Inc.

Oh no, this file was unprotected for almost three years.

Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150723/9e8733ae/attachment-0001.sig>


More information about the libvir-list mailing list