From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTjyX-0000Ks-I4 for Qemu-devel@nongnu.org; Tue, 08 Oct 2013 22:58:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTjyS-0004EM-Md for Qemu-devel@nongnu.org; Tue, 08 Oct 2013 22:58:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14235) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTjyS-0004E1-EH for Qemu-devel@nongnu.org; Tue, 08 Oct 2013 22:58:08 -0400 Message-ID: <5254C63C.7040704@redhat.com> Date: Tue, 08 Oct 2013 20:58:04 -0600 From: Eric Blake MIME-Version: 1.0 References: <1381286396-30051-1-git-send-email-wudxw@linux.vnet.ibm.com> In-Reply-To: <1381286396-30051-1-git-send-email-wudxw@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="1eVqGCuUngK337p3mbRxEWahq6RFkPmSo" Subject: Re: [Qemu-devel] [PATCH v3] Add interface to traverse the qmp command list by QmpCommand List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark Wu Cc: Michael Roth , Qemu-devel@nongnu.org, Luiz Capitulino This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --1eVqGCuUngK337p3mbRxEWahq6RFkPmSo Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 10/08/2013 08:39 PM, Mark Wu wrote: > In the original code, qmp_get_command_list is used to construct > a list of all commands' name. To get the information of all qga > commands, it traverses the name list and search the command info > with its name. So it can cause O(n^2) in the number of commands. >=20 > This patch adds an interface to traverse the qmp command list by > QmpCommand to replace qmp_get_command_list. It can decrease the > complexity from O(n^2) to O(n). >=20 > Signed-off-by: Mark Wu > --- > v3: > Add an accessor for cmd->name to avoid exposing internals of QmpCom= mand As your two patches are related, I'd send them threaded under one cover letter if you have to respin. But maybe we don't need that... > v2: > 1. Keep the signature of qmp_command_is_enabled (per Eric and Michael)= > 2. Remove the unnecessary pointer castings (per Eric) >=20 > include/qapi/qmp/dispatch.h | 6 ++-- > qapi/qmp-registry.c | 30 +++++------------- > qga/commands.c | 38 +++++++++-------------- > qga/main.c | 75 ++++++++++++++++++-------------------= -------- > 4 files changed, 57 insertions(+), 92 deletions(-) >=20 > -struct GuestAgentInfo *qmp_guest_info(Error **err) > +static void qmp_command_info(QmpCommand *cmd, void *opaque) > { > - while (*cmd_list) { > - cmd_info =3D g_malloc0(sizeof(GuestAgentCommandInfo)); > - cmd_info->name =3D g_strdup(*cmd_list); > - cmd_info->enabled =3D qmp_command_is_enabled(cmd_info->name); > + cmd_info =3D g_malloc0(sizeof(GuestAgentCommandInfo)); > + cmd_info->name =3D g_strdup(cmd->name); Oops, not using qmp_command_name(). Seems minor enough that if it is the only change after this much churn, and the maintainer is willing to fix it on your behalf, I could live with= : Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --1eVqGCuUngK337p3mbRxEWahq6RFkPmSo Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSVMY8AAoJEKeha0olJ0NqVQoH/iCHEZhqZuXSlgRlZlYWEybR JKhGfRVbDc0bm67ZlwqpUlrIkqWqeZpeNgrRtcPjzoh9ZAch2kUUq41Kno/kGSSO SDt59vqnEVpH0IGUtHHBwqx7gP7f9ZWl9cnsMBw73aURJuvV+Edbnix87bzA1ZEX Ep4rb2CEt3CCzqYN7OEGP5CCEZSao28vrb1VNefiv/FG+U+USYc/+UiyYKX/SEQd 2uSkvN3jVCGXf6VvemZrmwp/mZpKBsBCHzUfChk7scu5iS3N4oCIb9O+zJ+Ntxou djCvO5f8dkrjNffwuxEEzkOJi+QAPgyqYCNnPXHkvP8labCbGXm2S23JaivL7Vs= =3Atl -----END PGP SIGNATURE----- --1eVqGCuUngK337p3mbRxEWahq6RFkPmSo--