[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 08/10] migration: handle the error condition
From: |
Peter Xu |
Subject: |
Re: [Qemu-devel] [PATCH v3 08/10] migration: handle the error condition properly |
Date: |
Wed, 8 Aug 2018 13:08:46 +0800 |
User-agent: |
Mutt/1.10.0 (2018-05-17) |
On Tue, Aug 07, 2018 at 05:12:07PM +0800, address@hidden wrote:
> From: Xiao Guangrong <address@hidden>
>
> ram_find_and_save_block() can return negative if any error hanppens,
> however, it is completely ignored in current code
Could you hint me where we'll return an error?
(Anyway I agree that the error handling is not that good, mostly
because the QEMUFile APIs does not provide proper return code, e.g.,
qemu_put_be64 returns void)
>
> Signed-off-by: Xiao Guangrong <address@hidden>
> ---
> migration/ram.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/migration/ram.c b/migration/ram.c
> index 55966bc2c1..09be01dca2 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -2367,7 +2367,8 @@ static int ram_save_host_page(RAMState *rs,
> PageSearchStatus *pss,
> *
> * Called within an RCU critical section.
> *
> - * Returns the number of pages written where zero means no dirty pages
> + * Returns the number of pages written where zero means no dirty pages,
> + * or negative on error
> *
> * @rs: current RAM state
> * @last_stage: if we are at the completion stage
> @@ -3202,6 +3203,12 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
> done = 1;
> break;
> }
> +
> + if (pages < 0) {
> + qemu_file_set_error(f, pages);
> + break;
> + }
> +
> rs->iterations++;
>
> /* we want to check in the 1st loop, just in case it was the 1st time
> @@ -3243,7 +3250,7 @@ out:
> /**
> * ram_save_complete: function called to send the remaining amount of ram
> *
> - * Returns zero to indicate success
> + * Returns zero to indicate success or negative on error
> *
> * Called with iothread lock
> *
> @@ -3254,6 +3261,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
> {
> RAMState **temp = opaque;
> RAMState *rs = *temp;
> + int ret = 0;
>
> rcu_read_lock();
>
> @@ -3274,6 +3282,10 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
> if (pages == 0) {
> break;
> }
> + if (pages < 0) {
> + ret = pages;
> + break;
> + }
> }
>
> flush_compressed_data(rs);
> @@ -3285,7 +3297,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
> qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
> qemu_fflush(f);
>
> - return 0;
> + return ret;
> }
>
> static void ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size,
> --
> 2.14.4
>
Regards,
--
Peter Xu
- [Qemu-devel] [PATCH v3 02/10] migration: fix counting normal page for compression, (continued)
- [Qemu-devel] [PATCH v3 02/10] migration: fix counting normal page for compression, guangrong . xiao, 2018/08/07
- [Qemu-devel] [PATCH v3 03/10] migration: introduce save_zero_page_to_file, guangrong . xiao, 2018/08/07
- [Qemu-devel] [PATCH v3 04/10] migration: drop the return value of do_compress_ram_page, guangrong . xiao, 2018/08/07
- [Qemu-devel] [PATCH v3 05/10] migration: move handle of zero page to the thread, guangrong . xiao, 2018/08/07
- [Qemu-devel] [PATCH v3 06/10] migration: hold the lock only if it is really needed, guangrong . xiao, 2018/08/07
- [Qemu-devel] [PATCH v3 07/10] migration: do not flush_compressed_data at the end of each iteration, guangrong . xiao, 2018/08/07
- [Qemu-devel] [PATCH v3 08/10] migration: handle the error condition properly, guangrong . xiao, 2018/08/07
- Re: [Qemu-devel] [PATCH v3 08/10] migration: handle the error condition properly,
Peter Xu <=
- Re: [Qemu-devel] [PATCH v3 08/10] migration: handle the error condition properly, Dr. David Alan Gilbert, 2018/08/08
- Re: [Qemu-devel] [PATCH v3 08/10] migration: handle the error condition properly, Xiao Guangrong, 2018/08/08
[Qemu-devel] [PATCH v3 09/10] migration: fix calculating xbzrle_counters.cache_miss_rate, guangrong . xiao, 2018/08/07