aboutsummaryrefslogtreecommitdiff
path: root/src/lxc
diff options
context:
space:
mode:
authorMarcelo Cerri <mhcerri@linux.vnet.ibm.com>2012-08-15 19:10:35 -0300
committerMichal Privoznik <mprivozn@redhat.com>2012-08-20 19:13:33 +0200
commit6c3cf57d6cb27cf10064baf8cca0f396ec5d8061 (patch)
treee1a5159f3a49e59814325dbe131917dab031591b /src/lxc
parentselinux: Fix incorrect object label generation. (diff)
downloadlibvirt-6c3cf57d6cb27cf10064baf8cca0f396ec5d8061.tar.gz
libvirt-6c3cf57d6cb27cf10064baf8cca0f396ec5d8061.tar.bz2
libvirt-6c3cf57d6cb27cf10064baf8cca0f396ec5d8061.zip
Internal refactory of data structures
This patch updates the structures that store information about each domain and each hypervisor to support multiple security labels and drivers. It also updates all the remaining code to use the new fields. Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Diffstat (limited to 'src/lxc')
-rw-r--r--src/lxc/lxc_conf.c8
-rw-r--r--src/lxc/lxc_controller.c8
-rw-r--r--src/lxc/lxc_driver.c11
-rw-r--r--src/lxc/lxc_process.c23
4 files changed, 28 insertions, 22 deletions
diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index a508f212b..03340cf99 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -134,9 +134,13 @@ virCapsPtr lxcCapsInit(virLXCDriverPtr driver)
doi = virSecurityManagerGetDOI(driver->securityManager);
model = virSecurityManagerGetModel(driver->securityManager);
if (STRNEQ(model, "none")) {
- if (!(caps->host.secModel.model = strdup(model)))
+ /* Allocate just the primary security driver for LXC. */
+ if (VIR_ALLOC(caps->host.secModels) < 0)
goto no_memory;
- if (!(caps->host.secModel.doi = strdup(doi)))
+ caps->host.nsecModels = 1;
+ if (!(caps->host.secModels[0].model = strdup(model)))
+ goto no_memory;
+ if (!(caps->host.secModels[0].doi = strdup(doi)))
goto no_memory;
}
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 4c3c17fe2..e5aea1171 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1602,10 +1602,10 @@ int main(int argc, char *argv[])
goto cleanup;
VIR_DEBUG("Security model %s type %s label %s imagelabel %s",
- NULLSTR(ctrl->def->seclabel.model),
- virDomainSeclabelTypeToString(ctrl->def->seclabel.type),
- NULLSTR(ctrl->def->seclabel.label),
- NULLSTR(ctrl->def->seclabel.imagelabel));
+ NULLSTR(ctrl->def->seclabels[0]->model),
+ virDomainSeclabelTypeToString(ctrl->def->seclabels[0]->type),
+ NULLSTR(ctrl->def->seclabels[0]->label),
+ NULLSTR(ctrl->def->seclabels[0]->imagelabel));
ctrl->veths = veths;
ctrl->nveths = nveths;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 2b5707ec7..ff11c2c09 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -964,7 +964,6 @@ cleanup:
return ret;
}
-
/**
* lxcDomainStartWithFlags:
* @dom: domain to start
@@ -1182,12 +1181,12 @@ static int lxcNodeGetSecurityModel(virConnectPtr conn,
lxcDriverLock(driver);
memset(secmodel, 0, sizeof(*secmodel));
- /* NULL indicates no driver, which we treat as
- * success, but simply return no data in *secmodel */
- if (driver->caps->host.secModel.model == NULL)
+ /* we treat no driver as success, but simply return no data in *secmodel */
+ if (driver->caps->host.nsecModels == 0
+ || driver->caps->host.secModels[0].model == NULL)
goto cleanup;
- if (!virStrcpy(secmodel->model, driver->caps->host.secModel.model,
+ if (!virStrcpy(secmodel->model, driver->caps->host.secModels[0].model,
VIR_SECURITY_MODEL_BUFLEN)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("security model string exceeds max %d bytes"),
@@ -1196,7 +1195,7 @@ static int lxcNodeGetSecurityModel(virConnectPtr conn,
goto cleanup;
}
- if (!virStrcpy(secmodel->doi, driver->caps->host.secModel.doi,
+ if (!virStrcpy(secmodel->doi, driver->caps->host.secModels[0].doi,
VIR_SECURITY_DOI_BUFLEN)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("security DOI string exceeds max %d bytes"),
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index dc34bef97..cdbf14b19 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -706,10 +706,11 @@ int virLXCProcessStop(virLXCDriverPtr driver,
vm->def, false);
virSecurityManagerReleaseLabel(driver->securityManager, vm->def);
/* Clear out dynamically assigned labels */
- if (vm->def->seclabel.type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
- VIR_FREE(vm->def->seclabel.model);
- VIR_FREE(vm->def->seclabel.label);
- VIR_FREE(vm->def->seclabel.imagelabel);
+ if (vm->def->nseclabels &&
+ vm->def->seclabels[0]->type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
+ VIR_FREE(vm->def->seclabels[0]->model);
+ VIR_FREE(vm->def->seclabels[0]->label);
+ VIR_FREE(vm->def->seclabels[0]->imagelabel);
}
if (virCgroupForDomain(driver->cgroup, vm->def->name, &group, 0) == 0) {
@@ -1001,8 +1002,9 @@ int virLXCProcessStart(virConnectPtr conn,
/* If you are using a SecurityDriver with dynamic labelling,
then generate a security label for isolation */
VIR_DEBUG("Generating domain security label (if required)");
- if (vm->def->seclabel.type == VIR_DOMAIN_SECLABEL_DEFAULT)
- vm->def->seclabel.type = VIR_DOMAIN_SECLABEL_NONE;
+ if (vm->def->nseclabels &&
+ vm->def->seclabels[0]->type == VIR_DOMAIN_SECLABEL_DEFAULT)
+ vm->def->seclabels[0]->type = VIR_DOMAIN_SECLABEL_NONE;
if (virSecurityManagerGenLabel(driver->securityManager, vm->def) < 0) {
virDomainAuditSecurityLabel(vm, false);
@@ -1207,10 +1209,11 @@ cleanup:
vm->def, false);
virSecurityManagerReleaseLabel(driver->securityManager, vm->def);
/* Clear out dynamically assigned labels */
- if (vm->def->seclabel.type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
- VIR_FREE(vm->def->seclabel.model);
- VIR_FREE(vm->def->seclabel.label);
- VIR_FREE(vm->def->seclabel.imagelabel);
+ if (vm->def->nseclabels &&
+ vm->def->seclabels[0]->type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
+ VIR_FREE(vm->def->seclabels[0]->model);
+ VIR_FREE(vm->def->seclabels[0]->label);
+ VIR_FREE(vm->def->seclabels[0]->imagelabel);
}
}
for (i = 0 ; i < nttyFDs ; i++)