From patchwork Fri May 5 20:47:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 9714359 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 14ED560235 for ; Fri, 5 May 2017 20:50:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07BEA28618 for ; Fri, 5 May 2017 20:50:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF2F728635; Fri, 5 May 2017 20:50:20 +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 59BE228618 for ; Fri, 5 May 2017 20:50:20 +0000 (UTC) Received: from localhost ([::1]:48976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6kB9-0005XM-Jp for patchwork-qemu-devel@patchwork.kernel.org; Fri, 05 May 2017 16:50:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6k9D-000537-D8 for qemu-devel@nongnu.org; Fri, 05 May 2017 16:48:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6k9A-0006X9-Q2 for qemu-devel@nongnu.org; Fri, 05 May 2017 16:48:19 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36180) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6k9A-0006Vs-HV for qemu-devel@nongnu.org; Fri, 05 May 2017 16:48:16 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v45KhmPO011169 for ; Fri, 5 May 2017 16:48:15 -0400 Received: from e24smtp05.br.ibm.com (e24smtp05.br.ibm.com [32.104.18.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 2a8yxy1tgf-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 05 May 2017 16:48:15 -0400 Received: from localhost by e24smtp05.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 5 May 2017 17:48:12 -0300 Received: from d24relay03.br.ibm.com (9.18.232.225) by e24smtp05.br.ibm.com (10.172.0.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 5 May 2017 17:48:11 -0300 Received: from d24av04.br.ibm.com (d24av04.br.ibm.com [9.8.31.97]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v45Km92j23920692; Fri, 5 May 2017 17:48:10 -0300 Received: from d24av04.br.ibm.com (localhost [127.0.0.1]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v45Km9mn014078; Fri, 5 May 2017 17:48:09 -0300 Received: from arthas.ibm.com ([9.80.215.128]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v45Klsia013854; Fri, 5 May 2017 17:48:07 -0300 From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Fri, 5 May 2017 17:47:45 -0300 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170505204746.14116-1-danielhb@linux.vnet.ibm.com> References: <20170505204746.14116-1-danielhb@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17050520-0032-0000-0000-0000055BBF09 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17050520-0033-0000-0000-000011E0F33F Message-Id: <20170505204746.14116-6-danielhb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-05_16:, , 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-1705050194 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 v9 5/6] migration: spapr: migrate ccs_list in 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jianjun Duan ccs_list in spapr state maintains the device tree related information on the rtas side for hotplugged devices. In racing situations between hotplug events and migration operation, a rtas hotplug event could be migrated from the source guest to target guest, or the source guest could have not yet finished fetching the device tree when migration is started, the target will try to finish fetching the device tree. By migrating ccs_list, the target can fetch the device tree properly. In theory there would be other alternatives besides migrating the css_list to fix this. For example, we could add a flag that indicates whether a device is in the middle of the configure_connector during the migration process, in the post_load we can detect if this flag is active and then return an error informing the guest to restart the hotplug process. However, the DRC state can still be modified outside of hotplug. Using: drmgr -c pci -s -r drmgr -c pci -s -a it is possible to return a device to firmware and then later take it back and reconfigure it. This is not a common case but it's not prohibited, and performing a migration between these 2 operations would fail because the default coldplug state on target assumes a configured state in the source*. Migrating ccs_list is one solution that cover this case as well. ccs_list is put in a subsection in the spapr state VMSD to make sure migration across different versions is not broken. * see http://lists.nongnu.org/archive/html/qemu-devel/2016-10/msg01763.html for more information on this discussion. Signed-off-by: Jianjun Duan Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 30f0b7b..bc56249 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1467,6 +1467,37 @@ static const VMStateDescription vmstate_spapr_pending_dimm_unplugs = { }, }; +static bool spapr_ccs_list_needed(void *opaque) +{ + sPAPRMachineState *spapr = (sPAPRMachineState *)opaque; + return !QTAILQ_EMPTY(&spapr->ccs_list); +} + +static const VMStateDescription vmstate_spapr_ccs = { + .name = "spapr_configure_connector_state", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT32(drc_index, sPAPRConfigureConnectorState), + VMSTATE_INT32(fdt_offset, sPAPRConfigureConnectorState), + VMSTATE_INT32(fdt_depth, sPAPRConfigureConnectorState), + VMSTATE_END_OF_LIST() + }, +}; + +static const VMStateDescription vmstate_spapr_ccs_list = { + .name = "spapr_ccs_list", + .version_id = 1, + .minimum_version_id = 1, + .needed = spapr_ccs_list_needed, + .fields = (VMStateField[]) { + VMSTATE_QTAILQ_V(ccs_list, sPAPRMachineState, 1, + vmstate_spapr_ccs, sPAPRConfigureConnectorState, + next), + VMSTATE_END_OF_LIST() + }, +}; + static bool spapr_ov5_cas_needed(void *opaque) { sPAPRMachineState *spapr = opaque; @@ -1566,6 +1597,7 @@ static const VMStateDescription vmstate_spapr = { &vmstate_spapr_ov5_cas, &vmstate_spapr_patb_entry, &vmstate_spapr_pending_dimm_unplugs, + &vmstate_spapr_ccs_list, NULL } };