<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2013/4/17 Daniel P. Berrange <span dir="ltr"><<a href="mailto:berrange@redhat.com" target="_blank">berrange@redhat.com</a>></span><br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class=""><div class="h5">On Fri, Mar 22, 2013 at 05:36:09PM +0800, Chunyan Liu wrote:<br>
> Hi, List,<br>
><br>
> As the mail I've sent a week before:<br>
> <a href="https://www.redhat.com/archives/libvir-list/2013-March/msg00730.html" target="_blank">https://www.redhat.com/archives/libvir-list/2013-March/msg00730.html</a><br>
> I'm willing to push this work forward so that the passthrough APIs<br>
> could be reused by qemu driver and libxl driver (which doesn't support<br>
> pci passthrough yet and tries to add this function recently), or other<br>
> drivers.<br>
><br>
> But since this work affacts a lot, I'm not sure if I can control it in<br>
> a correct way. I write a draft to describe what I'm considering how to<br>
> do, as in the following and in attachment. Hope to get your review,<br>
> comment and guidence to improve the work before start coding. Any<br>
> feedback will be very appreciated!<br>
><br>
> Thanks!<br>
> Chunyan<br>
><br>
> ------------------------<br>
> DRAFT:<br>
><br>
> Write separate module for hostdev passthrough<br>
><br>
> 1. Purposes:<br>
><br>
>    * Move hostdev passthrough APIs from <a href="http://qemu_hostdev.ch" target="_blank">qemu_hostdev.ch</a> to separate module so<br>
>      that they could be reused by other hypervisors too<br>
><br>
>    * Maintain global in-use state of hostdevs<br>
><br>
><br>
> 2. Module design (draft):<br>
><br>
>    * New module name: hostdev_driver<br>
><br>
>    * New module files: <a href="http://hostdev_driver.ch" target="_blank">hostdev_driver.ch</a> <a href="http://hostdev_conf.ch" target="_blank">hostdev_conf.ch</a><br>
><br>
>    * New Definitions:<br>
><br>
>         ## [src/driver.h]<br>
><br>
>         typedef struct _virHostdevDriver virHostdevDriver;<br>
><br>
>         typedef virHostdevDriver *virHostdevDriverPtr;<br>
><br>
>         struct _virHosedevDriver {<br>
>             const char *name;<br>
>             virDrvOpen                  open;<br>
>             virDrvClose                 close;<br>
><br>
>             virDrvPrepareHostdevs        prepareHostdevs;<br>
>             virDrvPreparePciHostdevs        preparePciHostdevs;<br>
>             virDrvprepareUsbHostdevs        prepareUsbHostdevs;<br>
>             virDrvReattachHostdevs        reattachHostdevs;<br>
>             virDrvReattachPciHostdevs        reattachPciHostdevs;<br>
>             virDrvReattachUsbHostdevs       reattachUsbHostdevs;<br>
>             virDrvGetActivePciHostdevList       getActivePciHostdevList;<br>
>             virDrvGetActiveUsbHostdevList       getActiveUsbHostdevList;<br>
>             virDrvGetDomainActivePciHostdevList<br>
> getDomainActivePciHostdevList;<br>
>             virDrvGetDomainActiveUsbHostdevList<br>
> getDomainActiveUsbHostdevList;<br>
>            };<br>
<br>
</div></div>This is real overkill - we only need to do the driver table<br>
design for things which are public APIs with multiple pluggable<br>
implementations.<br>
<br>
For this scenario, we simply need one single set of internal APIs<br>
that any of the stateful hypervisor drivers can directly call into.<br>
Basically you just need to define some object to maintain the<br>
state eg<br>
<br>
    virHostdevManagerPtr<br>
<br>
and a method to get the default shared instance of it<br>
<br>
   virHostdevManagerPtr virHostdevManagerGetDefault();<br>
<br>
and then the various APIs for interacting with it<br>
<br>
     virHostdevManagerPrepareHostdevs(virHostdevManagerPtr mgr, ....);<br>
     ...etc..<br>
<br>
I'd just put this is all in a src/util/virhostdevmanager.{c,h}<br>
file.<br></blockquote><div><br></div><div>Got it. I'm writing it in the way you pointed, as a shared module instead of a driver, as Osier has pointed out too. Thanks for your suggestion about detail, I'll change code to follow that.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Regards,<br>
Daniel<br>
<span class=""><font color="#888888">--<br>
|: <a href="http://berrange.com" target="_blank">http://berrange.com</a>      -o-    <a href="http://www.flickr.com/photos/dberrange/" target="_blank">http://www.flickr.com/photos/dberrange/</a> :|<br>
|: <a href="http://libvirt.org" target="_blank">http://libvirt.org</a>              -o-             <a href="http://virt-manager.org" target="_blank">http://virt-manager.org</a> :|<br>
|: <a href="http://autobuild.org" target="_blank">http://autobuild.org</a>       -o-         <a href="http://search.cpan.org/%7Edanberr/" target="_blank">http://search.cpan.org/~danberr/</a> :|<br>
|: <a href="http://entangle-photo.org" target="_blank">http://entangle-photo.org</a>       -o-       <a href="http://live.gnome.org/gtk-vnc" target="_blank">http://live.gnome.org/gtk-vnc</a> :|<br>
<br>
</font></span></blockquote></div><br></div></div>