[libvirt] PATCH: 0/12: Modular build node devices integration

2008-11-13 Thread Daniel P. Berrange
The following series of patches are updated version of patches 7-11 of
this series

 http://www.redhat.com/archives/libvir-list/2008-October/msg00718.html

And integrating David Lively's node device patches ontop

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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] PATCH: 1/12: Build libtool convenience libraries

2008-11-13 Thread Daniel P. Berrange
This patch changes the makefile to build all drivers as libtool 
convenience libraries.

Daniel

diff -r 99484df67fe0 src/Makefile.am
--- a/src/Makefile.am   Fri Nov 07 11:53:35 2008 +
+++ b/src/Makefile.am   Fri Nov 07 11:54:20 2008 +
@@ -6,11 +6,7 @@
   [EMAIL PROTECTED]@/include \
   [EMAIL PROTECTED]@/qemud \
   $(LIBXML_CFLAGS) \
-  $(GNUTLS_CFLAGS) \
-  $(SASL_CFLAGS) \
   $(SELINUX_CFLAGS) \
-  $(NUMACTL_CFLAGS) \
-  $(XEN_CFLAGS) \
   -DBINDIR=\$(libexecdir)\ \
   -DSBINDIR=\$(sbindir)\ \
   -DSYSCONF_DIR=\$(sysconfdir)\ \
@@ -18,10 +14,6 @@
-DLOCAL_STATE_DIR=\$(localstatedir)\ \
-DGETTEXT_PACKAGE=\$(PACKAGE)\ \
   $(WARN_CFLAGS)
-
-DEPS = libvirt.la
-LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) libvirt.la ../gnulib/lib/libgnu.la
-VIRSH_LIBS = @VIRSH_LIBS@
 
 confdir = $(sysconfdir)/libvirt/
 conf_DATA = qemu.conf
@@ -40,7 +32,7 @@
 
 # These files are not related to driver APIs. Simply generic
 # helper APIs for various purposes
-GENERIC_LIB_SOURCES =  \
+UTIL_SOURCES = \
bridge.c bridge.h   \
buf.c buf.h \
conf.c conf.h   \
@@ -54,6 +46,16 @@
virterror.c virterror_internal.h\
logging.c logging.h \
xml.c xml.h
+
+# Internal generic driver infrastructure
+DRIVER_SOURCES =   \
+   driver.h\
+   internal.h  \
+   datatypes.c datatypes.h \
+   domain_event.c domain_event.h   \
+   stats_linux.c stats_linux.h \
+   libvirt.c libvirt_internal.h
+
 
 # Domain driver generic impl APIs
 DOMAIN_CONF_SOURCES =  \
@@ -147,62 +149,91 @@
 #
 # First deal with sources usable in non-daemon context
 
-libvirt_la_SOURCES =   \
-   driver.h\
-   internal.h  \
-   datatypes.c datatypes.h \
-   domain_event.c domain_event.h   \
-   stats_linux.c stats_linux.h \
-   libvirt.c libvirt_internal.h\
-   $(GENERIC_LIB_SOURCES)  \
+noinst_LTLIBRARIES = libvirt_util.la
+libvirt_la_LIBADD = libvirt_util.la
+libvirt_util_la_SOURCES =  \
+   $(UTIL_SOURCES)
+
+noinst_LTLIBRARIES += libvirt_driver.la
+libvirt_la_LIBADD += libvirt_driver.la
+libvirt_driver_la_SOURCES =\
+   $(DRIVER_SOURCES)   \
$(DOMAIN_CONF_SOURCES)  \
$(NETWORK_CONF_SOURCES) \
$(STORAGE_CONF_SOURCES)
 
 if WITH_TEST
-libvirt_la_SOURCES += $(TEST_DRIVER_SOURCES)
+noinst_LTLIBRARIES += libvirt_driver_test.la
+libvirt_la_LIBADD += libvirt_driver_test.la
+libvirt_driver_test_la_SOURCES = $(TEST_DRIVER_SOURCES)
 endif
 
 if WITH_REMOTE
-libvirt_la_SOURCES += $(REMOTE_DRIVER_SOURCES)
+noinst_LTLIBRARIES += libvirt_driver_remote.la
+libvirt_la_LIBADD += libvirt_driver_remote.la
+libvirt_driver_remote_la_CFLAGS =  \
+   $(GNUTLS_CFLAGS)\
+   $(SASL_CFLAGS)
+libvirt_driver_remote_la_LDFLAGS = \
+   $(GNUTLS_LIBS)  \
+   $(SASL_LIBS)
+libvirt_driver_remote_la_SOURCES = $(REMOTE_DRIVER_SOURCES)
 endif
 
 if WITH_XEN
-libvirt_la_SOURCES += $(XEN_DRIVER_SOURCES)
+noinst_LTLIBRARIES += libvirt_driver_xen.la
+libvirt_la_LIBADD += libvirt_driver_xen.la
+libvirt_driver_xen_la_CFLAGS = $(XEN_CFLAGS)
+libvirt_driver_xen_la_LDFLAGS = $(XEN_LIBS)
+libvirt_driver_xen_la_SOURCES = $(XEN_DRIVER_SOURCES)
 endif
 
 if WITH_OPENVZ
-libvirt_la_SOURCES += $(OPENVZ_DRIVER_SOURCES)
+noinst_LTLIBRARIES += libvirt_driver_openvz.la
+libvirt_la_LIBADD += libvirt_driver_openvz.la
+libvirt_driver_openvz_la_SOURCES = $(OPENVZ_DRIVER_SOURCES)
 endif
 
 if WITH_QEMU
-libvirt_la_SOURCES += $(QEMU_DRIVER_SOURCES)
+noinst_LTLIBRARIES += libvirt_driver_qemu.la
+libvirt_la_LIBADD += libvirt_driver_qemu.la
+libvirt_driver_qemu_la_CFLAGS = $(NUMACTL_CFLAGS)
+libvirt_driver_qemu_la_LDFLAGS = $(NUMACTL_LIBS)
+libvirt_driver_qemu_la_SOURCES = $(QEMU_DRIVER_SOURCES)
 endif
 
 if WITH_LXC

Re: [libvirt] PATCH: 2/12: Make use of versioned linker scripts

2008-11-13 Thread Daniel P. Berrange
This patch changes the way we use linker scripts to have fully versioned
symbols, and a versioned private section for symbols needed by libvirtd
and virsh.

Daniel

diff -r bbf3d0bc9d49 configure.in
--- a/configure.in  Tue Nov 11 17:28:27 2008 +
+++ b/configure.in  Tue Nov 11 17:28:31 2008 +
@@ -1076,6 +1076,7 @@
  gnulib/lib/Makefile \
  gnulib/tests/Makefile \
   libvirt.pc libvirt.spec mingw32-libvirt.spec \
+  src/libvirt_sym.version \
   po/Makefile.in \
  include/libvirt/Makefile include/libvirt/libvirt.h \
  python/Makefile python/tests/Makefile \
diff -r bbf3d0bc9d49 qemud/Makefile.am
--- a/qemud/Makefile.am Tue Nov 11 17:28:27 2008 +
+++ b/qemud/Makefile.am Tue Nov 11 17:28:31 2008 +
@@ -7,8 +7,7 @@
remote_dispatch_prototypes.h\
remote_dispatch_localvars.h \
remote_dispatch_proc_switch.h   \
-   remote_protocol.h remote_protocol.c \
-   $(srcdir)/../src/util-lib.c
+   remote_protocol.h remote_protocol.c
 
 AVAHI_SOURCES =\
mdns.c mdns.h
diff -r bbf3d0bc9d49 qemud/remote.c
--- a/qemud/remote.cTue Nov 11 17:28:27 2008 +
+++ b/qemud/remote.cTue Nov 11 17:28:31 2008 +
@@ -487,7 +487,7 @@
 {
 CHECK_CONN(client);
 
-ret-supported = __virDrvSupportsFeature (client-conn, args-feature);
+ret-supported = virDrvSupportsFeature (client-conn, args-feature);
 if (ret-supported == -1) return -1;
 
 return 0;
@@ -1396,9 +1396,9 @@
 return -2;
 }
 
-r = __virDomainMigratePrepare (client-conn, cookie, cookielen,
-   uri_in, uri_out,
-   args-flags, dname, args-resource);
+r = virDomainMigratePrepare (client-conn, cookie, cookielen,
+ uri_in, uri_out,
+ args-flags, dname, args-resource);
 if (r == -1) {
 VIR_FREE(uri_out);
 return -1;
@@ -1439,11 +1439,11 @@
 
 dname = args-dname == NULL ? NULL : *args-dname;
 
-r = __virDomainMigratePerform (dom,
-   args-cookie.cookie_val,
-   args-cookie.cookie_len,
-   args-uri,
-   args-flags, dname, args-resource);
+r = virDomainMigratePerform (dom,
+ args-cookie.cookie_val,
+ args-cookie.cookie_len,
+ args-uri,
+ args-flags, dname, args-resource);
 virDomainFree (dom);
 if (r == -1) return -1;
 
@@ -1460,11 +1460,11 @@
 virDomainPtr ddom;
 CHECK_CONN (client);
 
-ddom = __virDomainMigrateFinish (client-conn, args-dname,
- args-cookie.cookie_val,
- args-cookie.cookie_len,
- args-uri,
- args-flags);
+ddom = virDomainMigrateFinish (client-conn, args-dname,
+   args-cookie.cookie_val,
+   args-cookie.cookie_len,
+   args-uri,
+   args-flags);
 if (ddom == NULL) return -1;
 
 make_nonnull_domain (ret-ddom, ddom);
diff -r bbf3d0bc9d49 src/Makefile.am
--- a/src/Makefile.am   Tue Nov 11 17:28:27 2008 +
+++ b/src/Makefile.am   Tue Nov 11 17:28:31 2008 +
@@ -285,7 +285,6 @@
 
 virsh_SOURCES =\
console.c console.h \
-   util-lib.c util-lib.h   \
virsh.c
 
 virsh_LDFLAGS = $(WARN_CFLAGS) $(COVERAGE_LDFLAGS)
diff -r bbf3d0bc9d49 src/buf.c
--- a/src/buf.c Tue Nov 11 17:28:27 2008 +
+++ b/src/buf.c Tue Nov 11 17:28:31 2008 +
@@ -88,7 +88,7 @@
  *
  */
 void
-__virBufferAdd(const virBufferPtr buf, const char *str, int len)
+virBufferAdd(const virBufferPtr buf, const char *str, int len)
 {
 unsigned int needSize;
 
@@ -120,7 +120,7 @@
  *
  */
 void
-__virBufferAddChar (virBufferPtr buf, char c)
+virBufferAddChar (virBufferPtr buf, char c)
 {
 unsigned int needSize;
 
@@ -150,7 +150,7 @@
  * Returns the buffer content or NULL in case of error.
  */
 char *
-__virBufferContentAndReset(const virBufferPtr buf)
+virBufferContentAndReset(const virBufferPtr buf)
 {
 char *str;
 if (buf == NULL)
@@ -176,7 +176,7 @@
  * Return true if in error, 0 if normal
  */
 int
-__virBufferError(const virBufferPtr buf)
+virBufferError(const virBufferPtr buf)
 {
 if (buf == NULL)
 return 1;
@@ -208,7 +208,7 @@
  * Do a formatted print to an XML buffer.
  */
 void
-__virBufferVSprintf(const 

Re: [libvirt] PATCH: 3/12: Re-factor storage backend integration

2008-11-13 Thread Daniel P. Berrange
My previous patch for refactoring the storage backends broke the test
driver's storage capabilities. The problem was that it made the backends
private to the storage driver, but part of them was  in fact needed by
the XML parsers. This patch pulls a bunch of code out of the storage_backenmd
file, and individual drivers and puts it straight into storage_conf.c/h
for generic use by the parser. The storage backends are not totally
private to the storage driver, and the test driver's storage impl still
works

Daniel

diff -r 19c9bab70d15 src/Makefile.am
--- a/src/Makefile.am   Wed Nov 12 16:38:19 2008 +
+++ b/src/Makefile.am   Wed Nov 12 21:05:13 2008 +
@@ -69,8 +69,7 @@
 
 # Storage driver generic impl APIs
 STORAGE_CONF_SOURCES = \
-   storage_conf.h storage_conf.c   \
-   storage_backend.h storage_backend.c
+   storage_conf.h storage_conf.c
 
 
 # The remote RPC driver, covering domains, storage, networks, etc
@@ -123,7 +122,8 @@
 
 # And finally storage backend specific impls
 STORAGE_DRIVER_SOURCES =   \
-   storage_driver.h storage_driver.c
+   storage_driver.h storage_driver.c   \
+   storage_backend.h storage_backend.c
 
 STORAGE_DRIVER_FS_SOURCES =\
storage_backend_fs.h storage_backend_fs.c
diff -r 19c9bab70d15 src/storage_backend.c
--- a/src/storage_backend.c Wed Nov 12 16:38:19 2008 +
+++ b/src/storage_backend.c Wed Nov 12 21:05:13 2008 +
@@ -24,6 +24,7 @@
 #include config.h
 
 #include string.h
+#include stdio.h
 #if HAVE_REGEX_H
 #include regex.h
 #endif
@@ -60,10 +61,6 @@
 #include storage_backend_fs.h
 #endif
 
-VIR_ENUM_IMPL(virStorageBackendPartTable,
-  VIR_STORAGE_POOL_DISK_LAST,
-  unknown, dos, dvh, gpt,
-  mac, bsd, pc98, sun, lvm2);
 
 static virStorageBackendPtr backends[] = {
 #if WITH_STORAGE_DIR
@@ -95,81 +92,6 @@
 
 virStorageReportError(NULL, VIR_ERR_INTERNAL_ERROR,
   _(missing backend for pool type %d), type);
-return NULL;
-}
-
-virStorageBackendPoolOptionsPtr
-virStorageBackendPoolOptionsForType(int type) {
-virStorageBackendPtr backend = virStorageBackendForType(type);
-if (backend == NULL)
-return NULL;
-return backend-poolOptions;
-}
-
-virStorageBackendVolOptionsPtr
-virStorageBackendVolOptionsForType(int type) {
-virStorageBackendPtr backend = virStorageBackendForType(type);
-if (backend == NULL)
-return NULL;
-return backend-volOptions;
-}
-
-
-int
-virStorageBackendFromString(const char *type) {
-if (STREQ(type, dir))
-return VIR_STORAGE_POOL_DIR;
-#if WITH_STORAGE_FS
-if (STREQ(type, fs))
-return VIR_STORAGE_POOL_FS;
-if (STREQ(type, netfs))
-return VIR_STORAGE_POOL_NETFS;
-#endif
-#if WITH_STORAGE_LVM
-if (STREQ(type, logical))
-return VIR_STORAGE_POOL_LOGICAL;
-#endif
-#if WITH_STORAGE_ISCSI
-if (STREQ(type, iscsi))
-return VIR_STORAGE_POOL_ISCSI;
-#endif
-#if WITH_STORAGE_DISK
-if (STREQ(type, disk))
-return VIR_STORAGE_POOL_DISK;
-#endif
-
-virStorageReportError(NULL, VIR_ERR_INTERNAL_ERROR,
-  _(unknown storage backend type %s), type);
-return -1;
-}
-
-const char *
-virStorageBackendToString(int type) {
-switch (type) {
-case VIR_STORAGE_POOL_DIR:
-return dir;
-#if WITH_STORAGE_FS
-case VIR_STORAGE_POOL_FS:
-return fs;
-case VIR_STORAGE_POOL_NETFS:
-return netfs;
-#endif
-#if WITH_STORAGE_LVM
-case VIR_STORAGE_POOL_LOGICAL:
-return logical;
-#endif
-#if WITH_STORAGE_ISCSI
-case VIR_STORAGE_POOL_ISCSI:
-return iscsi;
-#endif
-#if WITH_STORAGE_DISK
-case VIR_STORAGE_POOL_DISK:
-return disk;
-#endif
-}
-
-virStorageReportError(NULL, VIR_ERR_INTERNAL_ERROR,
-  _(unknown storage backend type %d), type);
 return NULL;
 }
 
@@ -197,6 +119,13 @@
 
 return ret;
 }
+
+struct diskType {
+int part_table_type;
+unsigned short offset;
+unsigned short length;
+unsigned long long magic;
+};
 
 static struct diskType const disk_types[] = {
 { VIR_STORAGE_POOL_DISK_LVM2, 0x218, 8, 0x31303020324D564CULL },
@@ -367,6 +296,12 @@
 if (pool-def-target.path == NULL ||
 STREQ(pool-def-target.path, /dev) ||
 STREQ(pool-def-target.path, /dev/))
+goto ret_strdup;
+
+/* Skip whole thing for a pool which isn't in /dev
+ * so we don't mess will filesystem/dir based pools
+ */
+if (!STRPREFIX(pool-def-target.path, /dev))
 goto ret_strdup;
 
 /* The pool is pointing somewhere like /dev/disk/by-path
diff -r 19c9bab70d15 src/storage_backend.h
--- a/src/storage_backend.h Wed Nov 12 16:38:19 2008 +
+++ b/src/storage_backend.h Wed Nov 12 

Re: [libvirt] PATCH: 4/12: Refactoring URI probing

2008-11-13 Thread Daniel P. Berrange
This patch changes the way hypervisor URIs are probed when NULL is passed
to the virConnectOpen() method. Previously we had an explicit probe method
called in each driver. This does not work when we move some drivers out of
libvirt.so and into libvirtd daemon. So I've refactored the way this works
so that we simply pass a NULL uri into the individual driver open methods.
If they see a NULL uri, they will make an attempt to open, and return a
VIR_DRV_OPEN_DECLINED code if its not suitable. This also works for the
remote driver, probing supported URI inside the daemon. Quite alot of code
churn but the end result should be functionally the same

Daniel

diff -r d97fa69e255b proxy/libvirt_proxy.c
--- a/proxy/libvirt_proxy.c Wed Nov 12 21:05:13 2008 +
+++ b/proxy/libvirt_proxy.c Wed Nov 12 21:59:20 2008 +
@@ -82,7 +82,7 @@
 priv-xshandle = NULL;
 priv-proxy = -1;
 
-ret = xenHypervisorOpen(conn, NULL, NULL, 0);
+ret = xenHypervisorOpen(conn, NULL, 0);
 if (ret  0) {
 fprintf(stderr, Failed to open Xen hypervisor\n);
 return(-1);
@@ -98,7 +98,7 @@
 fprintf(stderr, Failed to connect to Xen daemon\n);
 return(-1);
 }
-ret = xenStoreOpen(conn, NULL, NULL, VIR_CONNECT_RO);
+ret = xenStoreOpen(conn, NULL, VIR_CONNECT_RO);
 if (ret  0) {
 fprintf(stderr, Failed to open XenStore connection);
 return (-1);
diff -r d97fa69e255b qemud/remote.c
--- a/qemud/remote.cWed Nov 12 21:05:13 2008 +
+++ b/qemud/remote.cWed Nov 12 21:59:20 2008 +
@@ -547,6 +547,23 @@
 if (hostname == NULL) return -1;
 
 ret-hostname = hostname;
+return 0;
+}
+
+static int
+remoteDispatchGetUri (struct qemud_server *server ATTRIBUTE_UNUSED,
+  struct qemud_client *client,
+  remote_message_header *req,
+  void *args ATTRIBUTE_UNUSED,
+  remote_get_uri_ret *ret)
+{
+char *uri;
+CHECK_CONN(client);
+
+uri = virConnectGetURI (client-conn);
+if (uri == NULL) return -1;
+
+ret-uri = uri;
 return 0;
 }
 
diff -r d97fa69e255b qemud/remote_dispatch_localvars.h
--- a/qemud/remote_dispatch_localvars.h Wed Nov 12 21:05:13 2008 +
+++ b/qemud/remote_dispatch_localvars.h Wed Nov 12 21:59:20 2008 +
@@ -138,6 +138,7 @@
 remote_storage_vol_get_path_ret lv_remote_storage_vol_get_path_ret;
 remote_domain_lookup_by_id_args lv_remote_domain_lookup_by_id_args;
 remote_domain_lookup_by_id_ret lv_remote_domain_lookup_by_id_ret;
+remote_get_uri_ret lv_remote_get_uri_ret;
 remote_domain_attach_device_args lv_remote_domain_attach_device_args;
 remote_num_of_networks_ret lv_remote_num_of_networks_ret;
 remote_storage_pool_get_info_args lv_remote_storage_pool_get_info_args;
diff -r d97fa69e255b qemud/remote_dispatch_proc_switch.h
--- a/qemud/remote_dispatch_proc_switch.h   Wed Nov 12 21:05:13 2008 +
+++ b/qemud/remote_dispatch_proc_switch.h   Wed Nov 12 21:59:20 2008 +
@@ -388,6 +388,12 @@
 ret_filter = (xdrproc_t) xdr_remote_get_type_ret;
 ret = (char *) lv_remote_get_type_ret;
 memset (lv_remote_get_type_ret, 0, sizeof lv_remote_get_type_ret);
+break;
+case REMOTE_PROC_GET_URI:
+fn = (dispatch_fn) remoteDispatchGetUri;
+ret_filter = (xdrproc_t) xdr_remote_get_uri_ret;
+ret = (char *) lv_remote_get_uri_ret;
+memset (lv_remote_get_uri_ret, 0, sizeof lv_remote_get_uri_ret);
 break;
 case REMOTE_PROC_GET_VERSION:
 fn = (dispatch_fn) remoteDispatchGetVersion;
diff -r d97fa69e255b qemud/remote_dispatch_prototypes.h
--- a/qemud/remote_dispatch_prototypes.hWed Nov 12 21:05:13 2008 +
+++ b/qemud/remote_dispatch_prototypes.hWed Nov 12 21:59:20 2008 +
@@ -55,6 +55,7 @@
 static int remoteDispatchGetHostname (struct qemud_server *server, struct 
qemud_client *client, remote_message_header *req, void *args, 
remote_get_hostname_ret *ret);
 static int remoteDispatchGetMaxVcpus (struct qemud_server *server, struct 
qemud_client *client, remote_message_header *req, remote_get_max_vcpus_args 
*args, remote_get_max_vcpus_ret *ret);
 static int remoteDispatchGetType (struct qemud_server *server, struct 
qemud_client *client, remote_message_header *req, void *args, 
remote_get_type_ret *ret);
+static int remoteDispatchGetUri (struct qemud_server *server, struct 
qemud_client *client, remote_message_header *req, void *args, 
remote_get_uri_ret *ret);
 static int remoteDispatchGetVersion (struct qemud_server *server, struct 
qemud_client *client, remote_message_header *req, void *args, 
remote_get_version_ret *ret);
 static int remoteDispatchListDefinedDomains (struct qemud_server *server, 
struct qemud_client *client, remote_message_header *req, 
remote_list_defined_domains_args *args, remote_list_defined_domains_ret *ret);
 static int remoteDispatchListDefinedNetworks (struct qemud_server *server, 
struct qemud_client *client, 

Re: [libvirt] PATCH: 5/12: Module build linking

2008-11-13 Thread Daniel P. Berrange
This patch changes the module biuld so that stateful drivers like QEMU
and LXC are directly linked into the libvirtd daemon, and not part of the
libvirt.so file. It also does this for network and storage drivers. We
need to export a few more symbols for this to work, and libvirtd has to
explicitly initialize these drivers. Thanks to the previous patch changing
the probe method, automatic driver probing still works.

Daniel

diff -r c21e0cdc2637 qemud/Makefile.am
--- a/qemud/Makefile.am Fri Nov 07 12:51:10 2008 +
+++ b/qemud/Makefile.am Fri Nov 07 12:51:13 2008 +
@@ -88,7 +88,25 @@
$(POLKIT_LIBS)
 
 libvirtd_DEPENDENCIES = ../src/libvirt.la
-libvirtd_LDADD = ../src/libvirt.la ../gnulib/lib/libgnu.la
+libvirtd_LDADD =   \
+   ../gnulib/lib/libgnu.la \
+   ../src/libvirt.la
+
+if WITH_QEMU
+libvirtd_LDADD += ../src/libvirt_driver_qemu.la
+endif
+
+if WITH_LXC
+libvirtd_LDADD += ../src/libvirt_driver_lxc.la
+endif
+
+if WITH_STORAGE_DIR
+libvirtd_LDADD += ../src/libvirt_driver_storage.la
+endif
+
+if WITH_NETWORK
+libvirtd_LDADD += ../src/libvirt_driver_network.la
+endif
 
 if HAVE_POLKIT
 policydir = $(datadir)/PolicyKit/policy
diff -r c21e0cdc2637 qemud/qemud.c
--- a/qemud/qemud.c Fri Nov 07 12:51:10 2008 +
+++ b/qemud/qemud.c Fri Nov 07 12:51:13 2008 +
@@ -60,6 +60,20 @@
 #ifdef HAVE_AVAHI
 #include mdns.h
 #endif
+
+#ifdef WITH_QEMU
+#include qemu_driver.h
+#endif
+#ifdef WITH_LXC
+#include lxc_driver.h
+#endif
+#ifdef WITH_NETWORK
+#include network_driver.h
+#endif
+#ifdef WITH_STORAGE_DIR
+#include storage_driver.h
+#endif
+
 
 static int godaemon = 0;/* -d: Be a daemon */
 static int verbose = 0; /* -v: Verbose mode */
@@ -727,6 +741,21 @@
 }
 
 server-sigread = sigread;
+
+virInitialize();
+
+#ifdef WITH_QEMU
+qemudRegister();
+#endif
+#ifdef WITH_LXC
+lxcRegister();
+#endif
+#ifdef WITH_NETWORK
+networkRegister();
+#endif
+#ifdef WITH_STORAGE_DIR
+storageRegister();
+#endif
 
 virEventRegisterImpl(virEventAddHandleImpl,
  virEventUpdateHandleImpl,
diff -r c21e0cdc2637 src/Makefile.am
--- a/src/Makefile.am   Fri Nov 07 12:51:10 2008 +
+++ b/src/Makefile.am   Fri Nov 07 12:51:13 2008 +
@@ -196,7 +196,8 @@
 
 if WITH_QEMU
 noinst_LTLIBRARIES += libvirt_driver_qemu.la
-libvirt_la_LIBADD += libvirt_driver_qemu.la
+# Stateful, so linked to daemon instead
+#libvirt_la_LIBADD += libvirt_driver_qemu.la
 libvirt_driver_qemu_la_CFLAGS = $(NUMACTL_CFLAGS)
 libvirt_driver_qemu_la_LDFLAGS = $(NUMACTL_LIBS)
 libvirt_driver_qemu_la_SOURCES = $(QEMU_DRIVER_SOURCES)
@@ -204,14 +205,16 @@
 
 if WITH_LXC
 noinst_LTLIBRARIES += libvirt_driver_lxc.la
-libvirt_la_LIBADD += libvirt_driver_lxc.la
+# Stateful, so linked to daemon instead
+#libvirt_la_LIBADD += libvirt_driver_lxc.la
 libvirt_driver_lxc_la_SOURCES = $(LXC_DRIVER_SOURCES)
 endif
 
 
 if WITH_NETWORK
 noinst_LTLIBRARIES += libvirt_driver_network.la
-libvirt_la_LIBADD += libvirt_driver_network.la
+# Stateful, so linked to daemon instead
+#libvirt_la_LIBADD += libvirt_driver_network.la
 libvirt_driver_network_la_SOURCES = $(NETWORK_DRIVER_SOURCES)
 endif
 
@@ -219,7 +222,8 @@
 libvirt_driver_storage_la_SOURCES =
 if WITH_STORAGE_DIR
 noinst_LTLIBRARIES += libvirt_driver_storage.la
-libvirt_la_LIBADD += libvirt_driver_storage.la
+# Stateful, so linked to daemon instead
+#libvirt_la_LIBADD += libvirt_driver_storage.la
 libvirt_driver_storage_la_SOURCES += $(STORAGE_DRIVER_SOURCES)
 libvirt_driver_storage_la_SOURCES += $(STORAGE_DRIVER_FS_SOURCES)
 endif
@@ -261,6 +265,7 @@
 $(COVERAGE_CFLAGS:-f%=-Wc,-f%) \
@CYGWIN_EXTRA_LDFLAGS@ @MINGW_EXTRA_LDFLAGS@
 libvirt_la_CFLAGS = $(COVERAGE_CFLAGS) -DIN_LIBVIRT
+libvirt_la_DEPENDENCIES = $(libvirt_la_LIBADD) $(srcdir)/libvirt_sym.version
 
 # Create an automake convenience library version of libvirt_la,
 # just for testing, since the test harness requires access to internal
diff -r c21e0cdc2637 src/libvirt.c
--- a/src/libvirt.c Fri Nov 07 12:51:10 2008 +
+++ b/src/libvirt.c Fri Nov 07 12:51:13 2008 +
@@ -50,18 +50,8 @@
 #ifdef WITH_REMOTE
 #include remote_internal.h
 #endif
-#ifdef WITH_QEMU
-#include qemu_driver.h
-#endif
 #ifdef WITH_OPENVZ
 #include openvz_driver.h
-#endif
-#ifdef WITH_LXC
-#include lxc_driver.h
-#endif
-#include storage_driver.h
-#ifdef WITH_NETWORK
-#include network_driver.h
 #endif
 
 /*
@@ -286,20 +276,8 @@
 #ifdef WITH_XEN
 if (xenUnifiedRegister () == -1) return -1;
 #endif
-#ifdef WITH_QEMU
-if (qemudRegister() == -1) return -1;
-#endif
 #ifdef WITH_OPENVZ
 if (openvzRegister() == -1) return -1;
-#endif
-#ifdef WITH_LXC
-if (lxcRegister() == -1) return -1;
-#endif
-#ifdef WITH_NETWORK
-if (networkRegister() == -1) return -1;
-#endif
-#ifdef WITH_STORAGE_DIR
-if (storageRegister() == -1) return -1;
 #endif
 #ifdef WITH_REMOTE
 if 

Re: [libvirt] PATCH: 6/12: Optional dlopen() support

2008-11-13 Thread Daniel P. Berrange

This patch is a small incremental change to optionally allow us to build
every driver as a dlopen()able module. This is disabled by default for
now. I'm not sure whether this is hugely usefl or not, but it was easy
enough to do, so here's the patch.

Daniel

diff -r ecc8ae6295bc configure.in
--- a/configure.in  Wed Nov 12 21:59:22 2008 +
+++ b/configure.in  Thu Nov 13 17:13:02 2008 +
@@ -1059,6 +1059,38 @@
 AC_CHECK_TOOL([WINDRES], [windres], [no])
 AM_CONDITIONAL([WITH_WIN_ICON], [test $WINDRES != no])
 
+
+
+dnl Driver-Modules library
+AC_ARG_WITH([driver-modules],
+  [  --with-driver-modules   build drivers as loadable modules],
+  [],
+  [with_driver_modules=no])
+
+DRIVER_MODULES_CFLAGS=
+DRIVER_MODULES_LIBS=
+if test x$with_driver_modules = xyes ; then
+  old_cflags=$CFLAGS
+  old_libs=$LIBS
+  fail=0
+  AC_CHECK_HEADER([dlfcn.h],[],[fail=1])
+  AC_CHECK_LIB([dl], [dlopen],[],[fail=1])
+  test $fail = 1 
+  AC_MSG_ERROR([You must have dlfcn.h / dlopen() support to build driver 
modules])
+
+  CFLAGS=$old_cflags
+  LIBS=$old_libs
+fi
+if test $with_driver_modules = yes; then
+  DRIVER_MODULES_CFLAGS=-export-dynamic
+  DRIVER_MODULES_LIBS=-ldl
+  AC_DEFINE_UNQUOTED([WITH_DRIVER_MODULES], 1, [whether to build drivers as 
modules])
+fi
+AM_CONDITIONAL([WITH_DRIVER_MODULES], [test $with_driver_modules != no])
+AC_SUBST([DRIVER_MODULES_CFLAGS])
+AC_SUBST([DRIVER_MODULES_LIBS])
+
+
 # Set LV_LIBTOOL_OBJDIR to . or $lt_cv_objdir, depending on whether
 # we're building shared libraries.  This is the name of the directory
 # in which .o files will be created.
@@ -1114,6 +1146,14 @@
 AC_MSG_NOTICE([   iSCSI: $with_storage_iscsi])
 AC_MSG_NOTICE([Disk: $with_storage_disk])
 AC_MSG_NOTICE([])
+AC_MSG_NOTICE([Driver Loadable Modules])
+AC_MSG_NOTICE([])
+if test $with_driver_modules != no ; then
+AC_MSG_NOTICE([  dlopen: $DRIVER_MODULES_CFLAGS $DRIVER_MODULES_LIBS])
+else
+AC_MSG_NOTICE([  dlopen: no])
+fi
+AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Libraries])
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([  libxml: $LIBXML_CFLAGS $LIBXML_LIBS])
diff -r ecc8ae6295bc qemud/Makefile.am
--- a/qemud/Makefile.am Wed Nov 12 21:59:22 2008 +
+++ b/qemud/Makefile.am Thu Nov 13 17:13:02 2008 +
@@ -92,6 +92,7 @@
../gnulib/lib/libgnu.la \
../src/libvirt.la
 
+if ! WITH_DRIVER_MODULES
 if WITH_QEMU
 libvirtd_LDADD += ../src/libvirt_driver_qemu.la
 endif
@@ -106,6 +107,7 @@
 
 if WITH_NETWORK
 libvirtd_LDADD += ../src/libvirt_driver_network.la
+endif
 endif
 
 if HAVE_POLKIT
diff -r ecc8ae6295bc qemud/qemud.c
--- a/qemud/qemud.c Wed Nov 12 21:59:22 2008 +
+++ b/qemud/qemud.c Thu Nov 13 17:13:02 2008 +
@@ -61,6 +61,9 @@
 #include mdns.h
 #endif
 
+#ifdef WITH_DRIVER_MODULES
+#include driver.h
+#else
 #ifdef WITH_QEMU
 #include qemu_driver.h
 #endif
@@ -72,6 +75,7 @@
 #endif
 #ifdef WITH_STORAGE_DIR
 #include storage_driver.h
+#endif
 #endif
 
 
@@ -744,8 +748,19 @@
 
 virInitialize();
 
+#ifdef WITH_DRIVER_MODULES
+/* We don't care if any of these fail, because the whole point
+ * is to allow users to only install modules they want to use.
+ * If they try to use a open a connection for a module that
+ * is not loaded they'll get a suitable error at that point
+ */
+virDriverLoadModule(qemu);
+virDriverLoadModule(lxc);
+virDriverLoadModule(network);
+virDriverLoadModule(storage);
+#else
 #ifdef WITH_QEMU
-qemudRegister();
+qemuRegister();
 #endif
 #ifdef WITH_LXC
 lxcRegister();
@@ -755,6 +770,7 @@
 #endif
 #ifdef WITH_STORAGE_DIR
 storageRegister();
+#endif
 #endif
 
 virEventRegisterImpl(virEventAddHandleImpl,
diff -r ecc8ae6295bc src/Makefile.am
--- a/src/Makefile.am   Wed Nov 12 21:59:22 2008 +
+++ b/src/Makefile.am   Thu Nov 13 17:13:02 2008 +
@@ -6,7 +6,10 @@
   [EMAIL PROTECTED]@/include \
   [EMAIL PROTECTED]@/qemud \
   $(LIBXML_CFLAGS) \
+  $(XEN_CFLAGS) \
   $(SELINUX_CFLAGS) \
+  $(DRIVER_MODULE_CFLAGS) \
+  -DLIBDIR=\$(libdir)\ \
   -DBINDIR=\$(libexecdir)\ \
   -DSBINDIR=\$(sbindir)\ \
   -DSYSCONF_DIR=\$(sysconfdir)\ \
@@ -30,6 +33,10 @@
 
 lib_LTLIBRARIES = libvirt.la
 
+moddir = $(libdir)/libvirt/drivers
+mod_LTLIBRARIES =
+
+
 # These files are not related to driver APIs. Simply generic
 # helper APIs for various purposes
 UTIL_SOURCES = \
@@ -49,7 +56,7 @@
 
 # Internal generic driver infrastructure
 DRIVER_SOURCES =   \
-   driver.h\
+   driver.c driver.h   \
internal.h  \
datatypes.c datatypes.h \
domain_event.c domain_event.h   \
@@ -163,67 +170,120 @@

Re: [libvirt] PATCH: 7/12: Public API for node devices

2008-11-13 Thread Daniel P. Berrange

This patch is the public API parts of the node device enumeration code.
No changes since David's last submission of this, except for some
Makefile tweaks

Daniel

diff -r 78738f80cf4c include/libvirt/libvirt.h
--- a/include/libvirt/libvirt.h Wed Nov 12 21:05:32 2008 +
+++ b/include/libvirt/libvirt.h Wed Nov 12 21:11:46 2008 +
@@ -995,6 +995,74 @@
  unsigned int flags);
 
 /*
+ * Host device enumeration
+ */
+
+/**
+ * virNodeDevice:
+ *
+ * A virNodeDevice contains a node (host) device details.
+ */
+
+typedef struct _virNodeDevice virNodeDevice;
+
+/**
+ * virNodeDevicePtr:
+ *
+ * A virNodeDevicePtr is a pointer to a virNodeDevice structure.  Get
+ * one via virNodeDeviceLookupByKey, virNodeDeviceLookupByName, or
+ * virNodeDeviceCreate.  Be sure to Call virNodeDeviceFree when done
+ * using a virNodeDevicePtr obtained from any of the above functions to
+ * avoid leaking memory.
+ */
+
+typedef virNodeDevice *virNodeDevicePtr;
+
+
+int virNodeNumOfDevices (virConnectPtr conn,
+ unsigned int flags);
+
+int virNodeListDevices  (virConnectPtr conn,
+ char **const names,
+ int maxnames,
+ unsigned int flags);
+
+int virNodeNumOfDevicesByCap (virConnectPtr conn,
+  const char *cap,
+  unsigned int flags);
+
+int virNodeListDevicesByCap (virConnectPtr conn,
+ const char *cap,
+ char **const names,
+ int maxnames,
+ unsigned int flags);
+
+virNodeDevicePtrvirNodeDeviceLookupByName (virConnectPtr conn,
+   const char *name);
+
+const char *virNodeDeviceGetName (virNodeDevicePtr dev);
+
+const char *virNodeDeviceGetParent   (virNodeDevicePtr dev);
+
+int virNodeDeviceNumOfCaps   (virNodeDevicePtr dev);
+
+int virNodeDeviceListCaps(virNodeDevicePtr dev,
+  char **const names,
+  int maxnames);
+
+char *  virNodeDeviceGetXMLDesc (virNodeDevicePtr dev,
+ unsigned int flags);
+
+virNodeDevicePtrvirNodeDeviceCreate (virConnectPtr conn,
+ const char *xml,
+ unsigned int flags);
+
+int virNodeDeviceDestroy(virNodeDevicePtr dev,
+ unsigned int flags);
+
+int virNodeDeviceFree   (virNodeDevicePtr dev);
+
+/*
  * Domain Event Notification
  */
 
diff -r 78738f80cf4c include/libvirt/libvirt.h.in
--- a/include/libvirt/libvirt.h.in  Wed Nov 12 21:05:32 2008 +
+++ b/include/libvirt/libvirt.h.in  Wed Nov 12 21:11:46 2008 +
@@ -995,6 +995,74 @@
  unsigned int flags);
 
 /*
+ * Host device enumeration
+ */
+
+/**
+ * virNodeDevice:
+ *
+ * A virNodeDevice contains a node (host) device details.
+ */
+
+typedef struct _virNodeDevice virNodeDevice;
+
+/**
+ * virNodeDevicePtr:
+ *
+ * A virNodeDevicePtr is a pointer to a virNodeDevice structure.  Get
+ * one via virNodeDeviceLookupByKey, virNodeDeviceLookupByName, or
+ * virNodeDeviceCreate.  Be sure to Call virNodeDeviceFree when done
+ * using a virNodeDevicePtr obtained from any of the above functions to
+ * avoid leaking memory.
+ */
+
+typedef virNodeDevice *virNodeDevicePtr;
+
+
+int virNodeNumOfDevices (virConnectPtr conn,
+ unsigned int flags);
+
+int virNodeListDevices  (virConnectPtr conn,
+ char **const names,
+ int maxnames,
+ unsigned int flags);
+
+int virNodeNumOfDevicesByCap (virConnectPtr conn,
+  const char *cap,
+  unsigned int flags);
+
+int virNodeListDevicesByCap (virConnectPtr conn,
+ const char *cap,
+ char **const names,
+ int maxnames,
+ 

Re: [libvirt] PATCH: 2/12: Make use of versioned linker scripts

2008-11-13 Thread Daniel Veillard
On Thu, Nov 13, 2008 at 05:21:23PM +, Daniel P. Berrange wrote:
 This patch changes the way we use linker scripts to have fully versioned
 symbols, and a versioned private section for symbols needed by libvirtd
 and virsh.

  Just a couple of questions:

 +++ b/src/driver.hTue Nov 11 17:28:31 2008 +
 @@ -73,7 +73,7 @@
  typedef int
  (*virDrvClose)   (virConnectPtr conn);
  typedef int
 -(*virDrvSupportsFeature) (virConnectPtr conn, int feature);
 +(*virDrvDrvSupportsFeature) (virConnectPtr conn, int feature);

  I miss the point ... err why ?

...]
 diff -r bbf3d0bc9d49 src/libvirt_sym.version.in
[...]
 +LIBVIRT_0.5.0 {
 +global:
 + virDomainCreateXML;
 + virEventRegisterImpl;
 + virConnectDomainEventRegister;
 + virConnectDomainEventDeregister;
 +} LIBVIRT_0.4.5;
 +
 +/*  define new API here using predicted next version number  */

So basically as part of doing a release I should guess the new version
number and make a template empty section here, commited after tagging
the release.


  Looks fine to me, and we need this, +1

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
[EMAIL PROTECTED]  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] PATCH: 8/12:Interal driver API for node devices

2008-11-13 Thread Daniel P. Berrange
This is the basic internal driver support code for the node device APIs.
The actual registration of the drivers was pushed to a later patch to
allow this to compile on its own  thus be fully bisectable.

Daniel

diff -r 6812c3044043 src/Makefile.am
--- a/src/Makefile.am   Wed Nov 12 21:11:46 2008 +
+++ b/src/Makefile.am   Wed Nov 12 21:11:51 2008 +
@@ -132,6 +132,10 @@
storage_driver.h storage_driver.c   \
storage_backend.h storage_backend.c
 
+# Network driver generic impl APIs
+NODE_DEVICE_CONF_SOURCES = \
+   node_device_conf.c node_device_conf.h
+
 STORAGE_DRIVER_FS_SOURCES =\
storage_backend_fs.h storage_backend_fs.c
 
@@ -167,7 +171,8 @@
$(DRIVER_SOURCES)   \
$(DOMAIN_CONF_SOURCES)  \
$(NETWORK_CONF_SOURCES) \
-   $(STORAGE_CONF_SOURCES)
+   $(STORAGE_CONF_SOURCES) \
+   $(NODE_DEVICE_CONF_SOURCES)
 
 if WITH_TEST
 if WITH_DRIVER_MODULES
diff -r 6812c3044043 src/node_device_conf.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/src/node_device_conf.cWed Nov 12 21:11:51 2008 +
@@ -0,0 +1,425 @@
+/*
+ * node_device_conf.c: config handling for node devices
+ *
+ * Copyright (C) 2008 Virtual Iron Software, Inc.
+ * Copyright (C) 2008 David F. Lively
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David F. Lively [EMAIL PROTECTED]
+ */
+
+#include config.h
+
+#include unistd.h
+#include errno.h
+
+#include virterror_internal.h
+#include memory.h
+
+#include node_device_conf.h
+#include memory.h
+#include xml.h
+#include util.h
+#include buf.h
+#include uuid.h
+
+
+VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST,
+  system,
+  pci,
+  usb_device,
+  usb,
+  net,
+  block,
+  scsi_host,
+  scsi,
+  storage);
+
+VIR_ENUM_IMPL(virNodeDevNetCap, VIR_NODE_DEV_CAP_NET_LAST,
+  80203,
+  80211);
+
+
+#define virNodeDeviceLog(msg...) fprintf(stderr, msg)
+
+virNodeDeviceObjPtr virNodeDeviceFindByName(const virNodeDeviceObjListPtr devs,
+const char *name)
+{
+unsigned int i;
+
+for (i = 0; i  devs-count; i++)
+if (STREQ(devs-objs[i]-def-name, name))
+return devs-objs[i];
+
+return NULL;
+}
+
+
+void virNodeDeviceDefFree(virNodeDeviceDefPtr def)
+{
+virNodeDevCapsDefPtr caps;
+
+if (!def)
+return;
+
+VIR_FREE(def-name);
+VIR_FREE(def-parent);
+
+caps = def-caps;
+while (caps) {
+virNodeDevCapsDefPtr next = caps-next;
+virNodeDevCapsDefFree(caps);
+caps = next;
+}
+
+VIR_FREE(def);
+}
+
+void virNodeDeviceObjFree(virNodeDeviceObjPtr dev)
+{
+if (!dev)
+return;
+
+virNodeDeviceDefFree(dev-def);
+if (dev-privateFree)
+(*dev-privateFree)(dev-privateData);
+
+VIR_FREE(dev);
+}
+
+void virNodeDeviceObjListFree(virNodeDeviceObjListPtr devs)
+{
+unsigned int i;
+for (i = 0 ; i  devs-count ; i++)
+virNodeDeviceObjFree(devs-objs[i]);
+VIR_FREE(devs-objs);
+devs-count = 0;
+}
+
+virNodeDeviceObjPtr virNodeDeviceAssignDef(virConnectPtr conn,
+   virNodeDeviceObjListPtr devs,
+   const virNodeDeviceDefPtr def)
+{
+virNodeDeviceObjPtr device;
+
+if ((device = virNodeDeviceFindByName(devs, def-name))) {
+virNodeDeviceDefFree(device-def);
+device-def = def;
+return device;
+}
+
+if (VIR_ALLOC(device)  0) {
+virNodeDeviceReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+return NULL;
+}
+
+device-def = def;
+
+if (VIR_REALLOC_N(devs-objs, devs-count+1)  0) {
+device-def = NULL;
+virNodeDeviceObjFree(device);
+virNodeDeviceReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+return NULL;
+}
+devs-objs[devs-count++] = device;
+
+return device;
+
+}
+
+void 

Re: [libvirt] PATCH: 9/12: HAL/DevitKit node device impl

2008-11-13 Thread Daniel P. Berrange
This is the main implementation of the local device enumation driver. The
main change since David's patch is that we hav a single nodedevRegister()
API call, instead of initializing HAL/DevKit separtely. This was needed
to make the dlopen() support easier to implement. Functionally the end
result is the same.

Daniel

diff -r acac4fc31665 configure.in
--- a/configure.in  Thu Nov 13 17:06:39 2008 +
+++ b/configure.in  Thu Nov 13 17:10:30 2008 +
@@ -1098,6 +1098,108 @@
 LV_LIBTOOL_OBJDIR=${lt_cv_objdir-.}
 AC_SUBST([LV_LIBTOOL_OBJDIR])
 
+dnl HAL or DeviceKit library for host device enumeration
+HAL_REQUIRED=0.0
+HAL_CFLAGS=
+HAL_LIBS=
+AC_ARG_WITH([hal],
+  [  --with-hal use HAL for host device enumeration],
+  [],
+  [with_hal=check])
+
+if test $with_libvirtd = no ; then
+  with_hal=no
+fi
+if test x$with_hal = xyes -o x$with_hal = xcheck; then
+  PKG_CHECK_MODULES(HAL, hal = $HAL_REQUIRED,
+[with_hal=yes], [
+if test x$with_hal = xcheck ; then
+   with_hal=no
+else
+   AC_MSG_ERROR(
+ [You must install hal-devel = $HAL_REQUIRED to compile libvirt])
+fi
+  ])
+  if test x$with_hal = xyes ; then
+AC_DEFINE_UNQUOTED([HAVE_HAL], 1,
+  [use HAL for host device enumeration])
+
+old_CFLAGS=$CFLAGS
+old_LDFLAGS=$LDFLAGS
+CFLAGS=$CFLAGS $HAL_CFLAGS
+LDFLAGS=$LDFLAGS $HAL_LIBS
+AC_CHECK_FUNCS([libhal_get_all_devices],,[with_hal=no])
+CFLAGS=$old_CFLAGS
+LDFLAGS=$old_LDFLAGS
+  fi
+fi
+AM_CONDITIONAL([HAVE_HAL], [test x$with_hal = xyes])
+AC_SUBST([HAL_CFLAGS])
+AC_SUBST([HAL_LIBS])
+
+DEVKIT_REQUIRED=0.0
+DEVKIT_CFLAGS=
+DEVKIT_LIBS=
+AC_ARG_WITH([devkit],
+  [  --with-devkit  use DeviceKit for host device enumeration],
+  [],
+  [with_devkit=check])
+
+if test $with_libvirtd = no ; then
+  with_devkit=no
+fi
+
+dnl Extra check needed while devkit pkg-config info missing glib2 dependency
+PKG_CHECK_MODULES(GLIB2, glib-2.0 = 0.0,,[
+  if test x$with_devkit = xcheck; then
+with_devkit=no
+  elif test x$with_devkit = xyes; then
+AC_MSG_ERROR([required package DeviceKit requires package glib-2.0])
+  fi])
+
+if test x$with_devkit = xyes -o x$with_devkit = xcheck; then
+  PKG_CHECK_MODULES(DEVKIT, devkit-gobject = $DEVKIT_REQUIRED,
+[with_devkit=yes], [
+if test x$with_devkit = xcheck ; then
+   with_devkit=no
+else
+   AC_MSG_ERROR(
+ [You must install DeviceKit-devel = $DEVKIT_REQUIRED to compile 
libvirt])
+fi
+  ])
+  if test x$with_devkit = xyes ; then
+AC_DEFINE_UNQUOTED([HAVE_DEVKIT], 1,
+  [use DeviceKit for host device enumeration])
+
+dnl Add glib2 flags explicitly while devkit pkg-config info missing glib2 
dependency
+DEVKIT_CFLAGS=$GLIB2_CFLAGS $DEVKIT_CFLAGS
+DEVKIT_LIBS=$GLIB2_LIBS $DEVKIT_LIBS
+
+dnl Add more flags apparently required for devkit to work properly
+DEVKIT_CFLAGS=$DEVKIT_CFLAGS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT
+
+old_CFLAGS=$CFLAGS
+old_LDFLAGS=$LDFLAGS
+CFLAGS=$CFLAGS $DEVKIT_CFLAGS
+LDFLAGS=$LDFLAGS $DEVKIT_LIBS
+AC_CHECK_FUNCS([devkit_client_connect],,[with_devkit=no])
+CFLAGS=$old_CFLAGS
+LDFLAGS=$old_LDFLAGS
+  fi
+fi
+AM_CONDITIONAL([HAVE_DEVKIT], [test x$with_devkit = xyes])
+AC_SUBST([DEVKIT_CFLAGS])
+AC_SUBST([DEVKIT_LIBS])
+
+with_nodedev=no;
+if test $with_devkit = yes -o $with_hal = yes;
+then
+  with_nodedev=yes
+  AC_DEFINE_UNQUOTED([WITH_NODE_DEVICES], 1, [with node device driver])
+fi
+AM_CONDITIONAL([WITH_NODE_DEVICES], [test $with_nodedev = yes])
+
+
 # very annoying
 rm -f COPYING
 cp COPYING.LIB COPYING
@@ -1188,6 +1290,16 @@
 else
 AC_MSG_NOTICE([  xen: no])
 fi
+if test $with_hal = yes ; then
+AC_MSG_NOTICE([  hal: $HAL_CFLAGS $HAL_LIBS])
+else
+AC_MSG_NOTICE([  hal: no])
+fi
+if test $with_devkit = yes ; then
+AC_MSG_NOTICE([  devkit: $DEVKIT_CFLAGS $DEVKIT_LIBS])
+else
+AC_MSG_NOTICE([  devkit: no])
+fi
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Test suite])
 AC_MSG_NOTICE([])
diff -r acac4fc31665 po/POTFILES.in
--- a/po/POTFILES.inThu Nov 13 17:06:39 2008 +
+++ b/po/POTFILES.inThu Nov 13 17:10:30 2008 +
@@ -13,6 +13,7 @@
 src/lxc_driver.c
 src/network_conf.c
 src/network_driver.c
+src/node_device.c
 src/openvz_conf.c
 src/openvz_driver.c
 src/proxy_internal.c
diff -r acac4fc31665 qemud/Makefile.am
--- a/qemud/Makefile.am Thu Nov 13 17:06:39 2008 +
+++ b/qemud/Makefile.am Thu Nov 13 17:10:30 2008 +
@@ -108,6 +108,10 @@
 if WITH_NETWORK
 libvirtd_LDADD += ../src/libvirt_driver_network.la
 endif
+
+if WITH_NODE_DEVICES
+libvirtd_LDADD += ../src/libvirt_driver_nodedev.la
+endif
 endif
 
 if HAVE_POLKIT
diff -r acac4fc31665 qemud/qemud.c
--- a/qemud/qemud.c Thu Nov 13 17:06:39 2008 +
+++ b/qemud/qemud.c Thu Nov 13 17:10:30 2008 +
@@ -75,6 +75,9 @@
 #endif
 #ifdef WITH_STORAGE_DIR
 #include storage_driver.h
+#endif
+#ifdef WITH_NODE_DEVICES
+#include node_device.h
 #endif
 #endif
 
@@ -758,6 +761,7 @@
 virDriverLoadModule(lxc);
 

Re: [libvirt] PATCH: 11/12: virsh support

2008-11-13 Thread Daniel P. Berrange
This patch adds two node virsh commands for the node device enumeration
APIs. The only change here is to change the command names to have a shorter
prefix,  nodedev-list and nodedev-dumpxml

Daniel

diff -r 0136f215fc06 src/virsh.c
--- a/src/virsh.c   Thu Nov 13 13:06:59 2008 +
+++ b/src/virsh.c   Thu Nov 13 13:07:59 2008 +
@@ -4410,6 +4410,96 @@
 vshPrint(ctl, _(Running hypervisor: %s %d.%d.%d\n),
  hvType, major, minor, rel);
 }
+return TRUE;
+}
+
+/*
+ * nodedev-list command
+ */
+static const vshCmdInfo info_node_list_devices[] = {
+{syntax, nodedev-list [--cap capability]},
+{help, gettext_noop(enumerate devices on this host)},
+{NULL, NULL}
+};
+
+static const vshCmdOptDef opts_node_list_devices[] = {
+{cap, VSH_OT_STRING, VSH_OFLAG_NONE, gettext_noop(capability name)},
+{NULL, 0, 0, NULL}
+};
+
+static int
+cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
+{
+char *cap;
+char **devices;
+int found, num_devices, i;
+
+if (!vshConnectionUsability(ctl, ctl-conn, TRUE))
+return FALSE;
+
+cap = vshCommandOptString(cmd, cap, found);
+if (!found)
+cap = NULL;
+
+num_devices = cap ? virNodeNumOfDevicesByCap(ctl-conn, cap, 0) :
+virNodeNumOfDevices(ctl-conn, 0);
+if (num_devices  0) {
+vshError(ctl, FALSE, %s, _(Failed to count node devices));
+return FALSE;
+} else if (num_devices == 0) {
+return TRUE;
+}
+
+devices = vshMalloc(ctl, sizeof(char *) * num_devices);
+num_devices = cap ?
+virNodeListDevicesByCap(ctl-conn, cap, devices, num_devices, 0) :
+virNodeListDevices(ctl-conn, devices, num_devices, 0);
+if (num_devices  0) {
+vshError(ctl, FALSE, %s, _(Failed to list node devices));
+free(devices);
+return FALSE;
+}
+for (i = 0; i  num_devices; i++) {
+vshPrint(ctl, %s\n, devices[i]);
+free(devices[i]);
+}
+free(devices);
+return TRUE;
+}
+
+/*
+ * nodedev-dumpxml command
+ */
+static const vshCmdInfo info_node_device_dumpxml[] = {
+{syntax, nodedev-dumpxml device},
+{help, gettext_noop(node device details in XML)},
+{desc, gettext_noop(Output the node device details as an XML dump to 
stdout.)},
+{NULL, NULL}
+};
+
+
+static const vshCmdOptDef opts_node_device_dumpxml[] = {
+{device, VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop(device key)},
+{NULL, 0, 0, NULL}
+};
+
+static int
+cmdNodeDeviceDumpXML (vshControl *ctl, const vshCmd *cmd)
+{
+const char *name;
+virNodeDevicePtr device;
+
+if (!vshConnectionUsability(ctl, ctl-conn, TRUE))
+return FALSE;
+if (!(name = vshCommandOptString(cmd, device, NULL)))
+return FALSE;
+if (!(device = virNodeDeviceLookupByName(ctl-conn, name))) {
+vshError(ctl, FALSE, %s '%s', _(Could not find matching device), 
name);
+return FALSE;
+}
+
+vshPrint(ctl, %s\n, virNodeDeviceGetXMLDesc(device, 0));
+virNodeDeviceFree(device);
 return TRUE;
 }
 
@@ -5565,6 +5655,9 @@
 {net-uuid, cmdNetworkUuid, opts_network_uuid, info_network_uuid},
 {nodeinfo, cmdNodeinfo, NULL, info_nodeinfo},
 
+{node-list-devices, cmdNodeListDevices, opts_node_list_devices, 
info_node_list_devices},
+{node-device-dumpxml, cmdNodeDeviceDumpXML, opts_node_device_dumpxml, 
info_node_device_dumpxml},
+
 {pool-autostart, cmdPoolAutostart, opts_pool_autostart, 
info_pool_autostart},
 {pool-build, cmdPoolBuild, opts_pool_build, info_pool_build},
 {pool-create, cmdPoolCreate, opts_pool_create, info_pool_create},

-- 
|: 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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] PATCH: 3/12: Re-factor storage backend integration

2008-11-13 Thread Daniel Veillard
On Thu, Nov 13, 2008 at 05:23:05PM +, Daniel P. Berrange wrote:
 My previous patch for refactoring the storage backends broke the test
 driver's storage capabilities. The problem was that it made the backends
 private to the storage driver, but part of them was  in fact needed by
 the XML parsers. This patch pulls a bunch of code out of the storage_backenmd
 file, and individual drivers and puts it straight into storage_conf.c/h
 for generic use by the parser. The storage backends are not totally
 private to the storage driver, and the test driver's storage impl still
 works

  Okay, this really looks like only stuff moved around ... with a bit of
renaming too, ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
[EMAIL PROTECTED]  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] PATCH: 12/12: python bindings for node devices

2008-11-13 Thread Daniel P. Berrange
This is the python bindings for node devices. No change from David's
last patches.

Daniel

diff -r b2546652397b python/generator.py
--- a/python/generator.py   Fri Nov 07 18:44:05 2008 +
+++ b/python/generator.py   Fri Nov 07 18:44:21 2008 +
@@ -260,6 +260,11 @@
 'const virConnectPtr':  ('O', virConnect, virConnectPtr, 
virConnectPtr),
 'virConnect *':  ('O', virConnect, virConnectPtr, virConnectPtr),
 'const virConnect *':  ('O', virConnect, virConnectPtr, 
virConnectPtr),
+
+'virNodeDevicePtr':  ('O', virNodeDevice, virNodeDevicePtr, 
virNodeDevicePtr),
+'const virNodeDevicePtr':  ('O', virNodeDevice, virNodeDevicePtr, 
virNodeDevicePtr),
+'virNodeDevice *':  ('O', virNodeDevice, virNodeDevicePtr, 
virNodeDevicePtr),
+'const virNodeDevice *':  ('O', virNodeDevice, virNodeDevicePtr, 
virNodeDevicePtr),
 }
 
 py_return_types = {
@@ -318,6 +323,9 @@
 'virDomainBlockPeek',
 'virDomainMemoryPeek',
 'virEventRegisterImpl',
+'virNodeListDevicesByCap',
+'virNodeListDevices',
+'virNodeDeviceListCaps',
 )
 
 
@@ -601,6 +609,8 @@
 virStoragePool *: (._o, virStoragePool(self, _obj=%s), 
virStoragePool),
 virStorageVolPtr: (._o, virStorageVol(self, _obj=%s), 
virStorageVol),
 virStorageVol *: (._o, virStorageVol(self, _obj=%s), 
virStorageVol),
+virNodeDevicePtr: (._o, virNodeDevice(self, _obj=%s), 
virNodeDevice),
+virNodeDevice *: (._o, virNodeDevice(self, _obj=%s), 
virNodeDevice),
 virConnectPtr: (._o, virConnect(_obj=%s), virConnect),
 virConnect *: (._o, virConnect(_obj=%s), virConnect),
 }
@@ -608,7 +618,8 @@
 converter_type = {
 }
 
-primary_classes = [virDomain, virNetwork, virStoragePool, 
virStorageVol, virConnect]
+primary_classes = [virDomain, virNetwork, virStoragePool, 
virStorageVol,
+   virConnect, virNodeDevice ]
 
 classes_ancestor = {
 }
@@ -617,6 +628,7 @@
 virNetwork: virNetworkFree,
 virStoragePool: virStoragePoolFree,
 virStorageVol: virStorageVolFree,
+virNodeDevice : virNodeDeviceFree
 }
 
 functions_noexcept = {
@@ -626,6 +638,8 @@
 'virStoragePoolGetName': True,
 'virStorageVolGetName': True,
 'virStorageVolGetkey': True,
+'virNodeDeviceGetName': True,
+'virNodeDeviceGetParent': True,
 }
 
 reference_keepers = {
@@ -706,6 +720,13 @@
 elif name[0:13] == virStorageVol:
 func = name[13:]
 func = string.lower(func[0:1]) + func[1:]
+elif name[0:13] == virNodeDevice:
+if name[13:16] == Get:
+func = string.lower(name[16]) + name[17:]
+elif name[13:19] == Lookup or name[13:] == Create:
+func = string.lower(name[3]) + name[4:]
+else:
+func = string.lower(name[13]) + name[14:]
 elif name[0:7] == virNode:
 func = name[7:]
 func = string.lower(func[0:1]) + func[1:]
@@ -958,7 +979,7 @@
else:
txt.write(Class %s()\n % (classname))
classes.write(class %s:\n % (classname))
-if classname in [ virDomain, virNetwork, virStoragePool, 
virStorageVol ]:
+if classname in [ virDomain, virNetwork, virStoragePool, 
virStorageVol, virNodeDevice ]:
 classes.write(def __init__(self, conn, _obj=None):\n)
 else:
 classes.write(def __init__(self, _obj=None):\n)
@@ -966,7 +987,7 @@
list = reference_keepers[classname]
for ref in list:
classes.write(self.%s = None\n % ref[1])
-if classname in [ virDomain, virNetwork ]:
+if classname in [ virDomain, virNetwork, virNodeDevice ]:
 classes.write(self._conn = conn\n)
 elif classname in [ virStorageVol, virStoragePool ]:
 classes.write(self._conn = conn\n + \
diff -r b2546652397b python/libvir.c
--- a/python/libvir.c   Fri Nov 07 18:44:05 2008 +
+++ b/python/libvir.c   Fri Nov 07 18:44:21 2008 +
@@ -1465,6 +1465,132 @@
 py_retval = libvirt_virStoragePoolPtrWrap((virStoragePoolPtr) c_retval);
 return(py_retval);
 }
+
+static PyObject *
+libvirt_virNodeListDevices(PyObject *self ATTRIBUTE_UNUSED,
+   PyObject *args) {
+PyObject *py_retval;
+char **names = NULL;
+int c_retval, i;
+virConnectPtr conn;
+PyObject *pyobj_conn;
+unsigned int flags;
+
+
+if (!PyArg_ParseTuple(args, (char *)Oi:virNodeListDevices, pyobj_conn, 
flags))
+return(NULL);
+conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+c_retval = virNodeNumOfDevices(conn, flags);
+if (c_retval  0)
+return VIR_PY_NONE;
+
+if (c_retval) {
+names = malloc(sizeof(*names) * c_retval);
+if (!names)
+return VIR_PY_NONE;
+c_retval = virNodeListDevices(conn, names, c_retval, flags);
+if (c_retval  0) {
+free(names);
+  

Re: [libvirt] PATCH: 2/12: Make use of versioned linker scripts

2008-11-13 Thread Daniel P. Berrange
On Thu, Nov 13, 2008 at 06:31:04PM +0100, Daniel Veillard wrote:
 On Thu, Nov 13, 2008 at 05:21:23PM +, Daniel P. Berrange wrote:
  This patch changes the way we use linker scripts to have fully versioned
  symbols, and a versioned private section for symbols needed by libvirtd
  and virsh.
 
   Just a couple of questions:
 
  +++ b/src/driver.h  Tue Nov 11 17:28:31 2008 +
  @@ -73,7 +73,7 @@
   typedef int
   (*virDrvClose) (virConnectPtr conn);
   typedef int
  -(*virDrvSupportsFeature) (virConnectPtr conn, int feature);
  +(*virDrvDrvSupportsFeature) (virConnectPtr conn, int feature);
 
   I miss the point ... err why ?

When I removed the __ from the 'private' symbols exported, this
internal driver typedef now clashes with the following public
symbol:

 -ret-supported = __virDrvSupportsFeature (client-conn, args-feature);
 +ret-supported = virDrvSupportsFeature (client-conn, args-feature);
 if (ret-supported == -1) return -1;

The DrvDrv looks a little odd, but it is actually consistent with
the naming for driver.h, which is basically s/vir/virDrv/ against
the public API :-)


 
 ...]
  diff -r bbf3d0bc9d49 src/libvirt_sym.version.in
 [...]
  +LIBVIRT_0.5.0 {
  +global:
  +   virDomainCreateXML;
  +   virEventRegisterImpl;
  +   virConnectDomainEventRegister;
  +   virConnectDomainEventDeregister;
  +} LIBVIRT_0.4.5;
  +
  +/*  define new API here using predicted next version number  */
 
 So basically as part of doing a release I should guess the new version
 number and make a template empty section here, commited after tagging
 the release.

Yeah, that'd be a reasonable thing todo - just add .1 to the existing
version. If we end up adding lots of new symbols, it'll be fairly obvious
that we should increment a major version number instead.

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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list