Re: [RFC PATCH 5/6] savevm: Migrate RAM based on name/offset

Chris Wright
2010-06-08T20:57:39Z

* Alex Williamson (alex.williamson@redhat.com) wrote:
> @@ -257,7 +272,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
> ram_addr_t addr;
> int flags;
>
> - if (version_id != 3) {
> + if (version_id < 3) {
> return -EINVAL;

Should we clamp to 3 and 4?

> }
>
> @@ -268,23 +283,89 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
> addr &= TARGET_PAGE_MASK;
>
> if (flags & RAM_SAVE_FLAG_MEM_SIZE) {

Does it simplify anything to simply add a new flag?

> - if (addr != ram_bytes_total()) {
> - return -EINVAL;
> + if (version_id == 3) {
> + if (addr != ram_bytes_total()) {
> + return -EINVAL;
> + }
> + } else {
> + /* Synchronize RAM block list */
> + char name[64];
> + ram_addr_t length;
> + ram_addr_t total_ram_bytes = addr;
> +
> + while (total_ram_bytes) {
> + RAMBlock *block;
> + qemu_get_buffer(f, (uint8_t *)name, sizeof(name));
> + length = qemu_get_be64(f);
> +
> + QLIST_FOREACH(block, &ram.blocks, next) {
> + if (!strncmp(name, block->name, sizeof(name))) {
> + if (block->length != length)
> + return -EINVAL;
> + break;
> + }
> + }
> +
> + if (!block) {
> + if (!qemu_ram_alloc(name, length))
> + return -ENOMEM;

Is there any usee to finding blocks in stream such that we simply allocate
them all dynamically?

thanks,
-chris