Skip to content

Commit 41b39c5

Browse files
lauxinwlijinxia
authored andcommitted
tools: acrn-crashlog: Defer the vm events processing when failed
In the original design, acrnprobe marked all handled VMs'events as "synced" in file vmrecordid(this patch changes the name to VM_eventsID.log). Currently, the Android log events are not logged if the first attempt at reading collecting them from the VM fails. This patch changes the logic so that the acrn-crashlog tool will retry continuously. This patch defines different tags for handled VMs'events, and only marks VMs'events "synced" after it returns successfully. Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com> Reviewed-by: xiaojin2 <xiaojing.liu@intel.com> Reviewed-by: Jin Zhi <zhi.jin@intel.com> Acked-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com> Acked-by: Chen gang <gang.c.chen@intel.com>
1 parent ccc222d commit 41b39c5

File tree

11 files changed

+310
-162
lines changed

11 files changed

+310
-162
lines changed

tools/acrn-crashlog/acrnprobe/android_events.c

Lines changed: 137 additions & 76 deletions
Large diffs are not rendered by default.

tools/acrn-crashlog/acrnprobe/include/android_events.h

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,33 @@
99

1010
extern char *loop_dev;
1111

12-
void refresh_vm_history(struct sender_t *sender,
13-
void (*fn)(char*, struct vm_t *));
12+
#define VMEVT_HANDLED 0
13+
#define VMEVT_DEFER -1
14+
15+
#define IGN_SPACES "%*[ ]"
16+
#define IGN_RESTS "%*c"
17+
#define IGN_ONEWORD "%*[^ ]" IGN_SPACES
18+
#define VM_NAME_FMT "%8[A-Z0-9]" IGN_SPACES
19+
20+
/* These below macros were defined to obtain strings from
21+
* andorid history_event
22+
*/
23+
#define ANDROID_WORD_LEN 32
24+
25+
/* Strings are constructed by A-Z, len < 8, e.g., CRASH REBOOT */
26+
#define ANDROID_ENEVT_FMT "%8[A-Z]" IGN_SPACES
27+
/* Hashkeys are constructed by 0-9&a-z, len = 20, e.g., 0b34ae1afba54aee5cd0.
28+
* But the hashkey was printed to history_event file in andorid side by using
29+
* format "%22s", so also using %22 here.
30+
*/
31+
#define ANDROID_KEY_FMT "%22[0-9a-z]" IGN_SPACES
32+
/* Strings, e.g., 2017-11-11/03:12:59 */
33+
#define ANDROID_LONGTIME_FMT "%20[0-9:/-]" IGN_SPACES
34+
/* It's a time or a subtype of event, e.g., JAVACRASH POWER-ON 424874:19:56 */
35+
#define ANDROID_TYPE_FMT "%16[A-Z0-9_:-]" IGN_SPACES
36+
#define ANDROID_LINE_REST_FMT "%4096[^\n]" IGN_RESTS
37+
38+
void refresh_vm_history(const struct sender_t *sender,
39+
int (*fn)(const char*, const struct vm_t *));
1440

1541
#endif

tools/acrn-crashlog/acrnprobe/include/load_conf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ struct conf_t conf;
203203
int load_conf(const char *path);
204204
struct trigger_t *get_trigger_by_name(char *name);
205205
struct log_t *get_log_by_name(char *name);
206-
int sender_id(struct sender_t *sender);
206+
int sender_id(const struct sender_t *sender);
207207
struct sender_t *get_sender_by_name(char *name);
208208
enum event_type_t get_conf_by_wd(int wd, void **private);
209209
struct crash_t *get_crash_by_wd(int wd);

tools/acrn-crashlog/acrnprobe/load_conf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ enum event_type_t get_conf_by_wd(int wd, void **private)
260260

261261
}
262262

263-
int sender_id(struct sender_t *s)
263+
int sender_id(const struct sender_t *s)
264264
{
265265
int id;
266266
struct sender_t *sender;

tools/acrn-crashlog/acrnprobe/main.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,18 @@ int main(int argc, char *argv[])
6565
int op;
6666
struct sender_t *sender;
6767
char cfg[PATH_MAX];
68-
char *config_path[2] = {CONFIG_CUSTOMIZE,
69-
CONFIG_INSTALL};
70-
struct option opts[] = {
68+
const char * const config_path[2] = {
69+
CONFIG_CUSTOMIZE,
70+
CONFIG_INSTALL
71+
};
72+
const struct option opts[] = {
7173
{ "config", required_argument, NULL, 'c' },
7274
{ "help", no_argument, NULL, 'h' },
7375
{ "version", no_argument, NULL, 'V' },
7476
{ NULL, 0, NULL, 0 }
7577
};
7678

79+
cfg[0] = 0;
7780
while ((op = getopt_long(argc, argv, "c:hV", opts,
7881
NULL)) != -1) {
7982
switch (op) {

tools/acrn-crashlog/acrnprobe/property.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ static int get_buildversion(struct sender_t *sender)
7070
char *logbuildid;
7171
char *currentbuild = gbuildversion;
7272

73-
ret = file_read_key_value(OS_VERSION, OS_VERSION_KEY, gbuildversion);
73+
ret = file_read_key_value(OS_VERSION, OS_VERSION_KEY,
74+
sizeof(gbuildversion), gbuildversion);
7475
if (ret <= 0) {
7576
LOGE("failed to get version from %s, error (%s)\n",
7677
OS_VERSION, strerror(-ret));

0 commit comments

Comments
 (0)