All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chun Yan Liu <cyliu@novell.com>
To: George Dunlap <george.dunlap@citrix.com>,
	Chun Yan Liu <cyliu@suse.com>,
	xen-devel@lists.xen.org
Cc: Juergen Gross <JGross@suse.com>,
	wei.liu2@citrix.com, ian.campbell@citrix.com,
	george.dunlap@eu.citrix.com, Ian.Jackson@eu.citrix.com,
	Jim Fehlig <JFEHLIG@suse.com>, Simon Cao <caobosimon@gmail.com>
Subject: Re: [PATCH V7 3/7] libxl: add pvusb API
Date: Wed, 14 Oct 2015 10:29:45 +0800	[thread overview]
Message-ID: <561DBE19.7090909@novell.com> (raw)
In-Reply-To: <561D03F4.5020901@citrix.com>



On 10/13/2015 09:15 PM, George Dunlap wrote:
> On 13/10/15 02:46, Chun Yan Liu wrote:
>>
>> On 10/12/2015 09:46 PM, George Dunlap wrote:
>>> On 12/10/15 08:19, Chun Yan Liu wrote:
>>>>>> +
>>>>>> +    usbinfo->devnum = usb->u.hostdev.hostaddr;
>>>>>> +    usbinfo->busnum = usb->u.hostdev.hostbus;
>>>>>> +
>>>>>> +    busid = usb_busaddr_to_busid(gc, usb->u.hostdev.hostbus,
>>>>>> +                                 usb->u.hostdev.hostaddr);
>>>>>> +    if (!busid) {
>>>>>> +        rc = ERROR_FAIL;
>>>>>> +        goto out;
>>>>>> +    }
>>>>>> +
>>>>>> +    filename = GCSPRINTF(SYSFS_USB_DEV"/%s/idVendor", busid);
>>>>>> +    if (!libxl_read_sysfs_file_contents(ctx, filename, &buf, NULL))
>>>>>> +        sscanf(buf, "%" SCNx16, &usbinfo->idVendor);
>>>>>> +
>>>>>> +    filename = GCSPRINTF(SYSFS_USB_DEV"/%s/idProduct", busid);
>>>>>> +    if (!libxl_read_sysfs_file_contents(ctx, filename, &buf, NULL))
>>>>>> +        sscanf(buf, "%" SCNx16, &usbinfo->idProduct);
>>>>>> +
>>>>>> +    filename = GCSPRINTF(SYSFS_USB_DEV"/%s/manufacturer", busid);
>>>>>> +    if (!libxl_read_sysfs_file_contents(ctx, filename, &buf,
>>>>>> &buflen) &&
>>>>>> +        buflen > 0) {
>>>>>> +        /* replace \n to \0 */
>>>>>> +        if (((char *)buf)[buflen - 1] == '\n')
>>>>>> +            ((char *)buf)[buflen - 1] = '\0';
>>>>>> +        usbinfo->manuf = libxl__strdup(NOGC, buf);
>>>>>> +   }
>>>>>> +
>>>>>> +    filename = GCSPRINTF(SYSFS_USB_DEV"/%s/product", busid);
>>>>>> +    if (!libxl_read_sysfs_file_contents(ctx, filename, &buf,
>>>>>> &buflen) &&
>>>>>> +        buflen > 0) {
>>>>>> +        /* replace \n to \0 */
>>>>>> +        if (((char *)buf)[buflen - 1] == '\n')
>>>>>> +            ((char *)buf)[buflen - 1] = '\0';
>>>>>> +        usbinfo->prod = libxl__strdup(NOGC, buf);
>>>>>> +    }
>>>>>    Basically, starting here, we have information which won't be
>>>>> available
>>>>> if we're using a pvusb driver domain.
>>>>>    This information is nice-to-have, but I don't think this
>>>>> information is
>>>>> directly relevant to libxl or xl; the funcitonality to get this
>>>>> information is available from other libraries like libusb.  I'm
>>>>> inclined
>>>>> to say that if we want to have pvusb driver domains (and I think we
>>>>> do),
>>>>> we should just get rid of this information.
>>>> For command 'xl usb-list', those information should be reported to user.
>>>> Do you mean we could call libusb to get thoes information directly in
>>>> xl toolstack and get rid of this function?
>>>>
>>>> I think we can keep the function, since every other device type has the
>>>> function XXX_getinfo. But here we could check backend_domid, for
>>>> backend=dom0, doing above work; for backend!=dom0 (e.g. pvusb
>>>> driver domain, no matter how, it should also be able to let users
>>>> getting
>>>> those information. Can add code  in future.)
>>> Does xl need that information?  Can't the user get that information from
>>> lsusb?
>>>
>>> In any case, I can see why it would be *useful* to have in xl.  But
>>> about having it in libxl, I think this question sort of goes along with
>>> the question about the next patch -- whether libxl should be in the
>>> business of providing general information about the USB devices it's
>>> handling, or whether it should limit itself to doing what is absolutely
>>> necessary to talk to usbback.
>>>
>>> There's a part of me that sees the point of it: it's not actually that
>>> much extra code (at least for Linux), and it makes it easy to add some
>>> very useful features to xl.
>>>
>>> On the other hand, it's not portable to other OSes.  At the moment of
>>> course pvusb isn't portable either, but once we have qemu USB (providing
>>> either emulated or PV usb) then I *think* most of the other
>>> functionality will Just Work on any platform that can compile qemu
>>> (incl. FreeBSD, NetBSD, &c), won't it?  The code you're introducing here
>>> would have to be re-implented for those platforms, and for every new
>>> platform that wanted to include this functionality, wouldn't it?
>> So, about the portability problem, I think it's back to: do need to
>> update code to call libusb instead of reading sysfs now? Except
>> for this function, still have places reading sysfs to get hostbus,
>> hostaddr, vendorId, deviceId. Those are not portable for other
>> platform.
> I realize I didn't give you very clear guidance; I guess I was hoping to
> get an opinion from the tools maintainers.  Or perhaps, I was hoping to
> let them be the "bad guys" and say, "You can't have this feature in
> libxl", so I wouldn't have to. :-)
>
> In the absence of guidance to the contrary, I suggest that patch series
> should focus on getting the core pvusb functionality in, without the
> extra usb-querying bits.  Then we can discuss a further series which
> either adds the usb querying functionality to libxl, or implement it in
> xl using libusb.
OK. Got it. Thanks.

-Chunyan

>
>   -George
>

  parent reply	other threads:[~2015-10-14  2:29 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-25  2:11 [PATCH V7 0/7] xen pvusb toolstack work Chunyan Liu
2015-09-25  2:11 ` [PATCH V7 1/7] libxl: export some functions for pvusb use Chunyan Liu
2015-09-25  2:11 ` [PATCH V7 2/7] libxl_read_file_contents: add new entry to read sysfs file Chunyan Liu
2015-09-30 11:22   ` George Dunlap
2015-10-02 13:25   ` Ian Campbell
2015-09-25  2:11 ` [PATCH V7 3/7] libxl: add pvusb API Chunyan Liu
2015-09-30 17:55   ` George Dunlap
2015-10-02 13:31     ` Ian Campbell
2015-10-09  8:12     ` Chun Yan Liu
2015-10-12  7:19     ` Chun Yan Liu
2015-10-12 13:46       ` George Dunlap
2015-10-13  1:46         ` Chun Yan Liu
2015-10-13 13:15           ` George Dunlap
2015-10-13 13:19             ` George Dunlap
2015-10-13 13:30             ` Ian Campbell
2015-10-14  2:29             ` Chun Yan Liu [this message]
2015-10-08 14:41   ` Ian Jackson
2015-10-08 14:54     ` Ian Campbell
2015-10-08 15:16       ` Ian Jackson
2015-10-12  7:00     ` Chun Yan Liu
2015-09-25  2:11 ` [PATCH V7 4/7] libxl: add libxl_device_usb_assignable_list API Chunyan Liu
2015-10-01 11:32   ` George Dunlap
2015-09-25  2:11 ` [PATCH V7 5/7] xl: add pvusb commands Chunyan Liu
2015-10-01 17:02   ` George Dunlap
2015-10-02 13:35     ` Ian Campbell
2015-10-02 15:17       ` George Dunlap
2015-10-02 15:29         ` Ian Campbell
2015-10-09  7:15     ` Chun Yan Liu
2015-09-25  2:11 ` [PATCH V7 6/7] xl: add usb-assignable-list command Chunyan Liu
2015-10-06 16:55   ` George Dunlap
2015-10-07  8:40     ` Ian Campbell
2015-10-07  9:55       ` Juergen Gross
2015-10-07 10:08         ` Ian Campbell
2015-10-07 10:10       ` George Dunlap
2015-10-07 10:15         ` George Dunlap
2015-10-07 10:35         ` Christiane Groß
2015-10-07 11:09         ` Ian Campbell
2015-10-07 11:20           ` George Dunlap
2015-10-07 11:25             ` Juergen Gross
2015-10-07 11:32               ` George Dunlap
2015-10-07 11:37               ` Ian Campbell
2015-10-07 11:39                 ` Juergen Gross
2015-10-07 11:43                 ` Ian Campbell
2015-10-07 11:39               ` Ian Campbell
2015-10-07 11:49                 ` Juergen Gross
2015-10-07 11:55                   ` Ian Campbell
2015-10-07 12:05                     ` Juergen Gross
2015-10-07 12:51                       ` Ian Campbell
2015-10-07 13:21                       ` George Dunlap
2015-10-07 13:54                         ` Juergen Gross
2015-10-07 14:05                           ` Ian Campbell
2015-10-07 14:26                             ` Juergen Gross
2015-10-07 14:35                               ` George Dunlap
2015-10-07 14:47                                 ` Juergen Gross
2015-10-07 15:03                                   ` George Dunlap
2015-10-07 15:13                                     ` Juergen Gross
2015-10-07 14:10                           ` George Dunlap
2015-09-25  2:11 ` [PATCH V7 7/7] domcreate: support pvusb in configuration file Chunyan Liu
2015-10-07 15:06   ` George Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=561DBE19.7090909@novell.com \
    --to=cyliu@novell.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JFEHLIG@suse.com \
    --cc=JGross@suse.com \
    --cc=caobosimon@gmail.com \
    --cc=cyliu@suse.com \
    --cc=george.dunlap@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.