[PATCH v2 03/10] security: implement domainUpdateSecurityImageLabel for stack

Peng Liang posted 10 patches 1 month, 2 weeks ago

[PATCH v2 03/10] security: implement domainUpdateSecurityImageLabel for stack

Posted by Peng Liang 1 month, 2 weeks ago
Signed-off-by: Peng Liang <liangpeng10@huawei.com>
---
 src/security/security_stack.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/security/security_stack.c b/src/security/security_stack.c
index 3c2239910aa5..7712cac3b542 100644
--- a/src/security/security_stack.c
+++ b/src/security/security_stack.c
@@ -706,6 +706,25 @@ virSecurityStackMoveImageMetadata(virSecurityManager *mgr,
     return rc;
 }
 
+static int
+virSecurityStackUpdateImageLabel(virSecurityManager *mgr,
+                                 virDomainDef *vm,
+                                 virStorageSource *src,
+                                 virSecurityDomainImageLabelFlags flags)
+{
+    virSecurityStackData *priv = virSecurityManagerGetPrivateData(mgr);
+    virSecurityStackItem *item = priv->itemsHead;
+    int rc = 0;
+
+    for (; item; item = item->next) {
+        if (virSecurityManagerUpdateImageLabel(item->securityManager,
+                                               vm, src, flags) < 0)
+            rc = -1;
+    }
+
+    return rc;
+}
+
 static int
 virSecurityStackSetMemoryLabel(virSecurityManager *mgr,
                                virDomainDef *vm,
@@ -1033,6 +1052,7 @@ virSecurityDriver virSecurityDriverStack = {
     .domainSetSecurityImageLabel        = virSecurityStackSetImageLabel,
     .domainRestoreSecurityImageLabel    = virSecurityStackRestoreImageLabel,
     .domainMoveImageMetadata            = virSecurityStackMoveImageMetadata,
+    .domainUpdateSecurityImageLabel     = virSecurityStackUpdateImageLabel,
 
     .domainSetSecurityMemoryLabel       = virSecurityStackSetMemoryLabel,
     .domainRestoreSecurityMemoryLabel   = virSecurityStackRestoreMemoryLabel,
-- 
2.31.1