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

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