virt-xml
Create or modify virtual machine definitions
TLDR
List all the suboptions for a specific option
List all the suboptions for disk, network, and boot
Edit a value for a specific domain
Change the description for a specific domain
Enable/Disable the boot device menu for a specific domain
Attach host USB hub to a running VM (See: tldr lsusb)
SYNOPSIS
virt-xml
PARAMETERS
The name or UUID of the virtual machine domain to be modified. If used with --create it becomes name of the new domain.
--edit
Edit the domain XML in an editor.
--update
Update the domain XML in place.
--create
Create a new domain XML file.
--define
Define (register) the domain with libvirt using the generated XML.
--template
Use a template file as a base for the XML configuration.
--disk
Configure disk devices with specified options (e.g., `--disk path=/path/to/disk,device=disk,bus=virtio`).
--network
Configure network interfaces with specified options (e.g., `--network bridge=virbr0,model=virtio`).
--memory
Configure memory settings (e.g., `--memory 2048`).
--vcpus
Configure virtual CPU settings (e.g., `--vcpus 2`).
--console
Configure the console device (e.g., `--console pty,target_type=serial`).
--graphics
Configure the graphical display (e.g., `--graphics vnc,listen=0.0.0.0`).
--video
Configure the video card (e.g., `--video model=qxl`).
--input
Configure an input device (e.g., `--input type=tablet,bus=usb`).
--serial
Configure a serial port (e.g., `--serial pty`).
--parallel
Configure a parallel port (e.g., `--parallel pty`).
--sound
Configure a sound device (e.g., `--sound model=ich9`).
--watchdog
Configure a watchdog device (e.g., `--watchdog model=i6300esb,action=reset`).
--balloon
Configure a memory balloon device (e.g., `--balloon`).
--filesystem
Configure a filesystem device (e.g., `--filesystem type=mount,accessmode=passthrough,source=/path/to/share,target=/guest/mount/point`).
--channel
Configure a channel device (e.g., `--channel unix,mode=source,source_path=/path/to/socket,target_name=org.qemu.guest_agent.0`).
--panic
Configure a panic device (e.g., `--panic model=i6300esb`).
--clock
Configure clock settings (e.g., `--clock offset=utc`).
--features
Configure CPU features (e.g., `--features acpi`).
--cpu
Configure CPU settings (e.g., `--cpu host-passthrough`).
--metadata
Configure domain metadata (e.g., `--metadata coreos.ignition.config.data=`).
--seclabel
Configure security labeling (e.g., `--seclabel type=dynamic`).
--devices
Add custom device XML elements (e.g., `--devices '
--rng
Configure Random Number Generator device (e.g., `--rng model=virtio,backend=/dev/urandom`).
--tpm
Configure Trusted Platform Module device (e.g., `--tpm model=tpm-crb,backend=/dev/tpm0`).
--pm
Configure Power Management (e.g., `--pm suspend_to_mem=enable,suspend_to_disk=enable`).
--boot
Configure boot options (e.g., `--boot dev=cdrom`).
--os
Configure operating system options (e.g., `--os type=hvm,machine=pc-i440fx-rhel7.0`).
--loader
Configure the bootloader path (e.g., `--loader /usr/lib/efi/OVMF.fd`).
--nvram
Configure the NVRAM path (e.g., `--nvram /path/to/nvram`).
--resource
Configure domain resource partitions (e.g., `--resource memory=4096MiB`).
--memorybacking
Configure memory backing options (e.g., `--memorybacking lock=on`).
--numad
Configure NUMA settings (e.g., `--numad placement=auto`).
--iommu
Configure IOMMU settings (e.g., `--iommu driver=intel`).
--qemu-commandline
Pass options directly to QEMU (e.g., `--qemu-commandline '-cpu host,kvm=off'`).
--replace
Replace an existing element.
--confirm
Prompt for confirmation before applying changes.
--quiet
Suppress non-error output.
--verbose
Enable verbose output.
--help
Display help message.
--version
Display version information.
DESCRIPTION
The `virt-xml` command is a command-line utility that allows users to modify and create XML configuration files for libvirt virtual machines. It provides a flexible way to manage virtual machine settings without directly editing the XML files themselves. This tool uses command-line options to perform various actions such as adding, removing, or modifying virtual hardware, configuring networking, and adjusting storage settings. `virt-xml` can be used to both create new XML configurations from scratch, and it can also modify existing configurations in place. This functionality is useful for automating virtual machine deployment and management tasks.
The tool uses the libvirt API for accessing the current domain configurations. `virt-xml` can safely handle most scenarios in both domain creation and modifications. For more complex modifications, however, it may be beneficial to manually edit the XML domain files using the virsh edit command.
EXAMPLES
Example Usage:
Create a new VM configuration:
`virt-xml newvm --memory 2048 --vcpus 2 --disk path=/path/to/disk.img,size=20,format=qcow2`
Modify an existing VM to add a network interface:
`virt-xml existingvm --network bridge=virbr0`
Modify an existing VM to remove a disk:
`virt-xml existingvm --disk path=/path/to/remove.img,remove=yes`
SEE ALSO
virsh(1)