[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v2 7/9] virsh: Add completer functions to domManaggementCmds



* opts_dom_pm_suspend completer initialization for "target" removed
  (moved to another patch)
---
 tools/virsh-domain.c | 230 +++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 179 insertions(+), 51 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index a2002c5..ff7a6e3 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -2756,8 +2756,7 @@ static const vshCmdOptDef opts_dom_pm_suspend[] = {
      .flags = VSH_OFLAG_REQ,
      .help = N_("mem(Suspend-to-RAM), "
                 "disk(Suspend-to-Disk), "
-                "hybrid(Hybrid-Suspend)"),
-     .completer = vshSuspendTargetCompleter
+                "hybrid(Hybrid-Suspend)")
     },
     {.name = NULL}
 };
@@ -4714,7 +4713,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}
 };
@@ -4800,7 +4800,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}
 };
@@ -10359,7 +10360,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,
@@ -10371,7 +10375,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,
@@ -10414,7 +10421,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",
@@ -10451,13 +10461,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,
@@ -10481,25 +10496,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,
@@ -10517,13 +10544,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,
@@ -10535,19 +10566,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,
@@ -10565,31 +10604,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,
@@ -10601,19 +10655,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,
@@ -10625,7 +10689,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,
@@ -10637,31 +10704,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,
@@ -10673,25 +10755,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,
@@ -10703,7 +10795,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,
@@ -10733,61 +10828,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,
@@ -10805,25 +10922,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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]