libvirt frequently used commands summary virsh
libvirt frequently used commands summary virsh
Let's summarize the frequently used commands for handling QEMU virtual machines with libvirt.
Virsh define
This command adds a virtual machine defined in libvirt Domain XML Format ( https://libvirt.org/formatdomain.html ) to libvirt.
virsh define [libvirt 도메인 정의 xml 파일 경로]
Virsh start
start
Use to start a virtual machine .virsh start [가상머신도메인 이름]
View virtual machine list virsh list
You can see the list of added virtual machines.
virsh list --all
Virsh delete
You can delete the added virtual machine.
virsh delete [snapshot name]
Pause / resume virtual machine virsh suspend, resume
Use to pause the virtual machine
suspend
.virsh suspend [snapshot name]
resume
Use to resume a paused virtual machine .virsh resume [snapshot name]
Turn off the virtual machine virsh destroy
Use to terminate the virtual machine you
destroy
were using.virsh destroy [snapshot name]
Create a virtual machine snapshot virsh snapshot-create-as
snapshot-create-as
Use to create a snapshot of the virtual machine .virsh snapshot-create-as --domain [domain] [snapshot name]
Here is an example:
virsh snapshot-create-as --domain win10 snapshot1
Checking virtual machine snapshot list virsh snapshot-list
snapshot-list
Use to check the snapshot list of the created virtual machine .virsh snapshot-list --domain [snapshot name]
Here is an example:
virsh snapshot-list --domain win10
Restore virtual machine snapshot virsh snapshot-revert
snapshot-revert
Use to restore the virtual machine to the specified snapshot state .virsh snapshot-revert [domain] [snapshot name]
Here is an example:
virsh snapshot-revert win10 snapshot1
Delete virtual machine snapshot virsh snapshot-delete
snapshot-delete
Use to delete the snapshot of the created virtual machine .virsh snapshot-delete --domain [domain] [snapshot name]
Here is an example:
virsh snapshot-delete --domain win10 snapshot1
Checking virtual machine status virsh domstats
You can check the status of the virtual machine to get information such as cpu utilization.
virsh domstats [domain]
Here is an example of the execution result:
[root@localhost bin]# virsh domstats win10
Domain: 'win10'
state.state=1
state.reason=5
cpu.time=197136008572
cpu.user=20720000000
cpu.system=82070000000
balloon.current=1048576
balloon.maximum=1048576
balloon.last-update=0
balloon.rss=1144
vcpu.current=1
vcpu.maximum=1
vcpu.0.state=1
vcpu.0.time=0
vcpu.0.wait=0
vcpu.0.halted=예
net.count=1
net.0.name=vnet0
net.0.rx.bytes=32349
net.0.rx.pkts=564
net.0.rx.errs=0
net.0.rx.drop=0
net.0.tx.bytes=16347
net.0.tx.pkts=241
net.0.tx.errs=0
net.0.tx.drop=0
block.count=1
block.0.name=sda
block.0.path=/home/vm/win10.qcow2
block.0.rd.reqs=1583
block.0.rd.bytes=29008384
block.0.rd.times=985020119
block.0.wr.reqs=953
block.0.wr.bytes=11841024
block.0.wr.times=171686524
block.0.fl.reqs=161
block.0.fl.times=19088993
block.0.allocation=870514688
block.0.capacity=42949672960
block.0.physical=870330368
You can see the current cpu information and network utilization of the virtual machine.
Comments
Post a Comment