Skip to contentSkip to conversation

migration: spapr: migrate pending_events of spapr state

PATCH Applied Daniel Henrique Barboza 2 participants 3 messages Jul 11, 2017 – Jul 12, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v15 1/1 migration: spapr: migrate pending_events of spapr state

v15:
- changed default endianess of sPAPREventLogEntry to native
- write the header fields and the extended_log directly in the guest memory

v14:
- several changes made in spapr_events.c to allow for a minimal VMSD to be migrated. Please check the commit message of the patch for more information.

This is the next version of the v13 that was sent a month ago. You can check out the v13 discussions here:

https://lists.nongnu.org/archive/html/qemu-devel/2017-05/msg04992.html

Previous changes:

v13:
- rebased with dgibson/ppc-for-2.10
- patch 1 removed from the series (already applied at ppc-for-2.10)
- data_size is now being calculated by using the extended_length field inside rtas_event_log_queue

v12:
- patch 2: added a switch statement to get the proper data_size based on the log_type

v11:
- patch 1 (new): cleanup of spapr_events.c:
* removed the 'exception' boolean from the sPAPREventLogEntry
* simplified the 'event_scan' function
- patch 2:
* data_size is now calculated inside rtas_event_log_queue()
* using VBUFFER instead of VARRAY to avoid casts
* log_type changed to int32_t

v10: detached from DRC patch set

v9: no changes

v8: no changes

v7: no changes

v6: - Rebased with QEMU master after 6+ months.
class and minor improvements.
- Added clarifications from the previous v5 discussions in the commit
messages.

v5: - Rebased on David's ppc-for-2.8.

v4: - Rebased on David's ppc-for-2.7.

v3: - Simplify overall design followng discussion with Paolo. No longer need
metadata to migrate QTAILQ.
- Extend VMStateInfo instead of adding similar fields to VMStateField.

v2: - Put the newly added migrating fields in subsections so that backward
migration is not broken.
(link: https://lists.nongnu.org/archive/html/qemu-devel/2016-05/msg04188.html)

v1: - Inital version.
(link: https://lists.nongnu.org/archive/html/qemu-devel/2016-04/msg02601.html)

Daniel Henrique Barboza (1):
migration: spapr: migrate pending_events of spapr state

 hw/ppc/spapr.c         |  32 +++++++++++++++
 hw/ppc/spapr_events.c  | 103 +++++++++++++++++++++++++++----------------------
 include/hw/ppc/spapr.h |   9 ++++-
 3 files changed, 96 insertions(+), 48 deletions(-)
Signature · 1 line
2.9.4
#1 lore raw

PATCH v15 1/1 migration: spapr: migrate pending_events of spapr state

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.

---
 hw/ppc/spapr.c         |  32 +++++++++++++++
 hw/ppc/spapr_events.c  | 103 +++++++++++++++++++++++++++----------------------
 include/hw/ppc/spapr.h |   9 ++++-
 3 files changed, 96 insertions(+), 48 deletions(-)
hw/ppc/spapr.c +32 -0
index f4e011c..b3664e3 100644
@@ -1517,6 +1517,37 @@ static bool version_before_3(void *opaque, int version_id)
     return version_id < 3;
 }
 
+static bool spapr_pending_events_needed(void *opaque)
+{
+    sPAPRMachineState *spapr = (sPAPRMachineState *)opaque;
+    return !QTAILQ_EMPTY(&spapr->pending_events);
+}
+
+static const VMStateDescription vmstate_spapr_event_entry = {
+    .name = "spapr_event_log_entry",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT32(header.summary, sPAPREventLogEntry),
+        VMSTATE_UINT32(header.extended_length, sPAPREventLogEntry),
+        VMSTATE_VBUFFER_ALLOC_UINT32(extended_log, sPAPREventLogEntry, 0,
+                                     NULL, header.extended_length),
+        VMSTATE_END_OF_LIST()
+    },
+};
+
+static const VMStateDescription vmstate_spapr_pending_events = {
+    .name = "spapr_pending_events",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = spapr_pending_events_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_QTAILQ_V(pending_events, sPAPRMachineState, 1,
+                         vmstate_spapr_event_entry, sPAPREventLogEntry, next),
+        VMSTATE_END_OF_LIST()
+    },
+};
+
 static bool spapr_ov5_cas_needed(void *opaque)
 {
     sPAPRMachineState *spapr = opaque;
@@ -1615,6 +1646,7 @@ static const VMStateDescription vmstate_spapr = {
     .subsections = (const VMStateDescription*[]) {
         &vmstate_spapr_ov5_cas,
         &vmstate_spapr_patb_entry,
+        &vmstate_spapr_pending_events,
         NULL
     }
 };
hw/ppc/spapr_events.c +57 -46

221 lines not on this page · raw message

include/hw/ppc/spapr.h +7 -2
index a184ffa..48a2cad 100644
@@ -601,9 +601,14 @@ struct sPAPRTCETable {
 
 sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong liobn);
 
+struct rtas_error_log {
+    uint32_t summary;
+    uint32_t extended_length;
+} QEMU_PACKED;
+
 struct sPAPREventLogEntry {
-    int log_type;
-    void *data;
+    struct rtas_error_log header;
+    void *extended_log;
     QTAILQ_ENTRY(sPAPREventLogEntry) next;
 };
 
Signature · 1 line
2.9.4
Applied
#2 lore raw
In reply to Daniel Henrique Barboza

Applied to ppc-for-2.10, though I'm going to make some minor followup cleanups.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson