From nobody Thu May 2 15:36:02 2024 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 1541785718116450.56313554369945; Fri, 9 Nov 2018 09:48:38 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 52F8F804F2; Fri, 9 Nov 2018 17:48:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 768795D787; Fri, 9 Nov 2018 17:48:33 +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 6090B18005CB; Fri, 9 Nov 2018 17:48:29 +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 wA9HVDZc020533 for ; Fri, 9 Nov 2018 12:31:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id D95CF60150; Fri, 9 Nov 2018 17:31:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D03F9600CD for ; Fri, 9 Nov 2018 17:31:13 +0000 (UTC) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (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 4F4ECBDD0 for ; Fri, 9 Nov 2018 17:31:12 +0000 (UTC) Received: by mail-qk1-f196.google.com with SMTP id 131so2920316qkd.4 for ; Fri, 09 Nov 2018 09:31:12 -0800 (PST) Received: from localhost.localdomain ([2804:431:b704:6b4f:611c:92f3:f15:3425]) by smtp.gmail.com with ESMTPSA id i33sm882440qtb.97.2018.11.09.09.31.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 09:31:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=rstxjUMfkLTP1Ed5gWrcFPEaz6n4zyc3ma/zSMR49V0=; b=Oe+M0E6pk0Ktd0jQk4W1c2kAkLVILVCQ8PUr4njYDgFJ/FQEJm2pF9422avyQIgKpf 7vIn2l8rEiaGdFHd0KqOKhphX60z1MDfteNbZ+2W6gIxec2HDu5QrgKZ9bF6LIj+XPum UGD0/RaCPWd3gw8W8jmOKf9amN2DW+Cg+87w315LYYT4Uo00rMBVJ792ZvFNnW5hVSIf i2W3Ak45PIAiTcvZuNO4k5r5aPdfniRe8DLehtsUGDtR+Ne4deWj1ttebjT+G9WFr2T0 K6yPWEe66QIp8ZKuwbUS81h0dbpXmvXw/mOAhgBkwsv0FFfMvpG0+0lyudjaK7wYjCNU mjzQ== 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:mime-version :content-transfer-encoding; bh=rstxjUMfkLTP1Ed5gWrcFPEaz6n4zyc3ma/zSMR49V0=; b=kSYXOX68qRkGK4P/1E2kBuF+ZZiJzEMvRnBOlAljgZ8OPmhiQ2W9hj65CNarQVnt3L B6UpGoPEHhNXGVDR9L5nH9SjgsY9KUQCOkkIDAgMNTS8gV9D45oueJhyG66HeVxyYXar BQgfL/x22pdea7lDsAYQWj+ZGOzxvsZLrvO34s4VME5aaPfCNrkz0ExgTtHoVyWefmJO xQ1sAQnsy7JRMe6N5F5yTh8trcczSz+Hhy6NYx4JBwr0iQiVbJRwZd0wKhHXc/PAgZLs etVS1ANMVAdAK64Obg5YWaN4r33PSSRMasCBgwPs87Yb1xEi2YEEe5jgc5WsyY25QiM5 7DUA== X-Gm-Message-State: AGRZ1gKJRFiDrN6IrEksxgC1fooxfbUj7R9j+JiATgbLHN/k9Ua3KmSU WQlB3hl/XzMZynygp8vOoi+q8j4nF+w= X-Google-Smtp-Source: AJdET5dOZP72ohaag34MGpfBahJJRa9RzyU5YbRBQ4FbbuOSQq+1/NXExjgdkGJ5fMkMGj4wV0sAWg== X-Received: by 2002:aed:34a3:: with SMTP id x32mr9334389qtd.316.1541784670770; Fri, 09 Nov 2018 09:31:10 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Fri, 9 Nov 2018 15:30:59 -0200 Message-Id: <20181109173059.31963-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.29]); Fri, 09 Nov 2018 17:31:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 09 Nov 2018 17:31:12 +0000 (UTC) for IP:'209.85.222.196' DOMAIN:'mail-qk1-f196.google.com' HELO:'mail-qk1-f196.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.196 mail-qk1-f196.google.com 209.85.222.196 mail-qk1-f196.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 09 Nov 2018 17:48:36 +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. Signed-off-by: Julio Faracco Reviewed-by: John Ferlan --- src/lxc/lxc_native.c | 45 +++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index cbdec723dd..d3ba12bb0e 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,12 +734,13 @@ 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) + /* LXC 3.0 uses "lxc.idmap", while legacy used "lxc.id_map" */ + if (STRNEQ(name, "lxc.idmap") || STRNEQ(name, "lxc.id_map") || !value-= >str) 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'= "), + virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid: '%s'"), value->str); return -1; } @@ -1041,19 +1052,27 @@ 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) - goto error; + 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 (!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 +1088,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