lxc: container: Convert <init> exec to virCommand

This commit is contained in:
Cole Robinson 2011-05-05 17:38:09 -04:00
parent f095398a47
commit 0719c3d64c

View File

@ -54,6 +54,7 @@
#include "veth.h" #include "veth.h"
#include "uuid.h" #include "uuid.h"
#include "files.h" #include "files.h"
#include "command.h"
#define VIR_FROM_THIS VIR_FROM_LXC #define VIR_FROM_THIS VIR_FROM_LXC
@ -103,33 +104,19 @@ struct __lxc_child_argv {
*/ */
static int lxcContainerExecInit(virDomainDefPtr vmDef) static int lxcContainerExecInit(virDomainDefPtr vmDef)
{ {
char *uuidenv, *nameenv;
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
virCommandPtr cmd;
virUUIDFormat(vmDef->uuid, uuidstr); virUUIDFormat(vmDef->uuid, uuidstr);
if (virAsprintf(&uuidenv, "LIBVIRT_LXC_UUID=%s", uuidstr) < 0) { cmd = virCommandNew(vmDef->os.init);
virReportOOMError();
return -1;
}
if (virAsprintf(&nameenv, "LIBVIRT_LXC_NAME=%s", vmDef->name) < 0) {
virReportOOMError();
return -1;
}
const char *const argv[] = { virCommandAddEnvString(cmd, "PATH=/bin:/sbin");
vmDef->os.init, virCommandAddEnvString(cmd, "TERM=linux");
NULL, virCommandAddEnvPair(cmd, "LIBVIRT_LXC_UUID", uuidstr);
}; virCommandAddEnvPair(cmd, "LIBVIRT_LXC_NAME", vmDef->name);
const char *const envp[] = {
"PATH=/bin:/sbin",
"TERM=linux",
uuidenv,
nameenv,
NULL,
};
return execve(argv[0], (char **)argv,(char**)envp); return virCommandExec(cmd);
} }
/** /**