Skip to contentSkip to conversation

kexec: implemented XEN KEXEC STATUS to determine if an image is loaded

PATCH Superseded Eric DeVolder 2 participants 11 messages Jan 24, 2017 – Jan 25, 2017

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 kexec: implemented XEN KEXEC STATUS to determine if an image is loaded

Instead of the scripts having to poke at various fields we can provide that functionality via the -S parameter.

kexec_loaded/kexec_crash_loaded exposes Linux kernel kexec/crash state. It does not say anything about Xen kexec/crash state. So, we need a special approach to get the latter. Though for compatibility we provide similar functionality in kexec-tools for the former.

This change enables the --status or -S option to work either with or without Xen.

Returns 0 if the payload is loaded. Can be used in combination with -l or -p to get the state of the proper kexec image.

---
Note: The corresponding Xen changes have been committed to the Xen staging branch. Follow this thread:
https://lists.xenproject.org/archives/html/xen-devel/2017-01/msg01570.html

v0: First version (internal product).
v1: Posted on kexec mailing list. Changed -s to -S
v2: Incorporated feedback from kexec mailing list, posted on kexec mailing list
v3: Incorporated feedback from kexec mailing list

---
 configure.ac      |  8 ++++++-
 kexec/kexec-xen.c | 26 +++++++++++++++++++++++
 kexec/kexec.8     |  6 ++++++
 kexec/kexec.c     | 62 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 kexec/kexec.h     |  5 ++++-
 5 files changed, 98 insertions(+), 9 deletions(-)
configure.ac +7 -1
index 3044185..c6e864b 100644
@@ -165,8 +165,14 @@ fi
 dnl find Xen control stack libraries
 if test "$with_xen" = yes ; then
 	AC_CHECK_HEADER(xenctrl.h,
-		[AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
+		[AC_CHECK_LIB(xenctrl, xc_kexec_load, [ have_xenctrl_h=yes ],
 		AC_MSG_NOTICE([Xen support disabled]))])
+if test "$have_xenctrl_h" = yes ; then
+	AC_CHECK_LIB(xenctrl, xc_kexec_status,
+		AC_DEFINE(HAVE_KEXEC_CMD_STATUS, 1,
+			[The kexec_status call is available]),
+		AC_MSG_NOTICE([The kexec_status call is not available]))
+fi
 fi
 
 dnl ---Sanity checks
kexec/kexec-xen.c +26 -0
index 24a4191..2b448d3 100644
@@ -105,6 +105,27 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return ret;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	xc_interface *xch;
+	uint8_t type;
+	int ret = -1;
+
+#ifdef HAVE_KEXEC_CMD_STATUS
+	xch = xc_interface_open(NULL, NULL, 0);
+	if (!xch)
+		return -1;
+
+	type = (kexec_flags & KEXEC_ON_CRASH) ? KEXEC_TYPE_CRASH : KEXEC_TYPE_DEFAULT;
+
+	ret = xc_kexec_status(xch, type);
+
+	xc_interface_close(xch);
+#endif
+
+	return ret;
+}
+
 void xen_kexec_exec(void)
 {
 	xc_interface *xch;
@@ -130,6 +151,11 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return -1;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	return -1;
+}
+
 void xen_kexec_exec(void)
 {
 }
kexec/kexec.8 +6 -0
index 4d0c1d1..f4b39a6 100644
@@ -107,6 +107,12 @@ command:
 .B \-d\ (\-\-debug)
 Enable debugging messages.
 .TP
+.B \-S\ (\-\-status)
+Return 0 if the type (by default crash) is loaded. Can be used in conjuction
+with -l or -p to toggle the type. Note this option supersedes other options
+and it will
+.BR not\ load\ or\ unload\ the\ kernel.
+.TP
 .B \-e\ (\-\-exec)
 Run the currently loaded kernel. Note that it will reboot into the loaded kernel without calling shutdown(8).
 .TP
kexec/kexec.c +55 -7

140 lines not on this page · raw message

kexec/kexec.h +4 -1
index 9194f1c..2b06f59 100644
@@ -219,6 +219,7 @@ extern int file_types;
 #define OPT_TYPE		't'
 #define OPT_PANIC		'p'
 #define OPT_KEXEC_FILE_SYSCALL	's'
+#define OPT_STATUS		'S'
 #define OPT_MEM_MIN             256
 #define OPT_MEM_MAX             257
 #define OPT_REUSE_INITRD	258
@@ -245,8 +246,9 @@ extern int file_types;
 	{ "reuseinitrd",	0, 0, OPT_REUSE_INITRD }, \
 	{ "kexec-file-syscall",	0, 0, OPT_KEXEC_FILE_SYSCALL }, \
 	{ "debug",		0, 0, OPT_DEBUG }, \
+	{ "status",		0, 0, OPT_STATUS }, \
 
-#define KEXEC_OPT_STR "h?vdfxyluet:ps"
+#define KEXEC_OPT_STR "h?vdfxyluet:psS"
 
 extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);
 extern void die(const char *fmt, ...)
@@ -311,5 +313,6 @@ int xen_present(void);
 int xen_kexec_load(struct kexec_info *info);
 int xen_kexec_unload(uint64_t kexec_flags);
 void xen_kexec_exec(void);
+int xen_kexec_status(uint64_t kexec_flags);
 
 #endif /* KEXEC_H */
Signature · 7 lines
2.7.4


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw
Quoted 46 lines · Eric DeVolder

Instead of the scripts having to poke at various fields we can provide that functionality via the -S parameter.

kexec_loaded/kexec_crash_loaded exposes Linux kernel kexec/crash state. It does not say anything about Xen kexec/crash state. So, we need a special approach to get the latter. Though for compatibility we provide similar functionality in kexec-tools for the former.

This change enables the --status or -S option to work either with or without Xen.

Returns 0 if the payload is loaded. Can be used in combination with -l or -p to get the state of the proper kexec image.

---
Note: The corresponding Xen changes have been committed to the Xen staging branch. Follow this thread:
https://lists.xenproject.org/archives/html/xen-devel/2017-01/msg01570.html

v0: First version (internal product).
v1: Posted on kexec mailing list. Changed -s to -S
v2: Incorporated feedback from kexec mailing list, posted on kexec mailing list
v3: Incorporated feedback from kexec mailing list

---
 configure.ac      |  8 ++++++-
 kexec/kexec-xen.c | 26 +++++++++++++++++++++++
 kexec/kexec.8     |  6 ++++++
 kexec/kexec.c     | 62 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 kexec/kexec.h     |  5 ++++-
 5 files changed, 98 insertions(+), 9 deletions(-)
configure.ac +0 -0
index 3044185..c6e864b 100644
@@ -165,8 +165,14 @@ fi
 dnl find Xen control stack libraries
 if test "$with_xen" = yes ; then

configure.ac fi · line 175

Quoted 10 lines
configure.ac +7 -1
 	AC_CHECK_HEADER(xenctrl.h,
-		[AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
+		[AC_CHECK_LIB(xenctrl, xc_kexec_load, [ have_xenctrl_h=yes ],
 		AC_MSG_NOTICE([Xen support disabled]))])
+if test "$have_xenctrl_h" = yes ; then
+	AC_CHECK_LIB(xenctrl, xc_kexec_status,
+		AC_DEFINE(HAVE_KEXEC_CMD_STATUS, 1,
+			[The kexec_status call is available]),
+		AC_MSG_NOTICE([The kexec_status call is not available]))
+fi

I have a feeling that you have missed my comment. Please add two TABs starting from "+if test "$have_xenctrl_h" = yes ; then" up to "+fi". So, it should look more or less like this:

AC_MSG_NOTICE([Xen support disabled]))])
+ if test "$have_xenctrl_h" = yes ; then
+ AC_CHECK_LIB(xenctrl, xc_kexec_status,
...

If it is not needed or something like that please drop me a line.

Quoted 52 lines
configure.ac +0 -0
 fi
 
 dnl ---Sanity checks
kexec/kexec-xen.c +26 -0
index 24a4191..2b448d3 100644
@@ -105,6 +105,27 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return ret;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	xc_interface *xch;
+	uint8_t type;
+	int ret = -1;
+
+#ifdef HAVE_KEXEC_CMD_STATUS
+	xch = xc_interface_open(NULL, NULL, 0);
+	if (!xch)
+		return -1;
+
+	type = (kexec_flags & KEXEC_ON_CRASH) ? KEXEC_TYPE_CRASH : KEXEC_TYPE_DEFAULT;
+
+	ret = xc_kexec_status(xch, type);
+
+	xc_interface_close(xch);
+#endif
+
+	return ret;
+}
+
 void xen_kexec_exec(void)
 {
 	xc_interface *xch;
@@ -130,6 +151,11 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return -1;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	return -1;
+}
+
 void xen_kexec_exec(void)
 {
 }
kexec/kexec.8 +0 -0
index 4d0c1d1..f4b39a6 100644

kexec/kexec.8 command: · line 114

Quoted 8 lines
kexec/kexec.8 +5 -0
@@ -107,6 +107,12 @@ command:
 .B \-d\ (\-\-debug)
 Enable debugging messages.
 .TP
+.B \-S\ (\-\-status)
+Return 0 if the type (by default crash) is loaded. Can be used in conjuction
+with -l or -p to toggle the type. Note this option supersedes other options
+and it will
+.BR not\ load\ or\ unload\ the\ kernel.

Same as above. I think that you have missed my earlier comments. I suppose that you can join "+and it will" and "+.BR not\ load\ or\
unload\ the\ kernel." into one line.

Quoted 19 lines
kexec/kexec.8 +1 -0
+.TP
 .B \-e\ (\-\-exec)
 Run the currently loaded kernel. Note that it will reboot into the loaded kernel without calling shutdown(8).
 .TP
kexec/kexec.c +3 -0
index 500e5a9..defbbe3 100644
@@ -51,6 +51,9 @@
 #include "kexec-lzma.h"
 #include <arch/options.h>
 
+#define KEXEC_LOADED_PATH "/sys/kernel/kexec_loaded"
+#define KEXEC_CRASH_LOADED_PATH "/sys/kernel/kexec_crash_loaded"
+
 unsigned long long mem_min = 0;
 unsigned long long mem_max = ULONG_MAX;
 static unsigned long kexec_flags = 0;

kexec/kexec.c static unsigned long kexec_flags = 0; · line 65

Quoted 5 lines
kexec/kexec.c +2 -0
@@ -58,6 +61,8 @@ static unsigned long kexec_flags = 0;
 static unsigned long kexec_file_flags = 0;
 int kexec_debug = 0;
 
+static int kexec_loaded(const char *file);
+

Why are you shuffling this...

kexec/kexec.c static int my_exec(void) · line 894

Quoted 9 lines
kexec/kexec.c +0 -2
 void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr)
 {
 	int i;
@@ -890,8 +895,6 @@ static int my_exec(void)
 	return -1;
 }
 
-static int kexec_loaded(void);
-

...and this. Could not you leave this forward declaration here (of course with arg change)? Or is it possible to drop it at all?

Daniel

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#2 lore raw
Quoted 67 lines · Daniel Kiper
Quoted 46 lines · Eric DeVolder

Instead of the scripts having to poke at various fields we can provide that functionality via the -S parameter.

kexec_loaded/kexec_crash_loaded exposes Linux kernel kexec/crash state. It does not say anything about Xen kexec/crash state. So, we need a special approach to get the latter. Though for compatibility we provide similar functionality in kexec-tools for the former.

This change enables the --status or -S option to work either with or without Xen.

Returns 0 if the payload is loaded. Can be used in combination with -l or -p to get the state of the proper kexec image.

---
Note: The corresponding Xen changes have been committed to the Xen staging branch. Follow this thread:
https://lists.xenproject.org/archives/html/xen-devel/2017-01/msg01570.html

v0: First version (internal product).
v1: Posted on kexec mailing list. Changed -s to -S
v2: Incorporated feedback from kexec mailing list, posted on kexec mailing list
v3: Incorporated feedback from kexec mailing list

---
 configure.ac      |  8 ++++++-
 kexec/kexec-xen.c | 26 +++++++++++++++++++++++
 kexec/kexec.8     |  6 ++++++
 kexec/kexec.c     | 62 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 kexec/kexec.h     |  5 ++++-
 5 files changed, 98 insertions(+), 9 deletions(-)
configure.ac +0 -0
index 3044185..c6e864b 100644
@@ -165,8 +165,14 @@ fi
 dnl find Xen control stack libraries
 if test "$with_xen" = yes ; then

configure.ac fi · line 175

Quoted 10 lines
configure.ac +7 -1
 	AC_CHECK_HEADER(xenctrl.h,
-		[AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
+		[AC_CHECK_LIB(xenctrl, xc_kexec_load, [ have_xenctrl_h=yes ],
 		AC_MSG_NOTICE([Xen support disabled]))])
+if test "$have_xenctrl_h" = yes ; then
+	AC_CHECK_LIB(xenctrl, xc_kexec_status,
+		AC_DEFINE(HAVE_KEXEC_CMD_STATUS, 1,
+			[The kexec_status call is available]),
+		AC_MSG_NOTICE([The kexec_status call is not available]))
+fi

I have a feeling that you have missed my comment. Please add two TABs starting from "+if test "$have_xenctrl_h" = yes ; then" up to "+fi". So, it should look more or less like this:

AC_MSG_NOTICE([Xen support disabled]))])

configure.ac +2 -0
+		if test "$have_xenctrl_h" = yes ; then
+			AC_CHECK_LIB(xenctrl, xc_kexec_status,
...
Quoted 1 line

If it is not needed or something like that please drop me a line.

The tabs are not needed for the configure to work properly.

If tabs are needed for readability/style purposes, I will add them in. There is not any precedent of nesting in the configure.ac file, so I am unsure what convention is for this package.

Quoted 57 lines
Quoted 57 lines
configure.ac +0 -0
 fi
 
 dnl ---Sanity checks
kexec/kexec-xen.c +26 -0
index 24a4191..2b448d3 100644
@@ -105,6 +105,27 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return ret;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	xc_interface *xch;
+	uint8_t type;
+	int ret = -1;
+
+#ifdef HAVE_KEXEC_CMD_STATUS
+	xch = xc_interface_open(NULL, NULL, 0);
+	if (!xch)
+		return -1;
+
+	type = (kexec_flags & KEXEC_ON_CRASH) ? KEXEC_TYPE_CRASH : KEXEC_TYPE_DEFAULT;
+
+	ret = xc_kexec_status(xch, type);
+
+	xc_interface_close(xch);
+#endif
+
+	return ret;
+}
+
 void xen_kexec_exec(void)
 {
 	xc_interface *xch;
@@ -130,6 +151,11 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return -1;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	return -1;
+}
+
 void xen_kexec_exec(void)
 {
 }
kexec/kexec.8 +1 -0
index 4d0c1d1..f4b39a6 100644
@@ -107,6 +107,12 @@ command:
 .B \-d\ (\-\-debug)
 Enable debugging messages.
 .TP
+.B \-S\ (\-\-status)
Quoted 8 lines

kexec/kexec.8 command: · line 114

Quoted 4 lines
kexec/kexec.8 +4 -0
+Return 0 if the type (by default crash) is loaded. Can be used in conjuction
+with -l or -p to toggle the type. Note this option supersedes other options
+and it will
+.BR not\ load\ or\ unload\ the\ kernel.

Same as above. I think that you have missed my earlier comments. I suppose that you can join "+and it will" and "+.BR not\ load\ or\
unload\ the\ kernel." into one line.

In that file, all dot directives start with the dot in the first column. I did the same for the .BR in this statement.

Quoted 35 lines
Quoted 20 lines
kexec/kexec.8 +1 -0
+.TP
 .B \-e\ (\-\-exec)
 Run the currently loaded kernel. Note that it will reboot into the loaded kernel without calling shutdown(8).
 .TP
kexec/kexec.c +3 -0
index 500e5a9..defbbe3 100644
@@ -51,6 +51,9 @@
 #include "kexec-lzma.h"
 #include <arch/options.h>
 
+#define KEXEC_LOADED_PATH "/sys/kernel/kexec_loaded"
+#define KEXEC_CRASH_LOADED_PATH "/sys/kernel/kexec_crash_loaded"
+
 unsigned long long mem_min = 0;
 unsigned long long mem_max = ULONG_MAX;
 static unsigned long kexec_flags = 0;

kexec/kexec.c static unsigned long kexec_flags = 0; · line 65

Quoted 5 lines
kexec/kexec.c +2 -0
@@ -58,6 +61,8 @@ static unsigned long kexec_flags = 0;
 static unsigned long kexec_file_flags = 0;
 int kexec_debug = 0;
 
+static int kexec_loaded(const char *file);
+

Why are you shuffling this...

Quoted 7 lines
kexec/kexec.c +0 -0
 void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr)
 {
 	int i;
@@ -890,8 +895,6 @@ static int my_exec(void)
 	return -1;
 }
 
Quoted 8 lines

kexec/kexec.c static int my_exec(void) · line 894

Quoted 2 lines
kexec/kexec.c +0 -2
-static int kexec_loaded(void);
-

...and this. Could not you leave this forward declaration here (of course with arg change)? Or is it possible to drop it at all?

Daniel

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#3 lore raw
Quoted 2 lines · Eric DeVolder
Quoted 1 line · Daniel Kiper

On Tue, Jan 24, 2017 at 12:55:35PM -0600, Eric DeVolder wrote:

[...]

Quoted 22 lines
Quoted 22 lines
Quoted 11 lines
configure.ac +0 -0
index 3044185..c6e864b 100644
@@ -165,8 +165,14 @@ fi

dnl find Xen control stack libraries
if test "$with_xen" = yes ; then
AC_CHECK_HEADER(xenctrl.h,

configure.ac +1 -1
-		[AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
+		[AC_CHECK_LIB(xenctrl, xc_kexec_load, [ have_xenctrl_h=yes ],

AC_MSG_NOTICE([Xen support disabled]))])

configure.ac fi · line 175

Quoted 6 lines
configure.ac +6 -0
+if test "$have_xenctrl_h" = yes ; then
+	AC_CHECK_LIB(xenctrl, xc_kexec_status,
+		AC_DEFINE(HAVE_KEXEC_CMD_STATUS, 1,
+			[The kexec_status call is available]),
+		AC_MSG_NOTICE([The kexec_status call is not available]))
+fi

I have a feeling that you have missed my comment. Please add two TABs starting from "+if test "$have_xenctrl_h" = yes ; then" up to "+fi". So, it should look more or less like this:

Quoted 8 lines
Quoted 6 lines

AC_MSG_NOTICE([Xen support disabled]))])

configure.ac +2 -0
+		if test "$have_xenctrl_h" = yes ; then
+			AC_CHECK_LIB(xenctrl, xc_kexec_status,
...

If it is not needed or something like that please drop me a line.

The tabs are not needed for the configure to work properly.

Yep.

Quoted 2 lines

If tabs are needed for readability/style purposes, I will add them in. There is not any precedent of nesting in

Please do as above.

Quoted 2 lines

the configure.ac file, so I am unsure what convention is for this package.

OK, no problem.

Quoted 65 lines
Quoted 56 lines
Quoted 56 lines

fi

dnl ---Sanity checks

kexec/kexec-xen.c +26 -0
index 24a4191..2b448d3 100644
@@ -105,6 +105,27 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return ret;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	xc_interface *xch;
+	uint8_t type;
+	int ret = -1;
+
+#ifdef HAVE_KEXEC_CMD_STATUS
+	xch = xc_interface_open(NULL, NULL, 0);
+	if (!xch)
+		return -1;
+
+	type = (kexec_flags & KEXEC_ON_CRASH) ? KEXEC_TYPE_CRASH : KEXEC_TYPE_DEFAULT;
+
+	ret = xc_kexec_status(xch, type);
+
+	xc_interface_close(xch);
+#endif
+
+	return ret;
+}
+
 void xen_kexec_exec(void)
 {
 	xc_interface *xch;
@@ -130,6 +151,11 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return -1;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	return -1;
+}
+
 void xen_kexec_exec(void)
 {
 }
kexec/kexec.8 +0 -0
index 4d0c1d1..f4b39a6 100644
@@ -107,6 +107,12 @@ command:
 .B \-d\ (\-\-debug)

Enable debugging messages.
.TP
+.B \-S\ (\-\-status)

Quoted 8 lines

kexec/kexec.8 command: · line 114

Quoted 4 lines
kexec/kexec.8 +4 -0
+Return 0 if the type (by default crash) is loaded. Can be used in conjuction
+with -l or -p to toggle the type. Note this option supersedes other options
+and it will
+.BR not\ load\ or\ unload\ the\ kernel.

Same as above. I think that you have missed my earlier comments. I suppose that you can join "+and it will" and "+.BR not\ load\ or\
unload\ the\ kernel." into one line.

Quoted 2 lines

In that file, all dot directives start with the dot in the first column. I did the same for the .BR in this statement.

OK, let's leave it then.

Daniel

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw
In reply to Eric DeVolder
Quoted 2 lines · Eric DeVolder
Quoted 1 line · Daniel Kiper

On Tue, Jan 24, 2017 at 12:55:35PM -0600, Eric DeVolder wrote:

[...]

Quoted 22 lines
Quoted 22 lines
Quoted 11 lines
configure.ac +0 -0
index 3044185..c6e864b 100644
@@ -165,8 +165,14 @@ fi

dnl find Xen control stack libraries
if test "$with_xen" = yes ; then
AC_CHECK_HEADER(xenctrl.h,

configure.ac +1 -1
-		[AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
+		[AC_CHECK_LIB(xenctrl, xc_kexec_load, [ have_xenctrl_h=yes ],

AC_MSG_NOTICE([Xen support disabled]))])

configure.ac fi · line 175

Quoted 6 lines
configure.ac +6 -0
+if test "$have_xenctrl_h" = yes ; then
+	AC_CHECK_LIB(xenctrl, xc_kexec_status,
+		AC_DEFINE(HAVE_KEXEC_CMD_STATUS, 1,
+			[The kexec_status call is available]),
+		AC_MSG_NOTICE([The kexec_status call is not available]))
+fi

I have a feeling that you have missed my comment. Please add two TABs starting from "+if test "$have_xenctrl_h" = yes ; then" up to "+fi". So, it should look more or less like this:

Quoted 8 lines
Quoted 6 lines

AC_MSG_NOTICE([Xen support disabled]))])

configure.ac +2 -0
+		if test "$have_xenctrl_h" = yes ; then
+			AC_CHECK_LIB(xenctrl, xc_kexec_status,
...

If it is not needed or something like that please drop me a line.

The tabs are not needed for the configure to work properly.

Yep.

Quoted 2 lines

If tabs are needed for readability/style purposes, I will add them in. There is not any precedent of nesting in

Please do as above.

Quoted 2 lines

the configure.ac file, so I am unsure what convention is for this package.

OK, no problem.

Quoted 65 lines
Quoted 56 lines
Quoted 56 lines

fi

dnl ---Sanity checks

kexec/kexec-xen.c +26 -0
index 24a4191..2b448d3 100644
@@ -105,6 +105,27 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return ret;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	xc_interface *xch;
+	uint8_t type;
+	int ret = -1;
+
+#ifdef HAVE_KEXEC_CMD_STATUS
+	xch = xc_interface_open(NULL, NULL, 0);
+	if (!xch)
+		return -1;
+
+	type = (kexec_flags & KEXEC_ON_CRASH) ? KEXEC_TYPE_CRASH : KEXEC_TYPE_DEFAULT;
+
+	ret = xc_kexec_status(xch, type);
+
+	xc_interface_close(xch);
+#endif
+
+	return ret;
+}
+
 void xen_kexec_exec(void)
 {
 	xc_interface *xch;
@@ -130,6 +151,11 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return -1;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	return -1;
+}
+
 void xen_kexec_exec(void)
 {
 }
kexec/kexec.8 +0 -0
index 4d0c1d1..f4b39a6 100644
@@ -107,6 +107,12 @@ command:
 .B \-d\ (\-\-debug)

Enable debugging messages.
.TP
+.B \-S\ (\-\-status)

Quoted 8 lines

kexec/kexec.8 command: · line 114

Quoted 4 lines
kexec/kexec.8 +4 -0
+Return 0 if the type (by default crash) is loaded. Can be used in conjuction
+with -l or -p to toggle the type. Note this option supersedes other options
+and it will
+.BR not\ load\ or\ unload\ the\ kernel.

Same as above. I think that you have missed my earlier comments. I suppose that you can join "+and it will" and "+.BR not\ load\ or\
unload\ the\ kernel." into one line.

Quoted 2 lines

In that file, all dot directives start with the dot in the first column. I did the same for the .BR in this statement.

OK, let's leave it then.

Daniel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw
In reply to Daniel Kiper
Quoted 67 lines · Daniel Kiper
Quoted 46 lines · Eric DeVolder

Instead of the scripts having to poke at various fields we can provide that functionality via the -S parameter.

kexec_loaded/kexec_crash_loaded exposes Linux kernel kexec/crash state. It does not say anything about Xen kexec/crash state. So, we need a special approach to get the latter. Though for compatibility we provide similar functionality in kexec-tools for the former.

This change enables the --status or -S option to work either with or without Xen.

Returns 0 if the payload is loaded. Can be used in combination with -l or -p to get the state of the proper kexec image.

---
Note: The corresponding Xen changes have been committed to the Xen staging branch. Follow this thread:
https://lists.xenproject.org/archives/html/xen-devel/2017-01/msg01570.html

v0: First version (internal product).
v1: Posted on kexec mailing list. Changed -s to -S
v2: Incorporated feedback from kexec mailing list, posted on kexec mailing list
v3: Incorporated feedback from kexec mailing list

---
 configure.ac      |  8 ++++++-
 kexec/kexec-xen.c | 26 +++++++++++++++++++++++
 kexec/kexec.8     |  6 ++++++
 kexec/kexec.c     | 62 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 kexec/kexec.h     |  5 ++++-
 5 files changed, 98 insertions(+), 9 deletions(-)
configure.ac +0 -0
index 3044185..c6e864b 100644
@@ -165,8 +165,14 @@ fi
 dnl find Xen control stack libraries
 if test "$with_xen" = yes ; then

configure.ac fi · line 175

Quoted 10 lines
configure.ac +7 -1
 	AC_CHECK_HEADER(xenctrl.h,
-		[AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
+		[AC_CHECK_LIB(xenctrl, xc_kexec_load, [ have_xenctrl_h=yes ],
 		AC_MSG_NOTICE([Xen support disabled]))])
+if test "$have_xenctrl_h" = yes ; then
+	AC_CHECK_LIB(xenctrl, xc_kexec_status,
+		AC_DEFINE(HAVE_KEXEC_CMD_STATUS, 1,
+			[The kexec_status call is available]),
+		AC_MSG_NOTICE([The kexec_status call is not available]))
+fi

I have a feeling that you have missed my comment. Please add two TABs starting from "+if test "$have_xenctrl_h" = yes ; then" up to "+fi". So, it should look more or less like this:

AC_MSG_NOTICE([Xen support disabled]))])

configure.ac +2 -0
+		if test "$have_xenctrl_h" = yes ; then
+			AC_CHECK_LIB(xenctrl, xc_kexec_status,
...
Quoted 1 line

If it is not needed or something like that please drop me a line.

The tabs are not needed for the configure to work properly.

If tabs are needed for readability/style purposes, I will add them in. There is not any precedent of nesting in the configure.ac file, so I am unsure what convention is for this package.

Quoted 57 lines
Quoted 57 lines
configure.ac +0 -0
 fi
 
 dnl ---Sanity checks
kexec/kexec-xen.c +26 -0
index 24a4191..2b448d3 100644
@@ -105,6 +105,27 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return ret;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	xc_interface *xch;
+	uint8_t type;
+	int ret = -1;
+
+#ifdef HAVE_KEXEC_CMD_STATUS
+	xch = xc_interface_open(NULL, NULL, 0);
+	if (!xch)
+		return -1;
+
+	type = (kexec_flags & KEXEC_ON_CRASH) ? KEXEC_TYPE_CRASH : KEXEC_TYPE_DEFAULT;
+
+	ret = xc_kexec_status(xch, type);
+
+	xc_interface_close(xch);
+#endif
+
+	return ret;
+}
+
 void xen_kexec_exec(void)
 {
 	xc_interface *xch;
@@ -130,6 +151,11 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return -1;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	return -1;
+}
+
 void xen_kexec_exec(void)
 {
 }
kexec/kexec.8 +1 -0
index 4d0c1d1..f4b39a6 100644
@@ -107,6 +107,12 @@ command:
 .B \-d\ (\-\-debug)
 Enable debugging messages.
 .TP
+.B \-S\ (\-\-status)
Quoted 8 lines

kexec/kexec.8 command: · line 114

Quoted 4 lines
kexec/kexec.8 +4 -0
+Return 0 if the type (by default crash) is loaded. Can be used in conjuction
+with -l or -p to toggle the type. Note this option supersedes other options
+and it will
+.BR not\ load\ or\ unload\ the\ kernel.

Same as above. I think that you have missed my earlier comments. I suppose that you can join "+and it will" and "+.BR not\ load\ or\
unload\ the\ kernel." into one line.

In that file, all dot directives start with the dot in the first column. I did the same for the .BR in this statement.

Quoted 35 lines
Quoted 20 lines
kexec/kexec.8 +1 -0
+.TP
 .B \-e\ (\-\-exec)
 Run the currently loaded kernel. Note that it will reboot into the loaded kernel without calling shutdown(8).
 .TP
kexec/kexec.c +3 -0
index 500e5a9..defbbe3 100644
@@ -51,6 +51,9 @@
 #include "kexec-lzma.h"
 #include <arch/options.h>
 
+#define KEXEC_LOADED_PATH "/sys/kernel/kexec_loaded"
+#define KEXEC_CRASH_LOADED_PATH "/sys/kernel/kexec_crash_loaded"
+
 unsigned long long mem_min = 0;
 unsigned long long mem_max = ULONG_MAX;
 static unsigned long kexec_flags = 0;

kexec/kexec.c static unsigned long kexec_flags = 0; · line 65

Quoted 5 lines
kexec/kexec.c +2 -0
@@ -58,6 +61,8 @@ static unsigned long kexec_flags = 0;
 static unsigned long kexec_file_flags = 0;
 int kexec_debug = 0;
 
+static int kexec_loaded(const char *file);
+

Why are you shuffling this...

Quoted 7 lines
kexec/kexec.c +0 -0
 void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr)
 {
 	int i;
@@ -890,8 +895,6 @@ static int my_exec(void)
 	return -1;
 }
 
Quoted 8 lines

kexec/kexec.c static int my_exec(void) · line 894

Quoted 2 lines
kexec/kexec.c +0 -2
-static int kexec_loaded(void);
-

...and this. Could not you leave this forward declaration here (of course with arg change)? Or is it possible to drop it at all?

Daniel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw
In reply to Daniel Kiper
Quoted 168 lines · Daniel Kiper
Quoted 46 lines · Eric DeVolder

Instead of the scripts having to poke at various fields we can provide that functionality via the -S parameter.

kexec_loaded/kexec_crash_loaded exposes Linux kernel kexec/crash state. It does not say anything about Xen kexec/crash state. So, we need a special approach to get the latter. Though for compatibility we provide similar functionality in kexec-tools for the former.

This change enables the --status or -S option to work either with or without Xen.

Returns 0 if the payload is loaded. Can be used in combination with -l or -p to get the state of the proper kexec image.

---
Note: The corresponding Xen changes have been committed to the Xen staging branch. Follow this thread:
https://lists.xenproject.org/archives/html/xen-devel/2017-01/msg01570.html

v0: First version (internal product).
v1: Posted on kexec mailing list. Changed -s to -S
v2: Incorporated feedback from kexec mailing list, posted on kexec mailing list
v3: Incorporated feedback from kexec mailing list

---
 configure.ac      |  8 ++++++-
 kexec/kexec-xen.c | 26 +++++++++++++++++++++++
 kexec/kexec.8     |  6 ++++++
 kexec/kexec.c     | 62 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 kexec/kexec.h     |  5 ++++-
 5 files changed, 98 insertions(+), 9 deletions(-)
configure.ac +0 -0
index 3044185..c6e864b 100644
@@ -165,8 +165,14 @@ fi
 dnl find Xen control stack libraries
 if test "$with_xen" = yes ; then

configure.ac fi · line 175

Quoted 10 lines
configure.ac +7 -1
 	AC_CHECK_HEADER(xenctrl.h,
-		[AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
+		[AC_CHECK_LIB(xenctrl, xc_kexec_load, [ have_xenctrl_h=yes ],
 		AC_MSG_NOTICE([Xen support disabled]))])
+if test "$have_xenctrl_h" = yes ; then
+	AC_CHECK_LIB(xenctrl, xc_kexec_status,
+		AC_DEFINE(HAVE_KEXEC_CMD_STATUS, 1,
+			[The kexec_status call is available]),
+		AC_MSG_NOTICE([The kexec_status call is not available]))
+fi

I have a feeling that you have missed my comment. Please add two TABs starting from "+if test "$have_xenctrl_h" = yes ; then" up to "+fi". So, it should look more or less like this:

AC_MSG_NOTICE([Xen support disabled]))])

configure.ac +2 -0
+		if test "$have_xenctrl_h" = yes ; then
+			AC_CHECK_LIB(xenctrl, xc_kexec_status,
...

If it is not needed or something like that please drop me a line.

Quoted 52 lines
configure.ac +0 -0
 fi
 
 dnl ---Sanity checks
kexec/kexec-xen.c +26 -0
index 24a4191..2b448d3 100644
@@ -105,6 +105,27 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return ret;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	xc_interface *xch;
+	uint8_t type;
+	int ret = -1;
+
+#ifdef HAVE_KEXEC_CMD_STATUS
+	xch = xc_interface_open(NULL, NULL, 0);
+	if (!xch)
+		return -1;
+
+	type = (kexec_flags & KEXEC_ON_CRASH) ? KEXEC_TYPE_CRASH : KEXEC_TYPE_DEFAULT;
+
+	ret = xc_kexec_status(xch, type);
+
+	xc_interface_close(xch);
+#endif
+
+	return ret;
+}
+
 void xen_kexec_exec(void)
 {
 	xc_interface *xch;
@@ -130,6 +151,11 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return -1;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	return -1;
+}
+
 void xen_kexec_exec(void)
 {
 }
kexec/kexec.8 +0 -0
index 4d0c1d1..f4b39a6 100644

kexec/kexec.8 command: · line 114

Quoted 8 lines
kexec/kexec.8 +5 -0
@@ -107,6 +107,12 @@ command:
 .B \-d\ (\-\-debug)
 Enable debugging messages.
 .TP
+.B \-S\ (\-\-status)
+Return 0 if the type (by default crash) is loaded. Can be used in conjuction
+with -l or -p to toggle the type. Note this option supersedes other options
+and it will
+.BR not\ load\ or\ unload\ the\ kernel.

Same as above. I think that you have missed my earlier comments. I suppose that you can join "+and it will" and "+.BR not\ load\ or\
unload\ the\ kernel." into one line.

Quoted 19 lines
kexec/kexec.8 +1 -0
+.TP
 .B \-e\ (\-\-exec)
 Run the currently loaded kernel. Note that it will reboot into the loaded kernel without calling shutdown(8).
 .TP
kexec/kexec.c +3 -0
index 500e5a9..defbbe3 100644
@@ -51,6 +51,9 @@
 #include "kexec-lzma.h"
 #include <arch/options.h>
 
+#define KEXEC_LOADED_PATH "/sys/kernel/kexec_loaded"
+#define KEXEC_CRASH_LOADED_PATH "/sys/kernel/kexec_crash_loaded"
+
 unsigned long long mem_min = 0;
 unsigned long long mem_max = ULONG_MAX;
 static unsigned long kexec_flags = 0;

kexec/kexec.c static unsigned long kexec_flags = 0; · line 65

Quoted 5 lines
kexec/kexec.c +2 -0
@@ -58,6 +61,8 @@ static unsigned long kexec_flags = 0;
 static unsigned long kexec_file_flags = 0;
 int kexec_debug = 0;
 
+static int kexec_loaded(const char *file);
+

Why are you shuffling this...

Quoted 7 lines
kexec/kexec.c +0 -0
 void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr)
 {
 	int i;
@@ -890,8 +895,6 @@ static int my_exec(void)
 	return -1;
 }
 
Quoted 5 lines

kexec/kexec.c static int my_exec(void) · line 894

Quoted 2 lines
kexec/kexec.c +0 -2
-static int kexec_loaded(void);
-

...and this. Could not you leave this forward declaration here (of course with arg change)? Or is it possible to drop it at all?

It is possible to relocate kexec_loaded() so that the forward declaration is not needed. I will do so.

eric

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#7 lore raw
Quoted 2 lines · Eric DeVolder
Quoted 1 line · Daniel Kiper

On Tue, Jan 24, 2017 at 12:55:35PM -0600, Eric DeVolder wrote:

[...]

Quoted 30 lines
Quoted 30 lines
Quoted 15 lines
kexec/kexec.c +3 -0
index 500e5a9..defbbe3 100644
@@ -51,6 +51,9 @@
 #include "kexec-lzma.h"
 #include <arch/options.h>
 
+#define KEXEC_LOADED_PATH "/sys/kernel/kexec_loaded"
+#define KEXEC_CRASH_LOADED_PATH "/sys/kernel/kexec_crash_loaded"
+
 unsigned long long mem_min = 0;
 unsigned long long mem_max = ULONG_MAX;
 static unsigned long kexec_flags = 0;

kexec/kexec.c static unsigned long kexec_flags = 0; · line 65

Quoted 5 lines
kexec/kexec.c +2 -0
@@ -58,6 +61,8 @@ static unsigned long kexec_flags = 0;
 static unsigned long kexec_file_flags = 0;
 int kexec_debug = 0;
 
+static int kexec_loaded(const char *file);
+

Why are you shuffling this...

Quoted 7 lines
kexec/kexec.c +0 -0
 void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr)
 {
 	int i;
@@ -890,8 +895,6 @@ static int my_exec(void)
 	return -1;
 }
 
Quoted 8 lines
Quoted 5 lines

kexec/kexec.c static int my_exec(void) · line 894

Quoted 2 lines
kexec/kexec.c +0 -2
-static int kexec_loaded(void);
-

...and this. Could not you leave this forward declaration here (of course with arg change)? Or is it possible to drop it at all?

It is possible to relocate kexec_loaded() so that the forward declaration is not needed. I will do so.

Great!

Daniel

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#8 lore raw
In reply to Eric DeVolder
Quoted 2 lines · Eric DeVolder
Quoted 1 line · Daniel Kiper

On Tue, Jan 24, 2017 at 12:55:35PM -0600, Eric DeVolder wrote:

[...]

Quoted 30 lines
Quoted 30 lines
Quoted 15 lines
kexec/kexec.c +3 -0
index 500e5a9..defbbe3 100644
@@ -51,6 +51,9 @@
 #include "kexec-lzma.h"
 #include <arch/options.h>
 
+#define KEXEC_LOADED_PATH "/sys/kernel/kexec_loaded"
+#define KEXEC_CRASH_LOADED_PATH "/sys/kernel/kexec_crash_loaded"
+
 unsigned long long mem_min = 0;
 unsigned long long mem_max = ULONG_MAX;
 static unsigned long kexec_flags = 0;

kexec/kexec.c static unsigned long kexec_flags = 0; · line 65

Quoted 5 lines
kexec/kexec.c +2 -0
@@ -58,6 +61,8 @@ static unsigned long kexec_flags = 0;
 static unsigned long kexec_file_flags = 0;
 int kexec_debug = 0;
 
+static int kexec_loaded(const char *file);
+

Why are you shuffling this...

Quoted 7 lines
kexec/kexec.c +0 -0
 void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr)
 {
 	int i;
@@ -890,8 +895,6 @@ static int my_exec(void)
 	return -1;
 }
 
Quoted 8 lines
Quoted 5 lines

kexec/kexec.c static int my_exec(void) · line 894

Quoted 2 lines
kexec/kexec.c +0 -2
-static int kexec_loaded(void);
-

...and this. Could not you leave this forward declaration here (of course with arg change)? Or is it possible to drop it at all?

It is possible to relocate kexec_loaded() so that the forward declaration is not needed. I will do so.

Great!

Daniel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#9 lore raw
In reply to Daniel Kiper
Quoted 168 lines · Daniel Kiper
Quoted 46 lines · Eric DeVolder

Instead of the scripts having to poke at various fields we can provide that functionality via the -S parameter.

kexec_loaded/kexec_crash_loaded exposes Linux kernel kexec/crash state. It does not say anything about Xen kexec/crash state. So, we need a special approach to get the latter. Though for compatibility we provide similar functionality in kexec-tools for the former.

This change enables the --status or -S option to work either with or without Xen.

Returns 0 if the payload is loaded. Can be used in combination with -l or -p to get the state of the proper kexec image.

---
Note: The corresponding Xen changes have been committed to the Xen staging branch. Follow this thread:
https://lists.xenproject.org/archives/html/xen-devel/2017-01/msg01570.html

v0: First version (internal product).
v1: Posted on kexec mailing list. Changed -s to -S
v2: Incorporated feedback from kexec mailing list, posted on kexec mailing list
v3: Incorporated feedback from kexec mailing list

---
 configure.ac      |  8 ++++++-
 kexec/kexec-xen.c | 26 +++++++++++++++++++++++
 kexec/kexec.8     |  6 ++++++
 kexec/kexec.c     | 62 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 kexec/kexec.h     |  5 ++++-
 5 files changed, 98 insertions(+), 9 deletions(-)
configure.ac +0 -0
index 3044185..c6e864b 100644
@@ -165,8 +165,14 @@ fi
 dnl find Xen control stack libraries
 if test "$with_xen" = yes ; then

configure.ac fi · line 175

Quoted 10 lines
configure.ac +7 -1
 	AC_CHECK_HEADER(xenctrl.h,
-		[AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
+		[AC_CHECK_LIB(xenctrl, xc_kexec_load, [ have_xenctrl_h=yes ],
 		AC_MSG_NOTICE([Xen support disabled]))])
+if test "$have_xenctrl_h" = yes ; then
+	AC_CHECK_LIB(xenctrl, xc_kexec_status,
+		AC_DEFINE(HAVE_KEXEC_CMD_STATUS, 1,
+			[The kexec_status call is available]),
+		AC_MSG_NOTICE([The kexec_status call is not available]))
+fi

I have a feeling that you have missed my comment. Please add two TABs starting from "+if test "$have_xenctrl_h" = yes ; then" up to "+fi". So, it should look more or less like this:

AC_MSG_NOTICE([Xen support disabled]))])

configure.ac +2 -0
+		if test "$have_xenctrl_h" = yes ; then
+			AC_CHECK_LIB(xenctrl, xc_kexec_status,
...

If it is not needed or something like that please drop me a line.

Quoted 52 lines
configure.ac +0 -0
 fi
 
 dnl ---Sanity checks
kexec/kexec-xen.c +26 -0
index 24a4191..2b448d3 100644
@@ -105,6 +105,27 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return ret;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	xc_interface *xch;
+	uint8_t type;
+	int ret = -1;
+
+#ifdef HAVE_KEXEC_CMD_STATUS
+	xch = xc_interface_open(NULL, NULL, 0);
+	if (!xch)
+		return -1;
+
+	type = (kexec_flags & KEXEC_ON_CRASH) ? KEXEC_TYPE_CRASH : KEXEC_TYPE_DEFAULT;
+
+	ret = xc_kexec_status(xch, type);
+
+	xc_interface_close(xch);
+#endif
+
+	return ret;
+}
+
 void xen_kexec_exec(void)
 {
 	xc_interface *xch;
@@ -130,6 +151,11 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return -1;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	return -1;
+}
+
 void xen_kexec_exec(void)
 {
 }
kexec/kexec.8 +0 -0
index 4d0c1d1..f4b39a6 100644

kexec/kexec.8 command: · line 114

Quoted 8 lines
kexec/kexec.8 +5 -0
@@ -107,6 +107,12 @@ command:
 .B \-d\ (\-\-debug)
 Enable debugging messages.
 .TP
+.B \-S\ (\-\-status)
+Return 0 if the type (by default crash) is loaded. Can be used in conjuction
+with -l or -p to toggle the type. Note this option supersedes other options
+and it will
+.BR not\ load\ or\ unload\ the\ kernel.

Same as above. I think that you have missed my earlier comments. I suppose that you can join "+and it will" and "+.BR not\ load\ or\
unload\ the\ kernel." into one line.

Quoted 19 lines
kexec/kexec.8 +1 -0
+.TP
 .B \-e\ (\-\-exec)
 Run the currently loaded kernel. Note that it will reboot into the loaded kernel without calling shutdown(8).
 .TP
kexec/kexec.c +3 -0
index 500e5a9..defbbe3 100644
@@ -51,6 +51,9 @@
 #include "kexec-lzma.h"
 #include <arch/options.h>
 
+#define KEXEC_LOADED_PATH "/sys/kernel/kexec_loaded"
+#define KEXEC_CRASH_LOADED_PATH "/sys/kernel/kexec_crash_loaded"
+
 unsigned long long mem_min = 0;
 unsigned long long mem_max = ULONG_MAX;
 static unsigned long kexec_flags = 0;

kexec/kexec.c static unsigned long kexec_flags = 0; · line 65

Quoted 5 lines
kexec/kexec.c +2 -0
@@ -58,6 +61,8 @@ static unsigned long kexec_flags = 0;
 static unsigned long kexec_file_flags = 0;
 int kexec_debug = 0;
 
+static int kexec_loaded(const char *file);
+

Why are you shuffling this...

Quoted 7 lines
kexec/kexec.c +0 -0
 void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr)
 {
 	int i;
@@ -890,8 +895,6 @@ static int my_exec(void)
 	return -1;
 }
 
Quoted 5 lines

kexec/kexec.c static int my_exec(void) · line 894

Quoted 2 lines
kexec/kexec.c +0 -2
-static int kexec_loaded(void);
-

...and this. Could not you leave this forward declaration here (of course with arg change)? Or is it possible to drop it at all?

It is possible to relocate kexec_loaded() so that the forward declaration is not needed. I will do so.

eric

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#10 lore raw
In reply to Eric DeVolder
Quoted 46 lines · Eric DeVolder

Instead of the scripts having to poke at various fields we can provide that functionality via the -S parameter.

kexec_loaded/kexec_crash_loaded exposes Linux kernel kexec/crash state. It does not say anything about Xen kexec/crash state. So, we need a special approach to get the latter. Though for compatibility we provide similar functionality in kexec-tools for the former.

This change enables the --status or -S option to work either with or without Xen.

Returns 0 if the payload is loaded. Can be used in combination with -l or -p to get the state of the proper kexec image.

---
Note: The corresponding Xen changes have been committed to the Xen staging branch. Follow this thread:
https://lists.xenproject.org/archives/html/xen-devel/2017-01/msg01570.html

v0: First version (internal product).
v1: Posted on kexec mailing list. Changed -s to -S
v2: Incorporated feedback from kexec mailing list, posted on kexec mailing list
v3: Incorporated feedback from kexec mailing list

---
 configure.ac      |  8 ++++++-
 kexec/kexec-xen.c | 26 +++++++++++++++++++++++
 kexec/kexec.8     |  6 ++++++
 kexec/kexec.c     | 62 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 kexec/kexec.h     |  5 ++++-
 5 files changed, 98 insertions(+), 9 deletions(-)
configure.ac +0 -0
index 3044185..c6e864b 100644
@@ -165,8 +165,14 @@ fi
 dnl find Xen control stack libraries
 if test "$with_xen" = yes ; then

configure.ac fi · line 175

Quoted 10 lines
configure.ac +7 -1
 	AC_CHECK_HEADER(xenctrl.h,
-		[AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
+		[AC_CHECK_LIB(xenctrl, xc_kexec_load, [ have_xenctrl_h=yes ],
 		AC_MSG_NOTICE([Xen support disabled]))])
+if test "$have_xenctrl_h" = yes ; then
+	AC_CHECK_LIB(xenctrl, xc_kexec_status,
+		AC_DEFINE(HAVE_KEXEC_CMD_STATUS, 1,
+			[The kexec_status call is available]),
+		AC_MSG_NOTICE([The kexec_status call is not available]))
+fi

I have a feeling that you have missed my comment. Please add two TABs starting from "+if test "$have_xenctrl_h" = yes ; then" up to "+fi". So, it should look more or less like this:

AC_MSG_NOTICE([Xen support disabled]))])
+ if test "$have_xenctrl_h" = yes ; then
+ AC_CHECK_LIB(xenctrl, xc_kexec_status,
...

If it is not needed or something like that please drop me a line.

Quoted 52 lines
configure.ac +0 -0
 fi
 
 dnl ---Sanity checks
kexec/kexec-xen.c +26 -0
index 24a4191..2b448d3 100644
@@ -105,6 +105,27 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return ret;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	xc_interface *xch;
+	uint8_t type;
+	int ret = -1;
+
+#ifdef HAVE_KEXEC_CMD_STATUS
+	xch = xc_interface_open(NULL, NULL, 0);
+	if (!xch)
+		return -1;
+
+	type = (kexec_flags & KEXEC_ON_CRASH) ? KEXEC_TYPE_CRASH : KEXEC_TYPE_DEFAULT;
+
+	ret = xc_kexec_status(xch, type);
+
+	xc_interface_close(xch);
+#endif
+
+	return ret;
+}
+
 void xen_kexec_exec(void)
 {
 	xc_interface *xch;
@@ -130,6 +151,11 @@ int xen_kexec_unload(uint64_t kexec_flags)
 	return -1;
 }
 
+int xen_kexec_status(uint64_t kexec_flags)
+{
+	return -1;
+}
+
 void xen_kexec_exec(void)
 {
 }
kexec/kexec.8 +0 -0
index 4d0c1d1..f4b39a6 100644

kexec/kexec.8 command: · line 114

Quoted 8 lines
kexec/kexec.8 +5 -0
@@ -107,6 +107,12 @@ command:
 .B \-d\ (\-\-debug)
 Enable debugging messages.
 .TP
+.B \-S\ (\-\-status)
+Return 0 if the type (by default crash) is loaded. Can be used in conjuction
+with -l or -p to toggle the type. Note this option supersedes other options
+and it will
+.BR not\ load\ or\ unload\ the\ kernel.

Same as above. I think that you have missed my earlier comments. I suppose that you can join "+and it will" and "+.BR not\ load\ or\
unload\ the\ kernel." into one line.

Quoted 19 lines
kexec/kexec.8 +1 -0
+.TP
 .B \-e\ (\-\-exec)
 Run the currently loaded kernel. Note that it will reboot into the loaded kernel without calling shutdown(8).
 .TP
kexec/kexec.c +3 -0
index 500e5a9..defbbe3 100644
@@ -51,6 +51,9 @@
 #include "kexec-lzma.h"
 #include <arch/options.h>
 
+#define KEXEC_LOADED_PATH "/sys/kernel/kexec_loaded"
+#define KEXEC_CRASH_LOADED_PATH "/sys/kernel/kexec_crash_loaded"
+
 unsigned long long mem_min = 0;
 unsigned long long mem_max = ULONG_MAX;
 static unsigned long kexec_flags = 0;

kexec/kexec.c static unsigned long kexec_flags = 0; · line 65

Quoted 5 lines
kexec/kexec.c +2 -0
@@ -58,6 +61,8 @@ static unsigned long kexec_flags = 0;
 static unsigned long kexec_file_flags = 0;
 int kexec_debug = 0;
 
+static int kexec_loaded(const char *file);
+

Why are you shuffling this...

kexec/kexec.c static int my_exec(void) · line 894

Quoted 9 lines
kexec/kexec.c +0 -2
 void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr)
 {
 	int i;
@@ -890,8 +895,6 @@ static int my_exec(void)
 	return -1;
 }
 
-static int kexec_loaded(void);
-

...and this. Could not you leave this forward declaration here (of course with arg change)? Or is it possible to drop it at all?

Daniel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel