1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

vsh: Annotate 'required' and 'positional' arguments explicitly

Add 'positional' and 'required' fields to vshCmdOptDef, which will
explicitly track the two properties of arguments.

To ensure that we have proper coverage, add checks to
vshCmddefCheckInternals validating the state of the above flags by
infering it from existing data.

This conversion will allow us:
 - remove VSH_OT_DATA in favor of VSH_OT_STRING
 - use VSH_OT_INT when required both as positional and non-positional
 - properly annotate which VSH_OT_ARGV are positional and which are not
   (currently inferred by whether an previous positional option exists)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2024-03-05 15:07:47 +01:00
parent 162b184d0e
commit ac150162fd
15 changed files with 283 additions and 4 deletions

View File

@ -738,6 +738,8 @@ static const vshCmdOptDef opts_domif_getlink[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "interface", {.name = "interface",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainInterfaceCompleter, .completer = virshDomainInterfaceCompleter,
.help = N_("interface device (MAC Address)") .help = N_("interface device (MAC Address)")
@ -1038,6 +1040,8 @@ static const vshCmdOptDef opts_domifstat[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "interface", {.name = "interface",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainInterfaceCompleter, .completer = virshDomainInterfaceCompleter,
.help = N_("interface device specified by name or MAC Address") .help = N_("interface device specified by name or MAC Address")
@ -2050,6 +2054,7 @@ static const vshCmdOptDef opts_domstats[] = {
}, },
{.name = "domain", {.name = "domain",
.type = VSH_OT_ARGV, .type = VSH_OT_ARGV,
.positional = true,
.help = N_("list of domains to get stats for"), .help = N_("list of domains to get stats for"),
.completer = virshDomainNameCompleter, .completer = virshDomainNameCompleter,
}, },

View File

@ -420,11 +420,15 @@ static const vshCmdOptDef opts_attach_disk[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "source", {.name = "source",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ | VSH_OFLAG_EMPTY_OK, .flags = VSH_OFLAG_REQ | VSH_OFLAG_EMPTY_OK,
.help = N_("source of disk device or name of network disk") .help = N_("source of disk device or name of network disk")
}, },
{.name = "target", {.name = "target",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompleteEmpty, .completer = virshCompleteEmpty,
.help = N_("target of disk device") .help = N_("target of disk device")
@ -812,11 +816,15 @@ static const vshCmdOptDef opts_attach_interface[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "type", {.name = "type",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("network interface type") .help = N_("network interface type")
}, },
{.name = "source", {.name = "source",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("source of network interface") .help = N_("source of network interface")
}, },
@ -1188,6 +1196,8 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "device", {.name = "device",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainDiskTargetCompleter, .completer = virshDomainDiskTargetCompleter,
.help = N_("block device") .help = N_("block device")
@ -1981,6 +1991,8 @@ static const vshCmdOptDef opts_blockcommit[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "path", {.name = "path",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainDiskTargetCompleter, .completer = virshDomainDiskTargetCompleter,
.help = N_("fully-qualified path of disk") .help = N_("fully-qualified path of disk")
@ -2200,6 +2212,8 @@ static const vshCmdOptDef opts_blockcopy[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "path", {.name = "path",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainDiskTargetCompleter, .completer = virshDomainDiskTargetCompleter,
.help = N_("fully-qualified path of source disk") .help = N_("fully-qualified path of source disk")
@ -2532,6 +2546,8 @@ static const vshCmdOptDef opts_blockjob[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "path", {.name = "path",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainDiskTargetCompleter, .completer = virshDomainDiskTargetCompleter,
.help = N_("fully-qualified path of disk") .help = N_("fully-qualified path of disk")
@ -2743,6 +2759,8 @@ static const vshCmdOptDef opts_blockpull[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "path", {.name = "path",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainDiskTargetCompleter, .completer = virshDomainDiskTargetCompleter,
.help = N_("fully-qualified path of disk") .help = N_("fully-qualified path of disk")
@ -2885,6 +2903,8 @@ static const vshCmdOptDef opts_blockresize[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "path", {.name = "path",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainDiskTargetCompleter, .completer = virshDomainDiskTargetCompleter,
.help = N_("Fully-qualified path of block device") .help = N_("Fully-qualified path of block device")
@ -3042,12 +3062,16 @@ static const vshCmdOptDef opts_domif_setlink[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "interface", {.name = "interface",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainInterfaceCompleter, .completer = virshDomainInterfaceCompleter,
.help = N_("interface device (MAC Address)") .help = N_("interface device (MAC Address)")
}, },
{.name = "state", {.name = "state",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainInterfaceStateCompleter, .completer = virshDomainInterfaceStateCompleter,
.help = N_("new state of the device") .help = N_("new state of the device")
@ -3188,6 +3212,8 @@ static const vshCmdOptDef opts_domiftune[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "interface", {.name = "interface",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainInterfaceCompleter, .completer = virshDomainInterfaceCompleter,
.help = N_("interface device (MAC Address)") .help = N_("interface device (MAC Address)")
@ -3413,6 +3439,8 @@ static const vshCmdOptDef opts_dom_pm_suspend[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_RUNNING), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_RUNNING),
{.name = "target", {.name = "target",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshNodeSuspendTargetCompleter, .completer = virshNodeSuspendTargetCompleter,
.help = N_("mem(Suspend-to-RAM), " .help = N_("mem(Suspend-to-RAM), "
@ -4096,6 +4124,8 @@ static const vshCmdOptDef opts_save[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "file", {.name = "file",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("where to save the data") .help = N_("where to save the data")
}, },
@ -4445,6 +4475,8 @@ static const vshCmdInfo info_save_image_dumpxml = {
static const vshCmdOptDef opts_save_image_dumpxml[] = { static const vshCmdOptDef opts_save_image_dumpxml[] = {
{.name = "file", {.name = "file",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("saved state file to read") .help = N_("saved state file to read")
}, },
@ -4502,11 +4534,15 @@ static const vshCmdInfo info_save_image_define = {
static const vshCmdOptDef opts_save_image_define[] = { static const vshCmdOptDef opts_save_image_define[] = {
{.name = "file", {.name = "file",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("saved state file to modify") .help = N_("saved state file to modify")
}, },
{.name = "xml", {.name = "xml",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompletePathLocalExisting, .completer = virshCompletePathLocalExisting,
.help = N_("filename containing updated XML for the target") .help = N_("filename containing updated XML for the target")
@ -4565,6 +4601,8 @@ static const vshCmdInfo info_save_image_edit = {
static const vshCmdOptDef opts_save_image_edit[] = { static const vshCmdOptDef opts_save_image_edit[] = {
{.name = "file", {.name = "file",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("saved state file to edit") .help = N_("saved state file to edit")
}, },
@ -4904,6 +4942,8 @@ static const vshCmdOptDef opts_managed_save_define[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE),
{.name = "xml", {.name = "xml",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompletePathLocalExisting, .completer = virshCompletePathLocalExisting,
.help = N_("filename containing updated XML for the target") .help = N_("filename containing updated XML for the target")
@ -5180,6 +5220,8 @@ static const vshCmdInfo info_restore = {
static const vshCmdOptDef opts_restore[] = { static const vshCmdOptDef opts_restore[] = {
{.name = "file", {.name = "file",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("the state to restore") .help = N_("the state to restore")
}, },
@ -5263,6 +5305,8 @@ static const vshCmdOptDef opts_dump[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "file", {.name = "file",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("where to dump the core") .help = N_("where to dump the core")
}, },
@ -5562,12 +5606,16 @@ static const vshCmdOptDef opts_setLifecycleAction[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "type", {.name = "type",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainLifecycleCompleter, .completer = virshDomainLifecycleCompleter,
.help = N_("lifecycle type to modify") .help = N_("lifecycle type to modify")
}, },
{.name = "action", {.name = "action",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainLifecycleActionCompleter, .completer = virshDomainLifecycleActionCompleter,
.help = N_("lifecycle action to set") .help = N_("lifecycle action to set")
@ -5654,11 +5702,15 @@ static const vshCmdOptDef opts_set_user_password[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "user", {.name = "user",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("the username") .help = N_("the username")
}, },
{.name = "password", {.name = "password",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompleteEmpty, .completer = virshCompleteEmpty,
.help = N_("the new password") .help = N_("the new password")
@ -7074,6 +7126,8 @@ static const vshCmdOptDef opts_setvcpus[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "count", {.name = "count",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.required = true,
.positional = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("number of virtual CPUs") .help = N_("number of virtual CPUs")
}, },
@ -7240,6 +7294,8 @@ static const vshCmdOptDef opts_setvcpu[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "vcpulist", {.name = "vcpulist",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainVcpulistCompleter, .completer = virshDomainVcpulistCompleter,
.help = N_("ids of vcpus to manipulate") .help = N_("ids of vcpus to manipulate")
@ -7314,12 +7370,16 @@ static const vshCmdOptDef opts_domblkthreshold[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "dev", {.name = "dev",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainDiskTargetCompleter, .completer = virshDomainDiskTargetCompleter,
.help = N_("device to set threshold for") .help = N_("device to set threshold for")
}, },
{.name = "threshold", {.name = "threshold",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.required = true,
.positional = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("threshold as a scaled number (by default bytes)") .help = N_("threshold as a scaled number (by default bytes)")
}, },
@ -7442,12 +7502,16 @@ static const vshCmdOptDef opts_iothreadpin[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "iothread", {.name = "iothread",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.required = true,
.positional = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainIOThreadIdCompleter, .completer = virshDomainIOThreadIdCompleter,
.help = N_("IOThread ID number") .help = N_("IOThread ID number")
}, },
{.name = "cpulist", {.name = "cpulist",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainCpulistCompleter, .completer = virshDomainCpulistCompleter,
.help = N_("host cpu number(s) to set") .help = N_("host cpu number(s) to set")
@ -7515,6 +7579,8 @@ static const vshCmdOptDef opts_iothreadadd[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "id", {.name = "id",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.required = true,
.positional = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("iothread for the new IOThread") .help = N_("iothread for the new IOThread")
}, },
@ -7571,6 +7637,8 @@ static const vshCmdOptDef opts_iothreadset[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "id", {.name = "id",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.required = true,
.positional = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainIOThreadIdCompleter, .completer = virshDomainIOThreadIdCompleter,
.help = N_("iothread id of existing IOThread") .help = N_("iothread id of existing IOThread")
@ -7687,6 +7755,8 @@ static const vshCmdOptDef opts_iothreaddel[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "id", {.name = "id",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.required = true,
.positional = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainIOThreadIdCompleter, .completer = virshDomainIOThreadIdCompleter,
.help = N_("iothread_id for the IOThread to delete") .help = N_("iothread_id for the IOThread to delete")
@ -8277,6 +8347,8 @@ static const vshCmdOptDef opts_metadata[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "uri", {.name = "uri",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("URI of the namespace") .help = N_("URI of the namespace")
}, },
@ -8455,6 +8527,7 @@ static const vshCmdOptDef opts_send_key[] = {
}, },
{.name = "keycode", {.name = "keycode",
.type = VSH_OT_ARGV, .type = VSH_OT_ARGV,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshKeycodeNameCompleter, .completer = virshKeycodeNameCompleter,
.help = N_("the key code") .help = N_("the key code")
@ -8539,12 +8612,16 @@ static const vshCmdOptDef opts_send_process_signal[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "pid", {.name = "pid",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompleteEmpty, .completer = virshCompleteEmpty,
.help = N_("the process ID") .help = N_("the process ID")
}, },
{.name = "signame", {.name = "signame",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainSignalCompleter, .completer = virshDomainSignalCompleter,
.help = N_("the signal number or name") .help = N_("the signal number or name")
@ -8633,6 +8710,8 @@ static const vshCmdOptDef opts_setmem[] = {
}, },
{.name = "size", {.name = "size",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.required = true,
.positional = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("new memory size, as scaled integer (default KiB)") .help = N_("new memory size, as scaled integer (default KiB)")
}, },
@ -8702,6 +8781,8 @@ static const vshCmdOptDef opts_setmaxmem[] = {
}, },
{.name = "size", {.name = "size",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.required = true,
.positional = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("new maximum memory size, as scaled integer (default KiB)") .help = N_("new maximum memory size, as scaled integer (default KiB)")
}, },
@ -9475,12 +9556,16 @@ static const vshCmdOptDef opts_dom_fd_associate[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "name", {.name = "name",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompleteEmpty, .completer = virshCompleteEmpty,
.help = N_("name of the FD group") .help = N_("name of the FD group")
}, },
{.name = "pass-fds", {.name = "pass-fds",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompleteEmpty, .completer = virshCompleteEmpty,
.help = N_("file descriptors N,M,... to associate") .help = N_("file descriptors N,M,... to associate")
@ -9557,6 +9642,7 @@ static const vshCmdOptDef opts_qemu_monitor_command[] = {
}, },
{.name = "cmd", {.name = "cmd",
.type = VSH_OT_ARGV, .type = VSH_OT_ARGV,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("command") .help = N_("command")
}, },
@ -9892,6 +9978,8 @@ static const vshCmdInfo info_qemu_attach = {
static const vshCmdOptDef opts_qemu_attach[] = { static const vshCmdOptDef opts_qemu_attach[] = {
{.name = "pid", {.name = "pid",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompleteEmpty, .completer = virshCompleteEmpty,
.help = N_("pid") .help = N_("pid")
@ -9949,6 +10037,7 @@ static const vshCmdOptDef opts_qemu_agent_command[] = {
}, },
{.name = "cmd", {.name = "cmd",
.type = VSH_OT_ARGV, .type = VSH_OT_ARGV,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("command") .help = N_("command")
}, },
@ -10045,6 +10134,7 @@ static const vshCmdOptDef opts_lxc_enter_namespace[] = {
}, },
{.name = "cmd", {.name = "cmd",
.type = VSH_OT_ARGV, .type = VSH_OT_ARGV,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("command to run") .help = N_("command to run")
}, },
@ -10224,11 +10314,15 @@ static const vshCmdInfo info_domxmlfromnative = {
static const vshCmdOptDef opts_domxmlfromnative[] = { static const vshCmdOptDef opts_domxmlfromnative[] = {
{.name = "format", {.name = "format",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("source config data format") .help = N_("source config data format")
}, },
{.name = "config", {.name = "config",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompletePathLocalExisting, .completer = virshCompletePathLocalExisting,
.help = N_("config data file to import from") .help = N_("config data file to import from")
@ -10272,6 +10366,8 @@ static const vshCmdInfo info_domxmltonative = {
static const vshCmdOptDef opts_domxmltonative[] = { static const vshCmdOptDef opts_domxmltonative[] = {
{.name = "format", {.name = "format",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("target config data type format") .help = N_("target config data type format")
}, },
@ -10339,6 +10435,8 @@ static const vshCmdInfo info_domname = {
static const vshCmdOptDef opts_domname[] = { static const vshCmdOptDef opts_domname[] = {
{.name = "domain", {.name = "domain",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainUUIDCompleter, .completer = virshDomainUUIDCompleter,
.help = N_("domain id or uuid") .help = N_("domain id or uuid")
@ -10372,6 +10470,8 @@ static const vshCmdOptDef opts_domrename[] = {
VIR_CONNECT_LIST_DOMAINS_INACTIVE), VIR_CONNECT_LIST_DOMAINS_INACTIVE),
{.name = "new-name", {.name = "new-name",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompleteEmpty, .completer = virshCompleteEmpty,
.help = N_("new domain name") .help = N_("new domain name")
@ -10474,6 +10574,8 @@ static const vshCmdOptDef opts_migrate[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "desturi", {.name = "desturi",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompleteEmpty, .completer = virshCompleteEmpty,
.help = N_("connection URI of the destination host as seen from the client(normal migration) or source(p2p migration)") .help = N_("connection URI of the destination host as seen from the client(normal migration) or source(p2p migration)")
@ -11171,6 +11273,8 @@ static const vshCmdOptDef opts_migrate_setmaxdowntime[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "downtime", {.name = "downtime",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.required = true,
.positional = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("maximum tolerable downtime (in milliseconds) for migration") .help = N_("maximum tolerable downtime (in milliseconds) for migration")
}, },
@ -11289,6 +11393,8 @@ static const vshCmdOptDef opts_migrate_setspeed[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "bandwidth", {.name = "bandwidth",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.required = true,
.positional = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("migration bandwidth limit in MiB/s") .help = N_("migration bandwidth limit in MiB/s")
}, },
@ -11878,6 +11984,8 @@ static const vshCmdOptDef opts_detach_device_alias[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "alias", {.name = "alias",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainDeviceAliasCompleter, .completer = virshDomainDeviceAliasCompleter,
.help = N_("device alias") .help = N_("device alias")
@ -12006,6 +12114,8 @@ static const vshCmdOptDef opts_detach_interface[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "type", {.name = "type",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("network interface type") .help = N_("network interface type")
}, },
@ -12378,6 +12488,8 @@ static const vshCmdOptDef opts_detach_disk[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "target", {.name = "target",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainDiskTargetCompleter, .completer = virshDomainDiskTargetCompleter,
.help = N_("target of disk device") .help = N_("target of disk device")
@ -12538,6 +12650,8 @@ static const vshCmdOptDef opts_change_media[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0), VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "path", {.name = "path",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshDomainDiskTargetCompleter, .completer = virshDomainDiskTargetCompleter,
.help = N_("Fully-qualified path or target of disk device") .help = N_("Fully-qualified path or target of disk device")
@ -13012,6 +13126,8 @@ static const vshCmdOptDef opts_get_user_sshkeys[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "user", {.name = "user",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("user to list authorized keys for"), .help = N_("user to list authorized keys for"),
}, },
@ -13059,6 +13175,8 @@ static const vshCmdOptDef opts_set_user_sshkeys[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "user", {.name = "user",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("user to set authorized keys for"), .help = N_("user to set authorized keys for"),
}, },

View File

@ -468,12 +468,16 @@ static const vshCmdInfo info_allocpages = {
static const vshCmdOptDef opts_allocpages[] = { static const vshCmdOptDef opts_allocpages[] = {
{.name = "pagesize", {.name = "pagesize",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshAllocpagesPagesizeCompleter, .completer = virshAllocpagesPagesizeCompleter,
.help = N_("page size (in kibibytes)") .help = N_("page size (in kibibytes)")
}, },
{.name = "pagecount", {.name = "pagecount",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("page count") .help = N_("page count")
}, },
@ -943,6 +947,8 @@ static const vshCmdInfo info_nodesuspend = {
static const vshCmdOptDef opts_node_suspend[] = { static const vshCmdOptDef opts_node_suspend[] = {
{.name = "target", {.name = "target",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshNodeSuspendTargetCompleter, .completer = virshNodeSuspendTargetCompleter,
.help = N_("mem(Suspend-to-RAM), disk(Suspend-to-Disk), " .help = N_("mem(Suspend-to-RAM), disk(Suspend-to-Disk), "
@ -950,6 +956,8 @@ static const vshCmdOptDef opts_node_suspend[] = {
}, },
{.name = "duration", {.name = "duration",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("Suspend duration in seconds, at least 60") .help = N_("Suspend duration in seconds, at least 60")
}, },
@ -1270,6 +1278,8 @@ static const vshCmdInfo info_cpu_models = {
static const vshCmdOptDef opts_cpu_models[] = { static const vshCmdOptDef opts_cpu_models[] = {
{.name = "arch", {.name = "arch",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.completer = virshArchCompleter, .completer = virshArchCompleter,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("architecture") .help = N_("architecture")

View File

@ -21,6 +21,8 @@
#define VIRSH_COMMON_OPT_INTERFACE(cflags) \ #define VIRSH_COMMON_OPT_INTERFACE(cflags) \
{.name = "interface", \ {.name = "interface", \
.type = VSH_OT_DATA, \ .type = VSH_OT_DATA, \
.positional = true, \
.required = true, \
.flags = VSH_OFLAG_REQ, \ .flags = VSH_OFLAG_REQ, \
.help = N_("interface name or MAC address"), \ .help = N_("interface name or MAC address"), \
.completer = virshInterfaceNameCompleter, \ .completer = virshInterfaceNameCompleter, \
@ -383,6 +385,8 @@ static const vshCmdInfo info_interface_name = {
static const vshCmdOptDef opts_interface_name[] = { static const vshCmdOptDef opts_interface_name[] = {
{.name = "interface", {.name = "interface",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshInterfaceMacCompleter, .completer = virshInterfaceMacCompleter,
.help = N_("interface mac") .help = N_("interface mac")
@ -414,6 +418,8 @@ static const vshCmdInfo info_interface_mac = {
static const vshCmdOptDef opts_interface_mac[] = { static const vshCmdOptDef opts_interface_mac[] = {
{.name = "interface", {.name = "interface",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshInterfaceNameCompleter, .completer = virshInterfaceNameCompleter,
.help = N_("interface name") .help = N_("interface name")
@ -716,12 +722,16 @@ static const vshCmdInfo info_interface_bridge = {
static const vshCmdOptDef opts_interface_bridge[] = { static const vshCmdOptDef opts_interface_bridge[] = {
{.name = "interface", {.name = "interface",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshInterfaceNameCompleter, .completer = virshInterfaceNameCompleter,
.help = N_("existing interface name") .help = N_("existing interface name")
}, },
{.name = "bridge", {.name = "bridge",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("new bridge device name") .help = N_("new bridge device name")
}, },
@ -943,6 +953,8 @@ static const vshCmdInfo info_interface_unbridge = {
static const vshCmdOptDef opts_interface_unbridge[] = { static const vshCmdOptDef opts_interface_unbridge[] = {
{.name = "bridge", {.name = "bridge",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("current bridge device name") .help = N_("current bridge device name")
}, },

View File

@ -33,6 +33,8 @@
#define VIRSH_COMMON_OPT_NETWORK(_helpstr, cflags) \ #define VIRSH_COMMON_OPT_NETWORK(_helpstr, cflags) \
{.name = "network", \ {.name = "network", \
.type = VSH_OT_DATA, \ .type = VSH_OT_DATA, \
.positional = true, \
.required = true, \
.flags = VSH_OFLAG_REQ, \ .flags = VSH_OFLAG_REQ, \
.help = _helpstr, \ .help = _helpstr, \
.completer = virshNetworkNameCompleter, \ .completer = virshNetworkNameCompleter, \
@ -56,6 +58,8 @@
#define VIRSH_COMMON_OPT_NETWORK_PORT(cflags) \ #define VIRSH_COMMON_OPT_NETWORK_PORT(cflags) \
{.name = "port", \ {.name = "port", \
.type = VSH_OT_DATA, \ .type = VSH_OT_DATA, \
.positional = true, \
.required = true, \
.flags = VSH_OFLAG_REQ, \ .flags = VSH_OFLAG_REQ, \
.help = N_("port UUID"), \ .help = N_("port UUID"), \
.completer = virshNetworkPortUUIDCompleter, \ .completer = virshNetworkPortUUIDCompleter, \
@ -502,6 +506,8 @@ static const vshCmdOptDef opts_network_metadata[] = {
VIRSH_COMMON_OPT_NETWORK_FULL(0), VIRSH_COMMON_OPT_NETWORK_FULL(0),
{.name = "uri", {.name = "uri",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("URI of the namespace") .help = N_("URI of the namespace")
}, },
@ -1127,6 +1133,8 @@ static const vshCmdInfo info_network_name = {
static const vshCmdOptDef opts_network_name[] = { static const vshCmdOptDef opts_network_name[] = {
{.name = "network", {.name = "network",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshNetworkUUIDCompleter, .completer = virshNetworkUUIDCompleter,
.help = N_("network uuid") .help = N_("network uuid")
@ -1224,18 +1232,24 @@ static const vshCmdOptDef opts_network_update[] = {
VIRSH_COMMON_OPT_NETWORK_FULL(0), VIRSH_COMMON_OPT_NETWORK_FULL(0),
{.name = "command", {.name = "command",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshNetworkUpdateCommandCompleter, .completer = virshNetworkUpdateCommandCompleter,
.help = N_("type of update (add-first, add-last (add), delete, or modify)") .help = N_("type of update (add-first, add-last (add), delete, or modify)")
}, },
{.name = "section", {.name = "section",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshNetworkUpdateSectionCompleter, .completer = virshNetworkUpdateSectionCompleter,
.help = N_("which section of network configuration to update") .help = N_("which section of network configuration to update")
}, },
{.name = "xml", {.name = "xml",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompletePathLocalExisting, .completer = virshCompletePathLocalExisting,
.help = N_("name of file containing xml (or, if it starts with '<', the complete " .help = N_("name of file containing xml (or, if it starts with '<', the complete "

View File

@ -97,6 +97,8 @@ static const vshCmdOptDef opts_node_device_destroy[] = {
}, },
{.name = "device", {.name = "device",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("device name or wwn pair in 'wwnn,wwpn' format"), .help = N_("device name or wwn pair in 'wwnn,wwpn' format"),
.completer = virshNodeDeviceNameCompleter, .completer = virshNodeDeviceNameCompleter,
@ -571,6 +573,8 @@ static const vshCmdInfo info_node_device_dumpxml = {
static const vshCmdOptDef opts_node_device_dumpxml[] = { static const vshCmdOptDef opts_node_device_dumpxml[] = {
{.name = "device", {.name = "device",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("device name or wwn pair in 'wwnn,wwpn' format"), .help = N_("device name or wwn pair in 'wwnn,wwpn' format"),
.completer = virshNodeDeviceNameCompleter, .completer = virshNodeDeviceNameCompleter,
@ -634,6 +638,8 @@ static const vshCmdInfo info_node_device_detach = {
static const vshCmdOptDef opts_node_device_detach[] = { static const vshCmdOptDef opts_node_device_detach[] = {
{.name = "device", {.name = "device",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("device key"), .help = N_("device key"),
.completer = virshNodeDeviceNameCompleter, .completer = virshNodeDeviceNameCompleter,
@ -696,6 +702,8 @@ static const vshCmdInfo info_node_device_reattach = {
static const vshCmdOptDef opts_node_device_reattach[] = { static const vshCmdOptDef opts_node_device_reattach[] = {
{.name = "device", {.name = "device",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("device key"), .help = N_("device key"),
.completer = virshNodeDeviceNameCompleter, .completer = virshNodeDeviceNameCompleter,
@ -741,6 +749,8 @@ static const vshCmdInfo info_node_device_reset = {
static const vshCmdOptDef opts_node_device_reset[] = { static const vshCmdOptDef opts_node_device_reset[] = {
{.name = "device", {.name = "device",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("device key"), .help = N_("device key"),
.completer = virshNodeDeviceNameCompleter, .completer = virshNodeDeviceNameCompleter,
@ -1002,6 +1012,8 @@ static const vshCmdInfo info_node_device_undefine = {
static const vshCmdOptDef opts_node_device_undefine[] = { static const vshCmdOptDef opts_node_device_undefine[] = {
{.name = "device", {.name = "device",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("device name or wwn pair in 'wwnn,wwpn' format"), .help = N_("device name or wwn pair in 'wwnn,wwpn' format"),
.completer = virshNodeDeviceNameCompleter, .completer = virshNodeDeviceNameCompleter,
@ -1093,6 +1105,8 @@ static const vshCmdInfo info_node_device_start = {
static const vshCmdOptDef opts_node_device_start[] = { static const vshCmdOptDef opts_node_device_start[] = {
{.name = "device", {.name = "device",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("device name"), .help = N_("device name"),
.completer = virshNodeDeviceNameCompleter, .completer = virshNodeDeviceNameCompleter,
@ -1138,6 +1152,8 @@ static const vshCmdInfo info_node_device_autostart = {
static const vshCmdOptDef opts_node_device_autostart[] = { static const vshCmdOptDef opts_node_device_autostart[] = {
{.name = "device", {.name = "device",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("device name or wwn pair in 'wwnn,wwpn' format"), .help = N_("device name or wwn pair in 'wwnn,wwpn' format"),
.completer = virshNodeDeviceNameCompleter, .completer = virshNodeDeviceNameCompleter,
@ -1195,6 +1211,8 @@ static const vshCmdInfo info_node_device_info = {
static const vshCmdOptDef opts_node_device_info[] = { static const vshCmdOptDef opts_node_device_info[] = {
{.name = "device", {.name = "device",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("device name or wwn pair in 'wwnn,wwpn' format"), .help = N_("device name or wwn pair in 'wwnn,wwpn' format"),
.completer = virshNodeDeviceNameCompleter, .completer = virshNodeDeviceNameCompleter,
@ -1245,6 +1263,8 @@ static const vshCmdInfo info_node_device_update = {
static const vshCmdOptDef opts_node_device_update[] = { static const vshCmdOptDef opts_node_device_update[] = {
{.name = "device", {.name = "device",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("device name or wwn pair in 'wwnn,wwpn' format"), .help = N_("device name or wwn pair in 'wwnn,wwpn' format"),
.completer = virshNodeDeviceNameCompleter, .completer = virshNodeDeviceNameCompleter,

View File

@ -129,6 +129,8 @@ static const vshCmdInfo info_nwfilter_undefine = {
static const vshCmdOptDef opts_nwfilter_undefine[] = { static const vshCmdOptDef opts_nwfilter_undefine[] = {
{.name = "nwfilter", {.name = "nwfilter",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("network filter name or uuid"), .help = N_("network filter name or uuid"),
.completer = virshNWFilterNameCompleter, .completer = virshNWFilterNameCompleter,
@ -167,6 +169,8 @@ static const vshCmdInfo info_nwfilter_dumpxml = {
static const vshCmdOptDef opts_nwfilter_dumpxml[] = { static const vshCmdOptDef opts_nwfilter_dumpxml[] = {
{.name = "nwfilter", {.name = "nwfilter",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("network filter name or uuid"), .help = N_("network filter name or uuid"),
.completer = virshNWFilterNameCompleter, .completer = virshNWFilterNameCompleter,
@ -391,6 +395,8 @@ static const vshCmdInfo info_nwfilter_edit = {
static const vshCmdOptDef opts_nwfilter_edit[] = { static const vshCmdOptDef opts_nwfilter_edit[] = {
{.name = "nwfilter", {.name = "nwfilter",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("network filter name or uuid"), .help = N_("network filter name or uuid"),
.completer = virshNWFilterNameCompleter, .completer = virshNWFilterNameCompleter,
@ -526,6 +532,8 @@ static const vshCmdInfo info_nwfilter_binding_delete = {
static const vshCmdOptDef opts_nwfilter_binding_delete[] = { static const vshCmdOptDef opts_nwfilter_binding_delete[] = {
{.name = "binding", {.name = "binding",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("network filter binding port dev"), .help = N_("network filter binding port dev"),
.completer = virshNWFilterBindingNameCompleter, .completer = virshNWFilterBindingNameCompleter,
@ -566,6 +574,8 @@ static const vshCmdInfo info_nwfilter_binding_dumpxml = {
static const vshCmdOptDef opts_nwfilter_binding_dumpxml[] = { static const vshCmdOptDef opts_nwfilter_binding_dumpxml[] = {
{.name = "binding", {.name = "binding",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("network filter binding portdev"), .help = N_("network filter binding portdev"),
.completer = virshNWFilterBindingNameCompleter, .completer = virshNWFilterBindingNameCompleter,

View File

@ -58,12 +58,16 @@
#define VIRSH_COMMON_OPT_POOL_X_AS \ #define VIRSH_COMMON_OPT_POOL_X_AS \
{.name = "name", \ {.name = "name", \
.type = VSH_OT_DATA, \ .type = VSH_OT_DATA, \
.positional = true, \
.required = true, \
.flags = VSH_OFLAG_REQ, \ .flags = VSH_OFLAG_REQ, \
.completer = virshCompleteEmpty, \ .completer = virshCompleteEmpty, \
.help = N_("name of the pool") \ .help = N_("name of the pool") \
}, \ }, \
{.name = "type", \ {.name = "type", \
.type = VSH_OT_DATA, \ .type = VSH_OT_DATA, \
.positional = true, \
.required = true, \
.flags = VSH_OFLAG_REQ, \ .flags = VSH_OFLAG_REQ, \
.completer = virshPoolTypeCompleter, \ .completer = virshPoolTypeCompleter, \
.help = N_("type of the pool") \ .help = N_("type of the pool") \
@ -1354,6 +1358,8 @@ static const vshCmdInfo info_find_storage_pool_sources_as = {
static const vshCmdOptDef opts_find_storage_pool_sources_as[] = { static const vshCmdOptDef opts_find_storage_pool_sources_as[] = {
{.name = "type", {.name = "type",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshPoolTypeCompleter, .completer = virshPoolTypeCompleter,
.help = N_("type of storage pool sources to find") .help = N_("type of storage pool sources to find")
@ -1437,6 +1443,8 @@ static const vshCmdInfo info_find_storage_pool_sources = {
static const vshCmdOptDef opts_find_storage_pool_sources[] = { static const vshCmdOptDef opts_find_storage_pool_sources[] = {
{.name = "type", {.name = "type",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshPoolTypeCompleter, .completer = virshPoolTypeCompleter,
.help = N_("type of storage pool sources to discover") .help = N_("type of storage pool sources to discover")

View File

@ -124,6 +124,8 @@ static const vshCmdInfo info_secret_dumpxml = {
static const vshCmdOptDef opts_secret_dumpxml[] = { static const vshCmdOptDef opts_secret_dumpxml[] = {
{.name = "secret", {.name = "secret",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("secret UUID"), .help = N_("secret UUID"),
.completer = virshSecretUUIDCompleter, .completer = virshSecretUUIDCompleter,
@ -179,6 +181,8 @@ static const vshCmdInfo info_secret_set_value = {
static const vshCmdOptDef opts_secret_set_value[] = { static const vshCmdOptDef opts_secret_set_value[] = {
{.name = "secret", {.name = "secret",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("secret UUID"), .help = N_("secret UUID"),
.completer = virshSecretUUIDCompleter, .completer = virshSecretUUIDCompleter,
@ -290,6 +294,8 @@ static const vshCmdInfo info_secret_get_value = {
static const vshCmdOptDef opts_secret_get_value[] = { static const vshCmdOptDef opts_secret_get_value[] = {
{.name = "secret", {.name = "secret",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("secret UUID"), .help = N_("secret UUID"),
.completer = virshSecretUUIDCompleter, .completer = virshSecretUUIDCompleter,
@ -343,6 +349,8 @@ static const vshCmdInfo info_secret_undefine = {
static const vshCmdOptDef opts_secret_undefine[] = { static const vshCmdOptDef opts_secret_undefine[] = {
{.name = "secret", {.name = "secret",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("secret UUID"), .help = N_("secret UUID"),
.completer = virshSecretUUIDCompleter, .completer = virshSecretUUIDCompleter,

View File

@ -1568,6 +1568,8 @@ static const vshCmdOptDef opts_snapshot_dumpxml[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT), VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT),
{.name = "snapshotname", {.name = "snapshotname",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("snapshot name"), .help = N_("snapshot name"),
.completer = virshSnapshotNameCompleter, .completer = virshSnapshotNameCompleter,

View File

@ -57,6 +57,8 @@
#define VIRSH_COMMON_OPT_VOL_NAME(_helpstr) \ #define VIRSH_COMMON_OPT_VOL_NAME(_helpstr) \
{.name = "vol", \ {.name = "vol", \
.type = VSH_OT_DATA, \ .type = VSH_OT_DATA, \
.positional = true, \
.required = true, \
.flags = VSH_OFLAG_REQ, \ .flags = VSH_OFLAG_REQ, \
.help = _helpstr, \ .help = _helpstr, \
.completer = virshStorageVolNameCompleter, \ .completer = virshStorageVolNameCompleter, \
@ -65,6 +67,8 @@
#define VIRSH_COMMON_OPT_VOL_KEY(_helpstr) \ #define VIRSH_COMMON_OPT_VOL_KEY(_helpstr) \
{.name = "vol", \ {.name = "vol", \
.type = VSH_OT_DATA, \ .type = VSH_OT_DATA, \
.positional = true, \
.required = true, \
.flags = VSH_OFLAG_REQ, \ .flags = VSH_OFLAG_REQ, \
.help = _helpstr, \ .help = _helpstr, \
.completer = virshStorageVolKeyCompleter, \ .completer = virshStorageVolKeyCompleter, \
@ -173,12 +177,16 @@ static const vshCmdOptDef opts_vol_create_as[] = {
VIRSH_COMMON_OPT_POOL_NAME, VIRSH_COMMON_OPT_POOL_NAME,
{.name = "name", {.name = "name",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompleteEmpty, .completer = virshCompleteEmpty,
.help = N_("name of the volume") .help = N_("name of the volume")
}, },
{.name = "capacity", {.name = "capacity",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompleteEmpty, .completer = virshCompleteEmpty,
.help = N_("size of the vol, as scaled integer (default bytes)") .help = N_("size of the vol, as scaled integer (default bytes)")
@ -520,6 +528,8 @@ static const vshCmdOptDef opts_vol_clone[] = {
VIRSH_COMMON_OPT_VOL_FULL, VIRSH_COMMON_OPT_VOL_FULL,
{.name = "newname", {.name = "newname",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompleteEmpty, .completer = virshCompleteEmpty,
.help = N_("clone name") .help = N_("clone name")
@ -1024,6 +1034,8 @@ static const vshCmdOptDef opts_vol_resize[] = {
VIRSH_COMMON_OPT_VOL_FULL, VIRSH_COMMON_OPT_VOL_FULL,
{.name = "capacity", {.name = "capacity",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = virshCompleteEmpty, .completer = virshCompleteEmpty,
.help = N_("new capacity for the vol, as scaled integer (default bytes)") .help = N_("new capacity for the vol, as scaled integer (default bytes)")

View File

@ -58,6 +58,8 @@
#define VIRSH_COMMON_OPT_POOL(_helpstr, cflags) \ #define VIRSH_COMMON_OPT_POOL(_helpstr, cflags) \
{.name = "pool", \ {.name = "pool", \
.type = VSH_OT_DATA, \ .type = VSH_OT_DATA, \
.positional = true, \
.required = true, \
.flags = VSH_OFLAG_REQ, \ .flags = VSH_OFLAG_REQ, \
.help = _helpstr, \ .help = _helpstr, \
.completer = virshStoragePoolNameCompleter, \ .completer = virshStoragePoolNameCompleter, \
@ -67,6 +69,8 @@
#define VIRSH_COMMON_OPT_DOMAIN(_helpstr, cflags) \ #define VIRSH_COMMON_OPT_DOMAIN(_helpstr, cflags) \
{.name = "domain", \ {.name = "domain", \
.type = VSH_OT_DATA, \ .type = VSH_OT_DATA, \
.positional = true, \
.required = true, \
.flags = VSH_OFLAG_REQ, \ .flags = VSH_OFLAG_REQ, \
.help = _helpstr, \ .help = _helpstr, \
.completer = virshDomainNameCompleter, \ .completer = virshDomainNameCompleter, \
@ -98,10 +102,12 @@
#define VIRSH_COMMON_OPT_FILE(_helpstr) \ #define VIRSH_COMMON_OPT_FILE(_helpstr) \
VIRSH_COMMON_OPT_FILE_FULL(_helpstr, true) VIRSH_COMMON_OPT_FILE_FULL(_helpstr, true)
#define VIRSH_COMMON_OPT_FILE_FULL(_helpstr, required) \ #define VIRSH_COMMON_OPT_FILE_FULL(_helpstr, required_) \
{.name = "file", \ {.name = "file", \
.type = required ? VSH_OT_DATA : VSH_OT_STRING, \ .type = required_ ? VSH_OT_DATA : VSH_OT_STRING, \
.flags = required ? VSH_OFLAG_REQ : VSH_OFLAG_NONE, \ .required = required_, \
.positional = required_, \
.flags = required_ ? VSH_OFLAG_REQ : VSH_OFLAG_NONE, \
.completer = virshCompletePathLocalExisting, \ .completer = virshCompletePathLocalExisting, \
.help = _helpstr \ .help = _helpstr \
} }

View File

@ -359,6 +359,8 @@ static const vshCmdInfo info_srv_threadpool_info = {
static const vshCmdOptDef opts_srv_threadpool_info[] = { static const vshCmdOptDef opts_srv_threadpool_info[] = {
{.name = "server", {.name = "server",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = vshAdmServerCompleter, .completer = vshAdmServerCompleter,
.help = N_("Server to retrieve threadpool attributes from."), .help = N_("Server to retrieve threadpool attributes from."),
@ -416,6 +418,8 @@ static const vshCmdInfo info_srv_threadpool_set = {
static const vshCmdOptDef opts_srv_threadpool_set[] = { static const vshCmdOptDef opts_srv_threadpool_set[] = {
{.name = "server", {.name = "server",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = vshAdmServerCompleter, .completer = vshAdmServerCompleter,
.help = N_("Server to alter threadpool attributes on."), .help = N_("Server to alter threadpool attributes on."),
@ -517,6 +521,8 @@ static const vshCmdInfo info_srv_clients_list = {
static const vshCmdOptDef opts_srv_clients_list[] = { static const vshCmdOptDef opts_srv_clients_list[] = {
{.name = "server", {.name = "server",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = vshAdmServerCompleter, .completer = vshAdmServerCompleter,
.help = N_("server which to list connected clients from"), .help = N_("server which to list connected clients from"),
@ -599,12 +605,16 @@ static const vshCmdInfo info_client_info = {
static const vshCmdOptDef opts_client_info[] = { static const vshCmdOptDef opts_client_info[] = {
{.name = "server", {.name = "server",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = vshAdmServerCompleter, .completer = vshAdmServerCompleter,
.help = N_("server to which <client> is connected to"), .help = N_("server to which <client> is connected to"),
}, },
{.name = "client", {.name = "client",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("client which to retrieve identity information for"), .help = N_("client which to retrieve identity information for"),
}, },
@ -681,12 +691,16 @@ static const vshCmdInfo info_client_disconnect = {
static const vshCmdOptDef opts_client_disconnect[] = { static const vshCmdOptDef opts_client_disconnect[] = {
{.name = "server", {.name = "server",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = vshAdmServerCompleter, .completer = vshAdmServerCompleter,
.help = N_("server which the client is currently connected to"), .help = N_("server which the client is currently connected to"),
}, },
{.name = "client", {.name = "client",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("client which to disconnect, specified by ID"), .help = N_("client which to disconnect, specified by ID"),
}, },
@ -742,6 +756,8 @@ static const vshCmdInfo info_srv_clients_info = {
static const vshCmdOptDef opts_srv_clients_info[] = { static const vshCmdOptDef opts_srv_clients_info[] = {
{.name = "server", {.name = "server",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = vshAdmServerCompleter, .completer = vshAdmServerCompleter,
.help = N_("Server to retrieve the client limits from."), .help = N_("Server to retrieve the client limits from."),
@ -796,6 +812,8 @@ static const vshCmdInfo info_srv_clients_set = {
static const vshCmdOptDef opts_srv_clients_set[] = { static const vshCmdOptDef opts_srv_clients_set[] = {
{.name = "server", {.name = "server",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.completer = vshAdmServerCompleter, .completer = vshAdmServerCompleter,
.help = N_("Server to alter the client-related configuration limits on."), .help = N_("Server to alter the client-related configuration limits on."),
@ -893,6 +911,8 @@ static const vshCmdInfo info_srv_update_tls_file = {
static const vshCmdOptDef opts_srv_update_tls_file[] = { static const vshCmdOptDef opts_srv_update_tls_file[] = {
{.name = "server", {.name = "server",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.positional = true,
.required = true,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("Available servers on a daemon. " .help = N_("Available servers on a daemon. "
"Currently only supports 'libvirtd' or 'virtproxyd'.") "Currently only supports 'libvirtd' or 'virtproxyd'.")
@ -991,6 +1011,8 @@ static const vshCmdInfo info_daemon_log_outputs = {
static const vshCmdOptDef opts_daemon_timeout[] = { static const vshCmdOptDef opts_daemon_timeout[] = {
{.name = "timeout", {.name = "timeout",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.positional = true,
.required = true,
.help = N_("number of seconds the daemon will run without any active connection"), .help = N_("number of seconds the daemon will run without any active connection"),
.flags = VSH_OFLAG_REQ | VSH_OFLAG_REQ_OPT .flags = VSH_OFLAG_REQ | VSH_OFLAG_REQ_OPT
}, },

View File

@ -248,6 +248,7 @@ vshCmddefCheckInternals(vshControl *ctl,
{ {
size_t i; size_t i;
bool seenOptionalOption = false; bool seenOptionalOption = false;
bool seenPositionalOption = false;
g_auto(virBuffer) complbuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) complbuf = VIR_BUFFER_INITIALIZER;
/* in order to perform the validation resolve the alias first */ /* in order to perform the validation resolve the alias first */
@ -301,6 +302,8 @@ vshCmddefCheckInternals(vshControl *ctl,
for (i = 0; cmd->opts[i].name; i++) { for (i = 0; cmd->opts[i].name; i++) {
const vshCmdOptDef *opt = &cmd->opts[i]; const vshCmdOptDef *opt = &cmd->opts[i];
bool isPositional = false;
bool isRequired = false;
if (i > 63) { if (i > 63) {
vshError(ctl, "command '%s' has too many options", cmd->name); vshError(ctl, "command '%s' has too many options", cmd->name);
@ -385,12 +388,17 @@ vshCmddefCheckInternals(vshControl *ctl,
} }
} }
break; break;
case VSH_OT_ARGV: case VSH_OT_ARGV:
if (cmd->opts[i + 1].name) { if (cmd->opts[i + 1].name) {
vshError(ctl, "parameter '%s' of command '%s' must be listed last", vshError(ctl, "parameter '%s' of command '%s' must be listed last",
opt->name, cmd->name); opt->name, cmd->name);
return -1; return -1;
} }
isRequired = opt->flags & VSH_OFLAG_REQ;
/* ARGV argument is positional if there are no positional options */
isPositional = !seenPositionalOption;
break; break;
case VSH_OT_DATA: case VSH_OT_DATA:
@ -400,6 +408,10 @@ vshCmddefCheckInternals(vshControl *ctl,
return -1; return -1;
} }
isRequired = true;
isPositional = true;
seenPositionalOption = true;
if (seenOptionalOption) { if (seenOptionalOption) {
vshError(ctl, "parameter '%s' of command '%s' must be listed before optional parameters", vshError(ctl, "parameter '%s' of command '%s' must be listed before optional parameters",
opt->name, cmd->name); opt->name, cmd->name);
@ -414,12 +426,28 @@ vshCmddefCheckInternals(vshControl *ctl,
opt->name, cmd->name); opt->name, cmd->name);
return -1; return -1;
} }
seenPositionalOption = true;
isPositional = true;
isRequired = true;
} else { } else {
seenOptionalOption = true; isPositional = false;
isRequired = false;
} }
break; break;
} }
if (opt->required != isRequired) {
vshError(ctl, "parameter '%s' of command '%s' 'required' state mismatch",
opt->name, cmd->name);
return -1;
}
if (opt->positional != isPositional) {
vshError(ctl, "parameter '%s' of command '%s' 'positional' state mismatch",
opt->name, cmd->name);
return -1;
}
} }
virBufferTrim(&complbuf, ", "); virBufferTrim(&complbuf, ", ");
@ -3241,6 +3269,7 @@ const vshCmdOptDef opts_echo[] = {
}, },
{.name = "string", {.name = "string",
.type = VSH_OT_ARGV, .type = VSH_OT_ARGV,
.positional = true,
.help = N_("arguments to echo") .help = N_("arguments to echo")
}, },
{.name = NULL} {.name = NULL}
@ -3379,6 +3408,7 @@ cmdSelfTest(vshControl *ctl, const vshCmd *cmd)
const vshCmdOptDef opts_complete[] = { const vshCmdOptDef opts_complete[] = {
{.name = "string", {.name = "string",
.type = VSH_OT_ARGV, .type = VSH_OT_ARGV,
.positional = true,
.flags = VSH_OFLAG_EMPTY_OK, .flags = VSH_OFLAG_EMPTY_OK,
.help = N_("partial string to autocomplete") .help = N_("partial string to autocomplete")
}, },

View File

@ -133,6 +133,8 @@ struct _vshCmdInfo {
struct _vshCmdOptDef { struct _vshCmdOptDef {
const char *name; /* the name of option, or NULL for list end */ const char *name; /* the name of option, or NULL for list end */
vshCmdOptType type; /* option type */ vshCmdOptType type; /* option type */
bool required; /* option is required */
bool positional; /* option is a positional option (not requiring '--optionname') */
unsigned int flags; /* flags */ unsigned int flags; /* flags */
const char *help; /* non-NULL help string; or for VSH_OT_ALIAS const char *help; /* non-NULL help string; or for VSH_OT_ALIAS
* the name of a later public option */ * the name of a later public option */