From: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx> Current disk could accept both 'readonly' and 'shareable' at the same time. But '--mode' could only accept one parameter. This patch enables '--mode' accept parameters like examples below: virsh # attach-disk domain /home/1.img sdd --mode shareable,readonly Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx> --- tools/virsh-domain.c | 22 +++++++++++++++++++--- tools/virsh.pod | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 856e888..ba67a69 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -563,7 +563,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) } if (mode) { - if (STRNEQ(mode, "readonly") && STRNEQ(mode, "shareable")) { + if (!(STRPREFIX(mode, "readonly") || + STRPREFIX(mode, "shareable"))) { vshError(ctl, _("No support for %s in command 'attach-disk'"), mode); goto cleanup; @@ -600,8 +601,23 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) (isFile) ? "file" : "dev", source); virBufferAsprintf(&buf, " <target dev='%s'/>\n", target); - if (mode) - virBufferAsprintf(&buf, " <%s/>\n", mode); + if (mode) { + if (STRPREFIX(mode, "readonly")) { + virBufferAddLit(&buf, " <readonly/>\n"); + } else { + virBufferAddLit(&buf, " <shareable/>\n"); + } + + char *rest; + if ((rest = strchr(mode, ','))) { + rest++; + if (STRPREFIX(rest, "readonly")) { + virBufferAddLit(&buf, " <readonly/>\n"); + } else if (STRPREFIX(rest, "shareable")) { + virBufferAddLit(&buf, " <shareable/>\n"); + } + } + } if (serial) virBufferAsprintf(&buf, " <serial>%s</serial>\n", serial); diff --git a/tools/virsh.pod b/tools/virsh.pod index e12a800..f6a80a3 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1915,7 +1915,7 @@ expected. =item B<attach-disk> I<domain> I<source> I<target> [[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]] [I<--driver driver>] [I<--subdriver subdriver>] [I<--cache cache>] -[I<--type type>] [I<--mode mode>] [I<--config>] [I<--sourcetype soucetype>] +[I<--type type>] [I<--mode mode[,mode2]>] [I<--config>] [I<--sourcetype soucetype>] [I<--serial serial>] [I<--wwn wwn>] [I<--shareable>] [I<--rawio>] [I<--address address>] [I<--multifunction>] [I<--print-xml>] -- 1.8.2.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list