From nobody Mon Feb 9 00:07:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629462742; cv=none; d=zohomail.com; s=zohoarc; b=KK7ZJ1Xn61Xg1Pb79SVZhOM/XwxExxo9aMBbZCAIB3MS4CsQetBoYyk7qHrtu5l/OMFjnB+rjVdS81Kq2Dk4CxKlP60L9WKAY7Rvw1utbW5AjzvSnRTYg3Yoocktm8YQ2S4sJvH/BUbtUNQ/oI/HFEJjcV9t4w1wYPoTolhlB8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629462742; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0nL04W+4v1j8KL+4pgwivdYM+QYLPE58LB8eUZCMTJE=; b=Siq2E6ncq/9AE8HZIyZidGUgF+volwL51RCrQfWwFYVY5JFc0dc2sb9qotyqpBbeZRT8xqLK5W2OhgOHPkHGM8DxrIZOLAwFpR+E3faIyZa8u2gpo5oL+no3PfmtasQZjpTd8Rz7oKXK/xrSjQDiYhcIQgI8bYQCCwfRzMJyfOs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1629462742904478.33855483510854; Fri, 20 Aug 2021 05:32:22 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-146-rDqRqqbYPtS5eKCtM1Fs5w-1; Fri, 20 Aug 2021 08:32:19 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F04871082920; Fri, 20 Aug 2021 12:32:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B219718A66; Fri, 20 Aug 2021 12:32:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 81365181A137; Fri, 20 Aug 2021 12:32:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KCUppN011233 for ; Fri, 20 Aug 2021 08:30:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 602503AFD; Fri, 20 Aug 2021 12:30:51 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD2061A26A for ; Fri, 20 Aug 2021 12:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629462741; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0nL04W+4v1j8KL+4pgwivdYM+QYLPE58LB8eUZCMTJE=; b=cRm/rUSlyHaz2EAFszmt34q9xgqpjnrlawBh2TMwMqPo2Ld10o3LgmBTrDM9mIETKt3vtd HmhSg+5B00R3660ur0EG7Nax0TqWXxhfYI1qVm/IWjZnMHG4oGT/KOz5UhyuwhbAX4n1Tu lY5rMkFjYRqHDsH8rTXmmwOt5VjzqeM= X-MC-Unique: rDqRqqbYPtS5eKCtM1Fs5w-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH 4/4] virsh: add support for '--validate' option in define secret Date: Fri, 20 Aug 2021 14:30:40 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629462743351100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova --- docs/manpages/virsh.rst | 4 +++- tools/virsh-secret.c | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 3eb310d02e..de6d6ee1c2 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -6697,13 +6697,15 @@ secret-define =20 :: =20 - secret-define file + secret-define file [--validate] =20 Create a secret with the properties specified in *file*, with no associated secret value. If *file* does not specify a UUID, choose one automatically. If *file* specifies a UUID of an existing secret, replace its properties by properties defined in *file*, without affecting the secret value. =20 +Optionally, the format of the input XML file can be validated against an +internal RNG schema with *--validate*. =20 secret-dumpxml -------------- diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index dde0d26398..173a77fd90 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -73,6 +73,10 @@ static const vshCmdInfo info_secret_define[] =3D { =20 static const vshCmdOptDef opts_secret_define[] =3D { VIRSH_COMMON_OPT_FILE(N_("file containing secret attributes in XML")), + {.name =3D "validate", + .type =3D VSH_OT_BOOL, + .help =3D N_("validate the XML against the schema") + }, {.name =3D NULL} }; =20 @@ -84,15 +88,19 @@ cmdSecretDefine(vshControl *ctl, const vshCmd *cmd) virSecretPtr res; char uuid[VIR_UUID_STRING_BUFLEN]; bool ret =3D false; + unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; =20 + if (vshCommandOptBool(cmd, "validate")) + flags |=3D VIR_SECRET_DEFINE_VALIDATE; + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; =20 - if (!(res =3D virSecretDefineXML(priv->conn, buffer, 0))) { + if (!(res =3D virSecretDefineXML(priv->conn, buffer, flags))) { vshError(ctl, _("Failed to set attributes from %s"), from); goto cleanup; } --=20 2.31.1