virsh: Add "validate" argument to [hypervisor-]cpu-compare

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Tim Wiederhake 2020-10-07 10:54:58 +02:00 committed by Peter Krempa
parent 4c3ed3b84e
commit 9702659807
2 changed files with 20 additions and 3 deletions

View File

@ -866,7 +866,7 @@ cpu-compare
::
cpu-compare FILE [--error]
cpu-compare FILE [--error] [--validate]
Compare CPU definition from XML <file> with host CPU. (See
``hypervisor-cpu-compare`` command for comparing the CPU definition with the CPU
@ -882,7 +882,8 @@ the CPU definition. For more information on guest CPU definition see:
`https://libvirt.org/formatdomain.html#elementsCPU <https://libvirt.org/formatdomain.html#elementsCPU>`__. If *--error* is
specified, the command will return an error when the given CPU is
incompatible with host CPU and a message providing more details about the
incompatibility will be printed out.
incompatibility will be printed out. If *--validate* is specified, validates
the format of the XML document against an internal RNG schema.
cpu-models
@ -928,7 +929,7 @@ hypervisor-cpu-compare
::
hypervisor-cpu-compare FILE [virttype] [emulator] [arch] [machine] [--error]
hypervisor-cpu-compare FILE [virttype] [emulator] [arch] [machine] [--error] [--validate]
Compare CPU definition from XML <file> with the CPU the hypervisor is able to
provide on the host. (This is different from ``cpu-compare`` which compares the
@ -951,6 +952,8 @@ specifies the path to the emulator, *arch* specifies the CPU architecture, and
*machine* specifies the machine type. If *--error* is specified, the command
will return an error when the given CPU is incompatible with the host CPU and a
message providing more details about the incompatibility will be printed out.
If *--validate* is specified, validates the format of the XML document against
an internal RNG schema.
hypervisor-cpu-baseline

View File

@ -1214,6 +1214,10 @@ static const vshCmdOptDef opts_cpu_compare[] = {
.type = VSH_OT_BOOL,
.help = N_("report error if CPUs are incompatible")
},
{.name = "validate",
.type = VSH_OT_BOOL,
.help = N_("validate the XML document against schema")
},
{.name = NULL}
};
@ -1230,6 +1234,9 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "error"))
flags |= VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE;
if (vshCommandOptBool(cmd, "validate"))
flags |= VIR_CONNECT_COMPARE_CPU_VALIDATE_XML;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false;
@ -1636,6 +1643,10 @@ static const vshCmdOptDef opts_hypervisor_cpu_compare[] = {
.type = VSH_OT_BOOL,
.help = N_("report error if CPUs are incompatible")
},
{.name = "validate",
.type = VSH_OT_BOOL,
.help = N_("validate the XML document against schema")
},
{.name = NULL}
};
@ -1657,6 +1668,9 @@ cmdHypervisorCPUCompare(vshControl *ctl,
if (vshCommandOptBool(cmd, "error"))
flags |= VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE;
if (vshCommandOptBool(cmd, "validate"))
flags |= VIR_CONNECT_COMPARE_CPU_VALIDATE_XML;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0 ||
vshCommandOptStringReq(ctl, cmd, "virttype", &virttype) < 0 ||
vshCommandOptStringReq(ctl, cmd, "emulator", &emulator) < 0 ||