WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] libxl: add custom disconnect functions for diffe

To: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] libxl: add custom disconnect functions for different device types
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: Fri, 23 Sep 2011 16:13:18 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 23 Sep 2011 08:20:15 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1d42b1b355c231e794a5.1316778942@loki>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <1d42b1b355c231e794a5.1316778942@loki>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Fri, 2011-09-23 at 12:55 +0100, Roger Pau Monne wrote:
> # HG changeset patch
> # User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
> # Date 1316778937 -7200
> # Node ID 1d42b1b355c231e794a56dfadf3ee450346e3516
> # Parent  0ab9f548890e5e58122f73aa1c4164fd6e319b1c
> libxl: add custom disconnect functions for different device types.
> 
> This patch creates a new struct, called libxl__disconnect that can be
> used to assign different functions that will be called to check if the
> device is disconnected and to add it to the shutdown watch. Added a
> helper function to get the libxl__device_kind from a be_path. The only
> device that has a different shutdown mechanism right now is vbd.

Looks good. I think all the new functions can be static to
libxl_device.c though.

> diff -r 0ab9f548890e -r 1d42b1b355c2 tools/libxl/libxl_device.c
> --- a/tools/libxl/libxl_device.c      Fri Sep 23 13:31:51 2011 +0200
> +++ b/tools/libxl/libxl_device.c      Fri Sep 23 13:55:37 2011 +0200
> @@ -59,6 +80,18 @@ char *libxl__device_backend_path(libxl__
>                            device->domid, device->devid);
>  }
>  
> +libxl__device_kinds libxl__device_identify(char *be_path)
> +{
> +    int len = sizeof(string_of_kinds)/sizeof(char *);
> +
> +    for (int j = 1; j < len; j++) {
> +        if (strstr(be_path, string_of_kinds[j]))
> +            return j;
> +    }
> +
> +    return DEVICE_UNKNOWN;

You can sscanf out the precise backend rather than using strstr (which I
worry might give false positives and/or rely in the ordering on the enum
in the future).

e.g. something like:
    /* /local/domain/<domid>/backend/<kind>/<domid>/<devid> */
    char strkind[16]; /* Longest is actually "console" */
    uint32_t domain;
    int rc = sscanf(path, "/local/domain/%d/backend/%16s/%d/%d",
                   domid, strkind, &domain, devid);

    /* loop and strcmp of strkind vs string_of_kinds */

Ian.



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>