1. 17 2月, 2016 12 次提交
    • D
      nbd: use "" as a default export name if none provided · 69b49502
      Daniel P. Berrange 提交于
      If the user does not provide an export name and the server
      is running the new style protocol, where export names are
      mandatory, use "" as the default export name if the user
      has not specified any. "" is defined in the NBD protocol
      as the default name to use in such scenarios.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-13-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      69b49502
    • D
      nbd: always query export list in fixed new style protocol · 9344e5f5
      Daniel P. Berrange 提交于
      With the new style protocol, the NBD client will currenetly
      send NBD_OPT_EXPORT_NAME as the first (and indeed only)
      option it wants. The problem is that the NBD protocol spec
      does not allow for returning an error message with the
      NBD_OPT_EXPORT_NAME option. So if the server mandates use
      of TLS, the client will simply see an immediate connection
      close after issuing NBD_OPT_EXPORT_NAME which is not user
      friendly.
      
      To improve this situation, if we have the fixed new style
      protocol, we can sent NBD_OPT_LIST as the first option
      to query the list of server exports. We can check for our
      named export in this list and raise an error if it is not
      found, instead of going ahead and sending NBD_OPT_EXPORT_NAME
      with a name that we know will be rejected.
      
      This improves the error reporting both in the case that the
      server required TLS, and in the case that the client requested
      export name does not exist on the server.
      
      If the server does not support NBD_OPT_LIST, we just ignore
      that and carry on with NBD_OPT_EXPORT_NAME as before.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-12-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      9344e5f5
    • D
      nbd: allow setting of an export name for qemu-nbd server · 3d4b2f9c
      Daniel P. Berrange 提交于
      The qemu-nbd server currently always uses the old style protocol
      since it never sets any export name. This is a problem because
      future TLS support will require use of the new style protocol
      negotiation.
      
      This adds "--exportname NAME" / "-x NAME" arguments to qemu-nbd
      which allow the user to set an explicit export name. When an
      export name is set the server will always use the new style
      NBD protocol.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-11-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      3d4b2f9c
    • D
      nbd: make client request fixed new style if advertised · e2a9d9a3
      Daniel P. Berrange 提交于
      If the server advertises support for the fixed new style
      negotiation, the client should in turn enable new style.
      This will allow the client to negotiate further NBD
      options besides the export name.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-10-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      e2a9d9a3
    • D
      nbd: make server compliant with fixed newstyle spec · 26afa868
      Daniel P. Berrange 提交于
      If the client does not request the fixed new style protocol,
      then we should only accept NBD_OPT_EXPORT_NAME. All other
      options are only valid when fixed new style has been activated.
      
      The qemu-nbd client doesn't currently request fixed new style
      protocol, but this change won't break qemu-nbd, because it
      fortunately only ever uses NBD_OPT_EXPORT_NAME, so was never
      triggering the non-compliant server behaviour.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-9-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      26afa868
    • D
      nbd: invert client logic for negotiating protocol version · f72d705f
      Daniel P. Berrange 提交于
      The nbd_receive_negotiate() method takes different code
      paths based on whether 'name == NULL', and then checks
      the expected protocol version in each branch.
      
      This patch inverts the logic, so that it takes different
      code paths based on what protocol version it receives and
      then checks if name is NULL or not as needed.
      
      This facilitates later code which allows the client to
      be capable of using the new style protocol regardless
      of whether an export name is listed or not.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-8-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f72d705f
    • D
      nbd: convert to using I/O channels for actual socket I/O · 1c778ef7
      Daniel P. Berrange 提交于
      Now that all callers are converted to use I/O channels for
      initial connection setup, it is possible to switch the core
      NBD protocol handling core over to use QIOChannel APIs for
      actual sockets I/O.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-7-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      1c778ef7
    • D
      nbd: convert blockdev NBD server to use I/O channels for connection setup · ae398278
      Daniel P. Berrange 提交于
      This converts the blockdev NBD server to use the QIOChannelSocket
      class for initial listener socket setup and accepting of client
      connections. Actual I/O is still being performed against the
      socket file descriptor using the POSIX socket APIs.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-6-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      ae398278
    • D
      nbd: convert qemu-nbd server to use I/O channels for connection setup · d0d6ff58
      Daniel P. Berrange 提交于
      This converts the qemu-nbd server to use the QIOChannelSocket
      class for initial listener socket setup and accepting of client
      connections. Actual I/O is still being performed against the
      socket file descriptor using the POSIX socket APIs.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-5-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      d0d6ff58
    • D
      nbd: convert block client to use I/O channels for connection setup · 064097d9
      Daniel P. Berrange 提交于
      This converts the NBD block driver client to use the QIOChannelSocket
      class for initial connection setup. The NbdClientSession struct has
      two pointers, one to the master QIOChannelSocket providing the raw
      data channel, and one to a QIOChannel which is the current channel
      used for I/O. Initially the two point to the same object, but when
      TLS support is added, they will point to different objects.
      
      The qemu-img & qemu-io tools now need to use MODULE_INIT_QOM to
      ensure the QIOChannel object classes are registered. The qemu-nbd
      tool already did this.
      
      In this initial conversion though, all I/O is still actually done
      using the raw POSIX sockets APIs.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-4-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      064097d9
    • D
      qemu-nbd: add support for --object command line arg · 0ab3b337
      Daniel P. Berrange 提交于
      Allow creation of user creatable object types with qemu-nbd
      via a new --object command line arg. This will be used to supply
      passwords and/or encryption keys to the various block driver
      backends via the recently added 'secret' object type.
      
       # printf letmein > mypasswd.txt
       # qemu-nbd --object secret,id=sec0,file=mypasswd.txt \
            ...other nbd args...
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-3-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      0ab3b337
    • D
      qom: add helpers for UserCreatable object types · 90998d58
      Daniel P. Berrange 提交于
      The QMP monitor code has two helper methods object_add
      and qmp_object_del that are called from several places
      in the code (QMP, HMP and main emulator startup).
      
      The HMP and main emulator startup code also share
      further logic that extracts the qom-type & id
      values from a qdict.
      
      We soon need to use this logic from qemu-img, qemu-io
      and qemu-nbd too, but don't want those to depend on
      the monitor, nor do we want to duplicate the code.
      
      To avoid this, move some code out of qmp.c and hmp.c
      adding new methods to qom/object_interfaces.c
      
       - user_creatable_add - takes a QDict holding a full
         object definition & instantiates it
       - user_creatable_add_type - takes an ID, type name,
         and QDict holding object properties & instantiates
         it
       - user_creatable_add_opts - takes a QemuOpts holding
         a full object definition & instantiates it
       - user_creatable_add_opts_foreach - variant on
         user_creatable_add_opts which can be directly used
         in conjunction with qemu_opts_foreach.
       - user_creatable_del - takes an ID and deletes the
         corresponding object
      
      The existing code is updated to use these new methods.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-2-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      90998d58
  2. 16 2月, 2016 12 次提交
  3. 15 2月, 2016 9 次提交
  4. 13 2月, 2016 7 次提交