From nobody Wed May 15 23:14:20 2024 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=1619007010; cv=none; d=zohomail.com; s=zohoarc; b=AHJ3nRj5r4odg0WsPoJJAHII1b+UmT8A0t/uQuNj50KCFX6AESPf+v8XXpSDHsKOeEd1ivo4ESq6UecTT9UmtSMVXZZQSqtOKqKn8GOrJZJsJUNvWZ2ryJO8DTkL3007103sHeuyFwRATusvs+wiZWjXtSGwL3z0bEBi5jW489s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619007010; 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=YHtIRLRmIbjd2hU47ilbIC2nstLRM3GYqu+PmbTN0l4=; b=axH4Pjm4qAoA5c0A1t2lUlOZw2GKXnFc6sId7EQioZFRu61V5wW7ecafyL3IwSQU5WanoAVRzY9kByNBFDHCoRxBpw9Bc6I+Hb331ex4GOmaIFkocTFC4bDwdM5Yeb54sEu6D7SM9IlzkJfqZQFp4DuZM08Zx45Q0Ov7oO+7Omg= 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 1619007010805543.0897090991508; Wed, 21 Apr 2021 05:10:10 -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-194-meyjBwT0MOG4rRyszuULMA-1; Wed, 21 Apr 2021 08:09:02 -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 715689F93A; Wed, 21 Apr 2021 12:08:56 +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 E47985D9C0; Wed, 21 Apr 2021 12:08:55 +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 11EC41806D38; Wed, 21 Apr 2021 12:08:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13LC8EnN008625 for ; Wed, 21 Apr 2021 08:08:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id DE95C60938; Wed, 21 Apr 2021 12:08:14 +0000 (UTC) Received: from work.redhat.com (ovpn-112-172.ams2.redhat.com [10.36.112.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08BF460871; Wed, 21 Apr 2021 12:08:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619007009; 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=YHtIRLRmIbjd2hU47ilbIC2nstLRM3GYqu+PmbTN0l4=; b=JEBaOddl00ZgavYfC5yq5+46ShMcHJhmpKpXOhFNm0Ugneqc5Dd1AlNo3vbiFmxVAR/3BR tAUhV3InglmOGWPQxHVNzwxZp9CXED1GroVBDOKu7hfwP8ajdCaXk7RiKELZECxcwPq5MM lnXHst/lo4wFO77LlJhi9wnJ5n4vnNQ= X-MC-Unique: meyjBwT0MOG4rRyszuULMA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 01/10] virDomainBackupDiskDefParseXML: Use virXMLProp* Date: Wed, 21 Apr 2021 14:07:59 +0200 Message-Id: <20210421120808.35786-2-twiederh@redhat.com> In-Reply-To: <20210421120808.35786-1-twiederh@redhat.com> References: <20210421120808.35786-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , 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 Reviewed-by: Peter Krempa --- src/conf/backup_conf.c | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index 7f54a25ff6..e4464b91a0 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -106,10 +106,6 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node, g_autofree char *type =3D NULL; g_autofree char *format =3D NULL; g_autofree char *idx =3D NULL; - g_autofree char *backup =3D NULL; - g_autofree char *state =3D NULL; - g_autofree char *backupmode =3D NULL; - int tmp; xmlNodePtr srcNode; unsigned int storageSourceParseFlags =3D 0; bool internal =3D flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL; @@ -127,15 +123,9 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node, =20 def->backup =3D VIR_TRISTATE_BOOL_YES; =20 - if ((backup =3D virXMLPropString(node, "backup"))) { - if ((tmp =3D virTristateBoolTypeFromString(backup)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid disk 'backup' state '%s'"), backup); - return -1; - } - - def->backup =3D tmp; - } + if (virXMLPropTristateBool(node, "backup", VIR_XML_PROP_NONE, + &def->backup) < 0) + return -1; =20 /* don't parse anything else if backup is disabled */ if (def->backup =3D=3D VIR_TRISTATE_BOOL_NO) @@ -146,28 +136,18 @@ virDomainBackupDiskDefParseXML(xmlNodePtr node, def->exportbitmap =3D virXMLPropString(node, "exportbitmap"); } =20 - if ((backupmode =3D virXMLPropString(node, "backupmode"))) { - if ((tmp =3D virDomainBackupDiskBackupModeTypeFromString(backupmod= e)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid backupmode '%s' of disk '%s'"), - backupmode, def->name); - return -1; - } - - def->backupmode =3D tmp; - } + if (virXMLPropEnum(node, "backupmode", + virDomainBackupDiskBackupModeTypeFromString, + VIR_XML_PROP_NONE, &def->backupmode) < 0) + return -1; =20 def->incremental =3D virXMLPropString(node, "incremental"); =20 if (internal) { - if (!(state =3D virXMLPropString(node, "state")) || - (tmp =3D virDomainBackupDiskStateTypeFromString(state)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("disk '%s' backup state wrong or missing'"), = def->name); + if (virXMLPropEnum(node, "state", + virDomainBackupDiskStateTypeFromString, + VIR_XML_PROP_REQUIRED, &def->state) < 0) return -1; - } - - def->state =3D tmp; } =20 type =3D virXMLPropString(node, "type"); --=20 2.26.3 From nobody Wed May 15 23:14:20 2024 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=1619006955; cv=none; d=zohomail.com; s=zohoarc; b=aNkvTNHf3PL4rK1jr+v6goZsHYc+Z8zI9n1lIPI9JYgejGY96eCXW60dej1CrT6kS+brZ/zLDt3MuT80feBPuHiIPLSGA9PYIFbVfCZA/I7FMgkC8Ho225SIv6X906EaTzFCqN2Uf+jaom3/X85DeX99Mpayi55sbA+scXdTi5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619006955; 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=9X+yq5+sMx8b6qVujrppl4ksh+94gcxfkoY8EcJd1IQ=; b=glaQ4VfIRMvbNNX5OGbo8N7/rAStW2asSpWg6i4INjb+mtbWyzFQya97JBz4zePyAtqvGRqG9YBbn6L4pG31HhsxRg0kQ0wCedRxRumAcBSoA3lvjM9KulWCNuAQ5HE+uW4Vn8pxwxbbiGXf/1E5+kEnjWVO9Y5IedVugLDgaJM= 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 1619006955246186.94121425532148; Wed, 21 Apr 2021 05:09:15 -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-370-MmSlR1XgMGGZcadjX6xewA-1; Wed, 21 Apr 2021 08:09:12 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 218C918B9F51; Wed, 21 Apr 2021 12:09:03 +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 EB1925C1B4; Wed, 21 Apr 2021 12:09:02 +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 B1A0B5533E; Wed, 21 Apr 2021 12:09:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13LC8Gbt008636 for ; Wed, 21 Apr 2021 08:08:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 381F260938; Wed, 21 Apr 2021 12:08:16 +0000 (UTC) Received: from work.redhat.com (ovpn-112-172.ams2.redhat.com [10.36.112.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CFD560871; Wed, 21 Apr 2021 12:08:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619006954; 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=9X+yq5+sMx8b6qVujrppl4ksh+94gcxfkoY8EcJd1IQ=; b=GnuhjKTwznHP/Swgz/vK2hxJIeXCUX6rSjctLRUBSu66A0vzfHvi36ZBs8hoam6khLWcNy wS5SX8wdMKke+qMyYSvmIDfnFyql2HMKvrIzrtlpIWMUhCGfp+igsEpUR9Mqix81T78wuv o2MGMp+i2Gbq8QBwCCiklzNsF1ekiVQ= X-MC-Unique: MmSlR1XgMGGZcadjX6xewA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 02/10] virDomainBackupDefParse: Use virXMLProp* Date: Wed, 21 Apr 2021 14:08:00 +0200 Message-Id: <20210421120808.35786-3-twiederh@redhat.com> In-Reply-To: <20210421120808.35786-1-twiederh@redhat.com> References: <20210421120808.35786-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , 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.16 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 Reviewed-by: Peter Krempa --- src/conf/backup_conf.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index e4464b91a0..7f176b783f 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -222,8 +222,6 @@ virDomainBackupDefParse(xmlXPathContextPtr ctxt, def->incremental =3D virXPathString("string(./incremental)", ctxt); =20 if ((node =3D virXPathNode("./server", ctxt))) { - g_autofree char *tls =3D NULL; - if (def->type !=3D VIR_DOMAIN_BACKUP_TYPE_PULL) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("use of requires pull mode backup")); @@ -249,18 +247,9 @@ virDomainBackupDefParse(xmlXPathContextPtr ctxt, return NULL; } =20 - if ((tls =3D virXMLPropString(node, "tls"))) { - int tmp; - - if ((tmp =3D virTristateBoolTypeFromString(tls)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown value '%s' of 'tls' attribute"),\ - tls); - return NULL; - } - - def->tls =3D tmp; - } + if (virXMLPropTristateBool(node, "tls", VIR_XML_PROP_NONE, + &def->tls) < 0) + return NULL; } =20 if ((n =3D virXPathNodeSet("./disks/*", ctxt, &nodes)) < 0) --=20 2.26.3 From nobody Wed May 15 23:14:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1619007014; cv=none; d=zohomail.com; s=zohoarc; b=MzLXvSpFikt9IGl1COS4UCFEBUJeecasXekUeRK6CDVazjY/yjSTigbn9eXx67yWJVlR12EPvx7zKb+LR7DaLFK0HGYHBVgVJvRGqYqinKr5+XVwukN4YQ0p0fPCfcw19Cn4HheHNAp4h5vIvNIZf0zjaq9+XYZFRV9kcCRq7lo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619007014; 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=aIrJBiWBHWBR2zJl//r+Iyi7viHZet7irSjWBcmiKz0=; b=AIFgUNL9nwQRXb8XEemOZu/cXs2t4NlcVYQ2hr0uxm+Atbt3V318IWEJRzn2L/UwnLfjuFepRI+X/w+NkfixfsRbx4fZTHpdXpc8+Qkfq72tgqwLwMu/UwORSmvTVa8qxm4EkeuF2JYOuAI6E6uc2yo7pJL2T9SVFgioo7czMps= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1619007014636315.62152976863536; Wed, 21 Apr 2021 05:10:14 -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-339-Z3qDgmJcNGaMLBj1XRYE3Q-1; Wed, 21 Apr 2021 08:09:10 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5246D107ACFC; Wed, 21 Apr 2021 12:09:03 +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 1E46F19744; Wed, 21 Apr 2021 12:09:03 +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 D6B1B5533F; Wed, 21 Apr 2021 12:09:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13LC8HNR008641 for ; Wed, 21 Apr 2021 08:08:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6DCCF6091B; Wed, 21 Apr 2021 12:08:17 +0000 (UTC) Received: from work.redhat.com (ovpn-112-172.ams2.redhat.com [10.36.112.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B6A160871; Wed, 21 Apr 2021 12:08:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619007012; 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=aIrJBiWBHWBR2zJl//r+Iyi7viHZet7irSjWBcmiKz0=; b=jQC9hWUgLBFXukOjucIyjmYl8OfHK7M48cCTN+9+D/ZARFKhlGXjuvyKD6lwyuv6kSG49c nTor9m/3BwqnmG001A27AsNlsr3JnyoeL4Yc2AmEm7bw4S9Bex9qyu1AHExVhh7mJJEFhe J+8+pUvTO+8R6NRdC9/Yy/HY4Gr7I64= X-MC-Unique: Z3qDgmJcNGaMLBj1XRYE3Q-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 03/10] virZPCIDeviceAddressParseXML: Use virXMLProp* Date: Wed, 21 Apr 2021 14:08:01 +0200 Message-Id: <20210421120808.35786-4-twiederh@redhat.com> In-Reply-To: <20210421120808.35786-1-twiederh@redhat.com> References: <20210421120808.35786-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , 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.84 on 10.5.11.23 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 Reviewed-by: Peter Krempa --- src/conf/device_conf.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 6a4b14cfda..9abbd5ebb7 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -52,32 +52,22 @@ static int virZPCIDeviceAddressParseXML(xmlNodePtr node, virPCIDeviceAddress *addr) { - virZPCIDeviceAddress def =3D { .uid =3D { 0 }, .fid =3D { 0 } }; - g_autofree char *uid =3D NULL; - g_autofree char *fid =3D NULL; + int retUid; + int retFid; =20 - uid =3D virXMLPropString(node, "uid"); - fid =3D virXMLPropString(node, "fid"); + if ((retUid =3D virXMLPropUInt(node, "uid", 0, VIR_XML_PROP_NONE, + &addr->zpci.uid.value)) < 0) + return -1; =20 - if (uid) { - if (virStrToLong_uip(uid, NULL, 0, &def.uid.value) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'uid' attribute")); - return -1; - } - def.uid.isSet =3D true; - } + if (retUid > 0) + addr->zpci.uid.isSet =3D true; =20 - if (fid) { - if (virStrToLong_uip(fid, NULL, 0, &def.fid.value) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'fid' attribute")); - return -1; - } - def.fid.isSet =3D true; - } + if ((retFid =3D virXMLPropUInt(node, "fid", 0, VIR_XML_PROP_NONE, + &addr->zpci.fid.value)) < 0) + return -1; =20 - addr->zpci =3D def; + if (retFid > 0) + addr->zpci.fid.isSet =3D true; =20 return 0; } --=20 2.26.3 From nobody Wed May 15 23:14:20 2024 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=1619007013; cv=none; d=zohomail.com; s=zohoarc; b=JJ2efQThQ1IG9FZc6bqQnmLk49Ynv/Qoq66UMwzyl78+gb++KCBzbOBa53qXvb6CcNU2lR5WDqHVjIeh93skNBaA4GnnVVhErUL4QM+GIYQOr/6sKJXwsPTUbld61kXoqfHuYPBRIBGBiT5CRPsjVHv4qMAqWc7QgWlSBxlrXNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619007013; 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=+d42O881bCBXZg/mCoOsdmYnOVceIRjqZKh3UITFGrg=; b=NTPSflqtXkGLBwgqf8XPRqvrQH1oacKltyJyggCy2ZShA+5No7R4Yxr3FbWb2zOEMVOBr6xBrTDu9qpnXruU/n4hagBApFVSTMRVOlfDBp4MLF6Nh0Awir5/6g2Oy6n+6rMRyCeOidbyowxsN+sZMcP356qF4lalmNtDWlbbGXE= 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 1619007013706323.7391389919494; Wed, 21 Apr 2021 05:10:13 -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-41-4eYl8YPONYe0nUkSh_OQ8g-1; Wed, 21 Apr 2021 08:09:16 -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 0868E18B9F60; Wed, 21 Apr 2021 12:09:06 +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 DD87C6091B; Wed, 21 Apr 2021 12:09:05 +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 A91F51806D1A; Wed, 21 Apr 2021 12:09:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13LC8IjV008656 for ; Wed, 21 Apr 2021 08:08:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9DC956091B; Wed, 21 Apr 2021 12:08:18 +0000 (UTC) Received: from work.redhat.com (ovpn-112-172.ams2.redhat.com [10.36.112.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFAE560871; Wed, 21 Apr 2021 12:08:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619007012; 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=+d42O881bCBXZg/mCoOsdmYnOVceIRjqZKh3UITFGrg=; b=CdOWQ4G1QYTJ2JALtyo1U1Jio3QxptM6ZwfjHY+SZtetHKyZAMxge7GHryZl7p00tjKPBD oV+D4hLRelPlSLI+qSl4JeyZPgFJAtqmOAemIVxlfTAmURqGJQlyn1u8m/fikfKTGOt6cC wNlFBckjyFlldCfhdvcCONjkncs0D+k= X-MC-Unique: 4eYl8YPONYe0nUkSh_OQ8g-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 04/10] virPCIDeviceAddressParseXML: Use virXMLProp* Date: Wed, 21 Apr 2021 14:08:02 +0200 Message-Id: <20210421120808.35786-5-twiederh@redhat.com> In-Reply-To: <20210421120808.35786-1-twiederh@redhat.com> References: <20210421120808.35786-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , 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.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" Signed-off-by: Tim Wiederhake Reviewed-by: Peter Krempa --- src/conf/device_conf.c | 47 +++++++++++------------------------------- 1 file changed, 12 insertions(+), 35 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 9abbd5ebb7..801552a9cf 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -200,52 +200,29 @@ virPCIDeviceAddressParseXML(xmlNodePtr node, { xmlNodePtr cur; xmlNodePtr zpci =3D NULL; - g_autofree char *domain =3D virXMLPropString(node, "domain"); - g_autofree char *bus =3D virXMLPropString(node, "bus"); - g_autofree char *slot =3D virXMLPropString(node, "slot"); - g_autofree char *function =3D virXMLPropString(node, "function"); - g_autofree char *multi =3D virXMLPropString(node, "multifunction"); =20 memset(addr, 0, sizeof(*addr)); =20 - if (domain && - virStrToLong_uip(domain, NULL, 0, &addr->domain) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'domain' attribute")); + if (virXMLPropUInt(node, "domain", 0, VIR_XML_PROP_NONE, + &addr->domain) < 0) return -1; - } =20 - if (bus && - virStrToLong_uip(bus, NULL, 0, &addr->bus) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'bus' attribute")); + if (virXMLPropUInt(node, "bus", 0, VIR_XML_PROP_NONE, + &addr->bus) < 0) return -1; - } =20 - if (slot && - virStrToLong_uip(slot, NULL, 0, &addr->slot) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'slot' attribute")); + if (virXMLPropUInt(node, "slot", 0, VIR_XML_PROP_NONE, + &addr->slot) < 0) return -1; - } =20 - if (function && - virStrToLong_uip(function, NULL, 0, &addr->function) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'function' attribute")); + if (virXMLPropUInt(node, "function", 0, VIR_XML_PROP_NONE, + &addr->function) < 0) + return -1; + + if (virXMLPropTristateSwitch(node, "multifunction", VIR_XML_PROP_NONE, + &addr->multi) < 0) return -1; - } =20 - if (multi) { - int value; - if ((value =3D virTristateSwitchTypeFromString(multi)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown value '%s' for
'multifunct= ion' attribute"), - multi); - return -1; - } - addr->multi =3D value; - } if (!virPCIDeviceAddressIsEmpty(addr) && !virPCIDeviceAddressIsValid(a= ddr, true)) return -1; =20 --=20 2.26.3 From nobody Wed May 15 23:14:20 2024 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=1619007006; cv=none; d=zohomail.com; s=zohoarc; b=Lhj5yzi0n4qV8mLshfzRDoaj/dapSUvTjMSRLVGep3nbpEKNNyHh5sLqeOdxqZcGDQKaDjzNlrwOBEYHlMXC7P8dKoz4kHE+XtZzq6pRGwas6gL7kRKMchbX1QxDpsA7XikmPv2DRz+CTAp3JXUEx+K2tvvwFCeh9HswytBP120= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619007006; 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=5v/82IzrX+GdmInrzkgXOvCzmpW35VWzk2i91zoeuD4=; b=L3IdF5H+lP8dUXt3vaQFb9eOBI3y9Cne1c7I6vC3W+xLmmZ8CgH08V/NStuhkwQmIZeFpV9TBggjpFt8bryAlWjb2kVYljAr95zqF92hxXtorabCT7WySTeBJzPTdzK7bQlywd34TqkyFDW9D2+6SPEYzdig+bgV0nSgRCD+bXk= 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 1619007006111805.1416843052343; Wed, 21 Apr 2021 05:10:06 -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-64-aGmv5--2NL6kBveRKKwaxA-1; Wed, 21 Apr 2021 08:09:13 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A71A83DD54; Wed, 21 Apr 2021 12:09:06 +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 F1BB0101E663; Wed, 21 Apr 2021 12:09:05 +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 BF7EB1806D23; Wed, 21 Apr 2021 12:09:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13LC8JES008662 for ; Wed, 21 Apr 2021 08:08:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id D5FBC6091B; Wed, 21 Apr 2021 12:08:19 +0000 (UTC) Received: from work.redhat.com (ovpn-112-172.ams2.redhat.com [10.36.112.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id F08A160871; Wed, 21 Apr 2021 12:08:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619007004; 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=5v/82IzrX+GdmInrzkgXOvCzmpW35VWzk2i91zoeuD4=; b=dcQhdm+h/U6ue+Me2vLcncfnSmnTr3jCbqdB47ubg7h5MZq0QbtVuguxcnxQalcWjJAZ52 Aoy1ibTh1bVjrwhWodmedqIvGulFs3jNPtup6QFaA95iyMhb8gcNrEONI933JutYGNQ2K6 M7PSrD93emP1/RlllCjR7MDrglezLsc= X-MC-Unique: aGmv5--2NL6kBveRKKwaxA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 05/10] virDomainDeviceCCWAddressParseXML: Use virXMLProp* Date: Wed, 21 Apr 2021 14:08:03 +0200 Message-Id: <20210421120808.35786-6-twiederh@redhat.com> In-Reply-To: <20210421120808.35786-1-twiederh@redhat.com> References: <20210421120808.35786-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , 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.84 on 10.5.11.22 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 Reviewed-by: Peter Krempa --- src/conf/device_conf.c | 53 ++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 801552a9cf..e527899d7d 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -267,43 +267,36 @@ int virDomainDeviceCCWAddressParseXML(xmlNodePtr node, virDomainDeviceCCWAddress *addr) { - g_autofree char *cssid =3D virXMLPropString(node, "cssid"); - g_autofree char *ssid =3D virXMLPropString(node, "ssid"); - g_autofree char *devno =3D virXMLPropString(node, "devno"); + int cssid; + int ssid; + int devno; =20 memset(addr, 0, sizeof(*addr)); =20 + if ((cssid =3D virXMLPropUInt(node, "cssid", 0, VIR_XML_PROP_NONE, + &addr->cssid)) < 0) + return -1; + + if ((ssid =3D virXMLPropUInt(node, "ssid", 0, VIR_XML_PROP_NONE, + &addr->ssid)) < 0) + return -1; + + if ((devno =3D virXMLPropUInt(node, "devno", 0, VIR_XML_PROP_NONE, + &addr->devno)) < 0) + return -1; + + if (!virDomainDeviceCCWAddressIsValid(addr)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid specification for virtio ccw address: cs= sid=3D'0x%x' ssid=3D'0x%x' devno=3D'0x%04x'"), + addr->cssid, addr->ssid, addr->devno); + return -1; + } + if (cssid && ssid && devno) { - if (cssid && - virStrToLong_uip(cssid, NULL, 0, &addr->cssid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'cssid' attribute")); - return -1; - } - if (ssid && - virStrToLong_uip(ssid, NULL, 0, &addr->ssid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'ssid' attribute")); - return -1; - } - if (devno && - virStrToLong_uip(devno, NULL, 0, &addr->devno) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'devno' attribute")); - return -1; - } - if (!virDomainDeviceCCWAddressIsValid(addr)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid specification for virtio ccw" - " address: cssid=3D'%s' ssid=3D'%s' devno=3D'= %s'"), - cssid, ssid, devno); - return -1; - } addr->assigned =3D true; } else if (cssid || ssid || devno) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Invalid partial specification for virtio ccw" - " address")); + _("Invalid partial specification for virtio ccw add= ress")); return -1; } =20 --=20 2.26.3 From nobody Wed May 15 23:14:20 2024 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=1619006964; cv=none; d=zohomail.com; s=zohoarc; b=ImVEtz8W97f7PE6Cnk1bQK6XiL9v3ilP/FeIulf52Q7V66T6B2w0b0eUURCu1k9lBZUDX/Slq6f7oJHsiLXnenLM4FD+zOzSEWxbXikiLys0qa12pSZZfHJUqQcBVDvnzRmMKgSB0J7Xws5ce8+4+eS4siVwrKbQeKxRX8ZXFns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619006964; 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=UgHZsnCg/tFdFTsLqMsX6DUXr4nZCPb9qKvi6zPUgII=; b=Nt+aTdizdpk7uXcH3ZpukeQ9y6insXr9LqE4nmjL0SXwZ3AZsH48xc4QslWUdPm8gk7+HSTv3tuLi5w/FibpcUwB2Rqju9tL2Rc8XtozxYBLFDQfLL5H9avdg8C1n/6Q+N/fyC8QjFoQ/7+szN2IZDS0UA4c8RnJ2rzarFlvbxo= 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 1619006964543569.7351385005057; Wed, 21 Apr 2021 05:09:24 -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-322-5gDiS_FdN3GEKfHBMpa0Iw-1; Wed, 21 Apr 2021 08:09:15 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE4918542CD; Wed, 21 Apr 2021 12:09:08 +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 AAE6D60C05; Wed, 21 Apr 2021 12:09:08 +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 66F8655345; Wed, 21 Apr 2021 12:09:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13LC8MG3008673 for ; Wed, 21 Apr 2021 08:08:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 12B0B60916; Wed, 21 Apr 2021 12:08:22 +0000 (UTC) Received: from work.redhat.com (ovpn-112-172.ams2.redhat.com [10.36.112.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31E0360871; Wed, 21 Apr 2021 12:08:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619006962; 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=UgHZsnCg/tFdFTsLqMsX6DUXr4nZCPb9qKvi6zPUgII=; b=NyoRS/J0YQM5eEVjoDN/v9YtgGKP6iswnBWLAbTsCQbYH2VdDo8BqpnJToqa7EapW7EP0e OHZxW7qalH9CK8BbxWtQkQXxQ1JHESHfgg/L3vwEh4rvKVjQvNCvoX8Ovd5qXleNP8EOQN JvxwJDNr+/TAsOMwFHBJOnEPfNXFqnc= X-MC-Unique: 5gDiS_FdN3GEKfHBMpa0Iw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 06/10] virDomainDeviceDriveAddressParseXML: Use virXMLProp* Date: Wed, 21 Apr 2021 14:08:04 +0200 Message-Id: <20210421120808.35786-7-twiederh@redhat.com> In-Reply-To: <20210421120808.35786-1-twiederh@redhat.com> References: <20210421120808.35786-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , 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.12 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 Reviewed-by: Peter Krempa --- src/conf/device_conf.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index e527899d7d..66b7af109f 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -319,40 +319,21 @@ int virDomainDeviceDriveAddressParseXML(xmlNodePtr node, virDomainDeviceDriveAddress *addr) { - g_autofree char *controller =3D virXMLPropString(node, "controller"); - g_autofree char *bus =3D virXMLPropString(node, "bus"); - g_autofree char *target =3D virXMLPropString(node, "target"); - g_autofree char *unit =3D virXMLPropString(node, "unit"); - memset(addr, 0, sizeof(*addr)); =20 - if (controller && - virStrToLong_uip(controller, NULL, 10, &addr->controller) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'controller' attribute")); + if (virXMLPropUInt(node, "controller", 10, VIR_XML_PROP_NONE, + &addr->controller) < 0) return -1; - } =20 - if (bus && - virStrToLong_uip(bus, NULL, 10, &addr->bus) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'bus' attribute")); + if (virXMLPropUInt(node, "bus", 10, VIR_XML_PROP_NONE, &addr->bus) < 0) return -1; - } =20 - if (target && - virStrToLong_uip(target, NULL, 10, &addr->target) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'target' attribute")); + if (virXMLPropUInt(node, "target", 10, VIR_XML_PROP_NONE, + &addr->target) < 0) return -1; - } =20 - if (unit && - virStrToLong_uip(unit, NULL, 10, &addr->unit) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'unit' attribute")); + if (virXMLPropUInt(node, "unit", 10, VIR_XML_PROP_NONE, &addr->unit) <= 0) return -1; - } =20 return 0; } --=20 2.26.3 From nobody Wed May 15 23:14:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1619006948; cv=none; d=zohomail.com; s=zohoarc; b=nILVeSMp+rv2d32ZIHykpTa/vH991pRm2sxHtF42LhYggNoxSs36kLoz9S14WRQR5kqmfQnTqxhDLlTQnpffkYVAX6OqjVc3bekKtcGNeQqUQ1YZC8aYPdOk6gN5vsnJdZEH2XvRaWnhAuooWRghn/R0J2lGpMpmTt/h/L/6wnk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619006948; 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=B+20aLeLer99d/GUe/rU3S4ZzsPl98Fe8tynJf1bPqA=; b=AjOtezUdMR8J9tK40hLmSg/iggqcP6bGYJG+iDVVGwaqN53JkrpnnwKc6atvfqyQyDMgWd1wEup2T3Q3NNlby39u3NfXmaWVT1jkeH1t1jyb8P3xof62MBK10urFWfK6Tq45gwOtkqYBRzjYxH/Qm8I65oQmaRqWlfKYl4NA5Ss= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1619006948099156.9905784647973; Wed, 21 Apr 2021 05:09:08 -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-365-qEYQpLH8OoyMJlzhaczeaw-1; Wed, 21 Apr 2021 08:09:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 704C38030C9; Wed, 21 Apr 2021 12:08:56 +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 4CEAF60C05; Wed, 21 Apr 2021 12:08:56 +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 9A4D51806D3C; Wed, 21 Apr 2021 12:08:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13LC8Nok008683 for ; Wed, 21 Apr 2021 08:08:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 45C236091B; Wed, 21 Apr 2021 12:08:23 +0000 (UTC) Received: from work.redhat.com (ovpn-112-172.ams2.redhat.com [10.36.112.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 661F960871; Wed, 21 Apr 2021 12:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619006946; 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=B+20aLeLer99d/GUe/rU3S4ZzsPl98Fe8tynJf1bPqA=; b=bHCRaNOaNewq0935Hb3pV33d1ILRVqi/FPMipDf3R2M0oMINsVTD/zv6ofEy7ieVKIoRGT DJyA3teenTN+It8Kt2QFXvtmgQhmJZqaMtomZ1LDSFJ3cQCsvbgTZMg3Y61k9wQhrkxuTv 1S7mxFrTmwH5mSjA1rzzky/mCpVPkfo= X-MC-Unique: qEYQpLH8OoyMJlzhaczeaw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 07/10] virDomainDeviceVirtioSerialAddressParseXML: Use virXMLProp* Date: Wed, 21 Apr 2021 14:08:05 +0200 Message-Id: <20210421120808.35786-8-twiederh@redhat.com> In-Reply-To: <20210421120808.35786-1-twiederh@redhat.com> References: <20210421120808.35786-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , 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.12 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 Reviewed-by: Peter Krempa --- src/conf/device_conf.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 66b7af109f..5360fb301f 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -342,32 +342,17 @@ int virDomainDeviceVirtioSerialAddressParseXML(xmlNodePtr node, virDomainDeviceVirtioSerialAddr= ess *addr) { - g_autofree char *controller =3D virXMLPropString(node, "controller"); - g_autofree char *bus =3D virXMLPropString(node, "bus"); - g_autofree char *port =3D virXMLPropString(node, "port"); - memset(addr, 0, sizeof(*addr)); =20 - if (controller && - virStrToLong_uip(controller, NULL, 10, &addr->controller) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'controller' attribute")); + if (virXMLPropUInt(node, "controller", 10, VIR_XML_PROP_NONE, + &addr->controller) < 0) return -1; - } =20 - if (bus && - virStrToLong_uip(bus, NULL, 10, &addr->bus) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'bus' attribute")); + if (virXMLPropUInt(node, "bus", 10, VIR_XML_PROP_NONE, &addr->bus) < 0) return -1; - } =20 - if (port && - virStrToLong_uip(port, NULL, 10, &addr->port) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'port' attribute")); + if (virXMLPropUInt(node, "port", 10, VIR_XML_PROP_NONE, &addr->port) <= 0) return -1; - } =20 return 0; } --=20 2.26.3 From nobody Wed May 15 23:14:20 2024 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=1619007069; cv=none; d=zohomail.com; s=zohoarc; b=m9CszXVmIpsY5Z3kwQWi7cNeW9SAQWG3lWPl0hr8PqPhrQwmvriLMe9J5905fGtl3Msc+kWGrqlstAimsV87VlLpqpO4EEUP+484Si58fIzmQAuSJBcHt5XZBy1mpEDqhwmhD14GETS7Ur6X8tR9K8XcMroVR80yOqgfbZErajw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619007069; 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=EuLhj0GOZZA3eGEoCrsm2HX4L8MFoinHOcM8vplU2Ao=; b=oL7aZaLuY+W2Yo7kP5f4dl3LFd8JM8vmgcabbSDsCXht0g1mqCD8VTi+rcn55Y8tVkmftFOLY1sCCqPrTLcZqJHH3hUZTUYkHkVdr53zYrKWqtQnAXGP443mA0eg5Z/VpqlIggaqjFGWAu/zBNIJTJ6cvwybfqTxJ235AA9SBtc= 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 1619007069948977.7669430791018; Wed, 21 Apr 2021 05:11:09 -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-89-ZEP58wRsPPGK7MM3pA0Y0g-1; Wed, 21 Apr 2021 08:09:20 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE3009F951; Wed, 21 Apr 2021 12:09:08 +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 BE224629C0; Wed, 21 Apr 2021 12:09:08 +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 75F6855341; Wed, 21 Apr 2021 12:09:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13LC8OFx008688 for ; Wed, 21 Apr 2021 08:08:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7F4626091B; Wed, 21 Apr 2021 12:08:24 +0000 (UTC) Received: from work.redhat.com (ovpn-112-172.ams2.redhat.com [10.36.112.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95F5160871; Wed, 21 Apr 2021 12:08:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619007068; 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=EuLhj0GOZZA3eGEoCrsm2HX4L8MFoinHOcM8vplU2Ao=; b=HQ518zHqLk8eHeUCNm8kLaNMiJEpNp8/ZnwR8u2zk2dPsuNBf/Fr45+/iT1SuXKODlBAQf Zlaowt31C5dGR8LdTERLJG1So1Rba86YVClRiDKMaIFrcmtGvfRkzJITnAHnmGmu81S1eU 5rXOs7zVLJKBijExLJ2yeZxzimIiabc= X-MC-Unique: ZEP58wRsPPGK7MM3pA0Y0g-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 08/10] virDomainDeviceCcidAddressParseXML: Use virXMLProp* Date: Wed, 21 Apr 2021 14:08:06 +0200 Message-Id: <20210421120808.35786-9-twiederh@redhat.com> In-Reply-To: <20210421120808.35786-1-twiederh@redhat.com> References: <20210421120808.35786-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , 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.15 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 Reviewed-by: Peter Krempa --- src/conf/device_conf.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 5360fb301f..dbe30b05c1 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -361,24 +361,14 @@ int virDomainDeviceCcidAddressParseXML(xmlNodePtr node, virDomainDeviceCcidAddress *addr) { - g_autofree char *controller =3D virXMLPropString(node, "controller"); - g_autofree char *slot =3D virXMLPropString(node, "slot"); - memset(addr, 0, sizeof(*addr)); =20 - if (controller && - virStrToLong_uip(controller, NULL, 10, &addr->controller) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'controller' attribute")); + if (virXMLPropUInt(node, "controller", 10, VIR_XML_PROP_NONE, + &addr->controller) < 0) return -1; - } =20 - if (slot && - virStrToLong_uip(slot, NULL, 10, &addr->slot) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'slot' attribute")); + if (virXMLPropUInt(node, "slot", 10, VIR_XML_PROP_NONE, &addr->slot) <= 0) return -1; - } =20 return 0; } --=20 2.26.3 From nobody Wed May 15 23:14:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1619006955; cv=none; d=zohomail.com; s=zohoarc; b=UbGOI7YGhM7quIGXlYxILp9Xw/hYO0Js8w2D+cv7t0YRm5E05oUz96hlr+7UDgzZGq3DFU1/g1fkbWropfu4DoNYfP8+SCvtTOqmBblbhMGIUgiTABqeD9iooPyEBAuxwPeDqDhIZSJ/uN1Vbss2DgEy6pQgNLlOKWCEI8Or0UQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619006955; 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=jXnAyBr/Gh4oYMT4ownwPRFTrLvSeDSTFQ3JYmhsekI=; b=SeFGCEe4MPs/djGigwv8wwqTCV4my2LwqqFVpvG4B1oJEewJKC+4DhmY69zl3pbWe7R+q6pEEFyKunFBTMtWGWpcvzFc/NqZHiVcoDwnTXnK7/2K0/ECDWfRdP6G/D6gd8c1AyMGRwvGIoYLD0144AJCRBEScpNHVDEgZCDNtp0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1619006955691205.61954878092217; Wed, 21 Apr 2021 05:09:15 -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-381-4k3rmrgFPbeQv2eMAj0E6Q-1; Wed, 21 Apr 2021 08:09:11 -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 6A33383DD46; Wed, 21 Apr 2021 12:09:03 +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 478A060916; Wed, 21 Apr 2021 12:09:03 +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 0D93955341; Wed, 21 Apr 2021 12:09:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13LC8PB3008698 for ; Wed, 21 Apr 2021 08:08:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id B180160916; Wed, 21 Apr 2021 12:08:25 +0000 (UTC) Received: from work.redhat.com (ovpn-112-172.ams2.redhat.com [10.36.112.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id D23CC60871; Wed, 21 Apr 2021 12:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619006954; 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=jXnAyBr/Gh4oYMT4ownwPRFTrLvSeDSTFQ3JYmhsekI=; b=Vp+JKHbYcm8HkGpfCET8PG6RTY8SCYZSWGnb+8k1wo6xc272t/52RrYYTPQPbnIhPgsPgY 0C+2IOqi8d2f+0tDCx7EwWYgGYM+xv7hjpTfP9GW2YDhsPsSlE8u4SlF9eYh4k6Sx9sKI5 kXTcR1SFQepeiri/3diTx9kexE4cYUs= X-MC-Unique: 4k3rmrgFPbeQv2eMAj0E6Q-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 09/10] virDomainDeviceUSBAddressParseXML: Use virXMLProp* Date: Wed, 21 Apr 2021 14:08:07 +0200 Message-Id: <20210421120808.35786-10-twiederh@redhat.com> In-Reply-To: <20210421120808.35786-1-twiederh@redhat.com> References: <20210421120808.35786-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , 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.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" Signed-off-by: Tim Wiederhake Reviewed-by: Peter Krempa --- src/conf/device_conf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index dbe30b05c1..9b0b81b2cb 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -401,19 +401,15 @@ virDomainDeviceUSBAddressParseXML(xmlNodePtr node, virDomainDeviceUSBAddress *addr) { g_autofree char *port =3D virXMLPropString(node, "port"); - g_autofree char *bus =3D virXMLPropString(node, "bus"); =20 memset(addr, 0, sizeof(*addr)); =20 if (port && virDomainDeviceUSBAddressParsePort(addr, port) < 0) return -1; =20 - if (bus && - virStrToLong_uip(bus, NULL, 10, &addr->bus) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse
'bus' attribute")); + if (virXMLPropUInt(node, "bus", 10, VIR_XML_PROP_NONE, &addr->bus) < 0) return -1; - } + return 0; } =20 --=20 2.26.3 From nobody Wed May 15 23:14:20 2024 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=1619006986; cv=none; d=zohomail.com; s=zohoarc; b=T9AGRurxpsPT0/BILnt55Juj81A63HDAoAzY32pw7yQxQSf2KEYpsxyyJabOad5CMICUWgT0+J76DuWXtdFH31zCrDNfGo0DP7yRV83EEEUNlVfRZ3p6NhxgZHGD+aVln5yG/tZOzXlVtBW/KnHXahhq/n2e9H/COCvPUY6C5qo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619006986; 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=7qa0ALJ3kAdySPNqMroIo5dacJZ39C2VygfikMc5Lgk=; b=LMMrHoU2EEBihO2NalfMxLCPJxfXFpvwOh7QD9TVPnnuVoWOeirgCzOflYIs35Nu8iZwH/r5deAEo825tT2SgrRq8t45pwA7/87a4tKnxq1HIWMRhcOJzKlo+qKX5Yidn3tdtJmzzPMfwGHnTu1WgiVq2Exa1LStwsAkupahV+8= 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 1619006986783582.0874533390324; Wed, 21 Apr 2021 05:09:46 -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-504-VACCst9cMkyb_Fx6hYWkjg-1; Wed, 21 Apr 2021 08:09:12 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7734B9F959; Wed, 21 Apr 2021 12:09:06 +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 5B6046064B; Wed, 21 Apr 2021 12:09:06 +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 EA3051800215; Wed, 21 Apr 2021 12:09:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13LC8Q6g008712 for ; Wed, 21 Apr 2021 08:08:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id E385960916; Wed, 21 Apr 2021 12:08:26 +0000 (UTC) Received: from work.redhat.com (ovpn-112-172.ams2.redhat.com [10.36.112.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E46F60871; Wed, 21 Apr 2021 12:08:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619006985; 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=7qa0ALJ3kAdySPNqMroIo5dacJZ39C2VygfikMc5Lgk=; b=Px0/P6Oml257dZi2FvC9UZ6lu/SOf/vQZbNGTb0tUosA6XYC6Rfg7p1cLYUvSL4SC7m10a wxCOytVdPQTCqmnDdw1A95sWZkDZXI53Pu+Rmm8VwMnVAoX2d+2BZJkmCoTKuMklA7TRHI Qkf1vz0IdZMQGpd4C7yuGagoB8BhbZE= X-MC-Unique: VACCst9cMkyb_Fx6hYWkjg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 10/10] virInterfaceLinkParseXML: Use virXMLProp* Date: Wed, 21 Apr 2021 14:08:08 +0200 Message-Id: <20210421120808.35786-11-twiederh@redhat.com> In-Reply-To: <20210421120808.35786-1-twiederh@redhat.com> References: <20210421120808.35786-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , 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.11 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" This strictens the parser to disallow negative values (interpreted as `UINT_MAX + value + 1`) for attribute `speed`, which does not make sense for a value measured in Mbits per second. Signed-off-by: Tim Wiederhake Reviewed-by: Peter Krempa --- src/conf/device_conf.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 9b0b81b2cb..034f072df4 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -465,28 +465,13 @@ int virInterfaceLinkParseXML(xmlNodePtr node, virNetDevIfLink *lnk) { - int state; - - g_autofree char *stateStr =3D virXMLPropString(node, "state"); - g_autofree char *speedStr =3D virXMLPropString(node, "speed"); - - if (stateStr) { - if ((state =3D virNetDevIfStateTypeFromString(stateStr)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown link state: %s"), - stateStr); - return -1; - } - lnk->state =3D state; - } + if (virXMLPropEnum(node, "state", virNetDevIfStateTypeFromString, + VIR_XML_PROP_NONE, &lnk->state) < 0) + return -1; =20 - if (speedStr && - virStrToLong_ui(speedStr, NULL, 10, &lnk->speed) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Unable to parse link speed: %s"), - speedStr); + if (virXMLPropUInt(node, "speed", 10, VIR_XML_PROP_NONE, &lnk->speed) = < 0) return -1; - } + return 0; } =20 --=20 2.26.3