]>
git.proxmox.com Git - mirror_lxc.git/blob - src/tests/criu_check_feature.c
3 * Copyright © 2017 Adrian Reber <areber@redhat.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2, as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "lxc/lxccontainer.h"
27 int main(int argc
, char *argv
[])
29 struct lxc_container
*c
;
30 struct migrate_opts m_opts
;
31 int ret
= EXIT_FAILURE
;
33 /* Test the feature check interface,
34 * we actually do not need a container. */
35 c
= lxc_container_new("check_feature", NULL
);
37 lxc_error("%s", "Failed to create container \"check_feature\"");
41 if (c
->is_defined(c
)) {
42 lxc_error("%s\n", "Container \"check_feature\" is defined");
46 /* check the migrate API call with wrong 'cmd' */
47 if (!c
->migrate(c
, UINT_MAX
, &m_opts
, sizeof(struct migrate_opts
))) {
48 /* This should failed */
49 lxc_error("%s\n", "Migrate API calls with command UINT_MAX did not fail");
53 /* do the actual feature check for memory tracking */
54 m_opts
.features_to_check
= FEATURE_MEM_TRACK
;
55 if (c
->migrate(c
, MIGRATE_FEATURE_CHECK
, &m_opts
, sizeof(struct migrate_opts
))) {
56 lxc_debug("%s\n", "System does not support \"FEATURE_MEM_TRACK\".");
59 /* check for lazy pages */
60 m_opts
.features_to_check
= FEATURE_LAZY_PAGES
;
61 if (c
->migrate(c
, MIGRATE_FEATURE_CHECK
, &m_opts
, sizeof(struct migrate_opts
))) {
62 lxc_debug("%s\n", "System does not support \"FEATURE_LAZY_PAGES\".");
65 /* check for lazy pages and memory tracking */
66 m_opts
.features_to_check
= FEATURE_LAZY_PAGES
| FEATURE_MEM_TRACK
;
67 if (c
->migrate(c
, MIGRATE_FEATURE_CHECK
, &m_opts
, sizeof(struct migrate_opts
))) {
68 if (m_opts
.features_to_check
== FEATURE_LAZY_PAGES
)
69 lxc_debug("%s\n", "System does not support \"FEATURE_MEM_TRACK\"");
70 else if (m_opts
.features_to_check
== FEATURE_MEM_TRACK
)
71 lxc_debug("%s\n", "System does not support \"FEATURE_LAZY_PAGES\"");
73 lxc_debug("%s\n", "System does not support \"FEATURE_MEM_TRACK\" "
74 "and \"FEATURE_LAZY_PAGES\"");
77 /* test for unknown feature; once there are 64 features to test
78 * this will be valid... */
79 m_opts
.features_to_check
= -1ULL;
80 if (!c
->migrate(c
, MIGRATE_FEATURE_CHECK
, &m_opts
, sizeof(struct migrate_opts
))) {
81 lxc_error("%s\n", "Unsupported feature supported, which is strange.");
89 if (ret
== EXIT_SUCCESS
)
90 lxc_debug("%s\n", "All criu feature check tests passed");