* [Qemu-devel] [PATCH v11 0/2] pseries: migrate pending_events of spapr state
@ 2017-05-18 20:24 Daniel Henrique Barboza
2017-05-18 20:24 ` [Qemu-devel] [PATCH v11 1/2] hw/ppc/spapr_events.c: removing 'exception' from sPAPREventLogEntry Daniel Henrique Barboza
2017-05-18 20:24 ` [Qemu-devel] [PATCH v11 2/2] migration: spapr: migrate pending_events of spapr state Daniel Henrique Barboza
0 siblings, 2 replies; 6+ messages in thread
From: Daniel Henrique Barboza @ 2017-05-18 20:24 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, david, mdroth
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)
This patch was detached from the patchset:
"[PATCH v9 0/6] migration/ppc: migrating DRC, ccs_list and pending_events"
Because it is independent and has use outside of the scope of the
pseries DRC migration patchset.
Daniel Henrique Barboza (1):
hw/ppc/spapr_events.c: removing 'exception' from sPAPREventLogEntry
Jianjun Duan (1):
migration: spapr: migrate pending_events of spapr state
hw/ppc/spapr.c | 32 ++++++++++++++++++++++++++++++
hw/ppc/spapr_events.c | 53 ++++++++------------------------------------------
include/hw/ppc/spapr.h | 4 ++--
3 files changed, 42 insertions(+), 47 deletions(-)
--
2.9.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v11 1/2] hw/ppc/spapr_events.c: removing 'exception' from sPAPREventLogEntry
2017-05-18 20:24 [Qemu-devel] [PATCH v11 0/2] pseries: migrate pending_events of spapr state Daniel Henrique Barboza
@ 2017-05-18 20:24 ` Daniel Henrique Barboza
2017-05-19 2:26 ` David Gibson
2017-05-18 20:24 ` [Qemu-devel] [PATCH v11 2/2] migration: spapr: migrate pending_events of spapr state Daniel Henrique Barboza
1 sibling, 1 reply; 6+ messages in thread
From: Daniel Henrique Barboza @ 2017-05-18 20:24 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, david, mdroth
Currenty we do not have any RTAS event that is reported by the
event-scan interface. The existing events, RTAS_LOG_TYPE_EPOW and
RTAS_LOG_TYPE_HOTPLUG, are being reported by the check-exception
interface and, as such, marked as 'exception=true'.
Commit 79853e18d9, 'spapr_events: event-scan RTAS interface', added
the event_scan interface because the guest kernel requires it to
initialize other required interfaces. It is acting since then as
a stub because no events that would be reported by it were added
since then. However, the existence of the 'exception' boolean adds
an unnecessary load in the future migration of the pending_events,
sPAPREventLogEntry QTAILQ that hosts the pending RTAS events.
To make the code cleaner and ease the future migration changes, this
patch makes the following changes:
- remove the 'exception' boolean that filter these events. There is
nothing to filter since all events are reported by check-exception;
- functions rtas_event_log_queue, rtas_event_log_dequeue and
rtas_event_log_contains don't receive the 'exception' boolean
as parameter;
- event_scan function was simplified. It was calling
'rtas_event_log_dequeue(mask, false)' that was always returning
'NULL' because we have no events that are created with
exception=false, thus in the end it would execute a jump to
'out_no_events' all the time. The function now assumes that
this will always be the case and all the remaining logic were
deleted.
In the future, when or if we add new RTAS events that should
be reported with the event_scan interface, we can refer to
the changes made in this patch to add the event_scan logic
back.
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
---
hw/ppc/spapr_events.c | 52 +++++++-------------------------------------------
include/hw/ppc/spapr.h | 1 -
2 files changed, 7 insertions(+), 46 deletions(-)
diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index f0b28d8..73e2a18 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -342,20 +342,18 @@ static int rtas_event_log_to_irq(sPAPRMachineState *spapr, int log_type)
return source->irq;
}
-static void rtas_event_log_queue(int log_type, void *data, bool exception)
+static void rtas_event_log_queue(int log_type, void *data)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
sPAPREventLogEntry *entry = g_new(sPAPREventLogEntry, 1);
g_assert(data);
entry->log_type = log_type;
- entry->exception = exception;
entry->data = data;
QTAILQ_INSERT_TAIL(&spapr->pending_events, entry, next);
}
-static sPAPREventLogEntry *rtas_event_log_dequeue(uint32_t event_mask,
- bool exception)
+static sPAPREventLogEntry *rtas_event_log_dequeue(uint32_t event_mask)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
sPAPREventLogEntry *entry = NULL;
@@ -364,10 +362,6 @@ static sPAPREventLogEntry *rtas_event_log_dequeue(uint32_t event_mask,
const sPAPREventSource *source =
rtas_event_log_to_source(spapr, entry->log_type);
- if (entry->exception != exception) {
- continue;
- }
-
if (source->mask & event_mask) {
break;
}
@@ -380,7 +374,7 @@ static sPAPREventLogEntry *rtas_event_log_dequeue(uint32_t event_mask,
return entry;
}
-static bool rtas_event_log_contains(uint32_t event_mask, bool exception)
+static bool rtas_event_log_contains(uint32_t event_mask)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
sPAPREventLogEntry *entry = NULL;
@@ -389,10 +383,6 @@ static bool rtas_event_log_contains(uint32_t event_mask, bool exception)
const sPAPREventSource *source =
rtas_event_log_to_source(spapr, entry->log_type);
- if (entry->exception != exception) {
- continue;
- }
-
if (source->mask & event_mask) {
return true;
}
@@ -479,7 +469,7 @@ static void spapr_powerdown_req(Notifier *n, void *opaque)
epow->event_modifier = RTAS_LOG_V6_EPOW_MODIFIER_NORMAL;
epow->extended_modifier = RTAS_LOG_V6_EPOW_XMODIFIER_PARTITION_SPECIFIC;
- rtas_event_log_queue(RTAS_LOG_TYPE_EPOW, new_epow, true);
+ rtas_event_log_queue(RTAS_LOG_TYPE_EPOW, new_epow);
qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr),
rtas_event_log_to_irq(spapr,
@@ -572,7 +562,7 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action,
cpu_to_be32(drc_id->count_indexed.index);
}
- rtas_event_log_queue(RTAS_LOG_TYPE_HOTPLUG, new_hp, true);
+ rtas_event_log_queue(RTAS_LOG_TYPE_HOTPLUG, new_hp);
qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr),
rtas_event_log_to_irq(spapr,
@@ -667,7 +657,7 @@ static void check_exception(PowerPCCPU *cpu, sPAPRMachineState *spapr,
xinfo |= (uint64_t)rtas_ld(args, 6) << 32;
}
- event = rtas_event_log_dequeue(mask, true);
+ event = rtas_event_log_dequeue(mask);
if (!event) {
goto out_no_events;
}
@@ -690,7 +680,7 @@ static void check_exception(PowerPCCPU *cpu, sPAPRMachineState *spapr,
* interrupts.
*/
for (i = 0; i < EVENT_CLASS_MAX; i++) {
- if (rtas_event_log_contains(EVENT_CLASS_MASK(i), true)) {
+ if (rtas_event_log_contains(EVENT_CLASS_MASK(i))) {
const sPAPREventSource *source =
spapr_event_sources_get_source(spapr->event_sources, i);
@@ -710,38 +700,10 @@ static void event_scan(PowerPCCPU *cpu, sPAPRMachineState *spapr,
target_ulong args,
uint32_t nret, target_ulong rets)
{
- uint32_t mask, buf, len, event_len;
- sPAPREventLogEntry *event;
- struct rtas_error_log *hdr;
-
if (nargs != 4 || nret != 1) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
}
-
- mask = rtas_ld(args, 0);
- buf = rtas_ld(args, 2);
- len = rtas_ld(args, 3);
-
- event = rtas_event_log_dequeue(mask, false);
- if (!event) {
- goto out_no_events;
- }
-
- hdr = event->data;
- event_len = be32_to_cpu(hdr->extended_length) + sizeof(*hdr);
-
- if (event_len < len) {
- len = event_len;
- }
-
- cpu_physical_memory_write(buf, event->data, len);
- rtas_st(rets, 0, RTAS_OUT_SUCCESS);
- g_free(event->data);
- g_free(event);
- return;
-
-out_no_events:
rtas_st(rets, 0, RTAS_OUT_NO_ERRORS_FOUND);
}
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 5802f88..02239a5 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -598,7 +598,6 @@ sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong liobn);
struct sPAPREventLogEntry {
int log_type;
- bool exception;
void *data;
QTAILQ_ENTRY(sPAPREventLogEntry) next;
};
--
2.9.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v11 2/2] migration: spapr: migrate pending_events of spapr state
2017-05-18 20:24 [Qemu-devel] [PATCH v11 0/2] pseries: migrate pending_events of spapr state Daniel Henrique Barboza
2017-05-18 20:24 ` [Qemu-devel] [PATCH v11 1/2] hw/ppc/spapr_events.c: removing 'exception' from sPAPREventLogEntry Daniel Henrique Barboza
@ 2017-05-18 20:24 ` Daniel Henrique Barboza
2017-05-19 2:32 ` David Gibson
1 sibling, 1 reply; 6+ messages in thread
From: Daniel Henrique Barboza @ 2017-05-18 20:24 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, david, mdroth
From: Jianjun Duan <duanj@linux.vnet.ibm.com>
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.
All the different fields of the events are encoded as defined by
PAPR. We can migrate them as uint8_t binary stream without any
concerns about data padding or endianess.
pending_events is put in a subsection in the spapr state VMSD to make
sure migration across different versions is not broken.
Signed-off-by: Jianjun Duan <duanj@linux.vnet.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
---
hw/ppc/spapr.c | 32 ++++++++++++++++++++++++++++++++
hw/ppc/spapr_events.c | 1 +
include/hw/ppc/spapr.h | 3 ++-
3 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 0980d73..5afd328 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1444,6 +1444,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_INT32(log_type, sPAPREventLogEntry),
+ VMSTATE_UINT32(data_size, sPAPREventLogEntry),
+ VMSTATE_VBUFFER_ALLOC_UINT32(data, sPAPREventLogEntry, 0,
+ NULL, data_size),
+ 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;
@@ -1542,6 +1573,7 @@ static const VMStateDescription vmstate_spapr = {
.subsections = (const VMStateDescription*[]) {
&vmstate_spapr_ov5_cas,
&vmstate_spapr_patb_entry,
+ &vmstate_spapr_pending_events,
NULL
}
};
diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index 73e2a18..96c1605 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -350,6 +350,7 @@ static void rtas_event_log_queue(int log_type, void *data)
g_assert(data);
entry->log_type = log_type;
entry->data = data;
+ entry->data_size = sizeof(*data);
QTAILQ_INSERT_TAIL(&spapr->pending_events, entry, next);
}
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 02239a5..0554e11 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -597,8 +597,9 @@ struct sPAPRTCETable {
sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong liobn);
struct sPAPREventLogEntry {
- int log_type;
+ int32_t log_type;
void *data;
+ uint32_t data_size;
QTAILQ_ENTRY(sPAPREventLogEntry) next;
};
--
2.9.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v11 1/2] hw/ppc/spapr_events.c: removing 'exception' from sPAPREventLogEntry
2017-05-18 20:24 ` [Qemu-devel] [PATCH v11 1/2] hw/ppc/spapr_events.c: removing 'exception' from sPAPREventLogEntry Daniel Henrique Barboza
@ 2017-05-19 2:26 ` David Gibson
0 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2017-05-19 2:26 UTC (permalink / raw)
To: Daniel Henrique Barboza; +Cc: qemu-devel, qemu-ppc, mdroth
[-- Attachment #1: Type: text/plain, Size: 7773 bytes --]
On Thu, May 18, 2017 at 05:24:01PM -0300, Daniel Henrique Barboza wrote:
> Currenty we do not have any RTAS event that is reported by the
> event-scan interface. The existing events, RTAS_LOG_TYPE_EPOW and
> RTAS_LOG_TYPE_HOTPLUG, are being reported by the check-exception
> interface and, as such, marked as 'exception=true'.
>
> Commit 79853e18d9, 'spapr_events: event-scan RTAS interface', added
> the event_scan interface because the guest kernel requires it to
> initialize other required interfaces. It is acting since then as
> a stub because no events that would be reported by it were added
> since then. However, the existence of the 'exception' boolean adds
> an unnecessary load in the future migration of the pending_events,
> sPAPREventLogEntry QTAILQ that hosts the pending RTAS events.
>
> To make the code cleaner and ease the future migration changes, this
> patch makes the following changes:
>
> - remove the 'exception' boolean that filter these events. There is
> nothing to filter since all events are reported by check-exception;
>
> - functions rtas_event_log_queue, rtas_event_log_dequeue and
> rtas_event_log_contains don't receive the 'exception' boolean
> as parameter;
>
> - event_scan function was simplified. It was calling
> 'rtas_event_log_dequeue(mask, false)' that was always returning
> 'NULL' because we have no events that are created with
> exception=false, thus in the end it would execute a jump to
> 'out_no_events' all the time. The function now assumes that
> this will always be the case and all the remaining logic were
> deleted.
>
> In the future, when or if we add new RTAS events that should
> be reported with the event_scan interface, we can refer to
> the changes made in this patch to add the event_scan logic
> back.
>
> Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Applied to ppc-for-2.10.
> ---
> hw/ppc/spapr_events.c | 52 +++++++-------------------------------------------
> include/hw/ppc/spapr.h | 1 -
> 2 files changed, 7 insertions(+), 46 deletions(-)
>
> diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
> index f0b28d8..73e2a18 100644
> --- a/hw/ppc/spapr_events.c
> +++ b/hw/ppc/spapr_events.c
> @@ -342,20 +342,18 @@ static int rtas_event_log_to_irq(sPAPRMachineState *spapr, int log_type)
> return source->irq;
> }
>
> -static void rtas_event_log_queue(int log_type, void *data, bool exception)
> +static void rtas_event_log_queue(int log_type, void *data)
> {
> sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
> sPAPREventLogEntry *entry = g_new(sPAPREventLogEntry, 1);
>
> g_assert(data);
> entry->log_type = log_type;
> - entry->exception = exception;
> entry->data = data;
> QTAILQ_INSERT_TAIL(&spapr->pending_events, entry, next);
> }
>
> -static sPAPREventLogEntry *rtas_event_log_dequeue(uint32_t event_mask,
> - bool exception)
> +static sPAPREventLogEntry *rtas_event_log_dequeue(uint32_t event_mask)
> {
> sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
> sPAPREventLogEntry *entry = NULL;
> @@ -364,10 +362,6 @@ static sPAPREventLogEntry *rtas_event_log_dequeue(uint32_t event_mask,
> const sPAPREventSource *source =
> rtas_event_log_to_source(spapr, entry->log_type);
>
> - if (entry->exception != exception) {
> - continue;
> - }
> -
> if (source->mask & event_mask) {
> break;
> }
> @@ -380,7 +374,7 @@ static sPAPREventLogEntry *rtas_event_log_dequeue(uint32_t event_mask,
> return entry;
> }
>
> -static bool rtas_event_log_contains(uint32_t event_mask, bool exception)
> +static bool rtas_event_log_contains(uint32_t event_mask)
> {
> sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
> sPAPREventLogEntry *entry = NULL;
> @@ -389,10 +383,6 @@ static bool rtas_event_log_contains(uint32_t event_mask, bool exception)
> const sPAPREventSource *source =
> rtas_event_log_to_source(spapr, entry->log_type);
>
> - if (entry->exception != exception) {
> - continue;
> - }
> -
> if (source->mask & event_mask) {
> return true;
> }
> @@ -479,7 +469,7 @@ static void spapr_powerdown_req(Notifier *n, void *opaque)
> epow->event_modifier = RTAS_LOG_V6_EPOW_MODIFIER_NORMAL;
> epow->extended_modifier = RTAS_LOG_V6_EPOW_XMODIFIER_PARTITION_SPECIFIC;
>
> - rtas_event_log_queue(RTAS_LOG_TYPE_EPOW, new_epow, true);
> + rtas_event_log_queue(RTAS_LOG_TYPE_EPOW, new_epow);
>
> qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr),
> rtas_event_log_to_irq(spapr,
> @@ -572,7 +562,7 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action,
> cpu_to_be32(drc_id->count_indexed.index);
> }
>
> - rtas_event_log_queue(RTAS_LOG_TYPE_HOTPLUG, new_hp, true);
> + rtas_event_log_queue(RTAS_LOG_TYPE_HOTPLUG, new_hp);
>
> qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr),
> rtas_event_log_to_irq(spapr,
> @@ -667,7 +657,7 @@ static void check_exception(PowerPCCPU *cpu, sPAPRMachineState *spapr,
> xinfo |= (uint64_t)rtas_ld(args, 6) << 32;
> }
>
> - event = rtas_event_log_dequeue(mask, true);
> + event = rtas_event_log_dequeue(mask);
> if (!event) {
> goto out_no_events;
> }
> @@ -690,7 +680,7 @@ static void check_exception(PowerPCCPU *cpu, sPAPRMachineState *spapr,
> * interrupts.
> */
> for (i = 0; i < EVENT_CLASS_MAX; i++) {
> - if (rtas_event_log_contains(EVENT_CLASS_MASK(i), true)) {
> + if (rtas_event_log_contains(EVENT_CLASS_MASK(i))) {
> const sPAPREventSource *source =
> spapr_event_sources_get_source(spapr->event_sources, i);
>
> @@ -710,38 +700,10 @@ static void event_scan(PowerPCCPU *cpu, sPAPRMachineState *spapr,
> target_ulong args,
> uint32_t nret, target_ulong rets)
> {
> - uint32_t mask, buf, len, event_len;
> - sPAPREventLogEntry *event;
> - struct rtas_error_log *hdr;
> -
> if (nargs != 4 || nret != 1) {
> rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
> return;
> }
> -
> - mask = rtas_ld(args, 0);
> - buf = rtas_ld(args, 2);
> - len = rtas_ld(args, 3);
> -
> - event = rtas_event_log_dequeue(mask, false);
> - if (!event) {
> - goto out_no_events;
> - }
> -
> - hdr = event->data;
> - event_len = be32_to_cpu(hdr->extended_length) + sizeof(*hdr);
> -
> - if (event_len < len) {
> - len = event_len;
> - }
> -
> - cpu_physical_memory_write(buf, event->data, len);
> - rtas_st(rets, 0, RTAS_OUT_SUCCESS);
> - g_free(event->data);
> - g_free(event);
> - return;
> -
> -out_no_events:
> rtas_st(rets, 0, RTAS_OUT_NO_ERRORS_FOUND);
> }
>
> diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
> index 5802f88..02239a5 100644
> --- a/include/hw/ppc/spapr.h
> +++ b/include/hw/ppc/spapr.h
> @@ -598,7 +598,6 @@ sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong liobn);
>
> struct sPAPREventLogEntry {
> int log_type;
> - bool exception;
> void *data;
> QTAILQ_ENTRY(sPAPREventLogEntry) next;
> };
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v11 2/2] migration: spapr: migrate pending_events of spapr state
2017-05-18 20:24 ` [Qemu-devel] [PATCH v11 2/2] migration: spapr: migrate pending_events of spapr state Daniel Henrique Barboza
@ 2017-05-19 2:32 ` David Gibson
2017-05-19 13:10 ` [Qemu-devel] [Qemu-ppc] " Daniel Henrique Barboza
0 siblings, 1 reply; 6+ messages in thread
From: David Gibson @ 2017-05-19 2:32 UTC (permalink / raw)
To: Daniel Henrique Barboza; +Cc: qemu-devel, qemu-ppc, mdroth
[-- Attachment #1: Type: text/plain, Size: 4166 bytes --]
On Thu, May 18, 2017 at 05:24:02PM -0300, Daniel Henrique Barboza wrote:
> From: Jianjun Duan <duanj@linux.vnet.ibm.com>
>
> 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.
>
> All the different fields of the events are encoded as defined by
> PAPR. We can migrate them as uint8_t binary stream without any
> concerns about data padding or endianess.
>
> pending_events is put in a subsection in the spapr state VMSD to make
> sure migration across different versions is not broken.
>
> Signed-off-by: Jianjun Duan <duanj@linux.vnet.ibm.com>
> Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
> ---
> hw/ppc/spapr.c | 32 ++++++++++++++++++++++++++++++++
> hw/ppc/spapr_events.c | 1 +
> include/hw/ppc/spapr.h | 3 ++-
> 3 files changed, 35 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 0980d73..5afd328 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1444,6 +1444,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_INT32(log_type, sPAPREventLogEntry),
> + VMSTATE_UINT32(data_size, sPAPREventLogEntry),
> + VMSTATE_VBUFFER_ALLOC_UINT32(data, sPAPREventLogEntry, 0,
> + NULL, data_size),
> + 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;
> @@ -1542,6 +1573,7 @@ static const VMStateDescription vmstate_spapr = {
> .subsections = (const VMStateDescription*[]) {
> &vmstate_spapr_ov5_cas,
> &vmstate_spapr_patb_entry,
> + &vmstate_spapr_pending_events,
> NULL
> }
> };
> diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
> index 73e2a18..96c1605 100644
> --- a/hw/ppc/spapr_events.c
> +++ b/hw/ppc/spapr_events.c
> @@ -350,6 +350,7 @@ static void rtas_event_log_queue(int log_type, void *data)
> g_assert(data);
> entry->log_type = log_type;
> entry->data = data;
> + entry->data_size = sizeof(*data);
This can't be right, since data is a void*. I'm surprised it even
compiles. You'll need to actually look into the data buffer here and
extract the size field.
> QTAILQ_INSERT_TAIL(&spapr->pending_events, entry, next);
> }
>
> diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
> index 02239a5..0554e11 100644
> --- a/include/hw/ppc/spapr.h
> +++ b/include/hw/ppc/spapr.h
> @@ -597,8 +597,9 @@ struct sPAPRTCETable {
> sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong liobn);
>
> struct sPAPREventLogEntry {
> - int log_type;
> + int32_t log_type;
> void *data;
> + uint32_t data_size;
> QTAILQ_ENTRY(sPAPREventLogEntry) next;
> };
>
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH v11 2/2] migration: spapr: migrate pending_events of spapr state
2017-05-19 2:32 ` David Gibson
@ 2017-05-19 13:10 ` Daniel Henrique Barboza
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Henrique Barboza @ 2017-05-19 13:10 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, mdroth
On 05/18/2017 11:32 PM, David Gibson wrote:
> On Thu, May 18, 2017 at 05:24:02PM -0300, Daniel Henrique Barboza wrote:
>> From: Jianjun Duan <duanj@linux.vnet.ibm.com>
>>
>> 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.
>>
>> All the different fields of the events are encoded as defined by
>> PAPR. We can migrate them as uint8_t binary stream without any
>> concerns about data padding or endianess.
>>
>> pending_events is put in a subsection in the spapr state VMSD to make
>> sure migration across different versions is not broken.
>>
>> Signed-off-by: Jianjun Duan <duanj@linux.vnet.ibm.com>
>> Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
>> ---
>> hw/ppc/spapr.c | 32 ++++++++++++++++++++++++++++++++
>> hw/ppc/spapr_events.c | 1 +
>> include/hw/ppc/spapr.h | 3 ++-
>> 3 files changed, 35 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>> index 0980d73..5afd328 100644
>> --- a/hw/ppc/spapr.c
>> +++ b/hw/ppc/spapr.c
>> @@ -1444,6 +1444,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_INT32(log_type, sPAPREventLogEntry),
>> + VMSTATE_UINT32(data_size, sPAPREventLogEntry),
>> + VMSTATE_VBUFFER_ALLOC_UINT32(data, sPAPREventLogEntry, 0,
>> + NULL, data_size),
>> + 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;
>> @@ -1542,6 +1573,7 @@ static const VMStateDescription vmstate_spapr = {
>> .subsections = (const VMStateDescription*[]) {
>> &vmstate_spapr_ov5_cas,
>> &vmstate_spapr_patb_entry,
>> + &vmstate_spapr_pending_events,
>> NULL
>> }
>> };
>> diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
>> index 73e2a18..96c1605 100644
>> --- a/hw/ppc/spapr_events.c
>> +++ b/hw/ppc/spapr_events.c
>> @@ -350,6 +350,7 @@ static void rtas_event_log_queue(int log_type, void *data)
>> g_assert(data);
>> entry->log_type = log_type;
>> entry->data = data;
>> + entry->data_size = sizeof(*data);
> This can't be right, since data is a void*. I'm surprised it even
> compiles. You'll need to actually look into the data buffer here and
> extract the size field.
Hehe completely forgot here that I was querying the sizeof void. Good catch.
I think it didn't throw an error because the compiler defaulted the type
of void
in sizeof() to something else (char perhaps?).
I'll fix it by making a switch with the log_type and setting sizeof with
the proper
structured used.
Daniel
>
>> QTAILQ_INSERT_TAIL(&spapr->pending_events, entry, next);
>> }
>>
>> diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
>> index 02239a5..0554e11 100644
>> --- a/include/hw/ppc/spapr.h
>> +++ b/include/hw/ppc/spapr.h
>> @@ -597,8 +597,9 @@ struct sPAPRTCETable {
>> sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong liobn);
>>
>> struct sPAPREventLogEntry {
>> - int log_type;
>> + int32_t log_type;
>> void *data;
>> + uint32_t data_size;
>> QTAILQ_ENTRY(sPAPREventLogEntry) next;
>> };
>>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-19 13:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-18 20:24 [Qemu-devel] [PATCH v11 0/2] pseries: migrate pending_events of spapr state Daniel Henrique Barboza
2017-05-18 20:24 ` [Qemu-devel] [PATCH v11 1/2] hw/ppc/spapr_events.c: removing 'exception' from sPAPREventLogEntry Daniel Henrique Barboza
2017-05-19 2:26 ` David Gibson
2017-05-18 20:24 ` [Qemu-devel] [PATCH v11 2/2] migration: spapr: migrate pending_events of spapr state Daniel Henrique Barboza
2017-05-19 2:32 ` David Gibson
2017-05-19 13:10 ` [Qemu-devel] [Qemu-ppc] " Daniel Henrique Barboza
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).