Description of problem: Cannot remove specific NIC from guest through virsh command. Version-Release number of selected component (if applicable): libvirt-0.9.10-21.el6_3.1.x86_64 How reproducible: 100% Steps to Reproduce: 1. Make sure there is a guest. 2. Click add hardware button. 3. Choose Network. 4. Choose specify shared device name for host device. 5. Fill virbr0 for bridge name(virbr0 should be there by default on rhel6). 6. Click Finish and remember the mac address. 7. Run #virsh detach-interface $guestname network --mac $macaddress 8. Try to remove this NIC through virt-manager. Actual results: 1. error: No found interface whose MAC address is $macaddress after step 7 2. Step 8 can work well. Expected results: 1. NIC could be removed normally in step 7 just like step 8. Additional info:
Created attachment 598366 [details] libvirtd's log file
you added a vNIC with type bridge, you should use command virsh detach-interface <domain> bridge --mac $macaddress rather than virsh detach-interface <domain> network --mac $macaddress I tried it, no such a problem, the virtual NIC could be detached successfully.
(In reply to comment #3) > you added a vNIC with type bridge, you should use command > > virsh detach-interface <domain> bridge --mac $macaddress > rather than > virsh detach-interface <domain> network --mac $macaddress > > I tried it, no such a problem, the virtual NIC could be detached > successfully. Why do we require the user to specify the network type? That seems strange, shouldn't we just require the MAC, and if more than one interface with that MAC exists, either error or remove them all?
Reopening to check if my suggestion in comment 4 is feasible. If not, please reclose.
(In reply to Dave Allan from comment #4) > (In reply to comment #3) > > you added a vNIC with type bridge, you should use command > > > > virsh detach-interface <domain> bridge --mac $macaddress > > rather than > > virsh detach-interface <domain> network --mac $macaddress > > > > I tried it, no such a problem, the virtual NIC could be detached > > successfully. > > Why do we require the user to specify the network type? That seems strange, > shouldn't we just require the MAC, and if more than one interface with that > MAC exists, either error or remove them all? Because 'virsh detach-interface' is trying to be user friendly. I mean, libvirt doesn't have any API such as detachInterface. Just detachDevice (any device) from guest which requires whole device XML to be passed in as input. So what detach-interface does, is take all the required info from user (in this case domain, network type and mac), constructs a minimal XML and calls detachDevice. The last two parameters are required by detachDevice - prior starting a detach job, the corresponding device needs to be found. So while detach-interface violates documented requirement and gives bad example to others, it works because we know what piece of device XML is really required. But this may change in the future which will leave us with broken detach-interface. Having said all of that, I see two possibilities of resolving this bug: 1) CLOSED NOTABUG 2) CLOSED as DUPLICATE of 616721 = my normalization API bug. The reason for going with 1) is the report isn't using the virsh command properly. The reason for going with 2) is, after my normalization API patches are merged, we can do detach-interface much more wisely: 1) dump domain XML 2) search for the corresponding device in the domain XML based on the minimum info provided by user, e.g. if there's a single NIC in the domain, user should really just be able to 'virsh detach-interface $dom' as it is clear which interface does he want to detach 3) use the device XML from domain XML not the minimalistic one virsh has produced. Since I think virsh has a lot of catching to do in field of user friendliness, I am going with 2). *** This bug has been marked as a duplicate of bug 616721 ***