How to get the virtual machine's runtime xml configuration in KVM ?

Solution Verified - Updated -



I attached a flash disk by command virsh attach-disk rhel5 /dev/sdc sdb , how to save this configuation ?


  • Red Hat Enterprise Linux 5
  • KVM


Execute command

# virsh dumpxml <YourVirtualMachineName>

and redirect the output to /etc/libvirt/qemu/ with a filename end of .xml ,then edit the xml file and

1 delete the "id" attribute of element "domain" .

2 delete the "target" element under "interface" element .

3 replace value of "port" attribute to -1 of "graphics" element .

after that backup your old configuation and replace it with new configuation .

For example:

# virsh dumpxml rhel5
<domain type='kvm' id='24'> ← Here
    <type arch='x86_64' machine='pc'>hvm</type>
    <boot dev='hd'/>
  <clock offset='utc'/>
    <disk type='block' device='disk'>
      <source dev='/dev/vgdata/rhel5'/>
      <target dev='hda' bus='ide'/>
    <interface type='network'>
      <mac address='54:52:00:23:d7:36'/>
      <source network='default'/>
      <target dev='vnet3'/> ← Here
    <serial type='pty'>
      <source path='/dev/pts/7'/>
      <target port='0'/>
    <console type='pty' tty='/dev/pts/7'>
      <source path='/dev/pts/7'/>
      <target port='0'/>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5902' autoport='yes' keymap='en-us'/> ← Here

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content