From: William Dauchy <wdauchy@gmail.com>
To: qemu-devel@nongnu.org
Cc: William Dauchy <wdauchy@gmail.com>
Subject: [Qemu-devel] [PATCH] `qdev_free` when unplug a pci device
Date: Tue, 22 Feb 2011 18:36:20 +0100 [thread overview]
Message-ID: <1298396180-23734-1-git-send-email-wdauchy@gmail.com> (raw)
`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)
--
William
next reply other threads:[~2011-02-22 17:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-22 17:36 William Dauchy [this message]
2011-02-23 2:50 ` [Qemu-devel] [PATCH] `qdev_free` when unplug a pci device Isaku Yamahata
2011-02-23 8:30 ` Markus Armbruster
2011-02-23 9:32 ` William Dauchy
2011-02-28 2:52 ` Wen Congyang
2011-03-01 4:11 ` Isaku Yamahata
2011-03-01 6:58 ` Wen Congyang
2011-03-01 7:13 ` Isaku Yamahata
2011-03-01 7:32 ` Wen Congyang
2011-03-01 9:49 ` Isaku Yamahata
2011-03-09 4:08 ` Ryan Harper
2011-03-09 5:04 ` Wen Congyang
2011-03-09 6:12 ` Ryan Harper
2011-03-09 7:19 ` Wen Congyang
2011-03-10 4:31 ` Ryan Harper
2011-03-10 5:28 ` Wen Congyang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1298396180-23734-1-git-send-email-wdauchy@gmail.com \
--to=wdauchy@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).