mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 13:05:27 +00:00
libxl: use job functions in vcpu set and pin functions
These operations aren't necessarily time consuming, but need to wait in the queue of modify jobs. Signed-off-by: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
parent
f9e6b7024c
commit
7df46cff6b
@ -2329,22 +2329,25 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|||||||
if (virDomainSetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainSetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm) && (flags & VIR_DOMAIN_VCPU_LIVE)) {
|
if (!virDomainObjIsActive(vm) && (flags & VIR_DOMAIN_VCPU_LIVE)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("cannot set vcpus on an inactive domain"));
|
_("cannot set vcpus on an inactive domain"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vm->persistent && (flags & VIR_DOMAIN_VCPU_CONFIG)) {
|
if (!vm->persistent && (flags & VIR_DOMAIN_VCPU_CONFIG)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("cannot change persistent config of a transient domain"));
|
_("cannot change persistent config of a transient domain"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((max = libxlConnectGetMaxVcpus(dom->conn, NULL)) < 0) {
|
if ((max = libxlConnectGetMaxVcpus(dom->conn, NULL)) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("could not determine max vcpus for the domain"));
|
_("could not determine max vcpus for the domain"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM) && vm->def->maxvcpus < max) {
|
if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM) && vm->def->maxvcpus < max) {
|
||||||
@ -2355,17 +2358,17 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("requested vcpus is greater than max allowable"
|
_("requested vcpus is greater than max allowable"
|
||||||
" vcpus for the domain: %d > %d"), nvcpus, max);
|
" vcpus for the domain: %d > %d"), nvcpus, max);
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
|
|
||||||
if (!(def = virDomainObjGetPersistentDef(cfg->caps, driver->xmlopt, vm)))
|
if (!(def = virDomainObjGetPersistentDef(cfg->caps, driver->xmlopt, vm)))
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
|
|
||||||
maplen = VIR_CPU_MAPLEN(nvcpus);
|
maplen = VIR_CPU_MAPLEN(nvcpus);
|
||||||
if (VIR_ALLOC_N(bitmask, maplen) < 0)
|
if (VIR_ALLOC_N(bitmask, maplen) < 0)
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
|
|
||||||
for (i = 0; i < nvcpus; ++i) {
|
for (i = 0; i < nvcpus; ++i) {
|
||||||
pos = i / 8;
|
pos = i / 8;
|
||||||
@ -2391,7 +2394,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to set vcpus for domain '%d'"
|
_("Failed to set vcpus for domain '%d'"
|
||||||
" with libxenlight"), dom->id);
|
" with libxenlight"), dom->id);
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2400,7 +2403,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to set vcpus for domain '%d'"
|
_("Failed to set vcpus for domain '%d'"
|
||||||
" with libxenlight"), dom->id);
|
" with libxenlight"), dom->id);
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
def->vcpus = nvcpus;
|
def->vcpus = nvcpus;
|
||||||
break;
|
break;
|
||||||
@ -2411,6 +2414,10 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|||||||
if (flags & VIR_DOMAIN_VCPU_CONFIG)
|
if (flags & VIR_DOMAIN_VCPU_CONFIG)
|
||||||
ret = virDomainSaveConfig(cfg->configDir, def);
|
ret = virDomainSaveConfig(cfg->configDir, def);
|
||||||
|
|
||||||
|
endjob:
|
||||||
|
if (!libxlDomainObjEndJob(driver, vm))
|
||||||
|
vm = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(bitmask);
|
VIR_FREE(bitmask);
|
||||||
if (vm)
|
if (vm)
|
||||||
@ -2502,15 +2509,18 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu,
|
|||||||
if (virDomainPinVcpuFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainPinVcpuFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if ((flags & VIR_DOMAIN_AFFECT_LIVE) && !virDomainObjIsActive(vm)) {
|
if ((flags & VIR_DOMAIN_AFFECT_LIVE) && !virDomainObjIsActive(vm)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("domain is inactive"));
|
_("domain is inactive"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainLiveConfigHelperMethod(cfg->caps, driver->xmlopt, vm,
|
if (virDomainLiveConfigHelperMethod(cfg->caps, driver->xmlopt, vm,
|
||||||
&flags, &targetDef) < 0)
|
&flags, &targetDef) < 0)
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
||||||
targetDef = vm->def;
|
targetDef = vm->def;
|
||||||
@ -2521,7 +2531,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu,
|
|||||||
|
|
||||||
pcpumap = virBitmapNewData(cpumap, maplen);
|
pcpumap = virBitmapNewData(cpumap, maplen);
|
||||||
if (!pcpumap)
|
if (!pcpumap)
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
||||||
libxl_bitmap map = { .size = maplen, .map = cpumap };
|
libxl_bitmap map = { .size = maplen, .map = cpumap };
|
||||||
@ -2532,7 +2542,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to pin vcpu '%d' with libxenlight"),
|
_("Failed to pin vcpu '%d' with libxenlight"),
|
||||||
vcpu);
|
vcpu);
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2542,14 +2552,14 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to delete vcpupin xml for vcpu '%d'"),
|
_("Failed to delete vcpupin xml for vcpu '%d'"),
|
||||||
vcpu);
|
vcpu);
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
goto out;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!targetDef->cputune.vcpupin) {
|
if (!targetDef->cputune.vcpupin) {
|
||||||
if (VIR_ALLOC(targetDef->cputune.vcpupin) < 0)
|
if (VIR_ALLOC(targetDef->cputune.vcpupin) < 0)
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
targetDef->cputune.nvcpupin = 0;
|
targetDef->cputune.nvcpupin = 0;
|
||||||
}
|
}
|
||||||
if (virDomainVcpuPinAdd(&targetDef->cputune.vcpupin,
|
if (virDomainVcpuPinAdd(&targetDef->cputune.vcpupin,
|
||||||
@ -2559,10 +2569,10 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu,
|
|||||||
vcpu) < 0) {
|
vcpu) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("failed to update or add vcpupin xml"));
|
"%s", _("failed to update or add vcpupin xml"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
done:
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
||||||
@ -2571,6 +2581,10 @@ out:
|
|||||||
ret = virDomainSaveConfig(cfg->configDir, targetDef);
|
ret = virDomainSaveConfig(cfg->configDir, targetDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endjob:
|
||||||
|
if (!libxlDomainObjEndJob(driver, vm))
|
||||||
|
vm = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user