From: John Snow <jsnow@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, John Snow <jsnow@redhat.com>,
jcody@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 8/9] iotests: 124: support differential backups
Date: Thu, 4 Jun 2015 20:20:41 -0400 [thread overview]
Message-ID: <1433463642-21840-9-git-send-email-jsnow@redhat.com> (raw)
In-Reply-To: <1433463642-21840-1-git-send-email-jsnow@redhat.com>
Rekerjigger the helper functions to be able to tolerate
differential backups.
Signed-off-by: John Snow <jsnow@redhat.com>
---
tests/qemu-iotests/124 | 69 +++++++++++++++++++++++++++++++-------------------
1 file changed, 43 insertions(+), 26 deletions(-)
diff --git a/tests/qemu-iotests/124 b/tests/qemu-iotests/124
index 07b1a47..c446c81 100644
--- a/tests/qemu-iotests/124
+++ b/tests/qemu-iotests/124
@@ -61,34 +61,47 @@ class Bitmap:
self.backups = list()
def base_target(self):
- return (self.drive['backup'], None)
+ return { 'type': 'full',
+ 'target': self.drive['backup'],
+ 'reference': None }
- def new_target(self, num=None):
+ def new_target(self, num=None, sync='incremental'):
if num is None:
num = self.num
self.num = num + 1
base = os.path.join(iotests.test_dir,
"%s.%s." % (self.drive['id'], self.name))
suff = "%i.%s" % (num, self.drive['fmt'])
- target = base + "inc" + suff
+ target = base + sync[:3] + suff
reference = base + "ref" + suff
- self.backups.append((target, reference))
- return (target, reference)
+
+ self.backups.append({ 'type': sync,
+ 'target': target,
+ 'reference': reference })
+ return self.backups[-1]
def last_target(self):
if self.backups:
return self.backups[-1]
return self.base_target()
+ def get_backing_file(self):
+ for backup in reversed(self.backups):
+ if backup['type'] != 'differential':
+ return backup['target']
+ return self.base_target()['target']
+
+ def remove_backup(self, backup):
+ try_remove(backup['target'])
+ try_remove(backup['reference'])
+
def del_target(self):
- for image in self.backups.pop():
- try_remove(image)
+ self.remove_backup(self.backups.pop())
self.num -= 1
def cleanup(self):
for backup in self.backups:
- for image in backup:
- try_remove(image)
+ self.remove_backup(backup)
class TestIncrementalBackup(iotests.QMPTestCase):
@@ -172,7 +185,7 @@ class TestIncrementalBackup(iotests.QMPTestCase):
def make_reference_backup(self, bitmap=None):
if bitmap is None:
bitmap = self.bitmaps[-1]
- _, reference = bitmap.last_target()
+ reference = bitmap.last_target()['reference']
res = self.do_qmp_backup(device=bitmap.drive['id'], sync='full',
format=bitmap.drive['fmt'], target=reference)
self.assertTrue(res)
@@ -187,29 +200,28 @@ class TestIncrementalBackup(iotests.QMPTestCase):
return bitmap
- def prepare_backup(self, bitmap=None, parent=None):
+ def prepare_backup(self, bitmap=None, parent=None, sync='incremental'):
if bitmap is None:
bitmap = self.bitmaps[-1]
if parent is None:
- parent, _ = bitmap.last_target()
+ parent = bitmap.get_backing_file()
- target, _ = bitmap.new_target()
+ target = bitmap.new_target(sync=sync)['target']
self.img_create(target, bitmap.drive['fmt'], parent=parent)
return target
- def create_incremental(self, bitmap=None, parent=None,
- parentFormat=None, validate=True):
+ def create_delta(self, sync='incremental', bitmap=None, parent=None,
+ parentFormat=None, validate=True):
if bitmap is None:
bitmap = self.bitmaps[-1]
if parent is None:
- parent, _ = bitmap.last_target()
+ parent = bitmap.get_backing_file()
- target = self.prepare_backup(bitmap, parent)
- res = self.do_qmp_backup(device=bitmap.drive['id'],
- sync='incremental', bitmap=bitmap.name,
- format=bitmap.drive['fmt'], target=target,
- mode='existing')
+ target = self.prepare_backup(bitmap, parent, sync)
+ res = self.do_qmp_backup(device=bitmap.drive['id'], sync=sync,
+ bitmap=bitmap.name, format=bitmap.drive['fmt'],
+ target=target, mode='existing')
if not res:
bitmap.del_target();
self.assertFalse(validate)
@@ -217,14 +229,19 @@ class TestIncrementalBackup(iotests.QMPTestCase):
self.make_reference_backup(bitmap)
return res
+ def create_incremental(self, *args, **kwargs):
+ return self.create_delta('incremental', *args, **kwargs)
+
+ def create_differential(self, *args, **kwargs):
+ return self.create_delta('differential', *args, **kwargs)
def check_backups(self):
for bitmap in self.bitmaps:
- for incremental, reference in bitmap.backups:
- self.assertTrue(iotests.compare_images(incremental, reference))
- last = bitmap.last_target()[0]
- self.assertTrue(iotests.compare_images(last, bitmap.drive['file']))
-
+ for backup in bitmap.backups:
+ self.assertTrue(iotests.compare_images(backup['target'],
+ backup['reference']))
+ self.assertTrue(iotests.compare_images(backup['target'],
+ bitmap.drive['file']))
def hmp_io_writes(self, drive, patterns):
for pattern in patterns:
--
2.1.0
next prev parent reply other threads:[~2015-06-05 0:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 0:20 [Qemu-devel] [PATCH 0/9] block: add differential backup support John Snow
2015-06-05 0:20 ` [Qemu-devel] [PATCH 1/9] qapi: Rename 'dirty-bitmap' mode to 'incremental' John Snow
2015-06-05 2:34 ` Eric Blake
2015-06-25 16:16 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-06-05 0:20 ` [Qemu-devel] [PATCH 2/9] hbitmap: add hbitmap_copy John Snow
2015-06-05 2:37 ` Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 3/9] block: add bdrv_copy_dirty_bitmap John Snow
2015-06-05 2:42 ` Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 4/9] qapi: add Copy data type for bitmaps John Snow
2015-06-05 2:57 ` Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 5/9] qmp: add qmp cmd block-dirty-bitmap-copy John Snow
2015-06-05 3:04 ` Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 6/9] qmp: add block-dirty-bitmap-copy transaction John Snow
2015-06-05 0:20 ` [Qemu-devel] [PATCH 7/9] block: add differential backup mode John Snow
2015-06-05 0:20 ` John Snow [this message]
2015-06-05 0:20 ` [Qemu-devel] [PATCH 9/9] iotests: add differential backup test John Snow
2015-06-23 17:00 ` [Qemu-devel] [PATCH 0/9] block: add differential backup support John Snow
2015-06-24 14:33 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1433463642-21840-9-git-send-email-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).