Skip to content

Commit db0d401

Browse files
eugpermarjasowang
authored andcommitted
net: parameterize the removing client from nc list
This change is used in later commits so we can avoid the removal of the netclient if it is delayed. No functional change intended. Reviewed-by: Si-Wei Liu <[email protected]> Acked-by: Jason Wang <[email protected]> Signed-off-by: Eugenio Pérez <[email protected]> Signed-off-by: Jason Wang <[email protected]>
1 parent d9a4282 commit db0d401

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

net/net.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,12 @@ NetClientState *qemu_get_peer(NetClientState *nc, int queue_index)
381381
return ncs->peer;
382382
}
383383

384-
static void qemu_cleanup_net_client(NetClientState *nc)
384+
static void qemu_cleanup_net_client(NetClientState *nc,
385+
bool remove_from_net_clients)
385386
{
386-
QTAILQ_REMOVE(&net_clients, nc, next);
387+
if (remove_from_net_clients) {
388+
QTAILQ_REMOVE(&net_clients, nc, next);
389+
}
387390

388391
if (nc->info->cleanup) {
389392
nc->info->cleanup(nc);
@@ -442,14 +445,14 @@ void qemu_del_net_client(NetClientState *nc)
442445
}
443446

444447
for (i = 0; i < queues; i++) {
445-
qemu_cleanup_net_client(ncs[i]);
448+
qemu_cleanup_net_client(ncs[i], true);
446449
}
447450

448451
return;
449452
}
450453

451454
for (i = 0; i < queues; i++) {
452-
qemu_cleanup_net_client(ncs[i]);
455+
qemu_cleanup_net_client(ncs[i], true);
453456
qemu_free_net_client(ncs[i]);
454457
}
455458
}
@@ -474,7 +477,7 @@ void qemu_del_nic(NICState *nic)
474477
for (i = queues - 1; i >= 0; i--) {
475478
NetClientState *nc = qemu_get_subqueue(nic, i);
476479

477-
qemu_cleanup_net_client(nc);
480+
qemu_cleanup_net_client(nc, true);
478481
qemu_free_net_client(nc);
479482
}
480483

0 commit comments

Comments
 (0)