From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WH223-0008H0-TQ for qemu-devel@nongnu.org; Fri, 21 Feb 2014 21:09:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WH21z-0006HI-Dj for qemu-devel@nongnu.org; Fri, 21 Feb 2014 21:09:35 -0500 Received: from lnantes-156-75-100-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:58696 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WH21z-0006H6-88 for qemu-devel@nongnu.org; Fri, 21 Feb 2014 21:09:31 -0500 Date: Sat, 22 Feb 2014 03:09:29 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140222020929.GA14498@irqsave.net> References: <1393032048-17982-1-git-send-email-benoit.canet@irqsave.net> <1393032048-17982-3-git-send-email-benoit.canet@irqsave.net> <53080069.8080600@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <53080069.8080600@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH V2 2/3] qmp: Make Quorum error events more palatable. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: =?iso-8859-1?Q?Beno=EEt?= Canet , kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com The Friday 21 Feb 2014 =E0 18:42:01 (-0700), Eric Blake wrote : > On 02/21/2014 06:20 PM, Beno=EEt Canet wrote: > > Insert quorum QMP events documentation alphabetically. > > > > Also change the "ret" errno value by an optional "error" being an str= error(-ret) > > in the QUORUM_REPORT_BAD qmp event. > > > > Signed-off-by: Benoit Canet > > --- > > > assert(node_name); > > - data =3D qobject_from_jsonf("{ 'ret': %d" > > - ", 'node-name': %s" > > + data =3D qobject_from_jsonf("{ 'node-name': %s" > > ", 'sector-num': %" PRId64 > > ", 'sectors-count': %d }", > > - ret, node_name, acb->sector_num, acb->= nb_sectors); > > + node_name, acb->sector_num, acb->nb_se= ctors); > > + if (ret < 0) { > > + QDict *dict =3D qobject_to_qdict(data); > > + qdict_put(dict, "error", qstring_from_str(strerror(-ret))); > > + } > > This puts it in dict, but never modifies data... qobject_to_qdict is an enhanced cast. /** * qobject_to_qdict(): Convert a QObject into a QDict */ QDict *qobject_to_qdict(const QObject *obj) { if (qobject_type(obj) !=3D QTYPE_QDICT) return NULL; return container_of(obj, QDict, base); } Also I took this snippet of code from what you pointed me as an example f= or the error handling. Best regards Beno=EEt > > > monitor_protocol_event(QEVENT_QUORUM_REPORT_BAD, data); > > ...but you send data, not dict, over the wire. > > It might be easier to do something like... > > char *str =3D NULL; > if (ret < 0) > str =3D strerror(-ret); > data =3D qobject_from_jsonf("{ 'node-name': %s" > "%s%s%s" > ", 'sector-num': %" PRId64 > ", 'sectors-cont': %d }", > node_name, > str ? ", 'error': \"" : "", str ? str : "", > str ? "\"" : "", > ...); > > -- > Eric Blake eblake redhat com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org >