From patchwork Fri Jun 11 12:21:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 55315 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3C6981007D2 for ; Fri, 11 Jun 2010 22:23:24 +1000 (EST) Received: from localhost ([127.0.0.1]:34063 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ON3Ga-0002vZ-6r for incoming@patchwork.ozlabs.org; Fri, 11 Jun 2010 08:23:20 -0400 Received: from [140.186.70.92] (port=33890 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ON3F0-0001yZ-QC for qemu-devel@nongnu.org; Fri, 11 Jun 2010 08:21:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ON3Ew-0007nn-Kf for qemu-devel@nongnu.org; Fri, 11 Jun 2010 08:21:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16459) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ON3Ew-0007nS-Ct for qemu-devel@nongnu.org; Fri, 11 Jun 2010 08:21:38 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5BCLauN017424 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 11 Jun 2010 08:21:37 -0400 Received: from blackfin.pond.sub.org (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5BCLZ4f029590 for ; Fri, 11 Jun 2010 08:21:36 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 500) id B97B9CA; Fri, 11 Jun 2010 14:21:34 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 11 Jun 2010 14:21:34 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH] Make netdev_del delete the netdev even when it's in use X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Signed-off-by: Markus Armbruster --- I can add a force option instead, if you think that's better. net.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-) diff --git a/net.c b/net.c index 4cb93ed..0703698 100644 --- a/net.c +++ b/net.c @@ -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;