libvirt/tools
Laine Stump def31e4c58 qemu: fix attach/detach of netdevs with matching mac addrs
This resolves:

   https://bugzilla.redhat.com/show_bug.cgi?id=862515

which describes inconsistencies in dealing with duplicate mac
addresses on network devices in a domain.

(at any rate, it resolves *almost* everything, and prints out an
informative error message for the one problem that isn't solved, but
has a workaround.)

A synopsis of the problems:

1) you can't do a persistent attach-interface of a device with a mac
address that matches an existing device.

2) you *can* do a live attach-interface of such a device.

3) you *can* directly edit a domain and put in two devices with
matching mac addresses.

4) When running virsh detach-device (live or config), only MAC address
is checked when matching the device to remove, so the first device
with the desired mac address will be removed. This isn't always the
one that's wanted.

5) when running virsh detach-interface (live or config), the only two
items that can be specified to match against are mac address and model
type (virtio, etc) - if multiple netdevs match both of those
attributes, it again just finds the first one added and assumes that
is the only match.

Since it is completely valid to have multiple network devices with the
same MAC address (although it can cause problems in many cases, there
*are* valid use cases), what is needed is:

1) remove the restriction that prohibits doing a persistent add of a
netdev with a duplicate mac address.

2) enhance the backend of virDomainDetachDeviceFlags to check for
something that *is* guaranteed unique (but still work with just mac
address, as long as it yields only a single results.

This patch does three things:

1) removes the check for duplicate mac address during a persistent
netdev attach.

2) unifies the searching for both live and config detach of netdevices
in the subordinate functions of qemuDomainModifyDeviceFlags() to use the
new function virDomainNetFindIdx (which matches mac address and PCI
address if available, checking for duplicates if only mac address was
specified). This function returns -2 if multiple matches are found,
allowing the callers to print out an appropriate message.

Steps 1 & 2 are enough to fully fix the problem when using virsh
attach-device and detach-device (which require an XML description of
the device rather than a bunch of commandline args)

3) modifies the virsh detach-interface command to check for multiple
matches of mac address and show an error message suggesting use of the
detach-device command in cases where there are multiple matching mac
addresses.

Later we should decide how we want to input a PCI address on the virsh
commandline, and enhance detach-interface to take a --address option,
eliminating the need to use detach-device

* src/conf/domain_conf.c
* src/conf/domain_conf.h
* src/libvirt_private.syms
  * added new virDomainNetFindIdx function
  * removed now unused virDomainNetIndexByMac and
    virDomainNetRemoveByMac

* src/qemu/qemu_driver.c
  * remove check for duplicate max from qemuDomainAttachDeviceConfig
  * use virDomainNetFindIdx/virDomainNetRemove instead
    of virDomainNetRemoveByMac in qemuDomainDetachDeviceConfig
  * use virDomainNetFindIdx instead of virDomainIndexByMac
    in qemuDomainUpdateDeviceConfig

* src/qemu/qemu_hotplug.c
  * use virDomainNetFindIdx instead of a homespun loop in
    qemuDomainDetachNetDevice.

* tools/virsh-domain.c: modified detach-interface command as described
    above
2012-10-26 20:47:54 -04:00
..
console.c maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
console.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
libvirt_win_icon_16x16.ico Move virsh into tools/ directory 2009-09-21 14:41:45 +01:00
libvirt_win_icon_32x32.ico Move virsh into tools/ directory 2009-09-21 14:41:45 +01:00
libvirt_win_icon_48x48.ico Move virsh into tools/ directory 2009-09-21 14:41:45 +01:00
libvirt_win_icon_64x64.ico Move virsh into tools/ directory 2009-09-21 14:41:45 +01:00
libvirt-guests.init.sh output status information during guest shutdown again 2012-08-21 15:52:26 -06:00
libvirt-guests.service.in output status information during guest shutdown again 2012-08-21 15:52:26 -06:00
libvirt-guests.sysconf libvirt-guests: Add parallel startup and shutdown of guests 2012-03-05 13:18:24 +01:00
Makefile.am build: fix syntax-check tab violation 2012-10-26 15:27:59 -06:00
virsh_win_icon.rc Move virsh into tools/ directory 2009-09-21 14:41:45 +01:00
virsh-domain-monitor.c maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-domain-monitor.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-domain.c qemu: fix attach/detach of netdevs with matching mac addrs 2012-10-26 20:47:54 -04:00
virsh-domain.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-edit.c maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-host.c virsh: Remove --flags from nodesuspend 2012-10-26 12:18:31 +02:00
virsh-host.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-interface.c maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-interface.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-network.c virsh: new net-update command 2012-09-20 22:20:22 -04:00
virsh-network.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-nodedev.c maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-nodedev.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-nwfilter.c maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-nwfilter.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-pool.c maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-pool.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-secret.c maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-secret.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-snapshot.c snapshot: improve snapshot-list error message 2012-10-25 16:48:08 -06:00
virsh-snapshot.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-volume.c maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh-volume.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh.c interface: add udev based backend for virInterface 2012-10-09 09:39:43 -06:00
virsh.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virsh.pod virsh: Fix POD syntax 2012-10-26 12:25:14 +02:00
virt-host-validate-common.c maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virt-host-validate-common.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virt-host-validate-lxc.c maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virt-host-validate-lxc.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virt-host-validate-qemu.c maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virt-host-validate-qemu.h maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virt-host-validate.c maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00
virt-pki-validate.in Fixup manpage names and copyright dates 2012-07-25 12:46:29 -04:00
virt-sanlock-cleanup.in Fix virt-sanlock-cleanup documentation 2011-10-17 10:57:36 -06:00
virt-xml-validate.in maint: fix up copyright notice inconsistencies 2012-09-20 16:30:55 -06:00