From nobody Sat Feb 7 22:44:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652281419; cv=none; d=zohomail.com; s=zohoarc; b=MqvfT9NHBhHdFE3An5gLAptGMwkhh71NpeoTdqwtnHosv1rYgu/nZlrJPdB+fS2dzwfe0roaIjuQuNLB3jNZz47ehFS7pyorsBZnfNhB+DxZgybx+dlgZepyhAgpu81S9SjSTcqS9/0dN14g//g3pDoctevSibDYQyKeWv+2FuM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652281419; 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=J6Kf697weuUCaETB1mfvpGQHP41YK+ZsN4l5EHJ905g=; b=YrzAN0HaqE3LFblrnl8+nY0QX48Hq/VVRw5R94c+oEyfHQ44gwCtuAXGcjG7hSm6ky+EB+Fqr8gTMsy1KeBWtnt//eku2a2hE1x1cuWv4a+/RfDqWONDoVMEVWCcKyRXtMRN3dPEXhM1wF4p8w1uJoN8MpzMqdTGMPBEKdwtNXo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652281419065565.195863314456; Wed, 11 May 2022 08:03:39 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-FSZamstYMVy806byX8yq9Q-1; Wed, 11 May 2022 11:03:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 21F46805F46; Wed, 11 May 2022 15:03:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EC002026D64; Wed, 11 May 2022 15:03:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E7A5A1947B84; Wed, 11 May 2022 15:03:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F1F4E194707B for ; Wed, 11 May 2022 15:03:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E56511121315; Wed, 11 May 2022 15:03:26 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D4BD1121314 for ; Wed, 11 May 2022 15:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652281418; 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=J6Kf697weuUCaETB1mfvpGQHP41YK+ZsN4l5EHJ905g=; b=PLVXG2t+LreohdLA+1Ul0ADY+4J2fC790i8BYLs8d/k78wzJWw4BsiSR0OuHdgctJsxw3N NfXtHenhioS9R7AryUhr/QATR0SNCWq0pdg/g0c0IMnfNAXyz2ZMVoOdEEJ4545Ec0Rwcb zd7dO2QQ2duBf9H+s6zeq9RXLMNEv2I= X-MC-Unique: FSZamstYMVy806byX8yq9Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] conf: Move virDomainObj::originalMemlock into qemuDomainObjPrivate Date: Wed, 11 May 2022 17:03:16 +0200 Message-Id: <4bfd63f9e2723e291a22babafe4fb0e79e06c7d0.1652281291.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652281420264100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Since v1.3.0-90-gafbe1d4c56 the original value of memlock limit is stored inside virDomainObj struct directly (under originalMemlock member). This is needless because the value is used only inside QEMU driver and thus can reside in qemuDomainObjPrivate struct. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/domain_conf.h | 3 --- src/qemu/qemu_domain.c | 9 +++++---- src/qemu/qemu_domain.h | 3 +++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8a48646160..f5d9df3fab 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3064,9 +3064,6 @@ struct _virDomainObj { int taint; size_t ndeprecations; char **deprecations; - - unsigned long long originalMemlock; /* Original RLIMIT_MEMLOCK, zero i= f no - * restore will be required later = */ }; =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainObj, virObjectUnref); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 7974cdb00b..4edae9cca9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9445,6 +9445,7 @@ int qemuDomainAdjustMaxMemLock(virDomainObj *vm, bool forceVFIO) { + qemuDomainObjPrivate *priv =3D vm->privateData; unsigned long long currentMemLock =3D 0; unsigned long long desiredMemLock =3D 0; =20 @@ -9457,8 +9458,8 @@ qemuDomainAdjustMaxMemLock(virDomainObj *vm, /* If this is the first time adjusting the limit, save the cur= rent * value so that we can restore it once memory locking is no l= onger * required */ - if (vm->originalMemlock =3D=3D 0) { - vm->originalMemlock =3D currentMemLock; + if (priv->originalMemlock =3D=3D 0) { + priv->originalMemlock =3D currentMemLock; } } else { /* If the limit is already high enough, we can assume @@ -9471,8 +9472,8 @@ qemuDomainAdjustMaxMemLock(virDomainObj *vm, } else { /* Once memory locking is no longer required, we can restore the * original, usually very low, limit */ - desiredMemLock =3D vm->originalMemlock; - vm->originalMemlock =3D 0; + desiredMemLock =3D priv->originalMemlock; + priv->originalMemlock =3D 0; } =20 if (desiredMemLock > 0 && diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index c7125722e0..248af92649 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -241,6 +241,9 @@ struct _qemuDomainObjPrivate { GSList *dbusVMStateIds; /* true if -object dbus-vmstate was added */ bool dbusVMState; + + unsigned long long originalMemlock; /* Original RLIMIT_MEMLOCK, zero i= f no + * restore will be required later = */ }; =20 #define QEMU_DOMAIN_PRIVATE(vm) \ --=20 2.35.1 From nobody Sat Feb 7 22:44:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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=1652281433; cv=none; d=zohomail.com; s=zohoarc; b=N+QomqnMKDhdOSpCurBKDOXpwFNlDyk6EumfEIk4aMvV6CMGPtv7KZRzcjyWMB4MT0L0Z091++97ColCKrFjQY91tDaos+oOxCG0b5BNUPiTeueUzxhonJiaVlKKHTRekfqKDNXuWKQRWZe4m228TtZW8nXtKYEQuH9FntkJBtI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652281433; 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=LpXUKHsj38WA+eYkrhJISOkd4L8JWeqZJ1by6i6ndJc=; b=c5x7R+NPHahhgMtrssBwFyU9FzyRNUdbScnDSLWYDBBvrNb6qF9Zh3BgSM+z1atXIrauMisXDxIwbqLVZPkTw1jHrUcuaDr3Y7+EhGgXbVAJfziVt/OZll9n8EyIR2qVILJgLX7bR5J/ItQLoFXFFLRXW9yWHIxLy84RsxRjACU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652281433822804.3553559022705; Wed, 11 May 2022 08:03:53 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-170-knQ-r8NlM0aftMmXZ9X9Wg-1; Wed, 11 May 2022 11:03:49 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6F3B101AA42; Wed, 11 May 2022 15:03:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D413914E0A0B; Wed, 11 May 2022 15:03:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A87091947B84; Wed, 11 May 2022 15:03:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A57C0193F6F7 for ; Wed, 11 May 2022 15:03:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 824AB1121315; Wed, 11 May 2022 15:03:27 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A41E1121314 for ; Wed, 11 May 2022 15:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652281432; 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=LpXUKHsj38WA+eYkrhJISOkd4L8JWeqZJ1by6i6ndJc=; b=VRaueqXkLCo8OWV8U+NTogIRLgRbJqYDEak03rXrHMiCZgjfIC9SqhlGNzM2pAAY8davrG jvs9djbPx/+haZ8nd1/5qK8BWGRXBsMQIFRIGsT+BznwkK+1H1BNTI/o4v5QbFvxFlz6QI 3pPhg/GyptPA7HhrbKgc9tNdRXgN1+o= X-MC-Unique: knQ-r8NlM0aftMmXZ9X9Wg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] qemu_domain: Format qemuDomainObjPrivate::originalMemlock Date: Wed, 11 May 2022 17:03:17 +0200 Message-Id: <407bf8c87a1802fa3ee8828d82dedba356755452.1652281291.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652281434301100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Now that qemuDomainObjPrivate struct gained new member format it into XML and parse it so that the value is preserved across daemon restarts. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/qemu/qemu_domain.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4edae9cca9..9602a42196 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2386,6 +2386,12 @@ qemuDomainObjPrivateXMLFormat(virBuffer *buf, if (qemuDomainObjPrivateXMLFormatBackups(buf, vm) < 0) return -1; =20 + if (priv->originalMemlock > 0) { + virBufferAsprintf(buf, + "%llu\n", + priv->originalMemlock); + } + return 0; } =20 @@ -3102,6 +3108,13 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, =20 priv->memPrealloc =3D virXPathBoolean("boolean(./memPrealloc)", ctxt) = =3D=3D 1; =20 + if (virXPathULongLong("string(./originalMemlock)", + ctxt, &priv->originalMemlock) =3D=3D -2) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to parse agent timeout")); + goto error; + } + return 0; =20 error: --=20 2.35.1 From nobody Sat Feb 7 22:44:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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=1652281506; cv=none; d=zohomail.com; s=zohoarc; b=kAzFBzWBek/bcaC9zs9uANj0JZVXcAsdsy8IabGpIPpe1jFPVGjdl4WQ8uc2fTO2RMWwBngbG8ghMljkLvvv2fOT6x/GwvRMVFBlhBpcCOllHtp1KTLGrruT6mi/ZLYTmnTuvmvEdeCeEVbDmIYggaYNaFpQgqpEdi5XZ8usBiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652281506; 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=RACBMckGFFzf2gvAvflZy/g0+NkEDB4pYSlt9Ckn6JM=; b=CIk2+1V3gaYZePBwovqCEyuekzSElL0QbMWeh1VblLfWdraVrMk/Dd145vtxBMmbJFxGNkKp/bjvt0FD2+vLvV6dVRbmJ1WbQ0mwt32DLHaRG+4R0DgYli64BkBlWj3R4wlufkPCIpR/LJm7hdouEmlaNsmJQMiE9OQ8DBIXsPg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652281506552455.9418540282418; Wed, 11 May 2022 08:05:06 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-25-RkvNayAMPBWFDfiYUQeAfA-1; Wed, 11 May 2022 11:04:08 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9C4C23831C5D; Wed, 11 May 2022 15:04:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88952C27E9E; Wed, 11 May 2022 15:04:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 520161947B84; Wed, 11 May 2022 15:04:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3C061194707B for ; Wed, 11 May 2022 15:03:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1EDA11121315; Wed, 11 May 2022 15:03:28 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB0EB1121314 for ; Wed, 11 May 2022 15:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652281505; 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=RACBMckGFFzf2gvAvflZy/g0+NkEDB4pYSlt9Ckn6JM=; b=EOItiSKYXpsovwsQJL6frKGc6MnLusBZV0kIWfLWGEkXjMeFbOipDgUsqqr9yi8fzGCY3z 6R/8UCzdhalll4Ir/WUCHkHX1JKqjRqzJyfAMY6wY2yOoWVsTzBoWLdoeYwKN5grLRVqaW 5ioJy7C2Paa2jj7LZrIMdNppo6zw9II= X-MC-Unique: RkvNayAMPBWFDfiYUQeAfA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] qemu_domain: Drop needless free from qemuDomainObjPrivateXMLParse() Date: Wed, 11 May 2022 17:03:18 +0200 Message-Id: <62cb4a8171c865412d1230bb96066da6b386385a.1652281291.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652281507622100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The qemuDomainObjPrivateXMLParse() is responsible for parsing given XML into qemuDomainObjPrivate struct. As it does so, memory might be allocated for some members. If an error occurs during parsing the control jumps onto 'error' label where only some of previously allocated memory is freed. The reason there's no memory leak is simple: the only caller (virDomainObjParseXML()) unrefs freshly created virDomainObj which in turn causes qemuDomainObjPrivateFree() to be called. Therefore, these partial, selective frees are needless and should be just dropped. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/qemu/qemu_domain.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9602a42196..4de4840c8e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3118,9 +3118,6 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, return 0; =20 error: - g_clear_pointer(&priv->namespaces, virBitmapFree); - g_clear_pointer(&priv->monConfig, virObjectUnref); - g_clear_pointer(&priv->qemuDevices, g_strfreev); return -1; } =20 --=20 2.35.1 From nobody Sat Feb 7 22:44:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652281451; cv=none; d=zohomail.com; s=zohoarc; b=cCsHajOs9sM2+IXSyTwdoRMUQjo6q5Ert8B9vElB0OBVn4xczqDfwmVzxnN/SrDDgSrzmxEXMZ93sR1nxeRjhHNLuD26In4uiTIjyZl+1HJsF2Ctp1224Iz6lRlRRy2cDxqENSEwgWiMv0gmtzneU99aCx5yecVWss8h/iMPUAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652281451; 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=B4PoGY3eebrHfGCG4P7edoZPHQy2yqUL8px3tK983K0=; b=U8a4I3F9+6YDutx5/CQT9pEyicISm5+mez4xgA/85VGyo14zLJqsI85r9VvT0tZT2T4YN59fVAAQtrrj72AR4etF0SPIMPyiF5SKBK6O0scGJLGuSELmeHxYRt6uMpL7No0oBfGfLwws3SqUU/sI8CL/vkkcc0XeaTW1NCpFmek= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 165228145188462.921232322707965; Wed, 11 May 2022 08:04:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-540-TU58EWXAOvyb6ZJRtWA9gw-1; Wed, 11 May 2022 11:03:37 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9A197382ECE3; Wed, 11 May 2022 15:03:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86A202026D2F; Wed, 11 May 2022 15:03:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 47D2E193F6F3; Wed, 11 May 2022 15:03:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CACE4194707B for ; Wed, 11 May 2022 15:03:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AF8811121315; Wed, 11 May 2022 15:03:28 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 578421121314 for ; Wed, 11 May 2022 15:03:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652281450; 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=B4PoGY3eebrHfGCG4P7edoZPHQy2yqUL8px3tK983K0=; b=TrdshWxwR4K+jdCOOaymInw54yaFqsDxVrKQR5Mj94THwSvPudIf6jefW4aRkYJprds5a4 DDL2ilaR+DcLz42HFZL9ukQEjdr6c9uqEmU8qmftVPvIE9fTDz+RuDrOmAFVtiMBq/jfJ9 je6pm03CgAX8Dkeimbc+x3gQlanb4kk= X-MC-Unique: TU58EWXAOvyb6ZJRtWA9gw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] qemu_domain: Drop needless 'error' label in qemuDomainObjPrivateXMLParse() Date: Wed, 11 May 2022 17:03:19 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652281452915100001 Content-Type: text/plain; charset="utf-8"; x-default="true" After previous cleanup the 'error' label in qemuDomainObjPrivateXMLParse() contains nothing but a return statement. Well, the label can be dropped and all 'goto'-s can be replaced with the return statement directly. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/qemu/qemu_domain.c | 53 ++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4de4840c8e..a86bba93d1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2912,13 +2912,13 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctx= t, g_autoptr(virQEMUCaps) qemuCaps =3D NULL; =20 if (!(priv->monConfig =3D virDomainChrSourceDefNew(NULL))) - goto error; + return -1; =20 if (!(monitorpath =3D virXPathString("string(./monitor[1]/@path)", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no monitor path")); - goto error; + return -1; } =20 tmp =3D virXPathString("string(./monitor[1]/@type)", ctxt); @@ -2940,13 +2940,13 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctx= t, virReportError(VIR_ERR_INTERNAL_ERROR, _("unsupported monitor type '%s'"), virDomainChrTypeToString(priv->monConfig->type)); - goto error; + return -1; } =20 if (virXPathInt("string(./agentTimeout)", ctxt, &priv->agentTimeout) = =3D=3D -2) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to parse agent timeout")); - goto error; + return -1; } =20 priv->dbusDaemonRunning =3D virXPathBoolean("boolean(./dbusDaemon)", c= txt) > 0; @@ -2963,11 +2963,11 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctx= t, virReportError(VIR_ERR_INTERNAL_ERROR, _("malformed namespace name: %s"), next->name); - goto error; + return -1; } =20 if (qemuDomainEnableNamespace(vm, ns) < 0) - goto error; + return -1; } } =20 @@ -2979,22 +2979,22 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctx= t, priv->rememberOwner =3D virXPathBoolean("count(./rememberOwner) > 0", = ctxt); =20 if ((n =3D virXPathNodeSet("./vcpus/vcpu", ctxt, &nodes)) < 0) - goto error; + return -1; =20 for (i =3D 0; i < n; i++) { if (qemuDomainObjPrivateXMLParseVcpu(nodes[i], i, vm->def) < 0) - goto error; + return -1; } VIR_FREE(nodes); =20 if ((n =3D virXPathNodeSet("./qemuCaps/flag", ctxt, &nodes)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to parse qemu capabilities flags")); - goto error; + return -1; } if (n > 0) { if (!(qemuCaps =3D virQEMUCapsNew())) - goto error; + return -1; =20 for (i =3D 0; i < n; i++) { g_autofree char *str =3D virXMLPropString(nodes[i], "name"); @@ -3003,7 +3003,7 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, if (flag < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown qemu capabilities flag %s"),= str); - goto error; + return -1; } virQEMUCapsSet(qemuCaps, flag); } @@ -3016,14 +3016,14 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctx= t, priv->lockState =3D virXPathString("string(./lockstate)", ctxt); =20 if (qemuDomainObjPrivateXMLParseJob(vm, ctxt) < 0) - goto error; + return -1; =20 priv->fakeReboot =3D virXPathBoolean("boolean(./fakereboot)", ctxt) = =3D=3D 1; =20 if ((n =3D virXPathNodeSet("./devices/device", ctxt, &nodes)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to parse qemu device list")); - goto error; + return -1; } if (n > 0) { /* NULL-terminated list */ @@ -3034,7 +3034,7 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, if (!priv->qemuDevices[i]) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to parse qemu device list")); - goto error; + return -1; } } } @@ -3043,7 +3043,7 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, if ((n =3D virXPathNodeSet("./slirp/helper", ctxt, &nodes)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to parse slirp helper list")); - goto error; + return -1; } for (i =3D 0; i < n; i++) { g_autofree char *alias =3D virXMLPropString(nodes[i], "alias"); @@ -3055,22 +3055,22 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctx= t, virStrToLong_i(pid, NULL, 10, &slirp->pid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to parse slirp helper list")); - goto error; + return -1; } =20 if (virDomainDefFindDevice(vm->def, alias, &dev, true) < 0 || dev.type !=3D VIR_DOMAIN_DEVICE_NET) - goto error; + return -1; =20 if (qemuDomainObjPrivateXMLParseSlirpFeatures(nodes[i], ctxt, slir= p) < 0) - goto error; + return -1; =20 QEMU_DOMAIN_NETWORK_PRIVATE(dev.data.net)->slirp =3D g_steal_point= er(&slirp); } VIR_FREE(nodes); =20 if (qemuDomainObjPrivateXMLParseAutomaticPlacement(ctxt, priv) < 0) - goto error; + return -1; =20 if ((tmp =3D virXPathString("string(./libDir/@path)", ctxt))) priv->libDir =3D tmp; @@ -3082,28 +3082,28 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctx= t, =20 if (virCPUDefParseXML(ctxt, "./cpu", VIR_CPU_TYPE_GUEST, &priv->origCP= U, false) < 0) - goto error; + return -1; =20 priv->chardevStdioLogd =3D virXPathBoolean("boolean(./chardevStdioLogd= )", ctxt) =3D=3D 1; =20 if (qemuDomainObjPrivateXMLParseAllowReboot(ctxt, &priv->allowReboot) = < 0) - goto error; + return -1; =20 qemuDomainObjPrivateXMLParsePR(ctxt, &priv->prDaemonRunning); =20 if (qemuDomainObjPrivateXMLParseBlockjobs(vm, priv, ctxt) < 0) - goto error; + return -1; =20 if (qemuDomainObjPrivateXMLParseBackups(priv, ctxt) < 0) - goto error; + return -1; =20 qemuDomainStorageIDReset(priv); if (virXPathULongLong("string(./nodename/@index)", ctxt, &priv->nodenameindex) =3D=3D -2) { virReportError(VIR_ERR_XML_ERROR, "%s", _("failed to parse node name index")); - goto error; + return -1; } =20 priv->memPrealloc =3D virXPathBoolean("boolean(./memPrealloc)", ctxt) = =3D=3D 1; @@ -3112,13 +3112,10 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctx= t, ctxt, &priv->originalMemlock) =3D=3D -2) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to parse agent timeout")); - goto error; + return -1; } =20 return 0; - - error: - return -1; } =20 =20 --=20 2.35.1