From nobody Tue Oct 22 23:24:47 2024 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=1694699843; cv=none; d=zohomail.com; s=zohoarc; b=mp8CYuFfSs5CWKIwXlFXpWmrfNv9TeelLSwQbTRPm/8eRxOfc7nAbryl2de+J29xDMJrGI0EwrBZT2D72dhQdYX0asWKFb+1QlPmzSap+StfGDvvPYhNAPup2D4NVkVC3qw04+z8AnVjWoWWk+jgbnKzvH1oEG8UCeShvKrqsgA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694699843; 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=4XC754ouJTXTN3f7QNC7CSY/SvsCLOS8bbmdwVfX6JM=; b=ASt3+uIlKF9xj71ixKMxfbpsRsOSc3GMbmr4Poj6LEDnIdaCirkkUs4v+XW1i5mdpQrIX575is07g1O5IKZO4SUUpJ2N6q/hgrtQyjBjYU6d5dp7aHMqcTpGGQfg4wXsuBzzBurLKpOwri556MyC+juK9rLmabzxB0A6LzMNtNc= 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 169469984384934.477770703652595; Thu, 14 Sep 2023 06:57:23 -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-693-_sSLgFGcPPqE_uRtiO65Zw-1; Thu, 14 Sep 2023 09:57:14 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B04F418312C2; Thu, 14 Sep 2023 13:57:12 +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 98E8B2026D4B; Thu, 14 Sep 2023 13:57:12 +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 3323019452E6; Thu, 14 Sep 2023 13:56:35 +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 A343E19452D8 for ; Thu, 14 Sep 2023 13:56:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 855B440C6E70; Thu, 14 Sep 2023 13:56:33 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.2.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D49040C6ECE for ; Thu, 14 Sep 2023 13:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694699842; 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=4XC754ouJTXTN3f7QNC7CSY/SvsCLOS8bbmdwVfX6JM=; b=ejAubR0HrlGW8hubTAgJMsL9wWUU5kMaZI+TFZ0vK2wCrhsDRBC0OVhEnQcRjZrXBDXQjp dAo/9sACmzV6A3ssy/HU+yq8I+sPgNWzMP5/yN4qr9gHZV7M2rPfsU/O+FVD69AVt/Smn2 1HNFShNaPmDlrnwNCnvTbnOn495rhzw= X-MC-Unique: _sSLgFGcPPqE_uRtiO65Zw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 14/20] virDomainRNGDef: Convert 'model' field to proper enum type Date: Thu, 14 Sep 2023 15:56:15 +0200 Message-ID: <997ea33fbf3afc079395081521476670f2a0d408.1694699682.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 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 3.1 on 10.11.54.4 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: 1694699844845100002 Content-Type: text/plain; charset="utf-8"; x-default="true" Convert the field and adjust the XML parser to use virXMLPropEnum(). Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 13 ++++--------- src/conf/domain_conf.h | 2 +- src/qemu/qemu_domain_address.c | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 95a71b204f..3b24d0218d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12116,21 +12116,16 @@ virDomainRNGDefParseXML(virDomainXMLOption *xmlop= t, VIR_XPATH_NODE_AUTORESTORE(ctxt) int nbackends; g_autofree xmlNodePtr *backends =3D NULL; - g_autofree char *model =3D NULL; g_autofree char *backend =3D NULL; g_autofree char *type =3D NULL; =20 def =3D g_new0(virDomainRNGDef, 1); =20 - if (!(model =3D virXMLPropString(node, "model"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", _("missing RNG device mode= l")); + if (virXMLPropEnum(node, "model", + virDomainRNGModelTypeFromString, + VIR_XML_PROP_REQUIRED, + &def->model) < 0) goto error; - } - - if ((def->model =3D virDomainRNGModelTypeFromString(model)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown RNG model '%= 1$s'"), model); - goto error; - } =20 ctxt->node =3D node; =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9dadda2d1d..f56c04ce36 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2609,7 +2609,7 @@ typedef enum { } virDomainRNGBackend; =20 struct _virDomainRNGDef { - int model; + virDomainRNGModel model; int backend; unsigned int rate; /* bytes per period */ unsigned int period; /* milliseconds */ diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 2e58930eec..0ed70e5b86 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -912,7 +912,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDevic= eDef *dev, break; =20 case VIR_DOMAIN_DEVICE_RNG: - switch ((virDomainRNGModel) dev->data.rng->model) { + switch (dev->data.rng->model) { case VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL: /* Transitional devices only work in conventional PCI slots */ return pciFlags; --=20 2.41.0