1. 06 7月, 2017 1 次提交
  2. 05 7月, 2017 2 次提交
  3. 04 7月, 2017 20 次提交
  4. 30 6月, 2017 17 次提交
    • S
      virtio-pci: use ioeventfd even when KVM is disabled · c324fd0a
      Stefan Hajnoczi 提交于
      Old kvm.ko versions only supported a tiny number of ioeventfds so
      virtio-pci avoids ioeventfds when kvm_has_many_ioeventfds() returns 0.
      
      Do not check kvm_has_many_ioeventfds() when KVM is disabled since it
      always returns 0.  Since commit 8c56c1a5
      ("memory: emulate ioeventfd") it has been possible to use ioeventfds in
      qtest or TCG mode.
      
      This patch makes -device virtio-blk-pci,iothread=iothread0 work even
      when KVM is disabled.
      
      I have tested that virtio-blk-pci works under TCG both with and without
      iothread.
      
      This patch fixes qemu-iotests 068, which was accidentally merged early
      despite the dependency on ioeventfd.
      
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Tested-by: NEric Blake <eblake@redhat.com>
      Tested-by: NKevin Wolf <kwolf@redhat.com>
      Message-id: 20170628184724.21378-7-stefanha@redhat.com
      Message-id: 20170615163813.7255-2-stefanha@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      c324fd0a
    • D
      spapr: Clean up DRC set_isolation_state() path · 0dfabd39
      David Gibson 提交于
      There are substantial differences in the various paths through
      set_isolation_state(), both for setting to ISOLATED versus UNISOLATED
      state and for logical versus physical DRCs.
      
      So, split the set_isolation_state() method into isolate() and unisolate()
      methods, and give it different implementations for the two DRC types.
      
      Factor some minimal common checks, including for valid indicator values
      (which we weren't previously checking) into rtas_set_isolation_state().
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      0dfabd39
    • D
      spapr: Clean up DRC set_allocation_state path · 61736732
      David Gibson 提交于
      The allocation-state indicator should only actually be implemented for
      "logical" DRCs, not physical ones.  Factor a check for this, and also for
      valid indicator state values into rtas_set_allocation_state().  Because
      they don't exist for physical DRCs, there's no reason that we'd ever want
      more than one method implementation, so it can just be a plain function.
      
      In addition, the setting to USABLE and setting to UNUSABLE paths in
      set_allocation_state() don't actually have much in common.  So, split the
      method separate functions for each parameter value (drc_set_usable()
      and drc_set_unusable()).
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      61736732
    • D
      spapr: Make DRC reset force DRC into known state · 4f9242fc
      David Gibson 提交于
      The reset handler for DRCs attempts several state transitions which are
      subject to various checks and restrictions.  But at reset time we know
      there is no guest, so we can ignore most of the usual sequencing rules and
      just set the DRC back to a known state.  In fact, it's safer to do so.
      
      The existing code also has several redundant checks for
      drc->awaiting_release inside a block which has already tested that.  This
      patch removes those and sets the DRC to a fixed initial state based only
      on whether a device is currently plugged or not.
      
      With DRCs correctly reset to a state based on device presence, we don't
      need to force state transitions as cold plugged devices are processed.
      This allows us to remove all the callers of the set_*_state() methods from
      outside spapr_drc.c.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      4f9242fc
    • D
      spapr: Split DRC release from DRC detach · 9c914e53
      David Gibson 提交于
      spapr_drc_detach() is called when qemu generic code requests a device be
      unplugged.  It makes a number of tests, which could well delay further
      action until later, before actually detach the device from the DRC.
      
      This splits out the part which actually removes the device from the DRC
      into spapr_drc_release().  This will be useful for further cleanups.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      9c914e53
    • D
      spapr: Eliminate DRC 'signalled' state variable · 307b7715
      David Gibson 提交于
      The 'signalled' field in the DRC appears to be entirely a torturous
      workaround for the fact that PCI devices were started in UNISOLATED state
      for unclear reasons.
      
      1) 'signalled' is already meaningless for logical (so far, all non PCI)
      DRCs.  It's always set to true (at least at any point it might be tested),
      and can't be assigned any real meaning due to the way signalling works for
      logical DRCs.
      
      2) For PCI DRCs, the only time signalled would be false is when non-zero
      functions of a multifunction device are hotplugged, followed by function
      zero (the other way around is explicitly not permitted). In that case the
      secondary function DRCs are attached, but the notification isn't sent to
      the guest until function 0 is plugged.
      
      3) signalled being false is used to allow a DRC detach to switch mode
      back to ISOLATED state, which allows a secondary function to be hotplugged
      then unplugged with function 0 never inserted.  Without this a secondary
      function starting in UNISOLATED state couldn't be detached again without
      function 0 being inserted, all the functions configured by the guest, then
      sent back to ISOLATED state.
      
      4) But now that PCI DRCs start in ISOLATED state, there's nothing to be
      done.  If the guest doesn't get the notification, it won't switch the
      device to UNISOLATED state, so nothing prevents it from being unplugged.
      If the guest does move it to UNISOLATED state without the signal (due to
      a manual drmgr call, for instance) then it really isn't safe to unplug it.
      
      So, this patch removes the signalled variable and all code related to it.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      307b7715
    • D
      spapr: Start hotplugged PCI devices in ISOLATED state · af8ad96b
      David Gibson 提交于
      PCI DRCs, and only PCI DRCs, are immediately moved to UNISOLATED isolation
      state once the device is attached.  This has been there from the initial
      implementation, and it's not clear why.
      
      The state diagram in PAPR 13.4 suggests PCI devices should start in
      ISOLATED state until the guest moves them into UNISOLATED, and the code in
      the guest-side drmgr tool seems to work that way too.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      af8ad96b
    • A
      target-ppc: Enable open-pic timers to count and generate interrupts · ddd5140b
      Aaron Larson 提交于
      Previously QEMU open-pic implemented the 4 open-pic timers including
      all timer registers, but the timers did not "count" or generate any
      interrupts.  The patch makes the timers both count and generate
      interrupts.  The timer clock frequency is fixed at 25MHZ.
      
      --
      
      Responding to V2 patch comments.
      - Simplify clock frequency logic and commentary.
      - Remove camelCase variables.
      - Timer objects now created at init rather than lazily.
      Signed-off-by: NAaron Larson <alarson@ddci.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      ddd5140b
    • D
      hw/ppc/spapr.c: consecutive 'spapr->patb_entry = 0' statements · aca8bf9f
      Daniel Henrique Barboza 提交于
      In ppc_spapr_reset(), if the guest is using HPT, the code was executing:
      
          } else {
              spapr->patb_entry = 0;
              spapr_setup_hpt_and_vrma(spapr);
          }
      
      And, at the end of spapr_setup_hpt_and_vrma:
      
          /* We're setting up a hash table, so that means we're not radix */
          spapr->patb_entry = 0;
      
      Resulting in spapr->patb_entry being assigned to 0 twice in a row.
      
      Given that 'spapr_setup_hpt_and_vrma' is also called inside
      'spapr_check_setup_free_hpt' of spapr_hcall.c, this trivial patch removes
      the 'patb_entry = 0' assignment from the 'else' clause inside ppc_spapr_reset
      to avoid this behavior.
      Signed-off-by: NDaniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      aca8bf9f
    • B
      spapr: prevent QEMU crash when CPU realization fails · 6595ab31
      Bharata B Rao 提交于
      ICPState objects were being allocated before CPU thread realization.
      However commit 9ed65663 (xics: setup cpu at realize time) reversed it
      by allocating ICPState objects after CPU thread is realized. But it
      didn't take care to fix the error path because of which we observe
      a SIGSEGV when CPU thread realization fails during cold/hotplug.
      
      Fix this by ensuring that we do object_unparent() of ICPState object
      only in case when is was created earlier.
      Signed-off-by: NBharata B Rao <bharata@linux.vnet.ibm.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      6595ab31
    • G
      spapr: fix migration of ICPState objects from/to older QEMU · 46f7afa3
      Greg Kurz 提交于
      Commit 5bc8d26d ("spapr: allocate the ICPState object from under
      sPAPRCPUCore") moved ICPState objects from the machine to CPU cores.
      This is an improvement since we no longer allocate ICPState objects
      that will never be used. But it has the side-effect of breaking
      migration of older machine types from older QEMU versions.
      
      This patch allows spapr to register dummy "icp/server" entries to vmstate.
      These entries use a dedicated VMStateDescription that can swallow and
      discard state of an incoming migration stream, and that don't send anything
      on outgoing migration.
      
      As for real ICPState objects, the instance_id is the cpu_index of the
      corresponding vCPU, which happens to be equal to the generated instance_id
      of older machine types.
      
      The machine can unregister/register these entries when CPUs are dynamically
      plugged/unplugged.
      
      This is only available for pseries-2.9 and older machines, thanks to a
      compat property.
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      46f7afa3
    • G
      xics: directly register ICPState objects to vmstate · c95f6161
      Greg Kurz 提交于
      The ICPState objects are currently registered to vmstate as qdev objects.
      Their instance ids are hence computed automatically in the migration code,
      and thus depends on the order the CPU cores were plugged.
      
      If the destination had its CPU cores plugged in a different order than the
      source, then ICPState objects will have different instance_ids and load
      the wrong state.
      
      Since CPU objects have a reliable cpu_index which is already used as
      instance_id in vmstate, let's use it for ICPState as well.
      
      Please note that this doesn't break migration. Older machine types used to
      allocate and realize all ICPState objects at machine init time, for the whole
      lifetime of the machine. The qdev instance ids are thus 0,1,2... nr_servers
      and happen to map to the vCPU indexes.
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      c95f6161
    • B
      spapr: Fix migration of Radix guests · d39c90f5
      Bharata B Rao 提交于
      Fix migration of radix guests by ensuring that we issue
      KVM_PPC_CONFIGURE_V3_MMU for radix case post migration.
      Reported-by: NNageswara R Sastry <rnsastry@linux.vnet.ibm.com>
      Signed-off-by: NBharata B Rao <bharata@linux.vnet.ibm.com>
      Reviewed-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      d39c90f5
    • B
      spapr: Add a "no HPT" encoding to HTAB migration stream · 3a384297
      Bharata B Rao 提交于
      Add a "no HPT" encoding (using value -1) to the HTAB migration
      stream (in the place of HPT size) when the guest doesn't allocate HPT.
      This will help the target side to match target HPT with the source HPT
      and thus enable successful migration.
      Suggested-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NBharata B Rao <bharata@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      3a384297
    • D
      ppc: Rework CPU compatibility testing across migration · d5fc133e
      David Gibson 提交于
      Migrating between different CPU versions is a bit complicated for ppc.
      A long time ago, we ensured identical CPU versions at either end by
      checking the PVR had the same value.  However, this breaks under KVM
      HV, because we always have to use the host's PVR - it's not
      virtualized.  That would mean we couldn't migrate between hosts with
      different PVRs, even if the CPUs are close enough to compatible in
      practice (sometimes identical cores with different surrounding logic
      have different PVRs, so this happens in practice quite often).
      
      So, we removed the PVR check, but instead checked that several flags
      indicating supported instructions matched.  This turns out to be a bad
      idea, because those instruction masks are not architected information, but
      essentially a TCG implementation detail.  So changes to qemu internal CPU
      modelling can break migration - this happened between qemu-2.6 and
      qemu-2.7.  That was addressed by 146c11f1 "target-ppc: Allow eventual
      removal of old migration mistakes".
      
      Now, verification of CPU compatibility across a migration basically doesn't
      happen.  We simply ignore the PVR of the incoming migration, and hope the
      cpu on the destination is close enough to work.
      
      Now that we've cleaned up handling of processor compatibility modes
      for pseries machine type, we can do better.  For new machine types
      (pseries-2.10+) We allow migration if:
      
          * The source and destination PVRs are for the same type of CPU, as
            determined by CPU class's pvr_match function
      OR  * When the source was in a compatibility mode, and the destination CPU
            supports the same compatibility mode
      
      For older machine types we retain the existing behaviour - current CAS
      code will usually set a compat mode which would break backwards
      migration if we made them use the new behaviour. [Fixed from an
      earlier version by Greg Kurz].
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      Tested-by: NAndrea Bolognani <abologna@redhat.com>
      d5fc133e
    • D
      pseries: Reset CPU compatibility mode · 66d5c492
      David Gibson 提交于
      Currently, the CPU compatibility mode is set when the cpu is initialized,
      then again when the guest negotiates features.  This means if a guest
      negotiates a compatibility mode, then reboots, that compatibility mode
      will be retained across the reset.
      
      Usually that will get overridden when features are negotiated on the next
      boot, but it's still not really correct.  This patch moves the initial set
      up of the compatibility mode from cpu init to reset time.  The mode *is*
      retained if the reboot was caused by the feature negotiation (it might
      be important in that case, though it's unlikely).
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Tested-by: NAndrea Bolognani <abologna@redhat.com>
      66d5c492
    • D
      pseries: Move CPU compatibility property to machine · 7843c0d6
      David Gibson 提交于
      Server class POWER CPUs have a "compat" property, which is used to set the
      backwards compatibility mode for the processor.  However, this only makes
      sense for machine types which don't give the guest access to hypervisor
      privilege - otherwise the compatibility level is under the guest's control.
      
      To reflect this, this removes the CPU 'compat' property and instead
      creates a 'max-cpu-compat' property on the pseries machine.  Strictly
      speaking this breaks compatibility, but AFAIK the 'compat' option was
      never (directly) used with -device or device_add.
      
      The option was used with -cpu.  So, to maintain compatibility, this
      patch adds a hack to the cpu option parsing to strip out any compat
      options supplied with -cpu and set them on the machine property
      instead of the now deprecated cpu property.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Tested-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Tested-by: NGreg Kurz <groug@kaod.org>
      Tested-by: NAndrea Bolognani <abologna@redhat.com>
      7843c0d6