diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index b33e6a3a86..5f5f48f83e 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -6574,7 +6574,7 @@ vol-create :: - vol-create pool-or-uuid FILE [--prealloc-metadata] + vol-create pool-or-uuid FILE [--prealloc-metadata] [--validate] Create a volume from an XML . @@ -6589,6 +6589,9 @@ support full allocation). This option creates a sparse image file with metadata, resulting in higher performance compared to images with no preallocation and only slightly higher initial disk space usage. +If *--validate* is specified, validates the format of the XML document against +an internal RNG schema. + **Example:** :: @@ -6606,7 +6609,7 @@ vol-create-from :: vol-create-from pool-or-uuid FILE vol-name-or-key-or-path - [--inputpool pool-or-uuid] [--prealloc-metadata] [--reflink] + [--inputpool pool-or-uuid] [--prealloc-metadata] [--reflink] [--validate] Create a volume, using another volume as input. @@ -6628,6 +6631,8 @@ When *--reflink* is specified, perform a COW lightweight copy, where the data blocks are copied only when modified. If this is not possible, the copy fails. +If *--validate* is specified, validates the format of the XML document against +an internal RNG schema. vol-create-as ------------- diff --git a/include/libvirt/libvirt-storage.h b/include/libvirt/libvirt-storage.h index af1c50b9f1..aaad4a3da1 100644 --- a/include/libvirt/libvirt-storage.h +++ b/include/libvirt/libvirt-storage.h @@ -437,6 +437,7 @@ const char* virStorageVolGetKey (virStorageVolPtr vol); typedef enum { VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA = 1 << 0, /* (Since: 1.0.1) */ VIR_STORAGE_VOL_CREATE_REFLINK = 1 << 1, /* perform a btrfs lightweight copy (Since: 1.2.13) */ + VIR_STORAGE_VOL_CREATE_VALIDATE = 1 << 2, /* Validate the XML document against schema (Since: 8.10.0) */ } virStorageVolCreateFlags; virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool, diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 300a0aa8e5..4f23481180 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -380,6 +380,10 @@ static const vshCmdOptDef opts_vol_create[] = { .type = VSH_OT_BOOL, .help = N_("preallocate metadata (for qcow2 instead of full allocation)") }, + {.name = "validate", + .type = VSH_OT_BOOL, + .help = N_("validate the XML against the schema") + }, {.name = NULL} }; @@ -395,6 +399,9 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "prealloc-metadata")) flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA; + if (vshCommandOptBool(cmd, "validate")) + flags |= VIR_STORAGE_VOL_CREATE_VALIDATE; + if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL))) return false; @@ -446,6 +453,10 @@ static const vshCmdOptDef opts_vol_create_from[] = { .type = VSH_OT_BOOL, .help = N_("use btrfs COW lightweight copy") }, + {.name = "validate", + .type = VSH_OT_BOOL, + .help = N_("validate the XML against the schema") + }, {.name = NULL} }; @@ -468,6 +479,9 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "reflink")) flags |= VIR_STORAGE_VOL_CREATE_REFLINK; + if (vshCommandOptBool(cmd, "validate")) + flags |= VIR_STORAGE_VOL_CREATE_VALIDATE; + if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false;