From: David Gibson <david@gibson.dropbear.id.au>
To: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, paulus@ozlabs.org
Subject: Re: [Qemu-devel] [QEMU-PPC] [PATCH V5 2/7] target/ppc/spapr_caps: Add macro to generate spapr_caps migration vmstate
Date: Fri, 19 Jan 2018 16:09:00 +1100 [thread overview]
Message-ID: <20180119050900.GH30352@umbus.fritz.box> (raw)
In-Reply-To: <20180119050005.29392-3-sjitindarsingh@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4467 bytes --]
On Fri, Jan 19, 2018 at 04:00:00PM +1100, Suraj Jitindar Singh wrote:
> 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 <sjitindarsingh@gmail.com>
Applied to ppc-for-2.12, thanks.
>
> ---
>
> 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)
> {
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-01-19 5:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-19 4:59 [Qemu-devel] [QEMU-PPC] [PATCH V5 0/7] target/ppc: Rework spapr_caps Suraj Jitindar Singh
2018-01-19 4:59 ` [Qemu-devel] [QEMU-PPC] [PATCH V5 1/7] target/ppc/kvm: Add cap_ppc_safe_[cache/bounds_check/indirect_branch] Suraj Jitindar Singh
2018-01-19 5:00 ` [Qemu-devel] [QEMU-PPC] [PATCH V5 2/7] target/ppc/spapr_caps: Add macro to generate spapr_caps migration vmstate Suraj Jitindar Singh
2018-01-19 5:09 ` David Gibson [this message]
2018-01-19 5:18 ` Alexey Kardashevskiy
2018-01-28 23:43 ` Suraj Jitindar Singh
2018-01-29 3:03 ` Alexey Kardashevskiy
2018-01-30 6:19 ` Suraj Jitindar Singh
2018-01-19 5:00 ` [Qemu-devel] [QEMU-PPC] [PATCH V5 3/7] target/ppc/spapr_caps: Add support for tristate spapr_capabilities Suraj Jitindar Singh
2018-01-19 5:00 ` [Qemu-devel] [QEMU-PPC] [PATCH V5 4/7] target/ppc/spapr_caps: Add new tristate cap safe_cache Suraj Jitindar Singh
2018-01-19 5:00 ` [Qemu-devel] [QEMU-PPC] [PATCH V5 5/7] target/ppc/spapr_caps: Add new tristate cap safe_bounds_check Suraj Jitindar Singh
2018-01-19 5:00 ` [Qemu-devel] [QEMU-PPC] [PATCH V5 6/7] target/ppc/spapr_caps: Add new tristate cap safe_indirect_branch Suraj Jitindar Singh
2018-01-19 5:00 ` [Qemu-devel] [QEMU-PPC] [PATCH V5 7/7] target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS Suraj Jitindar Singh
2018-01-19 5:29 ` [Qemu-devel] [QEMU-PPC] [PATCH V5 0/7] target/ppc: Rework spapr_caps no-reply
2018-01-29 0:36 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180119050900.GH30352@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=paulus@ozlabs.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=sjitindarsingh@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).