From 5037cea55e1f4029bc85a0ec3ade6fe8f24d1e8a Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 6 Jul 2011 16:33:53 -0600 Subject: [PATCH] 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. --- src/lxc/lxc_container.c | 12 ++++++------ src/lxc/lxc_driver.c | 12 +++++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index ef8469c411..8e1860bccb 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2010 Red Hat, Inc. + * Copyright (C) 2008-2011 Red Hat, Inc. * Copyright (C) 2008 IBM Corp. * * lxc_container.c: file description @@ -889,7 +889,7 @@ int lxcContainerStart(virDomainDefPtr def, char *ttyPath) { pid_t pid; - int flags; + int cflags; int stacksize = getpagesize() * 4; char *stack, *stacktop; lxc_child_argv_t args = { def, nveths, veths, control, ttyPath, @@ -902,19 +902,19 @@ int lxcContainerStart(virDomainDefPtr def, } 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()) { VIR_DEBUG("Enable user namespaces"); - flags |= CLONE_NEWUSER; + cflags |= CLONE_NEWUSER; } if (def->nets != NULL) { 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_DEBUG("clone() completed, new container PID is %d", pid); diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 69710da76d..b6da757b75 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -111,8 +111,10 @@ static void lxcDomainEventQueue(lxc_driver_t *driver, static virDrvOpenStatus lxcOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags ATTRIBUTE_UNUSED) + unsigned int flags) { + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + /* Verify uri was specified */ if (conn->uri == NULL) { if (lxc_driver == NULL) @@ -748,7 +750,7 @@ cleanup: static int lxcDomainSetMemoryParameters(virDomainPtr dom, virTypedParameterPtr params, int nparams, - unsigned int flags ATTRIBUTE_UNUSED) + unsigned int flags) { lxc_driver_t *driver = dom->conn->privateData; int i; @@ -756,6 +758,8 @@ static int lxcDomainSetMemoryParameters(virDomainPtr dom, virDomainObjPtr vm = NULL; int ret = -1; + virCheckFlags(0, -1); + lxcDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid); @@ -845,7 +849,7 @@ cleanup: static int lxcDomainGetMemoryParameters(virDomainPtr dom, virTypedParameterPtr params, int *nparams, - unsigned int flags ATTRIBUTE_UNUSED) + unsigned int flags) { lxc_driver_t *driver = dom->conn->privateData; int i; @@ -855,6 +859,8 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom, int ret = -1; int rc; + virCheckFlags(0, -1); + lxcDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid);