[libvirt PATCH 08/12] conf: add backupAlias attribute to <interface> driver subelement

Daniel P. Berrangé berrange at redhat.com
Tue Jan 21 15:25:07 UTC 2020


On Sun, Jan 19, 2020 at 10:24:15PM -0500, Laine Stump wrote:
> For <interface type='hostdev'> the <driver> subelement (including the
> backupAlias attribute) is parsed directly into the hostdev child
> object (virDomaniHostdevDef) of the interface (using
> virDomainHostdevDefParseXMLSubsys()).  But for <interface
> type='network'> where the network is a pool of hostdevs, the hostdev
> object doesn't exist until the network port is allocated at runtime,
> and so virDomainHostdevDefParseXMLSubsys() can't be called during XML
> parsing, and any backupAlias in the driver subelement of the XML will
> be lost.

I'm thinking this is a sign that we're storing the data in the
wrong way / structure internally, and possibly with the XML
schema too. Overall I'm not a fan of having the data scattered
across three different structs for different scenarios....
 
> For this case, we need to add a backupAlias member to the interface
> object (virDomainNetDef), and parse it during the <driver> parsing
> that happens for all non-hostdev interfaces. Then when the network
> port is allocated at runtime and the hostdev child object is created,
> we can copy the backupAlias into the hostdev so it is available when
> building the QEMU commandline.
> 
> An example usage:
> 
>   <interface type='network'>
>     <source network='mybridge'/>
>     <mac address='00:11:22:33:44:55'/>
>     <model type='virtio'/>
>     <alias name='ua-backup0'/>
>     <driver failover='on'/>
>   </interface>
>   <interface type='network'>
>     <source network='hostdev-pool'/>
>     <mac address='00:11:22:33:44:55'/>
>     <model type='virtio'/>
>     <driver backupAlias='ua-backup0'/>
>   </interface>

I get that a big part of the problem is that the <driver> element
is parsed by different bits of code depending on the type of
interface being use, so it is hard to get consistent handling
of this.

We could perhaps better deal with this by not using <driver> at all
and instead have a new <failover> element we store in virDomainNetDef
separately from the driver struct that's causing us trouble.

eg

   <interface type='network'>
     <source network='mybridge'/>
     <mac address='00:11:22:33:44:55'/>
     <model type='virtio'/>
     <alias name='ua-backup0'/>
     <failover type="primary"/>
   </interface>
   <interface type='network'>
     <source network='hostdev-pool'/>
     <mac address='00:11:22:33:44:55'/>
     <model type='virtio'/>
     <failover type="secondary" primary="ua-backup0"/>
   </interface>


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 libvir-list mailing list