]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_monitor_json: Report error in error paths in SEV related code
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 11 Jun 2024 08:44:24 +0000 (10:44 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 21 Jun 2024 07:25:32 +0000 (09:25 +0200)
While working on qemuMonitorJSONGetSEVMeasurement() and
qemuMonitorJSONGetSEVInfo() I've noticed that if these functions
fail, they do so without appropriate error set. Fill in error
reporting.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/qemu/qemu_monitor_json.c

index c5e758e7f86d39455cab5c5568571b58a8c18208..8f8f3c95f0862279ea5461fde2c7f8893c4dbd06 100644 (file)
@@ -7961,8 +7961,11 @@ qemuMonitorJSONGetSEVMeasurement(qemuMonitor *mon)
     if (!(data = qemuMonitorJSONGetReply(cmd, reply, VIR_JSON_TYPE_OBJECT)))
         return NULL;
 
-    if (!(tmp = virJSONValueObjectGetString(data, "data")))
+    if (!(tmp = virJSONValueObjectGetString(data, "data"))) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("query-sev-launch-measure reply was missing 'data'"));
         return NULL;
+    }
 
     return g_strdup(tmp);
 }
@@ -8005,8 +8008,11 @@ qemuMonitorJSONGetSEVInfo(qemuMonitor *mon,
     if (virJSONValueObjectGetNumberUint(data, "api-major", apiMajor) < 0 ||
         virJSONValueObjectGetNumberUint(data, "api-minor", apiMinor) < 0 ||
         virJSONValueObjectGetNumberUint(data, "build-id", buildID) < 0 ||
-        virJSONValueObjectGetNumberUint(data, "policy", policy) < 0)
+        virJSONValueObjectGetNumberUint(data, "policy", policy) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("query-sev reply was missing some data"));
         return -1;
+    }
 
     return 0;
 }