CN112015350A - Method, device and medium for unloading data disk of virtual machine - Google Patents

Method, device and medium for unloading data disk of virtual machine Download PDF

Info

Publication number
CN112015350A
CN112015350A CN202010889289.2A CN202010889289A CN112015350A CN 112015350 A CN112015350 A CN 112015350A CN 202010889289 A CN202010889289 A CN 202010889289A CN 112015350 A CN112015350 A CN 112015350A
Authority
CN
China
Prior art keywords
virtual machine
data disk
target data
disk
unloading
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
CN202010889289.2A
Other languages
Chinese (zh)
Other versions
CN112015350B (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.)
Inspur Jinan data Technology Co ltd
Original Assignee
Beijing Inspur Data Technology 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 Beijing Inspur Data Technology Co Ltd filed Critical Beijing Inspur Data Technology Co Ltd
Priority to CN202010889289.2A priority Critical patent/CN112015350B/en
Publication of CN112015350A publication Critical patent/CN112015350A/en
Application granted granted Critical
Publication of CN112015350B publication Critical patent/CN112015350B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • 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/0638Organizing or formatting or addressing of data
    • G06F3/0644Management of space entities, e.g. partitions, extents, pools
    • 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/445Program loading or initiating
    • G06F9/44594Unloading
    • 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/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • 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/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45579I/O management, e.g. providing access to device drivers or storage

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)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a method, a device and a medium for unloading a data disk of a virtual machine, which are used for receiving an unloading instruction of a target data disk, and calling a path acquisition rule matched with the type of a virtual machine system according to the type of the virtual machine system corresponding to the target data disk when the target data disk has IO operation so as to acquire a mount point of the target data disk on the virtual machine. And performing freezing operation on the file system corresponding to the mount point, so that all IO operations on the target data disk are suspended. And when the target data disk does not have IO operation or the freezing operation is performed on the file system corresponding to the mount point, the unloading operation can be performed on the target data disk. The technical scheme can support the safe unloading of the data disk of the virtual machine of various operating systems, prevent serious problems of data disk unloading failure or user data loss and the like caused by IO operation when a user unloads the data disk, and realize the safe unloading of the data disk.

Description

Method, device and medium for unloading data disk of virtual machine
Technical Field
The invention relates to the technical field of cloud services, in particular to a method and a device for unloading a data disk of a virtual machine and a computer-readable storage medium.
Background
When a user uses a virtual machine provided by a cloud platform daily, the data disk mounted by the virtual machine is often required to be frequently mounted and unloaded due to work, and if the virtual machine is applied or the user performs read-write operation on the data disk, the cloud platform continuously tries to unload the data disk. When the read-write operation lasts for a long time, the cloud platform gives up unloading the data disk and prompts a user that the unloading of the data disk fails.
Because the cloud platform unloads the data disk by performing related operation on the virtual machine through libvirt, the task of unloading the data disk belongs to asynchronous operation, the cloud platform notifies the user that the unloading of the data disk fails, but the libvirt side unloads the data disk of the virtual machine after waiting for the completion of the IO operation, and when the IO operation of the data disk is stopped, the xml data disk information of the virtual machine is deleted by the libvirt layer, and the scene causes the inconsistency between the disk information maintained by the cloud platform and the disk information of the virtual machine, thereby affecting the safe use of the data disk. When the disk to be unloaded on the virtual machine has continuous IO operation, user data loss or disk damage can be caused if the disk is forcibly unloaded.
It can be seen that how to safely uninstall a data disk is a problem that needs to be solved by those skilled in the art.
Disclosure of Invention
The embodiment of the invention aims to provide a method and a device for unloading a data disk of a virtual machine and a computer readable storage medium, which can safely unload the data disk and prevent serious problems of data disk unloading failure or user data loss and the like caused by IO operation when a user unloads the data disk.
To solve the foregoing technical problem, an embodiment of the present invention provides a method for unloading a data disk of a virtual machine, including:
receiving an unloading instruction of a target data disk;
judging whether IO operation exists in the target data disk;
when IO operation exists in the target data disk, calling a path obtaining rule matched with the type of the virtual machine system according to the type of the virtual machine system corresponding to the target data disk so as to obtain a mounting point of the target data disk on the virtual machine;
performing freezing operation on the file system corresponding to the mount point;
and when the target data disk does not have IO operation or freezing operation is performed on the file system corresponding to the mount point, unloading operation is performed on the target data disk.
Optionally, the invoking, according to the virtual machine system type corresponding to the target data disk, a path obtaining rule matched with the virtual machine system type to obtain a mount point of the target data disk on the virtual machine includes:
when the virtual machine system type is a windows system, calling a preset QGA instruction to acquire mounting point information of a file system and a disk serial number corresponding to the target data disk;
and determining the mounting point of the target data disk on the virtual machine according to the mounting point information of the file system and the disk serial number.
Optionally, the invoking, according to the virtual machine system type corresponding to the target data disk, a path obtaining rule matched with the virtual machine system type to obtain a mount point of the target data disk on the virtual machine includes:
when the virtual machine system type is a non-windows system, calling a preset virtual machine file script to acquire mounting point information of the file system and a partition path corresponding to the target data disk;
inquiring the corresponding disk partition information of the virtual machine under the partition path;
determining disk information of the target data disk mapped on the virtual machine according to the serial number of the target data disk on the cloud platform;
matching the disk information with the disk partition information to determine target disk partition information corresponding to the target data disk on the virtual machine;
and determining the mounting point of the target data disk on the virtual machine according to the partition information of the target disk and the mounting point information of the file system.
Optionally, the method further comprises:
when the virtual machine is frozen, performing a unfreezing operation on the virtual machine after performing an unloading operation on the target data disk.
Optionally, before the invoking a path obtaining rule matched with the virtual machine system type according to the virtual machine system type corresponding to the target data disk to obtain a mount point of the target data disk on the virtual machine, the method further includes:
when the target data disk has IO operation, displaying prompt information that the target data disk has IO operation;
and when receiving an unloading confirmation instruction of the target data disk, executing the step of calling a path acquisition rule matched with the virtual machine system type according to the virtual machine system type corresponding to the target data disk so as to acquire a mounting point of the target data disk on the virtual machine.
The embodiment of the invention also provides an unloading device of the virtual machine data disk, which comprises a receiving unit, a judging unit, an acquiring unit, a freezing unit and an unloading unit;
the receiving unit is used for receiving an unloading instruction of the target data disk;
the judging unit is used for judging whether IO operation exists in the target data disk;
the obtaining unit is configured to, when the target data disk has IO operation, invoke a path obtaining rule matched with a virtual machine system type according to the virtual machine system type corresponding to the target data disk, so as to obtain a mount point of the target data disk on a virtual machine;
the freezing unit is used for performing freezing operation on the file system corresponding to the mount point;
the unloading unit is configured to, when there is no IO operation in the target data disk or after a freezing operation is performed on the file system corresponding to the mount point, perform an unloading operation on the target data disk.
Optionally, the obtaining unit includes a calling subunit and a determining subunit;
the calling subunit is configured to, when the virtual machine system type is a windows system, call a preset QGA instruction to obtain mount point information of a file system and a disk serial number corresponding to the target data disk;
and the determining subunit is configured to determine, according to the mounting point information of the file system and the disk serial number, a mounting point of the target data disk on the virtual machine.
Optionally, the obtaining unit includes a calling subunit, a querying subunit, a mapping subunit, a matching subunit, and a determining subunit;
the calling subunit is configured to, when the virtual machine system type is a non-windows system, call a preset virtual machine file script to obtain mount point information of a file system and a partition path corresponding to the target data disk;
the inquiring subunit is configured to inquire the disk partition information corresponding to the virtual machine under the partition path;
the mapping subunit is configured to determine, according to a serial number of the target data disk on the cloud platform, disk information of the target data disk mapped on the virtual machine;
the matching subunit is configured to match the disk information with the disk partition information, and determine target disk partition information corresponding to the target data disk on the virtual machine;
and the determining subunit is configured to determine a mount point of the target data disk on the virtual machine according to the partition information of the target disk and the mount point information of the file system.
Optionally, a thawing unit is further included;
the unfreezing unit is used for performing unfreezing operation on the virtual machine after the unloading operation is performed on the target data disk when the virtual machine is frozen.
Optionally, the system further comprises a prompting unit and a confirming unit;
the prompting unit is used for displaying the prompting information of the IO operation of the target data disk when the IO operation of the target data disk exists;
and the confirming unit is used for triggering the acquiring unit to execute the step of calling a path acquiring rule matched with the system type of the virtual machine according to the system type of the virtual machine corresponding to the target data disk so as to acquire a mount point of the target data disk on the virtual machine when receiving a confirmed unloading instruction of the target data disk.
The embodiment of the present invention further provides an unloading device for a data disk of a virtual machine, including:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the method for offloading a data disk of a virtual machine as described in any one of the above.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method for offloading a data disk of a virtual machine according to any item above are implemented.
According to the technical scheme, the unloading instruction of the target data disk is received; and judging whether the target data disk has IO operation or not. When the target data disk has IO operation, if the unloading operation of the target data disk is executed forcibly, the target data disk may be damaged or user data may be lost. In order to ensure the safety of unloading the target data disk, a path acquisition rule matched with the type of the virtual machine system can be called according to the type of the virtual machine system corresponding to the target data disk, so as to acquire a mount point of the target data disk on the virtual machine. The mount points refer to the distribution positions of the target data disks on the cloud platform on the virtual machine, and the freezing operation is performed on the file system corresponding to the mount points, so that all IO operations on the target data disks are suspended, and the user data corresponding to the IO operations cannot be affected by the unloading operation performed on the target data disks. Therefore, when the target data disk has no IO operation or the freezing operation is performed on the file system corresponding to the mount point, the unloading operation can be performed on the target data disk. The technical scheme can support the safe unloading of the data disk of the virtual machine of various operating systems, prevent serious problems of data disk unloading failure or user data loss and the like caused by IO operation when a user unloads the data disk, and realize the safe unloading of the data disk.
Drawings
In order to illustrate the embodiments of the present invention more clearly, the drawings that are needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings can be obtained by those skilled in the art without inventive effort.
Fig. 1 is a flowchart of an offloading method for a virtual machine data disk according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of an offloading device for a virtual machine data disk according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a hardware structure of an offloading device for a virtual machine data disk according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without any creative work belong to the protection scope of the present invention.
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments.
Next, a method for unloading a data disk of a virtual machine according to an embodiment of the present invention is described in detail. Fig. 1 is a flowchart of a method for unloading a data disk of a virtual machine according to an embodiment of the present invention, where the method includes:
s101: and receiving an unloading instruction of the target data disk.
The number of data disks in the system is large, and for convenience of distinguishing, in the embodiment of the invention, the data disk needing to be unloaded can be called as a target data disk.
In practical application, a user can input an uninstalling instruction of a target data disk through a user interface provided by the cloud platform.
S102: and judging whether the target data disk has IO operation or not.
After receiving the unloading instruction of the data disk, the cloud platform can judge whether the target data disk has IO operation.
When the target data disk has IO operations, if the data disk is directly unloaded, user data is often lost or the target data disk is damaged. Therefore, in the embodiment of the present invention, when the target data disk has an IO operation, the IO operation on the target data disk may be frozen first, that is, S103 is executed when the target data disk has the IO operation.
S103: and calling a path acquisition rule matched with the virtual machine system type according to the virtual machine system type corresponding to the target data disk so as to acquire a mount point of the target data disk on the virtual machine.
When the target data disk has IO operation, in order to avoid conflict between the IO operation and the disk unloading operation, the IO operation may be frozen first, at this time, all mount points of the target data disk on the virtual machine need to be determined, and the mount points may be regarded as distribution positions of the target data disk on the virtual machine.
The virtual machine system types can be various, and different system types have different modes for determining the target data disk mounting point. In the embodiment of the invention, the system types of the virtual machine can be divided into a windows system and a non-windows system according to different obtaining modes of the mount points. The non-windows system may be a linux system or other heterogeneous operating system.
In a specific implementation, when the virtual machine system type is a windows system, a preset QGA instruction may be called to obtain mount point information (mount point) of the file system and a disk serial number (UUID) corresponding to the target data disk. According to the mounting point information of the file system and the serial number of the disk, the mounting point of the target data disk on the virtual machine can be determined.
The mount point information of the file system records the partition positions of all the data disks on the virtual machine. The disk serial number is the unique identification code of the target data disk. Matching the disk serial number of the target data disk with the mounting point information of the file system, and determining the partition position of the target data disk on the virtual machine, namely the mounting point.
When the type of the virtual machine system is a non-windows system, a preset virtual machine file script can be called to obtain mounting point information of the file system and a partition path corresponding to the target data disk. And inquiring the corresponding disk partition information of the virtual machine under the partition path. And determining the disk information of the target data disk mapped on the virtual machine according to the serial number of the target data disk on the cloud platform.
In practical application, the corresponding disk partition information can be found in a virtual machine/sys/class/block/$ name/sinks path, wherein the name is a partition path corresponding to the target data disk. And obtaining the serial number of the target data disk on the cloud platform under the internal/dev/disk/by-id path of the virtual machine.
And determining the disk information of the target data disk mapped on the virtual machine according to the serial number of the target data disk on the cloud platform. After determining the disk partition information corresponding to the virtual machine under the partition path and the disk information mapped by the target data disk on the virtual machine, matching the disk information with the disk partition information to determine the target disk partition information corresponding to the target data disk on the virtual machine; and determining the mounting point of the target data disk on the virtual machine according to the partition information of the target disk and the mounting point information of the file system.
For example, after obtaining mount point information (mount point) of the file system and a partition path (name) corresponding to the target data disk, the following steps may be performed: (1) corresponding disk partition information is acquired under a path of virtual machine/sys/class/block/$ name/slave, such as vdb1, vdb2, and vdb 3. (2) And then, finding the disk information corresponding to the serial number of the cloud platform, such as the cloud host/dev/vdb, from the internal/dev/disk/by-id of the virtual machine. (3) According to the fact that mount points on the virtual machine corresponding to the serial number of the cloud platform are mount points of mount point1, mount point2 and mount point3, wherein the mount points are located at vdb1 corresponding to mount point1, vdb2 corresponding to mount point2 and vdb3 corresponding to mount point3, which are determined in the step (1).
S104: and performing freezing operation on the file system corresponding to the mount point.
After the mount points of the target data disk on the virtual machine are determined, the freezing operation can be directly executed on the file systems corresponding to all the mount points.
S105: and when the target data disk does not have IO operation or the freezing operation is performed on the file system corresponding to the mount point, the unloading operation is performed on the target data disk.
After freezing operations on the file systems corresponding to all the mounting points are completed, IO operations do not exist on the target data disk, and the problem of conflict between the IO operations and disk unloading operations does not occur.
According to the technical scheme, the unloading instruction of the target data disk is received; and judging whether the target data disk has IO operation or not. When the target data disk has IO operation, if the unloading operation of the target data disk is executed forcibly, the target data disk may be damaged or user data may be lost. In order to ensure the safety of unloading the target data disk, a path acquisition rule matched with the type of the virtual machine system can be called according to the type of the virtual machine system corresponding to the target data disk, so as to acquire a mount point of the target data disk on the virtual machine. The mount points refer to the distribution positions of the target data disks on the cloud platform on the virtual machine, and the freezing operation is performed on the file system corresponding to the mount points, so that all IO operations on the target data disks are suspended, and the user data corresponding to the IO operations cannot be affected by the unloading operation performed on the target data disks. Therefore, when the target data disk has no IO operation or the freezing operation is performed on the file system corresponding to the mount point, the unloading operation can be performed on the target data disk. The technical scheme can support the safe unloading of the data disk of the virtual machine of various operating systems, prevent serious problems of data disk unloading failure or user data loss and the like caused by IO operation when a user unloads the data disk, and realize the safe unloading of the data disk.
In practical applications, when an unloading operation needs to be performed on a target data disk, a freezing operation may also be performed on a virtual machine corresponding to the target data disk, where all file systems on the virtual machine are frozen, and in order to reduce an influence on other data disks, when the virtual machine is frozen, a unfreezing operation may be performed on the virtual machine after the unloading operation is performed on the target data disk.
In the above description, when an IO operation exists on a target data disk, in order to avoid a conflict between the IO operation and an unload operation of the target data disk, a freeze operation may be performed on a file system corresponding to a mount point. In practical applications, it may be necessary to perform an unloading operation on the target data disk after the IO operation is completed.
Therefore, before a path obtaining rule matched with the virtual machine system type is called according to the virtual machine system type corresponding to the target data disk to obtain a mount point of the target data disk on the virtual machine, when the target data disk has an IO operation, prompt information of the target data disk having the IO operation can be displayed.
And when the system receives an unloading confirmation instruction of the target data disk, the system calls a path acquisition rule matched with the virtual machine system type according to the virtual machine system type corresponding to the target data disk so as to acquire a mounting point of the target data disk on the virtual machine.
By displaying the prompt information of the IO operation of the target data disk, a user can conveniently and visually know the current use state of the target data disk. The user can select whether to continue to execute the unloading operation of the target data disk according to the prompt information, so that the unloading operation of the target data disk is more in line with the actual requirement of the user.
Fig. 2 is a schematic structural diagram of an unloading device for a data disk of a virtual machine according to an embodiment of the present invention, including a receiving unit 21, a determining unit 22, an obtaining unit 23, a freezing unit 24, and an unloading unit 25;
a receiving unit 21, configured to receive an unload instruction of a target data disk;
a judging unit 22, configured to judge whether an IO operation exists in the target data disk;
the obtaining unit 23 is configured to, when an IO operation exists on the target data disk, call a path obtaining rule matched with a virtual machine system type according to the virtual machine system type corresponding to the target data disk, so as to obtain a mount point of the target data disk on the virtual machine;
the freezing unit 24 is used for performing freezing operation on the file system corresponding to the mount point;
and the unloading unit 25 is configured to, when there is no IO operation in the target data disk or after a freezing operation is performed on the file system corresponding to the mount point, perform an unloading operation on the target data disk.
Optionally, the obtaining unit includes a calling subunit and a determining subunit;
the calling subunit is used for calling a preset QGA instruction to acquire mounting point information of the file system and a disk serial number corresponding to the target data disk when the type of the virtual machine system is a windows system;
and the determining subunit is used for determining the mounting point of the target data disk on the virtual machine according to the mounting point information of the file system and the disk serial number.
Optionally, the obtaining unit includes a calling subunit, a querying subunit, a mapping subunit, a matching subunit, and a determining subunit;
the calling subunit is used for calling a preset virtual machine file script to acquire mounting point information of the file system and a partition path corresponding to the target data disk when the type of the virtual machine system is a non-windows system;
the inquiry subunit is used for inquiring the corresponding disk partition information of the virtual machine under the partition path;
the mapping subunit is used for determining the disk information of the target data disk mapped on the virtual machine according to the serial number of the target data disk on the cloud platform;
the matching subunit is used for matching the disk information with the disk partition information to determine target disk partition information corresponding to the target data disk on the virtual machine;
and the determining subunit is used for determining the mounting point of the target data disk on the virtual machine according to the partition information of the target disk and the mounting point information of the file system.
Optionally, a thawing unit is further included;
and the unfreezing unit is used for performing unfreezing operation on the virtual machine after the unloading operation is performed on the target data disk when the virtual machine is frozen.
Optionally, the system further comprises a prompting unit and a confirming unit;
the prompting unit is used for displaying the prompting information of the IO operation of the target data disk when the IO operation of the target data disk exists;
and the confirming unit is used for triggering the acquiring unit to execute the step of calling a path acquiring rule matched with the system type of the virtual machine according to the system type of the virtual machine corresponding to the target data disk so as to acquire the mounting point of the target data disk on the virtual machine when receiving the unloading confirming instruction of the target data disk.
The description of the features in the embodiment corresponding to fig. 2 may refer to the related description of the embodiment corresponding to fig. 1, and is not repeated here.
According to the technical scheme, the unloading instruction of the target data disk is received; and judging whether the target data disk has IO operation or not. When the target data disk has IO operation, if the unloading operation of the target data disk is executed forcibly, the target data disk may be damaged or user data may be lost. In order to ensure the safety of unloading the target data disk, a path acquisition rule matched with the type of the virtual machine system can be called according to the type of the virtual machine system corresponding to the target data disk, so as to acquire a mount point of the target data disk on the virtual machine. The mount points refer to the distribution positions of the target data disks on the cloud platform on the virtual machine, and the freezing operation is performed on the file system corresponding to the mount points, so that all IO operations on the target data disks are suspended, and the user data corresponding to the IO operations cannot be affected by the unloading operation performed on the target data disks. Therefore, when the target data disk has no IO operation or the freezing operation is performed on the file system corresponding to the mount point, the unloading operation can be performed on the target data disk. The technical scheme can support the safe unloading of the data disk of the virtual machine of various operating systems, prevent serious problems of data disk unloading failure or user data loss and the like caused by IO operation when a user unloads the data disk, and realize the safe unloading of the data disk.
Fig. 3 is a schematic hardware structure diagram of an offloading device 30 for a virtual machine data disk according to an embodiment of the present invention, including:
a memory 31 for storing a computer program;
a processor 32 for executing a computer program to implement the steps of the method for offloading a data disk of a virtual machine as described in any of the embodiments above.
The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method for unloading a data disk of a virtual machine according to any of the above embodiments are implemented.
The method, the device and the computer-readable storage medium for unloading the data disk of the virtual machine provided by the embodiment of the invention are described in detail above. The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

Claims (10)

1. A method for unloading a data disk of a virtual machine is characterized by comprising the following steps:
receiving an unloading instruction of a target data disk;
judging whether IO operation exists in the target data disk;
when IO operation exists in the target data disk, calling a path obtaining rule matched with the type of the virtual machine system according to the type of the virtual machine system corresponding to the target data disk so as to obtain a mounting point of the target data disk on the virtual machine;
performing freezing operation on the file system corresponding to the mount point;
and when the target data disk does not have IO operation or freezing operation is performed on the file system corresponding to the mount point, unloading operation is performed on the target data disk.
2. The method of claim 1, wherein the invoking a path acquisition rule matching the virtual machine system type according to the virtual machine system type corresponding to the target data disk to acquire a mount point of the target data disk on a virtual machine comprises:
when the virtual machine system type is a windows system, calling a preset QGA instruction to acquire mounting point information of a file system and a disk serial number corresponding to the target data disk;
and determining the mounting point of the target data disk on the virtual machine according to the mounting point information of the file system and the disk serial number.
3. The method of claim 1, wherein the invoking a path acquisition rule matching the virtual machine system type according to the virtual machine system type corresponding to the target data disk to acquire a mount point of the target data disk on a virtual machine comprises:
when the virtual machine system type is a non-windows system, calling a preset virtual machine file script to acquire mounting point information of the file system and a partition path corresponding to the target data disk;
inquiring the corresponding disk partition information of the virtual machine under the partition path;
determining disk information of the target data disk mapped on the virtual machine according to the serial number of the target data disk on the cloud platform;
matching the disk information with the disk partition information to determine target disk partition information corresponding to the target data disk on the virtual machine;
and determining the mounting point of the target data disk on the virtual machine according to the partition information of the target disk and the mounting point information of the file system.
4. The method of unloading a virtual machine data disk of claim 1, further comprising:
when the virtual machine is frozen, performing a unfreezing operation on the virtual machine after performing an unloading operation on the target data disk.
5. The method for unloading the data disk of the virtual machine according to any one of claims 1 to 4, wherein before the invoking a path obtaining rule matched with the virtual machine system type according to the virtual machine system type corresponding to the target data disk to obtain the mount point of the target data disk on the virtual machine, the method further includes:
when the target data disk has IO operation, displaying prompt information that the target data disk has IO operation;
and when receiving an unloading confirmation instruction of the target data disk, executing the step of calling a path acquisition rule matched with the virtual machine system type according to the virtual machine system type corresponding to the target data disk so as to acquire a mounting point of the target data disk on the virtual machine.
6. The unloading device of the virtual machine data disk is characterized by comprising a receiving unit, a judging unit, an acquiring unit, a freezing unit and an unloading unit;
the receiving unit is used for receiving an unloading instruction of the target data disk;
the judging unit is used for judging whether IO operation exists in the target data disk;
the obtaining unit is configured to, when the target data disk has IO operation, invoke a path obtaining rule matched with a virtual machine system type according to the virtual machine system type corresponding to the target data disk, so as to obtain a mount point of the target data disk on a virtual machine;
the freezing unit is used for performing freezing operation on the file system corresponding to the mount point;
the unloading unit is configured to, when there is no IO operation in the target data disk or after a freezing operation is performed on the file system corresponding to the mount point, perform an unloading operation on the target data disk.
7. The offload device for the data disk of the virtual machine according to claim 6, wherein the obtaining unit comprises a calling subunit and a determining subunit;
the calling subunit is configured to, when the virtual machine system type is a windows system, call a preset QGA instruction to obtain mount point information of a file system and a disk serial number corresponding to the target data disk;
and the determining subunit is configured to determine, according to the mounting point information of the file system and the disk serial number, a mounting point of the target data disk on the virtual machine.
8. The offload device for the data disk of the virtual machine according to claim 6, wherein the obtaining unit comprises a calling subunit, a querying subunit, a mapping subunit, a matching subunit, and a determining subunit;
the calling subunit is configured to, when the virtual machine system type is a non-windows system, call a preset virtual machine file script to obtain mount point information of a file system and a partition path corresponding to the target data disk;
the inquiring subunit is configured to inquire the disk partition information corresponding to the virtual machine under the partition path;
the mapping subunit is configured to determine, according to a serial number of the target data disk on the cloud platform, disk information of the target data disk mapped on the virtual machine;
the matching subunit is configured to match the disk information with the disk partition information, and determine target disk partition information corresponding to the target data disk on the virtual machine;
and the determining subunit is configured to determine a mount point of the target data disk on the virtual machine according to the partition information of the target disk and the mount point information of the file system.
9. An unloading device for a data disk of a virtual machine, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the method for offloading data disk of virtual machine according to any of claims 1 to 5.
10. A computer-readable storage medium, having stored thereon a computer program which, when executed by a processor, performs the steps of the method for offloading a virtual machine data disk of any of claims 1-5.
CN202010889289.2A 2020-08-28 2020-08-28 Method, device and medium for unloading data disk of virtual machine Active CN112015350B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010889289.2A CN112015350B (en) 2020-08-28 2020-08-28 Method, device and medium for unloading data disk of virtual machine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010889289.2A CN112015350B (en) 2020-08-28 2020-08-28 Method, device and medium for unloading data disk of virtual machine

Publications (2)

Publication Number Publication Date
CN112015350A true CN112015350A (en) 2020-12-01
CN112015350B CN112015350B (en) 2022-03-22

Family

ID=73503901

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010889289.2A Active CN112015350B (en) 2020-08-28 2020-08-28 Method, device and medium for unloading data disk of virtual machine

Country Status (1)

Country Link
CN (1) CN112015350B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102479057A (en) * 2010-11-29 2012-05-30 英业达股份有限公司 Method for changing storage space state
US20120179885A1 (en) * 2010-11-17 2012-07-12 Wade Gregory L Write control system
CN103336728A (en) * 2013-05-08 2013-10-02 上海爱数软件有限公司 Disk data recovery method
CN106126272A (en) * 2016-06-15 2016-11-16 北京小米移动软件有限公司 File system discharging method and device
CN106502721A (en) * 2016-09-26 2017-03-15 华为技术有限公司 A kind of order discharging method, device and physical machine
US9823865B1 (en) * 2015-06-30 2017-11-21 EMC IP Holding Company LLC Replication based security
CN107463404A (en) * 2017-08-03 2017-12-12 浪潮(北京)电子信息产业有限公司 Increase the method and system of configuration file in a kind of system to virtual machine file
CN109388478A (en) * 2018-11-01 2019-02-26 郑州云海信息技术有限公司 Method and apparatus for migrating virtual machine in OpenStack environment

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120179885A1 (en) * 2010-11-17 2012-07-12 Wade Gregory L Write control system
CN102479057A (en) * 2010-11-29 2012-05-30 英业达股份有限公司 Method for changing storage space state
CN103336728A (en) * 2013-05-08 2013-10-02 上海爱数软件有限公司 Disk data recovery method
US9823865B1 (en) * 2015-06-30 2017-11-21 EMC IP Holding Company LLC Replication based security
CN106126272A (en) * 2016-06-15 2016-11-16 北京小米移动软件有限公司 File system discharging method and device
CN106502721A (en) * 2016-09-26 2017-03-15 华为技术有限公司 A kind of order discharging method, device and physical machine
CN107463404A (en) * 2017-08-03 2017-12-12 浪潮(北京)电子信息产业有限公司 Increase the method and system of configuration file in a kind of system to virtual machine file
CN109388478A (en) * 2018-11-01 2019-02-26 郑州云海信息技术有限公司 Method and apparatus for migrating virtual machine in OpenStack environment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
汪进奇: "基于虚拟磁盘的数据保护管理系统的设计与实现", 《宁夏机械》 *

Also Published As

Publication number Publication date
CN112015350B (en) 2022-03-22

Similar Documents

Publication Publication Date Title
CN105468433B (en) A kind of acquisition methods and system of magnetic disk of virtual machine data
CN108241498B (en) Vehicle-mounted equipment upgrading method and device and vehicle
CN107682172B (en) Control center device, service system processing method and medium
CN112003917B (en) File storage management method, system, device and medium
CN106547645B (en) Method for automatically restoring image file and server system
CN115794257B (en) System starting method, device, electronic equipment and storage medium
CN110308880B (en) Log printing method, system, computer device and computer readable storage medium
CN112015350B (en) Method, device and medium for unloading data disk of virtual machine
CN110881224B (en) Network long connection method, device, equipment and storage medium
CN112818336A (en) Data access method, data access device and computer readable storage medium
CN104461655A (en) Method for automatically selecting application installation position and mobile terminal
CN106130815B (en) Board level testing method and device
CN113608767A (en) Service upgrade processing method, electronic device and storage medium
CN113760631B (en) Page loading time length determining method, device, equipment and storage medium
CN110888686B (en) Application program starting method, device and storage medium
CN111475220B (en) Cold start method and device, electronic equipment and computer storage medium
CN105511848B (en) Detection method and device for dynamic link library
CN110059071B (en) Data comparison monitoring method, system, equipment and medium based on storage process
CN109800567B (en) Method and device for monitoring foreground application starting and terminal equipment
CN113032196A (en) Chip testing method and device
CN112231290A (en) Method, device and equipment for processing local log and storage medium
CN113515299A (en) Software development kit SDK hot upgrading method, device, equipment and storage medium
CN117478721B (en) Connection method, device, equipment and storage medium for control program
CN105320853A (en) Information monitoring method and device and terminal
CN116502235B (en) TMS remote management method and system

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
TR01 Transfer of patent right

Effective date of registration: 20240523

Address after: Room s311, S05 / F, Langchao Science Park, 1036 Langchao Road, high tech Zone, Jinan City, Shandong Province, 250101

Patentee after: Inspur(Jinan)Data Technology Co.,Ltd

Country or region after: China

Address before: 100085 5 / F, building C, No.2, Shangdi Information Road, Haidian District, Beijing

Patentee before: Beijing Inspur Data Technology Co.,Ltd.

Country or region before: China