From nobody Thu May 16 17:17:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530714801183588.5362585926669; Wed, 4 Jul 2018 07:33:21 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 246A83082137; Wed, 4 Jul 2018 14:33:20 +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 DE0EF5DA62; Wed, 4 Jul 2018 14:33: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 7DB0918037ED; Wed, 4 Jul 2018 14:33:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w64EX6eX011950 for ; Wed, 4 Jul 2018 10:33:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 542FF215688A; Wed, 4 Jul 2018 14:33:06 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBBA62156880 for ; Wed, 4 Jul 2018 14:33:05 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 4 Jul 2018 16:40:55 +0200 Message-Id: <838c9f6a43d8881d0b01d6cece0877d3ffe48061.1530715196.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] qemu: hotplug: Do not try to add secret object for TLS if it does not exist 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 04 Jul 2018 14:33:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The check whether the object holding secret for decryption of the TLS environment was wrong and would always attempt to add the object. This lead to a crash due to recent refactors. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1598015 Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 23f6d1daba..fe99c0aca2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1338,7 +1338,7 @@ qemuDomainAddTLSObjects(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1; - if (secProps && + if (secProps && *secProps && qemuMonitorAddObject(priv->mon, secProps, &secAlias) < 0) goto error; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 16 17:17:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530714792705502.04317988916205; Wed, 4 Jul 2018 07:33:12 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4BE555F725; Wed, 4 Jul 2018 14:33:11 +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 C85471001643; Wed, 4 Jul 2018 14:33:10 +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 6F08E4A465; Wed, 4 Jul 2018 14:33:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w64EX7kR011960 for ; Wed, 4 Jul 2018 10:33:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id ECBD5215688A; Wed, 4 Jul 2018 14:33:06 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90DE62156880 for ; Wed, 4 Jul 2018 14:33:06 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 4 Jul 2018 16:40:56 +0200 Message-Id: <904195ffaf38be57b29160923eb305e4bd024345.1530715196.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] qemu: monitor: Make qemuMonitorAddObject more robust against programming errors 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 04 Jul 2018 14:33:11 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Document and check that @props contains a pointer to a json object and check that both necessary fields are present. Also marm @props as NONNULL. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor.c | 22 ++++++++++++++++------ src/qemu/qemu_monitor.h | 3 ++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 6ed475ede0..c1afe21cc1 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3073,8 +3073,9 @@ qemuMonitorCreateObjectProps(virJSONValuePtr *propsre= t, /** * qemuMonitorAddObject: * @mon: Pointer to monitor object - * @props: Optional arguments for the given type. The object is consumed a= nd - * the pointer is cleared. + * @props: Pointer to a JSON object holding configuration of the object to= add. + * The object must be non-null and contain at least the "qom-type"= and + * "id" field. The object is consumed and the pointer is cleared. * @alias: If not NULL, returns the alias of the added object if it was ad= ded * successfully to qemu. Caller should free the returned pointer. * @@ -3085,18 +3086,27 @@ qemuMonitorAddObject(qemuMonitorPtr mon, virJSONValuePtr *props, char **alias) { - const char *type =3D virJSONValueObjectGetString(*props, "qom-type"); - const char *id =3D virJSONValueObjectGetString(*props, "id"); + const char *type =3D NULL; + const char *id =3D NULL; char *tmp =3D NULL; int ret =3D -1; + if (!*props) { + virReportError(VIR_ERR_INTERNAL_ERROR, _("object props can't be NU= LL")); + goto cleanup; + } + + type =3D virJSONValueObjectGetString(*props, "qom-type"); + id =3D virJSONValueObjectGetString(*props, "id"); + VIR_DEBUG("type=3D%s id=3D%s", NULLSTR(type), NULLSTR(id)); QEMU_CHECK_MONITOR_GOTO(mon, cleanup); - if (!id) { + if (!id || !type) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing alias for qemu object '%s'"), NULLSTR(ty= pe)); + _("missing alias or qom-type for qemu object '%s'"), + NULLSTR(type)); goto cleanup; } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index b3d62324b4..e8adda8aa0 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -812,7 +812,8 @@ int qemuMonitorCreateObjectProps(virJSONValuePtr *props= ret, int qemuMonitorAddObject(qemuMonitorPtr mon, virJSONValuePtr *props, - char **alias); + char **alias) + ATTRIBUTE_NONNULL(1); int qemuMonitorDelObject(qemuMonitorPtr mon, const char *objalias); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list