From nobody Tue Nov 26 10:27:54 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