From nobody Mon May 6 22:57:59 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 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 Reviewed-by: John Ferlan --- 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 From nobody Mon May 6 22:57:59 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 1542217668273299.29955841229025; Wed, 14 Nov 2018 09:47:48 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B58438AE79; Wed, 14 Nov 2018 17:47:45 +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 E7CE7605CD; Wed, 14 Nov 2018 17:47:43 +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 960873D384; Wed, 14 Nov 2018 17:47:43 +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 wAEHQ5Yi012583 for ; Wed, 14 Nov 2018 12:26:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8DBB0601A9; Wed, 14 Nov 2018 17:26:05 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 792B660150 for ; Wed, 14 Nov 2018 17:26:05 +0000 (UTC) Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) (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 6E86F31256BE for ; Wed, 14 Nov 2018 17:26:03 +0000 (UTC) Received: by mail-qk1-f195.google.com with SMTP id o125so27180973qkf.3 for ; Wed, 14 Nov 2018 09:26:03 -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.26.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Nov 2018 09:26:01 -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=lAQKkJW2N1fdUd1OzkY2o8hGNTDcptMWcukE+ABzM8c=; b=B9WOtNuwaUe+tN+y0wNWsAj/VIuDT8p189X1jjKky84DJyKOxI7a+IzSsEwzdVJCYR bHTbDGPI4vYwf0cF8sPLViNjQ6mezH8S6icXGCuI3hrHWkrIpRxpMjlZRFNdg3QYmtM+ Hl+AiXFZLeA4+dkaYnYXSBBvSFBhLBA8j2C5OBuxr4zSyp84kTQdfAMEl/X0cgedEEw4 V+oyzu2uNEetBIxOIR7UiyvSLFLgzI3pIhA43ds/tCpmtOQnIYS6ARlTP1Q1EG9/tTne m4fxN1y7ULl4k5Wcebjg+P6RB35ZMZn9WcsO4baXrT4KvRhh796oe5Qf9eTwh3mbJ9Im MLtA== 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=lAQKkJW2N1fdUd1OzkY2o8hGNTDcptMWcukE+ABzM8c=; b=KvUchN9+gJksQvF7zI7fErEuCWQm/jGr0PSkfO2tu2yE56biI6VnUuIgf80nZeLrNJ ajevqqh3KHmcMWCBg8lDc1uATqh+pEs9jAkwyNSX9wWDWyEMGOfhYtZFI/BmZBEIO31D pAispX1DoUXqKjWwGo5qcv/IFcsPU0JMBuIlCLY5GSI/f8ShDwFnS9rw4OQJFoooXyG+ OgufVbekVB3zrcz8voSdJQSZnZ3zwnxPOOYaOZOlX3XOwIqklGS+/y4HMxKeM1OYm8cA wCP7oMZL79990RKJXcbDS7rlWgBJ44KP4/WJN/p1G5Y2jaMem4cnh1Smyx2seNB1gsAw ckww== X-Gm-Message-State: AGRZ1gIk+dbJ+K9SR5R0CXg9+jd9hjpaK7rlZMMNgWg4La1aGA2+Ogim XsnJ18VMYf9lesjZYRvhE3yt4vPHT6U= X-Google-Smtp-Source: AJdET5docQZuVn/nFa+Q6Kn4fljwlYBFV3MABeEoL/3r80KpRU04d+bBiXcBdhbE1draXJpPRejEgQ== X-Received: by 2002:a37:c0db:: with SMTP id v88mr2510696qkv.288.1542216361995; Wed, 14 Nov 2018 09:26:01 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Wed, 14 Nov 2018 15:25:46 -0200 Message-Id: <20181114172546.18656-3-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.46]); Wed, 14 Nov 2018 17:26:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 14 Nov 2018 17:26:03 +0000 (UTC) for IP:'209.85.222.195' DOMAIN:'mail-qk1-f195.google.com' HELO:'mail-qk1-f195.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.195 mail-qk1-f195.google.com 209.85.222.195 mail-qk1-f195.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v4 2/2] tests: Adding tests cases to cover rebased settings for LXC 3.0. 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 14 Nov 2018 17:47:46 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This commit includes new test cases to cover LXC version 3.0 and higher. This LXC version rebased some settings entries and deprecated other ones. As we support both, we should include tests to minimize problems with integration between them. Signed-off-by: Julio Faracco Reviewed-by: John Ferlan --- .../lxcconf2xml-blkiotune-v3.config | 11 ++++ .../lxcconf2xml-cpusettune-v3.config | 6 +++ .../lxcconf2xml-cputune-v3.config | 7 +++ .../lxcconf2xml-ethernet-v3.config | 44 ++++++++++++++++ .../lxcconf2xml-fstab-v3.config | 37 ++++++++++++++ .../lxcconf2xml-idmap-v3.config | 5 ++ .../lxcconf2xml-macvlannetwork-v3.config | 13 +++++ .../lxcconf2xml-memtune-v3.config | 10 ++++ .../lxcconf2xml-nonenetwork-v3.config | 4 ++ .../lxcconf2xml-nonetwork-v3.config | 3 ++ .../lxcconf2xml-physnetwork-v3.config | 11 ++++ .../lxcconf2xml-simple-v3.config | 45 ++++++++++++++++ .../lxcconf2xml-vlannetwork-v3.config | 12 +++++ tests/lxcconf2xmltest.c | 51 ++++++++++++++++++- 14 files changed, 257 insertions(+), 2 deletions(-) create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-blkiotune-v3.config create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-cpusettune-v3.config create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-cputune-v3.config create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-ethernet-v3.config create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-fstab-v3.config create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-idmap-v3.config create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork-v3.con= fig create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-memtune-v3.config create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-nonenetwork-v3.config create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-nonetwork-v3.config create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-physnetwork-v3.config create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-simple-v3.config create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-vlannetwork-v3.config diff --git a/tests/lxcconf2xmldata/lxcconf2xml-blkiotune-v3.config b/tests/= lxcconf2xmldata/lxcconf2xml-blkiotune-v3.config new file mode 100644 index 0000000000..6d82ac74eb --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-blkiotune-v3.config @@ -0,0 +1,11 @@ +lxc.rootfs.path =3D /var/lib/lxc/migrate_test/rootfs +lxc.uts.name =3D migrate_test +lxc.autodev=3D1 + +lxc.cgroup.blkio.weight =3D 500 +lxc.cgroup.blkio.device_weight =3D 8:16 1000 +lxc.cgroup.blkio.device_weight =3D 8:0 300 +lxc.cgroup.blkio.throttle.read_bps_device =3D 8:16 1234 +lxc.cgroup.blkio.throttle.write_bps_device =3D 8:16 5678 +lxc.cgroup.blkio.throttle.read_iops_device =3D 8:16 4321 +lxc.cgroup.blkio.throttle.write_iops_device =3D 8:16 8765 diff --git a/tests/lxcconf2xmldata/lxcconf2xml-cpusettune-v3.config b/tests= /lxcconf2xmldata/lxcconf2xml-cpusettune-v3.config new file mode 100644 index 0000000000..248874b198 --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune-v3.config @@ -0,0 +1,6 @@ +lxc.rootfs.path =3D /var/lib/lxc/migrate_test/rootfs +lxc.uts.name =3D migrate_test +lxc.autodev=3D1 + +lxc.cgroup.cpuset.cpus =3D 1,2,5-7 +lxc.cgroup.cpuset.mems =3D 1-4 diff --git a/tests/lxcconf2xmldata/lxcconf2xml-cputune-v3.config b/tests/lx= cconf2xmldata/lxcconf2xml-cputune-v3.config new file mode 100644 index 0000000000..bd2da94ec2 --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-cputune-v3.config @@ -0,0 +1,7 @@ +lxc.rootfs.path =3D /var/lib/lxc/migrate_test/rootfs +lxc.uts.name =3D migrate_test +lxc.autodev=3D1 + +lxc.cgroup.cpu.shares =3D 1024 +lxc.cgroup.cpu.cfs_quota_us =3D -1 +lxc.cgroup.cpu.cfs_period_us =3D 500000 diff --git a/tests/lxcconf2xmldata/lxcconf2xml-ethernet-v3.config b/tests/l= xcconf2xmldata/lxcconf2xml-ethernet-v3.config new file mode 100644 index 0000000000..630cb2ebb6 --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-ethernet-v3.config @@ -0,0 +1,44 @@ +# Template used to create this container: opensuse +# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075= ef + +lxc.network.type =3D veth +lxc.network.flags =3D up +lxc.network.hwaddr =3D 02:00:15:8f:05:c1 +lxc.network.name =3D eth0 +lxc.network.ipv4 =3D 192.168.122.2/24 +lxc.network.ipv4.gateway =3D 192.168.122.1 +lxc.network.ipv6 =3D 2003:db8:1:0:214:1234:fe0b:3596/64 +lxc.network.ipv6.gateway =3D 2003:db8:1:0:214:1234:fe0b:3595 + +#remove next line if host DNS configuration should not be available to con= tainer +lxc.mount.entry =3D proc proc proc nodev,noexec,nosuid 0 0 +lxc.mount.entry =3D sysfs sys sysfs defaults 0 0 +lxc.mount.entry =3D tmpfs run tmpfs size=3D8m,mode=3D0755,nodev,nosuid 0 0 +lxc.mount.entry =3D /etc/resolv.conf etc/resolv.conf none bind,ro 0 0 +lxc.rootfs.path =3D /var/lib/lxc/migrate_test/rootfs +lxc.uts.name =3D migrate_test +lxc.arch =3D x86 +lxc.autodev=3D1 +lxc.tty.max =3D 2 +lxc.pts =3D 1024 +lxc.cap.drop =3D sys_module mac_admin mac_override mknod + +# When using LXC with apparmor, uncomment the next line to run unconfined: +#lxc.aa_profile =3D unconfined + +lxc.cgroup.devices.deny =3D a +# /dev/null and zero +lxc.cgroup.devices.allow =3D c 1:3 rwm +lxc.cgroup.devices.allow =3D c 1:5 rwm +# consoles +lxc.cgroup.devices.allow =3D c 5:1 rwm +lxc.cgroup.devices.allow =3D c 5:0 rwm +lxc.cgroup.devices.allow =3D c 4:0 rwm +lxc.cgroup.devices.allow =3D c 4:1 rwm +# /dev/{,u}random +lxc.cgroup.devices.allow =3D c 1:9 rwm +lxc.cgroup.devices.allow =3D c 1:8 rwm +lxc.cgroup.devices.allow =3D c 136:* rwm +lxc.cgroup.devices.allow =3D c 5:2 rwm +# rtc +lxc.cgroup.devices.allow =3D c 254:0 rwm diff --git a/tests/lxcconf2xmldata/lxcconf2xml-fstab-v3.config b/tests/lxcc= onf2xmldata/lxcconf2xml-fstab-v3.config new file mode 100644 index 0000000000..8b62818657 --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-fstab-v3.config @@ -0,0 +1,37 @@ +# Template used to create this container: opensuse +# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075= ef + +lxc.network.type =3D veth +lxc.network.flags =3D up +lxc.network.link =3D virbr0 +lxc.network.hwaddr =3D 02:00:15:8f:05:c1 +lxc.network.name =3D eth0 + +#remove next line if host DNS configuration should not be available to con= tainer +lxc.mount.fstab =3D /var/lib/lxc/migrate_test/fstab +lxc.rootfs.path =3D /var/lib/lxc/migrate_test/rootfs +lxc.uts.name =3D migrate_test +lxc.autodev=3D1 +lxc.tty.max =3D 2 +lxc.pts =3D 1024 +lxc.cap.drop =3D sys_module mac_admin mac_override mknod + +# When using LXC with apparmor, uncomment the next line to run unconfined: +#lxc.aa_profile =3D unconfined + +lxc.cgroup.devices.deny =3D a +# /dev/null and zero +lxc.cgroup.devices.allow =3D c 1:3 rwm +lxc.cgroup.devices.allow =3D c 1:5 rwm +# consoles +lxc.cgroup.devices.allow =3D c 5:1 rwm +lxc.cgroup.devices.allow =3D c 5:0 rwm +lxc.cgroup.devices.allow =3D c 4:0 rwm +lxc.cgroup.devices.allow =3D c 4:1 rwm +# /dev/{,u}random +lxc.cgroup.devices.allow =3D c 1:9 rwm +lxc.cgroup.devices.allow =3D c 1:8 rwm +lxc.cgroup.devices.allow =3D c 136:* rwm +lxc.cgroup.devices.allow =3D c 5:2 rwm +# rtc +lxc.cgroup.devices.allow =3D c 254:0 rwm diff --git a/tests/lxcconf2xmldata/lxcconf2xml-idmap-v3.config b/tests/lxcc= onf2xmldata/lxcconf2xml-idmap-v3.config new file mode 100644 index 0000000000..2caae864cc --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-idmap-v3.config @@ -0,0 +1,5 @@ +lxc.rootfs.path =3D /var/lib/lxc/migrate_test/rootfs +lxc.uts.name =3D migrate_test + +lxc.idmap =3D u 10000 0 2000 +lxc.idmap =3D g 10000 0 1000 diff --git a/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork-v3.config b/t= ests/lxcconf2xmldata/lxcconf2xml-macvlannetwork-v3.config new file mode 100644 index 0000000000..631f07ecca --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork-v3.config @@ -0,0 +1,13 @@ +# Template used to create this container: opensuse +# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075= ef + +lxc.network.type =3D macvlan +lxc.network.flags =3D up +lxc.network.link =3D eth0 +lxc.network.hwaddr =3D 02:00:15:8f:05:c1 +lxc.network.macvlan.mode =3D vepa + +#remove next line if host DNS configuration should not be available to con= tainer +lxc.rootfs.path =3D /var/lib/lxc/migrate_test/rootfs +lxc.uts.name =3D migrate_test +lxc.autodev=3D1 diff --git a/tests/lxcconf2xmldata/lxcconf2xml-memtune-v3.config b/tests/lx= cconf2xmldata/lxcconf2xml-memtune-v3.config new file mode 100644 index 0000000000..5bd928eb1a --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-memtune-v3.config @@ -0,0 +1,10 @@ +lxc.rootfs.path =3D /var/lib/lxc/migrate_test/rootfs +lxc.uts.name =3D migrate_test +lxc.autodev=3D1 + +# 1GiB +lxc.cgroup.memory.limit_in_bytes =3D 1073741824 +# 128MiB +lxc.cgroup.memory.soft_limit_in_bytes =3D 134217728 +# 2GiB +lxc.cgroup.memory.memsw.limit_in_bytes =3D 2147483648 diff --git a/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork-v3.config b/test= s/lxcconf2xmldata/lxcconf2xml-nonenetwork-v3.config new file mode 100644 index 0000000000..f81a786f1e --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork-v3.config @@ -0,0 +1,4 @@ +lxc.rootfs.path =3D /var/lib/lxc/migrate_test/rootfs +lxc.uts.name =3D migrate_test +lxc.autodev=3D1 +lxc.network.type =3D none diff --git a/tests/lxcconf2xmldata/lxcconf2xml-nonetwork-v3.config b/tests/= lxcconf2xmldata/lxcconf2xml-nonetwork-v3.config new file mode 100644 index 0000000000..b33d5780b6 --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-nonetwork-v3.config @@ -0,0 +1,3 @@ +lxc.rootfs.path =3D /var/lib/lxc/migrate_test/rootfs +lxc.uts.name =3D migrate_test +lxc.autodev=3D1 diff --git a/tests/lxcconf2xmldata/lxcconf2xml-physnetwork-v3.config b/test= s/lxcconf2xmldata/lxcconf2xml-physnetwork-v3.config new file mode 100644 index 0000000000..92729841d7 --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-physnetwork-v3.config @@ -0,0 +1,11 @@ +lxc.network.type =3D phys +lxc.network.link =3D eth0 +lxc.network.name =3D eth1 +lxc.network.ipv4 =3D 192.168.122.2/24 +lxc.network.ipv4.gateway =3D 192.168.122.1 +lxc.network.ipv6 =3D 2003:db8:1:0:214:1234:fe0b:3596/64 +lxc.network.ipv6.gateway =3D 2003:db8:1:0:214:1234:fe0b:3595 + +lxc.rootfs.path =3D /var/lib/lxc/migrate_test/rootfs +lxc.uts.name =3D migrate_test +lxc.autodev=3D1 diff --git a/tests/lxcconf2xmldata/lxcconf2xml-simple-v3.config b/tests/lxc= conf2xmldata/lxcconf2xml-simple-v3.config new file mode 100644 index 0000000000..a0036a482e --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-simple-v3.config @@ -0,0 +1,45 @@ +# Template used to create this container: opensuse +# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075= ef + +lxc.network.type =3D veth +lxc.network.flags =3D up +lxc.network.link =3D virbr0 +lxc.network.hwaddr =3D 02:00:15:8f:05:c1 +lxc.network.name =3D eth0 +lxc.network.ipv4 =3D 192.168.122.2/24 +lxc.network.ipv4.gateway =3D 192.168.122.1 +lxc.network.ipv6 =3D 2003:db8:1:0:214:1234:fe0b:3596/64 +lxc.network.ipv6.gateway =3D 2003:db8:1:0:214:1234:fe0b:3595 + +#remove next line if host DNS configuration should not be available to con= tainer +lxc.mount.entry =3D proc proc proc nodev,noexec,nosuid 0 0 +lxc.mount.entry =3D sysfs sys sysfs defaults 0 0 +lxc.mount.entry =3D tmpfs run tmpfs size=3D8m,mode=3D0755,nodev,nosuid 0 0 +lxc.mount.entry =3D /etc/resolv.conf etc/resolv.conf none bind,ro 0 0 +lxc.rootfs.path =3D /var/lib/lxc/migrate_test/rootfs +lxc.uts.name =3D migrate_test +lxc.arch =3D x86 +lxc.autodev=3D1 +lxc.tty.max =3D 2 +lxc.pts =3D 1024 +lxc.cap.drop =3D sys_module mac_admin mac_override mknod + +# When using LXC with apparmor, uncomment the next line to run unconfined: +#lxc.aa_profile =3D unconfined + +lxc.cgroup.devices.deny =3D a +# /dev/null and zero +lxc.cgroup.devices.allow =3D c 1:3 rwm +lxc.cgroup.devices.allow =3D c 1:5 rwm +# consoles +lxc.cgroup.devices.allow =3D c 5:1 rwm +lxc.cgroup.devices.allow =3D c 5:0 rwm +lxc.cgroup.devices.allow =3D c 4:0 rwm +lxc.cgroup.devices.allow =3D c 4:1 rwm +# /dev/{,u}random +lxc.cgroup.devices.allow =3D c 1:9 rwm +lxc.cgroup.devices.allow =3D c 1:8 rwm +lxc.cgroup.devices.allow =3D c 136:* rwm +lxc.cgroup.devices.allow =3D c 5:2 rwm +# rtc +lxc.cgroup.devices.allow =3D c 254:0 rwm diff --git a/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork-v3.config b/test= s/lxcconf2xmldata/lxcconf2xml-vlannetwork-v3.config new file mode 100644 index 0000000000..31e26997dd --- /dev/null +++ b/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork-v3.config @@ -0,0 +1,12 @@ +# Template used to create this container: opensuse +# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075= ef + +lxc.network.type =3D vlan +lxc.network.flags =3D up +lxc.network.link =3D eth0 +lxc.network.hwaddr =3D 02:00:15:8f:05:c1 +lxc.network.vlan.id =3D 2 + +lxc.rootfs.path =3D /var/lib/lxc/migrate_test/rootfs +lxc.uts.name =3D migrate_test +lxc.autodev=3D1 diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c index 360d840e2e..0766239ec4 100644 --- a/tests/lxcconf2xmltest.c +++ b/tests/lxcconf2xmltest.c @@ -64,7 +64,7 @@ struct testInfo { }; =20 static int -testCompareXMLToConfigHelper(const void *data) +testCompareXMLToConfigHelperLegacy(const void *data) { int result =3D -1; const struct testInfo *info =3D data; @@ -85,6 +85,29 @@ testCompareXMLToConfigHelper(const void *data) return result; } =20 +static int +testCompareXMLToConfigHelperV3(const void *data) +{ + int result =3D -1; + const struct testInfo *info =3D data; + char *xml =3D NULL; + char *config =3D NULL; + + if (virAsprintf(&xml, "%s/lxcconf2xmldata/lxcconf2xml-%s.xml", + abs_srcdir, info->name) < 0 || + virAsprintf(&config, "%s/lxcconf2xmldata/lxcconf2xml-%s-v3.config", + abs_srcdir, info->name) < 0) + goto cleanup; + + result =3D testCompareXMLToConfigFiles(xml, config, info->expectError); + + cleanup: + VIR_FREE(xml); + VIR_FREE(config); + return result; +} + + static int mymain(void) { @@ -102,7 +125,7 @@ mymain(void) do { \ const struct testInfo info =3D { name, expectError }; \ if (virTestRun("LXC Native-2-XML " name, \ - testCompareXMLToConfigHelper, \ + testCompareXMLToConfigHelperLegacy, \ &info) < 0) \ ret =3D EXIT_FAILURE; \ } while (0) @@ -121,6 +144,30 @@ mymain(void) DO_TEST("blkiotune", false); DO_TEST("ethernet", false); =20 + /* Tests for LXC 3.0 and higher */ +# define DO_TEST3(name, expectError) \ + do { \ + const struct testInfo info =3D { name, expectError }; \ + if (virTestRun("LXC Native-3-XML " name, \ + testCompareXMLToConfigHelperV3, \ + &info) < 0) \ + ret =3D EXIT_FAILURE; \ + } while (0) + + DO_TEST3("simple", false); + DO_TEST3("fstab", true); + DO_TEST3("nonetwork", false); + DO_TEST3("nonenetwork", false); + DO_TEST3("physnetwork", false); + DO_TEST3("macvlannetwork", false); + DO_TEST3("vlannetwork", false); + DO_TEST3("idmap", false); + DO_TEST3("memtune", false); + DO_TEST3("cputune", false); + DO_TEST3("cpusettune", false); + DO_TEST3("blkiotune", false); + DO_TEST3("ethernet", false); + virObjectUnref(xmlopt); virObjectUnref(caps); =20 --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list