]>
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.
22 #include "lxc/lxccontainer.h"
25 int main(int argc
, char *argv
[])
27 struct lxc_container
*c
;
28 struct migrate_opts m_opts
;
29 int ret
= EXIT_FAILURE
;
31 /* Test the feature check interface,
32 * we actually do not need a container. */
33 c
= lxc_container_new("check_feature", NULL
);
35 lxc_error("%s", "Failed to create container \"check_feature\"");
39 if (c
->is_defined(c
)) {
40 lxc_error("%s\n", "Container \"check_feature\" is defined");
44 /* check the migrate API call with wrong 'cmd' */
45 if (!c
->migrate(c
, UINT_MAX
, &m_opts
, sizeof(struct migrate_opts
))) {
46 /* This should failed */
47 lxc_error("%s\n", "Migrate API calls with command UINT_MAX did not fail");
51 /* do the actual feature check for memory tracking */
52 m_opts
.features_to_check
= FEATURE_MEM_TRACK
;
53 if (c
->migrate(c
, MIGRATE_FEATURE_CHECK
, &m_opts
, sizeof(struct migrate_opts
))) {
54 lxc_debug("%s\n", "System does not support \"FEATURE_MEM_TRACK\".");
57 /* check for lazy pages */
58 m_opts
.features_to_check
= FEATURE_LAZY_PAGES
;
59 if (c
->migrate(c
, MIGRATE_FEATURE_CHECK
, &m_opts
, sizeof(struct migrate_opts
))) {
60 lxc_debug("%s\n", "System does not support \"FEATURE_LAZY_PAGES\".");
63 /* check for lazy pages and memory tracking */
64 m_opts
.features_to_check
= FEATURE_LAZY_PAGES
| FEATURE_MEM_TRACK
;
65 if (c
->migrate(c
, MIGRATE_FEATURE_CHECK
, &m_opts
, sizeof(struct migrate_opts
))) {
66 if (m_opts
.features_to_check
== FEATURE_LAZY_PAGES
)
67 lxc_debug("%s\n", "System does not support \"FEATURE_MEM_TRACK\"");
68 else if (m_opts
.features_to_check
== FEATURE_MEM_TRACK
)
69 lxc_debug("%s\n", "System does not support \"FEATURE_LAZY_PAGES\"");
71 lxc_debug("%s\n", "System does not support \"FEATURE_MEM_TRACK\" "
72 "and \"FEATURE_LAZY_PAGES\"");
75 /* test for unknown feature; once there are 64 features to test
76 * this will be valid... */
77 m_opts
.features_to_check
= -1ULL;
78 if (!c
->migrate(c
, MIGRATE_FEATURE_CHECK
, &m_opts
, sizeof(struct migrate_opts
))) {
79 lxc_error("%s\n", "Unsupported feature supported, which is strange.");
87 if (ret
== EXIT_SUCCESS
)
88 lxc_debug("%s\n", "All criu feature check tests passed");