[PATCH 1/7] fspool: introduce filesystem pools API

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

 



From: Olga Krishtal <okrishtal@xxxxxxxxxxxxx>

API follows the API of storage pools closely in parts which
do not differ for filesystems.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
 include/libvirt/libvirt-fs.h | 273 +++++++++++++++++++++++++++++++++++++++++++
 include/libvirt/libvirt.h    |   1 +
 2 files changed, 274 insertions(+)
 create mode 100644 include/libvirt/libvirt-fs.h

diff --git a/include/libvirt/libvirt-fs.h b/include/libvirt/libvirt-fs.h
new file mode 100644
index 0000000..4385220
--- /dev/null
+++ b/include/libvirt/libvirt-fs.h
@@ -0,0 +1,273 @@
+/* libvirt-fs.h
+ * Summary: APIs for management of filesystem pools and items
+ * Description: Provides APIs for the management of filesystem pools and items
+ * Author: Olga Krishtal <okrishtal@xxxxxxxxxxxxx>
+ *
+ * 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_FS_H__
+# define __VIR_LIBVIRT_FS_H__
+
+# ifndef __VIR_LIBVIRT_H_INCLUDES__
+#  error "Don't include this file directly, only use libvirt/libvirt.h"
+# endif
+
+typedef enum {
+    VIR_FS_POOL_CREATE_NORMAL = 0,
+
+    /* Create the fspool and perform fspool build without any flags */
+    VIR_FS_POOL_CREATE_WITH_BUILD = 1 << 0,
+
+    /* Create the fspool and perform fspool build using the
+     * exclusive to VIR_FS_POOL_CREATE_WITH_BUILD_NO_OVERWRITE */
+    VIR_FS_POOL_CREATE_WITH_BUILD_OVERWRITE = 1 << 1,
+
+    /* Create the pool and perform pool build using the
+     * VIR_FS_POOL_BUILD_NO_OVERWRITE flag. This is mutually
+     * exclusive to VIR_FS_POOL_CREATE_WITH_BUILD_OVERWRITE */
+    VIR_FS_POOL_CREATE_WITH_BUILD_NO_OVERWRITE = 1 << 2,
+} virFsPoolCreateFlags;
+
+typedef enum {
+    VIR_FS_POOL_BUILD_NEW  = 0,   /* Regular build from scratch */
+    VIR_FS_POOL_BUILD_NO_OVERWRITE = (1 << 2),  /* Do not overwrite existing pool */
+    VIR_FS_POOL_BUILD_OVERWRITE = (1 << 3),  /* Overwrite data */
+} virFsPoolBuildFlags;
+
+/**
+ * virFsPool:
+ *
+ * a virFsPool is a private structure representing a fspool
+ */
+typedef struct _virFsPool virFsPool;
+
+/**
+ * virFsPoolPtr:
+ *
+ * a virFSPoolPtr is pointer to a virFsPool private structure, this is the
+ * type used to reference a fspool in the API.
+ */
+typedef virFsPool *virFsPoolPtr;
+
+typedef enum {
+    VIR_FS_POOL_INACTIVE = 0,
+    VIR_FS_POOL_BUILDING = 1,
+    VIR_FS_POOL_RUNNING = 2,
+
+# ifdef VIR_ENUM_SENTINELS
+    VIR_FS_POOL_STATE_LAST
+# endif
+} virFsPoolState;
+
+typedef struct _virFsPoolInfo virFsPoolInfo;
+
+struct _virFsPoolInfo {
+    int state;                     /* virFsPoolState flags */
+    unsigned long long capacity;   /* Logical size bytes */
+    unsigned long long allocation; /* Current allocation bytes */
+    unsigned long long available;  /* Remaining free space bytes */
+};
+
+typedef virFsPoolInfo *virFsPoolInfoPtr;
+
+/**
+ * virFsItem:
+ *
+ * a virFsItem is a private structure representing a fspool item
+ */
+typedef struct _virFsItem virFsItem;
+
+/**
+ * virFsItemPtr:
+ *
+ * a virFsItemPtr is pointer to a virFsItem private structure, this is the
+ * type used to reference a fspool item in the API.
+ */
+typedef virFsItem *virFsItemPtr;
+
+typedef struct _virFsItemInfo virFsItemInfo;
+
+typedef enum {
+    VIR_FS_ITEM_DIR = 0,
+    VIR_FS_ITEM_LAST
+} virFsItemType;
+
+struct _virFsItemInfo {
+    int type;                      /* virFsItemType flags */
+    unsigned long long capacity;   /* Logical size bytes */
+    unsigned long long allocation; /* Current allocation bytes */
+};
+
+typedef virFsItemInfo *virFsItemInfoPtr;
+/*
+ * Get connection from fspool.
+ */
+virConnectPtr           virFsPoolGetConnect        (virFsPoolPtr fsool);
+
+/*
+ * List active fspools
+ */
+int                     virConnectNumOfFsPools     (virConnectPtr conn);
+int                     virConnectListFsPools      (virConnectPtr conn,
+                                                    char **const names,
+                                                    int maxnames);
+
+/*
+ * List inactive fspools
+ */
+int                     virConnectNumOfDefinedFsPools(virConnectPtr conn);
+int                     virConnectListDefinedFsPools(virConnectPtr conn,
+                                                     char **const names,
+                                                     int maxnames);
+
+
+/*
+ * virConnectListAllFsPoolsFlags:
+ *
+ * Flags used to tune fspools returned by virConnectListAllFsPools().
+ * Note that these flags come in groups; if all bits from a group are 0,
+ * then that group is not used to filter results.
+ */
+typedef enum {
+    VIR_CONNECT_LIST_FS_POOLS_INACTIVE      = 1 << 0,
+    VIR_CONNECT_LIST_FS_POOLS_ACTIVE        = 1 << 1,
+
+    VIR_CONNECT_LIST_FS_POOLS_PERSISTENT    = 1 << 2,
+    VIR_CONNECT_LIST_FS_POOLS_TRANSIENT     = 1 << 3,
+
+    VIR_CONNECT_LIST_FS_POOLS_AUTOSTART     = 1 << 4,
+    VIR_CONNECT_LIST_FS_POOLS_NO_AUTOSTART  = 1 << 5,
+
+    /* List fspools by type */
+    VIR_CONNECT_LIST_FS_POOLS_DIR                = 1 << 6,
+} virConnectListAllFsPoolsFlags;
+
+typedef enum {
+    VIR_FS_XML_INACTIVE    = (1 << 0), /* dump inactive fspool/item information */
+} virFsXMLFlags;
+
+
+int                     virConnectListAllFsPools(virConnectPtr conn,
+                                                 virFsPoolPtr **fspools,
+                                                 unsigned int flags);
+
+/*
+ * Lookup fspool by name or uuid
+ */
+virFsPoolPtr       virFsPoolLookupByName       (virConnectPtr conn,
+                                                const char *name);
+virFsPoolPtr       virFsPoolLookupByUUID       (virConnectPtr conn,
+                                                const unsigned char *uuid);
+virFsPoolPtr       virFsPoolLookupByUUIDString (virConnectPtr conn,
+                                                const char *uuid);
+virFsPoolPtr       virFsPoolLookupByItem       (virFsItemPtr item);
+
+
+/*
+ * Creating/destroying fspools
+ */
+virFsPoolPtr       virFsPoolCreateXML         (virConnectPtr conn,
+                                               const char *xmlDesc,
+                                               unsigned int flags);
+virFsPoolPtr       virFsPoolDefineXML         (virConnectPtr conn,
+                                               const char *xmlDesc,
+                                               unsigned int flags);
+int                     virFsPoolBuild        (virFsPoolPtr fsool,
+                                               unsigned int flags);
+int                     virFsPoolRefresh      (virFsPoolPtr fsool,
+                                               unsigned int flags);
+int                     virFsPoolUndefine     (virFsPoolPtr fsool);
+int                     virFsPoolCreate       (virFsPoolPtr pool,
+                                               unsigned int flags);
+int                     virFsPoolDestroy      (virFsPoolPtr fsool);
+int                     virFsPoolDelete       (virFsPoolPtr fsool,
+                                               unsigned int flags);
+int                     virFsPoolRefresh      (virFsPoolPtr fsool,
+                                               unsigned int flags);
+int                     virFsPoolRef          (virFsPoolPtr fspool);
+int                     virFsPoolFree         (virFsPoolPtr fspool);
+
+/*
+ * FsPool information
+ */
+const char*             virFsPoolGetName           (virFsPoolPtr fsool);
+int                     virFsPoolGetUUID           (virFsPoolPtr fsool,
+                                                    unsigned char *uuid);
+int                     virFsPoolGetUUIDString     (virFsPoolPtr fsool,
+                                                    char *buf);
+
+int                     virFsPoolGetInfo           (virFsPoolPtr item,
+                                                    virFsPoolInfoPtr info);
+
+char *                  virFsPoolGetXMLDesc        (virFsPoolPtr fsool,
+                                                    unsigned int flags);
+int                     virFsPoolGetAutostart      (virFsPoolPtr pool,
+                                                    int *autostart);
+int                     virFsPoolSetAutostart      (virFsPoolPtr pool,
+                                                    int autostart);
+
+
+/*
+ * List/lookup fs items within a fsool
+ */
+int                     virFsPoolNumOfItems      (virFsPoolPtr fsool);
+int                     virFsPoolListItems       (virFsPoolPtr fsool,
+                                                  char **const names,
+                                                  int maxnames);
+int                     virFsPoolListAllItems    (virFsPoolPtr fsool,
+                                                  virFsItemPtr **items,
+                                                  unsigned int flags);
+
+virConnectPtr           virFsItemGetConnect       (virFsItemPtr item);
+
+/*
+ * Lookup itemumes based on various attributes
+ */
+virFsItemPtr        virFsItemLookupByName       (virFsPoolPtr fsool,
+                                                 const char *name);
+virFsItemPtr        virFsItemLookupByKey        (virConnectPtr conn,
+                                                 const char *key);
+virFsItemPtr        virFsItemLookupByPath       (virConnectPtr conn,
+                                                 const char *path);
+
+
+const char*             virFsItemGetName            (virFsItemPtr item);
+const char*             virFsItemGetKey             (virFsItemPtr item);
+
+virFsItemPtr        virFsItemCreateXML          (virFsPoolPtr fsool,
+                                                 const char *xmldesc,
+                                                 unsigned int flags);
+virFsItemPtr        virFsItemCreateXMLFrom      (virFsPoolPtr fsool,
+                                                 const char *xmldesc,
+                                                 virFsItemPtr cloneitem,
+                                                 unsigned int flags);
+
+int                     virFsItemDelete             (virFsItemPtr item,
+                                                     unsigned int flags);
+int                     virFsItemRef                (virFsItemPtr item);
+int                     virFsItemFree               (virFsItemPtr item);
+
+int                     virFsItemGetInfo            (virFsItemPtr item,
+                                                     virFsItemInfoPtr info);
+char *                  virFsItemGetXMLDesc         (virFsItemPtr item,
+                                                     unsigned int flags);
+
+char *                  virFsItemGetPath            (virFsItemPtr item);
+
+int virFsPoolIsActive(virFsPoolPtr fspool);
+int virFsPoolIsPersistent(virFsPoolPtr fspool);
+
+
+
+#endif /* __VIR_LIBVIRT_FS_H__ */
diff --git a/include/libvirt/libvirt.h b/include/libvirt/libvirt.h
index 36f6d60..665414b 100644
--- a/include/libvirt/libvirt.h
+++ b/include/libvirt/libvirt.h
@@ -45,6 +45,7 @@ extern "C" {
 # include <libvirt/libvirt-secret.h>
 # include <libvirt/libvirt-storage.h>
 # include <libvirt/libvirt-stream.h>
+# include <libvirt/libvirt-fs.h>
 # undef __VIR_LIBVIRT_H_INCLUDES__
 
 # ifdef __cplusplus
-- 
1.8.3.1

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]