[lxc-devel] [PATCH 1/2] fix Coding Style

2010-10-12 Thread Daniel Lezcano
Fix the coding style, 80 chars lines, etc ...
Fix indentation blocks if ... then ... else ... fi

Signed-off-by: Daniel Lezcano dlezc...@fr.ibm.com
---
 src/lxc/conf.c |   78 
 1 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 4f1b46c..87d3265 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -186,51 +186,61 @@ static struct caps_opt caps_opt[] = {
{ mac_admin, CAP_MAC_ADMIN },
 };
 
-static int run_script(const char *name, const char *section, const char 
*script, ...)
+static int run_script(const char *name, const char *section,
+ const char *script, ...)
 {
va_list argp;
int vargc = 4;
+   int status = 0;
+
/* count variable arguments and add 4 for script, container
 * and section name  as well as the terminating NULL
 */
va_start(argp, script);
while (va_arg(argp, char*)) vargc++;
va_end(argp);
-   INFO(Executing script '%s' for container '%s', config section '%s', 
script, name, section);
+
+   INFO(Executing script '%s' for container '%s', config section '%s',
+script, name, section);
 
int pid = fork();
if (pid  0) {
ERROR(Error forking);
-   } else if (pid == 0) {
+   return -1;
+   }
+
+if (pid == 0) {
+
/* prepare command line arguments */
char *args[vargc];
int i;
args[0] = strdup(script);
args[1] = strdup(name);
args[2] = strdup(section);
+
va_start(argp, script);
-   for (i=3; ivargc; i++) {
+   for (i = 3; i  vargc; i++)
args[i] = va_arg(argp, char*);
-   }
va_end(argp);
+
args[vargc-1] = (char*) NULL;
 
execv(script, args);
/* if we cannot exec, we exit this fork */
-   SYSERROR(Failed to execute script '%s' for container '%s': 
%s, script, name, strerror(errno));
+   SYSERROR(Failed to execute script '%s' for container '%s': %s,
+script, name);
exit(1);
-   } else {
-   int status = 0;
-   waitpid( pid, status, 0 );
-   if (status != 0) {
-   /* something weird happened */
-   SYSERROR(Script '%s' terminated with non-zero exitcode 
%d,  name, status);
-   return -1;
-   } else {
-   return 0; /* all is well */
-   }
}
-   return -1;
+
+   waitpid(pid, status, 0);
+   if (status != 0) {
+   /* something weird happened */
+   SYSERROR(Script '%s' terminated with non-zero exitcode %d,
+name, status);
+   return -1;
+   }
+
+   return 0;
 }
 
 static int find_fstype_cb(char* buffer, void *data)
@@ -1317,13 +1327,10 @@ static int instanciate_veth(struct lxc_handler 
*handler, struct lxc_netdev *netd
}
 
if (netdev-upscript) {
-   err = run_script(handler-name, net, netdev-upscript, up, 
veth,
-veth1, (char*) NULL);
-   if (err) {
-   ERROR(Failed to run script '%s' for container '%s' and 
interface '%s',
- netdev-upscript, handler-name, veth1);
+   err = run_script(handler-name, net, netdev-upscript, up,
+veth, veth1, (char*) NULL);
+   if (err)
goto out_delete;
-   }
}
 
DEBUG(instanciated veth '%s/%s', index is '%d',
@@ -1370,13 +1377,10 @@ static int instanciate_macvlan(struct lxc_handler 
*handler, struct lxc_netdev *n
}
 
if (netdev-upscript) {
-   err = run_script(handler-name, net, netdev-upscript, up, 
macvlan,
-netdev-link, (char*) NULL);
-   if (err) {
-   ERROR(Failed to run script '%s' for container '%s' and 
interface '%s',
- netdev-upscript, handler-name, 
netdev-link);
+   err = run_script(handler-name, net, netdev-upscript, up,
+macvlan, netdev-link, (char*) NULL);
+   if (err)
return -1;
-   }
}
 
DEBUG(instanciated macvlan '%s', index is '%d' and mode '%d',
@@ -1433,13 +1437,10 @@ static int instanciate_phys(struct lxc_handler 
*handler, struct lxc_netdev *netd
 
if (netdev-upscript) {
int err;
-   err = run_script(handler-name, net, netdev-upscript, up, 
phys,
-netdev-link, (char*) NULL);
-   if (err) {
-

[lxc-devel] [GIT] lxc branch, master, updated. abbfd20baa348ce1b6b26dd9c2627c5e2f500b69

2010-10-12 Thread Daniel Lezcano
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project lxc.

The branch, master has been updated
   via  abbfd20baa348ce1b6b26dd9c2627c5e2f500b69 (commit)
   via  751d9dcd3904a45fcbad5d253498dadc401736af (commit)
   via  e3b4c4c44ae909ba5073edca975bc42ff007d9c9 (commit)
  from  49d3e78dceea24fcdd09529d1c748b69e19ef63f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -
commit abbfd20baa348ce1b6b26dd9c2627c5e2f500b69
Author: Daniel Lezcano daniel.lezc...@free.fr
Date:   Tue Oct 12 10:52:47 2010 +0200

use popen and redirect script output

Change the run_script function to use popen and to redirect
the output of the script to the log file.

Signed-off-by: Daniel Lezcano dlezc...@fr.ibm.com

commit 751d9dcd3904a45fcbad5d253498dadc401736af
Author: Daniel Lezcano daniel.lezc...@free.fr
Date:   Tue Oct 12 10:52:47 2010 +0200

fix Coding Style

Fix the coding style, 80 chars lines, etc ...
Fix indentation blocks if ... then ... else ... fi

Signed-off-by: Daniel Lezcano dlezc...@fr.ibm.com

commit e3b4c4c44ae909ba5073edca975bc42ff007d9c9
Author: Stefan Tomanek stefan.toma...@wertarbyte.de
Date:   Tue Oct 12 10:52:47 2010 +0200

add lxc.network.script.up configuration hook

This commit adds an configuration option to specify a script to be
executed after creating and configuring the network used by the
container. The following arguments are passed to the script:

* container name
* config section name (net)

Additional arguments depend on the config section employing a
script hook; the following are used by the network system:

* execution context (up)
* network type (empty/veth/macvlan/phys)

Depending on the network type, other arguments may be passed:

veth/macvlan/phys:
* (host-sided) device name

Signed-off-by: Daniel Lezcano dlezc...@fr.ibm.com

---

Summary of changes:
 src/lxc/conf.c|  119 +++--
 src/lxc/conf.h|   19 
 src/lxc/confile.c |   25 +++
 src/lxc/start.c   |2 +-
 4 files changed, 142 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
lxc

--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2  L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel