From nobody Sat Apr 27 07:41:23 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 From nobody Sat Apr 27 07:41:23 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=1578386548; cv=none; d=zohomail.com; s=zohoarc; b=QAg5c/5xWo9rRuxBcORG/2vBczmo/PmlRuFWmaowHGWPrxXjEmT319N/jwGcNdIgjPsMbHJ+4UyeIkiK7Qf2DyYrEBSqd+Tm+r8DFIrFg8hXVL3P67lxUyqEyGUQ9alIMffnhikNq2PWUkLaqEVSmfe53/RN5pypwhWP0xEHFYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578386548; 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=W9RJ4qYeXrH5oak7wz81bS67kGJ41SK++SK+kGUuXN8=; b=GTEbQbZYQXJJKGviGsJG3YEWUKTYcrmUrxPOZxy3voz5AJx4fNqFFJFcrqIxW0Imhh8m/5ZAhNQ/QBGVvoexkRaJNg3trzYRu7YI5T2BY8cztSBZYJsloDfrk2zz5VG7rkyIALCPZJp8CEW7Ml8dmgYl6hGzbLeKFk6rRi5znWk= 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 1578386548558289.1915444483286; Tue, 7 Jan 2020 00:42:28 -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-133-0hmoeJahNCO_Zo2gAg8ZYg-1; Tue, 07 Jan 2020 03:42:25 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4AABCDB60; Tue, 7 Jan 2020 08:42:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EFE577BFAD; Tue, 7 Jan 2020 08:42:19 +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 ACEA881C8B; Tue, 7 Jan 2020 08:42:19 +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 0078g6Hc009171 for ; Tue, 7 Jan 2020 03:42:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 65EE260C88; Tue, 7 Jan 2020 08:42:06 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94B1260BEC; Tue, 7 Jan 2020 08:42:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578386547; 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=W9RJ4qYeXrH5oak7wz81bS67kGJ41SK++SK+kGUuXN8=; b=UANCgvqhyodpKBeUw7Z2ODNfu4sx5b0UM9SdG14vw5u7uz77ZfQHVxSG9YkFlCKJlcKqZG nhBd0FMYkdlbD4r8Eq0k8F8R3RVZpkEtRZnKt/Oe4EfjHd58+35cyby5a3dRRZW0keUivN lW8lV4H5+acgXH+hWqob7dpQk8ykpnM= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 7 Jan 2020 09:41:53 +0100 Message-Id: <7547364641dedf5008686c6e85d50e1cfa53c92f.1578386376.git.mprivozn@redhat.com> 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 2/3] virsh: Fix virshDomainInterfaceSourceCompleter 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.11 X-MC-Unique: 0hmoeJahNCO_Zo2gAg8ZYg-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" Introduced in v5.10.0-449-gcf44ec5577 it used virshCommaStringListComplete() to generate list of options. But this is not correct because the '--source' argument of the 'domifaddr' doesn't accept a string list (for instance "arp,agent,lease") rather than a single string. Therefore, the completer must return these strings separately and thus must refrain from using virshCommaStringListComplete(). At the same time, now that we have strings we need declared as an enum we can use TypeToString() instead of copying strings. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- tools/virsh-completer-domain.c | 17 ++++++++++------- tools/virsh-domain-monitor.c | 1 - tools/virsh-domain-monitor.h | 2 ++ tools/virsh.h | 1 + 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 9423d2efb3..6da603048e 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -24,6 +24,7 @@ #include "viralloc.h" #include "virmacaddr.h" #include "virsh-domain.h" +#include "virsh-domain-monitor.h" #include "virsh-util.h" #include "virsh.h" #include "virstring.h" @@ -299,17 +300,19 @@ virshDomainShutdownModeCompleter(vshControl *ctl, =20 =20 char ** -virshDomainInterfaceAddrSourceCompleter(vshControl *ctl, - const vshCmd *cmd, +virshDomainInterfaceAddrSourceCompleter(vshControl *ctl G_GNUC_UNUSED, + const vshCmd *cmd G_GNUC_UNUSED, unsigned int flags) { - const char *sources[] =3D {"lease", "agent", "arp", NULL}; - const char *source =3D NULL; + char **ret =3D NULL; + size_t i; =20 virCheckFlags(0, NULL); =20 - if (vshCommandOptStringQuiet(ctl, cmd, "source", &source) < 0) - return NULL; + ret =3D g_new0(typeof(*ret), VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST += 1); =20 - return virshCommaStringListComplete(source, sources); + for (i =3D 0; i < VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST; i++) + ret[i] =3D g_strdup(virshDomainInterfaceAddressesSourceTypeToStrin= g(i)); + + return ret; } diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index de4abbaee7..97301f71f9 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -2358,7 +2358,6 @@ 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", diff --git a/tools/virsh-domain-monitor.h b/tools/virsh-domain-monitor.h index 11a9156ae2..0de47c50c4 100644 --- a/tools/virsh-domain-monitor.h +++ b/tools/virsh-domain-monitor.h @@ -26,4 +26,6 @@ char *virshGetDomainDescription(vshControl *ctl, virDomai= nPtr dom, bool title, unsigned int flags) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; =20 +VIR_ENUM_DECL(virshDomainInterfaceAddressesSource); + extern const vshCmdDef domMonitoringCmds[]; diff --git a/tools/virsh.h b/tools/virsh.h index d84659124a..903a2e53b6 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -31,6 +31,7 @@ #include "virpolkit.h" #include "vsh.h" #include "virsh-completer.h" +#include "virenum.h" =20 #define VIRSH_PROMPT_RW "virsh # " #define VIRSH_PROMPT_RO "virsh > " --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 07:41:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1578386539; cv=none; d=zohomail.com; s=zohoarc; b=Z9Hztql0sNbnxS48KePfTtbKjC7A0WoGQa1PAgrS85QqUSWFHF3e22AoZPFyF46DHHwI5W9uSeHj/7ocZS8lGYB5T8GWOqaPDd31LM8WOnlzG3PToKkKeHK2ih8fztfUo2ITTZtjyu4e5XWWwRGSJEQgXT68tWx7YuygRrmJN24= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578386539; 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=byOlV5s7jsHsTivqNhATAPhesk4Y6l6Ldz7ZaMk2HQk=; b=IuEDmJM5yBAgLbF6hdxgchTBnOcuRKsM6/1drEFgJTIgsxTfRUoq5X+9nIRmFZnS9AftxeBCOp51RmOlPW3kt4tjkAOR9l6hUIlNBYLJcHrHkCNCMtATFjIH3tH7XTyyVIJKPHftoOLjRvZNC1KCCEhfv0BdNoRVt/03O7S9vyM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 1578386539271390.02270904770205; Tue, 7 Jan 2020 00:42:19 -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-76-Akzb7iAGOLCQnTdh7eGoJg-1; Tue, 07 Jan 2020 03:42:16 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 46F1E801E6C; Tue, 7 Jan 2020 08:42:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1760584FE2; Tue, 7 Jan 2020 08:42:11 +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 B15BA81C82; Tue, 7 Jan 2020 08:42:10 +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 0078g7od009182 for ; Tue, 7 Jan 2020 03:42:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 838BD60C88; Tue, 7 Jan 2020 08:42:07 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id B311160BEC; Tue, 7 Jan 2020 08:42:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578386538; 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=byOlV5s7jsHsTivqNhATAPhesk4Y6l6Ldz7ZaMk2HQk=; b=hRtZzHU4zoeXJEKid+X0ZM0/qJDEqaneDTdiHKywUl70QS6aF1iVpbJLvS5hqfUST/nCOw 18gBdc8aBODJeXj/LIcnC3j1griMDLF7o30i76RsEu6hOz7Boc7Dzz//+ZJ1WOnXJIyMRB 7fKY8iGnq2l2e8BwCkQSrS62Nj5zzVo= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 7 Jan 2020 09:41:54 +0100 Message-Id: <2ad9da7ba771c17c56b2ee0d3bb8378152d846b9.1578386376.git.mprivozn@redhat.com> 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 3/3] cmdDomIfAddr: Move domain lookup down a few lines 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.13 X-MC-Unique: Akzb7iAGOLCQnTdh7eGoJg-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" The 'domifaddr' command accepts several arguments. Let's validate them first and look up domain to work with only after to save some RPC cycles should validation fail. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- tools/virsh-domain-monitor.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 97301f71f9..e357635757 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -2377,20 +2377,20 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) const char *sourcestr =3D NULL; int source =3D VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE; =20 - if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) - return false; - if (vshCommandOptStringReq(ctl, cmd, "interface", &ifacestr) < 0) - goto cleanup; + return false; if (vshCommandOptStringReq(ctl, cmd, "source", &sourcestr) < 0) - goto cleanup; + return false; =20 if (sourcestr && (source =3D virshDomainInterfaceAddressesSourceTypeFromString(sour= cestr)) < 0) { vshError(ctl, _("Unknown data source '%s'"), sourcestr); - goto cleanup; + return false; } =20 + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return false; + if ((ifaces_count =3D virDomainInterfaceAddresses(dom, &ifaces, source= , 0)) < 0) { vshError(ctl, _("Failed to query for interfaces addresses")); goto cleanup; --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list