Bug 840344 - Cannot remove specific NIC from guest through virsh command.
Summary: Cannot remove specific NIC from guest through virsh command.
Keywords:
Status: CLOSED DUPLICATE of bug 616721
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Michal Privoznik
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-07-16 03:28 UTC by Geyang Kong
Modified: 2014-07-06 19:31 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-10-16 08:48:59 UTC
Embargoed:


Attachments (Terms of Use)
libvirtd's log file (745.92 KB, application/zip)
2012-07-16 03:30 UTC, Geyang Kong
no flags Details

Description Geyang Kong 2012-07-16 03:28:31 UTC
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:

Comment 1 Geyang Kong 2012-07-16 03:30:28 UTC
Created attachment 598366 [details]
libvirtd's log file

Comment 3 Gunannan Ren 2012-07-19 04:08:19 UTC
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.

Comment 4 Dave Allan 2012-07-19 16:43:32 UTC
(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?

Comment 5 Dave Allan 2012-07-20 13:57:26 UTC
Reopening to check if my suggestion in comment 4 is feasible.  If not, please reclose.

Comment 7 Michal Privoznik 2013-10-16 08:48:59 UTC
(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 ***


Note You need to log in before you can comment on or make changes to this bug.