[libvirt] [PATCH 6/8] Implement Get Block IO Throttle for qemu driver

Adam Litke agl at us.ibm.com
Thu Oct 27 21:53:40 UTC 2011


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.

-- 
Adam Litke <agl at us.ibm.com>
IBM Linux Technology Center




More information about the libvir-list mailing list