From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wx9N7-00052j-6a for qemu-devel@nongnu.org; Wed, 18 Jun 2014 02:29:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wx9N2-00063n-3i for qemu-devel@nongnu.org; Wed, 18 Jun 2014 02:29:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37289) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wx9N1-00063j-Rm for qemu-devel@nongnu.org; Wed, 18 Jun 2014 02:29:20 -0400 Date: Wed, 18 Jun 2014 14:29:11 +0800 From: Amos Kong Message-ID: <20140618062911.GC32372@z.redhat.com> References: <1402065233-31894-1-git-send-email-akong@redhat.com> <1402065233-31894-3-git-send-email-akong@redhat.com> <53A07CC2.3030401@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <53A07CC2.3030401@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 2/4] qtest: introduce qmp_exec_hmp_cmd() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: stefanha@gmail.com, arei.gonglei@huawei.com, qemu-devel@nongnu.org, afaerber@suse.de On Tue, Jun 17, 2014 at 07:37:06PM +0200, Paolo Bonzini wrote: > Il 06/06/2014 16:33, Amos Kong ha scritto: > >+ va_end(ap); > >+ > >+ escaped_cmd = g_strescape(cmd, NULL); > >+ response = qmp("{\"execute\": \"human-monitor-command\"," > >+ " \"arguments\": {" > >+ " \"command-line\": \"%s\"" > >+ "}}", escaped_cmd); > >+ g_free(escaped_cmd); > > Instead of adding g_strescape everywhere, we should use json-parser's own > interpolation support. See this patch: > http://article.gmane.org/gmane.comp.emulators.qemu/279836 which also fixes a > leak as a bonus. > > Also, you can use ' instead of " if you fix another long-standing bug: > http://article.gmane.org/gmane.comp.emulators.qemu/279835 I will use ' instead of ", and escape string in QMP command as http://article.gmane.org/gmane.comp.emulators.qemu/279836 Thanks. > Paolo -- Amos.