From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOY2v-0003oe-U2 for Qemu-devel@nongnu.org; Tue, 24 Sep 2013 15:13:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VOY2q-00013a-6n for Qemu-devel@nongnu.org; Tue, 24 Sep 2013 15:13:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOY2p-00013W-V2 for Qemu-devel@nongnu.org; Tue, 24 Sep 2013 15:13:12 -0400 Message-ID: <5241E444.4040606@redhat.com> Date: Tue, 24 Sep 2013 13:13:08 -0600 From: Eric Blake MIME-Version: 1.0 References: <1379832654-21722-1-git-send-email-wudxw@linux.vnet.ibm.com> <20130924190032.7651.74662@loki> In-Reply-To: <20130924190032.7651.74662@loki> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="dx7Igr4ISIsgSnAnKN0qw4EDAL01WMaOD" Subject: Re: [Qemu-devel] [PATCH] Extend qemu-ga's 'guest-info' command to expose flag 'success-response' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Roth Cc: Mark Wu , Qemu-devel@nongnu.org, Luiz Capitulino This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --dx7Igr4ISIsgSnAnKN0qw4EDAL01WMaOD Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/24/2013 01:00 PM, Michael Roth wrote: > Quoting Mark Wu (2013-09-22 01:50:54) >> Now we have several qemu-ga commands not returning response on success= =2E >> It has been documented in qga/qapi-schema.json already. This patch exp= oses >> the 'success-response' flag by extending 'guest-info' command. With th= is >> change, the clients can handle the command response more flexibly. >> >> Changes: >> v2: add the notation 'since 1.7' to the option 'success-respon= se' >> (per Eric Blake's comments) >> >> Signed-off-by: Mark Wu >=20 > Reviewed-by: Michael Roth >=20 > Eric, do we have your reviewed-by other than the changes you mentioned?= If so I > can fix those up in my tree. Aha - force me to do a FULL review, rather than just an interface review. I found more issues, so this probably deserves a v2: >> +bool qmp_command_has_success_response(const char *name) >> +{ >> + QmpCommand *cmd; >> + >> + QTAILQ_FOREACH(cmd, &qmp_commands, node) { >> + if (strcmp(cmd->name, name) =3D=3D 0) { >> + return cmd->options !=3D QCO_NO_SUCCESS_RESP; cmd->options is a bitmask - it is feasible that we may add more QCO_NO_* flags in the future, at which point inequality is NOT correct. Rather, you want: return !(cmd->options & QCO_NO_SUCCESS_RESP); >> +++ b/qga/commands.c >> @@ -63,6 +63,8 @@ struct GuestAgentInfo *qmp_guest_info(Error **err) >> 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->success_response =3D >> + qmp_command_has_success_response(cmd_info->name); This feels wasteful. Why are we doing an O(n) lookup for BOTH qmp_command_is_enabled AND qmp_command_has_success_response, in an O(n) loop over command names? That's O(n^2) in the number of commands. Better would be getting a list of QmpCommand* instead of a list of char*, and looking directly in each object, for O(n) computation of the results. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --dx7Igr4ISIsgSnAnKN0qw4EDAL01WMaOD 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/ iQEcBAEBCAAGBQJSQeREAAoJEKeha0olJ0NqFo8IAJXPdGd1QHIbKv8veT5Ltsxs T27WQW5rJJGnSVRZgRA8BNstGTun7K9dBdEWLDVXM9cOlZnW+rl18b1ZRRJ8ifns Dtb4eyodAmyaiW8tDU6q9HYBsQDU+JbL/WnEpBTkU1QAR79r6bgMA8tJm/zLIdOC ywjteAcv8WtQGOlsN37zvZntUVz1vfVkMS+2rwufC7RnLePIp6L8dVh64XJm91va wylJQRniKzlN5+mdW1hPm54luL+xY+bmeHlP3zsSCCui5VxsW5vLwVER7EFiad9J Ts+58hz9dnvcHrCJ8lxqd6Jn1canrScdQlnhKRY1DiDrL9wDi2kgHAqPKlMV3Ws= =gG9l -----END PGP SIGNATURE----- --dx7Igr4ISIsgSnAnKN0qw4EDAL01WMaOD--