From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v2 3/6] libxc/migration: Be rather stricter with illformed callers Date: Mon, 11 May 2015 12:47:52 +0100 Message-ID: <555096E8.3050800@citrix.com> References: <1431119675-23847-1-git-send-email-andrew.cooper3@citrix.com> <1431119675-23847-4-git-send-email-andrew.cooper3@citrix.com> <1431343998.8263.31.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1431343998.8263.31.camel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: Wei Liu , Yang Hongyang , Ian Jackson , Xen-devel List-Id: xen-devel@lists.xenproject.org On 11/05/15 12:33, Ian Campbell wrote: > On Fri, 2015-05-08 at 22:14 +0100, Andrew Cooper wrote: >> The migration code itself should be able to validly assume all mandatory >> callbacks are set up. >> >> Signed-off-by: Andrew Cooper >> CC: Ian Campbell >> CC: Ian Jackson >> CC: Wei Liu >> CC: Yang Hongyang >> --- >> tools/libxc/xc_sr_save.c | 4 ++++ >> tools/libxc/xc_sr_save_x86_hvm.c | 7 ------- >> 2 files changed, 4 insertions(+), 7 deletions(-) >> >> diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c >> index 5d9c267..83f0591 100644 >> --- a/tools/libxc/xc_sr_save.c >> +++ b/tools/libxc/xc_sr_save.c >> @@ -738,6 +738,10 @@ int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom, >> ctx.save.max_iterations = 5; >> ctx.save.dirty_threshold = 50; >> >> + /* Sanity checks for callbacks. */ >> + if ( hvm ) >> + assert(callbacks->switch_qemu_logdirty); > assert(!hvm || callbacks->switch_qemu_logdirty) > > ? I would argue that the former is far easier to read. The intention for this, and a subsequent patch, is "if (some option) assert(mandatory callbacks for option)" ~Andrew > >> + >> IPRINTF("In experimental %s", __func__); >> DPRINTF("fd %d, dom %u, max_iters %u, max_factor %u, flags %u, hvm %d", >> io_fd, dom, max_iters, max_factor, flags, hvm); >> diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xc_sr_save_x86_hvm.c >> index 8baa104..58efdb9 100644 >> --- a/tools/libxc/xc_sr_save_x86_hvm.c >> +++ b/tools/libxc/xc_sr_save_x86_hvm.c >> @@ -166,13 +166,6 @@ static int x86_hvm_setup(struct xc_sr_context *ctx) >> { >> xc_interface *xch = ctx->xch; >> >> - if ( !ctx->save.callbacks->switch_qemu_logdirty ) >> - { >> - ERROR("No switch_qemu_logdirty callback provided"); >> - errno = EINVAL; >> - return -1; >> - } >> - >> if ( ctx->save.callbacks->switch_qemu_logdirty( >> ctx->domid, 1, ctx->save.callbacks->data) ) >> { >