CN110658998A - Qemu-based virtual machine disk thermal expansion method and device - Google Patents

Qemu-based virtual machine disk thermal expansion method and device Download PDF

Info

Publication number
CN110658998A
CN110658998A CN201910911806.9A CN201910911806A CN110658998A CN 110658998 A CN110658998 A CN 110658998A CN 201910911806 A CN201910911806 A CN 201910911806A CN 110658998 A CN110658998 A CN 110658998A
Authority
CN
China
Prior art keywords
virtual machine
disk
qemu
expansion
space
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.)
Granted
Application number
CN201910911806.9A
Other languages
Chinese (zh)
Other versions
CN110658998B (en
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.)
Shanghai Instrument Electric (group) Co Ltd Central Research Institute
Original Assignee
Shanghai Instrument Electric (group) Co Ltd Central Research Institute
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 Shanghai Instrument Electric (group) Co Ltd Central Research Institute filed Critical Shanghai Instrument Electric (group) Co Ltd Central Research Institute
Priority to CN201910911806.9A priority Critical patent/CN110658998B/en
Publication of CN110658998A publication Critical patent/CN110658998A/en
Application granted granted Critical
Publication of CN110658998B publication Critical patent/CN110658998B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0662Virtualisation aspects
    • G06F3/0665Virtualisation aspects at area level, e.g. provisioning of virtual or logical volumes

Abstract

The invention relates to a qemu-based method and a qemu-based device for thermal expansion of a virtual machine disk, which are applied to a virtual machine system, wherein a disk space is distributed to a virtual machine of the virtual machine system, the disk space comprises one or more disks and is distributed block storage, and the method comprises the following steps: starting a socket monitoring address to receive a disk space expansion instruction of a virtual machine; executing the disk space capacity expansion instruction of the virtual machine; and modifying the size of the disk space in the disk partition table of the virtual machine based on qemu to realize thermal expansion. Compared with the prior art, the invention has the advantages of simple thermal expansion mode, capacity expansion efficiency improvement and the like.

Description

Qemu-based virtual machine disk thermal expansion method and device
Technical Field
The invention relates to the technical field of virtual machines, in particular to a method and a device for thermal expansion of a disk of a virtual machine based on qemu.
Background
Users of the Windows operating system generally want sufficient space for their own C-disk, but the space of the computer C-disk used in practice is often not ideal enough. When the prior art solves this problem, it is usually to install a subregion instrument, for example subregion magic teacher, to realize expanding the volume C dish space.
This approach has certain limitations. Generally, another D partition is allocated next to the C partition, and when data is already stored in the D partition, the C partition can only be expanded by completely merging the C partition and the D partition, and because the D partition is a system partition, the system needs to be restarted to expand the partition. In the process of partition expansion, a large number of data files need to be moved, which is time-consuming.
Chinese patent application CN107479837A discloses a method for capacity expansion of a virtual machine in a cloud data system, comprising: receiving a request for expanding the capacity of a disk of a running virtual machine, wherein the capacity expansion request comprises the target size of disk capacity expansion; acquiring a virtual machine specification template of which the disk space meets the target size according to the target size of the disk expansion; and carrying out disk capacity expansion on the virtual machine by utilizing the virtual machine specification template. However, the method can only perform capacity expansion according to the preset specification template, still has the defect of troublesome operation, cannot solve the limitation of the prior art, and cannot meet the actual capacity expansion requirement.
Disclosure of Invention
The invention aims to overcome the defects in the prior art and provides a method and a device for thermal expansion of a disk of a virtual machine based on qemu.
The purpose of the invention can be realized by the following technical scheme:
a method for thermal expansion of a disk of a virtual machine based on qemu is applied to a virtual machine system, the virtual machine of the virtual machine system is distributed with a disk space, the disk space comprises one or more disks and is distributed block storage, and the method comprises the following steps:
starting a socket monitoring address to receive a disk space expansion instruction of a virtual machine;
executing the disk space capacity expansion instruction of the virtual machine;
and modifying the size of the disk space in the disk partition table of the virtual machine based on qemu to realize thermal expansion.
Further, the executing the disk space capacity expansion instruction of the virtual machine specifically includes:
and searching a host machine where the virtual machine is located through the name of the virtual machine, and executing the disk space expansion instruction of the virtual machine on the host machine.
Further, when the thermal expansion is realized, the size of the virtual machine space expansion is not greater than the total surplus of the distributed storage.
Further, the virtual machine comprises a qemu-guest-agent tool, and the qemu-guest-agent tool is used for modifying the size of the disk space in the disk partition table of the virtual machine.
Further, when the qemu-guest-agent tool is used for modifying the disk partition table of the virtual machine, different disk hot-expansion operation instructions are called according to different operating systems.
The invention also provides a qemu-based device for thermal expansion of a virtual machine disk, which is applied to a virtual machine system, wherein a disk space is distributed to a virtual machine of the virtual machine system, the disk space comprises one or more disks and is distributed block storage, and the device comprises:
the instruction receiving unit is used for starting a socket monitoring address to receive a disk space expansion instruction of the virtual machine;
the execution instruction unit is used for executing the disk space capacity expansion instruction of the virtual machine;
and the capacity expansion disk partition unit is used for modifying the size of the disk space in the disk partition table of the virtual machine based on qemu to realize thermal capacity expansion.
Further, the apparatus further comprises:
the scheduling instruction unit is used for searching the host machine where the virtual machine is located through the name of the virtual machine and transmitting the host machine where the virtual machine is located through the name of the virtual machine to the host machine;
and the execution instruction unit executes the disk space expansion instruction of the virtual machine on the host machine.
Further, when the thermal expansion is realized, the size of the virtual machine space expansion is not greater than the total surplus of the distributed storage.
Further, the virtual machine comprises a qemu-guest-agent tool, and the capacity expansion disk partition unit modifies the size of the disk space in the disk partition table of the virtual machine by using the qemu-guest-agent tool.
Further, the apparatus further comprises:
the judging operation system unit is used for judging the version of the virtual machine operation system by using the qemu-guest-agent tool and sending the version information of the operation system to the capacity expansion disk partition unit;
and the capacity expansion disk partition unit calls different disk hot capacity expansion operation instructions according to different operating system version information.
Compared with the prior art, the invention has the following beneficial effects:
1. the virtual machine disk is stored in the distributed block, the virtual machine disk is stored at the far end of the server and is not limited by the space capacity of the local disk of the host machine of the virtual machine, the virtual machine accesses the disk on the server through a network, the disk space is not required to be added with a blank space, the maximum threshold value of the partition table is directly modified, the disk space is expanded, and the thermal expansion mode is simple.
2. The invention avoids the problems of complex and time-consuming data file movement in the partition expansion process of the common Windows operating system at present.
3. The invention can realize the dynamic capacity expansion of the whole disk of the virtual machine or the target partition under the condition that the virtual machine is not shut down, and does not influence the use of other partitions behind the disk.
4. In the partition capacity expansion process, the data of the disk file in the virtual machine does not need to be moved, and the additional consumption of IO is reduced.
5. When the monitoring system monitors that the residual space capacity of the disk partition is insufficient, the thermal expansion is carried out on the virtual machine root disk through qemu, the problem that the root disk is full due to unreasonable occupation of disk resources is solved after the expansion of the virtual machine root disk is carried out in real time, a manual operation command of a system administrator is not needed in the whole process, the disk partition expansion efficiency is improved, and the technical effect of dynamically expanding the disk partition capacity is achieved.
Drawings
FIG. 1 is a schematic diagram of one embodiment of a thermal expansion method of the present invention;
FIG. 2 is a schematic diagram of root disk expansion according to an embodiment of the present invention;
fig. 3 is a schematic view of a thermal expansion device according to an embodiment of the present invention.
Detailed Description
The invention is described in detail below with reference to the figures and specific embodiments. The present embodiment is implemented on the premise of the technical solution of the present invention, and a detailed implementation manner and a specific operation process are given, but the scope of the present invention is not limited to the following embodiments.
Example 1
The embodiment provides a qemu-based method for thermally expanding a disk of a virtual machine, which is applied to a virtual machine system, wherein a disk space is distributed to a virtual machine of the virtual machine system, the disk space comprises one or more disks and is distributed block storage, the method receives and executes a disk space expansion instruction of the virtual machine, and the qemu modifies the size of the disk space in a disk partition table of the virtual machine to realize thermal expansion.
In one embodiment shown in fig. 1, a method for thermal disk expansion of a qemu-based virtual machine includes the following steps:
201. acquiring an instruction for expanding the disk space of the virtual machine, distributing a new disk space for a specified virtual machine disk, and searching a host machine where the virtual machine is located according to the name of the virtual machine;
202. the host dynamically expands the disk space of the virtual machine according to the issued instruction, the disk of the virtual machine uses distributed block storage, and the expansion size of the disk space of the virtual machine is not more than the total residual amount of the distributed block storage;
203. when the expanded disk space of the target partition is indexed in the partition table of the virtual machine disk, the size of the disk space in the partition table of the virtual machine disk is modified, and the disk space is expanded by directly modifying the maximum threshold value of the partition table without adding blank space to the disk space due to the fact that distributed block storage is used.
The virtual machine comprises a qemu-guest-agent tool, and the qemu-guest-agent tool is used for modifying the size of the disk space in the disk partition table of the virtual machine.
When the qemu-guest-agent tool is used for modifying the disk partition table of the virtual machine, different disk hot-expanding operation instructions are called according to different operating systems, wherein the different disk hot-expanding operation instructions comprise two major operating systems, namely Windows and Linux, and the Linux comprises a CentOS, a Ubuntu and a Suse operating system.
When virtual machine expansion is executed, a 'QEMU-Monitor-command' command of a virsh (command line management tool) is used for sending a command to a Monitor, before the virtual machine expansion is carried out, unix socket of QEMU-guest-agent needs to be started for the virtual machine, an external command can access files inside the virtual machine through setting of the QEMU Monitor and execute instructions inside the virtual machine, and control over the Monitor socket is added behind libvirt, so that operation can be carried out through the virsh command. The specific commands are as follows: the virtual qemu-monitor-command instance-00000001block _ rescued-virtual-disk 060G-hmp, wherein instance-00000001 is the name of a virtual machine domain, block _ rescize is a command for resetting the size of a block device, drive-virtual-disk 0 is the name of a block device with the reset size, and 60G is 60G after the size is reset.
According to the embodiment, the dynamic capacity expansion of the whole disk of the virtual machine or the target partition can be realized under the condition that the virtual machine is not shut down, the use of other partitions behind the virtual machine is not influenced, meanwhile, in the process of capacity expansion of the partitions, the data of disk files in the virtual machine does not need to be moved basically, and the additional consumption of IO is reduced.
As shown in the figure, for the expansion of the C partition, the maximum threshold value in the disk partition of the virtual machine is modified by modifying the capacity of the distributed storage partition; then simultaneously informing a qemu-guest-agent tool in the virtual machine; and modifying the partition table of the disk by qemu-guest-agent, formatting the file system and enlarging the size of the partition C. By the technical scheme, the dynamic expansion of the partition C can be realized under the condition that the virtual machine is not shut down, and the use of other subsequent partitions is not influenced. Meanwhile, in the process of partition expansion, except for reading and writing of the partition table and qcow2 metadata, the data of the disk file in the virtual machine does not need to be moved basically, and the additional consumption of IO is reduced.
For the capacity expansion of the whole virtual disk, firstly, the space of the virtual disk is expanded through a Qemu end; then, notifying qemu-guest-agent tools in the virtual machine; after the qemu-Guest-agent tool receives the additionally expanded disk space size, modifying a partition table of the disk, simultaneously informing a Guest operating system, and initializing a newly added space; the newly added space may then be merged into the last partition without shutting down the machine.
Example 2
This embodiment provides a device of virtual machine disk heat dilatation based on qemu, is applied to virtual machine system, and virtual machine of virtual machine system distributes there is the disk space, and the disk space is including one or polylith disk, for distributed block storage, and the device includes:
the instruction receiving unit is used for starting a socket monitoring address to receive a disk space expansion instruction of the virtual machine;
the scheduling instruction unit is used for searching the host machine where the virtual machine is located through the name of the virtual machine and transmitting the host machine where the virtual machine is located through the name of the virtual machine to the host machine;
the execution instruction unit is used for executing a disk space expansion instruction of the virtual machine on the host machine;
the judging operation system unit is used for judging the version of the virtual machine operation system by utilizing a qemu-guest-agent tool and sending the version information of the operation system to the capacity expansion disk partition unit;
and the capacity expansion disk partition unit is used for modifying the size of the disk space in the disk partition table of the virtual machine based on qemu to realize thermal capacity expansion.
And the judging operation system unit judges the file system of the virtual machine through the qemu-guest-agent tool, and executes different capacity expansion disk partition units aiming at different operation systems, wherein the different capacity expansion disk partition units comprise two large operation systems of Windows and Linux, and the Linux comprises a CentOS, a Ubuntu and a Suse operation system. Specifically, the qemu-guest-agent tool is used for operating a file system in the virtual machine system, reading the content in/etc/issue, if the read content is None, the version of the virtual machine operating system is Windows, if the read content contains a Ubuntu keyword, the operating system is Ubuntu, then the/etc/readhat-release file is read, if the content contains 6, the operating system is CentOS6, and if the content contains 7, the operating system is CentOS 7; and then different disk thermal expansion operations are respectively executed according to different operating systems.
In the capacity expansion disk partition unit, if the capacity expansion disk partition unit is Windows, a diskpart instruction is executed, and if the capacity expansion disk partition unit is Linux, a growth instruction is executed.
The terms "first," "second," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The foregoing detailed description of the preferred embodiments of the invention has been presented. It should be understood that numerous modifications and variations could be devised by those skilled in the art in light of the present teachings without departing from the inventive concepts. Therefore, the technical solutions available to those skilled in the art through logic analysis, reasoning and limited experiments based on the prior art according to the concept of the present invention should be within the scope of protection defined by the claims.

Claims (10)

1. A method for thermal expansion of a disk of a virtual machine based on qemu is applied to a virtual machine system, and the virtual machine of the virtual machine system is distributed with a disk space, wherein the disk space comprises one or more disks and is distributed block storage, and the method comprises the following steps:
starting a socket monitoring address to receive a disk space expansion instruction of a virtual machine;
executing the disk space capacity expansion instruction of the virtual machine;
and modifying the size of the disk space in the disk partition table of the virtual machine based on qemu to realize thermal expansion.
2. The qemu-based method for hot expansion of a virtual machine disk according to claim 1, wherein the executing of the virtual machine disk space expansion instruction specifically comprises:
and searching a host machine where the virtual machine is located through the name of the virtual machine, and executing the disk space expansion instruction of the virtual machine on the host machine.
3. The qemu-based virtual machine disk thermal expansion method according to claim 1, wherein when thermal expansion is realized, the size of virtual machine space expansion is not greater than the total remaining amount of distributed storage.
4. The method of claim 1, wherein the virtual machine comprises a qemu-guest-agent tool, and the qemu-guest-agent tool is used to modify the size of the disk space in the disk partition table of the virtual machine.
5. The qemu-based virtual machine disk hot-expansion method according to claim 4, wherein different disk hot-expansion operation instructions are called according to different operating systems when the qemu-guest-agent tool is used for modifying the virtual machine disk partition table.
6. The utility model provides a device of virtual machine disk heat dilatation based on qemu, is applied to virtual machine system, the virtual machine of virtual machine system distributes there is the disk space, its characterized in that, the disk space is including one or polylith disk, for distributed block storage, the device includes:
the instruction receiving unit is used for starting a socket monitoring address to receive a disk space expansion instruction of the virtual machine;
the execution instruction unit is used for executing the disk space capacity expansion instruction of the virtual machine;
and the capacity expansion disk partition unit is used for modifying the size of the disk space in the disk partition table of the virtual machine based on qemu to realize thermal capacity expansion.
7. The apparatus for qemu-based virtual machine disk thermal expansion according to claim 6, further comprising:
the scheduling instruction unit is used for searching the host machine where the virtual machine is located through the name of the virtual machine and transmitting the host machine where the virtual machine is located through the name of the virtual machine to the host machine;
and the execution instruction unit executes the disk space expansion instruction of the virtual machine on the host machine.
8. The apparatus for qemu-based virtual machine disk thermal expansion according to claim 6, wherein when thermal expansion is implemented, a size of a virtual machine space expansion is not greater than a total remaining amount of distributed storage.
9. The qemu-based device for thermally expanding disks of a virtual machine according to claim 6, wherein the virtual machine includes a qemu-guest-agent tool, and the expansion disk partitioning unit modifies the size of the disk space in the disk partition table of the virtual machine by using the qemu-guest-agent tool.
10. The apparatus for qemu-based virtual machine disk thermal expansion of claim 9, further comprising:
the judging operation system unit is used for judging the version of the virtual machine operation system by using the qemu-guest-agent tool and sending the version information of the operation system to the capacity expansion disk partition unit;
and the capacity expansion disk partition unit calls different disk hot capacity expansion operation instructions according to different operating system version information.
CN201910911806.9A 2019-09-25 2019-09-25 Method and device for thermally expanding disk of virtual machine based on qemu Active CN110658998B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910911806.9A CN110658998B (en) 2019-09-25 2019-09-25 Method and device for thermally expanding disk of virtual machine based on qemu

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910911806.9A CN110658998B (en) 2019-09-25 2019-09-25 Method and device for thermally expanding disk of virtual machine based on qemu

Publications (2)

Publication Number Publication Date
CN110658998A true CN110658998A (en) 2020-01-07
CN110658998B CN110658998B (en) 2023-10-03

Family

ID=69039110

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910911806.9A Active CN110658998B (en) 2019-09-25 2019-09-25 Method and device for thermally expanding disk of virtual machine based on qemu

Country Status (1)

Country Link
CN (1) CN110658998B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8171201B1 (en) * 2008-10-07 2012-05-01 Vizioncore, Inc. Systems and methods for improving virtual machine performance
CN107844260A (en) * 2016-09-19 2018-03-27 深圳市深信服电子科技有限公司 A kind of method and device of magnetic disk of virtual machine space dilatation
CN107861790A (en) * 2017-10-27 2018-03-30 新华三云计算技术有限公司 Magnetic disk of virtual machine Extend Methods of Spatial Distribution, device, host and readable storage medium storing program for executing
CN109375874A (en) * 2018-09-28 2019-02-22 深信服科技股份有限公司 A kind of call method of distributed storage, device and equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8171201B1 (en) * 2008-10-07 2012-05-01 Vizioncore, Inc. Systems and methods for improving virtual machine performance
CN107844260A (en) * 2016-09-19 2018-03-27 深圳市深信服电子科技有限公司 A kind of method and device of magnetic disk of virtual machine space dilatation
CN107861790A (en) * 2017-10-27 2018-03-30 新华三云计算技术有限公司 Magnetic disk of virtual machine Extend Methods of Spatial Distribution, device, host and readable storage medium storing program for executing
CN109375874A (en) * 2018-09-28 2019-02-22 深信服科技股份有限公司 A kind of call method of distributed storage, device and equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王春海等: "更改虚拟机磁盘容量与格式", 《网络安全和信息化》 *

Also Published As

Publication number Publication date
CN110658998B (en) 2023-10-03

Similar Documents

Publication Publication Date Title
US9811369B2 (en) Method and system for physical computer system virtualization
CN106933508B (en) Application container migration method and device
CN106354583B (en) A kind of heat backup method and system of MySQL database
US20120290802A1 (en) Snapshot creation from block lists
EP3885903A1 (en) Cloud desktop upgrade method, device, cloud server, and storage medium
US20120110293A1 (en) Method and system for managing virtual machine storage space and physical host
US10747777B2 (en) Computer system and transaction processing management method
US10318166B1 (en) Preserving locality of storage accesses by virtual machine copies in hyper-converged infrastructure appliances
CN107209683A (en) Backup Images recover
CN102385523A (en) Method for installing and managing driver of cloud operating system
TW201322134A (en) System and method for managing virtual machines
US20190332275A1 (en) Information processing system and volume allocation method
CN104156255A (en) Virtual machine migration method, virtual machine migration device and source physical host
CN107861790A (en) Magnetic disk of virtual machine Extend Methods of Spatial Distribution, device, host and readable storage medium storing program for executing
US20240061712A1 (en) Method, apparatus, and system for creating training task on ai training platform, and medium
JP2007133544A (en) Failure information analysis method and its implementation device
CN104503825A (en) Mixed type equipment virtualization method based on KVM (Kernel-based Virtual Machine)
CN108475201A (en) A kind of data capture method in virtual machine start-up course and cloud computing system
CN104407990B (en) A kind of disk access method and device
CN110580195B (en) Memory allocation method and device based on memory hot plug
CN105446794A (en) Disc operation method, apparatus and system based on virtual machine
CN105205178A (en) Multi-process access memory database system
EP3262519A1 (en) Configuration of a memory controller for copy-on-write
KR102315102B1 (en) Method, device, apparatus, and medium for booting a virtual machine
CN105162833A (en) Client computer management system and method applied to diskless workstation

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
GR01 Patent grant
GR01 Patent grant