[libvirt] [PATCH 6/8] qemu: Add capability for the HTM pSeries feature

Andrea Bolognani abologna at redhat.com
Fri Mar 9 15:07:52 UTC 2018


This is the first capability that depends on an object property,
so we need to introduce a couple new functions at the same time.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 src/qemu/qemu_capabilities.c                       |  38 +++++
 src/qemu/qemu_capabilities.h                       |   1 +
 src/qemu/qemu_monitor.c                            |  13 ++
 src/qemu/qemu_monitor.h                            |   3 +
 src/qemu/qemu_monitor_json.c                       |  10 ++
 src/qemu/qemu_monitor_json.h                       |   5 +
 .../caps_2.12.0-gicv2.aarch64.replies              |  24 ++-
 .../caps_2.12.0-gicv2.aarch64.xml                  |   2 +-
 .../caps_2.12.0-gicv3.aarch64.replies              |  24 ++-
 .../caps_2.12.0-gicv3.aarch64.xml                  |   2 +-
 .../qemucapabilitiesdata/caps_2.12.0.ppc64.replies | 170 ++++++++++++++++++++-
 tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml   |   3 +-
 .../caps_2.12.0.x86_64.replies                     |  30 ++--
 tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml  |   2 +-
 14 files changed, 289 insertions(+), 38 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 83ec8a67d5..0165de0407 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -460,6 +460,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "machine.pseries.max-cpu-compat",
               "dump-completed",
               "qom-list-properties",
+              "machine.pseries.cap-htm",
     );
 
 
@@ -1950,6 +1951,21 @@ static struct virQEMUCapsObjectTypeProps virQEMUCapsDeviceProps[] = {
       QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE },
 };
 
+/* Object properties.
+ *
+ * The following can be probed using the qom-list-properties QMP command
+ */
+
+static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsSPAPRMachine[] = {
+    { "cap-htm", QEMU_CAPS_MACHINE_PSERIES_CAP_HTM },
+};
+
+static struct virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
+    { "spapr-machine", virQEMUCapsObjectPropsSPAPRMachine,
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsSPAPRMachine),
+      -1 },
+};
+
 /* see documentation for virQEMUCapsQMPSchemaGetByPath for the query format */
 static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = {
     { "blockdev-add/arg-type/options/+gluster/debug-level", QEMU_CAPS_GLUSTER_DEBUG_LEVEL},
@@ -2876,6 +2892,28 @@ virQEMUCapsProbeQMPObjects(virQEMUCapsPtr qemuCaps,
         virStringListFreeCount(values, nvalues);
     }
 
+    /* If the qom-list-properties QMP command is available, then we
+     * can probe objects in addition to devices */
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QOM_LIST_PROPERTIES)) {
+        for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsObjectProps); i++) {
+            const char *type = virQEMUCapsObjectProps[i].type;
+            int cap = virQEMUCapsObjectProps[i].capsCondition;
+
+            if (cap >= 0 && !virQEMUCapsGet(qemuCaps, cap))
+                continue;
+
+            if ((nvalues = qemuMonitorGetObjectProps(mon,
+                                                     type,
+                                                     &values)) < 0)
+                return -1;
+            virQEMUCapsProcessStringFlags(qemuCaps,
+                                          virQEMUCapsObjectProps[i].nprops,
+                                          virQEMUCapsObjectProps[i].props,
+                                          nvalues, values);
+            virStringListFreeCount(values, nvalues);
+        }
+    }
+
     /* Prefer -chardev spicevmc (detected earlier) over -device spicevmc */
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_SPICEVMC))
         virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_SPICEVMC);
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index ce07dfd6b1..62a1138130 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -445,6 +445,7 @@ typedef enum {
     QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT, /* -machine pseries,max-cpu-compat= */
     QEMU_CAPS_DUMP_COMPLETED, /* DUMP_COMPLETED event */
     QEMU_CAPS_QOM_LIST_PROPERTIES, /* qom-list-properties QMP command */
+    QEMU_CAPS_MACHINE_PSERIES_CAP_HTM, /* -machine pseries,cap-htm= */
 
     QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 8ec759fe3f..6e43d268e1 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3954,6 +3954,19 @@ qemuMonitorGetDeviceProps(qemuMonitorPtr mon,
 }
 
 
+int
+qemuMonitorGetObjectProps(qemuMonitorPtr mon,
+                          const char *type,
+                          char ***props)
+{
+    VIR_DEBUG("type=%s props=%p", type, props);
+
+    QEMU_CHECK_MONITOR_JSON(mon);
+
+    return qemuMonitorJSONGetObjectProps(mon, type, props);
+}
+
+
 char *
 qemuMonitorGetTargetArch(qemuMonitorPtr mon)
 {
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 26074ef7dd..e83e49cd51 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1097,6 +1097,9 @@ int qemuMonitorGetObjectTypes(qemuMonitorPtr mon,
 int qemuMonitorGetDeviceProps(qemuMonitorPtr mon,
                               const char *type,
                               char ***props);
+int qemuMonitorGetObjectProps(qemuMonitorPtr mon,
+                              const char *type,
+                              char ***props);
 char *qemuMonitorGetTargetArch(qemuMonitorPtr mon);
 
 int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 141873a705..bb7e6e12e7 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6139,6 +6139,16 @@ qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon,
 }
 
 
+int
+qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon,
+                              const char *type,
+                              char ***props)
+{
+    return qemuMonitorJSONGetProps(mon, type, props,
+                                   "qom-list-properties");
+}
+
+
 char *
 qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon)
 {
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 4a1da725d1..2ce208845a 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -445,6 +445,11 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon,
                                   const char *type,
                                   char ***props)
     ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
+int qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon,
+                                  const char *type,
+                                  char ***props)
+    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
+
 char *qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon);
 
 int qemuMonitorJSONNBDServerStart(qemuMonitorPtr mon,
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0-gicv2.aarch64.replies b/tests/qemucapabilitiesdata/caps_2.12.0-gicv2.aarch64.replies
index 9b1ed887e9..1a328d6bce 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0-gicv2.aarch64.replies
+++ b/tests/qemucapabilitiesdata/caps_2.12.0-gicv2.aarch64.replies
@@ -5208,6 +5208,14 @@
   "id": "libvirt-35"
 }
 
+{
+  "id": "libvirt-36",
+  "error": {
+    "class": "DeviceNotFound",
+    "desc": "Class 'spapr-machine' not found"
+  }
+}
+
 {
   "return": [
     {
@@ -5497,7 +5505,7 @@
       "cpu-max": 1
     }
   ],
-  "id": "libvirt-36"
+  "id": "libvirt-37"
 }
 
 {
@@ -5668,20 +5676,20 @@
       "static": false
     }
   ],
-  "id": "libvirt-37"
+  "id": "libvirt-38"
 }
 
 {
   "return": [
   ],
-  "id": "libvirt-38"
+  "id": "libvirt-39"
 }
 
 {
   "return": [
     "emulator"
   ],
-  "id": "libvirt-39"
+  "id": "libvirt-40"
 }
 
 {
@@ -6838,7 +6846,7 @@
       "option": "drive"
     }
   ],
-  "id": "libvirt-40"
+  "id": "libvirt-41"
 }
 
 {
@@ -6896,7 +6904,7 @@
       "capability": "x-multifd"
     }
   ],
-  "id": "libvirt-41"
+  "id": "libvirt-42"
 }
 
 {
@@ -16953,7 +16961,7 @@
       "meta-type": "object"
     }
   ],
-  "id": "libvirt-42"
+  "id": "libvirt-43"
 }
 
 {
@@ -16969,7 +16977,7 @@
       "kernel": true
     }
   ],
-  "id": "libvirt-43"
+  "id": "libvirt-44"
 }
 
 {
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.12.0-gicv2.aarch64.xml
index 9c4e40973b..dab701b726 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0-gicv2.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0-gicv2.aarch64.xml
@@ -190,7 +190,7 @@
   <flag name='qom-list-properties'/>
   <version>2011050</version>
   <kvmVersion>0</kvmVersion>
-  <microcodeVersion>315524</microcodeVersion>
+  <microcodeVersion>315645</microcodeVersion>
   <package> (v2.11.0-2110-gf6d81cd)</package>
   <arch>aarch64</arch>
   <cpu type='kvm' name='pxa262'/>
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0-gicv3.aarch64.replies b/tests/qemucapabilitiesdata/caps_2.12.0-gicv3.aarch64.replies
index 9a12b14569..6a4302f2e0 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0-gicv3.aarch64.replies
+++ b/tests/qemucapabilitiesdata/caps_2.12.0-gicv3.aarch64.replies
@@ -5208,6 +5208,14 @@
   "id": "libvirt-35"
 }
 
+{
+  "id": "libvirt-36",
+  "error": {
+    "class": "DeviceNotFound",
+    "desc": "Class 'spapr-machine' not found"
+  }
+}
+
 {
   "return": [
     {
@@ -5497,7 +5505,7 @@
       "cpu-max": 1
     }
   ],
-  "id": "libvirt-36"
+  "id": "libvirt-37"
 }
 
 {
@@ -5668,20 +5676,20 @@
       "static": false
     }
   ],
-  "id": "libvirt-37"
+  "id": "libvirt-38"
 }
 
 {
   "return": [
   ],
-  "id": "libvirt-38"
+  "id": "libvirt-39"
 }
 
 {
   "return": [
     "emulator"
   ],
-  "id": "libvirt-39"
+  "id": "libvirt-40"
 }
 
 {
@@ -6838,7 +6846,7 @@
       "option": "drive"
     }
   ],
-  "id": "libvirt-40"
+  "id": "libvirt-41"
 }
 
 {
@@ -6896,7 +6904,7 @@
       "capability": "x-multifd"
     }
   ],
-  "id": "libvirt-41"
+  "id": "libvirt-42"
 }
 
 {
@@ -16953,7 +16961,7 @@
       "meta-type": "object"
     }
   ],
-  "id": "libvirt-42"
+  "id": "libvirt-43"
 }
 
 {
@@ -16969,7 +16977,7 @@
       "kernel": false
     }
   ],
-  "id": "libvirt-43"
+  "id": "libvirt-44"
 }
 
 {
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.12.0-gicv3.aarch64.xml
index 06e0068cbd..d14c7948b4 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0-gicv3.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0-gicv3.aarch64.xml
@@ -190,7 +190,7 @@
   <flag name='qom-list-properties'/>
   <version>2011050</version>
   <kvmVersion>0</kvmVersion>
-  <microcodeVersion>315524</microcodeVersion>
+  <microcodeVersion>315645</microcodeVersion>
   <package> (v2.11.0-2110-gf6d81cd)</package>
   <arch>aarch64</arch>
   <cpu type='kvm' name='pxa262'/>
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.replies b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.replies
index 0ccf0ad403..e941e59995 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.replies
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.replies
@@ -5279,6 +5279,162 @@
   "id": "libvirt-36"
 }
 
+{
+  "return": [
+    {
+      "name": "graphics",
+      "description": "Set on/off to enable/disable graphics emulation",
+      "type": "bool"
+    },
+    {
+      "name": "phandle-start",
+      "description": "The first phandle ID we may generate dynamically",
+      "type": "int"
+    },
+    {
+      "name": "dump-guest-core",
+      "description": "Include guest memory in  a core dump",
+      "type": "bool"
+    },
+    {
+      "name": "kernel-irqchip",
+      "description": "Configure KVM in-kernel irqchip",
+      "type": "on|off|split"
+    },
+    {
+      "name": "accel",
+      "description": "Accelerator list",
+      "type": "string"
+    },
+    {
+      "name": "append",
+      "description": "Linux kernel command line",
+      "type": "string"
+    },
+    {
+      "name": "dumpdtb",
+      "description": "Dump current dtb to a file and quit",
+      "type": "string"
+    },
+    {
+      "name": "igd-passthru",
+      "description": "Set on/off to enable/disable igd passthrou",
+      "type": "bool"
+    },
+    {
+      "name": "dt-compatible",
+      "description": "Overrides the \"compatible\" property of the dt root node",
+      "type": "string"
+    },
+    {
+      "name": "kernel",
+      "description": "Linux kernel image file",
+      "type": "string"
+    },
+    {
+      "name": "usb",
+      "description": "Set on/off to enable/disable usb",
+      "type": "bool"
+    },
+    {
+      "name": "suppress-vmdesc",
+      "description": "Set on to disable self-describing migration",
+      "type": "bool"
+    },
+    {
+      "name": "dtb",
+      "description": "Linux kernel device tree file",
+      "type": "string"
+    },
+    {
+      "name": "firmware",
+      "description": "Firmware image",
+      "type": "string"
+    },
+    {
+      "name": "mem-merge",
+      "description": "Enable/disable memory merge support",
+      "type": "bool"
+    },
+    {
+      "name": "initrd",
+      "description": "Linux initial ramdisk file",
+      "type": "string"
+    },
+    {
+      "name": "enforce-config-section",
+      "description": "Set on to enforce configuration section migration",
+      "type": "bool"
+    },
+    {
+      "name": "kvm-shadow-mem",
+      "description": "KVM shadow MMU size",
+      "type": "int"
+    },
+    {
+      "name": "cap-ibs",
+      "description": "Indirect Branch Speculation (broken, fixed-ibs, fixed-ccd)",
+      "type": "string"
+    },
+    {
+      "name": "cap-cfpc",
+      "description": "Cache Flush on Privilege Change (broken, workaround, fixed)",
+      "type": "string"
+    },
+    {
+      "name": "cap-sbbc",
+      "description": "Speculation Barrier Bounds Checking (broken, workaround, fixed)",
+      "type": "string"
+    },
+    {
+      "name": "cap-dfp",
+      "description": "Allow Decimal Floating Point (DFP)",
+      "type": "bool"
+    },
+    {
+      "name": "cap-htm",
+      "description": "Allow Hardware Transactional Memory (HTM)",
+      "type": "bool"
+    },
+    {
+      "name": "cap-vsx",
+      "description": "Allow Vector Scalar Extensions (VSX)",
+      "type": "bool"
+    },
+    {
+      "name": "cap-ibs",
+      "description": "Indirect Branch Speculation (broken, fixed-ibs, fixed-ccd)",
+      "type": "string"
+    },
+    {
+      "name": "cap-cfpc",
+      "description": "Cache Flush on Privilege Change (broken, workaround, fixed)",
+      "type": "string"
+    },
+    {
+      "name": "cap-sbbc",
+      "description": "Speculation Barrier Bounds Checking (broken, workaround, fixed)",
+      "type": "string"
+    },
+    {
+      "name": "cap-dfp",
+      "description": "Allow Decimal Floating Point (DFP)",
+      "type": "bool"
+    },
+    {
+      "name": "cap-htm",
+      "description": "Allow Hardware Transactional Memory (HTM)",
+      "type": "bool"
+    },
+    {
+      "name": "cap-vsx",
+      "description": "Allow Vector Scalar Extensions (VSX)",
+      "type": "bool"
+    }
+  ],
+  "id": "libvirt-37"
+}
+
 {
   "return": [
     {
@@ -5414,7 +5570,7 @@
       "cpu-max": 1
     }
   ],
-  "id": "libvirt-37"
+  "id": "libvirt-38"
 }
 
 {
@@ -7610,20 +7766,20 @@
       "static": false
     }
   ],
-  "id": "libvirt-38"
+  "id": "libvirt-39"
 }
 
 {
   "return": [
   ],
-  "id": "libvirt-39"
+  "id": "libvirt-40"
 }
 
 {
   "return": [
     "emulator"
   ],
-  "id": "libvirt-40"
+  "id": "libvirt-41"
 }
 
 {
@@ -8775,7 +8931,7 @@
       "option": "drive"
     }
   ],
-  "id": "libvirt-41"
+  "id": "libvirt-42"
 }
 
 {
@@ -8833,7 +8989,7 @@
       "capability": "x-multifd"
     }
   ],
-  "id": "libvirt-42"
+  "id": "libvirt-43"
 }
 
 {
@@ -18890,7 +19046,7 @@
       "meta-type": "object"
     }
   ],
-  "id": "libvirt-43"
+  "id": "libvirt-44"
 }
 
 {
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml
index a0df689c25..0a2b64e157 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml
@@ -186,9 +186,10 @@
   <flag name='machine.pseries.max-cpu-compat'/>
   <flag name='dump-completed'/>
   <flag name='qom-list-properties'/>
+  <flag name='machine.pseries.cap-htm'/>
   <version>2011050</version>
   <kvmVersion>0</kvmVersion>
-  <microcodeVersion>393199</microcodeVersion>
+  <microcodeVersion>397043</microcodeVersion>
   <package> (v2.11.0-2110-gf6d81cd)</package>
   <arch>ppc64</arch>
   <cpu type='kvm' name='default'/>
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies
index c161dd006b..c06bafa4ba 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.replies
@@ -4609,6 +4609,14 @@
   "id": "libvirt-39"
 }
 
+{
+  "id": "libvirt-40",
+  "error": {
+    "class": "DeviceNotFound",
+    "desc": "Class 'spapr-machine' not found"
+  }
+}
+
 {
   "return": [
     {
@@ -4815,7 +4823,7 @@
       "cpu-max": 255
     }
   ],
-  "id": "libvirt-40"
+  "id": "libvirt-41"
 }
 
 {
@@ -5329,7 +5337,7 @@
       "migration-safe": true
     }
   ],
-  "id": "libvirt-41"
+  "id": "libvirt-42"
 }
 
 {
@@ -5337,7 +5345,7 @@
     "tpm-crb",
     "tpm-tis"
   ],
-  "id": "libvirt-42"
+  "id": "libvirt-43"
 }
 
 {
@@ -5345,7 +5353,7 @@
     "passthrough",
     "emulator"
   ],
-  "id": "libvirt-43"
+  "id": "libvirt-44"
 }
 
 {
@@ -6636,7 +6644,7 @@
       "option": "drive"
     }
   ],
-  "id": "libvirt-44"
+  "id": "libvirt-45"
 }
 
 {
@@ -6694,7 +6702,7 @@
       "capability": "x-multifd"
     }
   ],
-  "id": "libvirt-45"
+  "id": "libvirt-46"
 }
 
 {
@@ -16751,7 +16759,7 @@
       "meta-type": "object"
     }
   ],
-  "id": "libvirt-46"
+  "id": "libvirt-47"
 }
 
 {
@@ -16939,7 +16947,7 @@
       }
     }
   },
-  "id": "libvirt-47"
+  "id": "libvirt-48"
 }
 
 {
@@ -17192,7 +17200,7 @@
       }
     }
   },
-  "id": "libvirt-48"
+  "id": "libvirt-49"
 }
 
 {
@@ -17380,7 +17388,7 @@
       }
     }
   },
-  "id": "libvirt-49"
+  "id": "libvirt-50"
 }
 
 {
@@ -17633,7 +17641,7 @@
       }
     }
   },
-  "id": "libvirt-50"
+  "id": "libvirt-51"
 }
 
 {
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
index fbdde1733f..dd910853f4 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
@@ -231,7 +231,7 @@
   <flag name='qom-list-properties'/>
   <version>2011050</version>
   <kvmVersion>0</kvmVersion>
-  <microcodeVersion>364740</microcodeVersion>
+  <microcodeVersion>364861</microcodeVersion>
   <package> (v2.11.0-2110-gf6d81cdec8-dirty)</package>
   <arch>x86_64</arch>
   <hostCPU type='kvm' model='base' migratability='yes'>
-- 
2.14.3




More information about the libvir-list mailing list