Make netdev_del delete the netdev even when it's in use
PATCH 1/1 Make netdev_del delete the netdev even when it's in use
To hot-unplug guest and host part of a network device, you do:
device_del NIC-ID
netdev_del NETDEV-ID
For PCI devices, device_del merely tells ACPI to unplug the device. The device goes away for real only after the guest processed the ACPI unplug event.
You have to wait until then (e.g. by polling info pci) before you can unplug the netdev. Not good.
Fix by removing the "in use" check from do_netdev_del(). Deleting a netdev while it's in use is safe; packets simply get routed to the bit bucket.
---
I can add a force option instead, if you think that's better.
net.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
net.c +0 -4
@@ -1221,10 +1221,6 @@ int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data)qerror_report (QERR_DEVICE_NOT_FOUND , id);return -1 ; } -if (vc->peer) { -qerror_report (QERR_DEVICE_IN_USE , id); -return -1 ; - }qemu_del_vlan_client (vc);qemu_opts_del (qemu_opts_find (&qemu_netdev_opts, id));return 0 ;
Signature · 1 line
1.6.6.1
Anthony Liguori
AppliedQuoted 9 lines · Markus Armbruster
To hot-unplug guest and host part of a network device, you do:
device_delNIC-ID
netdev_delNETDEV-IDFor PCI devices,
device_delmerely tells ACPI to unplug the device. The device goes away for real only after the guest processed the ACPI unplug event.
Quoted 9 lines
You have to wait until then (e.g. by polling info pci) before you can unplug the netdev. Not good.
Fix by removing the "in use" check from
do_netdev_del(). Deleting a netdev while it's in use is safe; packets simply get routed to the bit bucket.Signed-off-by Markus Armbruster<[email protected]>
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 22 lines
---
I can add a force option instead, if you think that's better.net.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)net.c +0
-4@@ -1221,10 +1221,6 @@ int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data)qerror_report (QERR_DEVICE_NOT_FOUND , id);return -1 ; } -if (vc->peer) { -qerror_report (QERR_DEVICE_IN_USE , id); -return -1 ; - }qemu_del_vlan_client (vc);qemu_opts_del (qemu_opts_find (&qemu_netdev_opts, id));return 0 ;