From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZADi3-0005vo-Vh for qemu-devel@nongnu.org; Wed, 01 Jul 2015 04:49:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZADi0-0006MH-De for qemu-devel@nongnu.org; Wed, 01 Jul 2015 04:49:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57887) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZADi0-0006M1-7j for qemu-devel@nongnu.org; Wed, 01 Jul 2015 04:49:32 -0400 From: Juan Quintela In-Reply-To: <1434043048-4444-8-git-send-email-dgilbert@redhat.com> (David Alan Gilbert's message of "Thu, 11 Jun 2015 18:17:23 +0100") References: <1434043048-4444-1-git-send-email-dgilbert@redhat.com> <1434043048-4444-8-git-send-email-dgilbert@redhat.com> Date: Wed, 01 Jul 2015 10:49:30 +0200 Message-ID: <87vbe41cv9.fsf@neno.neno> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2 07/12] Rework ram_control_load_hook to hook during block load Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" Cc: amit.shah@redhat.com, arei.gonglei@huawei.com, qemu-devel@nongnu.org, mrhines@us.ibm.com "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 .... Later, Juan.