From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtJiA-0007tK-7a for qemu-devel@nongnu.org; Mon, 02 Nov 2015 13:20:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtJi6-0002Uh-Ag for qemu-devel@nongnu.org; Mon, 02 Nov 2015 13:20:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39857) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtJi6-0002UD-6d for qemu-devel@nongnu.org; Mon, 02 Nov 2015 13:20:02 -0500 Date: Mon, 2 Nov 2015 18:19:56 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20151102181955.GB22239@work-vm> References: <1443515898-3594-1-git-send-email-dgilbert@redhat.com> <1443515898-3594-33-git-send-email-dgilbert@redhat.com> <87lhawa2sj.fsf@neno.neno> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87lhawa2sj.fsf@neno.neno> Subject: Re: [Qemu-devel] [PATCH v8 32/54] Postcopy: Maintain sentmap and calculate discard List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: aarcange@redhat.com, liang.z.li@intel.com, qemu-devel@nongnu.org, luis@cs.umu.se, bharata@linux.vnet.ibm.com, amit.shah@redhat.com, pbonzini@redhat.com * Juan Quintela (quintela@redhat.com) wrote: > > @@ -662,6 +672,24 @@ static int save_zero_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset, > > } > > > > /** > > + * ram_find_block_by_id: Find a ramblock by name. > > + * > > + * Returns: The RAMBlock with matching ID, or NULL. > > + */ > > +static RAMBlock *ram_find_block_by_id(const char *id) > > +{ > > + RAMBlock *block; > > + > > + QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { > > + if (!strcmp(id, block->idstr)) { > > + return block; > > + } > > + } > > + > > + return NULL; > > +} > > We don't have this function already..... > > Once here, could we split it in its own patch and use it in ram_load? > > > QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { > if (!strncmp(id, block->idstr, sizeof(id))) { > if (length != block->used_length) { > Error *local_err = NULL; > > ret = qemu_ram_resize(block->offset, length, &local_err); > if (local_err) { > error_report_err(local_err); > } > } > ram_control_load_hook(f, RAM_CONTROL_BLOCK_REG, > block->idstr); > break; > } > } > > if (!block) { > error_report("Unknown ramblock \"%s\", cannot " > "accept migration", id); > ret = -EINVAL; > } > > > We could also use it in: > > host_from_stream_offset Done; replaced both uses and it's now called 'qemu_ram_block_by_name' Dave -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK