[RFC PATCH v3 7/9] qemu: Implement the SBBC pSeries feature

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is the first pSeries-specific optional feature that is
used to represent a hardware bug and to control how it will
be exposed to the guest.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 docs/schemas/domaincommon.rng                      | 15 +++++++
 src/conf/domain_conf.c                             | 47 ++++++++++++++++++++++
 src/conf/domain_conf.h                             | 12 ++++++
 src/libvirt_private.syms                           |  2 +
 src/qemu/qemu_command.c                            | 13 ++++++
 src/qemu/qemu_domain.c                             | 13 ++++++
 .../pseries-features-invalid-machine.xml           |  1 +
 tests/qemuxml2argvdata/pseries-features.args       |  2 +-
 tests/qemuxml2argvdata/pseries-features.xml        |  1 +
 tests/qemuxml2argvtest.c                           |  1 +
 tests/qemuxml2xmltest.c                            |  1 +
 11 files changed, 107 insertions(+), 1 deletion(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index b4143f5bc3..eaec426121 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4802,6 +4802,11 @@
               <ref name="featurestate"/>
             </element>
           </optional>
+          <optional>
+            <element name="sbbc">
+              <ref name="hwbugstate"/>
+            </element>
+          </optional>
           <optional>
             <ref name="vmcoreinfo"/>
           </optional>
@@ -5824,6 +5829,16 @@
     </attribute>
   </define>
 
+  <define name="hwbugstate">
+    <attribute name="state">
+      <choice>
+        <value>broken</value>
+        <value>workaround</value>
+        <value>fixed</value>
+      </choice>
+    </attribute>
+  </define>
+
   <!--
        Optional hypervisor extensions in their own namespace:
          QEmu
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1c4568396d..a112215560 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -153,6 +153,7 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
               "hpt",
               "vmcoreinfo",
               "htm",
+              "sbbc",
 );
 
 VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_LAST,
@@ -913,6 +914,14 @@ VIR_ENUM_IMPL(virDomainHPTResizing,
               "required",
 );
 
+VIR_ENUM_IMPL(virDomainHWBug,
+              VIR_DOMAIN_HWBUG_LAST,
+              "none",
+              "broken",
+              "workaround",
+              "fixed",
+);
+
 /* Internal mapping: subset of block job types that can be present in
  * <mirror> XML (remaining types are not two-phase). */
 VIR_ENUM_DECL(virDomainBlockJob)
@@ -19353,6 +19362,23 @@ virDomainDefParseXML(xmlDocPtr xml,
             VIR_FREE(tmp);
             break;
 
+        case VIR_DOMAIN_FEATURE_SBBC:
+            if (!(tmp = virXMLPropString(nodes[i], "state"))) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("missing state attribute '%s' of feature '%s'"),
+                               tmp, virDomainFeatureTypeToString(val));
+                goto error;
+            }
+            if ((def->features[val] = virDomainHWBugTypeFromString(tmp)) < 0 ||
+                def->features[val] == VIR_DOMAIN_HWBUG_NONE) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("unknown state attribute '%s' of feature '%s'"),
+                               tmp, virDomainFeatureTypeToString(val));
+                goto error;
+            }
+            VIR_FREE(tmp);
+            break;
+
         /* coverity[dead_error_begin] */
         case VIR_DOMAIN_FEATURE_LAST:
             break;
@@ -21520,6 +21546,18 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
             }
             break;
 
+        case VIR_DOMAIN_FEATURE_SBBC:
+            if (src->features[i] != dst->features[i]) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("State of feature '%s' differs: "
+                                 "source: '%s=%s', destination: '%s=%s'"),
+                               featureName,
+                               "state", virDomainHWBugTypeToString(src->features[i]),
+                               "state", virDomainHWBugTypeToString(dst->features[i]));
+                return false;
+            }
+            break;
+
         case VIR_DOMAIN_FEATURE_LAST:
             break;
         }
@@ -27051,6 +27089,15 @@ virDomainDefFormatInternal(virDomainDefPtr def,
                                   virDomainHPTResizingTypeToString(def->features[i]));
                 break;
 
+            case VIR_DOMAIN_FEATURE_SBBC:
+                if (def->features[i] == VIR_DOMAIN_HWBUG_NONE)
+                    break;
+
+                virBufferAsprintf(buf, "<%s state='%s'/>\n",
+                                  name,
+                                  virDomainHWBugTypeToString(def->features[i]));
+                break;
+
             /* coverity[dead_error_begin] */
             case VIR_DOMAIN_FEATURE_LAST:
                 break;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 79530101e9..a907df7830 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1747,6 +1747,7 @@ typedef enum {
     VIR_DOMAIN_FEATURE_HPT,
     VIR_DOMAIN_FEATURE_VMCOREINFO,
     VIR_DOMAIN_FEATURE_HTM,
+    VIR_DOMAIN_FEATURE_SBBC,
 
     VIR_DOMAIN_FEATURE_LAST
 } virDomainFeature;
@@ -1887,6 +1888,17 @@ typedef enum {
 
 VIR_ENUM_DECL(virDomainHPTResizing);
 
+typedef enum {
+    VIR_DOMAIN_HWBUG_NONE = 0,
+    VIR_DOMAIN_HWBUG_BROKEN,
+    VIR_DOMAIN_HWBUG_WORKAROUND,
+    VIR_DOMAIN_HWBUG_FIXED,
+
+    VIR_DOMAIN_HWBUG_LAST
+} virDomainHWBug;
+
+VIR_ENUM_DECL(virDomainHWBug);
+
 /* Operating system configuration data & machine / arch */
 typedef struct _virDomainOSEnv virDomainOSEnv;
 typedef virDomainOSEnv *virDomainOSEnvPtr;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8a62ea159e..2f3ffed36e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -398,6 +398,8 @@ virDomainHostdevSubsysTypeToString;
 virDomainHPTResizingTypeToString;
 virDomainHubTypeFromString;
 virDomainHubTypeToString;
+virDomainHWBugTypeFromString;
+virDomainHWBugTypeToString;
 virDomainHypervTypeFromString;
 virDomainHypervTypeToString;
 virDomainInputBusTypeToString;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d40c038660..1d781d1abd 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7123,6 +7123,8 @@ virDomainFeatureToQEMUCaps(int feature)
     switch ((virDomainFeature) feature) {
     case VIR_DOMAIN_FEATURE_HTM:
         return QEMU_CAPS_MACHINE_PSERIES_CAP_HTM;
+    case VIR_DOMAIN_FEATURE_SBBC:
+        return QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC;
     case VIR_DOMAIN_FEATURE_ACPI:
     case VIR_DOMAIN_FEATURE_APIC:
     case VIR_DOMAIN_FEATURE_PAE:
@@ -7153,6 +7155,8 @@ virDomainFeatureToMachineOption(int feature)
     switch ((virDomainFeature) feature) {
     case VIR_DOMAIN_FEATURE_HTM:
         return "cap-htm";
+    case VIR_DOMAIN_FEATURE_SBBC:
+        return "cap-sbbc";
     case VIR_DOMAIN_FEATURE_ACPI:
     case VIR_DOMAIN_FEATURE_APIC:
     case VIR_DOMAIN_FEATURE_PAE:
@@ -7463,6 +7467,15 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
                     goto cleanup;
                 break;
 
+            case VIR_DOMAIN_FEATURE_SBBC:
+                if (def->features[i] == VIR_DOMAIN_HWBUG_NONE)
+                    break;
+
+                value = virDomainHWBugTypeToString(def->features[i]);
+                if (qemuBuildMachineCommandLineFeature(&buf, i, value, qemuCaps) < 0)
+                    goto cleanup;
+                break;
+
             case VIR_DOMAIN_FEATURE_ACPI:
             case VIR_DOMAIN_FEATURE_APIC:
             case VIR_DOMAIN_FEATURE_PAE:
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index fa32dd1075..38059215c6 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3390,6 +3390,19 @@ qemuDomainDefValidateFeatures(const virDomainDef *def)
             }
             break;
 
+        case VIR_DOMAIN_FEATURE_SBBC:
+            if (def->features[i] != VIR_DOMAIN_HWBUG_NONE &&
+                !qemuDomainIsPSeries(def)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("The '%s' feature is not supported for "
+                                 "architecture '%s' or machine type '%s'"),
+                               featureName,
+                               virArchToString(def->os.arch),
+                               def->os.machine);
+                return -1;
+            }
+            break;
+
         case VIR_DOMAIN_FEATURE_ACPI:
         case VIR_DOMAIN_FEATURE_APIC:
         case VIR_DOMAIN_FEATURE_PAE:
diff --git a/tests/qemuxml2argvdata/pseries-features-invalid-machine.xml b/tests/qemuxml2argvdata/pseries-features-invalid-machine.xml
index 76cbf0737f..0a6fcedc0c 100644
--- a/tests/qemuxml2argvdata/pseries-features-invalid-machine.xml
+++ b/tests/qemuxml2argvdata/pseries-features-invalid-machine.xml
@@ -10,6 +10,7 @@
     <!-- pSeries features can't be enabled for non-pSeries guests -->
     <hpt resizing='enabled'/>
     <htm state='on'/>
+    <sbbc state='broken'/>
   </features>
   <devices>
     <emulator>/usr/bin/qemu-system-x86_64</emulator>
diff --git a/tests/qemuxml2argvdata/pseries-features.args b/tests/qemuxml2argvdata/pseries-features.args
index 0517ca8237..7c9b803af9 100644
--- a/tests/qemuxml2argvdata/pseries-features.args
+++ b/tests/qemuxml2argvdata/pseries-features.args
@@ -7,7 +7,7 @@ QEMU_AUDIO_DRV=none \
 /usr/bin/qemu-system-ppc64 \
 -name guest \
 -S \
--machine pseries,accel=tcg,resize-hpt=required,cap-htm=on \
+-machine pseries,accel=tcg,resize-hpt=required,cap-htm=on,cap-sbbc=broken \
 -m 512 \
 -smp 1,sockets=1,cores=1,threads=1 \
 -uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
diff --git a/tests/qemuxml2argvdata/pseries-features.xml b/tests/qemuxml2argvdata/pseries-features.xml
index a0e98db8b2..273f74c285 100644
--- a/tests/qemuxml2argvdata/pseries-features.xml
+++ b/tests/qemuxml2argvdata/pseries-features.xml
@@ -11,6 +11,7 @@
   <features>
     <hpt resizing='required'/>
     <htm state='on'/>
+    <sbbc state='broken'/>
   </features>
   <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 03f8c429e0..284cb7fb68 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1899,6 +1899,7 @@ mymain(void)
     DO_TEST("pseries-features",
             QEMU_CAPS_MACHINE_OPT,
             QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
+            QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
             QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
     DO_TEST_FAILURE("pseries-features",
                     QEMU_CAPS_MACHINE_OPT);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index b9a8bd6f14..a063e8a7a3 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -766,6 +766,7 @@ mymain(void)
     DO_TEST("pseries-features",
             QEMU_CAPS_MACHINE_OPT,
             QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
+            QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC,
             QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
 
     DO_TEST("pseries-serial-native",
-- 
2.14.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux