Blame SOURCES/kvm-target-ppc-spapr_caps-Add-macro-to-generate-spapr_ca.patch

4a2fec
From 1f48270b951f370528fc7f9e6e76b25ed422ac77 Mon Sep 17 00:00:00 2001
4a2fec
From: Suraj Jitindar Singh <sursingh@redhat.com>
4a2fec
Date: Tue, 13 Feb 2018 04:12:22 +0100
4a2fec
Subject: [PATCH 05/15] target/ppc/spapr_caps: Add macro to generate spapr_caps
4a2fec
 migration vmstate
4a2fec
4a2fec
RH-Author: Suraj Jitindar Singh <sursingh@redhat.com>
4a2fec
Message-id: <1518495150-24134-2-git-send-email-sursingh@redhat.com>
4a2fec
Patchwork-id: 78983
4a2fec
O-Subject: [RHEL7.5 qemu-kvm-rhev PATCH 1/9] target/ppc/spapr_caps: Add macro to generate spapr_caps migration vmstate
4a2fec
Bugzilla: 1532050
4a2fec
RH-Acked-by: David Gibson <dgibson@redhat.com>
4a2fec
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
4a2fec
RH-Acked-by: Thomas Huth <thuth@redhat.com>
4a2fec
4a2fec
From: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
4a2fec
4a2fec
The vmstate description and the contained needed function for migration
4a2fec
of spapr_caps is the same for each cap, with the name of the cap
4a2fec
substituted. As such introduce a macro to allow for easier generation of
4a2fec
these.
4a2fec
4a2fec
Convert the three existing spapr_caps (htm, vsx, and dfp) to use this
4a2fec
macro.
4a2fec
4a2fec
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
4a2fec
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4a2fec
(cherry picked from commit 1f63ebaa91f73f469c8f107dbd266cabdbea3a40)
4a2fec
4a2fec
Conflicts: None
4a2fec
4a2fec
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1532050
4a2fec
4a2fec
Signed-off-by: Suraj Jitindar Singh <sursingh@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 hw/ppc/spapr_caps.c | 78 +++++++++++++++++------------------------------------
4a2fec
 1 file changed, 24 insertions(+), 54 deletions(-)
4a2fec
4a2fec
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
4a2fec
index d5c9ce7..5d52969 100644
4a2fec
--- a/hw/ppc/spapr_caps.c
4a2fec
+++ b/hw/ppc/spapr_caps.c
4a2fec
@@ -228,62 +228,32 @@ int spapr_caps_post_migration(sPAPRMachineState *spapr)
4a2fec
     return ok ? 0 : -EINVAL;
4a2fec
 }
4a2fec
 
4a2fec
-static bool spapr_cap_htm_needed(void *opaque)
4a2fec
-{
4a2fec
-    sPAPRMachineState *spapr = opaque;
4a2fec
-
4a2fec
-    return spapr->cmd_line_caps[SPAPR_CAP_HTM] &&
4a2fec
-           (spapr->eff.caps[SPAPR_CAP_HTM] != spapr->def.caps[SPAPR_CAP_HTM]);
4a2fec
-}
4a2fec
-
4a2fec
-const VMStateDescription vmstate_spapr_cap_htm = {
4a2fec
-    .name = "spapr/cap/htm",
4a2fec
-    .version_id = 1,
4a2fec
-    .minimum_version_id = 1,
4a2fec
-    .needed = spapr_cap_htm_needed,
4a2fec
-    .fields = (VMStateField[]) {
4a2fec
-        VMSTATE_UINT8(mig.caps[SPAPR_CAP_HTM], sPAPRMachineState),
4a2fec
-        VMSTATE_END_OF_LIST()
4a2fec
-    },
4a2fec
-};
4a2fec
-
4a2fec
-static bool spapr_cap_vsx_needed(void *opaque)
4a2fec
-{
4a2fec
-    sPAPRMachineState *spapr = opaque;
4a2fec
-
4a2fec
-    return spapr->cmd_line_caps[SPAPR_CAP_VSX] &&
4a2fec
-           (spapr->eff.caps[SPAPR_CAP_VSX] != spapr->def.caps[SPAPR_CAP_VSX]);
4a2fec
+/* Used to generate the migration field and needed function for a spapr cap */
4a2fec
+#define SPAPR_CAP_MIG_STATE(cap, ccap)                  \
4a2fec
+static bool spapr_cap_##cap##_needed(void *opaque)      \
4a2fec
+{                                                       \
4a2fec
+    sPAPRMachineState *spapr = opaque;                  \
4a2fec
+                                                        \
4a2fec
+    return spapr->cmd_line_caps[SPAPR_CAP_##ccap] &&    \
4a2fec
+           (spapr->eff.caps[SPAPR_CAP_##ccap] !=        \
4a2fec
+            spapr->def.caps[SPAPR_CAP_##ccap]);         \
4a2fec
+}                                                       \
4a2fec
+                                                        \
4a2fec
+const VMStateDescription vmstate_spapr_cap_##cap = {    \
4a2fec
+    .name = "spapr/cap/" #cap,                          \
4a2fec
+    .version_id = 1,                                    \
4a2fec
+    .minimum_version_id = 1,                            \
4a2fec
+    .needed = spapr_cap_##cap##_needed,                 \
4a2fec
+    .fields = (VMStateField[]) {                        \
4a2fec
+        VMSTATE_UINT8(mig.caps[SPAPR_CAP_##ccap],       \
4a2fec
+                      sPAPRMachineState),               \
4a2fec
+        VMSTATE_END_OF_LIST()                           \
4a2fec
+    },                                                  \
4a2fec
 }
4a2fec
 
4a2fec
-const VMStateDescription vmstate_spapr_cap_vsx = {
4a2fec
-    .name = "spapr/cap/vsx",
4a2fec
-    .version_id = 1,
4a2fec
-    .minimum_version_id = 1,
4a2fec
-    .needed = spapr_cap_vsx_needed,
4a2fec
-    .fields = (VMStateField[]) {
4a2fec
-        VMSTATE_UINT8(mig.caps[SPAPR_CAP_VSX], sPAPRMachineState),
4a2fec
-        VMSTATE_END_OF_LIST()
4a2fec
-    },
4a2fec
-};
4a2fec
-
4a2fec
-static bool spapr_cap_dfp_needed(void *opaque)
4a2fec
-{
4a2fec
-    sPAPRMachineState *spapr = opaque;
4a2fec
-
4a2fec
-    return spapr->cmd_line_caps[SPAPR_CAP_DFP] &&
4a2fec
-           (spapr->eff.caps[SPAPR_CAP_DFP] != spapr->def.caps[SPAPR_CAP_DFP]);
4a2fec
-}
4a2fec
-
4a2fec
-const VMStateDescription vmstate_spapr_cap_dfp = {
4a2fec
-    .name = "spapr/cap/dfp",
4a2fec
-    .version_id = 1,
4a2fec
-    .minimum_version_id = 1,
4a2fec
-    .needed = spapr_cap_dfp_needed,
4a2fec
-    .fields = (VMStateField[]) {
4a2fec
-        VMSTATE_UINT8(mig.caps[SPAPR_CAP_DFP], sPAPRMachineState),
4a2fec
-        VMSTATE_END_OF_LIST()
4a2fec
-    },
4a2fec
-};
4a2fec
+SPAPR_CAP_MIG_STATE(htm, HTM);
4a2fec
+SPAPR_CAP_MIG_STATE(vsx, VSX);
4a2fec
+SPAPR_CAP_MIG_STATE(dfp, DFP);
4a2fec
 
4a2fec
 void spapr_caps_reset(sPAPRMachineState *spapr)
4a2fec
 {
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec