From nobody Mon Feb 9 04:46:00 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=1653311454; cv=none; d=zohomail.com; s=zohoarc; b=oIqxnj2wQN1s9qYg4ZXnhppdJrY4mQz3+Vz9eInGATkh/m2jOo7A2htmkD7NLsbKOvlobj3xwkZ6RzFRs1lWjljjwgskP+AgrO7pmbsEnj1no2TF9WKEuc78kj3Be3fSIYpAavLH5rpCv1fDzsZaeQnDNH2mJKBUJC0ohHdijLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653311454; 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=OpsfBa9LsKYHuTfIkLXJaRYXiRYMw3C96I9cKClqt8A=; b=S7eOdYUujybZWFNi3VgasTwbsyYHCVQCHuAHmtHlTx3DAbFe3dSHtTghQyAebp3pNaTDKHn/HIYN4f4g6WGbqhhmcpvjhJ237sQs1XHPGh9oAxnP6eMA/jh5HS7awpRnoAc0lDIc/gSzKKiY9hcJVyoTEQjicZHtwTmBkW6JzRM= 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 1653311454244672.1116425558994; Mon, 23 May 2022 06:10:54 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-570-KPniDa2RMBmi8ZXWYiD3_Q-1; Mon, 23 May 2022 09:09:16 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C112F382ECF2; Mon, 23 May 2022 13:09:09 +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 A8C31112131E; Mon, 23 May 2022 13:09:09 +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 3558B1947072; Mon, 23 May 2022 13:09:09 +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 67EB6194705A for ; Mon, 23 May 2022 13:09:05 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5A53740D2820; Mon, 23 May 2022 13:09:05 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 013B040D2821 for ; Mon, 23 May 2022 13:09:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653311453; 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=OpsfBa9LsKYHuTfIkLXJaRYXiRYMw3C96I9cKClqt8A=; b=a5OKZF2DzzjDUVQHFpdkrfwdTB/rSKcMu84eXl84yJGaF2TQF7/SgNCXdH1Eg3R+dcFf+7 HmlFev4iAAyxNORTM02dyypCn/4kpCW2tko7qaApVGvQMS9jkmvt4qYHwHwPTKQg+L/P2M 9xpXOwzitFvOjGqQvwdhjb8QePbOG0o= X-MC-Unique: KPniDa2RMBmi8ZXWYiD3_Q-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: Mon, 23 May 2022 15:08:51 +0200 Message-Id: <8c3b70d425d79811e7a540cbdabddbbf7d2e6744.1653311262.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.3 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: 1653311455122100001 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 Reviewed-by: Boris Fiuczynski --- 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 44ab79c1f0..52a34cd131 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11934,23 +11934,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 b3d51565e3..cad19a3d5d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1381,8 +1381,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 @@ -1881,12 +1887,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