From patchwork Wed Jun 8 23:06:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianjun Duan X-Patchwork-Id: 9165919 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7643A60832 for ; Wed, 8 Jun 2016 23:15:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66B10282DC for ; Wed, 8 Jun 2016 23:15:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B0E628309; Wed, 8 Jun 2016 23:15:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B1611282DC for ; Wed, 8 Jun 2016 23:15:55 +0000 (UTC) Received: from localhost ([::1]:59923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAmhW-0002pO-TK for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Jun 2016 19:15:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAmZZ-0004oy-6q for qemu-devel@nongnu.org; Wed, 08 Jun 2016 19:07:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAmZT-0008PL-LJ for qemu-devel@nongnu.org; Wed, 08 Jun 2016 19:07:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:61280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAmZT-0008P9-EC for qemu-devel@nongnu.org; Wed, 08 Jun 2016 19:07:35 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u58N3ppt013579 for ; Wed, 8 Jun 2016 19:07:34 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 23e9m44kbd-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 08 Jun 2016 19:07:34 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 8 Jun 2016 17:07:34 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 8 Jun 2016 17:07:28 -0600 X-IBM-Helo: d03dlp02.boulder.ibm.com X-IBM-MailFrom: duanj@linux.vnet.ibm.com X-IBM-RcptTo: aurelien@aurel32.net; dmitry@daynix.com; david@gibson.dropbear.id.au; blauwirbel@gmail.com; veroniabahaa@gmail.com; mark.cave-ayland@ilande.co.uk; leon.alrae@imgtec.com; peter.maydell@linaro.org; qemu-devel@nongnu.org; qemu-ppc@nongnu.org; amit.shah@redhat.com; kraxel@redhat.com; kwolf@redhat.com; mreitz@redhat.com; mst@redhat.com; pbonzini@redhat.com; quintela@redhat.com; rth@twiddle.net Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 3ECF43E4001C; Wed, 8 Jun 2016 17:07:28 -0600 (MDT) Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u58N7SAR40173788; Wed, 8 Jun 2016 23:07:28 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B70E8AC046; Wed, 8 Jun 2016 19:07:27 -0400 (EDT) Received: from jianjun-w530.ibm.com (unknown [9.48.122.30]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id A0A40AC03C; Wed, 8 Jun 2016 19:07:24 -0400 (EDT) From: Jianjun Duan To: qemu-devel@nongnu.org Date: Wed, 8 Jun 2016 16:06:57 -0700 X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465427217-5551-1-git-send-email-duanj@linux.vnet.ibm.com> References: <1465427217-5551-1-git-send-email-duanj@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16060823-8235-0000-0000-0000088B3A11 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16060823-8236-0000-0000-0000320C71F6 Message-Id: <1465427217-5551-7-git-send-email-duanj@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-06-08_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-1604210000 definitions=main-1606080261 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [QEMU RFC PATCH v4 6/6] migration: 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: veroniabahaa@gmail.com, peter.maydell@linaro.org, duanj@linux.vnet.ibm.com, mst@redhat.com, quintela@redhat.com, mark.cave-ayland@ilande.co.uk, mdroth@linux.vnet.ibm.com, mreitz@redhat.com, blauwirbel@gmail.com, amit.shah@redhat.com, qemu-ppc@nongnu.org, kraxel@redhat.com, kwolf@redhat.com, dmitry@daynix.com, pbonzini@redhat.com, rth@twiddle.net, leon.alrae@imgtec.com, aurelien@aurel32.net, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- hw/ppc/spapr.c | 33 +++++++++++++++++++++++++++++++++ hw/ppc/spapr_events.c | 22 +++++++++++++--------- include/hw/ppc/spapr.h | 3 ++- 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 54a8af6..ecff138 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1266,12 +1266,32 @@ 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 bool spapr_ccs_list_needed(void *opaque) { sPAPRMachineState *spapr = (sPAPRMachineState *)opaque; return !QTAILQ_EMPTY(&spapr->ccs_list); } +static const VMStateDescription vmstate_spapr_event_entry = { + .name = "spapreventlogentry", + .version_id = 1, + .minimum_version_id = 1, + .fields = (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_ccs = { .name = "spaprconfigureconnectorstate", .version_id = 1, @@ -1284,6 +1304,18 @@ static const VMStateDescription vmstate_spapr_ccs = { }, }; +static const VMStateDescription vmstate_spapr_pending_events = { + .name = "spaprpendingevents", + .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 const VMStateDescription vmstate_spapr_ccs_list = { .name = "spaprccslist", .version_id = 1, @@ -1312,6 +1344,7 @@ static const VMStateDescription vmstate_spapr = { VMSTATE_END_OF_LIST() }, .subsections = (const VMStateDescription*[]) { + &vmstate_spapr_pending_events, &vmstate_spapr_ccs_list, NULL } diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index 049fb1b..1680c08 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -239,7 +239,8 @@ void spapr_events_fdt_skel(void *fdt, uint32_t check_exception_irq) _FDT((fdt_end_node(fdt))); } -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 = SPAPR_MACHINE(qdev_get_machine()); sPAPREventLogEntry *entry = g_new(sPAPREventLogEntry, 1); @@ -248,6 +249,7 @@ static void rtas_event_log_queue(int log_type, void *data, bool exception) entry->log_type = log_type; entry->exception = exception; entry->data = data; + entry->data_size = data_size; QTAILQ_INSERT_TAIL(&spapr->pending_events, entry, next); } @@ -350,6 +352,7 @@ static void spapr_powerdown_req(Notifier *n, void *opaque) struct rtas_event_log_v6_mainb *mainb; struct rtas_event_log_v6_epow *epow; struct epow_log_full *new_epow; + uint32_t data_size; new_epow = g_malloc0(sizeof(*new_epow)); hdr = &new_epow->hdr; @@ -358,13 +361,13 @@ static void spapr_powerdown_req(Notifier *n, void *opaque) mainb = &new_epow->mainb; epow = &new_epow->epow; + data_size = sizeof(*new_epow); hdr->summary = 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 = cpu_to_be32(sizeof(*new_epow) - - sizeof(new_epow->hdr)); + hdr->extended_length = cpu_to_be32(data_size - sizeof(new_epow->hdr)); spapr_init_v6hdr(v6hdr); spapr_init_maina(maina, 3 /* Main-A, Main-B and EPOW */); @@ -384,7 +387,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, true, data_size); qemu_irq_pulse(xics_get_qirq(spapr->icp, spapr->check_exception_irq)); } @@ -407,6 +410,7 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_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; new_hp = g_malloc0(sizeof(struct hp_log_full)); hdr = &new_hp->hdr; @@ -415,14 +419,14 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action, mainb = &new_hp->mainb; hp = &new_hp->hp; + data_size = sizeof(*new_hp); hdr->summary = 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 = cpu_to_be32(sizeof(*new_hp) - - sizeof(new_hp->hdr)); + hdr->extended_length = cpu_to_be32(data_size - sizeof(new_hp->hdr)); spapr_init_v6hdr(v6hdr); spapr_init_maina(maina, 3 /* Main-A, Main-B, HP */); @@ -463,7 +467,7 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action, hp->drc.index = cpu_to_be32(drc); } - rtas_event_log_queue(RTAS_LOG_TYPE_HOTPLUG, new_hp, true); + rtas_event_log_queue(RTAS_LOG_TYPE_HOTPLUG, new_hp, true, data_size); qemu_irq_pulse(xics_get_qirq(spapr->icp, spapr->check_exception_irq)); } @@ -530,7 +534,7 @@ static void check_exception(PowerPCCPU *cpu, sPAPRMachineState *spapr, goto out_no_events; } - hdr = event->data; + hdr = (struct rtas_error_log *)event->data; event_len = be32_to_cpu(hdr->extended_length) + sizeof(*hdr); if (event_len < len) { @@ -580,7 +584,7 @@ static void event_scan(PowerPCCPU *cpu, sPAPRMachineState *spapr, goto out_no_events; } - hdr = event->data; + hdr = (struct rtas_error_log *)event->data; event_len = be32_to_cpu(hdr->extended_length) + sizeof(*hdr); if (event_len < len) { diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 971df3d..965bd3e 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -554,7 +554,8 @@ sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong liobn); struct sPAPREventLogEntry { int log_type; bool exception; - void *data; + uint32_t data_size; + uint8_t *data; QTAILQ_ENTRY(sPAPREventLogEntry) next; };