[PATCH 12/14] virsh: Use 'virshCompletePathLocalExisting' for options reading local files

Peter Krempa pkrempa at redhat.com
Thu Sep 16 17:10:43 UTC 2021


Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 tools/virsh-backup.c     |  2 ++
 tools/virsh-checkpoint.c |  1 +
 tools/virsh-domain.c     | 10 ++++++++++
 tools/virsh-network.c    |  1 +
 tools/virsh-pool.c       |  1 +
 tools/virsh-secret.c     |  1 +
 tools/virsh-snapshot.c   |  1 +
 7 files changed, 17 insertions(+)

diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c
index 9125b7da97..7bac1923a6 100644
--- a/tools/virsh-backup.c
+++ b/tools/virsh-backup.c
@@ -39,10 +39,12 @@ static const vshCmdOptDef opts_backup_begin[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
     {.name = "backupxml",
      .type = VSH_OT_STRING,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("domain backup XML"),
     },
     {.name = "checkpointxml",
      .type = VSH_OT_STRING,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("domain checkpoint XML"),
     },
     {.name = "reuse-external",
diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c
index 1f3a318014..78272b43c4 100644
--- a/tools/virsh-checkpoint.c
+++ b/tools/virsh-checkpoint.c
@@ -88,6 +88,7 @@ static const vshCmdOptDef opts_checkpoint_create[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
     {.name = "xmlfile",
      .type = VSH_OT_STRING,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("domain checkpoint XML")
     },
     {.name = "redefine",
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index f45ab5b9d1..25e50064bd 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -2243,6 +2243,7 @@ static const vshCmdOptDef opts_blockcopy[] = {
     },
     {.name = "xml",
      .type = VSH_OT_STRING,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("filename containing XML description of the copy destination")
     },
     {.name = "format",
@@ -4140,6 +4141,7 @@ static const vshCmdOptDef opts_save[] = {
     },
     {.name = "xml",
      .type = VSH_OT_STRING,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("filename containing updated XML for the target")
     },
     {.name = "running",
@@ -4534,6 +4536,7 @@ static const vshCmdOptDef opts_save_image_define[] = {
     {.name = "xml",
      .type = VSH_OT_DATA,
      .flags = VSH_OFLAG_REQ,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("filename containing updated XML for the target")
     },
     {.name = "running",
@@ -4946,6 +4949,7 @@ static const vshCmdOptDef opts_managed_save_define[] = {
     {.name = "xml",
      .type = VSH_OT_DATA,
      .flags = VSH_OFLAG_REQ,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("filename containing updated XML for the target")
     },
     {.name = "running",
@@ -5248,6 +5252,7 @@ static const vshCmdOptDef opts_restore[] = {
     },
     {.name = "xml",
      .type = VSH_OT_STRING,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("filename containing updated XML for the target")
     },
     {.name = "running",
@@ -10007,6 +10012,7 @@ static const vshCmdOptDef opts_domxmlfromnative[] = {
     {.name = "config",
      .type = VSH_OT_DATA,
      .flags = VSH_OFLAG_REQ,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("config data file to import from")
     },
     {.name = NULL}
@@ -10062,6 +10068,7 @@ static const vshCmdOptDef opts_domxmltonative[] = {
     VIRSH_COMMON_OPT_DOMAIN_OT_STRING_FULL(VSH_OFLAG_REQ_OPT, 0),
     {.name = "xml",
      .type = VSH_OT_STRING,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("xml data file to export from")
     },
     {.name = NULL}
@@ -10392,6 +10399,7 @@ static const vshCmdOptDef opts_migrate[] = {
     },
     {.name = "xml",
      .type = VSH_OT_STRING,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("filename containing updated XML for the target")
     },
     {.name = "migrate-disks",
@@ -10438,6 +10446,7 @@ static const vshCmdOptDef opts_migrate[] = {
     },
     {.name = "persistent-xml",
      .type = VSH_OT_STRING,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("filename containing updated persistent XML for the target")
     },
     {.name = "tls",
@@ -13973,6 +13982,7 @@ static const vshCmdOptDef opts_set_user_sshkeys[] = {
     },
     {.name = "file",
      .type = VSH_OT_STRING,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("optional file to read keys from"),
     },
     {.name = "reset",
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index a8f7f46905..5c35310344 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -937,6 +937,7 @@ static const vshCmdOptDef opts_network_update[] = {
     {.name = "xml",
      .type = VSH_OT_DATA,
      .flags = VSH_OFLAG_REQ,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("name of file containing xml (or, if it starts with '<', the complete "
                 "xml element itself) to add/modify, or to be matched for search")
     },
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index f1dfe892e1..6ab0490b89 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -1509,6 +1509,7 @@ static const vshCmdOptDef opts_find_storage_pool_sources[] = {
     },
     {.name = "srcSpec",
      .type = VSH_OT_STRING,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("optional file of source xml to query for pools")
     },
     {.name = NULL}
diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
index 173a77fd90..d23cbf04bf 100644
--- a/tools/virsh-secret.c
+++ b/tools/virsh-secret.c
@@ -186,6 +186,7 @@ static const vshCmdOptDef opts_secret_set_value[] = {
     {.name = "file",
      .type = VSH_OT_STRING,
      .flags = VSH_OFLAG_REQ_OPT,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("read secret from file"),
     },
     {.name = "plain",
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index 60a68b334b..5a3c468c53 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -115,6 +115,7 @@ static const vshCmdOptDef opts_snapshot_create[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(0),
     {.name = "xmlfile",
      .type = VSH_OT_STRING,
+     .completer = virshCompletePathLocalExisting,
      .help = N_("domain snapshot XML")
     },
     {.name = "redefine",
-- 
2.31.1




More information about the libvir-list mailing list