Eric Blake b0245d6478 nbd/server: Advertise actual minimum block size
Both NBD_CMD_BLOCK_STATUS and structured NBD_CMD_READ will split their
reply according to bdrv_block_status() boundaries. If the block device
has a request_alignment smaller than 512, but we advertise a block
alignment of 512 to the client, then this can result in the server
reply violating client expectations by reporting a smaller region of
the export than what the client is permitted to address (although this
is less of an issue for qemu 4.0 clients, given recent client patches
to overlook our non-compliance at EOF).  Since it's always better to
be strict in what we send, it is worth advertising the actual minimum
block limit rather than blindly rounding it up to 512.

Note that this patch is not foolproof - it is still possible to
provoke non-compliant server behavior using:

$ qemu-nbd --image-opts driver=blkdebug,align=512,image.driver=file,image.filename=/path/to/non-aligned-file

That is arguably a bug in the blkdebug driver (it should never pass
back block status smaller than its alignment, even if it has to make
multiple bdrv_get_status calls and determine the
least-common-denominator status among the group to return). It may
also be possible to observe issues with a backing layer with smaller
alignment than the active layer, although so far I have been unable to
write a reliable iotest for that scenario (but again, an issue like
that could be argued to be a bug in the block layer, or something
where we need a flag to bdrv_block_status() to state whether the
result must be aligned to the current layer's limits or can be
subdivided for accuracy when chasing backing files).

Anyways, as blkdebug is not normally used, and as this patch makes our
server more interoperable with qemu 3.1 clients, it is worth applying
now, even while we still work on a larger patch series for the 4.1
timeframe to have byte-accurate file lengths.

Note that the iotests output changes - for 223 and 233, we can see the
server's better granularity advertisement; and for 241, the three test
cases have the following effects:
- natural alignment: the server's smaller alignment is now advertised,
and the hole reported at EOF is now the right result; we've gotten rid
of the server's non-compliance
- forced server alignment: the server still advertises 512 bytes, but
still sends a mid-sector hole. This is still a server compliance bug,
which needs to be fixed in the block layer in a later patch; output
does not change because the client is already being tolerant of the
non-compliance
- forced client alignment: the server's smaller alignment means that
the client now sees the server's status change mid-sector without any
protocol violations, but the fact that the map shows an unaligned
mid-sector hole is evidence of the block layer problems with aligned
block status, to be fixed in a later patch

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190329042750.14704-7-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
[eblake: rebase to enhanced iotest 241 coverage]
2019-04-01 08:52:28 -05:00
..
2018-01-23 12:34:43 +01:00
2017-07-11 17:45:02 +02:00
045
2019-02-25 15:11:28 +01:00
051
2019-03-19 15:51:31 +01:00
055
2018-03-19 12:01:24 +01:00
2018-03-19 12:01:24 +01:00
2018-02-13 12:27:17 +01:00
2015-01-23 12:41:32 -05:00
2017-05-11 12:08:24 +02:00
2017-09-06 15:19:01 +01:00
2018-03-19 14:58:36 -05:00
2018-05-23 14:30:51 +02:00
2018-01-23 12:34:42 +01:00
2018-06-11 16:18:45 +02:00
2017-07-10 13:18:05 +02:00
2017-10-26 15:01:14 +02:00
2018-05-23 13:29:03 +02:00
129
2018-03-09 15:40:07 +01:00
132
2018-03-09 15:40:07 +01:00
2016-05-19 16:45:31 +02:00
139
2019-03-08 12:26:45 +01:00
2018-05-23 14:30:51 +02:00
147
2019-01-31 00:44:55 +01:00
148
2018-03-09 15:40:07 +01:00
2018-06-18 17:05:17 +02:00
152
2018-03-09 15:40:07 +01:00
155
2018-05-23 14:30:51 +02:00
2016-09-20 22:10:57 +02:00
2016-09-20 22:10:57 +02:00
2017-09-26 15:00:32 +02:00
169
2018-10-30 21:13:54 -03:00
2016-09-20 22:10:57 +02:00
2017-09-18 19:43:38 -04:00
2017-02-12 00:47:42 +01:00
194
2018-04-10 16:33:43 +02:00
199
2018-03-13 17:06:32 -04:00
209
2018-03-13 15:44:09 -05:00
210
2019-02-25 15:11:27 +01:00
211
2019-02-25 15:11:28 +01:00
212
2019-02-25 15:11:27 +01:00
213
2019-02-25 15:11:27 +01:00
2018-05-15 16:15:21 +02:00
218
2018-10-26 17:17:32 +02:00
219
2018-06-11 16:18:45 +02:00
222
2018-07-10 11:55:11 +02:00
223
2019-03-09 20:55:44 +00:00
228
2019-02-25 15:11:27 +01:00
2019-02-25 15:11:27 +01:00
232
2019-03-19 15:49:29 +01:00
2019-03-19 15:49:29 +01:00
233
2019-03-09 20:55:44 +00:00
234
2019-02-01 13:46:44 +01:00
2019-02-01 13:46:44 +01:00
235
2019-02-22 14:07:01 -05:00
237
2019-02-25 15:11:27 +01:00
238
2019-03-08 12:26:45 +01:00
239
2019-02-01 13:46:44 +01:00
2019-02-01 13:46:44 +01:00
2019-02-11 14:35:43 -06:00
247
2019-03-19 15:49:29 +01:00
2019-03-19 15:49:29 +01:00
2019-03-08 12:26:45 +01:00

=== This is the QEMU I/O test suite ===

* Intro

This package contains a simple test suite for the I/O layer of qemu.
It does not require a guest, but only the qemu, qemu-img and qemu-io
binaries.  This does limit it to exercise the low-level I/O path only
but no actual block drivers like ide, scsi or virtio.

* Usage

Just run ./check to run all tests for the raw image format, or ./check
-qcow2 to test the qcow2 image format.  The output of ./check -h explains
additional options to test further image formats or I/O methods.

* Feedback and patches

Please send improvements to the test suite, general feedback or just
reports of failing tests cases to qemu-devel@nongnu.org with a CC:
to qemu-block@nongnu.org.