virsh
Comprehensive command reference for virsh covering domain lifecycle management, networking, storage pools, snapshots, migration, performance tuning, and hypervisor administration
Check system libvirt
virsh -c qemu:///system net-list --all
Name State Autostart Persistent
--------------------------------------------
default active yes yes
- Then run below and you should see changes has been done
virsh -c qemu:///system net-destroy default
virsh -c qemu:///system net-undefine default
virsh -c qemu:///system net-define win10.xml
virsh -c qemu:///system net-start win10
virsh -c qemu:///system net-autostart win10
Network default destroyed
Network default has been undefined
Network win10 defined from win10.xml
Network win10 started
Network win10 marked as autostarted
- Remember if you using
Virtual Managerenable xml editing and changedefaultunder network towin10
How edit hostname for the host
virsh -c qemu:///system net-dumpxml default \
| sed 's|<name>default</name>|<name>new_hostname</name>|' \
> new_hostname.xml
Command Examples
Check user libvirt
virsh -c qemu:///session net-list --all
Start network manually
virsh -c qemu:///system net-start <hostname>
Autostart network
virsh net-autostart default
attach device from an XML file
virsh attach-device
attach disk device
virsh attach-disk
attach network interface
virsh attach-interface
autostart a domain
virsh autostart
Set or query a block device I/O tuning parameters.
virsh blkdeviotune
Add or update a throttling group.
virsh domthrottlegroupset
Delete a throttling group.
virsh domthrottlegroupdel
Get a throttling group.
virsh domthrottlegroupinfo
list all domain throttlegroups.
virsh domthrottlegrouplist
Get or set blkio parameters
virsh blkiotune
Start a block commit operation.
virsh blockcommit
Start a block copy operation.
virsh blockcopy
Manage active block operations
virsh blockjob
Populate a disk from its backing image.
virsh blockpull
Resize block device of domain.
virsh blockresize
Change media of CD or floppy drive
virsh change-media
connect to the guest console
virsh console
show domain cpu statistics
virsh cpu-stats
create a domain from an XML file
virsh create
define (but don't start) a domain from an XML file
virsh define
show or set domain's description or title
virsh desc
destroy (stop) a domain
virsh destroy
detach device from an XML file
virsh detach-device
detach device from an alias
virsh detach-device-alias
detach disk device
virsh detach-disk
detach network interface
virsh detach-interface
domain display connection URI
virsh domdisplay
Freeze domain's mounted filesystems.
virsh domfsfreeze
Thaw domain's mounted filesystems.
virsh domfsthaw
Get information of domain's mounted filesystems.
virsh domfsinfo
Invoke fstrim on domain's mounted filesystems.
virsh domfstrim
print the domain's hostname
virsh domhostname
convert a domain name or UUID to domain id
virsh domid
set link state of a virtual interface
virsh domif-setlink
get/set parameters of a virtual interface
virsh domiftune
abort active domain job
virsh domjobabort
domain job information
virsh domjobinfo
Get domain launch security info
virsh domlaunchsecinfo
Set domain launch security state
virsh domsetlaunchsecstate
convert a domain id or UUID to domain name
virsh domname
rename a domain
virsh domrename
suspend a domain gracefully using power management functions
virsh dompmsuspend
wakeup a domain from pmsuspended state
virsh dompmwakeup
convert a domain name or id to domain UUID
virsh domuuid
Convert native config to domain XML
virsh domxml-from-native
Convert domain XML to native config
virsh domxml-to-native
dump the core of a domain to a file for analysis
virsh dump
domain information in XML
virsh dumpxml
edit XML configuration for a domain
virsh edit
list authorized SSH keys for given user (via agent)
virsh get-user-sshkeys
Inject NMI to the guest
virsh inject-nmi
view domain IOThreads
virsh iothreadinfo
control domain IOThread affinity
virsh iothreadpin
add an IOThread to the guest domain
virsh iothreadadd
modifies an existing IOThread of the guest domain
virsh iothreadset
delete an IOThread from the guest domain
virsh iothreaddel
Send keycodes to the guest
virsh send-key
Send signals to processes
virsh send-process-signal
LXC Guest Enter Namespace
virsh lxc-enter-namespace
managed save of a domain state
virsh managedsave
Remove managed save of a domain
virsh managedsave-remove
edit XML for a domain's managed save state file
virsh managedsave-edit
Domain information of managed save state file in XML
virsh managedsave-dumpxml
redefine the XML for a domain's managed save state file
virsh managedsave-define
Get or set memory parameters
virsh memtune
Get or set perf event
virsh perf
show or set domain's custom XML metadata
virsh metadata
migrate domain to another host
virsh migrate
set maximum tolerable downtime
virsh migrate-setmaxdowntime
get maximum tolerable downtime
virsh migrate-getmaxdowntime
get/set compression cache size
virsh migrate-compcache
Set the maximum migration bandwidth
virsh migrate-setspeed
Get the maximum migration bandwidth
virsh migrate-getspeed
Switch running migration from pre-copy to post-copy
virsh migrate-postcopy
Get or set numa parameters
virsh numatune
QEMU Attach
virsh qemu-attach
QEMU Monitor Command
virsh qemu-monitor-command
QEMU Monitor Events
virsh qemu-monitor-event
QEMU Guest Agent Command
virsh qemu-agent-command
Set the guest agent timeout
virsh guest-agent-timeout
reboot a domain
virsh reboot
reset a domain
virsh reset
restore a domain from a saved state in a file
virsh restore
resume a domain
virsh resume
save a domain state to a file
virsh save
redefine the XML for a domain's saved state file
virsh save-image-define
saved state domain information in XML
virsh save-image-dumpxml
edit XML for a domain's saved state file
virsh save-image-edit
show/set scheduler parameters
virsh schedinfo
take a screenshot of a current domain console and store it into a file
virsh screenshot
change lifecycle actions
virsh set-lifecycle-action
manipulate authorized SSH keys file for given user (via agent)
virsh set-user-sshkeys
set the user password inside the domain
virsh set-user-password
change maximum memory limit
virsh setmaxmem
change memory allocation
virsh setmem
change number of virtual CPUs
virsh setvcpus
gracefully shutdown a domain
virsh shutdown
start a (previously defined) inactive domain
virsh start
suspend a domain
virsh suspend
tty console
virsh ttyconsole
undefine a domain
virsh undefine
update device from an XML file
virsh update-device
update memory device of a domain
virsh update-memory-device
domain vcpu counts
virsh vcpucount
detailed domain vcpu information
virsh vcpuinfo
control or query domain vcpu affinity
virsh vcpupin
control or query domain emulator affinity
virsh emulatorpin
vnc display
virsh vncdisplay
query or modify state of vcpu in the guest (via agent)
virsh guestvcpus
attach/detach vcpu or groups of threads
virsh setvcpu
set the threshold for block-threshold event for a given block device or it's backing chain element
virsh domblkthreshold
query information about the guest (via agent)
virsh guestinfo
Calculate a vm's memory dirty rate
virsh domdirtyrate-calc
associate a FD with a domain
virsh dom-fd-associate
Reload domain's graphics display certificates
virsh domdisplay-reload
Show errors on block devices
virsh domblkerror
domain block device size information
virsh domblkinfo
list all domain blocks
virsh domblklist
get device block stats for a domain
virsh domblkstat
domain control interface state
virsh domcontrol
get link state of a virtual interface
virsh domif-getlink
Get network interfaces' addresses for a running domain
virsh domifaddr
list all domain virtual interfaces
virsh domiflist
get network interface stats for a domain
virsh domifstat
domain information
virsh dominfo
get memory statistics for a domain
virsh dommemstat
domain state
virsh domstate
get statistics about one or multiple domains
virsh domstats
domain time
virsh domtime
list domains
virsh list
Domain Events
virsh event
await a domain event
virsh await
Manipulate pages pool size
virsh allocpages
capabilities
virsh capabilities
compute baseline CPU
virsh cpu-baseline
compare host CPU with a CPU described by an XML file
virsh cpu-compare
CPU models
virsh cpu-models
domain capabilities
virsh domcapabilities
NUMA free memory
virsh freecell
NUMA free pages
virsh freepages
print the hypervisor hostname
virsh hostname
compute baseline CPU usable by a specific hypervisor
virsh hypervisor-cpu-baseline
compare a CPU with the CPU created by a hypervisor on the host
virsh hypervisor-cpu-compare
Hypervisor reported CPU models
virsh hypervisor-cpu-models
connection vcpu maximum
virsh maxvcpus
Get or set node memory parameters
virsh node-memory-tune
node cpu map
virsh nodecpumap
Prints cpu stats of the node.
virsh nodecpustats
node information
virsh nodeinfo
Prints memory stats of the node.
virsh nodememstats
node SEV information
virsh nodesevinfo
suspend the host node for a given time duration
virsh nodesuspend
print the hypervisor sysinfo
virsh sysinfo
print the hypervisor canonical URI
virsh uri
show version
virsh version
Create a checkpoint from XML
virsh checkpoint-create
Create a checkpoint from a set of args
virsh checkpoint-create-as
Delete a domain checkpoint
virsh checkpoint-delete
Dump XML for a domain checkpoint
virsh checkpoint-dumpxml
edit XML for a checkpoint
virsh checkpoint-edit
checkpoint information
virsh checkpoint-info
List checkpoints for a domain
virsh checkpoint-list
Get the name of the parent of a checkpoint
virsh checkpoint-parent
create a snapshot of current interfaces settings, which can be later committed (iface-commit) or restored (iface-rollback)
virsh iface-begin
create a bridge device and attach an existing network device to it
virsh iface-bridge
commit changes made since iface-begin and free restore point
virsh iface-commit
define an inactive persistent physical host interface or modify an existing persistent one from an XML file
virsh iface-define
destroy a physical host interface (disable it / "if-down")
virsh iface-destroy
interface information in XML
virsh iface-dumpxml
edit XML configuration for a physical host interface
virsh iface-edit
list physical host interfaces
virsh iface-list
convert an interface name to interface MAC address
virsh iface-mac
convert an interface MAC address to interface name
virsh iface-name
rollback to previous saved configuration created via iface-begin
virsh iface-rollback
start a physical host interface (enable it / "if-up")
virsh iface-start
undefine a bridge device after detaching its device(s)
virsh iface-unbridge
undefine a physical host interface (remove it from configuration)
virsh iface-undefine
define or update a network filter from an XML file
virsh nwfilter-define
network filter information in XML
virsh nwfilter-dumpxml
edit XML configuration for a network filter
virsh nwfilter-edit
list network filters
virsh nwfilter-list
undefine a network filter
virsh nwfilter-undefine
create a network filter binding from an XML file
virsh nwfilter-binding-create
delete a network filter binding
virsh nwfilter-binding-delete
network filter information in XML
virsh nwfilter-binding-dumpxml
list network filter bindings
virsh nwfilter-binding-list
autostart a network
virsh net-autostart
create a network from an XML file
virsh net-create
define an inactive persistent virtual network or modify an existing persistent one from an XML file
virsh net-define
show or set network's description or title
virsh net-desc
destroy (stop) a network
virsh net-destroy
print lease info for a given network
virsh net-dhcp-leases
network information in XML
virsh net-dumpxml
edit XML configuration for a network
virsh net-edit
Network Events
virsh net-event
network information
virsh net-info
list networks
virsh net-list
show or set network's custom XML metadata
virsh net-metadata
convert a network UUID to network name
virsh net-name
start a (previously defined) inactive network
virsh net-start
undefine a persistent network
virsh net-undefine
update parts of an existing network's configuration
virsh net-update
convert a network name to network UUID
virsh net-uuid
list network ports
virsh net-port-list
create a network port from an XML file
virsh net-port-create
network port information in XML
virsh net-port-dumpxml
delete the specified network port
virsh net-port-delete
create a device defined by an XML file on the node
virsh nodedev-create
destroy (stop) a device on the node
virsh nodedev-destroy
detach node device from its device driver
virsh nodedev-detach
node device details in XML
virsh nodedev-dumpxml
enumerate devices on this host
virsh nodedev-list
reattach node device to its device driver
virsh nodedev-reattach
reset node device
virsh nodedev-reset
Node Device Events
virsh nodedev-event
Define or modify a device by an xml file on a node
virsh nodedev-define
Undefine an inactive node device
virsh nodedev-undefine
Start an inactive node device
virsh nodedev-start
autostart a defined node device
virsh nodedev-autostart
node device information
virsh nodedev-info
Update a active and/or inactive node device
virsh nodedev-update
define or modify a secret from an XML file
virsh secret-define
secret attributes in XML
virsh secret-dumpxml
Secret Events
virsh secret-event
Output a secret value
virsh secret-get-value
list secrets
virsh secret-list
set a secret value
virsh secret-set-value
undefine a secret
virsh secret-undefine
Create a snapshot from XML
virsh snapshot-create
Create a snapshot from a set of args
virsh snapshot-create-as
Get or set the current snapshot
virsh snapshot-current
Delete a domain snapshot
virsh snapshot-delete
Dump XML for a domain snapshot
virsh snapshot-dumpxml
edit XML for a snapshot
virsh snapshot-edit
snapshot information
virsh snapshot-info
List snapshots for a domain
virsh snapshot-list
Get the name of the parent of a snapshot
virsh snapshot-parent
Revert a domain to a snapshot
virsh snapshot-revert
Start a disk backup of a live domain
virsh backup-begin
Dump XML for an ongoing domain block backup job
virsh backup-dumpxml
find potential storage pool sources
virsh find-storage-pool-sources-as
discover potential storage pool sources
virsh find-storage-pool-sources
autostart a pool
virsh pool-autostart
build a pool
virsh pool-build
create a pool from a set of args
virsh pool-create-as
create a pool from an XML file
virsh pool-create
define a pool from a set of args
virsh pool-define-as
define an inactive persistent storage pool or modify an existing persistent one from an XML file
virsh pool-define
delete a pool
virsh pool-delete
destroy (stop) a pool
virsh pool-destroy
pool information in XML
virsh pool-dumpxml
edit XML configuration for a storage pool
virsh pool-edit
storage pool information
virsh pool-info
list pools
virsh pool-list
convert a pool UUID to pool name
virsh pool-name
refresh a pool
virsh pool-refresh
start a (previously defined) inactive pool
virsh pool-start
undefine an inactive pool
virsh pool-undefine
convert a pool name to pool UUID
virsh pool-uuid
Storage Pool Events
virsh pool-event
storage pool capabilities
virsh pool-capabilities
clone a volume.
virsh vol-clone
create a volume from a set of args
virsh vol-create-as
create a vol from an XML file
virsh vol-create
create a vol, using another volume as input
virsh vol-create-from
delete a vol
virsh vol-delete
download volume contents to a file
virsh vol-download
vol information in XML
virsh vol-dumpxml
storage vol information
virsh vol-info
returns the volume key for a given volume name or path
virsh vol-key
list vols
virsh vol-list
returns the volume name for a given volume key or path
virsh vol-name
returns the volume path for a given volume name or key
virsh vol-path
returns the storage pool for a given volume key or path
virsh vol-pool
resize a vol
virsh vol-resize
upload file contents to a volume
virsh vol-upload
wipe a vol
virsh vol-wipe
change the current directory
virsh cd
echo arguments. Used for internal testing.
virsh echo
quit this interactive terminal
virsh exit
print help
virsh help
print the current directory
virsh pwd
quit this interactive terminal
virsh quit
(re)connect to hypervisor
virsh connect