From 71c36f19d1ac8ffd71a7a3f583edc86a97770b85 Mon Sep 17 00:00:00 2001 From: Sun Peng Date: Wed, 26 Aug 2020 10:54:19 +0000 Subject: [PATCH] dm: core: Convert print output to acrn-dm logger Unifies the logs to pr_* interfaces instead of printf for better log management. Tracked-On: #5267 Signed-off-by: Sun Peng Reviewed-by: Chi Mingqiang Acked-by: Wang, Yu1 --- devicemodel/core/monitor.c | 4 ++-- devicemodel/core/pm_vuart.c | 2 +- devicemodel/core/sw_load_bzimage.c | 18 +++++++++--------- devicemodel/core/sw_load_common.c | 2 +- devicemodel/core/sw_load_elf.c | 2 +- devicemodel/core/sw_load_ovmf.c | 2 +- devicemodel/core/sw_load_vsbl.c | 16 ++++++---------- 7 files changed, 21 insertions(+), 25 deletions(-) diff --git a/devicemodel/core/monitor.c b/devicemodel/core/monitor.c index ea33ff78c..634549de5 100644 --- a/devicemodel/core/monitor.c +++ b/devicemodel/core/monitor.c @@ -211,9 +211,9 @@ int acrn_parse_intr_monitor(const char *opt) (!dm_strtoui(cp + 1, &cp, 10, &period) && *cp == ',') && (!dm_strtoui(cp + 1, &cp, 10, &delay) && *cp == ',') && (!dm_strtoui(cp + 1, &cp, 10, &duration))) { - printf("interrupt storm monitor params: %d, %d, %d, %d\n", threshold, period, delay, duration); + pr_dbg("interrupt storm monitor params: %d, %d, %d, %d\n", threshold, period, delay, duration); } else { - printf("%s: not correct, it should be like: --intr_monitor 10000,10,1,100, please check!\n", opt); + pr_err("%s: not correct, it should be like: --intr_monitor 10000,10,1,100, please check!\n", opt); return -1; } diff --git a/devicemodel/core/pm_vuart.c b/devicemodel/core/pm_vuart.c index 089ab5d6e..a58cffd40 100644 --- a/devicemodel/core/pm_vuart.c +++ b/devicemodel/core/pm_vuart.c @@ -179,7 +179,7 @@ int parse_pm_by_vuart(const char *opts) } } - printf("pm by vuart node-index = %d\n", node_index); + pr_dbg("pm by vuart node-index = %d\n", node_index); strncpy(node_path, str, MAX_NODE_PATH - 1); free(cpy); diff --git a/devicemodel/core/sw_load_bzimage.c b/devicemodel/core/sw_load_bzimage.c index 13264e071..a505b2d80 100644 --- a/devicemodel/core/sw_load_bzimage.c +++ b/devicemodel/core/sw_load_bzimage.c @@ -128,14 +128,14 @@ acrn_parse_kernel(char *arg) if (len < STR_LEN) { strncpy(kernel_path, arg, len + 1); if (check_image(kernel_path, 0, &kernel_size) != 0){ - fprintf(stderr, "SW_LOAD: check_image failed for '%s'\n", + pr_err("SW_LOAD: check_image failed for '%s'\n", kernel_path); exit(10); /* Non-zero */ } kernel_file_name = kernel_path; with_kernel = 1; - printf("SW_LOAD: get kernel path %s\n", kernel_path); + pr_notice("SW_LOAD: get kernel path %s\n", kernel_path); return 0; } else return -1; @@ -149,13 +149,13 @@ acrn_parse_ramdisk(char *arg) if (len < STR_LEN) { strncpy(ramdisk_path, arg, len + 1); if (check_image(ramdisk_path, 0, &ramdisk_size) != 0){ - fprintf(stderr, "SW_LOAD: check_image failed for '%s'\n", + pr_err("SW_LOAD: check_image failed for '%s'\n", ramdisk_path); exit(11); /* Non-zero */ } with_ramdisk = 1; - printf("SW_LOAD: get ramdisk path %s\n", ramdisk_path); + pr_notice("SW_LOAD: get ramdisk path %s\n", ramdisk_path); return 0; } else return -1; @@ -170,7 +170,7 @@ acrn_prepare_ramdisk(struct vmctx *ctx) fp = fopen(ramdisk_path, "r"); if (fp == NULL) { - printf("SW_LOAD ERR: could not open ramdisk file %s\n", + pr_err("SW_LOAD ERR: could not open ramdisk file %s\n", ramdisk_path); return -1; } @@ -220,7 +220,7 @@ acrn_prepare_kernel(struct vmctx *ctx) fp = fopen(kernel_path, "r"); if (fp == NULL) { - printf("SW_LOAD ERR: could not open kernel file %s\n", + pr_err("SW_LOAD ERR: could not open kernel file %s\n", kernel_path); return -1; } @@ -236,7 +236,7 @@ acrn_prepare_kernel(struct vmctx *ctx) } if ((len + KERNEL_LOAD_OFF(ctx)) > RAMDISK_LOAD_OFF(ctx)) { - printf("SW_LOAD ERR: need big system memory to fit image\n"); + pr_err("SW_LOAD ERR: need big system memory to fit image\n"); fclose(fp); return -1; } @@ -245,13 +245,13 @@ acrn_prepare_kernel(struct vmctx *ctx) read = fread(ctx->baseaddr + KERNEL_LOAD_OFF(ctx), sizeof(char), len, fp); if (read < len) { - printf("SW_LOAD ERR: could not read the whole kernel file," + pr_err("SW_LOAD ERR: could not read the whole kernel file," " file len=%ld, read %lu\n", len, read); fclose(fp); return -1; } fclose(fp); - printf("SW_LOAD: kernel %s size %lu copied to guest 0x%lx\n", + pr_info("SW_LOAD: kernel %s size %lu copied to guest 0x%lx\n", kernel_path, kernel_size, KERNEL_LOAD_OFF(ctx)); return 0; diff --git a/devicemodel/core/sw_load_common.c b/devicemodel/core/sw_load_common.c index b5e7c9a15..2fab5e0d2 100644 --- a/devicemodel/core/sw_load_common.c +++ b/devicemodel/core/sw_load_common.c @@ -144,7 +144,7 @@ acrn_parse_bootargs(char *arg) if (len < BOOT_ARG_LEN) { strncpy(bootargs, arg, len + 1); with_bootargs = 1; - printf("SW_LOAD: get bootargs %s\n", bootargs); + pr_notice("SW_LOAD: get bootargs %s\n", bootargs); return 0; } return -1; diff --git a/devicemodel/core/sw_load_elf.c b/devicemodel/core/sw_load_elf.c index fdd586740..0a88cc18f 100644 --- a/devicemodel/core/sw_load_elf.c +++ b/devicemodel/core/sw_load_elf.c @@ -103,7 +103,7 @@ acrn_parse_elf(char *arg) strncpy(elf_path, arg, len + 1); if (check_image(elf_path, 0, &elfsz) == 0) { elf_file_name = elf_path; - printf("SW_LOAD: get elf path %s\n", elf_path); + pr_notice("SW_LOAD: get elf path %s\n", elf_path); err = 0; } } diff --git a/devicemodel/core/sw_load_ovmf.c b/devicemodel/core/sw_load_ovmf.c index b494d46ff..6d64890ad 100644 --- a/devicemodel/core/sw_load_ovmf.c +++ b/devicemodel/core/sw_load_ovmf.c @@ -99,7 +99,7 @@ acrn_parse_ovmf(char *arg) if (check_image(ovmf_path, OVMF_SZ_LIMIT, &ovmf_size) != 0) break; ovmf_file_name = ovmf_path; - printf("SW_LOAD: get ovmf path %s, size 0x%lx\n", + pr_notice("SW_LOAD: get ovmf path %s, size 0x%lx\n", ovmf_path, ovmf_size); error = 0; } diff --git a/devicemodel/core/sw_load_vsbl.c b/devicemodel/core/sw_load_vsbl.c index c4729c24f..68a01769e 100644 --- a/devicemodel/core/sw_load_vsbl.c +++ b/devicemodel/core/sw_load_vsbl.c @@ -149,8 +149,7 @@ acrn_prepare_guest_part_info(struct vmctx *ctx) fp = fopen(guest_part_info_path, "r"); if (fp == NULL) { - fprintf(stderr, - "SW_LOAD ERR: could not open partition blob %s\n", + pr_err("SW_LOAD ERR: could not open partition blob %s\n", guest_part_info_path); return -1; } @@ -159,15 +158,13 @@ acrn_prepare_guest_part_info(struct vmctx *ctx) len = ftell(fp); if (len != guest_part_info_size) { - fprintf(stderr, - "SW_LOAD ERR: partition blob changed\n"); + pr_err("SW_LOAD ERR: partition blob changed\n"); fclose(fp); return -1; } if ((len + GUEST_PART_INFO_OFF(ctx)) > BOOTARGS_OFF(ctx)) { - fprintf(stderr, - "SW_LOAD ERR: too large partition blob\n"); + pr_err("SW_LOAD ERR: too large partition blob\n"); fclose(fp); return -1; } @@ -176,13 +173,12 @@ acrn_prepare_guest_part_info(struct vmctx *ctx) read = fread(ctx->baseaddr + GUEST_PART_INFO_OFF(ctx), sizeof(char), len, fp); if (read < len) { - fprintf(stderr, - "SW_LOAD ERR: could not read whole partition blob\n"); + pr_err("SW_LOAD ERR: could not read whole partition blob\n"); fclose(fp); return -1; } fclose(fp); - printf("SW_LOAD: partition blob %s size %lu copy to guest 0x%lx\n", + pr_info("SW_LOAD: partition blob %s size %lu copy to guest 0x%lx\n", guest_part_info_path, guest_part_info_size, GUEST_PART_INFO_OFF(ctx)); @@ -199,7 +195,7 @@ acrn_parse_vsbl(char *arg) strncpy(vsbl_path, arg, len + 1); if (check_image(vsbl_path, 8 * MB, &vsbl_size) == 0) { vsbl_file_name = vsbl_path; - printf("SW_LOAD: get vsbl path %s\n", vsbl_path); + pr_notice("SW_LOAD: get vsbl path %s\n", vsbl_path); error = 0; } }