From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZADjv-00079r-9C for qemu-devel@nongnu.org; Wed, 01 Jul 2015 04:51:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZADjr-0007mv-Ro for qemu-devel@nongnu.org; Wed, 01 Jul 2015 04:51:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47290) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZADjr-0007mp-Lr for qemu-devel@nongnu.org; Wed, 01 Jul 2015 04:51:27 -0400 Date: Wed, 1 Jul 2015 09:51:22 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20150701085122.GB2137@work-vm> References: <1434043048-4444-1-git-send-email-dgilbert@redhat.com> <1434043048-4444-8-git-send-email-dgilbert@redhat.com> <87vbe41cv9.fsf@neno.neno> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87vbe41cv9.fsf@neno.neno> Subject: Re: [Qemu-devel] [PATCH v2 07/12] Rework ram_control_load_hook to hook during block load List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: amit.shah@redhat.com, arei.gonglei@huawei.com, qemu-devel@nongnu.org, mrhines@us.ibm.com * Juan Quintela (quintela@redhat.com) wrote: > "Dr. David Alan Gilbert (git)" wrote: > > From: "Dr. David Alan Gilbert" > > > > We need the names of RAMBlocks as they're loaded for RDMA, > > reuse a slightly modified ram_control_load_hook: > > a) Pass a 'data' parameter to use for the name in the block-reg > > case > > b) Only some hook types now require the presence of a hook function. > > > > Signed-off-by: Dr. David Alan Gilbert > > > @@ -1569,6 +1569,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) > > error_report_err(local_err); > > } > > } > > + ram_control_load_hook(f, RAM_CONTROL_BLOCK_REG, > > + block->idstr); > > break; > > } > > } > > @@ -1637,7 +1639,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) > > break; > > default: > > if (flags & RAM_SAVE_FLAG_HOOK) { > > - ram_control_load_hook(f, flags); > > + ram_control_load_hook(f, RAM_CONTROL_HOOK, NULL); > > Using a function in only two places, and passing two additional > parameters for that .... > > > +static int rdma_load_hook(QEMUFile *f, void *opaque, uint64_t flags, void *data) > > +{ > > + switch (flags) { > > + case RAM_CONTROL_BLOCK_REG: > > + /* TODO A later patch */ > > + return 0; > > + break; > > + > > + case RAM_CONTROL_HOOK: > > + return qemu_rdma_registration_handle(f, opaque); > > + > > + default: > > + /* Shouldn't be called with any other values */ > > + abort(); > > + } > > And you are doing two completely different things depending of the flag .... The other way would be to add a new function pointer to qemu_file and wire up the new pointer. It didn't seem any prettier. Dave > Later, Juan. -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK