From: Mark McLoughlin <markmc@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org, Mark McLoughlin <markmc@redhat.com>
Subject: [PATCH 08/12] kvm: qemu: device-assignment: introduce free_assigned_device()
Date: Fri, 28 Nov 2008 17:10:46 +0000 [thread overview]
Message-ID: <1227892250-14386-8-git-send-email-markmc@redhat.com> (raw)
In-Reply-To: <1227892250-14386-7-git-send-email-markmc@redhat.com>
Add a function to fully free the AssignedDevice and AssignedDevInfo
and remove from the list.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
qemu/hw/device-assignment.c | 16 ++++++++++++++--
qemu/hw/device-assignment.h | 1 +
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c
index fde17ac..2836059 100644
--- a/qemu/hw/device-assignment.c
+++ b/qemu/hw/device-assignment.c
@@ -439,6 +439,19 @@ again:
static LIST_HEAD(, AssignedDevInfo) adev_head;
+void free_assigned_device(AssignedDevInfo *adev)
+{
+ AssignedDevice *dev = adev->assigned_dev;
+
+ if (dev) {
+ pci_unregister_device(&dev->dev);
+ adev->assigned_dev = dev = NULL;
+ }
+
+ LIST_REMOVE(adev, next);
+ qemu_free(adev);
+}
+
static uint32_t calc_assigned_dev_id(uint8_t bus, uint8_t devfn)
{
return (uint32_t)bus << 8 | (uint32_t)devfn;
@@ -479,8 +492,7 @@ void assigned_dev_update_irq(PCIDevice *d)
adev->name, strerror(-r));
fprintf(stderr, "Perhaps you re you assigning a device "
"that shares IRQ with another device?\n");
- LIST_REMOVE(adev, next);
- pci_unregister_device(&assigned_dev->dev);
+ free_assigned_device(adev);
adev = next;
continue;
}
diff --git a/qemu/hw/device-assignment.h b/qemu/hw/device-assignment.h
index 5a01d98..c8c47d3 100644
--- a/qemu/hw/device-assignment.h
+++ b/qemu/hw/device-assignment.h
@@ -94,6 +94,7 @@ struct AssignedDevInfo {
int disable_iommu;
};
+void free_assigned_device(AssignedDevInfo *adev);
PCIDevice *init_assigned_device(AssignedDevInfo *adev, PCIBus *bus);
AssignedDevInfo *add_assigned_device(const char *arg);
void add_assigned_devices(PCIBus *bus, const char **devices, int n_devices);
--
1.5.4.3
next prev parent reply other threads:[~2008-11-28 17:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-28 17:10 [PATCH 01/12] kvm: qemu: device-assignment: add_assigned_device() returns a pointer Mark McLoughlin
2008-11-28 17:10 ` [PATCH 02/12] kvm: qemu: device-assignment: introduce add_assigned_devices() Mark McLoughlin
2008-11-28 17:10 ` [PATCH 03/12] kvm: qemu: device-assignment: exit if cmdline parsing fails Mark McLoughlin
2008-11-28 17:10 ` [PATCH 04/12] kvm: qemu: device-assignment: unregister device if assignment fails Mark McLoughlin
2008-11-28 17:10 ` [PATCH 05/12] kvm: qemu: device-assignment: fixup error reporting Mark McLoughlin
2008-11-28 17:10 ` [PATCH 06/12] kvm: qemu: device-assignment: cleanup irq assignment error messages Mark McLoughlin
2008-11-28 17:10 ` [PATCH 07/12] kvm: qemu: device-assignment: remove device if irq assignment fails Mark McLoughlin
2008-11-28 17:10 ` Mark McLoughlin [this message]
2008-11-28 17:10 ` [PATCH 09/12] kvm: qemu: device-assignment: free device if hotplug fails Mark McLoughlin
2008-11-28 17:10 ` [PATCH 10/12] kvm: qemu: device-assignment: close PCIDevRegions::config_fd Mark McLoughlin
2008-11-28 17:10 ` [PATCH 11/12] kvm: qemu: device-assignment: munmap() mmio regions Mark McLoughlin
2008-11-28 17:10 ` [PATCH 12/12] kvm: qemu: device-assignment: init_assigned_device() error handling Mark McLoughlin
2008-11-28 19:05 ` [PATCH 06/12] kvm: qemu: device-assignment: cleanup irq assignment error messages John Rousseau
2008-11-30 10:47 ` Avi Kivity
2008-12-10 10:23 ` [PATCH] kvm: qemu: device-assignment: really exit if cmdline parsing fails Mark McLoughlin
2008-12-10 10:28 ` Avi Kivity
2008-11-28 17:14 ` [PATCH 01/12] kvm: qemu: device-assignment: add_assigned_device() returns a pointer Mark McLoughlin
2008-11-30 10:42 ` Avi Kivity
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=1227892250-14386-8-git-send-email-markmc@redhat.com \
--to=markmc@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.