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