From nobody Sun Feb 8 06:54:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1542217678176875.5985039810217; Wed, 14 Nov 2018 09:47:58 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E6EC307D96D; Wed, 14 Nov 2018 17:47:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BFFEA60BF7; Wed, 14 Nov 2018 17:47:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 36D0F3D381; Wed, 14 Nov 2018 17:47:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAEHQ24I012562 for ; Wed, 14 Nov 2018 12:26:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id 696F760150; Wed, 14 Nov 2018 17:26:02 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5702B6019F for ; Wed, 14 Nov 2018 17:26:02 +0000 (UTC) Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 450C73086259 for ; Wed, 14 Nov 2018 17:26:01 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id a132so27191004qkg.1 for ; Wed, 14 Nov 2018 09:26:01 -0800 (PST) Received: from localhost.localdomain ([2804:431:b704:5cdb:adf7:2bc7:ec25:714]) by smtp.gmail.com with ESMTPSA id r1sm1123393qte.28.2018.11.14.09.25.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Nov 2018 09:25:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=y8x2L0sBwLIIOHY0Ep2vvE1SPXace7IMbqcxwc0zFuw=; b=PzlfWo96KcJV/ov868ps9Le0cRG+ZSlss/rlbJdwd7qw1jvwJWTgaaicRakIHcIbxP fDFrSkm66bQbGCgCPLk9rIeXUzY9UKT0J9bKg41h7UxV1T5DDiKuBvT2q5VYBlcKzNPa rFs+W9n4mfrMcVmZD6c7lsjhxHN9RC/kDA684MSbX/v48ZhZO6GribDQGTOLQrGZQldO LUzXLtlTaWPfpndzZm7vzm2OTnThn3PfDhdKNpw1JGG/Zbk9cw+B6ldI0rTBc2WGwe4X 3HaIa7v9Pq72BHP/q07V/Y1/5a495FhC/BzOw89xXAyIQ4PSlNZNRfEG4rRldOg+Ri+Y +1WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y8x2L0sBwLIIOHY0Ep2vvE1SPXace7IMbqcxwc0zFuw=; b=MwPjXr0A2ID1EVU68tHEBZu1Meg0OTsIyxmKnxHxiAXDt76R8znstumsnobU6hNObF gFo+jVG1uLC5BVHFtWfnxFNxbLcKxQnITK1y9Sdauzy7GimWFV1SausaYZYAGc3sxFfe J2/DEyNLk/fqPMYZZ4dhJEfs5R7sS4zjpmiu0d/hpf3fWYIMNvXQZ9L/RaIEHDfWUSuV VbUYjlvpMjYaIHjZ5s++VnFBQ4+LPn54thAlK6YhXHqNfAyD6UDVCP9F44kn+6z+/j29 rcAWWNDAaDO+arqSKQMOCsgUVS8bt2RZEf5YBN1WPHuN/FAJSBQ3NkieGxJgBO6Yus5p POTg== X-Gm-Message-State: AGRZ1gIQECrFZYUvthKSpWqbeuGg9Iz4MnZMNVQteoozKhPoArrHEWgn iFVZ7VLdUVs6mGuGZVaJ6pEOYEkiLM8= X-Google-Smtp-Source: AJdET5dMLdGp8A4uav01za6DZ7wDAYXboI7HR9FsrSpku3JvJtf9MkH5axi2rMAQ6RlS5eeTmvoZ1A== X-Received: by 2002:aed:2391:: with SMTP id j17mr2593993qtc.205.1542216360253; Wed, 14 Nov 2018 09:26:00 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Wed, 14 Nov 2018 15:25:45 -0200 Message-Id: <20181114172546.18656-2-jcfaracco@gmail.com> In-Reply-To: <20181114172546.18656-1-jcfaracco@gmail.com> References: <20181114172546.18656-1-jcfaracco@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 14 Nov 2018 17:26:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 14 Nov 2018 17:26:01 +0000 (UTC) for IP:'209.85.222.194' DOMAIN:'mail-qk1-f194.google.com' HELO:'mail-qk1-f194.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.111 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.222.194 mail-qk1-f194.google.com 209.85.222.194 mail-qk1-f194.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v4 1/2] lxc: Include support to lxc version 3.0 or higher. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 14 Nov 2018 17:47:57 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This patch introduce the new settings for LXC 3.0 or higher. The older versions keep the compatibility to deprecated settings for LXC, but after release 3.0, the compatibility was removed. This commit adds the support to the refactored settings. v1-v2: Michal's suggestions to handle differences between versions. v2-v3: Adding suggestions from Pino and John too. v3-v4: Appluing tests for LXC v3. Signed-off-by: Julio Faracco --- src/lxc/lxc_native.c | 52 ++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index cbdec723dd..9f6d4b3de8 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -200,8 +200,13 @@ lxcSetRootfs(virDomainDefPtr def, int type =3D VIR_DOMAIN_FS_TYPE_MOUNT; VIR_AUTOFREE(char *) value =3D NULL; =20 - if (virConfGetValueString(properties, "lxc.rootfs", &value) <=3D 0) - return -1; + if (virConfGetValueString(properties, "lxc.rootfs.path", &value) <=3D = 0) { + virResetLastError(); + + /* Check for pre LXC 3.0 legacy key */ + if (virConfGetValueString(properties, "lxc.rootfs", &value) <=3D 0) + return -1; + } =20 if (STRPREFIX(value, "/dev/")) type =3D VIR_DOMAIN_FS_TYPE_BLOCK; @@ -684,8 +689,13 @@ lxcCreateConsoles(virDomainDefPtr def, virConfPtr prop= erties) virDomainChrDefPtr console; size_t i; =20 - if (virConfGetValueString(properties, "lxc.tty", &value) <=3D 0) - return 0; + if (virConfGetValueString(properties, "lxc.tty.max", &value) <=3D 0) { + virResetLastError(); + + /* Check for pre LXC 3.0 legacy key */ + if (virConfGetValueString(properties, "lxc.tty", &value) <=3D 0) + return 0; + } =20 if (virStrToLong_i(value, NULL, 10, &nbttys) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse int: '%s= '"), @@ -724,13 +734,16 @@ lxcIdmapWalkCallback(const char *name, virConfValuePt= r value, void *data) char type; unsigned long start, target, count; =20 - if (STRNEQ(name, "lxc.id_map") || !value->str) - return 0; + /* LXC 3.0 uses "lxc.idmap", while legacy used "lxc.id_map" */ + if (STRNEQ(name, "lxc.idmap") || !value->str) { + if (!value->str || STRNEQ(name, "lxc.id_map")) + return 0; + } =20 if (sscanf(value->str, "%c %lu %lu %lu", &type, &target, &start, &count) !=3D 4) { - virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid lxc.id_map: '%s'= "), - value->str); + virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid %s: '%s'"), + name, value->str); return -1; } =20 @@ -1041,19 +1054,30 @@ lxcParseConfigString(const char *config, if (VIR_STRDUP(vmdef->os.init, "/sbin/init") < 0) goto error; =20 - if (virConfGetValueString(properties, "lxc.utsname", &value) <=3D 0 || - VIR_STRDUP(vmdef->name, value) < 0) + if (virConfGetValueString(properties, "lxc.uts.name", &value) <=3D 0) { + virResetLastError(); + + /* Check for pre LXC 3.0 legacy key */ + if (virConfGetValueString(properties, "lxc.utsname", &value) <=3D = 0) + goto error; + } + + if (VIR_STRDUP(vmdef->name, value) < 0) goto error; + if (!vmdef->name && (VIR_STRDUP(vmdef->name, "unnamed") < 0)) goto error; =20 if (lxcSetRootfs(vmdef, properties) < 0) goto error; =20 - /* Look for fstab: we shouldn't have it */ - if (virConfGetValue(properties, "lxc.mount")) { + /* LXC 3.0 uses "lxc.mount.fstab", while legacy used just "lxc.mount". + * In either case, generate the error to use "lxc.mount.entry" instead= */ + if (virConfGetValue(properties, "lxc.mount.fstab") || + virConfGetValue(properties, "lxc.mount")) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("lxc.mount found, use lxc.mount.entry lines inste= ad")); + _("lxc.mount.fstab or lxc.mount found, use " + "lxc.mount.entry lines instead")); goto error; } =20 @@ -1069,7 +1093,7 @@ lxcParseConfigString(const char *config, if (lxcCreateConsoles(vmdef, properties) < 0) goto error; =20 - /* lxc.id_map */ + /* lxc.idmap or legacy lxc.id_map */ if (virConfWalk(properties, lxcIdmapWalkCallback, vmdef) < 0) goto error; =20 --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list