qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: anthony@codemonkey.ws
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 09/32] qemu-iotests: Add 043 backing file chain infinite loop test
Date: Wed, 24 Oct 2012 11:50:33 +0200	[thread overview]
Message-ID: <1351072256-6112-10-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1351072256-6112-1-git-send-email-kwolf@redhat.com>

From: Stefan Hajnoczi <stefanha@redhat.com>

This new test verifies that qemu-img info --backing-chain safely aborts
when an image file has a backing file infinite loop.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/043       |   95 ++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/043.out   |   66 +++++++++++++++++++++++++++++
 tests/qemu-iotests/common.rc |   10 ++++
 tests/qemu-iotests/group     |    1 +
 4 files changed, 172 insertions(+), 0 deletions(-)
 create mode 100755 tests/qemu-iotests/043
 create mode 100644 tests/qemu-iotests/043.out

diff --git a/tests/qemu-iotests/043 b/tests/qemu-iotests/043
new file mode 100755
index 0000000..3ba08dc
--- /dev/null
+++ b/tests/qemu-iotests/043
@@ -0,0 +1,95 @@
+#!/bin/bash
+#
+# Test that qemu-img info --backing-chain detects infinite loops
+#
+# Copyright (C) 2012 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=stefanha@redhat.com
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+
+_cleanup()
+{
+    _cleanup_test_img
+    rm -f $TEST_IMG.[123].base
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+# Any format supporting backing files
+_supported_fmt qcow qcow2 vmdk qed
+_supported_proto generic
+_supported_os Linux
+
+
+size=128M
+_make_test_img $size
+$QEMU_IMG rebase -u -b $TEST_IMG $TEST_IMG
+
+echo
+echo "== backing file references self =="
+_img_info --backing-chain
+
+_make_test_img $size
+mv $TEST_IMG $TEST_IMG.base
+_make_test_img -b $TEST_IMG.base $size
+$QEMU_IMG rebase -u -b $TEST_IMG $TEST_IMG.base
+
+echo
+echo "== parent references self =="
+_img_info --backing-chain
+
+_make_test_img $size
+mv $TEST_IMG $TEST_IMG.1.base
+_make_test_img -b $TEST_IMG.1.base $size
+mv $TEST_IMG $TEST_IMG.2.base
+_make_test_img -b $TEST_IMG.2.base $size
+mv $TEST_IMG $TEST_IMG.3.base
+_make_test_img -b $TEST_IMG.3.base $size
+$QEMU_IMG rebase -u -b $TEST_IMG.2.base $TEST_IMG.1.base
+
+echo
+echo "== ancestor references another ancestor =="
+_img_info --backing-chain
+
+_make_test_img $size
+mv $TEST_IMG $TEST_IMG.1.base
+_make_test_img -b $TEST_IMG.1.base $size
+mv $TEST_IMG $TEST_IMG.2.base
+_make_test_img -b $TEST_IMG.2.base $size
+
+echo
+echo "== finite chain of length 3 (human) =="
+_img_info --backing-chain
+
+echo
+echo "== finite chain of length 3 (json) =="
+_img_info --backing-chain --output=json
+
+# success, all done
+echo "*** done"
+rm -f $seq.full
+status=0
diff --git a/tests/qemu-iotests/043.out b/tests/qemu-iotests/043.out
new file mode 100644
index 0000000..ad23337
--- /dev/null
+++ b/tests/qemu-iotests/043.out
@@ -0,0 +1,66 @@
+QA output created by 043
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 
+
+== backing file references self ==
+qemu-img: Backing file 'TEST_DIR/t.IMGFMT' creates an infinite loop.
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file='TEST_DIR/t.IMGFMT.base' 
+
+== parent references self ==
+qemu-img: Backing file 'TEST_DIR/t.IMGFMT' creates an infinite loop.
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file='TEST_DIR/t.IMGFMT.1.base' 
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file='TEST_DIR/t.IMGFMT.2.base' 
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file='TEST_DIR/t.IMGFMT.3.base' 
+
+== ancestor references another ancestor ==
+qemu-img: Backing file 'TEST_DIR/t.IMGFMT.2.base' creates an infinite loop.
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file='TEST_DIR/t.IMGFMT.1.base' 
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file='TEST_DIR/t.IMGFMT.2.base' 
+
+== finite chain of length 3 (human) ==
+image: TEST_DIR/t.IMGFMT
+file format: IMGFMT
+virtual size: 128M (134217728 bytes)
+cluster_size: 65536
+backing file: TEST_DIR/t.IMGFMT.2.base
+
+image: TEST_DIR/t.IMGFMT.2.base
+file format: IMGFMT
+virtual size: 128M (134217728 bytes)
+cluster_size: 65536
+backing file: TEST_DIR/t.IMGFMT.1.base
+
+image: TEST_DIR/t.IMGFMT.1.base
+file format: IMGFMT
+virtual size: 128M (134217728 bytes)
+cluster_size: 65536
+
+== finite chain of length 3 (json) ==
+[
+    {
+        "virtual-size": 134217728, 
+        "filename": "TEST_DIR/t.IMGFMT", 
+        "cluster-size": 65536, 
+        "format": "IMGFMT", 
+        "backing-filename": "TEST_DIR/t.IMGFMT.2.base", 
+        "dirty-flag": false
+    }, 
+    {
+        "virtual-size": 134217728, 
+        "filename": "TEST_DIR/t.IMGFMT.2.base", 
+        "cluster-size": 65536, 
+        "format": "IMGFMT", 
+        "backing-filename": "TEST_DIR/t.IMGFMT.1.base", 
+        "dirty-flag": false
+    }, 
+    {
+        "virtual-size": 134217728, 
+        "filename": "TEST_DIR/t.IMGFMT.1.base", 
+        "cluster-size": 65536, 
+        "format": "IMGFMT", 
+        "dirty-flag": false
+    }
+]
+*** done
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index d534e94..334534f 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -145,6 +145,16 @@ _check_test_img()
     	sed -e 's/qemu-img\: This image format does not support checks/No errors were found on the image./'
 }
 
+_img_info()
+{
+    $QEMU_IMG info "$@" $TEST_IMG 2>&1 | \
+        sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
+            -e "s#$TEST_DIR#TEST_DIR#g" \
+            -e "s#$IMGFMT#IMGFMT#g" \
+            -e "/^disk size:/ D" \
+            -e "/actual-size/ D"
+}
+
 _get_pids_by_name()
 {
     if [ $# -ne 1 ]
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index d5f9ab0..7407492 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -48,3 +48,4 @@
 039 rw auto
 040 rw auto
 042 rw auto quick
+043 rw auto backing
-- 
1.7.6.5

  parent reply	other threads:[~2012-10-24  9:51 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-24  9:50 [Qemu-devel] [PULL 00/32] Block patches Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 01/32] qemu-img: Fix division by zero for zero size images Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 02/32] qemu-iotests: Test qemu-img operation on zero size image Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 03/32] qmp: fix __accept() in qmp.py Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 04/32] qemu-img rebase: use empty string to rebase without backing file Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 05/32] block: make bdrv_find_backing_image compare canonical filenames Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 06/32] block: in commit, determine base image from the top image Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 07/32] qemu-iotests: add relative backing file tests for block-commit (040) Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 08/32] qemu-img: Add --backing-chain option to info command Kevin Wolf
2012-10-24  9:50 ` Kevin Wolf [this message]
2012-10-24  9:50 ` [Qemu-devel] [PATCH 10/32] qemu-img: document 'info --backing-chain' Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 11/32] block: bdrv_create(): don't leak cco.filename on error Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 12/32] monitor: Allow add-fd to any specified fd set Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 13/32] monitor: Enable adding an inherited fd to an " Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 14/32] monitor: Prevent removing fd from set during init Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 15/32] qemu-config: Add new -add-fd command line option Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 16/32] block: add bdrv_query_info Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 17/32] block: add bdrv_query_stats Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 18/32] block: add bdrv_open_backing_file Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 19/32] block: introduce new dirty bitmap functionality Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 20/32] block: export dirty bitmap information in query-block Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 21/32] block: rename block_job_complete to block_job_completed Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 22/32] block: add block-job-complete Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 23/32] block: introduce BLOCK_JOB_READY event Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 24/32] mirror: introduce mirror job Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 25/32] qmp: add drive-mirror command Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 26/32] mirror: implement completion Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 27/32] qemu-iotests: add mirroring test case Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 28/32] iostatus: forward block_job_iostatus_reset to block job Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 29/32] mirror: add support for on-source-error/on-target-error Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 30/32] qmp: add pull_event function Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 31/32] qemu-iotests: add testcases for mirroring on-source-error/on-target-error Kevin Wolf
2012-10-24  9:50 ` [Qemu-devel] [PATCH 32/32] osdep: Less restrictive F_SEFL in qemu_dup_flags() Kevin Wolf
2012-10-29 19:24 ` [Qemu-devel] [PULL 00/32] Block patches Anthony Liguori

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=1351072256-6112-10-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=anthony@codemonkey.ws \
    --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).