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

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1146511 Shanzhi Yu (3): qemu: save domain status after set the blkio parameters qemu: save domain status after set network interface's bandwidth parameters qemu: save domain status after set domain's numa parameters src/qemu/qemu_driver.c | 74 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 22 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 6606154..95244b4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7986,15 +7986,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; } } @@ -8087,9 +8090,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); @@ -8127,6 +8133,10 @@ qemuDomainSetBlkioParameters(virDomainPtr dom, ret = -1; } + endjob: + if (!qemuDomainObjEndJob(driver, vm)) + vm = NULL; + cleanup: if (vm) virObjectUnlock(vm); -- 1.9.3

After set network interface's bandwidth 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 qemuDomainSetInterfaceParameters Signed-off-by: Shanzhi Yu <shyu@redhat.com> --- src/qemu/qemu_driver.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 95244b4..dc3d0e4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10133,16 +10133,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) { @@ -10150,14 +10153,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]; @@ -10191,7 +10194,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 @@ -10199,7 +10202,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, @@ -10208,7 +10211,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, @@ -10216,7 +10219,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, } if (virNetDevBandwidthSet(net->ifname, newBandwidth, false) < 0) - goto cleanup; + goto endjob; virNetDevBandwidthFree(net->bandwidth); if (newBandwidth->in || newBandwidth->out) { @@ -10225,6 +10228,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, } else { net->bandwidth = NULL; } + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) + goto endjob; } if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (!persistentNet->bandwidth) { @@ -10248,10 +10253,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

On Mon, Sep 29, 2014 at 06:49:34PM +0800, Shanzhi Yu wrote:
After set network interface's bandwidth 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 qemuDomainSetInterfaceParameters
Signed-off-by: Shanzhi Yu <shyu@redhat.com> --- src/qemu/qemu_driver.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
Patch looks fine, but doesn't apply to current master, could you rebase the series and resend it, please? Martin

----- Original Message ----- | From: "Martin Kletzander" <mkletzan@redhat.com> | To: "Shanzhi Yu" <shyu@redhat.com> | Cc: libvir-list@redhat.com | Sent: Monday, October 6, 2014 5:43:13 PM | Subject: Re: [libvirt] [PATCH 2/3] qemu: save domain status after set network interface's bandwidth parameters | | On Mon, Sep 29, 2014 at 06:49:34PM +0800, Shanzhi Yu wrote: | >After set network interface's bandwidth 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 qemuDomainSetInterfaceParameters | > | >Signed-off-by: Shanzhi Yu <shyu@redhat.com> | >--- | > src/qemu/qemu_driver.c | 28 +++++++++++++++++++--------- | > 1 file changed, 19 insertions(+), 9 deletions(-) | > | | Patch looks fine, but doesn't apply to current master, could you | rebase the series and resend it, please? Martin, Thanks for your review, I will resend it. | | Martin | -- Regards shyu

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 dc3d0e4..4bf3c8c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8980,15 +8980,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; } } @@ -9001,18 +9004,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; } } } @@ -9022,18 +9025,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) { @@ -9041,14 +9047,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
participants (2)
-
Martin Kletzander
-
Shanzhi Yu