CN116340035A - Method for debugging debug jailhouse by dynamically setting log level - Google Patents

Method for debugging debug jailhouse by dynamically setting log level Download PDF

Info

Publication number
CN116340035A
CN116340035A CN202310113265.1A CN202310113265A CN116340035A CN 116340035 A CN116340035 A CN 116340035A CN 202310113265 A CN202310113265 A CN 202310113265A CN 116340035 A CN116340035 A CN 116340035A
Authority
CN
China
Prior art keywords
log
level
jailhouse
debug
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310113265.1A
Other languages
Chinese (zh)
Inventor
陈阳平
黄磊
张云飞
齐璇
战茅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kirin Software Co Ltd
Original Assignee
Kirin Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kirin Software Co Ltd filed Critical Kirin Software Co Ltd
Priority to CN202310113265.1A priority Critical patent/CN116340035A/en
Publication of CN116340035A publication Critical patent/CN116340035A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • G06F11/0781Error filtering or prioritizing based on a policy defined by the user or on a policy defined by a hardware/software module, e.g. according to a severity level
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • G06F11/0787Storage of error reports, e.g. persistent data storage, storage using memory protection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/366Software debugging using diagnostics
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The method for debugging the debug jailhouse by dynamically setting the log level comprises the following steps: the jailhouse driving layer adds an attr attribute, and the value of the attr attribute is used for a user to dynamically read or set in a user space; after the driver layer detects a change in the value of the attr attribute, the value of the attr attribute is passed to the hyperserver layer of the jailhouse using hvc command; the journal printing mechanism of the hypervisor is modified, the printing level is increased, and printing is performed only when the current log level is smaller than the attribute value of the incoming attr. According to the invention, log level debug jailouse can be dynamically set in a user layer, one-time log addition and one-time compiling are realized, whether the log is output or not is permanently controlled, the complexity that the original log system of the jailouse needs to be recompiled and installed each time of output and closing is changed, and the working efficiency is increased.

Description

Method for debugging debug jailhouse by dynamically setting log level
Technical Field
The invention relates to the technical field of the optimization of the function of the log record of a jailmouse, in particular to a method for dynamically setting log-level debug jailmouse.
Background
The log is abstract data for recording changes in the running process of the system, and is the most basic and important debugging means no matter what programs are developed, such as a singlechip, a mobile phone APP, a computer client side and a server. The effective log method can achieve the effect of twice the effort.
Jailhouse is a small Hypervisor for creating industrial-level applications, is a software program, enables asymmetric multiprocessing over existing Linux, and splits the system into independent partitions called cells. Each cell runs a gueastos and has a set of fully controlled allocated resources (CPU, memory area, PCI devices).
There are currently a variety of open source hypervisors for embedded systems that provide the functionality to virtualize on an embedded device.
Xen supports CPU virtualization, MMU virtualization, virtual interrupt handling, inter-client communication, domain is used to represent a virtual machine or client, dom0 runs a modified version of a Linux kernel, IO virtualization and client management services are provided by using the Linux kernel, priority is highest, and complete access rights to host hardware are provided. The user interface of the administration client is implemented using a Xen tool stack running in the Dom0 user space. Xen has the advantage of reusing existing device drivers and other parts of the Linux kernel, but has the disadvantage that Dom0 is just another domain of Xen, has its own nested page tables, and may be scheduled out by the Xen scheduler.
kvm allows the guest operating system to run in the same execution mode as the HOST operating system, HOST sees the virtual machine as a QEMU process and I/O access will be trapped into the HOST Linux kernel. The KVM virtualizes the CPU on HOST and relies on QEMU running in user space to handle client IO events. The advantage of KVM is reuse of existing device drivers and other parts of the Linux kernel, but the disadvantage is that the virtual machine switch from the client mode to the host mode of KVM relies on a nested page table fault mechanism, special command traps (Trap), host interrupts, client IO events, and another virtual machine switch to wake up the client execution from host mode, resulting in a substantial decrease in KVM overall performance.
Siemens developed Jailhouse based on the features of the above two hypervisors. Jailhouse allocates hardware directly to gueastos, transferring complex hardware processing boot issues from hypervisors to the general purpose operating system (gueastos). Jailhouse establishes an isolation domain and is able to directly access physical resources without emulation or paravirtualization. The Jailhouse not only reserves the universality of the Linux operating system, but also utilizes the advantage of simplicity, so that the operation of realizing safety critical and real-time critical workloads in an isolation domain is easy.
The log system of the jailhouse does not have a global switch, if the log is to be closed, each log needs to be annotated, and the method is particularly complicated, and the open and close changes of each log need to be modified, recompiled, reloaded and poor in flexibility.
Disclosure of Invention
In order to solve the defects existing in the prior art, the invention provides a method for debugging debug jailhouse by dynamically setting log level, which comprises the following steps:
step S1: the jailhouse driving layer adds an attr attribute, and the value of the attr attribute is used for a user to dynamically read or set in a user space; after the driver layer detects a change in the value of the attr attribute, the value of the attr attribute is passed to the hyperserver layer of the jailhouse using hvc command;
step S2: and modifying a log printing mechanism of the hypervisor, increasing the printing level, and printing the log corresponding to the corresponding log level only when the current log level is smaller than the attribute value of the incoming attr.
Wherein, the step S1 includes the following steps:
step S11: defining a global variable in main.c to store log levels set by a user and setting a default value;
step S12: adding a readable and writable attr attribute node in the sysfs.c file;
step S13: implementing the reading function of the attr attribute node;
step S14: an add hvc command, passing the value of the attr attribute to the hypervisor layer;
step S15: the write function of the attribute node is implemented and the set log level is passed into the hypervisor layer through the hvc command of the jailhouse package.
Wherein, the step S2 includes the following steps:
step S21: the hypervisor layer receives the debug_level value transmitted by the driving layer;
step S22: increasing the print function containing log levels;
step S23: defining printing functions of different grades;
step S24: different printing functions are selected as required.
Wherein, the step S2 further includes:
step S25: automatically generating a property file under a/sys/devices/jailhouse directory, and checking the value of the property file through a cat debug_level command;
step S26: an echo n > debug_level command sets a log level of desired printing, where n is the set log level of desired printing. According to the invention, log level debug jailouse can be dynamically set in a user layer, one-time log addition and one-time compiling are realized, whether the log is output or not is permanently controlled, the complexity that the original log system of the jailouse needs to be recompiled and installed each time of output and closing is changed, and the working efficiency is increased.
Drawings
FIG. 1 is a flow chart of an implementation of the method of the present invention for dynamically setting log level debug jailhouse.
Detailed Description
In order to further understand the technical scheme and beneficial effects of the present invention, the technical scheme and beneficial effects thereof will be described in detail with reference to the accompanying drawings.
The invention provides a log method for dynamically setting log level debug jailmouse by a user, which dynamically controls whether the log of the jailmouse is output or not and which levels of log logs need to be output according to the log level set by the user.
The technical conception of the invention is as follows: adding an attr attribute to the jailhouse driving layer, wherein a user can dynamically read or set the value of an attr attribute file in a user space, and after the driving layer detects that the value of the attr attribute is changed, the value is transmitted to the hypervir layer of the jailhouse by using a hvc command; the journal printing mechanism of the hypervisor is modified, the printing level is increased, and printing is performed only when the current log level is smaller than the attribute value of the incoming attr. A log method for dynamically setting log level debug jailhouse by a user is realized.
The specific implementation method is as follows:
prepare a ft2004 desktop or development board, install the cents 8.1 system, install Jailhosue code, and prepare the configuration files, main.c, information.c, required for testing.
The test environment comprises the following specific steps:
a. drive layer adds attr attribute nodes
Specifically, adding an attribute node named debug_attr to the driver layer, adding a debug_level variable for storing the value of the attribute node, including the following steps:
a1. defining a global variable in main.c to store the log level set by the user and set a default value, for example unsigned int debug _level=5;
a2. adding a readable and writable ATTR attribute node in the sysfs.c file, wherein the attribute node is a static device_attr_rw (debug_attr); and adds to the attribute list jaihoussysfs entries array;
a3. implementing read functions for debug_attr attribute nodes
static ssize_t debug_attr_show(struct device*dev,struct device_attribute*attr,
char*buf)
{
return sprintf(buf,"%d\n",debug_level);
}
Through the reading function, a user can read the value of the attribute node;
a4. add hvc command, pass attribute value to hypervisor
The method of transferring the debug_level variable to jailhouse hypervisor layer is added in the hypercall.h file, so that when the user modifies the debug_level value, the modified value can be transferred to the hypervisor layer, for example:
#define JAILHOUSE_HC_HYPERVISOR_DEBUG_LEVEL 9;
the Jailhouse code is divided into a driver layer and a hypersivor layer, the value of the attribute node bebug_attr is stored in a debug_level variable, and a user modifies the value of the debug_level by modifying the attribute node file debug_attr, and the driver layer and the hypersivor layer of the Jailhouse share the variable value.
a5. The write function of the debug_level attribute node is realized, and the user modified debug_level value is transmitted into the hypervisor through a hvc command of the jailmouse package, and the code is as follows:
static ssize_t debug_flag_store(struct device*dev,struct device_attribute*attr,
const char*buf,size_t size)
{
unsigned int val;
ssize_t rc;
rc=kstrtouint(buf,0,&val);
debug_level=val;
rc=jailhouse_call_arg1(JAILHOUSE_HC_HYPERVISOR_DEBUG_LEVEL,
val);
if(rc!=0)
return rc;
return size;
}
b.Hypervisor layer modification log system
b1. Receiving the debug_level value transferred by the drive layer
Specifically, after the user modifies the value of the debug_attr attribute file, the jailhouse driving layer transmits the modified value debug_level to the hypervisor layer through the step a5, and a global variable debug_lay2 is defined in the hypervisor to receive the value;
global variable unsigned int debug _lev2=5 is defined in control.c; controlling output of a hypervisor module log;
and assigning a debug_level value of the drive layer to debug_lev2 of the hypervisor in a hypvcall function;
case JAILHOUSE_HC_HYPERVISOR_DEBUG_LEVEL:
debug_level2=(unsigned int)arg1;
return 0;
b2. adding print functions containing log level decisions at the hypersivor layer
Increase in printk.c
void__attribute__((format(printf,2,3)))printk_level(unsigned int level,const char*fmt,...);
void printk_level(unsigned int level,const char*fmt,...){
if(level<debug_level2){
printk(fmt);
}
}
b3. Based on the print function of step b2, print functions of different levels such as error, info, debug are defined
Increase in printk.h:
#define printkE(fmt,...)printk_level(0,fmt,##__VA_ARGS__)
#define printkI(fmt,...)printk_level(3,fmt,##__VA_ARGS__)
#define printkV(fmt,...)printk_level(5,fmt,##__VA_ARGS__)
b4. selecting different printing functions according to the requirement
For example, in the cell_create function, print printi ("cell create |");
c. user control log output level
c1. Compiling an installation code and loading a driving module;
c2. an attribute file is automatically generated under the/sys/devices/jailhouse directory, the value of the attribute file is defaulted to 5 through a cat debug_attr command, the log level which is expected to be printed can be set to 4 through an echo 4> debug_attr command, and then the logs printed by using printkE and printkI functions in the code can be output, and the logs printed by using a printkV function can be automatically closed and can not be output.
Compiling the installation code, and after loading the driver, verifying the code as follows:
1. starting the hypervisor: jailhouse enable main. Cell
And finally, the serial port outputs the following information, which indicates that the hypervisor is started normally:
Activating hypervisor
2. test log
For example, in the cell_create function, print printi ("cell create |"); echo 4> debug_level
Execution jailhouse cell create information
The serial port outputs the cell create-! The following is carried out Information.
And if it
echo 3>debug_level
Execution jailhouse cell create information
The serial port will not output cell create-! The following is carried out Information.
In summary, the invention provides a log method for dynamically setting log level debug jailmouse by a user through shell command, which controls log opening and closing of a specific level log by dynamically controlling log opening and closing of jailmouse by the user; according to the invention, log level debug jailouse can be dynamically set in a user layer, one-time log addition and one-time compiling are realized, whether the log is output or not is permanently controlled, the complexity that the original log system of the jailouse needs to be recompiled and installed each time of output and closing is changed, and the working efficiency is increased.
Although the present invention has been described with reference to the above preferred embodiments, it should be understood that the present invention is not limited to the above embodiments, and that various changes and modifications can be made herein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (4)

1. The method for debugging the debug jailhouse by dynamically setting the log level is characterized by comprising the following steps:
step S1: the jailhouse driving layer adds an attr attribute, and the value of the attr attribute is used for a user to dynamically read or set in a user space; after the driver layer detects a change in the value of the attr attribute, the value of the attr attribute is passed to the hyperserver layer of the jailhouse using hvc command;
step S2: and modifying a log printing mechanism of the hypervisor, increasing the printing level, and printing the log corresponding to the corresponding log level only when the current log level is smaller than the attribute value of the incoming attr.
2. The method for debugging the debug jailhouse by dynamically setting log level according to claim 1, wherein said step S1 comprises the steps of:
step S11: defining a global variable in main.c to store log levels set by a user and setting a default value;
step S12: adding a readable and writable attr attribute node in the sysfs.c file;
step S13: implementing the reading function of the attr attribute node;
step S14: an add hvc command, passing the value of the attr attribute to the hypervisor layer;
step S15: the write function of the attribute node is implemented and the set log level is passed into the hypervisor layer through the hvc command of the jailhouse package.
3. The method for debugging the debug jailhouse by dynamically setting the log level according to claim 2, wherein said step S2 comprises the steps of:
step S21: the hypervisor layer receives the debug_level value transmitted by the driving layer;
step S22: increasing the print function containing log levels;
step S23: defining printing functions of different grades;
step S24: different printing functions are selected as required.
4. The method for debugging the debug jailhouse by dynamically setting log levels according to claim 3, wherein said step S2 further comprises:
step S25: automatically generating a property file under a/sys/devices/jailhouse directory, and checking the value of the property file through a cat debug_level command;
step S26: an echo n > debug_level command sets a log level of desired printing, where n is the set log level of desired printing.
CN202310113265.1A 2023-02-14 2023-02-14 Method for debugging debug jailhouse by dynamically setting log level Pending CN116340035A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310113265.1A CN116340035A (en) 2023-02-14 2023-02-14 Method for debugging debug jailhouse by dynamically setting log level

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310113265.1A CN116340035A (en) 2023-02-14 2023-02-14 Method for debugging debug jailhouse by dynamically setting log level

Publications (1)

Publication Number Publication Date
CN116340035A true CN116340035A (en) 2023-06-27

Family

ID=86883011

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310113265.1A Pending CN116340035A (en) 2023-02-14 2023-02-14 Method for debugging debug jailhouse by dynamically setting log level

Country Status (1)

Country Link
CN (1) CN116340035A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118227397A (en) * 2024-05-22 2024-06-21 湖北芯擎科技有限公司 Multi-platform BootROM test method and device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118227397A (en) * 2024-05-22 2024-06-21 湖北芯擎科技有限公司 Multi-platform BootROM test method and device

Similar Documents

Publication Publication Date Title
US9996396B2 (en) Cross architecture virtual machine migration
US9396013B2 (en) Method for controlling a virtual machine and a virtual machine system
US8024742B2 (en) Common program for switching between operation systems is executed in context of the high priority operating system when invoked by the high priority OS
Mergen et al. Virtualization for high-performance computing
EP1594052B1 (en) VEX - Virtual extension framework
US9619279B2 (en) Operating systems sharing supervisor address space with same virtual to physical mapping for supervisor address space using same translation formula with different translation tree
US8201170B2 (en) Operating systems are executed on common program and interrupt service routine of low priority OS is modified to response to interrupts from common program only
US7275028B2 (en) System and method for the logical substitution of processor control in an emulated computing environment
Williams et al. Unikernel monitors: extending minimalism outside of the box
US8091086B1 (en) System and method for virtualization using an open bus hypervisor
US20070074223A1 (en) Operating systems
Armand et al. A practical look at micro-kernels and virtual machine monitors
JP2010521034A (en) How to abstract an operating environment from an operating system
US11693722B2 (en) Fast memory mapped IO support by register switch
CN114721719B (en) Method and system for containerized deployment of heterogeneous applications in cluster
CN116340035A (en) Method for debugging debug jailhouse by dynamically setting log level
US20050246708A1 (en) Method of assigning virtual process identifier to process within process domain
EP1616257B1 (en) Operating systems
EP1410170A2 (en) Logical substitution of processor control in an emulated computing environment
CA2540490A1 (en) Operating systems
US20230350710A1 (en) Fast memory mapped io support by register switch
Costa VirtIO infrastructure for a static partition hypervisor: VirtIO-Net
Ribeiro VirtIO infrastructure for a static partition hypervisor: virtio-blk and virtio-console
Felizzi Trianqles: Porting Qubes to seL4
Galowicz et al. Migration zur Laufzeit von virtuellen Maschinen zwischen heterogenen Hostsystemen

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination