diff mbox series

[1/3] qemu: monitor: cleanup loadvm error handling

Message ID 05fe015e52f81def27c444ae323242d502bdf033.1554919494.git.crobinso@redhat.com
State Accepted
Commit a82c182171a58752d8423be1ce12715430fb1232
Headers show
Series qemu: monitor: detect more snapshot errors | expand

Commit Message

Cole Robinson April 10, 2019, 6:29 p.m. UTC
Drop redundant NULL checks, add error string prefixes, consolidate
a few indentical reports.

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 src/qemu/qemu_monitor_text.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 0b2c1a6aed..414da0ca28 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -215,28 +215,25 @@  int qemuMonitorTextLoadSnapshot(qemuMonitorPtr mon, const char *name)
     if (qemuMonitorHMPCommand(mon, cmd, &reply))
         goto cleanup;
 
-    if (strstr(reply, "No block device supports snapshots") != NULL) {
+    if (strstr(reply, "No block device supports snapshots")) {
         virReportError(VIR_ERR_OPERATION_INVALID, "%s",
                        _("this domain does not have a device to load snapshots"));
         goto cleanup;
-    } else if (strstr(reply, "Could not find snapshot") != NULL) {
+    } else if (strstr(reply, "Could not find snapshot")) {
         virReportError(VIR_ERR_OPERATION_INVALID,
                        _("the snapshot '%s' does not exist, and was not loaded"),
                        name);
         goto cleanup;
-    } else if (strstr(reply, "Snapshots not supported on device") != NULL) {
-        virReportError(VIR_ERR_OPERATION_INVALID, "%s", reply);
-        goto cleanup;
-    } else if (strstr(reply, "Could not open VM state file") != NULL) {
-        virReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
-        goto cleanup;
-    } else if (strstr(reply, "Error") != NULL
-             && strstr(reply, "while loading VM state") != NULL) {
-        virReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
+    } else if (strstr(reply, "Snapshots not supported on device")) {
+        virReportError(VIR_ERR_OPERATION_INVALID,
+                       _("Failed to load snapshot: %s"), reply);
         goto cleanup;
-    } else if (strstr(reply, "Error") != NULL
-             && strstr(reply, "while activating snapshot on") != NULL) {
-        virReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
+    } else if (strstr(reply, "Could not open VM state file") ||
+               (strstr(reply, "Error") &&
+                (strstr(reply, "while loading VM state") ||
+                 strstr(reply, "while activating snapshot on")))) {
+        virReportError(VIR_ERR_OPERATION_FAILED,
+                       _("Failed to load snapshot: %s"), reply);
         goto cleanup;
     }