physmem: replace function name with __func__ in ram_block_discard_range()

Use __func__ to avoid hard-coded function name.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240125023328.2520888-1-xiaoyao.li@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Xiaoyao Li 2024-01-24 21:33:28 -05:00 committed by Paolo Bonzini
parent 2a1019f209
commit ea18be78a6

View File

@ -3495,16 +3495,15 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)
uint8_t *host_startaddr = rb->host + start; uint8_t *host_startaddr = rb->host + start;
if (!QEMU_PTR_IS_ALIGNED(host_startaddr, rb->page_size)) { if (!QEMU_PTR_IS_ALIGNED(host_startaddr, rb->page_size)) {
error_report("ram_block_discard_range: Unaligned start address: %p", error_report("%s: Unaligned start address: %p",
host_startaddr); __func__, host_startaddr);
goto err; goto err;
} }
if ((start + length) <= rb->max_length) { if ((start + length) <= rb->max_length) {
bool need_madvise, need_fallocate; bool need_madvise, need_fallocate;
if (!QEMU_IS_ALIGNED(length, rb->page_size)) { if (!QEMU_IS_ALIGNED(length, rb->page_size)) {
error_report("ram_block_discard_range: Unaligned length: %zx", error_report("%s: Unaligned length: %zx", __func__, length);
length);
goto err; goto err;
} }
@ -3528,8 +3527,8 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)
* proper error message. * proper error message.
*/ */
if (rb->flags & RAM_READONLY_FD) { if (rb->flags & RAM_READONLY_FD) {
error_report("ram_block_discard_range: Discarding RAM" error_report("%s: Discarding RAM with readonly files is not"
" with readonly files is not supported"); " supported", __func__);
goto err; goto err;
} }
@ -3544,27 +3543,26 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)
* file. * file.
*/ */
if (!qemu_ram_is_shared(rb)) { if (!qemu_ram_is_shared(rb)) {
warn_report_once("ram_block_discard_range: Discarding RAM" warn_report_once("%s: Discarding RAM"
" in private file mappings is possibly" " in private file mappings is possibly"
" dangerous, because it will modify the" " dangerous, because it will modify the"
" underlying file and will affect other" " underlying file and will affect other"
" users of the file"); " users of the file", __func__);
} }
ret = fallocate(rb->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, ret = fallocate(rb->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
start, length); start, length);
if (ret) { if (ret) {
ret = -errno; ret = -errno;
error_report("ram_block_discard_range: Failed to fallocate " error_report("%s: Failed to fallocate %s:%" PRIx64 " +%zx (%d)",
"%s:%" PRIx64 " +%zx (%d)", __func__, rb->idstr, start, length, ret);
rb->idstr, start, length, ret);
goto err; goto err;
} }
#else #else
ret = -ENOSYS; ret = -ENOSYS;
error_report("ram_block_discard_range: fallocate not available/file" error_report("%s: fallocate not available/file"
"%s:%" PRIx64 " +%zx (%d)", "%s:%" PRIx64 " +%zx (%d)",
rb->idstr, start, length, ret); __func__, rb->idstr, start, length, ret);
goto err; goto err;
#endif #endif
} }
@ -3582,25 +3580,23 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length)
} }
if (ret) { if (ret) {
ret = -errno; ret = -errno;
error_report("ram_block_discard_range: Failed to discard range " error_report("%s: Failed to discard range "
"%s:%" PRIx64 " +%zx (%d)", "%s:%" PRIx64 " +%zx (%d)",
rb->idstr, start, length, ret); __func__, rb->idstr, start, length, ret);
goto err; goto err;
} }
#else #else
ret = -ENOSYS; ret = -ENOSYS;
error_report("ram_block_discard_range: MADVISE not available" error_report("%s: MADVISE not available %s:%" PRIx64 " +%zx (%d)",
"%s:%" PRIx64 " +%zx (%d)", __func__, rb->idstr, start, length, ret);
rb->idstr, start, length, ret);
goto err; goto err;
#endif #endif
} }
trace_ram_block_discard_range(rb->idstr, host_startaddr, length, trace_ram_block_discard_range(rb->idstr, host_startaddr, length,
need_madvise, need_fallocate, ret); need_madvise, need_fallocate, ret);
} else { } else {
error_report("ram_block_discard_range: Overrun block '%s' (%" PRIu64 error_report("%s: Overrun block '%s' (%" PRIu64 "/%zx/" RAM_ADDR_FMT")",
"/%zx/" RAM_ADDR_FMT")", __func__, rb->idstr, start, length, rb->max_length);
rb->idstr, start, length, rb->max_length);
} }
err: err: