Received: from eggs.gnu.org ([2001:4830:134:3::10]:53935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zzrbf-0003Eo-Nh for qemu-devel@nongnu.org; Fri, 20 Nov 2015 14:44:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zzrbc-0003tl-Ha for qemu-devel@nongnu.org; Fri, 20 Nov 2015 14:44:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58362) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zzrbc-0003th-9s for qemu-devel@nongnu.org; Fri, 20 Nov 2015 14:44:24 -0500 From: Markus Armbruster References: <1448024440-31222-1-git-send-email-armbru@redhat.com> <20151120141950.GI23717@thinpad.lan.raisama.net> <87fv004t2q.fsf@blackfin.pond.sub.org> <20151120152027.GJ23717@thinpad.lan.raisama.net> <87lh9szljx.fsf@blackfin.pond.sub.org> <20151120192622.GK23717@thinpad.lan.raisama.net> Date: Fri, 20 Nov 2015 20:44:21 +0100 In-Reply-To: <20151120192622.GK23717@thinpad.lan.raisama.net> (Eduardo Habkost's message of "Fri, 20 Nov 2015 17:26:22 -0200") Message-ID: <87y4dslalm.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] numa: Clean up query-memdev error handling, plug leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: hutao@cn.fujitsu.com, qemu-devel@nongnu.org, mst@redhat.com Eduardo Habkost writes: > On Fri, Nov 20, 2015 at 05:24:02PM +0100, Markus Armbruster wrote: >> Eduardo Habkost writes: >> >> > On Fri, Nov 20, 2015 at 03:57:17PM +0100, Markus Armbruster wrote: >> >> Eduardo Habkost writes: >> >> >> >> > On Fri, Nov 20, 2015 at 02:00:40PM +0100, Markus Armbruster wrote: >> >> >> qmp_query_memdev() doesn't fail. Instead, it returns an empty list. >> >> >> That's wrong. >> >> >> >> >> >> Two error paths: >> >> >> >> >> >> * When object_get_objects_root() returns null. It never does, so >> >> >> simply drop the useless error handling. >> >> >> >> >> >> * When query_memdev() fails. This can happen, and the error to return >> >> >> is the one that query_memdev() currently leaks. Passing the error >> >> >> from query_memdev() to qmp_query_memdev() isn't so simple, because >> >> >> object_child_foreach() is in the way. Fixable, but I'd rather not >> >> >> try it in hard freeze. Plug the leak, make up an error, and add a >> >> >> FIXME for the remaining work. >> >> >> >> >> >> Screwed up in commit 76b5d85 "qmp: add query-memdev". >> >> >> >> >> >> Signed-off-by: Markus Armbruster >> >> > >> >> > Reviewed-by: Eduardo Habkost >> >> > >> >> > Do you know how to trigger a query_memdev() error today, or is >> >> > just theoretical? >> >> >> >> Theoretical; I tested by injecting an error with gdb. >> >> >> >> query_memdev() fails exactly when some object_property_get_FOO() fails. >> >> If we decide such a failure would always be a programming error, we can >> >> pass &error_abort and simplify things. Opinions? >> > >> > The hostmem-backend property getters should never fail. Using >> > &error_abort on query_memdev() would make everything simpler. >> > >> > (I would even use the HostMemoryBackend struct fields directly, >> > instead of QOM properties. Is there a good reason to use QOM to >> > fetch the data that's readily available in the C struct?) >> >> I can't see why not, sketch appended. Note that I still go through the >> property for host_nodes, because I couldn't see how to do that simpler. >> If you like this patch, I'll post it as v2. >> >> >> >> numa: Clean up query-memdev error handling >> >> qmp_query_memdev() has two error paths: >> >> * When object_get_objects_root() returns null. It never does, so >> simply drop the useless error handling. >> >> * When query_memdev() fails. It looks like it could, but that's just >> because its code is pointlessly complicated. Simplify it, and drop >> the useless error handling. >> >> Messed up in commit 76b5d85 "qmp: add query-memdev". >> >> Signed-off-by: Markus Armbruster >> --- >> numa.c | 69 ++++++++++-------------------------------------------------------- >> 1 file changed, 10 insertions(+), 59 deletions(-) >> >> diff --git a/numa.c b/numa.c >> index fdfe294..4e9be9f 100644 >> --- a/numa.c >> +++ b/numa.c >> @@ -517,80 +517,31 @@ static int query_memdev(Object *obj, void *opaque) > [...] >> - m->value->prealloc = object_property_get_bool(obj, >> - "prealloc", &err); > [...] >> + m->value->prealloc = backend->prealloc; > > This changes the QMP command result because the property getter > currently[1] returns backend->prealloc || backend->force_prealloc. > > So, I stand corrected: there are at least two cases where using > the QOM property is useful at query_memdev(). Let's just use > &error_abort and keep all the existing object_property_get_*() > calls, then? > > [1] I am not sure this is the right thing to do, but if we're > going to change that, let's do it after 2.5.0. Okay, will do that in v2.