From nobody Thu May 16 23:09:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1606840922; cv=none; d=zohomail.com; s=zohoarc; b=lyLgiBJlLNvHboMulttDH5LREFZiZ+mDasuOvhRMYYukfQ+ew1qhIc9HR6D1BSLOxodPH/VrfD/dHXaGa9FuSZNnyqT++fo/b2kdEahmkCtxXdRR9zTVbmo8jgNqDBnUOt/r82kqI5KetUGcdJrWsQXPxdG3GlPGxNgIWkjTp2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606840922; 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=LouJeYXay0D9l2zNZBFOJypr1sAEo3JnxR1ssCMWCRQ=; b=XBRHXHh5Ow0I0y7DjTrsFZShCpfXY30wKVPOyOrtLo2ZT85GGcznmOC5Q+fK6EvHmCp8XC28K/zEuwA7T/fh/IX/Gvt+CE+ObiVCllO0LJiRYg+8qPoTV6byUYMgtXrI3NHevA59d9dYjgOCHM3/xOI1gygjIWjCSWckI+GxIk8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1606840922599432.0288397249816; Tue, 1 Dec 2020 08:42:02 -0800 (PST) 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-384-qpazIGEjOxuQ3Q-DkQu1CQ-1; Tue, 01 Dec 2020 11:41:58 -0500 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 9C097858182; Tue, 1 Dec 2020 16:41:52 +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 813F95D6AB; Tue, 1 Dec 2020 16:41:51 +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 264581809C9F; Tue, 1 Dec 2020 16:41:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B1GfocM030202 for ; Tue, 1 Dec 2020 11:41:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 758F618993; Tue, 1 Dec 2020 16:41:50 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9B4560BD8 for ; Tue, 1 Dec 2020 16:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606840921; 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=LouJeYXay0D9l2zNZBFOJypr1sAEo3JnxR1ssCMWCRQ=; b=dpo3c9zKTlo9ZDpABK6Uv1gx5+DEs4N+M/qGqiD5CiLZRrsPbPMfvP52PsEzqARiCV8jZ6 M2gLJO59wlyz7YeQIEhyiISajTeAmprzdER512deuCLZfhunKYlw+CwCGAMxAh2S4q56vs gwa5RSOcUVK7dFoyft/5dzTXdGMnZQo= X-MC-Unique: qpazIGEjOxuQ3Q-DkQu1CQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2] qemuDomainGetGuestInfo: Exit early if getting info fails Date: Tue, 1 Dec 2020 17:41:44 +0100 Message-Id: <75477002e3d18ec776e90c0e55d4f20728fa5ab3.1606840858.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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 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) Content-Type: text/plain; charset="utf-8" If there is an error getting info from guest agent, then the control on qemuDomainGetGuestInfo() jumps onto 'exitagent' label and subsequently continues on 'endagentjob'. Both labels are hit also in success case too. The control then continues by attempting to match fetched info (e.g. disk addresses) with domain def. But this is needless - the API will return error regardless. To return early from the function move both 'exitagent' and 'endagentjob' labels at the end of the function and jump straight onto 'cleanup' afterwards. This allows us to set 'ret =3D 0' later - only when we know we succeeded. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- v2 of: https://www.redhat.com/archives/libvir-list/2020-December/msg00020.html src/qemu/qemu_driver.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8eaa3ce68f..bca1c84630 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20116,12 +20116,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, } } =20 - ret =3D 0; - - exitagent: qemuDomainObjExitAgent(vm, agent); - - endagentjob: qemuDomainObjEndAgentJob(vm); =20 if (nfs > 0 || ndisks > 0) { @@ -20143,6 +20138,8 @@ qemuDomainGetGuestInfo(virDomainPtr dom, qemuDomainObjEndJob(driver, vm); } =20 + ret =3D 0; + cleanup: for (i =3D 0; i < nfs; i++) qemuAgentFSInfoFree(agentfsinfo[i]); @@ -20153,6 +20150,13 @@ qemuDomainGetGuestInfo(virDomainPtr dom, =20 virDomainObjEndAPI(&vm); return ret; + + exitagent: + qemuDomainObjExitAgent(vm, agent); + + endagentjob: + qemuDomainObjEndAgentJob(vm); + goto cleanup; } =20 =20 --=20 2.26.2