qemu: Use the correct vm def on cold attach
qemu: Use the correct vm def on cold attach

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

When attaching a device to the domain we need to be sure
to use the correct domain definition (vm->def or vm->newDef)
when calling virDomainDeviceDefParse because the post parse
processing algorithms that may assign an address for the
device will use whatever domain definition was passed in.

Additionally, some devices (SCSI hostdev and SCSI disk) use
algorithms that rely on knowing what already exists of the
other type when generating the new device's address. Using
the wrong VM definition could result in duplicated addresses.

In the case of the bz, two hostdev's with no domain address
provided were added to the running domain's config only.
However, the parsing algorithm used the live domain in
order to figure out the host device address resulting in
the same address being used and a subsequent start failing
due to duplicate address.

Fix this by separating the checks/code into CONFIG and LIVE
processing using the correct definition for each block and
performing cleanup for both options as necessary.

Signed-off-by: John Ferlan <87558058f6f829e5ec976c8ef960720af4ff9c7d@redhat.com>
ACKed-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>

nertpinx/libvirt,zippy2/libvirt,jardasgit/libvirt,libvirt/libvirt,crobinso/libvirt,andreabolognani/libvirt,nertpinx/libvirt,fabianfreyer/libvirt,nertpinx/libvirt,libvirt/libvirt,nertpinx/libvirt,eskultety/libvirt,jfehlig/libvirt,nertpinx/libvirt,crobinso/libvirt,olafhering/libvirt,andreabolognani/libvirt,andreabolognani/libvirt,andreabolognani/libvirt,fabianfreyer/libvirt,libvirt/libvirt,libvirt/libvirt,crobinso/libvirt,fabianfreyer/libvirt,olafhering/libvirt,jfehlig/libvirt,zippy2/libvirt,eskultety/libvirt,crobinso/libvirt,fabianfreyer/libvirt,eskultety/libvirt,olafhering/libvirt,zippy2/libvirt,andreabolognani/libvirt,jfehlig/libvirt,jardasgit/libvirt,eskultety/libvirt,zippy2/libvirt,jardasgit/libvirt,jardasgit/libvirt,jfehlig/libvirt,olafhering/libvirt,eskultety/libvirt,jardasgit/libvirt,fabianfreyer/libvirt