Skip to content

Commit

Permalink
hw/xen: only remove peers of PCI NICs on unplug
Browse files Browse the repository at this point in the history
When the Xen guest asks to unplug *emulated* NICs, it's kind of unhelpful
also to unplug the peer of the *Xen* PV NIC.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
  • Loading branch information
dwmw2 committed Nov 7, 2023
1 parent a72ccc7 commit 25511f3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions hw/i386/xen/xen_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,14 @@ static void unplug_nic(PCIBus *b, PCIDevice *d, void *o)
/* Remove the peer of the NIC device. Normally, this would be a tap device. */
static void del_nic_peer(NICState *nic, void *opaque)
{
NetClientState *nc;
NetClientState *nc = qemu_get_queue(nic);
ObjectClass *klass = module_object_class_by_name(nc->model);

/* Only delete peers of PCI NICs that we're about to delete */
if (!klass || !object_class_dynamic_cast(klass, TYPE_PCI_DEVICE)) {
return;
}

nc = qemu_get_queue(nic);
if (nc->peer)
qemu_del_net_client(nc->peer);
}
Expand Down

0 comments on commit 25511f3

Please sign in to comment.