From patchwork Fri Jan 19 05:00:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 10174539 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 BE0D160386 for ; Fri, 19 Jan 2018 05:05:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACB0C284D2 for ; Fri, 19 Jan 2018 05:05:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EC6F284F1; Fri, 19 Jan 2018 05:05:12 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 2970B284D2 for ; Fri, 19 Jan 2018 05:05:12 +0000 (UTC) Received: from localhost ([::1]:52464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecOrX-0002x4-Bq for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Jan 2018 00:05:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60238) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecOmz-0007QH-C1 for qemu-devel@nongnu.org; Fri, 19 Jan 2018 00:00:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecOmy-0004p0-31 for qemu-devel@nongnu.org; Fri, 19 Jan 2018 00:00:29 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:45168) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ecOmv-0004nd-6l; Fri, 19 Jan 2018 00:00:25 -0500 Received: by mail-pf0-x242.google.com with SMTP id a88so525353pfe.12; Thu, 18 Jan 2018 21:00:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vl4nmHg7KT8IbcFd5bNK9EMsl8YY+LSbu3dwu2mmZic=; b=g8Aly4Jsb2PDELMheS7xolVLT+xXFHpZKR1gZlZ8V1QDsWOk0B94ZR0D8GAjGsC2KX 6Y5w9AuVYtQ8R/vkT2/1Jad0lYYCwb175Ltycngj6oxTVHBQsKJ5nBsXpW4NFNTUN4c8 FpooWZYV3KSQN42O6LWu6PftyTET4BfdzBc4NQ2KWyxQ8dmMOaLmfBoVkjxKeGxxxAKj EXuyHGPOcRl0v8LWmmOJKd08+Ny64O+uigEqWU5DjKYpBhO8rqcjSNvQeTFZ7JLST30d PGV8kZvffGUgS5MM0I139qBJVSdXRiwR2aXTAdU4jmPqUeTpAhB6oh/ypRYhIPm4jT/S lD4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vl4nmHg7KT8IbcFd5bNK9EMsl8YY+LSbu3dwu2mmZic=; b=KVxSrDF5XSQLcdhL0TZM4lCXhQcZQC57wOvUd7i0jGKiHsRNZib8KQDSF3ZQjIFJYA vZG5Ap46kWll93TOWgJ0+6Dea+zdC9EJjakMyacQsx0zyWawIeWgmQ/gGwum0VT5NT3R UQVC6ahmH6j7daMmEVRPKEy9dgDaQqvVr5IlisVQnOAw59Aj3EQWdCYmxlgBDGijkoWv KeJ7boMYlVaRPfFtVb3B2sniAEGNwGlXm1eciAHZ+hghJE7V6vZ96CUeFRwwcyfcpsrA 4M6sAYpdrKtX1kzwYQp0LH5Kvkmc3zwprgpds+D0XiQlqRICcumqv5M1VgWoOcDiLPrP cafw== X-Gm-Message-State: AKwxytf7AYf2SuUhXT31ptQNzMsGm5aZHNXw7JYSfk4FzZlrFU2whiR5 ix/l80OlQHBZN7GB/sBBMxAY/ZR4 X-Google-Smtp-Source: ACJfBot5S+1whouLe7zELYRPn70Hjen1ABQ8vGmBGvZp0qB3Kc/ptnX2E+weF6Sla3r9kaMbNKDj0A== X-Received: by 10.98.18.10 with SMTP id a10mr14677969pfj.140.1516338023997; Thu, 18 Jan 2018 21:00:23 -0800 (PST) Received: from surajjs1.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id i128sm14653163pfg.83.2018.01.18.21.00.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 21:00:23 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Fri, 19 Jan 2018 16:00:00 +1100 Message-Id: <20180119050005.29392-3-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180119050005.29392-1-sjitindarsingh@gmail.com> References: <20180119050005.29392-1-sjitindarsingh@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [QEMU-PPC] [PATCH V5 2/7] target/ppc/spapr_caps: Add macro to generate spapr_caps migration vmstate 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: paulus@ozlabs.org, qemu-devel@nongnu.org, Suraj Jitindar Singh , 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 The vmstate description and the contained needed function for migration of spapr_caps is the same for each cap, with the name of the cap substituted. As such introduce a macro to allow for easier generation of these. Convert the three existing spapr_caps (htm, vsx, and dfp) to use this macro. Signed-off-by: Suraj Jitindar Singh --- V5: - Patch added to series --- hw/ppc/spapr_caps.c | 78 +++++++++++++++++------------------------------------ 1 file changed, 24 insertions(+), 54 deletions(-) diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index d5c9ce774a..5d52969bd5 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -228,62 +228,32 @@ int spapr_caps_post_migration(sPAPRMachineState *spapr) return ok ? 0 : -EINVAL; } -static bool spapr_cap_htm_needed(void *opaque) -{ - sPAPRMachineState *spapr = opaque; - - return spapr->cmd_line_caps[SPAPR_CAP_HTM] && - (spapr->eff.caps[SPAPR_CAP_HTM] != spapr->def.caps[SPAPR_CAP_HTM]); -} - -const VMStateDescription vmstate_spapr_cap_htm = { - .name = "spapr/cap/htm", - .version_id = 1, - .minimum_version_id = 1, - .needed = spapr_cap_htm_needed, - .fields = (VMStateField[]) { - VMSTATE_UINT8(mig.caps[SPAPR_CAP_HTM], sPAPRMachineState), - VMSTATE_END_OF_LIST() - }, -}; - -static bool spapr_cap_vsx_needed(void *opaque) -{ - sPAPRMachineState *spapr = opaque; - - return spapr->cmd_line_caps[SPAPR_CAP_VSX] && - (spapr->eff.caps[SPAPR_CAP_VSX] != spapr->def.caps[SPAPR_CAP_VSX]); +/* Used to generate the migration field and needed function for a spapr cap */ +#define SPAPR_CAP_MIG_STATE(cap, ccap) \ +static bool spapr_cap_##cap##_needed(void *opaque) \ +{ \ + sPAPRMachineState *spapr = opaque; \ + \ + return spapr->cmd_line_caps[SPAPR_CAP_##ccap] && \ + (spapr->eff.caps[SPAPR_CAP_##ccap] != \ + spapr->def.caps[SPAPR_CAP_##ccap]); \ +} \ + \ +const VMStateDescription vmstate_spapr_cap_##cap = { \ + .name = "spapr/cap/" #cap, \ + .version_id = 1, \ + .minimum_version_id = 1, \ + .needed = spapr_cap_##cap##_needed, \ + .fields = (VMStateField[]) { \ + VMSTATE_UINT8(mig.caps[SPAPR_CAP_##ccap], \ + sPAPRMachineState), \ + VMSTATE_END_OF_LIST() \ + }, \ } -const VMStateDescription vmstate_spapr_cap_vsx = { - .name = "spapr/cap/vsx", - .version_id = 1, - .minimum_version_id = 1, - .needed = spapr_cap_vsx_needed, - .fields = (VMStateField[]) { - VMSTATE_UINT8(mig.caps[SPAPR_CAP_VSX], sPAPRMachineState), - VMSTATE_END_OF_LIST() - }, -}; - -static bool spapr_cap_dfp_needed(void *opaque) -{ - sPAPRMachineState *spapr = opaque; - - return spapr->cmd_line_caps[SPAPR_CAP_DFP] && - (spapr->eff.caps[SPAPR_CAP_DFP] != spapr->def.caps[SPAPR_CAP_DFP]); -} - -const VMStateDescription vmstate_spapr_cap_dfp = { - .name = "spapr/cap/dfp", - .version_id = 1, - .minimum_version_id = 1, - .needed = spapr_cap_dfp_needed, - .fields = (VMStateField[]) { - VMSTATE_UINT8(mig.caps[SPAPR_CAP_DFP], sPAPRMachineState), - VMSTATE_END_OF_LIST() - }, -}; +SPAPR_CAP_MIG_STATE(htm, HTM); +SPAPR_CAP_MIG_STATE(vsx, VSX); +SPAPR_CAP_MIG_STATE(dfp, DFP); void spapr_caps_reset(sPAPRMachineState *spapr) {