From nobody Sun May 5 20:25:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616070423; cv=none; d=zohomail.com; s=zohoarc; b=YPAp8PvuIkkRJiygTKQAlPkDseQFvR4SKRGUj54/jnqSGaNVUuqGfCJOURdrdY92MH2l4374K1DvUQH/ikWEbDkY4FfRWh1wmMxRhD/qMp8v3FJ65Y4aqQ9nsE5wiRSL9D/2boNiYG1PdbXmSoo6eFT6gPyh7KsdKenJOCsXixg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616070423; 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=ZWUnQuCKOZwBHttcX5XOGYe1+Muph1vwF5QHDN10zIo=; b=Ffl0ZYHjPy4UiAB9JyM9hwCL+2aSEFZy6a5fNEiyxu8M6gZRzZ1BiBDrn0eebpMpIsQK3js9Yp5WSK6hXiXhqjP8WrTed8kg3jf5hLPjr4jgeAfsPA4b2t+dydVvAJTeQNV0KbOe78Q56FE+E0xbEXy/dcNyNMXKycgOBnhhpRY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1616070423290640.7500539225083; Thu, 18 Mar 2021 05:27:03 -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-217-32MRtkm9PX6_6vy46tCNFg-1; Thu, 18 Mar 2021 08:27:00 -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 061A08143F2; Thu, 18 Mar 2021 12:26:54 +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 A15825D9DE; Thu, 18 Mar 2021 12:26:53 +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 B7E191809C83; Thu, 18 Mar 2021 12:26:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12ICQq8o024650 for ; Thu, 18 Mar 2021 08:26:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 208965C239; Thu, 18 Mar 2021 12:26:52 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 945705C582 for ; Thu, 18 Mar 2021 12:26:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616070422; 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=ZWUnQuCKOZwBHttcX5XOGYe1+Muph1vwF5QHDN10zIo=; b=Z9nnOycUBuuCigt76vAb9o5tYsnsGjAfHGdS5fuk3OD7e369L0ZFEx3TdfPXToZ2m55sFF RoeMrz/vAS/a2jtW/lhhBG/kfo3WxqOzqJK5jJ4TWFIIos2AKUkKuKSPLenZ7xBhJn6YJP EdzXFIZnv7ksBAOHhDTBgs1gE+Vajpo= X-MC-Unique: 32MRtkm9PX6_6vy46tCNFg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 1/9] docs: improve description of secure attribute for loader element Date: Thu, 18 Mar 2021 13:26:38 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The original text was not explaining what this attribute actually controls and could have been interpreted as a control switch for the Secure boot feature in firmwares. Signed-off-by: Pavel Hrdina Reviewed-by: Kashyap Chamarthy =20 --- docs/formatdomain.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index a2ea2690a5..c101d5a1f1 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -167,7 +167,9 @@ harddisk, cdrom, network) determining where to obtain/f= ind the boot image. in the guest memory the file should be mapped. For instance, if the loa= der path points to an UEFI image, ``type`` should be ``pflash``. Moreover, = some firmwares may implement the Secure boot feature. Attribute ``secure`` c= an be - used then to control it. :since:`Since 2.1.0` + used to tell the hypervisor that the firmware implements Secure Boot Fe= ature. + It cannot be used to enable or disable the feature itself in the firmwa= re. + :since:`Since 2.1.0` ``nvram`` Some UEFI firmwares may want to use a non-volatile memory to store some variables. In the host, this is represented as a file and the absolute = path --=20 2.30.2 From nobody Sun May 5 20:25:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616070425; cv=none; d=zohomail.com; s=zohoarc; b=l6S7SCPaX/ewy88JfTvN3ebfuaTtzR++Sih7Mj+9YcvRekhG+fBY88TwHkCR31MyP1mwXryVJixN7rgsT4s9Wc2NEjJZ7XUd0xN6x7pTv9IrMayeVrCeBLYhB/PC3SdPprHpbtVAqJ2or+D2Kctpro87qV+gv2z8fWwPAQM9ptI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616070425; 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=09dcLqLDhK+CwNlPcqT3xRzGPJnPIRw6Q4JhcTMDaeA=; b=U9rrTHiNp/Qx+pxxZsq3u7PUCQ3XDgy3oAQz6T8q/onLZZPJ1qDJHx3Nna77eChJvUle4u6uaE8yP6imi7o7e5I8a2e901vx4Th5AQXFlx5LfXzeaUpdOyUr0tGz/9AmdI8Lz8bFSjysnfD1+R6U1ooIAY2gN6D5OU6hC7WXZIs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1616070425122466.5682728570172; Thu, 18 Mar 2021 05:27: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-48-tpeWcYZUPVekcnfuJp7Cig-1; Thu, 18 Mar 2021 08:27:01 -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 E3D691083E8A; Thu, 18 Mar 2021 12:26:55 +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 BD879610F0; Thu, 18 Mar 2021 12:26:55 +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 7A4B74A7C9; Thu, 18 Mar 2021 12:26:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12ICQrOV024656 for ; Thu, 18 Mar 2021 08:26:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id F2E965C582; Thu, 18 Mar 2021 12:26:52 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7323D5C239 for ; Thu, 18 Mar 2021 12:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616070424; 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=09dcLqLDhK+CwNlPcqT3xRzGPJnPIRw6Q4JhcTMDaeA=; b=S1O3aOXP25c1d/MJrkX1YkosmdNwpaxNIlGJv+//CCxBI+m8C4CbxPUYZaFqBV0kgcRNIt B3pMIQYeZjzFhT00vFr+nlYxC2FgZXr6XGjDyTMdHa3pA9oXCk2TWuNx62Z+jPf4oB8UFo qWl9etnSEtGCN7s/U2Xgw0jszf2ljR8= X-MC-Unique: tpeWcYZUPVekcnfuJp7Cig-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 2/9] conf: introduce virDomainDefParseBootInitOptions Date: Thu, 18 Mar 2021 13:26:39 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Extract the code to it's own function. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 109 +++++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 48 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 47756ff0be..31b908d8fe 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19523,12 +19523,70 @@ virDomainVcpuParse(virDomainDefPtr def, } =20 =20 +static int +virDomainDefParseBootInitOptions(virDomainDefPtr def, + xmlXPathContextPtr ctxt) +{ + char *name =3D NULL; + size_t i; + int n; + g_autofree xmlNodePtr *nodes =3D NULL; + + def->os.init =3D virXPathString("string(./os/init[1])", ctxt); + def->os.cmdline =3D virXPathString("string(./os/cmdline[1])", ctxt); + def->os.initdir =3D virXPathString("string(./os/initdir[1])", ctxt); + def->os.inituser =3D virXPathString("string(./os/inituser[1])", ctxt); + def->os.initgroup =3D virXPathString("string(./os/initgroup[1])", ctxt= ); + + if ((n =3D virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0) + return -1; + + def->os.initargv =3D g_new0(char *, n+1); + for (i =3D 0; i < n; i++) { + if (!nodes[i]->children || + !nodes[i]->children->content) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("No data supplied for element")); + return -1; + } + def->os.initargv[i] =3D g_strdup((const char *)nodes[i]->children-= >content); + } + def->os.initargv[n] =3D NULL; + VIR_FREE(nodes); + + if ((n =3D virXPathNodeSet("./os/initenv", ctxt, &nodes)) < 0) + return -1; + + def->os.initenv =3D g_new0(virDomainOSEnvPtr, n+1); + for (i =3D 0; i < n; i++) { + if (!(name =3D virXMLPropString(nodes[i], "name"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("No name supplied for element")); + return -1; + } + + if (!nodes[i]->children || + !nodes[i]->children->content) { + virReportError(VIR_ERR_XML_ERROR, + _("No value supplied for = element"), + name); + return -1; + } + + def->os.initenv[i] =3D g_new0(virDomainOSEnv, 1); + def->os.initenv[i]->name =3D name; + def->os.initenv[i]->value =3D g_strdup((const char *)nodes[i]->chi= ldren->content); + } + def->os.initenv[n] =3D NULL; + + return 0; +} + + static int virDomainDefParseBootOptions(virDomainDefPtr def, xmlXPathContextPtr ctxt) { - char *name =3D NULL; - size_t i; int n; g_autofree xmlNodePtr *nodes =3D NULL; g_autofree char *tmp =3D NULL; @@ -19543,53 +19601,8 @@ virDomainDefParseBootOptions(virDomainDefPtr def, */ =20 if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_EXE) { - def->os.init =3D virXPathString("string(./os/init[1])", ctxt); - def->os.cmdline =3D virXPathString("string(./os/cmdline[1])", ctxt= ); - def->os.initdir =3D virXPathString("string(./os/initdir[1])", ctxt= ); - def->os.inituser =3D virXPathString("string(./os/inituser[1])", ct= xt); - def->os.initgroup =3D virXPathString("string(./os/initgroup[1])", = ctxt); - - if ((n =3D virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0) + if (virDomainDefParseBootInitOptions(def, ctxt) < 0) return -1; - - def->os.initargv =3D g_new0(char *, n+1); - for (i =3D 0; i < n; i++) { - if (!nodes[i]->children || - !nodes[i]->children->content) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("No data supplied for element")= ); - return -1; - } - def->os.initargv[i] =3D g_strdup((const char *)nodes[i]->child= ren->content); - } - def->os.initargv[n] =3D NULL; - VIR_FREE(nodes); - - if ((n =3D virXPathNodeSet("./os/initenv", ctxt, &nodes)) < 0) - return -1; - - def->os.initenv =3D g_new0(virDomainOSEnvPtr, n+1); - for (i =3D 0; i < n; i++) { - if (!(name =3D virXMLPropString(nodes[i], "name"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("No name supplied for element"= )); - return -1; - } - - if (!nodes[i]->children || - !nodes[i]->children->content) { - virReportError(VIR_ERR_XML_ERROR, - _("No value supplied for element"), - name); - return -1; - } - - def->os.initenv[i] =3D g_new0(virDomainOSEnv, 1); - def->os.initenv[i]->name =3D name; - def->os.initenv[i]->value =3D g_strdup((const char *)nodes[i]-= >children->content); - } - def->os.initenv[n] =3D NULL; - VIR_FREE(nodes); } =20 if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_XEN || --=20 2.30.2 From nobody Sun May 5 20:25:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616070510; cv=none; d=zohomail.com; s=zohoarc; b=VETDjiX68eZ3M6UdP/4+fTmnEbrN97GphfPHDJZ0guHAA6ESXQyEhfXLB8wYzy1bUrkh96sfXq+sjv6M4DErbLSsrKMDRIbgDZEXbMi/Hy3Swlg4hncZoXoMiXJzK2TR4KmIM/svRJ2CKxlLui02Plfumqjc7AirEm8GpUW2Bqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616070510; 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=HCAuaQY3Re5F+XkslsEuTWb5SoaacE2lVfT56D0AQDU=; b=UtccVpR82rvYiH2IZBTP/zi2peuMZ3nB4U4D1pLj/iQfIoqhHry+husso8Z0u5NyPtB1F4ARaTlKmzf4KxXzV8pjl1/A6yScV8242wFEyCidod2ehZhx2eYmqBcdlabNgWu90M/5SFa0YnIYa/pvObajKKVHYrnS+axwTEwzHjc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1616070510777501.87659265585603; Thu, 18 Mar 2021 05:28:30 -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-237-n4n66PVAPE6sbM4VhvsdgA-1; Thu, 18 Mar 2021 08:28:26 -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 1F28B107ACCA; Thu, 18 Mar 2021 12:28:20 +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 C81855D6A8; Thu, 18 Mar 2021 12:28: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 6352A4A7C8; Thu, 18 Mar 2021 12:28:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12ICQr2q024664 for ; Thu, 18 Mar 2021 08:26:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id D2D1E5C582; Thu, 18 Mar 2021 12:26:53 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 528D35C239 for ; Thu, 18 Mar 2021 12:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616070509; 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=HCAuaQY3Re5F+XkslsEuTWb5SoaacE2lVfT56D0AQDU=; b=QqHd89CotsGyjIwEXPrickI63SArlDr/dMnSYnTBz0xH1JtAU8Bk/sl1sEE2LUlw48nrmM QVK1eEH9kOOO/DTxyR3UY5C6Q54gLA/tCTVFb0UvJeWVJd+3Ldo99jtgRKofj+b0ppCuhC mKSqyLuCJPGgyZY+LNIk75vHt9vgYyE= X-MC-Unique: n4n66PVAPE6sbM4VhvsdgA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 3/9] conf: introduce virDomainDefParseBootKernelOptions Date: Thu, 18 Mar 2021 13:26:40 +0100 Message-Id: <4d78d3597c02504366f8aea7435516a0905a722b.1616070296.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Extract the code to it's own function. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 31b908d8fe..4876fe61bb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19583,6 +19583,18 @@ virDomainDefParseBootInitOptions(virDomainDefPtr d= ef, } =20 =20 +static void +virDomainDefParseBootKernelOptions(virDomainDefPtr def, + xmlXPathContextPtr ctxt) +{ + def->os.kernel =3D virXPathString("string(./os/kernel[1])", ctxt); + def->os.initrd =3D virXPathString("string(./os/initrd[1])", ctxt); + def->os.cmdline =3D virXPathString("string(./os/cmdline[1])", ctxt); + def->os.dtb =3D virXPathString("string(./os/dtb[1])", ctxt); + def->os.root =3D virXPathString("string(./os/root[1])", ctxt); +} + + static int virDomainDefParseBootOptions(virDomainDefPtr def, xmlXPathContextPtr ctxt) @@ -19612,11 +19624,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def, g_autofree char *firmware =3D NULL; xmlNodePtr loader_node; =20 - def->os.kernel =3D virXPathString("string(./os/kernel[1])", ctxt); - def->os.initrd =3D virXPathString("string(./os/initrd[1])", ctxt); - def->os.cmdline =3D virXPathString("string(./os/cmdline[1])", ctxt= ); - def->os.dtb =3D virXPathString("string(./os/dtb[1])", ctxt); - def->os.root =3D virXPathString("string(./os/root[1])", ctxt); + virDomainDefParseBootKernelOptions(def, ctxt); =20 if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM && (firmware =3D virXPathString("string(./os/@firmware)", ctxt)))= { --=20 2.30.2 From nobody Sun May 5 20:25:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616070545; cv=none; d=zohomail.com; s=zohoarc; b=TWzq49pPNGNlBAqdZVAqpiUqPFnh9yW9pmv+cgQjtbmNvDOH5Ewe3EPXQ2PIUTCRuxxkxO0aQc2pFQNIc09EjgXi15oKPSYt4aurYhZ53RbuWP0MIdst2KM30xSdRnhhzvyEdxNpQFwpBcFTbw3G+ZCFJUaO7a17ZjFOf3Ul+Nc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616070545; 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=+geVVw8ccWVAxfqZjn2ybp93yH3rXvhxqdgK4iAjhew=; b=cFNUeLjbB2m/p7O767NzQeVm/9c91y7hGUJO6aA4x4eZCD0eJ3cgovhQ2ZjklTQ2tkWBuJgCkJ3TVaUjNIW7Uxx8pyqk7AEFghbGVQcZ84aDmxS1k8a5ZCYyxsKrTxx5QMGWCXFlNQ36EEoKeay3KYt1MozhbOonjN9CooWk+Nk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1616070545255992.924995095461; Thu, 18 Mar 2021 05:29: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-372-AFFumS62Pym6lX9dhxGKsA-1; Thu, 18 Mar 2021 08:29:01 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7E4DA5B365; Thu, 18 Mar 2021 12:28:56 +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 0DAB519C45; Thu, 18 Mar 2021 12:28:56 +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 B5E6E4A702; Thu, 18 Mar 2021 12:28:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12ICQvsA024692 for ; Thu, 18 Mar 2021 08:26:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id EBA8D5C239; Thu, 18 Mar 2021 12:26:57 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B2AE5C1D1 for ; Thu, 18 Mar 2021 12:26:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616070543; 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=+geVVw8ccWVAxfqZjn2ybp93yH3rXvhxqdgK4iAjhew=; b=iv/aIIc1bgWVy5wKPiP9RXtguu38SYCk7gL95Tjvpwfri7yBqc5aqMU3E8pDosLYPWtqt1 Xj5gQI3nnidlHGW/dDBkWfChz+YP/kAqDzzSbA7sbAJUZkSsHTPk3AlpsOb4/1GNCHg412 zc5UHj35efhUvzEOc7Yx34brT3ExtuU= X-MC-Unique: AFFumS62Pym6lX9dhxGKsA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 4/9] conf: introduce virDomainDefParseBootFirmwareOptions Date: Thu, 18 Mar 2021 13:26:41 +0100 Message-Id: <68f688f4266a9490bdbdac69e83f7d6647ee6689.1616070296.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Extract the code to it's own function. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4876fe61bb..03985b6687 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19595,6 +19595,31 @@ virDomainDefParseBootKernelOptions(virDomainDefPtr= def, } =20 =20 +static int +virDomainDefParseBootFirmwareOptions(virDomainDefPtr def, + xmlXPathContextPtr ctxt) +{ + g_autofree char *firmware =3D virXPathString("string(./os/@firmware)",= ctxt); + int fw =3D 0; + + if (!firmware) + return 0; + + fw =3D virDomainOsDefFirmwareTypeFromString(firmware); + + if (fw <=3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("unknown firmware value %s"), + firmware); + return -1; + } + + def->os.firmware =3D fw; + + return 0; +} + + static int virDomainDefParseBootOptions(virDomainDefPtr def, xmlXPathContextPtr ctxt) @@ -19621,23 +19646,13 @@ virDomainDefParseBootOptions(virDomainDefPtr def, def->os.type =3D=3D VIR_DOMAIN_OSTYPE_XENPVH || def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM || def->os.type =3D=3D VIR_DOMAIN_OSTYPE_UML) { - g_autofree char *firmware =3D NULL; xmlNodePtr loader_node; =20 virDomainDefParseBootKernelOptions(def, ctxt); =20 - if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM && - (firmware =3D virXPathString("string(./os/@firmware)", ctxt)))= { - int fw =3D virDomainOsDefFirmwareTypeFromString(firmware); - - if (fw <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown firmware value %s"), - firmware); + if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { + if (virDomainDefParseBootFirmwareOptions(def, ctxt) < 0) return -1; - } - - def->os.firmware =3D fw; } =20 if ((loader_node =3D virXPathNode("./os/loader[1]", ctxt))) { --=20 2.30.2 From nobody Sun May 5 20:25:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616070551; cv=none; d=zohomail.com; s=zohoarc; b=Tp94yWkcUtGVr8ssfYXuzskIF+uyscXanOsAE2JoSLvKznvqQzvHC8WnAh0FqTEgbh4VOmA/FvrQkPuxyzW3SKH6P/PNYwE5q7SaKCqx8+irWnskGoM5sl79HLIi+Yg312nJlUi4qCOSLV1RLLCKm3dwLKjUEp6rIAIo/OYuENg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616070551; 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=+WcKd5oq9jUd9Hka2kHMpDXdBsIhZto1R/iJQw+/Hj0=; b=ZfsT0fOu+Dik2BngyB5E7DNm6NwMf/j+KCES4ieaalpv0/iVIaceRSqimvbbcmJYx1Rso0GbA+K4hgII/kP4XwPa0k9YeS/kVIwLxMG0S967F3KrdX/duQh1AIFO/Xfc1PA8K9xAL3A2ccmuNKLU1zNjD7+rmQPwKThHq3Gacug= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1616070551322796.5945397313001; Thu, 18 Mar 2021 05:29:11 -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-170-axIS_TizMLmMd3Z-mfj4jg-1; Thu, 18 Mar 2021 08:29:08 -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 104AD10CE7AB; Thu, 18 Mar 2021 12:29:03 +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 DDCDB6EF41; Thu, 18 Mar 2021 12:29:02 +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 A0E391800215; Thu, 18 Mar 2021 12:29:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12ICR2Fw024702 for ; Thu, 18 Mar 2021 08:27:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id F20105C239; Thu, 18 Mar 2021 12:27:01 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 724B55C1D1 for ; Thu, 18 Mar 2021 12:26:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616070550; 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=+WcKd5oq9jUd9Hka2kHMpDXdBsIhZto1R/iJQw+/Hj0=; b=Gjffjw+IOEEmrrB2oleymsVyi55KJS8ZdZQ+jApU6ihY8pOFA8J42LLbLdN3+tOESzqZGs vRqtN62h5B6F7bLHvn43tyfHetcKMAdIeHRvqBTQi7dJJSuwpXwEAX2m80LEVaJUaF7vmy OrJhi4/wgFXgvn7p8eewy4Lm04wjEZY= X-MC-Unique: axIS_TizMLmMd3Z-mfj4jg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 5/9] conf: introduce virDomainDefParseBootLoaderOptions Date: Thu, 18 Mar 2021 13:26:42 +0100 Message-Id: <54a2fdc8bc7a8115e14a3fe985285822b6f690d0.1616070296.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Extract the code to it's own function. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 03985b6687..f6e8d5180a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19620,6 +19620,31 @@ virDomainDefParseBootFirmwareOptions(virDomainDefP= tr def, } =20 =20 +static int +virDomainDefParseBootLoaderOptions(virDomainDefPtr def, + xmlXPathContextPtr ctxt) +{ + xmlNodePtr loader_node =3D virXPathNode("./os/loader[1]", ctxt); + const bool fwAutoSelect =3D def->os.firmware !=3D VIR_DOMAIN_OS_DEF_FI= RMWARE_NONE; + + if (!loader_node) + return 0; + + def->os.loader =3D g_new0(virDomainLoaderDef, 1); + + if (virDomainLoaderDefParseXML(loader_node, + def->os.loader, + fwAutoSelect) < 0) + return -1; + + def->os.loader->nvram =3D virXPathString("string(./os/nvram[1])", ctxt= ); + if (!fwAutoSelect) + def->os.loader->templt =3D virXPathString("string(./os/nvram[1]/@t= emplate)", ctxt); + + return 0; +} + + static int virDomainDefParseBootOptions(virDomainDefPtr def, xmlXPathContextPtr ctxt) @@ -19646,7 +19671,6 @@ virDomainDefParseBootOptions(virDomainDefPtr def, def->os.type =3D=3D VIR_DOMAIN_OSTYPE_XENPVH || def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM || def->os.type =3D=3D VIR_DOMAIN_OSTYPE_UML) { - xmlNodePtr loader_node; =20 virDomainDefParseBootKernelOptions(def, ctxt); =20 @@ -19655,20 +19679,8 @@ virDomainDefParseBootOptions(virDomainDefPtr def, return -1; } =20 - if ((loader_node =3D virXPathNode("./os/loader[1]", ctxt))) { - const bool fwAutoSelect =3D def->os.firmware !=3D VIR_DOMAIN_O= S_DEF_FIRMWARE_NONE; - - def->os.loader =3D g_new0(virDomainLoaderDef, 1); - - if (virDomainLoaderDefParseXML(loader_node, - def->os.loader, - fwAutoSelect) < 0) - return -1; - - def->os.loader->nvram =3D virXPathString("string(./os/nvram[1]= )", ctxt); - if (!fwAutoSelect) - def->os.loader->templt =3D virXPathString("string(./os/nvr= am[1]/@template)", ctxt); - } + if (virDomainDefParseBootLoaderOptions(def, ctxt) < 0) + return -1; } =20 if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { --=20 2.30.2 From nobody Sun May 5 20:25:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616070513; cv=none; d=zohomail.com; s=zohoarc; b=ByZDJblJWg+ZzErWLcIT8YJkVnOaM+yipu+7T9JAgEss7GwQRYMQDUsIZ1RJyzIkl2iKjDnjGA2a+Vvd9gwvSK9oPprIbjInjtDsqjcsGEK4X51utjalIHmbzrloF87xtabkCd7fiDOSjqanalNH3H6DdU1YcmVbH6oXj+T2pRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616070513; 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=EDNEoncFa4LfukQwEZPepVklU5LP5NdZKGjZejrQi0A=; b=h8WyL4uhJ/U9/L5qXMbgtbJirNC2D3zbt/Acb+oiKqMHmY2socuBAU5oQvmFr+34LBQ+T/ygH/3swmwlI/NJ7Cx082TjB8mI6CIeA0Mal0cEakR3OMFHDQpPZyV8dT9D3yxYxM87sJCESwAOnMOx1yxk+shuv1eo2vJq4MZiilw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1616070513788720.2005323146648; Thu, 18 Mar 2021 05:28:33 -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-225-_Z0VCVsMOBaFnn8YpRIdAg-1; Thu, 18 Mar 2021 08:28:30 -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 5763A10CE7B2; Thu, 18 Mar 2021 12:28:24 +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 2AE3077BF5; Thu, 18 Mar 2021 12:28:24 +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 D58A61809C83; Thu, 18 Mar 2021 12:28:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12ICR6aT024714 for ; Thu, 18 Mar 2021 08:27:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1A4E85C239; Thu, 18 Mar 2021 12:27:06 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DA2F2CE3A for ; Thu, 18 Mar 2021 12:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616070512; 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=EDNEoncFa4LfukQwEZPepVklU5LP5NdZKGjZejrQi0A=; b=apwfxyiRcF5LonduPNU4nLBCQ5BgUlhJqeY5UnjWObsF7Q03ZhMJqcyH0F3ENWTywE3OPj Q0Hg807lavJ3oUvM/gvhAHeQrZYu8bR4mRgKyRGHkDZ22r02FUnq3qvVO7kxFfDUqgBdyG vhxkCBlBdqBivEPC3jVHrWTkyYtPOeE= X-MC-Unique: _Z0VCVsMOBaFnn8YpRIdAg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 6/9] conf: introduce virDomainDefParseBootAcpiOptions Date: Thu, 18 Mar 2021 13:26:43 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Extract the code to it's own function. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 79 ++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f6e8d5180a..14a2c818d6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19645,14 +19645,54 @@ virDomainDefParseBootLoaderOptions(virDomainDefPt= r def, } =20 =20 +static int +virDomainDefParseBootAcpiOptions(virDomainDefPtr def, + xmlXPathContextPtr ctxt) +{ + int n; + g_autofree xmlNodePtr *nodes =3D NULL; + g_autofree char *tmp =3D NULL; + + if ((n =3D virXPathNodeSet("./os/acpi/table", ctxt, &nodes)) < 0) + return -1; + + if (n > 1) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Only one acpi table is supported")); + return -1; + } + + if (n =3D=3D 1) { + tmp =3D virXMLPropString(nodes[0], "type"); + + if (!tmp) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing acpi table type")); + return -1; + } + + if (STREQ_NULLABLE(tmp, "slic")) { + VIR_FREE(tmp); + if (!(tmp =3D virXMLNodeContentString(nodes[0]))) + return -1; + + def->os.slic_table =3D virFileSanitizePath(tmp); + } else { + virReportError(VIR_ERR_XML_ERROR, + _("Unknown acpi table type: %s"), + tmp); + return -1; + } + } + + return 0; +} + + static int virDomainDefParseBootOptions(virDomainDefPtr def, xmlXPathContextPtr ctxt) { - int n; - g_autofree xmlNodePtr *nodes =3D NULL; - g_autofree char *tmp =3D NULL; - /* * Booting options for different OS types.... * @@ -19684,38 +19724,9 @@ virDomainDefParseBootOptions(virDomainDefPtr def, } =20 if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { - if ((n =3D virXPathNodeSet("./os/acpi/table", ctxt, &nodes)) < 0) + if (virDomainDefParseBootAcpiOptions(def, ctxt) < 0) return -1; =20 - if (n > 1) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Only one acpi table is supported")); - return -1; - } - - if (n =3D=3D 1) { - tmp =3D virXMLPropString(nodes[0], "type"); - - if (!tmp) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing acpi table type")); - return -1; - } - - if (STREQ_NULLABLE(tmp, "slic")) { - VIR_FREE(tmp); - if (!(tmp =3D virXMLNodeContentString(nodes[0]))) - return -1; - - def->os.slic_table =3D virFileSanitizePath(tmp); - } else { - virReportError(VIR_ERR_XML_ERROR, - _("Unknown acpi table type: %s"), - tmp); - return -1; - } - } - if (virDomainDefParseBootXML(ctxt, def) < 0) return -1; } --=20 2.30.2 From nobody Sun May 5 20:25:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616070556; cv=none; d=zohomail.com; s=zohoarc; b=GF93H4sOw1B46oPpJbguIfEzuxu4ALFZXanb4X4/JjEdUG365n2Qux3gVJSGxcDIHn4+c26mNyYR3TaGG8PkAwnYdXSqTaU03wdHFqwbZd5c8nRTTu3AsbrYh/yz2fI5lP8hQ8fPDpxz6l4gAas0uWOpcxaCkXpXnzHWvOc7Voo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616070556; 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=RsDdRKbMsUTv3fLrYXXpXrORtxrHycybF6dhVDz/o1Y=; b=mH6Psk+zHCFaDp2L5x7X1Ku5WZWnvnpp0JiI8JonVCHxSAJQ6pa2kdip9h2N5/dFWXMzSBrfDfZKCMtwyr7yqpgwU8MU3V87xBvZxly7wmbvbyJuFbPR9R/M87JhrRO5N9Jg6gAHm8kulMYt3Snuh7/H2bO+LYxm1Hb3XC8w0TI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1616070556087613.1131747800928; Thu, 18 Mar 2021 05:29:16 -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-513-ZIxU9N8WMYGYKlwYGLpydw-1; Thu, 18 Mar 2021 08:29:13 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E344E814315; Thu, 18 Mar 2021 12:29:06 +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 B446319D9B; Thu, 18 Mar 2021 12:29:06 +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 73C864A703; Thu, 18 Mar 2021 12:29:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12ICRAL1024730 for ; Thu, 18 Mar 2021 08:27:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5A84E5C582; Thu, 18 Mar 2021 12:27:10 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCF3F5C239 for ; Thu, 18 Mar 2021 12:27:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616070555; 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=RsDdRKbMsUTv3fLrYXXpXrORtxrHycybF6dhVDz/o1Y=; b=Y7wZ6NLnPGe74xK7c52B2glSNm1VGGkJTrM7qln64hfCO6+Sib8ZloCgnJfR9FMOwf290q aRZNnyYhOG4oPVMxW6N/qFhHplZJ6lOY9Bqf6/AawjFYBUjavjGi7jmOu9A3NeUEfZiJi4 PErgJYOLFrMUbEeOwl1dHfX5CVH0/b0= X-MC-Unique: ZIxU9N8WMYGYKlwYGLpydw-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 7/9] conf: use switch in virDomainDefParseBootOptions Date: Thu, 18 Mar 2021 13:26:44 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The original code used a lot of conditions and was not that obvious when each XML bits are parsed. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 14a2c818d6..7729333897 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19702,33 +19702,43 @@ virDomainDefParseBootOptions(virDomainDefPtr def, * - An init script (exe) */ =20 - if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_EXE) { - if (virDomainDefParseBootInitOptions(def, ctxt) < 0) - return -1; - } - - if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_XEN || - def->os.type =3D=3D VIR_DOMAIN_OSTYPE_XENPVH || - def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM || - def->os.type =3D=3D VIR_DOMAIN_OSTYPE_UML) { - + switch ((virDomainOSType) def->os.type) { + case VIR_DOMAIN_OSTYPE_HVM: virDomainDefParseBootKernelOptions(def, ctxt); =20 - if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { - if (virDomainDefParseBootFirmwareOptions(def, ctxt) < 0) - return -1; - } + if (virDomainDefParseBootFirmwareOptions(def, ctxt) < 0) + return -1; =20 if (virDomainDefParseBootLoaderOptions(def, ctxt) < 0) return -1; - } =20 - if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { if (virDomainDefParseBootAcpiOptions(def, ctxt) < 0) return -1; =20 if (virDomainDefParseBootXML(ctxt, def) < 0) return -1; + + break; + + case VIR_DOMAIN_OSTYPE_XEN: + case VIR_DOMAIN_OSTYPE_XENPVH: + case VIR_DOMAIN_OSTYPE_UML: + virDomainDefParseBootKernelOptions(def, ctxt); + + if (virDomainDefParseBootLoaderOptions(def, ctxt) < 0) + return -1; + + break; + + case VIR_DOMAIN_OSTYPE_EXE: + if (virDomainDefParseBootInitOptions(def, ctxt) < 0) + return -1; + + break; + + case VIR_DOMAIN_OSTYPE_LINUX: + case VIR_DOMAIN_OSTYPE_LAST: + break; } =20 return 0; --=20 2.30.2 From nobody Sun May 5 20:25:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616070516; cv=none; d=zohomail.com; s=zohoarc; b=Ue2qC37dSMPxbiNW6SLBhNgt8Ll5J83aXa21ICBpCYSUn6sm7ViGddM2x1DJ2vuyfPeeWVE8M9Cna2UQP7rwqhDN8VLLXNN6NZUxzHmg1kAIoEophhLb0mtBjY7RqLxJwme0KNd4u2fiqqjpV0udAamNIwIOy4g5TL89EcqPfNg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616070516; 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=Dc1ItgGRt5cKUJeYn6bWsVRlTEfLlN25x1Z2qRjINa8=; b=AcJVtybgvNgMsespvK9ltV3wLYilmKkJ1TYs11R02eK4eSF/sMQntAwjSTbzAJGUy1TXhjGd5HzKkyUMOtLxyWkkhkAvxe+pqM6l9/+0bLW4GTB3WEcwufoA+L+zpaHwT6+i+1hcpiQF1vkhub41rMgNzvHEyTMu186kh/biIyA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16160705161091023.655321136512; Thu, 18 Mar 2021 05:28:36 -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-168-dOThYQOpP_SMKSTojZkLzQ-1; Thu, 18 Mar 2021 08:28:33 -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 0059B1084D7D; Thu, 18 Mar 2021 12:28:25 +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 CD16118B1F; Thu, 18 Mar 2021 12:28:24 +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 7547818155DD; Thu, 18 Mar 2021 12:28:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12ICRBRw024765 for ; Thu, 18 Mar 2021 08:27:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C9825C582; Thu, 18 Mar 2021 12:27:11 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE4C25C239 for ; Thu, 18 Mar 2021 12:27:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616070515; 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=Dc1ItgGRt5cKUJeYn6bWsVRlTEfLlN25x1Z2qRjINa8=; b=M8cP1SmSqpg3rBF1HlR+8OoXOkSlK2bHT9Hg07Jv9kRX8S/udEDadJ+i+eGzxPZpB7/QKn uWTtEDVdzKd+hW5j9eCwx+Q9U2J8F3FcKGGNiMeHwJiFeaioFZtbEQxcFxEuwzuUH/aJOQ lPHbMvIj9x1Fsr1REgvj2aH1Pc+0gws= X-MC-Unique: dOThYQOpP_SMKSTojZkLzQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 8/9] conf: introduce support for firmware auto-selection feature filtering Date: Thu, 18 Mar 2021 13:26:45 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When the firmware auto-selection was introduced it always picked first usable firmware based on the JSON descriptions on the host. It is possible to add/remove/change the JSON files but it will always be for the whole host. This patch introduces support for configuring the auto-selection per VM by adding users an option to limit what features they would like to have available in the firmware. Signed-off-by: Pavel Hrdina --- docs/formatdomain.rst | 31 +++++++ docs/schemas/domaincommon.rng | 23 +++++ src/conf/domain_conf.c | 83 ++++++++++++++++++- src/conf/domain_conf.h | 10 +++ .../os-firmware-efi-invalid-type.xml | 28 +++++++ ...os-firmware-invalid-type.x86_64-latest.err | 1 + .../os-firmware-invalid-type.xml | 28 +++++++ tests/qemuxml2argvtest.c | 1 + ...aarch64-os-firmware-efi.aarch64-latest.xml | 1 + .../os-firmware-bios.x86_64-latest.xml | 1 + .../os-firmware-efi-secboot.x86_64-latest.xml | 1 + .../os-firmware-efi.x86_64-latest.xml | 1 + tests/vmx2xmldata/vmx2xml-firmware-efi.xml | 1 + 13 files changed, 207 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/os-firmware-efi-invalid-type.xml create mode 100644 tests/qemuxml2argvdata/os-firmware-invalid-type.x86_64-= latest.err create mode 100644 tests/qemuxml2argvdata/os-firmware-invalid-type.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index c101d5a1f1..dd063b0794 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -155,6 +155,37 @@ harddisk, cdrom, network) determining where to obtain/= find the boot image. the host native arch will be chosen. For the ``test``, ``ESX`` and ``VM= Ware`` hypervisor drivers, however, the ``i686`` arch will always be chosen ev= en on an ``x86_64`` host. :since:`Since 0.0.1` +``firmware`` + :since:`Since 7.2.0 QEMU/KVM only` + + When used together with ``firmware`` attribute of ``os`` element the ``= type`` + attribute must have the same value. + + List of mandatory attributes: + + - ``type`` (accepted values are ``bios`` and ``efi``) same as the ``fir= mware`` + attribute of ``os`` element. + + When using firmware auto-selection there are different features enabled= in + the firmwares. The list of features can be used to limit what firmware = should + be automatically selected for the VM. The list of features can be speci= fied + using zero or more ``feature`` elements. Libvirt will take into conside= ration + only the listed features and ignore the rest when selecting the firmwar= e. + + ``feature`` + The list of mandatory attributes: + + - ``enabled`` (accepted values are ``yes`` and ``no``) is used to te= ll libvirt + if the feature must be enabled or not in the automatically selecte= d firmware + + - ``name`` the name of the feature, the list of the features: + + - ``enrolled-keys`` whether the selected nvram template has default + certificate enrolled. Firmware with Secure Boot feature but with= out + enrolled keys will successfully boot non-signed binaries as well. + Valid only for firmwares with Secure Boot feature. + + - ``secure-boot`` whether the firmware implements UEFI Secure boot= feature. ``loader`` The optional ``loader`` tag refers to a firmware blob, which is specifi= ed by absolute path, used to assist the domain creation process. It is used b= y Xen diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index e6db2f5b74..1dbfc68f18 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -276,6 +276,29 @@ + + + + + bios + efi + + + + + + + + + + enrolled-keys + secure-boot + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7729333897..dcfe5c0d03 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1318,6 +1318,12 @@ VIR_ENUM_IMPL(virDomainOsDefFirmware, "efi", ); =20 +VIR_ENUM_IMPL(virDomainOsDefFirmwareFeature, + VIR_DOMAIN_OS_DEF_FIRMWARE_FEATURE_LAST, + "enrolled-keys", + "secure-boot", +); + VIR_ENUM_IMPL(virDomainCFPC, VIR_DOMAIN_CFPC_LAST, "none", @@ -19600,22 +19606,67 @@ virDomainDefParseBootFirmwareOptions(virDomainDef= Ptr def, xmlXPathContextPtr ctxt) { g_autofree char *firmware =3D virXPathString("string(./os/@firmware)",= ctxt); + g_autofree char *type =3D virXPathString("string(./os/firmware/@type)"= , ctxt); + g_autofree xmlNodePtr *nodes =3D NULL; + g_autofree int *features =3D NULL; int fw =3D 0; + int n =3D 0; + size_t i; =20 - if (!firmware) + if (!firmware && !type) return 0; =20 - fw =3D virDomainOsDefFirmwareTypeFromString(firmware); + if (firmware && type && STRNEQ(firmware, type)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("firmware attribute and firmware type has to be t= he same")); + return -1; + } + + if (!type) + type =3D g_steal_pointer(&firmware); + + fw =3D virDomainOsDefFirmwareTypeFromString(type); =20 if (fw <=3D 0) { virReportError(VIR_ERR_XML_ERROR, _("unknown firmware value %s"), - firmware); + type); return -1; } =20 def->os.firmware =3D fw; =20 + if ((n =3D virXPathNodeSet("./os/firmware/feature", ctxt, &nodes)) < 0) + return -1; + + if (n > 0) + features =3D g_new0(int, VIR_DOMAIN_OS_DEF_FIRMWARE_FEATURE_LAST); + + for (i =3D 0; i < n; i++) { + g_autofree char *name =3D virXMLPropString(nodes[i], "name"); + g_autofree char *enabled =3D virXMLPropString(nodes[i], "enabled"); + int feature =3D virDomainOsDefFirmwareFeatureTypeFromString(name); + int val =3D virTristateBoolTypeFromString(enabled); + + if (feature < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("invalid firmware feature name '%s'"), + name); + return -1; + } + + if (val < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("invalid firmware feature enabled value '%s'"= ), + enabled); + return -1; + } + + features[feature] =3D val; + } + + def->os.firmwareFeatures =3D g_steal_pointer(&features); + return 0; } =20 @@ -29455,6 +29506,32 @@ virDomainDefFormatInternalSetRootName(virDomainDef= Ptr def, virBufferAsprintf(buf, ">%s\n", virDomainOSTypeToString(def->os.type)); =20 + if (def->os.firmware) { + virBufferAsprintf(buf, "os.firmw= are)); + + if (def->os.firmwareFeatures) { + virBufferAddLit(buf, ">\n"); + + virBufferAdjustIndent(buf, 2); + + for (i =3D 0; i < VIR_DOMAIN_OS_DEF_FIRMWARE_FEATURE_LAST; i++= ) { + if (def->os.firmwareFeatures[i] =3D=3D VIR_TRISTATE_BOOL_A= BSENT) + continue; + + virBufferAsprintf(buf, "\n", + virTristateBoolTypeToString(def->os.firm= wareFeatures[i]), + virDomainOsDefFirmwareFeatureTypeToStrin= g(i)); + } + + virBufferAdjustIndent(buf, -2); + + virBufferAddLit(buf, "\n"); + } else { + virBufferAddLit(buf, "/>\n"); + } + } + virBufferEscapeString(buf, "%s\n", def->os.init); for (i =3D 0; def->os.initargv && def->os.initargv[i]; i++) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 54a631853b..87bc7e8625 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2235,9 +2235,19 @@ G_STATIC_ASSERT((int)VIR_DOMAIN_OS_DEF_FIRMWARE_LAST= =3D=3D (int)VIR_DOMAIN_LOADER_T =20 VIR_ENUM_DECL(virDomainOsDefFirmware); =20 +typedef enum { + VIR_DOMAIN_OS_DEF_FIRMWARE_FEATURE_ENROLLED_KEYS, + VIR_DOMAIN_OS_DEF_FIRMWARE_FEATURE_SECURE_BOOT, + + VIR_DOMAIN_OS_DEF_FIRMWARE_FEATURE_LAST +} virDomainOsDefFirmwareFeature; + +VIR_ENUM_DECL(virDomainOsDefFirmwareFeature); + struct _virDomainOSDef { int type; virDomainOsDefFirmware firmware; + int *firmwareFeatures; virArch arch; char *machine; size_t nBootDevs; diff --git a/tests/qemuxml2argvdata/os-firmware-efi-invalid-type.xml b/test= s/qemuxml2argvdata/os-firmware-efi-invalid-type.xml new file mode 100644 index 0000000000..41360df0f7 --- /dev/null +++ b/tests/qemuxml2argvdata/os-firmware-efi-invalid-type.xml @@ -0,0 +1,28 @@ + + fedora + 63840878-0deb-4095-97e6-fc444d9bc9fa + 8192 + 8192 + 1 + + hvm + + + /var/lib/libvirt/qemu/nvram/fedora_VARS.fd + + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + + diff --git a/tests/qemuxml2argvdata/os-firmware-invalid-type.x86_64-latest.= err b/tests/qemuxml2argvdata/os-firmware-invalid-type.x86_64-latest.err new file mode 100644 index 0000000000..c8174b1c8b --- /dev/null +++ b/tests/qemuxml2argvdata/os-firmware-invalid-type.x86_64-latest.err @@ -0,0 +1 @@ +unsupported configuration: firmware attribute and firmware type has to be = the same diff --git a/tests/qemuxml2argvdata/os-firmware-invalid-type.xml b/tests/qe= muxml2argvdata/os-firmware-invalid-type.xml new file mode 100644 index 0000000000..41360df0f7 --- /dev/null +++ b/tests/qemuxml2argvdata/os-firmware-invalid-type.xml @@ -0,0 +1,28 @@ + + fedora + 63840878-0deb-4095-97e6-fc444d9bc9fa + 8192 + 8192 + 1 + + hvm + + + /var/lib/libvirt/qemu/nvram/fedora_VARS.fd + + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 29054ba168..2b32b7f303 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3549,6 +3549,7 @@ mymain(void) DO_TEST_CAPS_LATEST("os-firmware-bios"); DO_TEST_CAPS_LATEST("os-firmware-efi"); DO_TEST_CAPS_LATEST("os-firmware-efi-secboot"); + DO_TEST_CAPS_LATEST_PARSE_ERROR("os-firmware-invalid-type"); DO_TEST_CAPS_ARCH_LATEST("aarch64-os-firmware-efi", "aarch64"); =20 DO_TEST_CAPS_LATEST("vhost-user-vga"); diff --git a/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-lates= t.xml b/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml index 627e285ae1..cb4f3ccfce 100644 --- a/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml +++ b/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml @@ -6,6 +6,7 @@ 1 hvm + /aarch64.kernel /aarch64.initrd earlyprintk console=3DttyAMA0,115200n8 rw root=3D/dev/vda roo= twait diff --git a/tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml b/= tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml index df6f61421a..016c5b863f 100644 --- a/tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/os-firmware-bios.x86_64-latest.xml @@ -6,6 +6,7 @@ 1 hvm + /var/lib/libvirt/qemu/nvram/fedora_VARS.fd diff --git a/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest= .xml b/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest.xml index c383546cc6..fa5eaa3148 100644 --- a/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/os-firmware-efi-secboot.x86_64-latest.xml @@ -6,6 +6,7 @@ 1 hvm + /var/lib/libvirt/qemu/nvram/fedora_VARS.fd diff --git a/tests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml b/t= ests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml index 04d57860e7..382146c23b 100644 --- a/tests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/os-firmware-efi.x86_64-latest.xml @@ -6,6 +6,7 @@ 1 hvm + /var/lib/libvirt/qemu/nvram/fedora_VARS.fd diff --git a/tests/vmx2xmldata/vmx2xml-firmware-efi.xml b/tests/vmx2xmldata= /vmx2xml-firmware-efi.xml index fee707fe71..fa10daf3a6 100644 --- a/tests/vmx2xmldata/vmx2xml-firmware-efi.xml +++ b/tests/vmx2xmldata/vmx2xml-firmware-efi.xml @@ -6,6 +6,7 @@ 1 hvm + destroy --=20 2.30.2 From nobody Sun May 5 20:25:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616070517; cv=none; d=zohomail.com; s=zohoarc; b=fs6N662PNnzGNKK60AUwbcIHbEBMxPvwEiTT0sIhWDoOEfv7XITisrb7yAidKYgt5iYIXxwsA66g5GY4eJv3utY8fFwhsmI4w4iEy1RBKG7mXm0PnuRtR4CGbtKEYz9Ky3DradWwWq0rrO0H0VAcAgjqcnia3p66iXfSaB2K5Ko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616070517; 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=2jOtOjnb8+ckPJ6bxBzq58MYR3EcOBVb4K77DXBO4v8=; b=M7VcYhUupMobNSURY4Sj8Z8VL6wxhKIZATMCvfQHpwPhbzivifaiVnaXc2hkXGSjPJKiYSrzG9hLGnAkub2MCVcVFsxPRVmtGm+6zKt61MPIT6j4GrynyYu7oL7KFDACHcMONexHVmI7/VoVKkmrYmGjFEklqHCZhe9/L1OtZCk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1616070517690669.6104670473595; Thu, 18 Mar 2021 05:28:37 -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-490-Tppk9uuGPZ-wjykmgZHOeQ-1; Thu, 18 Mar 2021 08:28:34 -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 2682D1927807; Thu, 18 Mar 2021 12:28:29 +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 E756A5D723; Thu, 18 Mar 2021 12:28:28 +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 8D1E34A7CB; Thu, 18 Mar 2021 12:28:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12ICRC5E024781 for ; Thu, 18 Mar 2021 08:27:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1F53818813; Thu, 18 Mar 2021 12:27:12 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E7805C582 for ; Thu, 18 Mar 2021 12:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616070516; 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=2jOtOjnb8+ckPJ6bxBzq58MYR3EcOBVb4K77DXBO4v8=; b=KFfD1rgqBtEdUhThh65ierA0FK0ZGL3rlSMRf1BcR2YLrxoie4TBFJjbv9dh5MR4cwwoYS 8OOIYQ142TQgWNn/Ce7iMqoh1wm5s9b7qB3EAxed/qqF8cBZm6iAhJ3OlhwvHhNIkaotSv HbwZ4IXhFwRMcuWtHp/oYyDLbvSrtpI= X-MC-Unique: Tppk9uuGPZ-wjykmgZHOeQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 9/9] qemu: implement support for firmware auto-selection feature filtering Date: Thu, 18 Mar 2021 13:26:46 +0100 Message-Id: <31c20ee58e900499a4e3c6377edd903dfd6149f0.1616070296.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/qemu/qemu_firmware.c | 40 +++++++++++++++ ...re-efi-no-enrolled-keys.x86_64-latest.args | 49 ++++++++++++++++++ .../os-firmware-efi-no-enrolled-keys.xml | 25 ++++++++++ tests/qemuxml2argvtest.c | 1 + ...are-efi-no-enrolled-keys.x86_64-latest.xml | 50 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 6 files changed, 166 insertions(+) create mode 100644 tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys= .x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys= .xml create mode 100644 tests/qemuxml2xmloutdata/os-firmware-efi-no-enrolled-ke= ys.x86_64-latest.xml diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index d3198e2d45..f6f371f51f 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -930,6 +930,10 @@ qemuFirmwareMatchDomain(const virDomainDef *def, bool supportsS4 =3D false; bool requiresSMM =3D false; bool supportsSEV =3D false; + bool supportsSecureBoot =3D false; + bool hasEnrolledKeys =3D false; + int reqSecureBoot; + int reqEnrolledKeys; =20 want =3D qemuFirmwareOSInterfaceTypeFromOsDefFirmware(def->os.firmware= ); =20 @@ -979,7 +983,13 @@ qemuFirmwareMatchDomain(const virDomainDef *def, break; =20 case QEMU_FIRMWARE_FEATURE_SECURE_BOOT: + supportsSecureBoot =3D true; + break; + case QEMU_FIRMWARE_FEATURE_ENROLLED_KEYS: + hasEnrolledKeys =3D true; + break; + case QEMU_FIRMWARE_FEATURE_VERBOSE_DYNAMIC: case QEMU_FIRMWARE_FEATURE_VERBOSE_STATIC: case QEMU_FIRMWARE_FEATURE_NONE: @@ -1000,6 +1010,36 @@ qemuFirmwareMatchDomain(const virDomainDef *def, return false; } =20 + if (def->os.firmwareFeatures) { + reqSecureBoot =3D def->os.firmwareFeatures[VIR_DOMAIN_OS_DEF_FIRMW= ARE_FEATURE_SECURE_BOOT]; + if (reqSecureBoot !=3D VIR_TRISTATE_BOOL_ABSENT) { + if (reqSecureBoot =3D=3D VIR_TRISTATE_BOOL_YES && !supportsSec= ureBoot) { + VIR_DEBUG("User requested Secure Boot, firmware '%s' doesn= 't support it", + path); + return false; + } + + if (reqSecureBoot =3D=3D VIR_TRISTATE_BOOL_NO && supportsSecur= eBoot) { + VIR_DEBUG("User refused Secure Boot, firmware '%s' support= s it", path); + return false; + } + } + + reqEnrolledKeys =3D def->os.firmwareFeatures[VIR_DOMAIN_OS_DEF_FIR= MWARE_FEATURE_ENROLLED_KEYS]; + if (reqEnrolledKeys !=3D VIR_TRISTATE_BOOL_ABSENT) { + if (reqEnrolledKeys =3D=3D VIR_TRISTATE_BOOL_YES && !hasEnroll= edKeys) { + VIR_DEBUG("User requested Enrolled keys, firmware '%s' doe= sn't support it", + path); + return false; + } + + if (reqEnrolledKeys =3D=3D VIR_TRISTATE_BOOL_NO && hasEnrolled= Keys) { + VIR_DEBUG("User refused Enrolled keys, firmware '%s' suppo= rts it", path); + return false; + } + } + } + if (def->os.loader && def->os.loader->secure =3D=3D VIR_TRISTATE_BOOL_YES && !requiresSMM) { diff --git a/tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.x86_64= -latest.args b/tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.x86_= 64-latest.args new file mode 100644 index 0000000000..561a905e78 --- /dev/null +++ b/tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.x86_64-latest= .args @@ -0,0 +1,49 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-fedora \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-fedora/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-fedora/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-fedora/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dfedora,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-fedora/master-key.aes \ +-blockdev '{"driver":"file","filename":"/usr/share/OVMF/OVMF_CODE.fd",\ +"node-name":"libvirt-pflash0-storage","auto-read-only":true,\ +"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,\ +"driver":"raw","file":"libvirt-pflash0-storage"}' \ +-blockdev '{"driver":"file",\ +"filename":"/var/lib/libvirt/qemu/nvram/fedora_VARS.fd",\ +"node-name":"libvirt-pflash1-storage","auto-read-only":true,\ +"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,\ +"driver":"raw","file":"libvirt-pflash1-storage"}' \ +-machine pc-q35-4.0,accel=3Dkvm,usb=3Doff,dump-guest-core=3Doff,\ +pflash0=3Dlibvirt-pflash0-format,pflash1=3Dlibvirt-pflash1-format,\ +memory-backend=3Dpc.ram \ +-cpu qemu64 \ +-m 8 \ +-object memory-backend-ram,id=3Dpc.ram,size=3D8388608 \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 63840878-0deb-4095-97e6-fc444d9bc9fa \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-device pcie-root-port,port=3D0x8,chassis=3D1,id=3Dpci.1,bus=3Dpcie.0,mult= ifunction=3Don,\ +addr=3D0x1 \ +-device pcie-root-port,port=3D0x9,chassis=3D2,id=3Dpci.2,bus=3Dpcie.0,addr= =3D0x1.0x1 \ +-device qemu-xhci,id=3Dusb,bus=3Dpci.1,addr=3D0x0 \ +-audiodev id=3Daudio1,driver=3Dnone \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.xml b/= tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.xml new file mode 100644 index 0000000000..6c0b323fd4 --- /dev/null +++ b/tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.xml @@ -0,0 +1,25 @@ + + fedora + 63840878-0deb-4095-97e6-fc444d9bc9fa + 8192 + 8192 + 1 + + + + + hvm + + + + + + + + /usr/bin/qemu-system-x86_64 + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 2b32b7f303..44c2a316b0 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3549,6 +3549,7 @@ mymain(void) DO_TEST_CAPS_LATEST("os-firmware-bios"); DO_TEST_CAPS_LATEST("os-firmware-efi"); DO_TEST_CAPS_LATEST("os-firmware-efi-secboot"); + DO_TEST_CAPS_LATEST("os-firmware-efi-no-enrolled-keys"); DO_TEST_CAPS_LATEST_PARSE_ERROR("os-firmware-invalid-type"); DO_TEST_CAPS_ARCH_LATEST("aarch64-os-firmware-efi", "aarch64"); =20 diff --git a/tests/qemuxml2xmloutdata/os-firmware-efi-no-enrolled-keys.x86_= 64-latest.xml b/tests/qemuxml2xmloutdata/os-firmware-efi-no-enrolled-keys.x= 86_64-latest.xml new file mode 100644 index 0000000000..3dbfbf0082 --- /dev/null +++ b/tests/qemuxml2xmloutdata/os-firmware-efi-no-enrolled-keys.x86_64-late= st.xml @@ -0,0 +1,50 @@ + + fedora + 63840878-0deb-4095-97e6-fc444d9bc9fa + 8192 + 8192 + 1 + + hvm + + + + + + + + + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + +
+ + +
+ + + + +
+ + + + +
+ + + +