]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
test_driver: Implement virNodeGetSecurityModel
authorLuke Yue <lukedyue@gmail.com>
Mon, 7 Jun 2021 07:38:18 +0000 (15:38 +0800)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 15 Jun 2021 12:15:13 +0000 (14:15 +0200)
Signed-off-by: Luke Yue <lukedyue@gmail.com>
src/test/test_driver.c
tests/virshtest.c

index 1b36c67eb299a3731d22f68c14e625223366b269..2cbe724724934bac678575ce28b44b7cda5a3c1a 100644 (file)
@@ -5007,6 +5007,36 @@ testDomainInterfaceAddressFromNet(testDriver *driver,
     return ret;
 }
 
+static int
+testNodeGetSecurityModel(virConnectPtr conn,
+                         virSecurityModelPtr secmodel)
+{
+    testDriver *driver = conn->privateData;
+
+    memset(secmodel, 0, sizeof(*secmodel));
+
+    if (driver->caps->host.nsecModels == 0 ||
+        driver->caps->host.secModels[0].model == NULL)
+        return 0;
+
+    if (virStrcpy(secmodel->model, driver->caps->host.secModels[0].model,
+                  VIR_SECURITY_MODEL_BUFLEN) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("security model string exceeds max %d bytes"),
+                       VIR_SECURITY_MODEL_BUFLEN - 1);
+        return -1;
+    }
+
+    if (virStrcpy(secmodel->doi, driver->caps->host.secModels[0].doi,
+                  VIR_SECURITY_DOI_BUFLEN) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("security DOI string exceeds max %d bytes"),
+                       VIR_SECURITY_DOI_BUFLEN - 1);
+        return -1;
+    }
+
+    return 0;
+}
 
 static int
 testDomainInterfaceAddresses(virDomainPtr dom,
@@ -9296,6 +9326,7 @@ static virHypervisorDriver testHypervisorDriver = {
     .domainGetVcpus = testDomainGetVcpus, /* 0.7.3 */
     .domainGetVcpuPinInfo = testDomainGetVcpuPinInfo, /* 1.2.18 */
     .domainGetMaxVcpus = testDomainGetMaxVcpus, /* 0.7.3 */
+    .nodeGetSecurityModel = testNodeGetSecurityModel, /* 7.5.0 */
     .domainGetXMLDesc = testDomainGetXMLDesc, /* 0.1.4 */
     .domainSetMemoryParameters = testDomainSetMemoryParameters, /* 5.6.0 */
     .domainGetMemoryParameters = testDomainGetMemoryParameters, /* 5.6.0 */
index add33215b78567cbf63cb17498ac9b67e585c6b8..119b2ef54df14fbdaa2916949558177c094a289f 100644 (file)
@@ -34,6 +34,8 @@ Used memory:    131072 KiB\n\
 Persistent:     yes\n\
 Autostart:      disable\n\
 Managed save:   no\n\
+Security model: testSecurity\n\
+Security DOI:   \n\
 \n";
 static const char *domuuid_fc4 = DOM_UUID "\n\n";
 static const char *domid_fc4 = "2\n\n";