1. 10 7月, 2017 10 次提交
  2. 15 6月, 2017 13 次提交
  3. 08 6月, 2017 1 次提交
    • E
      nbd: Fully initialize client in case of failed negotiation · df8ad9f1
      Eric Blake 提交于
      If a non-NBD client connects to qemu-nbd, we would end up with
      a SIGSEGV in nbd_client_put() because we were trying to
      unregister the client's association to the export, even though
      we skipped inserting the client into that list.  Easy trigger
      in two terminals:
      
      $ qemu-nbd -p 30001 --format=raw file
      $ nmap 127.0.0.1 -p 30001
      
      nmap claims that it thinks it connected to a pago-services1
      server (which probably means nmap could be updated to learn the
      NBD protocol and give a more accurate diagnosis of the open
      port - but that's not our problem), then terminates immediately,
      so our call to nbd_negotiate() fails.  The fix is to reorder
      nbd_co_client_start() to ensure that all initialization occurs
      before we ever try talking to a client in nbd_negotiate(), so
      that the teardown sequence on negotiation failure doesn't fault
      while dereferencing a half-initialized object.
      
      While debugging this, I also noticed that nbd_update_server_watch()
      called by nbd_client_closed() was still adding a channel to accept
      the next client, even when the state was no longer RUNNING.  That
      is fixed by making nbd_can_accept() pay attention to the current
      state.
      
      Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1451614Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20170527030421.28366-1-eblake@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      df8ad9f1
  4. 07 6月, 2017 5 次提交
  5. 27 3月, 2017 1 次提交
    • P
      nbd-client: fix handling of hungup connections · a12a712a
      Paolo Bonzini 提交于
      After the switch to reading replies in a coroutine, nothing is
      reentering pending receive coroutines if the connection hangs.
      Move nbd_recv_coroutines_enter_all to the reply read coroutine,
      which is the place where hangups are detected.  nbd_teardown_connection
      can simply wait for the reply read coroutine to detect the hangup
      and clean up after itself.
      
      This wouldn't be enough though because nbd_receive_reply returns 0
      (rather than -EPIPE or similar) when reading from a hung connection.
      Fix the return value check in nbd_read_reply_entry.
      
      This fixes qemu-iotests 083.
      Reported-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 20170314111157.14464-1-pbonzini@redhat.com
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      a12a712a
  6. 14 3月, 2017 1 次提交
  7. 01 3月, 2017 3 次提交
  8. 21 2月, 2017 1 次提交
  9. 23 1月, 2017 1 次提交
  10. 04 1月, 2017 1 次提交
  11. 10 11月, 2016 1 次提交
  12. 02 11月, 2016 2 次提交
    • E
      nbd: Implement NBD_CMD_WRITE_ZEROES on server · 1f4d6d18
      Eric Blake 提交于
      Upstream NBD protocol recently added the ability to efficiently
      write zeroes without having to send the zeroes over the wire,
      along with a flag to control whether the client wants to allow
      a hole.
      
      Note that when it comes to requiring full allocation, vs.
      permitting optimizations, the NBD spec intentionally picked a
      different sense for the flag; the rules in qemu are:
      MAY_UNMAP == 0: must write zeroes
      MAY_UNMAP == 1: may use holes if reads will see zeroes
      
      while in NBD, the rules are:
      FLAG_NO_HOLE == 1: must write zeroes
      FLAG_NO_HOLE == 0: may use holes if reads will see zeroes
      
      In all cases, the 'may use holes' scenario is optional (the
      server need not use a hole, and must not use a hole if
      subsequent reads would not see zeroes).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1476469998-28592-16-git-send-email-eblake@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      1f4d6d18
    • E
      nbd: Improve server handling of shutdown requests · b6f5d3b5
      Eric Blake 提交于
      NBD commit 6d34500b clarified how clients and servers are supposed
      to behave before closing a connection. It added NBD_REP_ERR_SHUTDOWN
      (for the server to announce it is about to go away during option
      haggling, so the client should quit sending NBD_OPT_* other than
      NBD_OPT_ABORT) and ESHUTDOWN (for the server to announce it is about
      to go away during transmission, so the client should quit sending
      NBD_CMD_* other than NBD_CMD_DISC).  It also clarified that
      NBD_OPT_ABORT gets a reply, while NBD_CMD_DISC does not.
      
      This patch merely adds the missing reply to NBD_OPT_ABORT and teaches
      the client to recognize server errors.  Actually teaching the server
      to send NBD_REP_ERR_SHUTDOWN or ESHUTDOWN would require knowing that
      the server has been requested to shut down soon (maybe we could do
      that by installing a SIGINT handler in qemu-nbd, which transitions
      from RUNNING to a new state that waits for the client to react,
      rather than just out-right quitting - but that's a bigger task for
      another day).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1476469998-28592-15-git-send-email-eblake@redhat.com>
      [Move dummy ESHUTDOWN to include/qemu/osdep.h. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b6f5d3b5