From nobody Sat May 11 16:43:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1646141629; cv=none; d=zohomail.com; s=zohoarc; b=ewCiKu/UVkWg63L24/5ddGfNhYBqRMz2BmYvEYXV5RwbHeuysWcr2FsInnqzHdzMbW2pFTOiPYXeIlkzEIiZZFMZqupWSUTDOJ6/U+ERxa1tTRLfFU7KWOC2SzeD8GfNCSUIHTd4tBymvf36mQdUPUZgaUWwbu17ud8gOTI0kHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646141629; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=8kd6g5FpJnlpkIGebExHChO+7s2UJDlaoYnnCe4xw7s=; b=V2e7SIjz9Wuxz2bxn/PN9qDC5dBV6cjRxEvCXwBiQp9E/3JLtCEmPA/A0oqVnqTzrMKiZ05bJ1UIHTupfn4ZCXQK6YzGAur88ngZvZty+LrGbdBmof5kmdFoIRoKJst7Pg8AK80z768oXsfVu6cE4jb+8L/1TqonNqFHsdamVvI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646141629030962.647236761227; Tue, 1 Mar 2022 05:33:49 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-QN-xRWzDOfOAL7DNT_4yiw-1; Tue, 01 Mar 2022 08:33:44 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7711D657; Tue, 1 Mar 2022 13:33:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 14F5BA22D; Tue, 1 Mar 2022 13:33:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 766E04ED66; Tue, 1 Mar 2022 13:33:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 221DXZ4Z021130 for ; Tue, 1 Mar 2022 08:33:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id B100778356; Tue, 1 Mar 2022 13:33:35 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FFB678345 for ; Tue, 1 Mar 2022 13:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646141628; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8kd6g5FpJnlpkIGebExHChO+7s2UJDlaoYnnCe4xw7s=; b=LWi+FQ1YOWNyXj3QqjiU6Utxwcmqcog3UI0sfQKyxUAR2iwkUecX79/tJ3zXIbbLBsh1nD oSEnHtEBC35M9g36SVRznWI2tzN5YnQGtCfMlXQ5rCeIjqWHv7Trtm9L2fKSHma5aTuLjy KCQsb2EHSTZ9mqrkZBmj0DnjBxlIMXA= X-MC-Unique: QN-xRWzDOfOAL7DNT_4yiw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] cmdQemuMonitorCommandQMPWrap: Reset ignored errors from JSON parsing Date: Tue, 1 Mar 2022 14:33:28 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646141630662100001 Content-Type: text/plain; charset="utf-8" 'cmdQemuMonitorCommandQMPWrap' is checking whether the user provided string is not valid JSON to avoid wrapping it. In cases where it's not JSON we ignore the error and add the wrapper. If the caller then reports a different non-libvirt error the error from the JSON parsing would be printed as well. Reset errors we ignore: # virsh qemu-monitor-command cd --pass-fds a asdf error: Unable to parse FD number 'a' error: internal error: cannot parse json asdf: lexical error: invalid char= in json text. asdf (right here) ------^ In the above case 'asdf' is not valid JSON, but the code did wrap it into '{"execute":"asdf"}', the only problem is the argument for --pass-fds. Signed-off-by: Peter Krempa Reviewed-by: Martin Kletzander --- tools/virsh-domain.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 9b1b14cdc2..743660e794 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9769,6 +9769,8 @@ cmdQemuMonitorCommandQMPWrap(vshControl *ctl, if (virJSONValueIsObject(fullcmdjson)) return g_steal_pointer(&fullcmd); + vshResetLibvirtError(); + /* we try to wrap the command and possible arguments into a JSON objec= t, if * we as fall back we pass through what we've got from the user */ @@ -9787,6 +9789,8 @@ cmdQemuMonitorCommandQMPWrap(vshControl *ctl, * JSON object wrapper and try using that */ g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + vshResetLibvirtError(); + virBufferAddLit(&buf, "{"); /* opt points to the _ARGV option bit containing the command so we= 'll * iterate through the arguments now */ --=20 2.35.1