From: Yang Zhong <yang.zhong@intel.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: yang.zhong@intel.com, pbonzini@redhat.com, eblake@redhat.com,
qemu-devel@nongnu.org, seanjc@google.com
Subject: Re: [PATCH v2 1/3] monitor: Add HMP and QMP interfaces
Date: Thu, 16 Sep 2021 14:14:54 +0800 [thread overview]
Message-ID: <20210916061454.GC31727@yangzhon-Virtual> (raw)
In-Reply-To: <YT9RKFjKyI+FThq0@redhat.com>
On Mon, Sep 13, 2021 at 02:24:56PM +0100, Daniel P. Berrangé wrote:
> On Mon, Sep 13, 2021 at 08:52:28PM +0800, Yang Zhong wrote:
> > On Mon, Sep 13, 2021 at 01:56:13PM +0100, Daniel P. Berrangé wrote:
> > > On Mon, Sep 13, 2021 at 02:48:37PM +0200, Paolo Bonzini wrote:
> > > > On 13/09/21 11:35, Daniel P. Berrangé wrote:
> > > > > > g_autoptr(Error) err = NULL
> > > > > I was mistaken here - Error shouldn't use g_autoptr, just
> > > > >
> > > > > Error err = NULL;
> > > > >
> > > > > > > + SGXInfo *info = qmp_query_sgx(NULL);
> > > > > > Pass in &err not NULL;
> > > > > >
> > > > > > Also declare it with 'g_autoptr(SGXInfo) info = ...'
> > > > > >
> > > > > > And then
> > > > > >
> > > > > > if (err) {
> > > > > > monitor_printf(mon, "%s\n", error_get_pretty(err);
> > > > > Then use the simpler:
> > > > >
> > > > > error_report_err(err);
> > > >
> > > > Indeed.
> > > >
> > > > That said, more long term (but this is something Coccinelle could help with)
> > > > perhaps error_report_err should not free the error, and instead we should
> > > > use g_autoptr(Error) in the callers. I don't like functions that do not
> > > > have free in their name and yet free a pointer...
> > >
> > > Yes, this error_report_err surprises me every 6 months when I
> > > come to deal with it. So I think using g_autoptr would be a
> > > nice replacement, with no additional burden in terms of lines
> > > of code in callers too.
> > >
> >
> > Do we need call qapi_free_SGXInfo(info) here?
> >
> > In previous code design, the code like below:
> >
> > SGXInfo *info = qmp_query_sgx(&err);
> > ......
> > qapi_free_SGXInfo(info);
>
> I suggested "g_autoptr(SGXInfo) info" for the declaration to avoid
> the need for qapi_free_SGXInfo calls
>
Daniel, thanks!
Paolo, i checked the sgx branch of your gitlab, we need add this definition
"g_autoptr(SGXInfo) info" into hmp_info_sgx() function. thanks!
Yang
>
> Regards,
> Daniel
> --
> |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org -o- https://fstop138.berrange.com :|
> |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2021-09-16 6:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-10 10:22 [PATCH v2 0/3] The HMP/QMP interfaces in Qemu SGX Yang Zhong
2021-09-10 10:22 ` [PATCH v2 1/3] monitor: Add HMP and QMP interfaces Yang Zhong
2021-09-10 12:39 ` Philippe Mathieu-Daudé
2021-09-13 10:37 ` Yang Zhong
2021-09-13 12:42 ` Paolo Bonzini
2021-09-10 13:46 ` Daniel P. Berrangé
2021-09-13 9:35 ` Daniel P. Berrangé
2021-09-13 10:46 ` Yang Zhong
2021-09-13 12:48 ` Paolo Bonzini
2021-09-13 12:56 ` Daniel P. Berrangé
2021-09-13 12:52 ` Yang Zhong
2021-09-13 13:24 ` Daniel P. Berrangé
2021-09-16 6:14 ` Yang Zhong [this message]
2021-09-10 10:22 ` [PATCH v2 2/3] qmp: Add the qmp_query_sgx_capabilities() Yang Zhong
2021-09-10 12:41 ` Philippe Mathieu-Daudé
2021-09-13 10:34 ` Yang Zhong
2021-09-10 10:22 ` [PATCH v2 3/3] pc: Cleanup the SGX definitions Yang Zhong
2021-09-10 14:15 ` [PATCH v2 0/3] The HMP/QMP interfaces in Qemu SGX Paolo Bonzini
2021-09-10 14:21 ` Daniel P. Berrangé
2021-09-10 19:10 ` Paolo Bonzini
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=20210916061454.GC31727@yangzhon-Virtual \
--to=yang.zhong@intel.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=seanjc@google.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).