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

Re: [PATCH v4] libxl/PCI: Fix PV hotplug & stubdom coldplug


  • To: Jason Andryuk <jandryuk@xxxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Thu, 13 Jan 2022 10:39:26 +0000
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, "Paul Durrant" <paul@xxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Thu, 13 Jan 2022 10:39:42 +0000
  • Ironport-data: A9a23:WsClR6mwsS4JGNLW+S2mE9Xo5gwAIURdPkR7XQ2eYbSJt1+Wr1Gzt xIWWzqAOqzYYDShc9kkPYy0pEpSuZPTzIdgTABsqXo2HiMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BClVlxJVF/fngqoDUUYYoAQgsA180IMsdoUg7wbRh29cz2YHR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 PRP5KHgQxwCBZ/3u8ESCzVkD3BbL6ITrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBMDtIIMYvGAm1TzDBOwqaZvCX7/L9ZlT2zJYasVmQ6+PP 5tHM2MHgBLoRz9NH147B5sFru6st0fHWnpHkmqQqv9ii4TU5FMoi+W8WDbPQfSSTNhRtlaVo CTB5WuRKg4eHMySz3yC6H3Eru3AhyTgQ6oJCaa1sPVthTW7xGUVBAcHSFiTrvywi0r4UNVaQ 2QE9yxroaUs+UiDStjmQwb+sHOCpgQbWddb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B17726RtN9/Yh0dcLy7V5VoBEmsk6KdgrNhWItKPjOW21dARbsKheCJrgEIWReOlNK1vZ 0QCpSWY+eRMbEVt6jH3DU=
  • Ironport-sdr: SYFDaHAMp5F3HvorWxSuXmE4WstW4dfzR3JQAq5jsZyZYr7nfkdjbfaqZN4XEuojna+V2zHzvk bJCJtny0WODoZfvjMlFWnfZ8Hps2j8kf+OG8v4ouOBRLZIbs8sxwxeklkkuqkjS/5GBwXMQtO3 OEvpgNUb4WhtLh3mXK8jynUz8L/h90kX0S/F6KU21ZnJLXINmsgldqP1B+ReLPWcMzsw5iWNbc IwhbGOQFqhsDv5byhiDrJcuxRplIbsWaWluiTMdHCcw/45U7EshHHeAkYRaWeOdEoVqL837gGX s+O956ocPr8GifWWtFOTivC9
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Jan 12, 2022 at 11:01:42PM -0500, Jason Andryuk wrote:
> commit 0fdb48ffe7a1 "libxl: Make sure devices added by pci-attach are
> reflected in the config" broken PCI hotplug (xl pci-attach) for PV
> domains when it moved libxl__create_pci_backend() later in the function.
> 
> This also broke HVM + stubdom PCI passthrough coldplug.  For that, the
> PCI devices are hotplugged to a running PV stubdom, and then the QEMU
> QMP device_add commands are made to QEMU inside the stubdom.
> 
> A running PV domain calls libxl__wait_for_backend().  With the current
> placement of libxl__create_pci_backend(), the path does not exist and
> the call immediately fails:
> libxl: error: libxl_device.c:1388:libxl__wait_for_backend: Backend 
> /local/domain/0/backend/pci/43/0 does not exist
> libxl: error: libxl_pci.c:1764:device_pci_add_done: Domain 
> 42:libxl__device_pci_add failed for PCI device 0:2:0.0 (rc -3)
> libxl: error: libxl_create.c:1857:domcreate_attach_devices: Domain 42:unable 
> to add pci devices
> 
> The wait is only relevant when:
> 1) The domain is PV
> 3) The domain is running
> 2) The backend is already present
> 
> 1) xen-pcifront is only used for PV.  It does not load for HVM domains
>    where QEMU is used.
> 
> 2) If the domain is not running (starting), then the frontend state will
>    be Initialising.  xen-pciback waits for the frontend to transition to
>    at Initialised before attempting to connect.  So a wait for a
>    non-running domain is not applicable as the backend will not
>    transition to Connected.
> 
> 3) For presence, num_devs is already used to determine if the backend
>    needs to be created.  Re-use num_devs to determine if the backend
>    wait is necessary.  The wait is necessary to avoid racing with
>    another PCI attachment reconfiguring the front/back or changing to
>    some other state like closing.  If we are creating the backend, then
>    we don't have to worry about the state since it is being created.
> 
> Fixes: 0fdb48ffe7a1 ("libxl: Make sure devices added by pci-attach are
> reflected in the config")
> 
> Signed-off-by: Jason Andryuk <jandryuk@xxxxxxxxx>

That patch is probably good enough for now, even if there is probably need to
rework the function with regards to issue raised in
https://lore.kernel.org/xen-devel/24859.43747.87671.739214@xxxxxxxxxxxxxxxxxxxxxxxx/
in the thread.

Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>

Thanks,

-- 
Anthony PERARD



 


Rackspace

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