From nobody Sat Feb 7 04:40: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=1620315088; cv=none; d=zohomail.com; s=zohoarc; b=AWi/56NOTlZvTPKBw/LM9pZw/Xf0m6Swa2unHVwGdIv32GliuQaAuxXf615lGQQzPx8bj0c8+4UHynQSwOm1BCQU//SdelnqUthfO4A83IVnSqk9S384fi9To22ZGUXHQw0UPFf2ZAKcP2s/ypuaRXulxPBAVwnUXTR1uLspiPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620315088; 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=jp2PUzu0TD8PaenIKKZplSZEH6zLBAl0OAI6c6PDP7E=; b=SPBdA19JBdVWblC9rB2bZsSTC0VtMPl9TPel7Z1MPQuta4W+8upCjd2bBP5yNco21SBZFRbyuB42U/aTWkm8HSY3qLfsWQlt4FkDUS1Cgxf7+1vtGVS2glIQUlwO6F5qyqiZdX1HB7NsQoK/GiTGX6JyM0HKnl0paeg7JDQzhJY= 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) header.from= 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 1620315088905618.3441420619013; Thu, 6 May 2021 08:31:28 -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-26--dteetfzP7yJBcdbeW5gsw-1; Thu, 06 May 2021 11:31:21 -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 A1983107ACFE; Thu, 6 May 2021 15:31:16 +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 8478760862; Thu, 6 May 2021 15:31:16 +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 4B3361800FF0; Thu, 6 May 2021 15:31:16 +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 146FVEj6011349 for ; Thu, 6 May 2021 11:31:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C6E31079149; Thu, 6 May 2021 15:31:14 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 932961079148 for ; Thu, 6 May 2021 15:31:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620315085; 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=jp2PUzu0TD8PaenIKKZplSZEH6zLBAl0OAI6c6PDP7E=; b=MWO6McW2H9XTZ/ICRjTRmQwjekY+0TH1lJ+ODYyCTrqAjENQSaLffFrJTbOLN93BDA+9oH GVcf3tuSX4yvxDs7xvrQ5o3PhLTjG63az/Slk4R/c45YAiZn+ek20BwXhyS0yuJE2pikCk ZlguqPyD5g2HNOznh0wM/3KZnz/pKf4= X-MC-Unique: -dteetfzP7yJBcdbeW5gsw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/17] virDomainVcpuParse: Assign default vcpus count based on return value of virXMLPropUInt Date: Thu, 6 May 2021 17:30:55 +0200 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.79 on 10.5.11.13 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" Assign the vcpu count when virXMLPropUInt returns '0' meaning that the cpu count was not present in the XML. This will allow to always initialize the value of @result in virXMLPropUInt to prevent use of uninitialized values. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f536630d72..a2dd7d649f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18030,6 +18030,7 @@ virDomainVcpuParse(virDomainDef *def, unsigned int vcpus; g_autofree char *tmp =3D NULL; g_autofree xmlNodePtr *nodes =3D NULL; + int rc; vcpus =3D maxvcpus =3D 1; @@ -18044,10 +18045,11 @@ virDomainVcpuParse(virDomainDef *def, } VIR_FREE(tmp); - vcpus =3D maxvcpus; - - if (virXMLPropUInt(vcpuNode, "current", 10, VIR_XML_PROP_NONE, &vc= pus) < 0) + if ((rc =3D virXMLPropUInt(vcpuNode, "current", 10, VIR_XML_PROP_N= ONE, &vcpus)) < 0) { return -1; + } else if (rc =3D=3D 0) { + vcpus =3D maxvcpus; + } def->placement_mode =3D VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC; if (virXMLPropEnum(vcpuNode, "placement", --=20 2.30.2