From nobody Mon Feb 9 20:34:16 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=1649405532; cv=none; d=zohomail.com; s=zohoarc; b=OTllo49vwBTxFaIKQD+gUIz1ghm5i6+qhsAVbiq23zegd6hc2qAo2sc6U74CjLmA2zfJS08wTsIsZvmpwm335mU5QHNMKUdDJ+O3nB3tao/J7+Lo4JN8ph5ktAiEUcN9VagzxhSoy3i9x64FbD/3zPfbdwWMIAhDDMrfyABf2fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649405532; 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=OKEUZ00XSDt7OpeBD3IfZBtMy88oef/fkZmZEhE5ZfQ=; b=TFu9yrOUrT5zM9Ok7KW5ycOIddd4UwZU+iqEjXYFot6VpMSQS0kdbWGMj4W0DPh5HIHwHVetv7H8e5tumomn753SCdWHh9mGpPIHsWFiq9TdD9dBlv4LKfEGW9rGLbIO9fhWgBwm1BQthPoTyh3dKdblxXpTLSVor3aWF/zaA28= 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 1649405532231690.4756439642731; Fri, 8 Apr 2022 01:12:12 -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-624-BrKFmiw9MMa8eU6KUPElDg-1; Fri, 08 Apr 2022 04:11:03 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7F4D4833974; Fri, 8 Apr 2022 08:11:00 +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 6B044145B989; Fri, 8 Apr 2022 08:11:00 +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 430C41940341; Fri, 8 Apr 2022 08:11:00 +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 0291B1940348 for ; Fri, 8 Apr 2022 08:10:57 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E5E7654ACB9; Fri, 8 Apr 2022 08:10:56 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D80454ACB0 for ; Fri, 8 Apr 2022 08:10:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649405531; 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=OKEUZ00XSDt7OpeBD3IfZBtMy88oef/fkZmZEhE5ZfQ=; b=Ds/jnMF4ZOBdwqesS+ry6an1wyyTfcjb1ZKcQLpgcUJQk96JXZ6C6s8ry3NhZdRRf8WNbN nlAHcTJnlu8J1nTxhlC2gFKVXEckT5E7lBLm4Z8i/1CFhs6iFkEiXtgHQeceTDHscFi16O UCZ6iQSlVEYa8stKIV1cvGYdIsJeYGQ= X-MC-Unique: BrKFmiw9MMa8eU6KUPElDg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 16/17] virDomainHubDefParseXML: Switch to virXMLPropEnumDefault() Date: Fri, 8 Apr 2022 10:08:55 +0200 Message-Id: <3aa0825673f55d050a927c569cf94171a147929a.1649405102.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.7 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: 1649405532798100007 Content-Type: text/plain; charset="utf-8"; x-default="true" The virDomainHubDefParseXML() 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 | 17 ++++------------- src/conf/domain_conf.h | 14 +++++++------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0cb8de8b1f..26acc56dc3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11901,23 +11901,14 @@ virDomainHubDefParseXML(virDomainXMLOption *xmlop= t, unsigned int flags) { virDomainHubDef *def; - g_autofree char *type =3D NULL; =20 def =3D g_new0(virDomainHubDef, 1); =20 - type =3D virXMLPropString(node, "type"); - - if (!type) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing hub device type")); + if (virXMLPropEnum(node, "type", + virDomainHubTypeFromString, + VIR_XML_PROP_REQUIRED, + &def->type) < 0) goto error; - } - - if ((def->type =3D virDomainHubTypeFromString(type)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown hub device type '%s'"), type); - goto error; - } =20 if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) goto error; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 836f518f9c..5c85d3e334 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1365,8 +1365,14 @@ struct _virDomainSmartcardDef { virDomainDeviceInfo info; }; =20 +typedef enum { + VIR_DOMAIN_HUB_TYPE_USB, + + VIR_DOMAIN_HUB_TYPE_LAST +} virDomainHubType; + struct _virDomainHubDef { - int type; + virDomainHubType type; virDomainDeviceInfo info; }; =20 @@ -1871,12 +1877,6 @@ typedef enum { VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST } virDomainGraphicsListenType; =20 -typedef enum { - VIR_DOMAIN_HUB_TYPE_USB, - - VIR_DOMAIN_HUB_TYPE_LAST -} virDomainHubType; - struct _virDomainGraphicsListenDef { virDomainGraphicsListenType type; char *address; --=20 2.35.1