|
|
37e7a1 |
From d5704100a478118313ce89e8725c714f20deb094 Mon Sep 17 00:00:00 2001
|
|
|
37e7a1 |
From: Suraj Jitindar Singh <sursingh@redhat.com>
|
|
|
37e7a1 |
Date: Tue, 13 Mar 2018 05:21:32 +0100
|
|
|
37e7a1 |
Subject: [PATCH 10/17] ppc/spapr-caps: Add support for custom
|
|
|
37e7a1 |
spapr_capabilities
|
|
|
37e7a1 |
|
|
|
37e7a1 |
RH-Author: Suraj Jitindar Singh <sursingh@redhat.com>
|
|
|
37e7a1 |
Message-id: <1520918499-27663-5-git-send-email-sursingh@redhat.com>
|
|
|
37e7a1 |
Patchwork-id: 79246
|
|
|
37e7a1 |
O-Subject: [RHEL7.5 qemu-kvm-rhev PATCH 04/11] ppc/spapr-caps: Add support for custom spapr_capabilities
|
|
|
37e7a1 |
Bugzilla: 1554957
|
|
|
37e7a1 |
RH-Acked-by: David Gibson <dgibson@redhat.com>
|
|
|
37e7a1 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
37e7a1 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
37e7a1 |
|
|
|
37e7a1 |
From: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
|
|
|
37e7a1 |
|
|
|
37e7a1 |
There are currently 2 implemented types of spapr-caps, boolean and
|
|
|
37e7a1 |
tristate. However there may be a need for caps which don't fit either of
|
|
|
37e7a1 |
these options. Add a custom capability type for which a list of custom
|
|
|
37e7a1 |
valid strings can be specified and implement the get/set functions for
|
|
|
37e7a1 |
these. Also add a field for help text to describe the available options.
|
|
|
37e7a1 |
|
|
|
37e7a1 |
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
|
|
|
37e7a1 |
[dwg: Change "help" option to "?" matching qemu conventions]
|
|
|
37e7a1 |
[dwg: Add ATTRIBUTE_UNUSED to avoid breaking bisect]
|
|
|
37e7a1 |
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
|
|
|
37e7a1 |
|
|
|
37e7a1 |
(cherry picked from commit 87175d1bc5272fff5cffb05c410b39f839dfc948)
|
|
|
37e7a1 |
|
|
|
37e7a1 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1548919
|
|
|
37e7a1 |
|
|
|
37e7a1 |
Signed-off-by: Suraj Jitindar Singh <sursingh@redhat.com>
|
|
|
37e7a1 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
37e7a1 |
---
|
|
|
37e7a1 |
hw/ppc/spapr_caps.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
37e7a1 |
1 file changed, 70 insertions(+)
|
|
|
37e7a1 |
|
|
|
37e7a1 |
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
|
|
|
37e7a1 |
index 99a4b71..3d8b796 100644
|
|
|
37e7a1 |
--- a/hw/ppc/spapr_caps.c
|
|
|
37e7a1 |
+++ b/hw/ppc/spapr_caps.c
|
|
|
37e7a1 |
@@ -32,6 +32,20 @@
|
|
|
37e7a1 |
|
|
|
37e7a1 |
#include "hw/ppc/spapr.h"
|
|
|
37e7a1 |
|
|
|
37e7a1 |
+typedef struct sPAPRCapPossible {
|
|
|
37e7a1 |
+ int num; /* size of vals array below */
|
|
|
37e7a1 |
+ const char *help; /* help text for vals */
|
|
|
37e7a1 |
+ /*
|
|
|
37e7a1 |
+ * Note:
|
|
|
37e7a1 |
+ * - because of the way compatibility is determined vals MUST be ordered
|
|
|
37e7a1 |
+ * such that later options are a superset of all preceding options.
|
|
|
37e7a1 |
+ * - the order of vals must be preserved, that is their index is important,
|
|
|
37e7a1 |
+ * however vals may be added to the end of the list so long as the above
|
|
|
37e7a1 |
+ * point is observed
|
|
|
37e7a1 |
+ */
|
|
|
37e7a1 |
+ const char *vals[];
|
|
|
37e7a1 |
+} sPAPRCapPossible;
|
|
|
37e7a1 |
+
|
|
|
37e7a1 |
typedef struct sPAPRCapabilityInfo {
|
|
|
37e7a1 |
const char *name;
|
|
|
37e7a1 |
const char *description;
|
|
|
37e7a1 |
@@ -41,6 +55,8 @@ typedef struct sPAPRCapabilityInfo {
|
|
|
37e7a1 |
ObjectPropertyAccessor *get;
|
|
|
37e7a1 |
ObjectPropertyAccessor *set;
|
|
|
37e7a1 |
const char *type;
|
|
|
37e7a1 |
+ /* Possible values if this is a custom string type */
|
|
|
37e7a1 |
+ sPAPRCapPossible *possible;
|
|
|
37e7a1 |
/* Make sure the virtual hardware can support this capability */
|
|
|
37e7a1 |
void (*apply)(sPAPRMachineState *spapr, uint8_t val, Error **errp);
|
|
|
37e7a1 |
} sPAPRCapabilityInfo;
|
|
|
37e7a1 |
@@ -133,6 +149,60 @@ out:
|
|
|
37e7a1 |
g_free(val);
|
|
|
37e7a1 |
}
|
|
|
37e7a1 |
|
|
|
37e7a1 |
+static void ATTRIBUTE_UNUSED spapr_cap_get_string(Object *obj, Visitor *v,
|
|
|
37e7a1 |
+ const char *name,
|
|
|
37e7a1 |
+ void *opaque, Error **errp)
|
|
|
37e7a1 |
+{
|
|
|
37e7a1 |
+ sPAPRCapabilityInfo *cap = opaque;
|
|
|
37e7a1 |
+ sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
|
|
|
37e7a1 |
+ char *val = NULL;
|
|
|
37e7a1 |
+ uint8_t value = spapr_get_cap(spapr, cap->index);
|
|
|
37e7a1 |
+
|
|
|
37e7a1 |
+ if (value >= cap->possible->num) {
|
|
|
37e7a1 |
+ error_setg(errp, "Invalid value (%d) for cap-%s", value, cap->name);
|
|
|
37e7a1 |
+ return;
|
|
|
37e7a1 |
+ }
|
|
|
37e7a1 |
+
|
|
|
37e7a1 |
+ val = g_strdup(cap->possible->vals[value]);
|
|
|
37e7a1 |
+
|
|
|
37e7a1 |
+ visit_type_str(v, name, &val, errp);
|
|
|
37e7a1 |
+ g_free(val);
|
|
|
37e7a1 |
+}
|
|
|
37e7a1 |
+
|
|
|
37e7a1 |
+static void ATTRIBUTE_UNUSED spapr_cap_set_string(Object *obj, Visitor *v,
|
|
|
37e7a1 |
+ const char *name,
|
|
|
37e7a1 |
+ void *opaque, Error **errp)
|
|
|
37e7a1 |
+{
|
|
|
37e7a1 |
+ sPAPRCapabilityInfo *cap = opaque;
|
|
|
37e7a1 |
+ sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
|
|
|
37e7a1 |
+ Error *local_err = NULL;
|
|
|
37e7a1 |
+ uint8_t i;
|
|
|
37e7a1 |
+ char *val;
|
|
|
37e7a1 |
+
|
|
|
37e7a1 |
+ visit_type_str(v, name, &val, &local_err);
|
|
|
37e7a1 |
+ if (local_err) {
|
|
|
37e7a1 |
+ error_propagate(errp, local_err);
|
|
|
37e7a1 |
+ return;
|
|
|
37e7a1 |
+ }
|
|
|
37e7a1 |
+
|
|
|
37e7a1 |
+ if (!strcmp(val, "?")) {
|
|
|
37e7a1 |
+ error_setg(errp, "%s", cap->possible->help);
|
|
|
37e7a1 |
+ goto out;
|
|
|
37e7a1 |
+ }
|
|
|
37e7a1 |
+ for (i = 0; i < cap->possible->num; i++) {
|
|
|
37e7a1 |
+ if (!strcasecmp(val, cap->possible->vals[i])) {
|
|
|
37e7a1 |
+ spapr->cmd_line_caps[cap->index] = true;
|
|
|
37e7a1 |
+ spapr->eff.caps[cap->index] = i;
|
|
|
37e7a1 |
+ goto out;
|
|
|
37e7a1 |
+ }
|
|
|
37e7a1 |
+ }
|
|
|
37e7a1 |
+
|
|
|
37e7a1 |
+ error_setg(errp, "Invalid capability mode \"%s\" for cap-%s", val,
|
|
|
37e7a1 |
+ cap->name);
|
|
|
37e7a1 |
+out:
|
|
|
37e7a1 |
+ g_free(val);
|
|
|
37e7a1 |
+}
|
|
|
37e7a1 |
+
|
|
|
37e7a1 |
static void cap_htm_apply(sPAPRMachineState *spapr, uint8_t val, Error **errp)
|
|
|
37e7a1 |
{
|
|
|
37e7a1 |
if (!val) {
|
|
|
37e7a1 |
--
|
|
|
37e7a1 |
1.8.3.1
|
|
|
37e7a1 |
|