All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed
@ 2016-07-14  8:45 Lee, Chun-Yi
  2016-07-14  9:51 ` Baoquan He
  2016-07-14 14:53 ` Vivek Goyal
  0 siblings, 2 replies; 14+ messages in thread
From: Lee, Chun-Yi @ 2016-07-14  8:45 UTC (permalink / raw)
  To: kexec; +Cc: Lee, Chun-Yi, Simon Horman, Vivek Goyal, Petr Tesarik

This patch adds a new "--fallback-kexec" option to give a chance to
fallback to old kexec syscall when file based kexec syscall operation
failed.

This option works with --kexec-file-syscall to provide more flexible
way to adapt to different kernels that those kernels built with
different kexec syscall config or have different verification policy.

Cc: Simon Horman <horms@verge.net.au>
Cc: Petr Tesarik <ptesarik@suse.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Lee, Chun-Yi <jlee@suse.com>
---
 kexec/kexec.c | 13 +++++++++++++
 kexec/kexec.h |  4 +++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/kexec/kexec.c b/kexec/kexec.c
index 500e5a9..e05b43f 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -969,6 +969,7 @@ void usage(void)
 	       "                      preserve context)\n"
 	       "                      to original kernel.\n"
 	       " -s, --kexec-file-syscall Use file based syscall for kexec operation\n"
+	       "     --fallback-kexec     Fallback to old kexec when file based syscall failed\n"
 	       " -d, --debug           Enable debugging to help spot a failure.\n"
 	       "\n"
 	       "Supported kernel file types and options: \n");
@@ -1204,6 +1205,7 @@ int main(int argc, char *argv[])
 	int do_unload = 0;
 	int do_reuse_initrd = 0;
 	int do_kexec_file_syscall = 0;
+	int do_fallback_kexec_syscall = 0;
 	void *entry = 0;
 	char *type = 0;
 	char *endptr;
@@ -1226,9 +1228,13 @@ int main(int argc, char *argv[])
 		case OPT_KEXEC_FILE_SYSCALL:
 			do_kexec_file_syscall = 1;
 			break;
+		case OPT_FALLBACK_KEXEC:
+			do_fallback_kexec_syscall = 1;
+			break;
 		}
 	}
 
+fallback:
 	/* Reset getopt for the next pass. */
 	opterr = 1;
 	optind = 1;
@@ -1407,6 +1413,13 @@ int main(int argc, char *argv[])
 			result = my_load(type, fileind, argc, argv,
 						kexec_flags, entry);
 	}
+	/* fallback to old kexec syscall */
+	if (do_kexec_file_syscall && result != 0 && do_fallback_kexec_syscall) {
+		fprintf(stderr, "Fallback to kexec syscall\n");
+		do_kexec_file_syscall = 0;
+		do_fallback_kexec_syscall = 0;
+		goto fallback;
+	}
 	/* Don't shutdown unless there is something to reboot to! */
 	if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded()) {
 		die("Nothing has been loaded!\n");
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 9194f1c..65dbd56 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -225,7 +225,8 @@ extern int file_types;
 #define OPT_LOAD_PRESERVE_CONTEXT 259
 #define OPT_LOAD_JUMP_BACK_HELPER 260
 #define OPT_ENTRY		261
-#define OPT_MAX			262
+#define OPT_FALLBACK_KEXEC	262
+#define OPT_MAX			263
 #define KEXEC_OPTIONS \
 	{ "help",		0, 0, OPT_HELP }, \
 	{ "version",		0, 0, OPT_VERSION }, \
@@ -244,6 +245,7 @@ extern int file_types;
 	{ "mem-max",		1, 0, OPT_MEM_MAX }, \
 	{ "reuseinitrd",	0, 0, OPT_REUSE_INITRD }, \
 	{ "kexec-file-syscall",	0, 0, OPT_KEXEC_FILE_SYSCALL }, \
+	{ "fallback-kexec",     0, 0, OPT_FALLBACK_KEXEC }, \
 	{ "debug",		0, 0, OPT_DEBUG }, \
 
 #define KEXEC_OPT_STR "h?vdfxyluet:ps"
-- 
2.6.6


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed
  2016-07-14  8:45 [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed Lee, Chun-Yi
@ 2016-07-14  9:51 ` Baoquan He
  2016-07-14 10:02   ` Baoquan He
  2016-07-14 10:35   ` joeyli
  2016-07-14 14:53 ` Vivek Goyal
  1 sibling, 2 replies; 14+ messages in thread
From: Baoquan He @ 2016-07-14  9:51 UTC (permalink / raw)
  To: Lee, Chun-Yi; +Cc: Lee, Chun-Yi, Simon Horman, kexec, Vivek Goyal, Petr Tesarik

On 07/14/16 at 04:45pm, Lee, Chun-Yi wrote:
> This patch adds a new "--fallback-kexec" option to give a chance to
> fallback to old kexec syscall when file based kexec syscall operation
> failed.
> 
> This option works with --kexec-file-syscall to provide more flexible
> way to adapt to different kernels that those kernels built with
> different kexec syscall config or have different verification policy.

Usually distribuition system uses script to build a framework to
connect the kexec/kdump, makedumpfile utility chain. This can make user
execute a very simple script command to implement kexec load or kexec
jumping job. In this case script can do what you are trying to do.

Besides, have you actually met that kexec-file failed but old kexec
syscall works? I mean how did you test it? I am wondering when it will
happen.

Thanks
Baoquan

> 
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Petr Tesarik <ptesarik@suse.com>
> Cc: Vivek Goyal <vgoyal@redhat.com>
> Signed-off-by: Lee, Chun-Yi <jlee@suse.com>
> ---
>  kexec/kexec.c | 13 +++++++++++++
>  kexec/kexec.h |  4 +++-
>  2 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/kexec/kexec.c b/kexec/kexec.c
> index 500e5a9..e05b43f 100644
> --- a/kexec/kexec.c
> +++ b/kexec/kexec.c
> @@ -969,6 +969,7 @@ void usage(void)
>  	       "                      preserve context)\n"
>  	       "                      to original kernel.\n"
>  	       " -s, --kexec-file-syscall Use file based syscall for kexec operation\n"
> +	       "     --fallback-kexec     Fallback to old kexec when file based syscall failed\n"
>  	       " -d, --debug           Enable debugging to help spot a failure.\n"
>  	       "\n"
>  	       "Supported kernel file types and options: \n");
> @@ -1204,6 +1205,7 @@ int main(int argc, char *argv[])
>  	int do_unload = 0;
>  	int do_reuse_initrd = 0;
>  	int do_kexec_file_syscall = 0;
> +	int do_fallback_kexec_syscall = 0;
>  	void *entry = 0;
>  	char *type = 0;
>  	char *endptr;
> @@ -1226,9 +1228,13 @@ int main(int argc, char *argv[])
>  		case OPT_KEXEC_FILE_SYSCALL:
>  			do_kexec_file_syscall = 1;
>  			break;
> +		case OPT_FALLBACK_KEXEC:
> +			do_fallback_kexec_syscall = 1;
> +			break;
>  		}
>  	}
>  
> +fallback:
>  	/* Reset getopt for the next pass. */
>  	opterr = 1;
>  	optind = 1;
> @@ -1407,6 +1413,13 @@ int main(int argc, char *argv[])
>  			result = my_load(type, fileind, argc, argv,
>  						kexec_flags, entry);
>  	}
> +	/* fallback to old kexec syscall */
> +	if (do_kexec_file_syscall && result != 0 && do_fallback_kexec_syscall) {
> +		fprintf(stderr, "Fallback to kexec syscall\n");
> +		do_kexec_file_syscall = 0;
> +		do_fallback_kexec_syscall = 0;
> +		goto fallback;
> +	}
>  	/* Don't shutdown unless there is something to reboot to! */
>  	if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded()) {
>  		die("Nothing has been loaded!\n");
> diff --git a/kexec/kexec.h b/kexec/kexec.h
> index 9194f1c..65dbd56 100644
> --- a/kexec/kexec.h
> +++ b/kexec/kexec.h
> @@ -225,7 +225,8 @@ extern int file_types;
>  #define OPT_LOAD_PRESERVE_CONTEXT 259
>  #define OPT_LOAD_JUMP_BACK_HELPER 260
>  #define OPT_ENTRY		261
> -#define OPT_MAX			262
> +#define OPT_FALLBACK_KEXEC	262
> +#define OPT_MAX			263
>  #define KEXEC_OPTIONS \
>  	{ "help",		0, 0, OPT_HELP }, \
>  	{ "version",		0, 0, OPT_VERSION }, \
> @@ -244,6 +245,7 @@ extern int file_types;
>  	{ "mem-max",		1, 0, OPT_MEM_MAX }, \
>  	{ "reuseinitrd",	0, 0, OPT_REUSE_INITRD }, \
>  	{ "kexec-file-syscall",	0, 0, OPT_KEXEC_FILE_SYSCALL }, \
> +	{ "fallback-kexec",     0, 0, OPT_FALLBACK_KEXEC }, \
>  	{ "debug",		0, 0, OPT_DEBUG }, \
>  
>  #define KEXEC_OPT_STR "h?vdfxyluet:ps"
> -- 
> 2.6.6
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed
  2016-07-14  9:51 ` Baoquan He
@ 2016-07-14 10:02   ` Baoquan He
  2016-07-14 10:35   ` joeyli
  1 sibling, 0 replies; 14+ messages in thread
From: Baoquan He @ 2016-07-14 10:02 UTC (permalink / raw)
  To: Lee, Chun-Yi; +Cc: Lee, Chun-Yi, Simon Horman, kexec, Vivek Goyal, Petr Tesarik

On 07/14/16 at 05:51pm, Baoquan He wrote:
> On 07/14/16 at 04:45pm, Lee, Chun-Yi wrote:
> > This patch adds a new "--fallback-kexec" option to give a chance to
> > fallback to old kexec syscall when file based kexec syscall operation
> > failed.
> > 
> > This option works with --kexec-file-syscall to provide more flexible
> > way to adapt to different kernels that those kernels built with
> > different kexec syscall config or have different verification policy.
> 
> Usually distribuition system uses script to build a framework to
	   ~ I mean distro here.
> connect the kexec/kdump, makedumpfile utility chain. This can make user
> execute a very simple script command to implement kexec load or kexec
> jumping job. In this case script can do what you are trying to do.
> 
> Besides, have you actually met that kexec-file failed but old kexec
> syscall works? I mean how did you test it? I am wondering when it will
> happen.
> 
> Thanks
> Baoquan
> 
> > 
> > Cc: Simon Horman <horms@verge.net.au>
> > Cc: Petr Tesarik <ptesarik@suse.com>
> > Cc: Vivek Goyal <vgoyal@redhat.com>
> > Signed-off-by: Lee, Chun-Yi <jlee@suse.com>
> > ---
> >  kexec/kexec.c | 13 +++++++++++++
> >  kexec/kexec.h |  4 +++-
> >  2 files changed, 16 insertions(+), 1 deletion(-)
> > 
> > diff --git a/kexec/kexec.c b/kexec/kexec.c
> > index 500e5a9..e05b43f 100644
> > --- a/kexec/kexec.c
> > +++ b/kexec/kexec.c
> > @@ -969,6 +969,7 @@ void usage(void)
> >  	       "                      preserve context)\n"
> >  	       "                      to original kernel.\n"
> >  	       " -s, --kexec-file-syscall Use file based syscall for kexec operation\n"
> > +	       "     --fallback-kexec     Fallback to old kexec when file based syscall failed\n"
> >  	       " -d, --debug           Enable debugging to help spot a failure.\n"
> >  	       "\n"
> >  	       "Supported kernel file types and options: \n");
> > @@ -1204,6 +1205,7 @@ int main(int argc, char *argv[])
> >  	int do_unload = 0;
> >  	int do_reuse_initrd = 0;
> >  	int do_kexec_file_syscall = 0;
> > +	int do_fallback_kexec_syscall = 0;
> >  	void *entry = 0;
> >  	char *type = 0;
> >  	char *endptr;
> > @@ -1226,9 +1228,13 @@ int main(int argc, char *argv[])
> >  		case OPT_KEXEC_FILE_SYSCALL:
> >  			do_kexec_file_syscall = 1;
> >  			break;
> > +		case OPT_FALLBACK_KEXEC:
> > +			do_fallback_kexec_syscall = 1;
> > +			break;
> >  		}
> >  	}
> >  
> > +fallback:
> >  	/* Reset getopt for the next pass. */
> >  	opterr = 1;
> >  	optind = 1;
> > @@ -1407,6 +1413,13 @@ int main(int argc, char *argv[])
> >  			result = my_load(type, fileind, argc, argv,
> >  						kexec_flags, entry);
> >  	}
> > +	/* fallback to old kexec syscall */
> > +	if (do_kexec_file_syscall && result != 0 && do_fallback_kexec_syscall) {
> > +		fprintf(stderr, "Fallback to kexec syscall\n");
> > +		do_kexec_file_syscall = 0;
> > +		do_fallback_kexec_syscall = 0;
> > +		goto fallback;
> > +	}
> >  	/* Don't shutdown unless there is something to reboot to! */
> >  	if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded()) {
> >  		die("Nothing has been loaded!\n");
> > diff --git a/kexec/kexec.h b/kexec/kexec.h
> > index 9194f1c..65dbd56 100644
> > --- a/kexec/kexec.h
> > +++ b/kexec/kexec.h
> > @@ -225,7 +225,8 @@ extern int file_types;
> >  #define OPT_LOAD_PRESERVE_CONTEXT 259
> >  #define OPT_LOAD_JUMP_BACK_HELPER 260
> >  #define OPT_ENTRY		261
> > -#define OPT_MAX			262
> > +#define OPT_FALLBACK_KEXEC	262
> > +#define OPT_MAX			263
> >  #define KEXEC_OPTIONS \
> >  	{ "help",		0, 0, OPT_HELP }, \
> >  	{ "version",		0, 0, OPT_VERSION }, \
> > @@ -244,6 +245,7 @@ extern int file_types;
> >  	{ "mem-max",		1, 0, OPT_MEM_MAX }, \
> >  	{ "reuseinitrd",	0, 0, OPT_REUSE_INITRD }, \
> >  	{ "kexec-file-syscall",	0, 0, OPT_KEXEC_FILE_SYSCALL }, \
> > +	{ "fallback-kexec",     0, 0, OPT_FALLBACK_KEXEC }, \
> >  	{ "debug",		0, 0, OPT_DEBUG }, \
> >  
> >  #define KEXEC_OPT_STR "h?vdfxyluet:ps"
> > -- 
> > 2.6.6
> > 
> > 
> > _______________________________________________
> > kexec mailing list
> > kexec@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/kexec
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed
  2016-07-14  9:51 ` Baoquan He
  2016-07-14 10:02   ` Baoquan He
@ 2016-07-14 10:35   ` joeyli
  2016-07-14 14:12     ` Baoquan He
  1 sibling, 1 reply; 14+ messages in thread
From: joeyli @ 2016-07-14 10:35 UTC (permalink / raw)
  To: Baoquan He; +Cc: Lee, Chun-Yi, kexec, Vivek Goyal, Simon Horman, Petr Tesarik

Hi Baoquan, 

Thanks for your response!

On Thu, Jul 14, 2016 at 05:51:24PM +0800, Baoquan He wrote:
> On 07/14/16 at 04:45pm, Lee, Chun-Yi wrote:
> > This patch adds a new "--fallback-kexec" option to give a chance to
> > fallback to old kexec syscall when file based kexec syscall operation
> > failed.
> > 
> > This option works with --kexec-file-syscall to provide more flexible
> > way to adapt to different kernels that those kernels built with
> > different kexec syscall config or have different verification policy.
> 
> Usually distribuition system uses script to build a framework to
> connect the kexec/kdump, makedumpfile utility chain. This can make user
> execute a very simple script command to implement kexec load or kexec
> jumping job. In this case script can do what you are trying to do.
> 

Yes, the fallback function can be implemented by script. But a new kexec
option is useful to the distro that it may not provides help scripts to
user.

> Besides, have you actually met that kexec-file failed but old kexec
> syscall works? I mean how did you test it? I am wondering when it will
> happen.
> 
> Thanks
> Baoquan
>

The currently mainline kernel allows to set CONFIG_KEXEC or CONFIG_KEXEC_FILE
individual. So if kexec found that the file based kexec syscall isn't
available then this is a case to fallback to old kexec.

Another case is when KEXEC_VERIFY_SIG is set, The fallback function is more
convenient to user to build his own kernel for using or testing. The kexec
tool can try old syscall when verification failed.


Thanks a lot!
Joey Lee
 
> > 
> > Cc: Simon Horman <horms@verge.net.au>
> > Cc: Petr Tesarik <ptesarik@suse.com>
> > Cc: Vivek Goyal <vgoyal@redhat.com>
> > Signed-off-by: Lee, Chun-Yi <jlee@suse.com>
> > ---
> >  kexec/kexec.c | 13 +++++++++++++
> >  kexec/kexec.h |  4 +++-
> >  2 files changed, 16 insertions(+), 1 deletion(-)
> > 
> > diff --git a/kexec/kexec.c b/kexec/kexec.c
> > index 500e5a9..e05b43f 100644
> > --- a/kexec/kexec.c
> > +++ b/kexec/kexec.c
> > @@ -969,6 +969,7 @@ void usage(void)
> >  	       "                      preserve context)\n"
> >  	       "                      to original kernel.\n"
> >  	       " -s, --kexec-file-syscall Use file based syscall for kexec operation\n"
> > +	       "     --fallback-kexec     Fallback to old kexec when file based syscall failed\n"
> >  	       " -d, --debug           Enable debugging to help spot a failure.\n"
> >  	       "\n"
> >  	       "Supported kernel file types and options: \n");
> > @@ -1204,6 +1205,7 @@ int main(int argc, char *argv[])
> >  	int do_unload = 0;
> >  	int do_reuse_initrd = 0;
> >  	int do_kexec_file_syscall = 0;
> > +	int do_fallback_kexec_syscall = 0;
> >  	void *entry = 0;
> >  	char *type = 0;
> >  	char *endptr;
> > @@ -1226,9 +1228,13 @@ int main(int argc, char *argv[])
> >  		case OPT_KEXEC_FILE_SYSCALL:
> >  			do_kexec_file_syscall = 1;
> >  			break;
> > +		case OPT_FALLBACK_KEXEC:
> > +			do_fallback_kexec_syscall = 1;
> > +			break;
> >  		}
> >  	}
> >  
> > +fallback:
> >  	/* Reset getopt for the next pass. */
> >  	opterr = 1;
> >  	optind = 1;
> > @@ -1407,6 +1413,13 @@ int main(int argc, char *argv[])
> >  			result = my_load(type, fileind, argc, argv,
> >  						kexec_flags, entry);
> >  	}
> > +	/* fallback to old kexec syscall */
> > +	if (do_kexec_file_syscall && result != 0 && do_fallback_kexec_syscall) {
> > +		fprintf(stderr, "Fallback to kexec syscall\n");
> > +		do_kexec_file_syscall = 0;
> > +		do_fallback_kexec_syscall = 0;
> > +		goto fallback;
> > +	}
> >  	/* Don't shutdown unless there is something to reboot to! */
> >  	if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded()) {
> >  		die("Nothing has been loaded!\n");
> > diff --git a/kexec/kexec.h b/kexec/kexec.h
> > index 9194f1c..65dbd56 100644
> > --- a/kexec/kexec.h
> > +++ b/kexec/kexec.h
> > @@ -225,7 +225,8 @@ extern int file_types;
> >  #define OPT_LOAD_PRESERVE_CONTEXT 259
> >  #define OPT_LOAD_JUMP_BACK_HELPER 260
> >  #define OPT_ENTRY		261
> > -#define OPT_MAX			262
> > +#define OPT_FALLBACK_KEXEC	262
> > +#define OPT_MAX			263
> >  #define KEXEC_OPTIONS \
> >  	{ "help",		0, 0, OPT_HELP }, \
> >  	{ "version",		0, 0, OPT_VERSION }, \
> > @@ -244,6 +245,7 @@ extern int file_types;
> >  	{ "mem-max",		1, 0, OPT_MEM_MAX }, \
> >  	{ "reuseinitrd",	0, 0, OPT_REUSE_INITRD }, \
> >  	{ "kexec-file-syscall",	0, 0, OPT_KEXEC_FILE_SYSCALL }, \
> > +	{ "fallback-kexec",     0, 0, OPT_FALLBACK_KEXEC }, \
> >  	{ "debug",		0, 0, OPT_DEBUG }, \
> >  
> >  #define KEXEC_OPT_STR "h?vdfxyluet:ps"
> > -- 
> > 2.6.6
> > 
> > 
> > _______________________________________________
> > kexec mailing list
> > kexec@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed
  2016-07-14 10:35   ` joeyli
@ 2016-07-14 14:12     ` Baoquan He
  0 siblings, 0 replies; 14+ messages in thread
From: Baoquan He @ 2016-07-14 14:12 UTC (permalink / raw)
  To: joeyli; +Cc: Simon Horman, Lee, Chun-Yi, kexec, Vivek Goyal, Petr Tesarik

On 07/14/16 at 06:35pm, joeyli wrote:
> Hi Baoquan, 
> 
> Thanks for your response!
> 
> On Thu, Jul 14, 2016 at 05:51:24PM +0800, Baoquan He wrote:
> > On 07/14/16 at 04:45pm, Lee, Chun-Yi wrote:
> > > This patch adds a new "--fallback-kexec" option to give a chance to
> > > fallback to old kexec syscall when file based kexec syscall operation
> > > failed.
> > > 
> > > This option works with --kexec-file-syscall to provide more flexible
> > > way to adapt to different kernels that those kernels built with
> > > different kexec syscall config or have different verification policy.
> > 
> > Usually distribuition system uses script to build a framework to
> > connect the kexec/kdump, makedumpfile utility chain. This can make user
> > execute a very simple script command to implement kexec load or kexec
> > jumping job. In this case script can do what you are trying to do.
> > 
> 
> Yes, the fallback function can be implemented by script. But a new kexec
> option is useful to the distro that it may not provides help scripts to
> user.
> 
> > Besides, have you actually met that kexec-file failed but old kexec
> > syscall works? I mean how did you test it? I am wondering when it will
> > happen.
> > 
> > Thanks
> > Baoquan
> >
> 

I understand, thanks for telling, Joey Lee.

However it seems not very necessary to me. So leave this to other
people, see if you can get support and an Acked-by.

Thanks
Baoquan

> The currently mainline kernel allows to set CONFIG_KEXEC or CONFIG_KEXEC_FILE
> individual. So if kexec found that the file based kexec syscall isn't
> available then this is a case to fallback to old kexec.
> 
> Another case is when KEXEC_VERIFY_SIG is set, The fallback function is more
> convenient to user to build his own kernel for using or testing. The kexec
> tool can try old syscall when verification failed.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed
  2016-07-14  8:45 [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed Lee, Chun-Yi
  2016-07-14  9:51 ` Baoquan He
@ 2016-07-14 14:53 ` Vivek Goyal
  2016-07-14 23:57   ` joeyli
  1 sibling, 1 reply; 14+ messages in thread
From: Vivek Goyal @ 2016-07-14 14:53 UTC (permalink / raw)
  To: Lee, Chun-Yi; +Cc: Lee, Chun-Yi, Simon Horman, kexec, Petr Tesarik

On Thu, Jul 14, 2016 at 04:45:11PM +0800, Lee, Chun-Yi wrote:
> This patch adds a new "--fallback-kexec" option to give a chance to
> fallback to old kexec syscall when file based kexec syscall operation
> failed.

I think caller should switch to using different interface if need be. But
I don't see much point in providing an option for this in kexec-tools.

Vivek

> 
> This option works with --kexec-file-syscall to provide more flexible
> way to adapt to different kernels that those kernels built with
> different kexec syscall config or have different verification policy.
> 
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Petr Tesarik <ptesarik@suse.com>
> Cc: Vivek Goyal <vgoyal@redhat.com>
> Signed-off-by: Lee, Chun-Yi <jlee@suse.com>
> ---
>  kexec/kexec.c | 13 +++++++++++++
>  kexec/kexec.h |  4 +++-
>  2 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/kexec/kexec.c b/kexec/kexec.c
> index 500e5a9..e05b43f 100644
> --- a/kexec/kexec.c
> +++ b/kexec/kexec.c
> @@ -969,6 +969,7 @@ void usage(void)
>  	       "                      preserve context)\n"
>  	       "                      to original kernel.\n"
>  	       " -s, --kexec-file-syscall Use file based syscall for kexec operation\n"
> +	       "     --fallback-kexec     Fallback to old kexec when file based syscall failed\n"
>  	       " -d, --debug           Enable debugging to help spot a failure.\n"
>  	       "\n"
>  	       "Supported kernel file types and options: \n");
> @@ -1204,6 +1205,7 @@ int main(int argc, char *argv[])
>  	int do_unload = 0;
>  	int do_reuse_initrd = 0;
>  	int do_kexec_file_syscall = 0;
> +	int do_fallback_kexec_syscall = 0;
>  	void *entry = 0;
>  	char *type = 0;
>  	char *endptr;
> @@ -1226,9 +1228,13 @@ int main(int argc, char *argv[])
>  		case OPT_KEXEC_FILE_SYSCALL:
>  			do_kexec_file_syscall = 1;
>  			break;
> +		case OPT_FALLBACK_KEXEC:
> +			do_fallback_kexec_syscall = 1;
> +			break;
>  		}
>  	}
>  
> +fallback:
>  	/* Reset getopt for the next pass. */
>  	opterr = 1;
>  	optind = 1;
> @@ -1407,6 +1413,13 @@ int main(int argc, char *argv[])
>  			result = my_load(type, fileind, argc, argv,
>  						kexec_flags, entry);
>  	}
> +	/* fallback to old kexec syscall */
> +	if (do_kexec_file_syscall && result != 0 && do_fallback_kexec_syscall) {
> +		fprintf(stderr, "Fallback to kexec syscall\n");
> +		do_kexec_file_syscall = 0;
> +		do_fallback_kexec_syscall = 0;
> +		goto fallback;
> +	}
>  	/* Don't shutdown unless there is something to reboot to! */
>  	if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded()) {
>  		die("Nothing has been loaded!\n");
> diff --git a/kexec/kexec.h b/kexec/kexec.h
> index 9194f1c..65dbd56 100644
> --- a/kexec/kexec.h
> +++ b/kexec/kexec.h
> @@ -225,7 +225,8 @@ extern int file_types;
>  #define OPT_LOAD_PRESERVE_CONTEXT 259
>  #define OPT_LOAD_JUMP_BACK_HELPER 260
>  #define OPT_ENTRY		261
> -#define OPT_MAX			262
> +#define OPT_FALLBACK_KEXEC	262
> +#define OPT_MAX			263
>  #define KEXEC_OPTIONS \
>  	{ "help",		0, 0, OPT_HELP }, \
>  	{ "version",		0, 0, OPT_VERSION }, \
> @@ -244,6 +245,7 @@ extern int file_types;
>  	{ "mem-max",		1, 0, OPT_MEM_MAX }, \
>  	{ "reuseinitrd",	0, 0, OPT_REUSE_INITRD }, \
>  	{ "kexec-file-syscall",	0, 0, OPT_KEXEC_FILE_SYSCALL }, \
> +	{ "fallback-kexec",     0, 0, OPT_FALLBACK_KEXEC }, \
>  	{ "debug",		0, 0, OPT_DEBUG }, \
>  
>  #define KEXEC_OPT_STR "h?vdfxyluet:ps"
> -- 
> 2.6.6

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed
  2016-07-14 14:53 ` Vivek Goyal
@ 2016-07-14 23:57   ` joeyli
  2016-07-15  7:58     ` Petr Tesarik
  0 siblings, 1 reply; 14+ messages in thread
From: joeyli @ 2016-07-14 23:57 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: Lee, Chun-Yi, kexec, Simon Horman, Petr Tesarik

Hi Vivek

On Thu, Jul 14, 2016 at 10:53:28AM -0400, Vivek Goyal wrote:
> On Thu, Jul 14, 2016 at 04:45:11PM +0800, Lee, Chun-Yi wrote:
> > This patch adds a new "--fallback-kexec" option to give a chance to
> > fallback to old kexec syscall when file based kexec syscall operation
> > failed.
> 
> I think caller should switch to using different interface if need be. But
> I don't see much point in providing an option for this in kexec-tools.
> 
> Vivek
>

OK~ Understood!

Thanks for Baoquan's and your opinion for this patch.

Joey Lee
 
> > 
> > This option works with --kexec-file-syscall to provide more flexible
> > way to adapt to different kernels that those kernels built with
> > different kexec syscall config or have different verification policy.
> > 
> > Cc: Simon Horman <horms@verge.net.au>
> > Cc: Petr Tesarik <ptesarik@suse.com>
> > Cc: Vivek Goyal <vgoyal@redhat.com>
> > Signed-off-by: Lee, Chun-Yi <jlee@suse.com>
> > ---
> >  kexec/kexec.c | 13 +++++++++++++
> >  kexec/kexec.h |  4 +++-
> >  2 files changed, 16 insertions(+), 1 deletion(-)
> > 
> > diff --git a/kexec/kexec.c b/kexec/kexec.c
> > index 500e5a9..e05b43f 100644
> > --- a/kexec/kexec.c
> > +++ b/kexec/kexec.c
> > @@ -969,6 +969,7 @@ void usage(void)
> >  	       "                      preserve context)\n"
> >  	       "                      to original kernel.\n"
> >  	       " -s, --kexec-file-syscall Use file based syscall for kexec operation\n"
> > +	       "     --fallback-kexec     Fallback to old kexec when file based syscall failed\n"
> >  	       " -d, --debug           Enable debugging to help spot a failure.\n"
> >  	       "\n"
> >  	       "Supported kernel file types and options: \n");
> > @@ -1204,6 +1205,7 @@ int main(int argc, char *argv[])
> >  	int do_unload = 0;
> >  	int do_reuse_initrd = 0;
> >  	int do_kexec_file_syscall = 0;
> > +	int do_fallback_kexec_syscall = 0;
> >  	void *entry = 0;
> >  	char *type = 0;
> >  	char *endptr;
> > @@ -1226,9 +1228,13 @@ int main(int argc, char *argv[])
> >  		case OPT_KEXEC_FILE_SYSCALL:
> >  			do_kexec_file_syscall = 1;
> >  			break;
> > +		case OPT_FALLBACK_KEXEC:
> > +			do_fallback_kexec_syscall = 1;
> > +			break;
> >  		}
> >  	}
> >  
> > +fallback:
> >  	/* Reset getopt for the next pass. */
> >  	opterr = 1;
> >  	optind = 1;
> > @@ -1407,6 +1413,13 @@ int main(int argc, char *argv[])
> >  			result = my_load(type, fileind, argc, argv,
> >  						kexec_flags, entry);
> >  	}
> > +	/* fallback to old kexec syscall */
> > +	if (do_kexec_file_syscall && result != 0 && do_fallback_kexec_syscall) {
> > +		fprintf(stderr, "Fallback to kexec syscall\n");
> > +		do_kexec_file_syscall = 0;
> > +		do_fallback_kexec_syscall = 0;
> > +		goto fallback;
> > +	}
> >  	/* Don't shutdown unless there is something to reboot to! */
> >  	if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded()) {
> >  		die("Nothing has been loaded!\n");
> > diff --git a/kexec/kexec.h b/kexec/kexec.h
> > index 9194f1c..65dbd56 100644
> > --- a/kexec/kexec.h
> > +++ b/kexec/kexec.h
> > @@ -225,7 +225,8 @@ extern int file_types;
> >  #define OPT_LOAD_PRESERVE_CONTEXT 259
> >  #define OPT_LOAD_JUMP_BACK_HELPER 260
> >  #define OPT_ENTRY		261
> > -#define OPT_MAX			262
> > +#define OPT_FALLBACK_KEXEC	262
> > +#define OPT_MAX			263
> >  #define KEXEC_OPTIONS \
> >  	{ "help",		0, 0, OPT_HELP }, \
> >  	{ "version",		0, 0, OPT_VERSION }, \
> > @@ -244,6 +245,7 @@ extern int file_types;
> >  	{ "mem-max",		1, 0, OPT_MEM_MAX }, \
> >  	{ "reuseinitrd",	0, 0, OPT_REUSE_INITRD }, \
> >  	{ "kexec-file-syscall",	0, 0, OPT_KEXEC_FILE_SYSCALL }, \
> > +	{ "fallback-kexec",     0, 0, OPT_FALLBACK_KEXEC }, \
> >  	{ "debug",		0, 0, OPT_DEBUG }, \
> >  
> >  #define KEXEC_OPT_STR "h?vdfxyluet:ps"
> > -- 
> > 2.6.6

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed
  2016-07-14 23:57   ` joeyli
@ 2016-07-15  7:58     ` Petr Tesarik
  2016-07-15 10:28       ` joeyli
  2016-07-15 12:51       ` Vivek Goyal
  0 siblings, 2 replies; 14+ messages in thread
From: Petr Tesarik @ 2016-07-15  7:58 UTC (permalink / raw)
  To: joeyli; +Cc: Simon Horman, Lee, Chun-Yi, kexec, Vivek Goyal

On Fri, 15 Jul 2016 07:57:22 +0800
joeyli <jlee@suse.com> wrote:

> Hi Vivek
> 
> On Thu, Jul 14, 2016 at 10:53:28AM -0400, Vivek Goyal wrote:
> > On Thu, Jul 14, 2016 at 04:45:11PM +0800, Lee, Chun-Yi wrote:
> > > This patch adds a new "--fallback-kexec" option to give a chance to
> > > fallback to old kexec syscall when file based kexec syscall operation
> > > failed.
> > 
> > I think caller should switch to using different interface if need be. But
> > I don't see much point in providing an option for this in kexec-tools.
> > 
> > Vivek
> >
> 
> OK~ Understood!
> 
> Thanks for Baoquan's and your opinion for this patch.

Is there some sort of diagnostics, so a calling script can determine
whether kexec failed, because there's no suppor for kexec_file_load(2)
or for a different reason? 

Thanks,
Petr T

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed
  2016-07-15  7:58     ` Petr Tesarik
@ 2016-07-15 10:28       ` joeyli
  2016-07-15 11:20         ` Petr Tesarik
  2016-07-15 12:51       ` Vivek Goyal
  1 sibling, 1 reply; 14+ messages in thread
From: joeyli @ 2016-07-15 10:28 UTC (permalink / raw)
  To: Petr Tesarik; +Cc: Simon Horman, Lee, Chun-Yi, kexec, Vivek Goyal

On Fri, Jul 15, 2016 at 09:58:22AM +0200, Petr Tesarik wrote:
> On Fri, 15 Jul 2016 07:57:22 +0800
> joeyli <jlee@suse.com> wrote:
> 
> > Hi Vivek
> > 
> > On Thu, Jul 14, 2016 at 10:53:28AM -0400, Vivek Goyal wrote:
> > > On Thu, Jul 14, 2016 at 04:45:11PM +0800, Lee, Chun-Yi wrote:
> > > > This patch adds a new "--fallback-kexec" option to give a chance to
> > > > fallback to old kexec syscall when file based kexec syscall operation
> > > > failed.
> > > 
> > > I think caller should switch to using different interface if need be. But
> > > I don't see much point in providing an option for this in kexec-tools.
> > > 
> > > Vivek
> > >
> > 
> > OK~ Understood!
> > 
> > Thanks for Baoquan's and your opinion for this patch.
> 
> Is there some sort of diagnostics, so a calling script can determine
> whether kexec failed, because there's no suppor for kexec_file_load(2)
> or for a different reason? 
> 
> Thanks,
> Petr T

The calling script needs to use "-s" option to access file based kexec, then
check the result and call kexec without -s to access old kexec syscall.

With this patch is just more convenience.


Thanks a lot!
Joey Lee

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed
  2016-07-15 10:28       ` joeyli
@ 2016-07-15 11:20         ` Petr Tesarik
  0 siblings, 0 replies; 14+ messages in thread
From: Petr Tesarik @ 2016-07-15 11:20 UTC (permalink / raw)
  To: joeyli; +Cc: Simon Horman, Lee, Chun-Yi, kexec, Vivek Goyal

On Fri, 15 Jul 2016 18:28:05 +0800
joeyli <jlee@suse.com> wrote:

> On Fri, Jul 15, 2016 at 09:58:22AM +0200, Petr Tesarik wrote:
> > On Fri, 15 Jul 2016 07:57:22 +0800
> > joeyli <jlee@suse.com> wrote:
> > 
> > > Hi Vivek
> > > 
> > > On Thu, Jul 14, 2016 at 10:53:28AM -0400, Vivek Goyal wrote:
> > > > On Thu, Jul 14, 2016 at 04:45:11PM +0800, Lee, Chun-Yi wrote:
> > > > > This patch adds a new "--fallback-kexec" option to give a chance to
> > > > > fallback to old kexec syscall when file based kexec syscall operation
> > > > > failed.
> > > > 
> > > > I think caller should switch to using different interface if need be. But
> > > > I don't see much point in providing an option for this in kexec-tools.
> > > > 
> > > > Vivek
> > > >
> > > 
> > > OK~ Understood!
> > > 
> > > Thanks for Baoquan's and your opinion for this patch.
> > 
> > Is there some sort of diagnostics, so a calling script can determine
> > whether kexec failed, because there's no suppor for kexec_file_load(2)
> > or for a different reason? 
> > 
> > Thanks,
> > Petr T
> 
> The calling script needs to use "-s" option to access file based kexec, then
> check the result

This is the part I was asking about. How do I "check the result"? In
other words, what is "the result" if kexec fails because of missing
kernel syscall, and what is "the result" if it fails for any other
reason (e.g. insufficient privileges)?

Or do you suggest that the script always retrius without "-s" after
"kexec -s" fails, just in case loading might work the old way?

Petr T

> and call kexec without -s to access old kexec syscall.
> 
> With this patch is just more convenience.
> 
> 
> Thanks a lot!
> Joey Lee


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed
  2016-07-15  7:58     ` Petr Tesarik
  2016-07-15 10:28       ` joeyli
@ 2016-07-15 12:51       ` Vivek Goyal
  2016-07-15 14:42         ` Petr Tesarik
  1 sibling, 1 reply; 14+ messages in thread
From: Vivek Goyal @ 2016-07-15 12:51 UTC (permalink / raw)
  To: Petr Tesarik; +Cc: joeyli, Lee, Chun-Yi, kexec, Simon Horman

On Fri, Jul 15, 2016 at 09:58:22AM +0200, Petr Tesarik wrote:
> On Fri, 15 Jul 2016 07:57:22 +0800
> joeyli <jlee@suse.com> wrote:
> 
> > Hi Vivek
> > 
> > On Thu, Jul 14, 2016 at 10:53:28AM -0400, Vivek Goyal wrote:
> > > On Thu, Jul 14, 2016 at 04:45:11PM +0800, Lee, Chun-Yi wrote:
> > > > This patch adds a new "--fallback-kexec" option to give a chance to
> > > > fallback to old kexec syscall when file based kexec syscall operation
> > > > failed.
> > > 
> > > I think caller should switch to using different interface if need be. But
> > > I don't see much point in providing an option for this in kexec-tools.
> > > 
> > > Vivek
> > >
> > 
> > OK~ Understood!
> > 
> > Thanks for Baoquan's and your opinion for this patch.
> 
> Is there some sort of diagnostics, so a calling script can determine
> whether kexec failed, because there's no suppor for kexec_file_load(2)
> or for a different reason? 

Will we not get -ENOSYS if kexec_file_load() is not implemented?

Vivek

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed
  2016-07-15 12:51       ` Vivek Goyal
@ 2016-07-15 14:42         ` Petr Tesarik
  2016-07-15 15:13           ` Vivek Goyal
  0 siblings, 1 reply; 14+ messages in thread
From: Petr Tesarik @ 2016-07-15 14:42 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: joeyli, Lee, Chun-Yi, kexec, Simon Horman

On Fri, 15 Jul 2016 08:51:14 -0400
Vivek Goyal <vgoyal@redhat.com> wrote:

> On Fri, Jul 15, 2016 at 09:58:22AM +0200, Petr Tesarik wrote:
> > On Fri, 15 Jul 2016 07:57:22 +0800
> > joeyli <jlee@suse.com> wrote:
> > 
> > > Hi Vivek
> > > 
> > > On Thu, Jul 14, 2016 at 10:53:28AM -0400, Vivek Goyal wrote:
> > > > On Thu, Jul 14, 2016 at 04:45:11PM +0800, Lee, Chun-Yi wrote:
> > > > > This patch adds a new "--fallback-kexec" option to give a chance to
> > > > > fallback to old kexec syscall when file based kexec syscall operation
> > > > > failed.
> > > > 
> > > > I think caller should switch to using different interface if need be. But
> > > > I don't see much point in providing an option for this in kexec-tools.
> > > > 
> > > > Vivek
> > > >
> > > 
> > > OK~ Understood!
> > > 
> > > Thanks for Baoquan's and your opinion for this patch.
> > 
> > Is there some sort of diagnostics, so a calling script can determine
> > whether kexec failed, because there's no suppor for kexec_file_load(2)
> > or for a different reason? 
> 
> Will we not get -ENOSYS if kexec_file_load() is not implemented?

Sure, the kexec code will see a beautiful ENOSYS in errno, but it
merely prints this message on stderr (possibly with a different error
string if not linked against glibc):

kexec_file_load failed: Function not implemented

...and exits with status 255 (same for any other error). Which is, um,
not very friendly to automated error handling...

Petr T

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed
  2016-07-15 14:42         ` Petr Tesarik
@ 2016-07-15 15:13           ` Vivek Goyal
  2016-07-15 15:26             ` Petr Tesarik
  0 siblings, 1 reply; 14+ messages in thread
From: Vivek Goyal @ 2016-07-15 15:13 UTC (permalink / raw)
  To: Petr Tesarik; +Cc: joeyli, Lee, Chun-Yi, kexec, Simon Horman

On Fri, Jul 15, 2016 at 04:42:40PM +0200, Petr Tesarik wrote:
> On Fri, 15 Jul 2016 08:51:14 -0400
> Vivek Goyal <vgoyal@redhat.com> wrote:
> 
> > On Fri, Jul 15, 2016 at 09:58:22AM +0200, Petr Tesarik wrote:
> > > On Fri, 15 Jul 2016 07:57:22 +0800
> > > joeyli <jlee@suse.com> wrote:
> > > 
> > > > Hi Vivek
> > > > 
> > > > On Thu, Jul 14, 2016 at 10:53:28AM -0400, Vivek Goyal wrote:
> > > > > On Thu, Jul 14, 2016 at 04:45:11PM +0800, Lee, Chun-Yi wrote:
> > > > > > This patch adds a new "--fallback-kexec" option to give a chance to
> > > > > > fallback to old kexec syscall when file based kexec syscall operation
> > > > > > failed.
> > > > > 
> > > > > I think caller should switch to using different interface if need be. But
> > > > > I don't see much point in providing an option for this in kexec-tools.
> > > > > 
> > > > > Vivek
> > > > >
> > > > 
> > > > OK~ Understood!
> > > > 
> > > > Thanks for Baoquan's and your opinion for this patch.
> > > 
> > > Is there some sort of diagnostics, so a calling script can determine
> > > whether kexec failed, because there's no suppor for kexec_file_load(2)
> > > or for a different reason? 
> > 
> > Will we not get -ENOSYS if kexec_file_load() is not implemented?
> 
> Sure, the kexec code will see a beautiful ENOSYS in errno, but it
> merely prints this message on stderr (possibly with a different error
> string if not linked against glibc):
> 
> kexec_file_load failed: Function not implemented
> 
> ...and exits with status 255 (same for any other error). Which is, um,
> not very friendly to automated error handling...

So what are the options? One should return different error codes as
returned by glibc? But bash or other script will not have a library
to translate it. I guess scripts will have to hard code the meaning
of a particular return code.

BTW, user can always try kexec_file_load() and if it fails, try older
version of syscall and that should work for lot of use cases?

Vivek

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed
  2016-07-15 15:13           ` Vivek Goyal
@ 2016-07-15 15:26             ` Petr Tesarik
  0 siblings, 0 replies; 14+ messages in thread
From: Petr Tesarik @ 2016-07-15 15:26 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: joeyli, Lee, Chun-Yi, kexec, Simon Horman

On Fri, 15 Jul 2016 11:13:46 -0400
Vivek Goyal <vgoyal@redhat.com> wrote:

> On Fri, Jul 15, 2016 at 04:42:40PM +0200, Petr Tesarik wrote:
> > On Fri, 15 Jul 2016 08:51:14 -0400
> > Vivek Goyal <vgoyal@redhat.com> wrote:
> > 
> > > On Fri, Jul 15, 2016 at 09:58:22AM +0200, Petr Tesarik wrote:
> > > > On Fri, 15 Jul 2016 07:57:22 +0800
> > > > joeyli <jlee@suse.com> wrote:
> > > > 
> > > > > Hi Vivek
> > > > > 
> > > > > On Thu, Jul 14, 2016 at 10:53:28AM -0400, Vivek Goyal wrote:
> > > > > > On Thu, Jul 14, 2016 at 04:45:11PM +0800, Lee, Chun-Yi wrote:
> > > > > > > This patch adds a new "--fallback-kexec" option to give a chance to
> > > > > > > fallback to old kexec syscall when file based kexec syscall operation
> > > > > > > failed.
> > > > > > 
> > > > > > I think caller should switch to using different interface if need be. But
> > > > > > I don't see much point in providing an option for this in kexec-tools.
> > > > > > 
> > > > > > Vivek
> > > > > >
> > > > > 
> > > > > OK~ Understood!
> > > > > 
> > > > > Thanks for Baoquan's and your opinion for this patch.
> > > > 
> > > > Is there some sort of diagnostics, so a calling script can determine
> > > > whether kexec failed, because there's no suppor for kexec_file_load(2)
> > > > or for a different reason? 
> > > 
> > > Will we not get -ENOSYS if kexec_file_load() is not implemented?
> > 
> > Sure, the kexec code will see a beautiful ENOSYS in errno, but it
> > merely prints this message on stderr (possibly with a different error
> > string if not linked against glibc):
> > 
> > kexec_file_load failed: Function not implemented
> > 
> > ...and exits with status 255 (same for any other error). Which is, um,
> > not very friendly to automated error handling...
> 
> So what are the options? One should return different error codes as
> returned by glibc? But bash or other script will not have a library
> to translate it. I guess scripts will have to hard code the meaning
> of a particular return code.
> 
> BTW, user can always try kexec_file_load() and if it fails, try older
> version of syscall and that should work for lot of use cases?

Yes, I can blindly retry. Thanks for considering other options.

Petr T

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-07-15 15:26 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-14  8:45 [PATCH] kexec: Add option to fallback to old kexec syscall when kexec file based syscall failed Lee, Chun-Yi
2016-07-14  9:51 ` Baoquan He
2016-07-14 10:02   ` Baoquan He
2016-07-14 10:35   ` joeyli
2016-07-14 14:12     ` Baoquan He
2016-07-14 14:53 ` Vivek Goyal
2016-07-14 23:57   ` joeyli
2016-07-15  7:58     ` Petr Tesarik
2016-07-15 10:28       ` joeyli
2016-07-15 11:20         ` Petr Tesarik
2016-07-15 12:51       ` Vivek Goyal
2016-07-15 14:42         ` Petr Tesarik
2016-07-15 15:13           ` Vivek Goyal
2016-07-15 15:26             ` Petr Tesarik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.