From nobody Fri May 17 06:54:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1584347823; cv=none; d=zohomail.com; s=zohoarc; b=ANsmMj9OOBG2L1Skxe2zP9AkJLM0hpg00iueUYG1CC9f316SB7LJAG4vsDnhogoFxXUaQ46Frf7pSBbDf+An2u7d/1i93crFNyWPuPPVhlUnB7PW3fuLjBqm5hAaBDKjm9a7iPb6PB0HVcOr4/H6BBSXdFbhJISUFXBdTIyahHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347823; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dkKl6zcq+L6xOad00U5/mjmLX7EyegpfEBfYNh++B8Q=; b=ZrSVSVOQR7ir+0gyLXTz5y863lHQp3N1cE8uuskM40EHwmnq8aHGZ6oc70UIG0POwBURLzyNIfRTPqf59oAHbvneyCEClGx9i1GWSe6+gcA3L9CdDt94I2qTZaRWgwJQL4umqi0EXeGsSgs6TK28ejhWXdLiNOiC6MqZ++YcNRM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1584347823552611.2035451949046; Mon, 16 Mar 2020 01:37:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-317-c1gfNC3tMVKTTuyIqFUWzg-1; Mon, 16 Mar 2020 04:36:40 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C47A149C3; Mon, 16 Mar 2020 08:36:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 13C3F60C63; Mon, 16 Mar 2020 08:36:34 +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 BC2061803C33; Mon, 16 Mar 2020 08:36:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02G8ZxU4026169 for ; Mon, 16 Mar 2020 04:35:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 04D0760BFB; Mon, 16 Mar 2020 08:35:59 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F6C960BF3 for ; Mon, 16 Mar 2020 08:35:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347822; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dkKl6zcq+L6xOad00U5/mjmLX7EyegpfEBfYNh++B8Q=; b=At5N/L4nwqlEPtgt5/ipC+U4tRBpvKeZXW7mwj0FTPpHqStCSM95BL/nl+iRxX04Tn+mv7 NDZpHLkQq346SN2wmk7cqFD6+Hd3n2d+VpjUbPUN4gOEruqg7MtQodpt8TF6ur1rEYDDDU H/ODxM/ylV//DRDjW6FGkKlzGxm0vC8= X-MC-Unique: c1gfNC3tMVKTTuyIqFUWzg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/12] qemuDomainGetGuestInfo: don't assign NULL hostname Date: Mon, 16 Mar 2020 09:35:43 +0100 Message-Id: <63d603c189717d9bde7dcaf92f16e91297b4b918.1584347691.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Don't rely on error check and assign hostname only when non-NULL. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 641a90d595..241513705d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -22909,14 +22909,14 @@ qemuDomainGetGuestInfo(virDomainPtr dom, } if (supportedTypes & VIR_DOMAIN_GUEST_INFO_HOSTNAME) { rc =3D qemuAgentGetHostname(agent, &hostname); - if (rc < 0 && !(rc =3D=3D -2 && types =3D=3D 0)) { + if (rc < 0 && !(rc =3D=3D -2 && types =3D=3D 0)) goto exitagent; - } else { - if (virTypedParamsAddString(params, nparams, &maxparams, "host= name", - hostname) < 0) - goto exitagent; - } } + + if (hostname && + virTypedParamsAddString(params, nparams, &maxparams, "hostname", h= ostname) < 0) + goto exitagent; + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) { rc =3D qemuAgentGetFSInfo(agent, &agentfsinfo); if (rc < 0) { --=20 2.24.1 From nobody Fri May 17 06:54:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1584347777; cv=none; d=zohomail.com; s=zohoarc; b=NjxFXxN+OnEaDS7Q/OpjS8MSjhGy++UfLe/seOWaoq/924Ir10KVADobs7f9EPk2c/ltT7C2WvpZttgwTSkhBwxmD1O0N1GgjoYZ81N/QHvQMouuwM3K6ryKb0I82qWf+4uOZzIyw0dkaIpU3WC0xBXNzsAJte3BEAQsNFfGCCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347777; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8xq+9i/XOy5zi31BzInXzdP0D+gOVKfpsOkjSrlhyy0=; b=Qb3Ksuqz+87O+1vD8AT7J9PhHp0AgURMNBNrZZgkxJIlwcMCkEHq+Nz9LPCEHyp3bu/C/BbAKbARL8VdrCi+0iUp61ZpxibMQAXByVEJZjfgs/HrA1Hgs6CLtg9ry/XnCc/Q7PNAcD4dTZsEb9agjwoNG0wZk0S9kkZ4cebjQPY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1584347777761234.9942206203284; Mon, 16 Mar 2020 01:36:17 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-L2x7E8G8MXmODfQ2h7LVXg-1; Mon, 16 Mar 2020 04:36:14 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 94C8D149C4; Mon, 16 Mar 2020 08:36:08 +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 30C7F5C1B2; Mon, 16 Mar 2020 08:36:08 +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 5C64C86FE0; Mon, 16 Mar 2020 08:36:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02G8ZxEL026177 for ; Mon, 16 Mar 2020 04:35:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id D223460BFB; Mon, 16 Mar 2020 08:35:59 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 581FF60BF3 for ; Mon, 16 Mar 2020 08:35:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347776; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8xq+9i/XOy5zi31BzInXzdP0D+gOVKfpsOkjSrlhyy0=; b=MeuWkTiVI+tiNXeCndzXP8Uh2piihoCsNcE+hCQoWZc8dgLZdef8JFgYpQk25VmYfcTAYr YTEeEfaWSR6SgoaiqxgIx49eZewXFMNOJRJmuzo2onSWmg2DRlLreJiBVmBQz/4p232QYV e2/jGW1OvzpuXCDRzERh0edp0rR9eLk= X-MC-Unique: L2x7E8G8MXmODfQ2h7LVXg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/12] qemuDomainGetGuestInfo: Validate supported information types Date: Mon, 16 Mar 2020 09:35:44 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 'qemuDomainGetGuestInfoCheckSupport' despite it's name was not checking whether the info types are supported. Convert the function to return integers and include the check. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 241513705d..f9a4cc2758 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -22744,20 +22744,32 @@ qemuDomainGetLaunchSecurityInfo(virDomainPtr doma= in, return ret; } -static const unsigned int supportedGuestInfoTypes =3D +static const unsigned int qemuDomainGetGuestInfoSupportedTypes =3D VIR_DOMAIN_GUEST_INFO_USERS | VIR_DOMAIN_GUEST_INFO_OS | VIR_DOMAIN_GUEST_INFO_TIMEZONE | VIR_DOMAIN_GUEST_INFO_HOSTNAME | VIR_DOMAIN_GUEST_INFO_FILESYSTEM; -static void -qemuDomainGetGuestInfoCheckSupport(unsigned int *types) +static int +qemuDomainGetGuestInfoCheckSupport(unsigned int types, + unsigned int *supportedTypes) { - if (*types =3D=3D 0) - *types =3D supportedGuestInfoTypes; + if (types =3D=3D 0) { + *supportedTypes =3D qemuDomainGetGuestInfoSupportedTypes; + return 0; + } + + *supportedTypes =3D types & qemuDomainGetGuestInfoSupportedTypes; + + if (types !=3D *supportedTypes) { + virReportError(VIR_ERR_INVALID_ARG, + _("unsupported guest information types '0x%x'"), + types & ~qemuDomainGetGuestInfoSupportedTypes); + return -1; + } - *types =3D *types & supportedGuestInfoTypes; + return 0; } static void @@ -22863,14 +22875,16 @@ qemuDomainGetGuestInfo(virDomainPtr dom, int ret =3D -1; int maxparams =3D 0; g_autofree char *hostname =3D NULL; - unsigned int supportedTypes =3D types; + unsigned int supportedTypes; int rc; size_t nfs =3D 0; qemuAgentFSInfoPtr *agentfsinfo =3D NULL; size_t i; virCheckFlags(0, -1); - qemuDomainGetGuestInfoCheckSupport(&supportedTypes); + + if (qemuDomainGetGuestInfoCheckSupport(types, &supportedTypes) < 0) + return -1; if (!(vm =3D qemuDomainObjFromDomain(dom))) goto cleanup; --=20 2.24.1 From nobody Fri May 17 06:54:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1584347803; cv=none; d=zohomail.com; s=zohoarc; b=PnZJalrbmqx+vdbM1YlId7a5KgjCaEo5wODj9bTQyga4pQPkSluAhgTiM2S+OvIAR/NYSEfAftdafZ3yScSZMi3Ub5pdHHcOiF3sI8OlrUwLGvH9mgnvRfEBzteekbYt7dG6O39WlZyy5aNb/qco3RkHD8dxciYYXTUphxKZ/1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347803; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p9TegAKBVhtDWub0fVij1VCvghu7l9dyysEk/9Xes7w=; b=Bqz3e5eXcbZpU9HZxiP33xQF0On7gKGbOZDGsDm/JQBxhXRshvQQ6La3cEIwJ0e0ml2UnHwMvl6A1GARd8pfeylpQ9T6u3KcK89Nit6ICHzJPN0+7ZlpMTASFbQ72+wA7Nlavo7Joie8B0aygEjuOD9r0FLhcl6HjTp0BD7rJQM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1584347803013153.97456186240174; Mon, 16 Mar 2020 01:36:43 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-317-1dcSPe1DOk2fr1JPjfy4YQ-1; Mon, 16 Mar 2020 04:36:40 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8050B18B9FC2; Mon, 16 Mar 2020 08:36:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C1E860C05; Mon, 16 Mar 2020 08:36:34 +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 EC09A1803C38; Mon, 16 Mar 2020 08:36:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02G8a0bS026184 for ; Mon, 16 Mar 2020 04:36:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id A86BA60BFB; Mon, 16 Mar 2020 08:36:00 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CD5160BF3 for ; Mon, 16 Mar 2020 08:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347802; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=p9TegAKBVhtDWub0fVij1VCvghu7l9dyysEk/9Xes7w=; b=gZIb2Fv4O0r5SEdQmW4OYwgf3S38NVj38TR+xiRoynzeiW1n/e3VGBoeSyVCogSUOfT8az /uOmBLcDZHqysooMTbKZK/Xu99W9fQxjMwDs60lLwN3umLtSgOWiqLHR21tEJ6S/1KGDXM 0KphNeZzgUWgN1BhY2aDfEHciEZB02I= X-MC-Unique: 1dcSPe1DOk2fr1JPjfy4YQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/12] qemuAgentCheckError: use g_autofree Date: Mon, 16 Mar 2020 09:35:45 +0100 Message-Id: <55036017c31c2ee53bb8b5cb808b6b266c21e2e6.1584347691.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 9ea2c59563..8790c47b87 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1055,8 +1055,8 @@ qemuAgentCheckError(virJSONValuePtr cmd, { if (virJSONValueObjectHasKey(reply, "error")) { virJSONValuePtr error =3D virJSONValueObjectGet(reply, "error"); - char *cmdstr =3D virJSONValueToString(cmd, false); - char *replystr =3D virJSONValueToString(reply, false); + g_autofree char *cmdstr =3D virJSONValueToString(cmd, false); + g_autofree char *replystr =3D virJSONValueToString(reply, false); /* Log the full JSON formatted command & error */ VIR_DEBUG("unable to execute QEMU agent command %s: %s", @@ -1073,20 +1073,16 @@ qemuAgentCheckError(virJSONValuePtr cmd, qemuAgentCommandName(cmd), qemuAgentStringifyError(error)); - VIR_FREE(cmdstr); - VIR_FREE(replystr); return -1; } else if (!virJSONValueObjectHasKey(reply, "return")) { - char *cmdstr =3D virJSONValueToString(cmd, false); - char *replystr =3D virJSONValueToString(reply, false); + g_autofree char *cmdstr =3D virJSONValueToString(cmd, false); + g_autofree char *replystr =3D virJSONValueToString(reply, false); VIR_DEBUG("Neither 'return' nor 'error' is set in the JSON reply %= s: %s", NULLSTR(cmdstr), NULLSTR(replystr)); virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to execute QEMU agent command '%s'"), qemuAgentCommandName(cmd)); - VIR_FREE(cmdstr); - VIR_FREE(replystr); return -1; } return 0; --=20 2.24.1 From nobody Fri May 17 06:54:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1584347806; cv=none; d=zohomail.com; s=zohoarc; b=AewX5eHzdKpqnZwpbl//KGo1wtvdnwPos3SgPZCqd1GNzicfHyY/OMJ2FvsUG3xX8yZqNMsk8XIDLK7QKP1HwdNoZRaFcyzd59kd7YyYTXO6FomOpZgSwNqZkQSg/foy4WZI0LhJtohp14brgODOJdsbK1NMzJsWrpIsqmgwYv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347806; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BfkgDnIt+OQCi1iUEQ8GWRk40PIcMVBBPNiQUjAOhb4=; b=Fwmwn7DMRpLOUM8DXrKMTjlPQ/hvrNbMCYBQpw2SfvNaS/x10/dZvLwVZ1XUMDd0Bo/fFKwTD53dXjCARut3VmpS/pAjHPS62s5xilrMm6SLV/LQel5UXJUTuBQhOo854aMYHX9zlwuRP1fbsjYEzJuHkMfQ8bJwiJ2mAqd4PxY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1584347806739956.8787172698559; Mon, 16 Mar 2020 01:36:46 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-39-WFYDPo_VN5W66F5coXgvng-1; Mon, 16 Mar 2020 04:36:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 179DB149C5; Mon, 16 Mar 2020 08:36: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 D862C8F374; Mon, 16 Mar 2020 08:36:37 +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 846F186FE2; Mon, 16 Mar 2020 08:36:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02G8a1ka026197 for ; Mon, 16 Mar 2020 04:36:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7CDB460BFB; Mon, 16 Mar 2020 08:36:01 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0244A60BF3 for ; Mon, 16 Mar 2020 08:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347805; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BfkgDnIt+OQCi1iUEQ8GWRk40PIcMVBBPNiQUjAOhb4=; b=N9GP24QXSFk0DUkh41kARsFAS5nk3+c/JLgYdNT5xPQgDPPRo5EmaBaqi0gIunDPWgXIz1 pDRpvpIVCKq5x/wnSuIE4ScRW9tuByN6KTuq+q5z6xA/SnUc7l8pF9xOK9cOIu+SIOl30O ffsAEoEDYxm7GquKEjJ0lNsK2T9r9uw= X-MC-Unique: WFYDPo_VN5W66F5coXgvng-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/12] qemuAgentCommand: Wire up suppressing of error reporting for unsupported commands Date: Mon, 16 Mar 2020 09:35:46 +0100 Message-Id: <71172e260c665d07b0ec7457d38018c36d8b556b.1584347691.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In some cases we don't want to log errors if an agent command is unsupported. Wire it up into qemuAgentCheckError via qemuAgentCommandFull and provide a thin wrapper (qemuAgentCommand) to prevent having to fix all callers. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 45 +++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 8790c47b87..bc5d57ab94 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1051,7 +1051,8 @@ qemuAgentCommandName(virJSONValuePtr cmd) static int qemuAgentCheckError(virJSONValuePtr cmd, - virJSONValuePtr reply) + virJSONValuePtr reply, + bool report_unsupported) { if (virJSONValueObjectHasKey(reply, "error")) { virJSONValuePtr error =3D virJSONValueObjectGet(reply, "error"); @@ -1063,15 +1064,25 @@ qemuAgentCheckError(virJSONValuePtr cmd, NULLSTR(cmdstr), NULLSTR(replystr)); /* Only send the user the command name + friendly error */ - if (!error) + if (!error) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to execute QEMU agent command '%s'"), qemuAgentCommandName(cmd)); - else - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unable to execute QEMU agent command '%s': %= s"), - qemuAgentCommandName(cmd), - qemuAgentStringifyError(error)); + return -1; + } + + if (!report_unsupported) { + const char *klass =3D virJSONValueObjectGetString(error, "clas= s"); + + if (STREQ_NULLABLE(klass, "CommandNotFound") || + STREQ_NULLABLE(klass, "CommandDisabled")) + return -2; + } + + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to execute QEMU agent command '%s': %s"), + qemuAgentCommandName(cmd), + qemuAgentStringifyError(error)); return -1; } else if (!virJSONValueObjectHasKey(reply, "return")) { @@ -1089,10 +1100,11 @@ qemuAgentCheckError(virJSONValuePtr cmd, } static int -qemuAgentCommand(qemuAgentPtr agent, - virJSONValuePtr cmd, - virJSONValuePtr *reply, - int seconds) +qemuAgentCommandFull(qemuAgentPtr agent, + virJSONValuePtr cmd, + virJSONValuePtr *reply, + int seconds, + bool report_unsupported) { int ret =3D -1; qemuAgentMessage msg; @@ -1143,7 +1155,7 @@ qemuAgentCommand(qemuAgentPtr agent, } *reply =3D msg.rxObject; - ret =3D qemuAgentCheckError(cmd, *reply); + ret =3D qemuAgentCheckError(cmd, *reply, report_unsupported); cleanup: VIR_FREE(cmdstr); @@ -1153,6 +1165,15 @@ qemuAgentCommand(qemuAgentPtr agent, return ret; } +static int +qemuAgentCommand(qemuAgentPtr agent, + virJSONValuePtr cmd, + virJSONValuePtr *reply, + int seconds) +{ + return qemuAgentCommandFull(agent, cmd, reply, seconds, true); +} + static virJSONValuePtr G_GNUC_NULL_TERMINATED qemuAgentMakeCommand(const char *cmdname, ...) --=20 2.24.1 From nobody Fri May 17 06:54:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1584347782; cv=none; d=zohomail.com; s=zohoarc; b=Bf6pfRSH/C5rAfZ4t0GHqnMGurQsehJ11xwv4ZtZmP2fNluGZTKrayUvACIuzetu13cDOmafvJW1nYa+GpVM5t4hIGV3nff8YMejGGsw21lHV6ixfwoed7zQzqzZ6PGLegUAxVsHrjXI2XqAA+Bviod7G2Yyk2mNsq++PyhdRdk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347782; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fPsV80CCL4MnkVuk5TPTqu8MDHxt+OZ1K6PLq1b/d6Q=; b=XOsf7kSTJN2rR9gEptq9SX1gGicfo+XG+2FrrY+VcZ73JFx7UlhwzwOGJ7Llar5kP7Ctw8QybwFIi2FMOvSG1QGmo/ebnvMMxAaCN/k8gU1LOD9cSGqcOy25k+xxn5ZnV5e+XmgicMYEP3qGi/cY4GgHWmrDZWg/+bN4MzlsCHo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1584347782417981.459441755718; Mon, 16 Mar 2020 01:36:22 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-118-LBSBRIAWNBuRNC9DjZ051A-1; Mon, 16 Mar 2020 04:36:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 00B1D18B9FC2; Mon, 16 Mar 2020 08:36:12 +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 3E4B660C05; Mon, 16 Mar 2020 08:36:09 +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 E0D9986FED; Mon, 16 Mar 2020 08:36:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02G8a53F026218 for ; Mon, 16 Mar 2020 04:36:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 099C360BF3; Mon, 16 Mar 2020 08:36:05 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83CDA60BFB for ; Mon, 16 Mar 2020 08:36:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347780; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fPsV80CCL4MnkVuk5TPTqu8MDHxt+OZ1K6PLq1b/d6Q=; b=FGooteq80EaG+PUN13dIdx/sn1cRxMlRsXe1vaoOX1GPjS1+EJ+5A2c4d4INsUiD9XxR8y JdJgyKo7Nk8r/tpI63EJg2/XcrAuCxXnjPGD0W2tLVN1IjqyUG7sFEaGbK8MPVZf6+WE0W 9VehuILwc+iCt+rf0WlPRD2b7DH/9fI= X-MC-Unique: LBSBRIAWNBuRNC9DjZ051A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/12] qemuAgentGetUsers: Fix return value on success Date: Mon, 16 Mar 2020 09:35:47 +0100 Message-Id: <3c8353df113cdcc48803445733036a237d0fbd6c.1584347691.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Return 0 on success as per documentation and due to the fact that callers don't check the value. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index bc5d57ab94..c55b989467 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2406,7 +2406,7 @@ qemuAgentGetUsers(qemuAgentPtr agent, return -1; } - return ndata; + return 0; } /* Returns: 0 on success --=20 2.24.1 From nobody Fri May 17 06:54:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1584347808; cv=none; d=zohomail.com; s=zohoarc; b=lXEDzBMpdOU/4UprlZGbFn/+h7aRgYRlsIDwVGQYnm6wyvMQLwgTDjHzJZXS/rEkw6U3n12M7G06kyHFIGXLPspvcbeOqolUsc8Nlfa4TZfOXTveQaI1XF//PjvhMWm9tpZmVNXBKqi98H1fEZEJV11dqlYqsjDYQNaAGD/MwGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347808; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7buFgGLaQAkVOBQCK42Zo+UVSrPy+AQi8B71Q0KFONw=; b=KFFczpvnjlO3buwO7DK8Br1qqHAaClGK4EZByb27SeNRghy4rrJaCV3mprSurf54xycv9X63jsv3Na3FRDjXthzYrdRvkJQJDNbG6VAE+kP/1t1Qy8grqeaGzwyIWyrPprWY0aLm8qxj09ITMlxDQMSw+oaAQVo/mgPeO8aGDBM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1584347808752433.1573140250779; Mon, 16 Mar 2020 01:36:48 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-45-XKq8TtWrO7eE-lhq5FzhPw-1; Mon, 16 Mar 2020 04:36:45 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A95D801E66; Mon, 16 Mar 2020 08:36:39 +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 6E6935C1C3; Mon, 16 Mar 2020 08:36:39 +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 20D6086FF3; Mon, 16 Mar 2020 08:36:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02G8a5Au026223 for ; Mon, 16 Mar 2020 04:36:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id D218860BFB; Mon, 16 Mar 2020 08:36:05 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5881F60BF3 for ; Mon, 16 Mar 2020 08:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347807; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7buFgGLaQAkVOBQCK42Zo+UVSrPy+AQi8B71Q0KFONw=; b=ExDrHRqSJ9wSfwV105KgQ6wUtg6xeqpk3a0nDacxPKtGQTnCdBe6YEK4ljBR5EotEnxMOm TVWZnKgH7M8IzcH5ERLqbOILMhr2+VJkr49KphpK8CUIYRHfeXO2ZIhrjRFPlhXQIr48K8 l7oPGZ3nVlok5Bsaq6HyEzkPwS2aYOo= X-MC-Unique: XKq8TtWrO7eE-lhq5FzhPw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/12] qemuAgentGetHostname: Refactor to remove cleanup section Date: Mon, 16 Mar 2020 09:35:48 +0100 Message-Id: <11ce85bdab9926424f5a278ac652e4b4eb99a07e.1584347691.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use g_autoptr instead. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index c55b989467..07aba2b45d 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1720,44 +1720,36 @@ int qemuAgentGetHostname(qemuAgentPtr agent, char **hostname) { - int ret =3D -1; - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuAgentMakeCommand("guest-get-host-n= ame", NULL); + g_autoptr(virJSONValue) reply =3D NULL; virJSONValuePtr data =3D NULL; const char *result =3D NULL; - cmd =3D qemuAgentMakeCommand("guest-get-host-name", - NULL); - if (!cmd) - return ret; + return -1; if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) { if (qemuAgentErrorCommandUnsupported(reply)) - ret =3D -2; - goto cleanup; + return -2; + + return -1; } if (!(data =3D virJSONValueObjectGet(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed return value")); - goto cleanup; + return -1; } if (!(result =3D virJSONValueObjectGetString(data, "host-name"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("'host-name' missing in guest-get-host-name reply= ")); - goto cleanup; + return -1; } *hostname =3D g_strdup(result); - ret =3D 0; - - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return 0; } --=20 2.24.1 From nobody Fri May 17 06:54:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1584347811; cv=none; d=zohomail.com; s=zohoarc; b=jLLVtUvg/0K/wodriuOGtU8leMD2Mw4xeyXQdDcyfe7LSGWhelWHRCKXOjmk7UYLoJYWZD5NKuhAeyESOLw48hESyhD9N3QGH/GlYG/TO4w9TTNnjF+8vojTuAxS0zjux2VSYg9Jjorq2Pvzm3z5M8actOhhtcZhkcHcxJTiZkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347811; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+08kKHPQ3g6FLqr4CEP3rmdOO9RwLXURR98Ri47VMM4=; b=P/0wp+etc2H0ZAvBiNOaZY7lzlQgMyTiVZgsqhjGZxlCtcpOucXSWFFMzaXp53/ItGOsZfnGFHWF31ITY58Qxhxt6tAGJshQcoqnQYsdqfUi2sYY24vBR4svZ0m5QabpR00lJylso3Hn/Zy1DQqJw3/p1LDhVt41Rp/hJU1arA8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1584347811032800.1680846606992; Mon, 16 Mar 2020 01:36:51 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-472-boL9oy3yPmmityXLsLPesg-1; Mon, 16 Mar 2020 04:36:47 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 57999101FC65; Mon, 16 Mar 2020 08:36:42 +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 1F9261001DF0; Mon, 16 Mar 2020 08:36:42 +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 AFFF386FF7; Mon, 16 Mar 2020 08:36:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02G8a8dN026238 for ; Mon, 16 Mar 2020 04:36:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id ACE0160BFB; Mon, 16 Mar 2020 08:36:08 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32D4E60BF3 for ; Mon, 16 Mar 2020 08:36:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347809; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+08kKHPQ3g6FLqr4CEP3rmdOO9RwLXURR98Ri47VMM4=; b=B49HbXQfyBgfL5IwxZAqQB2SoRnrUzdwbbLb4BQ0ez1KryiI5yQr3N0UP64yodq8kbeycw 3kxkkzDnV+X4lHNhGlE95UzbBDnIh/Q+ZXiT1vD3OuC8oXZsEmOlpVm/9zQZrtKD0s1Ve2 sB7tiYlmCel+S7kTRbDynfA5Pr81WGo= X-MC-Unique: boL9oy3yPmmityXLsLPesg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/12] qemuAgentGetHostname: expose 'report_unsupported' argument Date: Mon, 16 Mar 2020 09:35:49 +0100 Message-Id: <27ffcfe6ddd60fb0380a1f3249104854d47fb3dd.1584347691.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use qemuAgentCommandFull in qemuAgentGetHostname so that we can suppress error reports if the caller will not require them. Callers for now always require error reporting but will be fixed later. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 22 +++++++++++++++------- src/qemu/qemu_agent.h | 3 ++- src/qemu/qemu_driver.c | 4 ++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 07aba2b45d..7de1fe496a 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1716,24 +1716,32 @@ qemuAgentUpdateCPUInfo(unsigned int nvcpus, } +/** + * qemuAgentGetHostname: + * + * Gets the guest hostname using the guest agent. + * + * Returns 0 on success and fills @hostname. On error -1 is returned with = an + * error reported and if '@report_unsupported' is false -2 is returned if = the + * guest agent does not support the command without reporting an error + */ int qemuAgentGetHostname(qemuAgentPtr agent, - char **hostname) + char **hostname, + bool report_unsupported) { g_autoptr(virJSONValue) cmd =3D qemuAgentMakeCommand("guest-get-host-n= ame", NULL); g_autoptr(virJSONValue) reply =3D NULL; virJSONValuePtr data =3D NULL; const char *result =3D NULL; + int rc; if (!cmd) return -1; - if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) { - if (qemuAgentErrorCommandUnsupported(reply)) - return -2; - - return -1; - } + if ((rc =3D qemuAgentCommandFull(agent, cmd, &reply, agent->timeout, + report_unsupported)) < 0) + return rc; if (!(data =3D virJSONValueObjectGet(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h index 67fe9fcde9..7cf38d7091 100644 --- a/src/qemu/qemu_agent.h +++ b/src/qemu/qemu_agent.h @@ -129,7 +129,8 @@ int qemuAgentUpdateCPUInfo(unsigned int nvcpus, int qemuAgentGetHostname(qemuAgentPtr mon, - char **hostname); + char **hostname, + bool report_unsupported); int qemuAgentGetTime(qemuAgentPtr mon, long long *seconds, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f9a4cc2758..5e1f3efa7d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20128,7 +20128,7 @@ qemuDomainGetHostnameAgent(virQEMUDriverPtr driver, goto endjob; agent =3D qemuDomainObjEnterAgent(vm); - ignore_value(qemuAgentGetHostname(agent, hostname)); + ignore_value(qemuAgentGetHostname(agent, hostname, true)); qemuDomainObjExitAgent(vm, agent); ret =3D 0; @@ -22922,7 +22922,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, goto exitagent; } if (supportedTypes & VIR_DOMAIN_GUEST_INFO_HOSTNAME) { - rc =3D qemuAgentGetHostname(agent, &hostname); + rc =3D qemuAgentGetHostname(agent, &hostname, true); if (rc < 0 && !(rc =3D=3D -2 && types =3D=3D 0)) goto exitagent; } --=20 2.24.1 From nobody Fri May 17 06:54:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1584347813; cv=none; d=zohomail.com; s=zohoarc; b=P/i58ubNddTJWUs15OIN5nOxtTzxJoPhfbIvkRrXw2m5lR6DROFp9sKLfIvFeIjuDOMUc+if+FrpEai5JcfsimPXK36ieNtKnEj3mTzE9kGwpa0RwJ4ACI+2o8ahuntVs0vy+5uDCteXOxIEt8U1SuEi0mUnU467FxwTIZ4DHw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347813; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ohxGDnyAtNG5P6ZCecQ1obfdsGxO1GBDNEctuLIpjqM=; b=nVHcce/iMmi5c/Avjs2Pves3wCgorxcc6ZWaYUTYYtdooHyjBScuQO5i/Cv7S8mFY4ALsLCmqvJFC3Q8+3s19MVbgl/rmkGxdfB0orFi+GlPSqy+/+sMmFZfwWMeA2NOkTnEkEHCA31RnDDWfyx3GTzEf1JwwlqTQqhCxP8Sc+c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1584347813743461.59483202050455; Mon, 16 Mar 2020 01:36:53 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-174-PTVcrV8INIGGoZZDh-gnsg-1; Mon, 16 Mar 2020 04:36:50 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DF9E118B9FC3; Mon, 16 Mar 2020 08:36:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A8D34102AE1F; Mon, 16 Mar 2020 08:36:44 +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 375E71803C37; Mon, 16 Mar 2020 08:36:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02G8a9Mo026243 for ; Mon, 16 Mar 2020 04:36:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 82788610C9; Mon, 16 Mar 2020 08:36:09 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 088E860BFB for ; Mon, 16 Mar 2020 08:36:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347812; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ohxGDnyAtNG5P6ZCecQ1obfdsGxO1GBDNEctuLIpjqM=; b=YU8GrqdKRt1vDBevX2Clfrw2sF+gKvg0lr/gitDTDYnKspNAeSjA8DbLTZz3oeOW2zQuza c1qYNqzQQAfOMi61sw55R0tPKXdwM7F6Rey17HgC/IUggrVHWYrfT16NxFCdJkvO+1VGXF nxNO1IZd0RlwNcth8/REigGIYURQX5c= X-MC-Unique: PTVcrV8INIGGoZZDh-gnsg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/12] qemuAgentGetUsers: expose 'report_unsupported' argument Date: Mon, 16 Mar 2020 09:35:50 +0100 Message-Id: <1af384fe5f6e276b9aa81b9bbcb47f8d5c0f0d99.1584347691.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use qemuAgentCommandFull so that callers of qemuAgentGetUsers can suppress error reports if the function is not supported by the guest agent. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 17 +++++++++-------- src/qemu/qemu_agent.h | 3 ++- src/qemu/qemu_driver.c | 2 +- tests/qemuagenttest.c | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 7de1fe496a..261fc67021 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2319,29 +2319,30 @@ qemuAgentSetUserPassword(qemuAgentPtr agent, } /* Returns: 0 on success - * -2 when agent command is not supported by the agent - * -1 otherwise + * -2 when agent command is not supported by the agent and + * 'report_unsupported' is false (libvirt error is not reporte= d) + * -1 otherwise (libvirt error is reported) */ int qemuAgentGetUsers(qemuAgentPtr agent, virTypedParameterPtr *params, int *nparams, - int *maxparams) + int *maxparams, + bool report_unsupported) { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValuePtr data =3D NULL; size_t ndata; size_t i; + int rc; if (!(cmd =3D qemuAgentMakeCommand("guest-get-users", NULL))) return -1; - if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) { - if (qemuAgentErrorCommandUnsupported(reply)) - return -2; - return -1; - } + if ((rc =3D qemuAgentCommandFull(agent, cmd, &reply, agent->timeout, + report_unsupported)) < 0) + return rc; if (!(data =3D virJSONValueObjectGetArray(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h index 7cf38d7091..3702abf593 100644 --- a/src/qemu/qemu_agent.h +++ b/src/qemu/qemu_agent.h @@ -151,7 +151,8 @@ int qemuAgentSetUserPassword(qemuAgentPtr mon, int qemuAgentGetUsers(qemuAgentPtr mon, virTypedParameterPtr *params, int *nparams, - int *maxparams); + int *maxparams, + bool report_unsupported); int qemuAgentGetOSInfo(qemuAgentPtr mon, virTypedParameterPtr *params, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5e1f3efa7d..1347514b6c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -22907,7 +22907,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, * 'unsupported' errors and gather as much information as we can. In a= ll * other cases, abort on error. */ if (supportedTypes & VIR_DOMAIN_GUEST_INFO_USERS) { - rc =3D qemuAgentGetUsers(agent, params, nparams, &maxparams); + rc =3D qemuAgentGetUsers(agent, params, nparams, &maxparams, true); if (rc < 0 && !(rc =3D=3D -2 && types =3D=3D 0)) goto exitagent; } diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index 86fbfbaa4c..dee9068ce5 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -1040,7 +1040,7 @@ testQemuAgentUsers(const void *data) /* get users */ if (qemuAgentGetUsers(qemuMonitorTestGetAgent(test), - ¶ms, &nparams, &maxparams) < 0) + ¶ms, &nparams, &maxparams, true) < 0) goto cleanup; if (virTypedParamsGetUInt(params, nparams, "user.count", &count) < 0) @@ -1069,7 +1069,7 @@ testQemuAgentUsers(const void *data) /* get users with domain */ if (qemuAgentGetUsers(qemuMonitorTestGetAgent(test), - ¶ms, &nparams, &maxparams) < 0) + ¶ms, &nparams, &maxparams, true) < 0) goto cleanup; if (virTypedParamsGetUInt(params, nparams, "user.count", &count) < 0) --=20 2.24.1 From nobody Fri May 17 06:54:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1584347823; cv=none; d=zohomail.com; s=zohoarc; b=Pfy+9+wU4L+j5trcNqFyOl4XhSDTeco/CZvZV61J9d6p7/1OOkRAU4c4xRVZkMJagLfh/PyegYjxmCY+NLj/l+xzzjTFVnt2T6o6TolRmWEM1Eob2aOVOCIPl6tmDy6VXPBIX5qHB05Tw8DpJfb6Lnvket6O3Z5PBAeGUG3ztwA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347823; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X/87iTF2c2VEqkCRrl5RfbWWaPSq7WUILclRgcOj/TY=; b=fFoUoXTheiJH1gjIZnrtW5QeOLAzKxeHP4ZhwggKrz7hKcKmr3wMOujGdShj64n3BMecqGcY+CPFDB64YQsV8GE0JjeXvy59EWqei0/qvfnaH61tS/OQFIpXLnSzIFX6vCM23qNxaqQGRjTGPMg65gNAq7ahhfV09r7MEX1/NT0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1584347823302848.7206307413755; Mon, 16 Mar 2020 01:37:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-12-5dUv6PqJPdGcgPxg2KxmdQ-1; Mon, 16 Mar 2020 04:37:00 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C1694800D5E; Mon, 16 Mar 2020 08:36:54 +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 8870D93532; Mon, 16 Mar 2020 08:36:54 +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 3221585EDD; Mon, 16 Mar 2020 08:36:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02G8aANP026251 for ; Mon, 16 Mar 2020 04:36:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5766C60BFB; Mon, 16 Mar 2020 08:36:10 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id D11AB60BF3 for ; Mon, 16 Mar 2020 08:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347822; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=X/87iTF2c2VEqkCRrl5RfbWWaPSq7WUILclRgcOj/TY=; b=Oo9ufPfmxSV/mW7IRTl0T5ZHMMdI77Jxx3tUSwkd+aWoQ2R86Bfa1XnfIHQsDkT0TGxJIm WzFXXPUSHcgPw0EyQ60jPXOWriRF/tPSv+79+I/pVaTtC529dlWOcSF4FDpth9kjrd3Fl4 Txemj8FjnRqLagaIqK1B0wTBpMnMndk= X-MC-Unique: 5dUv6PqJPdGcgPxg2KxmdQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/12] qemuAgentGetOSInfo: expose 'report_unsupported' argument Date: Mon, 16 Mar 2020 09:35:51 +0100 Message-Id: <609907a671ae78dc685390e73a2121c9af8c8ac0.1584347691.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use qemuAgentCommandFull so that callers of qemuAgentGetOSInfo can suppress error reports if the function is not supported by the guest agent. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 17 +++++++++-------- src/qemu/qemu_agent.h | 3 ++- src/qemu/qemu_driver.c | 2 +- tests/qemuagenttest.c | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 261fc67021..77f3247602 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2411,27 +2411,28 @@ qemuAgentGetUsers(qemuAgentPtr agent, } /* Returns: 0 on success - * -2 when agent command is not supported by the agent - * -1 otherwise + * -2 when agent command is not supported by the agent and + * 'report_unsupported' is false (libvirt error is not reporte= d) + * -1 otherwise (libvirt error is reported) */ int qemuAgentGetOSInfo(qemuAgentPtr agent, virTypedParameterPtr *params, int *nparams, - int *maxparams) + int *maxparams, + bool report_unsupported) { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValuePtr data =3D NULL; + int rc; if (!(cmd =3D qemuAgentMakeCommand("guest-get-osinfo", NULL))) return -1; - if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) { - if (qemuAgentErrorCommandUnsupported(reply)) - return -2; - return -1; - } + if ((rc =3D qemuAgentCommandFull(agent, cmd, &reply, agent->timeout, + report_unsupported)) < 0) + return rc; if (!(data =3D virJSONValueObjectGetObject(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h index 3702abf593..9cade9ca4c 100644 --- a/src/qemu/qemu_agent.h +++ b/src/qemu/qemu_agent.h @@ -157,7 +157,8 @@ int qemuAgentGetUsers(qemuAgentPtr mon, int qemuAgentGetOSInfo(qemuAgentPtr mon, virTypedParameterPtr *params, int *nparams, - int *maxparams); + int *maxparams, + bool report_unsupported); int qemuAgentGetTimezone(qemuAgentPtr mon, virTypedParameterPtr *params, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1347514b6c..17d9bbe01c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -22912,7 +22912,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, goto exitagent; } if (supportedTypes & VIR_DOMAIN_GUEST_INFO_OS) { - rc =3D qemuAgentGetOSInfo(agent, params, nparams, &maxparams); + rc =3D qemuAgentGetOSInfo(agent, params, nparams, &maxparams, true= ); if (rc < 0 && !(rc =3D=3D -2 && types =3D=3D 0)) goto exitagent; } diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index dee9068ce5..57d0f857cc 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -1139,7 +1139,7 @@ testQemuAgentOSInfo(const void *data) /* get osinfo */ if (qemuAgentGetOSInfo(qemuMonitorTestGetAgent(test), - ¶ms, &nparams, &maxparams) < 0) + ¶ms, &nparams, &maxparams, true) < 0) goto cleanup; if (nparams !=3D 8) { @@ -1184,7 +1184,7 @@ testQemuAgentOSInfo(const void *data) /* get users with domain */ if (qemuAgentGetOSInfo(qemuMonitorTestGetAgent(test), - ¶ms, &nparams, &maxparams) < 0) + ¶ms, &nparams, &maxparams, true) < 0) goto cleanup; if (nparams !=3D 10) { --=20 2.24.1 From nobody Fri May 17 06:54:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1584347816; cv=none; d=zohomail.com; s=zohoarc; b=dmaQLtrR8oTZPI/QNiO3VMRAAT/xI9Jyy/PNXfxVUQL7Q4KtHrGH7Ju+12p71ZkVK4cSWP8VB94F6aynLvMzMiFejE3d8hU4Z5mo0hvwIIcHhwob5Jt7yvIofEN9aIO4HdC/uFJ5v66GceHK0dePckV4pyNaOieQvd6sTaXaJnA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347816; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=78ej6OdK4+MDF7t+AZZhpV22CS1CkomEj8cEZ9mUIiM=; b=bDReBkf/txpqF/+8pYeitTgfmec9YHy1i/hFUGAW9BztDl97C1cBBzCXild49nNUBMQfzteuisGmdhGZIixqfUNIsF+baf9Qlt7iUjFtVnoF5lh61WVHndhHbYgBiqFomF+oQ1K//A0ROrj0vzCpLafBz23PKL+37ZWJz5qbvb0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1584347816891622.2979114501675; Mon, 16 Mar 2020 01:36:56 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-415-Iva5aIZvP22xWEmSl-R8MQ-1; Mon, 16 Mar 2020 04:36:54 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8ECCF800D5A; Mon, 16 Mar 2020 08:36:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 692B560BEE; Mon, 16 Mar 2020 08:36:48 +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 2371E1803C42; Mon, 16 Mar 2020 08:36:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02G8aDBu026270 for ; Mon, 16 Mar 2020 04:36:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 69E2960BFB; Mon, 16 Mar 2020 08:36:13 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4E5D60BF3 for ; Mon, 16 Mar 2020 08:36:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347816; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=78ej6OdK4+MDF7t+AZZhpV22CS1CkomEj8cEZ9mUIiM=; b=H8UE+wTV/HEKNWX9dFk041cIdJAzKuMCuK6gjEuzV0g/kfVSMc0dLc69ScwCfx24sv8ciw 783jmQkdIxzWMa21risghra7QCq+YC4ji/GI1seswUihv+h9NovuEGBTS3jDQomc/vG1DF OF8rtIKvkYgqwnOG865sbxGfe68fHo0= X-MC-Unique: Iva5aIZvP22xWEmSl-R8MQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/12] qemuAgentGetTimezone: expose 'report_unsupported' argument Date: Mon, 16 Mar 2020 09:35:52 +0100 Message-Id: <4f2cffb158e22b7a1e9bb132e1cba1eeb91e12c0.1584347691.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use qemuAgentCommandFull so that callers of qemuAgentGetTimezone can suppress error reports if the function is not supported by the guest agent. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 17 +++++++++-------- src/qemu/qemu_agent.h | 3 ++- src/qemu/qemu_driver.c | 2 +- tests/qemuagenttest.c | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 77f3247602..efb6c52f96 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2465,29 +2465,30 @@ qemuAgentGetOSInfo(qemuAgentPtr agent, } /* Returns: 0 on success - * -2 when agent command is not supported by the agent - * -1 otherwise + * -2 when agent command is not supported by the agent and + * 'report_unsupported' is false (libvirt error is not reporte= d) + * -1 otherwise (libvirt error is reported) */ int qemuAgentGetTimezone(qemuAgentPtr agent, virTypedParameterPtr *params, int *nparams, - int *maxparams) + int *maxparams, + bool report_unsupported) { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virJSONValuePtr data =3D NULL; const char *name; int offset; + int rc; if (!(cmd =3D qemuAgentMakeCommand("guest-get-timezone", NULL))) return -1; - if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) { - if (qemuAgentErrorCommandUnsupported(reply)) - return -2; - return -1; - } + if ((rc =3D qemuAgentCommandFull(agent, cmd, &reply, agent->timeout, + report_unsupported)) < 0) + return rc; if (!(data =3D virJSONValueObjectGetObject(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h index 9cade9ca4c..361a67aaee 100644 --- a/src/qemu/qemu_agent.h +++ b/src/qemu/qemu_agent.h @@ -163,7 +163,8 @@ int qemuAgentGetOSInfo(qemuAgentPtr mon, int qemuAgentGetTimezone(qemuAgentPtr mon, virTypedParameterPtr *params, int *nparams, - int *maxparams); + int *maxparams, + bool report_unsupported); void qemuAgentSetResponseTimeout(qemuAgentPtr mon, int timeout); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 17d9bbe01c..1b1fa5e209 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -22917,7 +22917,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, goto exitagent; } if (supportedTypes & VIR_DOMAIN_GUEST_INFO_TIMEZONE) { - rc =3D qemuAgentGetTimezone(agent, params, nparams, &maxparams); + rc =3D qemuAgentGetTimezone(agent, params, nparams, &maxparams, tr= ue); if (rc < 0 && !(rc =3D=3D -2 && types =3D=3D 0)) goto exitagent; } diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index 57d0f857cc..7ea330892b 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -1244,7 +1244,7 @@ testQemuAgentTimezone(const void *data) response_) < 0) \ goto cleanup; \ if (qemuAgentGetTimezone(qemuMonitorTestGetAgent(test), \ - ¶ms_, &nparams_, &maxparams_) < 0) \ + ¶ms_, &nparams_, &maxparams_, true) <= 0) \ goto cleanup; \ if (nparams_ !=3D 2) { \ virReportError(VIR_ERR_INTERNAL_ERROR, \ --=20 2.24.1 From nobody Fri May 17 06:54:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1584347891; cv=none; d=zohomail.com; s=zohoarc; b=MsiNDey48BCcLC7Dno7cCptucV110WeQ8Gl9YEeFI+CgIiJuWG7ySwCDj3d7ayUoA8na1Rtn7ifgdIRb9X5nD6IIPgfIEq4uyQ7FYRFmxCVBNd9B+miftx35TqrM7rL4CltVbEnhBE7ZC4fAq62E1QOPUSIGqBFz4SJuzCkjiAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347891; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ya6tgc06Mj3jbsPW085tJ4SktuwZgzEe3XLO9hddSP0=; b=VSuv+X6fppMMr+iZfW/umcrgTS2AFNZpmlw5r27w7pQtlfQjlUVZmgRK+yobGHpa7QFNIywRvqvoMeP64ComMr4/STLPweqjnLsLeCuqgo9n4koTyulYLfUucUSkbJqu2ltc2x3sTAB9uhw5x1GrriFs6MCzWmSj5MMb+/oqCrk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1584347891774540.5906508879393; Mon, 16 Mar 2020 01:38:11 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-442-Qp5N8JbPORWXNWBH4vZbig-1; Mon, 16 Mar 2020 04:37:04 -0400 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 7665D18B9FC7; Mon, 16 Mar 2020 08:36:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3EB5B27099; Mon, 16 Mar 2020 08:36:59 +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 DABD31803C42; Mon, 16 Mar 2020 08:36:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02G8aGOE026282 for ; Mon, 16 Mar 2020 04:36:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id E09DE60BF3; Mon, 16 Mar 2020 08:36:16 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66C9160BFB for ; Mon, 16 Mar 2020 08:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347890; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Ya6tgc06Mj3jbsPW085tJ4SktuwZgzEe3XLO9hddSP0=; b=SmztZ4Ek0Wewpq1GQtiE6gyzP1tuJ+FgcfO9g80qgKuDZ8cARxjrPh50CWzWFF2uI+JEVn GzoJb+bt3WKsIKaiOJwQYRq55ynn2TUjS/3KJqvWfDdziiV9tXd3b5iD+6jbQLV1qwm1u+ syKgZQO7VtJrsWbnXR0Uv+ZfkA7eCeg= X-MC-Unique: Qp5N8JbPORWXNWBH4vZbig-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/12] qemuAgentGetFSInfo: expose 'report_unsupported' argument Date: Mon, 16 Mar 2020 09:35:53 +0100 Message-Id: <1c08b8abd290ac09deaf65b2baa929d23a806a38.1584347691.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use qemuAgentCommandFull so that callers of qemuAgentGetFSInfo can suppress error reports if the function is not supported by the guest agent. Since this patch removes the last use of qemuAgentErrorCommandUnsupported the whole function is deleted as well. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 42 +++++++++--------------------------------- src/qemu/qemu_agent.h | 4 +++- src/qemu/qemu_driver.c | 4 ++-- tests/qemuagenttest.c | 4 ++-- 4 files changed, 16 insertions(+), 38 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index efb6c52f96..358be30fa1 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -993,31 +993,6 @@ qemuAgentStringifyErrorClass(const char *klass) return "unknown QEMU command error"; } -/* Checks whether the agent reply msg is an error caused by an unsupported - * command. - * - * Returns true when reply is CommandNotFound or CommandDisabled - * false otherwise - */ -static bool -qemuAgentErrorCommandUnsupported(virJSONValuePtr reply) -{ - const char *klass; - virJSONValuePtr error; - - if (!reply) - return false; - - error =3D virJSONValueObjectGet(reply, "error"); - - if (!error) - return false; - - klass =3D virJSONValueObjectGetString(error, "class"); - return STREQ_NULLABLE(klass, "CommandNotFound") || - STREQ_NULLABLE(klass, "CommandDisabled"); -} - /* Ignoring OOM in this method, since we're already reporting * a more important error * @@ -1959,12 +1934,14 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondis= ks, } /* Returns: number of entries in '@info' on success - * -2 when agent command is not supported by the agent - * -1 otherwise + * -2 when agent command is not supported by the agent and + * 'report_unsupported' is false (libvirt error is not reporte= d) + * -1 otherwise (libvirt error is reported) */ int qemuAgentGetFSInfo(qemuAgentPtr agent, - qemuAgentFSInfoPtr **info) + qemuAgentFSInfoPtr **info, + bool report_unsupported) { size_t i; int ret =3D -1; @@ -1973,16 +1950,15 @@ qemuAgentGetFSInfo(qemuAgentPtr agent, virJSONValuePtr data; size_t ndata =3D 0; qemuAgentFSInfoPtr *info_ret =3D NULL; + int rc; cmd =3D qemuAgentMakeCommand("guest-get-fsinfo", NULL); if (!cmd) return ret; - if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) { - if (qemuAgentErrorCommandUnsupported(reply)) - ret =3D -2; - goto cleanup; - } + if ((rc =3D qemuAgentCommandFull(agent, cmd, &reply, agent->timeout, + report_unsupported)) < 0) + return rc; if (!(data =3D virJSONValueObjectGet(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h index 361a67aaee..2eeb376a68 100644 --- a/src/qemu/qemu_agent.h +++ b/src/qemu/qemu_agent.h @@ -98,7 +98,9 @@ int qemuAgentShutdown(qemuAgentPtr mon, int qemuAgentFSFreeze(qemuAgentPtr mon, const char **mountpoints, unsigned int nmountpoints); int qemuAgentFSThaw(qemuAgentPtr mon); -int qemuAgentGetFSInfo(qemuAgentPtr mon, qemuAgentFSInfoPtr **info); +int qemuAgentGetFSInfo(qemuAgentPtr mon, + qemuAgentFSInfoPtr **info, + bool report_unsupported); int qemuAgentSuspend(qemuAgentPtr mon, unsigned int target); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1b1fa5e209..2f043e3ad9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -21774,7 +21774,7 @@ qemuDomainGetFSInfoAgent(virQEMUDriverPtr driver, goto endjob; agent =3D qemuDomainObjEnterAgent(vm); - ret =3D qemuAgentGetFSInfo(agent, info); + ret =3D qemuAgentGetFSInfo(agent, info, true); qemuDomainObjExitAgent(vm, agent); endjob: @@ -22932,7 +22932,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, goto exitagent; if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) { - rc =3D qemuAgentGetFSInfo(agent, &agentfsinfo); + rc =3D qemuAgentGetFSInfo(agent, &agentfsinfo, true); if (rc < 0) { if (!(rc =3D=3D -2 && types =3D=3D 0)) goto exitagent; diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index 7ea330892b..42ef81ac9a 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -254,7 +254,7 @@ testQemuAgentGetFSInfo(const void *data) goto cleanup; if ((ninfo =3D qemuAgentGetFSInfo(qemuMonitorTestGetAgent(test), - &info)) < 0) + &info, true)) < 0) goto cleanup; if (ninfo !=3D 3) { @@ -326,7 +326,7 @@ testQemuAgentGetFSInfo(const void *data) "}") < 0) goto cleanup; - if (qemuAgentGetFSInfo(qemuMonitorTestGetAgent(test), &info) >=3D 0) { + if (qemuAgentGetFSInfo(qemuMonitorTestGetAgent(test), &info, true) >= =3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "agent get-fsinfo command should have failed"); goto cleanup; --=20 2.24.1 From nobody Fri May 17 06:54:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1584347886; cv=none; d=zohomail.com; s=zohoarc; b=EsS/vtLZKugLIoVEHYPBqcFMYiIqLWDe538p0aFlJdmZ4aPEgHxN7WMhTD+1Ax5XjATdj+JwE1HUylFlYQPyds1YtNF6FjfMjVgTQ9JeQDvZzYOrp1wGTS+wCq4viEL3NrlKkP5Xum5x+mJOrAiArjWo7IVEa3l/0gDl8FJmODk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347886; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DFTDaVp0yEQWkVt4DGKEkrYKeGrITFvrP430PT69PMA=; b=YA1Iw5AaMk60SEyWJDuuQnekubEdgjOCsf23QCN1kvv8ixdNH/Ku21FLXcM4r81N4+rDpR/oOTK1kItAMPQYXdHat+rn/folmRYimnMFBbv58g2Ue9VNiDXnJ3p/JZz+VTnsN8AH2Wyy4LyGgaDOdUFUccIdlIBeeXaiiF5+23w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1584347886231115.25172291609113; Mon, 16 Mar 2020 01:38:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-85-naQS8j8iOcKFgmcr3NUTMw-1; Mon, 16 Mar 2020 04:37:09 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F322913EA; Mon, 16 Mar 2020 08:37:03 +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 C3E6992D4F; Mon, 16 Mar 2020 08:37:03 +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 659C686A3E; Mon, 16 Mar 2020 08:37:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02G8aHVO026287 for ; Mon, 16 Mar 2020 04:36:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id B6CCC60BFB; Mon, 16 Mar 2020 08:36:17 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B5A260BF3 for ; Mon, 16 Mar 2020 08:36:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347885; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=DFTDaVp0yEQWkVt4DGKEkrYKeGrITFvrP430PT69PMA=; b=JmQ/GGXC4pxNMmj58paDdEa7CTdYNAjfHc+sQ0DQu0Qm/rjwehR2qZloIm7JdJv/VfnTQY BKBTIf+5MvuB6q7mrCOmPokGMfc90zR0B9/d1pytBwSPI4XcLg2tm709h3RX0q/XvlnW4G SDVv+lr+tMGlJ26A4B3tLKqFezjb3dE= X-MC-Unique: naQS8j8iOcKFgmcr3NUTMw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/12] qemuDomainGetGuestInfo: Suppress non-fatal errors Date: Mon, 16 Mar 2020 09:35:54 +0100 Message-Id: <2fb5f6ce09e22f178e5529d453e785502209beab.1584347691.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Don't report cases when the guest information is not requested explicitly and not present either. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 45 +++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2f043e3ad9..946fe63ea6 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -22876,6 +22876,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, int maxparams =3D 0; g_autofree char *hostname =3D NULL; unsigned int supportedTypes; + bool report_unsupported =3D types !=3D 0; int rc; size_t nfs =3D 0; qemuAgentFSInfoPtr *agentfsinfo =3D NULL; @@ -22906,37 +22907,31 @@ qemuDomainGetGuestInfo(virDomainPtr dom, * categories were explicitly requested (i.e. 'types' is 0), ignore * 'unsupported' errors and gather as much information as we can. In a= ll * other cases, abort on error. */ - if (supportedTypes & VIR_DOMAIN_GUEST_INFO_USERS) { - rc =3D qemuAgentGetUsers(agent, params, nparams, &maxparams, true); - if (rc < 0 && !(rc =3D=3D -2 && types =3D=3D 0)) - goto exitagent; - } - if (supportedTypes & VIR_DOMAIN_GUEST_INFO_OS) { - rc =3D qemuAgentGetOSInfo(agent, params, nparams, &maxparams, true= ); - if (rc < 0 && !(rc =3D=3D -2 && types =3D=3D 0)) - goto exitagent; - } - if (supportedTypes & VIR_DOMAIN_GUEST_INFO_TIMEZONE) { - rc =3D qemuAgentGetTimezone(agent, params, nparams, &maxparams, tr= ue); - if (rc < 0 && !(rc =3D=3D -2 && types =3D=3D 0)) - goto exitagent; - } - if (supportedTypes & VIR_DOMAIN_GUEST_INFO_HOSTNAME) { - rc =3D qemuAgentGetHostname(agent, &hostname, true); - if (rc < 0 && !(rc =3D=3D -2 && types =3D=3D 0)) - goto exitagent; - } + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_USERS && + qemuAgentGetUsers(agent, params, nparams, &maxparams, report_unsup= ported) =3D=3D -1) + goto exitagent; + + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_OS && + qemuAgentGetOSInfo(agent, params, nparams, &maxparams, report_unsu= pported) =3D=3D -1) + goto exitagent; + + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_TIMEZONE && + qemuAgentGetTimezone(agent, params, nparams, &maxparams, report_un= supported) =3D=3D -1) + goto exitagent; + + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_HOSTNAME && + qemuAgentGetHostname(agent, &hostname, report_unsupported) =3D=3D = -1) + goto exitagent; if (hostname && virTypedParamsAddString(params, nparams, &maxparams, "hostname", h= ostname) < 0) goto exitagent; if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) { - rc =3D qemuAgentGetFSInfo(agent, &agentfsinfo, true); - if (rc < 0) { - if (!(rc =3D=3D -2 && types =3D=3D 0)) - goto exitagent; - } else { + rc =3D qemuAgentGetFSInfo(agent, &agentfsinfo, report_unsupported); + if (rc =3D=3D -1) { + goto exitagent; + } else if (rc >=3D 0) { nfs =3D rc; } } --=20 2.24.1