Commit 73b9a2eb authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

cpuinfo: Add "cpuinfo [dump|check]" commands, v2

On Wed, Oct 01, 2014 at 05:51:09PM +0400, Pavel Emelyanov wrote:
> > Yes, what you've been expecting?
>
> if (!strcmp(argv[optind]))
> 	return cpu_cap_check()
>
> or smth like this.

updated. So if it become confusing -- feel free to merge [1;9] and
ping me to resend the rest, or pick up from attachements.

>From 6af96ff63ac82f9566c3cba9c116dc67698c9797 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov@openvz.org>
Date: Tue, 30 Sep 2014 18:33:40 +0400
Subject: [PATCH] cpuinfo: Add "cpuinfo [dump|check]" commands

They allow to validate cpuinfo information
without running complete dump/restore actions.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 87273ccd
......@@ -50,6 +50,13 @@ Starts pagemap data deduplication procedure, where *criu* scans over all
pagemap files and tries to minimalize the number of pagemap entries by
obtaining the references from a parent pagemap image.
*cpuinfo* *dump*::
Writes information about currently running CPU and its features into an image.
*cpuinfo* *check*::
Reads information about CPU from an image file and checks if it is compatible
with currently running CPU.
OPTIONS
-------
*-c*::
......
#undef LOG_PREFIX
#define LOG_PREFIX "cpu: "
#include <errno.h>
#include "cpu.h"
bool cpu_has_feature(unsigned int feature)
......@@ -22,3 +23,13 @@ int cpu_validate_cpuinfo(void)
{
return 0;
}
int cpu_dump_cpuinfo_single(void)
{
return -ENOTSUP;
}
int cpu_validate_image_cpuinfo_single(void)
{
return -ENOTSUP;
}
#undef LOG_PREFIX
#define LOG_PREFIX "cpu: "
#include <errno.h>
#include "cpu.h"
bool cpu_has_feature(unsigned int feature)
......@@ -22,3 +23,13 @@ int cpu_validate_cpuinfo(void)
{
return 0;
}
int cpu_dump_cpuinfo_single(void)
{
return -ENOTSUP;
}
int cpu_validate_image_cpuinfo_single(void)
{
return -ENOTSUP;
}
......@@ -355,3 +355,28 @@ err:
close_image(img);
return ret;
}
int cpuinfo_dump(void)
{
if (cpu_init())
return -1;
if (cpu_dump_cpuinfo())
return -1;
return 0;
}
int cpuinfo_check(void)
{
if (cpu_init())
return -1;
/*
* Force to check all caps because its been
* called as a special command from options.
*/
opts.cpu_cap = CPU_CAP_ALL;
if (cpu_validate_cpuinfo())
return -1;
return 0;
}
......@@ -201,5 +201,7 @@ extern bool cpu_has_feature(unsigned int feature);
extern int cpu_init(void);
extern int cpu_dump_cpuinfo(void);
extern int cpu_validate_cpuinfo(void);
extern int cpuinfo_dump(void);
extern int cpuinfo_check(void);
#endif /* __CR_CPU_H__ */
......@@ -36,6 +36,7 @@
#include "plugin.h"
#include "mount.h"
#include "cgroup.h"
#include "cpu.h"
#include "action-scripts.h"
#include "setproctitle.h"
......@@ -522,6 +523,15 @@ int main(int argc, char *argv[], char *envp[])
if (!strcmp(argv[optind], "dedup"))
return cr_dedup() != 0;
if (!strcmp(argv[optind], "cpuinfo")) {
if (!argv[optind + 1])
goto usage;
if (!strcmp(argv[optind + 1], "dump"))
return cpuinfo_dump();
else if (!strcmp(argv[optind + 1], "check"))
return cpuinfo_check();
}
pr_msg("Error: unknown command: %s\n", argv[optind]);
usage:
pr_msg("\n"
......@@ -545,6 +555,8 @@ usage:
" page-server launch page server\n"
" service launch service\n"
" dedup remove duplicates in memory dump\n"
" cpuinfo dump writes cpu information into image file\n"
" cpuinfo check validates cpu information read from image file\n"
);
if (usage_error) {
......
......@@ -7,5 +7,7 @@ extern bool cpu_has_feature(unsigned int feature);
extern int cpu_init(void);
extern int cpu_dump_cpuinfo(void);
extern int cpu_validate_cpuinfo(void);
extern int cpuinfo_dump(void);
extern int cpuinfo_check(void);
#endif /* __CR_CPU_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment