Add .completer and .completer_flags to domManagementCmds.
vshDomainCompleter (with appropriate flags) is enabled for
commands requiring only single <domain> argument.
---
tools/virsh-domain.c | 230 ++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 180 insertions(+), 50 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 5e1196f..b89b219 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -2752,7 +2752,8 @@ static const vshCmdOptDef opts_dom_pm_suspend[] = {
.flags = VSH_OFLAG_REQ,
.help = N_("mem(Suspend-to-RAM), "
"disk(Suspend-to-Disk), "
- "hybrid(Hybrid-Suspend)")
+ "hybrid(Hybrid-Suspend)"),
+ .completer = vshSuspendTargetCompleter
},
{.name = NULL}
};
@@ -4707,7 +4708,8 @@ static const vshCmdOptDef opts_shutdown[] = {
},
{.name = "mode",
.type = VSH_OT_STRING,
- .help = N_("shutdown mode: acpi|agent|initctl|signal")
+ .help = N_("shutdown mode: acpi|agent|initctl|signal"),
+ .completer = vshRebootShutdownModeCompleter
},
{.name = NULL}
};
@@ -4793,7 +4795,8 @@ static const vshCmdOptDef opts_reboot[] = {
},
{.name = "mode",
.type = VSH_OT_STRING,
- .help = N_("shutdown mode: acpi|agent|initctl|signal")
+ .help = N_("shutdown mode: acpi|agent|initctl|signal"),
+ .completer = vshRebootShutdownModeCompleter
},
{.name = NULL}
};
@@ -10333,7 +10336,10 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdAutostart,
.opts = opts_autostart,
.info = info_autostart,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "blkdeviotune",
.handler = cmdBlkdeviotune,
@@ -10345,7 +10351,10 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdBlkiotune,
.opts = opts_blkiotune,
.info = info_blkiotune,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "blockcommit",
.handler = cmdBlockCommit,
@@ -10388,7 +10397,10 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdConsole,
.opts = opts_console,
.info = info_console,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
#endif
{.name = "cpu-baseline",
@@ -10425,13 +10437,18 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdDesc,
.opts = opts_desc,
.info = info_desc,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "destroy",
.handler = cmdDestroy,
.opts = opts_destroy,
.info = info_destroy,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE
},
{.name = "detach-device",
.handler = cmdDetachDevice,
@@ -10455,25 +10472,37 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdDomDisplay,
.opts = opts_domdisplay,
.info = info_domdisplay,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "domfstrim",
.handler = cmdDomFSTrim,
.opts = opts_domfstrim,
.info = info_domfstrim,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "domhostname",
.handler = cmdDomHostname,
.opts = opts_domhostname,
.info = info_domhostname,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "domid",
.handler = cmdDomid,
.opts = opts_domid,
.info = info_domid,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "domif-setlink",
.handler = cmdDomIfSetLink,
@@ -10491,13 +10520,17 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdDomjobabort,
.opts = opts_domjobabort,
.info = info_domjobabort,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE
},
{.name = "domjobinfo",
.handler = cmdDomjobinfo,
.opts = opts_domjobinfo,
.info = info_domjobinfo,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE
},
{.name = "domname",
.handler = cmdDomname,
@@ -10509,19 +10542,27 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdDomPMSuspend,
.opts = opts_dom_pm_suspend,
.info = info_dom_pm_suspend,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_RUNNING
},
{.name = "dompmwakeup",
.handler = cmdDomPMWakeup,
.opts = opts_dom_pm_wakeup,
.info = info_dom_pm_wakeup,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE
},
{.name = "domuuid",
.handler = cmdDomuuid,
.opts = opts_domuuid,
.info = info_domuuid,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "domxml-from-native",
.handler = cmdDomXMLFromNative,
@@ -10539,31 +10580,46 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdDump,
.opts = opts_dump,
.info = info_dump,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_RUNNING
},
{.name = "dumpxml",
.handler = cmdDumpXML,
.opts = opts_dumpxml,
.info = info_dumpxml,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "edit",
.handler = cmdEdit,
.opts = opts_edit,
.info = info_edit,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "inject-nmi",
.handler = cmdInjectNMI,
.opts = opts_inject_nmi,
.info = info_inject_nmi,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_RUNNING
},
{.name = "send-key",
.handler = cmdSendKey,
.opts = opts_send_key,
.info = info_send_key,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_RUNNING
},
{.name = "send-process-signal",
.handler = cmdSendProcessSignal,
@@ -10575,19 +10631,29 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdLxcEnterNamespace,
.opts = opts_lxc_enter_namespace,
.info = info_lxc_enter_namespace,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "managedsave",
.handler = cmdManagedSave,
.opts = opts_managedsave,
.info = info_managedsave,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_RUNNING |
+ VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE
},
{.name = "managedsave-remove",
.handler = cmdManagedSaveRemove,
.opts = opts_managedsaveremove,
.info = info_managedsaveremove,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_INACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE
},
{.name = "maxvcpus",
.handler = cmdMaxvcpus,
@@ -10599,7 +10665,10 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdMemtune,
.opts = opts_memtune,
.info = info_memtune,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "migrate",
.handler = cmdMigrate,
@@ -10611,31 +10680,46 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdMigrateSetMaxDowntime,
.opts = opts_migrate_setmaxdowntime,
.info = info_migrate_setmaxdowntime,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "migrate-compcache",
.handler = cmdMigrateCompCache,
.opts = opts_migrate_compcache,
.info = info_migrate_compcache,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_RUNNING
},
{.name = "migrate-setspeed",
.handler = cmdMigrateSetMaxSpeed,
.opts = opts_migrate_setspeed,
.info = info_migrate_setspeed,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "migrate-getspeed",
.handler = cmdMigrateGetMaxSpeed,
.opts = opts_migrate_getspeed,
.info = info_migrate_getspeed,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "numatune",
.handler = cmdNumatune,
.opts = opts_numatune,
.info = info_numatune,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "qemu-attach",
.handler = cmdQemuAttach,
@@ -10647,25 +10731,35 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdQemuMonitorCommand,
.opts = opts_qemu_monitor_command,
.info = info_qemu_monitor_command,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "qemu-agent-command",
.handler = cmdQemuAgentCommand,
.opts = opts_qemu_agent_command,
.info = info_qemu_agent_command,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "reboot",
.handler = cmdReboot,
.opts = opts_reboot,
.info = info_reboot,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE
},
{.name = "reset",
.handler = cmdReset,
.opts = opts_reset,
.info = info_reset,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE
},
{.name = "restore",
.handler = cmdRestore,
@@ -10677,7 +10771,10 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdResume,
.opts = opts_resume,
.info = info_resume,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_PAUSED
},
{.name = "save",
.handler = cmdSave,
@@ -10707,61 +10804,83 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdSchedinfo,
.opts = opts_schedinfo,
.info = info_schedinfo,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "screenshot",
.handler = cmdScreenshot,
.opts = opts_screenshot,
.info = info_screenshot,
- .flags = 0
+ .flags = 0,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE
},
{.name = "setmaxmem",
.handler = cmdSetmaxmem,
.opts = opts_setmaxmem,
.info = info_setmaxmem,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "setmem",
.handler = cmdSetmem,
.opts = opts_setmem,
.info = info_setmem,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE
},
{.name = "setvcpus",
.handler = cmdSetvcpus,
.opts = opts_setvcpus,
.info = info_setvcpus,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE
},
{.name = "shutdown",
.handler = cmdShutdown,
.opts = opts_shutdown,
.info = info_shutdown,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE
},
{.name = "start",
.handler = cmdStart,
.opts = opts_start,
.info = info_start,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_INACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_PERSISTENT,
},
{.name = "suspend",
.handler = cmdSuspend,
.opts = opts_suspend,
.info = info_suspend,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE
},
{.name = "ttyconsole",
.handler = cmdTTYConsole,
.opts = opts_ttyconsole,
.info = info_ttyconsole,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE
},
{.name = "undefine",
.handler = cmdUndefine,
.opts = opts_undefine,
.info = info_undefine,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "update-device",
.handler = cmdUpdateDevice,
@@ -10779,25 +10898,36 @@ const vshCmdDef domManagementCmds[] = {
.handler = cmdVcpuinfo,
.opts = opts_vcpuinfo,
.info = info_vcpuinfo,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "vcpupin",
.handler = cmdVcpuPin,
.opts = opts_vcpupin,
.info = info_vcpupin,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "emulatorpin",
.handler = cmdEmulatorPin,
.opts = opts_emulatorpin,
.info = info_emulatorpin,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
+ VIR_CONNECT_LIST_DOMAINS_INACTIVE
},
{.name = "vncdisplay",
.handler = cmdVNCDisplay,
.opts = opts_vncdisplay,
.info = info_vncdisplay,
- .flags = 0
+ .flags = 0,
+ .completer = vshDomainCompleter,
+ .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE
},
{.name = NULL}
};
--
1.8.3.1