From nobody Tue Nov 26 09:40:52 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