2009-10-01 08:35:16 +00:00
|
|
|
From 17831d20051f8de8f1f7d661e8a23f4fe67c2153 Mon Sep 17 00:00:00 2001
|
2009-09-17 14:47:51 +00:00
|
|
|
From: Mark McLoughlin <markmc@redhat.com>
|
|
|
|
Date: Thu, 17 Sep 2009 15:32:45 +0100
|
|
|
|
Subject: [PATCH] Fix leak in PCI hostdev hot-unplug
|
|
|
|
|
|
|
|
* src/qemu_driver.c: sync the hostdev hot-unplug code with the disk/net
|
|
|
|
code.
|
|
|
|
|
2009-09-21 15:32:34 +00:00
|
|
|
(cherry-picked from commit a70da51ff76ed860bfc0cdee2e1d556da997c557)
|
|
|
|
|
2009-09-17 14:47:51 +00:00
|
|
|
Fedora-patch: libvirt-fix-pci-hostdev-hotunplug-leak.patch
|
|
|
|
---
|
|
|
|
src/qemu_driver.c | 20 +++++++++++++-------
|
|
|
|
1 files changed, 13 insertions(+), 7 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
|
|
|
|
index de31581..2ddcdc0 100644
|
|
|
|
--- a/src/qemu_driver.c
|
|
|
|
+++ b/src/qemu_driver.c
|
|
|
|
@@ -6206,14 +6206,20 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn,
|
|
|
|
pciFreeDevice(conn, pci);
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (i != --vm->def->nhostdevs)
|
|
|
|
- memmove(&vm->def->hostdevs[i],
|
|
|
|
- &vm->def->hostdevs[i+1],
|
|
|
|
- sizeof(*vm->def->hostdevs) * (vm->def->nhostdevs-i));
|
|
|
|
- if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs) < 0) {
|
|
|
|
- virReportOOMError(conn);
|
|
|
|
- ret = -1;
|
|
|
|
+ if (vm->def->nhostdevs > 1) {
|
|
|
|
+ memmove(vm->def->hostdevs + i,
|
|
|
|
+ vm->def->hostdevs + i + 1,
|
|
|
|
+ sizeof(*vm->def->hostdevs) *
|
|
|
|
+ (vm->def->nhostdevs - (i + 1)));
|
|
|
|
+ vm->def->nhostdevs--;
|
|
|
|
+ if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs) < 0) {
|
|
|
|
+ /* ignore, harmless */
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ VIR_FREE(vm->def->hostdevs);
|
|
|
|
+ vm->def->nhostdevs = 0;
|
|
|
|
}
|
|
|
|
+ virDomainHostdevDefFree(detach);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
--
|
|
|
|
1.6.2.5
|
|
|
|
|