qemu_hotplug.c: add net devices to the domain list earlier
qemu_hotplug.c: add net devices to the domain list earlier

An upcoming patch will be checking if the addition of a new net device
requires adjusting the domain locked memory limit, which must be done
prior to sending the command to qemu to add the new device. But
qemuDomainAdjustMaxMemLock() checks all (and only) the devices that
are currently in the domain definition, and currently we are adding
new net devices to the domain definition only at the very end of the
hotplug operation, after qemu has already executed the device_add
command.

In order for the upcoming patch to work, this patch changes
qemuDomainAttachNetDevice() to add the device to the domain nets list
at an earlier time. It can't be added until after PCI address and
alias name have been determined (because both of those examine
existing devices in the domain to figure out a unique value for the
new device), but must be done before making the qemu monitor call.

Since the device has been added to the list earlier, we need to
potentially remove it on failure. This is done by replacing the
existing call to virDomainNetRemoveHostdev() (which checks if this is
a hostdev net device, and if so removes it from the hostdevs list,
since it could have already been added to that list) with a call to
the new virDomainNetRemoveByObj(), which looks for the device on both
nets and hostdevs lists, and removes it where it finds it.

Signed-off-by: Laine Stump <c23361c43fbf79fed83e8b76173707b083d6caf5@redhat.com>
Reviewed-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>

libvirt/libvirt,nertpinx/libvirt,nertpinx/libvirt,jfehlig/libvirt,nertpinx/libvirt,crobinso/libvirt,nertpinx/libvirt,zippy2/libvirt,olafhering/libvirt,libvirt/libvirt,olafhering/libvirt,zippy2/libvirt,crobinso/libvirt,crobinso/libvirt,nertpinx/libvirt,crobinso/libvirt,jfehlig/libvirt,olafhering/libvirt,libvirt/libvirt,jfehlig/libvirt,olafhering/libvirt,zippy2/libvirt,jfehlig/libvirt,zippy2/libvirt,libvirt/libvirt