These are exposed under domfsfreeze command and domfsthaw command.
Although the API doesn't support specifying mount point yet, expose it
anyway.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiy...@hds.com>
---
 tools/virsh-domain.c |  108 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/virsh.pod      |   17 ++++++++
 2 files changed, 125 insertions(+)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 60abd3d..e28ac8f 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -10451,6 +10451,102 @@ cleanup:
     return ret;
 }
 
+static const vshCmdInfo info_domfsfreeze[] = {
+    {.name = "help",
+     .data = N_("Freeze domain's mounted filesystems.")
+    },
+    {.name = "desc",
+     .data = N_("Freeze domain's mounted filesystems.")
+    },
+    {.name = NULL}
+};
+
+static const vshCmdOptDef opts_domfsfreeze[] = {
+    {.name = "domain",
+     .type = VSH_OT_DATA,
+     .flags = VSH_OFLAG_REQ,
+     .help = N_("domain name, id or uuid")
+    },
+    {.name = "mountpoint",
+     .type = VSH_OT_DATA,
+     .help = N_("which mount point to fsfreeze")
+    },
+    {.name = NULL}
+};
+static bool
+cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd)
+{
+    virDomainPtr dom = NULL;
+    bool ret = false;
+    const char *mountPoint = NULL;
+    unsigned int flags = 0;
+
+    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+        return ret;
+
+    if (vshCommandOptStringReq(ctl, cmd, "mountpoint", &mountPoint) < 0)
+        goto cleanup;
+
+    if (virDomainFSFreeze(dom, mountPoint, flags) < 0) {
+        vshError(ctl, _("Unable to freeze filesystems"));
+        goto cleanup;
+    }
+
+    ret = true;
+
+cleanup:
+    virDomainFree(dom);
+    return ret;
+}
+
+static const vshCmdInfo info_domfsthaw[] = {
+    {.name = "help",
+     .data = N_("Thaw domain's mounted filesystems.")
+    },
+    {.name = "desc",
+     .data = N_("Thaw domain's mounted filesystems.")
+    },
+    {.name = NULL}
+};
+
+static const vshCmdOptDef opts_domfsthaw[] = {
+    {.name = "domain",
+     .type = VSH_OT_DATA,
+     .flags = VSH_OFLAG_REQ,
+     .help = N_("domain name, id or uuid")
+    },
+    {.name = "mountpoint",
+     .type = VSH_OT_DATA,
+     .help = N_("which mount point to thaw")
+    },
+    {.name = NULL}
+};
+static bool
+cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd)
+{
+    virDomainPtr dom = NULL;
+    bool ret = false;
+    const char *mountPoint = NULL;
+    unsigned int flags = 0;
+
+    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+        return ret;
+
+    if (vshCommandOptStringReq(ctl, cmd, "mountpoint", &mountPoint) < 0)
+        goto cleanup;
+
+    if (virDomainFSThaw(dom, mountPoint, flags) < 0) {
+        vshError(ctl, _("Unable to thaw filesystems"));
+        goto cleanup;
+    }
+
+    ret = true;
+
+cleanup:
+    virDomainFree(dom);
+    return ret;
+}
+
 const vshCmdDef domManagementCmds[] = {
     {.name = "attach-device",
      .handler = cmdAttachDevice,
@@ -10598,6 +10694,18 @@ const vshCmdDef domManagementCmds[] = {
      .info = info_domdisplay,
      .flags = 0
     },
+    {.name = "domfsfreeze",
+     .handler = cmdDomFSFreeze,
+     .opts = opts_domfsfreeze,
+     .info = info_domfsfreeze,
+     .flags = 0
+    },
+    {.name = "domfsthaw",
+     .handler = cmdDomFSThaw,
+     .opts = opts_domfsthaw,
+     .info = info_domfsthaw,
+     .flags = 0
+    },
     {.name = "domfstrim",
      .handler = cmdDomFSTrim,
      .opts = opts_domfstrim,
diff --git a/tools/virsh.pod b/tools/virsh.pod
index dac9a08..2835696 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -915,6 +915,23 @@ Output a URI which can be used to connect to the graphical 
display of the
 domain via VNC, SPICE or RDP. If I<--include-password> is specified, the
 SPICE channel password will be included in the URI.
 
+=item B<domfsfreeze> I<domain> [I<--mountpoint mountPoint>]
+
+Freeze all mounted filesystems within a running domain to prepare for
+consistent snapshots. If I<--mountpoint> parameter is specified,
+only one mount point is frozen.
+
+Note that B<snapshot-create> command has a I<--quiesce> option to freeze
+and thaw the filesystems automatically to keep snapshots consistent.
+B<domfsfreeze> command is only needed when a user wants to utilize the
+native snapshot features of storage devices not supported by libvirt yet.
+
+=item B<domfsthaw> I<domain> [I<--mountpoint mountPoint>]
+
+Thaw all mounted filesystems within a running domain, which are frozen
+by domfsfreeze command. If I<--mountpoint> parameter is specified,
+only one mount point is thawed.
+
 =item B<domfstrim> I<domain> [I<--minimum> B<bytes>]
 [I<--mountpoint mountPoint>]
 

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

Reply via email to