From nobody Tue Nov 26 09:31:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1578386537; cv=none; d=zohomail.com; s=zohoarc; b=f/LhDX6ik6mRI6bQHJCzgf36RGZMHBSAIPhDDFo5powWI+2PEHEu2N0I2B4mCinh/pzubN5vkTBR1mUrIsAHUo4sxavZAiMQQOUmeEq7heBTJlDdQlogfSZ0MJU4WSTvPwhWZvXeRI3LjfvEKeEHrUU20EA49+mnD3wiOk6QHkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578386537; h=Content-Type:Content-Transfer-Encoding:Cc: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=cqU/kHmSEoniupnA8b2bTD/jB8/jcy4GuDMhW+Dv4Vc=; b=Md5KcijQ5qkxAd8xWnHnhNxg8Qyccs8dzKx8+AvOMk2GwspFqeOL6Ot8aYNfyopRI6Pgjv3Vgtc9MMhPFtm+W5rWPBjp2j6XnnZnvGgtMp0w4tsRvusSeK3Qb6d0LFsBqBFPVokPFbZ5Gb0Sk1GdOO2rGaZDsOR4sXU/34UMhME= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1578386537399435.4411551755155; Tue, 7 Jan 2020 00:42:17 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-81-vf0mK5SiOdKAJ3XpxjSGuw-1; Tue, 07 Jan 2020 03:42:14 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5AF86477; Tue, 7 Jan 2020 08:42:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 300FE60C88; Tue, 7 Jan 2020 08:42:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7F3641803C37; Tue, 7 Jan 2020 08:42:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0078g59i009164 for ; Tue, 7 Jan 2020 03:42:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 49FE360CD0; Tue, 7 Jan 2020 08:42:05 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76E9960BEC; Tue, 7 Jan 2020 08:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578386536; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=cqU/kHmSEoniupnA8b2bTD/jB8/jcy4GuDMhW+Dv4Vc=; b=cYpdSbAilbotD6TEqdzR8iq3rBW04kmX9rUjgJYaSE78DjWNraSF4pOQEAUgjD+du/gv8B LJHXcLihjkX5QziGz1pa0VVn6RGyeQmYHqi9XQNEJhVDtrgmntTOUuPC3slVbxzbgadyoG N6+ePQXhvEtilEObNyrELaCITpwRK08= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 7 Jan 2020 09:41:52 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: jcfaracco@gmail.com, eskultet@redhat.com Subject: [libvirt] [PATCH 1/3] virsh: Use VIR_ENUM_* instead of open coding string -> enum conversion X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: vf0mK5SiOdKAJ3XpxjSGuw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There are more occurrences, but I'm converting --source argument of domifaddr command only, because I will need it in next commit. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- tools/virsh-domain-monitor.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 9e6bc99bf2..de4abbaee7 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -2358,6 +2358,13 @@ static const vshCmdOptDef opts_domifaddr[] =3D { {.name =3D NULL} }; =20 +VIR_ENUM_DECL(virshDomainInterfaceAddressesSource); +VIR_ENUM_IMPL(virshDomainInterfaceAddressesSource, + VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST, + "lease", + "agent", + "arp"); + static bool cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) { @@ -2379,17 +2386,10 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "source", &sourcestr) < 0) goto cleanup; =20 - if (sourcestr) { - if (STREQ(sourcestr, "lease")) { - source =3D VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE; - } else if (STREQ(sourcestr, "agent")) { - source =3D VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT; - } else if (STREQ(sourcestr, "arp")) { - source =3D VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP; - } else { - vshError(ctl, _("Unknown data source '%s'"), sourcestr); - goto cleanup; - } + if (sourcestr && + (source =3D virshDomainInterfaceAddressesSourceTypeFromString(sour= cestr)) < 0) { + vshError(ctl, _("Unknown data source '%s'"), sourcestr); + goto cleanup; } =20 if ((ifaces_count =3D virDomainInterfaceAddresses(dom, &ifaces, source= , 0)) < 0) { --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list