Disk processing method and apparatus
By configuring the disk serial number for the virtual machine and using the virtual machine proxy service to obtain the disk number, the risk of misoperation caused by issuing disk numbers on the cloud management platform is solved, and secure disk formatting and capacity expansion are achieved.
Patent Information
- Application Number
- PCT/CN2024/137920
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-27
- Filing Date
- 2024-12-09
- Publication Date
- 2025-07-03
AI Technical Summary
In the prior art, the disk processing through disk numbers issued by cloud management platforms is at a high risk of misoperation, especially when the virtual machine is turned off, which may lead to data loss or incorrect formatting.
By configuring the disk serial number in disk information for the virtual machine, using the virtual machine agent service to obtain the corresponding disk number and process it to ensure correct disk operation.
Reduces the risk of misoperation, ensures that the virtual machine can handle disks correctly both online and offline, and prevents data loss and multiple formatting or expansion.
Smart Images

Figure CN2024137920_03072025_PF_FP_ABST
Abstract
Description
Disk processing method and device
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This disclosure is based on Chinese Patent Publication No. 2023118231226, filed on December 27, 2023, entitled “A Disk Processing Method and Device,” and claims priority from that patent disclosure, all of which are incorporated herein by reference. Technical Field
[0003] The embodiments of the present disclosure relate to the field of communication technology, and in particular to a disk processing method and device. Background Art
[0004] In the related art, the cloud management platform mainly sends disk information (disk number, disk partition number, disk capacity) to the online virtual machine to automatically format or expand the disk through the corresponding parameters. These solutions have the following defects: (1) Formatting or expanding the disk by disk number may have the risk of misformatting (after adding a disk and then deleting the previous disk, the newly added disk number will become the deleted disk number), and the disk is identified by disk capacity (there may be multiple disks of the same capacity); (2) The disk mounted when the virtual machine is turned off will not receive disk formatting and expansion messages. If the virtual machine starts automatic formatting and expansion, it depends on the virtual machine's internal identification of whether the disk has partitions, and there is a possibility of misjudgment. In this case, formatting will 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.
[0005] There is no solution to the problem in related technologies that processing disks based on disk numbers issued by a cloud management platform carries a high risk of misoperation. Summary of the Invention
[0006] The embodiments of the present disclosure provide a disk processing method and apparatus to at least solve the problem in the related art of processing disks according to disk numbers issued by a cloud management platform, which carries a high risk of misoperation.
[0007] According to one embodiment of the present disclosure, a disk processing method is provided, which is applied to a cloud management platform. The method includes: configuring disk information of a disk to be processed for a virtual machine, wherein the disk information includes a disk serial number; providing the disk information to the virtual machine proxy service, wherein the disk serial number is used by the virtual machine proxy service to obtain a corresponding disk number, and processing the disk to be processed corresponding to the disk number.
[0008] According to another embodiment of the present disclosure, a disk processing method is also provided, which is applied to a virtual machine proxy service. The method includes: obtaining disk information of a disk to be processed configured by a cloud management platform, wherein the disk information includes a disk serial number; obtaining a disk number based on the disk serial number; and processing the disk to be processed corresponding to the disk number.
[0009] According to another embodiment of the present disclosure, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the steps of any one of the above method embodiments when running.
[0010] According to another embodiment of the present disclosure, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any one of the above method embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] FIG1 is a block diagram of the hardware structure of a computer device according to a disk processing method according to an embodiment of the present disclosure;
[0012] FIG2 is a flowchart of a disk processing method according to an embodiment of the present disclosure;
[0013] FIG3 is a second flowchart of a disk processing method according to an embodiment of the present disclosure;
[0014] FIG4 is an architectural diagram of a disk processing system for a cloud desktop according to this embodiment;
[0015] FIG5 is a schematic diagram of disk information of a virtual machine configuration file according to this embodiment;
[0016] 6 is a schematic diagram of finding the corresponding disk number through the serial number of the virtual machine disk according to this embodiment;
[0017] 7 is a schematic diagram of injection information of a virtual machine configuration file according to this embodiment;
[0018] FIG8 is a schematic diagram of injection information in the Windows registry according to this embodiment;
[0019] 9 is a flowchart of adding a disk to an online virtual machine according to this embodiment;
[0020] 10 is a flowchart of a virtual machine reading injection information according to the present embodiment;
[0021] 11 is a flowchart of formatting or expanding a new disk for a virtual machine according to the present embodiment;
[0022] 12 is a flowchart of the formatting and expansion of the Windows virtual machine proxy service according to the present embodiment;
[0023] 13 is a flowchart of formatting and capacity expansion of the Linux virtual machine proxy service according to the present embodiment;
[0024] 14 is a flowchart of formatting and expansion according to the present embodiment that does not depend on whether the disk is formatted or expanded;
[0025] FIG15 is a block diagram of a disk processing device according to an embodiment of the present disclosure;
[0026] FIG16 is a second block diagram of the disk processing device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] Hereinafter, embodiments of the present disclosure will be described in detail with reference to the accompanying drawings and in conjunction with embodiments.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0029] The method embodiments provided in the embodiments of the present disclosure can be executed in a computer device or a similar computing device. Taking operation on a computer device as an example, FIG1 is a hardware structure block diagram of a computer device of the disk processing method of the embodiment of the present disclosure. As shown in FIG1 , the computer device may include one or more (only one is shown in FIG1 ) 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 configured to store data, wherein the above-mentioned computer device may also include a transmission device 106 and an input and output device 108 configured to have a communication function. It can be understood by those skilled in the art that the structure shown in FIG1 is only for illustration, and it does not limit the structure of the above-mentioned computer device. For example, the computer device may also include more or fewer components than those shown in FIG1 , or have a configuration different from that shown in FIG1 .
[0030] The memory 104 can be configured 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 embodiment of the present disclosure. The processor 102 executes various functional applications and single board matching by running the computer program stored in the memory 104, that is, implements the above-mentioned method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0031] The transmission device 106 is configured to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by a communications provider of the computer device. In one embodiment, the transmission device 106 includes a network interface controller (NIC) that can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module that is configured to communicate with the Internet wirelessly.
[0032] In this embodiment, a disk processing method running on the above-mentioned computer device is provided. FIG2 is a flowchart of the disk processing method according to an embodiment of the present disclosure. As shown in FIG2 , the method is applied to a cloud management platform. The flowchart includes the following steps:
[0033] Step S202: configuring disk information of the disk to be processed for the virtual machine, wherein the disk information includes the disk serial number;
[0034] Step S204: providing the disk information to the virtual machine proxy service, wherein the disk serial number is used by the virtual machine proxy service to obtain the corresponding disk number and process the to-be-processed disk corresponding to the disk number.
[0035] Through the above steps S202 to S204, the problem of high risk of misoperation in the related art of processing disks according to the disk numbers issued by the cloud management platform can be solved. The disk number is obtained by the disk serial number provided by the cloud management platform, and the disk corresponding to the disk number is processed, which greatly reduces the risk of misoperation.
[0036] In the embodiment of the present disclosure, step S202 may specifically include configuring the disk serial number in the virtual machine's configuration file. Furthermore, if the virtual machine is online, the disk serial number is configured in the disk item of the virtual machine's configuration file; if the virtual machine is shut down, the disk serial number is configured in the disk item of the virtual machine's configuration file. Furthermore, the disk serial number is configured under the smbios configuration item of the virtual machine's configuration file.
[0037] In the disclosed embodiment, step S204 may specifically include: if the VM is online, sending the disk information to the VM proxy service; if the VM is shut down, injecting the disk information into the configuration file so that the VM can retrieve the disk information from the BIOS configuration item in the configuration file after it is started. Specifically, the BIOS configuration item is the BIOS registry for Windows VMs and the BIOS configuration file for Linux VMs.
[0038] The disk information in this embodiment also includes a disk processing tag, which is used to instruct the virtual machine proxy service to perform corresponding processing. The disk processing tag includes a formatting tag and an expansion tag.
[0039] This embodiment provides a secure cloud desktop disk expansion or formatting solution. By configuring a disk serial number that is the same as the disk UUID in the disk item of the virtual machine configuration file, and then transmitting the disk information that needs to be operated to the virtual machine proxy service through message transmission or offline message sending, the virtual machine proxy determines the disk number of the disk file to be operated by 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, thereby achieving secure disk management. For offline virtual machines, the disk information that needs to be operated is injected into the virtual machine's internal BIOS registry by changing the smbios item in the virtual machine configuration file. After the cloud desktop is started, the cloud desktop virtual machine service reads the relevant disk configuration and formats or expands the specific disk to ensure that the disk capacity can meet the user's requirements under any circumstances.
[0040] When adding a new disk 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 capacity of a running virtual machine, the user can immediately see the increase in disk capacity inside the virtual machine; when adding a new disk to an offline virtual machine through the cloud management platform, the user can immediately see the newly added disk inside the virtual machine after the virtual machine is started; when expanding the disk capacity of an offline virtual machine through the cloud management platform, the user can immediately see the increase in disk capacity inside the virtual machine after the virtual machine is started; when the virtual machine is online, it is sufficient to ensure that it can receive messages from the cloud management platform (relevant messages can be received through the serial port or the network).
[0041] The present disclosure also provides a disk processing method. FIG3 is a second flowchart of the disk processing method according to the present disclosure embodiment. As shown in FIG3 , the method is used for a virtual machine proxy service. The process includes the following steps:
[0042] Step S302: Obtain disk information of the disk to be processed configured by the cloud management platform, wherein the disk information includes the disk serial number;
[0043] In the disclosed embodiment, step S302 may specifically include: if the disk information is configured by the cloud management platform while the virtual machine is online, receiving the disk information sent by the cloud management platform; if the disk information is configured by the cloud management platform while the virtual machine is powered off, obtaining the disk information from a BIOS configuration item in a configuration file after the virtual machine is started. Specifically, the BIOS configuration item is the BIOS registry for Windows virtual machines and the BIOS configuration file for Linux virtual machines.
[0044] Step S304, obtaining the disk number according to the disk serial number;
[0045] Step S306: Process the disk to be processed corresponding to the disk number.
[0046] Through the above steps S302 to S306, the problem of high risk of misoperation in the related art of processing disks according to the disk numbers issued by the cloud management platform can be solved. The disk number is obtained by the disk serial number provided by the cloud management platform, and the disk corresponding to the disk number is processed, which greatly reduces the risk of misoperation.
[0047] In the embodiment of the present disclosure, the above step S306 may specifically include:
[0048] S3061, when the disk information also includes a disk processing tag, processing the disk to be processed according to the disk processing tag;
[0049] In one embodiment, the above-mentioned S3061 may specifically include: the above-mentioned disk processing label includes a formatting label and an expansion label; when the disk processing label is a formatting label, determine whether there is a disk partition on the disk to be processed, if no disk partition exists, create a disk partition, and format the disk partition; when the disk processing label is an 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 (that is, determine whether there is sufficient remaining capacity for disk expansion), and if the judgment result is yes, expand the disk partition.
[0050] In another embodiment, the above-mentioned S3061 may specifically include: the above-mentioned disk processing label includes a formatting label and an expansion label; when the disk processing label is a formatting label, the disk partition of the disk to be processed is obtained, and it is determined whether the disk to be processed has a file system; when the disk to be processed has no disk partition and no file system, the disk to be processed is formatted; when the disk processing label is an expansion label, it is determined whether the remaining capacity of the disk partition of the disk to be processed is greater than or equal to a preset threshold, and if the judgment result is yes, the disk partition is expanded.
[0051] S3062: If the disk information does not include a disk processing tag, the disk to be processed is processed according to the formatting mark file of the disk to be processed and the remaining capacity of the disk partition.
[0052] In one embodiment, the above-mentioned S3062 may specifically include: if the disk information is configured by the cloud management platform when the virtual machine is online, a formatting marker file is generated for the disk to be processed that does not have a formatting marker file, and the disk to be processed is formatted if the disk to be processed has no file system and no disk partition; for the disk to be processed that has a formatting marker file, it is determined whether the remaining capacity is greater than or greater than a preset threshold, and if the judgment result is yes, the disk to be processed is expanded.
[0053] 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 shut down state, all disks are detected after the virtual machine is started, and a formatting marker file is generated for the disk to be processed that does not have a formatting marker file. If 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 that has a formatting marker file, whether the remaining capacity is greater than or equal to a preset threshold is determined, and if the judgment result is yes, the disk to be processed is expanded.
[0054] FIG4 is an architectural diagram of a disk processing system for a cloud desktop according to this embodiment. As shown in FIG4 , the system comprises a cloud management platform and a virtual machine. The virtual machine includes a receiving module and a processing module. The receiving module and the processing module can be one module. The receiving module is primarily configured to receive messages sent by the host and read and parse disk information (disk serial number, disk partition, whether formatting is required, whether expansion is required) in the BIOS when the virtual machine is started. The processing module is primarily configured to query a specific disk number based on the disk serial number in the disk information and perform corresponding disk operations on the disk based on the disk number and partition information. A new disk or disk expansion is performed on a specific virtual machine through the cloud management platform. When the virtual machine is online, a message is sent to the receiving module. The receiving module receives the message and then performs the corresponding disk operation on the processing module. When the virtual machine is offline, the virtual machine configuration file smbios item is modified to inject the operation information of the disk to be operated. The receiving module parses the disk information in the BIOS configuration item and then performs the corresponding disk operation on the processing module.
[0055] Figure 5 is a schematic diagram of the disk information of the virtual machine configuration file according to this embodiment, and Figure 6 is a schematic diagram of finding the corresponding disk number through the serial number of the virtual machine's disk according to this embodiment. As shown in Figures 5 and 6, taking the Windows virtual machine as an example, it is only necessary to configure the serial field (configured as the disk's uuid) in the disk item of each disk in the virtual machine configuration file (config.xml), and then the virtual machine proxy service can find the disk number to be operated through the corresponding disk serial number (the virtual machine's internal disk serial number is the same as the virtual machine's disk uuid) (this method is applicable to both Windows and Linux virtual machines, the Windows internal disk serial number can be obtained through the Windows API or command, and the Linux virtual machine can be obtained through commands or reading related files). Figure 7 is a schematic diagram of the injection information of the virtual machine configuration file according to this embodiment, and Figure 8 is a schematic diagram of the injection information in the Windows registry according to this embodiment. As shown in Figures 7 and 8, it is only necessary to configure the information to be injected in the smbios item in the virtual machine configuration file (config.xml). After the virtual machine is started internally, relevant information can be obtained from the registry or file (the 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; the 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).
[0056] FIG9 is a flow chart of adding a disk to an online virtual machine according to this embodiment, as shown in FIG9 , including:
[0057] S901, add a disk to the virtual machine on the cloud management platform;
[0058] S902: Create a disk, modify the virtual machine configuration file, write the disk information into the configuration file, add the disk's UUID to the serial field, and create an XML file corresponding to the disk.
[0059] S903, add the corresponding disk by using 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 by using the disk serial number that is the same as the virtual machine disk uuid within the virtual machine.
[0060] FIG10 is a flow chart of a virtual machine reading injection information according to this embodiment, as shown in FIG10 , including:
[0061] S1001, before starting the virtual machine, write the disk information to be operated into the smbios configuration item of the virtual machine configuration file;
[0062] S1002, start the virtual machine;
[0063] S1003, the virtual machine proxy service reads relevant injection information;
[0064] S1004: Perform operations on the specific disk according to the injection information.
[0065] FIG11 is a flowchart of formatting or expanding a new disk in a virtual machine according to this embodiment, as shown in FIG11 , including:
[0066] S1101: The cloud management platform adds a new disk or expands the disk capacity of the virtual machine;
[0067] S1102, adding an expansion tag or a format tag to the specified disk;
[0068] 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, where, adding a disk: create a disk, change the virtual machine configuration file, write the disk information to the file, and add the disk's UUID to the serial field; expanding a disk: expand the specified disk;
[0069] S1104, determining whether the virtual machine is online. If the determination result is no, executing step S1105; if the determination result is yes, executing step S1107;
[0070] S1105, modify 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 online, directly dynamically mount the disk to the virtual machine (add a new 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;
[0071] S1106, shutting down the virtual machine and reading the disk information transparently transmitted in the BIOS information after starting the virtual machine, and the online virtual machine receives the message to obtain the disk information;
[0072] S1107, the virtual machine proxy service receives disk information;
[0073] S1108, obtaining the disk number according to the serial number in the disk information;
[0074] S1109, format the disk or expand the disk capacity according to the disk number and reply to the message;
[0075] S1110, receiving the message and clearing the disk processing flag.
[0076] FIG12 is a flow chart of formatting and expanding the capacity of the Windows virtual machine proxy service according to the present embodiment, as shown in FIG12 , including:
[0077] S1201, the virtual machine proxy service obtains disk format or expanded disk information;
[0078] S1202, obtaining the disk serial number of the corresponding disk, and obtaining 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;
[0079] S1203, determine whether to expand or format based on the processing tag, if it is formatting, execute step S1204, if it is expansion, execute step S1206;
[0080] S1204, determining whether the disk has partitions. If the determination result is no, executing step S1205; if the determination result is yes, executing step S1208;
[0081] S1205, creating a disk partition, formatting it and assigning a disk letter;
[0082] S1206: Determine whether the current partition can be expanded. If yes, execute step S1207; otherwise, execute step S1208.
[0083] S1207, expand disk capacity;
[0084] Format tag: Use the diskpart command or the IOCTL_DISK_GET_DRIVE_LAYOUT_EX control code of the DeviceIoControl function to obtain whether the corresponding disk partition exists. If no partition exists, the diskpart command or DeviceIoControl command is used to create the disk partition and format the created partition and assign a drive letter. If the partition exists, no operation is performed. Expansion tag: Use the DeviceIoControl function to determine whether the disk partition has excess capacity to expand. If expansion is possible, the diskpart command or DeviceIoControl function is used to expand the disk. If there is no excess capacity to expand, no operation is performed.
[0085] S1208, returns a message to clear the disk operation flag.
[0086] FIG13 is a flow chart of formatting and capacity expansion of the Linux virtual machine proxy service according to the present embodiment, as shown in FIG13 , including:
[0087] S1301, the virtual machine proxy service obtains disk format or expanded disk information;
[0088] S1302, obtain the disk serial number of the corresponding disk, and obtain the disk number of the disk to be processed based on the disk serial number. Specifically, the virtual machine obtains the disk serial number through the udevadminfo --query=all --name=device name command or checks the / sys / block / device name / serial file, thereby obtaining the corresponding device name;
[0089] S1303, determine whether to expand or format based on the processing tag, if it is formatting, execute step S1304, if it is expansion, execute step S1307;
[0090] S1304, determining whether the disk has partitions. If the determination result is no, executing step S1305; if the determination result is yes, executing step S1309;
[0091] S1305, determining whether the disk partition has a file system. If the determination result is no, executing step S1306; if the determination result is yes, executing step S1309;
[0092] S1306, creating a disk partition, formatting it, and assigning a disk letter;
[0093] S1307: Determine whether the current partition can be expanded. If yes, execute step S1308; otherwise, execute step S1309.
[0094] S1308, expand disk capacity;
[0095] Formatting: Use the lsblk command to determine the number of disk partitions. Use blkid to determine whether the disk has a file system. If no partitions or file systems exist, create them using commands like fdisk or parted. Then, use mkfs.exts4 to format the disk. Do not perform this operation on disks that already have partitions or file systems. Expansion: Use commands like lsblk or fdisk to determine whether the disk has excess capacity for expansion. If expansion is possible, recreate partitions using commands like fdisk or parted and expand using the resize2fs command. If there is no excess capacity, do nothing.
[0096] S1309: Return a message to clear the disk operation flag.
[0097] It should be noted that the VM's internal formatting process checks whether the disk has partitions and a file system. If a partition exists, formatting is not performed to protect user data. If a file system exists, formatting is not performed to protect user data. If the disk has no free space, capacity expansion is not performed. Disk properties are obtained. If the disk data is offline, the disk is brought online. If the disk is read-only, the read-only flag is removed. The VM can report internal disk information for display.
[0098] FIG14 is a flowchart of formatting and capacity expansion according to this embodiment, which is independent of whether the disk is formatted or has a capacity expansion tag. As shown in FIG14 , the flowchart includes:
[0099] S1401, expand disk capacity or add new disks on the cloud management platform;
[0100] S1402, changing the disk information in the virtual machine configuration file and expanding the specified disk or mounting the newly added disk to the specified virtual machine;
[0101] S1403, determining whether the virtual machine is online. If yes, proceed to step S1404; otherwise, proceed to step S1408.
[0102] S1404, the virtual machine proxy service receives the disk information and finds the corresponding disk number according to the disk serial number in the disk information;
[0103] S1405, determining whether a formatting file exists. If yes, proceed to step S1406; otherwise, proceed to step S1407.
[0104] S1406, check whether the disk has partitions and file systems, and format it if neither exists;
[0105] S1407, determining whether the disk has sufficient remaining capacity for expansion, and if so, performing expansion;
[0106] S1408: After starting the virtual machine, check all disks;
[0107] S1409, check which disks have formatted files;
[0108] S1410, for a disk without formatted files, check whether the disk has partitions and file systems, and format it if neither exists.
[0109] S1411, for a disk with a formatted file, determine whether there is sufficient remaining capacity for expansion, and if so, expand the capacity;
[0110] S1412, end.
[0111] It mainly records whether the disk has been formatted in the virtual machine (if it has been formatted once, it will not be formatted again, even if the disk is restored). It creates a file to mark whether the disk is formatted. The file is named using the virtual machine's uuid disk serial number to ensure that each disk corresponds to a unique marker file (you can also use a 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 the disk to the virtual machine on the cloud management platform; (2) Add a new disk: add a new disk and change the virtual machine configuration file, write the disk information to the file, and add the disk's uuid to the serial field; expand the 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 to obtain the disk information; (5) Get the disk number according to the serial number in the disk information; (6) Determine whether there is a formatting marker file. If there is no marker file, generate a marker file, determine the disk partition and file system. If the disk has no file system and no partition, format the disk; if there is a formatting marker file, determine whether the disk has free space, and expand the disk if there is free space. When the virtual machine is shut down, the process is as follows: (1) Add a new disk or expand the disk to the virtual machine on the cloud management platform; (2) Add a new disk: add a new disk and change the virtual machine configuration file, write the disk information to the file, and add the disk's uuid to the serial field; Expand the disk: expand the specified disk; (3) Start the virtual machine; (4) The virtual machine detects all disks; (5) Determine which disks do not have a formatting marker file, then generate a formatting marker file, and determine the disk partition and file system. If the disk has no file system and no partition, format the disk; if there is a formatting marker file, determine whether the disk has free space, and expand the disk if there is free space.
[0112] According to another embodiment of the present disclosure, a disk processing device is further provided. FIG15 is a block diagram of a disk processing device according to an embodiment of the present disclosure. As shown in FIG15 , the disk processing device is applied to a cloud management platform. The device includes:
[0113] The configuration module 152 is configured to configure disk information of a disk to be processed for the virtual machine, wherein the disk information includes a disk serial number;
[0114] The providing module 154 is configured to provide the disk information to the virtual machine proxy service, wherein the disk serial number is used by the virtual machine proxy service to obtain the corresponding disk number and process the to-be-processed disk corresponding to the disk number.
[0115] In one embodiment, the configuration module 152 is further configured to configure the disk serial number in the configuration file of the virtual machine.
[0116] In one embodiment, the configuration module 152 is further configured to configure the disk serial number in the disk item of the configuration file of the virtual machine if the virtual machine is in an online state; 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. The disk serial number is also configured under the smbios configuration item of the configuration file of the virtual machine.
[0117] In one embodiment, the providing module 154 is further configured to send the disk information to the virtual machine proxy service if the virtual machine is online; and to inject the disk information into the configuration file if the virtual machine is closed, so that the disk information can be obtained from the BIOS configuration item of the configuration file after the virtual machine is turned on.
[0118] In one embodiment, the disk information further includes a disk processing tag, and the disk processing tag is used to instruct the virtual machine proxy service to perform corresponding processing, wherein the disk processing tag includes a formatting tag and an expansion tag.
[0119] According to another embodiment of the present disclosure, a disk processing device is further provided. FIG16 is a block diagram of a second disk processing device according to an embodiment of the present disclosure. As shown in FIG16 , the disk processing device is applied to a virtual machine proxy service. The device includes:
[0120] A first acquisition module 162 is configured to acquire disk information of a disk to be processed configured by the cloud management platform, wherein the disk information includes a disk serial number;
[0121] A second obtaining module 164 is configured to obtain a disk number according to the disk serial number;
[0122] The processing module 166 is configured to process the disk to be processed corresponding to the disk number.
[0123] In one embodiment, the first acquisition module 162 is further configured to receive the disk information issued by the cloud management platform if the disk information is configured by the cloud management platform when the virtual machine is online; if the disk information is configured by the cloud management platform when the virtual machine is shut down, obtain the disk information from the BIOS configuration item in the configuration file after the virtual machine is started.
[0124] In one embodiment, the processing module 166 includes:
[0125] a first processing unit configured to process the disk to be processed according to the disk processing tag when the disk information further includes the disk processing tag;
[0126] The second processing unit is configured to process the disk to be processed according to the formatting mark file of the disk to be processed and the remaining capacity of the disk partition when the disk information does not include the disk processing tag.
[0127] In one embodiment, the first processing unit is further configured such that the disk processing label includes a formatting label and an expansion label;
[0128] In a case where the disk processing tag is the format tag, determining whether the disk to be processed has a disk partition, and if no disk partition exists, creating a disk partition and formatting the disk partition;
[0129] When the disk processing tag is the expansion tag, it is determined 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, the disk partition is expanded.
[0130] In one embodiment, the first processing unit is further configured such that the disk processing label includes a formatting label and an expansion label;
[0131] When the disk processing tag is the format tag, obtaining the disk partition of the disk to be processed and determining whether the disk to be processed has a file system; when the disk to be processed does not have the disk partition and does not have the file system, formatting the disk to be processed;
[0132] When the disk processing tag is the expansion tag, it is determined 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, the disk partition is expanded.
[0133] In one embodiment, the second processing unit is further configured to generate the formatting marker file for the disk to be processed if the disk information is configured by the cloud management platform when the virtual machine is online, and format the disk to be processed if the disk to be processed has no file system and no disk partition; and for the disk to be processed if the formatting marker file exists, determine whether the remaining capacity is greater than or greater than a preset threshold, and if the determination result is yes, expand the capacity of the disk to be processed.
[0134] In one embodiment, the second processing unit is further configured to detect all disks after the virtual machine is started if the disk information is configured by the cloud management platform when the virtual machine is in a closed state, generate the formatting marker file for the disk to be processed that does not have the formatting marker file, and format the disk to be processed if the disk to be processed has no file system and no disk partition; for the disk to be processed that has 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 capacity of the disk to be processed.
[0135] An embodiment of the present disclosure further provides a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any one of the above method embodiments when run.
[0136] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, 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 disk.
[0137] An embodiment of the present disclosure further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0138] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0139] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail here.
[0140] Obviously, those skilled in the art should understand that the modules or steps of the present disclosure described above can be implemented using a general-purpose computing device, they can be concentrated on a single computing device, or distributed across a network composed of multiple computing devices, they can be implemented using program code executable by the computing device, and 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 performed in a different order than herein, or they can be fabricated into separate integrated circuit modules, or multiple modules or steps can be fabricated into a single integrated circuit module for implementation. Thus, the present disclosure is not limited to any particular combination of hardware and software.
[0141] The foregoing description is merely a preferred embodiment of the present disclosure and is not intended to limit the present disclosure. Those skilled in the art will readily appreciate that various modifications and variations of the present disclosure are possible. Any modifications, equivalent substitutions, or improvements made within the principles of the present disclosure shall be included within the scope of protection of the present disclosure.
Claims
1. A disk processing method, applied to a cloud management platform, the method comprising: Configuring disk information of a disk to be processed for a virtual machine, wherein the disk information includes a disk serial number; Providing the disk information to the virtual machine agent service, wherein the disk serial number is used for the virtual machine agent 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 item 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 item 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 agent service includes: If the virtual machine is in an online state, sending the disk information to the virtual machine agent 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, wherein 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, wherein the disk processing label includes a formatting label and an expansion label.
6. A disk processing method, applied to a virtual machine agent service, the method comprising: Obtaining disk information of a disk to be processed configured by a cloud management platform, wherein 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, wherein Processing the disk to be processed corresponding to the disk number includes: In the case that the disk information further includes a disk processing label, processing the disk to be processed according to the disk processing label; In the case that the disk information does not include a disk processing label, processing the disk to be processed according to the formatting mark file of the disk to be processed and the remaining capacity of the disk partition.
9. 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; In the case that 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, 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 determination result is yes, perform 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 there is no such disk partition and no file system on the disk to be processed, 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. If the determination result is yes, perform disk expansion on the disk partition.
11. The method according to claim 8, wherein, Processing the disk to be processed according to the formatting mark 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 that does not have the formatting mark file, generate the formatting mark file, and format the disk to be processed when there is no file system and no disk partition on the disk to be processed; For the disk to be processed that has the formatting mark file, determine whether the remaining capacity is greater than or greater than a preset threshold. If 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 mark 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 that does not have the formatting mark file, generate the formatting mark file, and format the disk to be processed when there is no file system and no disk partition on the disk to be processed; For the disk to be processed that has the formatting mark file, determine whether the remaining capacity is greater than or equal to a preset threshold. If 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, wherein 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.
Citation Information
Patent Citations
Virtual environment disk operation method and apparatus
CN107193491A
Cloud disk management method and device of cloud host, computer equipment and storage medium
CN114253463A
Disk sharing method and device, electronic equipment and storage medium
CN116483262A
Disk processing method and device and storage medium
CN117234411A
Modifying disk images
US20150254080A1