From nobody Thu May 2 23:05:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1591402525; cv=none; d=zohomail.com; s=zohoarc; b=Zwx2+phb7JphHxyR3j+aZCmThaZHw8dgyQ9JszrcNegRysNrtwxTS5jF17o5odEiWzqSyYuIJzJOIboLvJKt4A+azYUK3qDOZTARtPyzf/bzkMX3EJKh/86Xz7lHd2da+RKFIroV+f6m9oWxSKv6+ywPkmwfjCS/iNizneYpNdI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591402525; 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=bK0Acy7hB7gioZWMkqEiGSSXUA48CfwiCcgKoSoVClc=; b=FNZ2j0MGH8ZtClz2VoKwNC/0eQhrZ1NuiYX5+jJv7y/NjT/f3CLD83MVCziviFSef1WCpaKlOTvVnWFQYCoGP1awrarpJqbD0Zd+ZqnnqVchXshSPlLqp2LfUOwRjbyNFH0r7vtnbAcZ0J0GQJasJ8+mA9izbz8N2Etmr3Dlbl0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1591402525446209.86026277875237; Fri, 5 Jun 2020 17:15:25 -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-320-usZy0LgdMBeHDR7GeUsQWQ-1; Fri, 05 Jun 2020 20:15:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 98804107ACCD; Sat, 6 Jun 2020 00:15:16 +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 7715D78FDE; Sat, 6 Jun 2020 00:15:16 +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 4BE5314CE7; Sat, 6 Jun 2020 00:15:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 054IiFWA002436 for ; Thu, 4 Jun 2020 14:44:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8F0F510013D6; Thu, 4 Jun 2020 18:44:15 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F1C8101E1C2 for ; Thu, 4 Jun 2020 18:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591402524; 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=bK0Acy7hB7gioZWMkqEiGSSXUA48CfwiCcgKoSoVClc=; b=cbJs9/jQpjZy9dU5gpQp3OfqjaGeIDjDL2+MZ0+N95yRsE56P9iHus07gakJGYUSEh1kmZ FT+w/QxS9eWSYYspLea0hBDhwQ6tf5y77En8oWoiUCj649s6AE6BvGLMr4GfkMrPXGpjRV n500srdP8pVOAHLjIviSwV1QdSHJBmE= X-MC-Unique: usZy0LgdMBeHDR7GeUsQWQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 1/8] domain_conf: Format NS always last Date: Thu, 4 Jun 2020 20:44:02 +0200 Message-Id: <53b4ec415935e97cc83dabece9fd9e2a7a6aeb20.1591296169.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" I think that since is kind of a hack, it doesn't deserve place in the front row. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1cdc7971fc..e84fbe1e21 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29877,16 +29877,16 @@ virDomainDefFormatInternalSetRootName(virDomainDe= fPtr def, for (n =3D 0; n < def->nseclabels; n++) virSecurityLabelDefFormat(buf, def->seclabels[n], flags); =20 - if (def->namespaceData && def->ns.format) { - if ((def->ns.format)(buf, def->namespaceData) < 0) - goto error; - } - if (def->keywrap) virDomainKeyWrapDefFormat(buf, def->keywrap); =20 virDomainSEVDefFormat(buf, def->sev); =20 + if (def->namespaceData && def->ns.format) { + if ((def->ns.format)(buf, def->namespaceData) < 0) + goto error; + } + virBufferAdjustIndent(buf, -2); virBufferAsprintf(buf, "\n", rootname); =20 --=20 2.26.2 From nobody Thu May 2 23:05:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1591402730; cv=none; d=zohomail.com; s=zohoarc; b=OaH6qZ5mGjinwrVvmfog9glvq+liyo6XEC9mCyy6THVnkBdSsw+rTv3AKO3HEpB6acJr+b2iEmxSQZs9sxybiLlaOL2p+qbwBJjeMM8eGZVj4DTtCye+AW5OpreGQtaHV2l6HKvUOjCFTH+9Fmtvfa/OqIWGo+JO+t/p+0UqL6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591402730; 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=N1ABTrErA8T2hpE+7KztaB0AqBiaHkUEhIKIfaQEfw8=; b=aH1J80/1mLZbwAtWCLGBZ4vv+e5qM81YK+bID0ukOFmPcAmFSd337sH955hKknUf+nypxltoaGKLk04QP3U75eL2I3m3BYn5QeEzuVq+MR+lxz0k4wweNB8+cHNw1InSP27Qjf44XP/FMwtwMlQT/YVgeMVCavU/q2AxsUHthjg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1591402730825592.3295923902759; Fri, 5 Jun 2020 17:18:50 -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-424-Ijj04Z0kMZaQ2wUnUPCIFg-1; Fri, 05 Jun 2020 20:18:47 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D1F118A8225; Sat, 6 Jun 2020 00:18:40 +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 D930210013D4; Sat, 6 Jun 2020 00:18:39 +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 A9A8C8742F; Sat, 6 Jun 2020 00:18:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 054IiGbp002445 for ; Thu, 4 Jun 2020 14:44:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6D4CB101E675; Thu, 4 Jun 2020 18:44:16 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id E226910013D6 for ; Thu, 4 Jun 2020 18:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591402729; 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=N1ABTrErA8T2hpE+7KztaB0AqBiaHkUEhIKIfaQEfw8=; b=BvGnOeCNZNNo6coh2L/cL3XPFO2yhunJYNaNpWTt7B5T4NF9UyKeh3cRFA5fPjkfX16NbE PKlTsF5n4LrHTMB8TtKGFato0kRplD9ULcW5dMNqcrkdKtesds/S0OYnjr5hOYFiNVvMI3 9H1rix0nEfQ5rjPOrBqSvQkN/DvJFWk= X-MC-Unique: Ijj04Z0kMZaQ2wUnUPCIFg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 2/8] virSysinfoParseXML: Mangle ctxt inside virSysinfoParseXML() Date: Thu, 4 Jun 2020 20:44:03 +0200 Message-Id: <51a7c6cfbbe0758bcb3b34f7f13f7b1e6a644826.1591296169.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There's no need to set ctxt->node outside of the function. The function can set it itself - it has all the info needed. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e84fbe1e21..57a5b7befe 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15714,10 +15714,13 @@ virSysinfoParseXML(xmlNodePtr node, unsigned char *domUUID, bool uuid_generated) { + VIR_XPATH_NODE_AUTORESTORE(ctxt); virSysinfoDefPtr def; xmlNodePtr tmpnode; g_autofree char *type =3D NULL; =20 + ctxt->node =3D node; + if (!virXMLNodeNameEqual(node, "sysinfo")) { virReportError(VIR_ERR_XML_ERROR, "%s", _("XML does not contain expected 'sysinfo' element"= )); @@ -22179,8 +22182,6 @@ virDomainDefParseXML(xmlDocPtr xml, } =20 if ((node =3D virXPathNode("./sysinfo[1]", ctxt)) !=3D NULL) { - VIR_XPATH_NODE_AUTORESTORE(ctxt); - ctxt->node =3D node; def->sysinfo =3D virSysinfoParseXML(node, ctxt, def->uuid, uuid_generated); =20 --=20 2.26.2 From nobody Thu May 2 23:05:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1591403104; cv=none; d=zohomail.com; s=zohoarc; b=HZtLAtkuF4kl9VLKnXqiDp7NWzGkmfMUKCOwvxZS2Y3kUfjiahveOkdgQEB3vJMgtp1dc7ie6j4h0SU4f6dJD5YrjDcEkesL50sLtGy06C4z0zm5aH7JIPeOkLee8mp5aJwNTzQDp53Vsd3xXP+LddNWgc4gr3SqkXTpo8HYxCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591403104; 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=/8vs5CoZNDQEoZkEhA728cBK3VFxNhp8WKWhJvLXVX0=; b=MoyJ8+9JMq6hLwk9D9wwcENleB92sK/fSbRyPMMOgxJZBu3iG+gaOdnv4UOqvJ1ywhobh90P5s5iyLOkp4hnLJSCkG/0qYuo6amvGJYItx9oBC7S+Nw2dWmftDvDM+xv4tvCW5uWct/iny8itfgMrpmRrfuQCBY72NK3xsoW3JM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1591403104364748.2431857212337; Fri, 5 Jun 2020 17:25:04 -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-402-9FIPQkoeNICKqX3rOFk5Ew-1; Fri, 05 Jun 2020 20:21:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4704A18FE86F; Sat, 6 Jun 2020 00:21:34 +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 2769360C1D; Sat, 6 Jun 2020 00:21:34 +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 EA987180530D; Sat, 6 Jun 2020 00:21:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 054IiHew002458 for ; Thu, 4 Jun 2020 14:44:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 762B2101E675; Thu, 4 Jun 2020 18:44:17 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id C195510013D6 for ; Thu, 4 Jun 2020 18:44:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591403102; 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=/8vs5CoZNDQEoZkEhA728cBK3VFxNhp8WKWhJvLXVX0=; b=L760Ab4+v3CGOIGAOKqngAjTnOuSOe4uX1wtl+oZgn2zTQZ0yimn7AjEt+D1AFfg8PrbWe RqPVK5AzOdvyz4xZQNx004VDTuiLm4+wn6w0n/tCNI2lYXAKRQBAefx0Ov82wsbapJDq1l V+4GHPmgBWn9M+4HU82PE/n8IuTze64= X-MC-Unique: 9FIPQkoeNICKqX3rOFk5Ew-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 3/8] conf: Add firmware blob configuration Date: Thu, 4 Jun 2020 20:44:04 +0200 Message-Id: <894fc8b38934b4a3f1c78ac4b651ec1296f401ea.1591296169.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" QEMU has -fw_cfg which allows users to tweak how firmware configures itself and/or provide new configuration blobs. Introduce new type "fwcfg" that will hold these new blobs. It's possible to either specify new value as a string or provide a filename which contents then serve as the value. Signed-off-by: Michal Privoznik --- docs/formatdomain.html.in | 32 +++ docs/schemas/domaincommon.rng | 143 ++++++++------ src/conf/domain_conf.c | 186 +++++++++++++----- src/conf/domain_conf.h | 4 +- src/qemu/qemu_command.c | 10 +- src/util/virsysinfo.c | 54 ++++- src/util/virsysinfo.h | 16 +- tests/qemuxml2argvdata/smbios-type-fwcfg.xml | 63 ++++++ .../qemuxml2xmloutdata/smbios-type-fwcfg.xml | 1 + tests/qemuxml2xmltest.c | 1 + 10 files changed, 396 insertions(+), 114 deletions(-) create mode 100644 tests/qemuxml2argvdata/smbios-type-fwcfg.xml create mode 120000 tests/qemuxml2xmloutdata/smbios-type-fwcfg.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 33cec1e6dd..6e51aad8b1 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -479,6 +479,10 @@ <entry>otherappname:more arbitrary data</entry> </oemStrings> </sysinfo> +<sysinfo type=3D'fwcfg'> + <entry name=3D'opt/com.example/name' value=3D'example value'/> + <entry name=3D'opt/com.coreos/config' file=3D'/tmp/provision.ign'/> +</sysinfo> ... =20

@@ -593,6 +597,34 @@ + +

fwcfg
+
+ Some hypervisors provide unified way to tweak how firmware configur= es + itself, or may contain tables to be installed for the guest OS, for + instance boot order, ACPI, SMBIOS, etc. It even allows users to def= ine + their own config blobs. In case of QEMU, these then appear under do= main's + sysfs, under /sys/firmware/qemu_fw_cfg. Note, that the= se + values apply regardless the <smbios/> mode under <os/>. + Since 6.5.0 + +
+  <smbios type=3D'fwcfg'>
+    <entry name=3D"opt/com.example/name" value=3D"example value"/>
+    <entry name=3D"opt/com.coreos/config" file=3D"/tmp/provision.ign"/&=
gt;
+  </smbios>
+
+ + The smbios element can have multiple entry + child elements. Each element then has mandatory name + attribute, which defines the name of the blob and must begin with + "opt/" and to avoid clashing with other names is advis= ed to + be in form "opt/$RFQDN/$name" where $RFQDN is a + reverse fully qualified domain name you control. + Then, the element can have either value attribute (to = set + the blob value directly), or file attribute (to set th= e blob + value from the file). +
=20

CPU Allocation

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 6727cd743b..9acf4b47d4 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -46,9 +46,9 @@ - + - + @@ -5506,68 +5506,93 @@ --> - - smbios - - - - - - - - - - + + + + smbios + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - + + + + + + fwcfg + + + + + + + + + + + + + + + + + + + =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 57a5b7befe..bed77f1dd7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3551,7 +3551,9 @@ void virDomainDefFree(virDomainDefPtr def) =20 virDomainNumaFree(def->numa); =20 - virSysinfoDefFree(def->sysinfo); + for (i =3D 0; i < def->nsysinfo; i++) + virSysinfoDefFree(def->sysinfo[i]); + VIR_FREE(def->sysinfo); =20 virDomainRedirFilterDefFree(def->redirfilter); =20 @@ -15708,67 +15710,146 @@ virSysinfoChassisParseXML(xmlNodePtr node, } =20 =20 -static virSysinfoDefPtr -virSysinfoParseXML(xmlNodePtr node, - xmlXPathContextPtr ctxt, - unsigned char *domUUID, - bool uuid_generated) +static int +virSysinfoParseSMBIOSDef(virSysinfoDefPtr def, + xmlXPathContextPtr ctxt, + unsigned char *domUUID, + bool uuid_generated) { - VIR_XPATH_NODE_AUTORESTORE(ctxt); - virSysinfoDefPtr def; xmlNodePtr tmpnode; - g_autofree char *type =3D NULL; - - ctxt->node =3D node; - - if (!virXMLNodeNameEqual(node, "sysinfo")) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("XML does not contain expected 'sysinfo' element"= )); - return NULL; - } - - if (VIR_ALLOC(def) < 0) - return NULL; - - type =3D virXMLPropString(node, "type"); - if (type =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("sysinfo must contain a type attribute")); - goto error; - } - if ((def->type =3D virSysinfoTypeFromString(type)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown sysinfo type '%s'"), type); - goto error; - } =20 /* Extract BIOS related metadata */ if ((tmpnode =3D virXPathNode("./bios[1]", ctxt)) !=3D NULL) { if (virSysinfoBIOSParseXML(tmpnode, ctxt, &def->bios) < 0) - goto error; + return -1; } =20 /* Extract system related metadata */ if ((tmpnode =3D virXPathNode("./system[1]", ctxt)) !=3D NULL) { if (virSysinfoSystemParseXML(tmpnode, ctxt, &def->system, domUUID, uuid_generated) < 0) - goto error; + return -1; } =20 /* Extract system base board metadata */ if (virSysinfoBaseBoardParseXML(ctxt, &def->baseBoard, &def->nbaseBoar= d) < 0) - goto error; + return -1; =20 /* Extract chassis related metadata */ if ((tmpnode =3D virXPathNode("./chassis[1]", ctxt)) !=3D NULL) { if (virSysinfoChassisParseXML(tmpnode, ctxt, &def->chassis) < 0) - goto error; + return -1; } =20 /* Extract system related metadata */ if ((tmpnode =3D virXPathNode("./oemStrings[1]", ctxt)) !=3D NULL) { if (virSysinfoOEMStringsParseXML(tmpnode, ctxt, &def->oemStrings) = < 0) + return -1; + } + + return 0; +} + + +static int +virSysinfoParseFWCfgDef(virSysinfoDefPtr def, + xmlNodePtr node, + xmlXPathContextPtr ctxt) +{ + VIR_XPATH_NODE_AUTORESTORE(ctxt); + g_autofree xmlNodePtr *nodes =3D NULL; + int n; + size_t i; + + ctxt->node =3D node; + + if ((n =3D virXPathNodeSet("./entry", ctxt, &nodes)) < 0) + return -1; + + if (n =3D=3D 0) + return 0; + + def->fw_cfgs =3D g_new0(virSysinfoFWCfgDef, n); + + for (i =3D 0; i < n; i++) { + g_autofree char *name =3D NULL; + g_autofree char *value =3D NULL; + g_autofree char *file =3D NULL; + + if (!(name =3D virXMLPropString(nodes[i], "name"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Firmware entry is missing 'name' attribute")= ); + return -1; + } + + value =3D virXMLPropString(nodes[i], "value"); + file =3D virXMLPropString(nodes[i], "file"); + + if (!value && !file) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Firmware entry must have either 'value' or " + "'file' attribute")); + return -1; + } + + def->fw_cfgs[i].name =3D g_steal_pointer(&name); + def->fw_cfgs[i].value =3D g_steal_pointer(&value); + def->fw_cfgs[i].file =3D g_steal_pointer(&file); + def->nfw_cfgs++; + } + + return 0; +} + + +static virSysinfoDefPtr +virSysinfoParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt, + unsigned char *domUUID, + bool uuid_generated) +{ + VIR_XPATH_NODE_AUTORESTORE(ctxt); + virSysinfoDefPtr def; + g_autofree char *typeStr =3D NULL; + int type; + + ctxt->node =3D node; + + if (!virXMLNodeNameEqual(node, "sysinfo")) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("XML does not contain expected 'sysinfo' element"= )); + return NULL; + } + + if (VIR_ALLOC(def) < 0) + return NULL; + + typeStr =3D virXMLPropString(node, "type"); + if (typeStr =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("sysinfo must contain a type attribute")); + goto error; + } + if ((type =3D virSysinfoTypeFromString(typeStr)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown sysinfo type '%s'"), typeStr); + goto error; + } + def->type =3D type; + + switch (def->type) { + case VIR_SYSINFO_SMBIOS: + if (virSysinfoParseSMBIOSDef(def, ctxt, domUUID, uuid_generated) <= 0) goto error; + break; + + case VIR_SYSINFO_FWCFG: + if (virSysinfoParseFWCfgDef(def, node, ctxt) < 0) + goto error; + break; + + case VIR_SYSINFO_LAST: + break; } =20 return def; @@ -22173,6 +22254,7 @@ virDomainDefParseXML(xmlDocPtr xml, =20 def->idmap.ngidmap =3D n; } + VIR_FREE(nodes); =20 if ((def->idmap.uidmap && !def->idmap.gidmap) || (!def->idmap.uidmap && def->idmap.gidmap)) { @@ -22181,13 +22263,21 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } =20 - if ((node =3D virXPathNode("./sysinfo[1]", ctxt)) !=3D NULL) { - def->sysinfo =3D virSysinfoParseXML(node, ctxt, - def->uuid, uuid_generated); + if ((n =3D virXPathNodeSet("./sysinfo", ctxt, &nodes)) < 0) + goto error; =20 - if (def->sysinfo =3D=3D NULL) + def->sysinfo =3D g_new0(virSysinfoDefPtr, n); + + for (i =3D 0; i < n; i++) { + virSysinfoDefPtr sysinfo =3D virSysinfoParseXML(nodes[i], ctxt, + def->uuid, uuid_gene= rated); + + if (!sysinfo) goto error; + + def->sysinfo[def->nsysinfo++] =3D sysinfo; } + VIR_FREE(nodes); =20 if ((tmp =3D virXPathString("string(./os/smbios/@mode)", ctxt))) { int mode; @@ -24072,8 +24162,16 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr= src, if (!virCPUDefIsEqual(src->cpu, dst->cpu, true)) goto error; =20 - if (!virSysinfoIsEqual(src->sysinfo, dst->sysinfo)) - goto error; + if (src->nsysinfo !=3D dst->nsysinfo) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target domain count of sysinfo does not match so= urce")); + goto error; + } + + for (i =3D 0; i < src->nsysinfo; i++) { + if (!virSysinfoIsEqual(src->sysinfo[i], dst->sysinfo[i])) + goto error; + } =20 if (src->ndisks !=3D dst->ndisks) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -29507,8 +29605,8 @@ virDomainDefFormatInternalSetRootName(virDomainDefP= tr def, if (def->resource) virDomainResourceDefFormat(buf, def->resource); =20 - if (def->sysinfo) - ignore_value(virSysinfoFormat(buf, def->sysinfo)); + for (i =3D 0; i < def->nsysinfo; i++) + virSysinfoFormat(buf, def->sysinfo[i]); =20 if (def->os.bootloader) { virBufferEscapeString(buf, "%s\n", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e152c599ca..bda8fb6bce 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2624,13 +2624,15 @@ struct _virDomainDef { size_t npanics; virDomainPanicDefPtr *panics; =20 + size_t nsysinfo; + virSysinfoDefPtr *sysinfo; + /* Only 1 */ virDomainWatchdogDefPtr watchdog; virDomainMemballoonDefPtr memballoon; virDomainNVRAMDefPtr nvram; virDomainTPMDefPtr tpm; virCPUDefPtr cpu; - virSysinfoDefPtr sysinfo; virDomainRedirFilterDefPtr redirfilter; virDomainIOMMUDefPtr iommu; virDomainVsockDefPtr vsock; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 419eca5675..6eb577a68b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5736,13 +5736,19 @@ qemuBuildSmbiosCommandLine(virCommandPtr cmd, /* Host and guest uuid must differ, by definition of UUID. */ skip_uuid =3D true; } else if (def->os.smbios_mode =3D=3D VIR_DOMAIN_SMBIOS_SYSINFO) { - if (def->sysinfo =3D=3D NULL) { + for (i =3D 0; i < def->nsysinfo; i++) { + if (def->sysinfo[i]->type =3D=3D VIR_SYSINFO_SMBIOS) { + source =3D def->sysinfo[i]; + break; + } + } + + if (!source) { virReportError(VIR_ERR_XML_ERROR, _("Domain '%s' sysinfo are not available"), def->name); return -1; } - source =3D def->sysinfo; /* domain_conf guaranteed that system_uuid matches guest uuid. */ } if (source !=3D NULL) { diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 41f4d1cff9..50e42610ca 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -43,6 +43,7 @@ VIR_LOG_INIT("util.sysinfo"); VIR_ENUM_IMPL(virSysinfo, VIR_SYSINFO_LAST, "smbios", + "fwcfg" ); =20 static const char *sysinfoDmidecode =3D DMIDECODE; @@ -1436,6 +1437,42 @@ virSysinfoOEMStringsFormat(virBufferPtr buf, virSysi= nfoOEMStringsDefPtr def) virBufferAddLit(buf, "\n"); } =20 + +static void +virSysinfoFormatSMBIOS(virBufferPtr buf, + virSysinfoDefPtr def) +{ + virSysinfoBIOSFormat(buf, def->bios); + virSysinfoSystemFormat(buf, def->system); + virSysinfoBaseBoardFormat(buf, def->baseBoard, def->nbaseBoard); + virSysinfoChassisFormat(buf, def->chassis); + virSysinfoProcessorFormat(buf, def); + virSysinfoMemoryFormat(buf, def); + virSysinfoOEMStringsFormat(buf, def->oemStrings); +} + + +static void +virSysinfoFormatFWCfg(virBufferPtr buf, + virSysinfoDefPtr def) +{ + size_t i; + + for (i =3D 0; i < def->nfw_cfgs; i++) { + const virSysinfoFWCfgDef *f =3D &def->fw_cfgs[i]; + + virBufferAsprintf(buf, "name); + + if (f->value) + virBufferEscapeString(buf, "value=3D'%s'", f->value); + else + virBufferEscapeString(buf, "file=3D'%s'", f->file); + + virBufferAddLit(buf, "/>\n"); + } +} + + /** * virSysinfoFormat: * @buf: buffer to append output to (may use auto-indentation) @@ -1458,13 +1495,16 @@ virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr= def) return -1; } =20 - virSysinfoBIOSFormat(&childrenBuf, def->bios); - virSysinfoSystemFormat(&childrenBuf, def->system); - virSysinfoBaseBoardFormat(&childrenBuf, def->baseBoard, def->nbaseBoar= d); - virSysinfoChassisFormat(&childrenBuf, def->chassis); - virSysinfoProcessorFormat(&childrenBuf, def); - virSysinfoMemoryFormat(&childrenBuf, def); - virSysinfoOEMStringsFormat(&childrenBuf, def->oemStrings); + switch (def->type) { + case VIR_SYSINFO_SMBIOS: + virSysinfoFormatSMBIOS(&childrenBuf, def); + break; + case VIR_SYSINFO_FWCFG: + virSysinfoFormatFWCfg(&childrenBuf, def); + break; + case VIR_SYSINFO_LAST: + break; + } =20 virBufferAsprintf(&attrBuf, " type=3D'%s'", type); =20 diff --git a/src/util/virsysinfo.h b/src/util/virsysinfo.h index f1d280e1c9..6b25969a4b 100644 --- a/src/util/virsysinfo.h +++ b/src/util/virsysinfo.h @@ -27,6 +27,7 @@ =20 typedef enum { VIR_SYSINFO_SMBIOS, + VIR_SYSINFO_FWCFG, =20 VIR_SYSINFO_LAST } virSysinfoType; @@ -112,11 +113,20 @@ struct _virSysinfoOEMStringsDef { char **values; }; =20 +typedef struct _virSysinfoFWCfgDef virSysinfoFWCfgDef; +typedef virSysinfoFWCfgDef *virSysinfoFWCfgDefPtr; +struct _virSysinfoFWCfgDef { + char *name; + char *value; + char *file; +}; + typedef struct _virSysinfoDef virSysinfoDef; typedef virSysinfoDef *virSysinfoDefPtr; struct _virSysinfoDef { - int type; + virSysinfoType type; =20 + /* The following members are valid for type =3D=3D VIR_SYSINFO_SMBIOS = */ virSysinfoBIOSDefPtr bios; virSysinfoSystemDefPtr system; =20 @@ -132,6 +142,10 @@ struct _virSysinfoDef { virSysinfoMemoryDefPtr memory; =20 virSysinfoOEMStringsDefPtr oemStrings; + + /* The following members are valid for type =3D=3D VIR_SYSINFO_FWCFG */ + size_t nfw_cfgs; + virSysinfoFWCfgDefPtr fw_cfgs; }; =20 virSysinfoDefPtr virSysinfoRead(void); diff --git a/tests/qemuxml2argvdata/smbios-type-fwcfg.xml b/tests/qemuxml2a= rgvdata/smbios-type-fwcfg.xml new file mode 100644 index 0000000000..2644833b21 --- /dev/null +++ b/tests/qemuxml2argvdata/smbios-type-fwcfg.xml @@ -0,0 +1,63 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + + LENOVO + 6FET82WW (3.12 ) + + + Fedora + Virt-Manager + 0.8.2-3.fc14 + 32dfcb37-5af1-552b-357c-be8c3aa38310 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1234567890 + Red Hat + + + Lenovo + 20BE0061MC + 0B98401 Pro + W1KS427111E + Not Available + + + + + + + + hvm + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + +
+ + +
+ + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/smbios-type-fwcfg.xml b/tests/qemuxml= 2xmloutdata/smbios-type-fwcfg.xml new file mode 120000 index 0000000000..09a2682910 --- /dev/null +++ b/tests/qemuxml2xmloutdata/smbios-type-fwcfg.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/smbios-type-fwcfg.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index dcc7b29ded..157e686f2a 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1125,6 +1125,7 @@ mymain(void) DO_TEST("shmem-plain-doorbell", NONE); DO_TEST("smbios", NONE); DO_TEST("smbios-multiple-type2", NONE); + DO_TEST("smbios-type-fwcfg", NONE); =20 DO_TEST_CAPS_LATEST("os-firmware-bios"); DO_TEST_CAPS_LATEST("os-firmware-efi"); --=20 2.26.2 From nobody Thu May 2 23:05:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1591402906; cv=none; d=zohomail.com; s=zohoarc; b=e762eKymy55d9uyxxSO5Vf9aIea7P6WndZpKmvo9S1D5jqfWNQT458pcN2FLOrUfZXHGxe5Of2x7EVFDXN92YNbbBfSiKmuWlgZl8DgVWuSLpPrnkopttEpWdNOoItxmgjRiWdS8cBEFuUQP4HPR7fmpjuWY1RT/UvxJmu8BjTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591402906; 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=stlIKTexXb5w1f/TLB139ZV6U+sUn2jysT+YbH1Xhdw=; b=U3yHinlYqFSMNBs/ckXdx+OI2SsIRvDuDoiLEa1UBAd2naNuyKVz7ovgV6lBewkmjSqNh4I6PhQdtL0vZw8CfO3pOJ4If5AhCveSz9TT8ZGgP9k5NPwefa4HdHGtkRAGlXu7ijHSa7ESepzg35ZbdaLzowu3YhbJjhYb47qqoog= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1591402906032721.0903116537909; Fri, 5 Jun 2020 17:21:46 -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-42-MdSDF-tQP4eydgWVZFsIVA-1; Fri, 05 Jun 2020 20:21:42 -0400 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 3C36310506ED; Sat, 6 Jun 2020 00:21:37 +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 1B7B84149; Sat, 6 Jun 2020 00:21:37 +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 E43DD104859; Sat, 6 Jun 2020 00:21:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 054IiITp002467 for ; Thu, 4 Jun 2020 14:44:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 54A3D101E675; Thu, 4 Jun 2020 18:44:18 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id C956910013D6 for ; Thu, 4 Jun 2020 18:44:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591402904; 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=stlIKTexXb5w1f/TLB139ZV6U+sUn2jysT+YbH1Xhdw=; b=MfQ8I4+lXk6RRGwMOqDaJvddyUFPhP/1UY+ByRLlqv+JSOH1AiNGfMEaB8REmRKwIBI3ce b9CYho771qVSXfX3mOfOcRmU5LJV8N5LQXsTHgvuvJ7uSNB9uL+D+AZkV1WxLvB1TiEtYr G3N67sCcenEqCQgXkuZYKOP2wLSESgQ= X-MC-Unique: MdSDF-tQP4eydgWVZFsIVA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 4/8] qemu: Validate firmware blob configuration Date: Thu, 4 Jun 2020 20:44:05 +0200 Message-Id: <0e6e4bd4b61374a3669824727ceaf12f1096e77e.1591296169.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There are recommendations and limitations to the name of the config blobs we need to follow [1]. Firstly, we don't want users to change any value only add new blobs. This means, that the name must have "opt/" prefix and at the same time must not begin with "opt/ovmf" nor "opt/org.qemu" as these are reserved for OVMF or QEMU respectively. Secondly, there is a limit (FW_CFG_MAX_FILE_PATH in qemu.git) of 56 characters for filename. 1: docs/specs/fw_cfg.txt from qemu.git Signed-off-by: Michal Privoznik --- src/qemu/qemu_validate.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 584d1375b8..56a7ebfd7f 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -762,6 +762,41 @@ qemuValidateDefGetVcpuHotplugGranularity(const virDoma= inDef *def) } =20 =20 +#define QEMU_FW_CFG_MAX_FILE_PATH 55 +static int +qemuValidateDomainDefSysinfo(const virSysinfoDef *def, + virQEMUCapsPtr qemuCaps G_GNUC_UNUSED) +{ + size_t i; + + for (i =3D 0; i < def->nfw_cfgs; i++) { + const virSysinfoFWCfgDef *f =3D &def->fw_cfgs[i]; + + if (!STRPREFIX(f->name, "opt/")) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Invalid firmware name")); + return -1; + } + + if (STRPREFIX(f->name, "opt/ovmf/") || + STRPREFIX(f->name, "opt/org.qemu/")) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("That firmware name is reserved")); + return -1; + } + + if (f->file && + strlen(f->file) > QEMU_FW_CFG_MAX_FILE_PATH) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("firmware file too long")); + return -1; + } + } + + return 0; +} + + int qemuValidateDomainDef(const virDomainDef *def, void *opaque) @@ -978,6 +1013,11 @@ qemuValidateDomainDef(const virDomainDef *def, } } =20 + for (i =3D 0; i < def->nsysinfo; i++) { + if (qemuValidateDomainDefSysinfo(def->sysinfo[i], qemuCaps) < 0) + return -1; + } + return 0; } =20 --=20 2.26.2 From nobody Thu May 2 23:05:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1591403645; cv=none; d=zohomail.com; s=zohoarc; b=Pb/EaQ4jlwgwCHaPiZP1i5CddhoKVeSRQnyOOKpinICldZntKM20SCKIGaDZ6Fdp5iQw69si5/vYoIoZDtRF2tCfAMPUI+JY8j0OorWld9oCOs8oMd/LQ/DGGMGNtuB4GxI4tdFCY9iT3GColZHOR/1M8txWgU14Ca/HX9c+57I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591403645; 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=DKTolDaUyppGUS3Tsq+PXLM21H3k0UEgWEahvqalybg=; b=XGGhqk7X9YkL2bF5bz7aove202IvgFUKnYVjBkutyCOlMk4u8aOWb6qdGHK9kUi4DZ3wdxC/utmx9PuGofgeUU2UwmV9S/NhG1WHzGIKrEedJ+uJv9nC/DMUHBXjoHmr+lyNZOXI5HP2zZcUz6KXDoum4HiVSqQIxFoOvUY2fO4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1591403645323175.55581955922162; Fri, 5 Jun 2020 17:34:05 -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-45-SyIQ216vOoC8Q5tgxwdJ_A-1; Fri, 05 Jun 2020 20:18:55 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A363100A902; Sat, 6 Jun 2020 00:18:43 +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 3A6D7891CA; Sat, 6 Jun 2020 00:18:43 +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 16A3887427; Sat, 6 Jun 2020 00:18:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 054IiJKH002475 for ; Thu, 4 Jun 2020 14:44:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5D3FD10016E8; Thu, 4 Jun 2020 18:44:19 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id A889310013D6 for ; Thu, 4 Jun 2020 18:44:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591403643; 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=DKTolDaUyppGUS3Tsq+PXLM21H3k0UEgWEahvqalybg=; b=d2H8BLklna/xHj00VfSQC1mkzQuu9hG3ys4zYMlhdLJdS06SSfkmstuJmqwdg8XE/Q6CCa 9RTTmTSnTaTx6PtCNAoqWO2LtFU0UqUqwBd1/3+cqkZw1DL0whylds0RcvSpQoTdXIhjJw IsdgLj2InxNhN97dGUgIl4qWQq02zK0= X-MC-Unique: SyIQ216vOoC8Q5tgxwdJ_A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 5/8] qemu: Introduce fw_cfg capability Date: Thu, 4 Jun 2020 20:44:06 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This capability tracks whether QEMU supports -fw_cfg command line option, more specifically whether it allows specifying filename. There are some releases of QEMU which support -fw_cfg but not filename. If this is ever a problem we can refine the capability later on. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 4 ++++ src/qemu/qemu_capabilities.h | 3 +++ tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml | 1 + tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml | 1 + 47 files changed, 52 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f12769635a..dbf8d6d45c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -582,6 +582,9 @@ VIR_ENUM_IMPL(virQEMUCaps, "tcg", "virtio-blk-pci.scsi.default.disabled", "pvscsi", + + /* 370 */ + "fw_cfg", ); =20 =20 @@ -3279,6 +3282,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCaps= CommandLine[] =3D { { "overcommit", NULL, QEMU_CAPS_OVERCOMMIT }, { "smp-opts", "dies", QEMU_CAPS_SMP_DIES }, { "fsdev", "multidevs", QEMU_CAPS_FSDEV_MULTIDEVS }, + { "fw_cfg", "file", QEMU_CAPS_FW_CFG }, }; =20 static int diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 076ecad0f7..7e5f007771 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -564,6 +564,9 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ QEMU_CAPS_VIRTIO_BLK_SCSI_DEFAULT_DISABLED, /* virtio-blk-pci.scsi dis= abled by default */ QEMU_CAPS_SCSI_PVSCSI, /* -device pvscsi */ =20 + /* 370 */ + QEMU_CAPS_FW_CFG, /* -fw_cfg command line option */ + QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; =20 diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml b/tests/qem= ucapabilitiesdata/caps_2.10.0.aarch64.xml index db8a298873..0848b1e18b 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml @@ -142,6 +142,7 @@ + 2010000 0 61700287 diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemuc= apabilitiesdata/caps_2.10.0.ppc64.xml index 15e8933300..82a37edd9c 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml @@ -142,6 +142,7 @@ + 2010000 0 42900287 diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.10.0.s390x.xml index 90c42cdf4f..7a1ad3d173 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml @@ -108,6 +108,7 @@ + 2010000 0 39100287 diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml b/tests/qemu= capabilitiesdata/caps_2.10.0.x86_64.xml index cb02723ada..f82ea38a26 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml @@ -185,6 +185,7 @@ + 2010000 0 43100287 diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.11.0.s390x.xml index d27f656ae0..1108aa46d0 100644 --- a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml @@ -115,6 +115,7 @@ + 2011000 0 39100288 diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml b/tests/qemu= capabilitiesdata/caps_2.11.0.x86_64.xml index 5245fc77dc..91cb5f80a6 100644 --- a/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml @@ -191,6 +191,7 @@ + 2011000 0 43100288 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml b/tests/qem= ucapabilitiesdata/caps_2.12.0.aarch64.xml index 38d36400e4..78070c0401 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml @@ -158,6 +158,7 @@ + 2012000 0 61700289 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml b/tests/qemuc= apabilitiesdata/caps_2.12.0.ppc64.xml index 53abf2debb..45d3baf080 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml @@ -159,6 +159,7 @@ + 2011090 0 42900289 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.12.0.s390x.xml index 880e5f137a..f9b92d11f2 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml @@ -127,6 +127,7 @@ + 2012000 0 39100289 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemu= capabilitiesdata/caps_2.12.0.x86_64.xml index 319dd6f2c3..8688dc32d5 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml @@ -200,6 +200,7 @@ + 2011090 0 43100289 diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.4.0.x86_64.xml index 7f0fe3b9aa..310f69499f 100644 --- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml @@ -136,6 +136,7 @@ + 2004000 0 43100242 diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.5.0.x86_64.xml index efb4ffa019..af9b9e96fd 100644 --- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml @@ -142,6 +142,7 @@ + 2005000 0 43100243 diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.aarch64.xml b/tests/qemu= capabilitiesdata/caps_2.6.0.aarch64.xml index 0ce5deb6e9..ec17ca5c27 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.aarch64.xml @@ -125,6 +125,7 @@ + 2006000 0 61700244 diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_2.6.0.ppc64.xml index 13573cfd03..13e6df006e 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml @@ -121,6 +121,7 @@ + 2006000 0 42900244 diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.6.0.x86_64.xml index 0c9f594a65..c25731997e 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml @@ -154,6 +154,7 @@ + 2006000 0 43100244 diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.7.0.s390x.xml index 571d748f6c..2421b46f35 100644 --- a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml @@ -92,6 +92,7 @@ + 2007000 0 39100245 diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.7.0.x86_64.xml index c97fa18a1f..9f25bd17ec 100644 --- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml @@ -159,6 +159,7 @@ + 2007000 0 43100245 diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.8.0.s390x.xml index be5cf4977b..083562f641 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml @@ -97,6 +97,7 @@ + 2007093 0 39100246 diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.8.0.x86_64.xml index 9a2b1f83ac..5426e8a54b 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml @@ -162,6 +162,7 @@ + 2008000 0 43100246 diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_2.9.0.ppc64.xml index 0c32a1c305..fe49896e72 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml @@ -134,6 +134,7 @@ + 2009000 0 42900247 diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.9.0.s390x.xml index c93cd4211f..32861f67ba 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml @@ -102,6 +102,7 @@ + 2009000 0 39100247 diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.9.0.x86_64.xml index 122d9509f1..f241cc7a59 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml @@ -179,6 +179,7 @@ + 2009000 0 43100247 diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_3.0.0.ppc64.xml index b81ed605d3..95f982eadf 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml @@ -161,6 +161,7 @@ + 2012050 0 42900239 diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml b/tests/qemu= capabilitiesdata/caps_3.0.0.riscv32.xml index e2c87dafe3..35d08c67ec 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml @@ -97,6 +97,7 @@ + 3000000 0 0 diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml b/tests/qemu= capabilitiesdata/caps_3.0.0.riscv64.xml index 0b8e5589db..42635c2e6d 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml @@ -97,6 +97,7 @@ + 3000000 0 0 diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_3.0.0.s390x.xml index 189bc09288..96d8953496 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml @@ -130,6 +130,7 @@ + 3000000 0 39100239 diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_3.0.0.x86_64.xml index 40cff641a8..80ab4914c6 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml @@ -206,6 +206,7 @@ + 3000000 0 43100239 diff --git a/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_3.1.0.ppc64.xml index 4e47e0a581..3a21eb3aab 100644 --- a/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml @@ -166,6 +166,7 @@ + 3000091 0 42900240 diff --git a/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_3.1.0.x86_64.xml index 3dbda4b3f3..b1f4794559 100644 --- a/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml @@ -209,6 +209,7 @@ + 3000092 0 43100240 diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml b/tests/qemu= capabilitiesdata/caps_4.0.0.aarch64.xml index 2b5210338f..b1047ca044 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml @@ -172,6 +172,7 @@ + 4000000 0 61700240 diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_4.0.0.ppc64.xml index 582cbdc8c2..a4916c2279 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml @@ -180,6 +180,7 @@ + 4000000 0 42900240 diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml b/tests/qemu= capabilitiesdata/caps_4.0.0.riscv32.xml index 199911d254..ec7c6b05e1 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml @@ -173,6 +173,7 @@ + 4000000 0 0 diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml b/tests/qemu= capabilitiesdata/caps_4.0.0.riscv64.xml index 4ddb79d2f8..d8924a10e8 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml @@ -173,6 +173,7 @@ + 4000000 0 0 diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_4.0.0.s390x.xml index d04129c327..671c28cb82 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml @@ -138,6 +138,7 @@ + 4000000 0 39100240 diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_4.0.0.x86_64.xml index bf7735caf3..a08a1655d4 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -214,6 +214,7 @@ + 4000000 0 43100240 diff --git a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_4.1.0.x86_64.xml index 8ce0f80e8a..cde7b85428 100644 --- a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml @@ -220,6 +220,7 @@ + 4001000 0 43100241 diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml b/tests/qemu= capabilitiesdata/caps_4.2.0.aarch64.xml index 154f70443e..11d487eefe 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml @@ -184,6 +184,7 @@ + 4001050 0 61700242 diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_4.2.0.ppc64.xml index eeec181f62..4d44cd4ac6 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml @@ -185,6 +185,7 @@ + 4001050 0 42900242 diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_4.2.0.s390x.xml index 4c0908294a..6db5926aaa 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml @@ -148,6 +148,7 @@ + 4002000 0 39100242 diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_4.2.0.x86_64.xml index 50ed35f092..fedd1ea13b 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml @@ -228,6 +228,7 @@ + 4002000 0 43100242 diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml b/tests/qemu= capabilitiesdata/caps_5.0.0.aarch64.xml index 9b24490137..7f993b38e1 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml @@ -193,6 +193,7 @@ + 5000000 0 61700241 diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_5.0.0.ppc64.xml index 69e5b4c8fa..409120262e 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml @@ -201,6 +201,7 @@ + 5000000 0 42900241 diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml b/tests/qemu= capabilitiesdata/caps_5.0.0.riscv64.xml index 7a091d27db..fb4956f144 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml @@ -189,6 +189,7 @@ + 5000000 0 0 diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_5.0.0.x86_64.xml index ba39fef713..d2c03444d5 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml @@ -234,6 +234,7 @@ + 5000000 0 43100241 diff --git a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_5.1.0.x86_64.xml index 3f538628b3..d1adcd6728 100644 --- a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml @@ -234,6 +234,7 @@ + 5000050 0 43100242 --=20 2.26.2 From nobody Thu May 2 23:05:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1591402908; cv=none; d=zohomail.com; s=zohoarc; b=L9cQ6XTV/oFUyIXSe9nVZSAlFxHjDu9FDOroWlMHz2jyvmeUUxRa0pIsnWTVEWFjzXimJ7n6MEDm2O180N2M6Pk1lJD320JIXqeOiR4d1pI3BXeqUpeZOB7YdgetB6n5I1mFPXUlYow/wj18KM4waQMDuLnVKxO1OXuG4wO73vA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591402908; 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=Odx3CMgQhFMeEStHVqepZkstDH5jNr+/h5muWLV55oQ=; b=FXFWZ4cZ6VVq1CURAMW6Xg0DtxiCEmGevuRaJDRNmmHRmm5rJfvzg26i95sDJ44EQHw3HsVOEsuN1DDiNVcflfJ/qtQAVT7GTs0+axp5PKH3AebVW0AUdvH/mLBVeliY3mjuhgCxrWPPL6L9rUCheHc/XW+iKodEyBdzxDZG2zM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 159140290852538.974854239110755; Fri, 5 Jun 2020 17:21:48 -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-404-MMx8A1MCMFy1SWn7xLph5Q-1; Fri, 05 Jun 2020 20:21:44 -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 B323C18FE868; Sat, 6 Jun 2020 00:21:39 +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 949C65D9E4; Sat, 6 Jun 2020 00:21:39 +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 66AD810485B; Sat, 6 Jun 2020 00:21:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 054IiKJT002494 for ; Thu, 4 Jun 2020 14:44:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3CB451001B2B; Thu, 4 Jun 2020 18:44:20 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id B131D10013D6 for ; Thu, 4 Jun 2020 18:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591402907; 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=Odx3CMgQhFMeEStHVqepZkstDH5jNr+/h5muWLV55oQ=; b=fxI0qQO360BxmYzBCk+45cax0foi1KfCG+OCX3IUbkXynEnswGJ3mSBFLlO8NrKR7k+8bz 7upaKBjJkkAVhg9dU5xLrtXsa8aL9aGbcoRFLfy03MOZRp50vU9Eiek2xxeFRHb3W6spXC aK88awB0QTX7Vr0ptqpEpmqDxvZTIBo= X-MC-Unique: MMx8A1MCMFy1SWn7xLph5Q-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 6/8] secdrivers: Relabel firmware config files Date: Thu, 4 Jun 2020 20:44:07 +0200 Message-Id: <36208614ffb19323b200051be8c66f23c5a64118.1591296170.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" For the case where -fw_cfg uses a file, we need to set the seclabels on it to allow QEMU the access. While QEMU allows writing into the file (if specified on the command line), so far we are enabling reading only and thus we can use read only label (in case of SELinux). Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/security/security_dac.c | 50 +++++++++++++++++++++++++++++++++ src/security/security_selinux.c | 50 +++++++++++++++++++++++++++++++++ src/security/virt-aa-helper.c | 12 ++++++++ 3 files changed, 112 insertions(+) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 7b95a6f86d..7e65b78fbe 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -1916,6 +1916,24 @@ virSecurityDACRestoreSEVLabel(virSecurityManagerPtr = mgr G_GNUC_UNUSED, } =20 =20 +static int +virSecurityDACRestoreSysinfoLabel(virSecurityManagerPtr mgr, + virSysinfoDefPtr def) +{ + size_t i; + + for (i =3D 0; i < def->nfw_cfgs; i++) { + virSysinfoFWCfgDefPtr f =3D &def->fw_cfgs[i]; + + if (f->file && + virSecurityDACRestoreFileLabel(mgr, f->file) < 0) + return -1; + } + + return 0; +} + + static int virSecurityDACRestoreAllLabel(virSecurityManagerPtr mgr, virDomainDefPtr def, @@ -1991,6 +2009,12 @@ virSecurityDACRestoreAllLabel(virSecurityManagerPtr = mgr, rc =3D -1; } =20 + for (i =3D 0; i < def->nsysinfo; i++) { + if (virSecurityDACRestoreSysinfoLabel(mgr, + def->sysinfo[i]) < 0) + rc =3D -1; + } + if (def->os.loader && def->os.loader->nvram && virSecurityDACRestoreFileLabel(mgr, def->os.loader->nvram) < 0) rc =3D -1; @@ -2094,6 +2118,27 @@ virSecurityDACSetSEVLabel(virSecurityManagerPtr mgr, } =20 =20 +static int +virSecurityDACSetSysinfoLabel(virSecurityManagerPtr mgr, + uid_t user, + gid_t group, + virSysinfoDefPtr def) +{ + size_t i; + + for (i =3D 0; i < def->nfw_cfgs; i++) { + virSysinfoFWCfgDefPtr f =3D &def->fw_cfgs[i]; + + if (f->file && + virSecurityDACSetOwnership(mgr, NULL, f->file, + user, group, true) < 0) + return -1; + } + + return 0; +} + + static int virSecurityDACSetAllLabel(virSecurityManagerPtr mgr, virDomainDefPtr def, @@ -2173,6 +2218,11 @@ virSecurityDACSetAllLabel(virSecurityManagerPtr mgr, if (virSecurityDACGetImageIds(secdef, priv, &user, &group)) return -1; =20 + for (i =3D 0; i < def->nsysinfo; i++) { + if (virSecurityDACSetSysinfoLabel(mgr, user, group, def->sysinfo[i= ]) < 0) + return -1; + } + if (def->os.loader && def->os.loader->nvram && virSecurityDACSetOwnership(mgr, NULL, def->os.loader->nvram, diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 7bb7c2b7b1..e6819af26c 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -2720,6 +2720,24 @@ virSecuritySELinuxGetBaseLabel(virSecurityManagerPtr= mgr, int virtType) } =20 =20 +static int +virSecuritySELinuxRestoreSysinfoLabel(virSecurityManagerPtr mgr, + virSysinfoDefPtr def) +{ + size_t i; + + for (i =3D 0; i < def->nfw_cfgs; i++) { + virSysinfoFWCfgDefPtr f =3D &def->fw_cfgs[i]; + + if (f->file && + virSecuritySELinuxRestoreFileLabel(mgr, f->file, true) < 0) + return -1; + } + + return 0; +} + + static int virSecuritySELinuxRestoreAllLabel(virSecurityManagerPtr mgr, virDomainDefPtr def, @@ -2786,6 +2804,11 @@ virSecuritySELinuxRestoreAllLabel(virSecurityManager= Ptr mgr, mgr) < 0) rc =3D -1; =20 + for (i =3D 0; i < def->nsysinfo; i++) { + if (virSecuritySELinuxRestoreSysinfoLabel(mgr, def->sysinfo[i]) < = 0) + rc =3D -1; + } + if (def->os.loader && def->os.loader->nvram && virSecuritySELinuxRestoreFileLabel(mgr, def->os.loader->nvram, tru= e) < 0) rc =3D -1; @@ -3123,6 +3146,26 @@ virSecuritySELinuxSetSecuritySmartcardCallback(virDo= mainDefPtr def, } =20 =20 +static int +virSecuritySELinuxSetSysinfoLabel(virSecurityManagerPtr mgr, + virSysinfoDefPtr def, + virSecuritySELinuxDataPtr data) +{ + size_t i; + + for (i =3D 0; i < def->nfw_cfgs; i++) { + virSysinfoFWCfgDefPtr f =3D &def->fw_cfgs[i]; + + if (f->file && + virSecuritySELinuxSetFilecon(mgr, f->file, + data->content_context, true) < 0) + return -1; + } + + return 0; +} + + static int virSecuritySELinuxSetAllLabel(virSecurityManagerPtr mgr, virDomainDefPtr def, @@ -3194,6 +3237,13 @@ virSecuritySELinuxSetAllLabel(virSecurityManagerPtr = mgr, mgr) < 0) return -1; =20 + for (i =3D 0; i < def->nsysinfo; i++) { + if (virSecuritySELinuxSetSysinfoLabel(mgr, + def->sysinfo[i], + data) < 0) + return -1; + } + /* This is different than kernel or initrd. The nvram store * is really a disk, qemu can read and write to it. */ if (def->os.loader && def->os.loader->nvram && diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 6e6dd1b1db..34c281100e 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1175,6 +1175,18 @@ get_files(vahControl * ctl) } } =20 + for (i =3D 0; i < ctl->def->nsysinfo; i++) { + size_t j; + + for (j =3D 0; j < ctl->def->sysinfo[i]->nfw_cfgs; j++) { + virSysinfoFWCfgDefPtr f =3D &ctl->def->sysinfo[i]->fw_cfgs[j]; + + if (f->file && + vah_add_file(&buf, f->file, "r") !=3D 0) + goto cleanup; + } + } + for (i =3D 0; i < ctl->def->nshmems; i++) { virDomainShmemDef *shmem =3D ctl->def->shmems[i]; /* explicit server paths can be on any model to overwrites default= s. --=20 2.26.2 From nobody Thu May 2 23:05:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1591402738; cv=none; d=zohomail.com; s=zohoarc; b=a62TJY/Su7XB9VG03K85EqPWVSNaWmcB/JEo39b6OT3WgmPKAalJdt97vvYp3kjMNdH1loPLsHbUjZvU5KA8pgfqXvfI27dAU9JwIWasWMfZijcVS+r7n4/mgqdPjFVKBGmKhipSp/eGZLOCgNTw4u0A6qYZqarGY13OJesSGf0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591402738; 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=kCCY6Vy/VmuQxBcs7CtW3iMchhiH0tbJlv3P1PX4KTg=; b=FU6HvPXL6Zpl0SleNTXv3XXtjWK6CQqkJTcH31OuY7gb7GfH8DzR7PjO2PkympImYgG7rDXdtZlJuuckMwhjPsFzM64SbBR9M8e9JhOKpv91RN4GuL51Stc/ZcOlGMkuE0tz/1Ntsx9O62X6odSBNDXUIJ5cd9d0GC+W+oH6ROs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1591402738924863.3198506910319; Fri, 5 Jun 2020 17:18:58 -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-473-DVeBo9BpMUqoC02dCsT6sw-1; Fri, 05 Jun 2020 20:18:55 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54EAE100D11C; Sat, 6 Jun 2020 00:18:46 +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 35E785F730; Sat, 6 Jun 2020 00:18:46 +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 0871C180954D; Sat, 6 Jun 2020 00:18:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 054IiLOF002501 for ; Thu, 4 Jun 2020 14:44:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2023D101E67B; Thu, 4 Jun 2020 18:44:21 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FCFC1001B2B for ; Thu, 4 Jun 2020 18:44:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591402737; 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=kCCY6Vy/VmuQxBcs7CtW3iMchhiH0tbJlv3P1PX4KTg=; b=TWvn7dFPQcYU9ZgZyiU8KxsVhZYnr4nc0T94aLhmcE8bExdYQRV6Yk963kZF2+4swukXG/ 7jY8noBU3XCMJJ9BzYvOYvpnm7aRfTpm+N0ic/xI3o07BUEStaEja3oqym/CFsuRNExn0t M/y6ahC7Mrh/mC0lgDg+qGNQixylPn8= X-MC-Unique: DVeBo9BpMUqoC02dCsT6sw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 7/8] qemu: Generate command line for -fw_cfg Date: Thu, 4 Jun 2020 20:44:08 +0200 Message-Id: <65c20fea7faa9492eaac208eb86f7429efbfa817.1591296170.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This is pretty straightforward and self explanatory. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1837990 Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_command.c | 44 +++++++++++++++++++ tests/qemuxml2argvdata/smbios-type-fwcfg.args | 38 ++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 3 files changed, 83 insertions(+) create mode 100644 tests/qemuxml2argvdata/smbios-type-fwcfg.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6eb577a68b..9d9b36adde 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5800,6 +5800,47 @@ qemuBuildSmbiosCommandLine(virCommandPtr cmd, } =20 =20 +static int +qemuBuildSysinfoCommandLine(virCommandPtr cmd, + virQEMUCapsPtr qemuCaps, + const virDomainDef *def) +{ + size_t i; + + /* We need to handle VIR_SYSINFO_FWCFG here, because + * VIR_SYSINFO_SMBIOS is handled in qemuBuildSmbiosCommandLine() */ + for (i =3D 0; i < def->nsysinfo; i++) { + size_t j; + + if (def->sysinfo[i]->type !=3D VIR_SYSINFO_FWCFG) + continue; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_FW_CFG)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("fw_cfg is not supported with this QEMU")); + return -1; + } + + for (j =3D 0; j < def->sysinfo[i]->nfw_cfgs; j++) { + const virSysinfoFWCfgDef *f =3D &def->sysinfo[i]->fw_cfgs[j]; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + + virBufferAsprintf(&buf, "name=3D%s", f->name); + + if (f->value) + virBufferEscapeString(&buf, ",string=3D%s", f->value); + else + virBufferEscapeString(&buf, ",file=3D%s", f->file); + + virCommandAddArg(cmd, "-fw_cfg"); + virCommandAddArgBuffer(cmd, &buf); + } + } + + return 0; +} + + static int qemuBuildVMGenIDCommandLine(virCommandPtr cmd, const virDomainDef *def) @@ -9640,6 +9681,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildSmbiosCommandLine(cmd, driver, def) < 0) return NULL; =20 + if (qemuBuildSysinfoCommandLine(cmd, qemuCaps, def) < 0) + return NULL; + if (qemuBuildVMGenIDCommandLine(cmd, def) < 0) return NULL; =20 diff --git a/tests/qemuxml2argvdata/smbios-type-fwcfg.args b/tests/qemuxml2= argvdata/smbios-type-fwcfg.args new file mode 100644 index 0000000000..372ae779b6 --- /dev/null +++ b/tests/qemuxml2argvdata/smbios-type-fwcfg.args @@ -0,0 +1,38 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i386 \ +-name QEMUGuest1 \ +-S \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 214 \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-smbios 'type=3D0,vendor=3DLENOVO,version=3D6FET82WW (3.12 )' \ +-smbios 'type=3D1,manufacturer=3DFedora,product=3DVirt-Manager,version=3D0= .8.2-3.fc14,\ +serial=3D32dfcb37-5af1-552b-357c-be8c3aa38310,\ +uuid=3Dc7a5fdbd-edaf-9455-926a-d65c16db1809,sku=3D1234567890,family=3DRed = Hat' \ +-smbios 'type=3D2,manufacturer=3DLenovo,product=3D20BE0061MC,version=3D0B9= 8401 Pro,\ +serial=3DW1KS427111E,location=3DNot Available' \ +-fw_cfg 'name=3Dopt/com.example/name,string=3Dexample value' \ +-fw_cfg name=3Dopt/com.coreos/config,file=3D/tmp/provision.ign \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-usb \ +-drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3103cac884..02f8846e57 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1684,6 +1684,7 @@ mymain(void) DO_TEST("smbios", NONE); DO_TEST_PARSE_ERROR("smbios-date", NONE); DO_TEST_PARSE_ERROR("smbios-uuid-match", NONE); + DO_TEST("smbios-type-fwcfg", QEMU_CAPS_FW_CFG); =20 DO_TEST("watchdog", NONE); DO_TEST("watchdog-device", NONE); --=20 2.26.2 From nobody Thu May 2 23:05:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1591402742; cv=none; d=zohomail.com; s=zohoarc; b=F3syHF7JvUbfxEuEiOhauf7Lf1gAiH6TMzNqjy75+3c1o1prLjdPt0ITGRTkCBG7gRLDb61y/3ySs0MInzuA9qnXKqwal2C+ukA4LuJ/d5EuiIGGSiQxeomX7Koaz/q4AG69uUagYP7m10WCFiuVjUHZdZpj6owJXrCaIjKupmk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591402742; 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=EIpEWfFQReWEP1NSFNqC/EThWQ9Imo5jomSVuCD92GM=; b=RWLhL6AMDTTLKWGbfOI4cZovmGpsP8SGEoVhW5ioPy6zygetugmywHg7PrssWbDBotcFC1sSg4wCniJbHC08CudB97FXNbdekZ9JKj9xccXhSW4zAKZpZJ6FDJmRG85/mzx5ExgyHi7f6+FQ3LHKqkUb3YPtsBq4wG3T/DMpLWI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1591402742111185.69701856052086; Fri, 5 Jun 2020 17:19:02 -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-235-ThNg_QDFNL2B7zvqApLWFg-1; Fri, 05 Jun 2020 20:18:58 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C83EA1054F9E; Sat, 6 Jun 2020 00:18:48 +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 A8EDC7B614; Sat, 6 Jun 2020 00:18:48 +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 78F391809561; Sat, 6 Jun 2020 00:18:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 054IiM2T002517 for ; Thu, 4 Jun 2020 14:44:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 551BC1001B2B; Thu, 4 Jun 2020 18:44:22 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8CE51002389 for ; Thu, 4 Jun 2020 18:44:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591402741; 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=EIpEWfFQReWEP1NSFNqC/EThWQ9Imo5jomSVuCD92GM=; b=fhOm7POrw4Kpzjc3NMlsTsWPZ58PnW50/h3qDDUVdZTUMIGJABCvnSg9nq395nRvQTA7LX rnuO9OSZIKj8bpOIhw3w+sQtwlsnegPuxFPN4RpJq+MGAINJdCjzedmGwdOaf19IlydsA2 31wTmom6KAJGtUbDKqaI/hqAQRqKqig= X-MC-Unique: ThNg_QDFNL2B7zvqApLWFg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 8/8] news: Document -fw_cfg Date: Thu, 4 Jun 2020 20:44:09 +0200 Message-Id: <7d79190e07f0ba7788c14d0358497716854e989d.1591296170.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/news.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 18d96af048..d89ba778e1 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -44,6 +44,18 @@
+ + + Allow firmware blobs configuration + + + QEMU offers a way to tweak how firmware configures itself + and/or provide new configuration blobs. New <sysinfo/> + type is introduced that will hold these new blobs. + It's possible to either specify new value as a string or + provide a filename which contents then serve as the value. + +
--=20 2.26.2