[netcf-devel] [PATCH] Reorganize code to making porting to other platforms easier

Laine Stump laine at laine.org
Wed Nov 17 17:59:46 UTC 2010


I just pushed this patch. You should now be able to create a new netcf 
port starting with the following source files:

netcf.[ch]
ncftool.c
dutil.[ch]
xslt_ext.c
internal.h
list.h
ref.h

and adding your own drv_xxx.c file that defines all the drv_*() 
functions that are prototyped in internal.h. (note that other ports 
needn't build ncftransform.c, since it's only useful as a test utility 
for the initscripts port.)

Most likely other portability problems will pop up. Let me know if 
anything in these files doesn't build without change on another 
platform, or if you see something in an inappropriate place.


On 11/16/2010 03:52 PM, Laine Stump wrote:
> netcf has always been intended to be ported to other platforms, but
> was originally only targetted to Fedora/RHEL (which both use the
> identical drv_initscripts.c driver). During development, there was a
> bit of mixing of platform-specific code with code that should be able
> to work / be useful on all netcf-supported platforms.
>
> This patch attempts to remedy that problem by moving around some
> functions, prototypes, and data definitions to better separate
> platform-specific things from platform-independent. Hopefully that
> will make upcoming ports to other platforms less painful.
>
> Note that there is still work to do, since this has only separated
> linux/initscripts functions from platform-independent. In the future
> when there is a port to a linux distro that doesn't use
> drv_initscripts.c some more refinement will need to take place.
>
> "make check" ran successfully after all the changes, and both ncftool
> and virsh iface-* appearred to continue working successfully.
>
> Note that almost all changes involved moving entire
> functions/prototypes/structures from one file to another. The few
> exceptions are noted below.
>
> Data structure changes:
>
> The only data structure change was to move the "rng" pointer from the
> driver object up one level into the netcf object (because this should
> be useful on all platforms).
>
> Functions moved into dutil.c:
>
>    free_netcf()
>    free_netcf_if()
>    argv_to_string()
>    report_error()
>    vreport_error()
>    xml_node()
>    xml_new_node()
>
> These functions were deemed probably buildable, and potentially usable
> on any platform, so they were moved into dutil.c, which should be
> included in any build on any platform.
>
> netlink/ioctl/exec/augeas related functions - These were all moved
> into dutil_linux.c
>
> dutil_get_aug/dutil_put_aug - since these functions (in dutil.c) were
> called only once (from functions in drv_initscripts.c), their bodies
> were moved into the calling functions.
>
> Related to that, ncf_get_aug and ncf_put_aug, which are exported from
> the library, but considered private (they are in netcf_private.syms)
> have been moved from netcf.c to drv_initscripts.c. This should allow
> netcf.c to build unmodified on all platforms. To make this work, the
> API_ENTRY() macro, used by those two functions, has been moved from
> netcf.c to internal.h.
>
> All other changes are collateral #include changes.
>
> One outstanding item - the prototypes for ncf_get_aug() and
> ncf_put_aug() are still located in internal.h (which should be
> platform-independent) even though they are only applicable to the
> initscripts version of netcf. I left these in place because there is
> currently no separate drv_initscripts.h file, and I didn't want to
> create one just for this purpose.
> ---
>   src/drv_initscripts.c |   58 +++-
>   src/dutil.c           |  931 ++++--------------------------------------------
>   src/dutil.h           |  111 ++-----
>   src/dutil_linux.c     |  948 +++++++++++++++++++++++++++++++++++++++++++++++++
>   src/dutil_linux.h     |   80 ++++-
>   src/internal.h        |   45 +--
>   src/netcf.c           |  244 +------------
>   src/xslt_ext.c        |    1 +
>   8 files changed, 1210 insertions(+), 1208 deletions(-)
> |



More information about the netcf-devel mailing list