aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/vl.c b/vl.c
index 69a9f91..bdd78cf 100644
--- a/vl.c
+++ b/vl.c
@@ -1836,45 +1836,34 @@ int get_param_value(char *buf, int buf_size,
return 0;
}
-int check_params(const char * const *params, const char *str)
+int check_params(char *buf, int buf_size,
+ const char * const *params, const char *str)
{
- int name_buf_size = 1;
const char *p;
- char *name_buf;
- int i, len;
- int ret = 0;
-
- for (i = 0; params[i] != NULL; i++) {
- len = strlen(params[i]) + 1;
- if (len > name_buf_size) {
- name_buf_size = len;
- }
- }
- name_buf = qemu_malloc(name_buf_size);
+ int i;
p = str;
while (*p != '\0') {
- p = get_opt_name(name_buf, name_buf_size, p, '=');
+ p = get_opt_name(buf, buf_size, p, '=');
if (*p != '=') {
- ret = -1;
- break;
+ return -1;
}
p++;
- for(i = 0; params[i] != NULL; i++)
- if (!strcmp(params[i], name_buf))
+ for (i = 0; params[i] != NULL; i++) {
+ if (!strcmp(params[i], buf)) {
break;
+ }
+ }
if (params[i] == NULL) {
- ret = -1;
- break;
+ return -1;
}
p = get_opt_value(NULL, 0, p);
- if (*p != ',')
+ if (*p != ',') {
break;
+ }
p++;
}
-
- qemu_free(name_buf);
- return ret;
+ return 0;
}
/***********************************************************/
@@ -2227,8 +2216,9 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)
"cache", "format", "serial", "werror",
NULL };
- if (check_params(params, str) < 0) {
- fprintf(stderr, "qemu: unknown parameter in '%s'\n", str);
+ if (check_params(buf, sizeof(buf), params, str) < 0) {
+ fprintf(stderr, "qemu: unknown parameter '%s' in '%s'\n",
+ buf, str);
return -1;
}
@@ -2709,7 +2699,7 @@ static int usb_device_add(const char *devname, int is_hotplug)
} else if (strstart(devname, "net:", &p)) {
int nic = nb_nics;
- if (net_client_init("nic", p) < 0)
+ if (net_client_init(NULL, "nic", p) < 0)
return -1;
nd_table[nic].model = "usb";
dev = usb_net_init(&nd_table[nic]);
@@ -4783,7 +4773,12 @@ static void termsig_handler(int signal)
qemu_system_shutdown_request();
}
-static void termsig_setup(void)
+static void sigchld_handler(int signal)
+{
+ waitpid(-1, NULL, WNOHANG);
+}
+
+static void sighandler_setup(void)
{
struct sigaction act;
@@ -4792,6 +4787,10 @@ static void termsig_setup(void)
sigaction(SIGINT, &act, NULL);
sigaction(SIGHUP, &act, NULL);
sigaction(SIGTERM, &act, NULL);
+
+ act.sa_handler = sigchld_handler;
+ act.sa_flags = SA_NOCLDSTOP;
+ sigaction(SIGCHLD, &act, NULL);
}
#endif
@@ -5920,7 +5919,7 @@ int main(int argc, char **argv, char **envp)
#ifndef _WIN32
/* must be after terminal init, SDL library changes signal handlers */
- termsig_setup();
+ sighandler_setup();
#endif
/* Maintain compatibility with multiple stdio monitors */