[virt-tools-list] [virt-manager PATCH v2 3/3] addhardware: enable setting model when adding controller

Chen Hanxiao chen_han_xiao at 126.com
Mon May 5 15:17:50 UTC 2014


On 04/24/2014 11:26 PM, Cole Robinson wrote:
> On 04/23/2014 06:23 AM, Chen Hanxiao wrote:
>> If no USB controller, we could add a new one;
>> if had, disable 'create-finish' button and
>> add a tooltip beside type combo.
>>
>> Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
>> ---
>>   ui/addhardware.ui          | 22 ++++++++++++++++++---
>>   virtManager/addhardware.py | 48 +++++++++++++++++++++++++++++++++++-----------
>>   2 files changed, 56 insertions(+), 14 deletions(-)
>>
> Calling add_device during validation is not okay, since this will actually
> attempt to alter the VM. We need to make self._dev a list in this case
> containing all the devices we want to add, and only then do it during
> add_device. We also need to avoid hotplug in that case since we can't hotplug
> multiple devices at once.
Do we really need to support adding multiple devices in add_device?
Or something like:
for dev in self._dev:
     add_device()

In this USB controller case, we could just modify the USB controller model
of 'none' to some other type, then our existed codes could do the rest 
things.

Thanks,

- Chen
>
> Also, if a controller type doesn't support any 'model' values, we should hide
> the model row (set_grid_row_visible) rather than de-sensitize it.
>
> - Cole
>


>> +        else:
>> +            controllers = self.vm.get_controller_devices()
>> +            controller_num = [x for x in controllers if
>> +                    (x.type == controller_type)]
>> +            if len(controller_num) > 0:
>> +                index_new = max([x.index for x in controller_num]) + 1
>> +                self._dev.index = index_new
>> +
>> +            self._dev.type = controller_type
>> +            if model != "none":
>> +                if model == "default":
>> +                    model = None
>> +                self._dev.model = model
>>   
>>       def validate_page_rng(self):
>>           conn = virtinst.VirtualRNGDevice.BACKEND_MODE_CONNECT in \
>>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
>





More information about the virt-tools-list mailing list