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

Re: [libvirt] [PATCH 6/6] qemu: Make save/restore with USB devices usable



On Tue, Oct 09, 2012 at 02:13:27PM +0200, Jiri Denemark wrote:
> Save/restore with passed through USB devices currently only works if the
> USB device can be found at the same USB address where it used to be
> before saving a domain. This makes sense in case a user explicitly
> configure the USB address in domain XML. However, if the device was
> found automatically by vendor/product identification, we should try to
> search for that device when restoring the domain and use any device we
> find as long as there is only one available. In other words, the USB
> device can now be removed and plugged again or the host can be rebooted
> between saving and restoring the domain.
> ---
>  src/conf/domain_conf.c    | 10 ++++++++++
>  src/conf/domain_conf.h    |  2 ++
>  src/qemu/qemu_driver.c    |  5 +++--
>  src/qemu/qemu_hostdev.c   | 47 ++++++++++++++++++++++++++++++++++++++++-------
>  src/qemu/qemu_migration.c |  3 ++-
>  5 files changed, 57 insertions(+), 10 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index c32ce8d..0cb686d 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -2695,6 +2695,7 @@ virDomainHostdevSubsysUsbDefParseXML(const xmlNodePtr node,
>      int got_product, got_vendor;
>      xmlNodePtr cur;
>      char *startupPolicy = NULL;
> +    char *autoAddress;
>  
>      if ((startupPolicy = virXMLPropString(node, "startupPolicy"))) {
>          def->startupPolicy =
> @@ -2709,6 +2710,12 @@ virDomainHostdevSubsysUsbDefParseXML(const xmlNodePtr node,
>          VIR_FREE(startupPolicy);
>      }
>  
> +    if ((autoAddress = virXMLPropString(node, "autoAddress"))) {
> +        if (STREQ(autoAddress, "yes"))
> +            def->source.subsys.u.usb.autoAddress = true;
> +        VIR_FREE(autoAddress);
> +    }
> +
>      /* Product can validly be 0, so we need some extra help to determine
>       * if it is uninitialized*/
>      got_product = 0;
> @@ -12072,6 +12079,9 @@ virDomainHostdevSourceFormat(virBufferPtr buf,
>          policy = virDomainStartupPolicyTypeToString(def->startupPolicy);
>          virBufferAsprintf(buf, " startupPolicy='%s'", policy);
>      }
> +    if (def->source.subsys.u.usb.autoAddress &&
> +        (flags & VIR_DOMAIN_XML_MIGRATABLE))
> +        virBufferAddLit(buf, " autoAddress='yes'");
>      virBufferAddLit(buf, ">\n");
>  
>      virBufferAdjustIndent(buf, 2);

Do we really need to add a new attribute for this. IMHO if the user
has specified a vendor+product, then it is always auto-address, even
if they have also given a dev+address.


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


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