[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] Fix a crash when restarting libvirtd.



On Mon, Jan 25, 2010 at 02:28:15PM -0500, Chris Lalancette wrote:
> If you shutdown libvirtd while a domain with PCI
> devices is running, then try to restart libvirtd,
> libvirtd will crash.
> 
> This happens because qemuUpdateActivePciHostdevs() is calling
> pciDeviceListSteal() with a dev of 0x0 (NULL), and then trying
> to dereference it.  This patch fixes it up so that
> qemuUpdateActivePciHostdevs() steals the devices after first
> Get()'ting them, avoiding the crash.
> 
> Signed-off-by: Chris Lalancette <clalance redhat com>
> ---
>  src/qemu/qemu_driver.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 55550ef..bbdbe33 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -2147,6 +2147,7 @@ qemuUpdateActivePciHostdevs(struct qemud_driver *driver,
>                              virDomainDefPtr def)
>  {
>      pciDeviceList *pcidevs;
> +    int i;
>      int ret = -1;
>  
>      if (!def->nhostdevs)
> @@ -2155,8 +2156,9 @@ qemuUpdateActivePciHostdevs(struct qemud_driver *driver,
>      if (!(pcidevs = qemuGetPciHostDeviceList(NULL, def)))
>          return -1;
>  
> -    while (pciDeviceListCount(pcidevs) > 0) {
> -        pciDevice *dev = pciDeviceListSteal(NULL, pcidevs, 0);
> +    for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
> +        pciDevice *dev = pciDeviceListGet(pcidevs, i);
> +        pciDeviceListSteal(NULL, pcidevs, dev);
>          if (pciDeviceListAdd(NULL,
>                               driver->activePciHostdevs,
>                               dev) < 0) {
> -- 

ACK

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]