From: Lei Yang <yanglei209(a)huawei.com>
In process of iothread hotplug, qemuDomainHotplugAddIOThread() calls
qemuProcessSetupIOThread(). When qemuProcessSetupIOThread() returned
a failure, only the cgroup directory 'iothread' was cleaned up within
the function. Right after that qemuDomainHotplugAddIOThread() would
return failure directly without rolling back the livedef and iothread
process that created previously.
Further, when 'virsh schedinfo domain --live' requires schedinfo of
such machine, the interface will always return a failure print as
follows: 'Failed to create v1 controller cpu for group: No such file
or directory'. The reason is qemuGetIOThreadsBWLive() using member
vm->def->iothreadids[0]->iothread_id to findout the corresponding
cgroup dircetory. In case mentioned previously, iothreadids[0] was not
been cleaned up while whose cgroup directroy has already been removed.
This patch rolls back the livedef and iothread process after
qemuProcessSetupIOThread() returned a failure. Of course we are not
limited to this function, we also perform the same rolling back after
any exception proecss in qemuDomainHotplugAddIOThread().
Signed-off-by: Lei Yang <yanglei209(a)huawei.com>
Signed-off-by: Wang Xin <wangxinxin.wang(a)huawei.com>
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
old mode 100644
new mode 100755
index f1f961c51c..4f09e82a13
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5293,6 +5293,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver,
qemuMonitorIOThreadInfo **new_iothreads = NULL;
virDomainIOThreadIDDef *iothrid;
virJSONValue *props = NULL;
+ bool objectHasAdded = false;
if (!(alias = g_strdup_printf("iothread%u", iothread_id)))
return -1;
@@ -5305,6 +5306,8 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver,
if (qemuMonitorAddObject(priv->mon, &props, NULL) < 0)
goto exit_monitor;
+ objectHasAdded = true;
+
exp_niothreads++;
/* After hotplugging the IOThreads we need to re-detect the
@@ -5352,6 +5355,13 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver,
ret = 0;
cleanup:
+ if (ret < 0 && objectHasAdded) {
+ qemuDomainObjEnterMonitor(driver, vm);
+ if (qemuMonitorDelObject(priv->mon, alias, true) < 0)
+ VIR_WARN("del iothread %d of %s failed when cleanup", iothread_id,
vm->def->name);
+ ignore_value(qemuDomainObjExitMonitor(driver, vm));
+ }
+
if (new_iothreads) {
for (idx = 0; idx < new_niothreads; idx++)
VIR_FREE(new_iothreads[idx]);
@@ -5360,6 +5370,8 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver,
virDomainAuditIOThread(vm, orig_niothreads, new_niothreads,
"update", ret == 0);
virJSONValueFree(props);
+ if (ret < 0)
+ virDomainIOThreadIDDel(vm->def, iothread_id);
return ret;
exit_monitor:
--
2.26.0.windows.1
Show replies by date