Community discussions

MikroTik App
 
brotherdust
Member Candidate
Member Candidate
Topic Author
Posts: 118
Joined: Tue Jun 05, 2007 1:31 am

CHR: "qemu-guest-agent" Wiki Documentation

Wed Jun 13, 2018 7:39 pm

RouterOS 6.42 and above now have support for qemu guest agent connectivity for provisioning. The wiki has a few cursory comments on what it can do and what is supported(https://wiki.mikrotik.com/wiki/Manual:CHR#KVM), but I think it needs a lot more detail on how to use it. By comparison, the VMware provisioning section is quite a bit more comprehensive, including an example Python script.

Can someone from Mikrotik please take some time to add more detail to the documentation? Specifically:
- What kind of scripts may be executed
- The security context under which the scripts are executed
- An example script that can serve as a basis for provisioning
- How to use the additional chr.provision_channel channel

Thank you for your consideration.
 
cdstg
just joined
Posts: 10
Joined: Thu Sep 12, 2019 4:15 am

Re: CHR: "qemu-guest-agent" Wiki Documentation SOLVED  [SOLVED]

Fri Oct 04, 2019 4:34 pm

Rather late I know but I finally got this to work

I connect to the qemu agent like this
socat /var/run/qemu-server/155.qga -

where 155 was my VM id on the hypervisor now I m talking to the Agent and can send commands you need to make sure you have a serial device in your VM config

Ok now to send a command
I ending up sending some commands and working out what needs to be sent if you just want to run a script that you send you use input-data option BUT your data must be base 64 encoded

so
{"execute": "guest-exec", "arguments": {"input-data": "OmlwIGFkZHJlc3MgYWRkIGFkZHJlc3M9MTkyLjE2OC4wLjEvMjQgaW50ZXJmYWNlPWV0aGVyMTs=" ,"capture-output": true } }

and it works
this is equal to
:ip address add address=192.168.0.1/24 interface=ether1; eg base64 encode this and send as your input


It would be good to see some more info in the Wiki though but I hope this helps someone
 
brotherdust
Member Candidate
Member Candidate
Topic Author
Posts: 118
Joined: Tue Jun 05, 2007 1:31 am

Re: CHR: "qemu-guest-agent" Wiki Documentation SOLVED

Wed May 05, 2021 9:48 pm

Rather late I know but I finally got this to work

I connect to the qemu agent like this
socat /var/run/qemu-server/155.qga -

where 155 was my VM id on the hypervisor now I m talking to the Agent and can send commands you need to make sure you have a serial device in your VM config

Ok now to send a command
I ending up sending some commands and working out what needs to be sent if you just want to run a script that you send you use input-data option BUT your data must be base 64 encoded

so
{"execute": "guest-exec", "arguments": {"input-data": "OmlwIGFkZHJlc3MgYWRkIGFkZHJlc3M9MTkyLjE2OC4wLjEvMjQgaW50ZXJmYWNlPWV0aGVyMTs=" ,"capture-output": true } }

and it works
this is equal to
:ip address add address=192.168.0.1/24 interface=ether1; eg base64 encode this and send as your input


It would be good to see some more info in the Wiki though but I hope this helps someone
It helped me! Thank you kindly!

Who is online

Users browsing this forum: No registered users and 4 guests