[CRIU] [PATCH v5 2/5] mount: Create binfmt_misc image w/o device suffix
Kirill Tkhai
ktkhai at virtuozzo.com
Mon Aug 15 01:39:31 PDT 2016
On 05.08.2016 18:34, Pavel Emelyanov wrote:
> On 08/04/2016 04:49 PM, Kirill Tkhai wrote:
>> Use name binfmt_misc-0.img for any mounted binfmt_misc.
>> Note, that newly created binfmt_misc images won't restore
>> on old criu.
>>
>> Also, because of above, let's change a behaviour of dump and now
>> we do not create binfmt_misc images if there is no registered
>> binfmt_misc entries.
>>
>> v5: New
>> Suggested-by: Pavel Emelyanov <xemul at virtuozzo.com>
>> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
>> ---
>> criu/mount.c | 40 ++++++++++++++++++++++++++++++++--------
>> 1 file changed, 32 insertions(+), 8 deletions(-)
>>
>> diff --git a/criu/mount.c b/criu/mount.c
>> index f90ec69..c5533de 100644
>> --- a/criu/mount.c
>> +++ b/criu/mount.c
>> @@ -1361,7 +1361,7 @@ static int dump_binfmt_misc_entry(int dfd, char *name, struct cr_img *img)
>>
>> static int binfmt_misc_dump(struct mount_info *pm)
>> {
>> - struct cr_img *img;
>> + struct cr_img *img = NULL;
>> struct dirent *de;
>> DIR *fdir = NULL;
>> int fd, ret;
>> @@ -1381,10 +1381,6 @@ static int binfmt_misc_dump(struct mount_info *pm)
>> }
>>
>> ret = -1;
>> - img = open_image(CR_FD_BINFMT_MISC, O_DUMP, pm->s_dev);
>> - if (!img)
>> - goto out;
>> -
>> while ((de = readdir(fdir))) {
>> if (dir_dots(de))
>> continue;
>> @@ -1393,6 +1389,13 @@ static int binfmt_misc_dump(struct mount_info *pm)
>> if (!strcmp(de->d_name, "status"))
>> continue;
>>
>> + if (!img) {
>> + /* Create image only if an extry exists, i.e. here */
>> + img = open_image(CR_FD_BINFMT_MISC, O_DUMP, 0);
>
> Let's change the name format and remove 0 from it.
It requires to add a new image type. Is it ok?
>> + if (!img)
>> + goto out;
>> + }
>> +
>> if (dump_binfmt_misc_entry(fd, de->d_name, img))
>> goto out;
>> }
>> @@ -1487,20 +1490,41 @@ static int make_bfmtm_magic_str(char *buf, BinfmtMiscEntry *bme)
>>
>> static int binfmt_misc_restore(struct mount_info *mi)
>> {
>> + unsigned int suffix;
>> struct cr_img *img;
>> + struct stat st;
>> char *buf;
>> - int ret = -1;
>> + int ret;
>>
>> buf = xmalloc(BINFMT_MISC_STR);
>> if (!buf)
>> return -1;
>>
>> - img = open_image(CR_FD_BINFMT_MISC, O_RSTR, mi->s_dev);
>> + suffix = 0;
>> + ret = stat_image(CR_FD_BINFMT_MISC, &st, suffix);
>
> There's no need to stat the image. Just do it like we did before -- try
> to open image by legacy name and, if it's empty_image(), try to open
> by new name.
Why so? open_image() does not make difference between "no image" and "wrong permittions",
for example. We may lose existing binfmt_misc if some problem exists, doesn't it?
>> + if (ret < 0) {
>> + if (ret == -ENOENT) {
>> + suffix = mi->s_dev;
>> + ret = stat_image(CR_FD_BINFMT_MISC, &st, suffix);
>> + if (ret == -ENOENT) {
>> + ret = 0;
>> + pr_info("No binfmt image found\n");
>> + goto free_buf;
>> + }
>> + }
>> + else if (ret) {
>> + pr_err("Can't stat binfmt_misc image: %s\n", strerror(ret));
>> + goto free_buf;
>> + }
>> + }
>> +
>> + img = open_image(CR_FD_BINFMT_MISC, O_RSTR, suffix);
>> if (!img) {
>> + pr_err("Can't open binfmt_misc image\n");
>> + ret = -1;
>> goto free_buf;
>> }
>>
>> - ret = 0;
>> while (ret == 0) {
>> BinfmtMiscEntry *bme;
>>
>>
>> _______________________________________________
>> CRIU mailing list
>> CRIU at openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu
>> .
>>
>
More information about the CRIU
mailing list