Re: [libvirt] [PATCH 2/5] macvtap support for libvirt -- parse new interface XML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 08, 2010 at 12:33:02PM -0500, Stefan Berger wrote:
> "Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote on 02/08/2010 11:59:52 
> AM:
> 
> > 
> > Please respond to "Daniel P. Berrange"
> > 
> > On Thu, Feb 04, 2010 at 08:02:42AM -0500, Stefan Berger wrote:
> > > This part adds support to domain_conf.{c|h} for parsing the new
> > > interface XML of type 'direct'.
> > > 
> > > Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxx>
> > 
> > > Index: libvirt-macvtap/src/conf/domain_conf.c
> > > ===================================================================
> > > --- libvirt-macvtap.orig/src/conf/domain_conf.c
> > > +++ libvirt-macvtap/src/conf/domain_conf.c
> > > @@ -41,6 +41,7 @@
> > >  #include "c-ctype.h"
> > >  #include "logging.h"
> > >  #include "network.h"
> > > +#include "macvtap.h"
> > > 
> > >  #define VIR_FROM_THIS VIR_FROM_DOMAIN
> > > 
> > > @@ -140,7 +141,8 @@ VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_N
> > >                "mcast",
> > >                "network",
> > >                "bridge",
> > > -              "internal")
> > > +              "internal",
> > > +              "direct")
> > > 
> > >  VIR_ENUM_IMPL(virDomainChrTarget, VIR_DOMAIN_CHR_TARGET_TYPE_LAST,
> > >                "null",
> > > @@ -222,6 +224,12 @@ VIR_ENUM_IMPL(virDomainSeclabel, VIR_DOM
> > >                "dynamic",
> > >                "static")
> > > 
> > > +VIR_ENUM_IMPL(virDomainNetdevMacvtap, 
> VIR_DOMAIN_NETDEV_MACVTAP_MODE_LAST,
> > > +              MACVTAP_MODE_PRIVATE_STR,
> > > +              MACVTAP_MODE_VEPA_STR,
> > > +              MACVTAP_MODE_BRIDGE_STR)
> > 
> > These strings should really be included here directly - other areas
> > of the code should only ever see the parsed enum integer value, never
> > the string form which is for the XML only.
> 
> Ok. The reason why I did not use the returned 'int's is because the 
> translated value will be passed to the driver and linux/if_link.h 
> unfortunately defines those as follows:
> 
> enum macvlan_mode {
>         MACVLAN_MODE_PRIVATE = 1,
>         MACVLAN_MODE_VEPA    = 2,
>         MACVLAN_MODE_BRIDGE  = 4,
> };
> 
> Should I use those values in the array and fill the 0 and 3 with dummy 
> values or have another function that translates the ones returned by the 
> XYZTypeFromString() call in the actual 'enum macvlan_mode'?

It is best to avoid tieing libvirt's internal parsed enum value, directly
to the kernel's values. So yes, just map between the two values when
needed.

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]