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

Solution Verified - Updated -

Issue

Issue

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

Environment

  • Red Hat Enterprise Linux 5
  • KVM

Resolution

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
  <name>rhel5u4</name>
  <uuid>635b059b-e352-8eab-f246-1773410b8599</uuid>
  <memory>524288</memory>
  <currentMemory>524288</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='block' device='disk'>
      <source dev='/dev/vgdata/rhel5'/>
      <target dev='hda' bus='ide'/>
    </disk>
    <interface type='network'>
      <mac address='54:52:00:23:d7:36'/>
      <source network='default'/>
      <target dev='vnet3'/> ← Here
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/7'/>
      <target port='0'/>
    </serial>
    <console type='pty' tty='/dev/pts/7'>
      <source path='/dev/pts/7'/>
      <target port='0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5902' autoport='yes' keymap='en-us'/> ← Here
  </devices>
</domain>

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