From nobody Tue Apr 30 06:30:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1643309132; cv=none; d=zohomail.com; s=zohoarc; b=BUiGYXIqJui4MjJmS1ZYR0ziDet8fYcmzLoYHZf2OFKp/FcMtAJbyGmeOR5WGevf3k/SkvQwcRNPHNXyvLHsz+tZRNEbTCb2kflYlUeqQxZxrwo5WJ2axCtumV2uV/QnCdIuAUej8+vBegnZ0kLg+qtVReZLkRFs6HcOGNVRh4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643309132; 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=hL/5nQk6Uv1wXP/Mv3Heg2p4ASlnhe8G0oppJzAUqIY=; b=bB8eUVO7LfKysoSmgI9ujUnEew+sfIkvnToy8ajS7vjzc71/fC2eGETA7iMeWrpnwktdVRMvQDc/zF68G87TRmymNigj+fNr7OBysIEya7k42Iofr9H/NujxhljlKQd6IaSIbKpyqJ+J9+kPEIXAxEYERk/NpK+KXzfX57+vqSQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1643309129806411.3847963414722; Thu, 27 Jan 2022 10:45:29 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-119-dPs_BbMaM7OBXiBELh1aNQ-1; Thu, 27 Jan 2022 13:45:25 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A50421091DB6; Thu, 27 Jan 2022 18:45:19 +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 3534E7D5B4; Thu, 27 Jan 2022 18:45:19 +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 853B71809CB8; Thu, 27 Jan 2022 18:45:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20RIjH4e002677 for ; Thu, 27 Jan 2022 13:45:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id B6ACD85898; Thu, 27 Jan 2022 18:45:17 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D8A8858B8 for ; Thu, 27 Jan 2022 18:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643309129; 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=hL/5nQk6Uv1wXP/Mv3Heg2p4ASlnhe8G0oppJzAUqIY=; b=SKCxnZGtRwv2oSeDMu+dVo8RBNwRJrEYB6aYoN3+juN/Y6dAhONPXkS2ADJdlHkV7kEnS0 04QoR8Icm4DUfxY7mPp+j0n5Y54a16WdUONMl8hiEA2OS2M2KJZXt+xEDaj9fLdAWAeXhQ M0mfPlmW9lH5Bv+NZV9ZlFpnkDtxDAA= X-MC-Unique: dPs_BbMaM7OBXiBELh1aNQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCHv2 1/2] virsh: domsetlaunchsecstate: report error if no options are passed Date: Thu, 27 Jan 2022 19:44:55 +0100 Message-Id: <141c5a3321215c49110e10213cd51dfddd014427.1643309033.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.12 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643309134150100003 We already exit if they are not present. Report an error, but do not mark them as required in case a future version of this command will want to accept a different set of parameters. https://bugzilla.redhat.com/show_bug.cgi?id=3D2046024 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- tools/virsh-domain.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index b56f6a90f5..43d310f2af 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9627,8 +9627,10 @@ cmdDomSetLaunchSecState(vshControl * ctl, const vshC= md * cmd) if (vshCommandOptStringReq(ctl, cmd, "secret", &secfile) < 0) return false; =20 - if (sechdrfile =3D=3D NULL || secfile =3D=3D NULL) + if (sechdrfile =3D=3D NULL || secfile =3D=3D NULL) { + vshError(ctl, "%s", _("Both secret and the secret header are requi= red")); return false; + } =20 if (virFileReadAll(sechdrfile, 1024*64, &sechdr) < 0) { vshSaveLibvirtError(); --=20 2.31.1 From nobody Tue Apr 30 06:30:39 2024 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=1643309141; cv=none; d=zohomail.com; s=zohoarc; b=F0yrG+oNXkXrIRwiRUfhosN87hhAzoIYwOaOO8+DDFRlvqe+Hi4/SgB0aT4F8cbl5ZVOoTMkROQzGrd18g38pJcGuIARuVfpUNtHpsuJsAURZZA8A0YmfyuTX1T7VdETUPcgrIRlhhVYyt5vZ56sZ1TCd76Xd2My+F4tRtNJlN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643309141; 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=RwrLh+hUQfO67GT8KWyw2lD/TDqeSgW7503Xyz2vMf0=; b=FQ/F0p/r8IsLBAASZxSmrbB6krqb+MtlD9zZEC5oAlcqwbgM+L9i6A6AcWtZx0tJbga79KHaEgHzFLhPWo8eFWIU9AZg4LtljBcoKVNZ5WA/zE51FfbwQ0oj0HNBAypM4gQT3pEIXqqjjfk+0VMuK0tvhW8wu3GY/loFCde0AVc= 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 1643309141569725.4834395069174; Thu, 27 Jan 2022 10:45:41 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-52-53OPQGQPOjqpkZfPpoyskQ-1; Thu, 27 Jan 2022 13:45:36 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4900F8143E5; Thu, 27 Jan 2022 18:45:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2BD8B7D5B2; Thu, 27 Jan 2022 18:45:31 +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 EA9C64A7CA; Thu, 27 Jan 2022 18:45:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20RIjIl1002685 for ; Thu, 27 Jan 2022 13:45:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id BA95985899; Thu, 27 Jan 2022 18:45:18 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 222DF858A3 for ; Thu, 27 Jan 2022 18:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643309140; 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=RwrLh+hUQfO67GT8KWyw2lD/TDqeSgW7503Xyz2vMf0=; b=EA9cs3EIj4wq6mIttxP4bbyYZFPGBl+go26dsE/YxSXvFuBxxwTxq1nUyYn8uPKL6DtAVI I5DmASsPSLIUcYavJH4HERgloXlOdaNQvEENpLYSXLkP5p8FnXbhQlnX9sIB48JIGWWnc9 uihckf9oIRKbd4KHDRNvsAtQH+4s6Hk= X-MC-Unique: 53OPQGQPOjqpkZfPpoyskQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCHv2 2/2] qemu: qemuDomainSetLaunchSecurityState: check for params presence Date: Thu, 27 Jan 2022 19:44:56 +0100 Message-Id: <3a8a95da4a7d5be6d244f9c2149978ded23dec8f.1643309033.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.12 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643309144166100001 We require the header and the secret to be present. Use a different approach to virParams to report an error if they are not present, instead of trying to pass empty arguments to QEMU via QMP. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0a1ba74e65..9b346e5cf0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19975,10 +19975,9 @@ qemuDomainSetLaunchSecurityState(virDomainPtr doma= in, virDomainObj *vm; int ret =3D -1; int rc; - size_t i; g_autoptr(virQEMUCaps) qemucaps =3D NULL; - g_autofree char *secrethdr =3D NULL; - g_autofree char *secret =3D NULL; + const char *secrethdr =3D NULL; + const char *secret =3D NULL; unsigned long long setaddr =3D 0; bool hasSetaddr =3D false; int state; @@ -20019,19 +20018,25 @@ qemuDomainSetLaunchSecurityState(virDomainPtr dom= ain, goto cleanup; } =20 - for (i =3D 0; i < nparams; i++) { - virTypedParameterPtr param =3D ¶ms[i]; - - if (STREQ(param->field, VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_HEAD= ER)) { - secrethdr =3D g_strdup(param->value.s); - } else if (STREQ(param->field, VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECR= ET)) { - secret =3D g_strdup(param->value.s); - } else if (STREQ(param->field, VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECR= ET_SET_ADDRESS)) { - setaddr =3D param->value.ul; - hasSetaddr =3D true; - } + if (virTypedParamsGetString(params, nparams, + VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_HEAD= ER, + &secrethdr) < 0 || + virTypedParamsGetString(params, nparams, + VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET, + &secret) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", + _("Both secret and the secret header are required")= ); + goto cleanup; } =20 + if ((rc =3D virTypedParamsGetULLong(params, nparams, + VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRE= T_SET_ADDRESS, + &setaddr)) < 0) + goto cleanup; + else if (rc =3D=3D 1) + hasSetaddr =3D true; + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; =20 --=20 2.31.1