From nobody Tue Nov 26 07:50:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1577977649; cv=none; d=zohomail.com; s=zohoarc; b=EDijJjoCBV9pME47edtjzLl4AK4yaS3SjenDWCS7xVDqhkKikFMb1OCB72+EqHuO35O+lIpCVA8h/Tvq6OaOqNm0I5JS+7geMxH7zktmzE4JMex0auYutnrxZz2GR56b/0fxXEch/7cDPCUs3FhiXF06BT7Qu8+I2PrJ+DopABU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977649; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=749W39QQVZ8YDuthNrupnC1mAQPmO/1nwrZJjyL4yf4=; b=Hd03k7MLhVxxnA6HPBWRCLBfsmCAnHO8J79DPlyNLQBeWdaRlRgWxE91nhIX0eF7lDjp5BNfObAiOW926CpyUq9ekxIS9X0IzPzYyq0bwX6sZ9kp8+sceWGX9FuAytRkFe09C9arpXT2r4j5yIifi5w0m0G+JeIDNGGNMAJH+ks= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1577977649892654.4666965727538; Thu, 2 Jan 2020 07:07:29 -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-379-DU8mQReOMNa0u5TgsKh4Jg-1; Thu, 02 Jan 2020 10:07:27 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2ACCB132DD8; Thu, 2 Jan 2020 15:07:21 +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 C8C2D5D9C9; Thu, 2 Jan 2020 15:07:20 +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 9228718034EA; Thu, 2 Jan 2020 15:07:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 002F7IOk012500 for ; Thu, 2 Jan 2020 10:07:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2F8F82022AA8; Thu, 2 Jan 2020 15:07:18 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AAA42026D69 for ; Thu, 2 Jan 2020 15:07:16 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 591331019290 for ; Thu, 2 Jan 2020 15:07:16 +0000 (UTC) Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-283-C3LlJvrWPfC205Q3L0RgyQ-1; Thu, 02 Jan 2020 10:07:14 -0500 Received: by mail-pg1-f174.google.com with SMTP id 6so22016842pgk.0 for ; Thu, 02 Jan 2020 07:07:14 -0800 (PST) Received: from localhost.localdomain ([191.255.52.34]) by smtp.gmail.com with ESMTPSA id h128sm66842994pfe.172.2020.01.02.07.07.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2020 07:07:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977648; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=749W39QQVZ8YDuthNrupnC1mAQPmO/1nwrZJjyL4yf4=; b=ChRRYXoV1wz7LhqXzhK4BKTESFXs4WSBFpgQUfvxCMiQu0FPyT7CI+eYUlRidpOR2TANMO 9Opjrj0BKDtc4jYl8+jlCPRFUqxXh37nIeJtFJZ1YfL3kBuXAMIiKMpKcWiqKOwI8HJVil zJ5QvaTEwTtAwc8+QjiLB5ZqBSmdhqQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=2jM4YrihBkMH/RrRlUwgusuUcHZ87LqKrNdpYaPpth4=; b=jyOPSzvAHAMgV8JZUtIgRQs7lcA9aB1Wz1ScimyfOiw3tVUBriJZks39CcxDmrVOr7 CIBNAlgvmtZCgdLUWiLpU7kk1oo/R13tDNZvtFHOBKCAq0AIqSwxGq876qfM+MBBxLqC 0TEzNR0gV3TM6QWiT3tVvQrGExGi69VeZCG03kFGEy8X756SjtmW7SgYef1EJ/cctsFe xfs8o37xTNdnfA7gOIe+t62fCierFuKTckqkp2XkKlKV3agOgOZL5auhu8kAWha3dyio K3xX4Z8xnHSUi089vPKnEL5/LJNMvwBhH+b1KQ94tdpPxjYUnUlexYEpr9AeTsFtxMEb jKag== X-Gm-Message-State: APjAAAXWYZiuXwfV4Ug8temyTyqVh7GtbjjETFzIh7XiKuM8VPPe36cK 26+flDUy9BSpVeraYx3W6CkOf6Vn X-Google-Smtp-Source: APXvYqzH/WuwUUHGnt8SHdfqY7gzOlxZNCmxhTTVSNX/Tq3HKajB3NHSulT5xJBcytFSvkrhuaM5JA== X-Received: by 2002:a63:1f5c:: with SMTP id q28mr83785320pgm.404.1577977632994; Thu, 02 Jan 2020 07:07:12 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 12:07:06 -0300 Message-Id: <20200102150706.13507-1-jcfaracco@gmail.com> MIME-Version: 1.0 X-MC-Unique: C3LlJvrWPfC205Q3L0RgyQ-1 X-MC-Unique: DU8mQReOMNa0u5TgsKh4Jg-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 002F7IOk012500 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] virsh: Add a completer for `domifaddr` --source parameter. 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.14 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 command `domifaddr` can use three different sources to grab IP address of a Virtual Machine: lease, agent and arp. This parameter does not have a completer function to return source options. Signed-off-by: Julio Faracco Reviewed-by: Erik Skultety --- tools/virsh-completer-domain.c | 17 +++++++++++++++++ tools/virsh-completer-domain.h | 5 +++++ tools/virsh-domain-monitor.c | 1 + 3 files changed, 23 insertions(+) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 0311ee50d0..c8709baa38 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -296,3 +296,20 @@ virshDomainShutdownModeCompleter(vshControl *ctl, =20 return virshCommaStringListComplete(mode, modes); } + + +char ** +virshDomainIfAddrSourceCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags) +{ + const char *sources[] =3D {"lease", "agent", "arp", NULL}; + const char *source =3D NULL; + + virCheckFlags(0, NULL); + + if (vshCommandOptStringQuiet(ctl, cmd, "source", &source) < 0) + return NULL; + + return virshCommaStringListComplete(source, sources); +} diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index 083ab327cc..f5e5625051 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -53,3 +53,8 @@ char ** virshDomainDeviceAliasCompleter(vshControl *ctl, char ** virshDomainShutdownModeCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** +virshDomainIfAddrSourceCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 30b186ffd1..1d1f87eb9e 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -2346,6 +2346,7 @@ static const vshCmdOptDef opts_domifaddr[] =3D { {.name =3D "source", .type =3D VSH_OT_STRING, .flags =3D VSH_OFLAG_NONE, + .completer =3D virshDomainIfAddrSourceCompleter, .help =3D N_("address source: 'lease', 'agent', or 'arp'")}, {.name =3D NULL} }; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list