]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
openvz: check the exitstatus of vzlist
authorLaine Stump <laine@laine.org>
Fri, 24 Aug 2012 05:43:19 +0000 (01:43 -0400)
committerLaine Stump <laine@laine.org>
Fri, 24 Aug 2012 07:07:00 +0000 (03:07 -0400)
I noticed this while auditing all calls to virCommandRun that request
an exit status from virCommandRun. Two functions in the openvz driver

  openvzDomainGetBarrierLimit
  openvzDomainSetBarrierLimit

request an exit status from virCommandRun (thus assuring that
virCommandRun won't log any errors just due to a non-0 exit status),
but then fail to examine that exit status. This could result in the
functions believing that the call to "vzlist" was successful, even
though it may have encountered an error.

src/openvz/openvz_driver.c

index 8257ed560f5fadcc5bb2a7aca34db67f445365e2..a1d3b42b484d6624f49088a3a9e6689b8a89a680 100644 (file)
@@ -1707,7 +1707,7 @@ openvzDomainGetBarrierLimit(virDomainPtr domain,
     virCommandSetOutputBuffer(cmd, &output);
     virCommandAddArgFormat(cmd, "-o%s.b,%s.l", param, param);
     virCommandAddArg(cmd, domain->name);
-    if (virCommandRun(cmd, &status)) {
+    if (virCommandRun(cmd, &status) < 0 || status != 0) {
         virReportError(VIR_ERR_OPERATION_FAILED,
                        _("Failed to get %s for %s: %d"), param, domain->name,
                        status);
@@ -1758,7 +1758,7 @@ openvzDomainSetBarrierLimit(virDomainPtr domain,
     virCommandAddArgFormat(cmd, "--%s", param);
     virCommandAddArgFormat(cmd, "%llu:%llu", barrier, limit);
     virCommandAddArg(cmd, "--save");
-    if (virCommandRun(cmd, &status)) {
+    if (virCommandRun(cmd, &status) < 0 || status != 0) {
         virReportError(VIR_ERR_OPERATION_FAILED,
                        _("Failed to set %s for %s: %d"), param, domain->name,
                        status);