(19)
(11)EP 3 594 807 A1

(12)EUROPEAN PATENT APPLICATION
published in accordance with Art. 153(4) EPC

(43)Date of publication:
15.01.2020 Bulletin 2020/03

(21)Application number: 17903827.8

(22)Date of filing:  11.12.2017
(51)International Patent Classification (IPC): 
G06F 9/455(2018.01)
(86)International application number:
PCT/CN2017/115506
(87)International publication number:
WO 2018/176911 (04.10.2018 Gazette  2018/40)
(84)Designated Contracting States:
AL AT BE BG CH CY CZ DE DK EE ES FI FR GB GR HR HU IE IS IT LI LT LU LV MC MK MT NL NO PL PT RO RS SE SI SK SM TR
Designated Extension States:
BA ME
Designated Validation States:
MA MD TN

(30)Priority: 31.03.2017 CN 201710212688

(71)Applicant: Huawei Technologies Co., Ltd.
Longgang District Shenzhen, Guangdong 518129 (CN)

(72)Inventors:
  • WO, Tianyu
    Beijing 100191 (CN)
  • KANG, Junbin
    Beijing 100191 (CN)
  • BAI, Xin
    Shenzhen Guangdong 518129 (CN)

(74)Representative: Pfenning, Meinig & Partner mbB 
Patent- und Rechtsanwälte Theresienhöhe 11a
80339 München
80339 München (DE)

  


(54)VIRTUAL DISK FILE FORMAT CONVERSION METHOD AND DEVICE


(57) A virtual disk file format conversion method and an apparatus are disclosed, and relate to the field of virtualization technologies, so as to resolve a service interruption caused by offline conversion of a virtual machine disk image file format when a virtual machine is migrated between different types of VMMs. The method includes: establishing a mapping table between a virtual address of a virtual machine VM disk image file and a physical address of a disk image file that is compatible with a virtual machine monitor VMM; converting, according to the mapping table, the virtual address used when a user performs reading/writing on the VM disk image file, into the physical address mapped to the virtual address; and further performing data reading/writing on the VM disk image file based on the physical address.




Description


[0001] This application claims priority to Chinese Patent Application No. 201710212688.3, filed with the Chinese Patent Office on March 31, 2017 and entitled "VIRTUAL DISK FILE FORMAT CONVERSION METHOD AND APPARATUS", which is incorporated herein by reference in its entirety.

TECHNICAL FIELD



[0002] This application relates to the field of virtualization technologies, and in particular, to a virtual disk file format conversion method and an apparatus.

BACKGROUND



[0003] As a means of multiplexing system resources and improving resource utilization, virtual machine technologies are widely researched and applied as cloud computing systems are deployed. In a system virtualization process, a virtual machine monitor (Virtual Machine Monitor, VMM) is responsible for managing a virtual machine (Virtual Machine, VM) instance in a system, and the VMM constructs virtual resource abstraction at a system level. In this way, a running environment perceived by the VM running in the VMM is almost the same as a physical computing system, so that running of software in the VM and migration between VMMs can be implemented without modifying software. In this process, a disk storage resource of the VM is usually carried by a file stored on a physical storage device (for example, a hard disk). The file is referred to as a disk image file. Reading/writing performed on disks in all VMs is translated by the VMM into reading/writing performed on the disk image file, so that storage of a plurality of VMs is allowed to be all carried on one physical device, as shown in FIG. 1.

[0004] A virtual machine disk image file usually has some internal formats, and is used to record related usage information of the disk of the virtual machine. Each VMM has a compatible virtual machine disk image file format. Because different virtual machine vendors use respective virtual disk formats, when the VMM performs reading/writing on a virtual disk file in a virtual disk format that is incompatible with the VMM, format conversion needs to be performed. An existing conversion tool is an offline conversion tool. In other words, when the VM is not running, an entire virtual machine disk image file is scanned by using a software tool (such as qemu-img or vmware converter), and a new virtual machine disk image file in a target format is generated, so that the virtual machine runs in a new VMM environment. However, the virtual machine needs to wait for a relatively long disk image format conversion time before starting running in a new environment, thereby causing a service interruption.

SUMMARY



[0005] Embodiments of this application provide a virtual disk file format conversion method and an apparatus, so as to resolve a service interruption caused by offline conversion of a virtual machine disk image file format when a virtual machine is migrated between different types of VMMs.

[0006] According to an aspect, a virtual disk file format conversion method is provided and includes: establishing, by a network device, a mapping table between a virtual address of a virtual machine VM disk image file and a physical address of a disk image file that is compatible with a virtual machine monitor VMM; converting, by the network device according to the mapping table, the virtual address used when a user performs reading/writing on the VM disk image file, into the physical address mapped to the virtual address; and performing, by the network device, data reading/writing on the VM disk image file based on the physical address. In this way, online conversion between virtual machine disk image formats can be implemented. In a system environment configuration, a virtual disk image file system in this application can be used to implement cross-adaption of virtual disk image files without a pre-startup image format conversion delay and with a low I/O performance loss, and storage support is provided for seamless migration of a virtual machine disk image of the user from a cloud platform to another cloud platform. The virtual disk image file system in this application has a relatively high application value especially in a scenario in which the user has a service encapsulated in the virtual machine disk image file, and test running needs to be performed on different cloud platforms. A mechanism in which a plurality of virtual machine disk image storage file formats coexist during running of one virtual machine monitor is provided, and less code for conversion between the plurality of storage file formats is developed.

[0007] In a possible design, the establishing, by a network device, a mapping table between a virtual address of a virtual machine VM disk image file and a physical address of a disk image file that is compatible with a virtual machine monitor VMM includes: mounting, by the network device, the VM disk image file; determining, by the network device, a storage grain of the VM disk image file based on metadata in the VM disk image file; and if the storage grain of the VM disk image file is consistent with a storage grain of the disk image file that is compatible with the VMM, one-to-one mapping, by the network device, data blocks of the VM disk image file to data blocks of the disk image file that is compatible with the VMM; or if the storage grain of the VM disk image file is inconsistent with a storage grain of the disk image file that is compatible with the VMM, mapping, by the network device, a block index of the VM disk image file to a most significant bit of the physical address of the disk image file that is compatible with the VMM, and mapping an intra-block index of the VM disk image file to a remaining address of the disk image file that is compatible with the VMM. Therefore, according to the newly established mapping table, the virtual address accessed by the user may be mapped to the physical address that is compatible with the VMM, in other words, data reading/writing may be performed on the VM disk image file according to the mapping table.

[0008] In a possible design, the converting, by the network device according to the mapping table, the virtual address used when a user performs reading/writing on the VM disk image file, into the physical address mapped to the virtual address includes: if the network device determines that the user performs a read operation on the VM disk image file, obtaining, by the network device according to the mapping table, and the block index and the intra-block index of the virtual address, the physical address mapped to the virtual address; and the performing, by the network device, data reading/writing on the VM disk image file based on the physical address includes: performing, by the network device, reading on the VM disk image file by using the physical address. In this way, when the VM is online, a plurality of VM disk image storage file formats coexist during running of one VMM.

[0009] In a possible design, the converting, by the network device according to the mapping table, the virtual address used when a user performs reading/writing on the VM disk image file, into the physical address mapped to the virtual address includes: if the network device determines that the user performs a write operation on the VM disk image file, obtaining, by the network device according to the mapping table, and the block index and the intra-block index of the virtual address, the physical address mapped to the virtual address; and the performing, by the network device, data reading/writing on the VM disk image file based on the physical address includes: performing, by the network device, writing on the VM disk image file by using the physical address.

[0010] In a possible design, the method further includes: if the network device determines that the user performs a read operation on a data block corresponding to the virtual address of the VM disk image file for a first time, reading, by the network device, at a corresponding physical address according to the mapping table, and creating a corresponding buffer block in a memory, so as to read from the buffer block during a subsequent read operation on the data block; and if the network device determines that the user performs a write operation on the data block, writing, by the network device, at the corresponding physical address according to the mapping table, and marking the buffer block as a dirty data block, so as to re-read at the corresponding physical address and overwrite the buffer block in the memory when the user performs a read operation on the data block for a next time. In this way, a data translation speed can be improved and intermediate conversion overheads can be reduced. A data block that is recently frequently used is buffered in a kernel virtual file system by using a kernel buffer mechanism. If back-end storage is frequently accessed, there is no need to repeatedly perform reading on a back-end file system, and read/write overheads are reduced.

[0011] According to another aspect, a network device is provided, including: a mapping module, configured to establish a mapping table between a virtual address of a virtual machine VM disk image file and a physical address of a disk image file that is compatible with a virtual machine monitor VMM, where the mapping module is further configured to convert, according to the mapping table, the virtual address used when a user performs reading/writing on the VM disk image file, into the physical address mapped to the virtual address; and a read/write module, configured to perform data reading/writing on the VM disk image file based on the physical address.

[0012] In a possible design, the mapping module is configured to mount the VM disk image file;
determine a storage grain of the VM disk image file based on metadata in the VM disk image file; and if the storage grain of the VM disk image file is consistent with a storage grain of the disk image file that is compatible with the VMM, one-to-one map data blocks of the VM disk image file to data blocks of the disk image file that is compatible with the VMM; or if the storage grain of the VM disk image file is inconsistent with a storage grain of the disk image file that is compatible with the VMM, map a block index of the VM disk image file to a most significant bit of the physical address of the disk image file that is compatible with the VMM, and map an intra-block index of the VM disk image file to a remaining address of the disk image file that is compatible with the VMM.

[0013] In a possible design, the mapping module is configured to: if the network device determines that the user performs a read operation on the VM disk image file, obtain, according to the mapping table, and the block index and the intra-block index of the virtual address, the physical address mapped to the virtual address; and the read/write module is configured to perform reading on the VM disk image file by using the physical address.

[0014] In a possible design, the mapping module is configured to: if the network device determines that the user performs a write operation on the VM disk image file, obtain, according to the mapping table, and the block index and the intra-block index of the virtual address, the physical address mapped to the virtual address; and the read/write module is configured to perform writing on the VM disk image file by using the physical address.

[0015] In a possible design, the network device further includes a storage module, configured to: if the network device determines that the user performs a read operation on a data block corresponding to the virtual address of the VM disk image file for a first time, read at a corresponding physical address according to the mapping table, and create a corresponding buffer block in a memory, so as to read from the buffer block during a subsequent read operation on the data block; and if the network device determines that the user performs a write operation on the data block, write at the corresponding physical address according to the mapping table, and mark the buffer block as a dirty data block, so as to re-read at the corresponding physical address and overwrite the buffer block in the memory when the user performs a read operation on the data block for a next time.

[0016] In the embodiments of this application, the mapping table between the virtual address of the virtual machine VM disk image file and the physical address of the disk image file that is compatible with the virtual machine monitor VMM is established; the virtual address used when the user performs reading/writing on the VM disk image file is converted, according to the mapping table, into the physical address mapped to the virtual address; and further, data reading/writing is performed on the VM disk image file based on the physical address, so that online conversion between virtual machine disk image formats can be implemented. In a system environment configuration, a virtual disk image file system in this application can be used to implement cross-adaption of virtual disk image files without a pre-startup image format conversion delay and with a low I/O performance loss, and storage support is provided for seamless migration of a virtual machine disk image of the user from a cloud platform to another cloud platform. The virtual disk image file system in this application has a relatively high application value especially in a scenario in which the user has a service encapsulated in the virtual machine disk image file, and test running needs to be performed on different cloud platforms. A mechanism in which a plurality of VM disk image storage file formats coexist during running of one VMM is provided, and less code for conversion between the plurality of storage file formats is developed.

BRIEF DESCRIPTION OF DRAWINGS



[0017] 

FIG. 1 is a schematic diagram in which a VMM translates reading/writing on a disk in a VM into reading/writing on a disk image file;

FIG. 2 is a schematic structural diagram of a network device according to an embodiment of this application;

FIG. 3 is a schematic diagram of layers of an implementation object according to an embodiment of this application;

FIG. 4 is a schematic flowchart of a virtual disk file format conversion method according to an embodiment of this application;

FIG. 5 is a schematic diagram of a mapping and conversion relationship from a virtual address to a physical address according to an embodiment of this application;

FIG. 6 is a schematic diagram of a built-in read/write buffer mechanism in VDFS according to an embodiment of this application;

FIG. 7 is a schematic flowchart of an online conversion process from a VMDK format to a RAW format according to an embodiment of this application;

FIG. 8 is a schematic diagram of mapping a virtual disk in a VMDK format to a virtual disk in a RAW format according to an embodiment of this application;

FIG. 9 is a schematic diagram of converting a level-2 directory into a level-1 directory according to an embodiment of this application;

FIG. 10 is a schematic diagram of mapping a VMDK virtual disk to a RAW virtual disk according to an embodiment of this application;

FIG. 10a is a schematic diagram of mapping a virtual address to a physical address according to an embodiment of this application;

FIG. 11 is a schematic diagram of design and implementation of a kernel buffer according to an embodiment of this application;

FIG. 12 is a schematic diagram of a read/write process of a kernel buffer according to an embodiment of this application;

FIG. 13 is a schematic structural diagram of a network device according to an embodiment of this application; and

FIG. 14 is a schematic structural diagram of a network device according to an embodiment of this application.


DESCRIPTION OF EMBODIMENTS



[0018] The embodiments of this application may be applied to a scenario in which different formats of virtual disks are online converted into corresponding compatible formats, so as to support migration of a virtual machine between different types of virtual machine monitors.

[0019] A network architecture in the embodiments of this application may be applied to different network devices. For example, the network devices may be a personal computer, a server, and a mobile phone. One or more virtual machines VMs, a virtual machine monitor VMM, and virtual machine disk image files corresponding to the VMs may be deployed in the network device. The network device is responsible for carrying. Different VMs may correspond to different virtual machine disk image files. Reading/writing performed on disks in all VMs may be translated by the VMM into reading/writing performed on the disk image files, so that storage of a plurality of VMs is allowed to be carried on one network device. As shown in FIG. 2, the network device 2 may include a mapping module 21, a read/write module 22, and a storage module 23. The mapping module 21 is configured to establish a mapping table between a virtual address of a VM disk image file and a physical address of a disk image file that can be identified by a VMM. When a user performs a read/write operation, the mapping module 21 is further configured to convert, according to the mapping table, the virtual address used when the user performs reading/writing on the VM disk image file, into the physical address mapped to the virtual address. The read/write module 22 is configured to perform data reading/writing on the VM disk image file based on the physical address. The storage module 23 is configured to store a data block, metadata of the data block, a physical address and a virtual address of the data block, a corresponding application program used to perform the method in the embodiments of this application, and the like. For specific applications of the mapping module 21, the read/write module 22, and the storage module 23 in the embodiments of this application, refer to descriptions in the following embodiments. In the embodiments of this application, the virtual machine disk image file and the disk image file have a same meaning.

[0020] An implementation object in the embodiments of this application may include three layers. As shown in FIG. 3, a target virtual machine disk image format at an uppermost layer may be referred to as a front-end virtual disk view, and include several storage grains that may also be referred to as blocks (block) herein. A virtual disk file system (Virtual Disk File System, VDFS) in the middle includes an input/output (Input/Output, I/O) mapping mechanism, and is responsible for mapping a storage unit address in a source virtual disk view to a corresponding unit address in the target virtual disk format. A source virtual machine disk image format at a lowermost layer may be referred to as a back-end disk image view, and also include several storage grains.

[0021] As shown in FIG. 4, an embodiment of this application is used to implement an online conversion method of virtual disk file formats for read/write buffer at a file system layer, and the method may include the following steps.

[0022] 401. A network device establishes a mapping table between a virtual address of a virtual machine VM disk image file and a physical address of a disk image file that is compatible with a virtual machine monitor VMM.

[0023] When the VM is migrated from one VMM to another VMM, if the network device determines that a format of the VM disk image file is different from a format of the disk image file supported by the VMM, the network device may first mount the VM disk image file, and then establish the mapping table based on layout characteristics of virtual disk format files at a front end and a back end. A storage grain of the VM disk image file may be first determined based on metadata in the VM disk image file. For different formats of virtual machine disk image files, different data block sizes may be defined, and a format of a block allocation table may be different. The block allocation table may have a plurality of levels, but finally show same data logical distribution.

[0024] Then, a virtual disk address accessed by a user, namely, a logical address of a back-end virtual disk view is converted into a physical address of a front-end virtual disk view. The conversion may be completed by using a VDFS address mapping table, and the VDFS address mapping table includes a plurality of mapping addresses (mapping address), as shown in FIG. 5. First, a mapping relationship may be determined, to be specific, there is a mapping relationship between data locations of virtual disk image files at a front end and a back end. The relationship is formed through converting by a middle block. If a storage grain of a front-end virtual disk image format is consistent with a storage grain of a back-end virtual disk image format, the relationship is one-to-one mapping. To be specific, if the storage grain of the VM disk image file is consistent with the storage grain of the disk image file that is compatible with the VMM, the network device one-to-one maps data blocks of the VM disk image file to data blocks of the disk image file that is compatible with the VMM. If the storage grain of the VM disk image file is inconsistent with the storage grain of the disk image file that is compatible with the VMM, the network device may map a block index (Block-Index) of the VM disk image file to a most significant bit of the physical address of the disk image file that is compatible with the VMM, and map an intra-block index (Block-Offset) of the VM disk image file to a remaining address of the disk image file that is compatible with the VMM.

[0025] 402. The network device converts, according to the mapping table, the virtual address used when a user performs reading/writing on the VM disk image file, into the physical address mapped to the virtual address.

[0026] When the network device determines that the user performs a read operation on the VM disk image file, online read/write redirection may be implemented at the file system layer according to the mapping table. Herein, the back-end disk image file may be transmitted to the VDFS as a parameter, and the VDFS is implemented as a virtual file system. The VDFS reads the back-end disk image file, and simulates a front-end disk image file view. For metadata conversion, the format of the image file that is compatible with the VMM may be simulated in an all-linear storage manner based on a requirement (such as a block size) on the front-end disk image format. For data block reading/writing, conversion may be directly completed according to the VDFS address mapping table.

[0027] 403. The network device performs data reading/writing on the VM disk image file based on the physical address.

[0028] If the network device determines that the user performs a read operation on the VM disk image file, the network device may obtain, according to the mapping table, and the block index and the intra-block index of the virtual address accessed by the user, the physical address mapped to the virtual address, and then perform reading on the VM disk image file by using the physical address. If the network device determines that the user performs a write operation on the VM disk image file, the network device may obtain, according to the mapping table, and the block index and the intra-block index of the virtual address, the physical address mapped to the virtual address, and then perform writing on the VM disk image file by using the physical address.

[0029] As shown in FIG. 6, to improve a data translation speed and reduce intermediate conversion overheads, in this embodiment of this application, a data block that is recently frequently used may be directly buffered in a kernel virtual file system by using a kernel buffer mechanism in the VDFS. If storage of a back-end virtual disk image file is frequently accessed, there is no need to repeatedly perform reading on a back-end file system, and read/write overheads can be reduced. When the user reads data for a first time, the data may be stored in a kernel buffer, so that the data is directly read from the kernel buffer for a next time. When the user writes new data into a data block, the data is directly written into a data block corresponding to a disk. A corresponding data block in the kernel buffer is denoted as a dirty data block, in other words, the writing makes the buffer dirty. When the data in the data block is read for a next time, the data block is re-read from the disk and stored in the kernel buffer.

[0030] In this embodiment of this application, the mapping table between the virtual address of the virtual machine VM disk image file and the physical address of the disk image file that is compatible with the virtual machine monitor VMM is established; the virtual address used when the user performs reading/writing on the VM disk image file is converted, according to the mapping table, into the physical address mapped to the virtual address; and further, data reading/writing is performed on the VM disk image file based on the physical address, so that online conversion between virtual machine disk image formats can be implemented. In a system environment configuration, the virtual disk image file system in this application can be used to implement cross-adaption of virtual disk image files without a pre-startup image format conversion delay and with a low I/O performance loss, and storage support is provided for seamless migration of a virtual machine disk image of the user from a cloud platform to another cloud platform. The virtual disk image file system in this application has a relatively high application value especially in a scenario in which the user has a service encapsulated in the virtual machine disk image file, and test running needs to be performed on different cloud platforms. A mechanism in which a plurality of virtual machine disk image storage file formats coexist during running of one virtual machine monitor is provided, and less code for conversion between the plurality of storage file formats is developed.

[0031] An offline conversion tool is compared with an online conversion tool implemented by the VDFS in this application. The existing offline conversion tool does not support VM online migration crossing heterogeneous VMMs. The online conversion tool VDFS in this application provides an abstraction layer between the VMM and the back-end virtual disk. The abstraction layer dynamically converts VMM access to the front-end virtual disk view into access to the back-end virtual disk, and shields a format difference in the back-end virtual disk for the VMM. In this way, VM online migration crossing heterogeneous VMMs can be supported in real time, without waiting for completion of offline conversion. In an actual application scenario of a virtual machine image, a read/write range of a data block is actually relatively limited. For example, a working set at startup is usually limited to a small quantity of disk blocks. By using an optimization mechanism such as buffering, I/O overheads for online conversion can be reduced, and performance of the disk image after an offline conversion tool is used is reached.

[0032] The following uses an example in which an original virtual machine disk image in a VMDK format of a user is mounted by using a VDFS, and reading/writing is performed on the virtual machine disk image file in a VMM that supports only a RAW format. In other words, an online conversion process from the VMDK format to the RAW format is used as an example for description. As shown in FIG. 7, the method includes the following steps.

[0033] 701. A network device reads and computes related metadata in the VMDK format by using the VDFS, learns of distribution and a physical layout of disk storage blocks, and dynamically maps a layout of a disk file in the VMDK format to a layout of a virtual disk file in the RAW format.

[0034] As shown in FIG. 8, a RAW file may be first logically divided into logical blocks that are in a same size as a grain (grain) in the virtual disk file in the VMDK format. Then, grains in the VMDK virtual disk file are mapped to corresponding logical blocks in the RAW one by one according to a sequence in a level-2 directory table in the VMDK virtual disk file.

[0035] Specifically, as shown in FIG. 9, the VMDK virtual disk file may be read into a memory according to a sequence of grain directory entries (Grain Directory Entry, GDE) in a grain directory (Grain Directory, GD), and a new mapping grain table (New Grain Table, NGT) is established, so that a level-2 directory in the VMDK virtual disk file is converted into a level-1 directory. Then, as shown in FIG. 10, a virtual disk file in a back-end VMDK format may be mapped to a virtual disk file in a front-end RAW format based on the newly established NGT. In this way, a logical block on which a user performs reading/writing is calculated based on a front-end RAW virtual disk view, and then the NGT may be queried, to map the logical block to an actual location at which data is located in the back-end VMDK virtual disk file.

[0036] 702. The network device converts, according to a mapping table, a virtual address (vaddress) used when a user performs reading/writing on a virtual machine disk image file in the RAW format, into a physical address mapped to the virtual address, so as to perform reading/writing on the RAW based on the physical address.

[0037] FIG. 10a is a schematic diagram of established mapping from a virtual address to a physical address. When reading/writing is performed on the image file in the RAW format, the address used when the user performs reading/writing, namely, the virtual address vaddress is divided into a block index gindex and an intra-block index offset according to the following formula: gindex=vaddress/grain_size, and offset=vaddress%grain_size, where grain_size indicates a block size. The table NGT is queried to obtain a grain offset address in the back-end VMDK virtual disk image file, then an offset offset of the data in the grain is added to obtain the physical address, and then data reading/writing is performed at the physical address in the VMDK virtual disk image file. If the gain offset gindex obtained through query is null, for example, is equal to -1, it may indicate that a read/write location has not been allocated.

[0038] FIG. 11 is a schematic diagram of design and implementation of a kernel buffer. For a read request, if the gindex obtained according to the foregoing formula is null, or exceeds a virtual capacity of the VMDK virtual disk, an error is returned to the user, or last block data in the VMDK is aligned if necessary. Then, it may be first determined whether to-be-read data is in the kernel buffer. If an intra-block offset is also in a data area in the buffer, and if a dirty flag bit of the data area is 0, it indicates that data in the data area is consistent with that in a corresponding data area in the disk, and data may be read from the data area in the buffer and returned. If the intra-block offset is not in the data area in the buffer, addressing may be performed to obtain a location NGT (gindex) of a grain corresponding to a logical block in the back-end virtual disk in the VMDK format, a grain with a size of grain size is read into the kernel buffer, and a length pre_off and a logical number gindex of actually read data are recorded, so that the data can be directly read from the kernel buffer for a next time. If the intra-block offset is in the data area in the buffer, but the dirty flag bit part is not 0, in other words, if the offset is greater than a buffer offset pre_off, it indicates that the intra-block offset of the to-be-read data is not covered by data in the buffer, addressing may be performed to obtain NGTE[gindex]*grain_size+offset, and be read from the disk. If offset is less than or equal to pre_off, data may be read from the buffer and be directly copied to user space.

[0039] For a write request, when it is determined whether a mapped location is available, if gindex calculated according to the foregoing formula is null, for example, 0, it indicates that a data block is not allocated, and in this case, a data block of a new grain may be allocated. If gindex obtained through calculation exceeds a file size, an error may be returned to the user space. If the gindex calculated according to the foregoing formula is not null, addressing may be performed to obtain NGTE[gindex]*grain_size+offset, and data is written into the back-end disk image file in the VMDK format. In addition, a buffer flag is updated. If a logical block number written into the front-end virtual disk view is consistent with a front-end view logical number corresponding to data in the buffer, the dirty flag bit needs to be set to 1, and it indicates that the data is dirty. The data needs to be read from the disk when being subsequently read.

[0040] In other words, when a read operation is performed on the virtual machine disk image file, the VDFS may translate an original address into a target address according to a corresponding storage block mapping table, and perform reading on an original VMDK file storage block by using the target address. When a write operation is performed on the virtual machine disk image file, the VDFS may translate an original address into a target address according to a corresponding storage block mapping function, and perform writing on an original VMDK file storage block by using the target address. When a first read operation occurs, a corresponding buffer block is maintained in a kernel control memory of the VDFS file system. For a subsequent read operation, data is directly returned to a corresponding buffer block before another write operation occurs. If a write operation occurs, to maintain data consistency, data is directly written at a corresponding physical address, and a corresponding buffer block is set to be dirty. The dirty block is re-read at the corresponding physical address and overwritten when a read operation occurs for a next time. A schematic diagram of a read/write process of the kernel buffer may be shown in FIG. 12.

[0041] By using the foregoing process, the VMM can efficiently online perform reading/writing on heterogeneous virtual machine disk image files, so as to implement online format conversion, and ensure continuous service running of a virtual machine.

[0042] The foregoing mainly describes the solutions provided in the embodiments of this application from the perspective of the network device. It may be understood that, to achieve the foregoing functions, the network device includes a corresponding hardware structure and/or software module for implementing each function. A person skilled in the art should be easily aware that units and algorithm steps in the examples described with reference to the examples described in the embodiments disclosed in this specification may be implemented in a form of hardware or in a form of a combination of hardware and computer software in this specification. Whether a function is performed by hardware or by computer software driving hardware depends on particular applications and design constraints of the technical solutions. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that the implementation goes beyond the scope of this application.

[0043] In the embodiments of this application, the network device may be divided into function modules based on the foregoing method examples. For example, each function module may be obtained through division based on each corresponding function, or two or more functions may be integrated into one processing module. The integrated module may be implemented in a form of hardware, or may be implemented in a form of a software functional module. It should be noted that the module division in the embodiments of this application is an example and is only logical function division. There may be other division manners in actual implementation.

[0044] When an integrated unit is used, FIG. 13 is a possible schematic structural diagram of the network device described in the foregoing embodiments. A network device 1300 includes a mapping unit 1302 and a read/write unit 1303. The mapping unit 1302 may be configured to support the network device in performing the processes 401 and 402 in FIG. 4, the process 701 in FIG. 7, and/or another process of the technology described in this specification. The read/write unit 1303 is configured to support the network device in performing the process 403 in FIG. 4 and the process 702 in FIG. 7. The network device may further include a storage unit 1301, configured to store program code and data of the network device.

[0045] Both the mapping unit 1302 and the read/write unit 1303 may be processors or controllers, for example, a central processing unit (Central Processing Unit, CPU), a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application-Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or another programmable logic device, a transistor logic device, a hardware component, or any combination thereof. The controller/processor may implement or execute various example logical blocks, modules, and circuits described with reference to content disclosed in this application. Alternatively, the processor may be a combination for implementing a computing function, for example, a combination of one or more microprocessors, or a combination of the DSP and a microprocessor. The storage unit 1301 may be a memory.

[0046] When both the mapping unit 1302 and the read/write unit 1303 may be a processor, and the storage unit 1301 is a memory, the network device in this embodiment of this application may be a network device shown in FIG. 14.

[0047] As shown in FIG. 14, the network device 1410 includes: a processor 1412, a transceiver 1413, a memory 1411, and a bus 1414. The processor 1412 and the memory 141 are connected to each other by using the bus 1414. The bus 1104 may be a Peripheral Component Interconnect (Peripheral Component Interconnect, PCI) bus, an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, or the like. The bus may be classified into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used to represent the bus in FIG. 14, but this does not mean that there is only one bus or only one type of bus.

[0048] Methods or algorithm steps described in combination with the content disclosed in this application may be implemented by hardware, or may be implemented by a processor by executing a software instruction. The software instruction may include a corresponding software module. The software module may be stored in a random access memory (Random Access Memory, RAM), a flash memory, a read-only memory (Read-Only Memory, ROM), an erasable programmable read only memory (Erasable Programmable ROM, EPROM), an electrically erasable programmable read only memory (Electrically EPROM, EEPROM), a register, a hard disk, a removable hard disk, a compact disc read-only memory (CD-ROM), or any other form of storage medium well-known in the art. For example, a storage medium is coupled to a processor, so that the processor can read information from the storage medium or write information into the storage medium. Certainly, the storage medium may be a component of the processor. The processor and the storage medium may be located in the ASIC. In addition, the ASIC may be located in a core network interface device. Certainly, the processor and the storage medium may exist in the core network interface device as discrete components.

[0049] A person skilled in the art should be aware that in the foregoing one or more examples, functions described in this application may be implemented by hardware, software, firmware, or any combination thereof. When the present invention is implemented by software, the foregoing functions may be stored in a computer-readable medium or transmitted as one or more instructions or code in the computer-readable medium. The computer-readable medium includes a computer storage medium and a communications medium, where the communications medium includes any medium that enables a computer program to be transmitted from one place to another. The storage medium may be any available medium accessible to a general-purpose or dedicated computer.

[0050] The objectives, technical solutions, and benefits of this application are further described in detail in the foregoing specific embodiments. It should be understood that the foregoing descriptions are merely specific embodiments of this application, but are not intended to limit the protection scope of this application. Any modification, equivalent replacement or improvement made based on the technical solutions of the present invention shall fall within the protection scope of this application.


Claims

1. A virtual disk file format conversion method, comprising:

establishing, by a network device, a mapping table between a virtual address of a virtual machine VM disk image file and a physical address of a disk image file that is compatible with a virtual machine monitor VMM;

converting, by the network device according to the mapping table, the virtual address used when a user performs reading/writing on the VM disk image file, into the physical address mapped to the virtual address; and

performing, by the network device, data reading/writing on the VM disk image file based on the physical address.


 
2. The method according to claim 1, wherein the establishing, by a network device, a mapping table between a virtual address of a virtual machine VM disk image file and a physical address of a disk image file that is compatible with a virtual machine monitor VMM comprises:

mounting, by the network device, the VM disk image file;

determining, by the network device, a storage grain of the VM disk image file based on metadata in the VM disk image file; and

if the storage grain of the VM disk image file is consistent with a storage grain of the disk image file that is compatible with the VMM, one-to-one mapping, by the network device, data blocks of the VM disk image file to data blocks of the disk image file that is compatible with the VMM; or

if the storage grain of the VM disk image file is inconsistent with a storage grain of the disk image file that is compatible with the VMM, mapping, by the network device, a block index of the VM disk image file to a most significant bit of the physical address of the disk image file that is compatible with the VMM, and mapping an intra-block index of the VM disk image file to a remaining address of the disk image file that is compatible with the VMM.


 
3. The method according to claim 1 or 2, wherein the converting, by the network device according to the mapping table, the virtual address used when a user performs reading/writing on the VM disk image file, into the physical address mapped to the virtual address comprises:

if the network device determines that the user performs a read operation on the VM disk image file, obtaining, by the network device according to the mapping table, and the block index and the intra-block index of the virtual address, the physical address mapped to the virtual address; and

the performing, by the network device, data reading/writing on the VM disk image file based on the physical address comprises:
performing, by the network device, reading on the VM disk image file by using the physical address.


 
4. The method according to any one of claims 1 to 3, wherein the converting, by the network device according to the mapping table, the virtual address used when a user performs reading/writing on the VM disk image file, into the physical address mapped to the virtual address comprises:

if the network device determines that the user performs a write operation on the VM disk image file, obtaining, by the network device according to the mapping table, and the block index and the intra-block index of the virtual address, the physical address mapped to the virtual address; and

the performing, by the network device, data reading/writing on the VM disk image file based on the physical address comprises:
performing, by the network device, writing on the VM disk image file by using the physical address.


 
5. The method according to any one of claims 1 to 4, wherein the method further comprises:

if the network device determines that the user performs a read operation on a data block corresponding to the virtual address of the VM disk image file for a first time, reading, by the network device, at a corresponding physical address according to the mapping table, and creating a corresponding buffer block in a memory, so as to read from the buffer block during a subsequent read operation on the data block; and

if the network device determines that the user performs a write operation on the data block, writing, by the network device, at the corresponding physical address according to the mapping table, and marking the buffer block as a dirty data block, so as to re-read at the corresponding physical address and overwrite the buffer block in the memory when the user performs a read operation on the data block for a next time.


 
6. A network device, comprising:

a mapping module, configured to establish a mapping table between a virtual address of a virtual machine VM disk image file and a physical address of a disk image file that is compatible with a virtual machine monitor VMM, wherein

the mapping module is further configured to convert, according to the mapping table, the virtual address used when a user performs reading/writing on the VM disk image file, into the physical address mapped to the virtual address; and

a read/write module, configured to perform data reading/writing on the VM disk image file based on the physical address.


 
7. The network device according to claim 6, wherein the mapping module is configured to:

mount the VM disk image file;

determine a storage grain of the VM disk image file based on metadata in the VM disk image file; and

if the storage grain of the VM disk image file is consistent with a storage grain of the disk image file that is compatible with the VMM, one-to-one map data blocks of the VM disk image file to data blocks of the disk image file that is compatible with the VMM; or

if the storage grain of the VM disk image file is inconsistent with a storage grain of the disk image file that is compatible with the VMM, map a block index of the VM disk image file to a most significant bit of the physical address of the disk image file that is compatible with the VMM, and map an intra-block index of the VM disk image file to a remaining address of the disk image file that is compatible with the VMM.


 
8. The network device according to claim 6 or 7, wherein the mapping module is configured to:
if the network device determines that the user performs a read operation on the VM disk image file, obtain, according to the mapping table, and the block index and the intra-block index of the virtual address, the physical address mapped to the virtual address; and the read/write module is configured to:
perform reading on the VM disk image file by using the physical address.
 
9. The network device according to any one of claims 6 to 8, wherein the mapping module is configured to:

if the network device determines that the user performs a write operation on the VM disk image file, obtain, according to the mapping table, and the block index and the intra-block index of the virtual address, the physical address mapped to the virtual address; and

the read/write module is configured to perform writing on the VM disk image file by using the physical address.


 
10. The network device according to any one of claims 6 to 9, further comprising a storage module, configured to:

if the network device determines that the user performs a read operation on a data block corresponding to the virtual address of the VM disk image file for a first time, read at a corresponding physical address according to the mapping table, and create a corresponding buffer block in a memory, so as to read from the buffer block during a subsequent read operation on the data block; and

if the network device determines that the user performs a write operation on the data block, write at the corresponding physical address according to the mapping table, and mark the buffer block as a dirty data block, so as to re-read at the corresponding physical address and overwrite the buffer block in the memory when the user performs a read operation on the data block for a next time.


 




Drawing


































Search report










Cited references

REFERENCES CITED IN THE DESCRIPTION



This list of references cited by the applicant is for the reader's convenience only. It does not form part of the European patent document. Even though great care has been taken in compiling the references, errors or omissions cannot be excluded and the EPO disclaims all liability in this regard.

Patent documents cited in the description