A virtual machine disk mounting method, device, equipment and storage medium
Patent Information
- Application Number
- CN202211261006.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-14
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2042-10-14
AI Technical Summary
[0003]然而,现有技术中的磁盘挂载方式无法满足同时给多个虚拟机挂载多个磁盘的需求,只能人工手动一个一个挂载,耗时长,效率低下
[0046]The technical solution provided by this invention can automatically mount a batch of disks to a batch of virtual machines. For users, they only need to configure some simple information such as the number of virtual machines and disks to realize one-click mounting of disks on virtual machines, which is very simple and efficient.
Smart Images

Figure CN115827151B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computers, and in particular to a method, apparatus, device, and storage medium for mounting virtual machine disks. Background Technology
[0002] Currently, cloud providers offer two ways to mount new disks to virtual machines: one is to add a new hard drive by creating a VMDK formatted disk using the Datastore method; the other is to add a new device RDM disk by creating a naked LUN.
[0003] However, existing disk mounting methods cannot meet the need to mount multiple disks for multiple virtual machines at the same time. They can only be mounted manually one by one, which is time-consuming and inefficient. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a method, apparatus, device, and storage medium for mounting virtual machine disks to improve disk mounting efficiency.
[0005] In a first aspect, embodiments of the present invention provide a method for mounting a virtual machine disk, including:
[0006] Receive user-triggered requests to mount N shared disks onto M virtual machines, where M and N are both integers greater than 1;
[0007] Create M*N atomic tasks;
[0008] Treat the first to Nth atomic tasks as the first task group, and call this task group: create N disk files and mount the N disk files to the first virtual machine;
[0009] Take the (k-1)*N+1 to k*N atomic tasks as the k-th task group and call this task group: mount the N created disk files to the k-th virtual machine in a shared manner, where k is an integer from 2 to M.
[0010] Furthermore, each atomic task in Task Group 1 performs the following operations sequentially: creating the disk file corresponding to its own atomic task and mounting the created disk file to the first virtual machine.
[0011] Furthermore, the method also includes: determining the execution order among task groups other than the first task group;
[0012] Based on the determined results, call other task groups except for task group 1. In task group k, the atomic tasks perform the following operations in a serial manner: mount the disk file corresponding to this atomic task to the kth virtual machine.
[0013] Furthermore, the execution order among the task groups other than Task Group 1 is determined, including:
[0014] The other task groups, except for the first task group, are divided into batches. Task groups in different batches are executed serially, while task groups in the same batch are executed in parallel.
[0015] Furthermore, the method also includes:
[0016] Calculate the total number of virtual machines (M) mounted on N shared disks (Pro) using the following formula:
[0017]
[0018] The system displays in real time the progress of mounting N shared disks onto the M virtual machines.
[0019] Among them, P i P represents the completion amount of the i-th atomic task currently executing in an M*N atomic task within this atomic task, with a value greater than or equal to 0 and less than or equal to 100. x represents the batch index of the currently executing task group, Q represents the maximum number of task groups within a batch specified by the batch partitioning rule, and P... x,y,z This represents the completion amount of the z-th atomic task within the y-th task group of the x-th batch, currently being executed, within this atomic task. y In parentheses, y takes the value from 1 to the xth batch number of task groups, and mod(i,N) represents the remainder when i is divided by N.
[0020] Furthermore, before creating the M*N atomic tasks, the method further includes: checking whether there are any ongoing virtual machine operation tasks in the M virtual machines; if the check result is negative, performing the step of creating the M*N atomic tasks.
[0021] Furthermore, before creating M*N atomic tasks, the method also includes:
[0022] Obtain the disk information of each virtual machine in the M virtual machines, including: the number and usage of Small Computer System Interface (SCSI) controllers, and the maximum number of disks mounted and their usage for each SCSI controller;
[0023] Based on the disk information of each of the M virtual machines, the user-triggered request received this time is verified; after the verification is successful, the step of creating M*N atomic tasks is executed.
[0024] In a second aspect, embodiments of the present invention provide a virtual machine disk mounting device, comprising:
[0025] The request receiving unit is used to receive user-triggered requests for mounting N shared disks on M virtual machines, where M and N are both integers greater than 1;
[0026] The task creation unit is used to create M*N atomic tasks;
[0027] The first task invocation unit is used to take the first to N atomic tasks as the first task group, and invoke this task group to create N disk files and mount the N disk files to the first virtual machine.
[0028] The second task invocation unit is used to take the (k-1)*N+1 to k*N atomic tasks as the k-th task group and invoke this task group to mount the N created disk files to the k-th virtual machine in a shared manner, where k is an integer from 2 to M.
[0029] Furthermore, each atomic task in Task Group 1 performs the following operations sequentially: creating the disk file corresponding to its own atomic task and mounting the created disk file to the first virtual machine.
[0030] Furthermore, the second task invocation unit is also used to: determine the execution order among task groups other than the first task group;
[0031] Based on the determined results, call other task groups except for task group 1. In task group k, the atomic tasks perform the following operations in a serial manner: mount the disk file corresponding to this atomic task to the kth virtual machine.
[0032] Furthermore, the second task invocation unit is used to determine the execution order among task groups other than the first task group, specifically including:
[0033] The other task groups, except for the first task group, are divided into batches. Task groups in different batches are executed serially, while task groups in the same batch are executed in parallel.
[0034] Furthermore, the device also includes a load completion display unit, used for:
[0035] Calculate the total number of virtual machines (M) mounted on N shared disks (Pro) using the following formula:
[0036]
[0037] The system displays in real time the progress of mounting N shared disks onto the M virtual machines.
[0038] Among them, P iP represents the completion amount of the i-th atomic task currently executing in an M*N atomic task within this atomic task, with a value greater than or equal to 0 and less than or equal to 100. x represents the batch index of the currently executing task group, Q represents the maximum number of task groups within a batch specified by the batch partitioning rule, and P... x,y,z This represents the completion amount of the z-th atomic task within the y-th task group of the x-th batch, currently being executed, within this atomic task. y In parentheses, y takes the value from 1 to the xth batch number of task groups, and mod(i,N) represents the remainder when i is divided by N.
[0039] Furthermore, the device also includes a checking unit, used to: check whether there are any ongoing virtual machine operation tasks in the M virtual machines; if the check result is negative, trigger the task creation unit to execute the step of creating M*N atomic tasks.
[0040] Furthermore, the device also includes a verification unit for:
[0041] Obtain the disk information of each virtual machine in the M virtual machines, including: the number and usage of Small Computer System Interface (SCSI) controllers, and the maximum number of disks mounted and their usage for each SCSI controller;
[0042] Based on the disk information of each of the M virtual machines, the user-triggered request received this time is verified;
[0043] After the verification is successful, the step of creating M*N atomic tasks is triggered.
[0044] Thirdly, embodiments of the present invention provide an electronic device, the electronic device comprising: a housing, a processor, a memory, a circuit board, and a power supply circuit, wherein the circuit board is disposed within the space enclosed by the housing, and the processor and the memory are disposed on the circuit board; the power supply circuit is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory is used to store executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, for executing the virtual machine disk mounting method described in the first aspect above.
[0045] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing one or more programs that can be executed by one or more central processing units to implement the virtual machine disk mounting method described in the first aspect.
[0046] The technical solution provided by this invention can automatically mount a batch of disks to a batch of virtual machines. For users, they only need to configure some simple information such as the number of virtual machines and disks to realize one-click mounting of disks on virtual machines, which is very simple and efficient. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0048] Figure 1 This is a flowchart of a virtual machine disk mounting method provided in Embodiment 1 of the present invention;
[0049] Figure 2 This is a schematic diagram of task invocation when multiple virtual machines mount multiple shared disks, as provided in Embodiment 1 of the present invention;
[0050] Figure 3 This is a flowchart of a virtual machine disk mounting method provided in Embodiment 2 of the present invention;
[0051] Figure 4 This is a flowchart of a virtual machine disk mounting method provided in Embodiment 3 of the present invention;
[0052] Figure 5 This is a schematic diagram of a virtual machine disk mounting device provided in Embodiment 4 of the present invention;
[0053] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0054] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0055] It should be understood that the described embodiments are merely some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0056] Example 1
[0057] This embodiment provides a method for mounting a virtual machine disk, which can be executed by a virtual machine disk mounting device, wherein the device is implemented in software. See also... Figure 1 The method includes the following steps 101-104.
[0058] Step 101: Receive a user-triggered request to mount N shared disks to M virtual machines.
[0059] In this step, after the user triggers a shared disk mount request for the virtual machines, the shared disk mount configuration interface is displayed. The interface receives information about M virtual machines (e.g., virtual machine identifiers) and N shared disks (e.g., shared disk size, storage pool attributes, etc.) configured by the user. This information is then used to generate a request to mount N shared disks to the M virtual machines. Here, M and N are both integers greater than 1.
[0060] Step 102: Create M*N atomic tasks.
[0061] Step 103: Treat the first to N atomic tasks as the first task group, and call this task group: create N disk files and mount the N disk files to the first virtual machine.
[0062] Step 104: Take the (k-1)*N+1 to k*N atomic tasks as the k-th task group and call this task group to mount the N created disk files to the k-th virtual machine in a shared manner. Here, k is an integer from 2 to M.
[0063] In this embodiment, to ensure that M virtual machines can automatically mount N shared disks and to know the mounting completion rate in real time, M*N atomic tasks are created, where:
[0064] The first to Nth atomic tasks, as the first task group, are responsible for mounting N disks to the first virtual machine of M virtual machines;
[0065] The (N+1) to 2Nth atomic tasks, as the second task group, are responsible for mounting the N disks to the second virtual machine of the M virtual machines in a shared manner.
[0066] The (2N+1) to 3Nth atomic tasks, as the third task group, are responsible for mounting the N disks to the third virtual machine of the M virtual machines in a shared manner.
[0067] The (3N+1) to 4Nth atomic tasks, as the 4th task group, are responsible for mounting the N disks to the 4th virtual machine of the M virtual machines in a shared manner.
[0068] And so on...
[0069] Until the (M-1)N+1 to M*Nth atomic task, as the Mth task group, the N disks are mounted to the Mth virtual machine of the M virtual machines in a shared manner.
[0070] Among them, the a*N+bth atomic task is responsible for mounting the bth disk to the (a+1th)th virtual machine of M virtual machines, where 0≤a≤M-1,1≤b≤N.
[0071] For example, each atomic task in task group 1 (i.e., the 1st to Nth atomic tasks) performs the following operations serially: creating the disk file corresponding to its own atomic task and mounting the created disk file to the 1st virtual machine. Further, for other task groups besides task group 1: atomic tasks within the same task group sequentially mount different shared disks to the same virtual machine, i.e., atomic tasks in task group k perform the following operations serially: mounting the created disk file corresponding to its own atomic task to the kth virtual machine; while tasks in different task groups can be executed serially or in parallel, meaning that the tasks of mounting shared disks to different virtual machines can be executed sequentially or simultaneously.
[0072] Accordingly, the virtual machine disk mounting method provided in this embodiment further includes: determining the execution order among task groups other than the first task group; and calling the other task groups other than the first task group according to the determined result. The execution order can be serial, parallel, or a combination of serial and parallel. As a preferred embodiment, determining the execution order among task groups other than the first task group can specifically include: batching the other task groups into batches, wherein task groups in different batches are executed serially, and task groups within the same batch are executed in parallel. In this preferred embodiment, all other task groups besides the first task group can be divided into batches of Q task groups, with the number of task groups in the last batch being less than or equal to Q. The number of task groups Q in a batch is typically greater than 1 and less than or equal to the maximum number of concurrent tasks allowed by the virtualization platform where the virtual machine resides; the specific number can be determined by those skilled in the art based on the actual virtualization platform environment configuration and experience.
[0073] like Figure 2 As shown, 11 virtual machines are mounted on N shared disks, forming 11 task groups, each with N atomic tasks. The remaining 10 task groups (excluding the first group) are divided into three batches: batches 1 and 2 each have 4 task groups (task groups 1-4), and batch 3 has 2 task groups (task groups 1 and 2). During this entire mounting process:
[0074] First, the N atomic tasks in the first task group are invoked to mount N disks to the first virtual machine in sequence;
[0075] After the first task group is completed, the four task groups in the first batch are called and executed in parallel. In each of the four task groups, the N atomic tasks are used to mount N disks to the corresponding virtual machines in sequence.
[0076] After the first batch of task groups has been completed, the four task groups in the second batch are called to be executed in parallel. In each of the four task groups, the N atomic tasks in the task group will mount N disks to the corresponding virtual machine in sequence.
[0077] After the task groups in the second batch have finished executing, the two task groups in the third batch are called and executed in parallel. In each of the two task groups, the N atomic tasks in the task group will mount N disks to the corresponding virtual machines in sequence.
[0078] at present Figure 2 The mounting progress shown indicates that the four task groups in the second batch are being executed in parallel. For example, the first two atomic tasks in task group 1 of the second batch have mounted two disks for the corresponding virtual machines, and the third atomic task is mounting the third disk for the corresponding virtual machine.
[0079] Example 2
[0080] This embodiment, based on Embodiment 1 above, further adds a visual display of the virtual machine shared disk mount completion status. This allows users to clearly see the feedback after a disk mount request is triggered, more accurately estimate the waiting time required to complete the mount task, and also facilitates technicians to more intuitively observe the speed at which each task group completes its mount task, thereby optimizing the disk mount implementation of atomic tasks within the task group. See also Figure 3 The virtual machine disk mounting method provided in this embodiment includes the following steps 301-306.
[0081] Step 301: Receive a user-triggered request to mount N shared disks to M virtual machines.
[0082] Step 302: Create M*N atomic tasks.
[0083] Step 303: Treat the first to N atomic tasks as the first task group, and call this task group: create N disk files and mount the N disk files to the first virtual machine.
[0084] Step 304: Take the (k-1)*N+1 to k*N atomic tasks as the k-th task group and call this task group to mount the N created disk files to the k-th virtual machine in a shared manner. Here, k is an integer from 2 to M.
[0085] Step 305: Calculate the completion amount of mounting N shared disks on M virtual machines.
[0086] Step 306: Display the completion status of M virtual machines mounting N shared disks in real time.
[0087] The completion status can be dynamically displayed using a progress bar or animation to show the progress of M virtual machines mounting N shared disks. The progress displayed on the progress bar or the animation progress is directly proportional to the completion status of the M virtual machines mounting N shared disks. A full progress bar or the completion of the animation indicates that the M virtual machines mounting N shared disks is fully completed. Typically, the completion status when all M virtual machines mounting N shared disks are complete is 100. The following details how to calculate the completion status of M virtual machines mounting N shared disks under three different execution orders for each task group.
[0088] (1) Scenario 1: Execution is performed serially within each task group and serially between groups.
[0089] Calculate the total number of virtual machines (M) mounted on N shared disks using the following formula:
[0090]
[0091] Among them, P i This represents the completion amount of the i-th atomic task currently performing an operation in this atomic task out of M*N atomic tasks. The value is greater than or equal to 0 and less than or equal to 100.
[0092] (2) Scenario 2: Execution is carried out serially within each task group, and parallelly among other task groups except for Task Group 1.
[0093] Calculate the total number of virtual machines (M) mounted on N shared disks using the following formula:
[0094]
[0095] in:
[0096] P i This represents the amount of completion of the i-th atomic task currently performing an operation in this atomic task out of M*N atomic tasks;
[0097] k is an integer from 2 to M; mod(i,N) is the remainder when i is divided by N, representing the t-th atomic task in the k-th task group; P k,y This represents the completion amount of the t-th atomic task in the k-th task group currently being executed, with a value greater than or equal to 0 and less than or equal to 100.
[0098] (3) Case 3: Execution is carried out serially within each task group, and serial and parallel execution is carried out between other task groups except for Task Group 1.
[0099] Calculate the total number of virtual machines (M) mounted on N shared disks (Pro) using the following formula:
[0100]
[0101] in:
[0102] P i This represents the completion amount of the i-th atomic task currently performing an operation in this atomic task out of M*N atomic tasks. The value is greater than or equal to 0 and less than or equal to 100.
[0103] x represents the batch index value to which the task group currently performing the operation belongs, and Q represents the maximum number of task groups within a batch specified by the batch partitioning rule;
[0104] P x,y,z This represents the completion amount of the z-th atomic task within the y-th task group of the x-th batch, currently being executed. The value is greater than or equal to 0 and less than or equal to 100. y In parentheses, y takes values from 1 to the number of task groups in the xth batch; mod(i,N) is the remainder when i is divided by N, representing the z-th atomic task in the y-th task group within the x-th batch.
[0105] It should be noted that the batch division rule is as follows: each batch consists of Q task groups, and all other task groups except the first task group are divided into batches. The number of task groups in the last batch is less than or equal to Q. The batch index value ranges from 1 to the total number of batches.
[0106] Example 3
[0107] This embodiment, based on the above embodiments, adds task checks and request verification operations upon receiving a user request. Only when the checks and verifications are successful is the task group invoked to perform the virtual machine's shared disk mount operation. This significantly improves the mount success rate and largely avoids the system resource waste caused by rollback after mount failure. See also Figure 4 The virtual machine disk mounting method provided in this embodiment includes the following steps 401-407.
[0108] Step 401: Receive a user-triggered request to mount N shared disks to M virtual machines.
[0109] Step 402: Obtain the disk information of each virtual machine in the M virtual machines.
[0110] The disk information for each virtual machine includes: the number and usage of Small Computer System Interface (SCSI) controllers, and the maximum number of disks mounted and their usage for each SCSI controller.
[0111] Step 403: Verify the user-triggered request received this time based on the disk information of each virtual machine in the M virtual machines.
[0112] In this step, the N shared disks specified in the request should be less than or equal to the total number of disks V that can be mounted by the currently M virtual machines' SCSI controllers, provided that each SCSI controller has the same maximum number of disks. The total number of disks V = the number of SCSI controllers that can be configured and are not currently occupied * the maximum number of disks mounted by each SCSI controller. If N is less than or equal to V, the verification passes, and step 404 is executed. Otherwise, the process ends. Preferably, the user can be prompted to modify the number of shared disks in the request.
[0113] Step 404: Check if there are any ongoing virtual machine operation tasks for the M virtual machines.
[0114] If yes, end the current process. Preferably, you can also indicate that there are M virtual machines with tasks in progress. If no, proceed to step 405.
[0115] Step 405: Create M*N atomic tasks.
[0116] Step 406: Treat the first to N atomic tasks as the first task group, and call this task group: create N disk files and mount the N disk files to the first virtual machine.
[0117] Step 407: Take the (k-1)*N+1 to k*N atomic tasks as the k-th task group and call this task group: mount the N created disk files to the k-th virtual machine in a shared manner.
[0118] Where k takes the value of an integer from 2 to M.
[0119] It should be noted that the above example provides a preferred implementation method, in which static information is checked first (corresponding to steps 402 and 403 above), and then runtime information is checked (corresponding to step 404 above). However, this does not mean that it must be executed in this manner. The execution order of steps 402 and 403 and step 404 can be interchanged, that is, step 404 can be executed first, followed by steps 402 and 403.
[0120] Furthermore, as a preferred implementation, when calling each task group, if the mounting operation of a certain atomic task in the group fails, a remounting attempt can be made. After multiple remounting attempts (preferably 3 times) fail, the current process ends, a rollback is performed, and the M virtual machines and N disks are restored to the state when the user triggered the request to mount N shared disks for the M virtual machines.
[0121] Furthermore, the virtual machine disk mounting method provided in this embodiment of the invention, based on the schemes described in the above method embodiments, may further include the following after receiving a user-triggered request to mount N shared disks for M virtual machines and before creating M*N atomic tasks:
[0122] Based on the shared disk information carried in the request, determine the amount of storage space required for this batch mounting;
[0123] Query the available space of each storage pool and filter out a list of storage pools that meet the storage space requirements for this batch mounting;
[0124] Select at least one storage pool from the filtered storage pool list, and divide it into N disks for the task group to mount to M virtual machines. The size of each of the N disks is equal to the size of the shared disk carried in the request.
[0125] Preferably, the disk information in the request may also include the storage pool level (e.g., availability level, disaster recovery level) information of the disk. After filtering out the list of storage pools, a target storage pool that meets the storage pool level information is matched from the list. A target storage pool is selected, and N disks are partitioned into it for the task group to mount to M virtual machines.
[0126] Example 4
[0127] This embodiment provides a virtual machine disk mounting device, which can be used to execute the virtual machine disk mounting method described in any embodiment of the present invention. This device is implemented in software. See also... Figure 5 The device specifically includes the following units:
[0128] The request receiving unit 501 is used to receive a user-triggered request to mount N shared disks for M virtual machines, where M and N are both integers greater than 1;
[0129] Task creation unit 502 is used to create M*N atomic tasks;
[0130] The first task invocation unit 503 is used to take the first to N atomic tasks as the first task group, and invoke this task group to create N disk files and mount the N disk files to the first virtual machine.
[0131] The second task calling unit 504 is used to take the (k-1)*N+1 to k*N atomic tasks as the k-th task group and call this task group: to mount the N created disk files to the k-th virtual machine in a shared manner, where k is an integer from 2 to M.
[0132] For example, each atomic task in the first task group performs the following operations in sequence: creates the disk file corresponding to its own atomic task, and mounts the created disk file to the first virtual machine.
[0133] For example, the second task invocation unit 504 is further configured to: determine the execution order among task groups other than the first task group;
[0134] Based on the determined results, call other task groups except for task group 1. In task group k, the atomic tasks perform the following operations in a serial manner: mount the disk file corresponding to this atomic task to the kth virtual machine.
[0135] Preferably, the second task invocation unit 504 is used to determine the execution order among task groups other than the first task group, specifically including:
[0136] The other task groups, except for the first task group, are divided into batches. Task groups in different batches are executed serially, while task groups in the same batch are executed in parallel.
[0137] Furthermore, the virtual machine disk mounting device provided in this embodiment also includes a mounting completion display unit 505, used for:
[0138] Calculate the total number of virtual machines (M) mounted on N shared disks (Pro) using the following formula:
[0139]
[0140] The system displays in real time the progress of mounting N shared disks onto the M virtual machines.
[0141] Among them, S i P represents the completion amount of the i-th atomic task currently executing within an M*N atomic task, with a value greater than or equal to 0 and less than or equal to 100. x represents the batch index of the currently executing task group, Q represents the maximum number of task groups within a batch specified by the batch partitioning rule, and P... x,y,z This represents the completion amount of the z-th atomic task within the y-th task group of the x-th batch, currently being executed, within this atomic task. y In parentheses, y takes the value from 1 to the xth batch number of task groups, and mod(i,N) represents the remainder when i is divided by N.
[0142] Furthermore, the virtual machine disk mounting device provided in this embodiment also includes a checking unit 506, used to: check whether there are any ongoing virtual machine operation tasks in the M virtual machines; if the check result is no, trigger the task creation unit 502 to execute the step of creating M*N atomic tasks.
[0143] Furthermore, the virtual machine disk mounting device provided in this embodiment also includes a verification unit 507, used for:
[0144] Obtain the disk information of each virtual machine in the M virtual machines, including: the number and usage of Small Computer System Interface (SCSI) controllers, and the maximum number of disks mounted and their usage for each SCSI controller;
[0145] Based on the disk information of each of the M virtual machines, the user-triggered request received this time is verified;
[0146] After the verification is successful, the step of creating M*N atomic tasks is triggered.
[0147] The virtual machine disk mounting device provided in this embodiment of the invention and the virtual machine disk mounting method provided in any embodiment of the invention belong to the same inventive concept. Technical details not described in this embodiment can be found in the relevant descriptions in the foregoing method embodiments, and will not be repeated here.
[0148] Figure 6 This is a schematic diagram of the structure of an embodiment of the electronic device of the present invention, which can be used to implement the flow of various method embodiments of the present invention, such as... Figure 6 As shown, the aforementioned electronic device may include: a housing 61, a processor 62, a memory 63, a circuit board 64, and a power supply circuit 65. The circuit board 64 is disposed inside the space enclosed by the housing 61, and the processor 62 and the memory 63 are disposed on the circuit board 64. The power supply circuit 65 is used to supply power to the various circuits or devices of the aforementioned electronic device. The memory 63 is used to store executable program code. The processor 62 runs a program corresponding to the executable program code by reading the executable program code stored in the memory 63, for executing the virtual machine disk mounting method described in any of the foregoing embodiments.
[0149] For details on the specific execution process of the above steps by the processor 62 and the steps further executed by the processor 62 by running executable program code, please refer to the descriptions of the various method embodiments of the present invention, which will not be repeated here.
[0150] This electronic device exists in various forms, including but not limited to:
[0151] (1) Mobile communication devices: These devices are characterized by their mobile communication capabilities and primarily aim to provide voice and data communication. These terminals include: smartphones (e.g., iPhones), multimedia phones, feature phones, and low-end phones, etc.
[0152] (2) Ultra-mobile personal computer devices: These devices fall under the category of personal computers, possessing computing and processing capabilities, and generally also have mobile internet access features. These terminals include PDAs, MIDs, and UMPCs, such as the iPad.
[0153] (3) Portable entertainment devices: These devices can display and play multimedia content. This category includes: audio and video players (such as iPods), handheld game consoles, e-books, as well as smart toys and portable car navigation devices.
[0154] (4) Server: A device that provides computing services. The components of a server include a processor, hard disk, memory, system bus, etc. Servers are similar to general computer architectures, but because they need to provide highly reliable services, they have higher requirements in terms of processing power, stability, reliability, security, scalability, and manageability.
[0155] (5) Other electronic devices with data interaction functions.
[0156] Furthermore, embodiments of the present invention also provide a computer-readable storage medium storing one or more programs, which can be executed by one or more central processing units to implement the virtual machine disk mounting method described in the foregoing embodiments.
[0157] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0158] In this embodiment of the invention, the term "and / or" describes the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. The character " / " generally indicates that the preceding and following associated objects have an "or" relationship.
[0159] The various embodiments in this specification are described in a related manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.
[0160] In particular, the device embodiment is basically similar to the method embodiment, so the description is relatively simple. For relevant details, please refer to the description of the method embodiment.
[0161] For ease of description, the above apparatus is described by dividing it into various functional units / modules. Of course, in implementing this invention, the functions of each unit / module can be implemented in one or more software and / or hardware.
[0162] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0163] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for mounting a virtual machine disk, characterized in that, The method includes: Receive user-triggered requests to mount N shared disks onto M virtual machines, where M and N are both integers greater than 1; Create M*N atomic tasks; Treat the first to Nth atomic tasks as the first task group, and call this task group: create N disk files and mount the N disk files to the first virtual machine; Take the (k-1)*N+1 ~ k*N atomic tasks as the k-th task group, and call this task group: mount the N created disk files to the k-th virtual machine in a shared manner, where k is an integer from 2 to M; In the first task group, each atomic task performs the following operations in sequence: creating the disk file corresponding to the atomic task and mounting the created disk file to the first virtual machine. The method further includes: determining the execution order among task groups other than the first task group; Based on the determined results, call other task groups except for task group 1. In task group k, the atomic tasks perform the following operations in a serial manner: mount the disk file corresponding to this atomic task to the kth virtual machine.
2. The method according to claim 1, characterized in that, Determine the execution order among task groups other than Task Group 1, including: The other task groups, except for the first task group, are divided into batches. Task groups in different batches are executed serially, while task groups in the same batch are executed in parallel.
3. The method according to claim 2, characterized in that, The method further includes: Calculate the total number of virtual machines mounted on N shared disks using the following formula. : The system displays in real time the progress of mounting N shared disks onto the M virtual machines. in, This represents the completion amount of the i-th atomic task currently executing within this atomic task out of M*N atomic tasks. Its value is greater than or equal to 0 and less than or equal to 100. This indicates the batch index value to which the task group currently performing the operation belongs. This indicates the maximum number of task groups within a batch, as specified by the batch partitioning rules. This indicates that the operation currently being performed belongs to the first... The first batch The first in the task group The amount of time an atomic task is completed within its own atomic task. middle Values range from 1 to the Number of task groups within a batch express Divide by The remainder.
4. The method according to claim 1, characterized in that, Before creating M*N atomic tasks, the method further includes: checking whether there are any ongoing virtual machine operation tasks in the M virtual machines; If the check result is negative, proceed with the step of creating M*N atomic tasks.
5. The method according to claim 1, characterized in that, Before creating M*N atomic tasks, the method further includes: Obtain the disk information of each virtual machine in the M virtual machines, including: the number and usage of Small Computer System Interface (SCSI) controllers, and the maximum number of disks mounted and their usage for each SCSI controller; Based on the disk information of each of the M virtual machines, the user-triggered request received this time is verified; After the verification is successful, proceed with the step of creating M*N atomic tasks.
6. A virtual machine disk mounting device, characterized in that, The device includes: The request receiving unit is used to receive user-triggered requests for mounting N shared disks on M virtual machines, where M and N are both integers greater than 1; The task creation unit is used to create M*N atomic tasks; The first task invocation unit is used to take the first to N atomic tasks as the first task group, and invoke this task group to create N disk files and mount the N disk files to the first virtual machine. The second task invocation unit is used to take the (k-1)*N+1 ~ k*N atomic tasks as the k task group and invoke this task group: mount the N created disk files to the k virtual machine in a shared manner, where k is an integer from 2 to M. In the first task group, each atomic task performs the following operations in sequence: creating the disk file corresponding to the atomic task and mounting the created disk file to the first virtual machine. The second task invocation unit is also used to: determine the execution order among task groups other than the first task group; Based on the determined results, call other task groups except for task group 1. In task group k, the atomic tasks perform the following operations in a serial manner: mount the disk file corresponding to this atomic task to the kth virtual machine.
7. An electronic device, characterized in that, The electronic device includes: a housing, a processor, a memory, a circuit board, and a power supply circuit, wherein the circuit board is disposed inside the space enclosed by the housing, and the processor and the memory are disposed on the circuit board; the power supply circuit is used to supply power to various circuits or devices of the electronic device; the memory is used to store executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, for executing the method of any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores one or more programs, which can be executed by one or more central processing units to implement the method of any one of claims 1-5.
Citation Information
Patent Citations
Method and device for sharing disks by core network virtualized systems and network management MANO system
CN107515725A