From patchwork Tue Feb 22 17:36:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Dauchy X-Patchwork-Id: 83984 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 88470B7118 for ; Wed, 23 Feb 2011 04:46:22 +1100 (EST) Received: from localhost ([127.0.0.1]:40785 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PrwGQ-0006qe-MJ for incoming@patchwork.ozlabs.org; Tue, 22 Feb 2011 12:43:06 -0500 Received: from [140.186.70.92] (port=51310 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PrwFT-0006Lk-1H for qemu-devel@nongnu.org; Tue, 22 Feb 2011 12:42:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PrwFC-0006Xz-IF for qemu-devel@nongnu.org; Tue, 22 Feb 2011 12:41:51 -0500 Received: from mail-wy0-f173.google.com ([74.125.82.173]:50817) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PrwFC-0006Xs-3c for qemu-devel@nongnu.org; Tue, 22 Feb 2011 12:41:50 -0500 Received: by wyb29 with SMTP id 29so2767049wyb.4 for ; Tue, 22 Feb 2011 09:41:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=rmqsOV39Z+9OaPVeU/5c8qOxWdDAptqCkxqSMVLs4JQ=; b=nsGP9YNaNmItV+L37z4ALRKU/WbiMsARg1p9x1dQ3PSDh8arHpY0PWfQPbBWEttga7 37Rq4Xp7dpk1J34dRpVd7K/vFAum7XMl2mye6I5++JGbp1SLdW2BpkAusZzd/kte1TnP SiLpZEA9KmK7Mq2PjZOAj91RWJefaEC58IkHQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=rbbTx60scbljuRh4s3gN0iE7n0IiaMPwra42LBy7muQW2BEVW/4Sh3R+VIDglU2km3 OfsvGx6BosiLhX/rjgIAZOFz6mso15cmffwR5L2DQGBwnr6BiXAsAl8MMRAKlJMD9kYN hpquUUE0uqVmzrYbU4CXl4oHfzVmLQbkB7n6E= Received: by 10.216.50.193 with SMTP id z43mr2663288web.49.1298396508704; Tue, 22 Feb 2011 09:41:48 -0800 (PST) Received: from localhost.localdomain (hitchhiker.gandi.net [217.70.181.24]) by mx.google.com with ESMTPS id 7sm2717859wet.0.2011.02.22.09.41.46 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 Feb 2011 09:41:47 -0800 (PST) From: William Dauchy To: qemu-devel@nongnu.org Date: Tue, 22 Feb 2011 18:36:20 +0100 Message-Id: <1298396180-23734-1-git-send-email-wdauchy@gmail.com> X-Mailer: git-send-email 1.7.2.3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.173 Cc: William Dauchy Subject: [Qemu-devel] [PATCH] `qdev_free` when unplug a pci device 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 `qdev_free` when unplug a pci device It resolves a bug when detaching/attaching a network device # virsh detach-interface dom0 network --mac 52:54:00:f6:84:ba Interface detached successfully # virsh attach-interface dom0 network default --mac 52:54:00:f6:84:ba error: Failed to attach interface error: internal error unable to execute QEMU command 'device_add': Duplicate ID 'net0' for device A detached pci device was not freed of the list `qemu_device_opts` --- hw/pci.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 8b76cea..1e9a8f0 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1671,13 +1671,16 @@ static int pci_unplug_device(DeviceState *qdev) { PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev); PCIDeviceInfo *info = container_of(qdev->info, PCIDeviceInfo, qdev); + int unplug; if (info->no_hotplug) { qerror_report(QERR_DEVICE_NO_HOTPLUG, info->qdev.name); return -1; } - return dev->bus->hotplug(dev->bus->hotplug_qdev, dev, + unplug = dev->bus->hotplug(dev->bus->hotplug_qdev, dev, PCI_HOTPLUG_DISABLED); + qdev_free(qdev); + return unplug; } void pci_qdev_register(PCIDeviceInfo *info)