From nobody Mon Apr 29 16:38:01 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=1584028929; cv=none; d=zohomail.com; s=zohoarc; b=EL4jAF2A/p+GBrAXa+6UL5wAzqdC79cgLEOXfVUSIieg9+7LlHj+QqCxJlS8sglPe9zvj5nQN/vGOuN4TRNudUCsyYtpJ9/3uMf2FkXleMT+wNx6ZeHX9W9K69VWG/P0aMBdt06nP7mjT3gjZFCDdeNHM6ADFDtkvh4XIMD7At4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584028929; 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=I2MOFic9+vh0y4vjS15XGd3+CI1EnHrpw7ZAgvXP0wo=; b=mGjQDKoikHDQsTFHvW1VR1ubUPxBGxBoJhmJuXrBuZHz81YgY1Jz0vKlYfgpV+QVpnBSN8uTRp6DaUjHFnWP1ntHyH7CB73tGJiU1KWSfWifuN8ObszUMgHcHOAutkC43XfNHXt8UosLL3sILiHhpWLpWYMyG6/pT9QBvmznFOw= 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-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 158402892983936.10649647622017; Thu, 12 Mar 2020 09:02:09 -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-4-h3_RaR7JPy2crS_QsRpTpQ-1; Thu, 12 Mar 2020 12:02:05 -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 9C4F28B7878; Thu, 12 Mar 2020 16:01:58 +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 5855C19C6A; Thu, 12 Mar 2020 16:01:57 +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 B6E1285ECC; Thu, 12 Mar 2020 16:01:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02CG1ttt027661 for ; Thu, 12 Mar 2020 12:01:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 881161001B3F; Thu, 12 Mar 2020 16:01:55 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E3B41001B0B for ; Thu, 12 Mar 2020 16:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584028928; 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=I2MOFic9+vh0y4vjS15XGd3+CI1EnHrpw7ZAgvXP0wo=; b=AuloByq3lND3ZHA6sglwz6UmFVRlLRAxQTsv3Tir18M8YJpxFm3UDxZGfcSueVsqykr/fy NbraPtl9oWHXGsD6nKBOwz4AK2YJzfjIVTkIzLqbhIZ368Qh66IICwWGos5doSlBi6Ab3b +K9TjrT61Q/+5ddOTZB3gPC8TjDAh8M= X-MC-Unique: h3_RaR7JPy2crS_QsRpTpQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] qemuAgentFSInfoFormatParams: Remove pointless returned value Date: Thu, 12 Mar 2020 17:01:49 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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" The only caller doesn't check the value and also there are no real errors to report anyways. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cd761f87b5..02ea582767 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -22709,24 +22709,20 @@ qemuDomainGetGuestInfoCheckSupport(unsigned int *= types) *types =3D *types & supportedGuestInfoTypes; } -/* Returns: 0 on success - * -1 otherwise - */ -static int +static void qemuAgentFSInfoFormatParams(qemuAgentFSInfoPtr *fsinfo, int nfs, virDomainDefPtr vmdef, virTypedParameterPtr *params, int *nparams, int *maxparams) { - int ret =3D -1; size_t i, j; /* FIXME: get disk target */ if (virTypedParamsAddUInt(params, nparams, maxparams, "fs.count", nfs) < 0) - goto cleanup; + return; for (i =3D 0; i < nfs; i++) { char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; @@ -22734,17 +22730,17 @@ qemuAgentFSInfoFormatParams(qemuAgentFSInfoPtr *f= sinfo, "fs.%zu.name", i); if (virTypedParamsAddString(params, nparams, maxparams, param_name, fsinfo[i]->name) < 0) - goto cleanup; + return; g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "fs.%zu.mountpoint", i); if (virTypedParamsAddString(params, nparams, maxparams, param_name, fsinfo[i]->mountpoint) < 0) - goto cleanup; + return; g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "fs.%zu.fstype", i); if (virTypedParamsAddString(params, nparams, maxparams, param_name, fsinfo[i]->fstype) < 0) - goto cleanup; + return; /* disk usage values are not returned by older guest agents, so * only add the params if the value is set */ @@ -22753,20 +22749,20 @@ qemuAgentFSInfoFormatParams(qemuAgentFSInfoPtr *f= sinfo, if (fsinfo[i]->total_bytes !=3D -1 && virTypedParamsAddULLong(params, nparams, maxparams, param_name, fsinfo[i]->total_bytes) < = 0) - goto cleanup; + return; g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "fs.%zu.used-bytes", i); if (fsinfo[i]->used_bytes !=3D -1 && virTypedParamsAddULLong(params, nparams, maxparams, param_name, fsinfo[i]->used_bytes) < 0) - goto cleanup; + return; g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "fs.%zu.disk.count", i); if (virTypedParamsAddUInt(params, nparams, maxparams, param_name, fsinfo[i]->ndisks) < 0) - goto cleanup; + return; for (j =3D 0; j < fsinfo[i]->ndisks; j++) { virDomainDiskDefPtr diskdef =3D NULL; qemuAgentDiskInfoPtr d =3D fsinfo[i]->disks[j]; @@ -22782,7 +22778,7 @@ qemuAgentFSInfoFormatParams(qemuAgentFSInfoPtr *fsi= nfo, if (diskdef->dst && virTypedParamsAddString(params, nparams, maxparams, param_name, diskdef->dst) < 0) - goto cleanup; + return; } g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, @@ -22790,22 +22786,19 @@ qemuAgentFSInfoFormatParams(qemuAgentFSInfoPtr *f= sinfo, if (d->serial && virTypedParamsAddString(params, nparams, maxparams, param_name, d->serial) < 0) - goto cleanup; + return; g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "fs.%zu.disk.%zu.device", i, j); if (d->devnode && virTypedParamsAddString(params, nparams, maxparams, param_name, d->devnode) < 0) - goto cleanup; + return; } } - ret =3D nfs; - - cleanup: - return ret; } + static int qemuDomainGetGuestInfo(virDomainPtr dom, unsigned int types, --=20 2.24.1 From nobody Mon Apr 29 16:38:01 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=1584029014; cv=none; d=zohomail.com; s=zohoarc; b=DyvHkCaI3GBtN45yRAzzEAIt+/zJpngRArQOsT0YxstGjUhA6nsTk53xyfTb2caiaaXB8hYCqpVpuSL37g3h2/oR6cx4UZVKG6o239W1f5/OEfujAxaFcsF/1YJgAWRUX0VylqPmJAnXplVR1jthfFqJtndOMm2oi5WiYJ56lZ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584029014; 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=lTZcS62aO1QSk/tX+vd8nWTnZfjxeLx6Oga/Y/735xE=; b=aCCb/nYsRZzaGP0Q/yvh1wg56omIR4JH4O3ItxQu++S6ZmZMx59s0USZ+KnzaEPVOYWMBlGK03ay+3tkMdgFfKGvkjWVjSejk3pw4uDaUTv1egeZqbmvdMiDiExdRVkY0hJ1h13I+AiWCgSgE33ZRvtllyryqqW9R4HlDyRf8+M= 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 1584029014042321.27091691437613; Thu, 12 Mar 2020 09:03:34 -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-401-88I7M63rPyGBD61Kfca10A-1; Thu, 12 Mar 2020 12:03:30 -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 210A1926B4; Thu, 12 Mar 2020 16:03:24 +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 D860A909FB; Thu, 12 Mar 2020 16:03:23 +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 85AF985ECD; Thu, 12 Mar 2020 16:03:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02CG1u7q027668 for ; Thu, 12 Mar 2020 12:01:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5EC101001B3F; Thu, 12 Mar 2020 16:01:56 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8B331001B0B for ; Thu, 12 Mar 2020 16:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584029012; 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=lTZcS62aO1QSk/tX+vd8nWTnZfjxeLx6Oga/Y/735xE=; b=hHeaZYZcIajN25TLMLoJaEu5teFuxcVilXgv9myWzChoYyaqMDmRHe+T0zbq+xhvTy4iOa HA9rIgsqCrt4jchaZLTzXEoVYSUmzT+j9iXPmub/lnmh5SixZPc91tlhjbCA8StOGk5qBX NOBWk98AQy4d8whJyLWH+VryEpsQhVU= X-MC-Unique: 88I7M63rPyGBD61Kfca10A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] qemuDomainGetGuestInfo: Don't try to free a negative number of entries Date: Thu, 12 Mar 2020 17:01:50 +0100 Message-Id: <49de341a7fcda42ac56b20d10778fa2c2e6d14a9.1584028878.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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" 'nfs' variable was set to -1 or -2 on agent failure. Cleanup then tried to free 'nfs' elements of the array which resulted into a crash. Make 'nfs' size_t and assign it only on successful agent call. https://bugzilla.redhat.com/show_bug.cgi?id=3D1812965 Broken by commit 599ae372d8cf092 Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 2 +- src/qemu/qemu_driver.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 9f3fb9732f..dff327e8d5 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1914,7 +1914,7 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks, return 0; } -/* Returns: 0 on success +/* Returns: number of entries in '@info' on success * -2 when agent command is not supported by the agent * -1 otherwise */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 02ea582767..e285e9373c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -22814,7 +22814,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, g_autofree char *hostname =3D NULL; unsigned int supportedTypes =3D types; int rc; - int nfs =3D 0; + size_t nfs =3D 0; qemuAgentFSInfoPtr *agentfsinfo =3D NULL; size_t i; @@ -22867,9 +22867,13 @@ qemuDomainGetGuestInfo(virDomainPtr dom, } } if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) { - rc =3D nfs =3D qemuAgentGetFSInfo(agent, &agentfsinfo); - if (rc < 0 && !(rc =3D=3D -2 && types =3D=3D 0)) - goto exitagent; + rc =3D qemuAgentGetFSInfo(agent, &agentfsinfo); + if (rc < 0) { + if (!(rc =3D=3D -2 && types =3D=3D 0)) + goto exitagent; + } else { + nfs =3D rc; + } } ret =3D 0; --=20 2.24.1