1 | The following changes since commit 98b2faeaee96ab084d0b1669918688d8895c155f: | 1 | The following changes since commit bfec359afba088aaacc7d316f43302f28c6e642a: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging (2017-02-10 18:07:02 +0000) | 3 | Merge remote-tracking branch 'remotes/armbru/tags/pull-qdev-2017-04-21' into staging (2017-04-21 11:42:03 +0100) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the git repository at: |
6 | 6 | ||
7 | git://github.com/XanClic/qemu.git tags/pull-block-2017-02-12 | 7 | git://github.com/codyprime/qemu-kvm-jtc.git tags/block-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to 10d6eda1926804a09aa0710ca62933087813de0b: | 9 | for you to fetch changes up to 1507631e438930bc07f776f303af127a9cdb4d41: |
10 | 10 | ||
11 | qemu-img: Avoid setting ret to unused value in img_convert() (2017-02-12 00:56:32 +0100) | 11 | qemu-iotests: _cleanup_qemu must be called on exit (2017-04-21 08:32:44 -0400) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block patches | 14 | |
15 | Block patches for 2.10 | ||
15 | 16 | ||
16 | ---------------------------------------------------------------- | 17 | ---------------------------------------------------------------- |
17 | Alberto Garcia (2): | ||
18 | qcow2: Optimize the refcount-block overlap check | ||
19 | qemu-io: don't allow I/O operations larger than BDRV_REQUEST_MAX_BYTES | ||
20 | 18 | ||
21 | Daniel P. Berrange (1): | 19 | Ashish Mittal (2): |
22 | iotests: record separate timings per format,protocol pair | 20 | block/vxhs.c: Add support for a new block device type called "vxhs" |
21 | block/vxhs.c: Add qemu-iotests for new block device type "vxhs" | ||
23 | 22 | ||
24 | Dou Liyang (2): | 23 | Jeff Cody (10): |
25 | block/qapi: reduce the coupling between the bdrv_query_stats and bdrv_query_bds_stats | 24 | qemu-iotests: exclude vxhs from image creation via protocol |
26 | block/qapi: reduce the execution time of qmp_query_blockstats | 25 | block: add bdrv_set_read_only() helper function |
26 | block: do not set BDS read_only if copy_on_read enabled | ||
27 | block: honor BDRV_O_ALLOW_RDWR when clearing bs->read_only | ||
28 | block: code movement | ||
29 | block: introduce bdrv_can_set_read_only() | ||
30 | block: use bdrv_can_set_read_only() during reopen | ||
31 | block/rbd - update variable names to more apt names | ||
32 | block/rbd: Add support for reopen() | ||
33 | qemu-iotests: _cleanup_qemu must be called on exit | ||
27 | 34 | ||
28 | Fam Zheng (2): | 35 | block.c | 56 +++- |
29 | qapi: Tweak error message of bdrv_query_image_info | 36 | block/Makefile.objs | 2 + |
30 | iotests: Fix reference output for 059 | 37 | block/bochs.c | 5 +- |
38 | block/cloop.c | 5 +- | ||
39 | block/dmg.c | 6 +- | ||
40 | block/rbd.c | 65 +++-- | ||
41 | block/trace-events | 17 ++ | ||
42 | block/vvfat.c | 19 +- | ||
43 | block/vxhs.c | 575 +++++++++++++++++++++++++++++++++++++++ | ||
44 | configure | 39 +++ | ||
45 | include/block/block.h | 2 + | ||
46 | qapi/block-core.json | 23 +- | ||
47 | tests/qemu-iotests/017 | 1 + | ||
48 | tests/qemu-iotests/020 | 1 + | ||
49 | tests/qemu-iotests/028 | 1 + | ||
50 | tests/qemu-iotests/029 | 1 + | ||
51 | tests/qemu-iotests/073 | 1 + | ||
52 | tests/qemu-iotests/094 | 11 +- | ||
53 | tests/qemu-iotests/102 | 5 +- | ||
54 | tests/qemu-iotests/109 | 1 + | ||
55 | tests/qemu-iotests/114 | 1 + | ||
56 | tests/qemu-iotests/117 | 1 + | ||
57 | tests/qemu-iotests/130 | 2 + | ||
58 | tests/qemu-iotests/134 | 1 + | ||
59 | tests/qemu-iotests/140 | 1 + | ||
60 | tests/qemu-iotests/141 | 1 + | ||
61 | tests/qemu-iotests/143 | 1 + | ||
62 | tests/qemu-iotests/156 | 2 + | ||
63 | tests/qemu-iotests/158 | 1 + | ||
64 | tests/qemu-iotests/common | 6 + | ||
65 | tests/qemu-iotests/common.config | 13 + | ||
66 | tests/qemu-iotests/common.filter | 1 + | ||
67 | tests/qemu-iotests/common.rc | 19 ++ | ||
68 | 33 files changed, 844 insertions(+), 42 deletions(-) | ||
69 | create mode 100644 block/vxhs.c | ||
31 | 70 | ||
32 | Jeff Cody (3): | 71 | -- |
33 | block: check full backing filename when searching protocol filenames | 72 | 2.9.3 |
34 | qemu-iotests: Don't create fifos / pidfiles with protocol paths | ||
35 | qemu-iotest: test to lookup protocol-based image with relative backing | ||
36 | 73 | ||
37 | Max Reitz (1): | ||
38 | qemu-img: Improve commit invalid base message | ||
39 | 74 | ||
40 | Nir Soffer (3): | ||
41 | qemu-io: Return non-zero exit code on failure | ||
42 | qemu-iotests: Add _unsupported_fmt helper | ||
43 | qemu-io: Add failure regression tests | ||
44 | |||
45 | Peter Lieven (2): | ||
46 | block/nfs: fix NULL pointer dereference in URI parsing | ||
47 | block/nfs: fix naming of runtime opts | ||
48 | |||
49 | Peter Maydell (2): | ||
50 | qemu-img: Use qemu_strtoul() rather than raw strtoul() | ||
51 | qemu-img: Avoid setting ret to unused value in img_convert() | ||
52 | |||
53 | QingFeng Hao (2): | ||
54 | iotests: Fix a problem in common.filter | ||
55 | block/vmdk: Fix the endian problem of buf_len and lba | ||
56 | |||
57 | Vladimir Sementsov-Ogievskiy (1): | ||
58 | block: bdrv_invalidate_cache: invalidate children first | ||
59 | |||
60 | tests/qemu-iotests/Makefile | 2 +- | ||
61 | block/qcow2.h | 1 + | ||
62 | block.c | 24 +++++++--- | ||
63 | block/nfs.c | 49 ++++++++++---------- | ||
64 | block/qapi.c | 99 +++++++++++++++++----------------------- | ||
65 | block/qcow2-refcount.c | 24 +++++++++- | ||
66 | block/qcow2.c | 1 + | ||
67 | block/vmdk.c | 4 +- | ||
68 | qemu-img.c | 44 +++++++++--------- | ||
69 | qemu-io-cmds.c | 20 +++++--- | ||
70 | qemu-io.c | 8 +++- | ||
71 | tests/qemu-iotests/.gitignore | 2 +- | ||
72 | tests/qemu-iotests/059.out | 5 +- | ||
73 | tests/qemu-iotests/070.out | 1 - | ||
74 | tests/qemu-iotests/075.out | 7 --- | ||
75 | tests/qemu-iotests/076.out | 3 -- | ||
76 | tests/qemu-iotests/078.out | 6 --- | ||
77 | tests/qemu-iotests/080.out | 18 -------- | ||
78 | tests/qemu-iotests/083.out | 17 ------- | ||
79 | tests/qemu-iotests/088.out | 6 --- | ||
80 | tests/qemu-iotests/092.out | 12 ----- | ||
81 | tests/qemu-iotests/116.out | 7 --- | ||
82 | tests/qemu-iotests/131.out | 1 - | ||
83 | tests/qemu-iotests/140.out | 1 - | ||
84 | tests/qemu-iotests/173 | 97 +++++++++++++++++++++++++++++++++++++++ | ||
85 | tests/qemu-iotests/173.out | 12 +++++ | ||
86 | tests/qemu-iotests/174 | 59 ++++++++++++++++++++++++ | ||
87 | tests/qemu-iotests/174.out | 7 +++ | ||
88 | tests/qemu-iotests/check | 12 +++-- | ||
89 | tests/qemu-iotests/common.config | 6 ++- | ||
90 | tests/qemu-iotests/common.filter | 2 +- | ||
91 | tests/qemu-iotests/common.qemu | 10 ++-- | ||
92 | tests/qemu-iotests/common.rc | 17 +++++-- | ||
93 | tests/qemu-iotests/group | 2 + | ||
94 | 34 files changed, 366 insertions(+), 220 deletions(-) | ||
95 | create mode 100755 tests/qemu-iotests/173 | ||
96 | create mode 100644 tests/qemu-iotests/173.out | ||
97 | create mode 100755 tests/qemu-iotests/174 | ||
98 | create mode 100644 tests/qemu-iotests/174.out | ||
99 | diff view generated by jsdifflib |
1 | From: Nir Soffer <nirsof@gmail.com> | 1 | From: Ashish Mittal <ashmit602@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Add regression tests checking that qemu-io fails with non-zero exit code | 3 | Source code for the qnio library that this code loads can be downloaded from: |
4 | when reading non-existing file or using the wrong image format. | 4 | https://github.com/VeritasHyperScale/libqnio.git |
5 | 5 | ||
6 | Signed-off-by: Nir Soffer <nirsof@gmail.com> | 6 | Sample command line using JSON syntax: |
7 | Message-id: 20170201003120.23378-4-nirsof@gmail.com | 7 | ./x86_64-softmmu/qemu-system-x86_64 -name instance-00000008 -S -vnc 0.0.0.0:0 |
8 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 8 | -k en-us -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 |
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 9 | -msg timestamp=on |
10 | 'json:{"driver":"vxhs","vdisk-id":"c3e9095a-a5ee-4dce-afeb-2a59fb387410", | ||
11 | "server":{"host":"172.172.17.4","port":"9999"}}' | ||
12 | |||
13 | Sample command line using URI syntax: | ||
14 | qemu-img convert -f raw -O raw -n | ||
15 | /var/lib/nova/instances/_base/0c5eacd5ebea5ed914b6a3e7b18f1ce734c386ad | ||
16 | vxhs://192.168.0.1:9999/c6718f6b-0401-441d-a8c3-1f0064d75ee0 | ||
17 | |||
18 | Sample command line using TLS credentials (run in secure mode): | ||
19 | ./qemu-io --object | ||
20 | tls-creds-x509,id=tls0,dir=/etc/pki/qemu/vxhs,endpoint=client -c 'read | ||
21 | -v 66000 2.5k' 'json:{"server.host": "127.0.0.1", "server.port": "9999", | ||
22 | "vdisk-id": "/test.raw", "driver": "vxhs", "tls-creds":"tls0"}' | ||
23 | |||
24 | Signed-off-by: Ashish Mittal <Ashish.Mittal@veritas.com> | ||
25 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
26 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
27 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
28 | Message-id: 1491277689-24949-2-git-send-email-Ashish.Mittal@veritas.com | ||
10 | --- | 29 | --- |
11 | tests/qemu-iotests/174 | 59 ++++++++++++++++++++++++++++++++++++++++++++++ | 30 | block/Makefile.objs | 2 + |
12 | tests/qemu-iotests/174.out | 7 ++++++ | 31 | block/trace-events | 17 ++ |
13 | tests/qemu-iotests/group | 1 + | 32 | block/vxhs.c | 575 +++++++++++++++++++++++++++++++++++++++++++++++++++ |
14 | 3 files changed, 67 insertions(+) | 33 | configure | 39 ++++ |
15 | create mode 100755 tests/qemu-iotests/174 | 34 | qapi/block-core.json | 23 ++- |
16 | create mode 100644 tests/qemu-iotests/174.out | 35 | 5 files changed, 654 insertions(+), 2 deletions(-) |
36 | create mode 100644 block/vxhs.c | ||
17 | 37 | ||
18 | diff --git a/tests/qemu-iotests/174 b/tests/qemu-iotests/174 | 38 | diff --git a/block/Makefile.objs b/block/Makefile.objs |
19 | new file mode 100755 | 39 | index XXXXXXX..XXXXXXX 100644 |
20 | index XXXXXXX..XXXXXXX | 40 | --- a/block/Makefile.objs |
21 | --- /dev/null | 41 | +++ b/block/Makefile.objs |
22 | +++ b/tests/qemu-iotests/174 | 42 | @@ -XXX,XX +XXX,XX @@ block-obj-$(CONFIG_LIBNFS) += nfs.o |
23 | @@ -XXX,XX +XXX,XX @@ | 43 | block-obj-$(CONFIG_CURL) += curl.o |
24 | +#!/bin/bash | 44 | block-obj-$(CONFIG_RBD) += rbd.o |
25 | +# | 45 | block-obj-$(CONFIG_GLUSTERFS) += gluster.o |
26 | +# Test that qemu-io fail with non-zero exit code | 46 | +block-obj-$(CONFIG_VXHS) += vxhs.o |
27 | +# | 47 | block-obj-$(CONFIG_LIBSSH2) += ssh.o |
28 | +# Copyright (C) 2017 Nir Soffer <nirsof@gmail.com> | 48 | block-obj-y += accounting.o dirty-bitmap.o |
29 | +# | 49 | block-obj-y += write-threshold.o |
30 | +# This program is free software; you can redistribute it and/or modify | 50 | @@ -XXX,XX +XXX,XX @@ rbd.o-cflags := $(RBD_CFLAGS) |
31 | +# it under the terms of the GNU General Public License as published by | 51 | rbd.o-libs := $(RBD_LIBS) |
32 | +# the Free Software Foundation; either version 2 of the License, or | 52 | gluster.o-cflags := $(GLUSTERFS_CFLAGS) |
33 | +# (at your option) any later version. | 53 | gluster.o-libs := $(GLUSTERFS_LIBS) |
34 | +# | 54 | +vxhs.o-libs := $(VXHS_LIBS) |
35 | +# This program is distributed in the hope that it will be useful, | 55 | ssh.o-cflags := $(LIBSSH2_CFLAGS) |
36 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | 56 | ssh.o-libs := $(LIBSSH2_LIBS) |
37 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 57 | block-obj-$(if $(CONFIG_BZIP2),m,n) += dmg-bz2.o |
38 | +# GNU General Public License for more details. | 58 | diff --git a/block/trace-events b/block/trace-events |
39 | +# | 59 | index XXXXXXX..XXXXXXX 100644 |
40 | +# You should have received a copy of the GNU General Public License | 60 | --- a/block/trace-events |
41 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | 61 | +++ b/block/trace-events |
42 | +# | 62 | @@ -XXX,XX +XXX,XX @@ qed_aio_write_data(void *s, void *acb, int ret, uint64_t offset, size_t len) "s |
43 | + | 63 | qed_aio_write_prefill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64 |
44 | +# creator | 64 | qed_aio_write_postfill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64 |
45 | +owner=nirsof@gmail.com | 65 | qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu" |
46 | + | 66 | + |
47 | +seq=`basename $0` | 67 | +# block/vxhs.c |
48 | +echo "QA output created by $seq" | 68 | +vxhs_iio_callback(int error) "ctx is NULL: error %d" |
49 | + | 69 | +vxhs_iio_callback_chnfail(int err, int error) "QNIO channel failed, no i/o %d, %d" |
50 | +here=`pwd` | 70 | +vxhs_iio_callback_unknwn(int opcode, int err) "unexpected opcode %d, errno %d" |
51 | +status=1 # failure is the default! | 71 | +vxhs_aio_rw_invalid(int req) "Invalid I/O request iodir %d" |
52 | + | 72 | +vxhs_aio_rw_ioerr(char *guid, int iodir, uint64_t size, uint64_t off, void *acb, int ret, int err) "IO ERROR (vDisk %s) FOR : Read/Write = %d size = %lu offset = %lu ACB = %p. Error = %d, errno = %d" |
53 | +_cleanup() | 73 | +vxhs_get_vdisk_stat_err(char *guid, int ret, int err) "vDisk (%s) stat ioctl failed, ret = %d, errno = %d" |
54 | +{ | 74 | +vxhs_get_vdisk_stat(char *vdisk_guid, uint64_t vdisk_size) "vDisk %s stat ioctl returned size %lu" |
55 | + _cleanup_test_img | 75 | +vxhs_complete_aio(void *acb, uint64_t ret) "aio failed acb %p ret %ld" |
56 | +} | 76 | +vxhs_parse_uri_filename(const char *filename) "URI passed via bdrv_parse_filename %s" |
57 | +trap "_cleanup; exit \$status" 0 1 2 3 15 | 77 | +vxhs_open_vdiskid(const char *vdisk_id) "Opening vdisk-id %s" |
58 | + | 78 | +vxhs_open_hostinfo(char *of_vsa_addr, int port) "Adding host %s:%d to BDRVVXHSState" |
59 | +# get standard environment, filters and checks | 79 | +vxhs_open_iio_open(const char *host) "Failed to connect to storage agent on host %s" |
60 | +. ./common.rc | 80 | +vxhs_parse_uri_hostinfo(char *host, int port) "Host: IP %s, Port %d" |
61 | +. ./common.filter | 81 | +vxhs_close(char *vdisk_guid) "Closing vdisk %s" |
62 | + | 82 | +vxhs_get_creds(const char *cacert, const char *client_key, const char *client_cert) "cacert %s, client_key %s, client_cert %s" |
63 | +_unsupported_fmt raw | 83 | diff --git a/block/vxhs.c b/block/vxhs.c |
64 | + | ||
65 | + | ||
66 | +size=256K | ||
67 | +IMGFMT=raw IMGOPTS= _make_test_img $size | _filter_imgfmt | ||
68 | + | ||
69 | +echo | ||
70 | +echo "== reading wrong format should fail ==" | ||
71 | +$QEMU_IO -f $IMGFMT -c "read 0 $size" "$TEST_IMG" 2>/dev/null | ||
72 | +test $? -eq 1 || _fail "did not fail" | ||
73 | + | ||
74 | +echo | ||
75 | +echo "== reading missing file should fail ==" | ||
76 | +$QEMU_IO -c "read 0 $size" "$TEST_DIR/missing" 2>/dev/null | ||
77 | +test $? -eq 1 || _fail "did not fail" | ||
78 | + | ||
79 | +# success, all done | ||
80 | +echo "*** done" | ||
81 | +rm -f $seq.full | ||
82 | +status=0 | ||
83 | diff --git a/tests/qemu-iotests/174.out b/tests/qemu-iotests/174.out | ||
84 | new file mode 100644 | 84 | new file mode 100644 |
85 | index XXXXXXX..XXXXXXX | 85 | index XXXXXXX..XXXXXXX |
86 | --- /dev/null | 86 | --- /dev/null |
87 | +++ b/tests/qemu-iotests/174.out | 87 | +++ b/block/vxhs.c |
88 | @@ -XXX,XX +XXX,XX @@ | 88 | @@ -XXX,XX +XXX,XX @@ |
89 | +QA output created by 174 | 89 | +/* |
90 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=262144 | 90 | + * QEMU Block driver for Veritas HyperScale (VxHS) |
91 | + | 91 | + * |
92 | +== reading wrong format should fail == | 92 | + * Copyright (c) 2017 Veritas Technologies LLC. |
93 | + | 93 | + * |
94 | +== reading missing file should fail == | 94 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
95 | +*** done | 95 | + * See the COPYING file in the top-level directory. |
96 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | 96 | + * |
97 | + */ | ||
98 | + | ||
99 | +#include "qemu/osdep.h" | ||
100 | +#include <qnio/qnio_api.h> | ||
101 | +#include <sys/param.h> | ||
102 | +#include "block/block_int.h" | ||
103 | +#include "qapi/qmp/qerror.h" | ||
104 | +#include "qapi/qmp/qdict.h" | ||
105 | +#include "qapi/qmp/qstring.h" | ||
106 | +#include "trace.h" | ||
107 | +#include "qemu/uri.h" | ||
108 | +#include "qapi/error.h" | ||
109 | +#include "qemu/uuid.h" | ||
110 | +#include "crypto/tlscredsx509.h" | ||
111 | + | ||
112 | +#define VXHS_OPT_FILENAME "filename" | ||
113 | +#define VXHS_OPT_VDISK_ID "vdisk-id" | ||
114 | +#define VXHS_OPT_SERVER "server" | ||
115 | +#define VXHS_OPT_HOST "host" | ||
116 | +#define VXHS_OPT_PORT "port" | ||
117 | + | ||
118 | +/* Only accessed under QEMU global mutex */ | ||
119 | +static uint32_t vxhs_ref; | ||
120 | + | ||
121 | +typedef enum { | ||
122 | + VDISK_AIO_READ, | ||
123 | + VDISK_AIO_WRITE, | ||
124 | +} VDISKAIOCmd; | ||
125 | + | ||
126 | +/* | ||
127 | + * HyperScale AIO callbacks structure | ||
128 | + */ | ||
129 | +typedef struct VXHSAIOCB { | ||
130 | + BlockAIOCB common; | ||
131 | + int err; | ||
132 | +} VXHSAIOCB; | ||
133 | + | ||
134 | +typedef struct VXHSvDiskHostsInfo { | ||
135 | + void *dev_handle; /* Device handle */ | ||
136 | + char *host; /* Host name or IP */ | ||
137 | + int port; /* Host's port number */ | ||
138 | +} VXHSvDiskHostsInfo; | ||
139 | + | ||
140 | +/* | ||
141 | + * Structure per vDisk maintained for state | ||
142 | + */ | ||
143 | +typedef struct BDRVVXHSState { | ||
144 | + VXHSvDiskHostsInfo vdisk_hostinfo; /* Per host info */ | ||
145 | + char *vdisk_guid; | ||
146 | + char *tlscredsid; /* tlscredsid */ | ||
147 | +} BDRVVXHSState; | ||
148 | + | ||
149 | +static void vxhs_complete_aio_bh(void *opaque) | ||
150 | +{ | ||
151 | + VXHSAIOCB *acb = opaque; | ||
152 | + BlockCompletionFunc *cb = acb->common.cb; | ||
153 | + void *cb_opaque = acb->common.opaque; | ||
154 | + int ret = 0; | ||
155 | + | ||
156 | + if (acb->err != 0) { | ||
157 | + trace_vxhs_complete_aio(acb, acb->err); | ||
158 | + ret = (-EIO); | ||
159 | + } | ||
160 | + | ||
161 | + qemu_aio_unref(acb); | ||
162 | + cb(cb_opaque, ret); | ||
163 | +} | ||
164 | + | ||
165 | +/* | ||
166 | + * Called from a libqnio thread | ||
167 | + */ | ||
168 | +static void vxhs_iio_callback(void *ctx, uint32_t opcode, uint32_t error) | ||
169 | +{ | ||
170 | + VXHSAIOCB *acb = NULL; | ||
171 | + | ||
172 | + switch (opcode) { | ||
173 | + case IRP_READ_REQUEST: | ||
174 | + case IRP_WRITE_REQUEST: | ||
175 | + | ||
176 | + /* | ||
177 | + * ctx is VXHSAIOCB* | ||
178 | + * ctx is NULL if error is QNIOERROR_CHANNEL_HUP | ||
179 | + */ | ||
180 | + if (ctx) { | ||
181 | + acb = ctx; | ||
182 | + } else { | ||
183 | + trace_vxhs_iio_callback(error); | ||
184 | + goto out; | ||
185 | + } | ||
186 | + | ||
187 | + if (error) { | ||
188 | + if (!acb->err) { | ||
189 | + acb->err = error; | ||
190 | + } | ||
191 | + trace_vxhs_iio_callback(error); | ||
192 | + } | ||
193 | + | ||
194 | + aio_bh_schedule_oneshot(bdrv_get_aio_context(acb->common.bs), | ||
195 | + vxhs_complete_aio_bh, acb); | ||
196 | + break; | ||
197 | + | ||
198 | + default: | ||
199 | + if (error == QNIOERROR_HUP) { | ||
200 | + /* | ||
201 | + * Channel failed, spontaneous notification, | ||
202 | + * not in response to I/O | ||
203 | + */ | ||
204 | + trace_vxhs_iio_callback_chnfail(error, errno); | ||
205 | + } else { | ||
206 | + trace_vxhs_iio_callback_unknwn(opcode, error); | ||
207 | + } | ||
208 | + break; | ||
209 | + } | ||
210 | +out: | ||
211 | + return; | ||
212 | +} | ||
213 | + | ||
214 | +static QemuOptsList runtime_opts = { | ||
215 | + .name = "vxhs", | ||
216 | + .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), | ||
217 | + .desc = { | ||
218 | + { | ||
219 | + .name = VXHS_OPT_FILENAME, | ||
220 | + .type = QEMU_OPT_STRING, | ||
221 | + .help = "URI to the Veritas HyperScale image", | ||
222 | + }, | ||
223 | + { | ||
224 | + .name = VXHS_OPT_VDISK_ID, | ||
225 | + .type = QEMU_OPT_STRING, | ||
226 | + .help = "UUID of the VxHS vdisk", | ||
227 | + }, | ||
228 | + { | ||
229 | + .name = "tls-creds", | ||
230 | + .type = QEMU_OPT_STRING, | ||
231 | + .help = "ID of the TLS/SSL credentials to use", | ||
232 | + }, | ||
233 | + { /* end of list */ } | ||
234 | + }, | ||
235 | +}; | ||
236 | + | ||
237 | +static QemuOptsList runtime_tcp_opts = { | ||
238 | + .name = "vxhs_tcp", | ||
239 | + .head = QTAILQ_HEAD_INITIALIZER(runtime_tcp_opts.head), | ||
240 | + .desc = { | ||
241 | + { | ||
242 | + .name = VXHS_OPT_HOST, | ||
243 | + .type = QEMU_OPT_STRING, | ||
244 | + .help = "host address (ipv4 addresses)", | ||
245 | + }, | ||
246 | + { | ||
247 | + .name = VXHS_OPT_PORT, | ||
248 | + .type = QEMU_OPT_NUMBER, | ||
249 | + .help = "port number on which VxHSD is listening (default 9999)", | ||
250 | + .def_value_str = "9999" | ||
251 | + }, | ||
252 | + { /* end of list */ } | ||
253 | + }, | ||
254 | +}; | ||
255 | + | ||
256 | +/* | ||
257 | + * Parse incoming URI and populate *options with the host | ||
258 | + * and device information | ||
259 | + */ | ||
260 | +static int vxhs_parse_uri(const char *filename, QDict *options) | ||
261 | +{ | ||
262 | + URI *uri = NULL; | ||
263 | + char *port; | ||
264 | + int ret = 0; | ||
265 | + | ||
266 | + trace_vxhs_parse_uri_filename(filename); | ||
267 | + uri = uri_parse(filename); | ||
268 | + if (!uri || !uri->server || !uri->path) { | ||
269 | + uri_free(uri); | ||
270 | + return -EINVAL; | ||
271 | + } | ||
272 | + | ||
273 | + qdict_put(options, VXHS_OPT_SERVER".host", qstring_from_str(uri->server)); | ||
274 | + | ||
275 | + if (uri->port) { | ||
276 | + port = g_strdup_printf("%d", uri->port); | ||
277 | + qdict_put(options, VXHS_OPT_SERVER".port", qstring_from_str(port)); | ||
278 | + g_free(port); | ||
279 | + } | ||
280 | + | ||
281 | + qdict_put(options, "vdisk-id", qstring_from_str(uri->path)); | ||
282 | + | ||
283 | + trace_vxhs_parse_uri_hostinfo(uri->server, uri->port); | ||
284 | + uri_free(uri); | ||
285 | + | ||
286 | + return ret; | ||
287 | +} | ||
288 | + | ||
289 | +static void vxhs_parse_filename(const char *filename, QDict *options, | ||
290 | + Error **errp) | ||
291 | +{ | ||
292 | + if (qdict_haskey(options, "vdisk-id") || qdict_haskey(options, "server")) { | ||
293 | + error_setg(errp, "vdisk-id/server and a file name may not be specified " | ||
294 | + "at the same time"); | ||
295 | + return; | ||
296 | + } | ||
297 | + | ||
298 | + if (strstr(filename, "://")) { | ||
299 | + int ret = vxhs_parse_uri(filename, options); | ||
300 | + if (ret < 0) { | ||
301 | + error_setg(errp, "Invalid URI. URI should be of the form " | ||
302 | + " vxhs://<host_ip>:<port>/<vdisk-id>"); | ||
303 | + } | ||
304 | + } | ||
305 | +} | ||
306 | + | ||
307 | +static int vxhs_init_and_ref(void) | ||
308 | +{ | ||
309 | + if (vxhs_ref++ == 0) { | ||
310 | + if (iio_init(QNIO_VERSION, vxhs_iio_callback)) { | ||
311 | + return -ENODEV; | ||
312 | + } | ||
313 | + } | ||
314 | + return 0; | ||
315 | +} | ||
316 | + | ||
317 | +static void vxhs_unref(void) | ||
318 | +{ | ||
319 | + if (--vxhs_ref == 0) { | ||
320 | + iio_fini(); | ||
321 | + } | ||
322 | +} | ||
323 | + | ||
324 | +static void vxhs_get_tls_creds(const char *id, char **cacert, | ||
325 | + char **key, char **cert, Error **errp) | ||
326 | +{ | ||
327 | + Object *obj; | ||
328 | + QCryptoTLSCreds *creds; | ||
329 | + QCryptoTLSCredsX509 *creds_x509; | ||
330 | + | ||
331 | + obj = object_resolve_path_component( | ||
332 | + object_get_objects_root(), id); | ||
333 | + | ||
334 | + if (!obj) { | ||
335 | + error_setg(errp, "No TLS credentials with id '%s'", | ||
336 | + id); | ||
337 | + return; | ||
338 | + } | ||
339 | + | ||
340 | + creds_x509 = (QCryptoTLSCredsX509 *) | ||
341 | + object_dynamic_cast(obj, TYPE_QCRYPTO_TLS_CREDS_X509); | ||
342 | + | ||
343 | + if (!creds_x509) { | ||
344 | + error_setg(errp, "Object with id '%s' is not TLS credentials", | ||
345 | + id); | ||
346 | + return; | ||
347 | + } | ||
348 | + | ||
349 | + creds = &creds_x509->parent_obj; | ||
350 | + | ||
351 | + if (creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) { | ||
352 | + error_setg(errp, | ||
353 | + "Expecting TLS credentials with a client endpoint"); | ||
354 | + return; | ||
355 | + } | ||
356 | + | ||
357 | + /* | ||
358 | + * Get the cacert, client_cert and client_key file names. | ||
359 | + */ | ||
360 | + if (!creds->dir) { | ||
361 | + error_setg(errp, "TLS object missing 'dir' property value"); | ||
362 | + return; | ||
363 | + } | ||
364 | + | ||
365 | + *cacert = g_strdup_printf("%s/%s", creds->dir, | ||
366 | + QCRYPTO_TLS_CREDS_X509_CA_CERT); | ||
367 | + *cert = g_strdup_printf("%s/%s", creds->dir, | ||
368 | + QCRYPTO_TLS_CREDS_X509_CLIENT_CERT); | ||
369 | + *key = g_strdup_printf("%s/%s", creds->dir, | ||
370 | + QCRYPTO_TLS_CREDS_X509_CLIENT_KEY); | ||
371 | +} | ||
372 | + | ||
373 | +static int vxhs_open(BlockDriverState *bs, QDict *options, | ||
374 | + int bdrv_flags, Error **errp) | ||
375 | +{ | ||
376 | + BDRVVXHSState *s = bs->opaque; | ||
377 | + void *dev_handlep; | ||
378 | + QDict *backing_options = NULL; | ||
379 | + QemuOpts *opts = NULL; | ||
380 | + QemuOpts *tcp_opts = NULL; | ||
381 | + char *of_vsa_addr = NULL; | ||
382 | + Error *local_err = NULL; | ||
383 | + const char *vdisk_id_opt; | ||
384 | + const char *server_host_opt; | ||
385 | + int ret = 0; | ||
386 | + char *cacert = NULL; | ||
387 | + char *client_key = NULL; | ||
388 | + char *client_cert = NULL; | ||
389 | + | ||
390 | + ret = vxhs_init_and_ref(); | ||
391 | + if (ret < 0) { | ||
392 | + ret = -EINVAL; | ||
393 | + goto out; | ||
394 | + } | ||
395 | + | ||
396 | + /* Create opts info from runtime_opts and runtime_tcp_opts list */ | ||
397 | + opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); | ||
398 | + tcp_opts = qemu_opts_create(&runtime_tcp_opts, NULL, 0, &error_abort); | ||
399 | + | ||
400 | + qemu_opts_absorb_qdict(opts, options, &local_err); | ||
401 | + if (local_err) { | ||
402 | + ret = -EINVAL; | ||
403 | + goto out; | ||
404 | + } | ||
405 | + | ||
406 | + /* vdisk-id is the disk UUID */ | ||
407 | + vdisk_id_opt = qemu_opt_get(opts, VXHS_OPT_VDISK_ID); | ||
408 | + if (!vdisk_id_opt) { | ||
409 | + error_setg(&local_err, QERR_MISSING_PARAMETER, VXHS_OPT_VDISK_ID); | ||
410 | + ret = -EINVAL; | ||
411 | + goto out; | ||
412 | + } | ||
413 | + | ||
414 | + /* vdisk-id may contain a leading '/' */ | ||
415 | + if (strlen(vdisk_id_opt) > UUID_FMT_LEN + 1) { | ||
416 | + error_setg(&local_err, "vdisk-id cannot be more than %d characters", | ||
417 | + UUID_FMT_LEN); | ||
418 | + ret = -EINVAL; | ||
419 | + goto out; | ||
420 | + } | ||
421 | + | ||
422 | + s->vdisk_guid = g_strdup(vdisk_id_opt); | ||
423 | + trace_vxhs_open_vdiskid(vdisk_id_opt); | ||
424 | + | ||
425 | + /* get the 'server.' arguments */ | ||
426 | + qdict_extract_subqdict(options, &backing_options, VXHS_OPT_SERVER"."); | ||
427 | + | ||
428 | + qemu_opts_absorb_qdict(tcp_opts, backing_options, &local_err); | ||
429 | + if (local_err != NULL) { | ||
430 | + ret = -EINVAL; | ||
431 | + goto out; | ||
432 | + } | ||
433 | + | ||
434 | + server_host_opt = qemu_opt_get(tcp_opts, VXHS_OPT_HOST); | ||
435 | + if (!server_host_opt) { | ||
436 | + error_setg(&local_err, QERR_MISSING_PARAMETER, | ||
437 | + VXHS_OPT_SERVER"."VXHS_OPT_HOST); | ||
438 | + ret = -EINVAL; | ||
439 | + goto out; | ||
440 | + } | ||
441 | + | ||
442 | + if (strlen(server_host_opt) > MAXHOSTNAMELEN) { | ||
443 | + error_setg(&local_err, "server.host cannot be more than %d characters", | ||
444 | + MAXHOSTNAMELEN); | ||
445 | + ret = -EINVAL; | ||
446 | + goto out; | ||
447 | + } | ||
448 | + | ||
449 | + /* check if we got tls-creds via the --object argument */ | ||
450 | + s->tlscredsid = g_strdup(qemu_opt_get(opts, "tls-creds")); | ||
451 | + if (s->tlscredsid) { | ||
452 | + vxhs_get_tls_creds(s->tlscredsid, &cacert, &client_key, | ||
453 | + &client_cert, &local_err); | ||
454 | + if (local_err != NULL) { | ||
455 | + ret = -EINVAL; | ||
456 | + goto out; | ||
457 | + } | ||
458 | + trace_vxhs_get_creds(cacert, client_key, client_cert); | ||
459 | + } | ||
460 | + | ||
461 | + s->vdisk_hostinfo.host = g_strdup(server_host_opt); | ||
462 | + s->vdisk_hostinfo.port = g_ascii_strtoll(qemu_opt_get(tcp_opts, | ||
463 | + VXHS_OPT_PORT), | ||
464 | + NULL, 0); | ||
465 | + | ||
466 | + trace_vxhs_open_hostinfo(s->vdisk_hostinfo.host, | ||
467 | + s->vdisk_hostinfo.port); | ||
468 | + | ||
469 | + of_vsa_addr = g_strdup_printf("of://%s:%d", | ||
470 | + s->vdisk_hostinfo.host, | ||
471 | + s->vdisk_hostinfo.port); | ||
472 | + | ||
473 | + /* | ||
474 | + * Open qnio channel to storage agent if not opened before | ||
475 | + */ | ||
476 | + dev_handlep = iio_open(of_vsa_addr, s->vdisk_guid, 0, | ||
477 | + cacert, client_key, client_cert); | ||
478 | + if (dev_handlep == NULL) { | ||
479 | + trace_vxhs_open_iio_open(of_vsa_addr); | ||
480 | + ret = -ENODEV; | ||
481 | + goto out; | ||
482 | + } | ||
483 | + s->vdisk_hostinfo.dev_handle = dev_handlep; | ||
484 | + | ||
485 | +out: | ||
486 | + g_free(of_vsa_addr); | ||
487 | + QDECREF(backing_options); | ||
488 | + qemu_opts_del(tcp_opts); | ||
489 | + qemu_opts_del(opts); | ||
490 | + g_free(cacert); | ||
491 | + g_free(client_key); | ||
492 | + g_free(client_cert); | ||
493 | + | ||
494 | + if (ret < 0) { | ||
495 | + vxhs_unref(); | ||
496 | + error_propagate(errp, local_err); | ||
497 | + g_free(s->vdisk_hostinfo.host); | ||
498 | + g_free(s->vdisk_guid); | ||
499 | + g_free(s->tlscredsid); | ||
500 | + s->vdisk_guid = NULL; | ||
501 | + } | ||
502 | + | ||
503 | + return ret; | ||
504 | +} | ||
505 | + | ||
506 | +static const AIOCBInfo vxhs_aiocb_info = { | ||
507 | + .aiocb_size = sizeof(VXHSAIOCB) | ||
508 | +}; | ||
509 | + | ||
510 | +/* | ||
511 | + * This allocates QEMU-VXHS callback for each IO | ||
512 | + * and is passed to QNIO. When QNIO completes the work, | ||
513 | + * it will be passed back through the callback. | ||
514 | + */ | ||
515 | +static BlockAIOCB *vxhs_aio_rw(BlockDriverState *bs, int64_t sector_num, | ||
516 | + QEMUIOVector *qiov, int nb_sectors, | ||
517 | + BlockCompletionFunc *cb, void *opaque, | ||
518 | + VDISKAIOCmd iodir) | ||
519 | +{ | ||
520 | + VXHSAIOCB *acb = NULL; | ||
521 | + BDRVVXHSState *s = bs->opaque; | ||
522 | + size_t size; | ||
523 | + uint64_t offset; | ||
524 | + int iio_flags = 0; | ||
525 | + int ret = 0; | ||
526 | + void *dev_handle = s->vdisk_hostinfo.dev_handle; | ||
527 | + | ||
528 | + offset = sector_num * BDRV_SECTOR_SIZE; | ||
529 | + size = nb_sectors * BDRV_SECTOR_SIZE; | ||
530 | + acb = qemu_aio_get(&vxhs_aiocb_info, bs, cb, opaque); | ||
531 | + | ||
532 | + /* | ||
533 | + * Initialize VXHSAIOCB. | ||
534 | + */ | ||
535 | + acb->err = 0; | ||
536 | + | ||
537 | + iio_flags = IIO_FLAG_ASYNC; | ||
538 | + | ||
539 | + switch (iodir) { | ||
540 | + case VDISK_AIO_WRITE: | ||
541 | + ret = iio_writev(dev_handle, acb, qiov->iov, qiov->niov, | ||
542 | + offset, (uint64_t)size, iio_flags); | ||
543 | + break; | ||
544 | + case VDISK_AIO_READ: | ||
545 | + ret = iio_readv(dev_handle, acb, qiov->iov, qiov->niov, | ||
546 | + offset, (uint64_t)size, iio_flags); | ||
547 | + break; | ||
548 | + default: | ||
549 | + trace_vxhs_aio_rw_invalid(iodir); | ||
550 | + goto errout; | ||
551 | + } | ||
552 | + | ||
553 | + if (ret != 0) { | ||
554 | + trace_vxhs_aio_rw_ioerr(s->vdisk_guid, iodir, size, offset, | ||
555 | + acb, ret, errno); | ||
556 | + goto errout; | ||
557 | + } | ||
558 | + return &acb->common; | ||
559 | + | ||
560 | +errout: | ||
561 | + qemu_aio_unref(acb); | ||
562 | + return NULL; | ||
563 | +} | ||
564 | + | ||
565 | +static BlockAIOCB *vxhs_aio_readv(BlockDriverState *bs, | ||
566 | + int64_t sector_num, QEMUIOVector *qiov, | ||
567 | + int nb_sectors, | ||
568 | + BlockCompletionFunc *cb, void *opaque) | ||
569 | +{ | ||
570 | + return vxhs_aio_rw(bs, sector_num, qiov, nb_sectors, cb, | ||
571 | + opaque, VDISK_AIO_READ); | ||
572 | +} | ||
573 | + | ||
574 | +static BlockAIOCB *vxhs_aio_writev(BlockDriverState *bs, | ||
575 | + int64_t sector_num, QEMUIOVector *qiov, | ||
576 | + int nb_sectors, | ||
577 | + BlockCompletionFunc *cb, void *opaque) | ||
578 | +{ | ||
579 | + return vxhs_aio_rw(bs, sector_num, qiov, nb_sectors, | ||
580 | + cb, opaque, VDISK_AIO_WRITE); | ||
581 | +} | ||
582 | + | ||
583 | +static void vxhs_close(BlockDriverState *bs) | ||
584 | +{ | ||
585 | + BDRVVXHSState *s = bs->opaque; | ||
586 | + | ||
587 | + trace_vxhs_close(s->vdisk_guid); | ||
588 | + | ||
589 | + g_free(s->vdisk_guid); | ||
590 | + s->vdisk_guid = NULL; | ||
591 | + | ||
592 | + /* | ||
593 | + * Close vDisk device | ||
594 | + */ | ||
595 | + if (s->vdisk_hostinfo.dev_handle) { | ||
596 | + iio_close(s->vdisk_hostinfo.dev_handle); | ||
597 | + s->vdisk_hostinfo.dev_handle = NULL; | ||
598 | + } | ||
599 | + | ||
600 | + vxhs_unref(); | ||
601 | + | ||
602 | + /* | ||
603 | + * Free the dynamically allocated host string etc | ||
604 | + */ | ||
605 | + g_free(s->vdisk_hostinfo.host); | ||
606 | + g_free(s->tlscredsid); | ||
607 | + s->tlscredsid = NULL; | ||
608 | + s->vdisk_hostinfo.host = NULL; | ||
609 | + s->vdisk_hostinfo.port = 0; | ||
610 | +} | ||
611 | + | ||
612 | +static int64_t vxhs_get_vdisk_stat(BDRVVXHSState *s) | ||
613 | +{ | ||
614 | + int64_t vdisk_size = -1; | ||
615 | + int ret = 0; | ||
616 | + void *dev_handle = s->vdisk_hostinfo.dev_handle; | ||
617 | + | ||
618 | + ret = iio_ioctl(dev_handle, IOR_VDISK_STAT, &vdisk_size, 0); | ||
619 | + if (ret < 0) { | ||
620 | + trace_vxhs_get_vdisk_stat_err(s->vdisk_guid, ret, errno); | ||
621 | + return -EIO; | ||
622 | + } | ||
623 | + | ||
624 | + trace_vxhs_get_vdisk_stat(s->vdisk_guid, vdisk_size); | ||
625 | + return vdisk_size; | ||
626 | +} | ||
627 | + | ||
628 | +/* | ||
629 | + * Returns the size of vDisk in bytes. This is required | ||
630 | + * by QEMU block upper block layer so that it is visible | ||
631 | + * to guest. | ||
632 | + */ | ||
633 | +static int64_t vxhs_getlength(BlockDriverState *bs) | ||
634 | +{ | ||
635 | + BDRVVXHSState *s = bs->opaque; | ||
636 | + int64_t vdisk_size; | ||
637 | + | ||
638 | + vdisk_size = vxhs_get_vdisk_stat(s); | ||
639 | + if (vdisk_size < 0) { | ||
640 | + return -EIO; | ||
641 | + } | ||
642 | + | ||
643 | + return vdisk_size; | ||
644 | +} | ||
645 | + | ||
646 | +static BlockDriver bdrv_vxhs = { | ||
647 | + .format_name = "vxhs", | ||
648 | + .protocol_name = "vxhs", | ||
649 | + .instance_size = sizeof(BDRVVXHSState), | ||
650 | + .bdrv_file_open = vxhs_open, | ||
651 | + .bdrv_parse_filename = vxhs_parse_filename, | ||
652 | + .bdrv_close = vxhs_close, | ||
653 | + .bdrv_getlength = vxhs_getlength, | ||
654 | + .bdrv_aio_readv = vxhs_aio_readv, | ||
655 | + .bdrv_aio_writev = vxhs_aio_writev, | ||
656 | +}; | ||
657 | + | ||
658 | +static void bdrv_vxhs_init(void) | ||
659 | +{ | ||
660 | + bdrv_register(&bdrv_vxhs); | ||
661 | +} | ||
662 | + | ||
663 | +block_init(bdrv_vxhs_init); | ||
664 | diff --git a/configure b/configure | ||
665 | index XXXXXXX..XXXXXXX 100755 | ||
666 | --- a/configure | ||
667 | +++ b/configure | ||
668 | @@ -XXX,XX +XXX,XX @@ numa="" | ||
669 | tcmalloc="no" | ||
670 | jemalloc="no" | ||
671 | replication="yes" | ||
672 | +vxhs="" | ||
673 | |||
674 | supported_cpu="no" | ||
675 | supported_os="no" | ||
676 | @@ -XXX,XX +XXX,XX @@ for opt do | ||
677 | ;; | ||
678 | --enable-replication) replication="yes" | ||
679 | ;; | ||
680 | + --disable-vxhs) vxhs="no" | ||
681 | + ;; | ||
682 | + --enable-vxhs) vxhs="yes" | ||
683 | + ;; | ||
684 | *) | ||
685 | echo "ERROR: unknown option $opt" | ||
686 | echo "Try '$0 --help' for more information" | ||
687 | @@ -XXX,XX +XXX,XX @@ disabled with --disable-FEATURE, default is enabled if available: | ||
688 | xfsctl xfsctl support | ||
689 | qom-cast-debug cast debugging support | ||
690 | tools build qemu-io, qemu-nbd and qemu-image tools | ||
691 | + vxhs Veritas HyperScale vDisk backend support | ||
692 | |||
693 | NOTE: The object files are built at the place where configure is launched | ||
694 | EOF | ||
695 | @@ -XXX,XX +XXX,XX @@ if compile_prog "" "" ; then | ||
696 | fi | ||
697 | |||
698 | ########################################## | ||
699 | +# Veritas HyperScale block driver VxHS | ||
700 | +# Check if libvxhs is installed | ||
701 | + | ||
702 | +if test "$vxhs" != "no" ; then | ||
703 | + cat > $TMPC <<EOF | ||
704 | +#include <stdint.h> | ||
705 | +#include <qnio/qnio_api.h> | ||
706 | + | ||
707 | +void *vxhs_callback; | ||
708 | + | ||
709 | +int main(void) { | ||
710 | + iio_init(QNIO_VERSION, vxhs_callback); | ||
711 | + return 0; | ||
712 | +} | ||
713 | +EOF | ||
714 | + vxhs_libs="-lvxhs -lssl" | ||
715 | + if compile_prog "" "$vxhs_libs" ; then | ||
716 | + vxhs=yes | ||
717 | + else | ||
718 | + if test "$vxhs" = "yes" ; then | ||
719 | + feature_not_found "vxhs block device" "Install libvxhs See github" | ||
720 | + fi | ||
721 | + vxhs=no | ||
722 | + fi | ||
723 | +fi | ||
724 | + | ||
725 | +########################################## | ||
726 | # End of CC checks | ||
727 | # After here, no more $cc or $ld runs | ||
728 | |||
729 | @@ -XXX,XX +XXX,XX @@ echo "tcmalloc support $tcmalloc" | ||
730 | echo "jemalloc support $jemalloc" | ||
731 | echo "avx2 optimization $avx2_opt" | ||
732 | echo "replication support $replication" | ||
733 | +echo "VxHS block device $vxhs" | ||
734 | |||
735 | if test "$sdl_too_old" = "yes"; then | ||
736 | echo "-> Your SDL version is too old - please upgrade to have SDL support" | ||
737 | @@ -XXX,XX +XXX,XX @@ if test "$pthread_setname_np" = "yes" ; then | ||
738 | echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak | ||
739 | fi | ||
740 | |||
741 | +if test "$vxhs" = "yes" ; then | ||
742 | + echo "CONFIG_VXHS=y" >> $config_host_mak | ||
743 | + echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak | ||
744 | +fi | ||
745 | + | ||
746 | if test "$tcg_interpreter" = "yes"; then | ||
747 | QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES" | ||
748 | elif test "$ARCH" = "sparc64" ; then | ||
749 | diff --git a/qapi/block-core.json b/qapi/block-core.json | ||
97 | index XXXXXXX..XXXXXXX 100644 | 750 | index XXXXXXX..XXXXXXX 100644 |
98 | --- a/tests/qemu-iotests/group | 751 | --- a/qapi/block-core.json |
99 | +++ b/tests/qemu-iotests/group | 752 | +++ b/qapi/block-core.json |
100 | @@ -XXX,XX +XXX,XX @@ | 753 | @@ -XXX,XX +XXX,XX @@ |
101 | 171 rw auto quick | 754 | # |
102 | 172 auto | 755 | # Drivers that are supported in block device operations. |
103 | 173 rw auto | 756 | # |
104 | +174 auto | 757 | +# @vxhs: Since 2.10 |
758 | +# | ||
759 | # Since: 2.9 | ||
760 | ## | ||
761 | { 'enum': 'BlockdevDriver', | ||
762 | @@ -XXX,XX +XXX,XX @@ | ||
763 | 'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs', | ||
764 | 'null-aio', 'null-co', 'parallels', 'qcow', 'qcow2', 'qed', | ||
765 | 'quorum', 'raw', 'rbd', 'replication', 'sheepdog', 'ssh', | ||
766 | - 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] } | ||
767 | + 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat', 'vxhs' ] } | ||
768 | |||
769 | ## | ||
770 | # @BlockdevOptionsFile: | ||
771 | @@ -XXX,XX +XXX,XX @@ | ||
772 | 'data': { '*offset': 'int', '*size': 'int' } } | ||
773 | |||
774 | ## | ||
775 | +# @BlockdevOptionsVxHS: | ||
776 | +# | ||
777 | +# Driver specific block device options for VxHS | ||
778 | +# | ||
779 | +# @vdisk-id: UUID of VxHS volume | ||
780 | +# @server: vxhs server IP, port | ||
781 | +# @tls-creds: TLS credentials ID | ||
782 | +# | ||
783 | +# Since: 2.10 | ||
784 | +## | ||
785 | +{ 'struct': 'BlockdevOptionsVxHS', | ||
786 | + 'data': { 'vdisk-id': 'str', | ||
787 | + 'server': 'InetSocketAddressBase', | ||
788 | + '*tls-creds': 'str' } } | ||
789 | + | ||
790 | +## | ||
791 | # @BlockdevOptions: | ||
792 | # | ||
793 | # Options for creating a block device. Many options are available for all | ||
794 | @@ -XXX,XX +XXX,XX @@ | ||
795 | 'vhdx': 'BlockdevOptionsGenericFormat', | ||
796 | 'vmdk': 'BlockdevOptionsGenericCOWFormat', | ||
797 | 'vpc': 'BlockdevOptionsGenericFormat', | ||
798 | - 'vvfat': 'BlockdevOptionsVVFAT' | ||
799 | + 'vvfat': 'BlockdevOptionsVVFAT', | ||
800 | + 'vxhs': 'BlockdevOptionsVxHS' | ||
801 | } } | ||
802 | |||
803 | ## | ||
105 | -- | 804 | -- |
106 | 2.11.0 | 805 | 2.9.3 |
107 | 806 | ||
108 | 807 | diff view generated by jsdifflib |
1 | From: QingFeng Hao <haoqf@linux.vnet.ibm.com> | 1 | From: Ashish Mittal <ashmit602@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | If TEST_DIR is set to /tmp, test case 144 will fail. The reason is that | 3 | These changes use a vxhs test server that is a part of the following |
4 | TEST_DIR resembles 144's test image name tmp.qcow2. | 4 | repository: |
5 | When 144 is testing $TEST_DIR/tmp.qcow2, it wants to replace | 5 | https://github.com/VeritasHyperScale/libqnio.git |
6 | $TEST_DIR/tmp.qcow2 to TEST_DIR/tmp.qcow2, but actually it will fail | ||
7 | and get TEST_DIRTEST_DIR.qcow2 in this case. | ||
8 | The fix is just to modify the code to replace $TEST_DIR/ with TEST_DIR/. | ||
9 | 6 | ||
10 | Signed-off-by: QingFeng Hao <haoqf@linux.vnet.ibm.com> | 7 | Signed-off-by: Ashish Mittal <Ashish.Mittal@veritas.com> |
11 | Message-id: 20161216054723.96055-2-haoqf@linux.vnet.ibm.com | 8 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
12 | Reviewed-by: Eric Blake <eblake@redhat.com> | 9 | Reviewed-by: Jeff Cody <jcody@redhat.com> |
13 | [mreitz: Fixed commit message and dropped superfluous escaping] | 10 | Signed-off-by: Jeff Cody <jcody@redhat.com> |
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 11 | Message-id: 1491277689-24949-3-git-send-email-Ashish.Mittal@veritas.com |
15 | --- | 12 | --- |
16 | tests/qemu-iotests/common.filter | 2 +- | 13 | tests/qemu-iotests/common | 6 ++++++ |
17 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | tests/qemu-iotests/common.config | 13 +++++++++++++ |
15 | tests/qemu-iotests/common.filter | 1 + | ||
16 | tests/qemu-iotests/common.rc | 19 +++++++++++++++++++ | ||
17 | 4 files changed, 39 insertions(+) | ||
18 | 18 | ||
19 | diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/tests/qemu-iotests/common | ||
22 | +++ b/tests/qemu-iotests/common | ||
23 | @@ -XXX,XX +XXX,XX @@ check options | ||
24 | -ssh test ssh | ||
25 | -nfs test nfs | ||
26 | -luks test luks | ||
27 | + -vxhs test vxhs | ||
28 | -xdiff graphical mode diff | ||
29 | -nocache use O_DIRECT on backing file | ||
30 | -misalign misalign memory allocations | ||
31 | @@ -XXX,XX +XXX,XX @@ testlist options | ||
32 | xpand=false | ||
33 | ;; | ||
34 | |||
35 | + -vxhs) | ||
36 | + IMGPROTO=vxhs | ||
37 | + xpand=false | ||
38 | + ;; | ||
39 | + | ||
40 | -ssh) | ||
41 | IMGPROTO=ssh | ||
42 | xpand=false | ||
43 | diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/tests/qemu-iotests/common.config | ||
46 | +++ b/tests/qemu-iotests/common.config | ||
47 | @@ -XXX,XX +XXX,XX @@ if [ -z "$QEMU_NBD_PROG" ]; then | ||
48 | export QEMU_NBD_PROG="`set_prog_path qemu-nbd`" | ||
49 | fi | ||
50 | |||
51 | +if [ -z "$QEMU_VXHS_PROG" ]; then | ||
52 | + export QEMU_VXHS_PROG="`set_prog_path qnio_server`" | ||
53 | +fi | ||
54 | + | ||
55 | _qemu_wrapper() | ||
56 | { | ||
57 | ( | ||
58 | @@ -XXX,XX +XXX,XX @@ _qemu_nbd_wrapper() | ||
59 | ) | ||
60 | } | ||
61 | |||
62 | +_qemu_vxhs_wrapper() | ||
63 | +{ | ||
64 | + ( | ||
65 | + echo $BASHPID > "${TEST_DIR}/qemu-vxhs.pid" | ||
66 | + exec "$QEMU_VXHS_PROG" $QEMU_VXHS_OPTIONS "$@" | ||
67 | + ) | ||
68 | +} | ||
69 | + | ||
70 | export QEMU=_qemu_wrapper | ||
71 | export QEMU_IMG=_qemu_img_wrapper | ||
72 | export QEMU_IO=_qemu_io_wrapper | ||
73 | export QEMU_NBD=_qemu_nbd_wrapper | ||
74 | +export QEMU_VXHS=_qemu_vxhs_wrapper | ||
75 | |||
76 | QEMU_IMG_EXTRA_ARGS= | ||
77 | if [ "$IMGOPTSSYNTAX" = "true" ]; then | ||
19 | diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter | 78 | diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter |
20 | index XXXXXXX..XXXXXXX 100644 | 79 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/tests/qemu-iotests/common.filter | 80 | --- a/tests/qemu-iotests/common.filter |
22 | +++ b/tests/qemu-iotests/common.filter | 81 | +++ b/tests/qemu-iotests/common.filter |
23 | @@ -XXX,XX +XXX,XX @@ _filter_generated_node_ids() | 82 | @@ -XXX,XX +XXX,XX @@ _filter_img_info() |
24 | # replace occurrences of the actual TEST_DIR value with TEST_DIR | 83 | -e "s#$TEST_DIR#TEST_DIR#g" \ |
25 | _filter_testdir() | 84 | -e "s#$IMGFMT#IMGFMT#g" \ |
26 | { | 85 | -e 's#nbd://127.0.0.1:10810$#TEST_DIR/t.IMGFMT#g' \ |
27 | - sed -e "s#$TEST_DIR#TEST_DIR#g" | 86 | + -e 's#json.*vdisk-id.*vxhs"}}#TEST_DIR/t.IMGFMT#' \ |
28 | + sed -e "s#$TEST_DIR/#TEST_DIR/#g" | 87 | -e "/encrypted: yes/d" \ |
88 | -e "/cluster_size: [0-9]\\+/d" \ | ||
89 | -e "/table_size: [0-9]\\+/d" \ | ||
90 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/tests/qemu-iotests/common.rc | ||
93 | +++ b/tests/qemu-iotests/common.rc | ||
94 | @@ -XXX,XX +XXX,XX @@ else | ||
95 | elif [ "$IMGPROTO" = "nfs" ]; then | ||
96 | TEST_DIR="nfs://127.0.0.1/$TEST_DIR" | ||
97 | TEST_IMG=$TEST_DIR/t.$IMGFMT | ||
98 | + elif [ "$IMGPROTO" = "vxhs" ]; then | ||
99 | + TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT | ||
100 | + TEST_IMG="vxhs://127.0.0.1:9999/t.$IMGFMT" | ||
101 | else | ||
102 | TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT | ||
103 | fi | ||
104 | @@ -XXX,XX +XXX,XX @@ _make_test_img() | ||
105 | eval "$QEMU_NBD -v -t -b 127.0.0.1 -p 10810 -f $IMGFMT $TEST_IMG_FILE >/dev/null &" | ||
106 | sleep 1 # FIXME: qemu-nbd needs to be listening before we continue | ||
107 | fi | ||
108 | + | ||
109 | + # Start QNIO server on image directory for vxhs protocol | ||
110 | + if [ $IMGPROTO = "vxhs" ]; then | ||
111 | + eval "$QEMU_VXHS -d $TEST_DIR > /dev/null &" | ||
112 | + sleep 1 # Wait for server to come up. | ||
113 | + fi | ||
29 | } | 114 | } |
30 | 115 | ||
31 | # replace occurrences of the actual IMGFMT value with IMGFMT | 116 | _rm_test_img() |
117 | @@ -XXX,XX +XXX,XX @@ _cleanup_test_img() | ||
118 | fi | ||
119 | rm -f "$TEST_IMG_FILE" | ||
120 | ;; | ||
121 | + vxhs) | ||
122 | + if [ -f "${TEST_DIR}/qemu-vxhs.pid" ]; then | ||
123 | + local QEMU_VXHS_PID | ||
124 | + read QEMU_VXHS_PID < "${TEST_DIR}/qemu-vxhs.pid" | ||
125 | + kill ${QEMU_VXHS_PID} >/dev/null 2>&1 | ||
126 | + rm -f "${TEST_DIR}/qemu-vxhs.pid" | ||
127 | + fi | ||
128 | + rm -f "$TEST_IMG_FILE" | ||
129 | + ;; | ||
130 | + | ||
131 | file) | ||
132 | _rm_test_img "$TEST_DIR/t.$IMGFMT" | ||
133 | _rm_test_img "$TEST_DIR/t.$IMGFMT.orig" | ||
32 | -- | 134 | -- |
33 | 2.11.0 | 135 | 2.9.3 |
34 | 136 | ||
35 | 137 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | When trying to invoke qemu-img commit with a base image file name that | ||
2 | is not part of the top image's backing chain, the user receives a rather | ||
3 | plain "Base not found" error message. This is not really helpful because | ||
4 | it does not explain what "not found" means, potentially leaving the user | ||
5 | wondering why qemu cannot find a file despite it clearly existing in the | ||
6 | file system. | ||
7 | 1 | ||
8 | Improve the error message by clarifying that "not found" means "not | ||
9 | found in the top image's backing chain". | ||
10 | |||
11 | Reported-by: Ala Hino <ahino@redhat.com> | ||
12 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
13 | Message-id: 20161201020508.24417-1-mreitz@redhat.com | ||
14 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
15 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
16 | --- | ||
17 | qemu-img.c | 4 +++- | ||
18 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
19 | |||
20 | diff --git a/qemu-img.c b/qemu-img.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/qemu-img.c | ||
23 | +++ b/qemu-img.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static int img_commit(int argc, char **argv) | ||
25 | if (base) { | ||
26 | base_bs = bdrv_find_backing_image(bs, base); | ||
27 | if (!base_bs) { | ||
28 | - error_setg(&local_err, QERR_BASE_NOT_FOUND, base); | ||
29 | + error_setg(&local_err, | ||
30 | + "Did not find '%s' in the backing chain of '%s'", | ||
31 | + base, filename); | ||
32 | goto done; | ||
33 | } | ||
34 | } else { | ||
35 | -- | ||
36 | 2.11.0 | ||
37 | |||
38 | diff view generated by jsdifflib |
1 | From: Peter Maydell <peter.maydell@linaro.org> | 1 | The protocol VXHS does not support image creation. Some tests expect |
---|---|---|---|
2 | to be able to create images through the protocol. Exclude VXHS from | ||
3 | these tests. | ||
2 | 4 | ||
3 | Some of the argument parsing in qemu-img uses strtoul() to parse | 5 | Signed-off-by: Jeff Cody <jcody@redhat.com> |
4 | integer arguments. This is tricky to get correct and in fact the | 6 | --- |
5 | code does not get it right, because it assigns the result of | 7 | tests/qemu-iotests/017 | 1 + |
6 | strtoul() to an 'int' variable and then tries to check for > INT_MAX. | 8 | tests/qemu-iotests/020 | 1 + |
7 | Coverity correctly complains that the comparison is always false. | 9 | tests/qemu-iotests/029 | 1 + |
10 | tests/qemu-iotests/073 | 1 + | ||
11 | tests/qemu-iotests/114 | 1 + | ||
12 | tests/qemu-iotests/130 | 1 + | ||
13 | tests/qemu-iotests/134 | 1 + | ||
14 | tests/qemu-iotests/156 | 1 + | ||
15 | tests/qemu-iotests/158 | 1 + | ||
16 | 9 files changed, 9 insertions(+) | ||
8 | 17 | ||
9 | Rewrite to use qemu_strtoul(), which has a saner convention for | 18 | diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017 |
10 | reporting conversion failures. | 19 | index XXXXXXX..XXXXXXX 100755 |
11 | 20 | --- a/tests/qemu-iotests/017 | |
12 | (Fixes CID 1356421, CID 1356422, CID 1356423.) | 21 | +++ b/tests/qemu-iotests/017 |
13 | 22 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | |
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | # Any format supporting backing files |
15 | Message-id: 1486744104-15590-2-git-send-email-peter.maydell@linaro.org | 24 | _supported_fmt qcow qcow2 vmdk qed |
16 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 25 | _supported_proto generic |
17 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 26 | +_unsupported_proto vxhs |
18 | --- | 27 | _supported_os Linux |
19 | qemu-img.c | 32 ++++++++++++++++---------------- | 28 | _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" |
20 | 1 file changed, 16 insertions(+), 16 deletions(-) | 29 | |
21 | 30 | diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020 | |
22 | diff --git a/qemu-img.c b/qemu-img.c | 31 | index XXXXXXX..XXXXXXX 100755 |
23 | index XXXXXXX..XXXXXXX 100644 | 32 | --- a/tests/qemu-iotests/020 |
24 | --- a/qemu-img.c | 33 | +++ b/tests/qemu-iotests/020 |
25 | +++ b/qemu-img.c | 34 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
26 | @@ -XXX,XX +XXX,XX @@ static int img_bench(int argc, char **argv) | 35 | # Any format supporting backing files |
27 | break; | 36 | _supported_fmt qcow qcow2 vmdk qed |
28 | case 'c': | 37 | _supported_proto generic |
29 | { | 38 | +_unsupported_proto vxhs |
30 | - char *end; | 39 | _supported_os Linux |
31 | - errno = 0; | 40 | _unsupported_imgopts "subformat=monolithicFlat" \ |
32 | - count = strtoul(optarg, &end, 0); | 41 | "subformat=twoGbMaxExtentFlat" \ |
33 | - if (errno || *end || count > INT_MAX) { | 42 | diff --git a/tests/qemu-iotests/029 b/tests/qemu-iotests/029 |
34 | + unsigned long res; | 43 | index XXXXXXX..XXXXXXX 100755 |
35 | + | 44 | --- a/tests/qemu-iotests/029 |
36 | + if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) { | 45 | +++ b/tests/qemu-iotests/029 |
37 | error_report("Invalid request count specified"); | 46 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
38 | return 1; | 47 | # Any format supporting intenal snapshots |
39 | } | 48 | _supported_fmt qcow2 |
40 | + count = res; | 49 | _supported_proto generic |
41 | break; | 50 | +_unsupported_proto vxhs |
42 | } | 51 | _supported_os Linux |
43 | case 'd': | 52 | # Internal snapshots are (currently) impossible with refcount_bits=1 |
44 | { | 53 | _unsupported_imgopts 'refcount_bits=1[^0-9]' |
45 | - char *end; | 54 | diff --git a/tests/qemu-iotests/073 b/tests/qemu-iotests/073 |
46 | - errno = 0; | 55 | index XXXXXXX..XXXXXXX 100755 |
47 | - depth = strtoul(optarg, &end, 0); | 56 | --- a/tests/qemu-iotests/073 |
48 | - if (errno || *end || depth > INT_MAX) { | 57 | +++ b/tests/qemu-iotests/073 |
49 | + unsigned long res; | 58 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
50 | + | 59 | |
51 | + if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) { | 60 | _supported_fmt qcow2 |
52 | error_report("Invalid queue depth specified"); | 61 | _supported_proto generic |
53 | return 1; | 62 | +_unsupported_proto vxhs |
54 | } | 63 | _supported_os Linux |
55 | + depth = res; | 64 | |
56 | break; | 65 | CLUSTER_SIZE=64k |
57 | } | 66 | diff --git a/tests/qemu-iotests/114 b/tests/qemu-iotests/114 |
58 | case 'f': | 67 | index XXXXXXX..XXXXXXX 100755 |
59 | @@ -XXX,XX +XXX,XX @@ static int img_bench(int argc, char **argv) | 68 | --- a/tests/qemu-iotests/114 |
60 | break; | 69 | +++ b/tests/qemu-iotests/114 |
61 | case OPTION_PATTERN: | 70 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
62 | { | 71 | |
63 | - char *end; | 72 | _supported_fmt qcow2 |
64 | - errno = 0; | 73 | _supported_proto generic |
65 | - pattern = strtoul(optarg, &end, 0); | 74 | +_unsupported_proto vxhs |
66 | - if (errno || *end || pattern > 0xff) { | 75 | _supported_os Linux |
67 | + unsigned long res; | 76 | |
68 | + | 77 | |
69 | + if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > 0xff) { | 78 | diff --git a/tests/qemu-iotests/130 b/tests/qemu-iotests/130 |
70 | error_report("Invalid pattern byte specified"); | 79 | index XXXXXXX..XXXXXXX 100755 |
71 | return 1; | 80 | --- a/tests/qemu-iotests/130 |
72 | } | 81 | +++ b/tests/qemu-iotests/130 |
73 | + pattern = res; | 82 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
74 | break; | 83 | |
75 | } | 84 | _supported_fmt qcow2 |
76 | case OPTION_FLUSH_INTERVAL: | 85 | _supported_proto generic |
77 | { | 86 | +_unsupported_proto vxhs |
78 | - char *end; | 87 | _supported_os Linux |
79 | - errno = 0; | 88 | |
80 | - flush_interval = strtoul(optarg, &end, 0); | 89 | qemu_comm_method="monitor" |
81 | - if (errno || *end || flush_interval > INT_MAX) { | 90 | diff --git a/tests/qemu-iotests/134 b/tests/qemu-iotests/134 |
82 | + unsigned long res; | 91 | index XXXXXXX..XXXXXXX 100755 |
83 | + | 92 | --- a/tests/qemu-iotests/134 |
84 | + if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) { | 93 | +++ b/tests/qemu-iotests/134 |
85 | error_report("Invalid flush interval specified"); | 94 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
86 | return 1; | 95 | |
87 | } | 96 | _supported_fmt qcow2 |
88 | + flush_interval = res; | 97 | _supported_proto generic |
89 | break; | 98 | +_unsupported_proto vxhs |
90 | } | 99 | _supported_os Linux |
91 | case OPTION_NO_DRAIN: | 100 | |
101 | |||
102 | diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156 | ||
103 | index XXXXXXX..XXXXXXX 100755 | ||
104 | --- a/tests/qemu-iotests/156 | ||
105 | +++ b/tests/qemu-iotests/156 | ||
106 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
107 | |||
108 | _supported_fmt qcow2 qed | ||
109 | _supported_proto generic | ||
110 | +_unsupported_proto vxhs | ||
111 | _supported_os Linux | ||
112 | |||
113 | # Create source disk | ||
114 | diff --git a/tests/qemu-iotests/158 b/tests/qemu-iotests/158 | ||
115 | index XXXXXXX..XXXXXXX 100755 | ||
116 | --- a/tests/qemu-iotests/158 | ||
117 | +++ b/tests/qemu-iotests/158 | ||
118 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
119 | |||
120 | _supported_fmt qcow2 | ||
121 | _supported_proto generic | ||
122 | +_unsupported_proto vxhs | ||
123 | _supported_os Linux | ||
124 | |||
125 | |||
92 | -- | 126 | -- |
93 | 2.11.0 | 127 | 2.9.3 |
94 | 128 | ||
95 | 129 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | We have a helper wrapper for checking for the BDS read_only flag, |
---|---|---|---|
2 | add a helper wrapper to set the read_only flag as well. | ||
2 | 3 | ||
3 | Current implementation invalidates firstly parent bds and then its | ||
4 | children. This leads to the following bug: | ||
5 | |||
6 | after incoming migration, in bdrv_invalidate_cache_all: | ||
7 | 1. invalidate parent bds - reopen it with BDRV_O_INACTIVE cleared | ||
8 | 2. child is not yet invalidated | ||
9 | 3. parent check that its BDRV_O_INACTIVE is cleared | ||
10 | 4. parent writes to child | ||
11 | 5. assert in bdrv_co_pwritev, as BDRV_O_INACTIVE is set for child | ||
12 | |||
13 | This patch fixes it by just changing invalidate sequence: invalidate | ||
14 | children first. | ||
15 | |||
16 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
17 | Message-id: 20170131112308.54189-1-vsementsov@virtuozzo.com | ||
18 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
19 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | 4 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
20 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 5 | Signed-off-by: Jeff Cody <jcody@redhat.com> |
6 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
7 | Message-id: 9b18972d05f5fa2ac16c014f0af98d680553048d.1491597120.git.jcody@redhat.com | ||
21 | --- | 8 | --- |
22 | block.c | 11 +++++------ | 9 | block.c | 5 +++++ |
23 | 1 file changed, 5 insertions(+), 6 deletions(-) | 10 | block/bochs.c | 2 +- |
11 | block/cloop.c | 2 +- | ||
12 | block/dmg.c | 2 +- | ||
13 | block/rbd.c | 2 +- | ||
14 | block/vvfat.c | 4 ++-- | ||
15 | include/block/block.h | 1 + | ||
16 | 7 files changed, 12 insertions(+), 6 deletions(-) | ||
24 | 17 | ||
25 | diff --git a/block.c b/block.c | 18 | diff --git a/block.c b/block.c |
26 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/block.c | 20 | --- a/block.c |
28 | +++ b/block.c | 21 | +++ b/block.c |
29 | @@ -XXX,XX +XXX,XX @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) | 22 | @@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size, |
30 | if (!(bs->open_flags & BDRV_O_INACTIVE)) { | ||
31 | return; | ||
32 | } | 23 | } |
33 | - bs->open_flags &= ~BDRV_O_INACTIVE; | 24 | } |
34 | 25 | ||
35 | - if (bs->drv->bdrv_invalidate_cache) { | 26 | +void bdrv_set_read_only(BlockDriverState *bs, bool read_only) |
36 | - bs->drv->bdrv_invalidate_cache(bs, &local_err); | 27 | +{ |
37 | + QLIST_FOREACH(child, &bs->children, next) { | 28 | + bs->read_only = read_only; |
38 | + bdrv_invalidate_cache(child->bs, &local_err); | 29 | +} |
39 | if (local_err) { | 30 | + |
40 | - bs->open_flags |= BDRV_O_INACTIVE; | 31 | void bdrv_get_full_backing_filename_from_filename(const char *backed, |
41 | error_propagate(errp, local_err); | 32 | const char *backing, |
42 | return; | 33 | char *dest, size_t sz, |
34 | diff --git a/block/bochs.c b/block/bochs.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/block/bochs.c | ||
37 | +++ b/block/bochs.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags, | ||
39 | return -EINVAL; | ||
40 | } | ||
41 | |||
42 | - bs->read_only = true; /* no write support yet */ | ||
43 | + bdrv_set_read_only(bs, true); /* no write support yet */ | ||
44 | |||
45 | ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs)); | ||
46 | if (ret < 0) { | ||
47 | diff --git a/block/cloop.c b/block/cloop.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/block/cloop.c | ||
50 | +++ b/block/cloop.c | ||
51 | @@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags, | ||
52 | return -EINVAL; | ||
53 | } | ||
54 | |||
55 | - bs->read_only = true; | ||
56 | + bdrv_set_read_only(bs, true); | ||
57 | |||
58 | /* read header */ | ||
59 | ret = bdrv_pread(bs->file, 128, &s->block_size, 4); | ||
60 | diff --git a/block/dmg.c b/block/dmg.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/block/dmg.c | ||
63 | +++ b/block/dmg.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags, | ||
65 | } | ||
66 | |||
67 | block_module_load_one("dmg-bz2"); | ||
68 | - bs->read_only = true; | ||
69 | + bdrv_set_read_only(bs, true); | ||
70 | |||
71 | s->n_chunks = 0; | ||
72 | s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL; | ||
73 | diff --git a/block/rbd.c b/block/rbd.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/block/rbd.c | ||
76 | +++ b/block/rbd.c | ||
77 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, | ||
78 | goto failed_open; | ||
79 | } | ||
80 | |||
81 | - bs->read_only = (s->snap != NULL); | ||
82 | + bdrv_set_read_only(bs, (s->snap != NULL)); | ||
83 | |||
84 | qemu_opts_del(opts); | ||
85 | return 0; | ||
86 | diff --git a/block/vvfat.c b/block/vvfat.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/block/vvfat.c | ||
89 | +++ b/block/vvfat.c | ||
90 | @@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, | ||
91 | s->current_cluster=0xffffffff; | ||
92 | |||
93 | /* read only is the default for safety */ | ||
94 | - bs->read_only = true; | ||
95 | + bdrv_set_read_only(bs, true); | ||
96 | s->qcow = NULL; | ||
97 | s->qcow_filename = NULL; | ||
98 | s->fat2 = NULL; | ||
99 | @@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, | ||
100 | if (ret < 0) { | ||
101 | goto fail; | ||
43 | } | 102 | } |
103 | - bs->read_only = false; | ||
104 | + bdrv_set_read_only(bs, false); | ||
44 | } | 105 | } |
45 | 106 | ||
46 | - QLIST_FOREACH(child, &bs->children, next) { | 107 | bs->total_sectors = cyls * heads * secs; |
47 | - bdrv_invalidate_cache(child->bs, &local_err); | 108 | diff --git a/include/block/block.h b/include/block/block.h |
48 | + bs->open_flags &= ~BDRV_O_INACTIVE; | 109 | index XXXXXXX..XXXXXXX 100644 |
49 | + if (bs->drv->bdrv_invalidate_cache) { | 110 | --- a/include/block/block.h |
50 | + bs->drv->bdrv_invalidate_cache(bs, &local_err); | 111 | +++ b/include/block/block.h |
51 | if (local_err) { | 112 | @@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, |
52 | bs->open_flags |= BDRV_O_INACTIVE; | 113 | int64_t sector_num, int nb_sectors, int *pnum); |
53 | error_propagate(errp, local_err); | 114 | |
115 | bool bdrv_is_read_only(BlockDriverState *bs); | ||
116 | +void bdrv_set_read_only(BlockDriverState *bs, bool read_only); | ||
117 | bool bdrv_is_sg(BlockDriverState *bs); | ||
118 | bool bdrv_is_inserted(BlockDriverState *bs); | ||
119 | int bdrv_media_changed(BlockDriverState *bs); | ||
54 | -- | 120 | -- |
55 | 2.11.0 | 121 | 2.9.3 |
56 | 122 | ||
57 | 123 | diff view generated by jsdifflib |
1 | From: Dou Liyang <douly.fnst@cn.fujitsu.com> | 1 | A few block drivers will set the BDS read_only flag from their |
---|---|---|---|
2 | .bdrv_open() function. This means the bs->read_only flag could | ||
3 | be set after we enable copy_on_read, as the BDRV_O_COPY_ON_READ | ||
4 | flag check occurs prior to the call to bdrv->bdrv_open(). | ||
2 | 5 | ||
3 | The bdrv_query_stats and bdrv_query_bds_stats functions need to call | 6 | This adds an error return to bdrv_set_read_only(), and an error will be |
4 | each other, that increases the coupling. it also makes the program | 7 | return if we try to set the BDS to read_only while copy_on_read is |
5 | complicated and makes some unnecessary tests. | 8 | enabled. |
6 | 9 | ||
7 | Remove the call from bdrv_query_bds_stats to bdrv_query_stats, just | 10 | This patch also changes the behavior of vvfat. Before, vvfat could |
8 | take some recursion to make it clearly. | 11 | override the drive 'readonly' flag with its own, internal 'rw' flag. |
9 | 12 | ||
10 | Avoid testing whether the blk is NULL during querying the bds stats. | 13 | For instance, this -drive parameter would result in a writable image: |
11 | It is unnecessary. | ||
12 | 14 | ||
13 | Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com> | 15 | "-drive format=vvfat,dir=/tmp/vvfat,rw,if=virtio,readonly=on" |
14 | Message-id: 1484467275-27919-2-git-send-email-douly.fnst@cn.fujitsu.com | 16 | |
15 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 17 | This is not correct. Now, attempting to use the above -drive parameter |
16 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 18 | will result in an error (i.e., 'rw' is incompatible with 'readonly=on'). |
19 | |||
20 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
21 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
22 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
23 | Message-id: 0c5b4c1cc2c651471b131f21376dfd5ea24d2196.1491597120.git.jcody@redhat.com | ||
17 | --- | 24 | --- |
18 | block/qapi.c | 26 ++++++++++++++------------ | 25 | block.c | 10 +++++++++- |
19 | 1 file changed, 14 insertions(+), 12 deletions(-) | 26 | block/bochs.c | 5 ++++- |
27 | block/cloop.c | 5 ++++- | ||
28 | block/dmg.c | 6 +++++- | ||
29 | block/rbd.c | 11 ++++++++++- | ||
30 | block/vvfat.c | 19 +++++++++++++++---- | ||
31 | include/block/block.h | 2 +- | ||
32 | 7 files changed, 48 insertions(+), 10 deletions(-) | ||
20 | 33 | ||
21 | diff --git a/block/qapi.c b/block/qapi.c | 34 | diff --git a/block.c b/block.c |
22 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/block/qapi.c | 36 | --- a/block.c |
24 | +++ b/block/qapi.c | 37 | +++ b/block.c |
25 | @@ -XXX,XX +XXX,XX @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, | 38 | @@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size, |
26 | qapi_free_BlockInfo(info); | ||
27 | } | ||
28 | |||
29 | -static BlockStats *bdrv_query_stats(BlockBackend *blk, | ||
30 | - const BlockDriverState *bs, | ||
31 | - bool query_backing); | ||
32 | - | ||
33 | static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk) | ||
34 | { | ||
35 | BlockAcctStats *stats = blk_get_stats(blk); | ||
36 | @@ -XXX,XX +XXX,XX @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk) | ||
37 | } | 39 | } |
38 | } | 40 | } |
39 | 41 | ||
40 | -static void bdrv_query_bds_stats(BlockStats *s, const BlockDriverState *bs, | 42 | -void bdrv_set_read_only(BlockDriverState *bs, bool read_only) |
41 | +static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs, | 43 | +int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp) |
42 | bool query_backing) | ||
43 | { | 44 | { |
44 | + BlockStats *s = NULL; | 45 | + /* Do not set read_only if copy_on_read is enabled */ |
45 | + | 46 | + if (bs->copy_on_read && read_only) { |
46 | + s = g_malloc0(sizeof(*s)); | 47 | + error_setg(errp, "Can't set node '%s' to r/o with copy-on-read enabled", |
47 | + s->stats = g_malloc0(sizeof(*s->stats)); | 48 | + bdrv_get_device_or_node_name(bs)); |
48 | + | 49 | + return -EINVAL; |
49 | + if (!bs) { | ||
50 | + return s; | ||
51 | + } | 50 | + } |
52 | + | 51 | + |
53 | if (bdrv_get_node_name(bs)[0]) { | 52 | bs->read_only = read_only; |
54 | s->has_node_name = true; | 53 | + return 0; |
55 | s->node_name = g_strdup(bdrv_get_node_name(bs)); | 54 | } |
56 | @@ -XXX,XX +XXX,XX @@ static void bdrv_query_bds_stats(BlockStats *s, const BlockDriverState *bs, | 55 | |
57 | 56 | void bdrv_get_full_backing_filename_from_filename(const char *backed, | |
58 | if (bs->file) { | 57 | diff --git a/block/bochs.c b/block/bochs.c |
59 | s->has_parent = true; | 58 | index XXXXXXX..XXXXXXX 100644 |
60 | - s->parent = bdrv_query_stats(NULL, bs->file->bs, query_backing); | 59 | --- a/block/bochs.c |
61 | + s->parent = bdrv_query_bds_stats(bs->file->bs, query_backing); | 60 | +++ b/block/bochs.c |
61 | @@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags, | ||
62 | return -EINVAL; | ||
62 | } | 63 | } |
63 | 64 | ||
64 | if (query_backing && bs->backing) { | 65 | - bdrv_set_read_only(bs, true); /* no write support yet */ |
65 | s->has_backing = true; | 66 | + ret = bdrv_set_read_only(bs, true, errp); /* no write support yet */ |
66 | - s->backing = bdrv_query_stats(NULL, bs->backing->bs, query_backing); | 67 | + if (ret < 0) { |
67 | + s->backing = bdrv_query_bds_stats(bs->backing->bs, query_backing); | 68 | + return ret; |
69 | + } | ||
70 | |||
71 | ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs)); | ||
72 | if (ret < 0) { | ||
73 | diff --git a/block/cloop.c b/block/cloop.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/block/cloop.c | ||
76 | +++ b/block/cloop.c | ||
77 | @@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags, | ||
78 | return -EINVAL; | ||
68 | } | 79 | } |
69 | 80 | ||
70 | + return s; | 81 | - bdrv_set_read_only(bs, true); |
71 | } | 82 | + ret = bdrv_set_read_only(bs, true, errp); |
72 | 83 | + if (ret < 0) { | |
73 | static BlockStats *bdrv_query_stats(BlockBackend *blk, | 84 | + return ret; |
74 | @@ -XXX,XX +XXX,XX @@ static BlockStats *bdrv_query_stats(BlockBackend *blk, | 85 | + } |
75 | { | 86 | |
76 | BlockStats *s; | 87 | /* read header */ |
77 | 88 | ret = bdrv_pread(bs->file, 128, &s->block_size, 4); | |
78 | - s = g_malloc0(sizeof(*s)); | 89 | diff --git a/block/dmg.c b/block/dmg.c |
79 | - s->stats = g_malloc0(sizeof(*s->stats)); | 90 | index XXXXXXX..XXXXXXX 100644 |
80 | + s = bdrv_query_bds_stats(bs, query_backing); | 91 | --- a/block/dmg.c |
81 | 92 | +++ b/block/dmg.c | |
82 | if (blk) { | 93 | @@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags, |
83 | s->has_device = true; | 94 | return -EINVAL; |
84 | s->device = g_strdup(blk_name(blk)); | ||
85 | bdrv_query_blk_stats(s->stats, blk); | ||
86 | } | 95 | } |
87 | - if (bs) { | 96 | |
88 | - bdrv_query_bds_stats(s, bs, query_backing); | 97 | + ret = bdrv_set_read_only(bs, true, errp); |
89 | - } | 98 | + if (ret < 0) { |
90 | 99 | + return ret; | |
91 | return s; | 100 | + } |
92 | } | 101 | + |
102 | block_module_load_one("dmg-bz2"); | ||
103 | - bdrv_set_read_only(bs, true); | ||
104 | |||
105 | s->n_chunks = 0; | ||
106 | s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL; | ||
107 | diff --git a/block/rbd.c b/block/rbd.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/block/rbd.c | ||
110 | +++ b/block/rbd.c | ||
111 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, | ||
112 | goto failed_shutdown; | ||
113 | } | ||
114 | |||
115 | + /* rbd_open is always r/w */ | ||
116 | r = rbd_open(s->io_ctx, s->name, &s->image, s->snap); | ||
117 | if (r < 0) { | ||
118 | error_setg_errno(errp, -r, "error reading header from %s", s->name); | ||
119 | goto failed_open; | ||
120 | } | ||
121 | |||
122 | - bdrv_set_read_only(bs, (s->snap != NULL)); | ||
123 | + /* If we are using an rbd snapshot, we must be r/o, otherwise | ||
124 | + * leave as-is */ | ||
125 | + if (s->snap != NULL) { | ||
126 | + r = bdrv_set_read_only(bs, true, &local_err); | ||
127 | + if (r < 0) { | ||
128 | + error_propagate(errp, local_err); | ||
129 | + goto failed_open; | ||
130 | + } | ||
131 | + } | ||
132 | |||
133 | qemu_opts_del(opts); | ||
134 | return 0; | ||
135 | diff --git a/block/vvfat.c b/block/vvfat.c | ||
136 | index XXXXXXX..XXXXXXX 100644 | ||
137 | --- a/block/vvfat.c | ||
138 | +++ b/block/vvfat.c | ||
139 | @@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, | ||
140 | |||
141 | s->current_cluster=0xffffffff; | ||
142 | |||
143 | - /* read only is the default for safety */ | ||
144 | - bdrv_set_read_only(bs, true); | ||
145 | s->qcow = NULL; | ||
146 | s->qcow_filename = NULL; | ||
147 | s->fat2 = NULL; | ||
148 | @@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, | ||
149 | s->sector_count = cyls * heads * secs - (s->first_sectors_number - 1); | ||
150 | |||
151 | if (qemu_opt_get_bool(opts, "rw", false)) { | ||
152 | - ret = enable_write_target(bs, errp); | ||
153 | + if (!bdrv_is_read_only(bs)) { | ||
154 | + ret = enable_write_target(bs, errp); | ||
155 | + if (ret < 0) { | ||
156 | + goto fail; | ||
157 | + } | ||
158 | + } else { | ||
159 | + ret = -EPERM; | ||
160 | + error_setg(errp, | ||
161 | + "Unable to set VVFAT to 'rw' when drive is read-only"); | ||
162 | + goto fail; | ||
163 | + } | ||
164 | + } else { | ||
165 | + /* read only is the default for safety */ | ||
166 | + ret = bdrv_set_read_only(bs, true, &local_err); | ||
167 | if (ret < 0) { | ||
168 | + error_propagate(errp, local_err); | ||
169 | goto fail; | ||
170 | } | ||
171 | - bdrv_set_read_only(bs, false); | ||
172 | } | ||
173 | |||
174 | bs->total_sectors = cyls * heads * secs; | ||
175 | diff --git a/include/block/block.h b/include/block/block.h | ||
176 | index XXXXXXX..XXXXXXX 100644 | ||
177 | --- a/include/block/block.h | ||
178 | +++ b/include/block/block.h | ||
179 | @@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, | ||
180 | int64_t sector_num, int nb_sectors, int *pnum); | ||
181 | |||
182 | bool bdrv_is_read_only(BlockDriverState *bs); | ||
183 | -void bdrv_set_read_only(BlockDriverState *bs, bool read_only); | ||
184 | +int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp); | ||
185 | bool bdrv_is_sg(BlockDriverState *bs); | ||
186 | bool bdrv_is_inserted(BlockDriverState *bs); | ||
187 | int bdrv_media_changed(BlockDriverState *bs); | ||
93 | -- | 188 | -- |
94 | 2.11.0 | 189 | 2.9.3 |
95 | 190 | ||
96 | 191 | diff view generated by jsdifflib |
1 | From: Peter Maydell <peter.maydell@linaro.org> | 1 | The BDRV_O_ALLOW_RDWR flag allows / prohibits the changing of |
---|---|---|---|
2 | the BDS 'read_only' state, but there are a few places where it | ||
3 | is ignored. In the bdrv_set_read_only() helper, make sure to | ||
4 | honor the flag. | ||
2 | 5 | ||
3 | Coverity points out that we assign the return value from | 6 | Signed-off-by: Jeff Cody <jcody@redhat.com> |
4 | bdrv_snapshot_load_tmp() to 'ret' in img_convert(), but then | 7 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
5 | never use that variable. (We check for failure by looking | 8 | Reviewed-by: John Snow <jsnow@redhat.com> |
6 | at local_err instead.) Drop the unused assignment, bringing | 9 | Message-id: be2e5fb2d285cbece2b6d06bed54a6f56520d251.1491597120.git.jcody@redhat.com |
7 | the call into line with the following call to | 10 | --- |
8 | bdrv_snapshot_laod_tmp_by_id_or_name(). | 11 | block.c | 7 +++++++ |
12 | 1 file changed, 7 insertions(+) | ||
9 | 13 | ||
10 | (Fixes CID 1247240.) | 14 | diff --git a/block.c b/block.c |
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Message-id: 1486744104-15590-3-git-send-email-peter.maydell@linaro.org | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
16 | --- | ||
17 | qemu-img.c | 8 ++++---- | ||
18 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
19 | |||
20 | diff --git a/qemu-img.c b/qemu-img.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/qemu-img.c | 16 | --- a/block.c |
23 | +++ b/qemu-img.c | 17 | +++ b/block.c |
24 | @@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv) | 18 | @@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp) |
19 | return -EINVAL; | ||
25 | } | 20 | } |
26 | 21 | ||
27 | if (sn_opts) { | 22 | + /* Do not clear read_only if it is prohibited */ |
28 | - ret = bdrv_snapshot_load_tmp(bs[0], | 23 | + if (!read_only && !(bs->open_flags & BDRV_O_ALLOW_RDWR)) { |
29 | - qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID), | 24 | + error_setg(errp, "Node '%s' is read only", |
30 | - qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME), | 25 | + bdrv_get_device_or_node_name(bs)); |
31 | - &local_err); | 26 | + return -EPERM; |
32 | + bdrv_snapshot_load_tmp(bs[0], | 27 | + } |
33 | + qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID), | 28 | + |
34 | + qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME), | 29 | bs->read_only = read_only; |
35 | + &local_err); | 30 | return 0; |
36 | } else if (snapshot_name != NULL) { | 31 | } |
37 | if (bs_n > 1) { | ||
38 | error_report("No support for concatenating multiple snapshot"); | ||
39 | -- | 32 | -- |
40 | 2.11.0 | 33 | 2.9.3 |
41 | 34 | ||
42 | 35 | diff view generated by jsdifflib |
1 | From: Dou Liyang <douly.fnst@cn.fujitsu.com> | 1 | Move bdrv_is_read_only() up with its friends. |
---|---|---|---|
2 | 2 | ||
3 | In order to reduce the execution time, this patch optimize | 3 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
4 | the qmp_query_blockstats(): | 4 | Reviewed-by: John Snow <jsnow@redhat.com> |
5 | Remove the next_query_bds function. | 5 | Signed-off-by: Jeff Cody <jcody@redhat.com> |
6 | Remove the bdrv_query_stats function. | 6 | Message-id: 73b2399459760c32506f9407efb9dddb3a2789de.1491597120.git.jcody@redhat.com |
7 | Remove some judgement sentence. | 7 | --- |
8 | block.c | 10 +++++----- | ||
9 | 1 file changed, 5 insertions(+), 5 deletions(-) | ||
8 | 10 | ||
9 | The original qmp_query_blockstats calls next_query_bds to get | 11 | diff --git a/block.c b/block.c |
10 | the next objects in each loops. In the next_query_bds, it checks | ||
11 | the query_nodes and blk. It also call bdrv_query_stats to get | ||
12 | the stats, In the bdrv_query_stats, it checks blk and bs each | ||
13 | times. This waste more times, which may stall the main loop a | ||
14 | bit. And if the disk is too many and donot use the dataplane | ||
15 | feature, this may affect the performance in main loop thread. | ||
16 | |||
17 | This patch removes that two functions, and makes the structure | ||
18 | clearly. | ||
19 | |||
20 | Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com> | ||
21 | Message-id: 1484467275-27919-3-git-send-email-douly.fnst@cn.fujitsu.com | ||
22 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
23 | [mreitz: Removed duplicate info->value assignment] | ||
24 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
25 | --- | ||
26 | block/qapi.c | 73 ++++++++++++++++++++++++------------------------------------ | ||
27 | 1 file changed, 29 insertions(+), 44 deletions(-) | ||
28 | |||
29 | diff --git a/block/qapi.c b/block/qapi.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/block/qapi.c | 13 | --- a/block.c |
32 | +++ b/block/qapi.c | 14 | +++ b/block.c |
33 | @@ -XXX,XX +XXX,XX @@ static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs, | 15 | @@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size, |
34 | return s; | 16 | } |
35 | } | 17 | } |
36 | 18 | ||
37 | -static BlockStats *bdrv_query_stats(BlockBackend *blk, | 19 | +bool bdrv_is_read_only(BlockDriverState *bs) |
38 | - const BlockDriverState *bs, | 20 | +{ |
39 | - bool query_backing) | 21 | + return bs->read_only; |
22 | +} | ||
23 | + | ||
24 | int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp) | ||
25 | { | ||
26 | /* Do not set read_only if copy_on_read is enabled */ | ||
27 | @@ -XXX,XX +XXX,XX @@ void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr) | ||
28 | *nb_sectors_ptr = nb_sectors < 0 ? 0 : nb_sectors; | ||
29 | } | ||
30 | |||
31 | -bool bdrv_is_read_only(BlockDriverState *bs) | ||
40 | -{ | 32 | -{ |
41 | - BlockStats *s; | 33 | - return bs->read_only; |
42 | - | ||
43 | - s = bdrv_query_bds_stats(bs, query_backing); | ||
44 | - | ||
45 | - if (blk) { | ||
46 | - s->has_device = true; | ||
47 | - s->device = g_strdup(blk_name(blk)); | ||
48 | - bdrv_query_blk_stats(s->stats, blk); | ||
49 | - } | ||
50 | - | ||
51 | - return s; | ||
52 | -} | 34 | -} |
53 | - | 35 | - |
54 | BlockInfoList *qmp_query_block(Error **errp) | 36 | bool bdrv_is_sg(BlockDriverState *bs) |
55 | { | 37 | { |
56 | BlockInfoList *head = NULL, **p_next = &head; | 38 | return bs->sg; |
57 | @@ -XXX,XX +XXX,XX @@ BlockInfoList *qmp_query_block(Error **errp) | ||
58 | return head; | ||
59 | } | ||
60 | |||
61 | -static bool next_query_bds(BlockBackend **blk, BlockDriverState **bs, | ||
62 | - bool query_nodes) | ||
63 | -{ | ||
64 | - if (query_nodes) { | ||
65 | - *bs = bdrv_next_node(*bs); | ||
66 | - return !!*bs; | ||
67 | - } | ||
68 | - | ||
69 | - *blk = blk_next(*blk); | ||
70 | - *bs = *blk ? blk_bs(*blk) : NULL; | ||
71 | - | ||
72 | - return !!*blk; | ||
73 | -} | ||
74 | - | ||
75 | BlockStatsList *qmp_query_blockstats(bool has_query_nodes, | ||
76 | bool query_nodes, | ||
77 | Error **errp) | ||
78 | { | ||
79 | BlockStatsList *head = NULL, **p_next = &head; | ||
80 | - BlockBackend *blk = NULL; | ||
81 | - BlockDriverState *bs = NULL; | ||
82 | + BlockBackend *blk; | ||
83 | + BlockDriverState *bs; | ||
84 | |||
85 | /* Just to be safe if query_nodes is not always initialized */ | ||
86 | - query_nodes = has_query_nodes && query_nodes; | ||
87 | - | ||
88 | - while (next_query_bds(&blk, &bs, query_nodes)) { | ||
89 | - BlockStatsList *info = g_malloc0(sizeof(*info)); | ||
90 | - AioContext *ctx = blk ? blk_get_aio_context(blk) | ||
91 | - : bdrv_get_aio_context(bs); | ||
92 | + if (has_query_nodes && query_nodes) { | ||
93 | + for (bs = bdrv_next_node(NULL); bs; bs = bdrv_next_node(bs)) { | ||
94 | + BlockStatsList *info = g_malloc0(sizeof(*info)); | ||
95 | + AioContext *ctx = bdrv_get_aio_context(bs); | ||
96 | |||
97 | - aio_context_acquire(ctx); | ||
98 | - info->value = bdrv_query_stats(blk, bs, !query_nodes); | ||
99 | - aio_context_release(ctx); | ||
100 | + aio_context_acquire(ctx); | ||
101 | + info->value = bdrv_query_bds_stats(bs, false); | ||
102 | + aio_context_release(ctx); | ||
103 | |||
104 | - *p_next = info; | ||
105 | - p_next = &info->next; | ||
106 | + *p_next = info; | ||
107 | + p_next = &info->next; | ||
108 | + } | ||
109 | + } else { | ||
110 | + for (blk = blk_next(NULL); blk; blk = blk_next(blk)) { | ||
111 | + BlockStatsList *info = g_malloc0(sizeof(*info)); | ||
112 | + AioContext *ctx = blk_get_aio_context(blk); | ||
113 | + BlockStats *s; | ||
114 | + | ||
115 | + aio_context_acquire(ctx); | ||
116 | + s = bdrv_query_bds_stats(blk_bs(blk), true); | ||
117 | + s->has_device = true; | ||
118 | + s->device = g_strdup(blk_name(blk)); | ||
119 | + bdrv_query_blk_stats(s->stats, blk); | ||
120 | + aio_context_release(ctx); | ||
121 | + | ||
122 | + info->value = s; | ||
123 | + *p_next = info; | ||
124 | + p_next = &info->next; | ||
125 | + } | ||
126 | } | ||
127 | |||
128 | return head; | ||
129 | -- | 39 | -- |
130 | 2.11.0 | 40 | 2.9.3 |
131 | 41 | ||
132 | 42 | diff view generated by jsdifflib |
1 | From: Fam Zheng <famz@redhat.com> | 1 | Introduce check function for setting read_only flags. Will return < 0 on |
---|---|---|---|
2 | error, with appropriate Error value set. Does not alter any flags. | ||
2 | 3 | ||
3 | @bs doesn't always have a device name, such as when it comes from | 4 | Signed-off-by: Jeff Cody <jcody@redhat.com> |
4 | "qemu-img info". Report file name instead. | 5 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
6 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
7 | Message-id: e2bba34ac3bc76a0c42adc390413f358ae0566e8.1491597120.git.jcody@redhat.com | ||
8 | --- | ||
9 | block.c | 14 +++++++++++++- | ||
10 | include/block/block.h | 1 + | ||
11 | 2 files changed, 14 insertions(+), 1 deletion(-) | ||
5 | 12 | ||
6 | Signed-off-by: Fam Zheng <famz@redhat.com> | 13 | diff --git a/block.c b/block.c |
7 | Message-id: 20170119130759.28319-2-famz@redhat.com | ||
8 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
10 | --- | ||
11 | block/qapi.c | 4 ++-- | ||
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/block/qapi.c b/block/qapi.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/block/qapi.c | 15 | --- a/block.c |
17 | +++ b/block/qapi.c | 16 | +++ b/block.c |
18 | @@ -XXX,XX +XXX,XX @@ void bdrv_query_image_info(BlockDriverState *bs, | 17 | @@ -XXX,XX +XXX,XX @@ bool bdrv_is_read_only(BlockDriverState *bs) |
19 | 18 | return bs->read_only; | |
20 | size = bdrv_getlength(bs); | 19 | } |
21 | if (size < 0) { | 20 | |
22 | - error_setg_errno(errp, -size, "Can't get size of device '%s'", | 21 | -int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp) |
23 | - bdrv_get_device_name(bs)); | 22 | +int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **errp) |
24 | + error_setg_errno(errp, -size, "Can't get image size '%s'", | 23 | { |
25 | + bs->exact_filename); | 24 | /* Do not set read_only if copy_on_read is enabled */ |
26 | goto out; | 25 | if (bs->copy_on_read && read_only) { |
26 | @@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp) | ||
27 | return -EPERM; | ||
27 | } | 28 | } |
28 | 29 | ||
30 | + return 0; | ||
31 | +} | ||
32 | + | ||
33 | +int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp) | ||
34 | +{ | ||
35 | + int ret = 0; | ||
36 | + | ||
37 | + ret = bdrv_can_set_read_only(bs, read_only, errp); | ||
38 | + if (ret < 0) { | ||
39 | + return ret; | ||
40 | + } | ||
41 | + | ||
42 | bs->read_only = read_only; | ||
43 | return 0; | ||
44 | } | ||
45 | diff --git a/include/block/block.h b/include/block/block.h | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/include/block/block.h | ||
48 | +++ b/include/block/block.h | ||
49 | @@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, | ||
50 | int64_t sector_num, int nb_sectors, int *pnum); | ||
51 | |||
52 | bool bdrv_is_read_only(BlockDriverState *bs); | ||
53 | +int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **errp); | ||
54 | int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp); | ||
55 | bool bdrv_is_sg(BlockDriverState *bs); | ||
56 | bool bdrv_is_inserted(BlockDriverState *bs); | ||
29 | -- | 57 | -- |
30 | 2.11.0 | 58 | 2.9.3 |
31 | 59 | ||
32 | 60 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Peter Lieven <pl@kamp.de> | ||
2 | 1 | ||
3 | parse_uint_full wants to put the parsed value into the | ||
4 | variable passed via its second argument which is NULL. | ||
5 | |||
6 | Fixes: 94d6a7a76e9df9919629428f6c598e2b97d9426c | ||
7 | Cc: qemu-stable@nongnu.org | ||
8 | Signed-off-by: Peter Lieven <pl@kamp.de> | ||
9 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
10 | Message-id: 1485942829-10756-2-git-send-email-pl@kamp.de | ||
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
12 | --- | ||
13 | block/nfs.c | 3 ++- | ||
14 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/block/nfs.c b/block/nfs.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/block/nfs.c | ||
19 | +++ b/block/nfs.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static int nfs_parse_uri(const char *filename, QDict *options, Error **errp) | ||
21 | qdict_put(options, "path", qstring_from_str(uri->path)); | ||
22 | |||
23 | for (i = 0; i < qp->n; i++) { | ||
24 | + unsigned long long val; | ||
25 | if (!qp->p[i].value) { | ||
26 | error_setg(errp, "Value for NFS parameter expected: %s", | ||
27 | qp->p[i].name); | ||
28 | goto out; | ||
29 | } | ||
30 | - if (parse_uint_full(qp->p[i].value, NULL, 0)) { | ||
31 | + if (parse_uint_full(qp->p[i].value, &val, 0)) { | ||
32 | error_setg(errp, "Illegal value for NFS parameter: %s", | ||
33 | qp->p[i].name); | ||
34 | goto out; | ||
35 | -- | ||
36 | 2.11.0 | ||
37 | |||
38 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | Signed-off-by: Jeff Cody <jcody@redhat.com> |
---|---|---|---|
2 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
3 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
4 | Message-id: 00aed7ffdd7be4b9ed9ce1007d50028a72b34ebe.1491597120.git.jcody@redhat.com | ||
5 | --- | ||
6 | block.c | 14 ++++++++------ | ||
7 | 1 file changed, 8 insertions(+), 6 deletions(-) | ||
2 | 8 | ||
3 | Passing a request size larger than BDRV_REQUEST_MAX_BYTES to any of the | 9 | diff --git a/block.c b/block.c |
4 | I/O commands results in an error. While 'read' and 'write' handle the | ||
5 | error correctly, 'aio_read' and 'aio_write' hit an assertion: | ||
6 | |||
7 | blk_aio_read_entry: Assertion `rwco->qiov->size == acb->bytes' failed. | ||
8 | |||
9 | The reason is that the QEMU I/O code cannot handle request sizes | ||
10 | larger than BDRV_REQUEST_MAX_BYTES, so this patch makes qemu-io check | ||
11 | that all values are within range. | ||
12 | |||
13 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
14 | Message-id: 79f66648c685929a144396bda24d13a207131dcf.1485878688.git.berto@igalia.com | ||
15 | [mreitz: Use BDRV_REQUEST_MAX_BYTES instead of INT_MAX] | ||
16 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
17 | --- | ||
18 | qemu-io-cmds.c | 20 +++++++++++++------- | ||
19 | 1 file changed, 13 insertions(+), 7 deletions(-) | ||
20 | |||
21 | diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | 10 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/qemu-io-cmds.c | 11 | --- a/block.c |
24 | +++ b/qemu-io-cmds.c | 12 | +++ b/block.c |
25 | @@ -XXX,XX +XXX,XX @@ create_iovec(BlockBackend *blk, QEMUIOVector *qiov, char **argv, int nr_iov, | 13 | @@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, |
26 | goto fail; | 14 | BlockDriver *drv; |
27 | } | 15 | QemuOpts *opts; |
28 | 16 | const char *value; | |
29 | - if (len > SIZE_MAX) { | 17 | + bool read_only; |
30 | - printf("Argument '%s' exceeds maximum size %llu\n", arg, | 18 | |
31 | - (unsigned long long)SIZE_MAX); | 19 | assert(reopen_state != NULL); |
32 | + if (len > BDRV_REQUEST_MAX_BYTES) { | 20 | assert(reopen_state->bs->drv != NULL); |
33 | + printf("Argument '%s' exceeds maximum size %" PRIu64 "\n", arg, | 21 | @@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, |
34 | + (uint64_t)BDRV_REQUEST_MAX_BYTES); | 22 | qdict_put(reopen_state->options, "driver", qstring_from_str(value)); |
35 | + goto fail; | ||
36 | + } | ||
37 | + | ||
38 | + if (count > BDRV_REQUEST_MAX_BYTES - len) { | ||
39 | + printf("The total number of bytes exceed the maximum size %" PRIu64 | ||
40 | + "\n", (uint64_t)BDRV_REQUEST_MAX_BYTES); | ||
41 | goto fail; | ||
42 | } | ||
43 | |||
44 | @@ -XXX,XX +XXX,XX @@ static int read_f(BlockBackend *blk, int argc, char **argv) | ||
45 | if (count < 0) { | ||
46 | print_cvtnum_err(count, argv[optind]); | ||
47 | return 0; | ||
48 | - } else if (count > SIZE_MAX) { | ||
49 | + } else if (count > BDRV_REQUEST_MAX_BYTES) { | ||
50 | printf("length cannot exceed %" PRIu64 ", given %s\n", | ||
51 | - (uint64_t) SIZE_MAX, argv[optind]); | ||
52 | + (uint64_t)BDRV_REQUEST_MAX_BYTES, argv[optind]); | ||
53 | return 0; | ||
54 | } | 23 | } |
55 | 24 | ||
56 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | 25 | - /* if we are to stay read-only, do not allow permission change |
57 | if (count < 0) { | 26 | - * to r/w */ |
58 | print_cvtnum_err(count, argv[optind]); | 27 | - if (!(reopen_state->bs->open_flags & BDRV_O_ALLOW_RDWR) && |
59 | return 0; | 28 | - reopen_state->flags & BDRV_O_RDWR) { |
60 | - } else if (count > SIZE_MAX) { | 29 | - error_setg(errp, "Node '%s' is read only", |
61 | + } else if (count > BDRV_REQUEST_MAX_BYTES) { | 30 | - bdrv_get_device_or_node_name(reopen_state->bs)); |
62 | printf("length cannot exceed %" PRIu64 ", given %s\n", | 31 | + /* If we are to stay read-only, do not allow permission change |
63 | - (uint64_t) SIZE_MAX, argv[optind]); | 32 | + * to r/w. Attempting to set to r/w may fail if either BDRV_O_ALLOW_RDWR is |
64 | + (uint64_t)BDRV_REQUEST_MAX_BYTES, argv[optind]); | 33 | + * not set, or if the BDS still has copy_on_read enabled */ |
65 | return 0; | 34 | + read_only = !(reopen_state->flags & BDRV_O_RDWR); |
35 | + ret = bdrv_can_set_read_only(reopen_state->bs, read_only, &local_err); | ||
36 | + if (local_err) { | ||
37 | + error_propagate(errp, local_err); | ||
38 | goto error; | ||
66 | } | 39 | } |
67 | 40 | ||
68 | -- | 41 | -- |
69 | 2.11.0 | 42 | 2.9.3 |
70 | 43 | ||
71 | 44 | diff view generated by jsdifflib |
1 | From: Peter Lieven <pl@kamp.de> | 1 | Update 'clientname' to be 'user', which tracks better with both |
---|---|---|---|
2 | the QAPI and rados variable naming. | ||
2 | 3 | ||
3 | commit 94d6a7a accidentally left the naming of runtime opts and QAPI | 4 | Update 'name' to be 'image_name', as it indicates the rbd image. |
4 | scheme inconsistent. As one consequence passing of parameters in the | 5 | Naming it 'image' would have been ideal, but we are using that for |
5 | URI is broken. Sync the naming of the runtime opts to the QAPI | 6 | the rados_image_t value returned by rbd_open(). |
6 | scheme. | ||
7 | 7 | ||
8 | Please note that this is technically backwards incompatible with the 2.8 | 8 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
9 | release, but the 2.8 release is the only version that had the wrong naming. | 9 | Signed-off-by: Jeff Cody <jcody@redhat.com> |
10 | Furthermore release 2.8 suffered from a NULL pointer dereference during | 10 | Reviewed-by: John Snow <jsnow@redhat.com> |
11 | URI parsing. | 11 | Message-id: b7ec1fb2e1cf36f9b6911631447a5b0422590b7d.1491597120.git.jcody@redhat.com |
12 | --- | ||
13 | block/rbd.c | 33 +++++++++++++++++---------------- | ||
14 | 1 file changed, 17 insertions(+), 16 deletions(-) | ||
12 | 15 | ||
13 | Fixes: 94d6a7a76e9df9919629428f6c598e2b97d9426c | 16 | diff --git a/block/rbd.c b/block/rbd.c |
14 | Cc: qemu-stable@nongnu.org | ||
15 | Signed-off-by: Peter Lieven <pl@kamp.de> | ||
16 | Message-id: 1485942829-10756-3-git-send-email-pl@kamp.de | ||
17 | [mreitz: Fixed commit message] | ||
18 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
19 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
20 | --- | ||
21 | block/nfs.c | 46 +++++++++++++++++++++++----------------------- | ||
22 | 1 file changed, 23 insertions(+), 23 deletions(-) | ||
23 | |||
24 | diff --git a/block/nfs.c b/block/nfs.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/block/nfs.c | 18 | --- a/block/rbd.c |
27 | +++ b/block/nfs.c | 19 | +++ b/block/rbd.c |
28 | @@ -XXX,XX +XXX,XX @@ static QemuOptsList runtime_opts = { | 20 | @@ -XXX,XX +XXX,XX @@ typedef struct BDRVRBDState { |
29 | .help = "Path of the image on the host", | 21 | rados_t cluster; |
30 | }, | 22 | rados_ioctx_t io_ctx; |
31 | { | 23 | rbd_image_t image; |
32 | - .name = "uid", | 24 | - char *name; |
33 | + .name = "user", | 25 | + char *image_name; |
34 | .type = QEMU_OPT_NUMBER, | 26 | char *snap; |
35 | .help = "UID value to use when talking to the server", | 27 | } BDRVRBDState; |
36 | }, | 28 | |
37 | { | 29 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp) |
38 | - .name = "gid", | 30 | int64_t bytes = 0; |
39 | + .name = "group", | 31 | int64_t objsize; |
40 | .type = QEMU_OPT_NUMBER, | 32 | int obj_order = 0; |
41 | .help = "GID value to use when talking to the server", | 33 | - const char *pool, *name, *conf, *clientname, *keypairs; |
42 | }, | 34 | + const char *pool, *image_name, *conf, *user, *keypairs; |
43 | { | 35 | const char *secretid; |
44 | - .name = "tcp-syncnt", | 36 | rados_t cluster; |
45 | + .name = "tcp-syn-count", | 37 | rados_ioctx_t io_ctx; |
46 | .type = QEMU_OPT_NUMBER, | 38 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp) |
47 | .help = "Number of SYNs to send during the session establish", | 39 | */ |
48 | }, | 40 | pool = qdict_get_try_str(options, "pool"); |
49 | { | 41 | conf = qdict_get_try_str(options, "conf"); |
50 | - .name = "readahead", | 42 | - clientname = qdict_get_try_str(options, "user"); |
51 | + .name = "readahead-size", | 43 | - name = qdict_get_try_str(options, "image"); |
52 | .type = QEMU_OPT_NUMBER, | 44 | + user = qdict_get_try_str(options, "user"); |
53 | .help = "Set the readahead size in bytes", | 45 | + image_name = qdict_get_try_str(options, "image"); |
54 | }, | 46 | keypairs = qdict_get_try_str(options, "=keyvalue-pairs"); |
55 | { | 47 | |
56 | - .name = "pagecache", | 48 | - ret = rados_create(&cluster, clientname); |
57 | + .name = "page-cache-size", | 49 | + ret = rados_create(&cluster, user); |
58 | .type = QEMU_OPT_NUMBER, | 50 | if (ret < 0) { |
59 | .help = "Set the pagecache size in bytes", | 51 | error_setg_errno(errp, -ret, "error initializing"); |
60 | }, | 52 | goto exit; |
61 | @@ -XXX,XX +XXX,XX @@ static int64_t nfs_client_open(NFSClient *client, QDict *options, | 53 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp) |
62 | goto fail; | 54 | goto shutdown; |
63 | } | 55 | } |
64 | 56 | ||
65 | - if (qemu_opt_get(opts, "uid")) { | 57 | - ret = rbd_create(io_ctx, name, bytes, &obj_order); |
66 | - client->uid = qemu_opt_get_number(opts, "uid", 0); | 58 | + ret = rbd_create(io_ctx, image_name, bytes, &obj_order); |
67 | + if (qemu_opt_get(opts, "user")) { | 59 | if (ret < 0) { |
68 | + client->uid = qemu_opt_get_number(opts, "user", 0); | 60 | error_setg_errno(errp, -ret, "error rbd create"); |
69 | nfs_set_uid(client->context, client->uid); | ||
70 | } | 61 | } |
71 | 62 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, | |
72 | - if (qemu_opt_get(opts, "gid")) { | 63 | Error **errp) |
73 | - client->gid = qemu_opt_get_number(opts, "gid", 0); | 64 | { |
74 | + if (qemu_opt_get(opts, "group")) { | 65 | BDRVRBDState *s = bs->opaque; |
75 | + client->gid = qemu_opt_get_number(opts, "group", 0); | 66 | - const char *pool, *snap, *conf, *clientname, *name, *keypairs; |
76 | nfs_set_gid(client->context, client->gid); | 67 | + const char *pool, *snap, *conf, *user, *image_name, *keypairs; |
68 | const char *secretid; | ||
69 | QemuOpts *opts; | ||
70 | Error *local_err = NULL; | ||
71 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, | ||
72 | pool = qemu_opt_get(opts, "pool"); | ||
73 | conf = qemu_opt_get(opts, "conf"); | ||
74 | snap = qemu_opt_get(opts, "snapshot"); | ||
75 | - clientname = qemu_opt_get(opts, "user"); | ||
76 | - name = qemu_opt_get(opts, "image"); | ||
77 | + user = qemu_opt_get(opts, "user"); | ||
78 | + image_name = qemu_opt_get(opts, "image"); | ||
79 | keypairs = qemu_opt_get(opts, "=keyvalue-pairs"); | ||
80 | |||
81 | - if (!pool || !name) { | ||
82 | + if (!pool || !image_name) { | ||
83 | error_setg(errp, "Parameters 'pool' and 'image' are required"); | ||
84 | r = -EINVAL; | ||
85 | goto failed_opts; | ||
77 | } | 86 | } |
78 | 87 | ||
79 | - if (qemu_opt_get(opts, "tcp-syncnt")) { | 88 | - r = rados_create(&s->cluster, clientname); |
80 | - client->tcp_syncnt = qemu_opt_get_number(opts, "tcp-syncnt", 0); | 89 | + r = rados_create(&s->cluster, user); |
81 | + if (qemu_opt_get(opts, "tcp-syn-count")) { | 90 | if (r < 0) { |
82 | + client->tcp_syncnt = qemu_opt_get_number(opts, "tcp-syn-count", 0); | 91 | error_setg_errno(errp, -r, "error initializing"); |
83 | nfs_set_tcp_syncnt(client->context, client->tcp_syncnt); | 92 | goto failed_opts; |
84 | } | 93 | } |
85 | 94 | ||
86 | #ifdef LIBNFS_FEATURE_READAHEAD | 95 | s->snap = g_strdup(snap); |
87 | - if (qemu_opt_get(opts, "readahead")) { | 96 | - s->name = g_strdup(name); |
88 | + if (qemu_opt_get(opts, "readahead-size")) { | 97 | + s->image_name = g_strdup(image_name); |
89 | if (open_flags & BDRV_O_NOCACHE) { | 98 | |
90 | error_setg(errp, "Cannot enable NFS readahead " | 99 | /* try default location when conf=NULL, but ignore failure */ |
91 | "if cache.direct = on"); | 100 | r = rados_conf_read_file(s->cluster, conf); |
92 | goto fail; | 101 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, |
93 | } | ||
94 | - client->readahead = qemu_opt_get_number(opts, "readahead", 0); | ||
95 | + client->readahead = qemu_opt_get_number(opts, "readahead-size", 0); | ||
96 | if (client->readahead > QEMU_NFS_MAX_READAHEAD_SIZE) { | ||
97 | error_report("NFS Warning: Truncating NFS readahead " | ||
98 | "size to %d", QEMU_NFS_MAX_READAHEAD_SIZE); | ||
99 | @@ -XXX,XX +XXX,XX @@ static int64_t nfs_client_open(NFSClient *client, QDict *options, | ||
100 | #endif | ||
101 | |||
102 | #ifdef LIBNFS_FEATURE_PAGECACHE | ||
103 | - if (qemu_opt_get(opts, "pagecache")) { | ||
104 | + if (qemu_opt_get(opts, "page-cache-size")) { | ||
105 | if (open_flags & BDRV_O_NOCACHE) { | ||
106 | error_setg(errp, "Cannot enable NFS pagecache " | ||
107 | "if cache.direct = on"); | ||
108 | goto fail; | ||
109 | } | ||
110 | - client->pagecache = qemu_opt_get_number(opts, "pagecache", 0); | ||
111 | + client->pagecache = qemu_opt_get_number(opts, "page-cache-size", 0); | ||
112 | if (client->pagecache > QEMU_NFS_MAX_PAGECACHE_SIZE) { | ||
113 | error_report("NFS Warning: Truncating NFS pagecache " | ||
114 | "size to %d pages", QEMU_NFS_MAX_PAGECACHE_SIZE); | ||
115 | @@ -XXX,XX +XXX,XX @@ static void nfs_refresh_filename(BlockDriverState *bs, QDict *options) | ||
116 | qdict_put(opts, "path", qstring_from_str(client->path)); | ||
117 | |||
118 | if (client->uid) { | ||
119 | - qdict_put(opts, "uid", qint_from_int(client->uid)); | ||
120 | + qdict_put(opts, "user", qint_from_int(client->uid)); | ||
121 | } | 102 | } |
122 | if (client->gid) { | 103 | |
123 | - qdict_put(opts, "gid", qint_from_int(client->gid)); | 104 | /* rbd_open is always r/w */ |
124 | + qdict_put(opts, "group", qint_from_int(client->gid)); | 105 | - r = rbd_open(s->io_ctx, s->name, &s->image, s->snap); |
106 | + r = rbd_open(s->io_ctx, s->image_name, &s->image, s->snap); | ||
107 | if (r < 0) { | ||
108 | - error_setg_errno(errp, -r, "error reading header from %s", s->name); | ||
109 | + error_setg_errno(errp, -r, "error reading header from %s", | ||
110 | + s->image_name); | ||
111 | goto failed_open; | ||
125 | } | 112 | } |
126 | if (client->tcp_syncnt) { | 113 | |
127 | - qdict_put(opts, "tcp-syncnt", | 114 | @@ -XXX,XX +XXX,XX @@ failed_open: |
128 | - qint_from_int(client->tcp_syncnt)); | 115 | failed_shutdown: |
129 | + qdict_put(opts, "tcp-syn-cnt", | 116 | rados_shutdown(s->cluster); |
130 | + qint_from_int(client->tcp_syncnt)); | 117 | g_free(s->snap); |
131 | } | 118 | - g_free(s->name); |
132 | if (client->readahead) { | 119 | + g_free(s->image_name); |
133 | - qdict_put(opts, "readahead", | 120 | failed_opts: |
134 | - qint_from_int(client->readahead)); | 121 | qemu_opts_del(opts); |
135 | + qdict_put(opts, "readahead-size", | 122 | g_free(mon_host); |
136 | + qint_from_int(client->readahead)); | 123 | @@ -XXX,XX +XXX,XX @@ static void qemu_rbd_close(BlockDriverState *bs) |
137 | } | 124 | rbd_close(s->image); |
138 | if (client->pagecache) { | 125 | rados_ioctx_destroy(s->io_ctx); |
139 | - qdict_put(opts, "pagecache", | 126 | g_free(s->snap); |
140 | - qint_from_int(client->pagecache)); | 127 | - g_free(s->name); |
141 | + qdict_put(opts, "page-cache-size", | 128 | + g_free(s->image_name); |
142 | + qint_from_int(client->pagecache)); | 129 | rados_shutdown(s->cluster); |
143 | } | 130 | } |
144 | if (client->debug) { | 131 | |
145 | qdict_put(opts, "debug", qint_from_int(client->debug)); | ||
146 | -- | 132 | -- |
147 | 2.11.0 | 133 | 2.9.3 |
148 | 134 | ||
149 | 135 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Nir Soffer <nirsof@gmail.com> | ||
2 | 1 | ||
3 | The result of openfile was not checked, leading to failure deep in the | ||
4 | actual command with confusing error message, and exiting with exit code 0. | ||
5 | |||
6 | Here is a simple example - trying to read with the wrong format: | ||
7 | |||
8 | $ touch file | ||
9 | $ qemu-io -f qcow2 -c 'read -P 1 0 1024' file; echo $? | ||
10 | can't open device file: Image is not in qcow2 format | ||
11 | no file open, try 'help open' | ||
12 | 0 | ||
13 | |||
14 | With this patch, we fail earlier with exit code 1: | ||
15 | |||
16 | $ ./qemu-io -f qcow2 -c 'read -P 1 0 1024' file; echo $? | ||
17 | can't open device file: Image is not in qcow2 format | ||
18 | 1 | ||
19 | |||
20 | Failing earlier, we don't log this error now: | ||
21 | |||
22 | no file open, try 'help open' | ||
23 | |||
24 | But some tests expected it; the line was removed from the test output. | ||
25 | |||
26 | Signed-off-by: Nir Soffer <nirsof@gmail.com> | ||
27 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
28 | Message-id: 20170201003120.23378-2-nirsof@gmail.com | ||
29 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
30 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
31 | --- | ||
32 | qemu-io.c | 8 ++++++-- | ||
33 | tests/qemu-iotests/059.out | 3 --- | ||
34 | tests/qemu-iotests/070.out | 1 - | ||
35 | tests/qemu-iotests/075.out | 7 ------- | ||
36 | tests/qemu-iotests/076.out | 3 --- | ||
37 | tests/qemu-iotests/078.out | 6 ------ | ||
38 | tests/qemu-iotests/080.out | 18 ------------------ | ||
39 | tests/qemu-iotests/083.out | 17 ----------------- | ||
40 | tests/qemu-iotests/088.out | 6 ------ | ||
41 | tests/qemu-iotests/092.out | 12 ------------ | ||
42 | tests/qemu-iotests/116.out | 7 ------- | ||
43 | tests/qemu-iotests/131.out | 1 - | ||
44 | tests/qemu-iotests/140.out | 1 - | ||
45 | 13 files changed, 6 insertions(+), 84 deletions(-) | ||
46 | |||
47 | diff --git a/qemu-io.c b/qemu-io.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/qemu-io.c | ||
50 | +++ b/qemu-io.c | ||
51 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
52 | exit(1); | ||
53 | } | ||
54 | opts = qemu_opts_to_qdict(qopts, NULL); | ||
55 | - openfile(NULL, flags, writethrough, opts); | ||
56 | + if (openfile(NULL, flags, writethrough, opts)) { | ||
57 | + exit(1); | ||
58 | + } | ||
59 | } else { | ||
60 | if (format) { | ||
61 | opts = qdict_new(); | ||
62 | qdict_put(opts, "driver", qstring_from_str(format)); | ||
63 | } | ||
64 | - openfile(argv[optind], flags, writethrough, opts); | ||
65 | + if (openfile(argv[optind], flags, writethrough, opts)) { | ||
66 | + exit(1); | ||
67 | + } | ||
68 | } | ||
69 | } | ||
70 | command_loop(); | ||
71 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/tests/qemu-iotests/059.out | ||
74 | +++ b/tests/qemu-iotests/059.out | ||
75 | @@ -XXX,XX +XXX,XX @@ QA output created by 059 | ||
76 | === Testing invalid granularity === | ||
77 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
78 | can't open device TEST_DIR/t.vmdk: Invalid granularity, image may be corrupt | ||
79 | -no file open, try 'help open' | ||
80 | |||
81 | === Testing too big L2 table size === | ||
82 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
83 | can't open device TEST_DIR/t.vmdk: L2 table size too big | ||
84 | -no file open, try 'help open' | ||
85 | |||
86 | === Testing too big L1 table size === | ||
87 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
88 | can't open device TEST_DIR/t.vmdk: L1 size too big | ||
89 | -no file open, try 'help open' | ||
90 | |||
91 | === Testing monolithicFlat creation and opening === | ||
92 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat | ||
93 | diff --git a/tests/qemu-iotests/070.out b/tests/qemu-iotests/070.out | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/tests/qemu-iotests/070.out | ||
96 | +++ b/tests/qemu-iotests/070.out | ||
97 | @@ -XXX,XX +XXX,XX @@ QA output created by 070 | ||
98 | can't open device TEST_DIR/iotest-dirtylog-10G-4M.vhdx: VHDX image file 'TEST_DIR/iotest-dirtylog-10G-4M.vhdx' opened read-only, but contains a log that needs to be replayed | ||
99 | To replay the log, run: | ||
100 | qemu-img check -r all 'TEST_DIR/iotest-dirtylog-10G-4M.vhdx' | ||
101 | - no file open, try 'help open' | ||
102 | === Verify open image replays log === | ||
103 | read 18874368/18874368 bytes at offset 0 | ||
104 | 18 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
105 | diff --git a/tests/qemu-iotests/075.out b/tests/qemu-iotests/075.out | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/tests/qemu-iotests/075.out | ||
108 | +++ b/tests/qemu-iotests/075.out | ||
109 | @@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 1048064 | ||
110 | |||
111 | == block_size must be a multiple of 512 == | ||
112 | can't open device TEST_DIR/simple-pattern.cloop: block_size 513 must be a multiple of 512 | ||
113 | -no file open, try 'help open' | ||
114 | |||
115 | == block_size cannot be zero == | ||
116 | can't open device TEST_DIR/simple-pattern.cloop: block_size cannot be zero | ||
117 | -no file open, try 'help open' | ||
118 | |||
119 | == huge block_size === | ||
120 | can't open device TEST_DIR/simple-pattern.cloop: block_size 4294966784 must be 64 MB or less | ||
121 | -no file open, try 'help open' | ||
122 | |||
123 | == offsets_size overflow === | ||
124 | can't open device TEST_DIR/simple-pattern.cloop: n_blocks 4294967295 must be 536870911 or less | ||
125 | -no file open, try 'help open' | ||
126 | |||
127 | == refuse images that require too many offsets === | ||
128 | can't open device TEST_DIR/simple-pattern.cloop: image requires too many offsets, try increasing block size | ||
129 | -no file open, try 'help open' | ||
130 | |||
131 | == refuse images with non-monotonically increasing offsets == | ||
132 | can't open device TEST_DIR/simple-pattern.cloop: offsets not monotonically increasing at index 1, image file is corrupt | ||
133 | -no file open, try 'help open' | ||
134 | |||
135 | == refuse images with invalid compressed block size == | ||
136 | can't open device TEST_DIR/simple-pattern.cloop: invalid compressed block size at index 1, image file is corrupt | ||
137 | -no file open, try 'help open' | ||
138 | *** done | ||
139 | diff --git a/tests/qemu-iotests/076.out b/tests/qemu-iotests/076.out | ||
140 | index XXXXXXX..XXXXXXX 100644 | ||
141 | --- a/tests/qemu-iotests/076.out | ||
142 | +++ b/tests/qemu-iotests/076.out | ||
143 | @@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 0 | ||
144 | |||
145 | == Negative catalog size == | ||
146 | can't open device TEST_DIR/parallels-v1: Catalog too large | ||
147 | -no file open, try 'help open' | ||
148 | |||
149 | == Overflow in catalog allocation == | ||
150 | can't open device TEST_DIR/parallels-v1: Catalog too large | ||
151 | -no file open, try 'help open' | ||
152 | |||
153 | == Zero sectors per track == | ||
154 | can't open device TEST_DIR/parallels-v1: Invalid image: Zero sectors per track | ||
155 | -no file open, try 'help open' | ||
156 | |||
157 | == Read from a valid v2 image == | ||
158 | read 65536/65536 bytes at offset 0 | ||
159 | diff --git a/tests/qemu-iotests/078.out b/tests/qemu-iotests/078.out | ||
160 | index XXXXXXX..XXXXXXX 100644 | ||
161 | --- a/tests/qemu-iotests/078.out | ||
162 | +++ b/tests/qemu-iotests/078.out | ||
163 | @@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0 | ||
164 | |||
165 | == Negative catalog size == | ||
166 | can't open device TEST_DIR/empty.bochs: Catalog size is too large | ||
167 | -no file open, try 'help open' | ||
168 | |||
169 | == Overflow for catalog size * sizeof(uint32_t) == | ||
170 | can't open device TEST_DIR/empty.bochs: Catalog size is too large | ||
171 | -no file open, try 'help open' | ||
172 | |||
173 | == Too small catalog bitmap for image size == | ||
174 | can't open device TEST_DIR/empty.bochs: Catalog size is too small for this disk size | ||
175 | -no file open, try 'help open' | ||
176 | can't open device TEST_DIR/empty.bochs: Catalog size is too small for this disk size | ||
177 | -no file open, try 'help open' | ||
178 | |||
179 | == Negative extent size == | ||
180 | can't open device TEST_DIR/empty.bochs: Extent size 2147483648 is too large | ||
181 | -no file open, try 'help open' | ||
182 | |||
183 | == Zero extent size == | ||
184 | can't open device TEST_DIR/empty.bochs: Extent size must be at least 512 | ||
185 | -no file open, try 'help open' | ||
186 | *** done | ||
187 | diff --git a/tests/qemu-iotests/080.out b/tests/qemu-iotests/080.out | ||
188 | index XXXXXXX..XXXXXXX 100644 | ||
189 | --- a/tests/qemu-iotests/080.out | ||
190 | +++ b/tests/qemu-iotests/080.out | ||
191 | @@ -XXX,XX +XXX,XX @@ QA output created by 080 | ||
192 | == Huge header size == | ||
193 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
194 | can't open device TEST_DIR/t.qcow2: qcow2 header exceeds cluster size | ||
195 | -no file open, try 'help open' | ||
196 | can't open device TEST_DIR/t.qcow2: qcow2 header exceeds cluster size | ||
197 | -no file open, try 'help open' | ||
198 | |||
199 | == Huge unknown header extension == | ||
200 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
201 | can't open device TEST_DIR/t.qcow2: Invalid backing file offset | ||
202 | -no file open, try 'help open' | ||
203 | can't open device TEST_DIR/t.qcow2: Header extension too large | ||
204 | -no file open, try 'help open' | ||
205 | can't open device TEST_DIR/t.qcow2: Header extension too large | ||
206 | -no file open, try 'help open' | ||
207 | |||
208 | == Huge refcount table size == | ||
209 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
210 | can't open device TEST_DIR/t.qcow2: Reference count table too large | ||
211 | -no file open, try 'help open' | ||
212 | can't open device TEST_DIR/t.qcow2: Reference count table too large | ||
213 | -no file open, try 'help open' | ||
214 | |||
215 | == Misaligned refcount table == | ||
216 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
217 | can't open device TEST_DIR/t.qcow2: Invalid reference count table offset | ||
218 | -no file open, try 'help open' | ||
219 | |||
220 | == Huge refcount offset == | ||
221 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
222 | can't open device TEST_DIR/t.qcow2: Invalid reference count table offset | ||
223 | -no file open, try 'help open' | ||
224 | |||
225 | == Invalid snapshot table == | ||
226 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
227 | can't open device TEST_DIR/t.qcow2: Too many snapshots | ||
228 | -no file open, try 'help open' | ||
229 | can't open device TEST_DIR/t.qcow2: Too many snapshots | ||
230 | -no file open, try 'help open' | ||
231 | can't open device TEST_DIR/t.qcow2: Invalid snapshot table offset | ||
232 | -no file open, try 'help open' | ||
233 | can't open device TEST_DIR/t.qcow2: Invalid snapshot table offset | ||
234 | -no file open, try 'help open' | ||
235 | |||
236 | == Hitting snapshot table size limit == | ||
237 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
238 | @@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0 | ||
239 | == Invalid L1 table == | ||
240 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
241 | can't open device TEST_DIR/t.qcow2: Active L1 table too large | ||
242 | -no file open, try 'help open' | ||
243 | can't open device TEST_DIR/t.qcow2: Active L1 table too large | ||
244 | -no file open, try 'help open' | ||
245 | can't open device TEST_DIR/t.qcow2: Invalid L1 table offset | ||
246 | -no file open, try 'help open' | ||
247 | can't open device TEST_DIR/t.qcow2: Invalid L1 table offset | ||
248 | -no file open, try 'help open' | ||
249 | |||
250 | == Invalid L1 table (with internal snapshot in the image) == | ||
251 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
252 | @@ -XXX,XX +XXX,XX @@ qemu-img: Could not open 'TEST_DIR/t.IMGFMT': L1 table is too small | ||
253 | == Invalid backing file size == | ||
254 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
255 | can't open device TEST_DIR/t.qcow2: Backing file name too long | ||
256 | -no file open, try 'help open' | ||
257 | |||
258 | == Invalid L2 entry (huge physical offset) == | ||
259 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
260 | diff --git a/tests/qemu-iotests/083.out b/tests/qemu-iotests/083.out | ||
261 | index XXXXXXX..XXXXXXX 100644 | ||
262 | --- a/tests/qemu-iotests/083.out | ||
263 | +++ b/tests/qemu-iotests/083.out | ||
264 | @@ -XXX,XX +XXX,XX @@ QA output created by 083 | ||
265 | === Check disconnect before neg1 === | ||
266 | |||
267 | can't open device nbd:127.0.0.1:PORT:exportname=foo | ||
268 | -no file open, try 'help open' | ||
269 | |||
270 | === Check disconnect after neg1 === | ||
271 | |||
272 | can't open device nbd:127.0.0.1:PORT:exportname=foo | ||
273 | -no file open, try 'help open' | ||
274 | |||
275 | === Check disconnect 8 neg1 === | ||
276 | |||
277 | can't open device nbd:127.0.0.1:PORT:exportname=foo | ||
278 | -no file open, try 'help open' | ||
279 | |||
280 | === Check disconnect 16 neg1 === | ||
281 | |||
282 | can't open device nbd:127.0.0.1:PORT:exportname=foo | ||
283 | -no file open, try 'help open' | ||
284 | |||
285 | === Check disconnect before export === | ||
286 | |||
287 | can't open device nbd:127.0.0.1:PORT:exportname=foo | ||
288 | -no file open, try 'help open' | ||
289 | |||
290 | === Check disconnect after export === | ||
291 | |||
292 | can't open device nbd:127.0.0.1:PORT:exportname=foo | ||
293 | -no file open, try 'help open' | ||
294 | |||
295 | === Check disconnect 4 export === | ||
296 | |||
297 | can't open device nbd:127.0.0.1:PORT:exportname=foo | ||
298 | -no file open, try 'help open' | ||
299 | |||
300 | === Check disconnect 12 export === | ||
301 | |||
302 | can't open device nbd:127.0.0.1:PORT:exportname=foo | ||
303 | -no file open, try 'help open' | ||
304 | |||
305 | === Check disconnect 16 export === | ||
306 | |||
307 | can't open device nbd:127.0.0.1:PORT:exportname=foo | ||
308 | -no file open, try 'help open' | ||
309 | |||
310 | === Check disconnect before neg2 === | ||
311 | |||
312 | can't open device nbd:127.0.0.1:PORT:exportname=foo | ||
313 | -no file open, try 'help open' | ||
314 | |||
315 | === Check disconnect after neg2 === | ||
316 | |||
317 | @@ -XXX,XX +XXX,XX @@ read failed: Input/output error | ||
318 | === Check disconnect 8 neg2 === | ||
319 | |||
320 | can't open device nbd:127.0.0.1:PORT:exportname=foo | ||
321 | -no file open, try 'help open' | ||
322 | |||
323 | === Check disconnect 10 neg2 === | ||
324 | |||
325 | can't open device nbd:127.0.0.1:PORT:exportname=foo | ||
326 | -no file open, try 'help open' | ||
327 | |||
328 | === Check disconnect before request === | ||
329 | |||
330 | @@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 0 | ||
331 | === Check disconnect before neg-classic === | ||
332 | |||
333 | can't open device nbd:127.0.0.1:PORT | ||
334 | -no file open, try 'help open' | ||
335 | |||
336 | === Check disconnect 8 neg-classic === | ||
337 | |||
338 | can't open device nbd:127.0.0.1:PORT | ||
339 | -no file open, try 'help open' | ||
340 | |||
341 | === Check disconnect 16 neg-classic === | ||
342 | |||
343 | can't open device nbd:127.0.0.1:PORT | ||
344 | -no file open, try 'help open' | ||
345 | |||
346 | === Check disconnect 24 neg-classic === | ||
347 | |||
348 | can't open device nbd:127.0.0.1:PORT | ||
349 | -no file open, try 'help open' | ||
350 | |||
351 | === Check disconnect 28 neg-classic === | ||
352 | |||
353 | can't open device nbd:127.0.0.1:PORT | ||
354 | -no file open, try 'help open' | ||
355 | |||
356 | === Check disconnect after neg-classic === | ||
357 | |||
358 | diff --git a/tests/qemu-iotests/088.out b/tests/qemu-iotests/088.out | ||
359 | index XXXXXXX..XXXXXXX 100644 | ||
360 | --- a/tests/qemu-iotests/088.out | ||
361 | +++ b/tests/qemu-iotests/088.out | ||
362 | @@ -XXX,XX +XXX,XX @@ QA output created by 088 | ||
363 | == Invalid block size == | ||
364 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
365 | can't open device TEST_DIR/t.vpc: Invalid block size 0 | ||
366 | -no file open, try 'help open' | ||
367 | can't open device TEST_DIR/t.vpc: Invalid block size 0 | ||
368 | -no file open, try 'help open' | ||
369 | can't open device TEST_DIR/t.vpc: Invalid block size 128 | ||
370 | -no file open, try 'help open' | ||
371 | can't open device TEST_DIR/t.vpc: Invalid block size 128 | ||
372 | -no file open, try 'help open' | ||
373 | can't open device TEST_DIR/t.vpc: Invalid block size 305419896 | ||
374 | -no file open, try 'help open' | ||
375 | can't open device TEST_DIR/t.vpc: Invalid block size 305419896 | ||
376 | -no file open, try 'help open' | ||
377 | *** done | ||
378 | diff --git a/tests/qemu-iotests/092.out b/tests/qemu-iotests/092.out | ||
379 | index XXXXXXX..XXXXXXX 100644 | ||
380 | --- a/tests/qemu-iotests/092.out | ||
381 | +++ b/tests/qemu-iotests/092.out | ||
382 | @@ -XXX,XX +XXX,XX @@ QA output created by 092 | ||
383 | == Invalid cluster size == | ||
384 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
385 | can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k | ||
386 | -no file open, try 'help open' | ||
387 | can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k | ||
388 | -no file open, try 'help open' | ||
389 | can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k | ||
390 | -no file open, try 'help open' | ||
391 | can't open device TEST_DIR/t.qcow: Cluster size must be between 512 and 64k | ||
392 | -no file open, try 'help open' | ||
393 | |||
394 | == Invalid L2 table size == | ||
395 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
396 | can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k | ||
397 | -no file open, try 'help open' | ||
398 | can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k | ||
399 | -no file open, try 'help open' | ||
400 | can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k | ||
401 | -no file open, try 'help open' | ||
402 | can't open device TEST_DIR/t.qcow: L2 table size must be between 512 and 64k | ||
403 | -no file open, try 'help open' | ||
404 | |||
405 | == Invalid size == | ||
406 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
407 | can't open device TEST_DIR/t.qcow: Image too large | ||
408 | -no file open, try 'help open' | ||
409 | can't open device TEST_DIR/t.qcow: Image too large | ||
410 | -no file open, try 'help open' | ||
411 | |||
412 | == Invalid backing file length == | ||
413 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
414 | can't open device TEST_DIR/t.qcow: Backing file name too long | ||
415 | -no file open, try 'help open' | ||
416 | can't open device TEST_DIR/t.qcow: Backing file name too long | ||
417 | -no file open, try 'help open' | ||
418 | *** done | ||
419 | diff --git a/tests/qemu-iotests/116.out b/tests/qemu-iotests/116.out | ||
420 | index XXXXXXX..XXXXXXX 100644 | ||
421 | --- a/tests/qemu-iotests/116.out | ||
422 | +++ b/tests/qemu-iotests/116.out | ||
423 | @@ -XXX,XX +XXX,XX @@ QA output created by 116 | ||
424 | == truncated header cluster == | ||
425 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
426 | can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument | ||
427 | -no file open, try 'help open' | ||
428 | |||
429 | == invalid header magic == | ||
430 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
431 | can't open device TEST_DIR/t.qed: Image not in QED format | ||
432 | -no file open, try 'help open' | ||
433 | |||
434 | == invalid cluster size == | ||
435 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
436 | can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument | ||
437 | -no file open, try 'help open' | ||
438 | |||
439 | == invalid table size == | ||
440 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
441 | can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument | ||
442 | -no file open, try 'help open' | ||
443 | |||
444 | == invalid header size == | ||
445 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
446 | can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument | ||
447 | -no file open, try 'help open' | ||
448 | |||
449 | == invalid L1 table offset == | ||
450 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
451 | can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument | ||
452 | -no file open, try 'help open' | ||
453 | |||
454 | == invalid image size == | ||
455 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 | ||
456 | can't open device TEST_DIR/t.qed: Could not open 'TEST_DIR/t.qed': Invalid argument | ||
457 | -no file open, try 'help open' | ||
458 | *** done | ||
459 | diff --git a/tests/qemu-iotests/131.out b/tests/qemu-iotests/131.out | ||
460 | index XXXXXXX..XXXXXXX 100644 | ||
461 | --- a/tests/qemu-iotests/131.out | ||
462 | +++ b/tests/qemu-iotests/131.out | ||
463 | @@ -XXX,XX +XXX,XX @@ read 32768/32768 bytes at offset 0 | ||
464 | 32 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
465 | == Corrupt image == | ||
466 | can't open device TEST_DIR/t.parallels: parallels: Image was not closed correctly; cannot be opened read/write | ||
467 | -no file open, try 'help open' | ||
468 | ERROR image was not closed correctly | ||
469 | |||
470 | 1 errors were found on the image. | ||
471 | diff --git a/tests/qemu-iotests/140.out b/tests/qemu-iotests/140.out | ||
472 | index XXXXXXX..XXXXXXX 100644 | ||
473 | --- a/tests/qemu-iotests/140.out | ||
474 | +++ b/tests/qemu-iotests/140.out | ||
475 | @@ -XXX,XX +XXX,XX @@ read 65536/65536 bytes at offset 0 | ||
476 | 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
477 | {"return": {}} | ||
478 | can't open device nbd+unix:///drv?socket=TEST_DIR/nbd: No export with name 'drv' available | ||
479 | -no file open, try 'help open' | ||
480 | {"return": {}} | ||
481 | {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"} | ||
482 | *** done | ||
483 | -- | ||
484 | 2.11.0 | ||
485 | |||
486 | diff view generated by jsdifflib |
1 | From: Nir Soffer <nirsof@gmail.com> | 1 | This adds support for reopen in rbd, for changing between r/w and r/o. |
---|---|---|---|
2 | 2 | ||
3 | This helper allows adding tests supporting any format expect the | 3 | Note, that this is only a flag change, but we will block a change from |
4 | specified formats. This may be useful to test that many formats behave | 4 | r/o to r/w if we are using an RBD internal snapshot. |
5 | in a common way. | ||
6 | 5 | ||
7 | Signed-off-by: Nir Soffer <nirsof@gmail.com> | 6 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> |
8 | Message-id: 20170201003120.23378-3-nirsof@gmail.com | 7 | Signed-off-by: Jeff Cody <jcody@redhat.com> |
9 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 8 | Reviewed-by: John Snow <jsnow@redhat.com> |
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 9 | Message-id: d4e87539167ec6527d44c97b164eabcccf96e4f3.1491597120.git.jcody@redhat.com |
11 | --- | 10 | --- |
12 | tests/qemu-iotests/common.rc | 11 +++++++++++ | 11 | block/rbd.c | 21 +++++++++++++++++++++ |
13 | 1 file changed, 11 insertions(+) | 12 | 1 file changed, 21 insertions(+) |
14 | 13 | ||
15 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | 14 | diff --git a/block/rbd.c b/block/rbd.c |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/tests/qemu-iotests/common.rc | 16 | --- a/block/rbd.c |
18 | +++ b/tests/qemu-iotests/common.rc | 17 | +++ b/block/rbd.c |
19 | @@ -XXX,XX +XXX,XX @@ _supported_fmt() | 18 | @@ -XXX,XX +XXX,XX @@ failed_opts: |
20 | _notrun "not suitable for this image format: $IMGFMT" | 19 | return r; |
21 | } | 20 | } |
22 | 21 | ||
23 | +# tests whether $IMGFMT is one of the unsupported image format for a test | 22 | + |
24 | +# | 23 | +/* Since RBD is currently always opened R/W via the API, |
25 | +_unsupported_fmt() | 24 | + * we just need to check if we are using a snapshot or not, in |
25 | + * order to determine if we will allow it to be R/W */ | ||
26 | +static int qemu_rbd_reopen_prepare(BDRVReopenState *state, | ||
27 | + BlockReopenQueue *queue, Error **errp) | ||
26 | +{ | 28 | +{ |
27 | + for f; do | 29 | + BDRVRBDState *s = state->bs->opaque; |
28 | + if [ "$f" = "$IMGFMT" ]; then | 30 | + int ret = 0; |
29 | + _notrun "not suitable for this image format: $IMGFMT" | 31 | + |
30 | + fi | 32 | + if (s->snap && state->flags & BDRV_O_RDWR) { |
31 | + done | 33 | + error_setg(errp, |
34 | + "Cannot change node '%s' to r/w when using RBD snapshot", | ||
35 | + bdrv_get_device_or_node_name(state->bs)); | ||
36 | + ret = -EINVAL; | ||
37 | + } | ||
38 | + | ||
39 | + return ret; | ||
32 | +} | 40 | +} |
33 | + | 41 | + |
34 | # tests whether $IMGPROTO is one of the supported image protocols for a test | 42 | static void qemu_rbd_close(BlockDriverState *bs) |
35 | # | 43 | { |
36 | _supported_proto() | 44 | BDRVRBDState *s = bs->opaque; |
45 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_rbd = { | ||
46 | .bdrv_parse_filename = qemu_rbd_parse_filename, | ||
47 | .bdrv_file_open = qemu_rbd_open, | ||
48 | .bdrv_close = qemu_rbd_close, | ||
49 | + .bdrv_reopen_prepare = qemu_rbd_reopen_prepare, | ||
50 | .bdrv_create = qemu_rbd_create, | ||
51 | .bdrv_has_zero_init = bdrv_has_zero_init_1, | ||
52 | .bdrv_get_info = qemu_rbd_getinfo, | ||
37 | -- | 53 | -- |
38 | 2.11.0 | 54 | 2.9.3 |
39 | 55 | ||
40 | 56 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | For the tests that use the common.qemu functions for running a QEMU |
---|---|---|---|
2 | process, _cleanup_qemu must be called in the exit function. | ||
2 | 3 | ||
3 | The metadata overlap checks introduced in a40f1c2add help detect | 4 | If it is not, if the qemu process aborts, then not all of the droppings |
4 | corruption in the qcow2 image by verifying that data writes don't | 5 | are cleaned up (e.g. pidfile, fifos). |
5 | overlap with existing metadata sections. | ||
6 | 6 | ||
7 | The 'refcount-block' check in particular iterates over the refcount | 7 | This updates those tests that did not have a cleanup in qemu-iotests. |
8 | table in order to get the addresses of all refcount blocks and check | ||
9 | that none of them overlap with the region where we want to write. | ||
10 | 8 | ||
11 | The problem with the refcount table is that since it always occupies | 9 | (I swapped spaces for tabs in test 102 as well) |
12 | complete clusters its size is usually very big. With the default | ||
13 | values of cluster_size=64KB and refcount_bits=16 this table holds 8192 | ||
14 | entries, each one of them enough to map 2GB worth of host clusters. | ||
15 | 10 | ||
16 | So unless we're using images with several TB of allocated data this | 11 | Reported-by: Eric Blake <eblake@redhat.com> |
17 | table is going to be mostly empty, and iterating over it is a waste of | 12 | Reviewed-by: Eric Blake <eblake@redhat.com> |
18 | CPU. If the storage backend is fast enough this can have an effect on | 13 | Signed-off-by: Jeff Cody <jcody@redhat.com> |
19 | I/O performance. | 14 | Message-id: d59c2f6ad6c1da8b9b3c7f357c94a7122ccfc55a.1492544096.git.jcody@redhat.com |
15 | --- | ||
16 | tests/qemu-iotests/028 | 1 + | ||
17 | tests/qemu-iotests/094 | 11 ++++++++--- | ||
18 | tests/qemu-iotests/102 | 5 +++-- | ||
19 | tests/qemu-iotests/109 | 1 + | ||
20 | tests/qemu-iotests/117 | 1 + | ||
21 | tests/qemu-iotests/130 | 1 + | ||
22 | tests/qemu-iotests/140 | 1 + | ||
23 | tests/qemu-iotests/141 | 1 + | ||
24 | tests/qemu-iotests/143 | 1 + | ||
25 | tests/qemu-iotests/156 | 1 + | ||
26 | 10 files changed, 19 insertions(+), 5 deletions(-) | ||
20 | 27 | ||
21 | This patch keeps the index of the last used (i.e. non-zero) entry in | 28 | diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028 |
22 | the refcount table and updates it every time the table changes. The | 29 | index XXXXXXX..XXXXXXX 100755 |
23 | refcount-block overlap check then uses that index instead of reading | 30 | --- a/tests/qemu-iotests/028 |
24 | the whole table. | 31 | +++ b/tests/qemu-iotests/028 |
25 | 32 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | |
26 | In my tests with a 4GB qcow2 file stored in RAM this doubles the | 33 | |
27 | amount of write IOPS. | 34 | _cleanup() |
28 | 35 | { | |
29 | Signed-off-by: Alberto Garcia <berto@igalia.com> | 36 | + _cleanup_qemu |
30 | Message-id: 20170201123828.4815-1-berto@igalia.com | 37 | rm -f "${TEST_IMG}.copy" |
31 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 38 | _cleanup_test_img |
32 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 39 | } |
33 | --- | 40 | diff --git a/tests/qemu-iotests/094 b/tests/qemu-iotests/094 |
34 | block/qcow2.h | 1 + | 41 | index XXXXXXX..XXXXXXX 100755 |
35 | block/qcow2-refcount.c | 24 +++++++++++++++++++++++- | 42 | --- a/tests/qemu-iotests/094 |
36 | block/qcow2.c | 1 + | 43 | +++ b/tests/qemu-iotests/094 |
37 | 3 files changed, 25 insertions(+), 1 deletion(-) | 44 | @@ -XXX,XX +XXX,XX @@ echo "QA output created by $seq" |
38 | 45 | here="$PWD" | |
39 | diff --git a/block/qcow2.h b/block/qcow2.h | 46 | status=1 # failure is the default! |
40 | index XXXXXXX..XXXXXXX 100644 | 47 | |
41 | --- a/block/qcow2.h | 48 | -trap "exit \$status" 0 1 2 3 15 |
42 | +++ b/block/qcow2.h | 49 | +_cleanup() |
43 | @@ -XXX,XX +XXX,XX @@ typedef struct BDRVQcow2State { | ||
44 | uint64_t *refcount_table; | ||
45 | uint64_t refcount_table_offset; | ||
46 | uint32_t refcount_table_size; | ||
47 | + uint32_t max_refcount_table_index; /* Last used entry in refcount_table */ | ||
48 | uint64_t free_cluster_index; | ||
49 | uint64_t free_byte_offset; | ||
50 | |||
51 | diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/block/qcow2-refcount.c | ||
54 | +++ b/block/qcow2-refcount.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static Qcow2SetRefcountFunc *const set_refcount_funcs[] = { | ||
56 | /*********************************************************/ | ||
57 | /* refcount handling */ | ||
58 | |||
59 | +static void update_max_refcount_table_index(BDRVQcow2State *s) | ||
60 | +{ | 50 | +{ |
61 | + unsigned i = s->refcount_table_size - 1; | 51 | + _cleanup_qemu |
62 | + while (i > 0 && (s->refcount_table[i] & REFT_OFFSET_MASK) == 0) { | 52 | + _cleanup_test_img |
63 | + i--; | 53 | + rm -f "$TEST_DIR/source.$IMGFMT" |
64 | + } | ||
65 | + /* Set s->max_refcount_table_index to the index of the last used entry */ | ||
66 | + s->max_refcount_table_index = i; | ||
67 | +} | 54 | +} |
68 | + | 55 | + |
69 | int qcow2_refcount_init(BlockDriverState *bs) | 56 | +trap "_cleanup; exit \$status" 0 1 2 3 15 |
57 | |||
58 | # get standard environment, filters and checks | ||
59 | . ./common.rc | ||
60 | @@ -XXX,XX +XXX,XX @@ _send_qemu_cmd $QEMU_HANDLE \ | ||
61 | |||
62 | wait=1 _cleanup_qemu | ||
63 | |||
64 | -_cleanup_test_img | ||
65 | -rm -f "$TEST_DIR/source.$IMGFMT" | ||
66 | |||
67 | # success, all done | ||
68 | echo '*** done' | ||
69 | diff --git a/tests/qemu-iotests/102 b/tests/qemu-iotests/102 | ||
70 | index XXXXXXX..XXXXXXX 100755 | ||
71 | --- a/tests/qemu-iotests/102 | ||
72 | +++ b/tests/qemu-iotests/102 | ||
73 | @@ -XXX,XX +XXX,XX @@ seq=$(basename $0) | ||
74 | echo "QA output created by $seq" | ||
75 | |||
76 | here=$PWD | ||
77 | -status=1 # failure is the default! | ||
78 | +status=1 # failure is the default! | ||
79 | |||
80 | _cleanup() | ||
70 | { | 81 | { |
71 | BDRVQcow2State *s = bs->opaque; | 82 | - _cleanup_test_img |
72 | @@ -XXX,XX +XXX,XX @@ int qcow2_refcount_init(BlockDriverState *bs) | 83 | + _cleanup_qemu |
73 | } | 84 | + _cleanup_test_img |
74 | for(i = 0; i < s->refcount_table_size; i++) | 85 | } |
75 | be64_to_cpus(&s->refcount_table[i]); | 86 | trap "_cleanup; exit \$status" 0 1 2 3 15 |
76 | + update_max_refcount_table_index(s); | 87 | |
77 | } | 88 | diff --git a/tests/qemu-iotests/109 b/tests/qemu-iotests/109 |
78 | return 0; | 89 | index XXXXXXX..XXXXXXX 100755 |
79 | fail: | 90 | --- a/tests/qemu-iotests/109 |
80 | @@ -XXX,XX +XXX,XX @@ static int alloc_refcount_block(BlockDriverState *bs, | 91 | +++ b/tests/qemu-iotests/109 |
81 | } | 92 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! |
82 | 93 | ||
83 | s->refcount_table[refcount_table_index] = new_block; | 94 | _cleanup() |
84 | + /* If there's a hole in s->refcount_table then it can happen | 95 | { |
85 | + * that refcount_table_index < s->max_refcount_table_index */ | 96 | + _cleanup_qemu |
86 | + s->max_refcount_table_index = | 97 | rm -f $TEST_IMG.src |
87 | + MAX(s->max_refcount_table_index, refcount_table_index); | 98 | _cleanup_test_img |
88 | 99 | } | |
89 | /* The new refcount block may be where the caller intended to put its | 100 | diff --git a/tests/qemu-iotests/117 b/tests/qemu-iotests/117 |
90 | * data, so let it restart the search. */ | 101 | index XXXXXXX..XXXXXXX 100755 |
91 | @@ -XXX,XX +XXX,XX @@ static int alloc_refcount_block(BlockDriverState *bs, | 102 | --- a/tests/qemu-iotests/117 |
92 | s->refcount_table = new_table; | 103 | +++ b/tests/qemu-iotests/117 |
93 | s->refcount_table_size = table_size; | 104 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! |
94 | s->refcount_table_offset = table_offset; | 105 | |
95 | + update_max_refcount_table_index(s); | 106 | _cleanup() |
96 | 107 | { | |
97 | /* Free old table. */ | 108 | + _cleanup_qemu |
98 | qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t), | 109 | _cleanup_test_img |
99 | @@ -XXX,XX +XXX,XX @@ write_refblocks: | 110 | } |
100 | s->refcount_table = on_disk_reftable; | 111 | trap "_cleanup; exit \$status" 0 1 2 3 15 |
101 | s->refcount_table_offset = reftable_offset; | 112 | diff --git a/tests/qemu-iotests/130 b/tests/qemu-iotests/130 |
102 | s->refcount_table_size = reftable_size; | 113 | index XXXXXXX..XXXXXXX 100755 |
103 | + update_max_refcount_table_index(s); | 114 | --- a/tests/qemu-iotests/130 |
104 | 115 | +++ b/tests/qemu-iotests/130 | |
105 | return 0; | 116 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! |
106 | 117 | ||
107 | @@ -XXX,XX +XXX,XX @@ int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset, | 118 | _cleanup() |
108 | } | 119 | { |
109 | 120 | + _cleanup_qemu | |
110 | if ((chk & QCOW2_OL_REFCOUNT_BLOCK) && s->refcount_table) { | 121 | _cleanup_test_img |
111 | - for (i = 0; i < s->refcount_table_size; i++) { | 122 | } |
112 | + unsigned last_entry = s->max_refcount_table_index; | 123 | trap "_cleanup; exit \$status" 0 1 2 3 15 |
113 | + assert(last_entry < s->refcount_table_size); | 124 | diff --git a/tests/qemu-iotests/140 b/tests/qemu-iotests/140 |
114 | + assert(last_entry + 1 == s->refcount_table_size || | 125 | index XXXXXXX..XXXXXXX 100755 |
115 | + (s->refcount_table[last_entry + 1] & REFT_OFFSET_MASK) == 0); | 126 | --- a/tests/qemu-iotests/140 |
116 | + for (i = 0; i <= last_entry; i++) { | 127 | +++ b/tests/qemu-iotests/140 |
117 | if ((s->refcount_table[i] & REFT_OFFSET_MASK) && | 128 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! |
118 | overlaps_with(s->refcount_table[i] & REFT_OFFSET_MASK, | 129 | |
119 | s->cluster_size)) { | 130 | _cleanup() |
120 | @@ -XXX,XX +XXX,XX @@ int qcow2_change_refcount_order(BlockDriverState *bs, int refcount_order, | 131 | { |
121 | /* Now update the rest of the in-memory information */ | 132 | + _cleanup_qemu |
122 | old_reftable = s->refcount_table; | 133 | _cleanup_test_img |
123 | s->refcount_table = new_reftable; | 134 | rm -f "$TEST_DIR/nbd" |
124 | + update_max_refcount_table_index(s); | 135 | } |
125 | 136 | diff --git a/tests/qemu-iotests/141 b/tests/qemu-iotests/141 | |
126 | s->refcount_bits = 1 << refcount_order; | 137 | index XXXXXXX..XXXXXXX 100755 |
127 | s->refcount_max = UINT64_C(1) << (s->refcount_bits - 1); | 138 | --- a/tests/qemu-iotests/141 |
128 | diff --git a/block/qcow2.c b/block/qcow2.c | 139 | +++ b/tests/qemu-iotests/141 |
129 | index XXXXXXX..XXXXXXX 100644 | 140 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! |
130 | --- a/block/qcow2.c | 141 | |
131 | +++ b/block/qcow2.c | 142 | _cleanup() |
132 | @@ -XXX,XX +XXX,XX @@ static int make_completely_empty(BlockDriverState *bs) | 143 | { |
133 | 144 | + _cleanup_qemu | |
134 | s->refcount_table_offset = s->cluster_size; | 145 | _cleanup_test_img |
135 | s->refcount_table_size = s->cluster_size / sizeof(uint64_t); | 146 | rm -f "$TEST_DIR/{b,m,o}.$IMGFMT" |
136 | + s->max_refcount_table_index = 0; | 147 | } |
137 | 148 | diff --git a/tests/qemu-iotests/143 b/tests/qemu-iotests/143 | |
138 | g_free(s->refcount_table); | 149 | index XXXXXXX..XXXXXXX 100755 |
139 | s->refcount_table = new_reftable; | 150 | --- a/tests/qemu-iotests/143 |
151 | +++ b/tests/qemu-iotests/143 | ||
152 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
153 | |||
154 | _cleanup() | ||
155 | { | ||
156 | + _cleanup_qemu | ||
157 | rm -f "$TEST_DIR/nbd" | ||
158 | } | ||
159 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
160 | diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156 | ||
161 | index XXXXXXX..XXXXXXX 100755 | ||
162 | --- a/tests/qemu-iotests/156 | ||
163 | +++ b/tests/qemu-iotests/156 | ||
164 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
165 | |||
166 | _cleanup() | ||
167 | { | ||
168 | + _cleanup_qemu | ||
169 | rm -f "$TEST_IMG{,.target}{,.backing,.overlay}" | ||
170 | } | ||
171 | trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
140 | -- | 172 | -- |
141 | 2.11.0 | 173 | 2.9.3 |
142 | 174 | ||
143 | 175 | diff view generated by jsdifflib |