[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 14:26:03 UTC 2015


Cole Robinson <crobinso at redhat.com> writes:

> On 03/26/2015 09:49 AM, Giuseppe Scrivano wrote:
>> 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):
>> 
>
> ACK, though I can't remember offhand what set_row_selection does if the
> requested selection isn't in the model. Might want to double check it doesn't
> throw an exception

Thanks, I've pushed it.  set_row_selection will use the first entry in
the model, if the requested selection is not present.

Giuseppe




More information about the virt-tools-list mailing list