All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] Backup Tool: Incremental backup
@ 2017-08-30 19:15 Ishani Chugh
  2017-08-30 19:15 ` [Qemu-devel] [PATCH 1/3] Backup Tool: Manpage for Incremental Backup Ishani Chugh
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Ishani Chugh @ 2017-08-30 19:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, jsnow, Ishani Chugh

This patch series is intended to add incremental backup functionality
to Backup Tool.
This patch series contains three patches,
            1) QEMU Backup command line tool(With Incremental backup).
            2) Test for incremental backup.
            3) Manpage for the tool(Incremental backup example).

Based on: 1504113297-22052-1-git-send-email-chugh.ishani@research.iiit.ac.in
Ishani Chugh (3):
  Backup Tool: Manpage for Incremental Backup
  Backup Tool: Support for Incremental Backup
  Backup Tool: Test for Incremental Backup

 contrib/backup/qemu-backup.py   | 101 +++++++++++++++++++++++++++++++++++++++-
 contrib/backup/qemu-backup.texi |  18 +++++++
 tests/qemu-iotests/193          |  86 ++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/193.out      |  34 ++++++++++++++
 tests/qemu-iotests/group        |   1 +
 5 files changed, 238 insertions(+), 2 deletions(-)
 create mode 100755 tests/qemu-iotests/193
 create mode 100644 tests/qemu-iotests/193.out

-- 
2.7.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 1/3] Backup Tool: Manpage for Incremental Backup
  2017-08-30 19:15 [Qemu-devel] [PATCH 0/3] Backup Tool: Incremental backup Ishani Chugh
@ 2017-08-30 19:15 ` Ishani Chugh
  2017-08-31  1:57   ` Fam Zheng
  2017-08-30 19:15 ` [Qemu-devel] [PATCH 2/3] Backup Tool: Support " Ishani Chugh
  2017-08-30 19:15 ` [Qemu-devel] [PATCH 3/3] Backup Tool: Test " Ishani Chugh
  2 siblings, 1 reply; 9+ messages in thread
From: Ishani Chugh @ 2017-08-30 19:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, jsnow, Ishani Chugh

Adds command description to perform incremental backup and
a full example for the same.

Signed-off-by: Ishani Chugh <chugh.ishani@research.iiit.ac.in>
---
 contrib/backup/qemu-backup.texi | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/contrib/backup/qemu-backup.texi b/contrib/backup/qemu-backup.texi
index 7ad266c..8e5cb86 100644
--- a/contrib/backup/qemu-backup.texi
+++ b/contrib/backup/qemu-backup.texi
@@ -58,6 +58,7 @@ qemu-backup command [command options].
 @item qemu-backup restore --guest guestname
 @item qemu-backup guest remove --guest guestname
 @item qemu-backup drive remove --guest guestname --id driveid
+@item qemu-backup backup --inc --guest guestname
 @end itemize
 @node  Command Parameters
 @chapter  Command Parameters
@@ -67,6 +68,7 @@ qemu-backup command [command options].
 @item --id: id of guest or drive.
 @item --qmp: Path of qmp socket.
 @item --target: Destination path on which you want your backup to be made.
+@item --inc: incremental backup (Optional).
 @end itemize
 
 @node  Command Descriptions
@@ -119,6 +121,11 @@ This command helps remove a drive which is set for backup in configuration of gi
 
 example: drive remove --guest=fedora --id=root
 
+@item qemu-backup backup --inc --guest guestname
+This command is used for making incremental backup.
+
+example: qemu-backup backup --inc --guest fedora
+
 @item A full backup can be performed by following the given steps:
 
 Perform a full backup of 'vm001', which has one drive:
@@ -129,6 +136,17 @@ qemu-backup add --id drive0 --guest vm001 --target /backups/vm001-drive0.img
 
 qemu-backup backup --guest vm001
 
+@item An incremental backup can be performed by following the given steps:
+
+Perform an incremental backup of 'vm001', which has one drive:
+
+qemu-backup guest add --guest vm001 --qmp /path/to/vm001.sock
+
+qemu-backup add --id drive0 --guest vm001 --target /backups/vm001-drive0.img
+
+qemu-backup backup --inc --guest vm001
+
+qemu-backup backup --inc --guest vm001
 
 @end itemize
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 2/3] Backup Tool: Support for Incremental Backup
  2017-08-30 19:15 [Qemu-devel] [PATCH 0/3] Backup Tool: Incremental backup Ishani Chugh
  2017-08-30 19:15 ` [Qemu-devel] [PATCH 1/3] Backup Tool: Manpage for Incremental Backup Ishani Chugh
@ 2017-08-30 19:15 ` Ishani Chugh
  2017-08-31  1:56   ` Fam Zheng
  2017-08-30 19:15 ` [Qemu-devel] [PATCH 3/3] Backup Tool: Test " Ishani Chugh
  2 siblings, 1 reply; 9+ messages in thread
From: Ishani Chugh @ 2017-08-30 19:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, jsnow, Ishani Chugh

Adds incremental backup functionality.

Signed-off-by: Ishani Chugh <chugh.ishani@research.iiit.ac.in>
---
 contrib/backup/qemu-backup.py | 101 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 99 insertions(+), 2 deletions(-)

diff --git a/contrib/backup/qemu-backup.py b/contrib/backup/qemu-backup.py
index 248ca9f..7a3077a 100644
--- a/contrib/backup/qemu-backup.py
+++ b/contrib/backup/qemu-backup.py
@@ -24,11 +24,13 @@ from __future__ import print_function
 from argparse import ArgumentParser
 import os
 import errno
+from string import Template
 from socket import error as socket_error
 try:
     import configparser
 except ImportError:
     import ConfigParser as configparser
+from configparser import NoOptionError
 import sys
 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..',
                              'scripts', 'qmp'))
@@ -41,7 +43,6 @@ class BackupTool(object):
                  '/.config/qemu/qemu-backup-config'):
         if "QEMU_BACKUP_CONFIG" in os.environ:
             self.config_file = os.environ["QEMU_BACKUP_CONFIG"]
-
         else:
             self.config_file = config_file
             try:
@@ -129,6 +130,97 @@ class BackupTool(object):
                         drive_list.remove(event['data']['device'])
         print("Backup Complete")
 
+    def _inc_backup(self, guest_name):
+        """
+        Performs Incremental backup
+        """
+        if guest_name not in self.config.sections():
+            print ("Cannot find specified guest", file=sys.stderr)
+            exit(1)
+
+        self.verify_guest_running(guest_name)
+        connection = QEMUMonitorProtocol(
+                                         self.get_socket_address(
+                                             self.config[guest_name]['qmp']))
+        connection.connect()
+        backup_cmd = {"execute": "transaction",
+                      "arguments": {"actions": [], "properties":
+                                    {"completion-mode": "grouped"}}}
+        bitmap_cmd = {"execute": "transaction", "arguments": {"actions": []}}
+        for key in self.config[guest_name]:
+            if key.startswith("drive_"):
+                drive = key[len('drive_'):]
+                target = self.config.get(guest_name, key).rsplit('/', 1)[0]
+                inc_backup_pattern = Template('${drive}_inc_${N}')
+                bitmap = 'qemu_backup_'+guest_name
+                try:
+                    query_block_cmd = {'execute': 'query-block'}
+                    returned_json = connection.cmd_obj(query_block_cmd)
+                    device_present = False
+                    for device in returned_json['return']:
+                        if device['device'] == drive:
+                            device_present = True
+                            bitmap_present = False
+                            for bitmaps in device['dirty-bitmaps']:
+                                if bitmap == bitmaps['name']:
+                                    bitmap_present = True
+                                    if os.path.isfile(self.config.get(
+                                                      guest_name,
+                                                      'inc_'+drive)) is False:
+                                        print("Initial Backup does not exist")
+                                        bitmap_remove = {"execute":
+                                                         "block-dirty" +
+                                                         "-bitmap-remove",
+                                                         "arguments":
+                                                         {"node": drive,
+                                                          "name":
+                                                          "qemu_backup_" +
+                                                          guest_name}}
+                                        connection.cmd_obj(bitmap_remove)
+                                        bitmap_present = False
+                            if bitmap_present is False:
+                                raise NoOptionError(guest_name, 'inc_'+drive)
+                            break
+
+                    if not device_present:
+                        print("No such drive in guest", file=sys.stderr)
+                        sys.exit(1)
+                    N = int(self.config.get(guest_name, drive+'_N'))+1
+                    target = self.config.get(guest_name, key).rsplit(
+                                                                    '/', 1)[0]\
+                        + '/' + inc_backup_pattern.substitute(drive=drive, N=N)
+                    os.system("qemu-img create -f qcow2 " + target + " -b " +
+                              self.config.get(guest_name, 'inc_' +
+                                              drive) + " -F qcow2")
+                    sub_cmd = {"type": "drive-backup",
+                               "data": {"device": drive, "bitmap": bitmap,
+                                        "mode": "existing",
+                                        "sync": "incremental",
+                                        "target": target}}
+                    backup_cmd['arguments']['actions'].append(sub_cmd)
+                    self.config.set(guest_name, drive+'_N',
+                                    str(int(self.config.get(guest_name,
+                                                            drive+'_N'))+1))
+                    self.config.set(guest_name, 'inc_'+drive, target)
+                except (NoOptionError, KeyError) as e:
+                    target = self.config.get(guest_name, key).rsplit(
+                                                                    '/', 1)[0]\
+                        + '/' + inc_backup_pattern.substitute(drive=drive, N=0)
+                    sub_cmd_1 = {"type": "block-dirty-bitmap-add",
+                                 "data": {"node": drive, "name": bitmap,
+                                          "persistent": True,
+                                          "autoload": True}}
+                    sub_cmd_2 = {"type": "drive-backup",
+                                 "data": {"device": drive, "target": target,
+                                          "sync": "full", "format": "qcow2"}}
+                    self.config.set(guest_name, drive+'_N', '0')
+                    self.config.set(guest_name, 'inc_'+drive, target)
+                    bitmap_cmd['arguments']['actions'].append(sub_cmd_1)
+                    bitmap_cmd['arguments']['actions'].append(sub_cmd_2)
+        connection.cmd_obj(bitmap_cmd)
+        connection.cmd_obj(backup_cmd)
+        self.write_config()
+
     def _drive_add(self, drive_id, guest_name, target=None):
         """
         Adds drive for backup
@@ -275,7 +367,10 @@ class BackupTool(object):
         """
         Wrapper for _full_backup method
         """
-        self._full_backup(args.guest)
+        if args.inc is False:
+            self._full_backup(args.guest)
+        else:
+            self._inc_backup(args.guest)
 
     def restore_wrapper(self, args):
         """
@@ -329,6 +424,8 @@ def main():
     backup_parser = subparsers.add_parser('backup', help='Creates backup')
     backup_parser.add_argument('--guest', action='store',
                                type=str, help='Name of the guest')
+    backup_parser.add_argument('--inc', nargs='?',
+                               default=False, help='Destination path')
     backup_parser.set_defaults(func=backup_tool.fullbackup_wrapper)
 
     backup_parser = subparsers.add_parser('restore', help='Restores drives')
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 3/3] Backup Tool: Test for Incremental Backup
  2017-08-30 19:15 [Qemu-devel] [PATCH 0/3] Backup Tool: Incremental backup Ishani Chugh
  2017-08-30 19:15 ` [Qemu-devel] [PATCH 1/3] Backup Tool: Manpage for Incremental Backup Ishani Chugh
  2017-08-30 19:15 ` [Qemu-devel] [PATCH 2/3] Backup Tool: Support " Ishani Chugh
@ 2017-08-30 19:15 ` Ishani Chugh
  2017-08-31  2:02   ` Fam Zheng
  2 siblings, 1 reply; 9+ messages in thread
From: Ishani Chugh @ 2017-08-30 19:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, jsnow, Ishani Chugh

This patch is the test for incremental backup implementation in Backup tool.
The test employs two basic subtests:
1) Backing up an empty guest and comparing it with base image.
2) Writing a pattern to the guest, creating backup, writing
   a pattern again, creating backup and comparing with base image.

Signed-off-by: Ishani Chugh <chugh.ishani@research.iiit.ac.in>
---
 tests/qemu-iotests/193     | 86 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/193.out | 34 ++++++++++++++++++
 tests/qemu-iotests/group   |  1 +
 3 files changed, 121 insertions(+)
 create mode 100755 tests/qemu-iotests/193
 create mode 100644 tests/qemu-iotests/193.out

diff --git a/tests/qemu-iotests/193 b/tests/qemu-iotests/193
new file mode 100755
index 0000000..500e5df
--- /dev/null
+++ b/tests/qemu-iotests/193
@@ -0,0 +1,86 @@
+#!/bin/bash
+#
+# Test Incremental backup functionality of qemu-backup tool
+#
+# Copyright (C) 2009 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+# creator
+owner=chugh.ishani@research.iiit.ac.in
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+status=1	# failure is the default!
+
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+. ./common.qemu
+
+_supported_fmt generic
+_supported_proto generic
+_supported_os Linux
+
+
+CONFIG_FILE=$TEST_DIR/backup-config
+SOCKET=unix:$TEST_DIR/backup_socket
+size=128M
+
+_make_test_img $size
+export QEMU_BACKUP_CONFIG=$CONFIG_FILE
+qemu_comm_method="monitor"
+echo
+_launch_qemu -drive if=virtio,file=$TEST_IMG -qmp $SOCKET,server,nowait
+$PYTHON ../../contrib/backup/qemu-backup.py guest add --guest adad --qmp $SOCKET
+$PYTHON ../../contrib/backup/qemu-backup.py drive add --id virtio0 --guest adad --target $TEST_DIR/virtio0
+echo
+echo "== Creating backup =="
+$PYTHON ../../contrib/backup/qemu-backup.py backup --inc --guest adad
+_send_qemu_cmd $QEMU_HANDLE 'quit' ''
+wait=1 _cleanup_qemu
+echo
+echo "== Comparing images =="
+$QEMU_IMG compare $TEST_DIR/virtio0_inc_0 $TEST_IMG
+
+rm $TEST_DIR/virtio0_inc_0
+
+_launch_qemu -drive if=virtio,id=virtio0,file=$TEST_IMG -qmp $SOCKET,server,nowait
+echo
+echo "== Writing Pattern =="
+_send_qemu_cmd $QEMU_HANDLE 'qemu-io virtio0 "write -P 0x22 0 1M"' "(qemu)" | _filter_qemu_io
+echo
+
+echo "== Creating backup =="
+$PYTHON ../../contrib/backup/qemu-backup.py backup --inc --guest adad
+
+echo "== Writing Pattern =="
+_send_qemu_cmd $QEMU_HANDLE 'qemu-io virtio0 "write -P 0x22 0 1M"' "(qemu)" | _filter_qemu_io
+echo
+$PYTHON ../../contrib/backup/qemu-backup.py backup --inc --guest adad
+_send_qemu_cmd $QEMU_HANDLE 'quit' ''
+wait=1 _cleanup_qemu
+echo
+echo "== Comparing images =="
+$QEMU_IMG compare $TEST_DIR/virtio0_inc_1 $TEST_IMG
+rm $TEST_DIR/virtio0_inc_0
+rm $TEST_DIR/virtio0_inc_1
+rm $CONFIG_FILE
+
+echo "*** done"
+status=0
\ No newline at end of file
diff --git a/tests/qemu-iotests/193.out b/tests/qemu-iotests/193.out
new file mode 100644
index 0000000..3a836c2
--- /dev/null
+++ b/tests/qemu-iotests/193.out
@@ -0,0 +1,34 @@
+QA output created by 193
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
+
+Successfully Added Guest
+Successfully Added Drive
+
+== Creating backup ==
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) Formatting 'TEST_DIR/virtio0_inc_0', fmt=qcow2 size=134217728 cluster_size=65536 lazy_refcounts=off refcount_bits=16
+quit
+
+== Comparing images ==
+Images are identical.
+
+== Writing Pattern ==
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) qemu-io virtio0 "write -P 0x22 0 1M"
+
+== Creating backup ==
+Initial Backup does not exist
+== Writing Pattern ==
+wrote 1048576/1048576 bytes at offset 0
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+(qemu) Formatting 'TEST_DIR/virtio0_inc_0', fmt=qcow2 size=134217728 cluster_size=65536 lazy_refcounts=off refcount_bits=16
+
+Formatting '/home/ishani/Desktop/opw/qemu/tests/qemu-iotests/scratch/virtio0_inc_1', fmt=qcow2 size=134217728 backing_file=/home/ishani/Desktop/opw/qemu/tests/qemu-iotests/scratch/virtio0_inc_0 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16
+qemu-io virtio0 "write -P 0x22 0 1M"
+wrote 1048576/1048576 bytes at offset 0
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+(qemu) quit
+
+== Comparing images ==
+Images are identical.
+*** done
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 33c945b..6b9e034 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -189,3 +189,4 @@
 191 rw auto
 192 rw auto quick
 194 rw auto migration quick
+193 rw auto
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] Backup Tool: Support for Incremental Backup
  2017-08-30 19:15 ` [Qemu-devel] [PATCH 2/3] Backup Tool: Support " Ishani Chugh
@ 2017-08-31  1:56   ` Fam Zheng
  0 siblings, 0 replies; 9+ messages in thread
From: Fam Zheng @ 2017-08-31  1:56 UTC (permalink / raw)
  To: Ishani Chugh; +Cc: qemu-devel, jsnow, stefanha

On Thu, 08/31 00:45, Ishani Chugh wrote:
> Adds incremental backup functionality.
> 
> Signed-off-by: Ishani Chugh <chugh.ishani@research.iiit.ac.in>
> ---
>  contrib/backup/qemu-backup.py | 101 +++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 99 insertions(+), 2 deletions(-)
> 
> diff --git a/contrib/backup/qemu-backup.py b/contrib/backup/qemu-backup.py
> index 248ca9f..7a3077a 100644
> --- a/contrib/backup/qemu-backup.py
> +++ b/contrib/backup/qemu-backup.py
> @@ -24,11 +24,13 @@ from __future__ import print_function
>  from argparse import ArgumentParser
>  import os
>  import errno
> +from string import Template
>  from socket import error as socket_error
>  try:
>      import configparser
>  except ImportError:
>      import ConfigParser as configparser
> +from configparser import NoOptionError
>  import sys
>  sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..',
>                               'scripts', 'qmp'))
> @@ -41,7 +43,6 @@ class BackupTool(object):
>                   '/.config/qemu/qemu-backup-config'):
>          if "QEMU_BACKUP_CONFIG" in os.environ:
>              self.config_file = os.environ["QEMU_BACKUP_CONFIG"]
> -
>          else:
>              self.config_file = config_file
>              try:
> @@ -129,6 +130,97 @@ class BackupTool(object):
>                          drive_list.remove(event['data']['device'])
>          print("Backup Complete")
>  
> +    def _inc_backup(self, guest_name):
> +        """
> +        Performs Incremental backup
> +        """
> +        if guest_name not in self.config.sections():
> +            print ("Cannot find specified guest", file=sys.stderr)

s/print (/print(/

> +            exit(1)
> +
> +        self.verify_guest_running(guest_name)
> +        connection = QEMUMonitorProtocol(
> +                                         self.get_socket_address(
> +                                             self.config[guest_name]['qmp']))
> +        connection.connect()
> +        backup_cmd = {"execute": "transaction",
> +                      "arguments": {"actions": [], "properties":
> +                                    {"completion-mode": "grouped"}}}
> +        bitmap_cmd = {"execute": "transaction", "arguments": {"actions": []}}
> +        for key in self.config[guest_name]:

>From here on the indentation level is launched straight into outer space. Please
either extract code blocks into functions, or at least try to rearrange it like:

> +            if key.startswith("drive_"):

               if not key.startswith("drive_"):
                   continue

               drive = ...
               ...
> +                drive = key[len('drive_'):]
> +                target = self.config.get(guest_name, key).rsplit('/', 1)[0]
> +                inc_backup_pattern = Template('${drive}_inc_${N}')
> +                bitmap = 'qemu_backup_'+guest_name

Whitespaces missing around +.

> +                try:
> +                    query_block_cmd = {'execute': 'query-block'}
> +                    returned_json = connection.cmd_obj(query_block_cmd)
> +                    device_present = False
> +                    for device in returned_json['return']:
> +                        if device['device'] == drive:

                           if device['device'] != drive:
                               continue
                           device_present = True
                           ...
> +                            device_present = True
> +                            bitmap_present = False
> +                            for bitmaps in device['dirty-bitmaps']:
> +                                if bitmap == bitmaps['name']:

                                   if bitmap != bitmaps['name']:
                                       continue
                                   bitmap_present = True
                                   ...
> +                                    bitmap_present = True
> +                                    if os.path.isfile(self.config.get(
> +                                                      guest_name,
> +                                                      'inc_'+drive)) is False:
> +                                        print("Initial Backup does not exist")
> +                                        bitmap_remove = {"execute":
> +                                                         "block-dirty" +
> +                                                         "-bitmap-remove",

Please fix the indentation level and join the string: "block-dirty-bitmap-remove".

Even if you cannot control the indentation level, long line is still better than
cutting it into halves. It makes the code hard to read and unfriendly to grep.

> +                                                         "arguments":
> +                                                         {"node": drive,
> +                                                          "name":
> +                                                          "qemu_backup_" +
> +                                                          guest_name}}
> +                                        connection.cmd_obj(bitmap_remove)
> +                                        bitmap_present = False
> +                            if bitmap_present is False:

Please "don't compare boolean values to True or False using ==", or "is":

s/bitmap_present is False/not bitmap_present/

> +                                raise NoOptionError(guest_name, 'inc_'+drive)
> +                            break
> +
> +                    if not device_present:
> +                        print("No such drive in guest", file=sys.stderr)
> +                        sys.exit(1)
> +                    N = int(self.config.get(guest_name, drive+'_N'))+1
> +                    target = self.config.get(guest_name, key).rsplit(
> +                                                                    '/', 1)[0]\
> +                        + '/' + inc_backup_pattern.substitute(drive=drive, N=N)
> +                    os.system("qemu-img create -f qcow2 " + target + " -b " +
> +                              self.config.get(guest_name, 'inc_' +
> +                                              drive) + " -F qcow2")
> +                    sub_cmd = {"type": "drive-backup",
> +                               "data": {"device": drive, "bitmap": bitmap,
> +                                        "mode": "existing",
> +                                        "sync": "incremental",
> +                                        "target": target}}
> +                    backup_cmd['arguments']['actions'].append(sub_cmd)
> +                    self.config.set(guest_name, drive+'_N',
> +                                    str(int(self.config.get(guest_name,
> +                                                            drive+'_N'))+1))
> +                    self.config.set(guest_name, 'inc_'+drive, target)
> +                except (NoOptionError, KeyError) as e:
> +                    target = self.config.get(guest_name, key).rsplit(
> +                                                                    '/', 1)[0]\
> +                        + '/' + inc_backup_pattern.substitute(drive=drive, N=0)
> +                    sub_cmd_1 = {"type": "block-dirty-bitmap-add",
> +                                 "data": {"node": drive, "name": bitmap,
> +                                          "persistent": True,
> +                                          "autoload": True}}
> +                    sub_cmd_2 = {"type": "drive-backup",
> +                                 "data": {"device": drive, "target": target,
> +                                          "sync": "full", "format": "qcow2"}}
> +                    self.config.set(guest_name, drive+'_N', '0')
> +                    self.config.set(guest_name, 'inc_'+drive, target)
> +                    bitmap_cmd['arguments']['actions'].append(sub_cmd_1)
> +                    bitmap_cmd['arguments']['actions'].append(sub_cmd_2)
> +        connection.cmd_obj(bitmap_cmd)
> +        connection.cmd_obj(backup_cmd)
> +        self.write_config()
> +
>      def _drive_add(self, drive_id, guest_name, target=None):
>          """
>          Adds drive for backup
> @@ -275,7 +367,10 @@ class BackupTool(object):
>          """
>          Wrapper for _full_backup method
>          """
> -        self._full_backup(args.guest)
> +        if args.inc is False:
> +            self._full_backup(args.guest)
> +        else:
> +            self._inc_backup(args.guest)

    if not args.inc:
        self._full_backup(...)
    else:
        ...

>  
>      def restore_wrapper(self, args):
>          """
> @@ -329,6 +424,8 @@ def main():
>      backup_parser = subparsers.add_parser('backup', help='Creates backup')
>      backup_parser.add_argument('--guest', action='store',
>                                 type=str, help='Name of the guest')
> +    backup_parser.add_argument('--inc', nargs='?',
> +                               default=False, help='Destination path')
>      backup_parser.set_defaults(func=backup_tool.fullbackup_wrapper)
>  
>      backup_parser = subparsers.add_parser('restore', help='Restores drives')
> -- 
> 2.7.4
> 
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 1/3] Backup Tool: Manpage for Incremental Backup
  2017-08-30 19:15 ` [Qemu-devel] [PATCH 1/3] Backup Tool: Manpage for Incremental Backup Ishani Chugh
@ 2017-08-31  1:57   ` Fam Zheng
  0 siblings, 0 replies; 9+ messages in thread
From: Fam Zheng @ 2017-08-31  1:57 UTC (permalink / raw)
  To: Ishani Chugh; +Cc: qemu-devel, jsnow, stefanha

On Thu, 08/31 00:45, Ishani Chugh wrote:
> Adds command description to perform incremental backup and
> a full example for the same.
> 
> Signed-off-by: Ishani Chugh <chugh.ishani@research.iiit.ac.in>
> ---
>  contrib/backup/qemu-backup.texi | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/contrib/backup/qemu-backup.texi b/contrib/backup/qemu-backup.texi
> index 7ad266c..8e5cb86 100644
> --- a/contrib/backup/qemu-backup.texi
> +++ b/contrib/backup/qemu-backup.texi
> @@ -58,6 +58,7 @@ qemu-backup command [command options].
>  @item qemu-backup restore --guest guestname
>  @item qemu-backup guest remove --guest guestname
>  @item qemu-backup drive remove --guest guestname --id driveid
> +@item qemu-backup backup --inc --guest guestname
>  @end itemize
>  @node  Command Parameters
>  @chapter  Command Parameters
> @@ -67,6 +68,7 @@ qemu-backup command [command options].
>  @item --id: id of guest or drive.
>  @item --qmp: Path of qmp socket.
>  @item --target: Destination path on which you want your backup to be made.
> +@item --inc: incremental backup (Optional).
>  @end itemize
>  
>  @node  Command Descriptions
> @@ -119,6 +121,11 @@ This command helps remove a drive which is set for backup in configuration of gi
>  
>  example: drive remove --guest=fedora --id=root
>  
> +@item qemu-backup backup --inc --guest guestname
> +This command is used for making incremental backup.
> +
> +example: qemu-backup backup --inc --guest fedora

Could you document the output file name generation?

Fam

> +
>  @item A full backup can be performed by following the given steps:
>  
>  Perform a full backup of 'vm001', which has one drive:
> @@ -129,6 +136,17 @@ qemu-backup add --id drive0 --guest vm001 --target /backups/vm001-drive0.img
>  
>  qemu-backup backup --guest vm001
>  
> +@item An incremental backup can be performed by following the given steps:
> +
> +Perform an incremental backup of 'vm001', which has one drive:
> +
> +qemu-backup guest add --guest vm001 --qmp /path/to/vm001.sock
> +
> +qemu-backup add --id drive0 --guest vm001 --target /backups/vm001-drive0.img
> +
> +qemu-backup backup --inc --guest vm001
> +
> +qemu-backup backup --inc --guest vm001
>  
>  @end itemize
>  
> -- 
> 2.7.4
> 
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] Backup Tool: Test for Incremental Backup
  2017-08-30 19:15 ` [Qemu-devel] [PATCH 3/3] Backup Tool: Test " Ishani Chugh
@ 2017-08-31  2:02   ` Fam Zheng
  2017-09-01 22:53     ` John Snow
  0 siblings, 1 reply; 9+ messages in thread
From: Fam Zheng @ 2017-08-31  2:02 UTC (permalink / raw)
  To: Ishani Chugh; +Cc: qemu-devel, jsnow, stefanha

On Thu, 08/31 00:45, Ishani Chugh wrote:
> This patch is the test for incremental backup implementation in Backup tool.
> The test employs two basic subtests:
> 1) Backing up an empty guest and comparing it with base image.
> 2) Writing a pattern to the guest, creating backup, writing
>    a pattern again, creating backup and comparing with base image.
> 
> Signed-off-by: Ishani Chugh <chugh.ishani@research.iiit.ac.in>
> ---
>  tests/qemu-iotests/193     | 86 ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/qemu-iotests/193.out | 34 ++++++++++++++++++
>  tests/qemu-iotests/group   |  1 +
>  3 files changed, 121 insertions(+)
>  create mode 100755 tests/qemu-iotests/193
>  create mode 100644 tests/qemu-iotests/193.out
> 
> diff --git a/tests/qemu-iotests/193 b/tests/qemu-iotests/193
> new file mode 100755
> index 0000000..500e5df
> --- /dev/null
> +++ b/tests/qemu-iotests/193
> @@ -0,0 +1,86 @@
> +#!/bin/bash
> +#
> +# Test Incremental backup functionality of qemu-backup tool
> +#
> +# Copyright (C) 2009 Red Hat, Inc.

Year is off, probably the copyright holder too?

> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program 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 General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +#
> +
> +# creator
> +owner=chugh.ishani@research.iiit.ac.in
> +
> +seq=`basename $0`
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +status=1	# failure is the default!

s/\t/ /

> +
> +
> +# get standard environment, filters and checks
> +. ./common.rc
> +. ./common.filter
> +. ./common.qemu
> +
> +_supported_fmt generic
> +_supported_proto generic
> +_supported_os Linux
> +
> +
> +CONFIG_FILE=$TEST_DIR/backup-config
> +SOCKET=unix:$TEST_DIR/backup_socket
> +size=128M
> +
> +_make_test_img $size
> +export QEMU_BACKUP_CONFIG=$CONFIG_FILE
> +qemu_comm_method="monitor"
> +echo
> +_launch_qemu -drive if=virtio,file=$TEST_IMG -qmp $SOCKET,server,nowait
> +$PYTHON ../../contrib/backup/qemu-backup.py guest add --guest adad --qmp $SOCKET
> +$PYTHON ../../contrib/backup/qemu-backup.py drive add --id virtio0 --guest adad --target $TEST_DIR/virtio0
> +echo
> +echo "== Creating backup =="
> +$PYTHON ../../contrib/backup/qemu-backup.py backup --inc --guest adad
> +_send_qemu_cmd $QEMU_HANDLE 'quit' ''
> +wait=1 _cleanup_qemu
> +echo
> +echo "== Comparing images =="
> +$QEMU_IMG compare $TEST_DIR/virtio0_inc_0 $TEST_IMG
> +
> +rm $TEST_DIR/virtio0_inc_0
> +
> +_launch_qemu -drive if=virtio,id=virtio0,file=$TEST_IMG -qmp $SOCKET,server,nowait
> +echo
> +echo "== Writing Pattern =="
> +_send_qemu_cmd $QEMU_HANDLE 'qemu-io virtio0 "write -P 0x22 0 1M"' "(qemu)" | _filter_qemu_io
> +echo
> +
> +echo "== Creating backup =="
> +$PYTHON ../../contrib/backup/qemu-backup.py backup --inc --guest adad
> +
> +echo "== Writing Pattern =="
> +_send_qemu_cmd $QEMU_HANDLE 'qemu-io virtio0 "write -P 0x22 0 1M"' "(qemu)" | _filter_qemu_io
> +echo
> +$PYTHON ../../contrib/backup/qemu-backup.py backup --inc --guest adad
> +_send_qemu_cmd $QEMU_HANDLE 'quit' ''
> +wait=1 _cleanup_qemu
> +echo
> +echo "== Comparing images =="
> +$QEMU_IMG compare $TEST_DIR/virtio0_inc_1 $TEST_IMG
> +rm $TEST_DIR/virtio0_inc_0
> +rm $TEST_DIR/virtio0_inc_1
> +rm $CONFIG_FILE
> +
> +echo "*** done"
> +status=0
> \ No newline at end of file
> diff --git a/tests/qemu-iotests/193.out b/tests/qemu-iotests/193.out
> new file mode 100644
> index 0000000..3a836c2
> --- /dev/null
> +++ b/tests/qemu-iotests/193.out
> @@ -0,0 +1,34 @@
> +QA output created by 193
> +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
> +
> +Successfully Added Guest
> +Successfully Added Drive
> +
> +== Creating backup ==
> +QEMU X.Y.Z monitor - type 'help' for more information
> +(qemu) Formatting 'TEST_DIR/virtio0_inc_0', fmt=qcow2 size=134217728 cluster_size=65536 lazy_refcounts=off refcount_bits=16
> +quit
> +
> +== Comparing images ==
> +Images are identical.
> +
> +== Writing Pattern ==
> +QEMU X.Y.Z monitor - type 'help' for more information
> +(qemu) qemu-io virtio0 "write -P 0x22 0 1M"
> +
> +== Creating backup ==
> +Initial Backup does not exist
> +== Writing Pattern ==
> +wrote 1048576/1048576 bytes at offset 0
> +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +(qemu) Formatting 'TEST_DIR/virtio0_inc_0', fmt=qcow2 size=134217728 cluster_size=65536 lazy_refcounts=off refcount_bits=16
> +
> +Formatting '/home/ishani/Desktop/opw/qemu/tests/qemu-iotests/scratch/virtio0_inc_1', fmt=qcow2 size=134217728 backing_file=/home/ishani/Desktop/opw/qemu/tests/qemu-iotests/scratch/virtio0_inc_0 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16
> +qemu-io virtio0 "write -P 0x22 0 1M"
> +wrote 1048576/1048576 bytes at offset 0
> +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +(qemu) quit
> +
> +== Comparing images ==
> +Images are identical.
> +*** done
> diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
> index 33c945b..6b9e034 100644
> --- a/tests/qemu-iotests/group
> +++ b/tests/qemu-iotests/group
> @@ -189,3 +189,4 @@
>  191 rw auto
>  192 rw auto quick
>  194 rw auto migration quick
> +193 rw auto

Let's add this line after 192 before 194, and you can add 'quick' btw.

Fam

> -- 
> 2.7.4
> 
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] Backup Tool: Test for Incremental Backup
  2017-08-31  2:02   ` Fam Zheng
@ 2017-09-01 22:53     ` John Snow
  2017-09-07  4:03       ` Ishani
  0 siblings, 1 reply; 9+ messages in thread
From: John Snow @ 2017-09-01 22:53 UTC (permalink / raw)
  To: Fam Zheng, Ishani Chugh; +Cc: qemu-devel, stefanha



On 08/30/2017 10:02 PM, Fam Zheng wrote:
> On Thu, 08/31 00:45, Ishani Chugh wrote:
>> This patch is the test for incremental backup implementation in Backup tool.
>> The test employs two basic subtests:
>> 1) Backing up an empty guest and comparing it with base image.
>> 2) Writing a pattern to the guest, creating backup, writing
>>    a pattern again, creating backup and comparing with base image.
>>
>> Signed-off-by: Ishani Chugh <chugh.ishani@research.iiit.ac.in>
>> ---
>>  tests/qemu-iotests/193     | 86 ++++++++++++++++++++++++++++++++++++++++++++++
>>  tests/qemu-iotests/193.out | 34 ++++++++++++++++++
>>  tests/qemu-iotests/group   |  1 +
>>  3 files changed, 121 insertions(+)
>>  create mode 100755 tests/qemu-iotests/193
>>  create mode 100644 tests/qemu-iotests/193.out
>>
>> diff --git a/tests/qemu-iotests/193 b/tests/qemu-iotests/193
>> new file mode 100755
>> index 0000000..500e5df
>> --- /dev/null
>> +++ b/tests/qemu-iotests/193
>> @@ -0,0 +1,86 @@
>> +#!/bin/bash
>> +#
>> +# Test Incremental backup functionality of qemu-backup tool
>> +#
>> +# Copyright (C) 2009 Red Hat, Inc.
> 
> Year is off, probably the copyright holder too?
> 

Yup, please take credit for your own work, Ishani :)

>> +#
>> +# This program is free software; you can redistribute it and/or modify
>> +# it under the terms of the GNU General Public License as published by
>> +# the Free Software Foundation; either version 2 of the License, or
>> +# (at your option) any later version.
>> +#
>> +# This program 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 General Public License for more details.
>> +#
>> +# You should have received a copy of the GNU General Public License
>> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
>> +#
>> +
>> +# creator
>> +owner=chugh.ishani@research.iiit.ac.in
>> +
>> +seq=`basename $0`
>> +echo "QA output created by $seq"
>> +
>> +here=`pwd`
>> +status=1	# failure is the default!
> 
> s/\t/ /
> 

Fam means to remove the tab here and use spaces instead.

>> +
>> +
>> +# get standard environment, filters and checks
>> +. ./common.rc
>> +. ./common.filter
>> +. ./common.qemu
>> +
>> +_supported_fmt generic
>> +_supported_proto generic
>> +_supported_os Linux
>> +
>> +
>> +CONFIG_FILE=$TEST_DIR/backup-config
>> +SOCKET=unix:$TEST_DIR/backup_socket
>> +size=128M
>> +
>> +_make_test_img $size
>> +export QEMU_BACKUP_CONFIG=$CONFIG_FILE
>> +qemu_comm_method="monitor"
>> +echo
>> +_launch_qemu -drive if=virtio,file=$TEST_IMG -qmp $SOCKET,server,nowait
>> +$PYTHON ../../contrib/backup/qemu-backup.py guest add --guest adad --qmp $SOCKET
>> +$PYTHON ../../contrib/backup/qemu-backup.py drive add --id virtio0 --guest adad --target $TEST_DIR/virtio0
>> +echo
>> +echo "== Creating backup =="
>> +$PYTHON ../../contrib/backup/qemu-backup.py backup --inc --guest adad
>> +_send_qemu_cmd $QEMU_HANDLE 'quit' ''
>> +wait=1 _cleanup_qemu
>> +echo
>> +echo "== Comparing images =="
>> +$QEMU_IMG compare $TEST_DIR/virtio0_inc_0 $TEST_IMG
>> +
>> +rm $TEST_DIR/virtio0_inc_0
>> +
>> +_launch_qemu -drive if=virtio,id=virtio0,file=$TEST_IMG -qmp $SOCKET,server,nowait
>> +echo
>> +echo "== Writing Pattern =="
>> +_send_qemu_cmd $QEMU_HANDLE 'qemu-io virtio0 "write -P 0x22 0 1M"' "(qemu)" | _filter_qemu_io
>> +echo
>> +
>> +echo "== Creating backup =="
>> +$PYTHON ../../contrib/backup/qemu-backup.py backup --inc --guest adad
>> +
>> +echo "== Writing Pattern =="
>> +_send_qemu_cmd $QEMU_HANDLE 'qemu-io virtio0 "write -P 0x22 0 1M"' "(qemu)" | _filter_qemu_io
>> +echo
>> +$PYTHON ../../contrib/backup/qemu-backup.py backup --inc --guest adad
>> +_send_qemu_cmd $QEMU_HANDLE 'quit' ''
>> +wait=1 _cleanup_qemu
>> +echo
>> +echo "== Comparing images =="
>> +$QEMU_IMG compare $TEST_DIR/virtio0_inc_1 $TEST_IMG
>> +rm $TEST_DIR/virtio0_inc_0
>> +rm $TEST_DIR/virtio0_inc_1
>> +rm $CONFIG_FILE
>> +
>> +echo "*** done"
>> +status=0
>> \ No newline at end of file
>> diff --git a/tests/qemu-iotests/193.out b/tests/qemu-iotests/193.out
>> new file mode 100644
>> index 0000000..3a836c2
>> --- /dev/null
>> +++ b/tests/qemu-iotests/193.out
>> @@ -0,0 +1,34 @@
>> +QA output created by 193
>> +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
>> +
>> +Successfully Added Guest
>> +Successfully Added Drive
>> +
>> +== Creating backup ==
>> +QEMU X.Y.Z monitor - type 'help' for more information
>> +(qemu) Formatting 'TEST_DIR/virtio0_inc_0', fmt=qcow2 size=134217728 cluster_size=65536 lazy_refcounts=off refcount_bits=16
>> +quit
>> +
>> +== Comparing images ==
>> +Images are identical.
>> +
>> +== Writing Pattern ==
>> +QEMU X.Y.Z monitor - type 'help' for more information
>> +(qemu) qemu-io virtio0 "write -P 0x22 0 1M"
>> +
>> +== Creating backup ==
>> +Initial Backup does not exist
>> +== Writing Pattern ==
>> +wrote 1048576/1048576 bytes at offset 0
>> +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +(qemu) Formatting 'TEST_DIR/virtio0_inc_0', fmt=qcow2 size=134217728 cluster_size=65536 lazy_refcounts=off refcount_bits=16
>> +
>> +Formatting '/home/ishani/Desktop/opw/qemu/tests/qemu-iotests/scratch/virtio0_inc_1', fmt=qcow2 size=134217728 backing_file=/home/ishani/Desktop/opw/qemu/tests/qemu-iotests/scratch/virtio0_inc_0 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16
>> +qemu-io virtio0 "write -P 0x22 0 1M"
>> +wrote 1048576/1048576 bytes at offset 0
>> +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +(qemu) quit
>> +
>> +== Comparing images ==
>> +Images are identical.
>> +*** done
>> diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
>> index 33c945b..6b9e034 100644
>> --- a/tests/qemu-iotests/group
>> +++ b/tests/qemu-iotests/group
>> @@ -189,3 +189,4 @@
>>  191 rw auto
>>  192 rw auto quick
>>  194 rw auto migration quick
>> +193 rw auto
> 
> Let's add this line after 192 before 194, and you can add 'quick' btw.
> 
> Fam
> 
>> -- 
>> 2.7.4
>>
>>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] Backup Tool: Test for Incremental Backup
  2017-09-01 22:53     ` John Snow
@ 2017-09-07  4:03       ` Ishani
  0 siblings, 0 replies; 9+ messages in thread
From: Ishani @ 2017-09-07  4:03 UTC (permalink / raw)
  To: jsnow; +Cc: Fam Zheng, qemu-devel, stefanha

Hello,
I apologize for late reply. I was occupied by exams.
I will send a revision asap. 
Thanks.

----- On Sep 2, 2017, at 4:23 AM, jsnow jsnow@redhat.com wrote:

> On 08/30/2017 10:02 PM, Fam Zheng wrote:
>> On Thu, 08/31 00:45, Ishani Chugh wrote:
>>> This patch is the test for incremental backup implementation in Backup tool.
>>> The test employs two basic subtests:
>>> 1) Backing up an empty guest and comparing it with base image.
>>> 2) Writing a pattern to the guest, creating backup, writing
>>>    a pattern again, creating backup and comparing with base image.
>>>
>>> Signed-off-by: Ishani Chugh <chugh.ishani@research.iiit.ac.in>
>>> ---
>>>  tests/qemu-iotests/193     | 86 ++++++++++++++++++++++++++++++++++++++++++++++
>>>  tests/qemu-iotests/193.out | 34 ++++++++++++++++++
>>>  tests/qemu-iotests/group   |  1 +
>>>  3 files changed, 121 insertions(+)
>>>  create mode 100755 tests/qemu-iotests/193
>>>  create mode 100644 tests/qemu-iotests/193.out
>>>
>>> diff --git a/tests/qemu-iotests/193 b/tests/qemu-iotests/193
>>> new file mode 100755
>>> index 0000000..500e5df
>>> --- /dev/null
>>> +++ b/tests/qemu-iotests/193
>>> @@ -0,0 +1,86 @@
>>> +#!/bin/bash
>>> +#
>>> +# Test Incremental backup functionality of qemu-backup tool
>>> +#
>>> +# Copyright (C) 2009 Red Hat, Inc.
>> 
>> Year is off, probably the copyright holder too?
>> 
> 
> Yup, please take credit for your own work, Ishani :)
> 
>>> +#
>>> +# This program is free software; you can redistribute it and/or modify
>>> +# it under the terms of the GNU General Public License as published by
>>> +# the Free Software Foundation; either version 2 of the License, or
>>> +# (at your option) any later version.
>>> +#
>>> +# This program 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 General Public License for more details.
>>> +#
>>> +# You should have received a copy of the GNU General Public License
>>> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
>>> +#
>>> +
>>> +# creator
>>> +owner=chugh.ishani@research.iiit.ac.in
>>> +
>>> +seq=`basename $0`
>>> +echo "QA output created by $seq"
>>> +
>>> +here=`pwd`
>>> +status=1	# failure is the default!
>> 
>> s/\t/ /
>> 
> 
> Fam means to remove the tab here and use spaces instead.
> 
>>> +
>>> +
>>> +# get standard environment, filters and checks
>>> +. ./common.rc
>>> +. ./common.filter
>>> +. ./common.qemu
>>> +
>>> +_supported_fmt generic
>>> +_supported_proto generic
>>> +_supported_os Linux
>>> +
>>> +
>>> +CONFIG_FILE=$TEST_DIR/backup-config
>>> +SOCKET=unix:$TEST_DIR/backup_socket
>>> +size=128M
>>> +
>>> +_make_test_img $size
>>> +export QEMU_BACKUP_CONFIG=$CONFIG_FILE
>>> +qemu_comm_method="monitor"
>>> +echo
>>> +_launch_qemu -drive if=virtio,file=$TEST_IMG -qmp $SOCKET,server,nowait
>>> +$PYTHON ../../contrib/backup/qemu-backup.py guest add --guest adad --qmp
>>> $SOCKET
>>> +$PYTHON ../../contrib/backup/qemu-backup.py drive add --id virtio0 --guest adad
>>> --target $TEST_DIR/virtio0
>>> +echo
>>> +echo "== Creating backup =="
>>> +$PYTHON ../../contrib/backup/qemu-backup.py backup --inc --guest adad
>>> +_send_qemu_cmd $QEMU_HANDLE 'quit' ''
>>> +wait=1 _cleanup_qemu
>>> +echo
>>> +echo "== Comparing images =="
>>> +$QEMU_IMG compare $TEST_DIR/virtio0_inc_0 $TEST_IMG
>>> +
>>> +rm $TEST_DIR/virtio0_inc_0
>>> +
>>> +_launch_qemu -drive if=virtio,id=virtio0,file=$TEST_IMG -qmp
>>> $SOCKET,server,nowait
>>> +echo
>>> +echo "== Writing Pattern =="
>>> +_send_qemu_cmd $QEMU_HANDLE 'qemu-io virtio0 "write -P 0x22 0 1M"' "(qemu)" |
>>> _filter_qemu_io
>>> +echo
>>> +
>>> +echo "== Creating backup =="
>>> +$PYTHON ../../contrib/backup/qemu-backup.py backup --inc --guest adad
>>> +
>>> +echo "== Writing Pattern =="
>>> +_send_qemu_cmd $QEMU_HANDLE 'qemu-io virtio0 "write -P 0x22 0 1M"' "(qemu)" |
>>> _filter_qemu_io
>>> +echo
>>> +$PYTHON ../../contrib/backup/qemu-backup.py backup --inc --guest adad
>>> +_send_qemu_cmd $QEMU_HANDLE 'quit' ''
>>> +wait=1 _cleanup_qemu
>>> +echo
>>> +echo "== Comparing images =="
>>> +$QEMU_IMG compare $TEST_DIR/virtio0_inc_1 $TEST_IMG
>>> +rm $TEST_DIR/virtio0_inc_0
>>> +rm $TEST_DIR/virtio0_inc_1
>>> +rm $CONFIG_FILE
>>> +
>>> +echo "*** done"
>>> +status=0
>>> \ No newline at end of file
>>> diff --git a/tests/qemu-iotests/193.out b/tests/qemu-iotests/193.out
>>> new file mode 100644
>>> index 0000000..3a836c2
>>> --- /dev/null
>>> +++ b/tests/qemu-iotests/193.out
>>> @@ -0,0 +1,34 @@
>>> +QA output created by 193
>>> +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
>>> +
>>> +Successfully Added Guest
>>> +Successfully Added Drive
>>> +
>>> +== Creating backup ==
>>> +QEMU X.Y.Z monitor - type 'help' for more information
>>> +(qemu) Formatting 'TEST_DIR/virtio0_inc_0', fmt=qcow2 size=134217728
>>> cluster_size=65536 lazy_refcounts=off refcount_bits=16
>>> +quit
>>> +
>>> +== Comparing images ==
>>> +Images are identical.
>>> +
>>> +== Writing Pattern ==
>>> +QEMU X.Y.Z monitor - type 'help' for more information
>>> +(qemu) qemu-io virtio0 "write -P 0x22 0 1M"
>>> +
>>> +== Creating backup ==
>>> +Initial Backup does not exist
>>> +== Writing Pattern ==
>>> +wrote 1048576/1048576 bytes at offset 0
>>> +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>>> +(qemu) Formatting 'TEST_DIR/virtio0_inc_0', fmt=qcow2 size=134217728
>>> cluster_size=65536 lazy_refcounts=off refcount_bits=16
>>> +
>>> +Formatting
>>> '/home/ishani/Desktop/opw/qemu/tests/qemu-iotests/scratch/virtio0_inc_1',
>>> fmt=qcow2 size=134217728
>>> backing_file=/home/ishani/Desktop/opw/qemu/tests/qemu-iotests/scratch/virtio0_inc_0
>>> backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off
>>> refcount_bits=16
>>> +qemu-io virtio0 "write -P 0x22 0 1M"
>>> +wrote 1048576/1048576 bytes at offset 0
>>> +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>>> +(qemu) quit
>>> +
>>> +== Comparing images ==
>>> +Images are identical.
>>> +*** done
>>> diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
>>> index 33c945b..6b9e034 100644
>>> --- a/tests/qemu-iotests/group
>>> +++ b/tests/qemu-iotests/group
>>> @@ -189,3 +189,4 @@
>>>  191 rw auto
>>>  192 rw auto quick
>>>  194 rw auto migration quick
>>> +193 rw auto
>> 
>> Let's add this line after 192 before 194, and you can add 'quick' btw.
>> 
>> Fam
>> 
>>> --
>>> 2.7.4
>>>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-09-07  4:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-30 19:15 [Qemu-devel] [PATCH 0/3] Backup Tool: Incremental backup Ishani Chugh
2017-08-30 19:15 ` [Qemu-devel] [PATCH 1/3] Backup Tool: Manpage for Incremental Backup Ishani Chugh
2017-08-31  1:57   ` Fam Zheng
2017-08-30 19:15 ` [Qemu-devel] [PATCH 2/3] Backup Tool: Support " Ishani Chugh
2017-08-31  1:56   ` Fam Zheng
2017-08-30 19:15 ` [Qemu-devel] [PATCH 3/3] Backup Tool: Test " Ishani Chugh
2017-08-31  2:02   ` Fam Zheng
2017-09-01 22:53     ` John Snow
2017-09-07  4:03       ` Ishani

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.