From 1355e0552e6212be1d6c7f62ada236b0446cff92 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 16 Sep 2009 16:28:46 +0100 Subject: [PATCH] Move all shared utility files to src/util/ * src/bridge.c, src/bridge.h, src/buf.c, src/buf.h, src/cgroup.c, src/cgroup.h, src/conf.c, src/conf.h, src/event.c, src/event.h, src/hash.c, src/hash.h, src/hostusb.c, src/hostusb.h, src/iptables.c, src/iptables.h, src/logging.c, src/logging.h, src/memory.c, src/memory.h, src/pci.c, src/pci.h, src/qparams.c, src/qparams.h, src/stats_linux.c, src/stats_linux.h, src/threads-pthread.c, src/threads-pthread.h, src/threads-win32.c, src/threads-win32.h, src/threads.c, src/threads.h, src/util.c, src/util.h, src/uuid.c, src/uuid.h, src/virterror.c, src/virterror_internal.h, src/xml.c, src/xml.h: Move all files into src/util/ * daemon/Makefile.am: Add -Isrc/util/ to build flags * src/Makefile.am: Add -Isrc/util/ to build flags and update for moved files * src/libvirt_private.syms: Export cgroup APIs since they're now in util rather than linking directly to drivers * src/xen/xs_internal.c: Disable bogus virEventRemoveHandle call when built under PROXY * proxy/Makefile.am: Update for changed file locations. Remove bogus build of event.c * tools/Makefile.am, tests/Makefile.am: Add -Isrc/util/ to build flags --- daemon/Makefile.am | 1 + docs/Makefile.am | 2 +- docs/apibuild.py | 4 +- proxy/Makefile.am | 23 ++++++----- src/Makefile.am | 59 +++++++++++++++-------------- src/libvirt_private.syms | 17 +++++++++ src/{ => util}/bridge.c | 0 src/{ => util}/bridge.h | 0 src/{ => util}/buf.c | 0 src/{ => util}/buf.h | 0 src/{ => util}/cgroup.c | 0 src/{ => util}/cgroup.h | 0 src/{ => util}/conf.c | 0 src/{ => util}/conf.h | 0 src/{ => util}/event.c | 0 src/{ => util}/event.h | 0 src/{ => util}/hash.c | 0 src/{ => util}/hash.h | 0 src/{ => util}/hostusb.c | 0 src/{ => util}/hostusb.h | 0 src/{ => util}/iptables.c | 0 src/{ => util}/iptables.h | 0 src/{ => util}/logging.c | 0 src/{ => util}/logging.h | 0 src/{ => util}/memory.c | 0 src/{ => util}/memory.h | 0 src/{ => util}/pci.c | 0 src/{ => util}/pci.h | 0 src/{ => util}/qparams.c | 0 src/{ => util}/qparams.h | 0 src/{ => util}/stats_linux.c | 0 src/{ => util}/stats_linux.h | 0 src/{ => util}/threads-pthread.c | 0 src/{ => util}/threads-pthread.h | 0 src/{ => util}/threads-win32.c | 0 src/{ => util}/threads-win32.h | 0 src/{ => util}/threads.c | 0 src/{ => util}/threads.h | 0 src/{ => util}/util.c | 0 src/{ => util}/util.h | 0 src/{ => util}/uuid.c | 0 src/{ => util}/uuid.h | 0 src/{ => util}/virterror.c | 0 src/{ => util}/virterror_internal.h | 0 src/{ => util}/xml.c | 0 src/{ => util}/xml.h | 0 src/xen/xs_internal.c | 2 + tests/Makefile.am | 1 + tools/Makefile.am | 3 +- 49 files changed, 69 insertions(+), 43 deletions(-) rename src/{ => util}/bridge.c (100%) rename src/{ => util}/bridge.h (100%) rename src/{ => util}/buf.c (100%) rename src/{ => util}/buf.h (100%) rename src/{ => util}/cgroup.c (100%) rename src/{ => util}/cgroup.h (100%) rename src/{ => util}/conf.c (100%) rename src/{ => util}/conf.h (100%) rename src/{ => util}/event.c (100%) rename src/{ => util}/event.h (100%) rename src/{ => util}/hash.c (100%) rename src/{ => util}/hash.h (100%) rename src/{ => util}/hostusb.c (100%) rename src/{ => util}/hostusb.h (100%) rename src/{ => util}/iptables.c (100%) rename src/{ => util}/iptables.h (100%) rename src/{ => util}/logging.c (100%) rename src/{ => util}/logging.h (100%) rename src/{ => util}/memory.c (100%) rename src/{ => util}/memory.h (100%) rename src/{ => util}/pci.c (100%) rename src/{ => util}/pci.h (100%) rename src/{ => util}/qparams.c (100%) rename src/{ => util}/qparams.h (100%) rename src/{ => util}/stats_linux.c (100%) rename src/{ => util}/stats_linux.h (100%) rename src/{ => util}/threads-pthread.c (100%) rename src/{ => util}/threads-pthread.h (100%) rename src/{ => util}/threads-win32.c (100%) rename src/{ => util}/threads-win32.h (100%) rename src/{ => util}/threads.c (100%) rename src/{ => util}/threads.h (100%) rename src/{ => util}/util.c (100%) rename src/{ => util}/util.h (100%) rename src/{ => util}/uuid.c (100%) rename src/{ => util}/uuid.h (100%) rename src/{ => util}/virterror.c (100%) rename src/{ => util}/virterror_internal.h (100%) rename src/{ => util}/xml.c (100%) rename src/{ => util}/xml.h (100%) diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 75f9c193a0..2938e6c070 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -84,6 +84,7 @@ libvirtd_CFLAGS = \ -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \ -I$(top_srcdir)/include -I$(top_builddir)/include \ -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/util \ -I$(top_srcdir)/src/conf \ $(LIBXML_CFLAGS) $(GNUTLS_CFLAGS) $(SASL_CFLAGS) \ $(POLKIT_CFLAGS) \ diff --git a/docs/Makefile.am b/docs/Makefile.am index 4cd11b005d..4077823923 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -109,7 +109,7 @@ $(srcdir)/html/index.html: libvirt-api.xml newapi.xsl page.xsl sitemap.html.in libvirt-api.xml libvirt-refs.xml: apibuild.py \ $(srcdir)/../include/libvirt/*.h \ - $(srcdir)/../src/*.h $(srcdir)/../src/*.c + $(srcdir)/../src/libvirt.c $(srcdir)/../src/util/virterror.c -(./apibuild.py) $(top_builddir)/NEWS: $(top_srcdir)/docs/news.xsl $(top_srcdir)/docs/news.html.in diff --git a/docs/apibuild.py b/docs/apibuild.py index 84bc1ac3bf..855569b5b1 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -2089,11 +2089,11 @@ def rebuild(): builder = None if glob.glob("../src/libvirt.c") != [] : print "Rebuilding API description for libvirt" - builder = docBuilder("libvirt", ["../src", "../include/libvirt"], + builder = docBuilder("libvirt", ["../src", "../src/util", "../include/libvirt"], []) elif glob.glob("src/libvirt.c") != [] : print "Rebuilding API description for libvir" - builder = docBuilder("libvirt", ["src", "include/libvirt"], + builder = docBuilder("libvirt", ["src", "src/util", "include/libvirt"], []) else: print "rebuild() failed, unable to guess the module" diff --git a/proxy/Makefile.am b/proxy/Makefile.am index bd6a0c8b84..3e0050b7b0 100644 --- a/proxy/Makefile.am +++ b/proxy/Makefile.am @@ -4,6 +4,7 @@ if WITH_PROXY INCLUDES = -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \ -I$(top_builddir)/include -I@top_srcdir@/include \ -I@top_srcdir@/proxy -I@top_srcdir@/src \ + -I@top_srcdir@/src/util \ -I@top_srcdir@/src/conf \ -I@top_srcdir@/src/xen \ @LIBXML_CFLAGS@ \ @@ -12,19 +13,21 @@ INCLUDES = -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \ libexec_PROGRAMS = libvirt_proxy -libvirt_proxy_SOURCES = libvirt_proxy.c @top_srcdir@/src/xen/xend_internal.c \ - @top_srcdir@/src/xen/xen_hypervisor.c @top_srcdir@/src/virterror.c \ - @top_srcdir@/src/xen/sexpr.c \ - @top_srcdir@/src/threads.c \ - @top_srcdir@/src/xen/xs_internal.c @top_srcdir@/src/buf.c \ +libvirt_proxy_SOURCES = libvirt_proxy.c \ + @top_srcdir@/src/util/buf.c \ + @top_srcdir@/src/util/logging.c \ + @top_srcdir@/src/util/memory.c \ + @top_srcdir@/src/util/threads.c \ + @top_srcdir@/src/util/util.c \ + @top_srcdir@/src/util/uuid.c \ + @top_srcdir@/src/util/virterror.c \ @top_srcdir@/src/conf/capabilities.c \ - @top_srcdir@/src/memory.c \ @top_srcdir@/src/conf/storage_encryption_conf.c \ @top_srcdir@/src/conf/domain_conf.c \ - @top_srcdir@/src/util.c \ - @top_srcdir@/src/event.c \ - @top_srcdir@/src/uuid.c \ - @top_srcdir@/src/logging.c + @top_srcdir@/src/xen/xend_internal.c \ + @top_srcdir@/src/xen/xen_hypervisor.c \ + @top_srcdir@/src/xen/sexpr.c \ + @top_srcdir@/src/xen/xs_internal.c libvirt_proxy_LDFLAGS = $(WARN_CFLAGS) $(XEN_LIBS) libvirt_proxy_DEPENDENCIES = libvirt_proxy_LDADD = ../gnulib/lib/libgnu.la diff --git a/src/Makefile.am b/src/Makefile.am index 113ffe3174..f5534d7a47 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,6 +7,7 @@ INCLUDES = \ -I$(top_srcdir)/gnulib/lib \ -I../gnulib/lib \ -I../include \ + -I@top_srcdir@/src/util \ -I@top_srcdir@/include \ $(DRIVER_MODULE_CFLAGS) \ $(LIBXML_CFLAGS) \ @@ -35,26 +36,28 @@ mod_LTLIBRARIES = # These files are not related to driver APIs. Simply generic # helper APIs for various purposes UTIL_SOURCES = \ - bridge.c bridge.h \ - buf.c buf.h \ - conf.c conf.h \ - event.c event.h \ - hash.c hash.h \ - iptables.c iptables.h \ - logging.c logging.h \ - memory.c memory.h \ - pci.c pci.h \ - hostusb.c hostusb.h \ - qparams.c qparams.h \ - threads.c threads.h \ - threads-pthread.h \ - threads-win32.h \ - uuid.c uuid.h \ - util.c util.h \ - virterror.c virterror_internal.h \ - xml.c xml.h - -EXTRA_DIST += threads-pthread.c threads-win32.c + util/bridge.c util/bridge.h \ + util/buf.c util/buf.h \ + util/conf.c util/conf.h \ + util/cgroup.c util/cgroup.h \ + util/event.c util/event.h \ + util/hash.c util/hash.h \ + util/iptables.c util/iptables.h \ + util/logging.c util/logging.h \ + util/memory.c util/memory.h \ + util/pci.c util/pci.h \ + util/hostusb.c util/hostusb.h \ + util/qparams.c util/qparams.h \ + util/stats_linux.c util/stats_linux.h \ + util/threads.c util/threads.h \ + util/threads-pthread.h \ + util/threads-win32.h \ + util/uuid.c util/uuid.h \ + util/util.c util/util.h \ + util/xml.c util/xml.h \ + util/virterror.c util/virterror_internal.h + +EXTRA_DIST += util/threads-pthread.c util/threads-win32.c # Internal generic driver infrastructure NODE_INFO_SOURCES = nodeinfo.h nodeinfo.c @@ -62,7 +65,6 @@ DRIVER_SOURCES = \ driver.c driver.h \ internal.h \ datatypes.c datatypes.h \ - stats_linux.c stats_linux.h \ $(NODE_INFO_SOURCES) \ libvirt.c libvirt_internal.h @@ -140,15 +142,13 @@ LXC_DRIVER_SOURCES = \ lxc/lxc_conf.c lxc/lxc_conf.h \ lxc/lxc_container.c lxc/lxc_container.h \ lxc/lxc_driver.c lxc/lxc_driver.h \ - lxc/veth.c lxc/veth.h \ - cgroup.c cgroup.h + lxc/veth.c lxc/veth.h LXC_CONTROLLER_SOURCES = \ lxc/lxc_conf.c lxc/lxc_conf.h \ lxc/lxc_container.c lxc/lxc_container.h \ lxc/lxc_controller.c \ - lxc/veth.c lxc/veth.h \ - cgroup.c cgroup.h + lxc/veth.c lxc/veth.h PHYP_DRIVER_SOURCES = \ phyp/phyp_driver.c phyp/phyp_driver.h @@ -166,9 +166,8 @@ VBOX_DRIVER_SOURCES = \ VBOX_DRIVER_EXTRA_DIST = vbox/vbox_tmpl.c vbox/README QEMU_DRIVER_SOURCES = \ - qemu/qemu_conf.c qemu/qemu_conf.h \ - qemu/qemu_driver.c qemu/qemu_driver.h \ - cgroup.c cgroup.h + qemu/qemu_conf.c qemu/qemu_conf.h \ + qemu/qemu_driver.c qemu/qemu_driver.h UML_DRIVER_SOURCES = \ uml/uml_conf.c uml/uml_conf.h \ @@ -533,6 +532,7 @@ endif libvirt_driver_storage_la_SOURCES = libvirt_driver_storage_la_CFLAGS = \ -I@top_srcdir@/src/conf +libvirt_driver_storage_la_LDFLAGS = if WITH_STORAGE_DIR if WITH_DRIVER_MODULES mod_LTLIBRARIES += libvirt_driver_storage.la @@ -542,7 +542,7 @@ noinst_LTLIBRARIES += libvirt_driver_storage.la #libvirt_la_LIBADD += libvirt_driver_storage.la endif if WITH_DRIVER_MODULES -libvirt_driver_storage_la_LDFLAGS = -module -avoid-version +libvirt_driver_storage_la_LDFLAGS += -module -avoid-version endif libvirt_driver_storage_la_SOURCES += $(STORAGE_DRIVER_SOURCES) libvirt_driver_storage_la_SOURCES += $(STORAGE_DRIVER_FS_SOURCES) @@ -563,6 +563,7 @@ endif if WITH_STORAGE_MPATH libvirt_driver_storage_la_SOURCES += $(STORAGE_DRIVER_MPATH_SOURCES) libvirt_driver_storage_la_CFLAGS += $(DEVMAPPER_CFLAGS) +libvirt_driver_storage_la_LDFLAGS += $(DEVMAPPER_LIBS) endif if WITH_STORAGE_DISK diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 867678fa34..a2646a33d7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -47,6 +47,23 @@ virConfWriteFile; virConfWriteMem; +# cgroup.h +virCgroupForDomain; +virCgroupForDriver; +virCgroupRemove; +virCgroupFree; +virCgroupAddTask; +virCgroupSetCpuShares; +virCgroupGetCpuShares; +virCgroupDenyDevicePath; +virCgroupAllowDevicePath; +virCgroupDenyAllDevices; +virCgroupAllowDeviceMajor; +virCgroupControllerTypeToString; +virCgroupControllerTypeFromString; +virCgroupGetCpuacctUsage; + + # datatypes.h virGetDomain; virGetInterface; diff --git a/src/bridge.c b/src/util/bridge.c similarity index 100% rename from src/bridge.c rename to src/util/bridge.c diff --git a/src/bridge.h b/src/util/bridge.h similarity index 100% rename from src/bridge.h rename to src/util/bridge.h diff --git a/src/buf.c b/src/util/buf.c similarity index 100% rename from src/buf.c rename to src/util/buf.c diff --git a/src/buf.h b/src/util/buf.h similarity index 100% rename from src/buf.h rename to src/util/buf.h diff --git a/src/cgroup.c b/src/util/cgroup.c similarity index 100% rename from src/cgroup.c rename to src/util/cgroup.c diff --git a/src/cgroup.h b/src/util/cgroup.h similarity index 100% rename from src/cgroup.h rename to src/util/cgroup.h diff --git a/src/conf.c b/src/util/conf.c similarity index 100% rename from src/conf.c rename to src/util/conf.c diff --git a/src/conf.h b/src/util/conf.h similarity index 100% rename from src/conf.h rename to src/util/conf.h diff --git a/src/event.c b/src/util/event.c similarity index 100% rename from src/event.c rename to src/util/event.c diff --git a/src/event.h b/src/util/event.h similarity index 100% rename from src/event.h rename to src/util/event.h diff --git a/src/hash.c b/src/util/hash.c similarity index 100% rename from src/hash.c rename to src/util/hash.c diff --git a/src/hash.h b/src/util/hash.h similarity index 100% rename from src/hash.h rename to src/util/hash.h diff --git a/src/hostusb.c b/src/util/hostusb.c similarity index 100% rename from src/hostusb.c rename to src/util/hostusb.c diff --git a/src/hostusb.h b/src/util/hostusb.h similarity index 100% rename from src/hostusb.h rename to src/util/hostusb.h diff --git a/src/iptables.c b/src/util/iptables.c similarity index 100% rename from src/iptables.c rename to src/util/iptables.c diff --git a/src/iptables.h b/src/util/iptables.h similarity index 100% rename from src/iptables.h rename to src/util/iptables.h diff --git a/src/logging.c b/src/util/logging.c similarity index 100% rename from src/logging.c rename to src/util/logging.c diff --git a/src/logging.h b/src/util/logging.h similarity index 100% rename from src/logging.h rename to src/util/logging.h diff --git a/src/memory.c b/src/util/memory.c similarity index 100% rename from src/memory.c rename to src/util/memory.c diff --git a/src/memory.h b/src/util/memory.h similarity index 100% rename from src/memory.h rename to src/util/memory.h diff --git a/src/pci.c b/src/util/pci.c similarity index 100% rename from src/pci.c rename to src/util/pci.c diff --git a/src/pci.h b/src/util/pci.h similarity index 100% rename from src/pci.h rename to src/util/pci.h diff --git a/src/qparams.c b/src/util/qparams.c similarity index 100% rename from src/qparams.c rename to src/util/qparams.c diff --git a/src/qparams.h b/src/util/qparams.h similarity index 100% rename from src/qparams.h rename to src/util/qparams.h diff --git a/src/stats_linux.c b/src/util/stats_linux.c similarity index 100% rename from src/stats_linux.c rename to src/util/stats_linux.c diff --git a/src/stats_linux.h b/src/util/stats_linux.h similarity index 100% rename from src/stats_linux.h rename to src/util/stats_linux.h diff --git a/src/threads-pthread.c b/src/util/threads-pthread.c similarity index 100% rename from src/threads-pthread.c rename to src/util/threads-pthread.c diff --git a/src/threads-pthread.h b/src/util/threads-pthread.h similarity index 100% rename from src/threads-pthread.h rename to src/util/threads-pthread.h diff --git a/src/threads-win32.c b/src/util/threads-win32.c similarity index 100% rename from src/threads-win32.c rename to src/util/threads-win32.c diff --git a/src/threads-win32.h b/src/util/threads-win32.h similarity index 100% rename from src/threads-win32.h rename to src/util/threads-win32.h diff --git a/src/threads.c b/src/util/threads.c similarity index 100% rename from src/threads.c rename to src/util/threads.c diff --git a/src/threads.h b/src/util/threads.h similarity index 100% rename from src/threads.h rename to src/util/threads.h diff --git a/src/util.c b/src/util/util.c similarity index 100% rename from src/util.c rename to src/util/util.c diff --git a/src/util.h b/src/util/util.h similarity index 100% rename from src/util.h rename to src/util/util.h diff --git a/src/uuid.c b/src/util/uuid.c similarity index 100% rename from src/uuid.c rename to src/util/uuid.c diff --git a/src/uuid.h b/src/util/uuid.h similarity index 100% rename from src/uuid.h rename to src/util/uuid.h diff --git a/src/virterror.c b/src/util/virterror.c similarity index 100% rename from src/virterror.c rename to src/util/virterror.c diff --git a/src/virterror_internal.h b/src/util/virterror_internal.h similarity index 100% rename from src/virterror_internal.h rename to src/util/virterror_internal.h diff --git a/src/xml.c b/src/util/xml.c similarity index 100% rename from src/xml.c rename to src/util/xml.c diff --git a/src/xml.h b/src/util/xml.h similarity index 100% rename from src/xml.h rename to src/util/xml.h diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c index 494728d639..54f410f29c 100644 --- a/src/xen/xs_internal.c +++ b/src/xen/xs_internal.c @@ -388,8 +388,10 @@ xenStoreClose(virConnectPtr conn) if (priv->xshandle == NULL) return(-1); +#ifndef PROXY if (priv->xsWatch != -1) virEventRemoveHandle(priv->xsWatch); +#endif xs_daemon_close(priv->xshandle); priv->xshandle = NULL; diff --git a/tests/Makefile.am b/tests/Makefile.am index 26b8c1f92d..cc16671725 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -10,6 +10,7 @@ INCLUDES = \ -I$(top_builddir)/include \ -I$(top_srcdir)/include \ -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/util \ -I$(top_srcdir)/src/conf \ $(LIBXML_CFLAGS) \ $(GNUTLS_CFLAGS) \ diff --git a/tools/Makefile.am b/tools/Makefile.am index 81698a4b30..c48b203e52 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -44,7 +44,8 @@ virsh_LDADD = \ virsh_CFLAGS = \ -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \ -I../include \ - -I../src \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/util \ -DGETTEXT_PACKAGE=\"$(PACKAGE)\" \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ $(COVERAGE_CFLAGS) \ -- GitLab