We exit if they are not present.
Let the virsh option parser do the checking instead of checking
it manually. Change the type to OT_DATA (i.e. a mandatory string),
mark them as required and remove VSH_OFLAG_REQ_OPT so that the
header file and the secret file can be specified without the option
names.
https://bugzilla.redhat.com/show_bug.cgi?id=2046024
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
tools/virsh-domain.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index b56f6a90f5..d279af68b2 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9587,13 +9587,13 @@ static const vshCmdInfo info_domsetlaunchsecstate[] = {
static const vshCmdOptDef opts_domsetlaunchsecstate[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "secrethdr",
- .type = VSH_OT_STRING,
- .flags = VSH_OFLAG_REQ_OPT,
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ,
.help = N_("path to file containing the secret header"),
},
{.name = "secret",
- .type = VSH_OT_STRING,
- .flags = VSH_OFLAG_REQ_OPT,
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ,
.help = N_("path to file containing the secret"),
},
{.name = "set-address",
@@ -9627,9 +9627,6 @@ cmdDomSetLaunchSecState(vshControl * ctl, const vshCmd * cmd)
if (vshCommandOptStringReq(ctl, cmd, "secret", &secfile) < 0)
return false;
- if (sechdrfile == NULL || secfile == NULL)
- return false;
-
if (virFileReadAll(sechdrfile, 1024*64, &sechdr) < 0) {
vshSaveLibvirtError();
return false;
--
2.31.1