Virtual environment disk operation method and device
Technical Field
The invention relates to a computer software application technology, in particular to a virtual environment disk operation method and device.
Background
With the further development of the internet technology and the popularization of cloud computing application, functions such as creation and mounting of a virtual machine disk are realized in various existing cloud computing platforms. After the disk or the extended disk is mounted, because processing such as formatting and/or partitioning is required before the mounted or extended disk is used, a user still needs to log in the virtual machine manually to perform operation of a disk command, and the virtual environment disk management is complex.
Disclosure of Invention
The invention provides a virtual environment disk operation method and device, which realize disk operation on a virtual machine through management of disk information of the virtual machine.
In order to achieve the purpose of the invention, the technical scheme adopted by the invention is as follows:
a virtual environment disk operation method is applied to a virtual machine agent instruction receiver and comprises the following steps:
acquiring or receiving virtual machine disk operation command information, wherein the virtual machine disk operation command information is used for configuring a disk to be operated;
executing the operation corresponding to the instruction content of the operation command information on the disk to be operated;
and feeding back the instruction content execution result of the virtual machine operation command information to the disk processor.
Preferably, the obtaining or receiving the virtual machine disk operation command information includes:
monitoring command messages of the message queue;
detecting whether the monitored command message comprises the unique identifier of the virtual machine, detecting whether the command message conforms to the message format of the disk operation command message when the monitored command message comprises the unique identifier of the virtual machine, and determining to acquire or receive the disk operation command message of the virtual machine when the monitored command message conforms to the message format of the disk operation command message.
Preferably, the operation corresponding to the instruction content of the operation command information executed by the disk to be operated includes at least one of:
selecting a disk to be operated according to the disk number information in the disk operation command;
creating a corresponding partition according to the disk partition information in the disk operation command, and marking the activity state of the partition;
distributing a drive number or a mounting point according to mounting information in the disk operation command;
according to the disk capacity expansion information in the disk operation command, executing expansion operation on the specified disk;
and executing formatting operation on the specified disk according to the disk formatting information in the disk operation command.
In order to solve the above technical problem, the present invention further provides a virtual environment disk operating method, applied to a disk processor, including:
determining the disk operation command information of the virtual machine according to a disk information table of the virtual machine, wherein the disk information table of the virtual machine comprises a mirror image and disk use information of the virtual machine, and is used for initializing the disk information of the virtual machine by the mirror image; the virtual machine disk operation command information is used for configuring a disk to be operated;
sending the virtual machine disk operation command information to a virtual machine agent instruction receiver;
and receiving the instruction content execution result of the virtual machine operation command information fed back by the virtual machine agent instruction receiver.
Preferably, determining the virtual machine disk operation command information according to the virtual machine disk information table includes:
and matching the disk command library to generate virtual machine disk operation command information according to the virtual machine disk information table.
Preferably, the sending the virtual machine disk operation command information to the virtual machine agent instruction acceptor comprises:
and formatting the disk operation command information, assembling the unique identifier of the virtual machine and the formatted disk operation command information, and sending the assembled unique identifier and the formatted disk operation command information to a message queue.
Preferably, after receiving the instruction content execution result of the virtual machine operation command information fed back by the virtual machine agent instruction acceptor, the method further includes:
if the execution result is successful, storing the result information of the partition and/or mounting and/or formatting and/or expanding of the disk in the execution result into an operation record log of the virtual machine;
and if the execution result is failure, manually analyzing the fed-back error code and the error information.
In order to solve the above technical problem, the present invention further provides a virtual environment disk operating apparatus, disposed at a virtual machine proxy instruction receiver, including:
the communication module is used for acquiring or receiving virtual machine disk operation command information, and the virtual machine disk operation command information is used for configuring a disk to be operated;
the execution module is configured to execute the operation corresponding to the instruction content of the operation command information on the disk to be operated;
the communication module is further configured to feed back an instruction content execution result of the virtual machine operation command information to the disk processor.
Preferably, the communication module includes:
the monitoring unit is arranged for monitoring the command message of the message queue;
and the detection unit is used for detecting whether the monitored command message comprises the unique identifier of the virtual machine, detecting whether the command message conforms to the message format of the disk operation command message when the monitored command message comprises the unique identifier of the virtual machine, and determining to acquire or receive the disk operation command message of the virtual machine when the monitored command message conforms to the message format of the disk operation command message.
Preferably, the operation corresponding to the instruction content of the operation command information executed by the execution module on the disk to be operated includes at least one of the following:
selecting a disk to be operated according to the disk number information in the disk operation command;
creating a corresponding partition according to the disk partition information in the disk operation command, and marking the activity state of the partition;
distributing a drive number or a mounting point according to mounting information in the disk operation command;
according to the disk capacity expansion information in the disk operation command, executing expansion operation on the specified disk;
and executing formatting operation on the specified disk according to the disk formatting information in the disk operation command.
In order to solve the above technical problem, the present invention further provides a virtual environment disk operating apparatus, disposed in a disk processor, including:
the command library module is arranged for determining the disk operation command information of the virtual machine according to a disk information table of the virtual machine, wherein the disk information table of the virtual machine comprises a mirror image and disk use information of the virtual machine and is used for initializing the disk information of the virtual machine by the mirror image; the virtual machine disk operation command information is used for configuring a disk to be operated;
the instruction output module is used for sending the virtual machine disk operation command information to a virtual machine agent instruction receiver;
and the disk management module is used for receiving the instruction content execution result of the virtual machine operation command information fed back by the virtual machine agent instruction receiver.
Preferably, the determining, by the command library module, the virtual machine disk operation command information according to the virtual machine disk information table includes:
and matching the disk command library to generate virtual machine disk operation command information according to the virtual machine disk information table.
Preferably, the sending the virtual machine disk operation command information to the virtual machine agent command acceptor by the command output module comprises:
and formatting the disk operation command information, assembling the unique identifier of the virtual machine and the formatted disk operation command information, and sending the assembled unique identifier and the formatted disk operation command information to a message queue.
Preferably, the disk management module is further configured to:
if the execution result is successful, storing the result information of the partition and/or mounting and/or formatting and/or expanding of the disk in the execution result into an operation record log of the virtual machine;
and if the execution result is failure, manually analyzing the fed-back error code and the error information.
Compared with the prior art, the invention has the following beneficial effects:
according to the technical scheme, when the virtual machine is created through mirroring, a plurality of disks are created and mounted on the virtual machine, and partitioning, formatting and mounting are carried out to the designated disk identifier or directory according to requirements. Or when the disk of the existing virtual machine is not satisfied, mounting a new disk or expanding an old disk, and partitioning, formatting and mounting to a specified disk character or directory according to requirements.
Drawings
FIG. 1 is a flowchart of a method for operating a virtual environment disk according to an embodiment of the present invention;
FIG. 2 is a flowchart of another virtual environment disk operating method according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a virtual environment disk operating apparatus according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of another virtual environment disk operating apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of disk processing in a virtual environment according to embodiment 1 of the present invention;
fig. 6 is a flowchart of virtual environment disk processing according to embodiment 1 of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following description of the embodiments of the present invention with reference to the accompanying drawings is provided, and it should be noted that, in the case of conflict, features in the embodiments and the embodiments in the present application may be arbitrarily combined with each other.
As shown in fig. 1, an embodiment of the present invention provides a virtual environment disk operating method, applied to a virtual machine proxy instruction acceptor, including:
s101, acquiring or receiving virtual machine disk operation command information, wherein the virtual machine disk operation command information is used for configuring a disk to be operated;
s102, executing operation corresponding to the instruction content of the operation command information on the disk to be operated;
s103, feeding back the instruction content execution result of the virtual machine operation command information to the disk processor.
The virtual machine proxy instruction acceptor may be a client installed on the virtual machine, or may be a device provided on the virtual machine. The method is used for appointing to accept the disk operation command, execute the command and return the command result aiming at the virtual machine.
The obtaining or receiving of the virtual machine disk operation command information in step S101 may be performed in the following manner:
monitoring command messages of the message queue;
detecting whether the monitored command message comprises the unique identifier of the virtual machine, detecting whether the command message conforms to the message format of the disk operation command message when the monitored command message comprises the unique identifier of the virtual machine, and determining to acquire or receive the disk operation command message of the virtual machine when the monitored command message conforms to the message format of the disk operation command message.
In the embodiment of the invention, the unique identification is carried out on the virtual machine, the unique message queue of the virtual machine is established through the unique identification, the virtual machine agent instruction receiver only monitors the unique message queue of the virtual machine where the virtual machine agent instruction receiver is located, the type distinction is added aiming at the condition that the disk operation instruction information sent to the virtual machine agent instruction receiver is formatted, and the virtual machine agent instruction receiver only executes the command type which can be identified.
In step S102, the operation corresponding to the instruction content of the operation command information executed by the disk to be operated includes at least one of:
selecting a disk to be operated according to the disk number information in the disk operation command;
creating a corresponding partition according to the disk partition information in the disk operation command, and marking the activity state of the partition;
distributing a drive number or a mounting point according to mounting information in the disk operation command;
according to the disk capacity expansion information in the disk operation command, executing expansion operation on the specified disk;
and executing formatting operation on the specified disk according to the disk formatting information in the disk operation command.
The virtual machine disk operation command information of the embodiment of the invention comprises partition information of a newly added disk, mounting information (disk identifier is distributed or mounted to a folder) and formatting information; mounting information (disk signature is allocated or mounted to a folder) after the disk is mounted to the virtual machine again; and expanding the capacity expansion information of the mounted disk.
As shown in fig. 2, an embodiment of the present invention further provides a virtual environment disk operation method, applied to a disk processor, including:
s201, determining virtual machine disk operation command information according to a virtual machine disk information table, wherein the virtual machine disk information table comprises a mirror image and disk use information of a virtual machine, and is used for initializing disk information of the virtual machine by the mirror image; the virtual machine disk operation command information is used for configuring a disk to be operated;
s202, sending the virtual machine disk operation command information to a virtual machine agent instruction receiver;
s203, receiving the instruction content execution result of the virtual machine operation instruction information fed back by the virtual machine agent instruction acceptor.
The disk processor can be a client installed on the upper computer or a device arranged on the upper computer.
When the virtual machine is created by using the mirror image, the disk information of the virtual machine is initialized through the virtual machine disk information table of the mirror image.
The contents contained in the disk information table of the virtual machine may be as shown in table 1:
TABLE 1
Serial number
|
Field information
|
Description of the invention
|
1
|
Inner code
|
Unique ID 32-bit uuid of magnetic disk
|
2
|
Disk name
|
Name information of magnetic disk
|
3
|
Using object designations
|
Virtual machine mark or mirror mark for mounting disk
|
4
|
Size and breadth
|
Size of magnetic disk (GB)
|
5
|
Hanging point
|
Mounting point of magnetic disk (the second disk under windows)
|
|
|
|
The contents contained in the virtual machine disk operation command information may be as shown in table 2:
TABLE 2
Serial number
|
Field information
|
Description of the invention
|
1
|
Inner code
|
Unique 32-bit uuid for disk partition information
|
2
|
Disk label
|
The unique designation of a disk, representing the partition of that disk
|
3
|
The first table partition
|
The partition is the second partition of the disk
|
4
|
Partition size
|
Size of the partition (GB)
|
5
|
Mounting path
|
Partition mounting path (disc symbol or folder)
|
|
|
|
Step S201 determines, according to the virtual machine disk information table, that the virtual machine disk operation command information includes:
and matching the disk command library to generate virtual machine disk operation command information according to the virtual machine disk information table.
The step S202 of sending the virtual machine disk operation command information to a virtual machine agent instruction acceptor includes:
and formatting the disk operation command information, assembling the unique identifier of the virtual machine and the formatted disk operation command information, and sending the assembled unique identifier and the formatted disk operation command information to a message queue.
Step S203 is followed by:
if the execution result is successful, storing the result information of the partition and/or mounting and/or formatting and/or expanding of the disk in the execution result into an operation record log of the virtual machine;
and if the execution result is failure, manually analyzing the fed-back error code and the error information.
The log display page of the embodiment of the invention is as follows:
and (3) executing the result:
microsoft DiskPart version 6.1.7601 copyright (C) 1999-: ZLABU2VF-MASTER disk 1 is now the selected disk. DiskPart successfully cleared the disk. Diskpart successfully created the specified partition. Partition 1 is now the selected partition. DiskPart marks the current partition as active. DiskPart successfully assigns a drive number or load point. 0 percent completed 100 percent completed distPart successfully formats the volume. Exit diskpart.start install pyodbc.step 1: chec
And (3) executing the result:
microsoft DiskPart version 6.1.7601 copyright (C) 1999-: ZLABU2VF-MASTER volume 3 is the selected volume. DiskPart successfully expands volumes. Exit diskpart.
As shown in fig. 3, an embodiment of the present invention provides a virtual environment disk operating apparatus, disposed in a virtual machine proxy instruction acceptor, including:
the communication module is used for acquiring or receiving virtual machine disk operation command information, and the virtual machine disk operation command information is used for configuring a disk to be operated;
the execution module is configured to execute the operation corresponding to the instruction content of the operation command information on the disk to be operated;
the communication module is further configured to feed back an instruction content execution result of the virtual machine operation command information to the disk processor.
The communication module includes:
the monitoring unit is arranged for monitoring the command message of the message queue;
and the detection unit is used for detecting whether the monitored command message comprises the unique identifier of the virtual machine, detecting whether the command message conforms to the message format of the disk operation command message when the monitored command message comprises the unique identifier of the virtual machine, and determining to acquire or receive the disk operation command message of the virtual machine when the monitored command message conforms to the message format of the disk operation command message.
The execution module executes the operation corresponding to the instruction content of the operation command information on the disk to be operated, and the operation comprises at least one of the following operations:
selecting a disk to be operated according to the disk number information in the disk operation command;
creating a corresponding partition according to the disk partition information in the disk operation command, and marking the activity state of the partition;
distributing a drive number or a mounting point according to mounting information in the disk operation command;
according to the disk capacity expansion information in the disk operation command, executing expansion operation on the specified disk;
and executing formatting operation on the specified disk according to the disk formatting information in the disk operation command.
As shown in fig. 4, an embodiment of the present invention further provides a virtual environment disk operating apparatus, disposed in a disk processor, including:
the command library module is arranged for determining the disk operation command information of the virtual machine according to a disk information table of the virtual machine, wherein the disk information table of the virtual machine comprises a mirror image and disk use information of the virtual machine and is used for initializing the disk information of the virtual machine by the mirror image; the virtual machine disk operation command information is used for configuring a disk to be operated;
the instruction output module is used for sending the virtual machine disk operation command information to a virtual machine agent instruction receiver;
and the disk management module is used for receiving the instruction content execution result of the virtual machine operation command information fed back by the virtual machine agent instruction receiver.
The command library module determines the virtual machine disk operation command information according to the virtual machine disk information table, and comprises the following steps:
and matching the disk command library to generate virtual machine disk operation command information according to the virtual machine disk information table.
The step that the instruction output module sends the virtual machine disk operation command information to the virtual machine proxy instruction receiver comprises the following steps:
and formatting the disk operation command information, assembling the unique identifier of the virtual machine and the formatted disk operation command information, and sending the assembled unique identifier and the formatted disk operation command information to a message queue.
The disk management module is further configured to:
if the execution result is successful, storing the result information of the partition and/or mounting and/or formatting and/or expanding of the disk in the execution result into an operation record log of the virtual machine;
and if the execution result is failure, manually analyzing the fed-back error code and the error information.
Example 1
As shown in fig. 5 and fig. 6, in this embodiment, a window operating system is combined to implement a disk processing function, and a virtual disk management page may be used to transmit a command by using a message queue (rabbitmq), so as to implement a remote disk operation, which specifically includes:
the disk processor determines virtual machine disk operation command information according to a virtual machine disk information table, wherein the virtual machine disk information table comprises a mirror image and disk use information of a virtual machine and is used for initializing disk information of the virtual machine by the mirror image; the virtual machine disk operation command information comprises mounting position information and partition information of the disk;
the virtual machine agent instruction receiver acquires or receives virtual machine disk operation command information, wherein the virtual machine disk operation command information comprises mounting position information and partition information of the disk;
the virtual machine agent instruction receiver partitions the virtual machine disk according to the virtual machine operation command information and mounts the partitioned disk to the mounting position;
and the virtual machine agent instruction receiver feeds back the instruction content execution result of the virtual machine operation command information to the disk processor.
The virtual disk management page can be used for receiving disk management settings of a user and displaying disk information and partition information under the virtual machine to the user.
Although the embodiments of the present invention have been described above, the contents thereof are merely embodiments adopted to facilitate understanding of the technical aspects of the present invention, and are not intended to limit the present invention. It will be apparent to persons skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined in the appended claims.