mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-03 09:55:01 +00:00
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>
This commit is contained in:
@@ -94,6 +94,9 @@ int mm_count_lines(struct mm_file_t *mfile)
|
||||
if (!mfile || mfile->size < 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (!mfile->size)
|
||||
return 0;
|
||||
|
||||
return strcnt(mfile->begin, '\n');
|
||||
}
|
||||
|
||||
@@ -432,7 +435,7 @@ int replace_file_head(char *filename, char *text)
|
||||
*
|
||||
* @return 0 if successful, or a negative errno-style value if not.
|
||||
*/
|
||||
int overwrite_file(char *filename, char *value)
|
||||
int overwrite_file(const char *filename, const char *value)
|
||||
{
|
||||
FILE *fp;
|
||||
int ret = 0;
|
||||
@@ -833,11 +836,13 @@ close:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int _file_read_key_value(char *path, char op, char *key, char *value)
|
||||
static int _file_read_key_value(const char *path, const char op,
|
||||
const char *key, const size_t limit,
|
||||
char *value)
|
||||
{
|
||||
int fd;
|
||||
int size;
|
||||
int len;
|
||||
size_t len;
|
||||
char *data;
|
||||
char *msg = NULL;
|
||||
char *end, *start;
|
||||
@@ -855,6 +860,10 @@ static int _file_read_key_value(char *path, char op, char *key, char *value)
|
||||
size = get_file_size(path);
|
||||
if (size < 0)
|
||||
return size;
|
||||
if (!size) {
|
||||
errno = ENOMSG;
|
||||
return -errno;
|
||||
}
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0)
|
||||
@@ -872,12 +881,14 @@ static int _file_read_key_value(char *path, char op, char *key, char *value)
|
||||
errno = ENOMSG;
|
||||
goto unmap;
|
||||
}
|
||||
end = strchr(msg, '\n');
|
||||
|
||||
start = msg + strlen(key);
|
||||
end = strchr(start, '\n');
|
||||
if (end == NULL)
|
||||
end = data + size;
|
||||
|
||||
start = msg + strlen(key);
|
||||
len = end - start;
|
||||
len = MIN(len, limit - 1);
|
||||
memcpy(value, start, len);
|
||||
*(value + len) = 0;
|
||||
|
||||
@@ -893,14 +904,16 @@ close:
|
||||
return -errno;
|
||||
}
|
||||
|
||||
int file_read_key_value(char *path, char *key, char *value)
|
||||
int file_read_key_value(const char *path, const char *key,
|
||||
const size_t limit, char *value)
|
||||
{
|
||||
return _file_read_key_value(path, 'l', key, value);
|
||||
return _file_read_key_value(path, 'l', key, limit, value);
|
||||
}
|
||||
|
||||
int file_read_key_value_r(char *path, char *key, char *value)
|
||||
int file_read_key_value_r(const char *path, const char *key,
|
||||
const size_t limit, char *value)
|
||||
{
|
||||
return _file_read_key_value(path, 'r', key, value);
|
||||
return _file_read_key_value(path, 'r', key, limit, value);
|
||||
}
|
||||
|
||||
int dir_contains(const char *dir, const char *filename, int exact,
|
||||
|
@@ -81,7 +81,7 @@ int append_file(char *filename, char *text);
|
||||
int mm_replace_str_line(struct mm_file_t *mfile, char *replace,
|
||||
int line);
|
||||
int replace_file_head(char *filename, char *text);
|
||||
int overwrite_file(char *filename, char *value);
|
||||
int overwrite_file(const char *filename, const char *value);
|
||||
int readline(int fd, char buffer[MAXLINESIZE]);
|
||||
int file_read_string(const char *file, char *string, int size);
|
||||
void file_reset_init(const char *filename);
|
||||
@@ -93,8 +93,10 @@ int space_available(char *path, int quota);
|
||||
int count_lines_in_file(const char *filename);
|
||||
int read_full_binary_file(const char *path, unsigned long *size,
|
||||
void **data);
|
||||
int file_read_key_value(char *path, char *key, char *value);
|
||||
int file_read_key_value_r(char *path, char *key, char *value);
|
||||
int file_read_key_value(const char *path, const char *key,
|
||||
const size_t limit, char *value);
|
||||
int file_read_key_value_r(const char *path, const char *key,
|
||||
const size_t limit, char *value);
|
||||
int dir_contains(const char *dir, const char *filename, int exact,
|
||||
char *fullname);
|
||||
int lsdir(const char *dir, char *fullname[], int limit);
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
|
||||
int strlinelen(char *str);
|
||||
char *strrstr(char *s, char *str);
|
||||
char *strrstr(const char *s, const char *str);
|
||||
char *next_line(char *buf);
|
||||
char *strtrim(char *str);
|
||||
int strcnt(char *str, char c);
|
||||
|
@@ -37,16 +37,16 @@ int strlinelen(char *str)
|
||||
* @return a pointer to the beginning of the substring,
|
||||
* or NULL if the substring is not found.
|
||||
*/
|
||||
char *strrstr(char *s, char *substr)
|
||||
char *strrstr(const char *s, const char *substr)
|
||||
{
|
||||
char *found;
|
||||
char *p = s;
|
||||
const char *found;
|
||||
const char *p = s;
|
||||
|
||||
while ((found = strstr(p, substr)))
|
||||
p = found + 1;
|
||||
|
||||
if (p != s)
|
||||
return p - 1;
|
||||
return (char *)(p - 1);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user