提交 2f678bb1 编写于 作者: M Martin Kletzander

virNetDevBandwidthClear: Improve error handling

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.
上级 9ac287f8
...@@ -2161,7 +2161,7 @@ networkStartNetworkVirtual(struct network_driver *driver, ...@@ -2161,7 +2161,7 @@ networkStartNetworkVirtual(struct network_driver *driver,
return 0; return 0;
err5: err5:
ignore_value(virNetDevBandwidthClear(network->def->bridge)); virNetDevBandwidthClear(network->def->bridge);
err4: err4:
if (!save_err) if (!save_err)
...@@ -2206,7 +2206,7 @@ networkStartNetworkVirtual(struct network_driver *driver, ...@@ -2206,7 +2206,7 @@ networkStartNetworkVirtual(struct network_driver *driver,
static int networkShutdownNetworkVirtual(struct network_driver *driver, static int networkShutdownNetworkVirtual(struct network_driver *driver,
virNetworkObjPtr network) virNetworkObjPtr network)
{ {
ignore_value(virNetDevBandwidthClear(network->def->bridge)); virNetDevBandwidthClear(network->def->bridge);
if (network->radvdPid > 0) { if (network->radvdPid > 0) {
char *radvdpidbase; char *radvdpidbase;
......
/* /*
* 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -69,7 +69,7 @@ virNetDevBandwidthSet(const char *ifname, ...@@ -69,7 +69,7 @@ virNetDevBandwidthSet(const char *ifname,
goto cleanup; goto cleanup;
} }
ignore_value(virNetDevBandwidthClear(ifname)); virNetDevBandwidthClear(ifname);
if (bandwidth->in) { if (bandwidth->in) {
if (virAsprintf(&average, "%llukbps", bandwidth->in->average) < 0) if (virAsprintf(&average, "%llukbps", bandwidth->in->average) < 0)
...@@ -166,12 +166,13 @@ int ...@@ -166,12 +166,13 @@ int
virNetDevBandwidthClear(const char *ifname) virNetDevBandwidthClear(const char *ifname)
{ {
int ret = 0; int ret = 0;
int dummy; /* for ignoring the exit status */
virCommandPtr cmd = NULL; virCommandPtr cmd = NULL;
cmd = virCommandNew(TC); cmd = virCommandNew(TC);
virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "root", NULL); virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "root", NULL);
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(cmd, &dummy) < 0)
ret = -1; ret = -1;
virCommandFree(cmd); virCommandFree(cmd);
...@@ -179,8 +180,9 @@ virNetDevBandwidthClear(const char *ifname) ...@@ -179,8 +180,9 @@ virNetDevBandwidthClear(const char *ifname)
cmd = virCommandNew(TC); cmd = virCommandNew(TC);
virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "ingress", NULL); virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "ingress", NULL);
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(cmd, &dummy) < 0)
ret = -1; ret = -1;
virCommandFree(cmd); virCommandFree(cmd);
return ret; return ret;
......
/* /*
* 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -44,7 +44,7 @@ void virNetDevBandwidthFree(virNetDevBandwidthPtr def); ...@@ -44,7 +44,7 @@ void virNetDevBandwidthFree(virNetDevBandwidthPtr def);
int virNetDevBandwidthSet(const char *ifname, virNetDevBandwidthPtr bandwidth) int virNetDevBandwidthSet(const char *ifname, virNetDevBandwidthPtr bandwidth)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virNetDevBandwidthClear(const char *ifname) int virNetDevBandwidthClear(const char *ifname)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_NONNULL(1);
int virNetDevBandwidthCopy(virNetDevBandwidthPtr *dest, const virNetDevBandwidthPtr src) int virNetDevBandwidthCopy(virNetDevBandwidthPtr *dest, const virNetDevBandwidthPtr src)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册