[libvirt PATCH] qemu: fix crash in qemuDomainSetBlkioParameters without cgroups

Pavel Hrdina posted 1 patch 3 years, 8 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1b4c5b5dcd1a28a1d7875f9060698a34d07dbae7.1597155712.git.phrdina@redhat.com
src/qemu/qemu_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt PATCH] qemu: fix crash in qemuDomainSetBlkioParameters without cgroups
Posted by Pavel Hrdina 3 years, 8 months ago
If we don't have cgroups available and user tries to update blkio
parameters for running VM it will crash.

It should have been protected by the virCgroupHasController() check but
it was never called if the API was executed without any flags.

We call virDomainObjGetDefs() which sets `def` and `persistentDef` based
on the flags and these two variables should be used to figure out if we
need to update LIVE, CONFIG or both states.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1808293

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/qemu/qemu_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 07e9518a9b..8008da6d16 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9356,7 +9356,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
     if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
         goto endjob;
 
-    if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+    if (def) {
         if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_BLKIO)) {
             virReportError(VIR_ERR_OPERATION_INVALID, "%s",
                            _("blkio cgroup isn't mounted"));
-- 
2.26.2

Re: [libvirt PATCH] qemu: fix crash in qemuDomainSetBlkioParameters without cgroups
Posted by Ján Tomko 3 years, 8 months ago
On a Tuesday in 2020, Pavel Hrdina wrote:
>If we don't have cgroups available and user tries to update blkio
>parameters for running VM it will crash.
>
>It should have been protected by the virCgroupHasController() check but
>it was never called if the API was executed without any flags.
>
>We call virDomainObjGetDefs() which sets `def` and `persistentDef` based
>on the flags and these two variables should be used to figure out if we
>need to update LIVE, CONFIG or both states.
>
>Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1808293
>
>Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
>---
> src/qemu/qemu_driver.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano