diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index e9f0ee0810..be11a7491c 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -251,10 +251,12 @@ virshParseSnapshotDiskspec(vshControl *ctl, virBufferPtr buf, const char *str)
const char *name = NULL;
const char *snapshot = NULL;
const char *driver = NULL;
+ const char *stype = NULL;
const char *file = NULL;
char **array = NULL;
int narray;
size_t i;
+ bool isFile = true;
narray = vshStringToArray(str, &array);
if (narray <= 0)
@@ -266,6 +268,8 @@ virshParseSnapshotDiskspec(vshControl *ctl, virBufferPtr buf, const char *str)
snapshot = array[i] + strlen("snapshot=");
else if (!driver && STRPREFIX(array[i], "driver="))
driver = array[i] + strlen("driver=");
+ else if (!stype && STRPREFIX(array[i], "stype="))
+ stype = array[i] + strlen("stype=");
else if (!file && STRPREFIX(array[i], "file="))
file = array[i] + strlen("file=");
else
@@ -275,13 +279,26 @@ virshParseSnapshotDiskspec(vshControl *ctl, virBufferPtr buf, const char *str)
virBufferEscapeString(buf, "\n");
virBufferAdjustIndent(buf, 2);
if (driver)
virBufferAsprintf(buf, "\n", driver);
- if (file)
- virBufferEscapeString(buf, "\n", file);
+ if (file) {
+ if (isFile)
+ virBufferEscapeString(buf, "\n", file);
+ else
+ virBufferEscapeString(buf, "\n", file);
+ }
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "\n");
} else {
@@ -351,7 +368,7 @@ static const vshCmdOptDef opts_snapshot_create_as[] = {
},
{.name = "diskspec",
.type = VSH_OT_ARGV,
- .help = N_("disk attributes: disk[,snapshot=type][,driver=type][,file=name]")
+ .help = N_("disk attributes: disk[,snapshot=type][,driver=type][,stype=type][,file=name]")
},
{.name = NULL}
};
diff --git a/tools/virsh.pod b/tools/virsh.pod
index dc39004a66..5168fa96b6 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -4676,11 +4676,14 @@ The I<--diskspec> option can be used to control how I<--disk-only> and
external full system snapshots create external files. This option can occur
multiple times, according to the number of elements in the domain
xml. Each is in the
-form B. A I
-must be provided for disks backed by block devices as libvirt doesn't
-auto-generate file names for those. To include a
-literal comma in B or in B, escape it with a second
-comma. A literal I<--diskspec> must precede each B unless
+form B.
+A I must be provided for disks backed by block devices as libvirt
+doesn't auto-generate file names for those. The optional B parameter
+allows to control the type of the source file. Supported values are 'file'
+(default) and 'block'.
+
+To include a literal comma in B or in B, escape it with a
+second comma. A literal I<--diskspec> must precede each B unless
all three of I, I, and I are also present.
For example, a diskspec of "vda,snapshot=external,file=/path/to,,new"
results in the following XML: