diff options
author | Pavel Emelyanov <xemul@parallels.com> | 2015-05-29 14:45:00 +0300 |
---|---|---|
committer | Pavel Emelyanov <xemul@parallels.com> | 2015-05-30 00:31:52 +0300 |
commit | c9c41ddfa90dffffbba8b043b6f4ce7971b87fc3 (patch) | |
tree | ca0c1466c39390d1c18cb7c9d78d829cbce22282 | |
parent | 5e55b71b93e452373fb9945ead5154a35c8d184c (diff) |
img: Remove empty lazy images after dump
If dump doesn't generate data into some image file the respective file
is not created at all as it used to be in 1.5. This brings potential
problem -- if the file with the image name exists during dump (e.g. a
dump file left from previous, maybe unsuccessful, dump) then restore
would pick this file and read bad/wrong/fake data from it.
To return the proper behavior back the file with the name of empty image
should be removed.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
-rw-r--r-- | image.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -369,9 +369,15 @@ int open_image_lazy(struct cr_img *img) void close_image(struct cr_img *img) { - if (lazy_image(img)) + if (lazy_image(img)) { + /* + * Remove the image file if it's there so that + * subsequent restore doesn't read wrong or fake + * data from it. + */ + unlinkat(get_service_fd(IMG_FD_OFF), img->path, 0); xfree(img->path); - else if (!empty_image(img)) + } else if (!empty_image(img)) bclose(&img->_x); xfree(img); |