[libvirt] [PATCH 03/12] Move virInterface related APIs out of libvirt.h.in

Daniel P. Berrange berrange at redhat.com
Thu Oct 23 12:58:25 UTC 2014


Create a new libvirt-interface.h file to hold the public
API definitions for the virInterface type. This header
file is not self-contained, so applications will not directly
include it. They will contain to #include <libvirt/libvirt.h>
---
 docs/apibuild.py                    |   2 +
 include/libvirt/Makefile.am         |   2 +
 include/libvirt/libvirt-interface.h | 110 ++++++++++
 include/libvirt/libvirt.h.in        | 390 +-----------------------------------
 4 files changed, 116 insertions(+), 388 deletions(-)
 create mode 100644 include/libvirt/libvirt-interface.h

diff --git a/docs/apibuild.py b/docs/apibuild.py
index 55d09f0..0e0f052 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -23,6 +23,8 @@ debugsym=None
 included_files = {
   "libvirt.h": "header with general libvirt API definitions",
   "libvirt-domain-snapshot.h": "header with general libvirt API definitions",
+  "libvirt-interface.h": "header with general libvirt API definitions",
+  "libvirt-network.h": "header with general libvirt API definitions",
   "virterror.h": "header with error specific API definitions",
   "libvirt.c": "Main interfaces for the libvirt library",
   "libvirt-domain.c": "Domain interfaces for the libvirt library",
diff --git a/include/libvirt/Makefile.am b/include/libvirt/Makefile.am
index ea935b0..9e7b1fb 100644
--- a/include/libvirt/Makefile.am
+++ b/include/libvirt/Makefile.am
@@ -20,6 +20,8 @@ virincdir = $(includedir)/libvirt
 
 virinc_HEADERS = libvirt.h		\
 		 libvirt-domain-snapshot.h \
+		 libvirt-interface.h \
+		 libvirt-network.h \
 		 libvirt-lxc.h		\
 		 libvirt-qemu.h		\
 		 virterror.h
diff --git a/include/libvirt/libvirt-interface.h b/include/libvirt/libvirt-interface.h
new file mode 100644
index 0000000..60c53e6
--- /dev/null
+++ b/include/libvirt/libvirt-interface.h
@@ -0,0 +1,110 @@
+/*
+ * libvirt-interface.h
+ * Summary: APIs for management of interfaces
+ * Description: Provides APIs for the management of interfaces
+ * Author: Daniel Veillard <veillard at redhat.com>
+ *
+ * Copyright (C) 2006-2014 Red Hat, Inc.
+ *
+ * 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, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __VIR_LIBVIRT_INTERFACE_H__
+# define __VIR_LIBVIRT_INTERFACE_H__
+
+# ifndef __VIR_LIBVIRT_H_INCLUDES__
+#  error "Don't include this file directly, only use libvirt/libvirt.h"
+# endif
+
+/**
+ * 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;
+
+virConnectPtr           virInterfaceGetConnect    (virInterfacePtr iface);
+
+int                     virConnectNumOfInterfaces (virConnectPtr conn);
+int                     virConnectListInterfaces  (virConnectPtr conn,
+                                                   char **const names,
+                                                   int maxnames);
+
+int                     virConnectNumOfDefinedInterfaces (virConnectPtr conn);
+int                     virConnectListDefinedInterfaces  (virConnectPtr conn,
+                                                          char **const names,
+                                                          int maxnames);
+/*
+ * virConnectListAllInterfaces:
+ *
+ * Flags used to filter the returned interfaces.
+ */
+typedef enum {
+    VIR_CONNECT_LIST_INTERFACES_INACTIVE      = 1 << 0,
+    VIR_CONNECT_LIST_INTERFACES_ACTIVE        = 1 << 1,
+} virConnectListAllInterfacesFlags;
+
+int                     virConnectListAllInterfaces (virConnectPtr conn,
+                                                     virInterfacePtr **ifaces,
+                                                     unsigned int flags);
+
+virInterfacePtr         virInterfaceLookupByName  (virConnectPtr conn,
+                                                   const char *name);
+virInterfacePtr         virInterfaceLookupByMACString (virConnectPtr conn,
+                                                       const char *mac);
+
+const char*             virInterfaceGetName       (virInterfacePtr iface);
+const char*             virInterfaceGetMACString  (virInterfacePtr iface);
+
+typedef enum {
+    VIR_INTERFACE_XML_INACTIVE = 1 << 0 /* dump inactive interface information */
+} virInterfaceXMLFlags;
+
+char *                  virInterfaceGetXMLDesc    (virInterfacePtr iface,
+                                                   unsigned int flags);
+virInterfacePtr         virInterfaceDefineXML     (virConnectPtr conn,
+                                                   const char *xmlDesc,
+                                                   unsigned int flags);
+
+int                     virInterfaceUndefine      (virInterfacePtr iface);
+
+int                     virInterfaceCreate        (virInterfacePtr iface,
+                                                   unsigned int flags);
+
+int                     virInterfaceDestroy       (virInterfacePtr iface,
+                                                   unsigned int flags);
+
+int                     virInterfaceRef           (virInterfacePtr iface);
+int                     virInterfaceFree          (virInterfacePtr iface);
+
+int                     virInterfaceChangeBegin   (virConnectPtr conn,
+                                                   unsigned int flags);
+int                     virInterfaceChangeCommit  (virConnectPtr conn,
+                                                   unsigned int flags);
+int                     virInterfaceChangeRollback(virConnectPtr conn,
+                                                   unsigned int flags);
+
+int virInterfaceIsActive(virInterfacePtr iface);
+
+
+#endif /* __VIR_LIBVIRT_INTERFACE_H__ */
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 77c7b1b..e231bde 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2855,271 +2855,7 @@ int                      virNodeGetCellsFreeMemory(virConnectPtr conn,
                                                    int startCell,
                                                    int maxCells);
 
-/*
- * Virtual Networks API
- */
-
-typedef enum {
-    VIR_NETWORK_XML_INACTIVE = (1 << 0), /* dump inactive network information */
-} virNetworkXMLFlags;
 
-/**
- * virNetwork:
- *
- * a virNetwork is a private structure representing a virtual network.
- */
-typedef struct _virNetwork virNetwork;
-
-/**
- * virNetworkPtr:
- *
- * a virNetworkPtr is pointer to a virNetwork private structure, this is the
- * type used to reference a virtual network in the API.
- */
-typedef virNetwork *virNetworkPtr;
-
-/*
- * Get connection from network.
- */
-virConnectPtr           virNetworkGetConnect    (virNetworkPtr network);
-
-/*
- * List active networks
- */
-int                     virConnectNumOfNetworks (virConnectPtr conn);
-int                     virConnectListNetworks  (virConnectPtr conn,
-                                                 char **const names,
-                                                 int maxnames);
-
-/*
- * List inactive networks
- */
-int                     virConnectNumOfDefinedNetworks  (virConnectPtr conn);
-int                     virConnectListDefinedNetworks   (virConnectPtr conn,
-                                                         char **const names,
-                                                         int maxnames);
-/*
- * virConnectListAllNetworks:
- *
- * Flags used to filter the returned networks. Flags in each group
- * are exclusive attributes of a network.
- */
-typedef enum {
-    VIR_CONNECT_LIST_NETWORKS_INACTIVE      = 1 << 0,
-    VIR_CONNECT_LIST_NETWORKS_ACTIVE        = 1 << 1,
-
-    VIR_CONNECT_LIST_NETWORKS_PERSISTENT    = 1 << 2,
-    VIR_CONNECT_LIST_NETWORKS_TRANSIENT     = 1 << 3,
-
-    VIR_CONNECT_LIST_NETWORKS_AUTOSTART     = 1 << 4,
-    VIR_CONNECT_LIST_NETWORKS_NO_AUTOSTART  = 1 << 5,
-} virConnectListAllNetworksFlags;
-
-int                     virConnectListAllNetworks       (virConnectPtr conn,
-                                                         virNetworkPtr **nets,
-                                                         unsigned int flags);
-
-/*
- * Lookup network by name or uuid
- */
-virNetworkPtr           virNetworkLookupByName          (virConnectPtr conn,
-                                                         const char *name);
-virNetworkPtr           virNetworkLookupByUUID          (virConnectPtr conn,
-                                                         const unsigned char *uuid);
-virNetworkPtr           virNetworkLookupByUUIDString    (virConnectPtr conn,
-                                                         const char *uuid);
-
-/*
- * Create active transient network
- */
-virNetworkPtr           virNetworkCreateXML     (virConnectPtr conn,
-                                                 const char *xmlDesc);
-
-/*
- * Define inactive persistent network
- */
-virNetworkPtr           virNetworkDefineXML     (virConnectPtr conn,
-                                                 const char *xmlDesc);
-
-/*
- * Delete persistent network
- */
-int                     virNetworkUndefine      (virNetworkPtr network);
-
-/**
- * virNetworkUpdateCommand:
- *
- * describes which type of update to perform on a <network>
- * definition.
- *
- */
-typedef enum {
-    VIR_NETWORK_UPDATE_COMMAND_NONE      = 0, /* (invalid) */
-    VIR_NETWORK_UPDATE_COMMAND_MODIFY    = 1, /* modify an existing element */
-    VIR_NETWORK_UPDATE_COMMAND_DELETE    = 2, /* delete an existing element */
-    VIR_NETWORK_UPDATE_COMMAND_ADD_LAST  = 3, /* add an element at end of list */
-    VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST = 4, /* add an element at start of list */
-#ifdef VIR_ENUM_SENTINELS
-    VIR_NETWORK_UPDATE_COMMAND_LAST
-#endif
-} virNetworkUpdateCommand;
-
-/**
- * virNetworkUpdateSection:
- *
- * describes which section of a <network> definition the provided
- * xml should be applied to.
- *
- */
-typedef enum {
-    VIR_NETWORK_SECTION_NONE              =  0, /* (invalid) */
-    VIR_NETWORK_SECTION_BRIDGE            =  1, /* <bridge> */
-    VIR_NETWORK_SECTION_DOMAIN            =  2, /* <domain> */
-    VIR_NETWORK_SECTION_IP                =  3, /* <ip> */
-    VIR_NETWORK_SECTION_IP_DHCP_HOST      =  4, /* <ip>/<dhcp>/<host> */
-    VIR_NETWORK_SECTION_IP_DHCP_RANGE     =  5, /* <ip>/<dhcp>/<range> */
-    VIR_NETWORK_SECTION_FORWARD           =  6, /* <forward> */
-    VIR_NETWORK_SECTION_FORWARD_INTERFACE =  7, /* <forward>/<interface> */
-    VIR_NETWORK_SECTION_FORWARD_PF        =  8, /* <forward>/<pf> */
-    VIR_NETWORK_SECTION_PORTGROUP         =  9, /* <portgroup> */
-    VIR_NETWORK_SECTION_DNS_HOST          = 10, /* <dns>/<host> */
-    VIR_NETWORK_SECTION_DNS_TXT           = 11, /* <dns>/<txt> */
-    VIR_NETWORK_SECTION_DNS_SRV           = 12, /* <dns>/<srv> */
-#ifdef VIR_ENUM_SENTINELS
-    VIR_NETWORK_SECTION_LAST
-#endif
-} virNetworkUpdateSection;
-
-/**
- * virNetworkUpdateFlags:
- *
- * Flags to control options for virNetworkUpdate()
- */
-typedef enum {
-    VIR_NETWORK_UPDATE_AFFECT_CURRENT = 0,      /* affect live if network is active,
-                                                   config if it's not active */
-    VIR_NETWORK_UPDATE_AFFECT_LIVE    = 1 << 0, /* affect live state of network only */
-    VIR_NETWORK_UPDATE_AFFECT_CONFIG  = 1 << 1, /* affect persistent config only */
-} virNetworkUpdateFlags;
-
-/*
- * Update an existing network definition
- */
-int                     virNetworkUpdate(virNetworkPtr network,
-                                         unsigned int command, /* virNetworkUpdateCommand */
-                                         unsigned int section, /* virNetworkUpdateSection */
-                                         int parentIndex,
-                                         const char *xml,
-                                         unsigned int flags);
-
-/*
- * Activate persistent network
- */
-int                     virNetworkCreate        (virNetworkPtr network);
-
-/*
- * Network destroy/free
- */
-int                     virNetworkDestroy       (virNetworkPtr network);
-int                     virNetworkRef           (virNetworkPtr network);
-int                     virNetworkFree          (virNetworkPtr network);
-
-/*
- * Network information
- */
-const char*             virNetworkGetName       (virNetworkPtr network);
-int                     virNetworkGetUUID       (virNetworkPtr network,
-                                                 unsigned char *uuid);
-int                     virNetworkGetUUIDString (virNetworkPtr network,
-                                                 char *buf);
-char *                  virNetworkGetXMLDesc    (virNetworkPtr network,
-                                                 unsigned int flags);
-char *                  virNetworkGetBridgeName (virNetworkPtr network);
-
-int                     virNetworkGetAutostart  (virNetworkPtr network,
-                                                 int *autostart);
-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;
-
-virConnectPtr           virInterfaceGetConnect    (virInterfacePtr iface);
-
-int                     virConnectNumOfInterfaces (virConnectPtr conn);
-int                     virConnectListInterfaces  (virConnectPtr conn,
-                                                   char **const names,
-                                                   int maxnames);
-
-int                     virConnectNumOfDefinedInterfaces (virConnectPtr conn);
-int                     virConnectListDefinedInterfaces  (virConnectPtr conn,
-                                                          char **const names,
-                                                          int maxnames);
-/*
- * virConnectListAllInterfaces:
- *
- * Flags used to filter the returned interfaces.
- */
-typedef enum {
-    VIR_CONNECT_LIST_INTERFACES_INACTIVE      = 1 << 0,
-    VIR_CONNECT_LIST_INTERFACES_ACTIVE        = 1 << 1,
-} virConnectListAllInterfacesFlags;
-
-int                     virConnectListAllInterfaces (virConnectPtr conn,
-                                                     virInterfacePtr **ifaces,
-                                                     unsigned int flags);
-
-virInterfacePtr         virInterfaceLookupByName  (virConnectPtr conn,
-                                                   const char *name);
-virInterfacePtr         virInterfaceLookupByMACString (virConnectPtr conn,
-                                                       const char *mac);
-
-const char*             virInterfaceGetName       (virInterfacePtr iface);
-const char*             virInterfaceGetMACString  (virInterfacePtr iface);
-
-typedef enum {
-    VIR_INTERFACE_XML_INACTIVE = 1 << 0 /* dump inactive interface information */
-} virInterfaceXMLFlags;
-
-char *                  virInterfaceGetXMLDesc    (virInterfacePtr iface,
-                                                   unsigned int flags);
-virInterfacePtr         virInterfaceDefineXML     (virConnectPtr conn,
-                                                   const char *xmlDesc,
-                                                   unsigned int flags);
-
-int                     virInterfaceUndefine      (virInterfacePtr iface);
-
-int                     virInterfaceCreate        (virInterfacePtr iface,
-                                                   unsigned int flags);
-
-int                     virInterfaceDestroy       (virInterfacePtr iface,
-                                                   unsigned int flags);
-
-int                     virInterfaceRef           (virInterfacePtr iface);
-int                     virInterfaceFree          (virInterfacePtr iface);
-
-int                     virInterfaceChangeBegin   (virConnectPtr conn,
-                                                   unsigned int flags);
-int                     virInterfaceChangeCommit  (virConnectPtr conn,
-                                                   unsigned int flags);
-int                     virInterfaceChangeRollback(virConnectPtr conn,
-                                                   unsigned int flags);
 
 /**
  * virStoragePool:
@@ -4241,13 +3977,9 @@ int virDomainIsActive(virDomainPtr dom);
 int virDomainIsPersistent(virDomainPtr dom);
 int virDomainIsUpdated(virDomainPtr dom);
 
-int virNetworkIsActive(virNetworkPtr net);
-int virNetworkIsPersistent(virNetworkPtr net);
-
 int virStoragePoolIsActive(virStoragePoolPtr pool);
 int virStoragePoolIsPersistent(virStoragePoolPtr pool);
 
-int virInterfaceIsActive(virInterfacePtr iface);
 
 int virConnectIsEncrypted(virConnectPtr conn);
 int virConnectIsSecure(virConnectPtr conn);
@@ -5228,126 +4960,6 @@ int virConnectDomainEventRegisterAny(virConnectPtr conn,
 int virConnectDomainEventDeregisterAny(virConnectPtr conn,
                                        int callbackID);
 
-/**
- * virNetworkEventLifecycleType:
- *
- * a virNetworkEventLifecycleType is emitted during network lifecycle events
- */
-typedef enum {
-    VIR_NETWORK_EVENT_DEFINED = 0,
-    VIR_NETWORK_EVENT_UNDEFINED = 1,
-    VIR_NETWORK_EVENT_STARTED = 2,
-    VIR_NETWORK_EVENT_STOPPED = 3,
-
-#ifdef VIR_ENUM_SENTINELS
-    VIR_NETWORK_EVENT_LAST
-#endif
-} virNetworkEventLifecycleType;
-
-/**
- * virConnectNetworkEventLifecycleCallback:
- * @conn: connection object
- * @net: network on which the event occurred
- * @event: The specific virNetworkEventLifeCycleType which occurred
- * @detail: contains some details on the reason of the event.
- *          It will be 0 for the while.
- * @opaque: application specified data
- *
- * This callback occurs when the network is started or stopped.
- *
- * The callback signature to use when registering for an event of type
- * VIR_NETWORK_EVENT_ID_LIFECYCLE with virConnectNetworkEventRegisterAny()
- */
-typedef void (*virConnectNetworkEventLifecycleCallback)(virConnectPtr conn,
-                                                        virNetworkPtr net,
-                                                        int event,
-                                                        int detail,
-                                                        void *opaque);
-
-/**
- * VIR_NETWORK_EVENT_CALLBACK:
- *
- * Used to cast the event specific callback into the generic one
- * for use for virConnectNetworkEventRegisterAny()
- */
-#define VIR_NETWORK_EVENT_CALLBACK(cb) ((virConnectNetworkEventGenericCallback)(cb))
-
-/**
- * virNetworkEventID:
- *
- * An enumeration of supported eventId parameters for
- * virConnectNetworkEventRegisterAny().  Each event id determines which
- * signature of callback function will be used.
- */
-typedef enum {
-    VIR_NETWORK_EVENT_ID_LIFECYCLE = 0,       /* virConnectNetworkEventLifecycleCallback */
-
-#ifdef VIR_ENUM_SENTINELS
-    VIR_NETWORK_EVENT_ID_LAST
-    /*
-     * NB: this enum value will increase over time as new events are
-     * added to the libvirt API. It reflects the last event ID supported
-     * by this version of the libvirt API.
-     */
-#endif
-} virNetworkEventID;
-
-typedef enum {
-    VIR_IP_ADDR_TYPE_IPV4,
-    VIR_IP_ADDR_TYPE_IPV6,
-
-#ifdef VIR_ENUM_SENTINELS
-    VIR_IP_ADDR_TYPE_LAST
-#endif
-} virIPAddrType;
-
-typedef struct _virNetworkDHCPLease virNetworkDHCPLease;
-typedef virNetworkDHCPLease *virNetworkDHCPLeasePtr;
-struct _virNetworkDHCPLease {
-    char *iface;                /* Network interface name */
-    long long expirytime;       /* Seconds since epoch */
-    int type;                   /* virIPAddrType */
-    char *mac;                  /* MAC address */
-    char *iaid;                 /* IAID */
-    char *ipaddr;               /* IP address */
-    unsigned int prefix;        /* IP address prefix */
-    char *hostname;             /* Hostname */
-    char *clientid;             /* Client ID or DUID */
-};
-
-void virNetworkDHCPLeaseFree(virNetworkDHCPLeasePtr lease);
-
-int virNetworkGetDHCPLeases(virNetworkPtr network,
-                            const char *mac,
-                            virNetworkDHCPLeasePtr **leases,
-                            unsigned int flags);
-
-/**
- * virConnectNetworkEventGenericCallback:
- * @conn: the connection pointer
- * @net: the network pointer
- * @opaque: application specified data
- *
- * A generic network event callback handler, for use with
- * virConnectNetworkEventRegisterAny(). Specific events usually
- * have a customization with extra parameters, often with @opaque being
- * passed in a different parameter position; use VIR_NETWORK_EVENT_CALLBACK()
- * when registering an appropriate handler.
- */
-typedef void (*virConnectNetworkEventGenericCallback)(virConnectPtr conn,
-                                                      virNetworkPtr net,
-                                                      void *opaque);
-
-/* Use VIR_NETWORK_EVENT_CALLBACK() to cast the 'cb' parameter  */
-int virConnectNetworkEventRegisterAny(virConnectPtr conn,
-                                      virNetworkPtr net, /* Optional, to filter */
-                                      int eventID,
-                                      virConnectNetworkEventGenericCallback cb,
-                                      void *opaque,
-                                      virFreeCallback freecb);
-
-int virConnectNetworkEventDeregisterAny(virConnectPtr conn,
-                                        int callbackID);
 
 /**
  * virNWFilter:
@@ -5651,6 +5263,8 @@ typedef virMemoryParameter *virMemoryParameterPtr;
 
 #define __VIR_LIBVIRT_H_INCLUDES__
 #include <libvirt/libvirt-domain-snapshot.h>
+#include <libvirt/libvirt-interface.h>
+#include <libvirt/libvirt-network.h>
 #undef __VIR_LIBVIRT_H_INCLUDES__
 
 #ifdef __cplusplus
-- 
2.1.0




More information about the libvir-list mailing list