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

Re: [PATCH v4 08/23] libxl: generalise 'driver_path' xenstore access functions in libxl_pci.c


  • To: Paul Durrant <paul@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Date: Tue, 1 Dec 2020 13:48:46 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wokN+bPcvXguk4xKfunrLZTNdt8u6aBsRhNNulVtlGA=; b=hlmswT9KUoux5lRZFA7dqCFfFrOhPsmBDPAnl2Ep1WH4cVRCLo1kFnERQxe1Pwo/cSQZqWrKBNinFg/1tQQlSMviJSxPpEfpFIwg4nsV3eu5plLMihEXt83gdRkmrTBAvpeEnqRJkZ1zZP7tPRxqkdopKF3m9u7+Ov4xqXrQ4lgNT+uhepSLJoBOtGp9sDfqGzYb/omhXkl82JLrVtzpIpYFyOREH82w5jsKLAVYGL8YREQUZinFRh4bZaHtWRboTdheo5pWlDc5/WWNPjy7we9kzcMcWdSPl+dTJ3dUeEqMcws0BgkbPQorUHU/GNjg4LJTnEpKYYr3Zio0/wSW4g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c5r26GqoT/BWE7hXoNw5hmYxjkvCv3Gq1ARlO6rvqL5XsKlfbIunfrY5llz6/j/1VwfERSvmxff0lMbRVf9yrFetIkST3qukVbQDmZhtAQaArAPYqVym9+9pq66L2WTtD/Y/zo/QIlYSUYIGrO/7UR++nsDZdVl0ZCwr0+G5hzR8+3FIlMR6n66yjyMaI8FsiaxzpHiNgRy3FhgxuzBUY6eu2D1q47QvvEm8x5M3WUm4icCGJ26whD4reuhMAK8XyUI2WcczpXVZorhkSa4VVz36kNjrn2N7Zta+tcufWYBrvdVKff+MClH9E/b+jNTPxNuL3opNiPRY+04tKwSaGw==
  • Authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=epam.com;
  • Cc: Paul Durrant <pdurrant@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 01 Dec 2020 13:49:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHWx+iwPYPJcGuC/0eTe1W0s2JAOQ==
  • Thread-topic: [PATCH v4 08/23] libxl: generalise 'driver_path' xenstore access functions in libxl_pci.c

Hi, Paul!

On 11/24/20 10:01 AM, Paul Durrant wrote:
> From: Paul Durrant <pdurrant@xxxxxxxxxx>
>
> For the purposes of re-binding a device to its previous driver
> libxl__device_pci_assignable_add() writes the driver path into xenstore.
> This path is then read back in libxl__device_pci_assignable_remove().
>
> The functions that support this writing to and reading from xenstore are
> currently dedicated for this purpose and hence the node name 'driver_path'
> is hard-coded. This patch generalizes these utility functions and passes
> 'driver_path' as an argument. Subsequent patches will invoke them to
> access other nodes.
>
> NOTE: Because functions will have a broader use (other than storing a
>        driver path in lieu of pciback) the base xenstore path is also
>        changed from '/libxl/pciback' to '/libxl/pci'.
>
> Signed-off-by: Paul Durrant <pdurrant@xxxxxxxxxx>

Reviewed-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>

Thank you,

Oleksandr

> ---
> Cc: Ian Jackson <iwj@xxxxxxxxxxxxxx>
> Cc: Wei Liu <wl@xxxxxxx>
> ---
>   tools/libs/light/libxl_pci.c | 66 
> +++++++++++++++++++++-----------------------
>   1 file changed, 32 insertions(+), 34 deletions(-)
>
> diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c
> index 77edd27345..a5d5d2e78b 100644
> --- a/tools/libs/light/libxl_pci.c
> +++ b/tools/libs/light/libxl_pci.c
> @@ -737,48 +737,46 @@ static int pciback_dev_unassign(libxl__gc *gc, 
> libxl_device_pci *pci)
>       return 0;
>   }
>   
> -#define PCIBACK_INFO_PATH "/libxl/pciback"
> +#define PCI_INFO_PATH "/libxl/pci"
>   
> -static void pci_assignable_driver_path_write(libxl__gc *gc,
> -                                            libxl_device_pci *pci,
> -                                            char *driver_path)
> +static char *pci_info_xs_path(libxl__gc *gc, libxl_device_pci *pci,
> +                              const char *node)
>   {
> -    char *path;
> +    return node ?
> +        GCSPRINTF(PCI_INFO_PATH"/"PCI_BDF_XSPATH"/%s",
> +                  pci->domain, pci->bus, pci->dev, pci->func,
> +                  node) :
> +        GCSPRINTF(PCI_INFO_PATH"/"PCI_BDF_XSPATH,
> +                  pci->domain, pci->bus, pci->dev, pci->func);
> +}
> +
> +
> +static void pci_info_xs_write(libxl__gc *gc, libxl_device_pci *pci,
> +                              const char *node, const char *val)
> +{
> +    char *path = pci_info_xs_path(gc, pci, node);
>   
> -    path = GCSPRINTF(PCIBACK_INFO_PATH"/"PCI_BDF_XSPATH"/driver_path",
> -                     pci->domain,
> -                     pci->bus,
> -                     pci->dev,
> -                     pci->func);
> -    if ( libxl__xs_printf(gc, XBT_NULL, path, "%s", driver_path) < 0 ) {
> -        LOGE(WARN, "Write of %s to node %s failed.", driver_path, path);
> +    if ( libxl__xs_printf(gc, XBT_NULL, path, "%s", val) < 0 ) {
> +        LOGE(WARN, "Write of %s to node %s failed.", val, path);
>       }
>   }
>   
> -static char * pci_assignable_driver_path_read(libxl__gc *gc,
> -                                              libxl_device_pci *pci)
> +static char *pci_info_xs_read(libxl__gc *gc, libxl_device_pci *pci,
> +                              const char *node)
>   {
> -    return libxl__xs_read(gc, XBT_NULL,
> -                          GCSPRINTF(
> -                           PCIBACK_INFO_PATH "/" PCI_BDF_XSPATH 
> "/driver_path",
> -                           pci->domain,
> -                           pci->bus,
> -                           pci->dev,
> -                           pci->func));
> +    char *path = pci_info_xs_path(gc, pci, node);
> +
> +    return libxl__xs_read(gc, XBT_NULL, path);
>   }
>   
> -static void pci_assignable_driver_path_remove(libxl__gc *gc,
> -                                              libxl_device_pci *pci)
> +static void pci_info_xs_remove(libxl__gc *gc, libxl_device_pci *pci,
> +                               const char *node)
>   {
> +    char *path = pci_info_xs_path(gc, pci, node);
>       libxl_ctx *ctx = libxl__gc_owner(gc);
>   
>       /* Remove the xenstore entry */
> -    xs_rm(ctx->xsh, XBT_NULL,
> -          GCSPRINTF(PCIBACK_INFO_PATH "/" PCI_BDF_XSPATH,
> -                    pci->domain,
> -                    pci->bus,
> -                    pci->dev,
> -                    pci->func) );
> +    xs_rm(ctx->xsh, XBT_NULL, path);
>   }
>   
>   static int libxl__device_pci_assignable_add(libxl__gc *gc,
> @@ -824,9 +822,9 @@ static int libxl__device_pci_assignable_add(libxl__gc *gc,
>       /* Store driver_path for rebinding to dom0 */
>       if ( rebind ) {
>           if ( driver_path ) {
> -            pci_assignable_driver_path_write(gc, pci, driver_path);
> +            pci_info_xs_write(gc, pci, "driver_path", driver_path);
>           } else if ( (driver_path =
> -                     pci_assignable_driver_path_read(gc, pci)) != NULL ) {
> +                     pci_info_xs_read(gc, pci, "driver_path")) != NULL ) {
>               LOG(INFO, PCI_BDF" not bound to a driver, will be rebound to 
> %s",
>                   dom, bus, dev, func, driver_path);
>           } else {
> @@ -834,7 +832,7 @@ static int libxl__device_pci_assignable_add(libxl__gc *gc,
>                   dom, bus, dev, func);
>           }
>       } else {
> -        pci_assignable_driver_path_remove(gc, pci);
> +        pci_info_xs_remove(gc, pci, "driver_path");
>       }
>   
>       if ( pciback_dev_assign(gc, pci) ) {
> @@ -884,7 +882,7 @@ static int libxl__device_pci_assignable_remove(libxl__gc 
> *gc,
>       }
>   
>       /* Rebind if necessary */
> -    driver_path = pci_assignable_driver_path_read(gc, pci);
> +    driver_path = pci_info_xs_read(gc, pci, "driver_path");
>   
>       if ( driver_path ) {
>           if ( rebind ) {
> @@ -897,7 +895,7 @@ static int libxl__device_pci_assignable_remove(libxl__gc 
> *gc,
>                   return -1;
>               }
>   
> -            pci_assignable_driver_path_remove(gc, pci);
> +            pci_info_xs_remove(gc, pci, "driver_path");
>           }
>       } else {
>           if ( rebind ) {

 


Rackspace

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