From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIryT-0005J6-3c for qemu-devel@nongnu.org; Thu, 21 Mar 2013 22:45:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIryM-0005TI-Rq for qemu-devel@nongnu.org; Thu, 21 Mar 2013 22:44:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36816) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIryM-0005SO-Jb for qemu-devel@nongnu.org; Thu, 21 Mar 2013 22:44:50 -0400 Message-ID: <514BC592.508@redhat.com> Date: Thu, 21 Mar 2013 20:44:34 -0600 From: Eric Blake MIME-Version: 1.0 References: <1363876125-8264-1-git-send-email-imammedo@redhat.com> <1363876125-8264-12-git-send-email-imammedo@redhat.com> In-Reply-To: <1363876125-8264-12-git-send-email-imammedo@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2WXIGEBFVQNECREFUFNOO" Subject: Re: [Qemu-devel] [PATCH 11/12] qmp: add cpu_set qmp command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: kwolf@redhat.com, peter.maydell@linaro.org, aliguori@us.ibm.com, ehabkost@redhat.com, mst@redhat.com, jan.kiszka@siemens.com, stefano.stabellini@eu.citrix.com, claudio.fontana@huawei.com, qemu-devel@nongnu.org, quintela@redhat.com, armbru@redhat.com, blauwirbel@gmail.com, yang.z.zhang@intel.com, alex.williamson@redhat.com, aderumier@odiso.com, kraxel@redhat.com, anthony.perard@citrix.com, pbonzini@redhat.com, lcapitulino@redhat.com, afaerber@suse.de, rth@twiddle.net This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2WXIGEBFVQNECREFUFNOO Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 03/21/2013 08:28 AM, Igor Mammedov wrote: > Signed-off-by: Igor Mammedov > --- > +++ b/qapi-schema.json > @@ -1385,6 +1385,15 @@ > { 'command': 'cpu', 'data': {'index': 'int'} } > =20 > ## > +# @cpu_set > +# I already mentioned naming this cpu-set on your cover letter. Additional= ly: > +# Sets specified cpu to online/ofline mode s/ofline/offline/ > +# > +# Notes: semantics is : cpu_set id=3Dx status=3Donline|offline > +## > +{ 'command': 'cpu_set', 'data': {'id': 'int', 'status': 'str'} } Don't open-code a 'str'. My preference would be a bool, with slightly different naming. Also, this is not the typical documentation style used in this file. Rather, it would be more like: # Sets specified cpu to online/offline mode # # @id: cpu id to be updated # # @online: true to put the cpu online, false to take it offline # ## { 'command': 'cpu-set', 'data': {'id': 'int', 'online': 'bool'} } > +void qmp_cpu_set(int64_t id, const char *status, Error **errp) > +{ > + if (!strcmp(status, "online")) { > + do_cpu_hot_add(id, errp); > + } else if (!strcmp(status, "offline")) { > + error_setg(errp, "Unplug is not implemented"); > + } else { > + error_setg(errp, "Invalid parameter '%s'", status); > + return; This return could be omitted, with no change in behavior. But again, I think a bool rather than an open-coded string parser would make this simpler: void qmp_cpu_set(int64_t id, bool online, Error **errp) { if (online) { do_cpu_hot_add(id, errp); } else { error_setg(errp, "Unplug is not implemented"); } } --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2WXIGEBFVQNECREFUFNOO 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.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRS8WSAAoJEKeha0olJ0Nqv/0H/2xBCS1nF04Ltm8WMoeLLKXS aNChp4AkhBkfTsQrC1iWwaF+JB9WtjVPnB9B9I0+o4K4mxK6NV2KOhNlAdFpA4pi Sftpwzsn9z++bhPKcBSPO3ExtLIXQaALkf/l2UK+1EuZZFmRHGVmstJ6QESAwvBK oxQC8ng3zcUWrduwm04I+WYlb5IAd/+VgB5V0ZECk2OgK0xpk8vwthvflMTLCz9j 0ym1LfyVpWeQm/SZx8oEleUCUgesjl54Lykc8RaUTr4plQSAIUKvPMwovxVbHPVZ caqZW0d+4RfmI7jUkMY33+9blo+wt9PdsJZIw9Y/6/LYau97WrG8T/kmme8fYDs= =/sZe -----END PGP SIGNATURE----- ------enig2WXIGEBFVQNECREFUFNOO--