[virt-tools-list] [virt-manager PATCH] addhardware: default to an existing bus when adding a new disk

Giuseppe Scrivano gscrivan at redhat.com
Thu Mar 26 13:49:24 UTC 2015


When a new disk is added, by default choose a bus that is already used
by an existing disk, if any.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1206097

Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
---
 virtManager/addhardware.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index b3ae68f..9153cad 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006-2007, 2012-2014 Red Hat, Inc.
+# Copyright (C) 2006-2007, 2012-2015 Red Hat, Inc.
 # Copyright (C) 2006 Hugh O. Brock <hbrock at redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -786,7 +786,15 @@ class vmmAddHardware(vmmGObjectUI):
         if self.conn.is_xen() or self.conn.is_test_conn():
             model.append(["xen", "Xen"])
 
-        if len(model) > 0:
+        default_bus = None
+        for i in self.vm.get_disk_devices():
+            if i.is_disk():
+                default_bus = i.bus
+                break
+
+        if default_bus:
+            uiutil.set_row_selection(widget, default_bus)
+        elif len(model) > 0:
             widget.set_active(0)
 
     def populate_disk_device(self, src):
-- 
2.1.0




More information about the virt-tools-list mailing list