依旧是:/etc/qemu-ifup:could not launch network script …… 这下傻眼了。仔细考虑一下,我认为是QEMU自身代码的问题。 于是稍微跟踪了一下代码,发现qemu中的net.c代码,第1023行的 static int launch_script(const char *setup_script, const char *ifname, int fd)函数老是返回 -1。 原来是第1045行的execv(setup_script, args);函数没有成功启动脚本, 加了打印函数,errno 是 8,即ENOEXEC
The new process image file has the appropriate access permissions, but is not in the proper format.意思是,权限没有问题,但是格式不对。哦,难道是exec函数族不能直接启动脚本? 呵呵,BUG,绝对的BUG。
于是更改代码如下:
static int launch_script(const char *setup_script, const char *ifname, int fd) { int pid, status; char *args[4]; /* bacon modified */ char **parg;
/* try to launch network script */ pid = fork(); if (pid >= 0) { if (pid == 0) { char path[20];/* bacon add */ int open_max = sysconf (_SC_OPEN_MAX), i; for (i = 0; i < open_max; i++) if (i != STDIN_FILENO && i != STDOUT_FILENO && i != STDERR_FILENO && i != fd) close(i);