From: "Benoît Canet" <benoit.canet@irqsave.net>
To: Eric Blake <eblake@redhat.com>
Cc: "Benoît Canet" <benoit.canet@irqsave.net>,
kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com,
mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH V2 2/3] qmp: Make Quorum error events more palatable.
Date: Sat, 22 Feb 2014 03:09:29 +0100 [thread overview]
Message-ID: <20140222020929.GA14498@irqsave.net> (raw)
In-Reply-To: <53080069.8080600@redhat.com>
The Friday 21 Feb 2014 à 18:42:01 (-0700), Eric Blake wrote :
> On 02/21/2014 06:20 PM, Benoît Canet wrote:
> > Insert quorum QMP events documentation alphabetically.
> >
> > Also change the "ret" errno value by an optional "error" being an strerror(-ret)
> > in the QUORUM_REPORT_BAD qmp event.
> >
> > Signed-off-by: Benoit Canet <benoit@irqsave.net>
> > ---
>
> > assert(node_name);
> > - data = qobject_from_jsonf("{ 'ret': %d"
> > - ", 'node-name': %s"
> > + data = 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_sectors);
> > + if (ret < 0) {
> > + QDict *dict = 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) != 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 for the
error handling.
Best regards
Benoît
>
> > 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 = NULL;
> if (ret < 0)
> str = strerror(-ret);
> data = 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
>
next prev parent reply other threads:[~2014-02-22 2:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-22 1:20 [Qemu-devel] [PATCH V2 0/3] Fix some quorum nits after merge Benoît Canet
2014-02-22 1:20 ` [Qemu-devel] [PATCH V2 1/3] qmp: Fix BlockdevOptionQuorum Benoît Canet
2014-02-22 1:20 ` [Qemu-devel] [PATCH V2 2/3] qmp: Make Quorum error events more palatable Benoît Canet
2014-02-22 1:42 ` Eric Blake
2014-02-22 2:09 ` Benoît Canet [this message]
2014-02-22 2:15 ` Eric Blake
2014-02-22 1:20 ` [Qemu-devel] [PATCH V2 3/3] qemu-io-test: Disable Quorum test when not compiled in Benoît Canet
2014-02-22 7:38 ` Fam Zheng
2014-02-22 11:58 ` Benoît Canet
2014-02-22 16:00 ` Fam Zheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140222020929.GA14498@irqsave.net \
--to=benoit.canet@irqsave.net \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).