From nobody Tue Oct 22 23:38:13 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=1694699844; cv=none; d=zohomail.com; s=zohoarc; b=QdYnFGSvN9rzpdMoXNnHR3GJqF5miWBpHIzvTid9m+TDsD4b2PaKLaH9UAxhNAGPxgfote56e98CaPJnFNHPE8ozOgD29z3S3tZAjEdYuu4Lfe8EVw6m4HSgbXDOHJoLX9WK3xGjaCEDp8kzujKCea16WBTQGJd9RCjQQwVjClU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694699844; 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=ZIxjOqyGTOjyGl5f1e/nz4+JvGB8VA0ioRl/Yp+JyHQ=; b=CoghIwhfQgdJaOVButLhdf4q5KsaLvQ7R9g03J0HK/P47957Bu3d+3MII6GT/O7b6iJz/vFF32UZzjHiLwV6uXwwARqxqnU+s8bNLpIvmNI80V/JwBivoDccd6V6DmBy72trgoZDC3KGAufR7EobL3KQ6zzI7qB/5BBTTvxpLXE= 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 1694699844969413.5811621367561; Thu, 14 Sep 2023 06:57:24 -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-19-Eb-eOn1cNLW2RcbcD-uHow-1; Thu, 14 Sep 2023 09:57:18 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 C0B9188B7AB; Thu, 14 Sep 2023 13:57:14 +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 9CF2C1054FCB; Thu, 14 Sep 2023 13:57:14 +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 67FDD19452F3; 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 3D6ED19452D8 for ; Thu, 14 Sep 2023 13:56:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 20E5840C6EC0; Thu, 14 Sep 2023 13:56:34 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.2.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD3FC40C6ECE 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=1694699844; 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=ZIxjOqyGTOjyGl5f1e/nz4+JvGB8VA0ioRl/Yp+JyHQ=; b=GQMDA2+FQI4BQf7wpsL53Jebuuij/KtvSZT05YJc6IeRJuTexWSInVMnwRd1JC4aZY0cZM VSwcThVk0K/4HKSS6Vo+E4Lb7UKnCUay9bUS9oTf+Nlm/mJq7x2D4hFKJXQ2b7L5D9y9n0 +qaD7Ylsbd2wHKXfRijCNKU0X6ZXSAI= X-MC-Unique: Eb-eOn1cNLW2RcbcD-uHow-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 15/20] virDomainRNGDef: Convert 'backend' field to proper enum type Date: Thu, 14 Sep 2023 15:56:16 +0200 Message-ID: <2193eb5ca00ba83c456342478c2c5320ebfe107d.1694699683.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.3 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: 1694699846479100007 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_audit.c | 4 ++-- src/conf/domain_conf.c | 22 ++++++++-------------- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 4 ++-- src/qemu/qemu_namespace.c | 2 +- src/qemu/qemu_validate.c | 2 +- 6 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index 4294b50c3a..7a6bb02203 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -215,7 +215,7 @@ virDomainAuditRNG(virDomainObj *vm, const char *oldsrcpath =3D NULL; =20 if (newDef) { - switch ((virDomainRNGBackend) newDef->backend) { + switch (newDef->backend) { case VIR_DOMAIN_RNG_BACKEND_RANDOM: newsrcpath =3D newDef->source.file; break; @@ -231,7 +231,7 @@ virDomainAuditRNG(virDomainObj *vm, } =20 if (oldDef) { - switch ((virDomainRNGBackend) oldDef->backend) { + switch (oldDef->backend) { case VIR_DOMAIN_RNG_BACKEND_RANDOM: oldsrcpath =3D oldDef->source.file; break; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3b24d0218d..47c4170f29 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12116,7 +12116,6 @@ virDomainRNGDefParseXML(virDomainXMLOption *xmlopt, VIR_XPATH_NODE_AUTORESTORE(ctxt) int nbackends; g_autofree xmlNodePtr *backends =3D NULL; - g_autofree char *backend =3D NULL; g_autofree char *type =3D NULL; =20 def =3D g_new0(virDomainRNGDef, 1); @@ -12151,19 +12150,14 @@ virDomainRNGDefParseXML(virDomainXMLOption *xmlop= t, goto error; } =20 - if (!(backend =3D virXMLPropString(backends[0], "model"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing RNG device backend model")); + if (virXMLPropEnum(backends[0], "model", + virDomainRNGBackendTypeFromString, + VIR_XML_PROP_REQUIRED, + &def->backend) < 0) { goto error; } =20 - if ((def->backend =3D virDomainRNGBackendTypeFromString(backend)) < 0)= { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown RNG backend model '%1$s'"), backend); - goto error; - } - - switch ((virDomainRNGBackend) def->backend) { + switch (def->backend) { case VIR_DOMAIN_RNG_BACKEND_RANDOM: def->source.file =3D virXPathString("string(./backend)", ctxt); break; @@ -15197,7 +15191,7 @@ virDomainRNGFind(virDomainDef *def, if (rng->rate !=3D tmp->rate || rng->period !=3D tmp->period) continue; =20 - switch ((virDomainRNGBackend) rng->backend) { + switch (rng->backend) { case VIR_DOMAIN_RNG_BACKEND_RANDOM: if (STRNEQ_NULLABLE(rng->source.file, tmp->source.file)) continue; @@ -25076,7 +25070,7 @@ virDomainRNGDefFormat(virBuffer *buf, } virBufferAsprintf(buf, "backend) { + switch (def->backend) { case VIR_DOMAIN_RNG_BACKEND_RANDOM: virBufferEscapeString(buf, ">%s\n", def->source.file); break; @@ -25117,7 +25111,7 @@ virDomainRNGDefFree(virDomainRNGDef *def) if (!def) return; =20 - switch ((virDomainRNGBackend) def->backend) { + switch (def->backend) { case VIR_DOMAIN_RNG_BACKEND_RANDOM: g_free(def->source.file); break; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f56c04ce36..c9b9fbabd3 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2610,7 +2610,7 @@ typedef enum { =20 struct _virDomainRNGDef { virDomainRNGModel model; - int backend; + virDomainRNGBackend backend; unsigned int rate; /* bytes per period */ unsigned int period; /* milliseconds */ =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 17d7bfcfd3..11ede25c0b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5361,7 +5361,7 @@ qemuBuildRNGBackendChrdev(virCommand *cmd, { g_autofree char *charAlias =3D qemuAliasChardevFromDevAlias(rng->info.= alias); =20 - switch ((virDomainRNGBackend) rng->backend) { + switch (rng->backend) { case VIR_DOMAIN_RNG_BACKEND_RANDOM: case VIR_DOMAIN_RNG_BACKEND_BUILTIN: case VIR_DOMAIN_RNG_BACKEND_LAST: @@ -5390,7 +5390,7 @@ qemuBuildRNGBackendProps(virDomainRNGDef *rng, =20 objAlias =3D g_strdup_printf("obj%s", rng->info.alias); =20 - switch ((virDomainRNGBackend) rng->backend) { + switch (rng->backend) { case VIR_DOMAIN_RNG_BACKEND_RANDOM: if (qemuMonitorCreateObjectProps(props, "rng-random", objAlias, "s:filename", rng->source.file, diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index f245712f9a..915d44310f 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -574,7 +574,7 @@ static int qemuDomainSetupRNG(virDomainRNGDef *rng, GSList **paths) { - switch ((virDomainRNGBackend) rng->backend) { + switch (rng->backend) { case VIR_DOMAIN_RNG_BACKEND_RANDOM: *paths =3D g_slist_prepend(*paths, g_strdup(rng->source.file)); break; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 2fcc86bb22..fc61c489e9 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2154,7 +2154,7 @@ qemuValidateDomainRNGDef(const virDomainRNGDef *def, { virDomainCapsDeviceRNG rngCaps =3D { 0 }; =20 - switch ((virDomainRNGBackend) def->backend) { + switch (def->backend) { case VIR_DOMAIN_RNG_BACKEND_RANDOM: if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_RNG_RANDOM)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", --=20 2.41.0