1. 17 2月, 2016 25 次提交
    • D
      migration: ensure htab_save_first completes after timeout · 378bc217
      David Gibson 提交于
      htab_save_first_pass could return without finishing its work due to
      timeout. The patch checks if another invocation of it is necessary and
      will call it in htab_save_complete if necessary.
      Signed-off-by: NJianjun Duan <duanj@linux.vnet.ibm.com>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      [removed overlong line]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      378bc217
    • D
      target-ppc: Remove hack for ppc_hash64_load_hpte*() with HV KVM · fa48b432
      David Gibson 提交于
      With HV KVM, the guest's hash page table (HPT) is managed by the kernel and
      not directly accessible to QEMU.  This means that spapr->htab is NULL
      and normally env->external_htab would also be NULL for each cpu.
      
      However, that would cause ppc_hash64_load_hpte*() to do the wrong thing in
      the few cases where QEMU does need to load entries from the in-kernel HPT.
      Specifically, seeing external_htab is NULL, they would look for an HPT
      within the guest's address space instead.
      
      To stop that we have an ugly hack in the pseries machine type code to
      set external htab to (void *)1 instead.
      
      This patch removes that hack by having ppc_hash64_load_hpte*() explicitly
      check kvmppc_kern_htab instead, which makes more sense.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      fa48b432
    • D
      pseries: Move hash page table allocation to reset time · c5f54f3e
      David Gibson 提交于
      At the moment the size of the hash page table (HPT) is fixed based on the
      maximum memory allowed to the guest.  As such, we allocate the table during
      machine construction, and just clear it at reset.
      
      However, we're planning to implement a PAPR extension allowing the hash
      page table to be resized at runtime.  This will mean that on reset we want
      to revert it to the default size.  It also means that when migrating, we
      need to make sure the destination allocates an HPT of size matching the
      host, since the guest could have changed it before the migration.
      
      This patch replaces the spapr_alloc_htab() and spapr_reset_htab() functions
      with a new spapr_reallocate_hpt() function.  This is called at reset and
      inbound migration only, not during machine init any more.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      c5f54f3e
    • D
      pseries: Add helper to calculate recommended hash page table size · 8dfe8e7f
      David Gibson 提交于
      At present we calculate the recommended hash page table (HPT) size for a
      pseries guest just once in ppc_spapr_init() before allocating the HPT.
      In future patches we're going to want this calculation in other places, so
      this splits it out into a helper function.  While we're at it, change the
      calculation to use ctz() instead of an explicit loop.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      8dfe8e7f
    • D
      pseries: Simplify handling of the hash page table fd · 715c5407
      David Gibson 提交于
      When migrating the 'pseries' machine type with KVM, we use a special fd
      to access the hash page table stored within KVM.  Usually, this fd is
      opened at the beginning of migration, and kept open until the migration
      is complete.
      
      However, if there is a guest reset during the migration, the fd can become
      stale and we need to re-open it.  At the moment we use an 'htab_fd_stale'
      flag in sPAPRMachineState to signal this, which is checked in the migration
      iterators.
      
      But that's rather ugly.  It's simpler to just close and invalidate the
      fd on reset, and lazily re-open it in migration if necessary.  This patch
      implements that change.
      
      This requires a small addition to the machine state's instance_init,
      so that htab_fd is initialized to -1 (telling the migration code it
      needs to open it) instead of 0, which could be a valid fd.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      715c5407
    • D
      target-ppc: Include missing MMU models for SDR1 in info registers · 808bc3b0
      David Gibson 提交于
      The HMP command "info registers" produces somewhat different information on
      different ppc cpu variants.  For those with a hash MMU it's supposed to
      include the SDR1, DAR and DSISR registers related to the MMU.  However,
      the switch is missing a couple of MMU model variants, meaning we will
      miss out this information on certain CPUs which should have it.
      
      This patch corrects the oversight.  (Really these MMU model IDs need a big
      cleanup, but we might as well fix the bug in the interim).
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      808bc3b0
    • D
      target-ppc: Remove unused kvmppc_update_sdr1() stub · b7f0bbd2
      David Gibson 提交于
      This KVM stub implementation isn't used anywhere.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      b7f0bbd2
    • A
      2f448e41
    • 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 15 次提交