virt-manager/man/virt-xml.pod

401 lines
12 KiB
Plaintext
Raw Normal View History

=pod
=head1 NAME
2014-01-27 01:25:18 +08:00
virt-xml - Edit libvirt XML using command line options.
=head1 SYNOPSIS
2014-01-27 01:25:18 +08:00
B<virt-xml> DOMAIN XML-ACTION XML-OPTION [OUTPUT-OPTION] [MISC-OPTIONS] ...
=head1 DESCRIPTION
2014-01-27 01:25:18 +08:00
B<virt-xml> is a command line tool for editing libvirt XML using explicit command line options. See the EXAMPLES section at the end of this document to jump right in.
Each B<virt-xml> invocation requires 3 things: name of an existing domain to alter (or XML passed on stdin), an action to on the XML, and an XML change to make. actions are one of:
--add-device: Append a new device definition to the XML
--remove-device: Remove an existing device definition
--edit: Edit an existing XML block
--build-xml: Just build the requested XML block and print it (no domain or input XML are required here).
An XML change is one instance of any of the XML options provided by virt-xml, for example --disk or --boot.
B<virt-xml> only allows one action and XML pair per invocation. If you need to make multiple edits, invoke the command multiple times.
=head1 OPTIONS
=over 4
2015-04-05 05:43:28 +08:00
=item B<-c> URI
2015-04-05 05:43:28 +08:00
=item B<--connect>=URI
2014-01-27 01:25:18 +08:00
Connect to a non-default hypervisor. See L<virt-install(1)> for details
2015-04-05 05:43:28 +08:00
=item B<domain>
2014-01-27 01:25:18 +08:00
domain is the name, UUID, or ID of the existing VM. This can be omitted if
using --build-xml, or if XML is passed on stdin.
When a domain is specified, the default output action is --define, even if the VM is running. To update the running VM configuration, add the --update option (but not all options/devices support updating the running VM configuration).
If XML is passed on stdin, the default output is --print-xml.
=back
2015-04-05 05:43:28 +08:00
=head1 XML ACTIONS
=over 4
=item B<--edit> [EDIT-OPTIONS]
2014-01-27 01:25:18 +08:00
Edit the specified XML block. EDIT-OPTIONS tell B<virt-xml> which block to edit. The type of XML that we are editing is decided by XML option that is passed to B<virt-xml>. So if --disk is passed, EDIT-OPTIONS select which <disk> block to edit.
2014-01-27 01:25:18 +08:00
Certain XML options only ever map to a single XML block, like --cpu, --security, --boot, --clock, and a few others. In those cases, B<virt-xml> will not complain if a corresponding XML block does not already exist, it will create it for you.
Most XML options support a special value 'clearxml=yes'. When combined with --edit, it will completely blank out the XML block being edited before applying the requested changes. This allows completely rebuilding an XML block. See EXAMPLES for some usage.
2014-01-27 01:25:18 +08:00
EDIT-OPTIONS examples:
=over 4
2015-04-05 05:43:28 +08:00
=item B<--edit>
2014-01-27 01:25:18 +08:00
--edit without any options implies 'edit the first block'. So '--edit --disk DISK-OPTIONS' means 'edit the first <disk>'.
For the single XML block options mentioned above, plain '--edit' without any options is what you always want to use.
2015-04-05 05:43:28 +08:00
=item B<--edit> #
2014-01-27 01:25:18 +08:00
Select the specified XML block number. So '--edit 2 --disk DISK-OPTS' means 'edit the second <disk>'. This option only really applies for device XML.
2015-04-05 05:43:28 +08:00
=item B<--edit> all
2014-01-27 01:25:18 +08:00
Modify every XML block of the XML option type. So '--edit all --disk DISK-OPTS' means 'edit ever <disk> block'. This option only really applies for device XML.
2015-04-05 05:43:28 +08:00
=item B<--edit> DEVICE-OPTIONS
2014-01-27 01:25:18 +08:00
Modify every XML block that matches the passed device options. The device options are in the same format as would be passed to the XML option.
So '--edit path=/tmp/foo --disk DISK-OPTS' means 'edit every <disk> with path /tmp/foo'. This option only really applies for device XML.
=back
2015-04-05 05:43:28 +08:00
=item B<--add-device>
2014-01-27 01:25:18 +08:00
Append the specified XML options to the XML <devices> list. Example: '--add-device --disk DISK-OPTIONS' will create a new <disk> block and add it to the XML.
This option will error if specified with a non-device XML option (see --edit section for a partial list).
2015-04-05 05:43:28 +08:00
=item B<--remove-device>
2014-01-27 01:25:18 +08:00
Remove the specified device from the XML. The device to remove is chosen by the XML option, which takes arguments in the same format as --edit. Examples
=over 4
2015-04-05 05:43:28 +08:00
=item B<--remove-device> --disk 2
2014-01-27 01:25:18 +08:00
Remove the second disk device
2015-04-05 05:43:28 +08:00
=item B<--remove-device> --network all
2014-01-27 01:25:18 +08:00
Remove all network devices
2015-04-05 05:43:28 +08:00
=item B<--remove-device> --sound pcspk
2014-01-27 01:25:18 +08:00
Remove all sound devices with model='pcspk'
=back
This option will error if specified with a non-device XML option (see --edit section for a partial list).
2015-04-05 05:43:28 +08:00
=item B<--build-xml>
2014-01-27 01:25:18 +08:00
Just build the specified XML, and print it to stdout. No input domain or input XML is required. Example: '--build-xml --disk DISK-OPTIONS' will just print the new <disk> device.
This option will error if specified with an XML option that does not map cleanly to a specific XML block, like --vcpus or --memory.
=back
2015-04-05 05:43:28 +08:00
=head1 OUTPUT OPTIONS
2014-01-27 01:25:18 +08:00
These options decide what action to take after altering the XML. In the common case these do not need to be specified, as 'XML actions' will imply a default output action, described in detail above. These are only needed if you want to modify the default output.
2015-04-05 05:43:28 +08:00
=over 4
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--update>
2014-01-27 01:25:18 +08:00
If the specified domain is running, attempt to alter the running VM configuration. 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 XML properties and devices do not support live update operations, so don't expect it to succeed in all cases.
Note that --update implies --define: it can't be used in isolation.
2015-04-05 05:43:28 +08:00
=item B<--define>
2014-01-27 01:25:18 +08:00
Define the requested XML change. 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.
2015-04-05 05:43:28 +08:00
=item B<--print-diff>
2014-01-27 01:25:18 +08:00
Print the generated XML change in unified diff format. If only this output option is specified, all other output options are disabled and no persistent change is made.
2015-04-05 05:43:28 +08:00
=item B<--print-xml>
2014-01-27 01:25:18 +08:00
Print the generated XML in its entirety. If only this output option is specified, all other output options are disabled and no persistent change is made.
2015-04-05 05:43:28 +08:00
=item B<--confirm>
2014-01-27 01:25:18 +08:00
Before defining or updating the domain, show the generated XML diff and interactively request confirmation.
=back
2014-01-27 01:25:18 +08:00
=head1 GUEST OS OPTIONS
=over 4
=item B<--os-variant> OS_VARIANT
Optimize the guest configuration for a specific operating system (ex.
'fedora29', 'rhel7', 'win10'). While not required, specifying this
options is HIGHLY RECOMMENDED, as it can greatly increase performance
by specifying virtio among other guest tweaks.
If the guest has been installed using virt-manager version 2.0.0 or newer,
providing this information should not be necessary, as the OS variant will
have been stored in the guest configuration during installation and virt-xml
will retrieve it from there automatically.
Use the command "osinfo-query os" to get the list of the accepted OS
variants.
=back
2015-04-05 05:43:28 +08:00
=head1 XML OPTIONS
2015-04-05 05:43:28 +08:00
=over 4
2015-04-05 05:43:28 +08:00
=item B<--disk>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--network>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--graphics>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--metadata>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--memory>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--vcpus>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--cpu>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--security>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--numatune>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--features>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--clock>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--pm>
2014-02-03 05:12:29 +08:00
2015-04-05 05:43:28 +08:00
=item B<--boot>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--filesystem>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--controller>
2014-01-27 01:25:18 +08:00
=item B<--input>
2015-04-05 05:43:28 +08:00
=item B<--serial>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--parallel>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--channel>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--console>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--hostdev>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--sound>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--watchdog>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--video>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--smartcard>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--redirdev>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--memballoon>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--tpm>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--rng>
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=item B<--panic>
2014-01-27 01:25:18 +08:00
=item B<--memdev>
=item B<--qemu-commandline>
2014-01-27 01:25:18 +08:00
These options alter the XML for a single class of XML elements. More complete documentation is found in L<virt-install(1)>.
Generally these options map pretty straightforwardly to the libvirt XML, documented at L<https://libvirt.org/formatdomain.html>
2014-01-27 01:25:18 +08:00
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=,'
2014-01-27 01:25:18 +08:00
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 EXAMPLES section below for some common examples.
=back
2014-01-27 01:25:18 +08:00
2015-04-05 05:43:28 +08:00
=head1 MISCELLANEOUS OPTIONS
2015-04-05 05:43:28 +08:00
=over 4
=item B<-h>
=item B<--help>
Show the help message and exit
2015-04-05 05:43:28 +08:00
=item B<--version>
Show program's version number and exit
=item B<-q>
=item B<--quiet>
Avoid verbose output.
2015-04-05 05:43:28 +08:00
=item B<-d>
=item B<--debug>
Print debugging information
2014-01-27 01:25:18 +08:00
=back
=head1 EXAMPLES
2014-01-27 01:25:18 +08:00
See a list of all suboptions that --disk and --network take
# virt-xml --disk=? --network=?
Change the <description> of domain 'EXAMPLE':
2014-01-27 01:25:18 +08:00
# virt-xml EXAMPLE --edit --metadata description="my new description"
2014-01-27 01:25:18 +08:00
# Enable the boot device menu for domain 'EXAMPLE':
2014-01-27 01:25:18 +08:00
# virt-xml EXAMPLE --edit --boot menu=on
2014-01-27 01:25:18 +08:00
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
2014-01-28 00:12:28 +08:00
Change the second sound card to model=ich6 on 'fedora19', but only output the diff:
2014-01-27 01:25:18 +08:00
# virt-xml fedora19 --edit 2 --sound model=ich6 --print-diff
2014-01-27 01:25:18 +08:00
2014-01-28 00:12:28 +08:00
Update the every graphics device password to 'foo' of the running VM 'rhel6':
2014-01-27 01:25:18 +08:00
2014-01-28 00:12:28 +08:00
# virt-xml rhel6 --edit all --graphics password=foo --update
2014-01-27 01:25:18 +08:00
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 XML from stdin, printing the new XML to stdout.
# cat <xmlfile> | virt-xml --edit device=disk --disk cache=none
Change disk 'hda' IO to native and use startup policy as 'optional'.
# virt-xml fedora20 --edit target=hda \
--disk io=native,startup_policy=optional
2014-01-27 01:25:18 +08:00
Change all host devices to use driver_name=vfio for VM 'fedora20' on the remote connection
# virt-xml --connect qemu+ssh://remotehost/system \
fedora20 --edit all --hostdev driver_name=vfio
2014-01-27 01:25:18 +08:00
Hotplug host USB device 001.003 to running domain 'fedora19':
# virt-xml fedora19 --update --add-device --hostdev 001.003
2014-01-27 01:25:18 +08:00
Add a spicevmc channel to the domain 'winxp', that will be available after the next VM shutdown.
# virt-xml winxp --add-device --channel spicevmc
Create a 10G qcow2 disk image and attach it to 'fedora18' for the next VM startup:
# virt-xml fedora18 --add-device \
--disk /var/lib/libvirt/images/newimage.qcow2,format=qcow2,size=10
Same as above, but ensure the disk is attached to the most appropriate bus
for the guest OS by providing information about it on the command line:
# virt-xml fedora18 --os-variant fedora18 --add-device \
--disk /var/lib/libvirt/images/newimage.qcow2,format=qcow2,size=10
Hotunplug the disk vdb from the running domain 'rhel7':
2014-01-27 01:25:18 +08:00
# virt-xml rhel7 --update --remove-device --disk target=vdb
2014-01-27 01:25:18 +08:00
Remove all graphics devices from the VM 'rhel7' after the next shutdown:
# virt-xml rhel7 --remove-device --graphics all
Generate XML for a virtio console device and print it to stdout:
# virt-xml --build-xml --console pty,target_type=virtio
Add qemu command line passthrough:
# virt-xml f25 --edit --confirm --qemu-commandline="-device FOO"
=head1 CAVEATS
Virtualization hosts supported by libvirt may not permit all changes that might seem possible. Some edits made to a VM's definition may be ignored. For instance, QEMU does not allow the removal of certain devices once they've been defined.
=head1 BUGS
Please see https://virt-manager.org/page/BugReporting
=head1 COPYRIGHT
Copyright (C) Red Hat, Inc, and various contributors.
This is free software. You may redistribute copies of it under the terms
of the GNU General Public License C<https://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.
=head1 SEE ALSO
L<virt-install(1)>, the project website C<https://virt-manager.org>
=cut