From nobody Tue Oct 22 23:32:10 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=1694699825; cv=none; d=zohomail.com; s=zohoarc; b=KTmJsFb63QDAWY2/I9EoaN0UXDtKn7Cc4O5/gHpH0T1UwfqQFApBMzjuYitRtQnfH5xWcHgljmmf8v++UrGAaaZP6UEAAo05v9BA5f8gr498/+Sjak4o5WWPO+o4a+Uk8wVT9Q/TdKoBMF4GJfIJvnOWsFZTChv4bJVGO9dKDqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694699825; 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=T1IUBK9GBjDcXqWEM0P0iHJnQR9e/PamDxmigDL6uGk=; b=YsebABEepGWihglURJPTU+vF8779g/uST/p+TdgRMl/IE9bhEM2IiJg61MWGWaqBbb3I8Svc9qEK553vupYcyY92YOhQVdlfJP1GxCa9PuVs7qcp+ZmNtMb5SBa9EXFPAtFSV8ZQof6/nHEOOLKy9AfF4ZahR37mrLswhGAe3IY= 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 1694699825942429.8963434317717; Thu, 14 Sep 2023 06:57:05 -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-455-xqwW2GfpP7-18Yz8sLgZKg-1; Thu, 14 Sep 2023 09:57:02 -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 0D840857A9E; Thu, 14 Sep 2023 13:56:59 +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 EBF441054FC0; Thu, 14 Sep 2023 13:56:58 +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 5B62119459E6; Thu, 14 Sep 2023 13:56:32 +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 786181946A76 for ; Thu, 14 Sep 2023 13:56:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 740DD40C6EBF; Thu, 14 Sep 2023 13:56:30 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.2.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BF1740C6EA8 for ; Thu, 14 Sep 2023 13:56:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694699825; 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=T1IUBK9GBjDcXqWEM0P0iHJnQR9e/PamDxmigDL6uGk=; b=gMu6gJncoAsmXUe6e98kfCJXweYaEIWayVFBe+iSGtS5b+k2DrSXj1Gl8wb4W5V4V5r4cQ AjL+PH9IA2dRWhZFtV1Q2U009ZDb2vydp4rHxAHNbqhBohQuR+j+bpSaxqNdgfm/+G2DcE UIC8DHOXrgC+llIx27cdl7Ssqo3V7tk= X-MC-Unique: xqwW2GfpP7-18Yz8sLgZKg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 09/20] virDomainHostdevSubsysSCSIVHost: Convert 'protocol' field to proper enum type Date: Thu, 14 Sep 2023 15:56:10 +0200 Message-ID: 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: 1694699826353100001 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 | 17 +++++------------ src/conf/domain_conf.h | 4 ++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ef5f02a23b..65b7b44ccb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6095,24 +6095,17 @@ virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodeP= tr sourcenode, virDomainHostdevDef *def) { virDomainHostdevSubsysSCSIVHost *hostsrc =3D &def->source.subsys.u.scs= i_host; - g_autofree char *protocol =3D NULL; g_autofree char *wwpn =3D NULL; =20 - if (!(protocol =3D virXMLPropString(sourcenode, "protocol"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing scsi_host subsystem protocol")); - return -1; - } =20 - if ((hostsrc->protocol =3D - virDomainHostdevSubsysSCSIHostProtocolTypeFromString(protocol)) <= =3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown scsi_host subsystem protocol '%1$s'"), - protocol); + if (virXMLPropEnum(sourcenode, "protocol", + virDomainHostdevSubsysSCSIHostProtocolTypeFromStrin= g, + VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, + &hostsrc->protocol) < 0) { return -1; } =20 - switch ((virDomainHostdevSubsysSCSIHostProtocolType) hostsrc->protocol= ) { + switch (hostsrc->protocol) { case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_VHOST: if (!(wwpn =3D virXMLPropString(sourcenode, "wwpn"))) { virReportError(VIR_ERR_XML_ERROR, "%s", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 5cce60420f..d6d0799f63 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -290,7 +290,7 @@ struct _virDomainHostdevSubsysMediatedDev { }; =20 typedef enum { - VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_NONE, + VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_NONE =3D 0, VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_VHOST, =20 VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_LAST, @@ -310,7 +310,7 @@ typedef enum { VIR_ENUM_DECL(virDomainHostdevSubsysSCSIVHostModel); =20 struct _virDomainHostdevSubsysSCSIVHost { - int protocol; /* enum virDomainHostdevSubsysSCSIHostProtocolType */ + virDomainHostdevSubsysSCSIHostProtocolType protocol; char *wwpn; virDomainHostdevSubsysSCSIVHostModelType model; }; --=20 2.41.0