2019-08-16 13:03:15 +01:00
|
|
|
# virsh
|
|
|
|
|
2024-03-14 05:01:06 +00:00
|
|
|
> Manage virsh guest domains. (Note: 'guest_id' can be the ID, name or UUID of the guest).
|
2021-09-13 09:21:21 +01:00
|
|
|
> Some subcommands such as `virsh list` have their own usage documentation.
|
2020-12-29 11:46:54 +00:00
|
|
|
> More information: <https://libvirt.org/virshcmdref.html>.
|
2019-08-16 13:03:15 +01:00
|
|
|
|
|
|
|
- Connect to a hypervisor session:
|
|
|
|
|
2021-04-29 19:02:33 +01:00
|
|
|
`virsh connect {{qemu:///system}}`
|
2019-08-16 13:03:15 +01:00
|
|
|
|
|
|
|
- List all domains:
|
|
|
|
|
|
|
|
`virsh list --all`
|
|
|
|
|
|
|
|
- Dump guest configuration file:
|
|
|
|
|
|
|
|
`virsh dumpxml {{guest_id}} > {{path/to/guest.xml}}`
|
|
|
|
|
|
|
|
- Create a guest from a configuration file:
|
|
|
|
|
|
|
|
`virsh create {{path/to/config_file.xml}}`
|
|
|
|
|
|
|
|
- Edit a guest's configuration file (editor can be changed with $EDITOR):
|
|
|
|
|
|
|
|
`virsh edit {{guest_id}}`
|
|
|
|
|
|
|
|
- Start/reboot/shutdown/suspend/resume a guest:
|
|
|
|
|
|
|
|
`virsh {{command}} {{guest_id}}`
|
|
|
|
|
|
|
|
- Save the current state of a guest to a file:
|
|
|
|
|
|
|
|
`virsh save {{guest_id}} {{filename}}`
|
|
|
|
|
|
|
|
- Delete a running guest:
|
|
|
|
|
|
|
|
`virsh destroy {{guest_id}} && virsh undefine {{guest_id}}`
|