首页 > 其他分享 >QGA命令行使用

QGA命令行使用

时间:2023-04-25 10:12:17浏览次数:39  
标签:name success enabled 命令行 使用 true response QGA guest

## 需要确保服务器的qga在线,并且端口是通的

命令行操作:

0. 查看guest的具体信息

virsh qemu-agent-command ${KVMID} --cmd '{"execute":"guest-info"}'

1. 修改密码

# virsh set-user-password vm4 --user root --password 123456789

2. 查看这台虚拟机支持哪些api

# virsh qemu-agent-command vm4 '{"execute":"guest-info"}'   //enabled=true的表示支持

{"return":{"version":"2.8.0","supported_commands":[{"enabled":true,"name":"guest-sync-delimited","success-response":true},{"enabled":true,"name":"guest-sync","success-response":true},{"enabled":true,"name":"guest-suspend-ram","success-response":false},{"enabled":true,"name":"guest-suspend-hybrid","success-response":false},{"enabled":true,"name":"guest-suspend-disk","success-response":false},{"enabled":true,"name":"guest-shutdown","success-response":false},{"enabled":true,"name":"guest-set-vcpus","success-response":true},{"enabled":true,"name":"guest-set-user-password","success-response":true},{"enabled":true,"name":"guest-set-time","success-response":true},{"enabled":true,"name":"guest-set-memory-blocks","success-response":true},{"enabled":true,"name":"guest-ping","success-response":true},{"enabled":true,"name":"guest-network-get-interfaces","success-response":true},{"enabled":true,"name":"guest-info","success-response":true},{"enabled":true,"name":"guest-get-vcpus","success-response":true},{"enabled":true,"name":"guest-get-time","success-response":true},{"enabled":true,"name":"guest-get-memory-blocks","success-response":true},{"enabled":true,"name":"guest-get-memory-block-info","success-response":true},{"enabled":true,"name":"guest-get-fsinfo","success-response":true},{"enabled":true,"name":"guest-fstrim","success-response":true},{"enabled":true,"name":"guest-fsfreeze-thaw","success-response":true},{"enabled":true,"name":"guest-fsfreeze-status","success-response":true},{"enabled":true,"name":"guest-fsfreeze-freeze-list","success-response":true},{"enabled":true,"name":"guest-fsfreeze-freeze","success-response":true},{"enabled":false,"name":"guest-file-write","success-response":true},{"enabled":false,"name":"guest-file-seek","success-response":true},{"enabled":false,"name":"guest-file-read","success-response":true},{"enabled":false,"name":"guest-file-open","success-response":true},{"enabled":false,"name":"guest-file-flush","success-response":true},{"enabled":false,"name":"guest-file-close","success-response":true},{"enabled":false,"name":"guest-exec-status","success-response":true},{"enabled":false,"name":"guest-exec","success-response":true}]}}

3. 试探能否正常通信

  # virsh qemu-agent-command vm4 '{"execute":"guest-ping"}'

4. 创建文件

[root@hypersys184 ~]# virsh qemu-agent-command vm4 '{"execute":"guest-file-create","arguments":{"path":"c:\\test.txt"}}'

Please enter your authentication name: root

Please enter your password:

error: 内部错误:无法执行 QEMU 代理命令 'guest-file-create':The command guest-file-create has not been found

5. 打开文件

[root@hypersys184 ~]# virsh qemu-agent-command win7 '{"execute":"guest-file-open","arguments":{"path":"C:\\Users\\win7\\Desktop\\test.txt"}}'

Please enter your authentication name: root

Please enter your password:

{"return":1000}

  以写模式打开(w+),以读模式打开(r)

[root@hypersys184 ~]# virsh qemu-agent-command win7 '{"execute":"guest-file-open","arguments":{"path":"C:\\Users\\win7\\Desktop\\test.txt", "mode":"w+"}}'

Please enter your authentication name: root

Please enter your password:

{"return":1002}

6. 关闭打开的文件

[root@hypersys184 ~]# virsh qemu-agent-command win7 '{"execute":"guest-file-close","arguments":{"handle": 1002}}'

Please enter your authentication name: root

Please enter your password:

{"return":{}}

7. 往文件内写入数据

[root@hypersys184 ~]# virsh qemu-agent-command win7 '{"execute":"guest-file-write","arguments":{"handle": 1002, "buf-b64": "MTExMWFhYWFh"}}'

Please enter your authentication name: root

Please enter your password:

{"return":{"count":0,"eof":false}}

标签:name,success,enabled,命令行,使用,true,response,QGA,guest
From: https://www.cnblogs.com/xuning-xuning/p/17351800.html

相关文章

  • 反射实现Hello World(注解的使用)
    注解中的元数据包括Target,Rentention,Inherited,Documented。注解:publicinterfaceAnnotationThecommoninterfaceextendedbyallannotationtypes.Notethataninterfacethatmanuallyextendsthisonedoesnotdefineanannotationtype.Alsonotethatthisinterf......
  • objection使用
    Fridaobjection启动objection保证Fridaserver开启命令行输出objection-gpackageNameexploreobjection的缺陷缺少对Native层的支持对象类型的数据打印有问题,比如Bytearray和Json,会显示成[object,object]对Spawn方式启动的支持不够流畅退出exit视频演示:https://asciinema.or......
  • vue3+jointjs 使用模板添加元素
    关于如何在Vue3和JointJS中使用拖拽模板来创建节点元素,可以按照以下步骤进行:1.安装JointJS使用npm进行安装:```npminstalljointjs```2.在Vue3中创建JointJS容器在Vue3中创建一个组件,用于创建JointJS的画布和节点。在组件的生命周期方法`mounted`......
  • 前端vue使用jsencrypt进行RAS加密/解密
    前端安装:npminstalljencrypt--sava在utils下创建jsencrypt.js文件,内容如下:importJSEncryptfrom"jsencrypt/bin/jsencrypt.min";/**RSA秘钥对生成网站http://web.chacuo.net/netrsakeypair*//**公钥512位*/constpublicKey='MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJ......
  • 用户密码加密存储与铺垫知识jwt工具类使用
    用户密码加密存储密码加密存储实际项目我们不会把密码明文存储在数据库中。默认使用PasswordEncoder要求数据库中的密码格式为{id}passwrod。它会根据id去判断密码为加密方式。但是我们一般不会采用这种方式。所以就需要替换PasswordEncod......
  • linux rv1126 查看内存使用情况 磁盘使用情况
    0.top命令,47.1表示占用47.1% 0.717与前面的GiB对应,总共0.717GB运行内存 1、cat/proc/meminfo内存映射文件 2、free-m  3、磁盘使用情况df-h ......
  • 界面控件DevExtreme使用指南 - 折叠组件快速入门(二)
    DevExtreme拥有高性能的HTML5/JavaScript小部件集合,使您可以利用现代Web开发堆栈(包括React,Angular,ASP.NETCore,jQuery,Knockout等)构建交互式的Web应用程序,该套件附带功能齐全的数据网格、交互式图表小部件、数据编辑器等。请注意:在开始本教程之前,请确保DevExtreme已安装在Angula......
  • 使用typescript实现Promise
    /***@nameMyPromise*@description简单实现Promise*@author*****/classMyPromise<T>{//存放成功的回调函数privateresolveFn:Function=()=>{};//存放失败的回调函数privaterejectFn:Function=()=>{};//当前的状态/......
  • 使用RAMMap+PoolMon分析Windows内存异常使用问题
    由于技术能力有限,文章仅能进行简要分析和说明,如有不对的地方,请指正,谢谢......
  • 类的定义与对象的创建使用
    定义类://定义一个手机类//属性:创建品牌、颜色、价格//行为:给xxx打电话群发短信publicclassphone{Stringbrand;Stringcolor;intprice;publicvoidcall(Stringname){System.out.println("给"+name+"打电话");}publicv......