2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 21:38:16 +00:00

img: Introduce O_FORCE_LOCAL flag for images

criu/image-desc.c    | 4 ++--
 criu/image.c         | 4 ++--
 criu/include/image.h | 1 +
 3 files changed, 5 insertions(+), 4 deletions(-)

In order to prepare for remote snapshots (possible with Image Proxy and Image
Cache) the O_FORCE_LOCAL flag is added to force some images not to be remote
and stay as local files in the file system.

Signed-off-by: Rodrigo Bruno <rbruno@gsd.inesc-id.pt>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Rodrigo Bruno 2017-02-11 04:34:39 +01:00 committed by Andrei Vagin
parent d9220e958b
commit c45eb121e5
3 changed files with 5 additions and 4 deletions

View File

@ -104,13 +104,13 @@ struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX] = {
[CR_FD_STATS] = { [CR_FD_STATS] = {
.fmt = "stats-%s", .fmt = "stats-%s",
.magic = STATS_MAGIC, .magic = STATS_MAGIC,
.oflags = O_SERVICE, .oflags = O_SERVICE | O_FORCE_LOCAL,
}, },
[CR_FD_IRMAP_CACHE] = { [CR_FD_IRMAP_CACHE] = {
.fmt = "irmap-cache", .fmt = "irmap-cache",
.magic = IRMAP_CACHE_MAGIC, .magic = IRMAP_CACHE_MAGIC,
.oflags = O_SERVICE, .oflags = O_SERVICE | O_FORCE_LOCAL,
}, },
[CR_FD_FILE_LOCKS_PID] = { [CR_FD_FILE_LOCKS_PID] = {

View File

@ -317,11 +317,11 @@ static int do_open_image(struct cr_img *img, int dfd, int type, unsigned long of
{ {
int ret, flags; int ret, flags;
flags = oflags & ~(O_NOBUF | O_SERVICE); flags = oflags & ~(O_NOBUF | O_SERVICE | O_FORCE_LOCAL);
ret = openat(dfd, path, flags, CR_FD_PERM); ret = openat(dfd, path, flags, CR_FD_PERM);
if (ret < 0) { if (ret < 0) {
if (!(flags & O_CREAT) && (errno == ENOENT)) { if (!(flags & O_CREAT) && (errno == ENOENT || ret == -ENOENT)) {
pr_info("No %s image\n", path); pr_info("No %s image\n", path);
img->_x.fd = EMPTY_IMG_FD; img->_x.fd = EMPTY_IMG_FD;
goto skip_magic; goto skip_magic;

View File

@ -108,6 +108,7 @@ extern bool img_common_magic;
#define O_DUMP (O_WRONLY | O_CREAT | O_TRUNC) #define O_DUMP (O_WRONLY | O_CREAT | O_TRUNC)
#define O_SHOW (O_RDONLY | O_NOBUF) #define O_SHOW (O_RDONLY | O_NOBUF)
#define O_RSTR (O_RDONLY) #define O_RSTR (O_RDONLY)
#define O_FORCE_LOCAL (O_SYNC)
struct cr_img { struct cr_img {
union { union {