qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Lei Li <lilei@linux.vnet.ibm.com>
To: "Michael R. Hines" <mrhines@linux.vnet.ibm.com>
Cc: aarcange@redhat.com, aliguori@us.ibm.com, quintela@redhat.com,
	qemu-devel@nongnu.org, lagarcia@br.ibm.com, pbonzini@redhat.com,
	rcj@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH 04/12] arch_init: introduce ram_page_save()
Date: Mon, 05 Aug 2013 10:49:00 +0800	[thread overview]
Message-ID: <51FF129C.7080707@linux.vnet.ibm.com> (raw)
In-Reply-To: <51FC0B48.8020405@linux.vnet.ibm.com>

On 08/03/2013 03:40 AM, Michael R. Hines wrote:
> On 07/25/2013 04:18 PM, Lei Li wrote:
>> Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
>> ---
>>   arch_init.c |   58 
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 files changed, 58 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch_init.c b/arch_init.c
>> index a8b91ee..a418071 100644
>> --- a/arch_init.c
>> +++ b/arch_init.c
>> @@ -699,6 +699,64 @@ static uint64_t ram_save_pending(QEMUFile *f, 
>> void *opaque, uint64_t max_size)
>>       return remaining_size;
>>   }
>>
>> +/* This is the last block from where we have sent data for local 
>> migration */
>> +static RAMBlock *last_block_local;
>> +static ram_addr_t last_offset_local;
>> +
>> +static int ram_page_save(QEMUFile *f)
>> +{
>> +    RAMBlock *block = last_block_local;
>> +    ram_addr_t offset = last_offset_local;
>> +    MemoryRegion *mr = block->mr;
>> +    int bytes_sent = 0;
>> +
>> +    if (!block) {
>> +        block = QTAILQ_FIRST(&ram_list.blocks);
>> +    }
>> +
>> +    do {
>> +        mr = block->mr;
>> +        uint8_t *p;
>> +        int cont = (block == last_block_local) ? 
>> RAM_SAVE_FLAG_CONTINUE : 0;
>> +
>> +        p = memory_region_get_ram_ptr(mr) + offset;
>> +
>> +        if (is_zero_page(p)) {
>> +            qemu_put_be64(f, offset | cont | RAM_SAVE_FLAG_COMPRESS);
>> +            if (!cont) {
>> +                qemu_put_byte(f, strlen(block->idstr));
>> +                qemu_put_buffer(f, (uint8_t *)block->idstr,
>> +                                strlen(block->idstr));
>> +            }
>> +            qemu_put_byte(f, *p);
>> +            bytes_sent = 1;
>> +        } else {
>> +            qemu_put_be64(f, offset | cont | RAM_SAVE_FLAG_PAGE);
>> +            if (!cont) {
>> +                qemu_put_byte(f, strlen(block->idstr));
>> +                qemu_put_buffer(f, (uint8_t *)block->idstr,
>> +                                strlen(block->idstr));
>> +            }
>> +            qemu_put_buffer(f, p, TARGET_PAGE_SIZE);
>> +            bytes_sent = TARGET_PAGE_SIZE;
>> +        }
>> +
>> +        offset += TARGET_PAGE_SIZE;
>> +        if (offset >= block->length) {
>> +            offset = 0;
>> +            block = QTAILQ_NEXT(block, next);
>> +            if (!block) {
>> +                block = QTAILQ_FIRST(&ram_list.blocks);
>> +            }
>> +        }
>> +    } while (block != last_block_local || offset != last_offset_local);
>> +
>> +    last_block_local = block;
>> +    last_offset_local = offset;
>> +
>> +    return bytes_sent;
>> +}
>> +
>>   static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
>>   {
>>       int ret, rc = 0;
>
> Seems like there's a lot of duplicate code.
>
> We have new hooks to override the way memory is saved in arch_init.c
>
> See the QEMUFileOps......... save_page() / before_ram_iterate() / 
> after_ram_iterate()
>
> You might need to introduce a new "load_page()" pointer in QEMUFileOps.
>
> Then all this code can be private to migration-local.c

Hi Michael,

This implementation was based on the tree that rdma migration you added have
not been merged...

Yes, Paolo also suggested that reuses the rdma hooks and I am trying to figure
it out. Your comments really helps, thanks for your suggestions!
  

>
> - Michael
>
>
>


-- 
Lei

  reply	other threads:[~2013-08-05  2:50 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-25 20:18 [Qemu-devel] [PATCH 0/12 RFC v2] Localhost migration Lei Li
2013-07-25 20:18 ` [Qemu-devel] [PATCH 01/12] migration: export MIG_STATE_xxx flags Lei Li
2013-07-25 20:18 ` [Qemu-devel] [PATCH 02/12] savevm: export qemu_save_device_state() Lei Li
2013-07-25 20:18 ` [Qemu-devel] [PATCH 03/12] rename is_active to is_block_active Lei Li
2013-07-25 20:18 ` [Qemu-devel] [PATCH 04/12] arch_init: introduce ram_page_save() Lei Li
2013-08-02 19:40   ` Michael R. Hines
2013-08-05  2:49     ` Lei Li [this message]
2013-07-25 20:18 ` [Qemu-devel] [PATCH 05/12] arch_init: introduce ram_save_local() Lei Li
2013-08-02 19:42   ` Michael R. Hines
2013-08-05  3:27     ` Lei Li
2013-07-25 20:18 ` [Qemu-devel] [PATCH 06/12] arch_init: add save_local_setup to savevm_ram_handlers Lei Li
2013-08-02 19:43   ` Michael R. Hines
2013-07-25 20:18 ` [Qemu-devel] [PATCH 07/12] savevm: introduce qemu_savevm_local() Lei Li
2013-08-02 19:48   ` Michael R. Hines
2013-08-05  3:02     ` Lei Li
2013-07-25 20:18 ` [Qemu-devel] [PATCH 08/12] savevm: adjust is_ram check in register_savevm_live() Lei Li
2013-07-25 20:18 ` [Qemu-devel] [PATCH 09/12] migration-local: implementation of outgoing part Lei Li
2013-08-02 19:45   ` Michael R. Hines
2013-08-05  3:18     ` Lei Li
2013-07-25 20:18 ` [Qemu-devel] [PATCH 10/12] migration-local: implementation of incoming part Lei Li
2013-07-25 20:18 ` [Qemu-devel] [PATCH 11/12] migration-local: add option to commandline for incoming-local Lei Li
2013-08-02 19:46   ` Michael R. Hines
2013-08-05  3:21     ` Lei Li
2013-07-25 20:18 ` [Qemu-devel] [PATCH 12/12] hmp: add hmp_localhost_migration interface Lei Li
2013-08-02 19:47   ` Michael R. Hines
2013-08-05  3:22     ` Lei Li
2013-07-26  9:41 ` [Qemu-devel] [PATCH 0/12 RFC v2] Localhost migration Paolo Bonzini
2013-08-05  8:56   ` Lei Li

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=51FF129C.7080707@linux.vnet.ibm.com \
    --to=lilei@linux.vnet.ibm.com \
    --cc=aarcange@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=lagarcia@br.ibm.com \
    --cc=mrhines@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=rcj@linux.vnet.ibm.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).