From nobody Tue Feb 10 08:01:17 2026 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=1619535934; cv=none; d=zohomail.com; s=zohoarc; b=RL9WzYk5LEUFpSagH9CG9cdQeGmj3/plFJNsa1qmhp4OnpE1t+veUSBcoaC9AlO512vkfPMytbOQSu3Z/HxZRLQ0B6ITbgnzr+Dd8AVzqO71E2yROZGyXXSfqIPUPKJET2bRcOjz61uslDSQ9vN0CMz1RqOe9j/cGPRe+Q0RNvI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619535934; 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=uhfLmwvVlu5WZaJ8UgSnc+P+mvNC+bAYT2bnRGgsvUA=; b=hb5b0BPv/+UEh/5TPbFs5IP9PbzvuXrTbaaEFJyvFZz9WFHhcw2WdZQRgNY/S656baDSfhW93OBljgcDA/HTKZSQTVBqhtF40U/Clz43lSfJJFfcKcEUMavNO9OpTUx86f86YhYSZgW1i9QSSCjWw0CrQBVZ8An67aRrXjJHps8= 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 1619535934661263.1916953228707; Tue, 27 Apr 2021 08:05:34 -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-63-1vqbf3pdMqiQYc06v2w4LA-1; Tue, 27 Apr 2021 11:05:29 -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 868C3107ACED; Tue, 27 Apr 2021 15:05:22 +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 5C4BF1002D71; Tue, 27 Apr 2021 15:05:22 +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 236D81806D25; Tue, 27 Apr 2021 15:05:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13RF5KaR032098 for ; Tue, 27 Apr 2021 11:05:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id E226561008; Tue, 27 Apr 2021 15:05:20 +0000 (UTC) Received: from work.redhat.com (ovpn-113-91.ams2.redhat.com [10.36.113.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id C69E960C0F; Tue, 27 Apr 2021 15:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619535932; 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=uhfLmwvVlu5WZaJ8UgSnc+P+mvNC+bAYT2bnRGgsvUA=; b=TYrYM+d0peTuTgp0KwDUMemeZLNhDVcCTePZ+CFnEKYoU5FOGPaiC3rRKcuuhKvoXs/tDc 9+kYNJwW9cCoElsZpfX2GiVUKEERTLH3414l7VnNTvZsF9zyMaGfrFCLDpi2KWp2bpzj+f 8/vMYTSUwEDpPqHOhqgkB7+j7Az2wD4= X-MC-Unique: 1vqbf3pdMqiQYc06v2w4LA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 10/10] virDomainRedirFilterUSBDevDefParseXML: Use virXMLProp* Date: Tue, 27 Apr 2021 17:04:41 +0200 Message-Id: <20210427150441.206606-11-twiederh@redhat.com> In-Reply-To: <20210427150441.206606-1-twiederh@redhat.com> References: <20210427150441.206606-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.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: J=C3=A1n Tomko --- src/conf/domain_conf.c | 66 +++++++++++------------------------------- 1 file changed, 17 insertions(+), 49 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2f7878da2b..805494ca11 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14935,52 +14935,28 @@ static virDomainRedirFilterUSBDevDef * virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr node) { virDomainRedirFilterUSBDevDef *def; - g_autofree char *class =3D NULL; - g_autofree char *vendor =3D NULL; - g_autofree char *product =3D NULL; g_autofree char *version =3D NULL; - g_autofree char *allow =3D NULL; + virTristateBool allow; =20 def =3D g_new0(virDomainRedirFilterUSBDevDef, 1); =20 - class =3D virXMLPropString(node, "class"); - if (class) { - if ((virStrToLong_i(class, NULL, 0, &def->usbClass)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Cannot parse USB Class code %s"), class); - goto error; - } + def->usbClass =3D -1; + if (virXMLPropInt(node, "class", 0, VIR_XML_PROP_NONE, &def->usbClass)= < 0) + goto error; =20 - if (def->usbClass !=3D -1 && def->usbClass &~ 0xFF) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid USB Class code %s"), class); - goto error; - } - } else { - def->usbClass =3D -1; + if (def->usbClass !=3D -1 && def->usbClass &~ 0xFF) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid USB Class code 0x%x"), def->usbClass); + goto error; } =20 - vendor =3D virXMLPropString(node, "vendor"); - if (vendor) { - if ((virStrToLong_i(vendor, NULL, 0, &def->vendor)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Cannot parse USB vendor ID %s"), vendor); - goto error; - } - } else { - def->vendor =3D -1; - } + def->vendor =3D -1; + if (virXMLPropInt(node, "vendor", 0, VIR_XML_PROP_NONE, &def->vendor) = < 0) + goto error; =20 - product =3D virXMLPropString(node, "product"); - if (product) { - if ((virStrToLong_i(product, NULL, 0, &def->product)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Cannot parse USB product ID %s"), product); - goto error; - } - } else { - def->product =3D -1; - } + def->product =3D -1; + if (virXMLPropInt(node, "product", 0, VIR_XML_PROP_NONE, &def->product= ) < 0) + goto error; =20 version =3D virXMLPropString(node, "version"); if (version) { @@ -14992,18 +14968,10 @@ virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr = node) def->version =3D -1; } =20 - allow =3D virXMLPropString(node, "allow"); - if (allow) { - if (virStringParseYesNo(allow, &def->allow) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Invalid allow value, either 'yes' or 'no'")); - goto error; - } - } else { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing allow attribute for USB redirection filt= er")); + if (virXMLPropTristateBool(node, "allow", VIR_XML_PROP_REQUIRED, &allo= w) < 0) goto error; - } + + def->allow =3D allow =3D=3D VIR_TRISTATE_BOOL_YES; =20 return def; =20 --=20 2.26.3