A method and system for transferring local file data to a virtual machine block device

By establishing a connection between the user client and the virtualization layer through WebSocket and NBD protocols, the problem of needing to upload files or download clients in existing technologies is solved. This enables browsers to directly mount virtual machine block devices, simplifies operations, and supports cluster management.

CN116506417BActive Publication Date: 2025-12-12CASICLOUD-TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310194296.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-03
Publication Date
2025-12-12
Estimated Expiration
2043-03-03

AI Technical Summary

Technical Problem

Existing technologies require uploading files or downloading client software in advance when mounting virtual machine block devices, making the operation complex and inflexible, and preventing remote mounting directly through a browser.

Method used

Using WebSocket and NBD protocols, a bidirectional connection is established between the user end and the virtualization layer through a block device mounting and management device, enabling the browser to directly mount and unmount block device files. A channel is established between the WebSocket client and the server, and file transfer is performed in conjunction with the NBD protocol.

Benefits of technology

It enables mounting and unmounting of block device files directly through a browser without uploading files or downloading a client, simplifying the operation process and supporting cluster management and horizontal scaling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116506417B_ABST
    Figure CN116506417B_ABST
Patent Text Reader

Abstract

The application discloses a method and system for transmitting local file data to a virtual machine block device, and belongs to the technical field of computer virtual devices. The application uses websocket transmission technology and NBD (Network Block Device) technology, and through designing a management and forwarding device, i.e. a block device mounting management device, mounting requests of clients are uniformly managed, and the block device mounting management device can serve as an intermediary to establish a connection between the clients and a virtualization hypervisor layer, so that mutual communication is achieved. Then, the NBD protocol is used to mount the block device as a network device. The application can directly mount read-only block device files (such as optical drive files, block disk files and the like) to a virtual machine through a web browser, and realizes corresponding systems. Therefore, the purpose of directly remotely mounting and unmounting and transmitting data on demand without uploading block device files and without additionally downloading a client auxiliary can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the technical field of computer virtual equipment, and particularly relates to a method and system for transmitting local file data to a virtual machine block device. BACKGROUND

[0002] A virtual machine is a virtual computer created on a virtualization platform and capable of serving as an independent computing device. The virtual machine contains various virtual hardware, including a CPU, memory, a disk, and other devices. During use of the virtual machine, there can be a need to mount a read-only block device to the virtual machine. For example, the virtual machine can need to install an operating system or run certain software, which can require mounting a CD-ROM.

[0003] For the above-mentioned needs, the conventional solutions mainly include the following two kinds:

[0004] The first solution is that a user uploads a block device file that needs to be mounted to a virtualization layer, and the virtualization system is responsible for mounting the file directly to the virtual machine. This method has the characteristics of stable mounting and is conducive to management, but has obvious shortcomings: the block device file needs to be transmitted to the virtualization system in advance, and the occupied space also needs to be manually cleaned up.

[0005] The second solution is that a user needs to download a client software, and uses the client software to start an NBD service, and then the virtualization system remotely connects and mounts. This method has the characteristics of not needing to upload the block device file to the server, but starting a connection on the client side, and has the shortcomings of needing to download the client in advance, the client needs to be compatible with the operating system of the user, and a fixed port needs to be opened on the client side for being accessed by the server.

[0006] The method and system proposed in this paper aim to solve the shortcomings of the above-mentioned methods, so that the user can directly mount a local block device file to a virtualization layer through a web browser without needing to upload the file in advance or download the client software in advance, and then mount the block device file to a virtual machine through virtualization technology. SUMMARY

[0007] The purpose of the present application is to provide a method and system for transmitting local file data to a virtual machine block device, which can directly mount a read-only block device file (such as a CD-ROM file or a block disk file) to a virtual machine through a web browser, and implement the corresponding system. Thus, the purpose of directly remotely mounting and unmounting and transmitting data on demand without needing to upload the block device file or download the client additionally can be achieved.

[0008] In order to solve the technical problems in the prior art and achieve the above-mentioned purpose, the technical solutions are provided as follows:

[0009] A system for transmitting local file data to a virtual machine block device, comprising a user terminal, a block device mounting management device, and a virtualization layer;

[0010] The block device mounting management device comprises a device mounting management front end, a websocket server, and an nbd server; is located between the user terminal and the virtualization layer, and uniformly manages mounting requests of the user terminal; the block device mounting management device serves as an intermediate medium, establishes a connection between the user terminal and the virtualization layer, and realizes communication between the user terminal and the virtualization layer.

[0011] The user terminal is composed of a plurality of user browsers, each of which has a block device file and a block device mounting management front end; a user can select a block device file and request mounting through a web browser; the block device file to be mounted is a read-only block device file.

[0012] The block device mounting management front end is a websocket client loaded by the browser, which is used to establish a communication channel with the websocket server in the block device mounting management device, and build a two-way connection between the block device mounting management device and the user terminal through the websocket protocol.

[0013] The device mounting management device is used to notify the hypervisor layer that a block device file needs to be mounted on a virtual machine; at the same time, the virtualization management system of the virtualization layer establishes a connection between the block device mounting management device and the virtualization layer through the nbd protocol, and realizes a two-way connection between the nbd server and the nbd client.

[0014] The virtualization layer comprises a plurality of virtual devices and a virtualization management system, and the virtualization layer block device can be directly mounted on a virtual machine.

[0015] When a virtual machine needs to read a block device file, a read request is first sent to the nbd server through the nbd protocol, and then the read request is sent to the websocket client through the websocket protocol by the block device mounting management device, the browser reads the block device file on demand, and the block device file content is returned to the virtual machine through the two-way connection, realizing remote mounting and reading data.

[0016] Further, the mounted block device file is a read-only block device file of an optical drive file or a disk file.

[0017] Further, when the virtualization layer is actually set as a cluster, the block device mounting management device uses a network mounting method, supports simultaneous management of mounting of all virtual machines in the cluster, and can be used on any physical machine.

[0018] The application provides a method for transmitting local file data to a virtual machine block device, which is implemented by using a system for transmitting local file data to a virtual machine block device and comprises the following steps.

[0019] Step 1, handshake phase

[0020] A user selects a block device file to be mounted and a virtual machine to be mounted, and sends a request to a block device mounting management device, so that the block device mounting management device leads the establishment and handshake of various connections.

[0021] Step 2, transmission phase

[0022] In this phase, various connections have been established, and when the user end actually mounts the block device file into the virtual machine and uses it, a request for reading the content of the block device file will be generated, which will be transmitted to the websocket client through two bidirectional connections and read by the browser, and the request in the transmission phase will be repeated several times according to the user's use.

[0023] Step 3, end phase

[0024] In this phase, the user end requests to disconnect, at this time, the websocket and NBD connections are disconnected and the virtualization layer block device is unloaded from the corresponding virtual machine under the guidance of the block device mounting management device.

[0025] The effective benefits of the application are as follows:

[0026] The application realizes the mounting of a block device file into a virtual machine through a web browser directly, and when a user uses the system to manage the virtual machine, the user can directly select a local file in the browser, and then the file can be mounted and used in the virtual machine by using a virtual optical drive and the like, so that the user operation is greatly simplified. DETAILED DESCRIPTION

[0027] Figure 1 The application is a system architecture diagram for transmitting local file data to a virtual machine block device.

[0028] Figure 2 The application is a handshake phase timing diagram of the method.

[0029] Figure 3 The application is a transmission phase timing diagram of the method.

[0030] Figure 4 The application is an end phase timing diagram of the method. DETAILED DESCRIPTION

[0031] The application will be explained and described in detail below with reference to the drawings.

[0032] The system design idea of transmitting local file data to a virtual machine block device is briefly described as follows: the websocket transmission technology and the NBD (Network Block Device) technology are used, a management and forwarding device, i.e., a block device mounting management device, is designed, mounting requests of the client are uniformly managed, and the client and the virtualization hypervisor layer can be connected as an intermediary to communicate with each other, and the block device is mounted as a network device by using the NBD protocol.

[0033] The system architecture of the application is shown in Figure 1

[0034] The system for transmitting local file data to a virtual machine block device comprises a user terminal, a block device mounting management device and a virtualization layer, the block device mounting management device is located between the user terminal and the virtualization layer, mounting requests of the user terminal are uniformly managed, the block device mounting management device is used as an intermediate medium to establish a connection between the user terminal and the virtualization layer, and communication between the user terminal and the virtualization layer is realized.

[0035] The user terminal is composed of a plurality of user browsers, each user browser has a block device file and a block device mounting management front end, and the user can select a block device file through a web browser and request mounting.

[0036] The block device mounting management front end is a websocket client, the websocket client is used to establish a communication channel with a websocket server in the block device mounting management device, and a two-way connection between the block device mounting management device and the user terminal is established.

[0037] The block device mounting management device comprises a websocket server and an nbd server, the device mounting management device is used to inform the hypervisor layer that a block device file needs to be mounted on a virtual machine, and the virtualization management system of the virtualization layer establishes a connection between the block device mounting management device and the virtualization layer through the nbd protocol to realize two-way connection of the nbd server and the nbd client.

[0038] The virtualization layer comprises a plurality of virtual devices and a virtualization management system, and the virtualization layer block device can be directly mounted on a virtual machine.

[0039] As shown in Figure 1 ​As shown, when mounting a block device file (such as an optical drive file or a disk file), the user only needs to select the block device file through the browser and request mounting, and the system first establishes a websocket connection channel to establish a two-way connection between the block device mounting management device and the browser end (user end), then notifies the hypervisor to establish a two-way connection between the virtualization layer block device and the block device mounting management device through the NBD protocol. Moreover, the virtualization layer block device can be directly mounted on the virtual machine 1.

[0040] After the two-way connection is established, when a virtual machine needs to read a block device file, the reading request is first sent to the nbd server through the nbd protocol, and then the reading request is sent to the websocket client through the block device mounting management device through the websocket protocol, and the browser reads the block device file on demand. Because the connection is two-way, the file content can be returned to the virtual machine 1 in the original path, so as to achieve the purpose of remote mounting and reading data.

[0041] The block device mounting management device of the present application can be combined with the virtualization management system as a system, but in actual use, it is recommended to be separated, because remote mounting of files involves a large amount of file transmission, and separate deployment can not only reduce the performance pressure of the service on the hypervisor, but also be beneficial to subsequent horizontal expansion when the service pressure is large.

[0042] The present application supports remote mounting of multiple files on multiple virtual machines at the same time, Figure 1 As an example, only one is shown.

[0043] The virtualization layer of the present application can actually be a cluster, and the block device mounting management device supports simultaneous management of the mounting of all virtual machines in the cluster due to the use of network mounting, regardless of which physical machine.

[0044] Meanwhile, the present application provides a method for transmitting local file data to a virtual machine block device, which is implemented by using the above-mentioned method for transmitting local file data to a virtual machine block device. The entire implementation process from connection establishment to disconnection includes the following steps:

[0045] Step 1, handshake phase

[0046] The main action of this phase is that the user selects the block device file to be mounted and the virtual machine to be mounted, and sends a request to the block device mounting management device, which dominates the establishment and handshake of various connections. The timing diagram is as shown in Figure 2 .

[0047] Step 2, transmission phase

[0048] At this stage, various connections have been established, when the user end actually mounts the block device file into the virtual machine and uses it, a request for reading the content of the block device file will be generated, which will be transmitted through the two bidirectional connections to the websocket client, and the browser will perform the file reading operation, the request of the transmission stage will be repeated several times according to the user's use. The timing diagram is as shown in Figure 3 .

[0049] Step 3, end stage

[0050] At this stage, the user end requests to disconnect, at this time, the websocket and NBD connection are disconnected, and the virtualization layer block device is unloaded from the corresponding virtual machine by the block device mounting management device. The timing diagram is as shown in Figure 4 .

[0051] The key points of the application are as follows:

[0052] Key point 1: The scheme described in the application can mount read-only block device files, and write operations cannot be supported temporarily, because web browsers generally do not have the permission to directly write files.

[0053] Key point 2: As long as the read-only block device file is mounted, it belongs to the application range of the application, including but not limited to optical drive files, block disk files, etc.

[0054] Key point 3: The difference between the application and the traditional scheme is that the application directly uses the web browser to read and mount files, without the need for the user to download the client or upload the file to be mounted. In order to achieve this effect, the implementation method of using websocket and NBD protocol is selected.

[0055] Key point 4: The application utilizes websocket to realize the communication between the browser and the block device mounting management device, and utilizes the open source NBD protocol to realize the network mapping of the block device. These two parts are public known technologies.

[0056] Key point 5: The system described in the application can reconnect after any connection is unexpectedly disconnected, thereby ensuring the availability of the system service. And it also supports horizontal expansion (deploying multiple instances for load balancing).

[0057] The above is a further detailed description of the application in combination with specific embodiments, and the specific implementation of the application cannot be limited to these descriptions. For ordinary skilled persons in the technical field to which the application belongs, without departing from the concept of the application, a number of simple deductions or substitutions can be made, which should be regarded as belonging to the protection scope of the application.

Claims

1. A system for transferring local file data to a virtual machine block device, characterized in that, The user terminal, the block device mounting management device, and the virtualization layer are included. The block device mounting management device includes a block device mounting management front end, a websocket server, and an nbd server. The block device mounting management device is located between the user terminal and the virtualization layer and uniformly manages mounting requests from the user terminal. The user terminal is composed of a plurality of user browsers, each of which has a block device file and a block device mounting management front end. The user can select a block device file and request mounting through a web browser. The requested mounting is a read-only block device file. The block device mounting management front end is a websocket client loaded by the browser. The websocket client is used to establish a communication channel with the websocket server in the block device mounting management device and build a two-way connection between the block device mounting management device and the user terminal through the websocket protocol. The block device mounting management device is used to notify the virtualization layer that a block device file needs to be mounted on a virtual machine.

2. The system for transferring local file data to a virtual machine block device of claim 1, wherein, Meanwhile, the virtualization management system of the virtualization layer establishes a connection between the block device mounting management device and the virtualization layer through the nbd protocol to realize a two-way connection between the nbd server and the nbd client.

3. The system for transferring local file data to a virtual machine block device of claim 1, wherein, The virtualization layer includes a plurality of virtual devices and a virtualization management system.

4. A method of transferring local file data to a virtual machine block device, the method comprising: When a virtual machine needs to read a block device file, it first sends a read request to the nbd server through the nbd protocol, and then sends the read request to the websocket client through the websocket protocol through the block device mounting management device. The browser reads the block device file on demand, and the content of the block device file is returned to the virtual machine through the two-way connection to realize remote mounting and reading of data. The mounted block device file is a read-only block device file of an optical drive file or a disk file. When the virtualization layer is a cluster, the block device mounting management device uses network mounting to support the mounting of all virtual machines in the cluster. The system for transmitting local file data to a virtual machine block device is implemented by the steps of: Step 1: Handshake phase The user selects the block device file to be mounted and the virtual machine to be mounted and sends a request to the block device mounting management device. Step 2: Transmission phase At this stage, all connections have been established. When the user mounts the block device file to the virtual machine and uses it, a request to read the block device file content will be generated. The request will be transmitted to the websocket client through the two-way connection, and the browser will read the block device file. The request in the transmission phase will be repeated several times according to the user's usage. Step 3: End phase At this stage, the user requests to disconnect, at which time the block device mounting management device takes the lead, disconnects the websocket and NBD connection, and unloads the virtualization layer block device from the corresponding virtual machine.

Citation Information

Patent Citations

  • A method and apparatus for mount management of a storage device

    CN109086079A

  • Storage block equipment management method and device, equipment and storage medium

    CN115185467A