[PATCH v2 01/25] add a flag to display/hide data of offline cpus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a field to pc->flags2 to display/hide data related to offline cpu. This
flag can be changed by the following 2 ways:
1. start crash with "--offline [show|hide]"
2. execute crash command "set offline show|hide"

The default set is "show". This flag can be used by later patches to hide
date related to offline cpus. And set can be checked by using command "set -v"

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 crash.8 |  4 ++++
 defs.h  |  1 +
 help.c  |  6 ++++++
 main.c  | 15 ++++++++++++++-
 tools.c | 15 +++++++++++++++
 5 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/crash.8 b/crash.8
index 1223aeb..bebffba 100644
--- a/crash.8
+++ b/crash.8
@@ -503,6 +503,10 @@ determined value.
 .TP
 .BI --kvmio \ <size>
 override the automatically-calculated KVM guest I/O hole size.
+.TP
+.BI --offline \ [show|hide]
+Display/hide data related to offline cpu. Crash command "set offline
+[on|off]" can be used to override the set here.
 .SH COMMANDS
 Each 
 .B crash
diff --git a/defs.h b/defs.h
index cbdaa47..32c9d4d 100755
--- a/defs.h
+++ b/defs.h
@@ -505,6 +505,7 @@ struct program_context {
 #define REM_PAUSED_F (0x1000ULL)
 #define RAMDUMP	(0x2000ULL)
 #define REMOTE_PAUSED() (pc->flags2 & REM_PAUSED_F)
+#define OFFLINE_HIDE (0x4000ULL)
 	char *cleanup;
 	char *namelist_orig;
 	char *namelist_debug_orig;
diff --git a/help.c b/help.c
index 30d7759..a6f834d 100755
--- a/help.c
+++ b/help.c
@@ -339,6 +339,10 @@ char *program_usage_info[] = {
     "  --kvmio <size>",
     "    override the automatically-calculated KVM guest I/O hole size.",
     "",
+    "  --offline [show|hide]",
+    "    Display/hide data related to offline cpu. Crash command \"set offline",
+    "    [show|hide]\" can be used to override the set here",
+    "",
     "FILES:",
     "",
     "  .crashrc",
@@ -1054,6 +1058,8 @@ char *help_set[] = {
 "                               must be a kernel or module text address, which", 
 "                               may be expressed symbolically or as a hexadecimal",
 "                               value.",
+"       offline show | hide     set crash to display or hide data related to",
+"                               offline cpu.",
 " ",
 "  Internal variables may be set in four manners:\n",
 "    1. entering the set command in $HOME/.%src.",
diff --git a/main.c b/main.c
index ad66058..8917f0f 100755
--- a/main.c
+++ b/main.c
@@ -70,6 +70,7 @@ static struct option long_options[] = {
 	{"dec", 0, 0, 0},
 	{"no_strip", 0, 0, 0},
 	{"hash", required_argument, 0, 0},
+	{"offline", required_argument, 0, 0},
         {0, 0, 0, 0}
 };
 
@@ -279,7 +280,17 @@ main(int argc, char **argv)
 				pc->flags2 |= RADIX_OVERRIDE;
 				pc->output_radix = 10;
 			}
-			
+
+			else if (STREQ(long_options[option_index].name, "offline")) {
+				if (STREQ(optarg, "show"))
+					pc->flags2 &= ~OFFLINE_HIDE;
+				else if (STREQ(optarg, "hide"))
+					pc->flags2 |= OFFLINE_HIDE;
+				else {
+					error(INFO, "invalid --offline argument: %s\n", optarg);
+					program_usage(SHORT_FORM);
+				}
+			}
 
 			else {
 				error(INFO, "internal error: option %s unhandled\n",
@@ -1393,6 +1404,8 @@ dump_program_context(void)
 		fprintf(fp, "%sALLOW_FP", others++ ? "|" : "");
 	if (pc->flags2 & RAMDUMP)
 		fprintf(fp, "%sRAMDUMP", others++ ? "|" : "");
+	if (pc->flags2 & OFFLINE_HIDE)
+		fprintf(fp, "%sOFFLINE_HIDE", others++ ? "|" : "");
 	fprintf(fp, ")\n");
 
 	fprintf(fp, "         namelist: %s\n", pc->namelist);
diff --git a/tools.c b/tools.c
index a5f514f..f9c97a4 100755
--- a/tools.c
+++ b/tools.c
@@ -2365,6 +2365,20 @@ cmd_set(void)
 					"on" : "off");
 			return;
 
+                } else if (STREQ(args[optind], "offline")) {
+
+                        if (args[optind+1]) {
+                                optind++;
+                                if (STREQ(args[optind], "show"))
+                                        pc->flags2 &= ~OFFLINE_HIDE;
+                                else if(STREQ(args[optind], "hide"))
+                                        pc->flags2 |= OFFLINE_HIDE;
+                                else
+                                        goto invalid_set_command;
+                        }
+
+			return;
+
 		} else if (XEN_HYPER_MODE()) {
 			error(FATAL, "invalid argument for the Xen hypervisor\n");
 		} else if (pc->flags & MINIMAL_MODE) {
@@ -2467,6 +2481,7 @@ show_options(void)
 		fprintf(fp, "(%s)\n", value_to_symstr(pc->scope, buf, 0));
 	else
 		fprintf(fp, "(not set)\n");
+	fprintf(fp, "       offline: %s\n", pc->flags2 & OFFLINE_HIDE ? "hide" : "show");
 }
 
 
-- 
1.8.5.3

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux