At 04/19/2011 03:44 PM, KAMEZAWA Hiroyuki Write:
This patch strips reusable part of qemudDomainUpdateDeviceFlags()
and consolidate it to qemudDomainModifyDeviceFlags().
No functional changes.
Based on Eric's and Hu's work.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com>
* src/qemu/qemu_driver.c
(qemudDomainUpdateDeviceLive) : core of UpdateDevice, extracted from
UpdateDeviceFlags()
(qemudDomainUpdateDeviceFlags): reworked as a wrapper function of
ModifyDeviceFlags()
---
src/qemu/qemu_driver.c | 209 +++++++++++++++++++++---------------------------
1 files changed, 90 insertions(+), 119 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f33a7f4..2bdf42e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3991,6 +3991,74 @@ static int qemudDomainDetachDeviceLive(virDomainObjPtr vm,
return ret;
}
+static int
+qemudDomainChangeDiskMediaLive(virDomainObjPtr vm,
+ virDomainDeviceDefPtr dev,
+ struct qemud_driver *driver,
+ virBitmapPtr qemuCaps,
+ bool force)
+{
+ virDomainDiskDefPtr disk = dev->data.disk;
+ virCgroupPtr cgroup = NULL;
+ int ret;
+
+ if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_DEVICES)) {
+ if (virCgroupForDomain(driver->cgroup,
+ vm->def->name, &cgroup, 0) !=0 ) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to find cgroup for %s"),
+ vm->def->name);
+ goto end;
+ }
+ if (qemuSetupDiskCgroup(driver, vm, cgroup, disk) < 0)
+ goto end;
+ }
+
+ switch (disk->device) {
+ case VIR_DOMAIN_DISK_DEVICE_CDROM:
+ case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
+ ret = qemuDomainChangeEjectableMedia(driver, vm, disk, qemuCaps, force);
+ if (ret == 0)
+ dev->data.disk = NULL;
+ break;
+ default:
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("disk bus '%s' cannot be updated."),
+ virDomainDiskBusTypeToString(disk->bus));
+ break;
+ }
+end:
If ret is not 0 and cgroup is not NULL, you should call qemuTeardownDiskCgroup() to do
some cleanup.
+ if (cgroup)
+ virCgroupFree(&cgroup);
+ return ret;
+}
+