[lxc-devel] current git: lxc-start now requires -f ?

Andrian Nord nightnord at gmail.com
Sun Nov 15 22:52:33 UTC 2009


On Sat, Nov 14, 2009 at 07:26:31PM +0300, Michael Tokarev wrote:
> Maybe if no -f given, look in /etc/lxc/$name.conf and use that
> if exists?

This is a patch for this, in only exception, that it restores previous
behaviour: it checks /etc/lxc/${lxc.name}/config if no -f specified.
That's because there is commonly two configs - config and fstab, and
it's better to keep them in separate dir, imo.

Signed-off-by: Andrian Nord <NightNord at gmail.com>

diff --git a/src/lxc/lxc_start.c b/src/lxc/lxc_start.c
index ffeb66b..4b76c91 100644
--- a/src/lxc/lxc_start.c
+++ b/src/lxc/lxc_start.c
@@ -20,7 +20,9 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
+#define _GNU_SOURCE
 #include <stdio.h>
+#undef _GNU_SOURCE
 #include <libgen.h>
 #include <unistd.h>
 #include <string.h>
@@ -39,7 +41,9 @@
 
 #include <lxc/lxc.h>
 #include <lxc/log.h>
+
 #include "arguments.h"
+#include "config.h"
 
 lxc_log_define(lxc_start, lxc);
 
@@ -119,6 +123,7 @@ int main(int argc, char *argv[])
 	char *const *args;
 	int err = -1;
 	struct termios tios;
+	char *rcfile;
 
 	char *const default_args[] = {
 		"/sbin/init",
@@ -165,7 +170,16 @@ int main(int argc, char *argv[])
 
 	save_tty(&tios);
 
-	err = lxc_start(my_args.name, args, my_args.rcfile);
+	if (my_args.rcfile) {
+		rcfile = my_args.rcfile;
+	} else {
+		if (!asprintf(&rcfile, LXCPATH "/%s/config", my_args.name)) {
+			SYSERROR("failed to allocate memory");
+			return -1;
+		}
+	}
+
+	err = lxc_start(my_args.name, args, rcfile);
 
 	restore_tty(&tios);
 




More information about the lxc-devel mailing list