1. 10 11月, 2017 6 次提交
    • E
      nbd-client: Stricter enforcing of structured reply spec · b4176cb3
      Eric Blake 提交于
      Ensure that the server is not sending unexpected chunk lengths
      for either the NONE or the OFFSET_DATA chunk, nor unexpected
      hole length for OFFSET_HOLE.  This will flag any server as
      broken that responds to a zero-length read with an OFFSET_DATA
      (what our server currently does, but that's about to be fixed)
      or with OFFSET_HOLE, even though we previously fixed our client
      to never be able to send such a request over the wire.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20171108215703.9295-7-eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      b4176cb3
    • E
      nbd-client: Short-circuit 0-length operations · 9d8f818c
      Eric Blake 提交于
      The NBD spec was recently clarified to state that clients should
      not send 0-length requests to the server, as the server behavior
      is undefined [1].  We know that qemu-nbd's behavior is a successful
      no-op (once it has filtered for read-only exports), but other NBD
      implementations might return an error.  To avoid any questionable
      server implementations, it is better to just short-circuit such
      requests on the client side (we are relying on the block layer to
      already filter out requests such as invalid offset, write to a
      read-only volume, and so forth); do the short-circuit as late as
      possible to still benefit from protections from assertions that
      the block layer is not violating our assumptions.
      
      [1] https://github.com/NetworkBlockDevice/nbd/commit/ee926037Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20171108215703.9295-6-eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      9d8f818c
    • E
      nbd: Fix struct name for structured reads · efdc0c10
      Eric Blake 提交于
      A closer read of the NBD spec shows that a structured reply chunk
      for a hole is not quite identical to the prefix of a data chunk,
      because the hole has to also send a 32-bit size field.  Although
      we do not yet send holes, we should fix the misleading information
      in our header and make it easier for a future patch to support
      sparse reads.  Messed up in commit bae245d1.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20171108215703.9295-5-eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      efdc0c10
    • E
      nbd/client: Nicer trace of structured reply · 079d3266
      Eric Blake 提交于
      It's useful to know which structured reply chunk is being processed.
      Missed in commit d2febedb.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20171108215703.9295-4-eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      079d3266
    • E
      nbd-client: Refuse read-only client with BDRV_O_RDWR · 1104d83c
      Eric Blake 提交于
      The NBD spec says that clients should not try to write/trim to
      an export advertised as read-only by the server.  But we failed
      to check that, and would allow the block layer to use NBD with
      BDRV_O_RDWR even when the server is read-only, which meant we
      were depending on the server sending a proper EPERM failure for
      various commands, and also exposes a leaky abstraction: using
      qemu-io in read-write mode would succeed on 'w -z 0 0' because
      of local short-circuiting logic, but 'w 0 0' would send a
      request over the wire (where it then depends on the server, and
      fails at least for qemu-nbd but might pass for other NBD
      implementations).
      
      With this patch, a client MUST request read-only mode to access
      a server that is doing a read-only export, or else it will get
      a message like:
      
      can't open device nbd://localhost:10809/foo: request for write access conflicts with read-only export
      
      It is no longer possible to even attempt writes over the wire
      (including the corner case of 0-length writes), because the block
      layer enforces the explicit read-only request; this matches the
      behavior of qcow2 when backed by a read-only POSIX file.
      
      Fix several iotests to comply with the new behavior (since
      qemu-nbd of an internal snapshot, as well as nbd-server-add over QMP,
      default to a read-only export, we must tell blockdev-add/qemu-io to
      set up a read-only client).
      
      CC: qemu-stable@nongnu.org
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20171108215703.9295-3-eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      1104d83c
    • E
      nbd-client: Fix error message typos · e659fb3b
      Eric Blake 提交于
      Provide missing spaces that are required when using string
      concatenation to break error messages across source lines.
      Introduced in commit f140e300.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20171108215703.9295-2-eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      e659fb3b
  2. 09 11月, 2017 1 次提交
    • V
      nbd/server: fix nbd_negotiate_handle_info · 46321d6b
      Vladimir Sementsov-Ogievskiy 提交于
      namelen should be here, length is unrelated, and always 0 at this
      point.  Broken in introduction in commit f37708f6, but mostly
      harmless (replying with '' as the name does not violate protocol,
      and does not confuse qemu as the nbd client since our implementation
      does not ask for the name; but might confuse some other client that
      does ask for the name especially if the default export is different
      than the export name being queried).
      
      Adding an assert makes it obvious that we are not skipping any bytes
      in the client's message, as well as making it obvious that we were
      using the wrong variable.
      Signed-off-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      CC: qemu-stable@nongnu.org
      Message-Id: <20171101154204.27146-1-vsementsov@virtuozzo.com>
      [eblake: improve commit message, squash in assert addition]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      46321d6b
  3. 08 11月, 2017 1 次提交
  4. 07 11月, 2017 19 次提交
  5. 06 11月, 2017 12 次提交
  6. 05 11月, 2017 1 次提交