On Wed, Jan 21, 2015 at 16:01:02 +0800, Zhu Guihua wrote:
This patch implements live hotunplug of a cpu device.
Signed-off-by: Zhu Guihua <zhugh.fnst(a)cn.fujitsu.com>
---
src/qemu/qemu_driver.c | 2 ++
src/qemu/qemu_hotplug.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_hotplug.h | 4 +++
3 files changed, 72 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ddc7eeb..004bc35 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7077,6 +7077,8 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
ret = qemuDomainDetachChrDevice(driver, vm, dev->data.chr);
break;
case VIR_DOMAIN_DEVICE_CPU:
+ ret = qemuDomainDetachCPUDevice(driver, vm, dev->data.cpu);
+ break;
case VIR_DOMAIN_DEVICE_FS:
case VIR_DOMAIN_DEVICE_INPUT:
case VIR_DOMAIN_DEVICE_SOUND:
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index bff0d14..41013d9 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2876,6 +2876,20 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
static int
+qemuDomainRemoveCPUDevice(virDomainObjPtr vm,
+ virDomainCPUDefPtr cpu)
+{
+ VIR_DEBUG("Removing cpu device %s from domain %p %s",
+ cpu->info.alias, vm, vm->def->name);
+
+ virDomainCPURemove(vm->def, cpu);
+ virDomainCPUDefFree(cpu);
If cpu is not identical (in meaning of being the same pointer), just a
definition denoting the same device this will leak the definition that
was previously stored in vm->def.
+
+ return 0;
+}
+
+
+static int
qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainChrDefPtr chr)
Peter