]> xenbits.xensource.com Git - libvirt.git/commitdiff
Implement public API for virDomainGetFSInfo
authorTomoki Sekiyama <tomoki.sekiyama@hds.com>
Sat, 22 Nov 2014 01:27:25 +0000 (20:27 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 24 Nov 2014 15:02:08 +0000 (10:02 -0500)
virDomainGetFSInfo returns a list of filesystems information mounted in the
guest, which contains mountpoints, device names, filesystem types, and
device aliases named by libvirt. This will be useful, for example, to
specify mountpoints to fsfreeze when taking snapshot of a part of disks.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
include/libvirt/libvirt-domain.h
src/driver-hypervisor.h
src/libvirt.c
src/libvirt_public.syms

index 298d7f41c521f709c2e99865f9ee609034aa28b5..ae2c49c75a7823ff4b38a26e2671b02990eb8701 100644 (file)
@@ -3497,6 +3497,28 @@ int virDomainFSThaw(virDomainPtr dom,
                     unsigned int nmountpoints,
                     unsigned int flags);
 
+/**
+ * virDomainFSInfo:
+ *
+ * The data structure containing mounted file systems within a guset
+ *
+ */
+typedef struct _virDomainFSInfo virDomainFSInfo;
+typedef virDomainFSInfo *virDomainFSInfoPtr;
+struct _virDomainFSInfo {
+    char *mountpoint; /* path to mount point */
+    char *name;       /* device name in the guest (e.g. "sda1") */
+    char *fstype;     /* filesystem type */
+    size_t ndevAlias; /* number of elements in devAlias */
+    char **devAlias;  /* array of disk device aliases */
+};
+
+void virDomainFSInfoFree(virDomainFSInfoPtr info);
+
+int virDomainGetFSInfo(virDomainPtr dom,
+                       virDomainFSInfoPtr **info,
+                       unsigned int flags);
+
 int virDomainGetTime(virDomainPtr dom,
                      long long *seconds,
                      unsigned int *nseconds,
index ad66629db323ab0a19e33c4a59b1a0ed4b0863be..9f26b13c5ae9461e7027ff88e0fe0d4f7517ebaf 100644 (file)
@@ -1138,6 +1138,11 @@ typedef int
                       unsigned int nmountpoints,
                       unsigned int flags);
 
+typedef int
+(*virDrvDomainGetFSInfo)(virDomainPtr dom,
+                         virDomainFSInfoPtr **info,
+                         unsigned int flags);
+
 typedef int
 (*virDrvNodeGetFreePages)(virConnectPtr conn,
                           unsigned int npages,
@@ -1390,6 +1395,7 @@ struct _virHypervisorDriver {
     virDrvConnectGetDomainCapabilities connectGetDomainCapabilities;
     virDrvConnectGetAllDomainStats connectGetAllDomainStats;
     virDrvNodeAllocPages nodeAllocPages;
+    virDrvDomainGetFSInfo domainGetFSInfo;
 };
 
 
index 3abedb4572b77980e9997b93d8c48b63eff93100..86b0daa46f76ab4d53aa0dd75ea801d5686f94a7 100644 (file)
@@ -1400,6 +1400,74 @@ virConnectOpenAuth(const char *name,
 }
 
 
+/**
+ * virDomainGetFSInfo:
+ * @dom: a domain object
+ * @info: a pointer to a variable to store an array of mount points information
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Get a list of mapping information for each mounted file systems within the
+ * specified guest and the disks.
+ *
+ * Returns the number of returned mount points, or -1 in case of error.
+ * On success, the array of the information is stored into @info. The caller is
+ * responsible for calling virDomainFSInfoFree() on each array element, then
+ * calling free() on @info. On error, @info is set to NULL.
+ */
+int
+virDomainGetFSInfo(virDomainPtr dom,
+                   virDomainFSInfoPtr **info,
+                   unsigned int flags)
+{
+    VIR_DOMAIN_DEBUG(dom, "info=%p, flags=%x", info, flags);
+
+    virResetLastError();
+
+    virCheckDomainReturn(dom, -1);
+    virCheckReadOnlyGoto(dom->conn->flags, error);
+    virCheckNonNullArgGoto(info, error);
+    *info = NULL;
+
+    if (dom->conn->driver->domainGetFSInfo) {
+        int ret = dom->conn->driver->domainGetFSInfo(dom, info, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(dom->conn);
+    return -1;
+}
+
+
+/**
+ * virDomainFSInfoFree:
+ * @info: pointer to a FSInfo object
+ *
+ * Frees all the memory occupied by @info.
+ */
+void
+virDomainFSInfoFree(virDomainFSInfoPtr info)
+{
+    size_t i;
+
+    if (!info)
+        return;
+
+    VIR_FREE(info->mountpoint);
+    VIR_FREE(info->name);
+    VIR_FREE(info->fstype);
+
+    for (i = 0; i < info->ndevAlias; i++)
+        VIR_FREE(info->devAlias[i]);
+    VIR_FREE(info->devAlias);
+}
+
+
+
 /**
  * virConnectClose:
  * @conn: pointer to the hypervisor connection
index 5f95802fd4ecd703ad075c86e9f03db178d13c67..e4c2df198fd96ebef6d9d9a3b9cfea1c74f10893 100644 (file)
@@ -684,4 +684,10 @@ LIBVIRT_1.2.9 {
         virNodeAllocPages;
 } LIBVIRT_1.2.8;
 
+LIBVIRT_1.2.11 {
+    global:
+        virDomainFSInfoFree;
+        virDomainGetFSInfo;
+} LIBVIRT_1.2.9;
+
 # .... define new API here using predicted next version number ....