From bf7773ce58cf3e7a95f8870a32767d567cb99210 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 25 Jul 2013 14:11:09 -0400 Subject: [PATCH] Guest: Drop add_device set_defaults option Was only used to fix one bug, but has too many side effects. Just fix it at the caller. --- virtManager/addhardware.py | 16 +++++++++------- virtManager/create.py | 2 +- virtManager/details.py | 2 +- virtinst/Guest.py | 11 +---------- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py index 1ac79510..76580dc1 100644 --- a/virtManager/addhardware.py +++ b/virtManager/addhardware.py @@ -73,11 +73,12 @@ tpm_widget_mappings = { class vmmAddHardware(vmmGObjectUI): - def __init__(self, vm): + def __init__(self, vm, is_customize_dialog): vmmGObjectUI.__init__(self, "vmm-add-hardware.ui", "vmm-add-hardware") self.vm = vm self.conn = vm.conn + self.is_customize_dialog = is_customize_dialog self.storage_browser = None @@ -1340,13 +1341,14 @@ class vmmAddHardware(vmmGObjectUI): return self.err.val_err(_("Storage parameter error."), e) # Generate target - used = [] - disks = (self.vm.get_disk_devices() + - self.vm.get_disk_devices(inactive=True)) - for d in disks: - used.append(d.target) + if not self.is_customize_dialog: + used = [] + disks = (self.vm.get_disk_devices() + + self.vm.get_disk_devices(inactive=True)) + for d in disks: + used.append(d.target) - disk.generate_target(used) + disk.generate_target(used) isfatal, errmsg = disk.is_size_conflict() if not isfatal and errmsg: diff --git a/virtManager/create.py b/virtManager/create.py index 3d417690..80741b93 100644 --- a/virtManager/create.py +++ b/virtManager/create.py @@ -1724,7 +1724,7 @@ class vmmCreate(vmmGObjectUI): self.conn, disk.path) self.disk = disk - self.guest.add_device(self.disk, set_defaults=True) + self.guest.add_device(self.disk) return True diff --git a/virtManager/details.py b/virtManager/details.py index 7f18249c..597b1c48 100644 --- a/virtManager/details.py +++ b/virtManager/details.py @@ -1518,7 +1518,7 @@ class vmmDetails(vmmGObjectUI): def add_hardware(self, src_ignore): try: if self.addhw is None: - self.addhw = vmmAddHardware(self.vm) + self.addhw = vmmAddHardware(self.vm, self.is_customize_dialog) self.addhw.show(self.topwin) except Exception, e: diff --git a/virtinst/Guest.py b/virtinst/Guest.py index 18bf9a50..d4b8ffad 100644 --- a/virtinst/Guest.py +++ b/virtinst/Guest.py @@ -330,7 +330,7 @@ class Guest(XMLBuilder): newlist.append(i) return newlist - def add_device(self, dev, set_defaults=False): + def add_device(self, dev): """ Add the passed device to the guest's device list. @@ -341,15 +341,6 @@ class Guest(XMLBuilder): self._add_child(dev) self._recalculate_device_xpaths() - if set_defaults: - origdev = self._devices - try: - self._devices = [dev] - self._set_device_defaults() - except: - self._devices = origdev - - def _track_device(self, dev): self._devices.append(dev)