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

Re: [libvirt] [PATCH 03/12] [v7] virNodeGetCPUTime: Implement public API



On 06/14/2011 03:04 AM, Daniel P. Berrange wrote:
> On Tue, Jun 07, 2011 at 10:00:23AM +0900, Minoru Usui wrote:
>> virNodeGetCPUTime: Implement public API

>> + * @cpuNum: number of node cpu. (VIR_CPU_STATS_ALL_CPUS means total cpu 
>> + *          statistics)

Trailing whitespace; tsk-tsk.  'make syntax-check' caught it.

>>
>> + * Here is the sample code snippet:
>> + *
>> + * if ((virNodeGetCPUStats(conn, cpuNum, NULL, &nparams, 0) == 0) &&
>> + *     (nparams != 0)) {
>> + *     params = vshMalloc(ctl, sizeof(virCPUStats) * nparams);
>> + *     memset(params, 0, sizeof(virCPUStats) * nparams);
>> + *     if (virNodeGetCPUStats(conn, cpuNum, params, &nparams, 0)) {
>> + *         vshError(ctl, "%s", _("Unable to get node cpu stats"));
>> + *         goto error;
>> + *     }
>> + * }
> 
> The example code should stick to using standard libc APIs for
> demonstration purposes, because applications developing against
> libvirt don't have use of vshMalloc or vshError. Just use normal
> malloc() and fprintf(stderr) here instead.

Copy and paste from a previous example, so I've fixed that, too.

> 
> 
>> + *
>> + * This function doesn't requires privileged access to the hypervisor.

s/requires/require/

> 
> ACK if the comment is changed.

Pushed with this squashed in (along with 2/12 unchanged):

diff --git i/src/libvirt.c w/src/libvirt.c
index ccb00cd..ace0120 100644
--- i/src/libvirt.c
+++ w/src/libvirt.c
@@ -3008,16 +3008,15 @@ error:
  * array, i.e. (sizeof(@virTypedParameter) * @nparams) bytes and call
the API
  * again.
  *
- * Here is the sample code snippet:
+ * Here is a sample code snippet:
  *
  * if ((virDomainGetMemoryParameters(dom, NULL, &nparams, 0) == 0) &&
  *     (nparams != 0)) {
- *     params = vshMalloc(ctl, sizeof(*params) * nparams);
+ *     if ((params = malloc(sizeof(*params) * nparams)) == NULL)
+ *         goto error;
  *     memset(params, 0, sizeof(*params) * nparams);
- *     if (virDomainGetMemoryParameters(dom, params, &nparams, 0)) {
- *         vshError(ctl, "%s", _("Unable to get memory parameters"));
+ *     if (virDomainGetMemoryParameters(dom, params, &nparams, 0))
  *         goto error;
- *     }
  * }
  *
  * This function requires privileged access to the hypervisor. This
function
@@ -5288,7 +5287,7 @@ error:
 /**
  * virNodeGetCPUStats:
  * @conn: pointer to the hypervisor connection.
- * @cpuNum: number of node cpu. (VIR_CPU_STATS_ALL_CPUS means total cpu
+ * @cpuNum: number of node cpu. (VIR_CPU_STATS_ALL_CPUS means total cpu
  *          statistics)
  * @params: pointer to node cpu time parameter objects
  * @nparams: number of node cpu time parameter (this value should be
same or
@@ -5307,19 +5306,18 @@ error:
  * array, i.e. (sizeof(@virCPUStats) * @nparams) bytes and call
  * the API again.
  *
- * Here is the sample code snippet:
+ * Here is a sample code snippet:
  *
  * if ((virNodeGetCPUStats(conn, cpuNum, NULL, &nparams, 0) == 0) &&
  *     (nparams != 0)) {
- *     params = vshMalloc(ctl, sizeof(virCPUStats) * nparams);
+ *     if ((params = malloc(sizeof(virCPUStats) * nparams)) == NULL)
+ *         goto error;
  *     memset(params, 0, sizeof(virCPUStats) * nparams);
- *     if (virNodeGetCPUStats(conn, cpuNum, params, &nparams, 0)) {
- *         vshError(ctl, "%s", _("Unable to get node cpu stats"));
+ *     if (virNodeGetCPUStats(conn, cpuNum, params, &nparams, 0))
  *         goto error;
- *     }
  * }
  *
- * This function doesn't requires privileged access to the hypervisor.
+ * This function doesn't require privileged access to the hypervisor.
  * This function expects the caller to allocate the @params.
  *
  * CPU time Statistics:

-- 
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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