libvirt/tests/seclabeltest.c
Michal Privoznik 3e26b476b5 security_manager: Load lock plugin on init
Now that we know what metadata lock manager user wishes to use we
can load it when initializing security driver. This is achieved
by adding new argument to virSecurityManagerNewDriver() and
subsequently to all functions that end up calling it.

The cfg.mk change is needed in order to allow lock_manager.h
inclusion in security driver without 'syntax-check' complaining.
This is safe thing to do as locking APIs will always exist (it's
only backend implementation that changes). However, instead of
allowing the include for all other drivers (like cpu, network,
and so on) allow it only for security driver. This will still
trigger the error if including from other drivers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-09-18 17:12:53 +02:00

47 lines
1012 B
C

#include <config.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "security/security_driver.h"
#include "virrandom.h"
#include "testutils.h"
static int
mymain(void)
{
virSecurityManagerPtr mgr;
const char *doi, *model;
if (virThreadInitialize() < 0)
return EXIT_FAILURE;
mgr = virSecurityManagerNew(NULL, "QEMU", NULL, VIR_SECURITY_MANAGER_DEFAULT_CONFINED);
if (mgr == NULL) {
fprintf(stderr, "Failed to start security driver");
return EXIT_FAILURE;
}
model = virSecurityManagerGetModel(mgr);
if (!model) {
fprintf(stderr, "Failed to copy secModel model: %s",
strerror(errno));
return EXIT_FAILURE;
}
doi = virSecurityManagerGetDOI(mgr);
if (!doi) {
fprintf(stderr, "Failed to copy secModel DOI: %s",
strerror(errno));
return EXIT_FAILURE;
}
virObjectUnref(mgr);
return 0;
}
VIR_TEST_MAIN(mymain)