提交 cac6d639 编写于 作者: P Peter Krempa

qemu: Refactor qemuDomainPinIOThread by reusing virDomainObjGetDefs

上级 1282b350
...@@ -5796,8 +5796,8 @@ qemuDomainPinIOThread(virDomainPtr dom, ...@@ -5796,8 +5796,8 @@ qemuDomainPinIOThread(virDomainPtr dom,
virQEMUDriverPtr driver = dom->conn->privateData; virQEMUDriverPtr driver = dom->conn->privateData;
virQEMUDriverConfigPtr cfg = NULL; virQEMUDriverConfigPtr cfg = NULL;
virDomainObjPtr vm; virDomainObjPtr vm;
virCapsPtr caps = NULL; virDomainDefPtr def;
virDomainDefPtr persistentDef = NULL; virDomainDefPtr persistentDef;
virBitmapPtr pcpumap = NULL; virBitmapPtr pcpumap = NULL;
qemuDomainObjPrivatePtr priv; qemuDomainObjPrivatePtr priv;
virCgroupPtr cgroup_iothread = NULL; virCgroupPtr cgroup_iothread = NULL;
...@@ -5820,9 +5820,6 @@ qemuDomainPinIOThread(virDomainPtr dom, ...@@ -5820,9 +5820,6 @@ qemuDomainPinIOThread(virDomainPtr dom,
if (virDomainPinIOThreadEnsureACL(dom->conn, vm->def, flags) < 0) if (virDomainPinIOThreadEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup; goto cleanup;
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) { if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Changing affinity for IOThread dynamically is " _("Changing affinity for IOThread dynamically is "
...@@ -5833,9 +5830,8 @@ qemuDomainPinIOThread(virDomainPtr dom, ...@@ -5833,9 +5830,8 @@ qemuDomainPinIOThread(virDomainPtr dom,
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup; goto cleanup;
if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
&persistentDef) < 0) goto cleanup;
goto endjob;
if (!(pcpumap = virBitmapNewData(cpumap, maplen))) if (!(pcpumap = virBitmapNewData(cpumap, maplen)))
goto endjob; goto endjob;
...@@ -5846,12 +5842,11 @@ qemuDomainPinIOThread(virDomainPtr dom, ...@@ -5846,12 +5842,11 @@ qemuDomainPinIOThread(virDomainPtr dom,
goto endjob; goto endjob;
} }
if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (def) {
virDomainIOThreadIDDefPtr iothrid; virDomainIOThreadIDDefPtr iothrid;
virBitmapPtr cpumask; virBitmapPtr cpumask;
if (!(iothrid = virDomainIOThreadIDFind(vm->def, iothread_id))) { if (!(iothrid = virDomainIOThreadIDFind(def, iothread_id))) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("iothread %d not found"), iothread_id); _("iothread %d not found"), iothread_id);
goto endjob; goto endjob;
...@@ -5901,13 +5896,10 @@ qemuDomainPinIOThread(virDomainPtr dom, ...@@ -5901,13 +5896,10 @@ qemuDomainPinIOThread(virDomainPtr dom,
event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams); event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams);
} }
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (persistentDef) {
virDomainIOThreadIDDefPtr iothrid; virDomainIOThreadIDDefPtr iothrid;
virBitmapPtr cpumask; virBitmapPtr cpumask;
/* Coverity didn't realize that targetDef must be set if we got here. */
sa_assert(persistentDef);
if (!(iothrid = virDomainIOThreadIDFind(persistentDef, iothread_id))) { if (!(iothrid = virDomainIOThreadIDFind(persistentDef, iothread_id))) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("iothreadid %d not found"), iothread_id); _("iothreadid %d not found"), iothread_id);
...@@ -5938,7 +5930,6 @@ qemuDomainPinIOThread(virDomainPtr dom, ...@@ -5938,7 +5930,6 @@ qemuDomainPinIOThread(virDomainPtr dom,
VIR_FREE(str); VIR_FREE(str);
virBitmapFree(pcpumap); virBitmapFree(pcpumap);
virDomainObjEndAPI(&vm); virDomainObjEndAPI(&vm);
virObjectUnref(caps);
virObjectUnref(cfg); virObjectUnref(cfg);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册