[PATCH 9/9] migration: update image labels in dst after migration

Peng Liang liangpeng10 at huawei.com
Mon Aug 23 02:41:20 UTC 2021


Bacause the timestamp (the uptime of the host) is used to validate the
remembered labels, it need to update after migration.

Signed-off-by: Peng Liang <liangpeng10 at huawei.com>
---
 src/qemu/qemu_migration.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index b441d0226c8f..a5f7bd4add97 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -5624,6 +5624,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver,
     qemuDomainJobInfo *jobInfo = NULL;
     bool inPostCopy = false;
     bool doKill = true;
+    size_t i;
 
     VIR_DEBUG("driver=%p, dconn=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
               "cookieout=%p, cookieoutlen=%p, flags=0x%lx, retcode=%d",
@@ -5831,6 +5832,17 @@ qemuMigrationDstFinish(virQEMUDriver *driver,
     /* Guest is successfully running, so cancel previous auto destroy */
     qemuProcessAutoDestroyRemove(driver, vm);
 
+    for (i = 0; i < vm->def->ndisks; i++) {
+        virStorageSource *src = vm->def->disks[i]->src;
+
+        if (!virStorageSourceIsLocalStorage(src) || !src->path ||
+            virFileIsSharedFS(src->path) < 0)
+            continue;
+
+        if (qemuSecurityUpdateImageLabel(driver, vm, src) < 0)
+            VIR_WARN("Failed to update security label for %s", src->path);
+    }
+
  endjob:
     if (!dom &&
         !(flags & VIR_MIGRATE_OFFLINE) &&
-- 
2.31.1





More information about the libvir-list mailing list