[CRIU] [PATCH] crtools: chdir to work dir before log_init
Pavel Emelyanov
xemul at parallels.com
Tue Nov 19 09:32:42 PST 2013
On 11/19/2013 05:47 PM, Ruslan Kuprieiev wrote:
> On 19.11.2013 12:11, Pavel Emelyanov wrote:
>> On 11/19/2013 03:51 PM, Ruslan Kuprieiev wrote:
>>> After set of patches which add --work-dir option we have an issue: logs are created relatively
>>> to current dir and not relatively to images dir(which is work dir, when --work-dir is not given).
>>> To solve this lets chdir to work dir, before log_init.
>>>
>>> Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
>>> ---
>>> crtools.c | 10 +++++-----
>>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/crtools.c b/crtools.c
>>> index b680236..0565c74 100644
>>> --- a/crtools.c
>>> +++ b/crtools.c
>>> @@ -285,6 +285,11 @@ int main(int argc, char *argv[])
>>> if (work_dir == NULL)
>>> work_dir = imgs_dir;
>>>
>>> + if (chdir(work_dir)) {
>>> + pr_perror("Can't change directory to %s", work_dir);
>>> + return -1;
>>> + }
>> After this line the call to open_image_dir() cannot succeed.
>
> Oh, now I have remembered why I was trying to use log_init_at =)))
> Anyway log_init_at is redundant too. We just need to init log after
> chdirng to workdir. Sorry for the mess.
Would you send me one final patch please. I'm dropping both.
>>
>>> +
>>> log_set_loglevel(log_level);
>>>
>>> if (log_init(opts.output))
>>> @@ -305,11 +310,6 @@ int main(int argc, char *argv[])
>>> }
>>> }
>>>
>>> - if (chdir(work_dir)) {
>>> - pr_perror("Can't change directory to %s", work_dir);
>>> - return -1;
>>> - }
>>> -
>>> if (!strcmp(argv[optind], "dump")) {
>>> if (!tree_id)
>>> goto opt_pid_missing;
>>>
>>
>
> .
>
More information about the CRIU
mailing list