TECHNICAL FIELD
[0001] This application relates to the field of information processing technologies, and
in particular, to a virtual machine migration method and a data center.
BACKGROUND
[0002] A data center needs to provide a virtual machine migration service based on a service
requirement. In other words, a virtual machine needs to be migrated from a first storage
location of the data center to a second storage location of the platform. In the present
invention, a migration process of a to-be-migrated virtual machine includes creating
a new virtual machine at the second storage location. The newly created virtual machine
and the to-be-migrated virtual machine complete a same service, and provide a same
function for a user. The newly created virtual machine at the second storage location
of the data center performs all services provided by the to-be-migrated virtual machine.
Virtual machine migration includes migration of a disk, a memory, and a device status
of a virtual machine, and migration of a network. The device status includes but is
not limited to a central processing unit (Central Processing Unit, CPU) status, an
input/output (Input/Output, I/O) device status, or the like. The migration of the
disk, the memory, and the device status ensures that a status of the new virtual machine
is the same as that of the to-be-migrated virtual machine. The migration of the network
ensures that a network connection of the new virtual machine is not affected.
[0003] Virtual machine live migration may also be referred to as virtual machine online
migration, and is a process of migrating a virtual machine while keeping the virtual
machine running and providing a service externally. The virtual machine live migration
allows only short downtime in a live migration process. This does not affect normal
running of a service on the virtual machine, and a user is not really aware of service
interruption of the virtual machine. For the virtual machine live migration, reducing
service interruption caused by network migration is important to reduction of downtime
of the virtual machine live migration.
SUMMARY
[0004] According to a first aspect, the present invention provides a virtual machine migration
method. The method includes the following steps: A control node obtains a virtual
machine migration message, where the virtual machine migration message includes location
information of a first virtual switch, and the first virtual switch is configured
to connect to a new virtual machine; the control node performs first network configuration
on the first virtual switch based on the location information of the first virtual
switch after obtaining the virtual machine migration message; and the control node
creates the new virtual machine after performing the first network configuration.
The control node further performs second network configuration on a second virtual
switch, where the second virtual switch is connected to another virtual machine, and
the another virtual machine has a communication connection to a to-be-migrated virtual
machine.
[0005] In the method, before the new virtual machine is created, a part of network configuration
in a virtual machine migration process is completed, that is, the first network configuration
for the first virtual switch does not affect a network connection of the to-be-migrated
virtual machine, so that the first network configuration may be skipped in a network
configuration process after the new virtual machine is created, and only the second
network configuration is performed. The network configuration process after the new
virtual machine is created may cause interruption of a virtual machine network connection.
However, in the method, the network configuration process after the new virtual machine
is created is reduced, thereby shortening a network interruption time in the virtual
machine migration process, and reducing impact of the virtual machine migration process
on a service.
[0006] With reference to the first aspect, in a first implementation of the first aspect,
the method further includes the following steps: The first virtual switch forwards,
to the new virtual machine based on the first network configuration, a packet sent
by the another virtual machine, and forwards, to the another virtual machine, a packet
sent by the new virtual machine; and the second virtual switch, forwards, to the another
virtual machine based on the second network configuration, a packet sent by the new
virtual machine, and forwards, to the new virtual machine, a packet sent by the another
virtual machine.
[0007] The first virtual switch and the second virtual switch establish a layer-2 network
connection between the new virtual machine and the another virtual machine by using
packet forwarding.
[0008] With reference to the first aspect or the first implementation of the first aspect,
in a second implementation of the first aspect, the method further includes the following
step: The control node performs third network configuration on a router, where the
router is deployed in a virtual network in which the to-be-migrated virtual machine
is located; and the router forwards, to the new virtual machine based on the third
network configuration, a packet sent by a cross-subnet virtual machine, and forwards,
to the cross-subnet virtual machine, the packet sent by the new virtual machine, where
the cross-subnet virtual machine and the to-be-migrated virtual machine are located
in different subnets.
[0009] The router establishes, by using the third network configuration, a layer 3 network
connection between the new virtual machine and the cross-subnet virtual machine, thereby
implementing network communication between the new virtual machine and the cross-subnet
virtual machine.
[0010] With reference to the first aspect, or the first or the second implementation of
the first aspect, in a third implementation of the first aspect, the new virtual machine
and the to-be-migrated virtual machine have a same internet protocol IP address, and
the method further includes the following step: The control node performs fourth network
configuration on the second virtual switch, so that the another virtual machine does
not forward the sent packet to the to-be-migrated virtual machine.
[0011] If live migration is used in a to-be-migrated virtual machine migration process,
the new virtual machine and the to-be-migrated virtual machine have the same internet
protocol IP address. The fourth network configuration can prevent the second virtual
switch from forwarding the packet sent by the another virtual machine to the to-be-migrated
virtual machine after a network connection between the new virtual machine and the
another virtual machine is created, and at the same time, reclaim storage space occupied
by a deletable forwarding table in the second virtual machine. The deletable forwarding
table is that the second virtual machine forwards another sent packet to a forwarding
table of the to-be-migrated virtual machine.
[0012] According to a second aspect, the present invention provides a virtual machine migration
method. The method includes the following steps: A control node obtains a virtual
machine migration message, where the virtual machine migration message includes location
information of a first virtual switch, and the first virtual switch is connected to
a new virtual machine; the control node performs fifth network configuration on the
first virtual switch based on the location information of the first virtual switch
after the virtual machine migration message is obtained, and performs sixth network
configuration on a router, where the router is deployed in a virtual network in which
a to-be-migrated virtual machine is located; and the control node creates the new
virtual machine after performing the fifth network configuration and the sixth network
configuration. The router forwards, to a cross-subnet virtual machine based on the
sixth network configuration, a packet sent by the new virtual machine, where the cross-subnet
virtual machine and the to-be-migrated virtual machine are located in different subnets.
The control node performs seventh network configuration on a second virtual switch,
where the second virtual switch is connected to another virtual machine; and the control
node performs eighth network configuration on the router, so that the router forwards,
to the new virtual machine, a packet sent by the cross-subnet virtual machine.
[0013] Same as the method in the first aspect, in the method, a network configuration process
after the new virtual machine is created is reduced, thereby shortening a network
interruption time in a virtual machine migration process, and reducing impact of the
virtual machine migration process on a service. In the method, without affecting communication
of the to-be-migrated virtual machine, the fifth network configuration for the first
virtual switch and a part of network configuration for the router, namely, the sixth
network configuration, is completed, so that the network configuration process after
the new virtual machine is created is further reduced, thereby further shortening
the network interruption time in the virtual machine migration process, and reducing
the impact of the virtual machine migration process on the service.
[0014] With reference to the second aspect, in a first implementation of the second aspect,
the method further includes the following steps: The first virtual switch sends, to
the new virtual machine based on the fifth network configuration, a packet sent by
the another virtual machine; and the second virtual switch sends, to the another virtual
machine based on the seventh network configuration, a packet sent by the new virtual
machine.
[0015] The first virtual switch and the second virtual switch establish a layer-2 network
connection between the new virtual machine and the another virtual machine by using
packet forwarding.
[0016] With reference to the first aspect, or the first implementation of the first aspect,
in a second implementation of the first aspect, the new virtual machine and the to-be-migrated
virtual machine have a same internet protocol IP address, and the method further includes
the following steps: The control node performs a ninth network configuration on the
second virtual switch, so that the another virtual machine does not forward the sent
packet to the to-be-migrated virtual machine.
[0017] If live migration is used in a to-be-migrated virtual machine migration process,
the new virtual machine and the to-be-migrated virtual machine have the same internet
protocol IP address. The fourth network configuration can prevent the second virtual
switch from forwarding the packet sent by the another virtual machine to the to-be-migrated
virtual machine after a network connection between the new virtual machine and the
another virtual machine is created, and at the same time, reclaim storage space occupied
by a deletable forwarding table in the second virtual machine. The deletable forwarding
table is that the second virtual machine forwards another sent packet to a forwarding
table of the to-be-migrated virtual machine.
[0018] According to a third aspect, the present invention provides a data center. The data
center includes at least one computing device, and each computing device includes
a processor and a memory. The processor of the at least one computing device is configured
to run a control node, a to-be-migrated virtual machine, a new virtual machine, another
virtual machine, a first virtual switch, and a second virtual switch, where the another
virtual machine has a communication connection to the to-be-migrated virtual machine,
the first virtual switch is configured to connect to the new virtual machine, and
the second virtual switch is connected to the another virtual machine.
[0019] The control node is configured to: obtain a virtual machine migration message, where
the virtual machine migration message includes location information of the first virtual
switch; perform first network configuration on the first virtual switch based on the
location information of the first virtual switch after the virtual machine migration
message is obtained; create the new virtual machine after performing the first network
configuration; and perform second network configuration on the second virtual switch.
[0020] When the control node deployed in the data center performs virtual machine migration,
a network configuration process after the new virtual machine is created is reduced,
thereby shortening a network interruption time in a virtual machine migration process,
and reducing impact of the virtual machine migration process on a service.
[0021] With reference to the third aspect, in a first implementation of the third aspect,
the first virtual switch is configured to forward, to the new virtual machine based
on the first network configuration, a packet sent by the another virtual machine;
and the second virtual switch is configured to forward, to the another virtual machine
based on the second network configuration, a packet sent by the new virtual machine.
[0022] The first virtual switch and the second virtual switch that are deployed in the data
center establish a layer-2 network connection between the new virtual machine and
the another virtual machine by using packet forwarding.
[0023] With reference to the third aspect, or the first implementation of the third aspect,
in a second implementation of the third aspect, the processor of the at least one
computing device of the data center is further configured to run a router and a cross-subnet
virtual machine, where the router is deployed in a virtual network in which the to-be-migrated
virtual machine is located; and the cross-subnet virtual machine and the to-be-migrated
virtual machine are located in different subnets. The control node is further configured
to perform third network configuration on the router. The router is configured to:
forward, to the new virtual machine based on the third network configuration, a packet
sent by the cross-subnet virtual machine, and forward, to the cross-subnet virtual
machine, the packet sent by the new virtual machine.
[0024] The control node and the router that are deployed in the data center establish, by
using the third network configuration, a layer 3 network connection between the new
virtual machine and the cross-subnet virtual machine, thereby implementing network
communication between the new virtual machine and the cross-subnet virtual machine.
[0025] With reference to the third aspect, or the first or the second implementation of
the third aspect, in a third implementation of the third aspect, the new virtual machine
and the to-be-migrated virtual machine have a same internet protocol IP address. The
control node is further configured to perform fourth network configuration on the
second virtual switch, so that the another virtual machine does not forward the sent
packet to the to-be-migrated virtual machine.
[0026] The control node deployed in the data center can prevent, by using the fourth network
configuration, the second virtual switch from forwarding the packet sent by the another
virtual machine to the to-be-migrated virtual machine after a network connection between
the new virtual machine and the another virtual machine is created, and at the same
time, reclaim storage space occupied by a deletable forwarding table in the second
virtual machine. The deletable forwarding table is that the second virtual machine
forwards another sent packet to a forwarding table of the to-be-migrated virtual machine.
[0027] According to a fourth aspect, the present invention provides a data center. The data
center includes at least one computing device, and each computing device includes
a processor and a memory. The processor of the at least one computing device is configured
to run a control node, a to-be-migrated virtual machine, a new virtual machine, another
virtual machine, a cross-subnet virtual machine, a first virtual switch, a second
virtual switch, and a router, where the another virtual machine has a communication
connection to the to-be-migrated virtual machine, the cross-subnet virtual machine
and the to-be-migrated virtual machine are located in different subnets, the first
virtual switch is configured to connect to the new virtual machine, the second virtual
switch is connected to the another virtual machine, and the router is deployed in
a virtual network in which the to-be-migrated virtual machine is located. The control
node is configured to: obtain a virtual machine migration message, where the virtual
machine migration message includes location information of the first virtual switch;
perform fifth network configuration on the first virtual switch based on the location
information of the first virtual switch after the virtual machine migration message
is obtained, and perform sixth network configuration on a router; create the new virtual
machine after performing the fifth network configuration and the sixth network configuration;
perform seventh network configuration on the second virtual switch; and perform eighth
network configuration on the router. The router is configured to: forward, to the
cross-subnet virtual machine based on the sixth network configuration, a packet sent
by the new virtual machine, and forward, to the new virtual machine based on the eighth
network configuration, a packet sent by the cross-subnet virtual machine.
[0028] Same as the data center in the third aspect, in the method, a network configuration
process after the new virtual machine is created is reduced, thereby shortening a
network interruption time in a virtual machine migration process, and reducing impact
of the virtual machine migration process on a service. In the method, without affecting
communication of the to-be-migrated virtual machine, the fifth network configuration
for the first virtual switch and a part of network configuration for the router, namely,
the sixth network configuration, is completed, so that the network configuration process
after the new virtual machine is created is further reduced, thereby further shortening
the network interruption time in the virtual machine migration process, and reducing
the impact of the virtual machine migration process on the service.
[0029] With reference to the fourth aspect, in a first implementation of the fourth aspect,
the first virtual switch is configured to send, to the new virtual machine based on
the fifth network configuration, a packet sent by the another virtual machine; and
the second virtual switch is configured to send, to the another virtual machine based
on the seventh network configuration, a packet sent by the new virtual machine.
[0030] The first virtual switch and the second virtual switch establish a layer-2 network
connection between the new virtual machine and the another virtual machine by using
packet forwarding.
[0031] According to a fifth aspect, the present invention provides a control node. The control
node is configured to migrate a to-be-migrated virtual machine, and the control node
includes an interface unit, a network configuration unit, and a virtual machine creation
unit. The interface unit is configured to obtain a virtual machine migration message,
where the virtual machine migration message includes location information of a first
virtual switch, and the first virtual switch is configured to connect to a new virtual
machine. The network configuration unit is configured to: perform first network configuration
on the first virtual switch based on the location information of the first virtual
switch that is obtained by the interface unit, where the first virtual switch forwards,
to the new virtual machine, a packet sent by another virtual machine, and the another
virtual machine has a communication connection to the to-be-migrated virtual machine;
and perform second network configuration on a second virtual switch, so that the second
virtual switch forwards, to the another virtual machine based on the second network
configuration, a packet sent by the new virtual machine, where the second virtual
switch is connected to the another virtual machine. The virtual machine creation unit
is configured to create the new virtual machine after the network configuration unit
completes the first network configuration.
[0032] Before the new virtual machine is created, the control node completes a part of network
configuration in a virtual machine migration process, that is, the first network configuration
for the first virtual switch does not affect a network connection of the to-be-migrated
virtual machine, so that the first network configuration may be skipped in a network
configuration process after the new virtual machine is created, and only the second
network configuration is performed. The network configuration process after the new
virtual machine is created may cause interruption of a virtual machine network connection.
However, in the method, the network configuration process after the new virtual machine
is created is reduced, thereby shortening a network interruption time in a virtual
machine migration process, and reducing impact of the virtual machine migration process
on a service.
[0033] With reference to the fifth aspect, in a first implementation of the fifth aspect,
the network configuration unit is further configured to perform third network configuration
on a router, so that the router forwards, to the new virtual machine based on the
third network configuration, a packet sent by a cross-subnet virtual machine, and
forwards, to the cross-subnet virtual machine, a packet sent by the new virtual machine,
where the router is deployed in a virtual network in which the to-be-migrated virtual
machine is located, and the cross-subnet virtual machine and the to-be-migrated virtual
machine are located in different subnets.
[0034] With reference to the fifth aspect, or the first implementation of the fifth aspect,
in a second implementation of the fifth aspect, the new virtual machine and the to-be-migrated
virtual machine have a same internet protocol IP address, and the network configuration
unit is further configured to perform fourth network configuration on the second virtual
switch, so that the another virtual machine does not forward the sent packet to the
to-be-migrated virtual machine.
[0035] According to a fifth aspect, the present invention provides a control node. The control
node is configured to migrate a to-be-migrated virtual machine, and the control node
includes an interface unit, a network configuration unit, and a virtual machine creation
unit. The interface unit is configured to obtain a virtual machine migration message,
where the virtual machine migration message includes location information of a first
virtual switch, and the first virtual switch is configured to connect to a new virtual
machine. The network configuration unit is configured to: perform fifth network configuration
on the first virtual switch based on the location information of the first virtual
switch that is obtained by the interface unit, so that the first virtual switch forwards,
to the new virtual machine based on the fifth network configuration, a packet sent
by another virtual machine, where the another virtual machine has a communication
connection to the to-be-migrated virtual machine; perform sixth network configuration
on a router, so that the router forwards, to a cross-subnet virtual machine based
on the sixth network configuration, a packet sent by the new virtual machine, where
the router is deployed in a virtual network in which the to-be-migrated virtual machine
is located, and the cross-subnet virtual machine and the to-be-migrated virtual machine
are located in different subnets; perform seventh network configuration on a second
virtual switch, so that the second virtual switch forwards, to the another virtual
machine based on the second network configuration, the packet sent by the new virtual
machine, where the second virtual switch is connected to the another virtual machine;
and perform eighth network configuration on the router, so that the router forwards,
to the new virtual machine, a packet sent by the cross-subnet virtual machine. The
virtual machine creation unit is configured to: create the new virtual machine after
the network configuration unit completes the fifth network configuration and the sixth
network configuration.
[0036] Same as the control node in the sixth aspect, in the method, a network configuration
process after the new virtual machine is created is reduced, thereby shortening a
network interruption time in a virtual machine migration process, and reducing impact
of the virtual machine migration process on a service. In the method, without affecting
communication of the to-be-migrated virtual machine, the fifth network configuration
for the first virtual switch and a part of network configuration for the router, namely,
the sixth network configuration, is completed, so that the network configuration process
after the new virtual machine is created is further reduced, thereby further shortening
the network interruption time in the virtual machine migration process, and reducing
the impact of the virtual machine migration process on the service.
[0037] According to a seventh aspect, the present invention further provides a computer
program product and a nonvolatile computer-readable storage medium, where the computer
program product and the nonvolatile computer-readable storage medium include a computer
instruction. A processor performs the computer instruction to implement the method
according to any one of the implementations of the first aspect in the present invention.
[0038] According to an eighth aspect, the present invention further provides a computer
program product and a nonvolatile computer-readable storage medium, where the computer
program product and the nonvolatile computer-readable storage medium include a computer
instruction. A processor performs the computer instruction to implement the method
according to any one of the implementations of the second aspect in the present invention.
[0039] According to a ninth aspect, the present invention further provides a computing device,
and the computing device includes a processor and a memory. The processor of the computing
device runs a program instruction in the memory to implement the control node according
to any one of the implementations of the fifth aspect in the present invention.
[0040] According to a tenth aspect, the present invention further provides a computing device,
and the computing device includes a processor and a memory. The processor of the computing
device runs a program instruction in the memory to implement the control node according
to any one of the implementations of the sixth aspect in the present invention.
BRIEF DESCRIPTION OF DRAWINGS
[0041]
FIG. 1 is a schematic diagram of a data center according to an embodiment of the present
invention;
FIG. 2 is a schematic diagram of a communication connection of a data center according
to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a virtual machine migration method according to an
embodiment of the present invention;
FIG. 4 is a schematic diagram of another virtual machine migration method according
to an embodiment of the present invention;
FIG. 5A to FIG. 5C are a schematic diagram of a virtual machine migration method based
on a network control node and a computing control node according to an embodiment
of the present invention;
FIG. 6A to FIG. 6C are a schematic diagram of another virtual machine migration method
based on a network control node and a computing control node according to an embodiment
of the present invention;
FIG. 7 is a schematic diagram of an implementation of a data center according to an
embodiment of the present invention; and
FIG. 8 is a schematic diagram of a control node according to an embodiment of the
present invention.
DESCRIPTION OF EMBODIMENTS
[0042] FIG. 1 is a schematic diagram of a data center according to an embodiment of the
present invention. The data center 100 is oriented to at least one user, and provides
services for each user. For example, FIG. 1 shows two users of the data center 100.
Virtual machines deployed in the data center are allocated to the users, to provide
specific services for the users. The virtual machine allocated to each user is located
in a virtual network of the user. Virtual networks of the users are isolated from
each other. Each user accesses, through the virtual network of the user, the virtual
machine in the virtual network, to obtain a service provided by the data center. Further,
the virtual network of each user may include a plurality of subnets, and virtual machines
of each user are deployed in different subnets. Deployment of the virtual machines
in different subnets may be based on a service requirement or a management requirement.
In this embodiment of the present invention, virtual machines that are located in
a same virtual network as a to-be-migrated virtual machine and that have a communication
connection to the to-be-migrated virtual machine are referred to as other virtual
machines. The other virtual machines further include a cross-subnet virtual machine.
The cross-subnet virtual machine is a virtual machine that is in the other virtual
machines and that is not in a same subnet as the to-be-migrated virtual machine. The
other virtual machines described in this embodiment of the present invention do not
include a new virtual machine.
[0043] A user 1 in FIG. 1 is used as an example. Virtual machines allocated to the user
1 are located in a virtual network 110, and the virtual network 110 includes a subnet
111, a subnet 112, and a subnet 113. Virtual machines having a communication connection
to a to-be-migrated virtual machine 121 (the communication connection is not shown
in FIG. 1) are deployed in the subnet 111, the subnet 112, and the subnet 113, to
provide a service for the user 1. Other virtual machines 151 include virtual machines
in the subnet 112 and virtual machines in the subnet 113, and a virtual machine 141
in the subnet 111. The virtual machines in the subnet 112 and the virtual machines
in the subnet 113 are cross-subnet virtual machines 161. FIG. 1 shows the virtual
network including three subnets as an example. In addition, the virtual network of
the user may further include two or more subnets. Alternatively, the virtual network
of the user may not include a subnet. In other words, all virtual machines of the
user are not isolated in terms of a subnet and are interconnected at layer 2. In this
case, the virtual machines of the user do not include a cross-subnet virtual machine.
The virtual machines of the user except a to-be-migrated virtual machine and a new
virtual machine are referred to as other virtual machines. This is not limited in
this embodiment of the present invention.
[0044] The user 1 in FIG. 1 is used as an example to describe a virtual machine migration
process. Migration of the to-be-migrated virtual machine 121 includes creation of
a new virtual machine 131, and establishment of a communication connection between
the new virtual machine 131 and the other virtual machines 151, including the cross-subnet
virtual machines 161. In addition, the migration of the to-be-migrated virtual machine
121 further includes deletion of the to-be-migrated virtual machine 121, and deletion
of the communication connection between the new virtual machine 131 and the other
virtual machines 151, including the cross-subnet virtual machines 161.
[0045] An embodiment of the present invention provides a virtual machine migration method.
In a virtual machine live migration process, network migration is divided into two
phases: Before a new virtual machine is created, a part of a process of the network
migration is completed without interrupting a network connection of a to-be-migrated
virtual machine. After the new virtual machine is created, the network connection
of the to-be-migrated virtual machine is interrupted and a network connection of the
new virtual machine is established. In this case, a network interruption time throughout
the virtual machine live migration is shortened to a time used for establishing the
network connection.
[0046] In this embodiment of the present invention, a communication connection between virtual
machines is implemented by a virtual switch and a router of a virtual network in which
the virtual machines are located. The router may be a virtual router or a distributed
virtual router. In this embodiment of the present invention, a virtual switch connected
to the new virtual machine is referred to as a first virtual switch, and a virtual
switch connected to other virtual machines (including cross-subnet virtual machines)
is referred to as a second virtual switch.
[0047] OpenStack (OpenStack) is a common public cloud management platform. A data center
in this embodiment of the present invention may be based on OpenStack. A communication
connection of a data center provided in an embodiment of the present invention is
shown in FIG. 2. The data center includes a virtual network (not shown in FIG. 2).
The virtual network includes at least one virtual machine, and the at least one virtual
machine includes a to-be-migrated virtual machine and other virtual machines. If a
plurality of subnets are deployed in the virtual network, the other virtual machines
alternatively include cross-subnet virtual machines. FIG. 2 further shows a new virtual
machine to which the to-be-migrated virtual machine is migrated, a first virtual machine
connected to the new virtual machine, a virtual switch connected to the to-be-migrated
virtual machine, a second virtual machine and a router that are connected to the other
virtual machines. In addition, the data center shown in FIG. 2 further includes a
control node.
[0048] Based on the data center shown in FIG. 2, an embodiment of the present invention
provides a virtual machine migration method, as shown in FIG. 3.
[0049] S301. A control node obtains a virtual machine migration message.
[0050] A user initiates a requirement for migrating a to-be-migrated virtual machine, and
the control node obtains the virtual machine migration message. The virtual machine
migration message includes location information of a first virtual switch. In this
case, the first virtual switch is already created, but the new virtual machine is
not yet created. The location information of the first virtual switch that is included
in the virtual machine migration message is used to determine the first virtual switch
connected to the new virtual machine.
[0051] S302. The control node performs first network configuration on the first virtual
switch, so that the first virtual switch can forward, to the new virtual machine based
on the first network configuration, a packet sent by another virtual machine, and
a communication tunnel between the new virtual machine and the another virtual machine
is created on a side of the new virtual machine.
[0052] In this case, the new virtual machine is not yet created, and the first network configuration
only enables the first virtual switch to have a packet forwarding capability. Configuring
only the first virtual switch does not affect forwarding of a packet related to the
to-be-migrated virtual machine by a second virtual switch. Therefore, the first network
configuration does not affect communication between the to-be-migrated virtual machine
and the another virtual machine. In a flow table-based forwarding scenario, the first
network configuration may be implemented by delivering a flow table on the first virtual
switch. The control node instructs a layer-2 network agent of the first virtual switch
to complete the first network configuration for the first virtual switch.
[0053] The configuration performed on the first virtual switch enables the first virtual
switch to have the packet forwarding capability. Although the new virtual machine
is not yet created at this time, a network between the another virtual machine and
the new virtual machine is not established either, and the first virtual switch receives
no packet from the new virtual machine or the another virtual machine, once creation
of the new virtual machine and establishment of a network connection are completed,
the first virtual switch may complete packet forwarding based on the first network
configuration.
[0054] S303. The control node creates the new virtual machine after performing the first
network configuration.
[0055] S304. The control node performs second network configuration on the second virtual
switch, so that the second virtual switch can forward, to the another virtual machine
based on the second network configuration, a packet sent by the new virtual machine.
[0056] After the new virtual machine is created, a computing agent of a host on which the
to-be-migrated virtual machine is located instructs the control node to perform the
second network configuration on the second virtual switch. In a flow table-based scenario,
a forwarding flow table is delivered on each second virtual switch connected to each
of other virtual machines, and each second virtual switch forwards, to the new virtual
machine based on the forwarding flow table, a packet sent by the another virtual machine,
and forwards, to the another virtual machine, the packet sent by the new virtual machine.
The control node instructs a layer-2 network agent of the second virtual switch to
complete the second network configuration for the second virtual switch.
[0057] S305. The control node performs third network configuration on a router, so that
the router can forward, to the new virtual machine based on the third network configuration,
a packet sent by a cross-subnet virtual machine, and forward, to the cross-subnet
virtual machine, a packet sent by the new virtual machine.
[0058] The another virtual machine further includes the cross-subnet virtual machine that
is not in a same subnet as the to-be-migrated virtual machine. To implement communication
between the new virtual machine and the cross-subnet virtual machine, the control
node further needs to perform the third configuration on the router of a virtual network
in which the to-be-migrated virtual machine is located. A specific implementation
includes that a routing table is delivered on the router, so that the router can perform
the third configuration. The router forwards, to the new virtual machine based on
the third network configuration, the packet sent by the cross-subnet virtual machine,
and forwards, to the cross-subnet virtual machine, the packet sent by the new virtual
machine. The control node instructs a layer-3 network agent of the router to complete
the third network configuration for the router.
[0059] Further, in a virtual machine live migration scenario, the new virtual machine and
a destination virtual machine have a same IP address. After a network connection between
the new virtual machine and the another virtual machine is created, to prevent the
second virtual switch from forwarding, to the to-be-migrated virtual machine, the
packet sent by another virtual machine, the control node further needs to perform
fourth network configuration on the second virtual switch. Specifically, the fourth
network configuration includes deleting a flow table used by the second virtual machine
to forward, to the to-be-migrated virtual machine, the packet sent by another virtual
machine. The flow table is deleted so that the another virtual machine cannot forward
the sent packet to the to-be-migrated virtual machine.
[0060] In addition, after the new virtual machine and the network connection between the
new virtual machine and the another virtual machine are created, a process of migrating
the to-be-migrated virtual machine to the new virtual machine further includes deleting
the to-be-migrated virtual machine and deleting the network connection between the
to-be-migrated virtual machine and the another virtual machine. Details are not described
in this embodiment.
[0061] According to the method provided in this embodiment of the present invention, a network
interruption time in a process of a to-be-migrated virtual machine live migration
is shortened. Before the new virtual machine is created, a part of network configuration
is first completed, that is, the first network configuration does not interrupt a
network connection of the to-be-migrated virtual machine. After the new virtual machine
is created, remaining network configuration is completed to implement the to-be-migrated
virtual machine live migration. In this method, a time in a network in the process
of the to-be-migrated virtual machine live migration is shortened, so that a breakdown
time of a service provided by the data center in the process of the to-be-migrated
virtual machine live migration is reduced, and stability of the service of the data
center is improved.
[0062] It can be learned from the foregoing method that, to implement communication between
the new virtual machine and the cross-subnet virtual machine, the control node further
needs to configure the router of the virtual network in which the to-be-migrated virtual
machine is located. Configuring of the router includes two aspects. First, the router
forwards, to the new virtual machine based on the configuration, the packet sent by
the cross-subnet virtual machine; second, the router forwards, to the cross-subnet
virtual machine, the packet sent by the new virtual machine. Before the new virtual
machine is created, the router is configured, so that the router can forward, to the
cross-subnet virtual machine, the packet sent by the new virtual machine. This does
not affect the network connection of the to-be-migrated virtual machine, further reducing
configuration steps after the new virtual machine is created, and further shortening
a network interruption time.
[0063] Based on this, based on the data center shown in FIG. 2, an embodiment of the present
invention provides another virtual machine migration method, as shown in FIG. 4.
[0064] S401. A control node obtains a virtual machine migration message.
[0065] Same as S301, a user initiates a requirement for migrating a to-be-migrated virtual
machine, and the control node obtains the virtual machine migration message. The control
node obtains, based on the virtual machine migration message, location information
of a first virtual switch connected to a new virtual machine.
[0066] The user initiates the requirement for migrating the to-be-migrated virtual machine,
and the control node obtains the virtual machine migration message. The virtual machine
migration message includes the location information of the first virtual switch. In
this case, the first virtual switch is already created, but the new virtual machine
is not created. The location information of the first virtual switch that is included
in the virtual machine migration message is used to determine the first virtual switch
connected to the new virtual machine.
[0067] S402. The control node performs fifth network configuration on the first virtual
switch, so that the first virtual switch can forward, to the new virtual machine based
on first network configuration, a packet sent by another virtual machine.
[0068] In this case, the new virtual machine is not yet created, and the fifth network configuration
only enables the first virtual switch to have a packet forwarding capability. Configuring
only the first virtual switch does not affect forwarding of a packet related to the
to-be-migrated virtual machine by the second virtual switch. Therefore, the first
network configuration does not affect communication between the to-be-migrated virtual
machine and the another virtual machine. In a flow table-based forwarding scenario,
the fifth network configuration may be implemented by delivering a flow table on the
first virtual switch. The control node instructs a layer-2 network agent of the first
virtual switch to complete the fifth network configuration for the first virtual switch.
[0069] S403. The control node performs sixth network configuration on the router, so that
the router can forward, to a cross-subnet virtual machine based on the sixth network
configuration, a packet sent by the new virtual machine.
[0070] To implement communication between the new virtual machine and the cross-subnet virtual
machine, the control node performs the sixth configuration on the router of a virtual
network in which the to-be-migrated virtual machine is located, and configures a layer-3
network connection of the new virtual machine. A specific implementation includes
that a routing table is delivered on the router, so that the router can perform the
sixth configuration. The router forwards, to the cross-subnet virtual machine based
on the sixth network configuration, the packet sent by the new virtual machine. Similarly,
at this time, the new virtual machine is not yet created, and the router does not
receive the packet sent by the new virtual machine to the cross-subnet virtual machine.
Therefore, the sixth network configuration does not affect a network connection of
the to-be-migrated virtual machine. The configuration of the router enables the router
to have a capability of forwarding, to the cross-subnet virtual machine, the packet
sent by the new virtual machine, thereby shortening a time for configuring a network
connection of the new virtual machine after the network connection of the to-be-migrated
virtual machine is interrupted. Once the virtual machine completes creation of the
new virtual machine and establishment of a network connection, the router may complete
packet forwarding based on the sixth network configuration. The control node instructs
a layer-3 network agent of the router to complete the sixth network configuration
for the router.
[0071] In another implementation of the present invention, because the new virtual machine
is not yet created, an implementation sequence of S402 and S403 may be adjusted, that
is, after S401, S403 is performed, and then S402 is performed. This is not limited
in this embodiment of the present invention.
[0072] S404. The control node creates the new virtual machine after performing the fifth
network configuration and the sixth network configuration.
[0073] S405. The control node performs seventh network configuration on a second virtual
switch, so that the second virtual switch can forward, to another virtual machine
based on the seventh network configuration, a packet sent by the new virtual machine.
The control node instructs a layer-2 network agent of the second virtual switch to
complete the seventh network configuration for the second virtual switch.
[0074] After the new virtual machine is created, a computing agent of a host on which the
to-be-migrated virtual machine is located instructs the control node to perform the
seventh network configuration on the second virtual switch. In a flow table-based
scenario, a forwarding flow table is delivered on each second virtual switch connected
to each of other virtual machines, and each second virtual switch forwards, to the
new virtual machine based on the forwarding flow table, a packet sent by the another
virtual machine, and forwards, to the another virtual machine, the packet sent by
the new virtual machine.
[0075] S406. The control node performs eighth network configuration on the router, so that
the router can forward, to the new virtual machine based on the eighth network configuration,
a packet sent by the cross-subnet virtual machine. The control node instructs the
layer-3 network agent of the router to complete the eighth network configuration for
the router.
[0076] In another implementation of the present invention, an implementation sequence of
S405 and S406 may be adjusted, that is, after S404, S406 is performed, and then S405
is performed. This is not limited in this embodiment of the present invention.
[0077] The another virtual machine further includes the cross-subnet virtual machine that
is not in a same subnet as the to-be-migrated virtual machine. To implement communication
between the new virtual machine and the cross-subnet virtual machine, the control
node further needs to perform the eighth configuration on the router of a virtual
network in which the to-be-migrated virtual machine is located. A specific implementation
includes that a routing table is delivered on the router, so that the router can perform
the eighth configuration. The router forwards, to the new virtual machine based on
the eighth network configuration, the packet sent by the cross-subnet virtual machine,
and forwards, to the cross-subnet virtual machine, the packet sent by the new virtual
machine.
[0078] Further, in a virtual machine live migration scenario, the new virtual machine and
a destination virtual machine have a same IP address. After a network connection between
the new virtual machine and the another virtual machine is created, to prevent the
second virtual switch from forwarding, to the to-be-migrated virtual machine, the
packet sent by another virtual machine, the control node further needs to perform
ninth network configuration on the second virtual switch. Specifically, the ninth
network configuration includes deleting a flow table used by the second virtual machine
to forward, to the to-be-migrated virtual machine, the packet sent by another virtual
machine. The flow table is deleted so that the another virtual machine cannot forward
the sent packet to the to-be-migrated virtual machine.
[0079] In addition, after the new virtual machine and the network connection between the
new virtual machine and the another virtual machine are created, a process of migrating
the to-be-migrated virtual machine to the new virtual machine further includes deleting
the to-be-migrated virtual machine and deleting the network connection between the
to-be-migrated virtual machine and the another virtual machine. Details are not described
in this embodiment.
[0080] In this embodiment of the present invention, after the new virtual machine is created,
configuration of a network of the to-be-migrated virtual machine by the control node
further includes: instructing the computing agent of the host on which the to-be-migrated
virtual machine is located to bring a port of the to-be-migrated virtual machine offline,
instructing a computing agent of the host on which the new virtual machine is located
to set a state of the new virtual machine to active (active), and the like. In addition,
in the network migration process of the to-be-migrated virtual machine, a host binding
relationship needs to be updated on the control node, that is, a binding relationship
between the to-be-migrated virtual machine and the host on which the to-be-migrated
virtual machine is located is deleted, and a binding relationship between the new
virtual machine and the host on which the new virtual machine is located is added.
Further, the new virtual machine and a destination virtual machine have a same internet
protocol (Internet Protocol, IP) address, and on a side of the to-be-migrated virtual
machine, a port of the to-be-migrated virtual machine needs to be brought offline,
and a communication tunnel between the to-be-migrated virtual machine and the another
virtual machine needs to be deleted.
[0081] The control node in this embodiment of the present invention includes the control
node of the data center in FIG. 2, and may include a computing control node and a
network control node. The computing control node is configured to implement management
of each virtual machine process, and the network control node is configured to manage
each virtual machine network. The computing control node further includes a first
computing control node and a second computing control node. The first computing control
node is configured to manage the to-be-migrated virtual machine, and the second computing
control node is configured to manage the new virtual machine.
[0082] In a process of migrating the to-be-migrated virtual machine, the computing control
node and the network control node cooperate to perform the method steps performed
by the foregoing control node. Specifically, that the foregoing control node obtains
the virtual machine migration message includes that the first computing control node
and the network control node separately receive the virtual machine migration message,
and complete pre-processing before migration of the to-be-migrated virtual machine.
That the control node performs the first network configuration to the eighth network
configuration includes that the network control node receives a message from the first
computing control node, and performs the first network configuration to the eighth
network configuration. That the control node receives the new virtual machine includes
that the first computing node creates a message from the network control node, and
creates the new virtual machine. The pre-processing before migration of the to-be-migrated
virtual machine includes creation of a backend port of the new virtual machine. The
creation of the backend port of the new virtual machine is to create, on the second
virtual switch, a backend port corresponding to the new virtual machine before the
new virtual machine is created, so that the new virtual machine can be connected to
the second virtual switch after being created. For more detailed configuration steps,
refer to descriptions in FIG. 4 and FIG. 5A to FIG. 5C.
[0083] In addition, in the data center in FIG. 2, each virtual switch has a corresponding
layer-2 network agent, and a router has a corresponding layer-3 network agent. The
network control node configures each virtual switch by using the corresponding layer-2
network agent and the corresponding layer-3 network agent. Specifically, the network
control node instructs the layer-2 network agent of each virtual switch to perform
network configuration on each virtual switch. In a flow table-based network scenario,
the network control node instructs the layer-2 network agent of each virtual switch
to separately deliver a forwarding flow table on each virtual switch to complete configuration.
The network control node instructs the layer-3 network agent of the router to perform
network configuration on the router, that is, the network control node instructs the
layer-3 network agent of the router to deliver a routing table on the router to complete
router configuration.
[0084] Based on the data center including the computing control node and the network control
node, an embodiment of the present invention provides a virtual machine migration
method, as shown in FIG. 5A to FIG. 5C.
[0085] S501. A first computing control node receives a virtual machine migration message.
[0086] S502. The first computing control node instructs a second computing control node
to start pre-processing before migration of a to-be-migrated virtual machine, namely,
creation of a backend port of a new virtual machine.
[0087] S503. The second computing control node creates the backend port of the new virtual
machine, and connects the backend port of the new virtual machine to a first virtual
switch.
[0088] S504. After the back-end port of the new virtual machine is created, the second computing
control node instructs a network control node to start a part of network configuration
for the new virtual machine. A notification interface between the second computing
control node and the network control node includes but is not limited to an event
notification.
[0089] S505. The network control node receives a notification from the second computing
control node, and instructs a layer-2 network agent of the first virtual switch to
perform first network configuration.
[0090] S506. The layer-2 network agent of the first virtual switch receives a notification
from the network control node, and performs the first network configuration.
[0091] S507. After performing the first network configuration, the layer-2 network agent
of the first virtual switch returns a configuration completion message to the network
control node. The configuration completion message may be a port reporting message.
Specifically, the layer-2 network agent of the first virtual switch delivers a forwarding
flow table on a destination virtual switch, and the forwarding flow table instructs
the destination virtual switch to forward a packet sent by the new virtual machine.
[0092] S508. The network control node receives the configuration complete message returned
by the layer-2 network agent in S507, and instructs the first computing control node
to create the new virtual machine. In this embodiment of the present invention, the
network control node may instruct, by using event communication, the first computing
control node to start a to-be-migrated virtual machine live migration. Specifically,
the network control node instructs the first computing control node to start the to-be-migrated
virtual machine live migration by using a programmable application programming interface
(Application Programming Interface, API) provided by the data center.
[0093] S509. The first computing control node receives the notification from the network
control node, and creates the new virtual machine. This specifically includes creating
the new virtual machine based on a disk, a memory, and a device status of the to-be-migrated
virtual machine.
[0094] S510. After creating the new virtual machine, the first computing node instructs
the network control node to perform third network configuration.
[0095] S511. The network control node instructs a layer-3 network agent of a router to perform
the third network configuration.
[0096] S512. The layer-3 network agent of the router receives the notification from the
network control node, and performs the third network configuration. If a host on which
the new virtual machine is located is the first node of a virtual network in which
the to-be-migrated virtual machine is located, sixth network configuration further
includes: creating a subnet gateway port and a file transfer protocol (File Transfer
Protocol, FIP) namespace of the new virtual machine, configuring a virtual router
of the new virtual machine, adding the new virtual machine to the virtual network
in which the to-be-migrated virtual machine is located.
[0097] Optionally, after the layer-3 network agent of the router performs the third network
configuration, the layer-3 network agent returns a configuration completion message
to the network control node, and the configuration completion message may be a path
reporting message.
[0098] S513. The first computing control node instructs the second computing control node
to change a state of the new virtual machine.
[0099] S514. The second computing control node receives the notification from the first
computing control node, and sets the new virtual machine to an active (active) state.
[0100] S515. The first computing control node instructs the network control node to update
a correspondence between a host and the new virtual machine.
[0101] S516. The network control node updates the correspondence between the host and the
new virtual machine.
[0102] S516. The network control node instructs a layer-2 network agent of a second virtual
machine to perform a second network configuration and fourth network configuration.
[0103] S517. The layer-2 network agent of the second virtual machine separately receives
notifications from the network control node, performs the second network configuration
and the fourth network configuration, and separately delivers and deletes a corresponding
forwarding flow table on a corresponding second virtual switch.
[0104] In addition, the migration of the to-be-migrated virtual machine further includes
deletion of the to-be-migrated virtual machine and deletion of a network connection
between the to-be-migrated virtual machine and another virtual machine. Details are
not described in this embodiment again.
[0105] An embodiment of the present invention further provides a virtual machine migration
method, as shown in FIG. 6A to FIG. 6C.
[0106] S601. A first computing control node receives a virtual machine migration message.
[0107] S602. The first computing control node instructs a second computing control node
to start pre-processing before migration of a to-be-migrated virtual machine, namely,
creation of a backend port of a new virtual machine.
[0108] S603. The second computing control node creates the backend port of the new virtual
machine, and connects the backend port of the new virtual machine to a destination
virtual switch.
[0109] S604. After the back-end port of the new virtual machine is created, the second computing
control node instructs a network control node to start a part of network configuration
for the new virtual machine. A notification interface between the second computing
control node and the network control node includes but is not limited to an event
notification.
[0110] S605. The network control node receives a notification from the second computing
control node, and instructs a layer-2 network agent of the first virtual switch to
perform fifth network configuration.
[0111] S606. The layer-2 network agent of the first virtual switch receives a notification
from the network control node, performs the fifth network configuration, and returns
a configuration completion message to the network control node after the fifth network
configuration is completed.
[0112] S607. After performing the fifth network configuration, the layer-2 network agent
of the first virtual switch returns a configuration completion message to the network
control node. The configuration completion message may be a port reporting message.
Specifically, the layer-2 network agent of the first virtual switch delivers a forwarding
flow table on a destination virtual switch, and the forwarding flow table instructs
the destination virtual switch to forward a packet sent by the new virtual machine.
[0113] S608. The network control node instructs a layer-3 network agent of a router to perform
sixth network configuration.
[0114] S609. The layer-3 network agent of the router receives the notification from the
network control node, and performs the sixth network configuration. If a host on which
the new virtual machine is located is the first node of a virtual network in which
the to-be-migrated virtual machine is located, sixth network configuration further
includes: creating a subnet gateway port and a file transfer protocol (File Transfer
Protocol, FIP) namespace of the new virtual machine, configuring a virtual router
of the new virtual machine, adding the new virtual machine to the virtual network
in which the to-be-migrated virtual machine is located.
[0115] S610. After the configuration is completed, the layer-3 network agent returns the
configuration completion message to the network control node, and the configuration
completion message may be a path reporting message.
[0116] It should be noted that, in this embodiment of the present invention, a sequence
of S605 to S610 may be exchanged. S605 and S608 are separately steps of instructing,
by the network control node after receiving a network pre-migration notification,
another network node to perform the network pre-migration. S606 and S607 are feedbacks
of the layer-2 network agent of the first virtual switch on the notification in S606.
S609 and S610 are feedbacks of the layer-2 network agent of the second virtual switch
on the notification in S608. After receiving the network pre-migration notification,
the network control node may first instruct the layer-3 network agent to configure
a virtual router, and then instruct a layer-2 network agent of a host on which the
new virtual machine is located to configure the destination virtual switch, that is,
a sequence of S605 to S610 may also be: S608, S609, S610, S605, S606, and S607. This
is not limited in this embodiment of the present invention.
[0117] S611. The network control node receives the configuration completion message returned
by the layer-2 network agent in S607 and the configuration completion message returned
by the layer-3 network agent in S608, and instructs the first computing control node
to create the new virtual machine. In this embodiment of the present invention, the
network control node may instruct, by using event communication, the first computing
control node to start a to-be-migrated virtual machine live migration. Specifically,
the network control node instructs the first computing control node to start the to-be-migrated
virtual machine live migration by using a programmable application programming interface
(Application Programming Interface, API) provided by the data center.
[0118] S612. The first computing control node receives the notification from the network
control node, and creates the new virtual machine. This specifically includes creating
the new virtual machine based on a disk, a memory, and a device status of the to-be-migrated
virtual machine.
[0119] S613. After creating the new virtual machine, the first computing node instructs
the network control node to perform eighth network configuration.
[0120] S614. The network control node instructs a layer-3 network agent of a router to perform
the eighth network configuration.
[0121] S615. The layer-3 network agent receives the notification of the network control
node, performs the eighth network configuration, delivers a routing table on the router,
configures a FIP return route, and triggers sending of a free address resolution protocol
(Address Resolution Protocol, ARP) packet.
[0122] S616. The first computing control node instructs the second computing control node
to change a state of the new virtual machine.
[0123] S617. The second computing control node receives the notification from the first
computing control node, sets the new virtual machine to an active (active) state,
and instructs the network control node to complete network migration.
[0124] S618. The first computing control node instructs the network control node to update
a correspondence between the host and the new virtual machine.
[0125] S619. The network control node receives the notification from the first computing
control node, and updates a correspondence between the new virtual machine and the
host on which the new virtual machine is located.
[0126] S620. The network control node instructs a layer-2 network agent of a second virtual
machine to perform seventh network configuration and ninth network configuration.
[0127] S621. The layer-2 network agent of the second virtual machine separately receives
the notification from the network control node, performs the seventh network configuration
and the ninth network configuration, and separately delivers and deletes a corresponding
forwarding flow table on a corresponding second virtual switch.
[0128] In addition, the migration of the to-be-migrated virtual machine further includes
deletion of the to-be-migrated virtual machine and deletion of a network connection
between the to-be-migrated virtual machine and another virtual machine. Details are
not described in this embodiment again.
[0129] An embodiment of the present invention provides a data center, as shown in FIG. 7.
The data center includes at least one computing device, and each computing device
includes one or more processors and one or more memories. The processor of the at
least one computing device is configured to run a control node, a to-be-migrated virtual
machine, a new virtual machine, another virtual machine, a first virtual switch, a
second virtual switch, and a router, to implement the data center in FIG. 2. The processor
and the memory may be connected by using a bus.
[0130] The processor includes one or more general-purpose processors. The general-purpose
processor may be any type of device that can process an electronic instruction, and
includes a central processing unit (Central Processing Unit, CPU), a microprocessor,
a microcontroller, a main processor, a controller, an ASIC (Application Specific Integrated
Circuit, application-specific integrated circuit), and the like. The processor performs
various types of digital storage instructions, for example, software or firmware programs
stored in the memory 65, so that the processor can enable the data center to provide
various relatively wide services. For example, the processor can perform a program
or process data, to perform at least a part of the method discussed in this specification.
[0131] The memory may include a volatile memory (Volatile Memory), for example, a random
access memory (Random Access Memory, RAM); or the memory may include a non-volatile
memory (Non-Volatile Memory), for example, a read-only memory (Read-Only Memory, ROM),
a flash memory (Flash Memory), a hard disk drive (Hard Disk Drive, HDD), or a solid-state
drive (Solid-State Drive, SSD); or the memory may include a combination of the foregoing
types of memories. The memory may store a service program, configured to provide a
service for the data center.
[0132] For example, FIG. 7 shows a processor on a computing device in the data center to
run the control node, the to-be-migrated virtual machine, the new virtual machine,
the another virtual machine, the first virtual switch, the second virtual switch,
and the router. As shown in FIG. 7, the control node, the to-be-migrated virtual machine,
and the router are separately run on different computing devices. The new virtual
machine and the first virtual switch are run on one computing device, and the another
virtual machine and the second virtual switch are run on another computing device.
FIG. 7 is merely an example for description. The control node, the to-be-migrated
virtual machine, the new virtual machine, the another virtual machine, the first virtual
switch, the second virtual switch, and the router may be flexibly combined and deployed
on any computing device. This is not limited in this embodiment of the present invention.
[0133] An embodiment of the present invention further includes a control node 800, as shown
in FIG. 8. The control node 800 includes an interface unit 801, a network configuration
unit 802, and a virtual machine creation unit 803. The control node 800 is configured
to implement the method in S301 to S305 or S501 to S517.
[0134] The interface unit 801 is configured to obtain a virtual machine migration message,
where the virtual machine migration message includes location information of a first
virtual switch, and the first virtual switch is configured to connect to a new virtual
machine.
[0135] The network configuration unit 802 is configured to:
perform first network configuration on the first virtual switch based on the location
information that of the first virtual switch obtained by the interface unit 801, so
that the first virtual switch forwards, to the new virtual machine, a packet sent
by another virtual machine, where the another virtual machine has a communication
connection to the to-be-migrated virtual machine;
perform second network configuration on a second virtual switch, so that the second
virtual switch forwards, to the another virtual machine based on the second network
configuration, a packet sent by the new virtual machine, where the second virtual
switch is connected to the another virtual machine; and
perform third network configuration on a router, so that the router forwards, to the
new virtual machine based on the third network configuration, a packet sent by a cross-subnet
virtual machine, and forwards, to the cross-subnet virtual machine, a packet sent
by the new virtual machine, where the router is deployed in a virtual network in which
the to-be-migrated virtual machine is located, and the cross-subnet virtual machine
and the to-be-migrated virtual machine are located in different subnets.
[0136] The virtual machine creation unit 803 is configured to create the new virtual machine
after the network configuration unit 802 completes the first network configuration.
[0137] If the new virtual machine and the to-be-migrated virtual machine have a same internet
protocol IP address, and the network configuration unit 802 is further configured
to perform fourth network configuration on the second virtual switch, so that the
another virtual machine does not forward the sent packet to the to-be-migrated virtual
machine.
[0138] The control node 800 may be further configured to implement the methods in S401 to
S406 or S601 to S621.
[0139] Specifically, the interface unit 801 is configured to obtain a virtual machine migration
message, where the virtual machine migration message includes location information
of a first virtual switch, and the first virtual switch is configured to connect to
a new virtual machine.
[0140] The network configuration unit 802 is configured to:
perform fifth network configuration on the first virtual switch based on the location
information that of the first virtual switch obtained by the interface unit 801, so
that the first virtual switch forwards, to the new virtual machine based on the fifth
network configuration, a packet sent by another virtual machine, where the another
virtual machine has a communication connection to the to-be-migrated virtual machine;
perform sixth network configuration on a router, so that the router forwards, to a
cross-subnet virtual machine based on the sixth network configuration, a packet sent
by the new virtual machine, where the router is deployed in a virtual network in which
the to-be-migrated virtual machine is located, and the cross-subnet virtual machine
and the to-be-migrated virtual machine are located in different subnets;
perform seventh network configuration on a second virtual switch, so that the second
virtual switch forwards, to the another virtual machine based on the second network
configuration, a packet sent by the new virtual machine, where the second virtual
switch is connected to the another virtual machine; and
perform eighth network configuration on the router, so that the router forwards, to
the new virtual machine, a packet sent by the cross-subnet virtual machine.
[0141] The virtual machine creation unit 803 is configured to: create the new virtual machine
after the network configuration unit 802 completes the fifth network configuration
and the sixth network configuration.
[0142] If the new virtual machine and the to-be-migrated virtual machine have a same internet
protocol IP address, and the network configuration unit 802 is further configured
to perform fourth network configuration on the second virtual switch, so that the
another virtual machine does not forward the sent packet to the to-be-migrated virtual
machine.
[0143] Optionally, the network configuration unit may be a network control node of the data
center, for example, a Neutron Server node of an OpenStack platform. The virtual machine
creation unit may be a computing control node of the data center, for example, a Neutron
Compute node on an OpenStack platform.
[0144] In another embodiment of the present invention, the control node 800 may be a computing
device shown in FIG. 7, and a control node is run on the computing device. In this
case, the interface unit 801 may be a communications interface on the computing device,
and the processor on the computing device performs the computer program instruction
in the memory, to implement functions of the network configuration unit 802 and the
virtual machine creation unit 803.
[0145] In the several embodiments provided in the present invention, it should be understood
that the disclosed apparatus and method may be implemented in other manners. The units
described as separate parts may or may not be physically separate, and parts displayed
as units may or may not be physical units, that is, may be located in one position,
or may be distributed on a plurality of network units. Some or all of the units may
be selected based on actual requirements to achieve the objectives of the solutions
of the embodiments. In addition, function units in the embodiments of the present
invention may be integrated into one processing unit, or each of the units may exist
alone physically, or two or more units are integrated into one unit.
1. A virtual machine migration method, wherein the method comprises:
obtaining, by a control node, a virtual machine migration message, wherein the virtual
machine migration message comprises location information of a first virtual switch,
and the first virtual switch is configured to connect to a new virtual machine;
performing, by the control node, first network configuration on the first virtual
switch based on the location information of the first virtual switch;
creating, by the control node, the new virtual machine after performing the first
network configuration; and
performing, by the control node, second network configuration on a second virtual
switch, wherein the second virtual switch is connected to another virtual machine,
and the another virtual machine has a communication connection to a to-be-migrated
virtual machine.
2. The method according to claim 1, wherein the method further comprises:
forwarding, by the first virtual switch to the new virtual machine based on the first
network configuration, a packet sent by the another virtual machine; and
forwarding, by the second virtual switch to the another virtual machine based on the
second network configuration, a packet sent by the new virtual machine.
3. The method according to claim 1 or 2, wherein the method further comprises:
performing, by the control node, third network configuration on a router, wherein
the router is deployed in a virtual network in which the to-be-migrated virtual machine
is located; and
forwarding, by the router to the new virtual machine based on the third network configuration,
a packet sent by a cross-subnet virtual machine, and forwarding, to the cross-subnet
virtual machine, the packet sent by the new virtual machine, wherein the cross-subnet
virtual machine and the to-be-migrated virtual machine are located in different subnets.
4. The method according to any one of claims 1 to 3, wherein the new virtual machine
and the to-be-migrated virtual machine have a same internet protocol IP address, and
the method further comprises:
performing, by the control node, fourth network configuration on the second virtual
switch, so that the another virtual machine does not forward the sent packet to the
to-be-migrated virtual machine.
5. A virtual machine migration method, wherein the method comprises:
obtaining, by a control node, a virtual machine migration message, wherein the virtual
machine migration message comprises location information of a first virtual switch,
and the first virtual switch is connected to a new virtual machine;
performing, by the control node, fifth network configuration on the first virtual
switch based on the location information of the first virtual switch;
performing, by the control node, sixth network configuration on a router, wherein
the router is deployed in a virtual network in which a to-be-migrated virtual machine
is located;
creating, by the control node, the new virtual machine after performing the fifth
network configuration and the sixth network configuration;
forwarding, by the router to a cross-subnet virtual machine based on the sixth network
configuration, a packet sent by the new virtual machine, wherein the cross-subnet
virtual machine and the to-be-migrated virtual machine are located in different subnets;
performing, by the control node, seventh network configuration on a second virtual
switch, wherein the second virtual switch is connected to another virtual machine;
and
performing, by the control node, eighth network configuration on the router, so that
the router forwards, to the new virtual machine, a packet sent by the cross-subnet
virtual machine.
6. The method according to claim 5, wherein the method further comprises:
sending, by the first virtual switch to the new virtual machine based on the fifth
network configuration, a packet sent by the another virtual machine; and
sending, by the second virtual switch to the another virtual machine based on the
seventh network configuration, a packet sent by the new virtual machine.
7. A data center, wherein the data center comprises at least one computing device, and
each computing device comprises a processor and a memory; and the processor of the
at least one computing device is configured to run a control node, a to-be-migrated
virtual machine, a new virtual machine, another virtual machine, a first virtual switch,
and a second virtual switch, wherein the another virtual machine has a communication
connection to the to-be-migrated virtual machine, the first virtual switch is configured
to connect to the new virtual machine, and the second virtual switch is connected
to the another virtual machine; and
the control node is configured to:
obtain a virtual machine migration message, wherein the virtual machine migration
message comprises location information of the first virtual switch;
perform first network configuration on the first virtual switch based on the location
information of the first virtual switch;
create the new virtual machine after performing the first network configuration; and
perform second network configuration on the second virtual switch.
8. The data center according to claim 7, wherein
the first virtual switch is configured to forward, to the new virtual machine based
on the first network configuration, a packet sent by the another virtual machine;
and
the second virtual switch is configured to forward, to the another virtual machine
based on the second network configuration, a packet sent by the new virtual machine.
9. The data center according to claim 7 or 8, wherein the processor of the at least one
computing device is further configured to run a router and a cross-subnet virtual
machine, the router is deployed in a virtual network in which the to-be-migrated virtual
machine is located, and the cross-subnet virtual machine and the to-be-migrated virtual
machine are located in different subnets;
the control node is further configured to perform third network configuration on the
router; and
the router is configured to: forward, to the new virtual machine based on the third
network configuration, a packet sent by the cross-subnet virtual machine, and forward,
to the cross-subnet virtual machine, a packet sent by the new virtual machine.
10. The data center according to any one of claims 7 to 9, wherein the new virtual machine
and the to-be-migrated virtual machine have a same internet protocol IP address; and
the control node is further configured to perform fourth network configuration on
the second virtual switch, so that the another virtual machine does not forward the
sent packet to the to-be-migrated virtual machine.
11. A data center, wherein the data center comprises at least one computing device, and
each computing device comprises a processor and a memory; and the processor of the
at least one computing device is configured to run a control node, a to-be-migrated
virtual machine, a new virtual machine, another virtual machine, a cross-subnet virtual
machine, a first virtual switch, a second virtual switch, and a router, wherein the
another virtual machine has a communication connection to the to-be-migrated virtual
machine, the cross-subnet virtual machine and the to-be-migrated virtual machine are
located in different subnets, the first virtual switch is configured to connect to
the new virtual machine, the second virtual switch is connected to the another virtual
machine, and the router is deployed in a virtual network in which the to-be-migrated
virtual machine is located;
the control node is configured to:
obtain a virtual machine migration message, wherein the virtual machine migration
message comprises location information of the first virtual switch;
perform fifth network configuration on the first virtual switch based on the location
information of the first virtual switch;
perform sixth network configuration on the router;
create the new virtual machine after performing the fifth network configuration and
the sixth network configuration;
perform seventh network configuration on the second virtual switch; and
perform eighth network configuration on the router; and
the router is configured to:
forward, to the cross-subnet virtual machine based on the sixth network configuration,
a packet sent by the new virtual machine; and
forward, to the new virtual machine based on the eighth network configuration, a packet
sent by the cross-subnet virtual machine.
12. The data center according to claim 11, wherein
the first virtual switch is configured to send, to the new virtual machine based on
the fifth network configuration, a packet sent by the another virtual machine; and
the second virtual switch is configured to send, to the another virtual machine based
on the seventh network configuration, a packet sent by the new virtual machine.
13. A control node, wherein the control node is configured to migrate a to-be-migrated
virtual machine, and the control node comprises an interface unit, a network configuration
unit, and a virtual machine creation unit;
the interface unit is configured to obtain a virtual machine migration message, wherein
the virtual machine migration message comprises location information of a first virtual
switch, and the first virtual switch is configured to connect to a new virtual machine;
the network configuration unit is configured to:
perform first network configuration on the first virtual switch based on the location
information of the first virtual switch that is obtained by the interface unit, so
that the first virtual switch forwards, to the new virtual machine, a packet sent
by another virtual machine, wherein the another virtual machine has a communication
connection to the to-be-migrated virtual machine; and
perform second network configuration on a second virtual switch, so that the second
virtual switch forwards, to the another virtual machine based on the second network
configuration, a packet sent by the new virtual machine, wherein the second virtual
switch is connected to the another virtual machine; and
the virtual machine creation unit is configured to: create the new virtual machine
after the network configuration unit completes the first network configuration.
14. The control node according to claim 13, wherein the network configuration unit is
further configured to:
perform third network configuration on a router, so that the router forwards, to the
new virtual machine based on the third network configuration, a packet sent by a cross-subnet
virtual machine, and forwards, to the cross-subnet virtual machine, the packet sent
by the new virtual machine, wherein the router is deployed in a virtual network in
which the to-be-migrated virtual machine is located, and the cross-subnet virtual
machine and the to-be-migrated virtual machine are located in different subnets.
15. The control node according to claim 12 or 13, wherein the new virtual machine and
the to-be-migrated virtual machine have a same internet protocol IP address, and the
network configuration unit is further configured to:
perform fourth network configuration on the second virtual switch, so that the another
virtual machine does not forward the sent packet to the to-be-migrated virtual machine.
16. A control node, wherein the control node is configured to migrate a to-be-migrated
virtual machine, and the control node comprises an interface unit, a network configuration
unit, and a virtual machine creation unit;
the interface unit is configured to obtain a virtual machine migration message, wherein
the virtual machine migration message comprises location information of a first virtual
switch, and the first virtual switch is configured to connect to a new virtual machine;
the network configuration unit is configured to:
perform fifth network configuration on the first virtual switch based on the location
information of the first virtual switch that is obtained by the interface unit, so
that the first virtual switch forwards, to the new virtual machine based on the fifth
network configuration, a packet sent by another virtual machine, wherein the another
virtual machine has a communication connection to the to-be-migrated virtual machine;
perform sixth network configuration on a router, so that the router forwards, to a
cross-subnet virtual machine based on the sixth network configuration, a packet sent
by the new virtual machine, wherein the router is deployed in a virtual network in
which the to-be-migrated virtual machine is located, and the cross-subnet virtual
machine and the to-be-migrated virtual machine are located in different subnets;
perform seventh network configuration on a second virtual switch, so that the second
virtual switch forwards, to the another virtual machine based on the second network
configuration, a packet sent by the new virtual machine, wherein the second virtual
switch is connected to the another virtual machine; and
perform eighth network configuration on the router, so that the router forwards, to
the new virtual machine, a packet sent by the cross-subnet virtual machine; and
the virtual machine creation unit is configured to create the new virtual machine
after the network configuration unit completes the fifth network configuration and
the sixth network configuration.