On Fri, Nov 11, 2011 at 08:27:48PM +0100, Marc-André Lureau wrote:
On Thu, Nov 10, 2011 at 9:34 PM, Christophe Fergeau
<cfergeau(a)redhat.com> wrote:
> Make GVirConfigInterface an abstract base class, and move the
> actual code in subclasses. This will make handling of the various
> types of network interfaces more understandable and more logical
> with respect to the corresponding XML.
I am not really convince about this approach, it breaks a bit the
mapping between objects and node. I will let someone else with more
familiarity with the XML to discuss this patch. Otherwise it works as
expected.
The various network interfaces XML descriptions have so many peculiarities
that I think it's the only sane way to handle this.
The documentation is at
http://libvirt.org/formatdomain.html#elementsNICS ,
and as I read it it's really
"if the interface type is XXX, you can have a <target> node with this format,
a <mac> node, a <virtualport> node, if it's YYY then the <target>
node as
this different format, and there is this <script> node that can be used,
and with type ZZZ you only have a <source> node"
If we try to handle all of this in a single class, it will be really easy
to generate non-sensical configs, and with no obvious way from the API to
guess what makes sense or not. Having separate classes make it much easier
to show which operations are useful/meaningful on what type of interface.
Christophe