From nobody Sun Apr 28 20:28:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494853977402269.56325971352214; Mon, 15 May 2017 06:12:57 -0700 (PDT) Received: from localhost ([::1]:36849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAFny-0004qu-Ut for importer@patchew.org; Mon, 15 May 2017 09:12:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37816) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAFmJ-0003eF-6Q for qemu-devel@nongnu.org; Mon, 15 May 2017 09:11:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAFmH-0004D5-KP for qemu-devel@nongnu.org; Mon, 15 May 2017 09:11:11 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52801 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dAFmH-0004Cv-FO for qemu-devel@nongnu.org; Mon, 15 May 2017 09:11:09 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4FD47Ug187486 for ; Mon, 15 May 2017 09:11:09 -0400 Received: from e24smtp04.br.ibm.com (e24smtp04.br.ibm.com [32.104.18.25]) by mx0b-001b2d01.pphosted.com with ESMTP id 2afbmxveej-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 15 May 2017 09:11:08 -0400 Received: from localhost by e24smtp04.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 May 2017 10:11:06 -0300 Received: from d24relay03.br.ibm.com (9.18.232.225) by e24smtp04.br.ibm.com (10.172.0.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 15 May 2017 10:11:04 -0300 Received: from d24av03.br.ibm.com (d24av03.br.ibm.com [9.8.31.95]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4FDB3ni35324050; Mon, 15 May 2017 10:11:03 -0300 Received: from d24av03.br.ibm.com (localhost [127.0.0.1]) by d24av03.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v4FDB4Ei019175; Mon, 15 May 2017 10:11:04 -0300 Received: from localhost.localdomain ([9.80.239.166]) by d24av03.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v4FDAwK6019098; Mon, 15 May 2017 10:11:02 -0300 From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Mon, 15 May 2017 10:10:52 -0300 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170515131052.23457-1-danielhb@linux.vnet.ibm.com> References: <20170515131052.23457-1-danielhb@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17051513-0028-0000-0000-000001B45F87 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17051513-0029-0000-0000-000014B4B86B Message-Id: <20170515131052.23457-2-danielhb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-15_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705150135 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v10] migration: spapr: migrate pending_events of spapr state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, mdroth@linux.vnet.ibm.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jianjun Duan 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 Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr.c | 33 +++++++++++++++++++++++++++++++++ hw/ppc/spapr_events.c | 24 +++++++++++++----------- include/hw/ppc/spapr.h | 3 ++- 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 80d12d0..8cfdc71 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1437,6 +1437,38 @@ static bool version_before_3(void *opaque, int versi= on_id) return version_id < 3; } =20 +static bool spapr_pending_events_needed(void *opaque) +{ + sPAPRMachineState *spapr =3D (sPAPRMachineState *)opaque; + return !QTAILQ_EMPTY(&spapr->pending_events); +} + +static const VMStateDescription vmstate_spapr_event_entry =3D { + .name =3D "spapr_event_log_entry", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_INT32(log_type, sPAPREventLogEntry), + VMSTATE_BOOL(exception, sPAPREventLogEntry), + VMSTATE_UINT32(data_size, sPAPREventLogEntry), + VMSTATE_VARRAY_UINT32_ALLOC(data, sPAPREventLogEntry, data_size, + 0, vmstate_info_uint8, uint8_t), + VMSTATE_END_OF_LIST() + }, +}; + +static const VMStateDescription vmstate_spapr_pending_events =3D { + .name =3D "spapr_pending_events", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D spapr_pending_events_needed, + .fields =3D (VMStateField[]) { + VMSTATE_QTAILQ_V(pending_events, sPAPRMachineState, 1, + vmstate_spapr_event_entry, sPAPREventLogEntry, ne= xt), + VMSTATE_END_OF_LIST() + }, +}; + static bool spapr_ov5_cas_needed(void *opaque) { sPAPRMachineState *spapr =3D opaque; @@ -1535,6 +1567,7 @@ static const VMStateDescription vmstate_spapr =3D { .subsections =3D (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 f0b28d8..70c7cfc 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -342,7 +342,8 @@ static int rtas_event_log_to_irq(sPAPRMachineState *spa= pr, int log_type) return source->irq; } =20 -static void rtas_event_log_queue(int log_type, void *data, bool exception) +static void rtas_event_log_queue(int log_type, void *data, bool exception, + int data_size) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); sPAPREventLogEntry *entry =3D g_new(sPAPREventLogEntry, 1); @@ -351,6 +352,7 @@ static void rtas_event_log_queue(int log_type, void *da= ta, bool exception) entry->log_type =3D log_type; entry->exception =3D exception; entry->data =3D data; + entry->data_size =3D data_size; QTAILQ_INSERT_TAIL(&spapr->pending_events, entry, next); } =20 @@ -445,6 +447,7 @@ static void spapr_powerdown_req(Notifier *n, void *opaq= ue) struct rtas_event_log_v6_mainb *mainb; struct rtas_event_log_v6_epow *epow; struct epow_log_full *new_epow; + uint32_t data_size; =20 new_epow =3D g_malloc0(sizeof(*new_epow)); hdr =3D &new_epow->hdr; @@ -453,14 +456,13 @@ static void spapr_powerdown_req(Notifier *n, void *op= aque) mainb =3D &new_epow->mainb; epow =3D &new_epow->epow; =20 + data_size =3D sizeof(*new_epow); hdr->summary =3D cpu_to_be32(RTAS_LOG_VERSION_6 | RTAS_LOG_SEVERITY_EVENT | RTAS_LOG_DISPOSITION_NOT_RECOVERED | RTAS_LOG_OPTIONAL_PART_PRESENT | RTAS_LOG_TYPE_EPOW); - hdr->extended_length =3D cpu_to_be32(sizeof(*new_epow) - - sizeof(new_epow->hdr)); - + hdr->extended_length =3D cpu_to_be32(data_size - sizeof(new_epow->hdr)= ); spapr_init_v6hdr(v6hdr); spapr_init_maina(maina, 3 /* Main-A, Main-B and EPOW */); =20 @@ -479,7 +481,7 @@ static void spapr_powerdown_req(Notifier *n, void *opaq= ue) epow->event_modifier =3D RTAS_LOG_V6_EPOW_MODIFIER_NORMAL; epow->extended_modifier =3D RTAS_LOG_V6_EPOW_XMODIFIER_PARTITION_SPECI= FIC; =20 - rtas_event_log_queue(RTAS_LOG_TYPE_EPOW, new_epow, true); + rtas_event_log_queue(RTAS_LOG_TYPE_EPOW, new_epow, true, data_size); =20 qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr), rtas_event_log_to_irq(spapr, @@ -504,6 +506,7 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint= 8_t hp_action, struct rtas_event_log_v6_maina *maina; struct rtas_event_log_v6_mainb *mainb; struct rtas_event_log_v6_hp *hp; + uint32_t data_size; =20 new_hp =3D g_malloc0(sizeof(struct hp_log_full)); hdr =3D &new_hp->hdr; @@ -512,14 +515,14 @@ static void spapr_hotplug_req_event(uint8_t hp_id, ui= nt8_t hp_action, mainb =3D &new_hp->mainb; hp =3D &new_hp->hp; =20 + data_size =3D sizeof(*new_hp); hdr->summary =3D cpu_to_be32(RTAS_LOG_VERSION_6 | RTAS_LOG_SEVERITY_EVENT | RTAS_LOG_DISPOSITION_NOT_RECOVERED | RTAS_LOG_OPTIONAL_PART_PRESENT | RTAS_LOG_INITIATOR_HOTPLUG | RTAS_LOG_TYPE_HOTPLUG); - hdr->extended_length =3D cpu_to_be32(sizeof(*new_hp) - - sizeof(new_hp->hdr)); + hdr->extended_length =3D cpu_to_be32(data_size - sizeof(new_hp->hdr)); =20 spapr_init_v6hdr(v6hdr); spapr_init_maina(maina, 3 /* Main-A, Main-B, HP */); @@ -572,7 +575,7 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint= 8_t hp_action, cpu_to_be32(drc_id->count_indexed.index); } =20 - rtas_event_log_queue(RTAS_LOG_TYPE_HOTPLUG, new_hp, true); + rtas_event_log_queue(RTAS_LOG_TYPE_HOTPLUG, new_hp, true, data_size); =20 qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr), rtas_event_log_to_irq(spapr, @@ -671,8 +674,7 @@ static void check_exception(PowerPCCPU *cpu, sPAPRMachi= neState *spapr, if (!event) { goto out_no_events; } - - hdr =3D event->data; + hdr =3D (struct rtas_error_log *)event->data; event_len =3D be32_to_cpu(hdr->extended_length) + sizeof(*hdr); =20 if (event_len < len) { @@ -728,7 +730,7 @@ static void event_scan(PowerPCCPU *cpu, sPAPRMachineSta= te *spapr, goto out_no_events; } =20 - hdr =3D event->data; + hdr =3D (struct rtas_error_log *)event->data; event_len =3D be32_to_cpu(hdr->extended_length) + sizeof(*hdr); =20 if (event_len < len) { diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 5802f88..fbe1d93 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -599,7 +599,8 @@ sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong lio= bn); struct sPAPREventLogEntry { int log_type; bool exception; - void *data; + uint8_t *data; + uint32_t data_size; QTAILQ_ENTRY(sPAPREventLogEntry) next; }; =20 --=20 2.9.3