- 浏览: 1477809 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (691)
- linux (207)
- shell (33)
- java (42)
- 其他 (22)
- javascript (33)
- cloud (16)
- python (33)
- c (48)
- sql (12)
- 工具 (6)
- 缓存 (16)
- ubuntu (7)
- perl (3)
- lua (2)
- 超级有用 (2)
- 服务器 (2)
- mac (22)
- nginx (34)
- php (2)
- 内核 (2)
- gdb (13)
- ICTCLAS (2)
- mac android (0)
- unix (1)
- android (1)
- vim (1)
- epoll (1)
- ios (21)
- mysql (3)
- systemtap (1)
- 算法 (2)
- 汇编 (2)
- arm (3)
- 我的数据结构 (8)
- websocket (12)
- hadoop (5)
- thrift (2)
- hbase (1)
- graphviz (1)
- redis (1)
- raspberry (2)
- qemu (31)
- opencv (4)
- socket (1)
- opengl (1)
- ibeacons (1)
- emacs (6)
- openstack (24)
- docker (1)
- webrtc (11)
- angularjs (2)
- neutron (23)
- jslinux (18)
- 网络 (13)
- tap (9)
- tensorflow (8)
- nlu (4)
- asm.js (5)
- sip (3)
- xl2tp (5)
- conda (1)
- emscripten (6)
- ffmpeg (10)
- srt (1)
- wasm (5)
- bert (3)
- kaldi (4)
- 知识图谱 (1)
最新评论
-
wahahachuang8:
我喜欢代码简洁易读,服务稳定的推送服务,前段时间研究了一下go ...
websocket的helloworld -
q114687576:
http://www.blue-zero.com/WebSoc ...
websocket的helloworld -
zhaoyanzimm:
感谢您的分享,给我提供了很大的帮助,在使用过程中发现了一个问题 ...
nginx的helloworld模块的helloworld -
haoningabc:
leebyte 写道太NB了,期待早日用上Killinux!么 ...
qemu+emacs+gdb调试内核 -
leebyte:
太NB了,期待早日用上Killinux!
qemu+emacs+gdb调试内核
bty:git 提交需要xwindow的办法
unset SSH_ASKPASS
1.在virsh的xml定义中加入channel指定host的socket映射到guest的dev
用virsh启动虚拟机的时候
注意加channel
2.在guest中启动qemu-ga:
yum install qemu-guest-agent qemu-kvm-tools
3.在host上使用python连socket或者socat
具体的control.xml
virsh define control.xml
virsh start control
在guest中
用socat调用
socat参考
http://wiki.qemu.org/Features/QAPI/GuestAgent
libvirt配置参考
http://wiki.libvirt.org/page/Qemu_guest_agent
其他参考
http://aspirer2004.blog.163.com/blog/static/1067647201352423628885/
参考
http://www.cloudcraft.cn/use-qemu-guest-agent-to-change-openstack-instance-root-password/
已有功能
http://www.cnblogs.com/biangbiang/p/3222458.html
参考
http://wiki.qemu.org/Features/QAPI/GuestAgent
unset SSH_ASKPASS
1.在virsh的xml定义中加入channel指定host的socket映射到guest的dev
用virsh启动虚拟机的时候
注意加channel
<channel type='unix'> <source mode='bind' path='/var/lib/libvirt/qemu/test.agent'/> <target type='virtio' name='com.haoning.spice.0'/> <alias name='channel0'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> </channel>
2.在guest中启动qemu-ga:
yum install qemu-guest-agent qemu-kvm-tools
qemu-ga -v -p /dev/virtio-ports/com.haoning.spice.0
3.在host上使用python连socket或者socat
socat unix-connect:/var/lib/libvirt/qemu/test.agent readline
具体的control.xml
<domain type='kvm' id='12'> <name>control</name> <uuid>d07d7290-9b1d-f33e-f54a-70a821252410</uuid> <memory unit='KiB'>4194304</memory> <currentMemory unit='KiB'>4194304</currentMemory> <vcpu placement='static'>1</vcpu> <os> <type arch='x86_64' machine='rhel6.5.0'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/home/rhel-server-6.5-x86_64-dvd.iso'/> <target dev='hdc' bus='ide'/> <readonly/> <alias name='ide0-1-0'/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk> <disk type='file' device='disk'> <driver name='qemu' type='qcow2' cache='none'/> <source file='/home/control.img'/> <target dev='vda' bus='virtio'/> <alias name='virtio-disk0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </disk> <controller type='usb' index='0'> <alias name='usb0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='ide' index='0'> <alias name='ide0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <controller type='virtio-serial' index='0'> <alias name='virtio-serial0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </controller> <interface type='bridge'> <mac address='52:54:02:a1:90:81'/> <source bridge='br0'/> <target dev='vnet0'/> <model type='virtio'/> <alias name='net0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> <source path='/dev/pts/1'/> <target port='0'/> <alias name='serial0'/> </serial> <console type='pty' tty='/dev/pts/1'> <source path='/dev/pts/1'/> <target type='serial' port='0'/> <alias name='serial0'/> </console> <channel type='unix'> <source mode='bind' path='/var/lib/libvirt/qemu/test.agent'/> <target type='virtio' name='com.haoning.spice.0'/> <alias name='channel0'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> </channel> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='5900' autoport='no' listen='0.0.0.0'> <listen type='address' address='0.0.0.0'/> </graphics> <sound model='ich6'> <alias name='sound0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </sound> <video> <model type='cirrus' vram='9216' heads='1'/> <alias name='video0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <alias name='balloon0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </memballoon> </devices> <seclabel type='dynamic' model='selinux' relabel='yes'> <label>system_u:system_r:svirt_t:s0:c681,c978</label> <imagelabel>system_u:object_r:svirt_image_t:s0:c681,c978</imagelabel> </seclabel> </domain>
virsh define control.xml
virsh start control
在guest中
[root@control ~]# qemu-ga -v -p /dev/virtio-ports/com.haoning.spice.0 1437616495.53279: debug: received EOF 1437616495.153410: debug: received EOF 1437616495.253627: debug: received EOF 1437616495.353849: debug: received EOF 1437616495.454057: debug: received EOF 1437616495.554266: debug: received EOF 1437616495.654507: debug: received EOF 1437616495.754719: debug: received EOF 1437616495.854928: debug: received EOF 1437616495.955151: debug: received EOF 1437616496.55375: debug: received EOF 1437616496.155490: debug: received EOF ^C1437616496.170249: debug: received signal num 2, quitting [root@control ~]#
[root@node11 ~]# ls poll_qemu_guest_agent.py [root@node11 ~]# cat poll_qemu_guest_agent.py #! /usr/bin/python import base64 import json import select import socket #sock_file = "/tmp/foo.sock" sock_file = "/var/lib/libvirt/qemu/test.agent" #import pdb;pdb.set_trace() READ_LEN = 1024 read_file = "/proc/cpuinfo" send_cmds = [{"execute": "guest-file-open", "arguments": {"path": read_file, "mode": "r"}}, {"execute": "guest-file-read", "arguments": {"handle": None, "count": READ_LEN}}, {"execute": "guest-file-close", "arguments": {"handle": None}}] serversocket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) serversocket.connect(sock_file) serversocket.setblocking(0) vm_fileno = serversocket.fileno() instances = {} instances[vm_fileno] = "instance-000004e8" epoll = select.epoll() epoll.register(vm_fileno, select.EPOLLIN | select.EPOLLOUT | select.EPOLLET) try: #import ipdb;ipdb.set_trace() cmd = 0 stop = False while True: print '-'*10 + 'start epoll' + '-'*10 events = epoll.poll(1) for fileno, event in events: if fileno in instances.keys():# new client is connecting print 'instance: ' + instances[fileno] if event & select.EPOLLIN: # new msg is coming in print "<<<<<<<<<<<recv" try: vm_resp = '' while True: vm_resp += serversocket.recv(READ_LEN) except socket.error: pass epoll.modify(fileno, select.EPOLLOUT | select.EPOLLET) try: vm_resps = vm_resp.split('\n') ok_resp = None for resp in vm_resps: if 'error' not in resp and 'return' in resp: ok_resp = resp break elif 'error' in resp: print 'error occurs: ', resp if ok_resp is not None: resp = json.loads(ok_resp) else: print 'no valid data recv' break except ValueError: print 'response content error: ', vm_resp break if len(send_cmds) <= cmd: stop = True print resp break try: if cmd == 1: print('+'*10 + 'receive:' + '+'*10 + '\n' + vm_resp) handle = resp["return"] send_cmds[cmd]["arguments"]["handle"] = handle send_cmds[cmd+1]["arguments"]["handle"] = handle elif cmd == 2: decoded_file = base64.decodestring(resp["return"]["buf-b64"]) print 'file content:\n', decoded_file print resp["return"]["count"] print 'EOF: ', resp["return"]["eof"] except (KeyError, ValueError, TypeError): print 'response content error: ', resp elif event & select.EPOLLOUT: # new msg need send out print ">>>>>>>>>send" if len(send_cmds) <= cmd: print 'no data to send' break try: byteswritten = 0 data = json.dumps(send_cmds[cmd]) while True: byteswritten += serversocket.send(data[byteswritten:]) if byteswritten == len(data): print '*'*10 + 'send over' + '*'*10 break except socket.error: pass epoll.modify(fileno, select.EPOLLIN | select.EPOLLET) cmd += 1 elif event & select.EPOLLHUP: # connect closed epoll.unregister(serversocket.fileno()) serversocket.close() print '-'*10 + 'end epoll' + '-'*10 + '\n' if stop: print 'stop now' break finally: epoll.unregister(serversocket.fileno()) epoll.close() serversocket.close() [root@node11 ~]#
用socat调用
socat unix-connect:/tmp/qga.sock readline {"execute":"guest-sync", "arguments":{"id":1234}} {"return": 1234}
socat参考
http://wiki.qemu.org/Features/QAPI/GuestAgent
libvirt配置参考
http://wiki.libvirt.org/page/Qemu_guest_agent
其他参考
http://aspirer2004.blog.163.com/blog/static/1067647201352423628885/
参考
http://www.cloudcraft.cn/use-qemu-guest-agent-to-change-openstack-instance-root-password/
已有功能
http://www.cnblogs.com/biangbiang/p/3222458.html
已有功能 目前qga最新版本为1.5.50,linux已经实现下面的所有功能,windows仅支持加*的那些功能: 复制代码 Ø guest-sync-delimited*:宿主机发送一个int数字给qga,qga返回这个数字,并且在后续返回字符串响应中加入ascii码为0xff的字符,其作用是检查宿主机与qga通信的同步状态,主要用在宿主机上多客户端与qga通信的情况下客户端间切换过程的状态同步检查,比如有两个客户端A、B,qga发送给A的响应,由于A已经退出,目前B连接到qga的socket,所以这个响应可能被B收到,如果B连接到socket之后,立即发送该请求给qga,响应中加入了这个同步码就能区分是A的响应还是B的响应;在qga返回宿主机客户端发送的int数字之前,qga返回的所有响应都要忽略; Ø guest-sync*:与上面相同,只是不在响应中加入0xff字符; Ø guest-ping*:Ping the guest agent, a non-error return implies success; Ø guest-get-time*:获取虚拟机时间(返回值为相对于1970-01-01 in UTC,Time in nanoseconds.); Ø guest-set-time*:设置虚拟机时间(输入为相对于1970-01-01 in UTC,Time in nanoseconds.); Ø guest-info*:返回qga支持的所有命令; Ø guest-shutdown*:关闭虚拟机(支持halt、powerdown、reboot,默认动作为powerdown); Ø guest-file-open:打开虚拟机内的某个文件(返回文件句柄); Ø guest-file-close:关闭打开的虚拟机内的文件; Ø guest-file-read:根据文件句柄读取虚拟机内的文件内容(返回base64格式的文件内容); Ø guest-file-write:根据文件句柄写入文件内容到虚拟机内的文件; Ø guest-file-seek:Seek to a position in the file, as with fseek(), and return the current file position afterward. Also encapsulates ftell()'s functionality, just Set offset=0, whence=SEEK_CUR; Ø guest-file-flush:Write file changes bufferred in userspace to disk/kernel buffers; Ø guest-fsfreeze-status:Get guest fsfreeze state. error state indicates; Ø guest-fsfreeze-freeze:Sync and freeze all freezable, local guest filesystems; Ø guest-fsfreeze-thaw:Unfreeze all frozen guest filesystems; Ø guest-fstrim:Discard (or "trim") blocks which are not in use by the filesystem; Ø guest-suspend-disk*:Suspend guest to disk; Ø guest-suspend-ram*:Suspend guest to ram; Ø guest-suspend-hybrid:Save guest state to disk and suspend to ram(This command requires the pm-utils package to be installed in the guest.); Ø guest-network-get-interfaces:Get list of guest IP addresses, MAC addresses and netmasks; Ø guest-get-vcpus:Retrieve the list of the guest's logical processors; guest-set-vcpus:Attempt to reconfigure (currently: enable/disable) logical processors inside the guest。
参考
http://wiki.qemu.org/Features/QAPI/GuestAgent
mdroth@illuin:~$ sudo socat unix-connect:/tmp/qga.sock readline {"execute":"guest-sync", "arguments":{"id":1234}} {"return": 1234} {"execute":"guest-ping"} {"return": {}} {"execute": "guest-info"} {"return": {"version": "1.0"}} // write "hello world!\n" to /tmp/testqga {"execute":"guest-file-open", "arguments":{"path":"/tmp/testqga","mode":"w+"}} {"return": 0} {"execute":"guest-file-write", "arguments":{"handle":0,"buf-b64":"aGVsbG8gd29ybGQhCg=="}} {"return": {"count": 13, "eof": false}} {"execute":"guest-file-close", "arguments":{"handle":0}} {"return": {}} // read back the "hello world!\n" from /tmp/testqga {"execute":"guest-file-open", "arguments":{"path":"/tmp/testqga","mode":"r"}} {"return": 1} {"execute":"guest-file-read", "arguments":{"handle":1,"count":1024}} {"return": {"buf-b64": "aGVsbG8gd29ybGQhCg==", "count": 13, "eof": true}} {"execute":"guest-file-close","arguments":{"handle":1}} {"return": {}} // freeze and unfreeze freezable guest filesystems {"execute":"guest-fsfreeze-status"} {"return": "thawed"} {"execute":"guest-fsfreeze-freeze"} {"return": 3} {"execute":"guest-fsfreeze-status"} {"return": "frozen"} {"execute":"guest-fsfreeze-thaw"} {"return": 3} {"execute":"guest-fsfreeze-status"} {"return": "thawed"}
发表评论
-
tinyemu
2019-01-24 17:59 1433参考https://bellard.org/jslinux/t ... -
jslinux-deobfuscated-network
2017-02-13 22:37 714基础知识 查看网络包 tcpdump -i eth0 -e ... -
用buildroot为jslinux建立最小rootfs
2016-11-18 17:59 1270############################### ... -
nginx rewrite替代apache rewrite
2016-10-18 20:30 834清理chrome的缓存 chrome://appcache-i ... -
qemu用tap方式启动vm的网络试验(ip route)
2016-09-14 11:29 2806ip route add 192.168.8.0/24 via ... -
qemu的不断网动态迁移的试验
2016-06-28 16:16 950需求: 目前有两台服务器 192.168.139.117 19 ... -
kvm的nested嵌套
2016-06-27 18:25 1330关键点是 modprobe kvm_intel nested= ... -
qemu的动态迁移的试验
2016-06-25 21:48 14261.安装qemu-2.5.1.tar 解决 ... -
libvirt建立快照和基本使用
2016-06-25 15:51 1637如果使用qemu的快照方式 在monitor中操作 (qe ... -
socket的方式使用qemu建立虚拟机
2016-06-24 17:54 1910qemu的-net参数 -net nic 必须有,基本配置mo ... -
tap的方式使用qemu建立虚拟机NAT网络
2016-06-23 18:03 9849基本概念: vm:虚拟机 ... -
qemu建立基本的虚拟机
2016-06-23 17:04 1985使用qemu建立虚拟机 1.需要内核文件 bzImage ... -
qemu用nat的方式使用tap建立虚拟机
2016-06-23 16:15 11普通桥接参考 http://haoningabc.iteye. ... -
tap的方式使用qemu建立虚拟机桥接网络
2016-06-22 20:53 7838需求:建立一个虚拟机,使网络和内网一样,当一台普通接入内网的服 ... -
使用buildroot为jslinux创建root.bin
2016-05-02 00:37 1347环境 gcc 版本 4.8.5 centos ... -
i386上的busybox
2016-04-26 22:51 1026环境:在64位机器上总莫名其妙问题,交叉编译也会有想不到的地方 ... -
qemu以64位和32位的方式跑busybox
2016-04-07 22:06 1603两种方式x86_64 和32位的i386方式 ------ ... -
neutron基础九(qemu nat网络)
2016-02-06 17:21 1621接上基础八,kvm透传nested忽略 1.在主机ce ... -
neutron基础七(qemu tap)
2016-02-02 17:02 1030使用qemu 建立个虚拟机 然后用tap设备, 根据基础六,t ... -
使用devstack安装magnum
2015-11-18 21:22 1430在redhat6.5上建立个centos7的虚拟机,使用cen ...
相关推荐
Windows整理后的qga包,包含amd64和qemu-ga两个文件。 amd64:首先安装证书,管理员运行cmd,命令:pnputil -I -a vioser.inf qemu-ga:将qemu-ga目录放到C:\\Program Files下,管理员运行cmd,命令:qemu-ga -s ...
Linux QEMU(Quick Emulator)是一款强大的开源模拟器和虚拟机监控程序,它允许你在同一台计算机上运行多个操作系统,而无需物理硬件。QEMU支持多种架构,包括x86、ARM、MIPS等,因此它在软件开发、测试、教学和虚拟...
QEMU客座代理适用于FreeBSD guest... eq: qemu_guest_agent_flags="-d -v -l /var/log/qemu-ga.log -p /dev/ttyV0.2"入门在使用和编译QEMU Guest Agent之前,请确保已加载模块“ virtio_console”先决条件在控制台
《QMP与QEMU在虚拟化技术中的应用详解》 在IT行业中,虚拟化技术扮演着至关重要的角色,它能够使一台物理机器运行多个独立的操作系统实例,极大地提高了硬件资源的利用率。QMP(QEMU Monitor Protocol)和QEMU是...
QEMU(Quick Emulator)是一款强大的开源模拟器和虚拟化工具,它允许用户在一台机器上运行多种操作系统,而无需重启或拥有多个物理系统。QEMU适用于Windows平台,为用户提供了一个方便的界面来管理和操作虚拟机。在...
s390:支持 z14 GA 2 CPU 型号,默认情况下启用 Multiple-epoch 和 PTFF 功能 s390:vfio-ap:支持热插拔,不再禁止内存膨胀 x86:HAX 加速器现在支持除 Darwin 以外的 POSIX 主机,包括 Linux 和 NetBSD x86:...
1.加入了在线自助装机系统,适合电脑公司网上装机订单。 2.加入在线网上报修系统 3.加入商城程序,公司网站+网上电脑商城销售两不误。 ... 5.修正后台支付接口漏洞,加入了更多支付接口 ...6.修改模板为纯蓝外观,更...
QEMU(Quick Emulator)是一款强大的开源模拟器和虚拟化工具,它允许用户在一台计算机上运行多种操作系统,而无需实际硬件。QEMU v3.0.0 是该软件的一个版本,提供了对不同架构的支持,包括x86(32位和64位)。 在...
虚拟机ubuntu安装qt,附所有安装包链接,Error 127 问题解决,虚拟机许可证-附件资源
在客户端机器上,你需要安装相应的Spice客户端软件,如`qemu-ga`或`spice-gtk`,然后使用连接信息(如IP地址、端口和密码)连接到虚拟机。 5. **安全和性能优化**: 为了安全,可以限制Spice服务只接受来自特定IP...
用于将virtio-win驱动程序打包到VFD,ISO和RPM中的脚本。 这里的目标是生成一个与... 并带有指向qemu-ga ,changelog等其他位的链接。 virtio-win驱动程序签名 所有Windows二进制文件都来自在Red Hat内部构建系统上完
`file:/OVS/vm/sol-10-u7-ga-x86-dvd.iso`是Solaris的ISO镜像,挂载在`hdc:cdrom`,标记为只读(`r`)。 5. **启动和管理虚拟机** 通过`xm create solaris`命令,使用指定的配置文件启动虚拟机。启动后,可以看到...