|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 3 of 4] libxl: Introduce pci_assignable_add and pci_assignable_remove
On 10/05/12 12:19, Ian Campbell wrote: The xl command does in fact do this (i.e., always passes '1' here). I considered just taking this option out, as you suggest, but I thought it might be useful for the libxl implementation to have more flexibility.On Wed, 2012-05-09 at 11:28 +0100, George Dunlap wrote:Introduce libxl helper functions to prepare devices to be passed through to guests. This is meant to replace of all the manual sysfs commands which are currently required. pci_assignable_add accepts a BDF for a device and will: * Unbind a device from its current driver, if any * If "rebind" is set, it will store the path of the driver from which we unplugged it in /libxl/pciback/$BDF/driver_pathSince you don't know whether the user is going to pass -r to assignable_remove why not always store this? I have no idea what the "slot" thing is for. What I've determined by experimentation is: * Before "echo $BDF > .../pciback/bind" will work, $BDF must be listed in pciback/slots * The way to get $BDF listed in pciback/slots is "echo $BDF > pciback/new_slot" * The above command is not idempotent; if you do it twice, you'll get two entries of $BDF in pciback/slots* If necessary, create a slot for it in pcibackI must confess I'm a bit fuzzy on the relationship between slots and bindings, where does the "if necessary" come into it? I was wondering while reading the patch if unconditionally adding a removing the slot might simplify a bunch of stuff, but I suspect I just don't appreciate some particular aspect of how pciback works... I wasn't sure if having two slots would be a problem or not; so I did the conservative thing, and check for the existence of $BDF in pciback/slots first, only creating a new slot if there is not already an existing slot. So "if necessary" means, "if the device doesn't already have a slot".
I don't really follow. What exactly is it you're proposing?
Done. Where you have pointer output params (like driver_path here) in general I think it is preferable to do everything with a local (single indirection) pointer and only update the output parameter on success. This means you avoid leaking/exposing a partial result on error but also means you can drop a lot of "*" from around the function. Maybe the gc makes this moot, but the "if ( driver_path )" stuff at the top of the fn took me several seconds to work out also ;-). Yeah, that's a lot simpler, and easier to read. Done.
Done. Technically, yes. You can't be bound without a slot; but you can have a slot without being bound. I don't know exactly what the "slot" functionality is for, and why it's a separate step, but that's the way it is at the moment.+/* Scan through /sys/.../pciback/slots looking for pcidev's BDF */ +static int pciback_dev_has_slot(libxl__gc *gc, libxl_device_pci *pcidev)Is the concept of "having a slot" distinct from being bound to pciback? Ah, right -- I don't think I knew anything about the whole PCI domains thing. Done. This way you get a sort of callback path; but I could take it out if you want.
ack
Just doing ERRNO for all the callers makes more sense to me.
ack + return ERROR_FAIL; + } + } + return 0; +} + +/* FIXME */Leftover? Yeah, noticed this just after I sent it. :-) TBH, I just looked at another bit of code that did xs transactions and tried to follow suit. Since I only need one operation, I'll take out the transaction stuff.+retry: + t = xs_transaction_start(ctx->xsh); + + path = libxl__sprintf(gc, PCIBACK_INFO_PATH"/"PCI_BDF_XSPATH"/driver_path", + pcidev->domain, + pcidev->bus, + pcidev->dev, + pcidev->func); + xs_rm(ctx->xsh, t, path);Why do you need to rm first? Won't the write just replace whatever it is (and that means the need for a transaction goes away too) In any case you should create path outside the retry loop instead of needlessly recreating it each time around. + xs_rm(ctx->xsh, t, path);You don't need a transaction for a single operation. (and if you did then "path = ..." could have been hoisted out) Very well.
Not yet, but I don't think it hurts to have that flexibility. Thanks for the detailed review. -George _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |