mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-17 06:03:52 +03:00
lxc: reject unknown flags
* src/lxc/lxc_driver.c (lxcOpen, lxcDomainSetMemoryParameters) (lxcDomainGetMemoryParameters): Reject unknown flags. * src/lxc/lxc_container.c (lxcContainerStart): Rename flags to cflags to reflect that it is not tied to libvirt.
This commit is contained in:
parent
9110941cfd
commit
5037cea55e
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2008-2010 Red Hat, Inc.
|
* Copyright (C) 2008-2011 Red Hat, Inc.
|
||||||
* Copyright (C) 2008 IBM Corp.
|
* Copyright (C) 2008 IBM Corp.
|
||||||
*
|
*
|
||||||
* lxc_container.c: file description
|
* lxc_container.c: file description
|
||||||
@ -889,7 +889,7 @@ int lxcContainerStart(virDomainDefPtr def,
|
|||||||
char *ttyPath)
|
char *ttyPath)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int flags;
|
int cflags;
|
||||||
int stacksize = getpagesize() * 4;
|
int stacksize = getpagesize() * 4;
|
||||||
char *stack, *stacktop;
|
char *stack, *stacktop;
|
||||||
lxc_child_argv_t args = { def, nveths, veths, control, ttyPath,
|
lxc_child_argv_t args = { def, nveths, veths, control, ttyPath,
|
||||||
@ -902,19 +902,19 @@ int lxcContainerStart(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
stacktop = stack + stacksize;
|
stacktop = stack + stacksize;
|
||||||
|
|
||||||
flags = CLONE_NEWPID|CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|SIGCHLD;
|
cflags = CLONE_NEWPID|CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|SIGCHLD;
|
||||||
|
|
||||||
if (userns_supported()) {
|
if (userns_supported()) {
|
||||||
VIR_DEBUG("Enable user namespaces");
|
VIR_DEBUG("Enable user namespaces");
|
||||||
flags |= CLONE_NEWUSER;
|
cflags |= CLONE_NEWUSER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->nets != NULL) {
|
if (def->nets != NULL) {
|
||||||
VIR_DEBUG("Enable network namespaces");
|
VIR_DEBUG("Enable network namespaces");
|
||||||
flags |= CLONE_NEWNET;
|
cflags |= CLONE_NEWNET;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid = clone(lxcContainerChild, stacktop, flags, &args);
|
pid = clone(lxcContainerChild, stacktop, cflags, &args);
|
||||||
VIR_FREE(stack);
|
VIR_FREE(stack);
|
||||||
VIR_DEBUG("clone() completed, new container PID is %d", pid);
|
VIR_DEBUG("clone() completed, new container PID is %d", pid);
|
||||||
|
|
||||||
|
@ -111,8 +111,10 @@ static void lxcDomainEventQueue(lxc_driver_t *driver,
|
|||||||
|
|
||||||
static virDrvOpenStatus lxcOpen(virConnectPtr conn,
|
static virDrvOpenStatus lxcOpen(virConnectPtr conn,
|
||||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||||
unsigned int flags ATTRIBUTE_UNUSED)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
||||||
|
|
||||||
/* Verify uri was specified */
|
/* Verify uri was specified */
|
||||||
if (conn->uri == NULL) {
|
if (conn->uri == NULL) {
|
||||||
if (lxc_driver == NULL)
|
if (lxc_driver == NULL)
|
||||||
@ -748,7 +750,7 @@ cleanup:
|
|||||||
static int lxcDomainSetMemoryParameters(virDomainPtr dom,
|
static int lxcDomainSetMemoryParameters(virDomainPtr dom,
|
||||||
virTypedParameterPtr params,
|
virTypedParameterPtr params,
|
||||||
int nparams,
|
int nparams,
|
||||||
unsigned int flags ATTRIBUTE_UNUSED)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
lxc_driver_t *driver = dom->conn->privateData;
|
lxc_driver_t *driver = dom->conn->privateData;
|
||||||
int i;
|
int i;
|
||||||
@ -756,6 +758,8 @@ static int lxcDomainSetMemoryParameters(virDomainPtr dom,
|
|||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
lxcDriverLock(driver);
|
lxcDriverLock(driver);
|
||||||
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
|
|
||||||
@ -845,7 +849,7 @@ cleanup:
|
|||||||
static int lxcDomainGetMemoryParameters(virDomainPtr dom,
|
static int lxcDomainGetMemoryParameters(virDomainPtr dom,
|
||||||
virTypedParameterPtr params,
|
virTypedParameterPtr params,
|
||||||
int *nparams,
|
int *nparams,
|
||||||
unsigned int flags ATTRIBUTE_UNUSED)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
lxc_driver_t *driver = dom->conn->privateData;
|
lxc_driver_t *driver = dom->conn->privateData;
|
||||||
int i;
|
int i;
|
||||||
@ -855,6 +859,8 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
lxcDriverLock(driver);
|
lxcDriverLock(driver);
|
||||||
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user