CN110658998B - Method and device for thermally expanding disk of virtual machine based on qemu - Google Patents
Method and device for thermally expanding disk of virtual machine based on qemu Download PDFInfo
- Publication number
- CN110658998B CN110658998B CN201910911806.9A CN201910911806A CN110658998B CN 110658998 B CN110658998 B CN 110658998B CN 201910911806 A CN201910911806 A CN 201910911806A CN 110658998 B CN110658998 B CN 110658998B
- Authority
- CN
- China
- Prior art keywords
- virtual machine
- disk
- qemu
- space
- expansion
- 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.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45504—Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input 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/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0662—Virtualisation aspects
- G06F3/0665—Virtualisation aspects at area level, e.g. provisioning of virtual or logical volumes
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Stored Programmes (AREA)
Abstract
The invention relates to a method and a device for thermally expanding a disk of a virtual machine based on qemu, which are applied to a virtual machine system, wherein the virtual machine of the virtual machine system is distributed with disk space, the disk space comprises one or more disks and is stored for distributed blocks, and the method comprises the following steps: starting a socket monitoring address to receive a virtual machine disk space capacity expansion instruction; executing the virtual machine disk space expansion instruction; 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
Technical Field
The invention relates to the technical field of virtual machines, in particular to a method and a device for thermally expanding a disk of a virtual machine based on qemu.
Background
Users of the Windows operating system generally want enough space for their own C-disk, but the space for the computer C-disk that is often practically used is not ideal. In the prior art, this problem is usually solved by installing a partitioning tool, such as a partitioning magic man, to expand the C-disc space.
However, this approach has certain limitations. In general, another D partition is allocated immediately after the C partition, and when the data is already stored in the D partition, the capacity expansion of the C partition can only be achieved by completely combining the C partition and the D partition, and because the partition is a system partition, the system needs to be restarted to achieve the capacity expansion of the partition. In the process of partition capacity expansion, a large number of data files also need to be moved, which is time-consuming.
Chinese patent application CN107479837a discloses a method for expanding capacity of virtual machines in a cloud data system, comprising: receiving a request for expanding the capacity of a disk of a running virtual machine, wherein the expansion request comprises a target size of the expansion of the disk; obtaining a virtual machine specification template with a disk space meeting the target size according to the target size of the disk expansion; and performing disk capacity expansion on the virtual machine by using the virtual machine specification template. However, the method can only expand the capacity according to the preset specification template, and still has the defect of troublesome operation, can not solve the limitation of the prior art, and can not meet the actual capacity expansion requirement.
Disclosure of Invention
The invention aims to overcome the defects in the prior art and provide a method and a device for thermally expanding the disk of a virtual machine based on qemu.
The aim of the invention can be achieved by the following technical scheme:
a method for thermally expanding a disk of a virtual machine based on qemu is applied to a virtual machine system, wherein the virtual machine of the virtual machine system is allocated with a disk space, the disk space comprises one or more disks and is used for distributed block storage, and the method comprises the following steps:
starting a socket monitoring address to receive a virtual machine disk space capacity expansion instruction;
executing the virtual machine disk space expansion instruction;
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 virtual machine disk space capacity expansion instruction specifically includes:
and searching a host machine where the virtual machine is located through the name of the virtual machine, and executing the virtual machine disk space expansion instruction on the host machine.
Further, when the thermal expansion is realized, the expansion size of the virtual machine space is not larger than the total residual quantity of the distributed storage.
Further, the virtual machine comprises a qemu-guest-agent tool, and the size of the disk space in the disk partition table of the virtual machine is modified by using the qemu-guest-agent tool.
Further, when the qemu-guide-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 device for thermally expanding the disk of the virtual machine based on qemu, which is applied to a virtual machine system, wherein the virtual machine of the virtual machine system is distributed with disk space, the disk space comprises one or more disks and is stored for distributed blocks, and the device comprises:
the receiving instruction unit is used for starting a socket monitoring address to receive a virtual machine disk space capacity expansion instruction;
the execution instruction unit is used for executing the virtual machine disk space capacity expansion instruction;
and the capacity expansion disk partition unit is used for modifying the size of the disk space in the virtual machine disk partition table based on qemu to realize thermal capacity expansion.
Further, the apparatus further comprises:
the scheduling instruction unit is used for searching a host computer where the virtual machine is located through the virtual machine name and transmitting the host computer where the virtual machine is located through the virtual machine name to the host computer;
and the execution instruction unit executes the virtual machine disk space expansion instruction on the host.
Further, when the thermal expansion is realized, the expansion size of the virtual machine space is not larger than the total residual quantity of the distributed storage.
Further, the virtual machine includes a qemu-gust-agent tool, and the capacity-expanding disk partition unit utilizes the qemu-gust-agent tool to modify the size of disk space in the virtual machine disk partition table.
Further, the apparatus further comprises:
the judging operation system unit is used for judging the version of the virtual machine operation system by utilizing the qemu-gust-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-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 at the remote end of the server by adopting the distributed block storage, is not limited by the local disk space capacity of the host machine of the virtual machine, accesses the disk on the server by the virtual machine through the network, does not need to add blank space to the disk space, directly modifies the maximum threshold value of the partition table, expands the disk space and has a simple thermal expansion mode.
2. The invention solves the problems of complex mobile data files and time consumption in the partition capacity expansion process of the conventional Windows operating system.
3. The invention can realize the dynamic capacity expansion of the whole disk or the target partition of the virtual machine under the condition that the virtual machine is not shut down, and the use of other partitions is not affected.
4. In the partition capacity expansion process, the method does not need to move the data of the disk file in the virtual machine, and reduces the extra consumption of IO.
5. When the monitoring system monitors that the residual space capacity of the disk partition is insufficient, the virtual machine root disk is subjected to thermal expansion through qemu, the problem that the root disk is full due to unreasonable occupation of disk resources after the virtual machine root disk is expanded in real time is solved, a system administrator does not need to manually operate a command in the whole process, the capacity expansion efficiency of the disk partition is improved, and the technical effect of dynamically expanding the capacity of the disk partition is achieved.
Drawings
FIG. 1 is a schematic representation of one embodiment of the thermal expansion method of the present invention;
FIG. 2 is a schematic diagram of root disk expansion in an embodiment of the invention;
fig. 3 is a schematic view of an embodiment of the thermal expansion apparatus of the present invention.
Detailed Description
The invention will now be described in detail with reference to the drawings and specific examples. The present embodiment is implemented on the premise of the technical scheme of the present invention, and a detailed implementation manner and a specific operation process are given, but the protection scope of the present invention is not limited to the following examples.
Example 1
The embodiment provides a method for thermally expanding a disk space of a virtual machine based on qemu, which is applied to a virtual machine system, wherein the virtual machine of the virtual machine system is distributed with a disk space, the disk space comprises one or more disks and is used for distributed block storage.
In one embodiment as shown in fig. 1, the method for thermal expansion of a qemu-based virtual machine disk 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 through a virtual machine name;
202. the method comprises the steps that a thermal expansion instruction of a disk space of a virtual machine is scheduled to a host computer, the instruction is issued to a specific host computer, the host computer 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 larger than the total residual quantity of the distributed 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 of the partition table without adding blank space to the disk space due to the use of distributed block storage.
The virtual machine includes a qemu-guest-agent tool that is utilized to modify the size of disk space in the virtual machine disk partition table.
When the qemu-gust-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 operation systems, wherein the operation systems comprise Windows and Linux, and Linux comprises CentOS, ubuntu, suse operation systems.
When the virtual machine expansion is executed, a 'QEMU-Monitor-command' command of virsh (command line management tool) is used for sending a command to the Monitor, unix socket of qemu_gum_agent needs to be started for the virtual machine before the virtual machine expansion is carried out, an external command can access files in the virtual machine through the setting of the QEMU Monitor, an instruction in the virtual machine is executed, and control of the Monitor socket is added behind libvirt, so that the virtual machine expansion can be operated through the virsh command. The specific commands are as follows: the virtual qemu-monitor-command instance-00000001block_resize drive-virtual-disk 0G-hmp, wherein instance-00000001 is the virtual machine domain name, block_restore is the command of resetting the block device size, drive-virtual-disk 0 is the block device name of resetting the size, and 60G is the size after capacity expansion is 60G.
According to the embodiment, the dynamic capacity expansion of the whole disk or the target partition of the virtual machine can be realized under the condition that the virtual machine is not powered off, the subsequent use of other partitions is not influenced, meanwhile, in the partition capacity expansion process, the data of the disk file in the virtual machine is basically not required to be moved, and the additional consumption of IO is reduced.
Taking the capacity expansion of the partition C as an example, as shown in the figure, the capacity of the partition C is modified to modify the maximum threshold value in the disk partition of the virtual machine; then notifying qemu-guest-agent tools in the virtual machine at the same time; the qemu-guest-agent modifies the partition table of the disk, formats the file system, and enlarges the size of the C partition. 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 subsequent use of other partitions is not influenced. Meanwhile, in the partition capacity expansion process, except the read-write of the partition table and qcow2 metadata, the data of the disk file in the virtual machine is basically not required to be moved, and the extra consumption of IO is reduced.
For the capacity expansion of the whole virtual disk, firstly expanding the space of the virtual disk through a Qemu end; then notifying qemu-guest-agent tools in the virtual machine; after receiving the additionally expanded disk space size, the qemu-gust-agent tool modifies the partition table of the disk, simultaneously informs a Guest operating system and performs initialization operation on the newly added space; the newly added space may then be merged into the last partition without shutting down.
Example 2
The embodiment provides a device for thermal expansion of a virtual machine disk based on qemu, which is applied to a virtual machine system, wherein a disk space is allocated to a virtual machine of the virtual machine system, the disk space comprises one or more disks and is used for distributed block storage, and the device comprises:
the receiving instruction unit is used for starting a socket monitoring address to receive a virtual machine disk space capacity expansion instruction;
the scheduling instruction unit is used for searching a host computer where the virtual machine is located through the virtual machine name and transmitting the host computer where the virtual machine is located through the virtual machine name to the host computer;
the execution instruction unit is used for executing the virtual machine disk space expansion instruction on the host;
the judging operation system unit is used for judging the version of the virtual machine operation system by utilizing a qemu-guide-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 virtual machine disk partition table based on qemu to realize thermal capacity expansion.
The judging operation system unit judges the file system of the virtual machine through the qemu-guide-agent tool, and different capacity expansion disk partition units are respectively executed aiming at different operation systems, wherein the operation systems comprise Windows and Linux, and the Linux comprises CentOS, ubuntu, suse operation systems. Specifically, the qemu-guide-agent tool is used for operating a file system in the virtual machine system, reading/etc/isue content, if None is read, indicating that the version of the virtual machine operating system is Windows, if Ubuntu keywords are contained in the read content, indicating that the operating system is Ubuntu, and then reading/etc/redhat-release files, if 6 is contained in the content, indicating that the content is CentrOS 6, and if 7 is contained in the content, indicating that the content is CentrOS 7; and then, executing different disk thermal expansion operations according to different operating systems.
In the flash disk partition unit, a diskpart instruction is executed if Windows, and a growth part instruction is executed if Linux.
The terms first, second and the like in the description and in the claims and in the above-described figures, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments described herein may be implemented in other sequences than those illustrated or otherwise 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 describes in detail preferred embodiments of the present invention. It should be understood that numerous modifications and variations can be made in accordance with the concepts of the invention by one of ordinary skill in the art without undue burden. Therefore, all technical solutions which can be obtained by logic analysis, reasoning or limited experiments based on the prior art by the person skilled in the art according to the inventive concept shall be within the scope of protection defined by the claims.
Claims (6)
1. The method is applied to a virtual machine system, wherein a virtual machine of the virtual machine system is distributed with disk space, and is characterized in that the disk space comprises one or more disks and is stored for distributed blocks, and the method comprises the following steps:
starting a socket monitoring address to receive a virtual machine disk space capacity expansion instruction;
executing the virtual machine disk space expansion instruction;
modifying the size of a disk space in a disk partition table of a virtual machine based on qemu to realize thermal expansion, wherein the virtual machine comprises a qemu-guest-agent tool, and modifying the size of the disk space in the disk partition table of the virtual machine by using the qemu-guest-agent tool;
when a qemu-guide-agent tool is used for modifying a disk partition table of the virtual machine, different disk hot expansion operation instructions are called according to different operation systems;
for the capacity expansion of the whole virtual disk, firstly expanding the space of the virtual disk through a Qemu end; then notifying qemu-guest-agent tools in the virtual machine; after receiving the additionally expanded disk space size, the qemu-gust-agent tool modifies the partition table of the disk, simultaneously informs a Guest operating system and performs initialization operation on the newly added space; the newly added space may then be merged into the last partition without shutting down.
2. The qemu-based method for hot expansion of a virtual machine disk according to claim 1, wherein the executing 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 virtual machine disk space expansion instruction on the host machine.
3. The qemu-based method for hot expansion of a virtual machine disk according to claim 1, wherein the size of expansion of the virtual machine space is not greater than the total remaining amount of distributed storage when hot expansion is implemented.
4. The utility model provides a virtual machine disk thermal expansion device based on qemu, is applied to virtual machine system, virtual machine of virtual machine system distributes the disk space, its characterized in that, the disk space is stored for distributed block including one or more disks, and the device includes:
the receiving instruction unit is used for starting a socket monitoring address to receive a virtual machine disk space capacity expansion instruction;
the execution instruction unit is used for executing the virtual machine disk space capacity expansion instruction;
the capacity expansion disk partition unit is used for realizing thermal expansion by modifying the size of the disk space in the disk partition table of the virtual machine based on qemu, wherein the virtual machine comprises a qemu-guest-agent tool, and the size of the disk space in the disk partition table of the virtual machine is modified by utilizing the qemu-guest-agent tool;
the apparatus further comprises:
the judging operation system unit is used for judging the version of the virtual machine operation system by utilizing the qemu-gust-agent tool and sending the version information of the operation system to the capacity expansion disk partition unit;
the capacity expansion disk partition unit calls different disk hot capacity expansion operation instructions according to different operating system version information;
for the capacity expansion of the whole virtual disk, firstly expanding the space of the virtual disk through a Qemu end; then notifying qemu-guest-agent tools in the virtual machine; after receiving the additionally expanded disk space size, the qemu-gust-agent tool modifies the partition table of the disk, simultaneously informs a Guest operating system and performs initialization operation on the newly added space; the newly added space may then be merged into the last partition without shutting down.
5. The qemu-based virtual machine disk hot-expansion apparatus of claim 4, further comprising:
the scheduling instruction unit is used for searching a host computer where the virtual machine is located through the virtual machine name and transmitting the host computer where the virtual machine is located through the virtual machine name to the host computer;
and the execution instruction unit executes the virtual machine disk space expansion instruction on the host.
6. The qemu-based device for thermally expanding a disk of a virtual machine according to claim 4, wherein the size of the expansion space of the virtual machine is not greater than the total remaining amount of the distributed storage when the thermal expansion is implemented.
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 CN110658998A (en) | 2020-01-07 |
CN110658998B true 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)
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 |
-
2019
- 2019-09-25 CN CN201910911806.9A patent/CN110658998B/en active Active
Patent Citations (4)
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)
Title |
---|
更改虚拟机磁盘容量与格式;王春海等;《网络安全和信息化》;20180905(第09期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN110658998A (en) | 2020-01-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11397648B2 (en) | Virtual machine recovery method and virtual machine management device | |
US8738883B2 (en) | Snapshot creation from block lists | |
US8850156B2 (en) | Method and system for managing virtual machine storage space and physical host | |
US20160092261A1 (en) | Method and system for physical computer system virtualization | |
EP2479677A1 (en) | Method, system and physical host for virtual machine (vm) storage space management | |
CN108376100A (en) | Container scheduling based on safety | |
WO2016165597A1 (en) | Processing method and device for data storage | |
US20120246456A1 (en) | Memory tagging and preservation during a hot upgrade | |
DE102010013263A1 (en) | Techniques to perform energy fail-safe caching without atomic metadata | |
WO2022095366A1 (en) | Redis-based data reading method and apparatus, device, and readable storage medium | |
US11199972B2 (en) | Information processing system and volume allocation method | |
US20140236892A1 (en) | Systems and methods for virtual machine backup process by examining file system journal records | |
CN108475201A (en) | A kind of data capture method in virtual machine start-up course and cloud computing system | |
US12360709B2 (en) | Distributed storage space management method, computing device and storage medium | |
CN107209683A (en) | Backup Images recover | |
CN102385523A (en) | Method for installing and managing driver of cloud operating system | |
CN113835644B (en) | Complete machine migration method, device, equipment and storage medium | |
CN104102460A (en) | Cloud computing-based memory management method and device | |
CN105389190B (en) | A kind of method, apparatus and system of os starting | |
KR102315102B1 (en) | Method, device, apparatus, and medium for booting a virtual machine | |
US20200371827A1 (en) | Method, Apparatus, Device and Medium for Processing Data | |
US20140281125A1 (en) | Systems and methods for in-place reorganization of device storage | |
CN113190241B (en) | Method and device for expanding capacity of data partition, electronic equipment and storage medium | |
CN110658998B (en) | Method and device for thermally expanding disk of virtual machine based on qemu | |
CN113268266A (en) | Multi-version coexistence management method, system and medium for applet rendering framework |
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 |