diff mbox

[RESEND,v5,1/3] qga: Add guest-fsfreeze-freeze-list command

Message ID 20140630215127.7224.22898.stgit@dhcp-17-70.bos.redhat.com
State New
Headers show

Commit Message

Tomoki Sekiyama June 30, 2014, 9:51 p.m. UTC
If an array of mount point paths is specified as 'mountpoints' argument
of guest-fsfreeze-freeze-list, qemu-ga will only freeze the file systems
mounted on specified paths in Linux guests. Otherwise, it works as the
same way as guest-fsfreeze-freeze.
This would be useful when the host wants to create partial disk snapshots.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 qga/commands-posix.c |   32 +++++++++++++++++++++++++++++++-
 qga/commands-win32.c |    9 +++++++++
 qga/qapi-schema.json |   17 +++++++++++++++++
 3 files changed, 57 insertions(+), 1 deletion(-)

Comments

Eric Blake Aug. 7, 2014, 10:03 p.m. UTC | #1
On 06/30/2014 03:51 PM, Tomoki Sekiyama wrote:
> If an array of mount point paths is specified as 'mountpoints' argument
> of guest-fsfreeze-freeze-list, qemu-ga will only freeze the file systems
> mounted on specified paths in Linux guests. Otherwise, it works as the
> same way as guest-fsfreeze-freeze.
> This would be useful when the host wants to create partial disk snapshots.
> 
> Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>  qga/commands-posix.c |   32 +++++++++++++++++++++++++++++++-
>  qga/commands-win32.c |    9 +++++++++
>  qga/qapi-schema.json |   17 +++++++++++++++++
>  3 files changed, 57 insertions(+), 1 deletion(-)
> 

> +++ b/qga/qapi-schema.json
> @@ -387,6 +387,23 @@
>    'returns': 'int' }
>  
>  ##
> +# @guest-fsfreeze-freeze-list:
> +#
> +# Sync and freeze specified guest filesystems
> +#
> +# @mountpoints: #optional an array of mountpoints of filesystems to be frozen.
> +#               If omitted, every mounted filesystem is frozen.
> +#
> +# Returns: Number of file systems currently frozen. On error, all filesystems
> +# will be thawed.
> +#
> +# Since: 2.1

This missed 2.1.  We'll need a followup patch (or rebase mdroth's
staging tree) to bump this to 2.2.
Michael Roth Aug. 7, 2014, 10:18 p.m. UTC | #2
Quoting Eric Blake (2014-08-07 17:03:57)
> On 06/30/2014 03:51 PM, Tomoki Sekiyama wrote:
> > If an array of mount point paths is specified as 'mountpoints' argument
> > of guest-fsfreeze-freeze-list, qemu-ga will only freeze the file systems
> > mounted on specified paths in Linux guests. Otherwise, it works as the
> > same way as guest-fsfreeze-freeze.
> > This would be useful when the host wants to create partial disk snapshots.
> > 
> > Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
> > Reviewed-by: Eric Blake <eblake@redhat.com>
> > ---
> >  qga/commands-posix.c |   32 +++++++++++++++++++++++++++++++-
> >  qga/commands-win32.c |    9 +++++++++
> >  qga/qapi-schema.json |   17 +++++++++++++++++
> >  3 files changed, 57 insertions(+), 1 deletion(-)
> > 
> 
> > +++ b/qga/qapi-schema.json
> > @@ -387,6 +387,23 @@
> >    'returns': 'int' }
> >  
> >  ##
> > +# @guest-fsfreeze-freeze-list:
> > +#
> > +# Sync and freeze specified guest filesystems
> > +#
> > +# @mountpoints: #optional an array of mountpoints of filesystems to be frozen.
> > +#               If omitted, every mounted filesystem is frozen.
> > +#
> > +# Returns: Number of file systems currently frozen. On error, all filesystems
> > +# will be thawed.
> > +#
> > +# Since: 2.1
> 
> This missed 2.1.  We'll need a followup patch (or rebase mdroth's
> staging tree) to bump this to 2.2.

Yikes, thanks for the quick catch. Updated the versions in qga branch
and in the pull branch that was just sent.

> 
> -- 
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
diff mbox

Patch

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 34ddba0..212988f 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -710,13 +710,21 @@  GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp)
     return GUEST_FSFREEZE_STATUS_THAWED;
 }
 
+int64_t qmp_guest_fsfreeze_freeze(Error **errp)
+{
+    return qmp_guest_fsfreeze_freeze_list(false, NULL, errp);
+}
+
 /*
  * Walk list of mounted file systems in the guest, and freeze the ones which
  * are real local file systems.
  */
-int64_t qmp_guest_fsfreeze_freeze(Error **errp)
+int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,
+                                       strList *mountpoints,
+                                       Error **errp)
 {
     int ret = 0, i = 0;
+    strList *list;
     FsMountList mounts;
     struct FsMount *mount;
     Error *local_err = NULL;
@@ -741,6 +749,19 @@  int64_t qmp_guest_fsfreeze_freeze(Error **errp)
     ga_set_frozen(ga_state);
 
     QTAILQ_FOREACH_REVERSE(mount, &mounts, FsMountList, next) {
+        /* To issue fsfreeze in the reverse order of mounts, check if the
+         * mount is listed in the list here */
+        if (has_mountpoints) {
+            for (list = mountpoints; list; list = list->next) {
+                if (strcmp(list->value, mount->dirname) == 0) {
+                    break;
+                }
+            }
+            if (!list) {
+                continue;
+            }
+        }
+
         fd = qemu_open(mount->dirname, O_RDONLY);
         if (fd == -1) {
             error_setg_errno(errp, errno, "failed to open %s", mount->dirname);
@@ -1474,6 +1495,15 @@  int64_t qmp_guest_fsfreeze_freeze(Error **errp)
     return 0;
 }
 
+int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,
+                                       strList *mountpoints,
+                                       Error **errp)
+{
+    error_set(errp, QERR_UNSUPPORTED);
+
+    return 0;
+}
+
 int64_t qmp_guest_fsfreeze_thaw(Error **errp)
 {
     error_set(errp, QERR_UNSUPPORTED);
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index e769396..94877e9 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -206,6 +206,15 @@  error:
     return 0;
 }
 
+int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,
+                                       strList *mountpoints,
+                                       Error **errp)
+{
+    error_set(errp, QERR_UNSUPPORTED);
+
+    return 0;
+}
+
 /*
  * Thaw local file systems using Volume Shadow-copy Service.
  */
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index a8cdcb3..caa4612 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -387,6 +387,23 @@ 
   'returns': 'int' }
 
 ##
+# @guest-fsfreeze-freeze-list:
+#
+# Sync and freeze specified guest filesystems
+#
+# @mountpoints: #optional an array of mountpoints of filesystems to be frozen.
+#               If omitted, every mounted filesystem is frozen.
+#
+# Returns: Number of file systems currently frozen. On error, all filesystems
+# will be thawed.
+#
+# Since: 2.1
+##
+{ 'command': 'guest-fsfreeze-freeze-list',
+  'data':    { '*mountpoints': ['str'] },
+  'returns': 'int' }
+
+##
 # @guest-fsfreeze-thaw:
 #
 # Unfreeze all frozen guest filesystems