[libvirt-users] [libvirt] Why virsh domxml-to-native qemu-argv changes PCI slot number

Daniel P. Berrangé berrange at redhat.com
Thu Apr 18 15:45:24 UTC 2019


On Thu, Apr 18, 2019 at 05:39:59PM +0200, Andrea Bolognani wrote:
> On Thu, 2019-04-18 at 15:29 +0100, Daniel P. Berrangé wrote:
> > On Thu, Apr 18, 2019 at 04:23:05PM +0200, Andrea Bolognani wrote:
> > > qemuDomainAssignAddresses() is supposed to make sure that any address
> > > configured explicitly by the user (or previously by libvirt) is
> > > preserved, and it's doing that correctly when it's called from inside
> > > qemuDomainDefAssignAddresses(); however, for some reason, by the time
> > > we call it again in qemuProcessPrepareDomain() the PCI address for
> > > the network interface is no longer set, and so a fresh one gets
> > > assigned instead.
> > > 
> > > I'll investigate further and get back to you.
> > 
> > It is a bug in qemuConnectDomainXMLToNative. You'll see we replace
> > the original type=bridge NIC with a type=ethernet, except we fail
> > to copy the address info & probably other properties too.
> 
> Yeah, I figured that out after digging a bit more :)
> 
> I'm not quite sure how to fix it properly, though. Adding yet more
> properties to the list of those we record before calling
> virDomainNetDefClear() and restore afterwards would be a stop-gap
> measure at best; limiting ourselves to merely changing net->type,
> on the other hand, though it seems to work from a quick test, will
> likely lead to hitting other corner cases.
> 
> Formatting the XML, replacing the type attribute and parsing it
> back perhaps? Other, hopefully better, ideas?

I think the problem is that we tried to use a whitelkist approach
to change the net backend. We should reverse it to use a blacklist
approach and thus not call virDomainNetDefClear at all.

We only need to be doing this munging for the bridge/network/direct/hostdev
network types, but we were lazy and cleared out all types. eg if someone
had requests slirp we should have honoured it.

So we should just selectively replace bits we dont want, leaving everything
else intact.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvirt-users mailing list