* [Qemu-devel] [PATCH 0/2] block: fix BDRV_O_SNAPSHOT with protocols
@ 2013-03-18 14:39 Stefan Hajnoczi
2013-03-18 14:39 ` [Qemu-devel] [PATCH 1/2] block: fix BDRV_O_SNAPSHOT protocol detection Stefan Hajnoczi
2013-03-18 14:39 ` [Qemu-devel] [PATCH 2/2] qemu-iotests: add 052 BDRV_O_SNAPSHOT test Stefan Hajnoczi
0 siblings, 2 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2013-03-18 14:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, rjones, Stefan Hajnoczi
Richard Jones <rjones@redhat.com> reported that BDRV_O_SNAPSHOT does not work
with NBD:
/usr/bin/qemu-system-x86_64 \
[...]
-device virtio-scsi-pci,id=scsi \
-drive file=nbd:localhost:61930,snapshot=on,format=raw,id=hd0,if=none \
-device scsi-hd,drive=hd0 \
[...]
gives the error:
qemu-system-x86_64: -drive file=nbd:localhost:61930,snapshot=on,format=raw,id=hd0,if=none: could not open disk image nbd:localhost:61930: No such file or directory
This series fixes the issue and adds a regression test, qemu-iotests 052. Run
the test like this:
$ QEMU_PROG=... PATH=... ./check -nbd 052
If Patch 1 is not applied, the test case fails. Note that the test case is
also useful with -raw or other formats.
Stefan Hajnoczi (2):
block: fix BDRV_O_SNAPSHOT protocol detection
qemu-iotests: add 052 BDRV_O_SNAPSHOT test
block.c | 9 +++----
tests/qemu-iotests/052 | 61 ++++++++++++++++++++++++++++++++++++++++++++++
tests/qemu-iotests/052.out | 13 ++++++++++
tests/qemu-iotests/group | 1 +
4 files changed, 78 insertions(+), 6 deletions(-)
create mode 100755 tests/qemu-iotests/052
create mode 100644 tests/qemu-iotests/052.out
--
1.8.1.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH 1/2] block: fix BDRV_O_SNAPSHOT protocol detection
2013-03-18 14:39 [Qemu-devel] [PATCH 0/2] block: fix BDRV_O_SNAPSHOT with protocols Stefan Hajnoczi
@ 2013-03-18 14:39 ` Stefan Hajnoczi
2013-03-18 14:39 ` [Qemu-devel] [PATCH 2/2] qemu-iotests: add 052 BDRV_O_SNAPSHOT test Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2013-03-18 14:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, rjones, Stefan Hajnoczi
realpath(3) is used to get an absolute path to the image file when
creating a -drive snapshot=on temporary qcow2. This does not work for
protocols since their filenames ("proto:foo:...") do not correspond to
file system paths.
Commit 7c96d46ec245d73fd76726588409f9abe4bd5dc1 ("Let snapshot work with
protocols") skipped realpath(3) for protocols. Later on the "raw"
format was introduced and broke the check.
Use path_has_protocol(filename) to decide if this image uses a protocol
or a filename.
Reported-by: Richard Jones <rjones@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/block.c b/block.c
index 124a9eb..acc7d1c 100644
--- a/block.c
+++ b/block.c
@@ -812,7 +812,6 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;
- int is_protocol = 0;
BlockDriver *bdrv_qcow2;
QEMUOptionParameter *options;
char backing_filename[PATH_MAX];
@@ -829,9 +828,6 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
}
total_size = bdrv_getlength(bs1) & BDRV_SECTOR_MASK;
- if (bs1->drv && bs1->drv->protocol_name)
- is_protocol = 1;
-
bdrv_delete(bs1);
ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));
@@ -840,11 +836,12 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
}
/* Real path is meaningless for protocols */
- if (is_protocol)
+ if (path_has_protocol(filename)) {
snprintf(backing_filename, sizeof(backing_filename),
"%s", filename);
- else if (!realpath(filename, backing_filename))
+ } else if (!realpath(filename, backing_filename)) {
return -errno;
+ }
bdrv_qcow2 = bdrv_find_format("qcow2");
options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH 2/2] qemu-iotests: add 052 BDRV_O_SNAPSHOT test
2013-03-18 14:39 [Qemu-devel] [PATCH 0/2] block: fix BDRV_O_SNAPSHOT with protocols Stefan Hajnoczi
2013-03-18 14:39 ` [Qemu-devel] [PATCH 1/2] block: fix BDRV_O_SNAPSHOT protocol detection Stefan Hajnoczi
@ 2013-03-18 14:39 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2013-03-18 14:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, rjones, Stefan Hajnoczi
Check that writes to an image opened with BDRV_O_SNAPSHOT do not modify
the underlying image file.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/qemu-iotests/052 | 61 ++++++++++++++++++++++++++++++++++++++++++++++
tests/qemu-iotests/052.out | 13 ++++++++++
tests/qemu-iotests/group | 1 +
3 files changed, 75 insertions(+)
create mode 100755 tests/qemu-iotests/052
create mode 100644 tests/qemu-iotests/052.out
diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052
new file mode 100755
index 0000000..14a5126
--- /dev/null
+++ b/tests/qemu-iotests/052
@@ -0,0 +1,61 @@
+#!/bin/bash
+#
+# Test bdrv_read/bdrv_write using BDRV_O_SNAPSHOT
+#
+# Copyright (C) 2013 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
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+_supported_fmt generic
+_supported_proto generic
+_supported_os Linux
+
+
+size=128M
+_make_test_img $size
+
+echo
+echo "== reading whole image =="
+$QEMU_IO -s -c "read 0 $size" $TEST_IMG | _filter_qemu_io
+
+echo
+echo "== writing whole image does not modify image =="
+$QEMU_IO -s -c "write -P 0xa 0 $size" $TEST_IMG | _filter_qemu_io
+$QEMU_IO -c "read -P 0 0 $size" $TEST_IMG | _filter_qemu_io
+
+# success, all done
+echo "*** done"
+rm -f $seq.full
+status=0
diff --git a/tests/qemu-iotests/052.out b/tests/qemu-iotests/052.out
new file mode 100644
index 0000000..8617aa2
--- /dev/null
+++ b/tests/qemu-iotests/052.out
@@ -0,0 +1,13 @@
+QA output created by 052
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
+
+== reading whole image ==
+read 134217728/134217728 bytes at offset 0
+128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+== writing whole image does not modify image ==
+wrote 134217728/134217728 bytes at offset 0
+128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 134217728/134217728 bytes at offset 0
+128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+*** done
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index fcf57e0..a496e2c 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -56,3 +56,4 @@
047 rw auto
048 img auto quick
049 rw auto
+052 rw auto backing
--
1.8.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-18 14:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-18 14:39 [Qemu-devel] [PATCH 0/2] block: fix BDRV_O_SNAPSHOT with protocols Stefan Hajnoczi
2013-03-18 14:39 ` [Qemu-devel] [PATCH 1/2] block: fix BDRV_O_SNAPSHOT protocol detection Stefan Hajnoczi
2013-03-18 14:39 ` [Qemu-devel] [PATCH 2/2] qemu-iotests: add 052 BDRV_O_SNAPSHOT test Stefan Hajnoczi
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).