[go: up one dir, main page]

CN116661945A - Virtual machine management method, system, electronic device and storage medium - Google Patents

Virtual machine management method, system, electronic device and storage medium Download PDF

Info

Publication number
CN116661945A
CN116661945A CN202310583140.5A CN202310583140A CN116661945A CN 116661945 A CN116661945 A CN 116661945A CN 202310583140 A CN202310583140 A CN 202310583140A CN 116661945 A CN116661945 A CN 116661945A
Authority
CN
China
Prior art keywords
virtual machine
pseudo
terminal
log
serial port
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
CN202310583140.5A
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.)
Huizhou Desay SV Intelligent Transport Technology Research Institute Co Ltd
Original Assignee
Huizhou Desay SV Intelligent Transport Technology Research Institute 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 Huizhou Desay SV Intelligent Transport Technology Research Institute Co Ltd filed Critical Huizhou Desay SV Intelligent Transport Technology Research Institute Co Ltd
Priority to CN202310583140.5A priority Critical patent/CN116661945A/en
Publication of CN116661945A publication Critical patent/CN116661945A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45591Monitoring or debugging support
    • 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)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本申请提供一种虚拟机管理方法,系统,电子设备及存储介质;所述虚拟机管理方法包括:启动虚拟机监视器,并创建第一伪终端和第二伪终端,同时所述虚拟机监视器启动虚拟机,使虚拟机在所述第一伪终端上运行;然后虚拟机向所述第一伪终端输出串口日志,第一伪终端向第二伪终端输出所述串口日志,所述虚拟机监视器监听所述第二伪终端的日志输入状态,当监听到所述第二伪终端接收到所述串口日志时,通过所述虚拟机监视器读取并存储所述串口日志。本申请通过虚拟机监视器获取到的串口日志,可以实现在虚拟机出现问题时,根据所述串口日志及时解决问题,以节省问题定位时间,提高问题定位效率,使项目交付可以得到保障。

The present application provides a virtual machine management method, system, electronic equipment, and storage medium; the virtual machine management method includes: starting a virtual machine monitor, and creating a first pseudo-terminal and a second pseudo-terminal, while the virtual machine monitors The virtual machine starts the virtual machine, so that the virtual machine runs on the first pseudo-terminal; then the virtual machine outputs the serial port log to the first pseudo-terminal, the first pseudo-terminal outputs the serial port log to the second pseudo-terminal, and the virtual The machine monitor monitors the log input status of the second pseudo-terminal, and when it detects that the second pseudo-terminal has received the serial port log, it reads and stores the serial port log through the virtual machine monitor. The application uses the serial port logs obtained by the virtual machine monitor to solve problems in a timely manner according to the serial port logs when problems occur in the virtual machine, so as to save problem location time, improve problem location efficiency, and ensure project delivery.

Description

虚拟机管理方法,系统,电子设备及存储介质Virtual machine management method, system, electronic device and storage medium

技术领域technical field

本申请涉及虚拟机设置领域,特别涉及一种虚拟机管理方法,系统,电子设备及存储介质。The present application relates to the field of virtual machine setting, and in particular to a virtual machine management method, system, electronic equipment and storage medium.

背景技术Background technique

Hypervisor是一种虚拟机监视器,是创建或运行虚拟机的载体。虚拟机监视器上运行着至少一个虚拟机,该虚拟机被称为客户机;所述虚拟机监视器则运行在计算机上,该计算机可以被称为主机。所述虚拟机监视器用于为客户操作系统创造一个虚拟的操作系统,以对各客户操作系统的运行进行管理。并且各客户操作系统可以共享虚拟化的硬件资源,使不同的客户操作系统能够在一个计算机上运行,且可以同时共享一个内核;其中,所述客户操作系统可以是Linux、Windows或MacOS。A hypervisor is a virtual machine monitor and a carrier for creating or running virtual machines. At least one virtual machine runs on the virtual machine monitor, and the virtual machine is called a client; the virtual machine monitor runs on a computer, and the computer can be called a host. The virtual machine monitor is used to create a virtual operating system for the guest operating systems, so as to manage the operation of each guest operating system. And each guest operating system can share virtualized hardware resources, so that different guest operating systems can run on one computer, and can share a kernel at the same time; wherein, the guest operating systems can be Linux, Windows or MacOS.

在新兴中控系统中,仪表和娱乐系统是运行在同一套硬件上的,并由虚拟机监视器统一管理。但是,目前虚拟机监视器在启动虚拟机后,无法监控虚拟机,也无法获取虚拟机日志。在虚拟机出现问题时,虚拟机监视器无法及时解决。In the emerging central control system, the instrument and the entertainment system run on the same set of hardware and are managed by a virtual machine monitor. However, currently, the virtual machine monitor cannot monitor the virtual machine after starting the virtual machine, and cannot obtain the virtual machine log. When there is a problem with the virtual machine, the virtual machine monitor cannot solve it in time.

发明内容Contents of the invention

本申请为解决上述技术问题,提供一种虚拟机管理方法,系统,电子设备及存储介质,通过在虚拟机监视器启动后启动虚拟机,实现虚拟机向第一伪终端输出串口日志,以及第一伪终端向第二伪终端输出所述串口日志,以根据所述虚拟机监视器监听到的所述第二伪终端的日志输入状态,完成第二伪终端对所述串口日志的读取和存储。In order to solve the above technical problems, the present application provides a virtual machine management method, system, electronic equipment and storage medium. By starting the virtual machine after the virtual machine monitor is started, the virtual machine can output serial port logs to the first pseudo-terminal, and the second A pseudo-terminal outputs the serial port log to the second pseudo-terminal, so as to complete the reading and processing of the serial port log by the second pseudo-terminal according to the log input status of the second pseudo-terminal monitored by the virtual machine monitor storage.

具体的,本申请提供一种虚拟机管理方法,包括以下步骤:Specifically, the present application provides a virtual machine management method, including the following steps:

S10:虚拟机监视器完成启动后,启动虚拟机。S10: After the virtual machine monitor finishes starting, start the virtual machine.

S20:所述虚拟机自动向第一伪终端输出串口日志,所述第一伪终端将所述串口日志输出至第二伪终端。S20: The virtual machine automatically outputs the serial port log to the first pseudo-terminal, and the first pseudo-terminal outputs the serial port log to the second pseudo-terminal.

S30:当所述第二伪终端接收到所述串口日志时,所述虚拟机监视器读取并存储所述串口日志。S30: When the second pseudo-terminal receives the serial port log, the virtual machine monitor reads and stores the serial port log.

通过上述方法可以实现读取虚拟机的串口日志,以在虚拟机出现问题时,虚拟机监视器可以根据所述串口日志及时解决问题。The above method can be used to read the serial port log of the virtual machine, so that when a problem occurs in the virtual machine, the virtual machine monitor can solve the problem in time according to the serial port log.

所述步骤S10,还包括:通过所述虚拟机监视器创建第一伪终端和第二伪终端,并在第一伪终端上启动和运行虚拟机;第一伪终端和第二伪终端是一对提供双向通信通道的虚拟字符设备;第一伪终端提供了一个接口,在第二伪终端写入的任何内容都会传输给打开第一伪终端的第一应用程序;写入第一伪终端的任何内容也都可以被连接到第二伪终端的第二应用程序读取。The step S10 further includes: creating a first pseudo-terminal and a second pseudo-terminal through the virtual machine monitor, and starting and running a virtual machine on the first pseudo-terminal; the first pseudo-terminal and the second pseudo-terminal are a For a virtual character device that provides a two-way communication channel; the first pseudo-terminal provides an interface, and any content written in the second pseudo-terminal will be transmitted to the first application program that opens the first pseudo-terminal; writing to the first pseudo-terminal Any content can also be read by a second application connected to the second pseudo-terminal.

创建第一伪终端和第二伪终端,使得虚拟机的串口日志借由第一伪终端输出至第二伪终端,并且所述第二伪终端连接了第二应用程序,实现串口日志可以通过所述第二应用程序进行读取。Create the first pseudo-terminal and the second pseudo-terminal, so that the serial port log of the virtual machine is output to the second pseudo-terminal through the first pseudo-terminal, and the second pseudo-terminal is connected to the second application program, so that the serial port log can be passed through the the second application to read it.

所述步骤S20,还包括:所述虚拟机监视器通过所述第二应用程序监听所述第二伪终端的日志输入状态;所述日志输入状态包括第一状态和第二状态。The step S20 further includes: the virtual machine monitor monitors the log input status of the second pseudo-terminal through the second application program; the log input status includes a first status and a second status.

通过第二应用程序监听第二伪终端的日志输入状态,以确定串口日志是否从第一伪终端正常输出。The log input status of the second pseudo-terminal is monitored through the second application program to determine whether the serial log is normally output from the first pseudo-terminal.

当所述日志输入状态为第一状态时,判定当前第二伪终端已接收到所述串口日志,通过所述虚拟机监视器读取并存储所述串口日志;当所述日志输入状态为第二状态时,判定当前第二伪终端未接收到所述串口日志,所述虚拟机监视器继续通过所述第二应用程序监听所述第二伪终端的日志输入状态。When the log input state is the first state, it is determined that the current second pseudo-terminal has received the serial port log, and the serial port log is read and stored by the virtual machine monitor; when the log input state is the second In the second state, it is determined that the second pseudo-terminal has not received the serial port log, and the virtual machine monitor continues to monitor the log input status of the second pseudo-terminal through the second application program.

日志输入状态包括两个,第一状态表示第二伪终端有数据可读,串口日志输入正常,而第二状态则表示第二伪终端无数据可读,串口日志未从第一伪终端输出至第二伪终端,属于数据阻塞状态;通过监听日志输入状态,可以确定第二伪终是否有数据可读,以实现进一步的读取和存储串口日志。The log input status includes two. The first status indicates that the second pseudo-terminal has data to read, and the serial port log input is normal, while the second status indicates that the second pseudo-terminal has no data to read, and the serial port log is not output from the first pseudo-terminal to The second pseudo-terminal belongs to the data blocking state; by monitoring the log input status, it can be determined whether the second pseudo-terminal has data readable, so as to realize further reading and storage of serial port logs.

基于同一发明构思,本申请还提供一种虚拟机串口日志读取系统,所述系统包括:Based on the same inventive concept, the present application also provides a virtual machine serial port log reading system, the system comprising:

启动模块:用于在虚拟机监视器完成启动后,启动虚拟机。Startup module: used to start the virtual machine after the virtual machine monitor finishes starting.

第一输出模块:用于虚拟机自动向第一伪终端输出串口日志。The first output module: used for the virtual machine to automatically output serial port logs to the first pseudo-terminal.

第二输出模块:用于所述第一伪终端向第二伪终端输出所述串口日志。The second output module: used for the first pseudo-terminal to output the serial log to the second pseudo-terminal.

读取模块:用于当所述第二伪终端接收到所述串口日志时,所述虚拟机监视器通过所述第二应用程序读取所述串口日志,并将其进行存储。A reading module: used for, when the second pseudo-terminal receives the serial port log, the virtual machine monitor reads the serial port log through the second application program and stores it.

所述系统还包括:The system also includes:

创建模块:用于创建所述第一伪终端和第二伪终端。Creation module: used to create the first pseudo-terminal and the second pseudo-terminal.

监听模块:用于所述虚拟机监视器通过所述第二应用程序监听所述第二伪终端的日志输入状态;所述日志输入状态包括第一状态和第二状态;当所述日志输入状态为第一状态时,转入所述读取模块;当所述日志输入状态为第二状态时,所述虚拟机监视器继续通过所述第二应用程序监听所述第二伪终端的日志输入状态。Monitoring module: used for the virtual machine monitor to monitor the log input state of the second pseudo-terminal through the second application program; the log input state includes a first state and a second state; when the log input state When it is the first state, transfer to the reading module; when the log input state is the second state, the virtual machine monitor continues to monitor the log input of the second pseudo-terminal through the second application program state.

通过上述系统可以实现对串口日志的读取和存储,以在虚拟机出现问题时,虚拟机监视器可以根据读取的串口日志及时解决问题。The reading and storage of serial port logs can be realized through the above system, so that when a problem occurs in the virtual machine, the virtual machine monitor can solve the problem in time according to the read serial port log.

基于同一发明构思,本申请还提供一种电子设备,包括:存储器和处理器,所述存储器和所述处理器之间互相通信连接,所述存储器中存储有计算机指令,所述处理器通过执行所述计算机指令,从而执行所述虚拟机管理方法。Based on the same inventive concept, the present application also provides an electronic device, including: a memory and a processor, the memory and the processor are connected to each other in communication, and computer instructions are stored in the memory, and the processor executes the The computer instructs to execute the virtual machine management method.

基于同一发明构思,本申请还提供一种存储介质,为计算机可读存储介质中的一种,所述计算机可读存储介质存储有计算机指令,所述计算机指令用于使计算机执行所述虚拟机管理方法。Based on the same inventive concept, the present application also provides a storage medium, which is one of the computer-readable storage media, and the computer-readable storage medium stores computer instructions, and the computer instructions are used to make the computer execute the virtual machine Management method.

与现有技术相比,本申请的有益效果在于:Compared with the prior art, the beneficial effects of the present application are:

本申请通过虚拟机监视器获取到的串口日志,可以实现在虚拟机出现问题时,根据所述串口日志及时解决问题,以节省问题定位时间,提高问题定位效率,使项目交付可以得到保障;解决了现有技术中的虚拟机监视器在启动虚拟机后,无法监控虚拟机,也无法获取虚拟机日志;以致在虚拟机出现问题时,虚拟机监视器无法及时解决的技术问题。The serial port log obtained by the application through the virtual machine monitor can realize that when a problem occurs in the virtual machine, the problem can be solved in time according to the serial port log, so as to save the problem location time, improve the problem location efficiency, and ensure the project delivery; solve After starting the virtual machine, the virtual machine monitor in the prior art cannot monitor the virtual machine, and cannot obtain the virtual machine log; so that when a problem occurs in the virtual machine, the virtual machine monitor cannot solve the technical problem in time.

附图说明Description of drawings

图1为本申请所述的虚拟机管理方法的流程图。FIG. 1 is a flow chart of the virtual machine management method described in this application.

图2为图1所述的虚拟机管理方法的系统框架图。FIG. 2 is a system frame diagram of the virtual machine management method described in FIG. 1 .

具体实施方式Detailed ways

本申请实施例提供一种虚拟机管理方法,系统,电子设备及存储介质;以解决现有技术中的虚拟机监视器在启动虚拟机后,无法监控虚拟机,也无法获取虚拟机日志;以致在虚拟机出现问题时,虚拟机监视器无法及时解决的技术问题。The embodiment of the present application provides a virtual machine management method, system, electronic equipment and storage medium; to solve the problem that the virtual machine monitor in the prior art cannot monitor the virtual machine after starting the virtual machine, and cannot obtain the virtual machine log; so that When there is a problem with the virtual machine, the technical problem that the virtual machine monitor cannot solve in time.

本申请技术方案提供一种虚拟机管理方法,总体思路如下:The technical solution of this application provides a virtual machine management method, the general idea is as follows:

启动虚拟机监视器,并创建第一伪终端和第二伪终端,同时所述虚拟机监视器启动虚拟机,使虚拟机在所述第一伪终端上运行;然后虚拟机向所述第一伪终端输出串口日志,第一伪终端向第二伪终端输出所述串口日志,所述虚拟机监视器监听所述第二伪终端的日志输入状态,当监听到所述第二伪终端接收到所述串口日志时,通过所述虚拟机监视器读取并存储所述串口日志。Start a virtual machine monitor, and create a first pseudo-terminal and a second pseudo-terminal, and at the same time, the virtual machine monitor starts a virtual machine so that the virtual machine runs on the first pseudo-terminal; then the virtual machine sends to the first pseudo-terminal The pseudo-terminal outputs the serial port log, the first pseudo-terminal outputs the serial port log to the second pseudo-terminal, the virtual machine monitor monitors the log input status of the second pseudo-terminal, and when the second pseudo-terminal receives the When the serial port log is used, the virtual machine monitor is used to read and store the serial port log.

下面结合具体实施例及附图对本申请的一种虚拟机管理方法,系统,电子设备及存储介质,作进一步详细描述。A virtual machine management method, system, electronic device, and storage medium of the present application will be further described in detail below in conjunction with specific embodiments and accompanying drawings.

如图1所示,本申请技术方案提供一种虚拟机管理方法,包括以下步骤:As shown in Figure 1, the technical solution of the present application provides a virtual machine management method, including the following steps:

S10:虚拟机监视器完成启动后,启动虚拟机。S10: After the virtual machine monitor finishes starting, start the virtual machine.

还包括:通过所述虚拟机监视器创建第一伪终端和第二伪终端,使所述虚拟机在第一伪终端上运行;其中,第一伪终端例如为从属伪终端,第二伪终端例如为主控伪终端。It also includes: creating a first pseudo-terminal and a second pseudo-terminal through the virtual machine monitor, so that the virtual machine runs on the first pseudo-terminal; wherein, the first pseudo-terminal is, for example, a subordinate pseudo-terminal, and the second pseudo-terminal For example, the master pseudo-terminal.

具体的,虚拟机监视器完成启动后,创建第一伪终端和第二伪终端,并在第一伪终端上启动和运行虚拟机。Specifically, after the virtual machine monitor is started, a first pseudo-terminal and a second pseudo-terminal are created, and the virtual machine is started and run on the first pseudo-terminal.

其中,第一伪终端和第二伪终端是一对提供双向通信通道的虚拟字符设备。第一伪终端提供了一个行为类似于传统终端的接口,在第二伪终端写入的任何内容都会传输给打开第一伪终端的第一应用程序;写入第一伪终端的任何内容也都可以被连接到第二伪终端的第二应用程序读取。Among them, the first pseudo-terminal and the second pseudo-terminal are a pair of virtual character devices that provide a two-way communication channel. The first pseudo-terminal provides an interface that behaves like a traditional terminal. Anything written in the second pseudo-terminal is transmitted to the first application that opened the first pseudo-terminal; Can be read by a second application connected to a second pseudo-terminal.

所述虚拟字符设备可以认为是虚拟设备和字符设备的结合,在计算机上是一种可以由多个进程共用的设备,并且字节只能一个一个读取,读取数据需要按照先后顺序进行。The virtual character device can be considered as a combination of a virtual device and a character device. It is a device that can be shared by multiple processes on a computer, and the bytes can only be read one by one, and the data must be read in sequence.

虚拟机通过第一应用程序打开第一伪终端,并将虚拟机和第一伪终端相连,使得虚拟机可以在第一伪终端上运行;第二应用程序连接第二伪终端,所述第二应用程序可以监控第二伪终端的日志输入状态,也可以读取写入第一伪终端并传输至第二伪终端的串口日志;所述第二应用程序例如为monitor程序。The virtual machine opens the first pseudo-terminal through the first application, and connects the virtual machine to the first pseudo-terminal, so that the virtual machine can run on the first pseudo-terminal; the second application connects to the second pseudo-terminal, and the second The application program can monitor the log input status of the second pseudo-terminal, and can also read the serial log written in the first pseudo-terminal and transmitted to the second pseudo-terminal; the second application program is, for example, a monitor program.

S20:所述虚拟机自动向第一伪终端输出串口日志,所述第一伪终端将所述串口日志输出至第二伪终端。S20: The virtual machine automatically outputs the serial port log to the first pseudo-terminal, and the first pseudo-terminal outputs the serial port log to the second pseudo-terminal.

还包括:所述虚拟机监视器通过所述第二应用程序监听所述第二伪终端的日志输入状态;所述日志输入状态包括第一状态和第二状态。It also includes: the virtual machine monitor monitors the log input status of the second pseudo-terminal through the second application program; the log input status includes a first status and a second status.

需要说明的是,所述第一状态为ready状态,第二状态为block状态。It should be noted that the first state is a ready state, and the second state is a block state.

其中,所述ready状态表示当前主控伪终端有数据可读,这些可读数据就是从所述从属伪终端传送过来的串口日志数据;block状态表示当前主控伪终端无数据可读,属于数据阻塞状态。Wherein, the ready state indicates that the current master control pseudo-terminal has data readable, and these readable data are the serial port log data transmitted from the slave pseudo-terminal; the block state indicates that the current master control pseudo-terminal has no data to read, which belongs to the data blocked state.

具体的,所述虚拟机自动向从属伪终端输出串口日志,所述从属伪终端将所述串口日志输出至主控伪终端。Specifically, the virtual machine automatically outputs the serial port log to the slave pseudo-terminal, and the slave pseudo-terminal outputs the serial port log to the master pseudo-terminal.

需要说明的是,因为虚拟机的串口日志会输出到系统的默认终端上,而虚拟机在从属伪终端上运行,所以系统的默认终端为从属伪终端;因此,虚拟机的串口日志会输出到从属伪终端上。It should be noted that because the serial port log of the virtual machine will be output to the default terminal of the system, and the virtual machine runs on the slave pseudo-terminal, the default terminal of the system is the slave pseudo-terminal; therefore, the serial port log of the virtual machine will be output to on the slave pseudo-terminal.

其中,所述串口日志为Android系统日志,但并不是只限制于此。Wherein, the serial port log is an Android system log, but not limited thereto.

S30:当所述第二伪终端接收到所述串口日志时,所述虚拟机监视器读取并存储所述串口日志。S30: When the second pseudo-terminal receives the serial port log, the virtual machine monitor reads and stores the serial port log.

具体的,当所述日志输入状态为第一状态时,判定当前第二伪终端已接收到所述串口日志,通过所述虚拟机监视器读取并存储所述串口日志。Specifically, when the log input state is the first state, it is determined that the second pseudo-terminal has received the serial port log, and the serial port log is read and stored by the virtual machine monitor.

当所述日志输入状态为第二状态时,判定当前第二伪终端未接收到所述串口日志,所述虚拟机监视器继续通过所述第二应用程序监听所述第二伪终端的日志输入状态。When the log input state is the second state, it is determined that the current second pseudo-terminal has not received the serial port log, and the virtual machine monitor continues to monitor the log input of the second pseudo-terminal through the second application program state.

如图2所示,本申请技术方案还提供一种虚拟机串口日志读取系统,所述系统包括:As shown in Figure 2, the technical solution of the present application also provides a virtual machine serial port log reading system, the system comprising:

启动模块:用于在虚拟机监视器完成启动后,启动虚拟机。Startup module: used to start the virtual machine after the virtual machine monitor finishes starting.

第一输出模块:用于虚拟机自动向第一伪终端输出串口日志。The first output module: used for the virtual machine to automatically output serial port logs to the first pseudo-terminal.

第二输出模块:用于所述第一伪终端向第二伪终端输出所述串口日志。The second output module: used for the first pseudo-terminal to output the serial log to the second pseudo-terminal.

其中,第一伪终端为从属伪终端,第二伪终端为主控伪终端。Wherein, the first pseudo-terminal is a slave pseudo-terminal, and the second pseudo-terminal is a master pseudo-terminal.

需要说明的是,从属伪终端和主控伪终端是一对提供双向通信通道的虚拟字符设备,可以将二者统称为伪终端;其中,从属伪终端对应/dev/pts/目录下的一个文件,而主控伪终端则在内存中标识为一个文件描述符(fd)。伪终端由终端模拟器提供,终端模拟器是一个运行在用户态的应用程序。It should be noted that the slave pseudo-terminal and the master pseudo-terminal are a pair of virtual character devices that provide two-way communication channels, and they can be collectively referred to as pseudo-terminals; among them, the slave pseudo-terminal corresponds to a file in the /dev/pts/ directory , while the master pseudo-terminal is identified in memory as a file descriptor (fd). Pseudo-terminals are provided by a terminal emulator, which is an application running in user mode.

主控伪终端更接近用户显示器、键盘的一端,从属伪终端是在虚拟终端上运行的CLI(Command Line Interface,命令行接口)程序。Linux的伪终端驱动程序,会把主控伪终端(如键盘)写入的数据转发给从属伪终端供程序输入,把程序写入从属伪终端的数据转发给主控伪终端供显示器驱动等读取。The master pseudo-terminal is closer to the end of the user's monitor and keyboard, and the slave pseudo-terminal is a CLI (Command Line Interface, command line interface) program running on the virtual terminal. The Linux pseudo-terminal driver will forward the data written by the master pseudo-terminal (such as a keyboard) to the slave pseudo-terminal for program input, and forward the data written by the program to the slave pseudo-terminal to the master pseudo-terminal for display driver to read. Pick.

我们打开的终端桌面程序,比如GNOME Terminal,其实是一种终端模拟软件。当终端模拟软件运行时,它通过打开/dev/ptmx文件创建了一个伪终端的主控端和从属端对,并让 shell运行在从属端。当用户在终端模拟软件中按下键盘按键时,它产生字节流并写入主控端中,shell进程便可从从属端中读取输入;shell和它的子程序,将输出内容写入从属端中,由终端模拟软件负责将字符打印到窗口中。The terminal desktop program we open, such as GNOME Terminal, is actually a terminal emulation software. When the terminal emulation software is running, it creates a pseudo-terminal pair of master and slave by opening the /dev/ptmx file and letting the shell run on the slave. When the user presses a keyboard key in the terminal emulation software, it generates a byte stream and writes it to the master, and the shell process can read input from the slave; the shell and its subroutines write the output to the slave. On the slave side, the terminal emulation software is responsible for printing characters to the window.

读取模块:用于当所述第二伪终端接收到所述串口日志时,所述虚拟机监视器通过第二应用程序读取所述串口日志,并将其进行存储。A reading module: used for, when the second pseudo-terminal receives the serial port log, the virtual machine monitor reads the serial port log through a second application program and stores it.

所述系统还包括:The system also includes:

创建模块:用于通过虚拟机监视器创建所述第一伪终端和第二伪终端。A creation module: used to create the first pseudo-terminal and the second pseudo-terminal through a virtual machine monitor.

其中,在完成虚拟机监视器的启动后,就创建所述第一伪终端和第二伪终端,使得虚拟机启动时运行在所述第一伪终端上。Wherein, after the startup of the virtual machine monitor is completed, the first pseudo-terminal and the second pseudo-terminal are created, so that the virtual machine runs on the first pseudo-terminal when starting.

监听模块:用于所述虚拟机监视器通过第二应用程序监听所述第二伪终端的日志输入状态;所述日志输入状态包括第一状态和第二状态;当所述日志输入状态为第一状态时,转入所述读取模块;当所述日志输入状态为第二状态时,虚拟机监视器继续通过所述第二应用程序监听所述第二伪终端的日志输入状态。Monitoring module: used for the virtual machine monitor to monitor the log input state of the second pseudo-terminal through the second application program; the log input state includes the first state and the second state; when the log input state is the first In the first state, transfer to the reading module; when the log input state is in the second state, the virtual machine monitor continues to monitor the log input state of the second pseudo-terminal through the second application program.

其中,第一状态为ready状态,第二状态为block状态;当所述日志输入状态为ready状态时,转入所述读取模块;当所述日志输入状态为block状态时,继续监听所述第二伪终端的日志输入状态。Wherein, the first state is a ready state, and the second state is a block state; when the log input state is a ready state, transfer to the reading module; when the log input state is a block state, continue to monitor the The log input status of the second pseudo-terminal.

本申请技术方案还提供一种电子设备,包括:存储器和处理器,所述存储器和所述处理器之间互相通信连接,所述存储器中存储有计算机指令,所述处理器通过执行所述计算机指令,从而执行所述虚拟机管理方法。The technical solution of the present application also provides an electronic device, including: a memory and a processor, the memory and the processor are connected to each other in communication, the memory stores computer instructions, and the processor executes the instructions, so as to execute the virtual machine management method.

本申请实施例中的存储器用于存储各种类型的数据以支持电子设备的操作。这些数据的示例包括:用于在电子设备上操作的任何计算机程序。可以理解,存储器可以是易失性存储器或非易失性存储器,也可以包括易失性和非易失性存储器两者。The memory in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on an electronic device. It can be understood that the memory may be a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memory.

其中,非易失性存储器可以是只读存储器、可编程只读存储器、可擦除可编程只读存储器、电可擦除可编程只读存储器、磁性随机存取存储器、快闪存储器、磁表面存储器、光盘或只读光盘。Among them, the non-volatile memory can be read-only memory, programmable read-only memory, erasable programmable read-only memory, electrically erasable programmable read-only memory, magnetic random access memory, flash memory, magnetic surface memory, CD-ROM or CD-ROM.

易失性存储器可以是随机存取存储器、静态随机存取存储器、同步静态随机存取存储器、动态随机存取存储器、同步动态随机存取存储器、双倍数据速率同步动态随机存取存储器、增强型同步动态随机存取存储器、同步连接动态随机存取存储器或直接内存总线随机存取存储器。Volatile memory can be random access memory, static random access memory, synchronous static random access memory, dynamic random access memory, synchronous dynamic random access memory, double data rate synchronous dynamic random access memory, enhanced Synchronous DRAM, Synchronous Linked DRAM, or DMB RAM.

需要说明的是,本申请实施例描述的存储器旨在包括但不限于这些和任意其它适合类型的存储器。It should be noted that the memory described in the embodiments of the present application is intended to include but not limited to these and any other suitable types of memory.

上述本申请实施例揭示的方法可以应用于处理器中,或者由处理器实现。处理器可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。The methods disclosed in the foregoing embodiments of the present application may be applied to, or implemented by, a processor. A processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software.

上述的处理器可以是通用处理器,或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。处理器可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者任何常规的处理器等。处理器读取存储器中的计算机指令,处理器执行所述计算机指令时实现本申请实施例的各个方法中的相应流程,为了简洁,在此不再赘述。The above-mentioned processor may be a general-purpose processor, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and the like. The processor may implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. A general purpose processor may be a microprocessor or any conventional processor or the like. The processor reads the computer instructions in the memory, and when the processor executes the computer instructions, the corresponding processes in the various methods of the embodiments of the present application are implemented. For the sake of brevity, details are not repeated here.

本申请技术方案还提供一种存储介质,为计算机可读存储介质中的一种,所述计算机可读存储介质存储有计算机指令,所述计算机指令用于使计算机执行所述虚拟机管理方法。The technical solution of the present application also provides a storage medium, which is one of computer-readable storage media, where the computer-readable storage medium stores computer instructions, and the computer instructions are used to cause a computer to execute the virtual machine management method.

需要说明的是,上述计算机指令可由处理器执行,以完成前述方法所述步骤。计算机可读存储介质可以是FRAM、ROM、PROM、EPROM、EEPROM、Flash Memory、磁表面存储器、光盘、或CD-ROM等存储器。It should be noted that the above computer instructions can be executed by a processor to complete the steps in the foregoing method. The computer-readable storage medium may be memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disk, or CD-ROM.

综上所述,本申请提供一种虚拟机管理方法,系统,电子设备及存储介质;通过创建第一伪终端和第二伪终端,实现虚拟机向第一伪终端输出串口日志,以及第一伪终端向第二伪终端输出串口日志,以根据所述虚拟机监视器监听到的所述第二伪终端的日志输入状态,完成第二伪终端对所述串口日志的读取和存储。本申请通过获取到的串口日志,可以实现在虚拟机出现问题时,根据所述串口日志及时解决问题,以节省问题定位时间,提高问题定位效率,使项目交付可以得到保障。To sum up, the present application provides a virtual machine management method, system, electronic equipment, and storage medium; by creating a first pseudo-terminal and a second pseudo-terminal, the virtual machine can output serial port logs to the first pseudo-terminal, and the first The pseudo-terminal outputs the serial port log to the second pseudo-terminal, so as to complete the reading and storage of the serial port log by the second pseudo-terminal according to the log input status of the second pseudo-terminal monitored by the virtual machine monitor. Through the obtained serial port log, this application can solve the problem in time according to the serial port log when a problem occurs in the virtual machine, so as to save the problem location time, improve the problem location efficiency, and ensure the project delivery can be guaranteed.

尽管这里已经参考附图描述了示例实施例,应理解上述示例实施例仅仅是示例性的,并不意图将本申请的范围限制于此。本领域普通技术人员可以在其中进行各种改变和修改,而不偏离本申请的范围和精神。所有这些改变和修改意在被包括在所附权利要求所要求的本申请的范围之内。Although example embodiments have been described herein with reference to the accompanying drawings, it should be understood that the above-described example embodiments are exemplary only, and are not intended to limit the scope of the application thereto. Various changes and modifications can be made therein by those of ordinary skill in the art without departing from the scope and spirit of the application. All such changes and modifications are intended to be included within the scope of this application as claimed in the appended claims.

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those skilled in the art can appreciate that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may use different methods to implement the described functions for each specific application, but such implementation should not be regarded as exceeding the scope of the present application.

在本申请所提供的几个实施例中,应该理解到,所揭露的设备和方法,可以通过其它的方式实现。例如,以上所描述的设备实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个设备,或一些特征可以忽略,或不执行。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or May be integrated into another device, or some features may be omitted, or not implemented.

本申请的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本申请实施例的一些模块的一些或者全部功能。本申请还可以实现为用于执行这里所描述的方法的一部分或者全部的装置程序(例如,计算机程序和计算机程序产品)。这样的实现本申请的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。The various component embodiments of the present application may be realized in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art should understand that a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all functions of some modules according to the embodiments of the present application. The present application can also be implemented as an apparatus program (for example, a computer program and a computer program product) for performing a part or all of the methods described herein. Such a program implementing the present application may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet site, or provided on a carrier signal, or provided in any other form.

需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is a relationship between these entities or operations. There is no such actual relationship or order between them. Furthermore, the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus comprising a set of elements includes not only those elements, but also includes elements not expressly listed. other elements of or also include elements inherent in such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising said element.

虽然对本申请的描述是结合以上具体实施例进行的,但是,熟悉本技术领域的人员能够根据上述的内容进行许多替换、修改和变化是显而易见的。因此,所有这样的替代、改进和变化都包括在附后的权利要求的精神和范围内。Although the description of the present application is made in conjunction with the above specific embodiments, it is obvious that those skilled in the art can make many substitutions, modifications and changes based on the above contents. Accordingly, all such alternatives, modifications and changes are intended to be included within the spirit and scope of the appended claims.

Claims (10)

1. A method for virtual machine management, comprising the steps of:
s10: starting the virtual machine after the virtual machine monitor finishes starting;
s20: the virtual machine automatically outputs a serial port log to a first pseudo terminal, and the first pseudo terminal outputs the serial port log to a second pseudo terminal;
s30: and when the second pseudo terminal receives the serial port log, the virtual machine monitor reads and stores the serial port log.
2. The virtual machine management method according to claim 1, wherein the step S10 further comprises: creating a first pseudo terminal and a second pseudo terminal through the virtual machine monitor, and starting and operating a virtual machine on the first pseudo terminal; the first pseudo terminal and the second pseudo terminal are a pair of virtual character devices providing a bi-directional communication channel; the first pseudo terminal provides an interface, and any content written in the second pseudo terminal is transmitted to a first application program for opening the first pseudo terminal; any content written to the first pseudo terminal may also be read by a second application connected to the second pseudo terminal.
3. The virtual machine management method according to claim 2, wherein the step S20 further comprises: the virtual machine monitor monitors the log input state of the second pseudo terminal through the second application program; the log entry state includes a first state and a second state.
4. The virtual machine management method according to claim 3, wherein when the log input state is a first state, it is determined that the serial port log has been received by a current second pseudo terminal, and the virtual machine monitor reads and stores the serial port log through the second application program.
5. The method according to claim 4, wherein when the log input state is the second state, it is determined that the serial port log is not received by the current second pseudo terminal, and the virtual machine monitor continues to monitor the log input state of the second pseudo terminal.
6. A system employing the virtual machine management method of any one of claims 1-5, the system comprising:
and a starting module: the virtual machine monitor is used for starting the virtual machine after the virtual machine monitor is started;
a first output module: the virtual machine is used for automatically outputting a serial port log to the first pseudo terminal;
and a second output module: the serial port log is used for outputting the serial port log to a second pseudo terminal by the first pseudo terminal;
and a reading module: and the virtual machine monitor is used for reading the serial port log through a second application program and storing the serial port log when the second pseudo terminal receives the serial port log.
7. The system of claim 6, wherein the system further comprises:
the creation module: for creating the first and second pseudo terminals by the virtual machine monitor.
8. The system of claim 7, wherein the system further comprises:
monitoring module: the virtual machine monitor monitors the log input state of the second pseudo terminal through the second application program; the log entry state includes a first state and a second state;
when the log input state is the first state, transferring to the reading module;
and when the log input state is the second state, the virtual machine monitor continues to monitor the log input state of the second pseudo terminal through the second application program.
9. An electronic device, comprising: a memory and a processor, the memory and the processor being communicatively coupled to each other, the memory having stored therein computer instructions, the processor executing the computer instructions to perform the virtual machine management method of any of claims 1-5.
10. A storage medium, one of computer-readable storage media, wherein the computer-readable storage medium stores computer instructions for causing a computer to perform the virtual machine management method of any one of claims 1-5.
CN202310583140.5A 2023-05-23 2023-05-23 Virtual machine management method, system, electronic device and storage medium Pending CN116661945A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310583140.5A CN116661945A (en) 2023-05-23 2023-05-23 Virtual machine management method, system, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310583140.5A CN116661945A (en) 2023-05-23 2023-05-23 Virtual machine management method, system, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN116661945A true CN116661945A (en) 2023-08-29

Family

ID=87723498

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310583140.5A Pending CN116661945A (en) 2023-05-23 2023-05-23 Virtual machine management method, system, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN116661945A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119621612A (en) * 2025-02-13 2025-03-14 长扬科技(北京)股份有限公司 Communication method and device based on KVM virtual machine accessing host physical serial port

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100037220A1 (en) * 2008-08-05 2010-02-11 International Business Machines Corporation System and Method for Creating and Associating a Virtual Pseudo TTY with a Running Process
CN109347698A (en) * 2018-10-25 2019-02-15 北京凝思科技有限公司 User terminal operations order and echo message monitoring method under a kind of linux system
CN110764962A (en) * 2018-07-26 2020-02-07 武汉海康存储技术有限公司 Log processing method and device
CN113411206A (en) * 2021-05-26 2021-09-17 北京沃东天骏信息技术有限公司 Log auditing method, device, equipment and computer storage medium
CN115712540A (en) * 2022-11-17 2023-02-24 国电南瑞南京控制系统有限公司 Linux system terminal operation record real-time monitoring method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100037220A1 (en) * 2008-08-05 2010-02-11 International Business Machines Corporation System and Method for Creating and Associating a Virtual Pseudo TTY with a Running Process
CN110764962A (en) * 2018-07-26 2020-02-07 武汉海康存储技术有限公司 Log processing method and device
CN109347698A (en) * 2018-10-25 2019-02-15 北京凝思科技有限公司 User terminal operations order and echo message monitoring method under a kind of linux system
CN113411206A (en) * 2021-05-26 2021-09-17 北京沃东天骏信息技术有限公司 Log auditing method, device, equipment and computer storage medium
CN115712540A (en) * 2022-11-17 2023-02-24 国电南瑞南京控制系统有限公司 Linux system terminal operation record real-time monitoring method and device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119621612A (en) * 2025-02-13 2025-03-14 长扬科技(北京)股份有限公司 Communication method and device based on KVM virtual machine accessing host physical serial port

Similar Documents

Publication Publication Date Title
US9658941B2 (en) Methods and systems of function-specific tracing
CN107370622B (en) Method and system for multiplexing host machine MAC and IP by virtual machine
US10228993B2 (en) Data dump for a memory in a data processing system
US10394571B2 (en) Passing data from a host-based utility to a service processor
CN108509215B (en) System software replacing method and device, terminal equipment and storage medium
CN104216771B (en) The method for restarting and device of software program
CN115629843A (en) Cloud heterogeneous virtual digital simulation platform
CN105159703B (en) The method and system of factory reset
CN114371908A (en) Cloud application program operation method and device
CN114499945A (en) Intrusion detection method and device for virtual machine
US8973019B1 (en) Method and system for emulation of super speed devices in virtual machines
CN116661945A (en) Virtual machine management method, system, electronic device and storage medium
KR20200135138A (en) Method, device, apparatus, and medium for booting a virtual machine
WO2020000947A1 (en) Method, apparatus, and device for refreshing encapsulated bios data
US20130318142A1 (en) Remote card content management using synchronous server-side scripting
CN115292000B (en) Method, device and electronic device for dynamic migration of virtual machines
CN111190693B (en) Method and device for building cloud platform based on Kunpeng platform
CN117369938A (en) Data interaction method applied between host machine and virtual machine and host machine
CN114465902A (en) Method, system, equipment and medium for cloud host multi-network card management bond
US11513825B2 (en) System and method for implementing trusted execution environment on PCI device
US20250245015A1 (en) Processor Environment Architecture Agnostic Unified BIOS Memory Mapping Operation
TWI779630B (en) Systems and methods for storing debug information
CN116702129B (en) Safe calling method and device for power architecture running service code
CN115292140B (en) Method, apparatus and computer readable medium for monitoring system startup
CN115437561B (en) Method and system for reducing disk space occupied by virtualized image file

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