]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virNetDevBandwidthClear: Improve error handling
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 18 Sep 2012 10:01:18 +0000 (12:01 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 18 Sep 2012 14:41:13 +0000 (16:41 +0200)
Two changes are introduced in this patch:

 - The first change removes ATTRIBUTE_RETURN_CHECK from
   virNetDevBandwidthClear, because it was called with ignore_value
   always, anyway. The function is used even when it's not necessary
   to call it, just for cleanup purposes.

 - The second change is added ignoring of the command's exit status,
   since it may report an error even when run just as "to be sure we
   clean up" function. No libvirt errors are suppresed by this.

src/network/bridge_driver.c
src/util/virnetdevbandwidth.c
src/util/virnetdevbandwidth.h

index 0e38016e2c06c263e87ce163e5375dcbc02970a6..3a800c933bba22a7d121d6636d5b26269d315c79 100644 (file)
@@ -2161,7 +2161,7 @@ networkStartNetworkVirtual(struct network_driver *driver,
     return 0;
 
  err5:
-    ignore_value(virNetDevBandwidthClear(network->def->bridge));
+    virNetDevBandwidthClear(network->def->bridge);
 
  err4:
     if (!save_err)
@@ -2206,7 +2206,7 @@ networkStartNetworkVirtual(struct network_driver *driver,
 static int networkShutdownNetworkVirtual(struct network_driver *driver,
                                         virNetworkObjPtr network)
 {
-    ignore_value(virNetDevBandwidthClear(network->def->bridge));
+    virNetDevBandwidthClear(network->def->bridge);
 
     if (network->radvdPid > 0) {
         char *radvdpidbase;
index b23ccd3372229745d883c53fb2ba9f6445181086..8faeae640d47eb2477bce61942853e27742c13f5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009-2011 Red Hat, Inc.
+ * Copyright (C) 2009-2012 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -69,7 +69,7 @@ virNetDevBandwidthSet(const char *ifname,
         goto cleanup;
     }
 
-    ignore_value(virNetDevBandwidthClear(ifname));
+    virNetDevBandwidthClear(ifname);
 
     if (bandwidth->in) {
         if (virAsprintf(&average, "%llukbps", bandwidth->in->average) < 0)
@@ -166,12 +166,13 @@ int
 virNetDevBandwidthClear(const char *ifname)
 {
     int ret = 0;
+    int dummy; /* for ignoring the exit status */
     virCommandPtr cmd = NULL;
 
     cmd = virCommandNew(TC);
     virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "root", NULL);
 
-    if (virCommandRun(cmd, NULL) < 0)
+    if (virCommandRun(cmd, &dummy) < 0)
         ret = -1;
 
     virCommandFree(cmd);
@@ -179,8 +180,9 @@ virNetDevBandwidthClear(const char *ifname)
     cmd = virCommandNew(TC);
     virCommandAddArgList(cmd, "qdisc",  "del", "dev", ifname, "ingress", NULL);
 
-    if (virCommandRun(cmd, NULL) < 0)
+    if (virCommandRun(cmd, &dummy) < 0)
         ret = -1;
+
     virCommandFree(cmd);
 
     return ret;
index 18384ae620646a3d46eb1cd2a4f267d13ae2bb92..3fc903cfe85f8c9fc748bb1bc5263bb63061f65b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009-2011 Red Hat, Inc.
+ * Copyright (C) 2009-2012 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -44,7 +44,7 @@ void virNetDevBandwidthFree(virNetDevBandwidthPtr def);
 int virNetDevBandwidthSet(const char *ifname, virNetDevBandwidthPtr bandwidth)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
 int virNetDevBandwidthClear(const char *ifname)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
+    ATTRIBUTE_NONNULL(1);
 int virNetDevBandwidthCopy(virNetDevBandwidthPtr *dest, const virNetDevBandwidthPtr src)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;