1. 摘要信息类
1.1 dominfo 获取配置等摘要信息
[root@hyperhost ~]# virsh dominfo --domain centos7.6
Id: 1
Name: centos7.6
UUID: 11377dd6-bb49-4b9d-8e36-773787858871
OS Type: hvm
State: running
CPU(s): 2
CPU time: 503.1s
Max memory: 4194304 KiB
Used memory: 4194304 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: none
Security DOI: 0
1.2domstate 获取虚拟机状态信息及原因
option:
--domain <string> domain name, id or uuid
--reason 打印原因
[root@hyperhost ~]# virsh domstate --domain centos7.6 --reason
running (booted)
[root@hyperhost ~]# virsh domstate --domain small --reason
shut off (unknown)
1.3 domuuid\ domid\ domname查找虚拟机的uuid\id\name
# 通过虚拟机的id或者name查找虚拟机的uuid
[root@hyperhost ~]# virsh domuuid 1
11377dd6-bb49-4b9d-8e36-773787858871
[root@hyperhost ~]# virsh domuuid centos7.6
11377dd6-bb49-4b9d-8e36-773787858871
# 通过虚拟机的uuid或者name查找虚拟机的id
[root@hyperhost ~]# virsh domid centos7.6
1
[root@hyperhost ~]# virsh domid 11377dd6-bb49-4b9d-8e36-773787858871
1
# 通过虚拟机的id或者uuid查找虚拟机的name
[root@hyperhost ~]# virsh domname 1
centos7.6
[root@hyperhost ~]# virsh domname 11377dd6-bb49-4b9d-8e36-773787858871
centos7.6
1.4 domuuid\ domid\ domname查找虚拟机的uuid\id\name
# 通过虚拟机的id或者name查找虚拟机的uuid
[root@hyperhost ~]# virsh domuuid 1
11377dd6-bb49-4b9d-8e36-773787858871
[root@hyperhost ~]# virsh domuuid centos7.6
11377dd6-bb49-4b9d-8e36-773787858871
# 通过虚拟机的uuid或者name查找虚拟机的id
[root@hyperhost ~]# virsh domid centos7.6
1
[root@hyperhost ~]# virsh domid 11377dd6-bb49-4b9d-8e36-773787858871
1
# 通过虚拟机的id或者uuid查找虚拟机的name
[root@hyperhost ~]# virsh domname 1
centos7.6
[root@hyperhost ~]# virsh domname 11377dd6-bb49-4b9d-8e36-773787858871
centos7.6
1.5 domdisplay 获得虚拟机vnc\spice\rdb地址
--domain <string> domain name, id or uuid
--include-password includes the password into the connection URI if available ???
--type <string> select particular graphical display (e.g. "vnc", "spice", "rdp")
--all show all possible graphical displays
[root@hyperhost ~]# virsh domdisplay centos7.6
spice://127.0.0.1:5900
1.6 domstats 输出虚拟机统计信息(cpu、内存、网络接口、块设备等统计信息)
option:
--state 返回虚拟机运行状态,原因,类似于virsh domstate guest
--cpu-total report domain physical cpu usage
--balloon report domain balloon statistics
--vcpu report domain virtual cpu information
--interface report domain network interface information
--block report domain block device statistics
--perf report domain perf event statistics
--list-active list only active domains
--list-inactive list only inactive domains
--list-persistent list only persistent domains
--list-transient list only transient domains
--list-running list only running domains
--list-paused list only paused domains
--list-shutoff list only shutoff domains
--list-other list only domains in other states
--raw do not pretty-print the fields
--enforce enforce requested stats parameters
--backing add backing chain information to block stats
--nowait report only stats that are accessible instantly
<domain> list of domains to get stats for
[root@hyperhost ~]# virsh domstats centos7.6 --state
Domain: 'centos7.6'
state.state=1
state.reason=1
1.7 domrename 为处于不活跃状态的虚拟机重命名
option:
--domain <string> 虚拟机的name或者uuid,处于关机的虚拟机没有id
--new-name <string> 新名称
1.8 domtime 获取/设置虚拟机时间
option:
--domain <string> 虚拟机 name, id or uuid
--now set to the time of the host running virsh(设置虚拟机时间为用户敲击virsh命令的时间)
--pretty 以友好格式输出虚拟机时间,缺省为自1970年1月1日至现在的秒数(in seconds relative to Epoch of 1970-01-01 in UTC)
--sync instead of setting given time, synchronize from domain's RTC
--time <number> 设置一个给定的时间
[root@hyperhost ~]# virsh domtime centos7.6
Time: 1655865135 # 自1970年1月1日到当前时间的秒数
[root@hyperhost ~]# virsh domtime centos7.6 --pretty
Time: 2022-06-22 02:32:41 # 虚拟机的RTC时间
[root@hyperhost ~]# virsh domtime centos7.6 --time "1655865135" # 貌似time参数只接受这种格式
[root@hyperhost ~]# virsh domtime centos7.6 --now # 将用户在主机上敲击virsh命令时的主机时间设置为虚拟机时间
[root@hyperhost ~]# virsh domtime centos7.6 --sync # 没找到和now的区别,暂时未知作用?
标签:--,虚拟机,hyperhost,命令,domxxx,virsh,root,centos7.6
From: https://www.cnblogs.com/wang272/p/some_virsh_domxxx_commands.html