HV:Acrn-hypvervisor Root Directory Clean-up and create misc/ folder for Acrn daemons, services and tools.

This patch is to clean-up acrn-hypervisor root directory, targt only 5 folders under acrn-hypervisor:1.hypervisor,2.devicemodel,3.misc,4.doc,5.build

Tracked-On: #3482
Signed-off-by: Terry Zou <terry.zou@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Terry Zou
2019-07-29 12:21:54 +08:00
committed by Xie, Nanlin
parent 555a03db99
commit a9c38a5cfb
119 changed files with 62 additions and 57 deletions

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __ANDROID_EVENTS_H__
#define __ANDROID_EVENTS_H__
#include "load_conf.h"
extern char *loop_dev;
#define VMEVT_HANDLED 0
#define VMEVT_DEFER -1
struct vm_event_t {
char *vm_msg;
size_t vm_msg_len;
const struct vm_t *vm;
};
#define ANDROID_LOGS_DIR "/logs/"
#define IGN_SPACES "%*[[[:space:]]*]"
#define IGN_RESTS "%*[[.]*]"
#define IGN_ONEWORD "%*[[^[:space:]]*]" IGN_SPACES
#define VM_NAME_FMT "%[[A-Z0-9]{3}]" IGN_SPACES
/* These below macros were defined to obtain strings from
* andorid history_event
*/
#define ANDROID_WORD_LEN 32
/* Strings are constructed by A-Z, len < 8, e.g., CRASH REBOOT */
#define ANDROID_ENEVT_FMT "%[[A-Z]{1,7}]" IGN_SPACES
/* Hashkeys are constructed by 0-9&a-z, len = 20, e.g., 0b34ae1afba54aee5cd0. */
#define ANDROID_KEY_FMT "%[[0-9a-z]{20}]" IGN_SPACES
/* Strings, e.g., 2017-11-11/03:12:59 */
#define ANDROID_LONGTIME_FMT "%[[0-9:/-]{15,20}]" IGN_SPACES
/* It's a time or a subtype of event, e.g., JAVACRASH POWER-ON 424874:19:56 */
#define ANDROID_TYPE_FMT "%[[A-Z0-9_:-]{3,16}]" IGN_SPACES
#define ANDROID_LINE_REST_FMT "%[[^\n]*]" IGN_RESTS
void refresh_vm_history(struct sender_t *sender,
int (*fn)(const char*, size_t, const struct vm_t *));
int android_event_analyze(const char *msg, size_t len, char **result,
size_t *rsize);
#endif

View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _CHANNELS_H
#define _CHANNELS_H
#define BASE_DIR_MASK (IN_CLOSE_WRITE | IN_DELETE_SELF | IN_MOVE_SELF)
#define UPTIME_MASK IN_CLOSE_WRITE
#define MAXEVENTS 15
#define HEART_RATE (6 * 1000) /* ms */
struct channel_t {
char *name;
int fd;
void (*channel_fn)(struct channel_t *);
};
extern int create_detached_thread(pthread_t *pid,
void *(*fn)(void *), void *arg);
extern int init_channels(void);
#endif

View File

@@ -0,0 +1,8 @@
/*
* Copyright (C) 2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
extern int crash_match_filefmt(const struct crash_t *crash,
const char *filefmt);
extern void init_crash_reclassify(void);

View File

@@ -0,0 +1,6 @@
/*
* Copyright (C) 2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
extern int init_event_handler(void);

View File

@@ -0,0 +1,44 @@
/*
* Copyright (C) 2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __EVENT_QUEUE_H__
#define __EVENT_QUEUE_H__
#include <sys/queue.h>
enum event_type_t {
CRASH,
INFO,
UPTIME,
HEART_BEAT,
REBOOT,
VM,
UNKNOWN
};
extern const char *etype_str[];
__extension__
struct event_t {
int watchfd;
enum event_type_t event_type;
const char *channel;
void *private;
TAILQ_ENTRY(event_t) entries;
/* dir to storage logs */
char *dir;
size_t dlen;
int len;
char path[0]; /* keep this at tail*/
};
void event_enqueue(struct event_t *event);
int events_count(void);
struct event_t *event_dequeue(void);
void init_event_queue(void);
#endif

View File

@@ -0,0 +1,35 @@
/*
* Copyright (C) 2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* Copyright (C) 2018 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __HISTORY_H__
#define __HISTORY_H__
#define HISTORY_NAME "history_event"
extern char *history_file;
int prepare_history(void);
void hist_raise_infoerror(const char *type, size_t tlen);
void hist_raise_uptime(char *lastuptime);
void hist_raise_event(const char *event, const char *type, const char *log,
const char *lastuptime, const char *key);
#endif

View File

@@ -0,0 +1,257 @@
/*
* Copyright (C) 2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __LOAD_CONF_H__
#define __LOAD_CONF_H__
#include <stdio.h>
#include <sys/queue.h>
#include <ext2fs/ext2fs.h>
#include "event_queue.h"
#include "probeutils.h"
#include "vmrecord.h"
#define CONTENT_MAX 10
#define EXPRESSION_MAX 5
#define LOG_MAX 20
#define TRIGGER_MAX 20
#define SENDER_MAX 3
#define DATA_MAX 3
#define CRASH_MAX 20
#define INFO_MAX 20
#define VM_MAX 4
#define VM_EVENT_TYPE_MAX 20
struct trigger_t {
int id;
const char *name;
size_t name_len;
const char *type;
size_t type_len;
const char *path;
size_t path_len;
};
struct vm_t {
int id;
const char *name;
size_t name_len;
const char *channel;
size_t channel_len;
const char *interval;
size_t interval_len;
const char *syncevent[VM_EVENT_TYPE_MAX];
size_t syncevent_len[VM_EVENT_TYPE_MAX];
ext2_filsys datafs;
unsigned long history_size[SENDER_MAX];
char *history_data;
char last_evt_detected[SENDER_MAX][SHORT_KEY_LENGTH + 1];
};
struct log_t {
int id;
const char *name;
size_t name_len;
const char *type;
size_t type_len;
const char *path;
size_t path_len;
const char *lines;
size_t lines_len;
const char *deletesource;
size_t deletesource_len;
const char *sizelimit;
size_t sizelimit_len;
void (*get)(struct log_t *, void *);
};
struct crash_t {
int id;
const char *name;
size_t name_len;
const char *channel;
size_t channel_len;
const char *interval;
size_t interval_len;
struct trigger_t *trigger;
const char *content[CONTENT_MAX];
size_t content_len[CONTENT_MAX];
const char *mightcontent[EXPRESSION_MAX][CONTENT_MAX];
size_t mightcontent_len[EXPRESSION_MAX][CONTENT_MAX];
struct log_t *log[LOG_MAX];
const char *data[DATA_MAX];
size_t data_len[DATA_MAX];
struct crash_t *parents;
TAILQ_ENTRY(crash_t) entries;
TAILQ_HEAD(, crash_t) children;
int wd;
int level;
struct crash_t *(*reclassify)(const struct crash_t *, const char*,
char**, size_t *);
};
struct info_t {
int id;
const char *name;
size_t name_len;
const char *channel;
size_t channel_len;
const char *interval;
size_t interval_len;
struct trigger_t *trigger;
struct log_t *log[LOG_MAX];
};
struct uptime_t {
const char *name;
size_t name_len;
const char *frequency;
size_t frequency_len;
const char *eventhours;
size_t eventhours_len;
int wd;
char *path;
};
struct sender_t {
int id;
const char *name;
size_t name_len;
const char *outdir;
size_t outdir_len;
const char *maxcrashdirs;
size_t maxcrashdirs_len;
const char *maxlines;
size_t maxlines_len;
const char *spacequota;
size_t spacequota_len;
const char *foldersize;
size_t foldersize_len;
struct uptime_t *uptime;
void (*send)(struct event_t *);
struct vmrecord_t vmrecord;
size_t outdir_blocks_size;
int sw_updated; /* each sender has their own record */
};
struct conf_t {
struct sender_t *sender[SENDER_MAX];
struct vm_t *vm[VM_MAX];
struct trigger_t *trigger[TRIGGER_MAX];
struct log_t *log[LOG_MAX];
struct crash_t *crash[CRASH_MAX];
struct info_t *info[INFO_MAX];
};
struct conf_t conf;
#define for_each_sender(id, sender, conf) \
for (id = 0; \
id < SENDER_MAX && (sender = conf.sender[id]); \
id++)
#define for_each_trigger(id, trigger, conf) \
for (id = 0; \
id < TRIGGER_MAX && (trigger = conf.trigger[id]); \
id++)
#define for_each_vm(id, vm, conf) \
for (id = 0; \
id < VM_MAX && (vm = conf.vm[id]); \
id++)
#define for_each_syncevent_vm(id, event, vm) \
for (id = 0; \
id < VM_EVENT_TYPE_MAX && (event = vm->syncevent[id]); \
id++)
#define for_each_info(id, info, conf) \
for (id = 0; \
id < INFO_MAX && (info = conf.info[id]); \
id++)
#define for_each_log(id, log, conf) \
for (id = 0; \
id < LOG_MAX && (log = conf.log[id]); \
id++)
#define for_each_crash(id, crash, conf) \
for (id = 0; \
id < CRASH_MAX && (crash = conf.crash[id]); \
id++)
#define for_each_log_collect(id, log, type) \
for (id = 0; \
id < LOG_MAX && (log = type->log[id]); \
id++)
#define for_each_content_crash(id, content, crash) \
for (id = 0; \
id < CONTENT_MAX && (content = crash->content[id]); \
id++)
#define for_each_content_expression(id, content, exp) \
for (id = 0; \
id < CONTENT_MAX && (content = exp[id]); \
id++)
#define exp_valid(exp) \
(__extension__ \
({ \
int _ret = 0; \
int _id; \
const char *content; \
for_each_content_expression(_id, content, exp) { \
if (content) \
_ret = 1; \
} \
_ret; \
}) \
)
#define for_each_expression_crash(id, exp, crash) \
for (id = 0; \
id < EXPRESSION_MAX && (exp = crash->mightcontent[id]); \
id++)
#define for_crash_children(crash, tcrash) \
TAILQ_FOREACH(crash, &tcrash->children, entries)
#define is_leaf_crash(crash) \
(crash && TAILQ_EMPTY(&crash->children))
#define is_root_crash(crash) \
(crash && crash->parents == NULL)
#define to_collect_logs(type) \
(__extension__ \
({ \
int _id; \
int _ret = 0; \
for (_id = 0; _id < LOG_MAX; _id++) \
if (type->log[_id]) \
_ret = 1; \
_ret; \
}) \
)
int load_conf(const char *path);
struct trigger_t *get_trigger_by_name(const char *name);
struct log_t *get_log_by_name(const char *name);
struct vm_t *get_vm_by_name(const char *name);
struct sender_t *get_sender_by_name(const char *name);
enum event_type_t get_conf_by_wd(int wd, void **private);
struct crash_t *get_crash_by_wd(int wd);
int crash_depth(struct crash_t *tcrash);
int cfg_atoi(const char *a, size_t alen, int *i);
#endif

View File

@@ -0,0 +1,19 @@
/*
* Copyright (C) 2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <ext2fs/ext2fs.h>
int loopdev_num_get_free(void);
int loopdev_set_img_par(const char *loopdev, const char *img_path,
const char *parname);
int loopdev_check_parname(const char *loopdev, const char *parname);
int e2fs_dump_file_by_fpath(ext2_filsys fs, const char *in_fp,
const char *out_fp);
int e2fs_read_file_by_fpath(ext2_filsys fs, const char *in_fp,
void **out_data, unsigned long *size);
int e2fs_dump_dir_by_dpath(ext2_filsys fs, const char *in_dp,
const char *out_dp, int *count);
int e2fs_open(const char *dev, ext2_filsys *outfs);
void e2fs_close(ext2_filsys fs);

View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* Copyright (C) 2018 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __PROBEUTILS_H__
#define __PROBEUTILS_H__
#define UPTIME_SIZE 24
#define LONG_TIME_SIZE 32
#define SHORT_KEY_LENGTH 20
#define LONG_KEY_LENGTH 32
enum e_dir_mode {
MODE_CRASH = 0,
MODE_STATS,
MODE_VMEVENT,
};
enum key_type {
KEY_SHORT = 0,
KEY_LONG,
};
int get_uptime_string(char newuptime[24], int *hours);
int get_current_time_long(char buf[32]);
unsigned long long get_uptime(void);
char *generate_event_id(const char *seed1, size_t slen1, const char *seed2,
size_t slen2, enum key_type type);
void generate_crashfile(const char *dir, const char *event, size_t elen,
const char *hashkey, size_t hlen,
const char *type, size_t tlen, const char *data0,
size_t d0len, const char *data1, size_t d1len,
const char *data2, size_t d2len);
char *generate_log_dir(enum e_dir_mode mode, char *hashkey, size_t *dlen);
int is_boot_id_changed(void);
#endif

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* Copyright (C) 2018 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __PROPERTY_H__
#define __PROPERTY_H__
#include "load_conf.h"
#define VERSION_SIZE 256
/* UUID_SIZE contains the UUID number, dashes and some buffer*/
#define UUID_SIZE 48
/* General BUILD_VERSION like 23690 */
#define BUILD_VERSION_SIZE 16
char guuid[UUID_SIZE];
char gbuildversion[BUILD_VERSION_SIZE];
int init_properties(struct sender_t *sender);
int swupdated(struct sender_t *sender);
#endif

View File

@@ -0,0 +1,6 @@
/*
* Copyright (C) 2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
extern int init_sender(void);

View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* Copyright (C) 2018 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define REBOOT_REASON_SIZE 32
extern void read_startupreason(char *startupreason, const size_t limit);

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) 2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __VMRECORD_H__
#define __VMRECORD_H__
#include "pthread.h"
#define VMRECORD_HEAD_LINES 10
#define VMRECORD_TAG_LEN 9
#define VMRECORD_TAG_WAITING_SYNC " <=="
#define VMRECORD_TAG_NOT_FOUND "NOT_FOUND"
#define VMRECORD_TAG_MISS_LOG "MISS_LOGS"
#define VMRECORD_TAG_ON_GOING " ON_GOING"
#define VMRECORD_TAG_NO_RESOURCE "NO_RESORC"
#define VMRECORD_TAG_SUCCESS " "
enum vmrecord_mark_t {
SUCCESS,
NOT_FOUND,
WAITING_SYNC,
ON_GOING,
NO_RESRC,
MISS_LOG
};
struct vmrecord_t {
char *path;
pthread_mutex_t mtx;
struct mm_file_t *recos;
};
int vmrecord_last(struct vmrecord_t *vmrecord, const char *vm_name,
size_t nlen, char *vmkey, size_t ksize);
int vmrecord_mark(struct vmrecord_t *vmrecord, const char *vmkey,
size_t klen, enum vmrecord_mark_t type);
int vmrecord_open_mark(struct vmrecord_t *vmrecord, const char *vmkey,
size_t klen, enum vmrecord_mark_t type);
int vmrecord_gen_ifnot_exists(struct vmrecord_t *vmrecord);
int vmrecord_new(struct vmrecord_t *vmrecord, const char *vm_name,
const char *key);
#endif