Search

20.18. Converting QEMU Arguments to Domain XML

download PDF
The virsh domxml-from-native command provides a way to convert an existing set of QEMU arguments into a Domain XML configuration file that can then be used by libvirt. Note that this command is intended to be used only to convert existing QEMU guests previously started from the command line, in order to enable them to be managed through libvirt. Therefore, the method described here should not be used to create new guests from scratch. New guests should be created using either virsh, virt-install, or virt-manager. Additional information can be found on the libvirt upstream website.

Procedure 20.3. How to convert a QEMU guest to libvirt

  1. Start with a QEMU guest with a arguments file (file type *.args), named demo.args in this example:
    $ cat demo.args
    LC_ALL=C
    PATH=/bin
    HOME=/home/test
    USER=test
    LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
    
  2. To convert this file into a domain XML file so that the guest can be managed by libvirt, enter the following command. Remember to replace qemu-guest1 with the name of your guest virtual machine and demo.args with the filename of your QEMU args file.
    # virsh domxml-from-native qemu-guest1 demo.args
    This command turns the demo.args file into the following domain XML file:
    
    <domain type='qemu'>
      <uuid>00000000-0000-0000-0000-000000000000</uuid>
      <memory>219136</memory>
      <currentMemory>219136</currentMemory>
      <vcpu>1</vcpu>
      <os>
        <type arch='i686' machine='pc'>hvm</type>
        <boot dev='hd'/>
      </os>
      <clock offset='utc'/>
      <on_poweroff>destroy</on_poweroff>
      <on_reboot>restart</on_reboot>
      <on_crash>destroy</on_crash>
      <devices>
        <emulator>/usr/bin/qemu</emulator>
        <disk type='block' device='disk'>
          <source dev='/dev/HostVG/QEMUGuest1'/>
          <target dev='hda' bus='ide'/>
        </disk>
      </devices>
    </domain>

    Figure 20.1. Guest virtual machine new configuration file

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.