[libvirt PATCH] qemu: Restore original memory locking limit on reconnect

Jiri Denemark posted 1 patch 1 year, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/38e144057a8f01b2d8ab2e8ec3a9d91d4e3bf7f9.1658927919.git.jdenemar@redhat.com
src/qemu/qemu_migration.c | 13 +++++++++----
src/qemu/qemu_process.c   |  2 ++
2 files changed, 11 insertions(+), 4 deletions(-)
[libvirt PATCH] qemu: Restore original memory locking limit on reconnect
Posted by Jiri Denemark 1 year, 9 months ago
Commit v8.4.0-287-gd4d3bb8130 tried to make sure the original
pre-migration memory locking limit is restored at the end of migration,
but it missed the case when libvirt daemon is restarted during
migration which needs to be aborted on reconnect.

And if this was not enough, I forgot to actually save the status XML
after setting the field in priv (in the commit mentioned above and also
in v8.4.0-291-gd375993ab3).

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_migration.c | 13 +++++++++----
 src/qemu/qemu_process.c   |  2 ++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 8e9428a5bb..e1f5e49683 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -4672,10 +4672,12 @@ qemuMigrationSrcStart(virDomainObj *vm,
     switch (spec->destType) {
     case MIGRATION_DEST_HOST:
         if (STREQ(spec->dest.host.protocol, "rdma") &&
-            virMemoryLimitIsSet(vm->def->mem.hard_limit) &&
-            qemuDomainSetMaxMemLock(vm, vm->def->mem.hard_limit << 10,
-                                    &priv->preMigrationMemlock) < 0) {
-            return -1;
+            virMemoryLimitIsSet(vm->def->mem.hard_limit)) {
+            if (qemuDomainSetMaxMemLock(vm, vm->def->mem.hard_limit << 10,
+                                        &priv->preMigrationMemlock) < 0)
+                return -1;
+            /* Store the original memory locking limit */
+            qemuDomainSaveStatus(vm);
         }
         return qemuMonitorMigrateToHost(priv->mon, migrateFlags,
                                         spec->dest.host.protocol,
@@ -4868,6 +4870,9 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
 
         if (qemuDomainSetMaxMemLock(vm, limit << 10, &priv->preMigrationMemlock) < 0)
             goto error;
+
+        /* Store the original memory locking limit */
+        qemuDomainSaveStatus(vm);
     }
 
     if (storageMigration) {
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d42333195a..137dcf5cf4 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3678,6 +3678,7 @@ qemuProcessRecoverMigration(virQEMUDriver *driver,
 {
     virDomainJobStatus migStatus = VIR_DOMAIN_JOB_STATUS_NONE;
     qemuDomainJobPrivate *jobPriv = job->privateData;
+    qemuDomainObjPrivate *priv = vm->privateData;
     virDomainState state;
     int reason;
     int rc;
@@ -3727,6 +3728,7 @@ qemuProcessRecoverMigration(virQEMUDriver *driver,
 
     qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_NONE,
                              jobPriv->migParams, job->apiFlags);
+    qemuDomainSetMaxMemLock(vm, 0, &priv->preMigrationMemlock);
 
     return 0;
 }
-- 
2.35.1
Re: [libvirt PATCH] qemu: Restore original memory locking limit on reconnect
Posted by Michal Prívozník 1 year, 9 months ago
On 7/27/22 15:18, Jiri Denemark wrote:
> Commit v8.4.0-287-gd4d3bb8130 tried to make sure the original
> pre-migration memory locking limit is restored at the end of migration,
> but it missed the case when libvirt daemon is restarted during
> migration which needs to be aborted on reconnect.
> 
> And if this was not enough, I forgot to actually save the status XML
> after setting the field in priv (in the commit mentioned above and also
> in v8.4.0-291-gd375993ab3).
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=2107424
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/qemu/qemu_migration.c | 13 +++++++++----
>  src/qemu/qemu_process.c   |  2 ++
>  2 files changed, 11 insertions(+), 4 deletions(-)


Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

and safe for freeze, since it's a bugfix :-)

Michal