[libvirt] [PATCHv2 0/3] Save domain satus after change some parameters

Related bug: https://bugzilla.redhat.com/show_bug.cgi?id=1146511 Also add BeginJob/EndJob in qemuDomainSetBlkioParameters, qemuDomainSetInterfaceParameters,qemuDomainSetNumaParameters Shanzhi Yu (3): qemu: save domain status after set the blkio parameters qemu: call qemuDomainObjBeginJob/qemuDomainObjEndJob in qemuDomainSetInterfaceParameters qemu: save domain status after set domain's numa parameters src/qemu/qemu_driver.c | 76 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 24 deletions(-) -- 1.9.3

After set the blkio parameters for running domain, save the change into live xml is needed to survive restarting the libvirtd, same story with bug 1146511, meanwhile add call qemuDomainObjBeginJob/qemuDomainObjEndJob in qemuDomainSetBlkioParameters Signed-off-by: Shanzhi Yu <shyu@redhat.com> --- src/qemu/qemu_driver.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d111ccd..37d1a86 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7992,15 +7992,18 @@ qemuDomainSetBlkioParameters(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) - goto cleanup; + goto endjob; if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_BLKIO)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("blkio cgroup isn't mounted")); - goto cleanup; + goto endjob; } } @@ -8093,9 +8096,12 @@ qemuDomainSetBlkioParameters(virDomainPtr dom, VIR_FREE(devices); } } + + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) + goto endjob; } if (ret < 0) - goto cleanup; + goto endjob; if (flags & VIR_DOMAIN_AFFECT_CONFIG) { /* Clang can't see that if we get here, persistentDef was set. */ sa_assert(persistentDef); @@ -8133,6 +8139,10 @@ qemuDomainSetBlkioParameters(virDomainPtr dom, ret = -1; } + endjob: + if (!qemuDomainObjEndJob(driver, vm)) + vm = NULL; + cleanup: if (vm) virObjectUnlock(vm); -- 1.9.3

add call qemuDomainObjBeginJob/qemuDomainObjEndJob in qemuDomainSetInterfaceParameters Signed-off-by: Shanzhi Yu <shyu@redhat.com> --- src/qemu/qemu_driver.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 37d1a86..188b4f5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10139,16 +10139,19 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) - goto cleanup; + goto endjob; if (flags & VIR_DOMAIN_AFFECT_LIVE) { net = virDomainNetFind(vm->def, device); if (!net) { virReportError(VIR_ERR_INVALID_ARG, _("Can't find device %s"), device); - goto cleanup; + goto endjob; } } if (flags & VIR_DOMAIN_AFFECT_CONFIG) { @@ -10156,14 +10159,14 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, if (!persistentNet) { virReportError(VIR_ERR_INVALID_ARG, _("Can't find device %s"), device); - goto cleanup; + goto endjob; } } if ((VIR_ALLOC(bandwidth) < 0) || (VIR_ALLOC(bandwidth->in) < 0) || (VIR_ALLOC(bandwidth->out) < 0)) - goto cleanup; + goto endjob; for (i = 0; i < nparams; i++) { virTypedParameterPtr param = ¶ms[i]; @@ -10197,7 +10200,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (VIR_ALLOC(newBandwidth) < 0) - goto cleanup; + goto endjob; /* virNetDevBandwidthSet() will clear any previous value of * bandwidth parameters, so merge with old bandwidth parameters @@ -10205,7 +10208,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, if (bandwidth->in || (!inboundSpecified && net->bandwidth && net->bandwidth->in)) { if (VIR_ALLOC(newBandwidth->in) < 0) - goto cleanup; + goto endjob; memcpy(newBandwidth->in, bandwidth->in ? bandwidth->in : net->bandwidth->in, @@ -10214,7 +10217,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, if (bandwidth->out || (!outboundSpecified && net->bandwidth && net->bandwidth->out)) { if (VIR_ALLOC(newBandwidth->out) < 0) - goto cleanup; + goto endjob; memcpy(newBandwidth->out, bandwidth->out ? bandwidth->out : net->bandwidth->out, @@ -10222,7 +10225,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, } if (virNetDevBandwidthSet(net->ifname, newBandwidth, false) < 0) - goto cleanup; + goto endjob; virNetDevBandwidthFree(net->bandwidth); if (newBandwidth->in || newBandwidth->out) { @@ -10236,11 +10239,11 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, virNetDevBandwidthFree(net->data.network.actual->bandwidth); if (virNetDevBandwidthCopy(&net->data.network.actual->bandwidth, net->bandwidth) < 0) - goto cleanup; + goto endjob; } if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) - goto cleanup; + goto endjob; } if (flags & VIR_DOMAIN_AFFECT_CONFIG) { @@ -10265,10 +10268,15 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, } if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0) - goto cleanup; + goto endjob; } ret = 0; + + endjob: + if (!qemuDomainObjEndJob(driver, vm)) + vm = NULL; + cleanup: virNetDevBandwidthFree(bandwidth); virNetDevBandwidthFree(newBandwidth); -- 1.9.3

After set domain's numa parameters for running domain, save the change, save the change into live xml is needed to survive restarting the libvirtd, same story with bug 1146511; meanwihle add call qemuDomainObjBeginJob/qemuDomainObjEndJob in qemuDomainSetNumaParameters Signed-off-by: Shanzhi Yu <shyu@redhat.com> --- src/qemu/qemu_driver.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 188b4f5..ead53ad 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8986,15 +8986,18 @@ qemuDomainSetNumaParameters(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) - goto cleanup; + goto endjob; if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("cgroup cpuset controller is not mounted")); - goto cleanup; + goto endjob; } } @@ -9007,18 +9010,18 @@ qemuDomainSetNumaParameters(virDomainPtr dom, if (mode < 0 || mode >= VIR_DOMAIN_NUMATUNE_MEM_LAST) { virReportError(VIR_ERR_INVALID_ARG, _("unsupported numatune mode: '%d'"), mode); - goto cleanup; + goto endjob; } } else if (STREQ(param->field, VIR_DOMAIN_NUMA_NODESET)) { if (virBitmapParse(param->value.s, 0, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) - goto cleanup; + goto endjob; if (virBitmapIsAllClear(nodeset)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Invalid nodeset for numatune")); - goto cleanup; + goto endjob; } } } @@ -9028,18 +9031,21 @@ qemuDomainSetNumaParameters(virDomainPtr dom, virDomainNumatuneGetMode(vm->def->numatune, -1) != mode) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("can't change numatune mode for running domain")); - goto cleanup; + goto endjob; } if (nodeset && qemuDomainSetNumaParamsLive(vm, caps, nodeset) < 0) - goto cleanup; + goto endjob; if (virDomainNumatuneSet(&vm->def->numatune, vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC, -1, mode, nodeset) < 0) - goto cleanup; + goto endjob; + + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) + goto endjob; } if (flags & VIR_DOMAIN_AFFECT_CONFIG) { @@ -9047,14 +9053,18 @@ qemuDomainSetNumaParameters(virDomainPtr dom, persistentDef->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC, -1, mode, nodeset) < 0) - goto cleanup; + goto endjob; if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0) - goto cleanup; + goto endjob; } ret = 0; + endjob: + if (!qemuDomainObjEndJob(driver, vm)) + vm = NULL; + cleanup: virBitmapFree(nodeset); if (vm) -- 1.9.3

On 10/06/2014 05:00 PM, Shanzhi Yu wrote:
Related bug: https://bugzilla.redhat.com/show_bug.cgi?id=1146511
Also add BeginJob/EndJob in qemuDomainSetBlkioParameters, qemuDomainSetInterfaceParameters,qemuDomainSetNumaParameters
Shanzhi Yu (3): qemu: save domain status after set the blkio parameters qemu: call qemuDomainObjBeginJob/qemuDomainObjEndJob in qemuDomainSetInterfaceParameters qemu: save domain status after set domain's numa parameters
src/qemu/qemu_driver.c | 76 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 24 deletions(-)
The patches looks OK. I have only just one thing to mention that for the "qemuDomainSetBlkioParameters" the values are not stored in the internal VM definition, they are directly applied into the cgroups and getting the values is done by asking the cgroups. The values then survived the restart of libvirtd, but it should definitely be stored in the internal VM definition. But this is a different issue and should be addressed by its own patch series. ACK and pushed, Thanks, Pavel.
participants (2)
-
Pavel Hrdina
-
Shanzhi Yu