qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Guoyi Tu <tugy@chinatelecom.cn>
To: "【外部账号】 Fabiano Rosas" <farosas@suse.de>, "Peter Xu" <peterx@redhat.com>
Cc: tugy@chinatelecom.cn, Juan Quintela <quintela@redhat.com>,
	Leonardo Bras <leobras@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH] migrate/ram: let ram_save_target_page_legacy() return if qemu file got error
Date: Thu, 17 Aug 2023 10:19:19 +0800	[thread overview]
Message-ID: <15874e41-fee0-49db-98fc-cf2b545fe7c2@chinatelecom.cn> (raw)
In-Reply-To: <87o7j7kohx.fsf@suse.de>



On 2023/8/16 23:15, 【外部账号】 Fabiano Rosas wrote:
> Peter Xu <peterx@redhat.com> writes:
> 
>> On Tue, Aug 15, 2023 at 07:42:24PM -0300, Fabiano Rosas wrote:
>>> Yep, I see that. I meant explicitly move the code into the loop. Feels a
>>> bit weird to check the QEMUFile for errors first thing inside the
>>> function when nothing around it should have touched the QEMUFile.
>>
>> Valid point.  This reminded me that now we have one indirection into
>> ->ram_save_target_page() which is a hook now.  Putting in the caller will
>> work for all hooks, even though they're not yet exist.
>>
>> But since we don't have any other hooks yet, it'll be the same for now.
>>
>> Acked-by: Peter Xu <peterx@redhat.com>
>>
>> For the long term: there's one more reason to rework qemu_put_byte()/... to
>> return error codes.. Then things like save_normal_page() can simply already
>> return negatives when hit an error.
>>
>> Fabiano - I see that you've done quite a few patches in reworking migration
>> code.  I had that for a long time in my todo, but if you're interested feel
>> free to look into it.
>>
>> IIUC the idea is introducing another similar layer of API for qemufile (I'd
>> call it qemu_put_1|2|4|8(), or anything you can come up better with..) then
>> let migration to switch over to it, with retval reflecting errors.  Then we
>> should be able to drop this patch along with most of the explicit error
>> checks for the qemufile spread all over.
> 
> I was just ranting about this situation in another thread! Yes, we need
> something like that. QEMUFile errors should only be set by code doing
> actual IO and if we want to store the error for other parts of the code
> to use, that should be another interface.
> 
> While reviewing this patch I noticed we have stuff like this:
> 
> pages = ram_find_and_save_block()
> ...
> if (pages < 0) {
>      qemu_file_set_error(f, pages);
>      break;
> }
> 
> So the low-level code sets the error, ram_save_target_page_legacy() sees
> it and returns -1, and this^ code loses all track of the initial error
> and inadvertently turns it into -EPERM!
> 
> I'll try to find some time to start cleaning this up

It sounds very reasonable. the return value of the QEMUFile interface
cannot accurately reflect the actual situation, and the way these
interfaces are being called during the migration process also is a
little bit weird.

I'm glad to see that you have plans to improve these interfaces. If you
need any assistance, I'd be more than happy to be involved.


  reply	other threads:[~2023-08-17  2:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-15  7:21 [PATCH] migrate/ram: let ram_save_target_page_legacy() return if qemu file got error Guoyi Tu
2023-08-15 12:35 ` Fabiano Rosas
2023-08-15 22:19   ` Peter Xu
2023-08-15 22:42     ` Fabiano Rosas
2023-08-16 14:48       ` Peter Xu
2023-08-16 15:15         ` Fabiano Rosas
2023-08-17  2:19           ` Guoyi Tu [this message]
2023-08-17 13:35             ` Peter Xu
2023-08-17 14:29               ` Guoyi Tu
2023-08-17 14:32           ` Guoyi Tu
2023-08-16  2:09     ` Guoyi Tu
     [not found] ` <1289281636.5044.1692148361356.JavaMail.root@jt-retransmission-dep-56f978df86-2gmr2>
2023-08-16  2:01   ` Guoyi Tu
2023-08-16 12:18 ` Fabiano Rosas
2023-09-04 11:55 ` Guoyi Tu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15874e41-fee0-49db-98fc-cf2b545fe7c2@chinatelecom.cn \
    --to=tugy@chinatelecom.cn \
    --cc=farosas@suse.de \
    --cc=leobras@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).