qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 3/8] migration: support to detect compression an


From: Xiao Guangrong
Subject: Re: [Qemu-devel] [PATCH 3/8] migration: support to detect compression and decompression errors
Date: Fri, 16 Mar 2018 16:25:25 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0



On 03/15/2018 07:29 PM, Dr. David Alan Gilbert wrote:

@@ -1051,11 +1052,13 @@ static int do_compress_ram_page(QEMUFile *f, z_stream 
*stream, RAMBlock *block,
  {
      RAMState *rs = ram_state;
      int bytes_sent, blen;
-    uint8_t *p = block->host + (offset & TARGET_PAGE_MASK);
+    uint8_t buf[TARGET_PAGE_SIZE], *p;

That should be malloc'd somewhere rather than be on the stack; it's a
bit big and also there are architectures where TARGET_PAGE_SIZE isn't
compile time constant.


Okay, i will allocate a internal buffer for each thread...

(Also, please use g_try_malloc rather than g_malloc on larger chunks,
since g_try_malloc will return NULL so you can fail nicely;  g_malloc is
OK for small things that are very unlikely to fail).

Other than that, I think the patch is fine.

Thank you, Dave!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]