From f08313513bb8fc06eb38fb179bfa99f2daa27caf Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Tue, 9 Jul 2013 14:53:22 +0200 Subject: [PATCH] Use proper disk targets. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=968878 Signed-off-by: Martin Kletzander --- 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 b212c844..6c28c4a6 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 ffcddca2..a1d14494 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 # # 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