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

Re: [virt-tools-list] [virt-manager PATCH] Use proper disk targets.



On 07/09/2013 08:53 AM, Martin Kletzander wrote:
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=968878
> 
> Signed-off-by: Martin Kletzander <mkletzan redhat com>
> ---
>  virtManager/create.py |  2 +-
>  virtinst/Guest.py     | 14 +++++++++++---
>  2 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/virtManager/create.py b/virtManager/create.py
> index 5d9e516..8dd006d 100644
> --- a/virtManager/create.py
> +++ b/virtManager/create.py
> @@ -1716,7 +1716,7 @@ class vmmCreate(vmmGObjectUI):
>                                                   self.conn, disk.path)
> 
>          self.disk = disk
> -        self.guest.add_device(self.disk)
> +        self.guest.add_device(self.disk, set_defaults=True)
> 
>          return True
> 
> diff --git a/virtinst/Guest.py b/virtinst/Guest.py
> index ffcddca..a1d1449 100644
> --- a/virtinst/Guest.py
> +++ b/virtinst/Guest.py
> @@ -1,7 +1,7 @@
>  #
>  # Common code for all guests
>  #
> -# Copyright 2006-2009  Red Hat, Inc.
> +# Copyright 2006-2009, 2013  Red Hat, Inc.
>  # Jeremy Katz <katzj redhat com>
>  #
>  # This program is free software; you can redistribute it and/or modify
> @@ -536,11 +536,12 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
>                  newlist.append(i)
>          return newlist
> 
> -    def add_device(self, dev):
> +    def add_device(self, dev, set_defaults=False):
>          """
>          Add the passed device to the guest's device list.
> 
>          @param dev: VirtualDevice instance to attach to guest
> +        @param set_defaults: Whether to set defaults for the device
>          """
>          if not isinstance(dev, VirtualDevice):
>              raise ValueError(_("Must pass a VirtualDevice instance."))
> @@ -551,7 +552,14 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
>              dev.set_xml_node(node)
>              self._add_child_node("./devices", node)
> 
> -        return self._add_device(dev)
> +        self._add_device(dev)
> +        if set_defaults:
> +            def list_one_dev(devtype):
> +                if dev.virtual_device_type == devtype:
> +                    return [dev][:]
> +                else:
> +                    return []
> +            self._set_defaults(list_one_dev, None, self.features)
> 
>      def _add_device(self, dev):
>          devtype = dev.virtual_device_type
> 

Thanks, I pushed it since I had it applied for a test spin.

- Cole


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