Method of debugging Jailhouse based on Qemu
Through the Qemu-based debugging method, the Jailhouse is debugged using the virtual serial port, which solves the problem of system crash during Jailhouse debugging, and achieves a more stable and efficient debugging process.
Patent Information
- Application Number
- CN202210408147.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-19
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2042-04-19
AI Technical Summary
Jailhouse debugging lacks a safe and effective method, which can easily cause system crashes during the debugging process, especially because the system crashes may occur when the device is reused.
Through the Qemu-based debugging method, a Qemu virtual machine is built, and two local pseudo-terminals pty are used as the two Qemu virtual serial ports to debug Jailhouse, which is used for error information debugging of Linux and Jailhouse respectively.
This method greatly reduces the time for embedded engineers to debug Jailhouse configuration files and system firmware, ensures system stability, and avoids the risk of system crashes.
Smart Images

Figure CN114924948B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software debugging, and in particular to a method for debugging Jailhouse based on Qemu. Background Art
[0002] Jailhouse is a Linux-based partition hypervisor. It is capable of running bare-metal applications or adapted operating systems other than Linux. To do this, it configures the CPU and device virtualization capabilities of the hardware platform so that these domains (herein referred to as "cells") do not interfere with each other in an unacceptable way.
[0003] Jailhouse is a virtualization technology that is strongly related to hardware. The software itself has only about 20,000 lines and is highly dependent on configuration files. When writing configuration files, the slightest carelessness will cause the system to crash, so the method of debugging Jailhouse is particularly important.
[0004] Jailhouse is currently in its infancy and lacks many functions, especially debugging technology. The official has not provided a safe and effective debugging method. Few people on the Internet are studying this.
[0005] Jailhouse debugging requires a serial port, and Linux boot information also requires a serial port. Jailhouse itself does not have the function of device reuse. When device reuse occurs between non-root cells or between root cells and non-root cells, the system may crash. Summary of the invention
[0006] In view of the above-mentioned shortcomings of the prior art, the present invention provides a method for debugging Jailhouse based on Qemu, so as to provide a safe and effective debugging method to avoid system freeze or crash.
[0007] To achieve the above objectives, the present invention is implemented through the following technical solutions:
[0008] The present invention provides a method for debugging Jailhouse based on Qemu, which is applied to a platform device with a Linux operating system. The method comprises the following steps:
[0009] S1. Get the Jailhouse source code from the Jailhouse open source official website and save it as local source code;
[0010] S2, download the container image;
[0011] S3, running the container image in the local source code to build a Qemu virtual machine;
[0012] S4. Modify the Qemu virtual machine startup script to ensure the normal operation of the Qemu virtual machine;
[0013] S5. Add the serial port parameters for debugging jailhouse in the startup command line parameters of the Qemu virtual machine;
[0014] S6. Execute the command to enable kvm nested virtualization;
[0015] S7, execute the Qemu virtual machine startup script to run the Qemu virtual machine;
[0016] S8. After the platform device is connected, the debugging information of the Jailhouse can be obtained.
[0017] Optionally, the following steps are also included before step S1:
[0018] Install the software for git, elfutils-libelf-devel, qemu-kvm, python3, and python3-pip.
[0019] Optionally, the following steps are also included before step S2:
[0020] Execute the export command to set the terminal proxy.
[0021] Optionally, the step S2 further specifically includes the following steps:
[0022] Use podman or docker tool to download the container image, where the container image includes the kas-isar image.
[0023] Optionally, the step S3 further specifically includes the following steps:
[0024] Install the podman tool;
[0025] Enter the local source code root directory;
[0026] Execute the podman run command to enter the container image:
[0027] Execute the unset command to delete the NO_PROXY environment variable;
[0028] Execute the export command to set the terminal proxy;
[0029] Execute the kas build command to build the Qemu virtual machine;
[0030] After waiting for the Qemu virtual machine to be built successfully, exit the container image.
[0031] Optionally, step S3 further includes the following steps:
[0032] During the process of building the Qemu virtual machine, execute iftop -B and top -d 1 commands outside the container image to view the progress of building the Qemu virtual machine.
[0033] Optionally, the step S4 further specifically includes the following steps:
[0034] Replace the qemu executable program path with the executable program path of the qemu-kvm;
[0035] Add VNC full network card listening port;
[0036] Add ssh debugging port.
[0037] Optionally, the step S4 further specifically includes the following steps:
[0038] The qemu execution program path is replaced with the execution program path of the qemu-kvm by the sed command;
[0039] Use the sed command to add the vnc full network card listening port, and replace serial vc with serial vc-vnc0.0.0.0:1;
[0040] Use the sed command to add the ssh debugging port and replace netdev=net with netdev=net0-netdevuser,id=net0,hostfwd=tcp::5555-:22.
[0041] Optionally, the serial port parameters in step S5 include: -chardev pty,id=cs0-device isa-serial,chardev=cs0,id=serial0 and / or -chardev pty,id=cs1-device isa-serial,chardev=cs1,id=serial1.
[0042] Optionally, the jailhouse debugging information described in step S8 is output through a serial port.
[0043] Compared with the prior art, the method for debugging Jailhouse based on Qemu provided by the present invention has the following advantages:
[0044] The method for debugging Jailhouse based on Qemu provided by this patent can greatly reduce the time spent by embedded engineers in debugging Jailhouse configuration files and system firmware. The present invention uses two local pseudo-terminals pty as two virtual serial ports of Qemu to debug Jailhouse, one of which is used for Linux error information debugging and the other is used for Jailhouse error information debugging, thus ensuring the stability of the system and preventing system crashes. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0046] Figure 1 A method for debugging Jailhouse based on Qemu is provided in one embodiment of the present invention. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] See also Figure 1 An embodiment of the present invention provides a method for debugging Jailhouse based on Qemu, which is applied to a platform device with a Linux operating system. The method includes the following steps:
[0049] S1. Get the Jailhouse source code from the Jailhouse open source official website and save it as local source code;
[0050] S2, download the container image;
[0051] S3, running the container image in the local source code to build a Qemu virtual machine;
[0052] S4. Modify the Qemu virtual machine startup script to ensure the normal operation of the Qemu virtual machine;
[0053] S5. Add the serial port parameters for debugging jailhouse in the startup command line parameters of the Qemu virtual machine;
[0054] S6. Execute the command to enable kvm nested virtualization;
[0055] S7, execute the Qemu virtual machine startup script to run the Qemu virtual machine;
[0056] S8. After the platform device is connected, the debugging information of the Jailhouse can be obtained.
[0057] Therefore, the method for debugging Jailhouse based on Qemu provided by this patent can greatly reduce the time spent by embedded engineers in debugging Jailhouse configuration files and system firmware. The present invention uses two local pseudo terminals pty as two virtual serial ports of Qemu to debug Jailhouse, one of which is used for Linux error information debugging, and the other is used for Jailhouse error information debugging, thereby ensuring the stability of the system and preventing system crashes.
[0058] Preferably, before step S1, the following step is also included: installing git, elfutils-libelf-devel, qemu-kvm, python3 and python3-pip software.
[0059] Preferably, before step S2, the method further includes the following step: executing an export instruction to set a terminal proxy.
[0060] Preferably, the step S2 further specifically includes the following steps: using podman or docker tool to download the container image, wherein the container image includes a kas-isar image.
[0061] like Figure 1 As shown, the step S3 further specifically includes the following steps:
[0062] Install the podman tool;
[0063] Enter the local source code root directory;
[0064] Execute the podman run command to enter the container image:
[0065] Execute the unset command to delete the NO_PROXY environment variable;
[0066] Execute the export command to set the terminal proxy;
[0067] Execute the kas build command to build the Qemu virtual machine;
[0068] After waiting for the Qemu virtual machine to be built successfully, exit the container image.
[0069] It should be noted that the specific command for kas build is: kas build / repo / kas.yml. The specific command for podman run is:
[0070] podman run -v`pwd`: / repo:ro -v`pwd`: / work:rw--workdir= / work-e USER_ID=0-e GROUP_ID=0--rm-tie TERM=xterm-e KAS_TARGET=mc:qemu-amd64-jailhouse-demo:demo-image-e SHELL= / bin / bash--privileged--pid=host--userns=keep-id--security-opt label=disable ghcr.io / siemens / kas / kas-isar:2.4 / bin / bash.
[0071] Preferably, step S3 also includes the following steps: in the process of building the Qemu virtual machine, executing iftop-B and top-d 1 commands outside the container image to view the progress of building the Qemu virtual machine.
[0072] Preferably, step S4 further specifically includes the following steps: replacing the qemu execution program path with the execution program path of the qemu-kvm; adding a vnc full network card listening port; and adding an ssh debugging port.
[0073] Preferably, step S4 further specifically includes the following steps: replacing the qemu execution program path with the qemu-kvm execution program path through the sed command; adding the vnc full network card listening port through the sed command, replacing serial vc with serial vc-vnc0.0.0.0:1; adding the ssh debugging port through the sed command, replacing netdev=net with netdev=net0-netdev user,id=net0,hostfwd=tcp::5555-:22.
[0074] Preferably, the serial port parameters in step S5 include: -chardev pty,id=cs0 -device isa-serial,chardev=cs0,id=serial0 and / or -chardev pty,id=cs1 -device isa-serial,chardev=cs1,id=serial1.
[0075] Preferably, the jailhouse debugging information in step S8 is output through a serial port.
[0076] It should be noted that the Qemu virtual machine startup script in step S4 is Figure 1 The start-qemu.sh file shown in FIG. 1 can be used to run the Qemu virtual machine in an x86 architecture environment through . / start-qemu.sh x86; after running the Qemu virtual machine, you can connect / dev / pty / 5 and / dev / pty / 6 according to the prompt. After connecting to / dev / pty / 5, you can see the debugging information of Jailhouse. After connecting to / dev / pty / 6, you can see the serial port output debugging information of Linux; in step S6, the command for opening the kvm nested virtualization feature is usually rmmod kvm_intel; modprobe kvm-intel nested=1.
[0077] In summary, compared with the prior art, the cloth drive system provided by the present invention has the following advantages: The method for debugging Jailhouse based on Qemu provided by this patent can greatly reduce the time spent by embedded engineers in debugging Jailhouse configuration files and system firmware. The present invention uses two local pseudo-terminals pty as two virtual serial ports of Qemu to debug Jailhouse, one of which is used for Linux error information debugging, and the other is used for Jailhouse error information debugging, which ensures the stability of the system and does not cause system crashes.
[0078] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements will not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for debugging Jailhouse based on Qemu, applied to a platform device with a Linux operating system, characterized in that: The method comprises the following steps: S1. Get the Jailhouse source code from the Jailhouse open source official website and save it as local source code; S2, download the container image; S3, running the container image in the local source code to build a Qemu virtual machine; S4. Modify the Qemu virtual machine startup script to ensure the normal operation of the Qemu virtual machine; S5. Add the serial port parameters for debugging jailhouse in the startup command line parameters of the Qemu virtual machine; S6. Execute the command to enable kvm nested virtualization; S7, execute the Qemu virtual machine startup script to run the Qemu virtual machine; S8. After the platform device is connected, the debugging information of the Jailhouse can be obtained; In step S5, two local pseudo terminals pty are used as two virtual serial ports of Qemu to debug Jailhouse, wherein one serial port is used for error information debugging of Linux, and the other serial port is used for error information debugging of Jailhouse.
2. The method for debugging Jailhouse based on Qemu according to claim 1, characterized in that: Before step S1, the following steps are also included: Install the software for git, elfutils-libelf-devel, qemu-kvm, python3, and python3-pip.
3. The method for debugging Jailhouse based on Qemu according to claim 1, characterized in that: Before step S2, the method further includes the following steps: Execute the export command to set the terminal proxy.
4. The method for debugging Jailhouse based on Qemu according to claim 1, characterized in that: The step S2 further specifically includes the following steps: Use podman or docker tool to download the container image, where the container image includes the kas-isar image.
5. The method for debugging Jailhouse based on Qemu according to claim 3, characterized in that: The step S3 further specifically comprises the following steps: Install the podman tool; Enter the local source code root directory; Execute the podman run command to enter the container image: Execute the unset command to delete the NO_PROXY environment variable; Execute the export command to set the terminal proxy; Execute the kas build command to build the Qemu virtual machine; After waiting for the Qemu virtual machine to be built successfully, exit the container image.
6. The method for debugging Jailhouse based on Qemu according to claim 1, characterized in that: Described step S3 also comprises the following steps: During the process of building the Qemu virtual machine, execute the iftop -B and top -d 1 commands outside the container image to view the progress of building the Qemu virtual machine.
7. The method for debugging Jailhouse based on Qemu according to claim 2, characterized in that: Described step S4 also specifically comprises the following steps: Replace the qemu executable program path with the executable program path of the qemu-kvm; Add VNC full network card listening port; Add ssh debugging port.
8. The method for debugging Jailhouse based on Qemu according to claim 7, characterized in that: The step S4 further specifically includes the following steps: Use the sed command to replace the qemu execution program path with the execution program path of the qemu-kvm; Use the sed command to add VNC listening ports for all network cards and replace serial vc with serial vc -vnc 0.0.0.0:1; Use the sed command to add the ssh debugging port and replace netdev=net with netdev=net0 -netdev user,id=net0,hostfwd=tcp::5555-:
22.
9. The method for debugging Jailhouse based on Qemu according to claim 1, characterized in that: The serial port parameters in step S5 include: -chardev pty,id=cs0 -device isa-serial,chardev=cs0,id=serial0 and / or -chardev pty,id=cs1 -device isa-serial,chardev=cs1,id=serial1.
10. The method for debugging Jailhouse based on Qemu according to claim 1, characterized in that: The jailhouse debugging information in step S8 is output through the serial port.
Citation Information
Patent Citations
Virtual machine automatic-starting control method under sun4v architecture
CN102622245A
Method and apparatus for implementing GSM support in android system
CN103916517A