1. 17 2月, 2016 17 次提交
    • P
      Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging · 3fc63c3f
      Peter Maydell 提交于
      * Coverity fixes for IPMI and mptsas
      * qemu-char fixes from Daniel and Marc-André
      * Bug fixes that break qemu-iotests
      * Changes to fix reset from panicked state
      * checkpatch false positives for designated initializers
      * TLS support in the NBD servers and clients
      
      # gpg: Signature made Tue 16 Feb 2016 16:27:17 GMT using RSA key ID 78C7AE83
      # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>"
      # gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>"
      
      * remotes/bonzini/tags/for-upstream: (28 commits)
        nbd: enable use of TLS with nbd-server-start command
        nbd: enable use of TLS with qemu-nbd server
        nbd: enable use of TLS with NBD block driver
        nbd: implement TLS support in the protocol negotiation
        nbd: use "" as a default export name if none provided
        nbd: always query export list in fixed new style protocol
        nbd: allow setting of an export name for qemu-nbd server
        nbd: make client request fixed new style if advertised
        nbd: make server compliant with fixed newstyle spec
        nbd: invert client logic for negotiating protocol version
        nbd: convert to using I/O channels for actual socket I/O
        nbd: convert blockdev NBD server to use I/O channels for connection setup
        nbd: convert qemu-nbd server to use I/O channels for connection setup
        nbd: convert block client to use I/O channels for connection setup
        qemu-nbd: add support for --object command line arg
        qom: add helpers for UserCreatable object types
        ipmi: sensor number should not exceed MAX_SENSORS
        mptsas: fix wrong formula
        mptsas: fix memory leak
        mptsas: add missing va_end
        ...
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      3fc63c3f
    • D
      nbd: enable use of TLS with nbd-server-start command · ddffee39
      Daniel P. Berrange 提交于
      This modifies the nbd-server-start QMP command so that it
      is possible to request use of TLS. This is done by adding
      a new optional parameter "tls-creds" which provides the ID
      of a previously created QCryptoTLSCreds object instance.
      
      TLS is only supported when using an IPv4/IPv6 socket listener.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-17-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      ddffee39
    • D
      nbd: enable use of TLS with qemu-nbd server · 145614a1
      Daniel P. Berrange 提交于
      This modifies the qemu-nbd program so that it is possible to
      request the use of TLS with the server. It simply adds a new
      command line option --tls-creds which is used to provide the
      ID of a QCryptoTLSCreds object previously created via the
      --object command line option.
      
      For example
      
        qemu-nbd --object tls-creds-x509,id=tls0,endpoint=server,\
                          dir=/home/berrange/security/qemutls \
                 --tls-creds tls0 \
                 --exportname default
      
      TLS requires the new style NBD protocol, so if no export name
      is set (via --export-name), then we use the default NBD protocol
      export name ""
      
      TLS is only supported when using an IPv4/IPv6 socket listener.
      It is not possible to use with UNIX sockets, which includes
      when connecting the NBD server to a host device.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-16-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      145614a1
    • D
      nbd: enable use of TLS with NBD block driver · 75822a12
      Daniel P. Berrange 提交于
      This modifies the NBD driver so that it is possible to request
      use of TLS. This is done by providing the 'tls-creds' parameter
      with the ID of a previously created QCryptoTLSCreds object.
      
      For example
      
        $QEMU -object tls-creds-x509,id=tls0,endpoint=client,\
                      dir=/home/berrange/security/qemutls \
              -drive driver=nbd,host=localhost,port=9000,tls-creds=tls0
      
      The client will drop the connection if the NBD server does not
      provide TLS.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-15-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      75822a12
    • D
      nbd: implement TLS support in the protocol negotiation · f95910fe
      Daniel P. Berrange 提交于
      This extends the NBD protocol handling code so that it is capable
      of negotiating TLS support during the connection setup. This involves
      requesting the STARTTLS protocol option before any other NBD options.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-14-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f95910fe
    • 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 23 次提交