Re: [libvirt] Re: [PATCH 1/6] host (node) device enumeration - public API additions

2008-10-28 Thread Daniel Veillard
On Tue, Oct 21, 2008 at 01:49:19PM -0400, David Lively wrote:
 This patch contains the public API additions.
 

  the libvirt.h part looks just fine at this point for me.
I'm just wondering a bit about some of the naming node driver
are devkit and Hal really node drivers, then sound more like
device watcher.
  Maybe the error file should state
VIR_FROM_DEVWATCH instead of VIR_FROM_NODE
then the names we pick for the internal symbols can be changed

  We will need to augment the terminology section at some point
but I'm not sure what's the best way to describe those new internal
APIs, Node driver doesn't really fit IMHO, Device watcher is a bit
better but doesn't feel great either.


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


[libvirt] Re: [PATCH 1/6] host (node) device enumeration - public API additions

2008-10-21 Thread David Lively
This patch contains the public API additions.

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 3624367..c888943 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -993,6 +993,76 @@ char *  virStorageVolGetPath(virStorageVolPtr vol);
 virDomainPtrvirDomainCreateLinux(virConnectPtr conn,
  const char *xmlDesc,
  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);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 8e24708..020b8dc 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -58,6 +58,7 @@ typedef enum {
 VIR_FROM_STORAGE,   /* Error from storage driver */
 VIR_FROM_NETWORK,   /* Error from network config */
 VIR_FROM_DOMAIN,/* Error from domain config */
+VIR_FROM_NODE,  /* Error from node driver */
 } virErrorDomain;
 
 
@@ -148,6 +149,9 @@ typedef enum {
 VIR_WAR_NO_STORAGE, /* failed to start storage */
 VIR_ERR_NO_STORAGE_POOL, /* storage pool not found */
 VIR_ERR_NO_STORAGE_VOL, /* storage pool not found */
+VIR_WAR_NO_NODE, /* failed to start node driver */
+VIR_ERR_INVALID_NODE_DEVICE,/* invalid node device object */
+VIR_ERR_NO_NODE_DEVICE,/* node device not found */
 } virErrorNumber;
 
 /**
diff --git a/src/libvirt.c b/src/libvirt.c
index ca2675a..5cef752 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -73,6 +73,8 @@ static virNetworkDriverPtr virNetworkDriverTab[MAX_DRIVERS];
 static int virNetworkDriverTabCount = 0;
 static virStorageDriverPtr virStorageDriverTab[MAX_DRIVERS];
 static int virStorageDriverTabCount = 0;
+static virNodeDriverPtr virNodeDriverTab[MAX_DRIVERS];
+static int virNodeDriverTabCount = 0;
 #ifdef WITH_LIBVIRTD
 static virStateDriverPtr virStateDriverTab[MAX_DRIVERS];
 static int virStateDriverTabCount = 0;
@@ -299,6 +301,12 @@ virInitialize(void)
 #ifdef WITH_NETWORK
 if (networkRegister() == -1) return -1;
 #endif
+#ifdef HAVE_HAL
+if (halNodeRegister() == -1) return -1;
+#endif
+#ifdef HAVE_DEVKIT
+if (devkitNodeRegister() == -1) return -1;
+#endif
 if (storageRegister() == -1) return -1;