From nobody Tue Feb 10 01:19:33 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=1620650940; cv=none; d=zohomail.com; s=zohoarc; b=K2guU+JUOzDE4c1Pd5wYiOzo0bN8cslewTe/pIfMbFz+6REEIRfp28begFn+8HpIvOIaBYyk7cWvbxRUQ/BMNjBTAitjeq4L2Q0b5ITHlM/0+7xClfLHNkQavVkENQKc0K3ZGjzvIMSPq90u9zR5+RZYDM1Uzg9DmuAuVLaLOkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620650940; h=Content-Type:Content-Transfer-Encoding:Cc: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=NknhAQqWRiKtQk61xr6Q7xkifLdEbEj4ZJuAadhulDc=; b=XqPCWE+LmT7q1aSASTFmNurvZ8I+UOwTQjetGM4aPRMvcq9MTW6aUfJ5jfExWugrzcJwZPTMqafS3lk6dfYoGKCZvVieYytZaP4MPSZRYqKrLTESRqwTF4XtLVjca2tm5LQ3vbzTm7MqRkYEHJYKKXvX3vSsHfHNhFuJIvw2mnQ= 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 1620650940690803.1917339674845; Mon, 10 May 2021 05:49:00 -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-228-r5GkCTT6OkOBAQIP5dAjNA-1; Mon, 10 May 2021 08:48:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 93F57108C283; Mon, 10 May 2021 12:48:51 +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 3F2F25D9FC; Mon, 10 May 2021 12:48:51 +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 0F2F444A63; Mon, 10 May 2021 12:48:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14ACml3b005593 for ; Mon, 10 May 2021 08:48:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 543AD1724D; Mon, 10 May 2021 12:48:47 +0000 (UTC) Received: from work.redhat.com (ovpn-113-46.ams2.redhat.com [10.36.113.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 926355F707; Mon, 10 May 2021 12:48:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620650938; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=NknhAQqWRiKtQk61xr6Q7xkifLdEbEj4ZJuAadhulDc=; b=K3EDEWCCUZI8C0FO/L8p5x8kJ4GnW0yT217LbjGcCLLcIlymzKwxfQl1u3BaWsQu+2kjya 8Nh+jG2h5NLqL8YA49Ah/SWIHmSxar6+pvqsGWvm9U2tGQIR7ZY34yDZ8CYQXqlH/nPHbD kY5YZuKUrPb2NOCl7ZYybEccifdL7cM= X-MC-Unique: r5GkCTT6OkOBAQIP5dAjNA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 01/10] virDomainObjParseXML: Use virXMLProp* Date: Mon, 10 May 2021 14:48:32 +0200 Message-Id: <20210510124841.123066-2-twiederh@redhat.com> In-Reply-To: <20210510124841.123066-1-twiederh@redhat.com> References: <20210510124841.123066-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.14 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" Signed-off-by: Tim Wiederhake --- src/conf/domain_conf.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e8632e4d73..0d396cbdda 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20354,7 +20354,7 @@ virDomainObjParseXML(xmlDocPtr xml, virDomainObj *obj; size_t i; int n; - int state; + virDomainState state; int reason =3D 0; void *parseOpaque =3D NULL; g_autofree char *tmp =3D NULL; @@ -20377,17 +20377,9 @@ virDomainObjParseXML(xmlDocPtr xml, if (!obj->def) goto error; =20 - if (!(tmp =3D virXMLPropString(ctxt->node, "state"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing domain state")); + if (virXMLPropEnum(ctxt->node, "state", virDomainStateTypeFromString, + VIR_XML_PROP_REQUIRED, &state) < 0) goto error; - } - if ((state =3D virDomainStateTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid domain state '%s'"), tmp); - goto error; - } - VIR_FREE(tmp); =20 if ((tmp =3D virXMLPropString(ctxt->node, "reason"))) { if ((reason =3D virDomainStateReasonFromString(state, tmp)) < 0) { @@ -20409,18 +20401,16 @@ virDomainObjParseXML(xmlDocPtr xml, if ((n =3D virXPathNodeSet("./taint", ctxt, &taintNodes)) < 0) goto error; for (i =3D 0; i < n; i++) { - char *str =3D virXMLPropString(taintNodes[i], "flag"); - if (str) { - int flag =3D virDomainTaintTypeFromString(str); - if (flag < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown taint flag %s"), str); - VIR_FREE(str); - goto error; - } - VIR_FREE(str); - virDomainObjTaint(obj, flag); - } + int rc; + virDomainTaintFlags taint; + + if ((rc =3D virXMLPropEnum(taintNodes[i], "flag", + virDomainTaintTypeFromString, + VIR_XML_PROP_NONE, &taint)) < 0) + goto error; + + if (rc =3D=3D 1) + virDomainObjTaint(obj, taint); } =20 if ((n =3D virXPathNodeSet("./deprecation", ctxt, &depNodes)) < 0) --=20 2.26.3