From nobody Mon Feb 9 12:09:59 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=1653311413; cv=none; d=zohomail.com; s=zohoarc; b=GUE91KyM08F8zjUU92KRpzXc/1tiDMCI5rKTdvLbUdZljP8kW/7h1fDmyYgrryTaX2yx3Vgo+LCG0fNkAJU/kii+uTemducBBRdAVyo6Tl+B+wo3O1VNOMptqSA9EUXmCT+1QSDQIjLpWLa4eHyr5/Pi5Lir9zEvOJS8oxGtzJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653311413; 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=xEtlCon82zvVJLlcjnsOSQuLEdxz3j/Fmp5eC4gb/BQ=; b=FKa5xTXQ8uzmA4H0kDfmetSLxT+9kmW8o0Pz3uDjOP3D93x/MEj2RCqRYnogZqEhry8qZwt8745nmcV5UkOCe+s5MN8EHDt1iK2LVP7Ca1T2QD7f8Z0XCd4AO72GKKnLTRE937IbqQONZOvuJevDFUMZOEEKiSAr31xOCdJIorA= 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 1653311413798885.8904884105735; Mon, 23 May 2022 06:10:13 -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-330--WFnZ39hMHaXCoyhZJfSKg-1; Mon, 23 May 2022 09:09:14 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 055CB803B42; Mon, 23 May 2022 13:09:06 +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 E4B482166B2D; Mon, 23 May 2022 13:09:05 +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 9EF58194705A; Mon, 23 May 2022 13:09:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4BDB9194705A for ; Mon, 23 May 2022 13:09:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3FC5B400E122; Mon, 23 May 2022 13:09:02 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id DABCD4010E22 for ; Mon, 23 May 2022 13:09:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653311412; 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=xEtlCon82zvVJLlcjnsOSQuLEdxz3j/Fmp5eC4gb/BQ=; b=VCCyesIRgXSiNGr/cKtaCF+/JxaueTz21wUR1CsURMjcsg8B2IHrtTQK6EpZzEzEfa/xMj /AP25MnL+ctpX416x4ey/rf/PS6h9MD790rJN7CnTRQ3AVO0G7WFmYDZRSlVSgGjQuVlCt H0hg3UzH2yLHxTyfqvGCEkkfmPeaTqQ= X-MC-Unique: -WFnZ39hMHaXCoyhZJfSKg-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: Mon, 23 May 2022 15:08:46 +0200 Message-Id: <712c1fa50b64b3781d7dbab9be0bbf8ff089c00d.1653311261.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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.6 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: 1653311414859100004 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 Reviewed-by: Boris Fiuczynski --- 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 c42ac9c0c9..44b507b74d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9039,15 +9039,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