[PATCH] test_driver: Implement virDomainGetSecurityLabelList

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Luke Yue <lukedyue@xxxxxxxxx>
---
 src/test/test_driver.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 611ec6d7ec..ae1b8ebc23 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -136,6 +136,7 @@ VIR_ONCE_GLOBAL_INIT(testDriver);
 
 #define TEST_MODEL "i686"
 #define TEST_EMULATOR "/usr/bin/test-hv"
+#define TEST_SECURITY_LABEL_LIST_LENGTH 2
 
 static const virNodeInfo defaultNodeInfo = {
     TEST_MODEL,
@@ -5037,6 +5038,45 @@ testDomainGetSecurityLabel(virDomainPtr dom,
     return ret;
 }
 
+static int
+testDomainGetSecurityLabelList(virDomainPtr dom,
+                               virSecurityLabelPtr* seclabels)
+{
+    virDomainObj *vm;
+    size_t i;
+    int ret = -1;
+
+    if (!(vm = testDomObjFromDomain(dom)))
+        return -1;
+
+    if (!virDomainObjIsActive(vm)) {
+        /* No seclabels */
+        *seclabels = NULL;
+        ret = 0;
+    } else {
+        int len = TEST_SECURITY_LABEL_LIST_LENGTH;
+
+        (*seclabels) = g_new0(virSecurityLabel, len);
+        memset(*seclabels, 0, sizeof(**seclabels) * len);
+
+        /* Fill the array */
+        for (i = 0; i < len; i++) {
+            if (virStrcpyStatic(seclabels[i]->label, "libvirt-test") < 0) {
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                            _("security label exceeds maximum: %zu"),
+                            sizeof(seclabels[i]->label) - 1);
+                VIR_FREE(*seclabels);
+                goto cleanup;
+            }
+        }
+        ret = len;
+    }
+
+ cleanup:
+    virDomainObjEndAPI(&vm);
+    return ret;
+}
+
 static int
 testNodeGetSecurityModel(virConnectPtr conn,
                          virSecurityModelPtr secmodel)
@@ -9357,6 +9397,7 @@ static virHypervisorDriver testHypervisorDriver = {
     .domainGetVcpuPinInfo = testDomainGetVcpuPinInfo, /* 1.2.18 */
     .domainGetMaxVcpus = testDomainGetMaxVcpus, /* 0.7.3 */
     .domainGetSecurityLabel = testDomainGetSecurityLabel, /* 7.5.0 */
+    .domainGetSecurityLabelList = testDomainGetSecurityLabelList, /* 7.5.0 */
     .nodeGetSecurityModel = testNodeGetSecurityModel, /* 7.5.0 */
     .domainGetXMLDesc = testDomainGetXMLDesc, /* 0.1.4 */
     .domainSetMemoryParameters = testDomainSetMemoryParameters, /* 5.6.0 */
-- 
2.32.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux