On Wed, Jun 26, 2019 at 03:37:26PM +0200, Juergen Gross wrote:
> After a reboot of a guest only the first pci device configuration will
> be retrieved from Xenstore resulting in loss of any further assigned
> passed through pci devices.
> 
> The main reason is that all passed through pci devices reside under a
> common root device "0" in Xenstore. So when the device list is rebuilt
> from Xenstore after a reboot the sub-devices below that root device
> need to be selected instead of using the root device number as a
> selector.
> 
> Fix that by adding a new member to struct libxl_device_type which when
> set is used to get the number of devices. Add such a member for pci to
> get the correct number of pci devices instead of implying it from the
> number of pci root devices (which will always be 1).
> 
> While at it fix the type of libxl__device_pci_from_xs_be() to match
> the one of the .from_xenstore member of struct libxl_device_type. This
> fixes a latent bug checking the return value of a function returning
> void.
> 
> Signed-off-by: Juergen Gross <[email protected]>
> Tested-by: Chao Gao <[email protected]>

Reviewed-by: Roger Pau Monné <[email protected]>

Thanks!

> ---
>  tools/libxl/libxl_device.c   | 24 +++++++++++++++++++-----
>  tools/libxl/libxl_internal.h |  2 ++
>  tools/libxl/libxl_pci.c      | 35 ++++++++++++++++++++++++++---------
>  3 files changed, 47 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
> index db6c0203b7..a2569102ee 100644
> --- a/tools/libxl/libxl_device.c
> +++ b/tools/libxl/libxl_device.c
> @@ -2026,6 +2026,7 @@ void *libxl__device_list(libxl__gc *gc, const struct 
> libxl_device_type *dt,
>      char *libxl_path;
>      char **dir = NULL;
>      unsigned int ndirs = 0;
> +    unsigned int ndevs = 0;

I think you could reduce the scope of ndevs...

>      int rc;
>  
>      *num = 0;
> @@ -2037,21 +2038,34 @@ void *libxl__device_list(libxl__gc *gc, const struct 
> libxl_device_type *dt,
>      dir = libxl__xs_directory(gc, XBT_NULL, libxl_path, &ndirs);
>  
>      if (dir && ndirs) {

... by declaring it here.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to