[libvirt] [PATCH] Kernel command line support for UML

Daniel P. Berrange berrange at redhat.com
Mon Jul 27 19:46:44 UTC 2009


On Mon, Jul 27, 2009 at 07:51:08PM +0100, Ron Yorston wrote:
> When experimenting with libvirt and UML I found it necessary to add
> support for additional kernel command line arguments.

ACK, this looks reasonable.

Daniel

> diff -up libvirt-0.6.5/src/uml_conf.c.uml-cmdline libvirt-0.6.5/src/uml_conf.c
> --- libvirt-0.6.5/src/uml_conf.c.uml-cmdline	2009-07-10 16:28:51.000000000 +0100
> +++ libvirt-0.6.5/src/uml_conf.c	2009-07-27 19:39:59.000000000 +0100
> @@ -326,6 +326,31 @@ umlBuildCommandLineChr(virConnectPtr con
>  }
>  
>  /*
> + * Null-terminate the current argument and return a pointer to the next.
> + * This should follow the same rules as the Linux kernel: arguments are
> + * separated by spaces; arguments can be quoted with double quotes; double
> + * quotes can't be escaped.
> + */
> +static char *umlNextArg(char *args)
> +{
> +    int in_quote = 0;
> +
> +    for (; *args; args++) {
> +        if (*args == ' ' && !in_quote) {
> +            *args++ = '\0';
> +            break;
> +        }
> +        if (*args == '"')
> +            in_quote = !in_quote;
> +    }
> +
> +    while (*args == ' ')
> +        args++;
> +
> +    return args;
> +}
> +
> +/*
>   * Constructs a argv suitable for launching uml with config defined
>   * for a given virtual machine.
>   */
> @@ -342,6 +367,7 @@ int umlBuildCommandLine(virConnectPtr co
>      const char **qargv = NULL;
>      int qenvc = 0, qenva = 0;
>      const char **qenv = NULL;
> +    char *cmdline = NULL;
>  
>      uname(&ut);
>  
> @@ -474,6 +500,22 @@ int umlBuildCommandLine(virConnectPtr co
>          ADD_ARG(ret);
>      }
>  
> +    if (vm->def->os.cmdline) {
> +        char *args, *next_arg;
> +        if ((cmdline = strdup(vm->def->os.cmdline)) == NULL)
> +            goto no_memory;
> +
> +        args = cmdline;
> +        while (*args == ' ')
> +            args++;
> +
> +        while (*args) {
> +            next_arg = umlNextArg(args);
> +            ADD_ARG_LIT(args);
> +            args = next_arg;
> +        }
> +    }
> +
>      ADD_ARG(NULL);
>      ADD_ENV(NULL);
>  
> @@ -495,6 +537,7 @@ int umlBuildCommandLine(virConnectPtr co
>              VIR_FREE((qenv)[i]);
>          VIR_FREE(qenv);
>      }
> +    VIR_FREE(cmdline);
>      return -1;
>  
>  #undef ADD_ARG
> 
> --
> Libvir-list mailing list
> Libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list