Installation guide

Chapter 30. Managing guests with virsh
260
This command outputs the guest's XML configuration file to standard out (stdout). You can save the
data by piping the output to a file. An example of piping the output to a file called guest.xml:
# virsh dumpxml GuestID > guest.xml
This file guest.xml can recreate the guest (refer to Editing a guest's configuration file. You can edit
this XML configuration file to configure additional devices or to deploy additional guests. Refer to
Section 33.1, “Using XML configuration files with virsh” for more information on modifying files created
with virsh dumpxml.
An example of virsh dumpxml output:
# virsh dumpxml r5b2-mySQL01
<domain type='kvm' id='13'>
<name>r5b2-mySQL01</name>
<uuid>4a4c59a7ee3fc78196e4288f2862f011</uuid>
<bootloader>/usr/bin/pygrub</bootloader>
<os>
<type>linux</type>
<kernel>/var/lib/libvirt/vmlinuz.2dgnU_</kernel>
<initrd>/var/lib/libvirt/initrd.UQafMw</initrd>
<cmdline>ro root=/dev/VolGroup00/LogVol00 rhgb quiet</cmdline>
</os>
<memory>512000</memory>
<vcpu>1</vcpu>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<interface type='bridge'>
<source bridge='br0'/>
<mac address='00:16:3e:49:1d:11'/>
<script path='bridge'/>
</interface>
<graphics type='vnc' port='5900'/>
<console tty='/dev/pts/4'/>
</devices>
</domain>
Creating a guest from a configuration file
Guests can be created from XML configuration files. You can copy existing XML from previously
created guests or use the dumpxml option (refer to Creating a virtual machine XML dump
(configuration file)). To create a guest with virsh from an XML file:
# virsh create configuration_file.xml
Editing a guest's configuration file
Instead of using the dumpxml option (refer to Creating a virtual machine XML dump (configuration
file)) guests can be edited either while they run or while they are offline. The virsh edit command
provides this functionality. For example, to edit the guest named softwaretesting:
# virsh edit softwaretesting
This opens a text editor. The default text editor is the $EDITOR shell parameter (set to vi by default).