diff options
author | Eric Blake <eblake@redhat.com> | 2016-07-21 13:34:46 -0600 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-08-03 18:44:56 +0200 |
commit | 7423f417827146f956df820f172d0bf80a489495 (patch) | |
tree | c344d494cc4fab46a7bb1daacb0088bc35e9ee1f /qemu-nbd.c | |
parent | 5bee0f4717c4c67394aaade0c5a9cee3d42cc614 (diff) | |
download | qemu-7423f417827146f956df820f172d0bf80a489495.tar.gz qemu-7423f417827146f956df820f172d0bf80a489495.tar.bz2 qemu-7423f417827146f956df820f172d0bf80a489495.zip |
nbd: Limit nbdflags to 16 bits
Rather than asserting that nbdflags is within range, just give
it the correct type to begin with :) nbdflags corresponds to
the per-export portion of NBD Protocol "transmission flags", which
is 16 bits in response to NBD_OPT_EXPORT_NAME and NBD_OPT_GO.
Furthermore, upstream NBD has never passed the global flags to
the kernel via ioctl(NBD_SET_FLAGS) (the ioctl was first
introduced in NBD 2.9.22; then a latent bug in NBD 3.1 actually
tried to OR the global flags with the transmission flags, with
the disaster that the addition of NBD_FLAG_NO_ZEROES in 3.9
caused all earlier NBD 3.x clients to treat every export as
read-only; NBD 3.10 and later intentionally clip things to 16
bits to pass only transmission flags). Qemu should follow suit,
since the current two global flags (NBD_FLAG_FIXED_NEWSTYLE
and NBD_FLAG_NO_ZEROES) have no impact on the kernel's behavior
during transmission.
CC: qemu-stable@nongnu.org
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1469129688-22848-3-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qemu-nbd.c')
-rw-r--r-- | qemu-nbd.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/qemu-nbd.c b/qemu-nbd.c index 321f02bd15..e3571c2025 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -251,7 +251,7 @@ static void *nbd_client_thread(void *arg) { char *device = arg; off_t size; - uint32_t nbdflags; + uint16_t nbdflags; QIOChannelSocket *sioc; int fd; int ret; @@ -465,7 +465,7 @@ int main(int argc, char **argv) BlockBackend *blk; BlockDriverState *bs; off_t dev_offset = 0; - uint32_t nbdflags = 0; + uint16_t nbdflags = 0; bool disconnect = false; const char *bindto = "0.0.0.0"; const char *port = NULL; |