[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC
From: |
Jes Sorensen |
Subject: |
[Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC |
Date: |
Tue, 07 Dec 2010 15:18:28 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Lightning/1.0b3pre Thunderbird/3.1.6 |
On 12/03/10 19:03, Michael Roth wrote:
> Add RPC to retrieve a guest file. This interface is intended
> for smaller reads like peeking at logs and /proc and such.
I think you need to redesign your approach here..... see below.
In 06/21 you had:
+#define VA_GETFILE_MAX 1 << 30
> + while ((ret = read(fd, buf, VA_FILEBUF_LEN)) > 0) {
> + file_contents = qemu_realloc(file_contents, count + VA_FILEBUF_LEN);
> + memcpy(file_contents + count, buf, ret);
UH OH!
realloc will do a malloc and a memcpy of the data, this is going to turn
into a really nasty malloc memcpy loop if someone tries to transfer a
large file using this method. You could end up with almost 4GB of
parallel allocations for a guest that might have been configured as a
1GB guest. This would allow the guest to effectively blow the expected
memory consumption out of the water. It's not exactly going to be fast
either :(
Maybe use a tmp file, and write data out to that as you receive it to
avoid the malloc ballooning.
Jes
- [Qemu-devel] [RFC][PATCH v5 03/21] virtagent: common code for managing client/server rpc jobs, (continued)
- [Qemu-devel] [RFC][PATCH v5 03/21] virtagent: common code for managing client/server rpc jobs, Michael Roth, 2010/12/03
- [Qemu-devel] [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Michael Roth, 2010/12/03
- [Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Adam Litke, 2010/12/06
- [Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC,
Jes Sorensen <=
- [Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Adam Litke, 2010/12/07
- [Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Jes Sorensen, 2010/12/08
- [Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Adam Litke, 2010/12/09
- [Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Michael Roth, 2010/12/09
- [Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Jes Sorensen, 2010/12/10
[Qemu-devel] [RFC][PATCH v5 09/21] virtagent: add va.getdmesg RPC, Michael Roth, 2010/12/03