14.15. Migrating Guest Virtual Machines with virsh


Information on migration using virsh is located in the section entitled Live KVM Migration with virsh Refer to Section 4.4, “Live KVM Migration with virsh”

14.15.1. Interface Commands

The following commands manipulate host interfaces and as such should not be run from the guest virtual machine. These commands should be run from a terminal on the host physical machine.

Warning

The commands in this section are only supported if the machine has the NetworkManager service disabled, and is using the network service instead.
Often, these host interfaces can then be used by name within domain <interface> elements (such as a system-created bridge interface), but there is no requirement that host interfaces be tied to any particular guest configuration XML at all. Many of the commands for host interfaces are similar to the ones used for domains, and the way to name an interface is either by its name or its MAC address. However, using a MAC address for an iface option only works when that address is unique (if an interface and a bridge share the same MAC address, which is often the case, then using that MAC address results in an error due to ambiguity, and you must resort to a name instead).

14.15.1.1. Defining and starting a host physical machine interface via an XML file

The virsh iface-define file command define a host interface from an XML file. This command will only define the interface and will not start it.
virsh iface-define iface.xml
To start an interface which has already been defined, run iface-start interface, where interface is the interface name.

14.15.1.2. Editing the XML configuration file for the host interface

The command iface-edit interface edits the XML configuration file for a host interface. This is the only recommended way to edit the XML configuration file. (Refer to Chapter 20, Manipulating the Domain XML for more information about these files.)

14.15.1.3. Listing active host interfaces

The iface-list --inactive --all displays a list of active host interfaces. If --all is specified, this list will also include interfaces that are defined but are inactive. If --inactive is specified only the inactive interfaces will be listed.

14.15.1.4. Converting a MAC address into an interface name

The iface-name interface command converts a host interface MAC to an interface name, provided the MAC address is unique among the host’s interfaces. This command requires interface which is the interface's MAC address.
The iface-mac interface command will convert a host's interface name to MAC address where in this case interface, is the interface name.

14.15.1.5. Stopping a specific host physical machine interface

The virsh iface-destroy interface command destroys (stops) a given host interface, which is the same as running if-down on the host. This command will disable that interface from active use and takes effect immediately.
To undefine the interface, use the iface-undefine interface command along with the interface name.

14.15.1.6. Displaying the host configuration file

virsh iface-dumpxml interface --inactive displays the host interface information as an XML dump to stdout. If the --inactive option is specified, then the output reflects the persistent state of the interface that will be used the next time it is started.

14.15.1.7. Creating bridge devices

The iface-bridge creates a bridge device named bridge, and attaches the existing network device interface to the new bridge, which starts working immediately, with STP enabled and a delay of 0.
# virsh iface-bridge interface bridge --no-stp delay --no-start
Note that these settings can be altered with --no-stp, --no-start, and an integer number of seconds for delay. All IP address configuration of interface will be moved to the new bridge device. Refer to Section 14.15.1.8, “Tearing down a bridge device” for information on tearing down the bridge.

14.15.1.8. Tearing down a bridge device

The iface-unbridge bridge --no-start command tears down a specified bridge device named bridge, releases its underlying interface back to normal usage, and moves all IP address configuration from the bridge device to the underlying device. The underlying interface is restarted unless --no-start option is used, but keep in mind not restarting is generally not recommended. Refer to Section 14.15.1.7, “Creating bridge devices” for the command to use to create a bridge.

14.15.1.9. Manipulating interface snapshots

The iface-begin command creates a snapshot of current host interface settings, which can later be committed (with iface-commit) or restored (iface-rollback). If a snapshot already exists, then this command will fail until the previous snapshot has been committed or restored. Undefined behavior will result if any external changes are made to host interfaces outside of the libvirt API between the time of the creation of a snapshot and its eventual commit or rollback.
Use the iface-commit command to declare all changes made since the last iface-begin as working, and then delete the rollback point. If no interface snapshot has already been started via iface-begin, then this command will fail.
Use the iface-rollback to revert all host interface settings back to the state that recorded the last time the iface-begin command was executed. If iface-begin command had not been previously executed, then iface-rollback will fail. Note that rebooting the host physical machine also serves as an implicit rollback point.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.