Skip to content
  • Stefan Hajnoczi's avatar
    7faae95e
    hostmem-file: fix pmem file size check · 7faae95e
    Stefan Hajnoczi authored
    
    
    Commit 314aec4a ("hostmem-file: reject
    invalid pmem file sizes") added a file size check that verifies the
    hostmem object's size parameter against the actual devdax pmem file.
    This is useful because getting the size wrong results in confusing
    errors inside the guest.
    
    However, the code doesn't work properly for files where struct
    stat::st_size is zero.  Hostmem-file's ->alloc() function returns early
    without setting an Error, causing the following assertion failure:
    
      qemu/memory.c:2215: memory_region_get_ram_ptr: Assertion `mr->ram_block' failed.
    
    This patch handles the case where qemu_get_pmem_size() returns 0 but
    there is no error.
    
    Fixes: 314aec4a
    Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20190823135632.25010-1-stefanha@redhat.com>
    Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
    7faae95e
    hostmem-file: fix pmem file size check
    Stefan Hajnoczi authored
    
    
    Commit 314aec4a ("hostmem-file: reject
    invalid pmem file sizes") added a file size check that verifies the
    hostmem object's size parameter against the actual devdax pmem file.
    This is useful because getting the size wrong results in confusing
    errors inside the guest.
    
    However, the code doesn't work properly for files where struct
    stat::st_size is zero.  Hostmem-file's ->alloc() function returns early
    without setting an Error, causing the following assertion failure:
    
      qemu/memory.c:2215: memory_region_get_ram_ptr: Assertion `mr->ram_block' failed.
    
    This patch handles the case where qemu_get_pmem_size() returns 0 but
    there is no error.
    
    Fixes: 314aec4a
    Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20190823135632.25010-1-stefanha@redhat.com>
    Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
Loading