</disks>
</domainsnapshot>
-
EOF
-virsh -c $test_url snapshot-create-as --print-xml test \
+virsh -q -c $test_url snapshot-create-as --print-xml test \
--diskspec 'vda,file=a&b,,c,snapshot=external' --description '1<2' \
--diskspec vdb >out 2>>err || fail=1
compare out exp-out || fail=1
+cat <<\EOF > exp-out || framework_failure
+<domainsnapshot>
+ <name>name</name>
+ <description>vda</description>
+ <disks>
+ <disk name='vdb'/>
+ </disks>
+</domainsnapshot>
+
+EOF
+virsh -q -c $test_url snapshot-create-as --print-xml test name vda vdb \
+ >out 2>>err || fail=1
+compare out exp-out || fail=1
+
+cat <<\EOF > exp-out || framework_failure
+<domainsnapshot>
+ <name>name</name>
+ <description>desc</description>
+ <disks>
+ <disk name='vda'/>
+ <disk name='vdb'/>
+ </disks>
+</domainsnapshot>
+
+EOF
+for args in \
+ 'test name desc vda vdb' \
+ 'test name desc --diskspec vda vdb' \
+ 'test name desc --diskspec vda --diskspec vdb' \
+ 'test name desc vda vdb' \
+ 'test --diskspec vda name --diskspec vdb desc' \
+ '--description desc --name name --domain test vda vdb' \
+; do
+ virsh -q -c $test_url snapshot-create-as --print-xml $args \
+ >out 2>>err || fail=1
+ compare out exp-out || fail=1
+done
+
test -s err && fail=1
(exit $fail); exit $fail
/* Grab least-significant set bit */
i = ffs(*opts_need_arg) - 1;
opt = &cmd->opts[i];
- if (opt->type != VSH_OT_ARGV)
+ if (opt->type != VSH_OT_ARGV) {
*opts_need_arg &= ~(1 << i);
- *opts_seen |= 1 << i;
+ *opts_seen |= 1 << i;
+ }
return opt;
}
char buf[256];
uint32_t opts_need_arg;
uint32_t opts_required;
+ bool shortopt = false; /* true if 'arg' works instead of '--opt arg' */
if (vshCmddefOptParse(def, &opts_need_arg, &opts_required)) {
vshError(ctl, _("internal error: bad options in command: '%s'"),
/* xgettext:c-format */
fmt = ((opt->flags & VSH_OFLAG_REQ) ? "<%s>"
: _("[--%s <number>]"));
+ if (!(opt->flags & VSH_OFLAG_REQ_OPT))
+ shortopt = true;
break;
case VSH_OT_STRING:
/* xgettext:c-format */
fmt = _("[--%s <string>]");
+ if (!(opt->flags & VSH_OFLAG_REQ_OPT))
+ shortopt = true;
break;
case VSH_OT_DATA:
fmt = ((opt->flags & VSH_OFLAG_REQ) ? "<%s>" : "[<%s>]");
+ if (!(opt->flags & VSH_OFLAG_REQ_OPT))
+ shortopt = true;
break;
case VSH_OT_ARGV:
/* xgettext:c-format */
- fmt = (opt->flags & VSH_OFLAG_REQ) ? _("<%s>...")
- : _("[<%s>]...");
+ if (shortopt) {
+ fmt = (opt->flags & VSH_OFLAG_REQ)
+ ? _("{[--%s] <string>}...")
+ : _("[[--%s] <string>]...");
+ } else {
+ fmt = (opt->flags & VSH_OFLAG_REQ) ? _("<%s>...")
+ : _("[<%s>]...");
+ }
break;
default:
assert(0);
opt->name);
break;
case VSH_OT_ARGV:
- /* Not really an option. */
- snprintf(buf, sizeof(buf), _("<%s>"), opt->name);
+ snprintf(buf, sizeof(buf),
+ shortopt ? _("[--%s] <string>") : _("<%s>"),
+ opt->name);
break;
default:
assert(0);
=item B<snapshot-create-as> I<domain> {[I<--print-xml>]
| [I<--no-metadata>] [I<--halt>]} [I<name>] [I<description>]
-[I<--disk-only> [I<diskspec>]...]
+[I<--disk-only> [[I<--diskspec>] B<diskspec>]...
Create a snapshot for domain I<domain> with the given <name> and
<description>; if either value is omitted, libvirt will choose a
arguments to add <disk> elements to the xml. Each <diskspec> is in the
form B<disk[,snapshot=type][,driver=type][,file=name]>. To include a
literal comma in B<disk> or in B<file=name>, escape it with a second
-comma. For example, a diskspec of "vda,snapshot=external,file=/path/to,,new"
+comma. A literal I<--diskspec> must preceed each B<diskspec> unless
+all three of I<domain>, I<name>, and I<description> are also present.
+For example, a diskspec of "vda,snapshot=external,file=/path/to,,new"
results in the following XML:
<disk name='vda' snapshot='external'>
<source file='/path/to,new'/>