From: Chris Wright Subject: Re: [RFC PATCH 5/6] savevm: Migrate RAM based on name/offset Date: Tue, 8 Jun 2010 13:54:47 -0700 Message-ID: <20100608205447.GP28492@x200.localdomain> References: <20100608191447.4451.47795.stgit@localhost.localdomain> <20100608191633.4451.59848.stgit@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws, kvm@vger.kernel.org, quintela@redhat.com, chrisw@redhat.com To: Alex Williamson Return-path: Received: from mx1.redhat.com ([209.132.183.28]:9761 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756535Ab0FHU5j (ORCPT ); Tue, 8 Jun 2010 16:57:39 -0400 Content-Disposition: inline In-Reply-To: <20100608191633.4451.59848.stgit@localhost.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: * 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