mirror of https://gitee.com/openkylin/qemu.git
virtio-mem: Don't report errors when ram_block_discard_range() fails
Any errors are unexpected and ram_block_discard_range() already properly prints errors. Let's stop manually reporting errors. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Alex Williamson <alex.williamson@redhat.com> Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> Cc: Igor Mammedov <imammedo@redhat.com> Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com> Cc: Peter Xu <peterx@redhat.com> Cc: Auger Eric <eric.auger@redhat.com> Cc: Wei Yang <richard.weiyang@linux.alibaba.com> Cc: teawater <teawaterz@linux.alibaba.com> Cc: Marek Kedzierski <mkedzier@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20210413095531.25603-5-david@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
7a9d5d0282
commit
3aca6380fd
|
@ -246,17 +246,14 @@ static int virtio_mem_set_block_state(VirtIOMEM *vmem, uint64_t start_gpa,
|
|||
uint64_t size, bool plug)
|
||||
{
|
||||
const uint64_t offset = start_gpa - vmem->addr;
|
||||
int ret;
|
||||
RAMBlock *rb = vmem->memdev->mr.ram_block;
|
||||
|
||||
if (virtio_mem_is_busy()) {
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
if (!plug) {
|
||||
ret = ram_block_discard_range(vmem->memdev->mr.ram_block, offset, size);
|
||||
if (ret) {
|
||||
error_report("Unexpected error discarding RAM: %s",
|
||||
strerror(-ret));
|
||||
if (ram_block_discard_range(rb, offset, size)) {
|
||||
return -EBUSY;
|
||||
}
|
||||
}
|
||||
|
@ -345,15 +342,12 @@ static void virtio_mem_resize_usable_region(VirtIOMEM *vmem,
|
|||
static int virtio_mem_unplug_all(VirtIOMEM *vmem)
|
||||
{
|
||||
RAMBlock *rb = vmem->memdev->mr.ram_block;
|
||||
int ret;
|
||||
|
||||
if (virtio_mem_is_busy()) {
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
ret = ram_block_discard_range(rb, 0, qemu_ram_get_used_length(rb));
|
||||
if (ret) {
|
||||
error_report("Unexpected error discarding RAM: %s", strerror(-ret));
|
||||
if (ram_block_discard_range(rb, 0, qemu_ram_get_used_length(rb))) {
|
||||
return -EBUSY;
|
||||
}
|
||||
bitmap_clear(vmem->bitmap, 0, vmem->bitmap_size);
|
||||
|
@ -625,14 +619,8 @@ static int virtio_mem_discard_range_cb(const VirtIOMEM *vmem, void *arg,
|
|||
uint64_t offset, uint64_t size)
|
||||
{
|
||||
RAMBlock *rb = vmem->memdev->mr.ram_block;
|
||||
int ret;
|
||||
|
||||
ret = ram_block_discard_range(rb, offset, size);
|
||||
if (ret) {
|
||||
error_report("Unexpected error discarding RAM: %s", strerror(-ret));
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
return ram_block_discard_range(rb, offset, size) ? -EINVAL : 0;
|
||||
}
|
||||
|
||||
static int virtio_mem_restore_unplugged(VirtIOMEM *vmem)
|
||||
|
|
Loading…
Reference in New Issue