mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
network: only clear bandwidth if it has been set
libvirt was unconditionally calling virNetDevBandwidthClear() for every interface (and network bridge) of a type that supported bandwidth, whether it actually had anything set or not. This doesn't hurt anything (unless ifname == NULL!), but is wasteful. This patch makes sure that all calls to virNetDevBandwidthClear() are qualified by checking that the interface really had some bandwidth setup done, and checks for a null ifname inside virNetDevBandwidthClear(), silently returning success if it is null (as well as removing the ATTRIBUTE_NONNULL from that function's prototype, since we can't guarantee that it is never null, e.g. sometimes a type='ethernet' interface has no ifname as it is provided on the fly by qemu).
This commit is contained in:
parent
18f9f69bb5
commit
118b240808
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2014 Red Hat, Inc.
|
||||
* Copyright (C) 2009-2015 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
|
||||
@ -285,7 +285,8 @@ virDomainClearNetBandwidth(virDomainObjPtr vm)
|
||||
|
||||
for (i = 0; i < vm->def->nnets; i++) {
|
||||
type = virDomainNetGetActualType(vm->def->nets[i]);
|
||||
if (virNetDevSupportBandwidth(type))
|
||||
if (virDomainNetGetActualBandwidth(vm->def->nets[i]) &&
|
||||
virNetDevSupportBandwidth(type))
|
||||
virNetDevBandwidthClear(vm->def->nets[i]->ifname);
|
||||
}
|
||||
}
|
||||
|
@ -4650,7 +4650,8 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm,
|
||||
actualType = virDomainNetGetActualType(detach);
|
||||
|
||||
/* clear network bandwidth */
|
||||
if (virNetDevSupportBandwidth(actualType) &&
|
||||
if (virDomainNetGetActualBandwidth(detach) &&
|
||||
virNetDevSupportBandwidth(actualType) &&
|
||||
virNetDevBandwidthClear(detach->ifname))
|
||||
goto cleanup;
|
||||
|
||||
|
@ -2096,7 +2096,8 @@ networkStartNetworkVirtual(virNetworkObjPtr network)
|
||||
return 0;
|
||||
|
||||
err5:
|
||||
virNetDevBandwidthClear(network->def->bridge);
|
||||
if (network->def->bandwidth)
|
||||
virNetDevBandwidthClear(network->def->bridge);
|
||||
|
||||
err4:
|
||||
if (!save_err)
|
||||
@ -2142,7 +2143,8 @@ networkStartNetworkVirtual(virNetworkObjPtr network)
|
||||
|
||||
static int networkShutdownNetworkVirtual(virNetworkObjPtr network)
|
||||
{
|
||||
virNetDevBandwidthClear(network->def->bridge);
|
||||
if (network->def->bandwidth)
|
||||
virNetDevBandwidthClear(network->def->bridge);
|
||||
|
||||
if (network->radvdPid > 0) {
|
||||
char *radvdpidbase;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* qemu_hotplug.c: QEMU device hotplug management
|
||||
*
|
||||
* Copyright (C) 2006-2014 Red Hat, Inc.
|
||||
* Copyright (C) 2006-2015 Red Hat, Inc.
|
||||
* Copyright (C) 2006 Daniel P. Berrange
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@ -3750,7 +3750,8 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virNetDevSupportBandwidth(virDomainNetGetActualType(detach)) &&
|
||||
if (virDomainNetGetActualBandwidth(detach) &&
|
||||
virNetDevSupportBandwidth(virDomainNetGetActualType(detach)) &&
|
||||
virNetDevBandwidthClear(detach->ifname) < 0)
|
||||
VIR_WARN("cannot clear bandwidth setting for device : %s",
|
||||
detach->ifname);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2014 Red Hat, Inc.
|
||||
* Copyright (C) 2009-2015 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
|
||||
@ -268,6 +268,9 @@ virNetDevBandwidthClear(const char *ifname)
|
||||
int dummy; /* for ignoring the exit status */
|
||||
virCommandPtr cmd = NULL;
|
||||
|
||||
if (!ifname)
|
||||
return 0;
|
||||
|
||||
cmd = virCommandNew(TC);
|
||||
virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "root", NULL);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2013 Red Hat, Inc.
|
||||
* Copyright (C) 2009-2015 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
|
||||
@ -47,8 +47,7 @@ int virNetDevBandwidthSet(const char *ifname,
|
||||
virNetDevBandwidthPtr bandwidth,
|
||||
bool hierarchical_class)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
||||
int virNetDevBandwidthClear(const char *ifname)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
int virNetDevBandwidthClear(const char *ifname);
|
||||
int virNetDevBandwidthCopy(virNetDevBandwidthPtr *dest,
|
||||
const virNetDevBandwidth *src)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
||||
|
Loading…
x
Reference in New Issue
Block a user