/* NOTE: this parser is an approximate form of the real command parser. Number of args have a limit of MAX_ARGS. If cmdline contains more, it will return with failure.  */
static int parse_cmdline(const char *cmdline, int *pnb_args, char **args)
/* NOTE: this parser is an approximate form of the real command parser. Number of args have a limit of MAX_ARGS. If cmdline contains more, it will return with failure.  */
static int parse_cmdline(const char *cmdline, int *pnb_args, char **args)
{
    const char *p;
    int nb_args, ret;
    char buf[1024];
    p = cmdline;
    nb_args = 0;
    for (;;) {
        while (qemu_isspace(*p)) {
            p++;
        }
        if (*p == '\0') {
            break;
        }
        if (nb_args >= MAX_ARGS) {
            goto fail;
        }
        ret = get_str(buf, sizeof(buf), &p);
        if (ret < 0) {
            goto fail;
        }
        args[nb_args] = g_strdup(buf);
        nb_args++;
    }
    *pnb_args = nb_args;
    return 0;
 fail:
    free_cmdline_args(args, nb_args);
    return -1;
}