[libvirt] [Qemu-devel] Regarding guest-file-write

Eric Blake eblake at redhat.com
Tue Jun 24 15:32:17 UTC 2014


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 at 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 at 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 at vm04 qga]# cat /tmp/testqga
> 
> i�^]y�!�9%�z)��-��1[root at 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140624/31e2db21/attachment-0001.sig>


More information about the libvir-list mailing list