On 07/24/2012 11:18 AM, Osier Yang wrote:
This will avoid many conflicts if moving the codes for each command
group into separate files in later patches.
---
tools/virsh.c | 967 ++++++++++++++++++++++++++++-----------------------------
1 files changed, 483 insertions(+), 484 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 6bb0fc8..81976a0 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -18183,371 +18183,38 @@ cleanup:
return ret;
}
-static const vshCmdDef domManagementCmds[] = {
- {"attach-device", cmdAttachDevice, opts_attach_device,
- info_attach_device, 0},
- {"attach-disk", cmdAttachDisk, opts_attach_disk,
- info_attach_disk, 0},
- {"attach-interface", cmdAttachInterface, opts_attach_interface,
- info_attach_interface, 0},
- {"autostart", cmdAutostart, opts_autostart, info_autostart, 0},
- {"blkdeviotune", cmdBlkdeviotune, opts_blkdeviotune, info_blkdeviotune,
0},
- {"blkiotune", cmdBlkiotune, opts_blkiotune, info_blkiotune, 0},
- {"blockcopy", cmdBlockCopy, opts_block_copy, info_block_copy, 0},
- {"blockjob", cmdBlockJob, opts_block_job, info_block_job, 0},
- {"blockpull", cmdBlockPull, opts_block_pull, info_block_pull, 0},
- {"blockresize", cmdBlockResize, opts_block_resize, info_block_resize, 0},
- {"change-media", cmdChangeMedia, opts_change_media, info_change_media,
0},
-#ifndef WIN32
- {"console", cmdConsole, opts_console, info_console, 0},
-#endif
- {"cpu-baseline", cmdCPUBaseline, opts_cpu_baseline, info_cpu_baseline,
0},
- {"cpu-compare", cmdCPUCompare, opts_cpu_compare, info_cpu_compare, 0},
- {"cpu-stats", cmdCPUStats, opts_cpu_stats, info_cpu_stats, 0},
- {"create", cmdCreate, opts_create, info_create, 0},
- {"define", cmdDefine, opts_define, info_define, 0},
- {"desc", cmdDesc, opts_desc, info_desc, 0},
- {"destroy", cmdDestroy, opts_destroy, info_destroy, 0},
- {"detach-device", cmdDetachDevice, opts_detach_device,
- info_detach_device, 0},
- {"detach-disk", cmdDetachDisk, opts_detach_disk, info_detach_disk, 0},
- {"detach-interface", cmdDetachInterface, opts_detach_interface,
- info_detach_interface, 0},
- {"domdisplay", cmdDomDisplay, opts_domdisplay, info_domdisplay, 0},
- {"domhostname", cmdDomHostname, opts_domhostname, info_domhostname, 0},
- {"domid", cmdDomid, opts_domid, info_domid, 0},
- {"domif-setlink", cmdDomIfSetLink, opts_domif_setlink, info_domif_setlink,
0},
- {"domiftune", cmdDomIftune, opts_domiftune, info_domiftune, 0},
- {"domjobabort", cmdDomjobabort, opts_domjobabort, info_domjobabort, 0},
- {"domjobinfo", cmdDomjobinfo, opts_domjobinfo, info_domjobinfo, 0},
- {"domname", cmdDomname, opts_domname, info_domname, 0},
- {"dompmsuspend", cmdDomPMSuspend,
- opts_dom_pm_suspend, info_dom_pm_suspend, 0},
- {"dompmwakeup", cmdDomPMWakeup,
- opts_dom_pm_wakeup, info_dom_pm_wakeup, 0},
- {"domuuid", cmdDomuuid, opts_domuuid, info_domuuid, 0},
- {"domxml-from-native", cmdDomXMLFromNative, opts_domxmlfromnative,
- info_domxmlfromnative, 0},
- {"domxml-to-native", cmdDomXMLToNative, opts_domxmltonative,
- info_domxmltonative, 0},
- {"dump", cmdDump, opts_dump, info_dump, 0},
- {"dumpxml", cmdDumpXML, opts_dumpxml, info_dumpxml, 0},
- {"edit", cmdEdit, opts_edit, info_edit, 0},
- {"inject-nmi", cmdInjectNMI, opts_inject_nmi, info_inject_nmi, 0},
- {"send-key", cmdSendKey, opts_send_key, info_send_key, 0},
- {"managedsave", cmdManagedSave, opts_managedsave, info_managedsave, 0},
- {"managedsave-remove", cmdManagedSaveRemove, opts_managedsaveremove,
- info_managedsaveremove, 0},
- {"maxvcpus", cmdMaxvcpus, opts_maxvcpus, info_maxvcpus, 0},
- {"memtune", cmdMemtune, opts_memtune, info_memtune, 0},
- {"migrate", cmdMigrate, opts_migrate, info_migrate, 0},
- {"migrate-setmaxdowntime", cmdMigrateSetMaxDowntime,
- opts_migrate_setmaxdowntime, info_migrate_setmaxdowntime, 0},
- {"migrate-setspeed", cmdMigrateSetMaxSpeed,
- opts_migrate_setspeed, info_migrate_setspeed, 0},
- {"migrate-getspeed", cmdMigrateGetMaxSpeed,
- opts_migrate_getspeed, info_migrate_getspeed, 0},
- {"numatune", cmdNumatune, opts_numatune, info_numatune, 0},
- {"reboot", cmdReboot, opts_reboot, info_reboot, 0},
- {"reset", cmdReset, opts_reset, info_reset, 0},
- {"restore", cmdRestore, opts_restore, info_restore, 0},
- {"resume", cmdResume, opts_resume, info_resume, 0},
- {"save", cmdSave, opts_save, info_save, 0},
- {"save-image-define", cmdSaveImageDefine, opts_save_image_define,
- info_save_image_define, 0},
- {"save-image-dumpxml", cmdSaveImageDumpxml, opts_save_image_dumpxml,
- info_save_image_dumpxml, 0},
- {"save-image-edit", cmdSaveImageEdit, opts_save_image_edit,
- info_save_image_edit, 0},
- {"schedinfo", cmdSchedinfo, opts_schedinfo, info_schedinfo, 0},
- {"screenshot", cmdScreenshot, opts_screenshot, info_screenshot, 0},
- {"setmaxmem", cmdSetmaxmem, opts_setmaxmem, info_setmaxmem, 0},
- {"setmem", cmdSetmem, opts_setmem, info_setmem, 0},
- {"setvcpus", cmdSetvcpus, opts_setvcpus, info_setvcpus, 0},
- {"shutdown", cmdShutdown, opts_shutdown, info_shutdown, 0},
- {"start", cmdStart, opts_start, info_start, 0},
- {"suspend", cmdSuspend, opts_suspend, info_suspend, 0},
- {"ttyconsole", cmdTTYConsole, opts_ttyconsole, info_ttyconsole, 0},
- {"undefine", cmdUndefine, opts_undefine, info_undefine, 0},
- {"update-device", cmdUpdateDevice, opts_update_device,
- info_update_device, 0},
- {"vcpucount", cmdVcpucount, opts_vcpucount, info_vcpucount, 0},
- {"vcpuinfo", cmdVcpuinfo, opts_vcpuinfo, info_vcpuinfo, 0},
- {"vcpupin", cmdVcpuPin, opts_vcpupin, info_vcpupin, 0},
- {"vncdisplay", cmdVNCDisplay, opts_vncdisplay, info_vncdisplay, 0},
- {NULL, NULL, NULL, NULL, 0}
-};
-
-static const vshCmdDef domMonitoringCmds[] = {
- {"domblkerror", cmdDomBlkError, opts_domblkerror, info_domblkerror, 0},
- {"domblkinfo", cmdDomblkinfo, opts_domblkinfo, info_domblkinfo, 0},
- {"domblklist", cmdDomblklist, opts_domblklist, info_domblklist, 0},
- {"domblkstat", cmdDomblkstat, opts_domblkstat, info_domblkstat, 0},
- {"domcontrol", cmdDomControl, opts_domcontrol, info_domcontrol, 0},
- {"domif-getlink", cmdDomIfGetLink, opts_domif_getlink, info_domif_getlink,
0},
- {"domiflist", cmdDomiflist, opts_domiflist, info_domiflist, 0},
- {"domifstat", cmdDomIfstat, opts_domifstat, info_domifstat, 0},
- {"dominfo", cmdDominfo, opts_dominfo, info_dominfo, 0},
- {"dommemstat", cmdDomMemStat, opts_dommemstat, info_dommemstat, 0},
- {"domstate", cmdDomstate, opts_domstate, info_domstate, 0},
- {"list", cmdList, opts_list, info_list, 0},
- {NULL, NULL, NULL, NULL, 0}
-};
+/* ---------------
+ * Utils for work with command definition
+ * ---------------
+ */
+static const char *
+vshCmddefGetInfo(const vshCmdDef * cmd, const char *name)
+{
+ const vshCmdInfo *info;
-static const vshCmdDef storagePoolCmds[] = {
- {"find-storage-pool-sources-as", cmdPoolDiscoverSourcesAs,
- opts_find_storage_pool_sources_as, info_find_storage_pool_sources_as, 0},
- {"find-storage-pool-sources", cmdPoolDiscoverSources,
- opts_find_storage_pool_sources, info_find_storage_pool_sources, 0},
- {"pool-autostart", cmdPoolAutostart, opts_pool_autostart,
- info_pool_autostart, 0},
- {"pool-build", cmdPoolBuild, opts_pool_build, info_pool_build, 0},
- {"pool-create-as", cmdPoolCreateAs, opts_pool_X_as, info_pool_create_as,
0},
- {"pool-create", cmdPoolCreate, opts_pool_create, info_pool_create, 0},
- {"pool-define-as", cmdPoolDefineAs, opts_pool_X_as, info_pool_define_as,
0},
- {"pool-define", cmdPoolDefine, opts_pool_define, info_pool_define, 0},
- {"pool-delete", cmdPoolDelete, opts_pool_delete, info_pool_delete, 0},
- {"pool-destroy", cmdPoolDestroy, opts_pool_destroy, info_pool_destroy,
0},
- {"pool-dumpxml", cmdPoolDumpXML, opts_pool_dumpxml, info_pool_dumpxml,
0},
- {"pool-edit", cmdPoolEdit, opts_pool_edit, info_pool_edit, 0},
- {"pool-info", cmdPoolInfo, opts_pool_info, info_pool_info, 0},
- {"pool-list", cmdPoolList, opts_pool_list, info_pool_list, 0},
- {"pool-name", cmdPoolName, opts_pool_name, info_pool_name, 0},
- {"pool-refresh", cmdPoolRefresh, opts_pool_refresh, info_pool_refresh,
0},
- {"pool-start", cmdPoolStart, opts_pool_start, info_pool_start, 0},
- {"pool-undefine", cmdPoolUndefine, opts_pool_undefine,
- info_pool_undefine, 0},
- {"pool-uuid", cmdPoolUuid, opts_pool_uuid, info_pool_uuid, 0},
- {NULL, NULL, NULL, NULL, 0}
-};
+ for (info = cmd->info; info && info->name; info++) {
+ if (STREQ(info->name, name))
+ return info->data;
+ }
+ return NULL;
+}
-static const vshCmdDef storageVolCmds[] = {
- {"vol-clone", cmdVolClone, opts_vol_clone, info_vol_clone, 0},
- {"vol-create-as", cmdVolCreateAs, opts_vol_create_as,
- info_vol_create_as, 0},
- {"vol-create", cmdVolCreate, opts_vol_create, info_vol_create, 0},
- {"vol-create-from", cmdVolCreateFrom, opts_vol_create_from,
- info_vol_create_from, 0},
- {"vol-delete", cmdVolDelete, opts_vol_delete, info_vol_delete, 0},
- {"vol-download", cmdVolDownload, opts_vol_download, info_vol_download,
0},
- {"vol-dumpxml", cmdVolDumpXML, opts_vol_dumpxml, info_vol_dumpxml, 0},
- {"vol-info", cmdVolInfo, opts_vol_info, info_vol_info, 0},
- {"vol-key", cmdVolKey, opts_vol_key, info_vol_key, 0},
- {"vol-list", cmdVolList, opts_vol_list, info_vol_list, 0},
- {"vol-name", cmdVolName, opts_vol_name, info_vol_name, 0},
- {"vol-path", cmdVolPath, opts_vol_path, info_vol_path, 0},
- {"vol-pool", cmdVolPool, opts_vol_pool, info_vol_pool, 0},
- {"vol-resize", cmdVolResize, opts_vol_resize, info_vol_resize, 0},
- {"vol-upload", cmdVolUpload, opts_vol_upload, info_vol_upload, 0},
- {"vol-wipe", cmdVolWipe, opts_vol_wipe, info_vol_wipe, 0},
- {NULL, NULL, NULL, NULL, 0}
-};
+/* Validate that the options associated with cmd can be parsed. */
+static int
+vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg,
+ uint32_t *opts_required)
+{
+ int i;
+ bool optional = false;
-static const vshCmdDef networkCmds[] = {
- {"net-autostart", cmdNetworkAutostart, opts_network_autostart,
- info_network_autostart, 0},
- {"net-create", cmdNetworkCreate, opts_network_create,
- info_network_create, 0},
- {"net-define", cmdNetworkDefine, opts_network_define,
- info_network_define, 0},
- {"net-destroy", cmdNetworkDestroy, opts_network_destroy,
- info_network_destroy, 0},
- {"net-dumpxml", cmdNetworkDumpXML, opts_network_dumpxml,
- info_network_dumpxml, 0},
- {"net-edit", cmdNetworkEdit, opts_network_edit, info_network_edit, 0},
- {"net-info", cmdNetworkInfo, opts_network_info, info_network_info, 0},
- {"net-list", cmdNetworkList, opts_network_list, info_network_list, 0},
- {"net-name", cmdNetworkName, opts_network_name, info_network_name, 0},
- {"net-start", cmdNetworkStart, opts_network_start, info_network_start,
0},
- {"net-undefine", cmdNetworkUndefine, opts_network_undefine,
- info_network_undefine, 0},
- {"net-uuid", cmdNetworkUuid, opts_network_uuid, info_network_uuid, 0},
- {NULL, NULL, NULL, NULL, 0}
-};
+ *opts_need_arg = 0;
+ *opts_required = 0;
-static const vshCmdDef nodedevCmds[] = {
- {"nodedev-create", cmdNodeDeviceCreate, opts_node_device_create,
- info_node_device_create, 0},
- {"nodedev-destroy", cmdNodeDeviceDestroy, opts_node_device_destroy,
- info_node_device_destroy, 0},
- {"nodedev-detach", cmdNodeDeviceDetach, opts_node_device_detach,
- info_node_device_detach, 0},
- {"nodedev-dettach", cmdNodeDeviceDetach, opts_node_device_detach,
- info_node_device_detach, VSH_CMD_FLAG_ALIAS},
- {"nodedev-dumpxml", cmdNodeDeviceDumpXML, opts_node_device_dumpxml,
- info_node_device_dumpxml, 0},
- {"nodedev-list", cmdNodeListDevices, opts_node_list_devices,
- info_node_list_devices, 0},
- {"nodedev-reattach", cmdNodeDeviceReAttach, opts_node_device_reattach,
- info_node_device_reattach, 0},
- {"nodedev-reset", cmdNodeDeviceReset, opts_node_device_reset,
- info_node_device_reset, 0},
- {NULL, NULL, NULL, NULL, 0}
-};
+ if (!cmd->opts)
+ return 0;
-static const vshCmdDef ifaceCmds[] = {
- {"iface-begin", cmdInterfaceBegin, opts_interface_begin,
- info_interface_begin, 0},
- {"iface-bridge", cmdInterfaceBridge, opts_interface_bridge,
- info_interface_bridge, 0},
- {"iface-commit", cmdInterfaceCommit, opts_interface_commit,
- info_interface_commit, 0},
- {"iface-define", cmdInterfaceDefine, opts_interface_define,
- info_interface_define, 0},
- {"iface-destroy", cmdInterfaceDestroy, opts_interface_destroy,
- info_interface_destroy, 0},
- {"iface-dumpxml", cmdInterfaceDumpXML, opts_interface_dumpxml,
- info_interface_dumpxml, 0},
- {"iface-edit", cmdInterfaceEdit, opts_interface_edit,
- info_interface_edit, 0},
- {"iface-list", cmdInterfaceList, opts_interface_list,
- info_interface_list, 0},
- {"iface-mac", cmdInterfaceMAC, opts_interface_mac,
- info_interface_mac, 0},
- {"iface-name", cmdInterfaceName, opts_interface_name,
- info_interface_name, 0},
- {"iface-rollback", cmdInterfaceRollback, opts_interface_rollback,
- info_interface_rollback, 0},
- {"iface-start", cmdInterfaceStart, opts_interface_start,
- info_interface_start, 0},
- {"iface-unbridge", cmdInterfaceUnbridge, opts_interface_unbridge,
- info_interface_unbridge, 0},
- {"iface-undefine", cmdInterfaceUndefine, opts_interface_undefine,
- info_interface_undefine, 0},
- {NULL, NULL, NULL, NULL, 0}
-};
-
-static const vshCmdDef nwfilterCmds[] = {
- {"nwfilter-define", cmdNWFilterDefine, opts_nwfilter_define,
- info_nwfilter_define, 0},
- {"nwfilter-dumpxml", cmdNWFilterDumpXML, opts_nwfilter_dumpxml,
- info_nwfilter_dumpxml, 0},
- {"nwfilter-edit", cmdNWFilterEdit, opts_nwfilter_edit,
- info_nwfilter_edit, 0},
- {"nwfilter-list", cmdNWFilterList, opts_nwfilter_list,
- info_nwfilter_list, 0},
- {"nwfilter-undefine", cmdNWFilterUndefine, opts_nwfilter_undefine,
- info_nwfilter_undefine, 0},
- {NULL, NULL, NULL, NULL, 0}
-};
-
-static const vshCmdDef secretCmds[] = {
- {"secret-define", cmdSecretDefine, opts_secret_define,
- info_secret_define, 0},
- {"secret-dumpxml", cmdSecretDumpXML, opts_secret_dumpxml,
- info_secret_dumpxml, 0},
- {"secret-get-value", cmdSecretGetValue, opts_secret_get_value,
- info_secret_get_value, 0},
- {"secret-list", cmdSecretList, NULL, info_secret_list, 0},
- {"secret-set-value", cmdSecretSetValue, opts_secret_set_value,
- info_secret_set_value, 0},
- {"secret-undefine", cmdSecretUndefine, opts_secret_undefine,
- info_secret_undefine, 0},
- {NULL, NULL, NULL, NULL, 0}
-};
-
-static const vshCmdDef virshCmds[] = {
- {"cd", cmdCd, opts_cd, info_cd, VSH_CMD_FLAG_NOCONNECT},
- {"echo", cmdEcho, opts_echo, info_echo, VSH_CMD_FLAG_NOCONNECT},
- {"exit", cmdQuit, NULL, info_quit, VSH_CMD_FLAG_NOCONNECT},
- {"help", cmdHelp, opts_help, info_help, VSH_CMD_FLAG_NOCONNECT},
- {"pwd", cmdPwd, NULL, info_pwd, VSH_CMD_FLAG_NOCONNECT},
- {"quit", cmdQuit, NULL, info_quit, VSH_CMD_FLAG_NOCONNECT},
- {NULL, NULL, NULL, NULL, 0}
-};
-
-static const vshCmdDef snapshotCmds[] = {
- {"snapshot-create", cmdSnapshotCreate, opts_snapshot_create,
- info_snapshot_create, 0},
- {"snapshot-create-as", cmdSnapshotCreateAs, opts_snapshot_create_as,
- info_snapshot_create_as, 0},
- {"snapshot-current", cmdSnapshotCurrent, opts_snapshot_current,
- info_snapshot_current, 0},
- {"snapshot-delete", cmdSnapshotDelete, opts_snapshot_delete,
- info_snapshot_delete, 0},
- {"snapshot-dumpxml", cmdSnapshotDumpXML, opts_snapshot_dumpxml,
- info_snapshot_dumpxml, 0},
- {"snapshot-edit", cmdSnapshotEdit, opts_snapshot_edit,
- info_snapshot_edit, 0},
- {"snapshot-info", cmdSnapshotInfo, opts_snapshot_info,
- info_snapshot_info, 0},
- {"snapshot-list", cmdSnapshotList, opts_snapshot_list,
- info_snapshot_list, 0},
- {"snapshot-parent", cmdSnapshotParent, opts_snapshot_parent,
- info_snapshot_parent, 0},
- {"snapshot-revert", cmdDomainSnapshotRevert, opts_snapshot_revert,
- info_snapshot_revert, 0},
- {NULL, NULL, NULL, NULL, 0}
-};
-
-static const vshCmdDef hostAndHypervisorCmds[] = {
- {"capabilities", cmdCapabilities, NULL, info_capabilities, 0},
- {"connect", cmdConnect, opts_connect, info_connect,
- VSH_CMD_FLAG_NOCONNECT},
- {"freecell", cmdFreecell, opts_freecell, info_freecell, 0},
- {"hostname", cmdHostname, NULL, info_hostname, 0},
- {"nodecpustats", cmdNodeCpuStats, opts_node_cpustats, info_nodecpustats,
0},
- {"nodeinfo", cmdNodeinfo, NULL, info_nodeinfo, 0},
- {"nodememstats", cmdNodeMemStats, opts_node_memstats, info_nodememstats,
0},
- {"nodesuspend", cmdNodeSuspend, opts_node_suspend, info_nodesuspend, 0},
- {"qemu-attach", cmdQemuAttach, opts_qemu_attach, info_qemu_attach, 0},
- {"qemu-monitor-command", cmdQemuMonitorCommand,
opts_qemu_monitor_command,
- info_qemu_monitor_command, 0},
- {"sysinfo", cmdSysinfo, NULL, info_sysinfo, 0},
- {"uri", cmdURI, NULL, info_uri, 0},
- {"version", cmdVersion, opts_version, info_version, 0},
- {NULL, NULL, NULL, NULL, 0}
-};
-
-static const vshCmdGrp cmdGroups[] = {
- {VSH_CMD_GRP_DOM_MANAGEMENT, "domain", domManagementCmds},
- {VSH_CMD_GRP_DOM_MONITORING, "monitor", domMonitoringCmds},
- {VSH_CMD_GRP_HOST_AND_HV, "host", hostAndHypervisorCmds},
- {VSH_CMD_GRP_IFACE, "interface", ifaceCmds},
- {VSH_CMD_GRP_NWFILTER, "filter", nwfilterCmds},
- {VSH_CMD_GRP_NETWORK, "network", networkCmds},
- {VSH_CMD_GRP_NODEDEV, "nodedev", nodedevCmds},
- {VSH_CMD_GRP_SECRET, "secret", secretCmds},
- {VSH_CMD_GRP_SNAPSHOT, "snapshot", snapshotCmds},
- {VSH_CMD_GRP_STORAGE_POOL, "pool", storagePoolCmds},
- {VSH_CMD_GRP_STORAGE_VOL, "volume", storageVolCmds},
- {VSH_CMD_GRP_VIRSH, "virsh", virshCmds},
- {NULL, NULL, NULL}
-};
-
-
-/* ---------------
- * Utils for work with command definition
- * ---------------
- */
-static const char *
-vshCmddefGetInfo(const vshCmdDef * cmd, const char *name)
-{
- const vshCmdInfo *info;
-
- for (info = cmd->info; info && info->name; info++) {
- if (STREQ(info->name, name))
- return info->data;
- }
- return NULL;
-}
-
-/* Validate that the options associated with cmd can be parsed. */
-static int
-vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg,
- uint32_t *opts_required)
-{
- int i;
- bool optional = false;
-
- *opts_need_arg = 0;
- *opts_required = 0;
-
- if (!cmd->opts)
- return 0;
-
- for (i = 0; cmd->opts[i].name; i++) {
- const vshCmdOptDef *opt = &cmd->opts[i];
+ for (i = 0; cmd->opts[i].name; i++) {
+ const vshCmdOptDef *opt = &cmd->opts[i];
if (i > 31)
return -1; /* too many options */
@@ -20923,135 +20590,467 @@ vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
#endif
vshPrint(ctl, "\n");
- vshPrint(ctl, "%s", _(" Miscellaneous:"));
-#ifdef WITH_NODE_DEVICES
- vshPrint(ctl, " Nodedev");
-#endif
-#ifdef WITH_SECDRIVER_APPARMOR
- vshPrint(ctl, " AppArmor");
-#endif
-#ifdef WITH_SECDRIVER_SELINUX
- vshPrint(ctl, " SELinux");
-#endif
-#ifdef WITH_SECRETS
- vshPrint(ctl, " Secrets");
-#endif
-#ifdef ENABLE_DEBUG
- vshPrint(ctl, " Debug");
-#endif
-#ifdef WITH_DTRACE_PROBES
- vshPrint(ctl, " DTrace");
-#endif
-#ifdef USE_READLINE
- vshPrint(ctl, " Readline");
-#endif
-#ifdef WITH_DRIVER_MODULES
- vshPrint(ctl, " Modular");
-#endif
- vshPrint(ctl, "\n");
-}
+ vshPrint(ctl, "%s", _(" Miscellaneous:"));
+#ifdef WITH_NODE_DEVICES
+ vshPrint(ctl, " Nodedev");
+#endif
+#ifdef WITH_SECDRIVER_APPARMOR
+ vshPrint(ctl, " AppArmor");
+#endif
+#ifdef WITH_SECDRIVER_SELINUX
+ vshPrint(ctl, " SELinux");
+#endif
+#ifdef WITH_SECRETS
+ vshPrint(ctl, " Secrets");
+#endif
+#ifdef ENABLE_DEBUG
+ vshPrint(ctl, " Debug");
+#endif
+#ifdef WITH_DTRACE_PROBES
+ vshPrint(ctl, " DTrace");
+#endif
+#ifdef USE_READLINE
+ vshPrint(ctl, " Readline");
+#endif
+#ifdef WITH_DRIVER_MODULES
+ vshPrint(ctl, " Modular");
+#endif
+ vshPrint(ctl, "\n");
+}
+
+static bool
+vshAllowedEscapeChar(char c)
+{
+ /* Allowed escape characters:
+ * a-z A-Z @ [ \ ] ^ _
+ */
+ return ('a' <= c && c <= 'z') ||
+ ('@' <= c && c <= '_');
+}
+
+/*
+ * argv[]: virsh [options] [command]
+ *
+ */
+static bool
+vshParseArgv(vshControl *ctl, int argc, char **argv)
+{
+ int arg, len;
+ struct option opt[] = {
+ {"debug", required_argument, NULL, 'd'},
+ {"help", no_argument, NULL, 'h'},
+ {"quiet", no_argument, NULL, 'q'},
+ {"timing", no_argument, NULL, 't'},
+ {"version", optional_argument, NULL, 'v'},
+ {"connect", required_argument, NULL, 'c'},
+ {"readonly", no_argument, NULL, 'r'},
+ {"log", required_argument, NULL, 'l'},
+ {"escape", required_argument, NULL, 'e'},
+ {NULL, 0, NULL, 0}
+ };
+
+ /* Standard (non-command) options. The leading + ensures that no
+ * argument reordering takes place, so that command options are
+ * not confused with top-level virsh options. */
+ while ((arg = getopt_long(argc, argv, "+d:hqtc:vVrl:e:", opt, NULL)) !=
-1) {
+ switch (arg) {
+ case 'd':
+ if (virStrToLong_i(optarg, NULL, 10, &ctl->debug) < 0) {
+ vshError(ctl, "%s", _("option -d takes a numeric
argument"));
+ exit(EXIT_FAILURE);
+ }
+ break;
+ case 'h':
+ vshUsage();
+ exit(EXIT_SUCCESS);
+ break;
+ case 'q':
+ ctl->quiet = true;
+ break;
+ case 't':
+ ctl->timing = true;
+ break;
+ case 'c':
+ ctl->name = vshStrdup(ctl, optarg);
+ break;
+ case 'v':
+ if (STRNEQ_NULLABLE(optarg, "long")) {
+ puts(VERSION);
+ exit(EXIT_SUCCESS);
+ }
+ /* fall through */
+ case 'V':
+ vshShowVersion(ctl);
+ exit(EXIT_SUCCESS);
+ case 'r':
+ ctl->readonly = true;
+ break;
+ case 'l':
+ ctl->logfile = vshStrdup(ctl, optarg);
+ break;
+ case 'e':
+ len = strlen(optarg);
+
+ if ((len == 2 && *optarg == '^' &&
+ vshAllowedEscapeChar(optarg[1])) ||
+ (len == 1 && *optarg != '^')) {
+ ctl->escapeChar = optarg;
+ } else {
+ vshError(ctl, _("Invalid string '%s' for escape
sequence"),
+ optarg);
+ exit(EXIT_FAILURE);
+ }
+ break;
+ default:
+ vshError(ctl, _("unsupported option '-%c'. See --help."),
arg);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ if (argc > optind) {
+ /* parse command */
+ ctl->imode = false;
+ if (argc - optind == 1) {
+ vshDebug(ctl, VSH_ERR_INFO, "commands: \"%s\"\n",
argv[optind]);
+ return vshCommandStringParse(ctl, argv[optind]);
+ } else {
+ return vshCommandArgvParse(ctl, argc - optind, argv + optind);
+ }
+ }
+ return true;
+}
+
+static const vshCmdDef domManagementCmds[] = {
+ {"attach-device", cmdAttachDevice, opts_attach_device,
+ info_attach_device, 0},
+ {"attach-disk", cmdAttachDisk, opts_attach_disk,
+ info_attach_disk, 0},
+ {"attach-interface", cmdAttachInterface, opts_attach_interface,
+ info_attach_interface, 0},
+ {"autostart", cmdAutostart, opts_autostart, info_autostart, 0},
+ {"blkdeviotune", cmdBlkdeviotune, opts_blkdeviotune, info_blkdeviotune,
0},
+ {"blkiotune", cmdBlkiotune, opts_blkiotune, info_blkiotune, 0},
+ {"blockcopy", cmdBlockCopy, opts_block_copy, info_block_copy, 0},
+ {"blockjob", cmdBlockJob, opts_block_job, info_block_job, 0},
+ {"blockpull", cmdBlockPull, opts_block_pull, info_block_pull, 0},
+ {"blockresize", cmdBlockResize, opts_block_resize, info_block_resize, 0},
+ {"change-media", cmdChangeMedia, opts_change_media, info_change_media,
0},
+#ifndef WIN32
+ {"console", cmdConsole, opts_console, info_console, 0},
+#endif
+ {"cpu-baseline", cmdCPUBaseline, opts_cpu_baseline, info_cpu_baseline,
0},
+ {"cpu-compare", cmdCPUCompare, opts_cpu_compare, info_cpu_compare, 0},
+ {"cpu-stats", cmdCPUStats, opts_cpu_stats, info_cpu_stats, 0},
+ {"create", cmdCreate, opts_create, info_create, 0},
+ {"define", cmdDefine, opts_define, info_define, 0},
+ {"desc", cmdDesc, opts_desc, info_desc, 0},
+ {"destroy", cmdDestroy, opts_destroy, info_destroy, 0},
+ {"detach-device", cmdDetachDevice, opts_detach_device,
+ info_detach_device, 0},
+ {"detach-disk", cmdDetachDisk, opts_detach_disk, info_detach_disk, 0},
+ {"detach-interface", cmdDetachInterface, opts_detach_interface,
+ info_detach_interface, 0},
+ {"domdisplay", cmdDomDisplay, opts_domdisplay, info_domdisplay, 0},
+ {"domhostname", cmdDomHostname, opts_domhostname, info_domhostname, 0},
+ {"domid", cmdDomid, opts_domid, info_domid, 0},
+ {"domif-setlink", cmdDomIfSetLink, opts_domif_setlink, info_domif_setlink,
0},
+ {"domiftune", cmdDomIftune, opts_domiftune, info_domiftune, 0},
+ {"domjobabort", cmdDomjobabort, opts_domjobabort, info_domjobabort, 0},
+ {"domjobinfo", cmdDomjobinfo, opts_domjobinfo, info_domjobinfo, 0},
+ {"domname", cmdDomname, opts_domname, info_domname, 0},
+ {"dompmsuspend", cmdDomPMSuspend,
+ opts_dom_pm_suspend, info_dom_pm_suspend, 0},
+ {"dompmwakeup", cmdDomPMWakeup,
+ opts_dom_pm_wakeup, info_dom_pm_wakeup, 0},
+ {"domuuid", cmdDomuuid, opts_domuuid, info_domuuid, 0},
+ {"domxml-from-native", cmdDomXMLFromNative, opts_domxmlfromnative,
+ info_domxmlfromnative, 0},
+ {"domxml-to-native", cmdDomXMLToNative, opts_domxmltonative,
+ info_domxmltonative, 0},
+ {"dump", cmdDump, opts_dump, info_dump, 0},
+ {"dumpxml", cmdDumpXML, opts_dumpxml, info_dumpxml, 0},
+ {"edit", cmdEdit, opts_edit, info_edit, 0},
+ {"inject-nmi", cmdInjectNMI, opts_inject_nmi, info_inject_nmi, 0},
+ {"send-key", cmdSendKey, opts_send_key, info_send_key, 0},
+ {"managedsave", cmdManagedSave, opts_managedsave, info_managedsave, 0},
+ {"managedsave-remove", cmdManagedSaveRemove, opts_managedsaveremove,
+ info_managedsaveremove, 0},
+ {"maxvcpus", cmdMaxvcpus, opts_maxvcpus, info_maxvcpus, 0},
+ {"memtune", cmdMemtune, opts_memtune, info_memtune, 0},
+ {"migrate", cmdMigrate, opts_migrate, info_migrate, 0},
+ {"migrate-setmaxdowntime", cmdMigrateSetMaxDowntime,
+ opts_migrate_setmaxdowntime, info_migrate_setmaxdowntime, 0},
+ {"migrate-setspeed", cmdMigrateSetMaxSpeed,
+ opts_migrate_setspeed, info_migrate_setspeed, 0},
+ {"migrate-getspeed", cmdMigrateGetMaxSpeed,
+ opts_migrate_getspeed, info_migrate_getspeed, 0},
+ {"numatune", cmdNumatune, opts_numatune, info_numatune, 0},
+ {"reboot", cmdReboot, opts_reboot, info_reboot, 0},
+ {"reset", cmdReset, opts_reset, info_reset, 0},
+ {"restore", cmdRestore, opts_restore, info_restore, 0},
+ {"resume", cmdResume, opts_resume, info_resume, 0},
+ {"save", cmdSave, opts_save, info_save, 0},
+ {"save-image-define", cmdSaveImageDefine, opts_save_image_define,
+ info_save_image_define, 0},
+ {"save-image-dumpxml", cmdSaveImageDumpxml, opts_save_image_dumpxml,
+ info_save_image_dumpxml, 0},
+ {"save-image-edit", cmdSaveImageEdit, opts_save_image_edit,
+ info_save_image_edit, 0},
+ {"schedinfo", cmdSchedinfo, opts_schedinfo, info_schedinfo, 0},
+ {"screenshot", cmdScreenshot, opts_screenshot, info_screenshot, 0},
+ {"setmaxmem", cmdSetmaxmem, opts_setmaxmem, info_setmaxmem, 0},
+ {"setmem", cmdSetmem, opts_setmem, info_setmem, 0},
+ {"setvcpus", cmdSetvcpus, opts_setvcpus, info_setvcpus, 0},
+ {"shutdown", cmdShutdown, opts_shutdown, info_shutdown, 0},
+ {"start", cmdStart, opts_start, info_start, 0},
+ {"suspend", cmdSuspend, opts_suspend, info_suspend, 0},
+ {"ttyconsole", cmdTTYConsole, opts_ttyconsole, info_ttyconsole, 0},
+ {"undefine", cmdUndefine, opts_undefine, info_undefine, 0},
+ {"update-device", cmdUpdateDevice, opts_update_device,
+ info_update_device, 0},
+ {"vcpucount", cmdVcpucount, opts_vcpucount, info_vcpucount, 0},
+ {"vcpuinfo", cmdVcpuinfo, opts_vcpuinfo, info_vcpuinfo, 0},
+ {"vcpupin", cmdVcpuPin, opts_vcpupin, info_vcpupin, 0},
+ {"vncdisplay", cmdVNCDisplay, opts_vncdisplay, info_vncdisplay, 0},
+ {NULL, NULL, NULL, NULL, 0}
+};
+
+static const vshCmdDef domMonitoringCmds[] = {
+ {"domblkerror", cmdDomBlkError, opts_domblkerror, info_domblkerror, 0},
+ {"domblkinfo", cmdDomblkinfo, opts_domblkinfo, info_domblkinfo, 0},
+ {"domblklist", cmdDomblklist, opts_domblklist, info_domblklist, 0},
+ {"domblkstat", cmdDomblkstat, opts_domblkstat, info_domblkstat, 0},
+ {"domcontrol", cmdDomControl, opts_domcontrol, info_domcontrol, 0},
+ {"domif-getlink", cmdDomIfGetLink, opts_domif_getlink, info_domif_getlink,
0},
+ {"domiflist", cmdDomiflist, opts_domiflist, info_domiflist, 0},
+ {"domifstat", cmdDomIfstat, opts_domifstat, info_domifstat, 0},
+ {"dominfo", cmdDominfo, opts_dominfo, info_dominfo, 0},
+ {"dommemstat", cmdDomMemStat, opts_dommemstat, info_dommemstat, 0},
+ {"domstate", cmdDomstate, opts_domstate, info_domstate, 0},
+ {"list", cmdList, opts_list, info_list, 0},
+ {NULL, NULL, NULL, NULL, 0}
+};
+
+static const vshCmdDef storagePoolCmds[] = {
+ {"find-storage-pool-sources-as", cmdPoolDiscoverSourcesAs,
+ opts_find_storage_pool_sources_as, info_find_storage_pool_sources_as, 0},
+ {"find-storage-pool-sources", cmdPoolDiscoverSources,
+ opts_find_storage_pool_sources, info_find_storage_pool_sources, 0},
+ {"pool-autostart", cmdPoolAutostart, opts_pool_autostart,
+ info_pool_autostart, 0},
+ {"pool-build", cmdPoolBuild, opts_pool_build, info_pool_build, 0},
+ {"pool-create-as", cmdPoolCreateAs, opts_pool_X_as, info_pool_create_as,
0},
+ {"pool-create", cmdPoolCreate, opts_pool_create, info_pool_create, 0},
+ {"pool-define-as", cmdPoolDefineAs, opts_pool_X_as, info_pool_define_as,
0},
+ {"pool-define", cmdPoolDefine, opts_pool_define, info_pool_define, 0},
+ {"pool-delete", cmdPoolDelete, opts_pool_delete, info_pool_delete, 0},
+ {"pool-destroy", cmdPoolDestroy, opts_pool_destroy, info_pool_destroy,
0},
+ {"pool-dumpxml", cmdPoolDumpXML, opts_pool_dumpxml, info_pool_dumpxml,
0},
+ {"pool-edit", cmdPoolEdit, opts_pool_edit, info_pool_edit, 0},
+ {"pool-info", cmdPoolInfo, opts_pool_info, info_pool_info, 0},
+ {"pool-list", cmdPoolList, opts_pool_list, info_pool_list, 0},
+ {"pool-name", cmdPoolName, opts_pool_name, info_pool_name, 0},
+ {"pool-refresh", cmdPoolRefresh, opts_pool_refresh, info_pool_refresh,
0},
+ {"pool-start", cmdPoolStart, opts_pool_start, info_pool_start, 0},
+ {"pool-undefine", cmdPoolUndefine, opts_pool_undefine,
+ info_pool_undefine, 0},
+ {"pool-uuid", cmdPoolUuid, opts_pool_uuid, info_pool_uuid, 0},
+ {NULL, NULL, NULL, NULL, 0}
+};
+
+static const vshCmdDef storageVolCmds[] = {
+ {"vol-clone", cmdVolClone, opts_vol_clone, info_vol_clone, 0},
+ {"vol-create-as", cmdVolCreateAs, opts_vol_create_as,
+ info_vol_create_as, 0},
+ {"vol-create", cmdVolCreate, opts_vol_create, info_vol_create, 0},
+ {"vol-create-from", cmdVolCreateFrom, opts_vol_create_from,
+ info_vol_create_from, 0},
+ {"vol-delete", cmdVolDelete, opts_vol_delete, info_vol_delete, 0},
+ {"vol-download", cmdVolDownload, opts_vol_download, info_vol_download,
0},
+ {"vol-dumpxml", cmdVolDumpXML, opts_vol_dumpxml, info_vol_dumpxml, 0},
+ {"vol-info", cmdVolInfo, opts_vol_info, info_vol_info, 0},
+ {"vol-key", cmdVolKey, opts_vol_key, info_vol_key, 0},
+ {"vol-list", cmdVolList, opts_vol_list, info_vol_list, 0},
+ {"vol-name", cmdVolName, opts_vol_name, info_vol_name, 0},
+ {"vol-path", cmdVolPath, opts_vol_path, info_vol_path, 0},
+ {"vol-pool", cmdVolPool, opts_vol_pool, info_vol_pool, 0},
+ {"vol-resize", cmdVolResize, opts_vol_resize, info_vol_resize, 0},
+ {"vol-upload", cmdVolUpload, opts_vol_upload, info_vol_upload, 0},
+ {"vol-wipe", cmdVolWipe, opts_vol_wipe, info_vol_wipe, 0},
+ {NULL, NULL, NULL, NULL, 0}
+};
+
+static const vshCmdDef networkCmds[] = {
+ {"net-autostart", cmdNetworkAutostart, opts_network_autostart,
+ info_network_autostart, 0},
+ {"net-create", cmdNetworkCreate, opts_network_create,
+ info_network_create, 0},
+ {"net-define", cmdNetworkDefine, opts_network_define,
+ info_network_define, 0},
+ {"net-destroy", cmdNetworkDestroy, opts_network_destroy,
+ info_network_destroy, 0},
+ {"net-dumpxml", cmdNetworkDumpXML, opts_network_dumpxml,
+ info_network_dumpxml, 0},
+ {"net-edit", cmdNetworkEdit, opts_network_edit, info_network_edit, 0},
+ {"net-info", cmdNetworkInfo, opts_network_info, info_network_info, 0},
+ {"net-list", cmdNetworkList, opts_network_list, info_network_list, 0},
+ {"net-name", cmdNetworkName, opts_network_name, info_network_name, 0},
+ {"net-start", cmdNetworkStart, opts_network_start, info_network_start,
0},
+ {"net-undefine", cmdNetworkUndefine, opts_network_undefine,
+ info_network_undefine, 0},
+ {"net-uuid", cmdNetworkUuid, opts_network_uuid, info_network_uuid, 0},
+ {NULL, NULL, NULL, NULL, 0}
+};
+
+static const vshCmdDef nodedevCmds[] = {
+ {"nodedev-create", cmdNodeDeviceCreate, opts_node_device_create,
+ info_node_device_create, 0},
+ {"nodedev-destroy", cmdNodeDeviceDestroy, opts_node_device_destroy,
+ info_node_device_destroy, 0},
+ {"nodedev-detach", cmdNodeDeviceDetach, opts_node_device_detach,
+ info_node_device_detach, 0},
+ {"nodedev-dettach", cmdNodeDeviceDetach, opts_node_device_detach,
+ info_node_device_detach, VSH_CMD_FLAG_ALIAS},
+ {"nodedev-dumpxml", cmdNodeDeviceDumpXML, opts_node_device_dumpxml,
+ info_node_device_dumpxml, 0},
+ {"nodedev-list", cmdNodeListDevices, opts_node_list_devices,
+ info_node_list_devices, 0},
+ {"nodedev-reattach", cmdNodeDeviceReAttach, opts_node_device_reattach,
+ info_node_device_reattach, 0},
+ {"nodedev-reset", cmdNodeDeviceReset, opts_node_device_reset,
+ info_node_device_reset, 0},
+ {NULL, NULL, NULL, NULL, 0}
+};
+
+static const vshCmdDef ifaceCmds[] = {
+ {"iface-begin", cmdInterfaceBegin, opts_interface_begin,
+ info_interface_begin, 0},
+ {"iface-bridge", cmdInterfaceBridge, opts_interface_bridge,
+ info_interface_bridge, 0},
+ {"iface-commit", cmdInterfaceCommit, opts_interface_commit,
+ info_interface_commit, 0},
+ {"iface-define", cmdInterfaceDefine, opts_interface_define,
+ info_interface_define, 0},
+ {"iface-destroy", cmdInterfaceDestroy, opts_interface_destroy,
+ info_interface_destroy, 0},
+ {"iface-dumpxml", cmdInterfaceDumpXML, opts_interface_dumpxml,
+ info_interface_dumpxml, 0},
+ {"iface-edit", cmdInterfaceEdit, opts_interface_edit,
+ info_interface_edit, 0},
+ {"iface-list", cmdInterfaceList, opts_interface_list,
+ info_interface_list, 0},
+ {"iface-mac", cmdInterfaceMAC, opts_interface_mac,
+ info_interface_mac, 0},
+ {"iface-name", cmdInterfaceName, opts_interface_name,
+ info_interface_name, 0},
+ {"iface-rollback", cmdInterfaceRollback, opts_interface_rollback,
+ info_interface_rollback, 0},
+ {"iface-start", cmdInterfaceStart, opts_interface_start,
+ info_interface_start, 0},
+ {"iface-unbridge", cmdInterfaceUnbridge, opts_interface_unbridge,
+ info_interface_unbridge, 0},
+ {"iface-undefine", cmdInterfaceUndefine, opts_interface_undefine,
+ info_interface_undefine, 0},
+ {NULL, NULL, NULL, NULL, 0}
+};
-static bool
-vshAllowedEscapeChar(char c)
-{
- /* Allowed escape characters:
- * a-z A-Z @ [ \ ] ^ _
- */
- return ('a' <= c && c <= 'z') ||
- ('@' <= c && c <= '_');
-}
+static const vshCmdDef nwfilterCmds[] = {
+ {"nwfilter-define", cmdNWFilterDefine, opts_nwfilter_define,
+ info_nwfilter_define, 0},
+ {"nwfilter-dumpxml", cmdNWFilterDumpXML, opts_nwfilter_dumpxml,
+ info_nwfilter_dumpxml, 0},
+ {"nwfilter-edit", cmdNWFilterEdit, opts_nwfilter_edit,
+ info_nwfilter_edit, 0},
+ {"nwfilter-list", cmdNWFilterList, opts_nwfilter_list,
+ info_nwfilter_list, 0},
+ {"nwfilter-undefine", cmdNWFilterUndefine, opts_nwfilter_undefine,
+ info_nwfilter_undefine, 0},
+ {NULL, NULL, NULL, NULL, 0}
+};
-/*
- * argv[]: virsh [options] [command]
- *
- */
-static bool
-vshParseArgv(vshControl *ctl, int argc, char **argv)
-{
- int arg, len;
- struct option opt[] = {
- {"debug", required_argument, NULL, 'd'},
- {"help", no_argument, NULL, 'h'},
- {"quiet", no_argument, NULL, 'q'},
- {"timing", no_argument, NULL, 't'},
- {"version", optional_argument, NULL, 'v'},
- {"connect", required_argument, NULL, 'c'},
- {"readonly", no_argument, NULL, 'r'},
- {"log", required_argument, NULL, 'l'},
- {"escape", required_argument, NULL, 'e'},
- {NULL, 0, NULL, 0}
- };
+static const vshCmdDef secretCmds[] = {
+ {"secret-define", cmdSecretDefine, opts_secret_define,
+ info_secret_define, 0},
+ {"secret-dumpxml", cmdSecretDumpXML, opts_secret_dumpxml,
+ info_secret_dumpxml, 0},
+ {"secret-get-value", cmdSecretGetValue, opts_secret_get_value,
+ info_secret_get_value, 0},
+ {"secret-list", cmdSecretList, NULL, info_secret_list, 0},
+ {"secret-set-value", cmdSecretSetValue, opts_secret_set_value,
+ info_secret_set_value, 0},
+ {"secret-undefine", cmdSecretUndefine, opts_secret_undefine,
+ info_secret_undefine, 0},
+ {NULL, NULL, NULL, NULL, 0}
+};
- /* Standard (non-command) options. The leading + ensures that no
- * argument reordering takes place, so that command options are
- * not confused with top-level virsh options. */
- while ((arg = getopt_long(argc, argv, "+d:hqtc:vVrl:e:", opt, NULL)) !=
-1) {
- switch (arg) {
- case 'd':
- if (virStrToLong_i(optarg, NULL, 10, &ctl->debug) < 0) {
- vshError(ctl, "%s", _("option -d takes a numeric
argument"));
- exit(EXIT_FAILURE);
- }
- break;
- case 'h':
- vshUsage();
- exit(EXIT_SUCCESS);
- break;
- case 'q':
- ctl->quiet = true;
- break;
- case 't':
- ctl->timing = true;
- break;
- case 'c':
- ctl->name = vshStrdup(ctl, optarg);
- break;
- case 'v':
- if (STRNEQ_NULLABLE(optarg, "long")) {
- puts(VERSION);
- exit(EXIT_SUCCESS);
- }
- /* fall through */
- case 'V':
- vshShowVersion(ctl);
- exit(EXIT_SUCCESS);
- case 'r':
- ctl->readonly = true;
- break;
- case 'l':
- ctl->logfile = vshStrdup(ctl, optarg);
- break;
- case 'e':
- len = strlen(optarg);
+static const vshCmdDef virshCmds[] = {
+ {"cd", cmdCd, opts_cd, info_cd, VSH_CMD_FLAG_NOCONNECT},
+ {"echo", cmdEcho, opts_echo, info_echo, VSH_CMD_FLAG_NOCONNECT},
+ {"exit", cmdQuit, NULL, info_quit, VSH_CMD_FLAG_NOCONNECT},
+ {"help", cmdHelp, opts_help, info_help, VSH_CMD_FLAG_NOCONNECT},
+ {"pwd", cmdPwd, NULL, info_pwd, VSH_CMD_FLAG_NOCONNECT},
+ {"quit", cmdQuit, NULL, info_quit, VSH_CMD_FLAG_NOCONNECT},
+ {NULL, NULL, NULL, NULL, 0}
+};
- if ((len == 2 && *optarg == '^' &&
- vshAllowedEscapeChar(optarg[1])) ||
- (len == 1 && *optarg != '^')) {
- ctl->escapeChar = optarg;
- } else {
- vshError(ctl, _("Invalid string '%s' for escape
sequence"),
- optarg);
- exit(EXIT_FAILURE);
- }
- break;
- default:
- vshError(ctl, _("unsupported option '-%c'. See --help."),
arg);
- exit(EXIT_FAILURE);
- }
- }
+static const vshCmdDef snapshotCmds[] = {
+ {"snapshot-create", cmdSnapshotCreate, opts_snapshot_create,
+ info_snapshot_create, 0},
+ {"snapshot-create-as", cmdSnapshotCreateAs, opts_snapshot_create_as,
+ info_snapshot_create_as, 0},
+ {"snapshot-current", cmdSnapshotCurrent, opts_snapshot_current,
+ info_snapshot_current, 0},
+ {"snapshot-delete", cmdSnapshotDelete, opts_snapshot_delete,
+ info_snapshot_delete, 0},
+ {"snapshot-dumpxml", cmdSnapshotDumpXML, opts_snapshot_dumpxml,
+ info_snapshot_dumpxml, 0},
+ {"snapshot-edit", cmdSnapshotEdit, opts_snapshot_edit,
+ info_snapshot_edit, 0},
+ {"snapshot-info", cmdSnapshotInfo, opts_snapshot_info,
+ info_snapshot_info, 0},
+ {"snapshot-list", cmdSnapshotList, opts_snapshot_list,
+ info_snapshot_list, 0},
+ {"snapshot-parent", cmdSnapshotParent, opts_snapshot_parent,
+ info_snapshot_parent, 0},
+ {"snapshot-revert", cmdDomainSnapshotRevert, opts_snapshot_revert,
+ info_snapshot_revert, 0},
+ {NULL, NULL, NULL, NULL, 0}
+};
- if (argc > optind) {
- /* parse command */
- ctl->imode = false;
- if (argc - optind == 1) {
- vshDebug(ctl, VSH_ERR_INFO, "commands: \"%s\"\n",
argv[optind]);
- return vshCommandStringParse(ctl, argv[optind]);
- } else {
- return vshCommandArgvParse(ctl, argc - optind, argv + optind);
- }
- }
- return true;
-}
+static const vshCmdDef hostAndHypervisorCmds[] = {
+ {"capabilities", cmdCapabilities, NULL, info_capabilities, 0},
+ {"connect", cmdConnect, opts_connect, info_connect,
+ VSH_CMD_FLAG_NOCONNECT},
+ {"freecell", cmdFreecell, opts_freecell, info_freecell, 0},
+ {"hostname", cmdHostname, NULL, info_hostname, 0},
+ {"nodecpustats", cmdNodeCpuStats, opts_node_cpustats, info_nodecpustats,
0},
+ {"nodeinfo", cmdNodeinfo, NULL, info_nodeinfo, 0},
+ {"nodememstats", cmdNodeMemStats, opts_node_memstats, info_nodememstats,
0},
+ {"nodesuspend", cmdNodeSuspend, opts_node_suspend, info_nodesuspend, 0},
+ {"qemu-attach", cmdQemuAttach, opts_qemu_attach, info_qemu_attach, 0},
+ {"qemu-monitor-command", cmdQemuMonitorCommand,
opts_qemu_monitor_command,
+ info_qemu_monitor_command, 0},
+ {"sysinfo", cmdSysinfo, NULL, info_sysinfo, 0},
+ {"uri", cmdURI, NULL, info_uri, 0},
+ {"version", cmdVersion, opts_version, info_version, 0},
+ {NULL, NULL, NULL, NULL, 0}
+};
+
+static const vshCmdGrp cmdGroups[] = {
+ {VSH_CMD_GRP_DOM_MANAGEMENT, "domain", domManagementCmds},
+ {VSH_CMD_GRP_DOM_MONITORING, "monitor", domMonitoringCmds},
+ {VSH_CMD_GRP_HOST_AND_HV, "host", hostAndHypervisorCmds},
+ {VSH_CMD_GRP_IFACE, "interface", ifaceCmds},
+ {VSH_CMD_GRP_NWFILTER, "filter", nwfilterCmds},
+ {VSH_CMD_GRP_NETWORK, "network", networkCmds},
+ {VSH_CMD_GRP_NODEDEV, "nodedev", nodedevCmds},
+ {VSH_CMD_GRP_SECRET, "secret", secretCmds},
+ {VSH_CMD_GRP_SNAPSHOT, "snapshot", snapshotCmds},
+ {VSH_CMD_GRP_STORAGE_POOL, "pool", storagePoolCmds},
+ {VSH_CMD_GRP_STORAGE_VOL, "volume", storageVolCmds},
+ {VSH_CMD_GRP_VIRSH, "virsh", virshCmds},
+ {NULL, NULL, NULL}
+};
int
main(int argc, char **argv)
Looks clean and should not make any problems, ACK.
Martin