From nobody Mon May 6 08:13:28 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 1495478603135444.8518287279386; Mon, 22 May 2017 11:43:23 -0700 (PDT) Received: from localhost ([::1]:44368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dCsIb-0008Uv-Hd for importer@patchew.org; Mon, 22 May 2017 14:43:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dCsGL-0007HO-PZ for qemu-devel@nongnu.org; Mon, 22 May 2017 14:41:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dCsGJ-0003QC-0O for qemu-devel@nongnu.org; Mon, 22 May 2017 14:41:01 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58145) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dCsGI-0003PX-Dz for qemu-devel@nongnu.org; Mon, 22 May 2017 14:40:58 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4MIXnm7033546 for ; Mon, 22 May 2017 14:40:56 -0400 Received: from e24smtp05.br.ibm.com (e24smtp05.br.ibm.com [32.104.18.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 2am3rw3vdy-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 22 May 2017 14:40:56 -0400 Received: from localhost by e24smtp05.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 22 May 2017 15:40:54 -0300 Received: from d24relay04.br.ibm.com (9.18.232.146) by e24smtp05.br.ibm.com (10.172.0.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 22 May 2017 15:40:52 -0300 Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay04.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4MIepZI5898590; Mon, 22 May 2017 15:40:51 -0300 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v4MIepYH012865; Mon, 22 May 2017 15:40:51 -0300 Received: from localhost.localdomain ([9.85.129.159]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v4MIejTw012811; Mon, 22 May 2017 15:40:49 -0300 From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Mon, 22 May 2017 15:40:39 -0300 X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170522184039.23877-1-danielhb@linux.vnet.ibm.com> References: <20170522184039.23877-1-danielhb@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17052218-0032-0000-0000-00000560F25B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052218-0033-0000-0000-000011E65885 Message-Id: <20170522184039.23877-2-danielhb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-22_09:, , 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-1705220098 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v13] 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 a binary stream inside VBUFFER 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 | 32 ++++++++++++++++++++++++++++++++ hw/ppc/spapr_events.c | 19 +++++++++++++++++++ include/hw/ppc/spapr.h | 3 ++- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 75e298b..558f951 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1453,6 +1453,37 @@ 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_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 =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; @@ -1551,6 +1582,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 73e2a18..6c42041 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -346,10 +346,29 @@ static void rtas_event_log_queue(int log_type, void *= data) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); sPAPREventLogEntry *entry =3D g_new(sPAPREventLogEntry, 1); + struct epow_log_full *new_epow =3D NULL; + struct hp_log_full *new_hp =3D NULL; + uint32_t ext_length =3D 0; =20 g_assert(data); entry->log_type =3D log_type; entry->data =3D data; + + switch (log_type) { + case RTAS_LOG_TYPE_EPOW: + new_epow =3D (struct epow_log_full *)data; + ext_length =3D be32_to_cpu(new_epow->hdr.extended_length); + entry->data_size =3D ext_length + sizeof(new_epow->hdr); + break; + case RTAS_LOG_TYPE_HOTPLUG: + new_hp =3D (struct hp_log_full *)data; + ext_length =3D be32_to_cpu(new_hp->hdr.extended_length); + entry->data_size =3D ext_length + sizeof(new_hp->hdr); + break; + default: + g_assert(false); + } + QTAILQ_INSERT_TAIL(&spapr->pending_events, entry, next); } =20 diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index be2b3b8..b2fcd62 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -598,8 +598,9 @@ struct sPAPRTCETable { sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong liobn); =20 struct sPAPREventLogEntry { - int log_type; + int32_t log_type; void *data; + uint32_t data_size; QTAILQ_ENTRY(sPAPREventLogEntry) next; }; =20 --=20 2.9.4