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

Re: [libvirt] [Fwd: first cut public API for physical host interface configuration]



To summarize (correct anything I've gotten wrong):

1) Supporting transient interfaces would be nice, but would require too much re-implementation of ifup-type scripts in our code (and for every platorm), so it is out of scope. danpb thinks at least being able to query transient interfaces (those that exist, but have no ifcfg-* file) would be nice. (Since libnetcf currently does everything by reading the ifcfg-* files and converting them into XML, that would require some work).

2) Just querying by name isn't good enough, but using UUID creates extra complexity. The problem can also solved by querying with MAC address. I'll add in the appropriate functions.

3) For consistency, virInterfaceStart() should be renamed to virInterfaceCreate(), and virInterfaceStop() to either virInterfaceDestroy() or virInterfaceDelete() (I still like Startp/Stop, since htey imply that the objects can be re-used, but The idea of a less polluted namespace has its advantages). So which

4) virInterfaceDefineXML(), virInterfaceCreate(), and virInterfaceHumiliateAndEmasculate() (pending a concensus on name) should have a "flags" argument added, currently unused, but to allow for future expansion without needing to obsolete the API.

5) For bonus points, danpb suggests adding:

  int virInterfaceStats (virInterfacePtr interface,
                         virInterfaceStatsPtr stats,
                         size_t size);

Useful idea, but I'll save the bonus points for later - right now I'm just trying to avoid getting kicked off the island! (seriously, though, that is outside the current scope of libnetcf. Depending on what stats you wanted, it could be implemented on linux by just sifting through /proc/net/dev. Are you just looking for the same stats that are delivered by virDomainInterfaceStats (except for the physical host)?

Did I get everything? (I'm attaching another libvirt.h diff, based on the comments).



diff --git a/include/libvirt/libvirt.h b/include/libvirt/libvirt.h
index 779ea72..b92a799 100644
--- a/include/libvirt/libvirt.h
+++ b/include/libvirt/libvirt.h
@@ -854,6 +854,79 @@ int                     virNetworkGetAutostart  (virNetworkPtr network,
 int                     virNetworkSetAutostart  (virNetworkPtr network,
                                                  int autostart);
 
+/*
+ * Physical host interface configuration API
+ */
+
+/**
+ * virInterface:
+ *
+ * a virInterface is a private structure representing a virtual interface.
+ */
+typedef struct _virInterface virInterface;
+
+/**
+ * virInterfacePtr:
+ *
+ * a virInterfacePtr is pointer to a virInterface private structure, this is the
+ * type used to reference a virtual interface in the API.
+ */
+typedef virInterface *virInterfacePtr;
+
+/*
+ * Get connection from interface.
+ */
+virConnectPtr           virInterfaceGetConnect    (virInterfacePtr interface);
+
+/*
+ * List defined interfaces
+ */
+int                     virConnectNumOfInterfaces (virConnectPtr conn);
+int                     virConnectListInterfaces  (virConnectPtr conn,
+                                                   char **const names,
+                                                   int maxnames);
+
+/*
+ * Lookup interface by name or MAC address
+ */
+virInterfacePtr         virInterfaceLookupByName  (virConnectPtr conn,
+                                                   const char *name);
+virInterfacePtr         virInterfaceLookupByMAC   (virConnectPtr conn,
+                                                   const unsigned char *mac);
+
+/*
+ * Define interface (or modify existing interface configuration)
+ */
+virInterfacePtr         virInterfaceDefineXML     (virConnectPtr conn,
+                                                   const char *xmlDesc,
+                                                   int flags);
+
+/*
+ * Delete interface
+ */
+int                     virInterfaceUndefine      (virInterfacePtr interface);
+
+/*
+ * Activate interface (ie call "ifup")
+ */
+int                     virInterfaceCreate        (virInterfacePtr interface,
+                                                   int flags);
+
+/*
+ * De-activate interface (call "ifdown")
+ */
+int                     virInterfaceDestroy       (virInterfacePtr interface,
+                                                   int flags);
+
+/*
+ * Interface information
+ */
+const char*             virInterfaceGetName       (virInterfacePtr interface);
+int                     virInterfaceGetMAC        (virInterfacePtr interface,
+                                                   unsigned char *mac);
+
+char *                  virInterfaceGetXMLDesc    (virInterfacePtr interface,
+                                                   int flags);
 
 /**
  * virStoragePool:

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