mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 07:05:28 +00:00
conf: Remove the actual hostdev when removing a network
Commit 50348e6edf
reused the code to remove the hostdev portion of a
network definition on multiple places but forgot to take into account
that sometimes the "actual" network is passed and in some cases the
parent of that.
This patch uses the virDomainNetGetActualHostdev() helper to acquire the
correct pointer all the time while removing the hostdev portion from the
list.
This commit is contained in:
parent
8d67c550e9
commit
991270db99
@ -10002,14 +10002,14 @@ void
|
|||||||
virDomainNetRemoveHostdev(virDomainDefPtr def,
|
virDomainNetRemoveHostdev(virDomainDefPtr def,
|
||||||
virDomainNetDefPtr net)
|
virDomainNetDefPtr net)
|
||||||
{
|
{
|
||||||
if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
|
|
||||||
/* hostdev net devices are normally also be in the hostdevs
|
/* hostdev net devices are normally also be in the hostdevs
|
||||||
* array, but might have already been removed by the time we
|
* array, but might have already been removed by the time we
|
||||||
* get here.
|
* get here.
|
||||||
*/
|
*/
|
||||||
virDomainHostdevDefPtr hostdev = &net->data.hostdev.def;
|
virDomainHostdevDefPtr hostdev = virDomainNetGetActualHostdev(net);
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
if (hostdev) {
|
||||||
for (i = 0; i < def->nhostdevs; i++) {
|
for (i = 0; i < def->nhostdevs; i++) {
|
||||||
if (def->hostdevs[i] == hostdev) {
|
if (def->hostdevs[i] == hostdev) {
|
||||||
virDomainHostdevRemove(def, i);
|
virDomainHostdevRemove(def, i);
|
||||||
|
Loading…
Reference in New Issue
Block a user