--- src/lxc/lxc_native.c | 44 ++++++++++++++++++++++++++++ tests/lxcconf2xmldata/lxcconf2xml-simple.xml | 6 ++++ 2 files changed, 50 insertions(+) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 7997fda..96523c4 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -500,6 +500,46 @@ lxcConvertNetworkSettings(virDomainDefPtr def, virConfPtr properties) return 0; } +static int +lxcCreateConsoles(virDomainDefPtr def, virConfPtr properties) +{ + virConfValuePtr value; + int nbttys = 0; + virDomainChrDefPtr console; + size_t i; + + if (!(value = virConfGetValue(properties, "lxc.tty")) || !value->str) + return 0; + + if (virStrToLong_i(value->str, NULL, 10, &nbttys) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse int: '%s'"), + value->str); + return -1; + } + + 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; +} + virDomainDefPtr lxcParseConfigString(const char *config) { @@ -564,6 +604,10 @@ lxcParseConfigString(const char *config) if (lxcConvertNetworkSettings(vmdef, properties) < 0) goto error; + /* Consoles */ + if (lxcCreateConsoles(vmdef, properties) < 0) + goto error; + goto cleanup; error: diff --git a/tests/lxcconf2xmldata/lxcconf2xml-simple.xml b/tests/lxcconf2xmldata/lxcconf2xml-simple.xml index 75c3b28..711e0d9 100644 --- a/tests/lxcconf2xmldata/lxcconf2xml-simple.xml +++ b/tests/lxcconf2xmldata/lxcconf2xml-simple.xml @@ -31,5 +31,11 @@ <source bridge='virbr0'/> <link state='up'/> </interface> + <console type='pty'> + <target type='lxc' port='0'/> + </console> + <console type='pty'> + <target type='lxc' port='1'/> + </console> </devices> </domain> -- 1.8.5.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list