+ chunk->length > sizeof(context_id) + wide * sizeof(count) + len) {
trace_nbd_parse_blockstatus_compliance("more than one extent");
}
if (extent->length > orig_length) {
@@ -1117,7 +1127,7 @@ static int coroutine_fn
nbd_co_receive_cmdread_reply(BDRVNBDState *s, uint64_t h
static int coroutine_fn nbd_co_receive_blockstatus_reply(BDRVNBDState *s,
uint64_t handle,
uint64_t length,
- NBDExtent *extent,
+ NBDExtentExt *extent,
int *request_ret,
Error **errp)
{
NBDReplyChunkIter iter;
@@ -1125,6 +1135,7 @@ static int coroutine_fn
nbd_co_receive_blockstatus_reply(BDRVNBDState *s,
void *payload = NULL;
Error *local_err = NULL;
bool received = false;
+ bool wide = false;
assert(!extent->length);
NBD_FOREACH_REPLY_CHUNK(s, iter, handle, false, NULL, &reply, &payload) {
@@ -1134,7 +1145,13 @@ static int coroutine_fn
nbd_co_receive_blockstatus_reply(BDRVNBDState *s,
assert(nbd_reply_is_structured(&reply));
switch (chunk->type) {
+ case NBD_REPLY_TYPE_BLOCK_STATUS_EXT:
+ wide = true;
+ /* fallthrough */
case NBD_REPLY_TYPE_BLOCK_STATUS:
+ if (s->info.extended_headers != wide) {
+ trace_nbd_extended_headers_compliance("block_status");
You set wide to true once, on first "NBD_REPLY_TYPE_BLOCK_STATUS_EXT", and then parse
following "NBD_REPLY_TYPE_BLOCK_STATUS" if the come with wide=true.
Should it be:
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -1135,7 +1135,7 @@ static int coroutine_fn
nbd_co_receive_blockstatus_reply(BDRVNBDState *s,
void *payload = NULL;
Error *local_err = NULL;
bool received = false;
- bool wide = false;
+ bool wide;
assert(!extent->length);
NBD_FOREACH_REPLY_CHUNK(s, iter, handle, false, NULL, &reply, &payload) {
@@ -1146,9 +1146,8 @@ static int coroutine_fn
nbd_co_receive_blockstatus_reply(BDRVNBDState *s,
switch (chunk->type) {
case NBD_REPLY_TYPE_BLOCK_STATUS_EXT:
- wide = true;
- /* fallthrough */
case NBD_REPLY_TYPE_BLOCK_STATUS:
+ wide = chunk->type == NBD_REPLY_TYPE_BLOCK_STATUS_EXT;
if (s->info.extended_headers != wide) {