All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Regarding guest-file-write
@ 2014-06-24 12:50 Puneet Bakshi
  2014-06-24 12:57 ` [Qemu-devel] [libvirt] " Daniel P. Berrange
  2014-06-24 15:32 ` [Qemu-devel] " Eric Blake
  0 siblings, 2 replies; 5+ messages in thread
From: Puneet Bakshi @ 2014-06-24 12:50 UTC (permalink / raw)
  To: libvir-list, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2246 bytes --]

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?

1b. What is the limit of data, I can send in one guest-file-write command?

2. In the guest, file data seems to be different. Am I doing something
wrong here?


Host (file write)

[root@sdsr720-14 ~]# virsh qemu-agent-command vm_04 '{"
execute":"guest-file-open", "arguments":{"path":"/tmp/testqga","mode":"w
+"}}'

{"return":1000}


[root@sdsr720-14 ~]# virsh qemu-agent-command vm_04 '{"
execute":"guest-file-write",
"arguments":{"handle":1000,"buf-b64":"abcdefghijklmnopqrstuvwxyz"}}'

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


[root@sdsr720-14 ~]# virsh qemu-agent-command vm_04 '{"
execute":"guest-file-close", "arguments":{"handle":1000}}'

{"return":{}}


Host (file read)

[root@sdsr720-14 ~]# virsh qemu-agent-command vm_04 '{"
execute":"guest-file-open", "arguments":{"path":"/tmp/testqga","mode":"r"}}'

{"return":1001}


[root@sdsr720-14 ~]# virsh qemu-agent-command vm_04 '{"
execute":"guest-file-read", "arguments":{"handle":1001,"count":18}}'

{"return":{"count":18,"buf-b64":"abcdefghijklmnopqrstuvwx","eof":false}}


[root@sdsr720-14 ~]# virsh qemu-agent-command vm_04 '{"
execute":"guest-file-close", "arguments":{"handle":1001}}'

{"return":{}}

Guest

[root@vm04 qga]# ll /tmp/testqga

-rw-rw-rw-. 1 root root 18 Jun 24 15:06 /tmp/testqga


[root@vm04 qga]# cat /tmp/testqga

i�^]y�!�9%�z)��-��1[root@vm04 qga]#


[root@vm04 qga]# od -x /tmp/testqga

0000000 b769 791d 21f8 398a 9a25 297a bbaa ba2d

0000020 31fc

0000022

     [root@vm04 qga]# strings /tmp/testqga

     [root@vm04 qga]# hexdump /tmp/testqga
     0000000 b769 791d 21f8 398a 9a25 297a bbaa ba2d
     0000010 31fc
     0000012

     [root@vm04 qga]# hexdump -c /tmp/testqga
     0000000   i 267 035   y 370   ! 212   9   % 232   z   ) 252 273   - 272
     0000010 374   1
     0000012
     [root@vm04 qga]#

Regards,
~Puneet

[-- Attachment #2: Type: text/html, Size: 16507 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [libvirt] Regarding guest-file-write
  2014-06-24 12:50 [Qemu-devel] Regarding guest-file-write Puneet Bakshi
@ 2014-06-24 12:57 ` Daniel P. Berrange
  2014-06-24 13:10   ` Puneet Bakshi
  2014-06-24 15:32 ` [Qemu-devel] " Eric Blake
  1 sibling, 1 reply; 5+ messages in thread
From: Daniel P. Berrange @ 2014-06-24 12:57 UTC (permalink / raw)
  To: Puneet Bakshi; +Cc: libvir-list, qemu-devel

On Tue, Jun 24, 2014 at 06:20:16PM +0530, 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?
> 
> 1b. What is the limit of data, I can send in one guest-file-write command?
> 
> 2. In the guest, file data seems to be different. Am I doing something
> wrong here?

Yes, the command does not take raw data, it takes base-64 encoded data.
So those 26 characters you specified were base64 decoded which gives
you 18 bytes of raw data.

The clue is in the variable name 'buf-b64' - a shorthand for base64:

> [root@sdsr720-14 ~]# virsh qemu-agent-command vm_04 '{"
> execute":"guest-file-write",
> "arguments":{"handle":1000,"buf-b64":"abcdefghijklmnopqrstuvwxyz"}}'
> 
> {"return":{"count":18,"eof":false}}

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [libvirt] Regarding guest-file-write
  2014-06-24 12:57 ` [Qemu-devel] [libvirt] " Daniel P. Berrange
@ 2014-06-24 13:10   ` Puneet Bakshi
  2014-06-24 15:34     ` Eric Blake
  0 siblings, 1 reply; 5+ messages in thread
From: Puneet Bakshi @ 2014-06-24 13:10 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: libvir-list, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1800 bytes --]

1. In that case, I hope it allow sending binary data (non-ASCII) also.

2. If I encode my data in base-64 form, is there a limit on size of the
data I can pass (or I can pass arbitrarily large amount of data).

​Regards​,
~Puneet

On Tue, Jun 24, 2014 at 6:27 PM, Daniel P. Berrange <berrange@redhat.com>
wrote:

> On Tue, Jun 24, 2014 at 06:20:16PM +0530, 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?
> >
> > 1b. What is the limit of data, I can send in one guest-file-write
> command?
> >
> > 2. In the guest, file data seems to be different. Am I doing something
> > wrong here?
>
> Yes, the command does not take raw data, it takes base-64 encoded data.
> So those 26 characters you specified were base64 decoded which gives
> you 18 bytes of raw data.
>
> The clue is in the variable name 'buf-b64' - a shorthand for base64:
>
> > [root@sdsr720-14 ~]# virsh qemu-agent-command vm_04 '{"
> > execute":"guest-file-write",
> > "arguments":{"handle":1000,"buf-b64":"abcdefghijklmnopqrstuvwxyz"}}'
> >
> > {"return":{"count":18,"eof":false}}
>
> Regards,
> Daniel
> --
> |: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/
> :|
> |: http://libvirt.org              -o-             http://virt-manager.org
> :|
> |: http://autobuild.org       -o-         http://search.cpan.org/~danberr/
> :|
> |: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc
> :|
>

[-- Attachment #2: Type: text/html, Size: 3132 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] Regarding guest-file-write
  2014-06-24 12:50 [Qemu-devel] Regarding guest-file-write Puneet Bakshi
  2014-06-24 12:57 ` [Qemu-devel] [libvirt] " Daniel P. Berrange
@ 2014-06-24 15:32 ` Eric Blake
  1 sibling, 0 replies; 5+ messages in thread
From: Eric Blake @ 2014-06-24 15:32 UTC (permalink / raw)
  To: Puneet Bakshi, libvir-list, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2457 bytes --]

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [libvirt] Regarding guest-file-write
  2014-06-24 13:10   ` Puneet Bakshi
@ 2014-06-24 15:34     ` Eric Blake
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2014-06-24 15:34 UTC (permalink / raw)
  To: Puneet Bakshi, Daniel P. Berrange; +Cc: libvir-list, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 675 bytes --]

On 06/24/2014 07:10 AM, Puneet Bakshi wrote:

[please don't top-post on technical lists]

> 1. In that case, I hope it allow sending binary data (non-ASCII) also.

Yes, the reason guest-file-write takes base64 encoded data is PRECISELY
so that it can cope with binary data while still using only ascii
representation over the wire.

> 
> 2. If I encode my data in base-64 form, is there a limit on size of the
> data I can pass (or I can pass arbitrarily large amount of data).

At this point, it may be faster for you to read the qemu source code.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-24 15:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-24 12:50 [Qemu-devel] Regarding guest-file-write Puneet Bakshi
2014-06-24 12:57 ` [Qemu-devel] [libvirt] " Daniel P. Berrange
2014-06-24 13:10   ` Puneet Bakshi
2014-06-24 15:34     ` Eric Blake
2014-06-24 15:32 ` [Qemu-devel] " Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.