From: Weidong Han Subject: [PATCH RFC] qemu: fix hot remove assigned device Date: Tue, 9 Jun 2009 01:17:15 +0800 Message-ID: <1244481435-17224-1-git-send-email-weidong.han@intel.com> Cc: kvm@vger.kernel.org, Weidong Han To: avi@redhat.com, paul@codesourcery.com Return-path: Received: from mga14.intel.com ([143.182.124.37]:4374 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753428AbZFHJRO (ORCPT ); Mon, 8 Jun 2009 05:17:14 -0400 Sender: kvm-owner@vger.kernel.org List-ID: When hot remove an assigned device, segmentation fault was triggered by qemu_free(&pci_dev->qdev) in pci_unregister_device(). pci_register_device() doesn't initialize or set pci_dev->qdev. For an assigned device, qdev variable isn't touched at all. So segmentation fault happens when to free a non-initialized qdev. Paul, you introduced the code to free qdev in pci_unregiser_device. Did you miss something? Following patch changes the code back to free pci_dev, and fixes the hot remove issue. Signed-off-by: Weidong Han --- hw/pci.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 25581a4..77d63d8 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -377,7 +377,7 @@ int pci_unregister_device(PCIDevice *pci_dev) qemu_free_irqs(pci_dev->irq); pci_irq_index--; pci_dev->bus->devices[pci_dev->devfn] = NULL; - qdev_free(&pci_dev->qdev); + qemu_free(pci_dev); return 0; } -- 1.6.0.4