diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2013-03-19 07:58:44 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-03-19 07:58:44 -0500 |
commit | 277ba8a6d717abb2f36896cd9877a68d2cf03d77 (patch) | |
tree | 3b330b5d9e5a529410444237fd56e86c1c2193f4 | |
parent | 2c8a59422c06fe1e37c85502d92ccdfb5e2ac987 (diff) | |
parent | a8e5cc0c076a6e3a62f0e9aad88b007dccf3dd17 (diff) |
Merge remote-tracking branch 'kwolf/for-anthony' into staging
# By Stefan Hajnoczi (2) and others
# Via Kevin Wolf
* kwolf/for-anthony:
virtio-blk: Do not segfault fault if failed to initialize dataplane
qemu-iotests: add 052 BDRV_O_SNAPSHOT test
block: fix BDRV_O_SNAPSHOT protocol detection
qcow2: Fix segfault in qcow2_invalidate_cache
sheepdog: show error message for halt status
-rw-r--r-- | block.c | 6 | ||||
-rw-r--r-- | block/qcow2.c | 12 | ||||
-rw-r--r-- | block/qcow2.h | 3 | ||||
-rw-r--r-- | block/sheepdog.c | 2 | ||||
-rw-r--r-- | hw/virtio-blk.c | 2 | ||||
-rwxr-xr-x | tests/qemu-iotests/052 | 61 | ||||
-rw-r--r-- | tests/qemu-iotests/052.out | 13 | ||||
-rw-r--r-- | tests/qemu-iotests/group | 1 |
8 files changed, 92 insertions, 8 deletions
@@ -830,7 +830,6 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, 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]; @@ -847,9 +846,6 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, } 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)); @@ -858,7 +854,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, } /* 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)) { diff --git a/block/qcow2.c b/block/qcow2.c index 1f99866cf4..98bb7f31bf 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -29,6 +29,7 @@ #include "block/qcow2.h" #include "qemu/error-report.h" #include "qapi/qmp/qerror.h" +#include "qapi/qmp/qbool.h" #include "trace.h" /* @@ -520,7 +521,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags) goto fail; } - s->use_lazy_refcounts = qemu_opt_get_bool(opts, "lazy_refcounts", + s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); qemu_opts_del(opts); @@ -930,6 +931,7 @@ static void qcow2_invalidate_cache(BlockDriverState *bs) AES_KEY aes_encrypt_key; AES_KEY aes_decrypt_key; uint32_t crypt_method = 0; + QDict *options; /* * Backing files are read-only which makes all of their metadata immutable, @@ -944,8 +946,14 @@ static void qcow2_invalidate_cache(BlockDriverState *bs) qcow2_close(bs); + options = qdict_new(); + qdict_put(options, QCOW2_OPT_LAZY_REFCOUNTS, + qbool_from_int(s->use_lazy_refcounts)); + memset(s, 0, sizeof(BDRVQcowState)); - qcow2_open(bs, NULL, flags); + qcow2_open(bs, options, flags); + + QDECREF(options); if (crypt_method) { s->crypt_method = crypt_method; diff --git a/block/qcow2.h b/block/qcow2.h index 103abdb2c0..e4b5e11a91 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -58,6 +58,9 @@ #define DEFAULT_CLUSTER_SIZE 65536 + +#define QCOW2_OPT_LAZY_REFCOUNTS "lazy_refcounts" + typedef struct QCowHeader { uint32_t magic; uint32_t version; diff --git a/block/sheepdog.c b/block/sheepdog.c index 4245328569..54d3e53162 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -65,6 +65,7 @@ #define SD_RES_WAIT_FOR_FORMAT 0x16 /* Waiting for a format operation */ #define SD_RES_WAIT_FOR_JOIN 0x17 /* Waiting for other nodes joining */ #define SD_RES_JOIN_FAILED 0x18 /* Target node had failed to join sheepdog */ +#define SD_RES_HALT 0x19 /* Sheepdog is stopped serving IO request */ /* * Object ID rules @@ -344,6 +345,7 @@ static const char * sd_strerror(int err) {SD_RES_WAIT_FOR_FORMAT, "Sheepdog is waiting for a format operation"}, {SD_RES_WAIT_FOR_JOIN, "Sheepdog is waiting for other nodes joining"}, {SD_RES_JOIN_FAILED, "Target node had failed to join sheepdog"}, + {SD_RES_HALT, "Sheepdog is stopped serving IO request"}, }; for (i = 0; i < ARRAY_SIZE(errors); ++i) { diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index e6f8875d00..f2143fded3 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -663,7 +663,7 @@ static int virtio_blk_device_init(VirtIODevice *vdev) s->vq = virtio_add_queue(vdev, 128, virtio_blk_handle_output); #ifdef CONFIG_VIRTIO_BLK_DATA_PLANE if (!virtio_blk_data_plane_create(vdev, blk, &s->dataplane)) { - virtio_cleanup(vdev); + virtio_common_cleanup(vdev); return -1; } #endif diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052 new file mode 100755 index 0000000000..14a5126635 --- /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 0000000000..8617aa2a9e --- /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 1d7e4f31a0..73c5966e10 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -57,3 +57,4 @@ 048 img auto quick 049 rw auto 050 rw auto backing quick +052 rw auto backing |