On 06/24/2014 06:50 AM, Puneet Bakshi wrote:
Hi,
>From host, I wrote 26 alphabets in guest file (/tmp/testqga) using
guest-file-write guest agent command (logs pasted below). I faced 2 issues
when doing that.
1a. It could wrote only 18bytes! Why could it not write all 26 characters?
Are we supposed to track how much data is written and need to resend the
remaining one?
You aren't using the command correctly. The qemu-guest-agent interface
for guest-file-write expects data to be base64-encoded.
1b. What is the limit of data, I can send in one guest-file-write command?
That's a question for the qemu list, as qemu-guest-agent is maintained
there, not here.
2. In the guest, file data seems to be different. Am I doing something
wrong here?
Yes, you aren't encoding your data properly.
Host (file write)
[root@sdsr720-14 ~]# virsh qemu-agent-command vm_04 '{"
execute":"guest-file-open",
"arguments":{"path":"/tmp/testqga","mode":"w
+"}}'
Remember, the use of qemu-agent-command is EXPLICITLY unsupported by
libvirt. It's there as a debugging and development aid, and NOT
something you should be using in your production environment.
I *highly* recommend that you figure out how to set up shared file
systems (NFS, gluster, plan9, MTP, ...) so that you can have the guest
read a file already exported by the host through existing shared
filesystem code, rather than slogging through trying to write the file
through arcane invocations of the qemu-guest-agent.
[root@sdsr720-14 ~]# virsh qemu-agent-command vm_04 '{"
execute":"guest-file-write",
"arguments":{"handle":1000,"buf-b64":"abcdefghijklmnopqrstuvwxyz"}}'
{"return":{"count":18,"eof":false}}
That is NOT a valid base64 encoded buffer.
$ printf abcdefghijklmnopqrstuvwxyz | base64 -d | od -tx1z
base64: invalid input
0000000 69 b7 1d 79 f8 21 8a 39 25 9a 7a 29 aa bb 2d ba >i..y.!.9%.z)..-.<
0000020 fc 31 cb >.1.<
0000023
[root@vm04 qga]# cat /tmp/testqga
i�^]y�!�9%�z)��-��1[root@vm04 qga]#
But those contents match the base64 decoding of (the valid portion of)
the buffer that you passed in. So the only bug here is in your usage,
not in qemu-guest-agent or in libvirt.
-
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org