[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 07/16] LXC from native: convert lxc.tty to console devices



On Tue, Jan 14, 2014 at 02:49:56PM +0100, Cédric Bosdonnat wrote:
> ---
>  src/lxc/lxc_native.c                         | 41 ++++++++++++++++++++++++++++
>  tests/lxcconf2xmldata/lxcconf2xml-simple.xml |  6 ++++
>  2 files changed, 47 insertions(+)
> 
> diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
> index 3667d04..6ea4998 100644
> --- a/src/lxc/lxc_native.c
> +++ b/src/lxc/lxc_native.c
> @@ -673,6 +673,43 @@ lxcConvertNetworkSettings(virDomainDefPtr def, virPropertiesPtr properties)
>      return 0;
>  }
>  
> +static int
> +lxcCreateConsoles(virDomainDefPtr def, virPropertiesPtr properties)
> +{
> +    char *tty;
> +    int nbttys = 0;
> +    virDomainChrDefPtr console;
> +    size_t i;
> +
> +    if (!(tty = virPropertiesLookup(properties, "lxc.tty")))
> +        return 0;
> +
> +    if (virStrToLong_i(tty, NULL, 10, &nbttys) < 0)
> +        return -1;

You need to virReportError when this fails to parse.

> +
> +    if (VIR_ALLOC_N(def->consoles, nbttys) < 0)
> +        return -1;
> +
> +    def->nconsoles = nbttys;
> +    for (i = 0; i < nbttys; i++) {
> +        if (!(console = virDomainChrDefNew()))
> +            goto error;
> +
> +        console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
> +        console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC;
> +        console->target.port = i;
> +        console->source.type = VIR_DOMAIN_CHR_TYPE_PTY;
> +
> +        def->consoles[i] = console;
> +    }
> +
> +    return 0;
> +
> +error:
> +    virDomainChrDefFree(console);
> +    return -1;
> +}
> +


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]