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

[libvirt] [PATCH] use virGetLastErrorMessage instead of virGetLastError to check for NULL in qemu



---
 src/qemu/qemu_capabilities.c | 18 ++++++++----------
 src/qemu/qemu_driver.c       | 12 +++++-------
 2 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b223837..af35f89 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3089,10 +3089,9 @@ virQEMUCapsInitCached(virQEMUCapsPtr qemuCaps, const char *cacheDir)
 
     if (virQEMUCapsLoadCache(qemuCaps, capsfile, &qemuctime, &selfctime,
                              &selfvers) < 0) {
-        virErrorPtr err = virGetLastError();
+        const char *err = virGetLastErrorMessage();
         VIR_WARN("Failed to load cached caps from '%s' for '%s': %s",
-                 capsfile, qemuCaps->binary, err ? NULLSTR(err->message) :
-                 _("unknown error"));
+                 capsfile, qemuCaps->binary, err);
         virResetLastError();
         ret = 0;
         virQEMUCapsReset(qemuCaps);
@@ -3320,9 +3319,9 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
     /* @mon is supposed to be locked by callee */
 
     if (qemuMonitorSetCapabilities(mon) < 0) {
-        virErrorPtr err = virGetLastError();
+        const char *err = virGetLastErrorMessage();
         VIR_DEBUG("Failed to set monitor capabilities %s",
-                  err ? err->message : "<unknown problem>");
+                  err);
         ret = 0;
         goto cleanup;
     }
@@ -3330,9 +3329,9 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
     if (qemuMonitorGetVersion(mon,
                               &major, &minor, &micro,
                               &package) < 0) {
-        virErrorPtr err = virGetLastError();
+        const char *err = virGetLastErrorMessage();
         VIR_DEBUG("Failed to query monitor version %s",
-                  err ? err->message : "<unknown problem>");
+                  err);
         ret = 0;
         goto cleanup;
     }
@@ -3561,15 +3560,14 @@ virQEMUCapsLogProbeFailure(const char *binary)
         { .key = "LIBVIRT_QEMU_BINARY", .s = binary, .iv = 0 },
         { .key = NULL },
     };
-    virErrorPtr err = virGetLastError();
+    const char *err = virGetLastErrorMessage();
 
     virLogMessage(&virLogSelf,
                   VIR_LOG_WARN,
                   __FILE__, __LINE__, __func__,
                   meta,
                   _("Failed to probe capabilities for %s: %s"),
-                  binary, err && err->message ? err->message :
-                  _("unknown failure"));
+                  binary, err);
 }
 
 
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 29c3bc8..85e5441 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -277,7 +277,7 @@ qemuAutostartDomain(virDomainObjPtr vm,
                     void *opaque)
 {
     struct qemuAutostartData *data = opaque;
-    virErrorPtr err;
+    const char *err;
     int flags = 0;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(data->driver);
     int ret = -1;
@@ -291,19 +291,17 @@ qemuAutostartDomain(virDomainObjPtr vm,
     if (vm->autostart &&
         !virDomainObjIsActive(vm)) {
         if (qemuProcessBeginJob(data->driver, vm) < 0) {
-            err = virGetLastError();
+            err = virGetLastErrorMessage();
             VIR_ERROR(_("Failed to start job on VM '%s': %s"),
-                      vm->def->name,
-                      err ? err->message : _("unknown error"));
+                      vm->def->name, err);
             goto cleanup;
         }
 
         if (qemuDomainObjStart(data->conn, data->driver, vm, flags,
                                QEMU_ASYNC_JOB_START) < 0) {
-            err = virGetLastError();
+            err = virGetLastErrorMessage();
             VIR_ERROR(_("Failed to autostart VM '%s': %s"),
-                      vm->def->name,
-                      err ? err->message : _("unknown error"));
+                      vm->def->name, err);
         }
 
         qemuProcessEndJob(data->driver, vm);
-- 
2.5.0


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