1. 17 7月, 2017 7 次提交
    • D
      spapr: Abort on delete failure in spapr_drc_release() · ba50822f
      David Gibson 提交于
      We currently ignore errors from the object_property_del() in
      spapr_drc_release().  But the only way that could fail is if the property
      doesn't exist, in which case it's a bug that we're in spapr_drc_release()
      at all.  So change from ignoring to abort()ing on errors.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      ba50822f
    • D
      spapr: Simplify unplug path · 765d1bdd
      David Gibson 提交于
      spapr_lmb_release() and spapr_core_release() call hotplug_handler_unplug()
      which after a bunch of indirection calls spapr_memory_unplug() or
      spapr_core_unplug().  But we already know which is the appropriate thing
      to call here, so we can just fold it directly into the release function.
      
      Once that's done, there's no need for an hc->unplug method in the spapr
      machine at all: since we also have an hc->unplug_request method, the
      hotplug core will never use ->unplug.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Tested-by: NDaniel Barboza <danielhb@linux.vnet.ibm.com>
      765d1bdd
    • D
      spapr: Remove 'awaiting_allocation' DRC flag · 82a93a1d
      David Gibson 提交于
      The awaiting_allocation flag in the DRC was introduced by aab99135
      "spapr_drc: Prevent detach racing against attach for CPU DR", allegedly to
      prevent a guest crash on racing attach and detach.  Except.. information
      from the BZ actually suggests a qemu crash, not a guest crash.  And there
      shouldn't be a problem here anyway: if the guest has already moved the DRC
      away from UNUSABLE state, the detach would already be deferred, and if it
      hadn't it should be safe to detach it (the guest should fail gracefully
      when it attempts to change the allocation state).
      
      I think this was probably just a bandaid for some other problem in the
      state management.  So, remove awaiting_allocation and associated code.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Tested-by: NGreg Kurz <groug@kaod.org>
      Tested-by: NDaniel Barboza <danielhb@linux.vnet.ibm.com>
      82a93a1d
    • L
      spapr: Treat devices added before inbound migration as coldplugged · 94fd9cba
      Laurent Vivier 提交于
      When migrating a guest which has already had devices hotplugged,
      libvirt typically starts the destination qemu with -incoming defer,
      adds those hotplugged devices with qmp, then initiates the incoming
      migration.
      
      This causes problems for the management of spapr DRC state.  Because
      the device is treated as hotplugged, it goes into a DRC state for a
      device immediately after it's plugged, but before the guest has
      acknowledged its presence.  However, chances are the guest on the
      source machine *has* acknowledged the device's presence and configured
      it.
      
      If the source has fully configured the device, then DRC state won't be
      sent in the migration stream: for maximum migration compatibility with
      earlier versions we don't migrate DRCs in coldplug-equivalent state.
      That means that the DRC effectively changes state over the migrate,
      causing problems later on.
      
      In addition, logging hotplug events for these devices isn't what we
      want because a) those events should already have been issued on the
      source host and b) the event queue should get wiped out by the
      incoming state anyway.
      
      In short, what we really want is to treat devices added before an
      incoming migration as if they were coldplugged.
      
      To do this, we first add a spapr_drc_hotplugged() helper which
      determines if the device is hotplugged in the sense relevant for DRC
      state management.  We only send hotplug events when this is true.
      Second, when we add a device which isn't hotplugged in this sense, we
      force a reset of the DRC state - this ensures the DRC is in a
      coldplug-equivalent state (there isn't usually a system reset between
      these device adds and the incoming migration).
      
      This is based on an earlier patch by Laurent Vivier, cleaned up and
      extended.
      Signed-off-by: NLaurent Vivier <lvivier@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Tested-by: NDaniel Barboza <danielhb@linux.vnet.ibm.com>
      94fd9cba
    • D
      spapr: Minor cleanups to events handling · 5341258e
      David Gibson 提交于
      The rtas_error_log structure is marked packed, which strongly suggests its
      precise layout is important to match an external interface.  Along with
      that one could expect it to have a fixed endianness to match the same
      interface.  That used to be the case - matching the layout of PAPR RTAS
      event format and requiring BE fields.
      
      Now, however, it's only used embedded within sPAPREventLogEntry with the
      fields in native order, since they're processed internally.
      
      Clear that up by removing the nested structure in sPAPREventLogEntry.
      struct rtas_error_log is moved back to spapr_events.c where it is used as
      a temporary to help convert the fields in sPAPREventLogEntry to the correct
      in memory format when delivering an event to the guest.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      5341258e
    • D
      spapr: migrate pending_events of spapr state · fd38804b
      Daniel Henrique Barboza 提交于
      In racing situations between hotplug events and migration operation,
      a rtas hotplug event could have not yet be delivered to the source
      guest when migration is started. In this case the pending_events of
      spapr state need be transmitted to the target so that the hotplug
      event can be finished on the target.
      
      To achieve the minimal VMSD possible to migrate the pending_events list,
      this patch makes the changes in spapr_events.c:
      
      - 'log_type' of sPAPREventLogEntry struct deleted. This information can be
      derived by inspecting the rtas_error_log summary field. A new function
      called 'spapr_event_log_entry_type' was added to retrieve the type of
      a given sPAPREventLogEntry.
      
      - sPAPREventLogEntry, epow_log_full and hp_log_full were redesigned. The
      only data we're going to migrate in the VMSD is the event log data itself,
      which can be divided in two parts: a rtas_error_log header and an extended
      event log field. The rtas_error_log header contains information about the
      size of the extended log field, which can be used inside VMSD as the size
      parameter of the VBUFFER_ALOC field that will store it. To allow this use,
      the header.extended_length field must be exposed inline to the VMSD instead
      of embedded into a 'data' field that holds everything. With this in mind,
      the following changes were done:
      
          * a new 'header' field was added to sPAPREventLogEntry. This field holds a
      a struct rtas_error_log inline.
          * the declaration of the 'rtas_error_log' struct was moved to spapr.h
      to be visible to the VMSD macros.
          * 'data' field of sPAPREventLogEntry was renamed to 'extended_log' and
      now holds only the contents of the extended event log.
         *  'struct rtas_error_log hdr' were taken away from both epow_log_full
      and hp_log_full. This information is now available at the header field of
      sPAPREventLogEntry.
         * epow_log_full and hp_log_full were renamed to epow_extended_log and
      hp_extended_log respectively. This rename makes it clearer to understand
      the new purpose of both structures: hold the information of an extended
      event log field.
          * spapr_powerdown_req and spapr_hotplug_req_event now creates a
      sPAPREventLogEntry structure that contains the full rtas log entry.
          * rtas_event_log_queue and rtas_event_log_dequeue now receives a
      sPAPREventLogEntry pointer as a parameter instead of a void pointer.
      
      - the endianess of the sPAPREventLogEntry header is now native instead
      of be32. We can use the fields in native endianess internally and write
      them in be32 in the guest physical memory inside 'check_exception'. This
      allows the VMSD inside spapr.c to read the correct size of the
      entended_log field.
      
      - inside spapr.c, pending_events is put in a subsection in the spapr state
      VMSD to make sure migration across different versions is not broken.
      
      A small change in rtas_event_log_queue and rtas_event_log_dequeue were also
      made: instead of calling qdev_get_machine(), both functions now receive
      a pointer to the sPAPRMachineState. This pointer is already available in
      the callers of these functions and we don't need to waste resources
      calling qdev() again.
      Signed-off-by: NDaniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      fd38804b
    • D
      spapr: Remove unnecessary instance_size specifications from DRC subtypes · 3579d606
      David Gibson 提交于
      All the DRC subtypes explicitly list instance_size in TypeInfo (all as
      sizeof(sPAPRDRConnector).  This isn't necessary, since if it's not listed
      it will be derived from the parent type.
      
      Worse, this is dangerous, because if a subtype is changed in future to
      have a larger structure, then subtypes of that subtype also need to have
      instance_size changed, or it will lead to hard to track memory corruption
      bugs.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      3579d606
  2. 15 7月, 2017 1 次提交
  3. 14 7月, 2017 32 次提交