On 10/28/2011 05:53 AM, Adam Litke wrote:

On Thu, Oct 27, 2011 at 05:20:08PM +0800, Lei HH Li wrote:
+static int
+qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result,
+                                   const char *device,
+                                   virDomainBlockIoThrottleInfoPtr reply)
+{
+    virJSONValuePtr io_throttle;
+    int ret = -1;
+    int i;
+    int found = 0;
+
+    io_throttle = virJSONValueObjectGet(result, "return");
+
+    if (!io_throttle ||io_throttle->type != VIR_JSON_TYPE_ARRAY) {
                           ^ need a space between || and io_throttle

+        qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                        _(" block_io_throttle reply was missing device list 
"));
+        goto cleanup;
+    }
+
+    for (i = 0; i<  virJSONValueArraySize(io_throttle); i++) {
+        virJSONValuePtr temp_dev = virJSONValueArrayGet(io_throttle, i);
+        virJSONValuePtr inserted;
+        const char *current_dev;
+
+       if (!temp_dev || temp_dev->type !=VIR_JSON_TYPE_OBJECT) {
                                             ^ watch spaces

+            qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                            _("block io throttle device entry was not in expected 
format"));
+            goto cleanup;
+        }
+
+        if ((current_dev = virJSONValueObjectGetString(temp_dev, "device")) == 
NULL) {
+            qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                            _("block io throttle device entry was not in expected 
format"));
+            goto cleanup;
+        }
+
+        if(STRPREFIX(current_dev, QEMU_DRIVE_HOST_PREFIX))
+            current_dev += strlen(QEMU_DRIVE_HOST_PREFIX);
Is the drive prefix always going to be there?  If so, I would report an error if
it is missing.  As written, we'll tolerate either if it's there or not.

New QEMU has separate names for host&  guest side of the disk
and libvirt gives the host side a 'drive-' prefix. The passed
in dev_name is the guest side though.
It's for read mode, finding the asked block device by name then
get the return value of 'query-block', json-object: 'inserted'.


--
Lei

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to