mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-24 12:22:20 +00:00
qemu: fix iothread residual when qemuProcessSetupIOThread failed
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@huawei.com> Signed-off-by: Wang Xin <wangxinxin.wang@huawei.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
131fddd429
commit
d34640b0c0
18
src/qemu/qemu_driver.c
Normal file → Executable file
18
src/qemu/qemu_driver.c
Normal file → Executable file
@ -5293,6 +5293,8 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver,
|
|||||||
qemuMonitorIOThreadInfo **new_iothreads = NULL;
|
qemuMonitorIOThreadInfo **new_iothreads = NULL;
|
||||||
virDomainIOThreadIDDef *iothrid;
|
virDomainIOThreadIDDef *iothrid;
|
||||||
virJSONValue *props = NULL;
|
virJSONValue *props = NULL;
|
||||||
|
bool threadAdded = false;
|
||||||
|
bool objectAdded = false;
|
||||||
|
|
||||||
if (!(alias = g_strdup_printf("iothread%u", iothread_id)))
|
if (!(alias = g_strdup_printf("iothread%u", iothread_id)))
|
||||||
return -1;
|
return -1;
|
||||||
@ -5305,6 +5307,8 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver,
|
|||||||
if (qemuMonitorAddObject(priv->mon, &props, NULL) < 0)
|
if (qemuMonitorAddObject(priv->mon, &props, NULL) < 0)
|
||||||
goto exit_monitor;
|
goto exit_monitor;
|
||||||
|
|
||||||
|
objectAdded = true;
|
||||||
|
|
||||||
exp_niothreads++;
|
exp_niothreads++;
|
||||||
|
|
||||||
/* After hotplugging the IOThreads we need to re-detect the
|
/* After hotplugging the IOThreads we need to re-detect the
|
||||||
@ -5344,6 +5348,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver,
|
|||||||
if (!(iothrid = virDomainIOThreadIDAdd(vm->def, iothread_id)))
|
if (!(iothrid = virDomainIOThreadIDAdd(vm->def, iothread_id)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
threadAdded = true;
|
||||||
iothrid->thread_id = new_iothreads[idx]->thread_id;
|
iothrid->thread_id = new_iothreads[idx]->thread_id;
|
||||||
|
|
||||||
if (qemuProcessSetupIOThread(vm, iothrid) < 0)
|
if (qemuProcessSetupIOThread(vm, iothrid) < 0)
|
||||||
@ -5352,6 +5357,19 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (ret < 0) {
|
||||||
|
if (threadAdded)
|
||||||
|
virDomainIOThreadIDDel(vm->def, iothread_id);
|
||||||
|
|
||||||
|
if (objectAdded) {
|
||||||
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
if (qemuMonitorDelObject(priv->mon, alias, true) < 0)
|
||||||
|
VIR_WARN("deletion of iothread object %d of domain %s failed when cleanup",
|
||||||
|
iothread_id, vm->def->name);
|
||||||
|
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (new_iothreads) {
|
if (new_iothreads) {
|
||||||
for (idx = 0; idx < new_niothreads; idx++)
|
for (idx = 0; idx < new_niothreads; idx++)
|
||||||
VIR_FREE(new_iothreads[idx]);
|
VIR_FREE(new_iothreads[idx]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user