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

Re: [Xen-devel] [PATCH] libxl: fix pci device re-assigning after domain reboot


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 27 Jun 2019 10:28:34 +0200
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@xxxxxxxxxx; spf=Pass smtp.mailfrom=roger.pau@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Ian Jackson <ian.jackson@xxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 27 Jun 2019 08:28:50 +0000
  • Ironport-sdr: P4GJzsqQKoHajYZORygcV6PlnAwhbwfhup0nstVjLswhIyPqD+HJDh5Hu1foVehHqjBx2a4SFn kguCZS9bSQ+C/5QDpFFd1K8ue5K66f2wdNrhebHPv/JGdXz8DPK5EEif8B0hRZu8lz+A30l8Wo 6I5Nxt6ZMzQi1hCSdrp2jk0vmXDdDYQmzH4543CXzGS6msowdtInn/k00PluNMAjGiLVd4OEWo Pv9qo0Z5RHskkmSR+qaT8Z6Sg3n3MyCaUsX+fsZI/4eDMWP5fHXpjZqkBhISfqvqds7Q4/qg4S K2s=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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 <jgross@xxxxxxxx>
> Tested-by: Chao Gao <chao.gao@xxxxxxxxx>

Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

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
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.