virt-xml (1)
Leading comments
Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) Standard preamble: ========================================================================
NAME
virt-xml - Edit libvirt XML using command line options.SYNOPSIS
virt-xmlDESCRIPTION
virt-xml is a command line tool for editing libvirtEach virt-xml invocation requires 3 things: name of an existing domain to alter (or
--add-device: Append a new device definition to the
An
virt-xml only allows one action and
OPTIONS
- -c URI
- --connect=URI
- Connect to a non-default hypervisor. See virt-install(1) for details
- domain
-
domain is the name, UUID,orIDof the existingVM.This can be omitted if using --build-xml, or ifXMLis passed on stdin.
When a domain is specified, the default output action is --define, even if the
VMis running. To update the runningVMconfiguration, add the --update option (but not all options/devices support updating the runningVMconfiguration).If
XMLis passed on stdin, the default output is --print-xml.
XML ACTIONS
- --edit [EDIT-OPTIONS]
-
Edit the specified XMLblock. EDIT-OPTIONS tell virt-xml which block to edit. The type ofXMLthat we are editing is decided byXMLoption that is passed to virt-xml. So if --disk is passed, EDIT-OPTIONS select which <disk> block to edit.
Certain
XMLoptions only ever map to a singleXMLblock, like --cpu, --security, --boot, --clock, and a few others. In those cases, virt-xml will not complain if a correspondingXMLblock does not already exist, it will create it for you.Most
XMLoptions support a special value 'clearxml=yes'. When combined with --edit, it will completely blank out theXMLblock being edited before applying the requested changes. This allows completely rebuilding anXMLblock. SeeEXAMPLESfor some usage.EDIT-OPTIONS examples:
-
- --edit
-
--edit without any options implies 'edit the first block'. So '--edit --disk DISK-OPTIONS' means 'edit the first <disk>'.
For the single
XMLblock options mentioned above, plain '--edit' without any options is what you always want to use. - --edit #
-
Select the specified XMLblock number. So '--edit 2 --diskDISK-OPTS' means 'edit the second <disk>'. This option only really applies for deviceXML.
- --edit all
-
Modify every XMLblock of theXMLoption type. So '--edit all --diskDISK-OPTS' means 'edit ever <disk> block'. This option only really applies for deviceXML.
- --edit DEVICE-OPTIONS
-
Modify every XMLblock that matches the passed device options. The device options are in the same format as would be passed to theXMLoption.
So '--edit path=/tmp/foo --disk
DISK-OPTS' means 'edit every <disk> with path /tmp/foo'. This option only really applies for deviceXML.
-
- --add-device
-
Append the specified XMLoptions to theXML<devices> list. Example: '--add-device --diskDISK-OPTIONS' will create a new <disk> block and add it to theXML.
This option will error if specified with a non-device
XMLoption (see --edit section for a partial list). - --remove-device
-
Remove the specified device from the XML.The device to remove is chosen by theXMLoption, which takes arguments in the same format as --edit. Examples
-
- --remove-device --disk 2
- Remove the second disk device
- --remove-device --network all
- Remove all network devices
- --remove-device --sound pcspk
- Remove all sound devices with model='pcspk'
-
This option will error if specified with a non-device
XMLoption (see --edit section for a partial list).
-
- --build-xml
-
Just build the specified XML,and print it to stdout. No input domain or inputXMLis required. Example: '--build-xml --diskDISK-OPTIONS' will just print the new <disk> device.
This option will error if specified with an
XMLoption that does not map cleanly to a specificXMLblock, like --vcpus or --memory.
OUTPUT OPTIONS
These options decide what action to take after altering the- --update
-
If the specified domain is running, attempt to alter the running VMconfiguration. If combined with --edit, this is an update operation. If combined with --add-device, this is a device hotplug. If combined with --remove-device, this is a device hotunplug.
Keep in mind, most
XMLproperties and devices do not support live update operations, so don't expect it to succeed in all cases. - --define
-
Define the requested XMLchange. This is typically the default if no output option is specified, but if a --print option is specified, --define is required to force the change.
- --print-diff
-
Print the generated XMLchange in unified diff format. If only this output option is specified, all other output options are disabled and no persistent change is made.
- --print-xml
-
Print the generated XMLin its entirety. If only this output option is specified, all other output options are disabled and no persistent change is made.
- --confirm
-
Before defining or updating the domain, show the generated XMLdiff and interactively request confirmation.
XML OPTIONS
- --disk
- --network
- --graphics
- --metadata
- --memory
- --vcpus
- --cpu
- --security
- --numatune
- --features
- --clock
- --pm
- --boot
- --filesystem
- --controller
- --input
- --serial
- --parallel
- --channel
- --console
- --hostdev
- --sound
- --watchdog
- --video
- --smartcard
- --redirdev
- --memballoon
- --tpm
- --rng
- --panic
-
These options alter the XMLfor a single class ofXMLelements. More complete documentation is found in virt-install(1).
Generally these options map pretty straightforwardly to the libvirt
XML,documented at <libvirt.org/formatdomain.html>Option strings are in the format of: --option opt=val,opt2=val2,... example: --disk path=/tmp/foo,shareable=on. Properties can be used with '--option opt=,', so to clear a disks cache setting you could use '--disk cache=,'
For any option, use --option=? to see a list of all available sub options, example: --disk=? or --boot=?
--help output also lists a few general examples. See the
EXAMPLESsection below for some common examples.
MISCELLANEOUS OPTIONS
- -h
- --help
- Show the help message and exit
- --version
- Show program's version number and exit
- -q
- --quiet
- Avoid verbose output.
- -d
- --debug
- Print debugging information
EXAMPLES
See a list of all suboptions that --disk and --network take
# virt-xml --disk=? --network=?
Change the <description> of domain '
# virt-xml EXAMPLE --edit --metadata description="my new description"
# Enable the boot device menu for domain '
# virt-xml EXAMPLE --edit --boot menu=on
Clear the previous <cpu> definition of domain 'winxp', change it to 'host-model', but interactively confirm the diff before saving:
# virt-xml winxp --edit --cpu host-model,clearxml=yes --confirm
Change the second sound card to model=ich6 on 'fedora19', but only output the diff:
# virt-xml fedora19 --edit 2 --sound model=ich6 --print-diff
Update the every graphics device password to 'foo' of the running
# virt-xml rhel6 --edit all --graphics password=foo --update
Remove the disk path from disk device hdc:
# virt-xml rhel6 --edit target=hdc --disk path=
Change all disk devices of type 'disk' to use cache=none, using
# cat <xmlfile> | virt-xml --edit device=disk --disk cache=none
Change disk 'hda'
# virt-xml fedora20 --edit target=hda \ --disk io=native,startup_policy=optional
Change all host devices to use driver_name=vfio for
# virt-xml --connect qemu+ssh://remotehost/system \ fedora20 --edit all --hostdev driver_name=vfio
Hotplug host
# virt-xml fedora19 --update --add-device --hostdev 001.003
Add a spicevmc channel to the domain 'winxp', that will be available after the next
# virt-xml winxp --add-device --channel spicevmc
Create a 10G qcow2 disk image and attach it to 'fedora18' for the next
# virt-xml fedora18 --add-device \ --disk /var/lib/libvirt/images/newimage.qcow2,format=qcow2,size=10
Hotunplug the disk vdb from the running domain 'rhel7':
# virt-xml rhel7 --update --remove-device --disk target=vdb
Remove all graphics devices from the
# virt-xml rhel7 --remove-device --graphics all
Generate
# virt-xml --build-xml --console pty,target_type=virtio