CN109240796A - Virtual machine information acquisition methods and device - Google Patents
Virtual machine information acquisition methods and device Download PDFInfo
- Publication number
- CN109240796A CN109240796A CN201810914373.8A CN201810914373A CN109240796A CN 109240796 A CN109240796 A CN 109240796A CN 201810914373 A CN201810914373 A CN 201810914373A CN 109240796 A CN109240796 A CN 109240796A
- Authority
- CN
- China
- Prior art keywords
- address
- message
- mac address
- memory
- virtual machine
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45595—Network integration; Enabling network access in virtual machine instances
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Small-Scale Networks (AREA)
Abstract
The disclosure provides a kind of virtual machine information acquisition methods and device, is related to field of communication technology.Method is applied to virtual switch, and the virtual switch and virtual machine connection are to realize the data interaction between virtual machine, which comprises the message of setting type is obtained from the message that the virtual switch receives;For the message of the setting type of acquisition, parsing obtains the Protocol IP address and MAC address interconnected between the network of the corresponding virtual machine of the message;Where IP address and MAC Address associated storage to the virtual switch that parsing is obtained in the file system of hardware device.To easily obtain the relevant information of virtual machine.
Description
Technical field
This disclosure relates to field of communication technology, in particular to a kind of virtual machine information acquisition methods and device.
Background technique
Virtualization is a kind of resource management techniques, is in after can the various actual resources of computer being abstracted, be converted
Reveal and, breaks the obstacle between entity structure.Virtual switch is the friendship formed by way of software using virtual platform
It changes planes.In virtualization technology, virtual switch chance connects multiple virtual machines, and completes the data interaction between virtual machine.For
Virtual network is managed, needs to obtain the agreement (Internet Protocol, IP) interconnected between the network of virtual machine
The relevant informations such as address, thus, the relevant information for easily obtaining virtual machine is needed for application.
Summary of the invention
In view of this, the disclosure provides a kind of virtual machine information acquisition methods and device.
In a first aspect, it is applied to virtual switch present disclose provides a kind of virtual machine information acquisition methods, it is described virtual
Interchanger and virtual machine connection are to realize the data interaction between virtual machine, which comprises
The message of setting type is obtained from the message that the virtual switch receives;
For the message of the setting type of acquisition, parsing obtains interconnecting between the network of the corresponding virtual machine of the message
Protocol IP address and MAC address;
The file of hardware device where IP address and MAC Address associated storage to the virtual switch that parsing is obtained
In system.
Optionally, the method also includes:
In the initialization procedure after virtual switch starting, the IP address in the file system will be stored in
Where being loaded onto the virtual switch with MAC Address in the memory of hardware device;
When the virtual switch receives message, judge whether the message meets preset condition, if the message
Meet the preset condition, then parsed from the message and obtain the IP address and MAC Address of corresponding virtual machine, described in judgement
Whether the IP address and MAC Address storage is associated in memory;
If the IP address and MAC Address are not associated storage in the memory, by the IP address and MAC
Location associated storage is into the memory.
Optionally, the step of whether message meets preset condition judged, comprising:
Judge whether the message is message that virtual switch described in first passage is forwarded, if headed by the message
The secondary message being forwarded by the virtual switch then judges whether the message is the message for setting type;
It when the message that the message is forwarded for virtual switch described in first passage, and is the setting type
When message, the message is determined for the message that meets preset condition.
Optionally, the IP address being stored in the file system and MAC Address are loaded onto the virtual switch institute
Step in the memory of hardware device, comprising: using the MAC Address being stored in the file system as key, with the MAC Address
Corresponding IP address is value, by the file system IP address and MAC Address be stored in it is hard where the virtual switch
In the Hash table of the memory of part equipment;
It is described to judge the step of whether IP address and MAC Address being associated storage in the memory, comprising:
Whether the Hash table inquired in the memory is stored with the MAC Address;
If being stored with the MAC Address, judge to store in the Hash table with the associated IP address of the MAC Address whether
It is consistent with the IP address in the message, if inconsistent, by stored in the Hash table with the associated IP of the MAC Address
Location is updated to the IP address in the message;
If not stored in the Hash table have the MAC Address, using the MAC Address as key, with the corresponding IP of the MAC Address
Address is value, by the message IP address and MAC Address be stored in the virtual switch where hardware device memory
Hash table in.
Optionally, the method also includes:
Information addition request is received, with adding the IP address added needed for parsing obtains in request and MAC from the information
Location;
Judge whether the IP address and MAC Address have been associated storage in the memory;
If the IP address and MAC Address are not associated storage in the memory, by the IP address and MAC
Location associated storage is into the memory.
Optionally, the method also includes:
Judge whether each IP address stored in memory and MAC Address reach aging condition, if it exists IP address and
MAC Address reaches the aging condition, then deletes the IP address and MAC Address.
Second aspect, the disclosure also provide a kind of virtual machine information acquisition device, are applied to virtual switch, described virtual
To realize the data interaction between virtual machine, the virtual machine information acquisition device includes: for interchanger and virtual machine connection
Message obtains module, for obtaining the message of setting type from the message that the virtual switch receives;
Packet parsing module, for the message for the setting type obtained, parsing obtains the corresponding void of the message
The Protocol IP address and MAC address interconnected between the network of quasi- machine;
Information storage module, for obtained IP address and MAC Address associated storage will to be parsed to the virtual switch
In the file system of place hardware device.
Optionally, the virtual machine information acquisition device further include:
Signal load unit, for will be stored in described in the initialization procedure after virtual switch starting
Where IP address and MAC Address in file system are loaded onto the virtual switch in the memory of hardware device;
Message processing module (MPM), for it is pre- to judge whether the message meets when the virtual switch receives message
If condition, if the message meets the preset condition, parsing obtains the IP address of corresponding virtual machine from the message
And MAC Address, judge whether the IP address and MAC Address have been associated storage in the memory, if in the memory not
The IP address and MAC Address are associated storage, then by the IP address and MAC Address associated storage to the memory
In.
Optionally, the message processing module (MPM) is used for, using the MAC Address being stored in the file system as key, with this
The corresponding IP address of MAC Address be value, by the file system IP address and MAC Address be stored in the virtual switch
In the Hash table of the memory of place hardware device;
Whether the message processing module (MPM) has been used to judge by following steps in the memory by the IP address and MAC
Location is associated storage:
Whether the Hash table inquired in the memory is stored with the MAC Address;
If being stored with the MAC Address, judge to store in the Hash table with the associated IP address of the MAC Address whether
It is consistent with the IP address in the message, if inconsistent, by stored in the Hash table with the associated IP of the MAC Address
Location is updated to the IP address in the message;
If not stored in the Hash table have the MAC Address, using the MAC Address as key, with the corresponding IP of the MAC Address
Address is value, by the message IP address and MAC Address be stored in the virtual switch where hardware device memory
Hash table in.
Optionally, the virtual machine information acquisition device further include:
Message processing module adds needed for obtaining from parsing in information addition request for receiving information addition request
The IP address and MAC Address added;
Information storage module, for judging whether the IP address and MAC Address have been associated storage in the memory,
If the IP address and MAC Address are not associated storage in the memory, the IP address is associated with MAC Address and is deposited
Storage is into the memory.
The third aspect, the disclosure also provide a kind of server, comprising: memory, processor and storage are on a memory simultaneously
The computer program that can be run on a processor, the processor make the virtual friendship in the server when executing described program
It changes planes and realizes above-mentioned virtual machine information acquisition methods.
Fourth aspect, the disclosure provide a kind of computer readable storage medium, and the computer readable storage medium includes
Computer program, the computer program controlled when running the computer readable storage medium virtual friendship in the server
It changes planes and executes above-mentioned virtual machine information acquisition methods.
The virtual machine information acquisition methods and device that the disclosure provides, have carried out ingehious design to virtual switch, directly
The message received is handled by virtual switch, the IP address and MAC Address of virtual machine can be obtained, will acquire
Where the IP address and MAC Address of virtual machine are stored in virtual switch in the file system of hardware device, so that virtual machine
IP address and MAC Address can easily be obtained from file system.
To enable the above objects, features, and advantages of the disclosure to be clearer and more comprehensible, preferred embodiment is cited below particularly, and cooperate
Appended attached drawing, is described in detail below.
Detailed description of the invention
In order to illustrate more clearly of the technical solution of the disclosure, letter will be made to attached drawing needed in the embodiment below
It singly introduces, it should be understood that the following drawings illustrates only some embodiments of the disclosure, therefore is not construed as to range
It limits, it for those of ordinary skill in the art, without creative efforts, can also be according to these attached drawings
Obtain other relevant attached drawings.
Fig. 1 is a kind of block diagram for server that the disclosure provides.
Fig. 2 is a kind of flow diagram for virtual machine information acquisition methods that the disclosure provides.
Fig. 3 is a kind of another flow diagram for virtual machine information acquisition methods that the disclosure provides.
A kind of flow diagram of step S24 in Fig. 3 that Fig. 4 provides for the disclosure.
Fig. 5 is a kind of another flow diagram for virtual machine information acquisition methods that the disclosure provides.
Fig. 6 is a kind of block diagram for virtual machine information acquisition device that the disclosure provides.
Icon: 10- server;11- memory;12- processor;13- network module;20- virtual machine information acquisition device;
21- message obtains module;22- packet parsing module;23- information storage module;24- signal load unit;25- Message processing mould
Block;26- message processing module.
Specific embodiment
In order to be managed to virtual network, network speed limit management, application access control list (Access are such as carried out
Control List, ACL) strategy and firewall policy management etc., the IP for the virtual machine that empty machine interchanger needs acquisition connected
The information such as address.It has been investigated that Libvirt mainly pass through packet capture function library (Packet Capture Libray,
Libpcap data packet) is grabbed, the data packet of crawl is filtered, required type of message is obtained, and then is obtained and virtual machine
Media access control (Media Access Control or Medium Access Control, MAC) corresponding void in address
The address agreement (Internet Protocol Address, IP) interconnected between the network of quasi- machine.
Wherein, Libvirt is API (the Application Programming for managing the open source of virtual platform
Interface, application programming interface), background program and management tool.It can be used for managing KVM, Xen, VMware
ESX, QEMU and other virtualization technologies.Data packet, which is grabbed, by packet capture function library needs the mistake from the data packet of crawl
The type of message filtered out mainly includes following several: ARP Request, ARP Reply messages, DHCP Offer and
IPv4packet.Can by judge DETECT (it was found that) mode distinguishes the type of data packet.For example, if data packet is
DETECT DHCP (Dynamic Host Configuration Protocol, dynamic host configuration protocol), then pass through DHCP
Offer message obtains the IP address of virtual machine.If it is DETECT STATIC, pass through ARP (Address
Resolution Protocol, address resolution protocol) message and IP packet obtain the IP address of virtual machine.
Although the IP address based on the available virtual machine of Libvirt.However, obtaining the IP of virtual machine based on Libvirt
Address needs to rely on the installation of Libpcap, supports the IP address type for obtaining virtual machine relatively limited, mainly supports IPV4
The IP address of type obtains.The IP address procurement function of Libvirt is located at the Nwfilter module of Libvirt, Nwfilter's
Function includes ACL strategy, as drop (discarding) or pass (passing through) is sent to or message from some IP address section.?
The IP address of the virtual machine of Libvirt layers of acquisition can be supplied to Nwfilter, after the IP address of virtual machine is supplied to Nwfilter,
Nwfilter does not consider the IP address of virtual machine being supplied to other modules, does not provide and store the IP address of virtual machine
Other modules are facilitated to obtain the information in functions such as file system.Thus other modules, as virtual switch can not be easily
Get the IP address.
Wherein, Nwfilter is a module of Libvirt management, be responsible for issuing ACL, status firewall tactical management,
Speed limit etc., to manage the network between virtual machine.
Based on the studies above, present disclose provides a kind of virtual machine information acquisition methods and devices, independent of Libpcap
Installation, will acquire the function of the IP address of virtual machine as a kind of Services Integration independently of Nwfilter in the virtual of open source
Interchanger (Open Virtual Switch, OVS), and the IP address for the virtual machine that will acquire is stored in virtual switch institute
In the file system of hardware device, applied consequently facilitating each functional module can easily obtain the information.Due to void
Quasi- interchanger is mainly responsible for the data exchange completed between each virtual machine, itself is meeting sending and receiving data packet, thus virtually hands over
It changes planes and needs not rely upon Libpcap.
For defect present in above scheme, be inventor being obtained after practicing and carefully studying as a result,
Therefore, the discovery procedure of the above problem and the solution that hereinafter disclosure is proposed regarding to the issue above all should be
The contribution that inventor makes the disclosure during disclosure.
Below in conjunction with attached drawing in the disclosure, the technical solution in the disclosure is clearly and completely described, it is clear that
Described embodiment is only disclosure a part of the embodiment, instead of all the embodiments.Usually retouched in attached drawing here
The component for the disclosure stated and shown can be arranged and be designed with a variety of different configurations.Therefore, below to mentioning in the accompanying drawings
The detailed description of the embodiment of the disclosure of confession is not intended to limit claimed the scope of the present disclosure, but is merely representative of this
Disclosed selected embodiment.Based on embodiment of the disclosure, those skilled in the art are in the premise for not making creative work
Under every other embodiment obtained, belong to the disclosure protection range.
It should also be noted that similar label and letter indicate similar terms in following attached drawing, therefore, once a certain Xiang Yi
It is defined in a attached drawing, does not then need that it is further defined and explained in subsequent attached drawing.
Virtual information in the disclosure, which obtains scheme, can be applied to server 10 shown in FIG. 1.Service in the disclosure
Device 10 can have the hardware device of communication function for router, interchanger etc., can pass through virtualization technology in server 10
Virtual switch and virtual machine are fictionalized, virtual switch and virtual machine connection are to realize the data interaction between virtual machine.Example
Such as, can have on virtual switch multiple virtual network interfaces (Edit mouthfuls of Virtual Network, vnet mouthfuls), it is vnet mouthfuls each
An IP address is bound respectively, and virtual switch is by vnet mouthfuls of IP address come transmitting data flow amount.
As shown in Figure 1, server 10 may include: that memory 11, processor 12, network module 13 and virtual machine information obtain
Take device 20.
The memory 11, processor 12 and network module 13 are directly or indirectly electrically connected between each other, with reality
The transmission or interaction of existing data.For example, these elements can be realized between each other by one or more communication bus or signal wire
It is electrically connected.Virtual machine information acquisition device 20 is stored in memory 11, the virtual machine information acquisition device 20 includes extremely
A few software function module that can be stored in the form of software or firmware (firmware) in the memory 11, the place
The software program and module that reason device 12 is stored in memory 11 by operation, as the virtual machine information in the disclosure obtains dress
20 are set, so that the virtual switch in server 10 performs various functions application and data processing, that is, realizes the disclosure
In virtual machine information acquisition methods.
Wherein, the memory 11 may be, but not limited to, random access memory (RandomAccess Memory,
RAM), read-only memory (Read Only Memory, ROM), programmable read only memory (Programmable Read-Only
Memory, PROM), erasable read-only memory (Erasable Programmable Read-Only Memory, EPROM),
Electricallyerasable ROM (EEROM) (Electric Erasable Programmable Read-Only Memory, EEPROM) etc..
Wherein, memory 11 is for storing program, and the processor 12 executes described program after receiving and executing instruction.
The processor 12 may be a kind of IC chip, the processing capacity with data.Above-mentioned processor 12
It can be general processor, including central processing unit (Central Processing Unit, CPU), network processing unit
(Network Processor, NP) etc..It may be implemented or execute each method, step disclosed in the disclosure and logic diagram.
General processor can be microprocessor or the processor is also possible to any conventional processor etc..
Network module 13 is used to establish the communication connection between server 10 and other communication equipments by network, realizes net
The transmitting-receiving of network signal and data operates.Above-mentioned network signal may include wireless signal or wire signal.
It is appreciated that structure shown in FIG. 1 is only to illustrate, server 10 may also include than shown in Fig. 1 more or more
Few component, or with the configuration different from shown in Fig. 1.Each component shown in Fig. 1 can use hardware, software or its group
It closes and realizes.
On the basis of the above, the disclosure also provides a kind of computer readable storage medium, the computer-readable storage medium
Matter includes computer program, the computer program controls the computer readable storage medium when running where in server 10
Virtual switch execute following virtual machine information acquisition methods.
Fig. 2 is please referred to, the disclosure provides a kind of virtual machine information acquisition methods, is applied to server 10 shown in Fig. 1
In the virtual switch that fictionalizes, virtual switch and virtual machine connection are to realize the data interaction between virtual machine.
Method may comprise steps of.
Step S11 obtains the message of setting type from the message that the virtual switch receives.
In the disclosure, the IP address procurement function of Integrated Virtual machine in virtual switch, for example, can be in virtual switch
Increase the IP address study module of virtual machine in machine newly.Pass through the integrated of the IP address procurement function to virtual machine, virtual switch
By vnet mouthfuls of reception messages, the message of setting type is obtained from the message received, and then executes the IP of subsequent virtual machine
Address acquiring operation.
Wherein, the message for setting type includes the IPV4 (Internet Protocol Version 4) for carrying virtual machine, IPV6 (internet association
Discuss version 6) and MAC Address message.For example, the message of setting type may include ARP Request and internet information association
It discusses sixth version (Internet Control ManagemetProtocol Version 6, ICMPV6).
In the disclosure, virtual switch can judge whether the message is setting type for each message received
Message, such as whether for ARP Request type message or ICMPV6 type message, thus from the message received
Obtain the message of setting type.
Step S12, for the message of the setting type of acquisition, parsing obtains the network of the corresponding virtual machine of the message
Between the Protocol IP address and MAC address that interconnect.
The message of setting type is parsed, the IP address of virtual machine can be obtained, such as IPV4 and IPV6 and MAC
Address.
Step S13 sets IP address and MAC Address associated storage to virtual switch place hardware that parsing obtains
In standby file system.
Optionally, hardware device where virtual switch, as server 10 supports Linux, correspondingly, IP address and MAC
Where address information is stored in virtual switch in the Linux file system of hardware device.For example, Linux file can be based on
System safeguards the MAC Address of a storage virtual machine, the file of IPV4 and IPV6 information pair.
In the disclosure, virtual switch is parsed after obtaining IP address and MAC Address, can be directly by IP address and MAC
Address information is stored into the file system of hardware device where virtual switch.First IP address and MAC Address can also be closed
Connection is stored into the memory of hardware device where virtual switch, then again periodically will be in memory by certain time interval
The file system of hardware device where IP address and MAC Address are synchronized to virtual switch.It should be appreciated that can also in real time by
The file system of hardware device where IP address and MAC Address in memory are synchronized to virtual switch.
Wherein, IP address and MAC Address can be using various ways associated storages in memory, and the disclosure does not limit this
System.In view of the convenience of acquisition of information, it is alternatively possible to which MAC Address and IP address that parsing is obtained are with the side of key-value pair
Where formula is stored in virtual switch in the Hash table of the memory of hardware device, so the Hash table of the memory storage is synchronous
To the file system of hardware device where the virtual switch.
Based on this kind of virtual machine information acquisition methods, will acquire the function of the IP address of virtual machine as it is a kind of independently of
The Services Integration of Nwfilter independent of the installation of Libpcap, but passes through virtual switch in the virtual switch of open source
The IP address that virtual machine is obtained in vnet mouthfuls of received messages, the IP address for simplifying virtual machine obtain process.
By the IP address of virtual machine and MAC Address associated storage in file system, so that needing application virtual machine
It when IP address, directly can be obtained from file system, it is more convenient to realize.
Fig. 3 is please referred to, in the scene for the IP address for needing to obtain virtual machine, for example, starting in virtual switch
In initialization procedure later, the information such as IP address being stored in memory originally can be removed, in order to realize to newly-increased IP
The reliable recognition and acquisition of location, can execute following steps.
The IP address being stored in the file system and MAC Address are loaded onto the virtual switch institute by step S21
In the memory of hardware device.
IP address and MAC Address can be loaded onto memory in several ways, as long as can be associated in memory
Storage.In view of the convenience of acquisition of information, it is alternatively possible to by file system MAC Address and IP address with key
Where the mode of value pair is stored in virtual switch in the Hash table of the memory of hardware device.For example, to be stored in the file
MAC Address in system is key, is value with the corresponding IP address of the MAC Address, by the IP address and MAC in the file system
Where address is stored in the virtual switch in the Hash table of the memory of hardware device.
Wherein, the corresponding IP address of MAC Address may include IPV4 or IPV6, correspondingly, in storage, to be stored in
Stating the MAC Address in file system is key, is value with the corresponding address IPV4 or IPV6 of the MAC Address, by the file system
In IP address and MAC Address be stored in the virtual switch where hardware device memory Hash table in.
Step S22 judges whether the message meets preset condition when the virtual switch receives message, if
The message meets the preset condition, thens follow the steps S23 to step S25.
Wherein, preset condition can flexibly be set, for example, in order to which IPV4, IPV6 for carrying virtual machine is recognized accurately
With the message of MAC Address, preset condition can be that message is the message for setting type.Wherein, the message for setting type can wrap
Include ARP Request and ICMPV6.In another example in view of the identical message that virtual switch has been transmitted through, entrained MAC
The MAC Address and IP address obtained in location and IP address and last transmission process is identical, in order to avoid virtual switch is to this
Class message is repeated the operation several times, to occupy process resource, preset condition may include that message is that first passage is virtually handed over
It changes planes the message being forwarded.
Wherein, virtual switch can be judged by the following manner whether message is that first passage virtual switch is turned
Hair: when the vnet of the virtual switch received message of mouth, message is forwarded to the kernel module in Datapath module, by interior
Core module is forwarded data, such as is forwarded by forwarding table.Thus, when receiving message, kernel module should
The information of message is matched with forwarding table, if being not matched to, determines that message is turned for first passage virtual switch
Hair, thus by message up sending to User space, and then judge whether message is the message for setting type, in the message to set type
When, it obtains the information such as the IP address in message and executes subsequent operation.
Optionally, virtual switch can be judged by the following manner whether the message meets preset condition: judge institute
State whether message is message that virtual switch described in first passage is forwarded, if the message is virtual described in first passage
The message that interchanger is forwarded then judges whether the message is the message for setting type.When the message is for the first time
The message being forwarded by the virtual switch, and for it is described setting type message when, determine that the message is full
The message of sufficient preset condition, and then execute subsequent step S23.Correspondingly, if virtual switch described in the non-first passage of message into
The message of the message of row forwarding or non-setting type, then be directly forwarded operation.
By the setting of preset condition, so that virtual switch only can from IPV4, IPV6 and the MAC for carrying virtual machine
Location, and parsing obtains IP address and MAC Address in the message being forwarded for first passage virtual switch, and then significantly mentions
The high accuracy of acquisition of information, avoids the waste of process resource.
Step S23, parsing obtains the IP address and MAC Address of corresponding virtual machine from the message.
Step S24 judges whether the IP address and MAC Address have been associated storage in the memory.If in described
The IP address and MAC Address are not associated storage in depositing, then follow the steps S25.If in memory by the IP address and
MAC Address is associated storage, then no longer needs to execute storage operation.
Step S25, by the IP address and MAC Address associated storage into the memory.
Fig. 4 is please referred to, the MAC Address and IP address in file system are stored in memory in a manner of key-value pair
In the case where in Hash table, it can be judged by the following manner in the memory and whether carry out the IP address and MAC Address
Associated storage.
Whether step S241, the Hash table inquired in the memory are stored with the MAC Address.If being stored with the MAC Address,
Then follow the steps S242 and step S243.If not stored in the Hash table have the MAC Address, S244 is thened follow the steps.
Step S242, judge to store in the Hash table with the associated IP address of the MAC Address whether with the message
In IP address it is consistent, if inconsistent, illustrate to change with the associated IP address of MAC Address, need the content to storage
It is updated, thereby executing step S243.If consistent, illustrate not change with the associated IP address of MAC Address, be not necessarily to pair
The content of storage is updated.
Step S243 is updated to what is stored in the Hash table in the message with the associated IP address of the MAC Address
IP address.And then the information of update periodically or is in real time synchronized to file system.
Step S244 is value with the corresponding IP address of the MAC Address, by the IP in the message using the MAC Address as key
Where address and MAC Address are stored in the virtual switch in the Hash table of the memory of hardware device.And then the letter that will be increased newly
Breath timing is synchronized to file system in real time.
By step S21 to step S25, in the initialization procedure after virtual switch starting, the text will be stored in
Where IP address and MAC Address in part system are loaded onto the virtual switch in the memory of hardware device, by judge from
In whether IP address receiving, meeting the virtual machine parsed in the message of preset condition and MAC Address have been stored in
In depositing, to find out updated and newly-increased IP address and MAC Address pair.By updated and newly-increased IP address
With MAC Address to storing into the memory, and then it is synchronized to file system, to complete to IP address and MAC Address pair
It updates and newly-increased.And so on, it by the continuous renewal to IP address in file system and MAC Address pair and increases newly, realizes
IP address and MAC Address to virtual machine store comprehensively, reliably.So that other function module is from file system
IP address and mac address information convenient, that comprehensively obtain virtual machine.
It wherein, can be by updated in memory and newly-increased IP address and MAC Address pair in order to improve synchronous efficiency
It is identified, judges corresponding IP address and MAC Address to whether needing to be synchronized to file system by mark.For example, can be with
By updated in memory and newly-increased IP address and MAC Address to being identified as True, and then there will be the IP of mark True
Address and MAC Address are to being synchronized to file system.
In order to improve the applicability of the disclosure, in virtual switch by vnet mouthfuls of reception messages, and then virtual machine is obtained
IP address on the basis of, virtual switch can also be configured, so that virtual switch can support user to increase manually
Add or update MAC Address and IP address pair.
Fig. 5 is please referred to, virtual machine information acquisition methods can also include the following steps.
Step S31 receives information addition request, the IP address added needed for obtaining from parsing in information addition request
And MAC Address.
Wherein, information addition request can increase or update MAC Address life related to IP address pair for user hand is dynamic
It enables, correspondingly, after virtual switch receives the order, the IP address added needed for obtaining and MAC Address can be parsed, and execute
Subsequent step S32 and step S33.
Step S32 judges whether the IP address and MAC Address have been associated storage in the memory.If in described
The IP address and MAC Address are not associated storage in depositing, then follow the steps S33.If in memory by the IP address and
MAC Address is associated storage, then no longer needs to execute storage operation.
Step S33, by the IP address and MAC Address associated storage into the memory.
IP address stored in memory and MAC Address are excessive in order to prevent, and optionally, the disclosure is also set with aging item
Part.Correspondingly, virtual machine information acquisition methods further include: judge whether are each IP address stored in memory and MAC Address
Reach aging condition, IP address and MAC Address reach the aging condition if it exists, then delete the IP address and MAC Address.
Wherein, aging condition can flexibly be set.For example, least recently used (LeastRecently can be based on
Used, LRU) algorithm, the IP address that preset ratio in memory is at least used and MAC Address are deleted.In another example can be in memory
After the IP address and MAC Address of middle storage reach set amount, by the IP address of the preset ratio of storage time at most and MAC
It deletes location.So that it is guaranteed that memory headroom is enough.
Referring to Fig. 6, the disclosure also provides a kind of virtual machine information acquisition device 20, it is applied to virtual switch, it is described
To realize the data interaction between virtual machine, the virtual machine information acquisition device 20 includes for virtual switch and virtual machine connection
Message obtains module 21, packet parsing module 22 and information storage module 23.
Wherein, message obtains the report that module 21 is used to obtain setting type from the message that the virtual switch receives
Text.
The implementation for obtaining module 21 about message can not go to live in the household of one's in-laws on getting married herein refering to the associated description of step S11 in Fig. 2
It states.
Packet parsing module 22 is used for the message for the setting type obtained, and parsing obtains the corresponding void of the message
The Protocol IP address and MAC address interconnected between the network of quasi- machine.
Implementation about packet parsing module 22 can not go to live in the household of one's in-laws on getting married herein refering to the associated description of step S12 in Fig. 2
It states.
Information storage module 23 will be for that will parse obtained IP address and MAC Address associated storage to the virtual switch
In the file system of place hardware device.
Implementation about information storage module 23 can not go to live in the household of one's in-laws on getting married herein refering to the associated description of step S13 in Fig. 2
It states.
Optionally, the information storage module 23 will be for that will parse obtained MAC Address and IP address with the side of key-value pair
It is where formula is stored in the virtual switch in the Hash table of the memory of hardware device, the Hash table of the memory storage is synchronous
To the file system of hardware device where the virtual switch.
Optionally, the virtual machine information acquisition device 20 further includes signal load unit 24 and message processing module (MPM) 25.
Wherein, signal load unit 24 is used in the initialization procedure after virtual switch starting, will be stored
In the file system IP address and MAC Address be loaded onto where the virtual switch in the memory of hardware device.
Message processing module (MPM) 25 is used for when the virtual switch receives message, and it is pre- to judge whether the message meets
If condition, if the message meets the preset condition, parsing obtains the IP address of corresponding virtual machine from the message
And MAC Address, judge whether the IP address and MAC Address have been associated storage in the memory, if in the memory not
The IP address and MAC Address are associated storage, then by the IP address and MAC Address associated storage to the memory
In.
Optionally, the message processing module (MPM) 25 is used for using the MAC Address being stored in the file system as key, with this
The corresponding IP address of MAC Address be value, by the file system IP address and MAC Address be stored in the virtual switch
In the Hash table of the memory of place hardware device.
Whether the message processing module (MPM) 25 by following steps for being judged in the memory by the IP address and MAC
Address is associated storage: whether the Hash table inquired in the memory is stored with the MAC Address.If being stored with the MAC Address,
Then judge to store in the Hash table it is whether consistent with the IP address in the message with the associated IP address of the MAC Address,
If inconsistent, by the IP being updated to the associated IP address of the MAC Address in the message stored in the Hash table
Location.If not stored in the Hash table have the MAC Address, using the MAC Address as key, with the corresponding IP address of the MAC Address
For value, by the message IP address and MAC Address be stored in the virtual switch where hardware device memory Kazakhstan
In uncommon table.
Optionally, the virtual machine information acquisition device 20 further includes message processing module 26.
Message processing module 26 adds needed for obtaining from parsing in information addition request for receiving information addition request
The IP address and MAC Address added judges whether the IP address and MAC Address have been associated storage in the memory, if institute
It states in memory and the IP address and MAC Address is not associated storage, then extremely by the IP address and MAC Address associated storage
In the memory.
In the disclosure, about virtual machine information acquisition device 20 realization principle can refering to preceding method embodiment,
This is not repeated.
Virtual machine information acquisition methods and device in the disclosure, the IP address for simplifying virtual machine obtain, independent of
The installation of Libpcap.It may insure identical message only and will do it the IP address acquisition an of virtual machine, save process resource,
Improve efficiency.The IP address and MAC Address that virtual machine is saved by file system, enable other function module to pass through visit
Ask that this document system easily obtains the information such as the IP address of virtual machine, it is more convenient to realize.
In several embodiments provided by the disclosure, it should be understood that disclosed device and method can also pass through
Other modes are realized.Device and method embodiment described above is only schematical, for example, the flow chart in attached drawing
The device of multiple embodiments according to the disclosure, the system in the cards of method and computer program product are shown with block diagram
Framework, function and operation.In this regard, each box in flowchart or block diagram can represent a module, program segment or generation
A part of code, a part of the module, section or code include one or more for realizing defined logic function
Executable instruction.It should also be noted that function marked in the box can also be in some implementations as replacement
Occur different from the sequence marked in attached drawing.For example, two continuous boxes can actually be basically executed in parallel, they
Sometimes it can also execute in the opposite order, this depends on the function involved.It is also noted that block diagram and or flow chart
In each box and the box in block diagram and or flow chart combination, can function or movement as defined in executing it is special
Hardware based system is realized, or can be realized using a combination of dedicated hardware and computer instructions.
In addition, each functional module in each embodiment of the disclosure can integrate one independent portion of formation together
Point, it is also possible to modules individualism, an independent part can also be integrated to form with two or more modules.
It, can be with if the function is realized and when sold or used as an independent product in the form of software function module
It is stored in a computer readable storage medium.Based on this understanding, the technical solution of the disclosure is substantially in other words
The part of the part that contributes to existing technology or the technical solution can be embodied in the form of software products, the meter
Calculation machine software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be a
People's computer, server or network equipment etc.) execute each embodiment the method for the disclosure all or part of the steps.
And storage medium above-mentioned include: USB flash disk, mobile hard disk, read-only server hardware resource (ROM, Read-Only Memory),
The hardware resource (RAM, Random Access Memory) of arbitrary access server, magnetic or disk etc. are various to be can store
The medium of program code.It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to
Cover non-exclusive inclusion, so that the process, method, article or equipment for including a series of elements not only includes those
Element, but also including other elements that are not explicitly listed, or further include for this process, method, article or setting
Standby intrinsic element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that
There is also other identical elements in the process, method, article or apparatus that includes the element.
The foregoing is merely the alternative embodiments of the disclosure, are not limited to the disclosure, for the skill of this field
For art personnel, the disclosure can have various modifications and variations.It is all within the spirit and principle of the disclosure, it is made any to repair
Change, equivalent replacement, improvement etc., should be included within the protection scope of the disclosure.
Claims (10)
1. a kind of virtual machine information acquisition methods, are applied to virtual switch, the virtual switch is connect with virtual machine with reality
Data interaction between existing virtual machine, which is characterized in that the described method includes:
The message of setting type is obtained from the message that the virtual switch receives;
For the message of the setting type of acquisition, parsing obtains the association interconnected between the network of the corresponding virtual machine of the message
Discuss IP address and MAC address;
The file system of hardware device where IP address and MAC Address associated storage to the virtual switch that parsing is obtained
In.
2. virtual machine information acquisition methods according to claim 1, which is characterized in that the method also includes:
The virtual switch starting after initialization procedure in, will be stored in the IP address in the file system and
Where MAC Address is loaded onto the virtual switch in the memory of hardware device;
When the virtual switch receives message, judge whether the message meets preset condition, if the message meets
The preset condition, then parsing obtains the IP address and MAC Address of corresponding virtual machine from the message, judges the memory
In whether the IP address and MAC Address have been associated storage;
If the IP address and MAC Address are not associated storage in the memory, the IP address and MAC Address are closed
Connection is stored into the memory.
3. virtual machine information acquisition methods according to claim 2, which is characterized in that it is pre- to judge whether the message meets
If the step of condition, comprising:
Judge whether the message is message that virtual switch described in first passage is forwarded, if the message is to lead to for the first time
The message that the virtual switch is forwarded is crossed, then judges whether the message is the message for setting type;
It when the message that the message is forwarded for virtual switch described in first passage, and is the message of the setting type
When, the message is determined for the message that meets preset condition.
4. virtual machine information acquisition methods according to claim 2, which is characterized in that will be stored in the file system
IP address and MAC Address be loaded onto the virtual switch where hardware device memory in step, comprising: to be stored in
MAC Address in the file system is key, is value with the corresponding IP address of the MAC Address, by the IP in the file system
Where address and MAC Address are stored in the virtual switch in the Hash table of the memory of hardware device;
It is described to judge the step of whether IP address and MAC Address being associated storage in the memory, comprising:
Whether the Hash table inquired in the memory is stored with the MAC Address;
If being stored with the MAC Address, judge to store in the Hash table with the associated IP address of the MAC Address whether with institute
The IP address stated in message is consistent, if inconsistent, will be stored in the Hash table with the associated IP address of the MAC Address more
It is newly the IP address in the message;
If not stored in the Hash table have the MAC Address, using the MAC Address as key, with the corresponding IP address of the MAC Address
For value, by the message IP address and MAC Address be stored in the virtual switch where hardware device memory Kazakhstan
In uncommon table.
5. virtual machine information acquisition methods according to claim 2, which is characterized in that the method also includes:
Information addition request is received, the IP address and MAC Address added needed for obtaining from parsing in information addition request;
Judge whether the IP address and MAC Address have been associated storage in the memory;
If the IP address and MAC Address are not associated storage in the memory, the IP address and MAC Address are closed
Connection is stored into the memory.
6. according to virtual machine information acquisition methods described in claim 2 to 5 any one, which is characterized in that the method is also
Include:
Judge whether each IP address stored in memory and MAC Address reach aging condition, if it exists IP address and MAC
Location reaches the aging condition, then deletes the IP address and MAC Address.
7. a kind of virtual machine information acquisition device, is applied to virtual switch, the virtual switch is connect with virtual machine with reality
Data interaction between existing virtual machine, which is characterized in that the virtual machine information acquisition device includes:
Message obtains module, for obtaining the message of setting type from the message that the virtual switch receives;
Packet parsing module, for the message for the setting type obtained, parsing obtains the corresponding virtual machine of the message
Network between the Protocol IP address and MAC address that interconnect;
Information storage module, for obtained IP address and MAC Address associated storage will to be parsed to the virtual switch place
In the file system of hardware device.
8. virtual machine information acquisition device according to claim 7, which is characterized in that the virtual machine information acquisition device
Further include:
Signal load unit, for the file will to be stored in the initialization procedure after virtual switch starting
Where IP address and MAC Address in system are loaded onto the virtual switch in the memory of hardware device;
Message processing module (MPM), for judging whether the message meets default item when the virtual switch receives message
Part, if the message meets the preset condition, parsing obtains the IP address and MAC of corresponding virtual machine from the message
Address judges whether the IP address and MAC Address have been associated storage in the memory, if will not be described in the memory
IP address and MAC Address are associated storage, then by the IP address and MAC Address associated storage into the memory.
9. virtual machine information acquisition device according to claim 8, which is characterized in that the message processing module (MPM) is used for,
It is value with the corresponding IP address of the MAC Address, by the file system using the MAC Address being stored in the file system as key
Where IP address and MAC Address in system are stored in the virtual switch in the Hash table of the memory of hardware device;
The message processing module (MPM) be used to judge in the memory by following steps whether by the IP address and MAC Address into
Row associated storage:
Whether the Hash table inquired in the memory is stored with the MAC Address;
If being stored with the MAC Address, judge to store in the Hash table with the associated IP address of the MAC Address whether with institute
The IP address stated in message is consistent, if inconsistent, will be stored in the Hash table with the associated IP address of the MAC Address more
It is newly the IP address in the message;
If not stored in the Hash table have the MAC Address, using the MAC Address as key, with the corresponding IP address of the MAC Address
For value, by the message IP address and MAC Address be stored in the virtual switch where hardware device memory Kazakhstan
In uncommon table.
10. virtual machine information acquisition device according to claim 8, which is characterized in that the virtual machine information obtains dress
It sets further include:
Message processing module adds needed for obtaining from parsing in information addition request for receiving information addition request
IP address and MAC Address judge whether the IP address and MAC Address have been associated storage in the memory, if in described
The IP address and MAC Address storage is not associated in depositing, then by the IP address and MAC Address associated storage to described
In memory.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810914373.8A CN109240796A (en) | 2018-08-10 | 2018-08-10 | Virtual machine information acquisition methods and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810914373.8A CN109240796A (en) | 2018-08-10 | 2018-08-10 | Virtual machine information acquisition methods and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109240796A true CN109240796A (en) | 2019-01-18 |
Family
ID=65071281
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810914373.8A Pending CN109240796A (en) | 2018-08-10 | 2018-08-10 | Virtual machine information acquisition methods and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109240796A (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110061921A (en) * | 2019-04-17 | 2019-07-26 | 北京云杉世纪网络科技有限公司 | A kind of cloud platform packet delivery method and system |
CN111225078A (en) * | 2019-12-31 | 2020-06-02 | 北京安码科技有限公司 | Socket technology-based method for rapidly acquiring KVM virtual machine address |
CN112835646A (en) * | 2021-02-20 | 2021-05-25 | 杭州迪普科技股份有限公司 | Equipment configuration recovery method and device |
CN114880076A (en) * | 2022-05-11 | 2022-08-09 | 科东(广州)软件科技有限公司 | Dynamic loading method and device for dynamic mapping file of user-mode virtual machine |
CN115529245A (en) * | 2021-06-25 | 2022-12-27 | 深信服科技股份有限公司 | Stream information completion method and device, cloud host equipment and computer storage medium |
CN115914163A (en) * | 2022-11-15 | 2023-04-04 | 北京北信源软件股份有限公司 | Address information maintenance method, device, computer equipment and storage medium |
CN116708357A (en) * | 2023-06-08 | 2023-09-05 | 北京志凌海纳科技有限公司 | Method and system for discovering virtual network IP address based on OVS |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5708654A (en) * | 1996-11-27 | 1998-01-13 | Arndt; Manfred R. | Method for detecting proxy ARP replies from devices in a local area network |
CN101114989A (en) * | 2006-07-28 | 2008-01-30 | 中兴通讯股份有限公司 | Method for processing three-layer ethernet switchboard direct connection host computer routing |
US20150055474A1 (en) * | 2013-08-20 | 2015-02-26 | Brocade Communications Systems, Inc. | Virtual Machine Traffic Engineering |
CN104426816A (en) * | 2013-08-19 | 2015-03-18 | 华为技术有限公司 | Virtual machine communication method and device |
US20160050120A1 (en) * | 2013-04-25 | 2016-02-18 | Hangzhou H3C Technologies Co., Ltd. | Network resource matching |
CN106034052A (en) * | 2015-03-13 | 2016-10-19 | 北京网御星云信息技术有限公司 | System and method for monitoring two-layer traffic among virtual machines |
CN107547339A (en) * | 2017-06-14 | 2018-01-05 | 新华三技术有限公司 | A kind of gateway media access control MAC address feedback method and device |
-
2018
- 2018-08-10 CN CN201810914373.8A patent/CN109240796A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5708654A (en) * | 1996-11-27 | 1998-01-13 | Arndt; Manfred R. | Method for detecting proxy ARP replies from devices in a local area network |
CN101114989A (en) * | 2006-07-28 | 2008-01-30 | 中兴通讯股份有限公司 | Method for processing three-layer ethernet switchboard direct connection host computer routing |
US20160050120A1 (en) * | 2013-04-25 | 2016-02-18 | Hangzhou H3C Technologies Co., Ltd. | Network resource matching |
CN104426816A (en) * | 2013-08-19 | 2015-03-18 | 华为技术有限公司 | Virtual machine communication method and device |
US20150055474A1 (en) * | 2013-08-20 | 2015-02-26 | Brocade Communications Systems, Inc. | Virtual Machine Traffic Engineering |
CN106034052A (en) * | 2015-03-13 | 2016-10-19 | 北京网御星云信息技术有限公司 | System and method for monitoring two-layer traffic among virtual machines |
CN107547339A (en) * | 2017-06-14 | 2018-01-05 | 新华三技术有限公司 | A kind of gateway media access control MAC address feedback method and device |
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110061921A (en) * | 2019-04-17 | 2019-07-26 | 北京云杉世纪网络科技有限公司 | A kind of cloud platform packet delivery method and system |
CN111225078A (en) * | 2019-12-31 | 2020-06-02 | 北京安码科技有限公司 | Socket technology-based method for rapidly acquiring KVM virtual machine address |
CN111225078B (en) * | 2019-12-31 | 2023-04-28 | 北京安码科技有限公司 | Socket technology-based method for rapidly acquiring KVM virtual machine address |
CN112835646A (en) * | 2021-02-20 | 2021-05-25 | 杭州迪普科技股份有限公司 | Equipment configuration recovery method and device |
CN115529245A (en) * | 2021-06-25 | 2022-12-27 | 深信服科技股份有限公司 | Stream information completion method and device, cloud host equipment and computer storage medium |
CN114880076A (en) * | 2022-05-11 | 2022-08-09 | 科东(广州)软件科技有限公司 | Dynamic loading method and device for dynamic mapping file of user-mode virtual machine |
CN114880076B (en) * | 2022-05-11 | 2023-02-03 | 科东(广州)软件科技有限公司 | Dynamic loading method and device for dynamic mapping file of user-mode virtual machine |
CN115914163A (en) * | 2022-11-15 | 2023-04-04 | 北京北信源软件股份有限公司 | Address information maintenance method, device, computer equipment and storage medium |
CN116708357A (en) * | 2023-06-08 | 2023-09-05 | 北京志凌海纳科技有限公司 | Method and system for discovering virtual network IP address based on OVS |
CN116708357B (en) * | 2023-06-08 | 2024-02-23 | 北京志凌海纳科技有限公司 | Method and system for discovering virtual network IP address based on OVS |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109240796A (en) | Virtual machine information acquisition methods and device | |
CN109802985B (en) | Data transmission method, device, equipment and readable storage medium | |
US10187459B2 (en) | Distributed load balancing system, health check method, and service node | |
RU2562438C2 (en) | Network system and network management method | |
US7440415B2 (en) | Virtual network addresses | |
US10091274B2 (en) | Method, device, and system for controlling network device auto-provisioning | |
US9110703B2 (en) | Virtual machine packet processing | |
CN107360184B (en) | Terminal equipment authentication method and device | |
US9276953B2 (en) | Method and apparatus to detect and block unauthorized MAC address by virtual machine aware network switches | |
CN103229478B (en) | A kind of method and apparatus determining virtual-machine drift | |
CN108777640B (en) | Server detection method, device, system and storage medium | |
CN104852840B (en) | A kind of method and device exchanged visits between control virtual machine | |
CN107544835B (en) | Method and device for detecting service network port of virtual machine | |
CN105227466B (en) | Communication processing method and device | |
CN108011819B (en) | Route issuing method and device | |
US20180176098A1 (en) | Messaging Queue Spinning Engine | |
CN112887229B (en) | Session information synchronization method and device | |
US8914503B2 (en) | Detected IP link and connectivity inference | |
CN106878106B (en) | Reachability detection method and device | |
CN106411575B (en) | Cloud environment lower network configures method of calibration and relevant device | |
CN107249038A (en) | Business datum retransmission method and system | |
JP6036506B2 (en) | Program and information processing apparatus for specifying fault influence range | |
KR20210016802A (en) | Method for optimizing flow table for network service based on server-client in software defined networking environment and sdn switch thereofor | |
CN104426759A (en) | Host machine router acquiring method, host machine router acquiring device, and host machine router acquiring system | |
US20180007075A1 (en) | Monitoring dynamic device configuration protocol offers to determine anomaly |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190118 |