From nobody Mon Feb 9 19:06:35 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=1649405534; cv=none; d=zohomail.com; s=zohoarc; b=YROPzwz4Au5jMdcZFLcP0FHbMN2xBOk62Kna+d+fZroIqpvgVIclLRkjI/lZdo7of6paExAZElIdDfMozfxD2eVARfLAoiTlfbHAYFXHyZ6gKbBT3QXwf7IBNQFVuafVwmFIVGqMIBdmsn3Bc+nADwFG36pdzUlG8tFwS4GuIYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649405534; 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=2j6oiso8I94F4bghlnnc+qKThxqHvk5jWvDbB7rLxcI=; b=ZlTRpb283eqw/KQ+zwLR6K7wQnh7DxX1DBv6vzeB29O1aMbMXbOW5Eey2DNMgQ7e2CIHE+lbiEE5dWAx1hkEMsN5LBE+/4dknz+05QDqBRkvV91sOcPBgkJlMTS7lU9t+CnKft63BXhPYGkZUTlh4OMbsfDRca6HnlOonx0M+Rg= 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 1649405534719353.9562437259765; Fri, 8 Apr 2022 01:12:14 -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-401-5wz6RlOKO0StseYog8C_tQ-1; Fri, 08 Apr 2022 04:11:02 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B0F586B8AB; Fri, 8 Apr 2022 08:10:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7483F54ACB0; Fri, 8 Apr 2022 08:10:58 +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 A004A1940350; Fri, 8 Apr 2022 08:10:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D93881940344 for ; Fri, 8 Apr 2022 08:10:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CDDD1482CCE; Fri, 8 Apr 2022 08:10:53 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7649D54ACBC for ; Fri, 8 Apr 2022 08:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649405533; 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=2j6oiso8I94F4bghlnnc+qKThxqHvk5jWvDbB7rLxcI=; b=CR2ISYhiOBxzNR4jV0nCCAyU4YbB/ouS/iKDEW0BgxnYu/LQLulqCo8+3imy9S9QUwjbog +4lT19Nd86J7SW2KLoFW1R2RPFdNmGqpO3WS6M7Ed3iDScoMYA6CXhwvzexOZi5/Rdli2K 3iCnhS5zZ5pH0bdUZrxwr1/sACwVMm4= X-MC-Unique: 5wz6RlOKO0StseYog8C_tQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 11/17] virDomainDiskDefParseSourceXML: Switch to virXMLPropEnumDefault() Date: Fri, 8 Apr 2022 10:08:50 +0200 Message-Id: <248f0398fd941df1c9c81afddf26bb46863ff84c.1649405101.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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.9 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: 1649405536815100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The virDomainDiskDefParseSourceXML() function uses old style of parsing XML (virXMLPropString + str2enum conversion). Use virXMLPropEnumDefault() which encapsulates those steps. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3bbc5f2214..97cf4f20eb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9043,15 +9043,11 @@ virDomainDiskDefParseSourceXML(virDomainXMLOption *= xmlopt, if (virDomainStorageSourceParse(tmp, ctxt, src, flags, xmlopt) < 0) return NULL; =20 - if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { - g_autofree char *sourceindex =3D NULL; - - if ((sourceindex =3D virXMLPropString(tmp, "index")) && - virStrToLong_uip(sourceindex, NULL, 10, &src->id) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid disk index '%s'"), sourceindex); - return NULL; - } + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && + virXMLPropUInt(tmp, "index", 10, + VIR_XML_PROP_NONE, + &src->id) < 0) { + return NULL; } } else { /* Reset src->type in case when 'source' was not present */ --=20 2.35.1