14.15. Migrating Guest Virtual Machines with virsh
14.15.1. Interface Commands
<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
ifaceoption 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).
184.108.40.206. Defining and starting a host physical machine interface via an XML file
virsh iface-define filecommand 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
iface-start interface, where interface is the interface name.
220.127.116.11. Editing the XML configuration file for the host interface
iface-edit interfaceedits 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.)
18.104.22.168. Listing active host interfaces
iface-listdisplays a list of active host interfaces. If
--allis specified, this list will also include interfaces that are defined but are inactive. If
--inactiveis specified only the inactive interfaces will be listed.
22.214.171.124. Converting a MAC address into an interface name
iface-name interfacecommand 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.
iface-mac interfacecommand will convert a host's interface name to MAC address where in this case interface, is the interface name.
126.96.36.199. Stopping a specific host physical machine interface
virsh iface-destroy interfacecommand destroys (stops) a given host interface, which is the same as running
if-downon the host. This command will disable that interface from active use and takes effect immediately.
iface-undefine interfacecommand along with the interface name.
188.8.131.52. Displaying the host configuration file
virsh iface-dumpxml interfacedisplays the host interface information as an XML dump to stdout. If the
--inactiveoption is specified, then the output reflects the persistent state of the interface that will be used the next time it is started.
184.108.40.206. Creating bridge devices
iface-bridgecreates 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
220.127.116.11. Tearing down a bridge device
iface-unbridge bridgecommand 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-startoption is used, but keep in mind not restarting is generally not recommended. Refer to Section 18.104.22.168, “Creating bridge devices” for the command to use to create a bridge.
22.214.171.124. Manipulating interface snapshots
iface-begincommand 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.
iface-commitcommand to declare all changes made since the last
iface-beginas working, and then delete the rollback point. If no interface snapshot has already been started via
iface-begin, then this command will fail.
iface-rollbackto revert all host interface settings back to the state that recorded the last time the
iface-begincommand was executed. If
iface-begincommand had not been previously executed, then
iface-rollbackwill fail. Note that rebooting the host physical machine also serves as an implicit rollback point.