mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-26 22:45:17 +00:00
network: consolidate connection count updates for device pool
networkReleaseActualDevice() and networkNotifyActualDevice() both were updating the individual devices' connections count in two separate places (unlike networkAllocateActualDevice() which does it in a single unified place after success:). The code is correct, but prone to confusion / later breakage. All of these updates are anyway located at the end of if/else clauses that are (with the exception of a single VIR_DEBUG() in each case) immediately followed by the success: label anyway, so this patch replaces the duplicated ++/-- instructions with a single ++/-- inside a qualifying "if (dev)" down below success:. (NB: if dev != NULL, by definition we are using a device (either pci or netdev, doesn't matter for these purposes) from the network's pool) The VIR_DEBUG args (which will be replaced in a followup patch anyway) were all adjusted to account for the connection count being out of date at the time.
This commit is contained in:
parent
98782f8899
commit
3ea8b8b87f
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* bridge_driver.c: core driver methods for managing network
|
* bridge_driver.c: core driver methods for managing network
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2015 Red Hat, Inc.
|
* Copyright (C) 2006-2016 Red Hat, Inc.
|
||||||
* Copyright (C) 2006 Daniel P. Berrange
|
* Copyright (C) 2006 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -4389,10 +4389,8 @@ networkNotifyActualDevice(virDomainDefPtr dom,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we are now assured of success, so mark the allocation */
|
|
||||||
dev->connections++;
|
|
||||||
VIR_DEBUG("Using physical device %s, connections %d",
|
VIR_DEBUG("Using physical device %s, connections %d",
|
||||||
dev->device.dev, dev->connections);
|
dev->device.dev, dev->connections + 1);
|
||||||
|
|
||||||
} else /* if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) */ {
|
} else /* if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) */ {
|
||||||
virDomainHostdevDefPtr hostdev;
|
virDomainHostdevDefPtr hostdev;
|
||||||
@ -4444,8 +4442,6 @@ networkNotifyActualDevice(virDomainDefPtr dom,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we are now assured of success, so mark the allocation */
|
|
||||||
dev->connections++;
|
|
||||||
VIR_DEBUG("Using physical device %04x:%02x:%02x.%x, connections %d",
|
VIR_DEBUG("Using physical device %04x:%02x:%02x.%x, connections %d",
|
||||||
dev->device.pci.domain, dev->device.pci.bus,
|
dev->device.pci.domain, dev->device.pci.bus,
|
||||||
dev->device.pci.slot, dev->device.pci.function,
|
dev->device.pci.slot, dev->device.pci.function,
|
||||||
@ -4454,6 +4450,8 @@ networkNotifyActualDevice(virDomainDefPtr dom,
|
|||||||
|
|
||||||
success:
|
success:
|
||||||
netdef->connections++;
|
netdef->connections++;
|
||||||
|
if (dev)
|
||||||
|
dev->connections++;
|
||||||
VIR_DEBUG("Using network %s, %d connections",
|
VIR_DEBUG("Using network %s, %d connections",
|
||||||
netdef->name, netdef->connections);
|
netdef->name, netdef->connections);
|
||||||
|
|
||||||
@ -4562,9 +4560,8 @@ networkReleaseActualDevice(virDomainDefPtr dom,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->connections--;
|
|
||||||
VIR_DEBUG("Releasing physical device %s, connections %d",
|
VIR_DEBUG("Releasing physical device %s, connections %d",
|
||||||
dev->device.dev, dev->connections);
|
dev->device.dev, dev->connections - 1);
|
||||||
|
|
||||||
} else /* if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) */ {
|
} else /* if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) */ {
|
||||||
virDomainHostdevDefPtr hostdev;
|
virDomainHostdevDefPtr hostdev;
|
||||||
@ -4598,16 +4595,18 @@ networkReleaseActualDevice(virDomainDefPtr dom,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->connections--;
|
|
||||||
VIR_DEBUG("Releasing physical device %04x:%02x:%02x.%x, connections %d",
|
VIR_DEBUG("Releasing physical device %04x:%02x:%02x.%x, connections %d",
|
||||||
dev->device.pci.domain, dev->device.pci.bus,
|
dev->device.pci.domain, dev->device.pci.bus,
|
||||||
dev->device.pci.slot, dev->device.pci.function,
|
dev->device.pci.slot, dev->device.pci.function,
|
||||||
dev->connections);
|
dev->connections - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
success:
|
success:
|
||||||
if (iface->data.network.actual) {
|
if (iface->data.network.actual) {
|
||||||
netdef->connections--;
|
netdef->connections--;
|
||||||
|
if (dev)
|
||||||
|
dev->connections--;
|
||||||
|
|
||||||
VIR_DEBUG("Releasing network %s, %d connections",
|
VIR_DEBUG("Releasing network %s, %d connections",
|
||||||
netdef->name, netdef->connections);
|
netdef->name, netdef->connections);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user