[libvirt] [PATCH v3 05/18] virSecurityDACRestoreAllLabel: Reorder device relabeling

Michal Privoznik mprivozn at redhat.com
Wed Dec 12 12:40:49 UTC 2018


It helps whe trying to match calls with virSecurityDACSetAllLabel
if the order in which devices are set/restored is the same in
both functions.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange at redhat.com>
---
 src/security/security_dac.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 7be555903d..4935c962b9 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -1664,24 +1664,6 @@ virSecurityDACRestoreAllLabel(virSecurityManagerPtr mgr,
     VIR_DEBUG("Restoring security label on %s migrated=%d",
               def->name, migrated);
 
-    for (i = 0; i < def->nhostdevs; i++) {
-        if (virSecurityDACRestoreHostdevLabel(mgr,
-                                              def,
-                                              def->hostdevs[i],
-                                              NULL) < 0)
-            rc = -1;
-    }
-
-    for (i = 0; i < def->ngraphics; i++) {
-        if (virSecurityDACRestoreGraphicsLabel(mgr, def, def->graphics[i]) < 0)
-            return -1;
-    }
-
-    for (i = 0; i < def->ninputs; i++) {
-        if (virSecurityDACRestoreInputLabel(mgr, def, def->inputs[i]) < 0)
-            rc = -1;
-    }
-
     for (i = 0; i < def->ndisks; i++) {
         if (virSecurityDACRestoreImageLabelInt(mgr,
                                                def,
@@ -1690,6 +1672,24 @@ virSecurityDACRestoreAllLabel(virSecurityManagerPtr mgr,
             rc = -1;
     }
 
+    for (i = 0; i < def->ngraphics; i++) {
+        if (virSecurityDACRestoreGraphicsLabel(mgr, def, def->graphics[i]) < 0)
+            return -1;
+    }
+
+    for (i = 0; i < def->ninputs; i++) {
+        if (virSecurityDACRestoreInputLabel(mgr, def, def->inputs[i]) < 0)
+            rc = -1;
+    }
+
+    for (i = 0; i < def->nhostdevs; i++) {
+        if (virSecurityDACRestoreHostdevLabel(mgr,
+                                              def,
+                                              def->hostdevs[i],
+                                              NULL) < 0)
+            rc = -1;
+    }
+
     for (i = 0; i < def->nmems; i++) {
         if (virSecurityDACRestoreMemoryLabel(mgr,
                                              def,
-- 
2.19.2




More information about the libvir-list mailing list