Bug 857838

Summary: VM payload should accept arbitrary binary input
Product: Red Hat Enterprise Virtualization Manager Reporter: Geert Jansen <gjansen>
Component: ovirt-engine-restapiAssignee: Nobody <nobody>
Status: CLOSED NOTABUG QA Contact: Tareq Alayan <talayan>
Severity: high Docs Contact:
Priority: high    
Version: 3.1.0CC: acathrow, bugzilla, ecohen, iheim, jkt, jrankin, michal.skrivanek, mpastern, Rhev-m-bugs, shavivi
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: virt
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-11 21:24:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Geert Jansen 2012-09-17 07:57:58 UTC
Currently the VM payload feature is restricted in the input it accepts. I haven't tested the full range of characters that it might accept, but so far my testing has found this:

 * Newlines are not accepted.
 * XML unsafe characters like '<' and '>' are not accepted as they result in the input XML being not well formed and rejected at the RESTeasy level.

As a design goal, we should make sure we support a wide array of applications with VM payload. This means that we should have as little limitations on the payload data as possible.

I propose that the API accepts the VM payload in an encoded format that is safe to embed in XML. The most common format seems to be base64.

At some point before the payload is provided to the VM, should be decoded. This decoding can be done where ever makes sense (API, engine, VDSM). The goal is that a user is able to provide a binary blob as payload containing the full range of  byte values (0 .. 255) up to the length limit for VM payloads.

Below i've added an example that  shows that the API currently does not accept multi-line input:

# cat update.xml
<vm>
  <payloads>
    <payload type="floppy">
      <file name="payload.txt">
<content>line one
line two
line three
</content>
      </file>
    </payload>
  </payloads>
</vm>

Using this cURL command:

# curl -k --user admin@internal:xxxx --request PUT --data @update.xml --header "Content-Type: application/xml" https://localhost:443/api/vms/{id}

What i get back is this:

    <payloads>
        <payload type="floppy">
            <file name="payload.txt">
                <content>line oneline twoline three</content>
            </file>
        </payload>
    </payloads>

So the content is now all on 1 line. And when i mount the floppy in the guest, i see the same thing (newlines removed).

Comment 1 Geert Jansen 2012-09-17 11:45:49 UTC
This is not a FutureFeature.

Comment 2 Andrew Cathrow 2012-09-17 13:05:23 UTC
We should accept any content in the payload.

Michael - what's the scope of effort to fix this?

Comment 3 Itamar Heim 2012-09-17 15:47:27 UTC
michael/shahar - don't we support base64 encoded content?

Comment 4 Yaniv Kaul 2012-09-18 20:32:50 UTC
(In reply to comment #2)
> We should accept any content in the payload.

According to http://wiki.ovirt.org/wiki/Features/VMPayload : "The payload data will be encoded using base64 encoding", so we don't accept *any* type - unless we have some encoding mechanism.

QE conditional NACK on requirements.

> 
> Michael - what's the scope of effort to fix this?

Comment 5 Michael Pasternak 2012-09-19 06:20:40 UTC
Hi Geert,

I had no problem passing multilined <content> using [1], i think the problem
is in the client you have used.

[1]

<vm>
  <payloads>
    <payload type="floppy">
      <file name="payload.txt">
        <content>
          content here1
          content here2
          content here3
        </content>
      </file>
    </payload>
  </payloads>
</vm>

Comment 6 Michael Pasternak 2012-09-19 06:44:46 UTC
(In reply to comment #4)
> (In reply to comment #2)
> > We should accept any content in the payload.
> 
> According to http://wiki.ovirt.org/wiki/Features/VMPayload : "The payload
> data will be encoded using base64 encoding", so we don't accept *any* type -
> unless we have some encoding mechanism.

if there any "encoding mechanism" it's resides in BE, (api is agnostic to data formats and /get on payload returns plain text), Shahar?

> 
> QE conditional NACK on requirements.
> 
> > 
> > Michael - what's the scope of effort to fix this?

Comment 7 Shahar Havivi 2012-09-23 09:42:53 UTC
The VmPayload current design is support only text files.
The engine is getting a plain text and encode it to Base64 before storing the data in DB.
Geert, I think Michael is right, you can try use cdata tag as your content wrapper: http://www.w3schools.com/xml/xml_cdata.asp

Comment 9 Itamar Heim 2012-10-01 13:17:33 UTC
please re-open if can be reproduced per above comments.

Comment 10 Geert Jansen 2012-10-16 16:38:04 UTC
I tried CDATA but it gave a RESTeasy error. But in any case, you cannot pass arbitrary binary data in CDATA so the point is moot.

Why is this closed by the way? It was already moved to rhevm-future and if it is closed we would not be able to find it anymore.

Comment 11 Itamar Heim 2012-10-17 05:36:17 UTC
bugs with needinfo for too long are closed insufficent data asking to re-open if can be reproduced.

Comment 12 Itamar Heim 2012-10-17 05:37:19 UTC
michael, per your comment 5, can you please put a sample of updating multi line content and getting it back as multiline?

thanks,
  Itamar

Comment 13 Michael Pasternak 2012-10-17 08:27:16 UTC
(In reply to comment #12)
> michael, per your comment 5, can you please put a sample of updating multi
> line content and getting it back as multiline?
> 
> thanks,
>   Itamar


* using FF REST extension

vm before
=========
GET http://localhost:8080/api/vms/f409c734-65f2-4d7c-b25b-3e285d8d5a76

<vm id="f409c734-65f2-4d7c-b25b-3e285d8d5a76" href="/api/vms/f409c734-65f2-4d7c-b25b-3e285d8d5a76">
    <name>iscsi_desktop</name>
    <type>desktop</type>
    <status>
        <state>down</state>
    </status>
    ...
</vm>

request
=======
PUT http://localhost:8080/api/vms/f409c734-65f2-4d7c-b25b-3e285d8d5a76

<vm>
  <payloads>
    <payload type="floppy">
      <file name="payload.txt">
        <content>
          content here1
          content here2
          content here3
        </content>
      </file>
    </payload>
  </payloads>
</vm>

vm after
========
GET http://localhost:8080/api/vms/f409c734-65f2-4d7c-b25b-3e285d8d5a76

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<vm id="f409c734-65f2-4d7c-b25b-3e285d8d5a76" href="/api/vms/f409c734-65f2-4d7c-b25b-3e285d8d5a76">
    <name>iscsi_desktop</name>
    <type>desktop</type>
    <status>
        <state>down</state>
    </status>
    ...
    <payloads>
        <payload type="floppy">
            <file name="payload.txt">
                <content>
          content here1
          content here2
          content here3
                </content>
            </file>
        </payload>
    </payloads>
    ...
</vm>

Comment 14 Itamar Heim 2012-10-17 08:34:04 UTC
geert - please review comment 13

Comment 15 Geert Jansen 2012-10-17 10:02:22 UTC
Regarding comment 13, multi-line input may work now, but this BZ is about accepting *binary* input for the vmpayload feature.

Even using CDATA, you cannot pass binary input.

Comment 16 Michael Pasternak 2012-10-17 12:17:13 UTC
(In reply to comment #15)
> Regarding comment 13, multi-line input may work now, but this BZ is about
> accepting *binary* input for the vmpayload feature.
> 
> Even using CDATA, you cannot pass binary input.

WORKS-FOR-ME (Geert, i think the problem is in your client):

request:
=======
PUT http://localhost:8080/api/vms/f409c734-65f2-4d7c-b25b-3e285d8d5a76

<vm>
  <payloads>
    <payload type="floppy">
      <file name="payload.txt">
        <content>
<![CDATA[
^?ELF^B^A^A^@^@^@^@^@^@^@^@^@^B^@>^@^A^@^@^@<D0>^_@^@^@^@^@^@@^@^@^@^@^@^@^@<U+0620>^@^@^@^@^@^@^@^@^@^@@^@8^@^H^@@^@^_^@^^^@^F^@^@^@^E^@^@^@@^@^@^@^@^@^@^@@^@
@^@^@^@^@^@@^@@^@^@^@^@^@<C0>^A^@^@^@^@^@^@<C0>^A^@^@^@^@^@^@^H^@^@^@^@^@^@^@^C^@^@^@^D^@^@^@^@^B^@^@^@^@^@^@^@^B@^@^@^@^@^@^@^B@^@^@^@^@^@^\^@^@^@^@^@^@^@^\^@
^@^@^@^@^@^@^A^@^@^@^@^@^@^@^A^@^@^@^E^@^@^@^@^@^@^@^@^@^@^@^@^@@^@^@^@^@^@^@^@@^@^@^@^@^@><8D>^@^@^@^@^@^@><8D>^@^@^@^@^@^@^@^@ ^@^@^@^@^@^A^@^@^@^F^@^@^@^@
<90>^@^@^@^@^@^@^@<90>`^@^@^@^@^@^@<90>`^@^@^@^@^@<E0>^F^@^@^@^@^@^@<98>8^A^@^@^@^@^@^@^@ ^@^@^@^@^@^B^@^@^@^F^@^@^@(<90>^@^@^@^@^@^@(<90>`^@^@^@^@^@(<90>`^@^@
^@^@^@<A0>^A^@^@^@^@^@^@<A0>^A^@^@^@^@^@^@^H^@^@^@^@^@^@^@^D^@^@^@^D^@^@^@^\^B^@^@^@^@^@^@^\^B@^@^@^@^@^@^\^B@^@^@^@^@^@D^@^@^@^@^@^@^@D^@^@^@^@^@^@^@^D^@^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api/vms/f409c734-65f2-4d7c-b25b-3e285d8d5a76

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<vm id="f409c734-65f2-4d7c-b25b-3e285d8d5a76" href="/api/vms/f409c734-65f2-4d7c-b25b-3e285d8d5a76">
    <name>iscsi_desktop</name>
    <type>desktop</type>
    <status>
        <state>down</state>
    </status>
    <payloads>
        <payload type="floppy">
            <file name="payload.txt">
                <content>

^?ELF^B^A^A^@^@^@^@^@^@^@^@^@^B^@&gt;^@^A^@^@^@&lt;D0&gt;^_@^@^@^@^@^@@^@^@^@^@^@^@^@&lt;U+0620&gt;^@^@^@^@^@^@^@^@^@^@@^@8^@^H^@@^@^_^@^^^@^F^@^@^@^E^@^@^@@^@^@^@^@^@^@^@@^@
@^@^@^@^@^@@^@@^@^@^@^@^@&lt;C0&gt;^A^@^@^@^@^@^@&lt;C0&gt;^A^@^@^@^@^@^@^H^@^@^@^@^@^@^@^C^@^@^@^D^@^@^@^@^B^@^@^@^@^@^@^@^B@^@^@^@^@^@^@^B@^@^@^@^@^@^\^@^@^@^@^@^@^@^\^@
^@^@^@^@^@^@^A^@^@^@^@^@^@^@^A^@^@^@^E^@^@^@^@^@^@^@^@^@^@^@^@^@@^@^@^@^@^@^@^@@^@^@^@^@^@&gt;&lt;8D&gt;^@^@^@^@^@^@&gt;&lt;8D&gt;^@^@^@^@^@^@^@^@ ^@^@^@^@^@^A^@^@^@^F^@^@^@^@
&lt;90&gt;^@^@^@^@^@^@^@&lt;90&gt;`^@^@^@^@^@^@&lt;90&gt;`^@^@^@^@^@&lt;E0&gt;^F^@^@^@^@^@^@&lt;98&gt;8^A^@^@^@^@^@^@^@ ^@^@^@^@^@^B^@^@^@^F^@^@^@(&lt;90&gt;^@^@^@^@^@^@(&lt;90&gt;`^@^@^@^@^@(&lt;90&gt;`^@^@
^@^@^@&lt;A0&gt;^A^@^@^@^@^@^@&lt;A0&gt;^A^@^@^@^@^@^@^H^@^@^@^@^@^@^@^D^@^@^@^D^@^@^@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@^@^@^@^@^@^@^@^@^@&lt;FC&gt;^@^@^@^R^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
^@^@^@d^A^@^@^R^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^Z^A^@^@^R^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@&lt;D0&gt;^A^@^@^R^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^N^@^@^@
 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^]^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@&lt;DE&gt;^@^@^@^R^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@U^B^@^@^R^@^@^@^@^@^@^@
^@^@^@^@^@^@^@^@^@^@^@^@&lt;83&gt;^@^@^@^R^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@v^@^@^@^R^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^C^B^@^@^R^@^@^@^@^@^@^@^@^@^@^@^@^@^@
^@^@^@^@^@&lt;F4&gt;^@^@^@^R^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@X^A^@^@^R^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@&lt;9B&gt;^@^@^@^R^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@

        </content>
            </file>
        </payload>
    </payloads>
    ...
</vm>

Comment 17 Geert Jansen 2012-10-17 12:41:23 UTC
Michael, please try to upload a file that contains the characters ']]>'. This will not work.

Also, the *output* of the API above, will very likely be invalid XML, unless RESTeasy inserts CDATA on output too.

Comment 18 Michael Pasternak 2012-10-17 13:04:57 UTC
(In reply to comment #17)
> Michael, please try to upload a file that contains the characters ']]>'.
> This will not work.

indeed, - it's explicitly forbidden by spec., workaround will be allowing
file upload via dedicated endpoint rather than using xml element for this.

also it means that we won't be able displaying it.

i guess for now we can state that we support only text files and
binary is a TP.

> 
> Also, the *output* of the API above, will very likely be invalid XML, unless
> RESTeasy inserts CDATA on output too.

this output fetched from my server.

Comment 19 Geert Jansen 2012-10-17 13:14:50 UTC
Can we do this: add a encoding="base64" attribute to <content>, and if set, base64-decode the contents? Should be a few lines of Java code.

Comment 20 Michael Pasternak 2012-10-17 13:31:56 UTC
(In reply to comment #19)
> Can we do this: add a encoding="base64" attribute to <content>, and if set,
> base64-decode the contents? Should be a few lines of Java code.

we can, but it's not so user friendly, now when i'm thinking about this, we modelled entire feature incorrectly,

it was suppose to be sub-collection/resource of vm, this way we would have
/api/vms/xxx/payloads endpoint for uploads (also it adds tone of garbage to
vm representation on GET):

/api/vms/xxx/payloads
  <payloads>
    <payload type="floppy" id=yyy>
      <file name="payload.txt">
        <content>
          ...
        </content>
      </file>
    </payload>
  </payloads>

/api/vms/xxx/payloads/yyy
  <payload type="floppy" id=yyy>
    <file name="payload.txt">
      <content>
        ...
      </content>
    </file>
  </payload>

if we want changing it, the time is now, or we will have to carry this design
for next few versions, andy/simon/itamar/geert?

Comment 21 Geert Jansen 2012-10-17 14:04:48 UTC
Your proposed changes make sense. However, this does not remove the need for base64 encoded <content>.

Comment 22 Michael Pasternak 2012-10-17 14:13:05 UTC
(In reply to comment #21)
> Your proposed changes make sense. However, this does not remove the need for
> base64 encoded <content>.

why? you will be able uploading binary file as-is, without converting
it to text and/or encoding.

Comment 23 Geert Jansen 2012-10-17 14:48:19 UTC
If we keep the logic, then the "payloads" collection will contain <payload> resources that itself are XML and contain a <file> child element with a <content> grandchild element.

Or do you want a "content" sub-resource below the payload resource, i.e "/api/vms/xxx/payloads/yyy/contents"?

Comment 24 Itamar Heim 2012-10-17 22:40:55 UTC
geert - can you explain the use case for binary input? you do remember it is limited to 16KB? it is not intended for binary upload in general?

michael - we don't have an id per payload (other than the file id maybe)?

Comment 25 Michael Pasternak 2012-10-18 06:53:43 UTC
(In reply to comment #24)
> geert - can you explain the use case for binary input? you do remember it is
> limited to 16KB? it is not intended for binary upload in general?
> 
> michael - we don't have an id per payload (other than the file id maybe)?

not a problem, i can create UUID from the file name 
(it's unique - thanks to file system)

Comment 26 Michael Pasternak 2012-10-18 07:03:38 UTC
(In reply to comment #23)
> If we keep the logic, then the "payloads" collection will contain <payload>
> resources that itself are XML and contain a <file> child element with a
> <content> grandchild element.
> 
> Or do you want a "content" sub-resource below the payload resource, i.e
> "/api/vms/xxx/payloads/yyy/contents"?

i planned [1], but your proposal even better, this way we can restrict
viewing content nicely, i guess the question now "if user should see payloads?"
or it available for admins only and we can stay with [1]. 

[1] /api/vms/xxx/payloads/yyy

  <payload type="floppy" id=yyy>
    <file name="payload.txt">
      <content>
        ...
      </content>
    </file>
  </payload>

Comment 27 Geert Jansen 2012-10-22 19:39:26 UTC
If you do your proposal [1] then you still need to encode the <contents> section, right? I am for your proposal by the way, i do not want to introduce a separate "contents" resource.

Comment 28 Geert Jansen 2012-10-22 19:40:18 UTC
Regarding comment 24: yes i realize this is limited to small files. But we still need binary input.