From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avgBn-0007Cw-3P for qemu-devel@nongnu.org; Thu, 28 Apr 2016 03:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avgBj-0001n6-T4 for qemu-devel@nongnu.org; Thu, 28 Apr 2016 03:16:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52396) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avgBj-0001mw-Kc for qemu-devel@nongnu.org; Thu, 28 Apr 2016 03:16:39 -0400 References: <1460977906-25218-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> <1460977906-25218-2-git-send-email-zhangchen.fnst@cn.fujitsu.com> <5721B379.5080809@redhat.com> From: Jason Wang Message-ID: <5721B8D0.3030700@redhat.com> Date: Thu, 28 Apr 2016 15:16:32 +0800 MIME-Version: 1.0 In-Reply-To: <5721B379.5080809@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH V3 1/4] colo-compare: introduce colo compare initlization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Zhang Chen , qemu devel Cc: Li Zhijian , Gui jianfeng , "eddie.dong" , zhanghailiang , "Dr. David Alan Gilbert" , Yang Hongyang On 04/28/2016 02:53 PM, Jason Wang wrote: > +static void compare_set_outdev(Object *obj, const char *value, Error **errp) > > +{ > > + CompareState *s = COLO_COMPARE(obj); > > + > > + g_free(s->outdev); > > + s->outdev = g_strdup(value); > > +} > > + > > +/* > > + * called from the main thread on the primary > > + * to setup colo-compare. > > + */ > > +static void colo_compare_complete(UserCreatable *uc, Error **errp) > > +{ > > + CompareState *s = COLO_COMPARE(uc); > > + > > + if (!s->pri_indev || !s->sec_indev || !s->outdev) { > > + error_setg(errp, "colo compare needs 'primary_in' ," > > + "'secondary_in','outdev' property set"); > > + return; > > + } else if (!strcmp(s->pri_indev, s->outdev) || > > + !strcmp(s->sec_indev, s->outdev) || > > + !strcmp(s->pri_indev, s->sec_indev)) { > > + error_setg(errp, "'indev' and 'outdev' could not be same " > > + "for compare module"); > > + return; > > + } > > + > > + s->chr_pri_in = qemu_chr_find(s->pri_indev); > > + if (s->chr_pri_in == NULL) { > > + error_setg(errp, "Primary IN Device '%s' not found", > > + s->pri_indev); > > + return; > > + } > > + > > + s->chr_sec_in = qemu_chr_find(s->sec_indev); > > + if (s->chr_sec_in == NULL) { > > + error_setg(errp, "Secondary IN Device '%s' not found", > > + s->sec_indev); > > + return; > > + } > > + > > + s->chr_out = qemu_chr_find(s->outdev); > > + if (s->chr_out == NULL) { > > + error_setg(errp, "OUT Device '%s' not found", s->outdev); > > + return; > > + } > > + > > + qemu_chr_fe_claim_no_fail(s->chr_pri_in); > > + qemu_chr_add_handlers(s->chr_pri_in, compare_chr_can_read, > > + compare_pri_chr_in, NULL, s); > > + > > + qemu_chr_fe_claim_no_fail(s->chr_sec_in); > > + qemu_chr_add_handlers(s->chr_sec_in, compare_chr_can_read, > > + compare_sec_chr_in, NULL, s); > > + Btw, what's the reason of handling this in main loop? I thought it would be better to do this in colo thread? Otherwise, you need lots of extra synchronizations? > > + qemu_chr_fe_claim_no_fail(s->chr_out); > > + QTAILQ_INSERT_TAIL(&net_compares, s, next); > > + > > + return; > > +}