查询虚拟机信息

概述

StratoVirt可以查询虚拟机状态、vCPU拓扑信息、vCPU上线情况等。由于StratoVirt使用QMP管理虚拟机,所以查询虚拟机信息,也需要先连接到虚拟机。

查询状态

使用query-status命令查询虚拟机的运行状态。

  • 用法:

    { “execute”: “query-status” }

  • 示例:

  1. <- { "execute": "query-status" }
  2. -> { "return": { "running": true,"singlestep": false,"status": "running" }

查询拓扑

使用query-cpus命令查询所有CPU的拓扑结构。

  • 用法:

{ “execute”: “query-cpus” }

  • 示例:
  1. <- { "execute": "query-cpus" }
  2. -> {"return":[{"CPU":0,"arch":"x86","current":true,"halted":false,"props":{"core-id":0,"socket-id":0,"thread-id":0},"qom_path":"/machine/unattached/device[0]","thread_id":8439},{"CPU":1,"arch":"x86","current":true,"halted":false,"props":{"core-id":0,"socket-id":1,"thread-id":0},"qom_path":"/machine/unattached/device[1]","thread_id":8440}]}

查询vCPU上线情况

使用query-hotpluggable-cpus命令查询所有vCPU的online/offline情况。

  • 用法:

{ “execute”: “query-hotpluggable-cpus” }

  • 示例:
  1. <- { "execute": "query-hotpluggable-cpus" }
  2. -> {"return":[{"props":{"core-id":0,"socket-id":0,"thread-id":0},"qom-path":"/machine/unattached/device[0]","type":"host-x86-cpu","vcpus-count":1},{"props":{"core-id":0,"socket-id":1,"thread-id":0},"qom-path":"/machine/unattached/device[1]","type":"host-x86-cpu","vcpus-count":1}]}

其中,online的vCPU具有qom-path项,offline的vCPU则没有。