}
+/* Returns -1 on error, 0 if SEV is not supported, 1 if SEV is supported */
static int
virQEMUCapsProbeQMPSEVCapabilities(virQEMUCapsPtr qemuCaps,
qemuMonitorPtr mon)
{
+ int rc = -1;
virSEVCapability *caps = NULL;
- if (qemuMonitorGetSEVCapabilities(mon, &caps) < 0)
- return -1;
+ if ((rc = qemuMonitorGetSEVCapabilities(mon, &caps)) <= 0)
+ return rc;
virSEVCapabilitiesFree(qemuCaps->sevCapabilities);
qemuCaps->sevCapabilities = caps;
- return 0;
+ return rc;
}
/* Probe for SEV capabilities */
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST)) {
- if (virQEMUCapsProbeQMPSEVCapabilities(qemuCaps, mon) < 0)
+ int rc = virQEMUCapsProbeQMPSEVCapabilities(qemuCaps, mon);
+
+ if (rc < 0)
+ goto cleanup;
+
+ if (rc == 0)
virQEMUCapsClear(qemuCaps, QEMU_CAPS_SEV_GUEST);
}
}
+/**
+ * qemuMonitorJSONGetSEVCapabilities:
+ * @mon: qemu monitor object
+ * @capabilities: pointer to pointer to a SEV capability structure to be filled
+ *
+ * This function queries and fills in AMD's SEV platform-specific data.
+ * Note that from QEMU's POV both -object sev-guest and query-sev-capabilities
+ * can be present even if SEV is not available, which basically leaves us with
+ * checking for JSON "GenericError" in order to differentiate between
+ * compiled-in support and actual SEV support on the platform.
+ *
+ * Returns -1 on error, 0 if SEV is not supported, and 1 if SEV is supported on
+ * the platform.
+ */
int
qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon,
virSEVCapability **capabilities)
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
- /* Both -object sev-guest and query-sev-capabilities can be present
- * even if SEV is not available */
+ /* QEMU has only compiled-in support of SEV */
if (qemuMonitorJSONHasError(reply, "GenericError")) {
ret = 0;
goto cleanup;
capability->cbitpos = cbitpos;
capability->reduced_phys_bits = reduced_phys_bits;
VIR_STEAL_PTR(*capabilities, capability);
- ret = 0;
-
+ ret = 1;
cleanup:
virJSONValueFree(cmd);
virJSONValueFree(reply);
<flag name='tpm-emulator'/>
<flag name='mch'/>
<flag name='mch.extended-tseg-mbytes'/>
- <flag name='sev-guest'/>
<flag name='usb-storage.werror'/>
<flag name='egl-headless'/>
<flag name='vfio-pci.display'/>