mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
lxc: Set default security model in XML parser config
Attempting to create a lxc domain with <seclabel type='none'/> fails virsh --connect lxc:/// create distro_nosec.xml error: Failed to create domain from distro_nosec.xml error: unsupported configuration: Security driver model '(null)' is not available Commit638ffa2228
adjusted the logic for setting a driver's default security model. The lxc driver does not set a default security driver model in the XML parser config, causing seclabels of type='none' to have a null model. The lxc driver's security manager is initialized in lxcStateInitialize() by calling lxcSecurityInit(). Use the model of this manager as the default in the XML parser config. For the record, this is a regression caused by commit638ffa2228
, which changed the logic for setting a driver's default security model. The qemu driver was adjusted accordingly, but a similar change was missed in the lxc driver. Signed-off-by: Jim Fehlig <jfehlig@suse.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
f6c11a23c8
commit
cf4e7e620a
@ -209,9 +209,10 @@ virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver,
|
|||||||
|
|
||||||
|
|
||||||
virDomainXMLOptionPtr
|
virDomainXMLOptionPtr
|
||||||
lxcDomainXMLConfInit(virLXCDriverPtr driver)
|
lxcDomainXMLConfInit(virLXCDriverPtr driver, const char *defsecmodel)
|
||||||
{
|
{
|
||||||
virLXCDriverDomainDefParserConfig.priv = driver;
|
virLXCDriverDomainDefParserConfig.priv = driver;
|
||||||
|
virLXCDriverDomainDefParserConfig.defSecModel = defsecmodel;
|
||||||
return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig,
|
return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig,
|
||||||
&virLXCDriverPrivateDataCallbacks,
|
&virLXCDriverPrivateDataCallbacks,
|
||||||
&virLXCDriverDomainXMLNamespace,
|
&virLXCDriverDomainXMLNamespace,
|
||||||
|
@ -112,7 +112,8 @@ int virLXCLoadDriverConfig(virLXCDriverConfigPtr cfg,
|
|||||||
virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver);
|
virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver);
|
||||||
virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver,
|
virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver,
|
||||||
bool refresh);
|
bool refresh);
|
||||||
virDomainXMLOptionPtr lxcDomainXMLConfInit(virLXCDriverPtr driver);
|
virDomainXMLOptionPtr lxcDomainXMLConfInit(virLXCDriverPtr driver,
|
||||||
|
const char *defsecmodel);
|
||||||
|
|
||||||
static inline void lxcDriverLock(virLXCDriverPtr driver)
|
static inline void lxcDriverLock(virLXCDriverPtr driver)
|
||||||
{
|
{
|
||||||
|
@ -169,7 +169,7 @@ virLXCControllerDriverNew(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
driver->caps = virLXCDriverCapsInit(NULL);
|
driver->caps = virLXCDriverCapsInit(NULL);
|
||||||
driver->xmlopt = lxcDomainXMLConfInit(driver);
|
driver->xmlopt = lxcDomainXMLConfInit(driver, NULL);
|
||||||
|
|
||||||
return driver;
|
return driver;
|
||||||
}
|
}
|
||||||
|
@ -1470,6 +1470,7 @@ static int lxcStateInitialize(bool privileged,
|
|||||||
{
|
{
|
||||||
virLXCDriverConfigPtr cfg = NULL;
|
virLXCDriverConfigPtr cfg = NULL;
|
||||||
bool autostart = true;
|
bool autostart = true;
|
||||||
|
const char *defsecmodel;
|
||||||
|
|
||||||
if (root != NULL) {
|
if (root != NULL) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
@ -1525,7 +1526,9 @@ static int lxcStateInitialize(bool privileged,
|
|||||||
if (!(lxc_driver->hostdevMgr = virHostdevManagerGetDefault()))
|
if (!(lxc_driver->hostdevMgr = virHostdevManagerGetDefault()))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(lxc_driver->xmlopt = lxcDomainXMLConfInit(lxc_driver)))
|
defsecmodel = virSecurityManagerGetModel(lxc_driver->securityManager);
|
||||||
|
|
||||||
|
if (!(lxc_driver->xmlopt = lxcDomainXMLConfInit(lxc_driver, defsecmodel)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(lxc_driver->closeCallbacks = virCloseCallbacksNew()))
|
if (!(lxc_driver->closeCallbacks = virCloseCallbacksNew()))
|
||||||
|
@ -71,7 +71,7 @@ testLXCDriverInit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
driver->caps = testLXCCapsInit();
|
driver->caps = testLXCCapsInit();
|
||||||
driver->xmlopt = lxcDomainXMLConfInit(driver);
|
driver->xmlopt = lxcDomainXMLConfInit(driver, NULL);
|
||||||
|
|
||||||
return driver;
|
return driver;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user