Disk processing method and device
By configuring the disk serial number for the virtual machine and providing it to the virtual machine agent service, the problem of the high risk of misoperation when issuing disk numbers on the cloud management platform is solved, and the accuracy and security of disk processing are achieved.
Patent Information
- Application Number
- CN202311823122.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-27
- Publication Date
- 2025-06-27
AI Technical Summary
In the prior art, there is a high risk of misoperation in processing disks through disk numbers issued by cloud management platforms, especially when the virtual machine is turned off, disk formatting and expansion messages cannot be delivered in time, which may lead to loss of user data.
By configuring disk information of the to-process disk for the virtual machine, including the disk serial number, this information is provided to the virtual machine agent service. The virtual machine agent service obtains the corresponding disk number based on the disk serial number and performs corresponding processing on the to-process disk.
Obtaining the disk number through the disk serial number provided by the cloud management platform reduces the risk of misoperation, ensures the accuracy and security of disk processing, and avoids the loss of user data.
Smart Images

Figure CN120215808A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the field of communication technologies, and more specifically, to a disk processing method and apparatus. Background Art
[0002] In the related art, disk information (disk number, disk partition number, disk capacity) is mainly sent from a cloud management platform to an online virtual machine (VM) internally, and automatic disk formatting or expansion is performed based on corresponding parameters. However, these solutions have the following defects: (1) When performing disk formatting or expansion based on the disk number, there is a risk of incorrect formatting (after adding a disk and then deleting the previous disk, the disk number of the newly added disk will become the disk number of the deleted disk), and disks are discriminated by disk capacity (there may be multiple disks with the same capacity); (2) Disks mounted on a VM in the closed state do not receive disk formatting and expansion messages. If the VM starts automatic formatting and expansion, it depends on the internal discrimination of whether there are partitions on the disk and the judgment of the file system, which may lead to incorrect judgment. At this time, formatting may cause user data loss; (3) The cloud management platform may send formatting messages multiple times, and some users do not want their disks to be formatted.
[0003] Regarding the problem of a high risk of incorrect operations when processing disks according to the disk numbers sent by the cloud management platform in the related art, no solution has been proposed yet. Summary of the Invention
[0004] Embodiments of the present application provide a disk processing method and apparatus to at least solve the problem of a high risk of incorrect operations when processing disks according to the disk numbers sent by the cloud management platform in the related art.
[0005] According to an embodiment of the present application, a disk processing method is provided, which is applied to a cloud management platform. The method includes:
[0006] Configuring disk information of a disk to be processed for a virtual machine, where the disk information includes a disk serial number;
[0007] Providing the disk information to the virtual machine proxy service, where the disk serial number is used for the virtual machine proxy service to obtain a corresponding disk number and process the disk to be processed corresponding to the disk number.
[0008] According to another embodiment of the present application, a disk processing method is further provided, which is applied to a virtual machine proxy service. The method includes:
[0009] Obtaining disk information of a disk to be processed configured by a cloud management platform, where the disk information includes a disk serial number;
[0010] Obtaining a disk number according to the disk serial number;
[0011] Process the to-be-processed disk corresponding to the disk number.
[0012] According to another embodiment of the present application, there is also provided a disk processing device, which is applied to a cloud management platform. The device includes:
[0013] A configuration module, configured to configure disk information of a to-be-processed disk for a virtual machine, where the disk information includes a disk serial number;
[0014] A providing module, configured to provide the disk information to the virtual machine proxy service, where the disk serial number is used for the virtual machine proxy service to obtain a corresponding disk number and process the to-be-processed disk corresponding to the disk number.
[0015] According to another embodiment of the present application, there is also provided a disk processing device, which is applied to a virtual machine proxy service. The device includes:
[0016] A first obtaining module, configured to obtain disk information of a to-be-processed disk configured by a cloud management platform, where the disk information includes a disk serial number;
[0017] A second obtaining module, configured to obtain a disk number according to the disk serial number;
[0018] A processing module, configured to process the to-be-processed disk corresponding to the disk number.
[0019] According to still another embodiment of the present application, there is also provided a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps in any one of the above method embodiments when running.
[0020] According to still another embodiment of the present application, there is also provided an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0021] In the embodiment of the present application, disk information of a to-be-processed disk is configured for a virtual machine, where the disk information includes a disk serial number; the disk information is provided to the virtual machine proxy service, where the disk serial number is used for the virtual machine proxy service to obtain a corresponding disk number and process the to-be-processed disk corresponding to the disk number, which can solve the problem in the related art that when processing a disk according to the disk number issued by the cloud management platform, the risk of misoperation is relatively high. By obtaining the disk number through the disk serial number provided by the cloud management platform, and then processing the disk corresponding to the disk number, the risk of misoperation is greatly reduced. Description of the Drawings
[0022] Figure 1 is the hardware structure block diagram of a computer device for the disk processing method according to an embodiment of the present application;
[0023] Figure 2 is the process flow of the disk processing method according to an embodiment of the present application Figure 1 ;
[0024] Figure 3 is the process flow of the disk processing method according to an embodiment of the present application Figure 2 ;
[0025] Figure 4 is the architecture diagram of the disk processing system of the cloud desktop according to this embodiment;
[0026] Figure 5 is the schematic diagram of the disk information of the virtual machine configuration file according to this embodiment;
[0027] Figure 6 is the schematic diagram of finding the corresponding disk number through the serial number of the disk of the virtual machine according to this embodiment;
[0028] Figure 7 is the schematic diagram of the injection information of the virtual machine configuration file according to this embodiment;
[0029] Figure 8 is the schematic diagram of the injection information in the windows registry according to this embodiment;
[0030] Figure 9 is the flow chart of adding a disk to an online virtual machine according to this embodiment;
[0031] Figure 10 is the flow chart of the virtual machine reading the injection information according to this embodiment;
[0032] Figure 11 is the flow chart of formatting or expanding the disk when a new disk is added to the virtual machine according to this embodiment;
[0033] Figure 12 is the flow chart of formatting and expanding the windows virtual machine proxy service according to this embodiment;
[0034] Figure 13 is the flow chart of formatting and expanding the linux virtual machine proxy service according to this embodiment;
[0035] Figure 14 is the flow chart of formatting and expanding without depending on whether the disk is formatted or the expansion label according to this embodiment;
[0036] Figure 15 is the block of the disk processing device according to an embodiment of the present application Figure 1 ;
[0037] Figure 16 is the block diagram of the disk processing device according to an embodiment of the present application Figure 2 . Specific Embodiments
[0038] In the following, embodiments of the present application will be described in detail with reference to the accompanying drawings and in conjunction with the embodiments.
[0039] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence.
[0040] The method embodiments provided in the embodiments of the present application can be executed in a computer device or a similar computing device. Taking the operation on a computer device as an example,[[]] Figure 1 is the hardware structure block diagram of the computer device for the disk processing method according to an embodiment of the present application. As Figure 1 shown, the computer device may include one or more ( Figure 1 only one is shown in [[]]) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device) and a memory 104 for storing data. Among them, the above-mentioned computer device may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 the structure shown in [[]] is only schematic, and it does not limit the structure of the above-mentioned computer device. For example, the computer device may further include more or fewer components than those shown in Figure 1 [[]], or have a different configuration from that shown in Figure 1 [[]].[[]]
[0041] The memory 104 can be used to store computer programs. For example, software programs and modules of application software, such as the computer program corresponding to the disk processing method in the embodiments of the present application. The processor 102 executes various functional applications and single-board matching by running the computer program stored in the memory 104, that is, the above-mentioned method is implemented. The memory 104 may include a high-speed random access memory, and may further include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely set relative to the processor 102, and these remote memories may be connected to the computer device through a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.
[0042] The transmission device 106 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by a communication provider of a computer device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, abbreviated as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a Radio Frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0043] In this embodiment, a disk processing method running on the above-mentioned computer device is provided. Figure 2 It is the flow of the disk processing method according to the embodiment of the present application. Figure 1 , such as Figure 2 shown, applied to the cloud management platform, the process includes the following steps:
[0044] Step S202, configure the disk information of the disk to be processed for the virtual machine, where the disk information includes the disk serial number;
[0045] Step S204, provide the disk information to the virtual machine proxy service, where the disk serial number is used for the virtual machine proxy service to obtain the corresponding disk number and process the disk to be processed corresponding to the disk number.
[0046] Through the above steps S202 to S204, it is possible to solve the problem in the related art that when processing a disk according to the disk number issued by the cloud management platform, the risk of misoperation is relatively large. The disk number is obtained through the disk serial number provided by the cloud management platform, and then the disk corresponding to the disk number is processed, greatly reducing the risk of misoperation.
[0047] In the embodiment of the present application, the above step S202 may specifically include: configuring the disk serial number in the configuration file of the virtual machine. Further, if the virtual machine is in an online state, configure the disk serial number in the disk item of the virtual machine's configuration file; if the virtual machine is in a closed state, configure the disk serial number in the disk item of the virtual machine's configuration file and configure the disk serial number under the smbios configuration item of the virtual machine's configuration file.
[0048] In the embodiment of the present application, the above step S204 may specifically include: if the virtual machine is in an online state, send the disk information to the virtual machine proxy service; if the virtual machine is in a closed state, inject the disk information into the configuration file so that the virtual machine can obtain the disk information from the bios configuration item of the configuration file after being started. Specifically, for the bios configuration item, it is the bios registry in a Windows virtual machine and the bios configuration file in a Linux virtual machine.
[0049] The disk information in this embodiment further includes a disk processing label, which is used to instruct the virtual machine agent service to perform corresponding processing. The disk processing label includes a formatting label and an expansion label.
[0050] This embodiment provides a secure cloud desktop disk expansion or formatting solution. By configuring the same disk serial number as the disk uuid in the disk item of the virtual machine configuration file, and then transmitting the disk information to be operated to the virtual machine agent service through message pass-through or online message distribution. The virtual machine agent determines the disk number of the disk file to be operated through the disk serial number to ensure that the correct disk file can be operated. The parameters of whether the disk needs to be formatted and expanded are introduced to ensure that the disk will not be formatted and expanded multiple times, thus achieving secure disk management. For offline virtual machines, the disk information of the disk to be operated is injected into the virtual machine internal bios registry by changing the smbios item of the virtual machine configuration file. After the cloud desktop is started, the relevant disk configuration is read through the cloud desktop virtual machine service to format or expand a specific disk to ensure that the disk capacity can meet the user's requirements in any case.
[0051] When a new disk is added to a running virtual machine through the cloud management platform, the user can immediately see the newly added disk inside the virtual machine; when the cloud management platform expands the disk of a running virtual machine, the user can immediately see the increased disk capacity inside the virtual machine; when a new disk is added to an offline virtual machine through the cloud management platform, after the virtual machine is started, the user can immediately see the newly added disk inside the virtual machine; when the cloud management platform expands the disk of an offline virtual machine, after the virtual machine is started, the user can immediately see the increased disk capacity inside the virtual machine. When the virtual machine is online, it only needs to ensure that it can receive messages from the cloud management platform (relevant messages can be received through the serial port or network).
[0052] This application embodiment also provides a disk processing method. Figure 3 It is the flow of the disk processing method according to the embodiment of this application. Figure 2 , as Figure 3 shown, for the virtual machine agent service, the flow includes the following steps:
[0053] Step S302, obtain the disk information of the disk to be processed configured by the cloud management platform, where the disk information includes the disk serial number;
[0054] In the embodiments of the present application, step S302 may specifically include: if the disk information is configured by the cloud management platform when the virtual machine is in the online state, receiving the disk information sent by the cloud management platform; if the disk information is configured by the cloud management platform when the virtual machine is in the shutdown state, obtaining the disk information from the bios configuration item of the configuration file after the virtual machine is started. Specifically, for the bios configuration item, it is the bios registry in the Windows virtual machine and the bios configuration file in the Linux virtual machine.
[0055] Step S304, obtaining the disk number according to the disk serial number;
[0056] Step S306, processing the disk to be processed corresponding to the disk number.
[0057] Through the above steps S302 to S306, the problem of a relatively high risk of misoperation in processing disks according to the disk numbers sent by the cloud management platform in the related art can be solved. The disk number is obtained through the disk serial number provided by the cloud management platform, and then the disk corresponding to the disk number is processed, greatly reducing the risk of misoperation.
[0058] In the embodiments of the present application, step S306 may specifically include:
[0059] S3061, when the disk information further includes a disk processing label, processing the disk to be processed according to the disk processing label;
[0060] In one embodiment, S3061 may specifically include: the above disk processing label includes a formatting label and an expansion label; when the disk processing label is the formatting label, determining whether there is a disk partition on the disk to be processed. If there is no disk partition, creating a disk partition and formatting the disk partition; when the disk processing label is the expansion label, determining whether the remaining capacity of the disk partition of the disk to be processed is greater than or equal to a preset threshold (that is, determining whether there is enough remaining capacity for disk expansion). If the determination result is yes, performing disk expansion on the disk partition.
[0061] In another embodiment, S3061 may specifically include: the above disk processing label includes a formatting label and an expansion label; when the disk processing label is the formatting label, obtaining the disk partition of the disk to be processed and determining whether there is a file system on the disk to be processed; when there is no disk partition and no file system on the disk to be processed, formatting the disk to be processed; when the disk processing label is the expansion label, determining whether the remaining capacity of the disk partition of the disk to be processed is greater than or equal to a preset threshold. If the determination result is yes, performing disk expansion on the disk partition.
[0062] S3062. When the disk information does not include a disk processing label, the disk to be processed is processed according to the formatting marker file of the disk to be processed and the remaining capacity of the disk partition.
[0063] In one embodiment, the above S3062 may specifically include: If the disk information is configured by the cloud management platform when the virtual machine is in an online state, for the disk to be processed without a formatting marker file, a formatting marker file is generated, and when the disk to be processed has no file system and no disk partition, the disk to be processed is formatted; for the disk to be processed with a formatting marker file, it is determined whether the remaining capacity is greater than or greater than a preset threshold, and if the determination result is yes, the disk to be processed is expanded.
[0064] In another embodiment, the above S3062 may specifically include: If the disk information is configured by the cloud management platform when the virtual machine is in a closed state, after the virtual machine is started, all disks are detected. For the disk to be processed without a formatting marker file, a formatting marker file is generated, and when the disk to be processed has no file system and no disk partition, the disk to be processed is formatted; for the disk to be processed with a formatting marker file, it is determined whether the remaining capacity is greater than or equal to a preset threshold, and if the determination result is yes, the disk to be processed is expanded.
[0065] Figure 4 It is an architecture diagram of the disk processing system of the cloud desktop according to this embodiment, as Figure 4 shown, including: a cloud management platform and a virtual machine. Inside the virtual machine, there are a receiving module and a processing module. Among them, the receiving module and the processing module can be one module. The receiving module is mainly used to receive messages sent by the host and read and parse the disk information (disk serial number, disk partition, whether formatting is required, whether expansion is required) in the bios when starting the virtual machine. The processing module is mainly used to query the specified disk number according to the disk serial number in the disk information, and perform corresponding disk operations on the disk according to the disk number and partition information. By the cloud management platform, new disks or expanded disks are added to a specific virtual machine. When the virtual machine is online, a message is sent to the receiving module by sending a message, and the receiving module receives the message and then gives it to the processing module for corresponding disk operations. In the case of being offline, the virtual machine configuration file smbios item is changed to inject the operation information of the disk to be operated, and the receiving module parses the disk information in the bios configuration item and then gives it to the processing module for corresponding disk operations.
[0066] Figure 5 It is a schematic diagram of the disk information of the virtual machine configuration file according to this embodiment, Figure 6 It is a schematic diagram of finding the corresponding disk number through the serial number of the disk of the virtual machine according to this embodiment, as Figure 5 and 6As shown in the figure, taking a Windows virtual machine as an example, only need to configure the serial field (configured as the UUID of the disk) in the disk item of each disk in the virtual machine configuration file (config.xml). Then the virtual machine agent service can find the disk number to be operated through the corresponding disk serial number (the internal disk serial number of the virtual machine is the same as the virtual machine disk UUID). This method is applicable to both Windows and Linux virtual machines. The internal disk serial number of Windows can be obtained through the Windows API or command, and the Linux virtual machine can obtain it through commands or by reading relevant files). Figure 7 It is a schematic diagram of the injection information of the virtual machine configuration file according to this embodiment. Figure 8 It is a schematic diagram in the Windows registry according to the injection information of this embodiment, as Figure 7 and Figure 8 shown, only need to configure the information to be injected in the smbios item in the virtual machine configuration file (config.xml). After the virtual machine starts internally, it can obtain relevant information from the registry or file (Windows virtual machine can obtain relevant injection information from the registry HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS or HKEY_LOCAL_MACHINE\SYSTEM\HardwareConfig\Current; Linux virtual machine can read the bios file in the / sys / devices / virtual / dmi directory or obtain relevant injection information through commands such as dmidecode).
[0067] Figure 9 It is a flowchart of adding a disk to an online virtual machine according to this embodiment, as Figure 9 shown, including:[[]]END]]
[0068] S901, adding a disk to the virtual machine in the cloud management platform;
[0069] S902, creating a disk, changing the virtual machine configuration file, writing the disk information into the configuration file, and adding the UUID of the disk to the serial field; and creating the xml file corresponding to the disk;
[0070] S903, adding the corresponding disk through the (virsh attach-device virtual machine uuid specific disk xml) command. At this time, the online virtual machine can query the disk number of the disk to be operated inside the virtual machine through the disk serial number that is the same as the virtual machine disk UUID).
[0071] Figure 10 It is a flowchart of the virtual machine reading injection information according to this embodiment, as Figure 10 shown, including:
[0072] S1001, Before starting the virtual machine, write the disk information to be operated into the smbios configuration item of the virtual machine configuration file;
[0073] S1002, Start the virtual machine;
[0074] S1003, The virtual machine agent service reads the relevant injection information;
[0075] S1004, Operate on a specific disk according to the injection information.
[0076] Figure 11 It is a flowchart for formatting or expanding the disk of a newly added virtual machine according to this embodiment. As Figure 11 shown, it includes:
[0077] S1101, The cloud management platform adds a disk or expands the disk for the virtual machine;
[0078] S1102, Add an expansion label or a formatting label to the specified disk;
[0079] S1103, Change the disk information in the virtual machine configuration file and expand the specified disk or mount the newly added disk to the specified virtual machine. Among them, for the newly added disk: create a disk, change the virtual machine configuration file, write the disk information into the file, and add the uuid of the disk to the serial field; for expanding the disk: expand the specified disk;
[0080] S1104, Determine whether the virtual machine is online. If the judgment result is no, execute step S1105. If the judgment result is yes, execute step S1107;
[0081] S1105, Change the virtual machine configuration file, and write the disk information of the disk to be processed into the smbios configuration item. Specifically, when the virtual machine is in the online state, directly dynamically mount the disk to the virtual machine (newly added disk), and send the disk information to the virtual machine agent; if the virtual machine is shut down, write the disk information into the smbios configuration item of the virtual machine;
[0082] S1106, Shut down the virtual machine. After starting the virtual machine, read the disk information passed through in the bios information, and the online virtual machine receives the message to obtain the disk information;
[0083] S1107, The virtual machine agent service receives the disk information;
[0084] S1108, Obtain the disk number according to the serial number in the disk information;
[0085] S1109, Format or expand the disk according to the disk number and reply to the message;
[0086] S1110, Receive the message and clear the disk processing flag.
[0087] Figure 12 It is the flowchart of the formatted expansion of the windows virtual machine proxy service according to this embodiment. As Figure 12 shown, it includes:
[0088] S1201, The virtual machine proxy service obtains the disk format or the disk information of the expansion;
[0089] S1202, Obtain the disk serial number of the corresponding disk, and obtain the disk number of the disk to be processed according to the disk serial number. Specifically, the virtual machine obtains the disk serial number of the corresponding disk through the wmic diskdrive get index,SerialNumber command or the IOCTL_STORAGE_QUERY_PROPERTY control code of the DeviceIoControl function, and thus obtains the corresponding disk number;
[0090] S1203, Determine whether to expand or format according to the processing label. If it is formatting, execute step S1204. If it is expansion, execute step S1206;
[0091] S1204, Determine whether the disk has partitions. If the judgment result is no, execute step S1205. If the judgment result is yes, execute step S1208;
[0092] S1205, Create a disk partition, format it and assign a drive letter;
[0093] S1206, Determine whether the current partition can be expanded. If the judgment result is yes, execute step S1207. Otherwise, execute S1208;
[0094] S1207, Expand the disk;
[0095] Formatting label: Obtain whether there is a partition on the corresponding disk through the diskpart command or the IOCTL_DISK_GET_DRIVE_LAYOUT_EX control code of the DeviceIoControl function. If there is no partition, create a disk partition through the diskpart command or the DeviceIoControl command, and format the created partition and assign a drive letter; if there is a partition, do nothing. Expansion label: Use the DeviceIoControl function to judge whether there is extra capacity in the disk partition for expansion. If it can be expanded, expand the disk through the diskpart command or the DeviceIoControl function. If there is no extra capacity for expansion, do nothing.
[0096] S1208, Return a message to clear the disk operation flag.
[0097] Figure 13 It is a flowchart of the formatted expansion of the linux virtual machine proxy service according to this embodiment, as Figure 13 shown, including:
[0098] S1301, The virtual machine proxy service obtains the disk information of disk formatting or expansion;
[0099] S1302, Obtain the disk serial number of the corresponding disk, and obtain the disk number of the disk to be processed according to the disk serial number. Specifically, the virtual machine uses the udevadm info --query=all --name=device name command or views files such as / sys / block / device name / serial to obtain the disk serial number, and thus obtains the corresponding device name;
[0100] S1303, Determine whether to expand or format according to the processing label. If it is formatting, execute step S1304. If it is expansion, execute step S1307;
[0101] S1304, Determine whether the disk has partitions. If the judgment result is no, execute step S1305. If the judgment result is yes, execute step S1309;
[0102] S1305, Determine whether there is a file system on the disk partition. If the judgment result is no, execute step S1306. If the judgment result is yes, execute step S1309;
[0103] S1306, Create a disk partition, format it and assign a disk letter;
[0104] S1307, Determine whether the current partition can be expanded. If the judgment result is yes, execute step S1308. Otherwise, execute S1309;
[0105] S1308, Expand the disk;
[0106] Formatting label: Use the lsblk command to obtain the number of disk partitions, use blkid to obtain whether there is a file system on the disk. If there are no partitions and no file system, create a disk partition for the disk through commands such as fdisk or parted, and then format the disk through mkfs.exts4. Do not operate on disks with partitions or file systems. Expansion label: Use commands such as lsblk or fdisk to judge whether there is enough free space on the disk for expansion. If it can be expanded, rebuild the partition through commands such as fdisk or parted and expand it through the resize2fs command. If there is no enough free space for expansion, do not perform any operation.
[0107] S1309, return a message to clear the disk operation flag.
[0108] It should be noted that the virtual machine internal formatting process will detect whether the disk has partitions and whether there is a file system. In the case of existing partitions, formatting will not be performed to ensure that user data is not damaged; in the case of an existing file system on the disk, formatting will not be performed to ensure that user data is not damaged; when there is no free space on the disk to be operated, no expansion will be performed; obtain the disk attributes, and when it is determined that the disk data is offline, set the disk to online, and when the disk is read-only, remove the read-only flag; the virtual machine can report the disk information inside the virtual machine for display.
[0109] Figure 14 It is a flowchart of formatting and expansion that does not depend on whether the disk is formatted or the expansion label according to this embodiment, as Figure 14 shown, including:
[0110] S1401, the cloud management platform expands the disk or adds a new disk;
[0111] S1402, change the disk information in the virtual machine configuration file and expand the specified disk or mount the newly added disk to the specified virtual machine;
[0112] S1403, determine whether the virtual machine is online. If the determination result is yes, execute step S1404; if the determination result is no, execute step S1408;
[0113] S1404, the virtual machine agent service receives the disk information and finds the corresponding disk number according to the disk serial number in the disk information;
[0114] S1405, determine whether there is a formatting file. If the determination result is yes, execute step S1406; if the determination result is no, execute step S1407;
[0115] S1406, check whether the disk has partitions and a file system. If neither exists, perform formatting;
[0116] S1407, determine whether the disk has enough remaining capacity for expansion. If so, perform expansion;
[0117] S1408, detect all disks after starting the virtual machine;
[0118] S1409, check which disks have formatting files;
[0119] S1410, for disks without formatting files, check whether the disks have partitions and a file system. If neither exists, perform formatting;
[0120] S1411. For a disk with a formatted file, determine whether there is enough remaining capacity for expansion. If so, perform the expansion.
[0121] S1412. End.
[0122] Mainly by recording whether the disk has been formatted inside the virtual machine (if it has been formatted once, it will not be formatted again, even if the disk is restored), creating a file to mark whether the disk is formatted, and naming the file with the uuid of the virtual machine and the disk serial number, ensuring that each disk corresponds to a unique marker file (it can also be represented by using one file to record the serial numbers of all disks to indicate that the disk has been formatted). When the virtual machine is online, the process is as follows: (1) Add a new disk or expand a disk for the virtual machine in the cloud management platform; (2) Add a new disk: Add a new disk and change the virtual machine configuration file, write the disk information into the file, and add the uuid of the disk to the serial field; Expand a disk: Expand the specified disk; (3) Mount the disk to the virtual machine and send the disk information to the virtual machine agent; (4) The virtual machine receives the message and obtains the disk information; (5) Obtain the disk number according to the serial number in the disk information; (6) Judge whether there is a formatting marker file. If there is no marker file, generate a marker file, judge the disk partition and file system, and format the disk if there is no file system and no partition on the disk; If there is a formatting marker file, judge whether there is free space on the disk, and perform expansion if there is free space. When the virtual machine is shut down, the process is as follows: (1) Add a new disk or expand a disk for the virtual machine in the cloud management platform; (2) Add a new disk: Add a new disk and change the virtual machine configuration file, write the disk information into the file, and add the uuid of the disk to the serial field; Expand a disk: Expand the specified disk; (3) Start the virtual machine; (4) The virtual machine detects all disks; (5) Judge which disks do not have a formatting marker file, generate a formatting marker file, and judge the disk partition and file system, and format the disk if there is no file system and no partition on the disk; If there is a formatting marker file, judge whether there is free space on the disk, and perform expansion if there is free space.
[0123] According to another embodiment of the present application, a disk processing device is further provided. Figure 15 It is a block diagram of the disk processing device according to the embodiment of the present application. Figure 1 As Figure 15 shown, applied to the cloud management platform, the device includes:
[0124] A configuration module 152, configured to configure disk information of a disk to be processed for a virtual machine, where the disk information includes a disk serial number.
[0125] A providing module 154 is used to provide the disk information to the virtual machine agent service, where the disk serial number is used for the virtual machine agent service to obtain the corresponding disk number and process the to-be-processed disk corresponding to the disk number.
[0126] In one embodiment, the configuration module 152 is further used to configure the disk serial number in the configuration file of the virtual machine.
[0127] In one embodiment, the configuration module 152 is further used to, if the virtual machine is in an online state, configure the disk serial number in the disk item of the configuration file of the virtual machine; if the virtual machine is in a closed state, configure the disk serial number in the disk item of the configuration file of the virtual machine and configure the disk serial number under the smbios configuration item of the configuration file of the virtual machine.
[0128] In one embodiment, the providing module 154 is further used to, if the virtual machine is in an online state, send the disk information to the virtual machine agent service; if the virtual machine is in a closed state, inject the disk information into the configuration file so that the virtual machine can obtain the disk information from the bios configuration item of the configuration file after being started.
[0129] In one embodiment, the disk information further includes a disk processing label, and the disk processing label is used to instruct the virtual machine agent service to perform corresponding processing, where the disk processing label includes a formatting label and an expansion label.
[0130] According to another embodiment of the present application, a disk processing device is further provided. Figure 16 is a block diagram of the disk processing device according to the embodiment of the present application Figure 2 , as Figure 16 shown, applied to the virtual machine agent service, the device includes:
[0131] A first obtaining module 162 is used to obtain the disk information of the to-be-processed disk configured by the cloud management platform, where the disk information includes a disk serial number;
[0132] A second obtaining module 164 is used to obtain the disk number according to the disk serial number;
[0133] A processing module 166 is used to process the to-be-processed disk corresponding to the disk number.
[0134] In one embodiment, the first acquisition module 162 is further configured to receive the disk information sent by the cloud management platform if the disk information is configured by the cloud management platform when the virtual machine is in an online state; if the disk information is configured by the cloud management platform when the virtual machine is in a closed state, obtain the disk information from the bios configuration item of the configuration file after the virtual machine is started.
[0135] In one embodiment, the processing module 166 includes:
[0136] A first processing unit, configured to process the disk to be processed according to the disk processing label if the disk information further includes a disk processing label;
[0137] A second processing unit, configured to process the disk to be processed according to the formatting marker file of the disk to be processed and the remaining capacity of the disk partition if the disk information does not include a disk processing label.
[0138] In one embodiment, the first processing unit is further configured to the disk processing label includes a formatting label and an expansion label;
[0139] When the disk processing label is the formatting label, determine whether there is a disk partition on the disk to be processed. If there is no disk partition, create a disk partition and format the disk partition.
[0140] When the disk processing label is the expansion label, determine whether the remaining capacity of the disk partition of the disk to be processed is greater than or equal to a preset threshold. If the judgment result is yes, perform disk expansion on the disk partition.
[0141] In one embodiment, the first processing unit is further configured to the disk processing label includes a formatting label and an expansion label;
[0142] When the disk processing label is the formatting label, obtain the disk partition of the disk to be processed and determine whether there is a file system on the disk to be processed; when there is no disk partition and no file system on the disk to be processed, format the disk to be processed.
[0143] When the disk processing label is the expansion label, determine whether the remaining capacity of the disk partition of the disk to be processed is greater than or equal to a preset threshold. If the judgment result is yes, perform disk expansion on the disk partition.
[0144] In one embodiment, the second processing unit is further configured to, if the disk information is configured by the cloud management platform when the virtual machine is in an online state, generate the formatting marker file for the to-be-processed disk without the formatting marker file, and format the to-be-processed disk when the to-be-processed disk has no file system and no disk partition; for the to-be-processed disk with the formatting marker file, determine whether the remaining capacity is greater than or equal to a preset threshold, and if the determination result is yes, expand the to-be-processed disk.
[0145] In one embodiment, the second processing unit is further configured to, if the disk information is configured by the cloud management platform when the virtual machine is in a closed state, detect all disks after the virtual machine is started, generate the formatting marker file for the to-be-processed disk without the formatting marker file, and format the to-be-processed disk when the to-be-processed disk has no file system and no disk partition; for the to-be-processed disk with the formatting marker file, determine whether the remaining capacity is greater than or equal to a preset threshold, and if the determination result is yes, expand the to-be-processed disk.
[0146] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, and the computer program is configured to execute the steps in any one of the above method embodiments when running.
[0147] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: various media such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disc that can store a computer program.
[0148] An embodiment of the present application further provides an electronic device, including a memory and a processor, where a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0149] In an exemplary embodiment, the above electronic device may further include a transmission device and an input / output device, where the transmission device is connected to the above processor, and the input / output device is connected to the above processor.
[0150] Specific examples in this embodiment may refer to the examples described in the above embodiments and exemplary embodiments, and will not be repeated here.
[0151] Obviously, those skilled in the art should understand that the various modules or steps of the present application described above can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed over a network composed of multiple computing devices. They can be implemented by program codes executable by the computing device. Thus, they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order from here, or they can be separately fabricated into individual integrated circuit modules, or multiple modules or steps among them can be fabricated into a single integrated circuit module for implementation. In this way, the present application is not limited to any specific combination of hardware and software.
[0152] The above are only the preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the principle of the present application shall be included within the protection scope of the present application.
Claims
1. A disk processing method, applied to a cloud management platform, characterized in that The method includes: Configuring disk information of a disk to be processed for a virtual machine, where the disk information includes a disk serial number; Providing the disk information to the virtual machine proxy service, where the disk serial number is used by the virtual machine proxy service to obtain a corresponding disk number and process the disk to be processed corresponding to the disk number.
2. The method according to claim 1, wherein Configuring disk information of a disk to be processed for a virtual machine includes: Configuring the disk serial number in the configuration file of the virtual machine.
3. The method according to claim 2, wherein Configuring the disk serial number in the configuration file of the virtual machine includes: If the virtual machine is in an online state, configuring the disk serial number in the disk entry of the configuration file of the virtual machine; If the virtual machine is in a shutdown state, configuring the disk serial number in the disk entry of the configuration file of the virtual machine and configuring the disk serial number under the smbios configuration item of the configuration file of the virtual machine.
4. The method according to claim 3, wherein Providing the disk information to the virtual machine proxy service includes: If the virtual machine is in an online state, sending the disk information to the virtual machine proxy service; If the virtual machine is in a shutdown state, injecting the disk information into the configuration file so that the virtual machine can obtain the disk information from the bios configuration item of the configuration file after being started.
5. The method according to any one of claims 1 to 4, characterized in that The disk information further includes a disk processing label, and the disk processing label is used to instruct the virtual machine proxy service to perform corresponding processing, where the disk processing label includes a formatting label and an expansion label.
6. A disk processing method, applied to a virtual machine proxy service, characterized in that The method includes: Obtaining disk information of a disk to be processed configured by a cloud management platform, where the disk information includes a disk serial number; Obtaining a disk number according to the disk serial number; Processing the disk to be processed corresponding to the disk number.
7. The method according to claim 6, wherein Obtaining disk information of a disk to be processed configured by a cloud management platform includes: If the disk information is configured by the cloud management platform when the virtual machine is in an online state, receiving the disk information sent by the cloud management platform; If the disk information is configured by the cloud management platform when the virtual machine is in a shutdown state, obtaining the disk information from the bios configuration item of the configuration file after the virtual machine is started.
8. The method according to claim 6, characterized in that, Processing the disk to be processed corresponding to the disk number includes: In the case where the disk information further includes a disk processing label, processing the disk to be processed according to the disk processing label; In the case where the disk information does not include a disk processing label, processing the disk to be processed according to the formatting marker file of the disk to be processed and the remaining capacity of the disk partition.
9. The method according to claim 8, characterized in that, Processing the disk to be processed according to the disk processing label includes: The disk processing label includes a formatting label and an expansion label; In the case where the disk processing label is the formatting label, determining whether there is a disk partition on the disk to be processed. If there is no disk partition, creating a disk partition and formatting the disk partition; In the case where the disk processing label is the expansion label, determining whether the remaining capacity of the disk partition of the disk to be processed is greater than or equal to a preset threshold. If the determination result is yes, performing disk expansion on the disk partition.
10. The method according to claim 8, wherein Processing the disk to be processed according to the disk processing label includes: The disk processing label includes a formatting label and an expansion label; When the disk processing label is the formatting label, obtain the disk partition of the disk to be processed, and determine whether there is a file system on the disk to be processed; when the disk to be processed has no such disk partition and no such file system, format the disk to be processed; When the disk processing label is the expansion label, determine whether the remaining capacity of the disk partition of the disk to be processed is greater than or equal to a preset threshold, and when the determination result is yes, expand the disk partition.
11. The method according to claim 8, wherein Processing the disk to be processed according to the formatting marker file of the disk to be processed and the remaining capacity of the disk partition includes: If the disk information is configured by the cloud management platform when the virtual machine is in the online state, for the disk to be processed without the formatting marker file, generate the formatting marker file, and format the disk to be processed when the disk to be processed has no file system and no disk partition; For the disk to be processed with the formatting marker file, determine whether the remaining capacity is greater than or greater than a preset threshold, and when the determination result is yes, expand the disk to be processed.
12. The method according to claim 8, wherein Processing the disk to be processed according to the formatting marker file of the disk to be processed and the remaining capacity of the disk partition includes: If the disk information is configured by the cloud management platform when the virtual machine is in the closed state, detect all disks after the virtual machine is started, for the disk to be processed without the formatting marker file, generate the formatting marker file, and when the disk to be processed has no file system and no disk partition, format the disk to be processed; For the disk to be processed with the formatting marker file, determine whether the remaining capacity is greater than or equal to a preset threshold, and when the determination result is yes, expand the disk to be processed.
13. A computer-readable storage medium storing a computer program therein, wherein, The computer program is set to execute the method described in any one of claims 1 to 5, 6 to 12 when running.
14. An electronic device, including a memory and a processor, where a computer program is stored in the memory, and the processor is set to run the computer program to execute the method described in any one of claims 1 to 5, 6 to 12.