From nobody Fri Apr 19 06:42:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1641820475; cv=none; d=zohomail.com; s=zohoarc; b=VcAsO5fVkdDW3pr9wDj5Ebx285YPnKfXbY8MDscS+y9WF4QuU+yorrSpu9hduK11HaJqjk4krzf9zbOTZ/+vm95g7/MZdAUkNTaj6M4L29IjRK3DmehgJWZCjMEEKjAsf/OM4CE2gewa05y3C7gltiAy9L4Ew3SwRdTAY/j9mM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641820475; h=Content-Type:Content-Transfer-Encoding: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=A9Q30fHZONQtpSigIP5l5gkGafMxxMil1EnL7F5qlRg=; b=Jrcz/P1s+FhGOfRDQwieJbLBY5V1otLwImVA5uyGJWugUD0WB68vy8B2UdZ7R5WhusOhTo5suZFx7O1kQFMokm04lLikGDaT8O6B+yQTlR7fc7xRL9X34kwKibJEVNjvh8lGmF4yTTlnM9es50cdz21P9qTS9RaMbwwZ+4kaXFM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 164182047538624.41082598291746; Mon, 10 Jan 2022 05:14:35 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-56-S8lj2LNBPt-MOJqTm2SPcw-1; Mon, 10 Jan 2022 08:14:32 -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 607E85A080; Mon, 10 Jan 2022 13:14:28 +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 39BAC7E67A; Mon, 10 Jan 2022 13:14:28 +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 02BBD4A705; Mon, 10 Jan 2022 13:14:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20ADEP1Y005974 for ; Mon, 10 Jan 2022 08:14:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 75B3D7553C; Mon, 10 Jan 2022 13:14:25 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00C5175521 for ; Mon, 10 Jan 2022 13:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641820474; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=A9Q30fHZONQtpSigIP5l5gkGafMxxMil1EnL7F5qlRg=; b=Q6CmhjhJMzSnZXOT2S12qv4vpnc4AC+7Wcjk1n96kiZYYb0fjrx6cN5dF15aY5Z76X2xTN M1ik+MJ+DgTiNBwnGtII9A+7NlecKpmW12/6Ko+NeS6ySzc520xCdkmNNcXJltc555C2c8 rZHnuqxaUKz4fP6WoWu8oQ4qLq/eGe0= X-MC-Unique: S8lj2LNBPt-MOJqTm2SPcw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] virsh: Introduce net-update --command completer Date: Mon, 10 Jan 2022 14:14:10 +0100 Message-Id: <80251fd63c358b151ca60b90aa838babcacccd5e.1641820399.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641820476851100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- tools/virsh-completer-network.c | 23 +++++++++++++++++++++++ tools/virsh-completer-network.h | 5 +++++ tools/virsh-network.c | 2 +- tools/virsh-network.h | 2 ++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tools/virsh-completer-network.c b/tools/virsh-completer-networ= k.c index d498f59cb8..d0cf80f22c 100644 --- a/tools/virsh-completer-network.c +++ b/tools/virsh-completer-network.c @@ -218,3 +218,26 @@ virshNetworkDhcpMacCompleter(vshControl *ctl, } return ret; } + + +char ** +virshNetworkUpdateCommandCompleter(vshControl *ctl G_GNUC_UNUSED, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int flags) +{ + char **ret =3D NULL; + size_t i; + + virCheckFlags(0, NULL); + + ret =3D g_new0(char *, VIR_NETWORK_UPDATE_COMMAND_LAST + 1); + + /* The first item in the enum is not accepted by virsh, But there's "a= dd" + * which is accepted an is just an alias to "add-last". */ + ret[0] =3D g_strdup("add"); + + for (i =3D 1; i < VIR_NETWORK_UPDATE_COMMAND_LAST; i++) + ret[i] =3D g_strdup(virshNetworkUpdateCommandTypeToString(i)); + + return ret; +} diff --git a/tools/virsh-completer-network.h b/tools/virsh-completer-networ= k.h index ffcda68355..7557dfdb0d 100644 --- a/tools/virsh-completer-network.h +++ b/tools/virsh-completer-network.h @@ -46,3 +46,8 @@ char ** virshNetworkDhcpMacCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** +virshNetworkUpdateCommandCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 02b22bf912..2a0a24c6d3 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -919,6 +919,7 @@ static const vshCmdOptDef opts_network_update[] =3D { {.name =3D "command", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshNetworkUpdateCommandCompleter, .help =3D N_("type of update (add-first, add-last (add), delete, or m= odify)") }, {.name =3D "section", @@ -943,7 +944,6 @@ static const vshCmdOptDef opts_network_update[] =3D { {.name =3D NULL} }; =20 -VIR_ENUM_DECL(virshNetworkUpdateCommand); VIR_ENUM_IMPL(virshNetworkUpdateCommand, VIR_NETWORK_UPDATE_COMMAND_LAST, "none", "modify", "delete", "add-last", "add-first"); diff --git a/tools/virsh-network.h b/tools/virsh-network.h index 3c786dd7a1..05da736cce 100644 --- a/tools/virsh-network.h +++ b/tools/virsh-network.h @@ -44,4 +44,6 @@ typedef struct virshNetworkEventCallback virshNetworkEven= tCallback; =20 extern virshNetworkEventCallback virshNetworkEventCallbacks[]; =20 +VIR_ENUM_DECL(virshNetworkUpdateCommand); + extern const vshCmdDef networkCmds[]; --=20 2.34.1 From nobody Fri Apr 19 06:42:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1641820478; cv=none; d=zohomail.com; s=zohoarc; b=PcUwJEsIRsXhu+Kim9Qp6BzY94JuATzBX+FbDVHfBSKgM07ZB0thWBSS1Quva09pZZ+bqmWSf01VY2NP1dKRMDPvvfV/2/7hh6pPLesXCdL2wFsMHQ3qh5N0EbaikJ5m0oo7u0Ux3C3f3z3GLFxvraaOghPTf8WacOiw/d7eh+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641820478; h=Content-Type:Content-Transfer-Encoding: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=KhBRvkIScVSD3v1aslfIqExK3NUEdX9lQJ5HSieJZWo=; b=OQB+zg7P3kPojhVERy59WezWhnuiwF4MAYp5zrOTzVTtoeqrg/HyPc5ekNcgSEi2+xfeploBcIDvdBnKzZCYnzubPB9we7tfQL4GoNlDRHvKMNwd3BPloxaSXC6qMb2FvKKT53PS5Cre1wCEshBu89tHC+wWad94rYB+5x6vlmA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1641820478782198.4872176454419; Mon, 10 Jan 2022 05:14:38 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-481-cMicsINAPuW_gVXuKWJ2rw-1; Mon, 10 Jan 2022 08:14:34 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B07231923E26; Mon, 10 Jan 2022 13:14:28 +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 90336105B218; Mon, 10 Jan 2022 13:14:28 +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 551151809CB9; Mon, 10 Jan 2022 13:14:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20ADEQZm005983 for ; Mon, 10 Jan 2022 08:14:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4302A7553C; Mon, 10 Jan 2022 13:14:26 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1D5375521 for ; Mon, 10 Jan 2022 13:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641820477; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=KhBRvkIScVSD3v1aslfIqExK3NUEdX9lQJ5HSieJZWo=; b=WvdX3NOzW4y1phRM5CaydpKRs8my0p24K3whPjbqLr8sUHl9gVfEtTAoyAafrog/RJGlX9 QFObrjM+mrlxnIWIlqrfXd2YlFbgbgLpVi/ZioeZZbPd+UFzqtO2YO5HjpJF3CyyQMA5Sr ZwNjQVbvgBsbjvm1tw22hermKZTfD2Q= X-MC-Unique: cMicsINAPuW_gVXuKWJ2rw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] virsh: Introduce net-update --section completer Date: Mon, 10 Jan 2022 14:14:11 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641820479457100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- tools/virsh-completer-network.c | 20 ++++++++++++++++++++ tools/virsh-completer-network.h | 5 +++++ tools/virsh-network.c | 2 +- tools/virsh-network.h | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tools/virsh-completer-network.c b/tools/virsh-completer-networ= k.c index d0cf80f22c..839d71e961 100644 --- a/tools/virsh-completer-network.c +++ b/tools/virsh-completer-network.c @@ -241,3 +241,23 @@ virshNetworkUpdateCommandCompleter(vshControl *ctl G_G= NUC_UNUSED, =20 return ret; } + + +char ** +virshNetworkUpdateSectionCompleter(vshControl *ctl G_GNUC_UNUSED, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int flags) +{ + char **ret =3D NULL; + size_t i; + + virCheckFlags(0, NULL); + + ret =3D g_new0(char *, VIR_NETWORK_SECTION_LAST); + + /* The first item in the enum is not accepted by virsh. */ + for (i =3D 1; i < VIR_NETWORK_SECTION_LAST; i++) + ret[i - 1] =3D g_strdup(virshNetworkSectionTypeToString(i)); + + return ret; +} diff --git a/tools/virsh-completer-network.h b/tools/virsh-completer-networ= k.h index 7557dfdb0d..c7ceff0b13 100644 --- a/tools/virsh-completer-network.h +++ b/tools/virsh-completer-network.h @@ -51,3 +51,8 @@ char ** virshNetworkUpdateCommandCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** +virshNetworkUpdateSectionCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 2a0a24c6d3..5f574be78c 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -925,6 +925,7 @@ static const vshCmdOptDef opts_network_update[] =3D { {.name =3D "section", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshNetworkUpdateSectionCompleter, .help =3D N_("which section of network configuration to update") }, {.name =3D "xml", @@ -948,7 +949,6 @@ VIR_ENUM_IMPL(virshNetworkUpdateCommand, VIR_NETWORK_UPDATE_COMMAND_LAST, "none", "modify", "delete", "add-last", "add-first"); =20 -VIR_ENUM_DECL(virshNetworkSection); VIR_ENUM_IMPL(virshNetworkSection, VIR_NETWORK_SECTION_LAST, "none", "bridge", "domain", "ip", "ip-dhcp-host", diff --git a/tools/virsh-network.h b/tools/virsh-network.h index 05da736cce..ffd157f054 100644 --- a/tools/virsh-network.h +++ b/tools/virsh-network.h @@ -45,5 +45,6 @@ typedef struct virshNetworkEventCallback virshNetworkEven= tCallback; extern virshNetworkEventCallback virshNetworkEventCallbacks[]; =20 VIR_ENUM_DECL(virshNetworkUpdateCommand); +VIR_ENUM_DECL(virshNetworkSection); =20 extern const vshCmdDef networkCmds[]; --=20 2.34.1