nbd: iotest fixes and error message improvement
PATCH 2/4 iotests: Fix 100 for nbd
In reply to Max ReitzIn case of NBD, _make_test_img starts a new NBD server. Therefore, _cleanup_test_img (which shuts that server down) has to be invoked before the next _make_test_img call in order to make 100 work for NBD.
--- tests/qemu-iotests/100 | 12 ++++++++++++ 1 file changed, 12 insertions(+)
tests/qemu-iotests/100 +12 -0
@@ -55,6 +55,8 @@ echo "== verify pattern ==" $QEMU_IO -c "read -P 0xcd 0 4k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "read -P 0 4k 4k" "$TEST_IMG" | _filter_qemu_io +_cleanup_test_img + echo echo "== Sequential requests ==" _make_test_img $size
@@ -66,6 +68,8 @@ $QEMU_IO -c "read -P 0xcd 0 4k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "read -P 0xce 4k 4k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "read -P 0 8k 4k" "$TEST_IMG" | _filter_qemu_io +_cleanup_test_img + echo echo "== Superset overlapping requests ==" _make_test_img $size
@@ -79,6 +83,8 @@ $QEMU_IO -c "read -P 0xcd 0 1k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "read -P 0xcd 3k 1k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "read -P 0 4k 4k" "$TEST_IMG" | _filter_qemu_io +_cleanup_test_img + echo echo "== Subset overlapping requests ==" _make_test_img $size
@@ -92,6 +98,8 @@ $QEMU_IO -c "read -P 0xce 0 1k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "read -P 0xce 3k 1k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "read -P 0 4k 4k" "$TEST_IMG" | _filter_qemu_io +_cleanup_test_img + echo echo "== Head overlapping requests ==" _make_test_img $size
@@ -104,6 +112,8 @@ echo "== verify pattern ==" $QEMU_IO -c "read -P 0xce 2k 2k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "read -P 0 4k 4k" "$TEST_IMG" | _filter_qemu_io +_cleanup_test_img + echo echo "== Tail overlapping requests ==" _make_test_img $size
@@ -116,6 +126,8 @@ echo "== verify pattern ==" $QEMU_IO -c "read -P 0xce 0k 2k" "$TEST_IMG" | _filter_qemu_io $QEMU_IO -c "read -P 0 4k 4k" "$TEST_IMG" | _filter_qemu_io +_cleanup_test_img + echo echo "== Disjoint requests ==" _make_test_img $size
Signature · 1 line
2.1.0
cover nbd: iotest fixes and error message improvement
This series is a follow-up to my previous patch "iotests: Specify format for qemu-nbd" and as such relies on it.
The first three patches of this series fix the qemu-iotests so they once again pass when using NBD.
The fourth patch of this series improves NBD's error message for establishing connections, especially if the server's and the client's NBD version differs (which, until now, was simply "Bad magic received").
Max Reitz (4):
iotests: Fix 083
iotests: Fix 100 for nbd
iotests: Fix 104 for NBD
nbd: Improve error messages
block/nbd-client.c | 4 +- block/nbd-client.h | 2 +- block/nbd.c | 2 +- include/block/nbd.h | 2 +- nbd.c | 42 ++++++++++++--------- qemu-nbd.c | 7 +++- tests/qemu-iotests/083 | 3 +- tests/qemu-iotests/083.out | 81 ++++++++++++++-------------------------- tests/qemu-iotests/100 | 12 ++++++ tests/qemu-iotests/104 | 9 ++--- tests/qemu-iotests/common.filter | 1 + 11 files changed, 82 insertions(+), 83 deletions(-)
Signature · 1 line
2.1.0
PATCH 3/4 iotests: Fix 104 for NBD
_make_test_img sets up an NBD server, _cleanup_test_img shuts it down; thus, _cleanup_test_img has to be called before _make_test_img is invoked another time.
Furthermore, the pipe through _filter_test_img was unnecessary; _make_test_img already takes care of that.
And finally, a filter is added to _filter_img_info to replace "nbd://127.0.0.1:10810" by "TEST_DIR/t.IMGFMT", since the former is the way to express the full image path (normally the latter) for NBD tests.
--- tests/qemu-iotests/104 | 9 +++------ tests/qemu-iotests/common.filter | 1 + 2 files changed, 4 insertions(+), 6 deletions(-)
tests/qemu-iotests/104 +3 -6
@@ -28,11 +28,7 @@ here=`pwd` tmp=/tmp/$$ status=1 # failure is the default! -_cleanup() -{ - _cleanup_test_img -} -trap "_cleanup; exit \$status" 0 1 2 3 15 +trap "exit \$status" 0 1 2 3 15 # get standard environment, filters and checks . ./common.rc
@@ -47,8 +43,9 @@ echo image_sizes="1024 1234" for s in $image_sizes; do - _make_test_img $s | _filter_img_create + _make_test_img $s _img_info | _filter_img_info + _cleanup_test_img done # success, all done
tests/qemu-iotests/common.filter +1 -0
@@ -200,6 +200,7 @@ _filter_img_info() sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ -e "s#$TEST_DIR#TEST_DIR#g" \ -e "s#$IMGFMT#IMGFMT#g" \ + -e 's#nbd://127.0.0.1:10810$#TEST_DIR/t.IMGFMT#g' \ -e "/encrypted: yes/d" \ -e "/cluster_size: [0-9]\\+/d" \ -e "/table_size: [0-9]\\+/d" \
Signature · 1 line
2.1.0
PATCH 1/4 iotests: Fix 083
In reply to Max ReitzAs of 8f9e835fd2e687d2bfe936819c3494af4343614d, probing should be disabled in the qemu-iotests (at least when using qemu-io). This broke 083's reference output (which consisted mostly of "Could not read image for determining its format").
This patch fixes it.
Note that one case which failed before is now successful: Disconnect after data. This is due to qemu having read twice before (once for probing, once for the qemu-io read command), but only once now (the qemu-io read command). Therefore, reading is successful (which is correct).
--- tests/qemu-iotests/083.out | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-)
tests/qemu-iotests/083.out +11 -19
@@ -62,8 +62,7 @@ no file open, try 'help open' === Check disconnect after neg2 === -qemu-io: can't open device nbd:127.0.0.1:PORT:exportname=foo: Could not read image for determining its format: Input/output error -no file open, try 'help open' +read failed: Input/output error === Check disconnect 8 neg2 ===
@@ -80,49 +79,43 @@ no file open, try 'help open' === Check disconnect before request === -qemu-io: can't open device nbd:127.0.0.1:PORT:exportname=foo: Could not read image for determining its format: Input/output error -no file open, try 'help open' +read failed: Input/output error === Check disconnect after request === -qemu-io: can't open device nbd:127.0.0.1:PORT:exportname=foo: Could not read image for determining its format: Input/output error -no file open, try 'help open' +read failed: Input/output error === Check disconnect before reply === -qemu-io: can't open device nbd:127.0.0.1:PORT:exportname=foo: Could not read image for determining its format: Input/output error -no file open, try 'help open' +read failed: Input/output error === Check disconnect after reply === -qemu-io: can't open device nbd:127.0.0.1:PORT:exportname=foo: Could not read image for determining its format: Input/output error -no file open, try 'help open' +read failed: Input/output error === Check disconnect 4 reply === -qemu-io: can't open device nbd:127.0.0.1:PORT:exportname=foo: Could not read image for determining its format: Input/output error -no file open, try 'help open' +read failed: Input/output error === Check disconnect 8 reply === -qemu-io: can't open device nbd:127.0.0.1:PORT:exportname=foo: Could not read image for determining its format: Input/output error -no file open, try 'help open' +read failed: Input/output error === Check disconnect before data === -qemu-io: can't open device nbd:127.0.0.1:PORT:exportname=foo: Could not read image for determining its format: Input/output error -no file open, try 'help open' +read failed: Input/output error === Check disconnect after data === -read failed: Input/output error +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) === Check disconnect before neg-classic ===
@@ -157,7 +150,6 @@ no file open, try 'help open' === Check disconnect after neg-classic === -qemu-io: can't open device nbd:127.0.0.1:PORT: Could not read image for determining its format: Input/output error -no file open, try 'help open' +read failed: Input/output error *** done
Signature · 1 line
2.1.0
PATCH 4/4 nbd: Improve error messages
In reply to Max ReitzThis patch makes use of the Error object for nbd_receive_negotiate() so that errors during negotiation look nicer.
Furthermore, this patch adds an additional error message if the received magic was wrong, but would be correct for the other protocol version,
respectively: So if an export name was specified, but the NBD server magic corresponds to an old handshake, this condition is explicitly signaled to the user, and vice versa.
As these messages are now part of the "Could not open image" error message, additional filtering has to be employed in iotest 083, which this patch does as well.
--- block/nbd-client.c | 4 ++-- block/nbd-client.h | 2 +- block/nbd.c | 2 +- include/block/nbd.h | 2 +- nbd.c | 42 ++++++++++++++++++++++---------------- qemu-nbd.c | 7 ++++++- tests/qemu-iotests/083 | 3 ++- tests/qemu-iotests/083.out | 51 ++++++++++++++++------------------------------ 8 files changed, 55 insertions(+), 58 deletions(-)
block/nbd-client.c +2 -2
@@ -373,7 +373,7 @@ void nbd_client_session_close(NbdClientSession *client) }int nbd_client_session_init (NbdClientSession *client,BlockDriverState *bs, -int sock,const char *export) +int sock,const char *export,Error **errp) {int ret;
@@ -382,7 +382,7 @@ int nbd_client_session_init(NbdClientSession *client, BlockDriverState *bs,qemu_set_block (sock); ret =nbd_receive_negotiate (sock, export, &client->nbdflags, &client->size, - &client->blocksize); + &client->blocksize, errp);if (ret <0 ) {logout ("Failed to negotiate with the NBD server\n" );closesocket (sock);
block/nbd-client.h +1 -1
@@ -36,7 +36,7 @@ typedef struct NbdClientSession { } NbdClientSession;int nbd_client_session_init (NbdClientSession *client,BlockDriverState *bs, -int sock,const char *export_name); +int sock,const char *export_name,Error **errp);void nbd_client_session_close (NbdClientSession *client); int nbd_client_session_co_discard(NbdClientSession *client, int64_t sector_num,
block/nbd.c +1 -1
@@ -271,7 +271,7 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, }/* NBD handshake */ - result =nbd_client_session_init (&s->client, bs, sock, export); + result =nbd_client_session_init (&s->client, bs, sock, export, errp);g_free (export);return result; }
include/block/nbd.h +1 -1
@@ -75,7 +75,7 @@ enum {ssize_t nbd_wr_sync (int fd,void *buffer,size_t size,bool do_read);int nbd_receive_negotiate (int csock,const char *name,uint32_t *flags, -off_t *size,size_t *blocksize); +off_t *size,size_t *blocksize,Error **errp);int nbd_init (int fd,int csock,uint32_t flags,off_t size,size_t blocksize);ssize_t nbd_send_request (int csock,struct nbd_request *request);ssize_t nbd_receive_reply (int csock,struct nbd_reply *reply);
nbd.c +25 -17
128 lines not on this page · raw message
qemu-nbd.c +6 -1
@@ -284,6 +284,7 @@ static void *nbd_client_thread(void *arg)int fd, sock;int ret;pthread_t show_parts_thread; +Error *local_error =NULL ; sock =unix_socket_outgoing (sockpath);if (sock <0 ) {
@@ -291,8 +292,12 @@ static void *nbd_client_thread(void *arg) } ret =nbd_receive_negotiate (sock,NULL , &nbdflags, - &size, &blocksize); + &size, &blocksize, &local_error);if (ret <0 ) { +if (local_error) { +fprintf (stderr,"%s\n" ,error_get_pretty (local_error)); +error_free (local_error); + } goto out_socket; }
tests/qemu-iotests/083 +2 -1
@@ -56,7 +56,8 @@ filter_nbd() { # # Filter out the TCP port number since this changes between runs. sed -e 's#^.*nbd\.c:.*##g' \ - -e 's#nbd:127\.0\.0\.1:[^:]*:#nbd:127\.0\.0\.1:PORT:#g' + -e 's#nbd:127\.0\.0\.1:[^:]*:#nbd:127\.0\.0\.1:PORT:#g' \ + -e 's#\(exportname=foo\|PORT\): Failed to .*$#\1#' } check_disconnect() {
tests/qemu-iotests/083.out +17 -34
125 lines not on this page · raw message
Signature · 1 line
2.1.0
Quoted 9 lines · Max Reitz
This series is a follow-up to my previous patch "iotests: Specify format for qemu-nbd" and as such relies on it.
The first three patches of this series fix the qemu-iotests so they once again pass when using NBD.
The fourth patch of this series improves NBD's error message for establishing connections, especially if the server's and the client's NBD version differs (which, until now, was simply "Bad magic received").
Good idea!
Quoted 6 lines
Max Reitz (4):
iotests: Fix 083
iotests: Fix 100 for nbd
iotests: Fix 104 for NBD
nbd: Improve error messages
Quoted 13 lines
block/nbd-client.c | 4 +- block/nbd-client.h | 2 +- block/nbd.c | 2 +- include/block/nbd.h | 2 +- nbd.c | 42 ++++++++++++--------- qemu-nbd.c | 7 +++- tests/qemu-iotests/083 | 3 +- tests/qemu-iotests/083.out | 81 ++++++++++++++-------------------------- tests/qemu-iotests/100 | 12 ++++++ tests/qemu-iotests/104 | 9 ++--- tests/qemu-iotests/common.filter | 1 + 11 files changed, 82 insertions(+), 83 deletions(-)
Kevin Wolf
AppliedAm 27.01.2015 um 03:02 hat Max Reitz geschrieben:
Quoted 9 lines
This series is a follow-up to my previous patch "iotests: Specify format for qemu-nbd" and as such relies on it.
The first three patches of this series fix the qemu-iotests so they once again pass when using NBD.
The fourth patch of this series improves NBD's error message for establishing connections, especially if the server's and the client's NBD version differs (which, until now, was simply "Bad magic received").
Thanks, applied to the block branch.
Kevin