<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7601.19038"></HEAD>
<BODY style="MARGIN: 4px 4px 1px; FONT: 10pt 微软雅黑">
<DIV><BR><BR>>>> Cole Robinson <crobinso@redhat.com> 2017/11/22 星期三 上午 6:18 >>><BR>>On 11/06/2017 07:52 AM, Lin Ma wrote:<BR>>> Through virt-manager, After we removed a virtio-scsi controller which<BR>>> virtual disks still attach to it, Libvirt will add a LSI scsi controller<BR>>> for this guest automatically and trigger a lifecycle event, virt-manager<BR>>> updates and shows this new scsi controller in details panel once it got<BR>>> the lifecycle event.<BR>>> <BR>>> It may confuse user that a LSI scsi controller occurs while one removes<BR>>> the virtio-scsi controller.<BR>>> <BR>>> This patch prevents removing a scsi controller if any disks attaching to<BR>>> it.<BR>>> <BR>>> Signed-off-by: Lin Ma <lma@suse.com><BR>>> ---<BR>>>  virtManager/details.py | 6 ++++++<BR>>>  1 file changed, 6 insertions(+)<BR>>> <BR>>> diff --git a/virtManager/details.py b/virtManager/details.py<BR>>> index a51f5623..0923f4b0 100644<BR>>> --- a/virtManager/details.py<BR>>> +++ b/virtManager/details.py<BR>>> @@ -3000,6 +3000,12 @@ class vmmDetails(vmmGObjectUI):<BR>>>              can_remove = False<BR>>>          if dev.type == "pci":<BR>>>              can_remove = False<BR>>> +        if dev.type == "scsi":<BR>>> +            for disk in self.vm.get_disk_devices(inactive=True):<BR>>> +                if (dev.type == disk.bus and<BR>>> +                    dev.index == disk.address.controller):<BR>>> +                    can_remove = False<BR>>> +                    break<BR>>>          self.widget("config-remove").set_sensitive(can_remove)<BR>>>  <BR>>>          type_label = dev.pretty_desc()<BR>>> <BR>><BR>>Good idea, we should do this for other controller types too I think.<BR></DIV>
<DIV>No problem, I'd like to do it for other controller types(say SATA,</DIV>
<DIV>VirtIO Serial and Floppy in a new patch after this patch got merged.</DIV>
<DIV><BR>>(Another nice addition would be setting a tooltip on config-remove in<BR>>these cases to at least give the chance of informing the user _why_ the<BR>>device can't be removed. but again not required)<BR></DIV>
<DIV>ok, I'll try to add them after these patches got merged.</DIV>
<DIV><BR>>Why inactive=True here though? If you drop it, it will use the current<BR>>state of the VM active or inactive which seems the best option</DIV>
<DIV><BR>Yes, dropping it is the best option, I'll do it.</DIV>
<DIV> </DIV>
<DIV>Thanks!</DIV>
<DIV>Lin</DIV></BODY></HTML>