[PATCH virt-manager v3] virt-manager: prevent attach of inactive nodedevs

Shalini Chellathurai Saroja shalini at linux.ibm.com
Fri Feb 11 13:48:47 UTC 2022


On 2/3/22 21:42, Cole Robinson wrote:
> On 2/1/22 8:43 AM, Shalini Chellathurai Saroja wrote:
>> With virt-manager application, it is possible to add inactive node
>> devices(eg: mediated device) in host system to guest system. But it is
>> impossible to start a guest system with inactive node devices.  Also,
>> it is not yet possible to start a node device with virt-manager
>> application. So, the user cannot use the inactive node devices.
>>
>> This patch disables the "finish" button and provides a tip, when
>> inactive node devices are selected. So, it is not possible to add
>> inactive node devices to the guest system.
>>
>> Signed-off-by: Shalini Chellathurai Saroja<shalini at linux.ibm.com>
>> Reviewed-by: Boris Fiuczynski<fiuczy at linux.ibm.com>
>> ---
>>   virtManager/addhardware.py | 42 +++++++++++++++++++++++++++++++++++---
>>   1 file changed, 39 insertions(+), 3 deletions(-)
>>
> [...Snip...]
>> +        if hostdev[1] is None:
>> +            self.widget("create-finish").set_sensitive(False)
>> +            self.widget("create-finish").set_tooltip_text()
>> +        elif hostdev[2]:
>> +            self.widget("create-finish").set_sensitive(True)
>> +            self.widget("create-finish").set_tooltip_text()
>> +        else:
>> +            tooltip = (_("%s is not active in the host system.\n"
>> +            "Please start the mdev in the host system before adding it to the guest.")
>> +            % hostdev[1])
>> +            self.widget("create-finish").set_sensitive(False)
>> +            self.widget("create-finish").set_tooltip_text(tooltip)
>> +
> I prefer if there's only a single set_sensitive and set_tooltip_text
> call. The state is basically
>
> tooltip = None
> sensitive = row[2]
> if row[1] and sensitive is False:
>      tooltip = ...
> set_tooltip_text(tooltip)
> set_sensitive(sensitive)
>
Hello Cole,

Thank you very much for your comments.

I have implemented all of your comments and have sent v4 of the patch.I 
only did a minor change

to the above comment, I used the below code to avoid providing a tool 
tip when no devices are available.

if row[0] and sensitive is False: # instead of row[1]

-- 
Kind regards
Shalini Chellathurai Saroja
Linux on Z and Virtualization Development
Vorsitzende des Aufsichtsrats: Gregor Pillen
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20220211/867bc161/attachment.htm>


More information about the virt-tools-list mailing list