mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-06 09:55:46 +00:00
test_driver: Implement virDomainGetSecurityLabel
Signed-off-by: Luke Yue <lukedyue@gmail.com>
This commit is contained in:
parent
0af05dffb8
commit
69f469ea83
@ -5007,6 +5007,36 @@ testDomainInterfaceAddressFromNet(testDriver *driver,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
testDomainGetSecurityLabel(virDomainPtr dom,
|
||||||
|
virSecurityLabelPtr seclabel)
|
||||||
|
{
|
||||||
|
virDomainObj *vm;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
memset(seclabel, 0, sizeof(*seclabel));
|
||||||
|
|
||||||
|
if (!(vm = testDomObjFromDomain(dom)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (virDomainObjIsActive(vm)) {
|
||||||
|
if (virStrcpyStatic(seclabel->label, "libvirt-test") < 0) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("security label exceeds maximum: %zu"),
|
||||||
|
sizeof(seclabel->label) - 1);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
seclabel->enforcing = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virDomainObjEndAPI(&vm);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
testNodeGetSecurityModel(virConnectPtr conn,
|
testNodeGetSecurityModel(virConnectPtr conn,
|
||||||
virSecurityModelPtr secmodel)
|
virSecurityModelPtr secmodel)
|
||||||
@ -9326,6 +9356,7 @@ static virHypervisorDriver testHypervisorDriver = {
|
|||||||
.domainGetVcpus = testDomainGetVcpus, /* 0.7.3 */
|
.domainGetVcpus = testDomainGetVcpus, /* 0.7.3 */
|
||||||
.domainGetVcpuPinInfo = testDomainGetVcpuPinInfo, /* 1.2.18 */
|
.domainGetVcpuPinInfo = testDomainGetVcpuPinInfo, /* 1.2.18 */
|
||||||
.domainGetMaxVcpus = testDomainGetMaxVcpus, /* 0.7.3 */
|
.domainGetMaxVcpus = testDomainGetMaxVcpus, /* 0.7.3 */
|
||||||
|
.domainGetSecurityLabel = testDomainGetSecurityLabel, /* 7.5.0 */
|
||||||
.nodeGetSecurityModel = testNodeGetSecurityModel, /* 7.5.0 */
|
.nodeGetSecurityModel = testNodeGetSecurityModel, /* 7.5.0 */
|
||||||
.domainGetXMLDesc = testDomainGetXMLDesc, /* 0.1.4 */
|
.domainGetXMLDesc = testDomainGetXMLDesc, /* 0.1.4 */
|
||||||
.domainSetMemoryParameters = testDomainSetMemoryParameters, /* 5.6.0 */
|
.domainSetMemoryParameters = testDomainSetMemoryParameters, /* 5.6.0 */
|
||||||
|
@ -21,6 +21,7 @@ main(void)
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
# define DOM_UUID "ef861801-45b9-11cb-88e3-afbfe5370493"
|
# define DOM_UUID "ef861801-45b9-11cb-88e3-afbfe5370493"
|
||||||
|
# define SECURITY_LABEL "libvirt-test (enforcing)"
|
||||||
|
|
||||||
static const char *dominfo_fc4 = "\
|
static const char *dominfo_fc4 = "\
|
||||||
Id: 2\n\
|
Id: 2\n\
|
||||||
@ -36,6 +37,7 @@ Autostart: disable\n\
|
|||||||
Managed save: no\n\
|
Managed save: no\n\
|
||||||
Security model: testSecurity\n\
|
Security model: testSecurity\n\
|
||||||
Security DOI: \n\
|
Security DOI: \n\
|
||||||
|
Security label: " SECURITY_LABEL "\n\
|
||||||
\n";
|
\n";
|
||||||
static const char *domuuid_fc4 = DOM_UUID "\n\n";
|
static const char *domuuid_fc4 = DOM_UUID "\n\n";
|
||||||
static const char *domid_fc4 = "2\n\n";
|
static const char *domid_fc4 = "2\n\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user