From nobody Tue Oct 22 23:30:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1694699857; cv=none; d=zohomail.com; s=zohoarc; b=c3HqEL472aP6UtVwTozXA+pkw7inpIa8F3IA6aURTBo+Bg/QTK6/RPxV/4oajlzOSOtdovnXEdmFymybVlKTh/0phkZcu7ZmHmY77Jd5SVdvoMmSZNDBPr1l2wQH1gZwF1YlQWd/kXthTBcuFZE/2pUMZ+0d1Z2rXII8cwGFxNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694699857; 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=CNGriYCe4YKA5CPLsnlUnhOhcwdqdj6M9EQ6i2tqg/E=; b=isJSabF4ZBGVUevdKxkBWH0n6qw97kVabLgsnTuIV8g//NY2Dod3jIZqajqV2RGUWlae1ewVw8o4fe3R7OTk3SDUIhOwf8+I9n1Wuvc0Uz8gAFvkxKve/WPtbHn98U3uaVCCgzfpQG/+nMcFIxwvLf54lu3kRLCCyFo4p+qpfJA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1694699857929897.3596502925459; Thu, 14 Sep 2023 06:57:37 -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-164-FLTBOtC6OD2aF7S9vhgtSA-1; Thu, 14 Sep 2023 09:57:33 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 12543101FAA6; Thu, 14 Sep 2023 13:57:31 +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 F05C6200A35C; Thu, 14 Sep 2023 13:57:30 +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 F118D19451DA; Thu, 14 Sep 2023 13:56:40 +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 CC77819452D8 for ; Thu, 14 Sep 2023 13:56:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C85B740C6EC0; 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 7089540C6ECD for ; Thu, 14 Sep 2023 13:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694699855; 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=CNGriYCe4YKA5CPLsnlUnhOhcwdqdj6M9EQ6i2tqg/E=; b=RgKPAwgz9jQnWIlQPKlE8fzTMPkyZlmTpg06Rvcei7JKB0HgqF3tsqkQXLnW2O/4G6B0BL bm59V5/VAQWwuNhGh/+DB/q2oc9s4Z4PS2uLYpuOkCZrPvPSfIqAIqSf/GTVFWuJM1jVv2 PKWH+FV0v4J/I6r35bTWQmxjGH+foRU= X-MC-Unique: FLTBOtC6OD2aF7S9vhgtSA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 16/20] virDomainWatchdogDef: Convert 'model' field to proper enum type Date: Thu, 14 Sep 2023 15:56:17 +0200 Message-ID: <1f3cb6006c0e07849a58f13fff97ed6d5d92e8a6.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.6 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: 1694699859152100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Convert the field and adjust the XML parsers to use virXMLPropEnum(). Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 15 ++++----------- src/conf/domain_conf.h | 2 +- src/qemu/qemu_domain_address.c | 2 +- src/qemu/qemu_validate.c | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 47c4170f29..5c1712cb46 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12065,21 +12065,14 @@ virDomainWatchdogDefParseXML(virDomainXMLOption *= xmlopt, unsigned int flags) { virDomainWatchdogDef *def; - g_autofree char *model =3D NULL; g_autofree char *action =3D NULL; =20 def =3D g_new0(virDomainWatchdogDef, 1); =20 - model =3D virXMLPropString(node, "model"); - if (model =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("watchdog must contain model name")); - goto error; - } - def->model =3D virDomainWatchdogModelTypeFromString(model); - if (def->model < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown watchdog model '%1$s'"), model); + if (virXMLPropEnum(node, "model", + virDomainWatchdogModelTypeFromString, + VIR_XML_PROP_REQUIRED, + &def->model) < 0) { goto error; } =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c9b9fbabd3..e7c663b0e9 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1759,7 +1759,7 @@ typedef enum { } virDomainWatchdogAction; =20 struct _virDomainWatchdogDef { - int model; + virDomainWatchdogModel model; int action; virDomainDeviceInfo info; }; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 0ed70e5b86..099778b2a8 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -927,7 +927,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDevic= eDef *dev, =20 case VIR_DOMAIN_DEVICE_WATCHDOG: /* only one model connects using PCI */ - switch ((virDomainWatchdogModel) dev->data.watchdog->model) { + switch (dev->data.watchdog->model) { case VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB: return pciFlags; =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index fc61c489e9..27fd5b9a99 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2251,7 +2251,7 @@ qemuValidateDomainWatchdogDef(const virDomainWatchdog= Def *dev, return -1; } =20 - switch ((virDomainWatchdogModel) dev->model) { + switch (dev->model) { case VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB: if (dev->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && dev->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { --=20 2.41.0