]> xenbits.xensource.com Git - libvirt.git/commitdiff
virterror: Add error message for unsupported operations.
authorPeter Krempa <pkrempa@redhat.com>
Thu, 9 Aug 2012 13:12:12 +0000 (15:12 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Sat, 11 Aug 2012 08:03:00 +0000 (10:03 +0200)
This patch introduces a new error code VIR_ERR_OPERATION_UNSUPPORTED to
mark error messages regarding operations that failed due to lack of
support on the hypervisor or other than libvirt issues.

The code is first used in reporting error if qemu does not support block
IO tuning variables yielding error message:
error: Unable to get block I/O throttle parameters
error: Operation not supported: block_io_throttle field
'total_bytes_sec' missing in qemu's output

instead of:
error: Unable to get block I/O throttle parameters
error: internal error cannot read total_bytes_sec

include/libvirt/virterror.h
src/qemu/qemu_monitor_json.c
src/util/virterror.c

index ad8e10169b108ad76be26b1b21cc4f666af76eb6..913fc5d3125641a724ea889c0f9059ccdec7ed06 100644 (file)
@@ -277,6 +277,8 @@ typedef enum {
     VIR_ERR_MIGRATE_UNSAFE = 81,        /* Migration is not safe */
     VIR_ERR_OVERFLOW = 82,              /* integer overflow */
     VIR_ERR_BLOCK_COPY_ACTIVE = 83,     /* action prevented by block copy job */
+    VIR_ERR_OPERATION_UNSUPPORTED = 84, /* The requested operation is not
+                                           supported */
 } virErrorNumber;
 
 /**
index 3ede88d67c5d446783eb4fcf6e570a30d977cd18..7e482d132bef6693e0f028746105863b83a11959 100644 (file)
@@ -3652,11 +3652,11 @@ int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon,
     if (virJSONValueObjectGetNumberUlong(inserted,                            \
                                          FIELD,                               \
                                          &reply->STORE) < 0) {                \
-        virReportError(VIR_ERR_INTERNAL_ERROR,                                \
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,                         \
                        _("block_io_throttle field '%s' missing "              \
                          "in qemu's output"),                                 \
                        #STORE);                                               \
-            goto cleanup;                                                     \
+        goto cleanup;                                                         \
     }
 static int
 qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result,
index a40cfe0b381e42c31b74893de974d800127ff293..c438de8457dad26278fe8e768145d01ca64d5656 100644 (file)
@@ -1185,6 +1185,12 @@ virErrorMsg(virErrorNumber error, const char *info)
             else
                 errmsg = _("block copy still active: %s");
             break;
+        case VIR_ERR_OPERATION_UNSUPPORTED:
+            if (!info)
+                errmsg = _("Operation not supported");
+            else
+                errmsg = _("Operation not supported: %s");
+            break;
     }
     return errmsg;
 }