From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065054; cv=none; d=zoho.com; s=zohoarc; b=WTFW5+XFZ0yxZVx46v8VrupmlhtODNXCfyaknC6hNU9Llmlqn9efp897hlXKIAheiZBDYXhtPip4dhtv48wAoRLp+xCCw6vIj6A5d/ievoGaXLSYyDYnurvt39eYGq07jHo1RPQRj1xBmHw9KcTMLVeICFlbDysg+906BnabFz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065054; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=Djp0dXVHI7LnNz4gC2HIBz0Q7YFceyB1adWze87J91U=; b=oarc7gKx0PRES2XF57N6hMp0hgyBTze00j2X4KbFy4diMV1lf41uHr+xMsSvVa6vzQruMk10hxTKcaXiRoUKYJtsw0QX59yISaZKWa5iESv7wDas+SX23L3uWw4jOUDNfEsZhQkxjki7zT3PLBHmlipRFcSNOlMoSMkqiM2GQmY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065054517407.74565750750605; Thu, 25 Jul 2019 07:30:54 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 753A9309265C; Thu, 25 Jul 2019 14:30:52 +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 3064461B89; Thu, 25 Jul 2019 14:30:52 +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 0C2D41800207; Thu, 25 Jul 2019 14:30:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6PEUnAs012724 for ; Thu, 25 Jul 2019 10:30:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4F41635F2; Thu, 25 Jul 2019 14:30:49 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 48B785DE6F for ; Thu, 25 Jul 2019 14:30:46 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA76A30C34D0 for ; Thu, 25 Jul 2019 14:30:45 +0000 (UTC) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PEThJx113450 for ; Thu, 25 Jul 2019 10:30:45 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tyceyn3y5-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:45 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:44 +0100 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:42 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUfoH54788366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:41 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0A92DBE053; Thu, 25 Jul 2019 14:30:41 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ACB20BE05A; Thu, 25 Jul 2019 14:30:40 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:40 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:15 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-8235-0000-0000-00000EBE02DE X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237265; UDB=6.00652184; IPR=6.01018639; MB=3.00027886; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:43 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-8236-0000-0000-0000468AF20F Message-Id: <20190725143033.1176271-2-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 25 Jul 2019 14:30:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 25 Jul 2019 14:30:45 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 01/19] secret: Add support for usage type vTPM, extend schema and test case 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 25 Jul 2019 14:30:53 +0000 (UTC) Add support for usage type vTPM to secret. Extend the schema for the Secret to support the vTPM usage type and add a test case for parsing the Secret with usage type vTPM. Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/schemas/secret.rng | 10 ++++++++++ include/libvirt/libvirt-secret.h | 1 + src/conf/secret_conf.c | 13 +++++++++++++ src/util/virsecret.c | 2 +- tests/secretxml2xmlin/usage-vtpm.xml | 7 +++++++ tests/secretxml2xmltest.c | 1 + 6 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/secretxml2xmlin/usage-vtpm.xml diff --git a/docs/schemas/secret.rng b/docs/schemas/secret.rng index 1e94d66e48..e0add8a5e9 100644 --- a/docs/schemas/secret.rng +++ b/docs/schemas/secret.rng @@ -37,6 +37,7 @@ + @@ -81,4 +82,13 @@ =20 + + + vtpm + + + + + + diff --git a/include/libvirt/libvirt-secret.h b/include/libvirt/libvirt-sec= ret.h index 9a1065f0f3..e5aaac9450 100644 --- a/include/libvirt/libvirt-secret.h +++ b/include/libvirt/libvirt-secret.h @@ -43,6 +43,7 @@ typedef enum { VIR_SECRET_USAGE_TYPE_CEPH =3D 2, VIR_SECRET_USAGE_TYPE_ISCSI =3D 3, VIR_SECRET_USAGE_TYPE_TLS =3D 4, + VIR_SECRET_USAGE_TYPE_VTPM =3D 5, =20 # ifdef VIR_ENUM_SENTINELS VIR_SECRET_USAGE_TYPE_LAST diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index 5b85a7c0be..b291339e77 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -110,6 +110,15 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt, } break; =20 + case VIR_SECRET_USAGE_TYPE_VTPM: + def->usage_id =3D virXPathString("string(./usage/name)", ctxt); + if (!def->usage_id) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("vTPM usage specified, but name is missing")); + return -1; + } + break; + default: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected secret usage type %d"), @@ -257,6 +266,10 @@ virSecretDefFormatUsage(virBufferPtr buf, virBufferEscapeString(buf, "%s\n", def->usage_id); break; =20 + case VIR_SECRET_USAGE_TYPE_VTPM: + virBufferEscapeString(buf, "%s\n", def->usage_id); + break; + default: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected secret usage type %d"), diff --git a/src/util/virsecret.c b/src/util/virsecret.c index 854dc72b06..7844a76a56 100644 --- a/src/util/virsecret.c +++ b/src/util/virsecret.c @@ -34,7 +34,7 @@ VIR_LOG_INIT("util.secret"); =20 VIR_ENUM_IMPL(virSecretUsage, VIR_SECRET_USAGE_TYPE_LAST, - "none", "volume", "ceph", "iscsi", "tls", + "none", "volume", "ceph", "iscsi", "tls", "vtpm", ); =20 void diff --git a/tests/secretxml2xmlin/usage-vtpm.xml b/tests/secretxml2xmlin/u= sage-vtpm.xml new file mode 100644 index 0000000000..5baff3034d --- /dev/null +++ b/tests/secretxml2xmlin/usage-vtpm.xml @@ -0,0 +1,7 @@ + + aa6c7af2-45a7-477c-85a2-fe86d9f2514e + vTPM secret + + vTPMvTPMvTPM + + diff --git a/tests/secretxml2xmltest.c b/tests/secretxml2xmltest.c index fd93703424..595583346a 100644 --- a/tests/secretxml2xmltest.c +++ b/tests/secretxml2xmltest.c @@ -80,6 +80,7 @@ mymain(void) DO_TEST("usage-ceph"); DO_TEST("usage-iscsi"); DO_TEST("usage-tls"); + DO_TEST("usage-vtpm"); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065064; cv=none; d=zoho.com; s=zohoarc; b=TLyhRNEAkMY7fD21uK4BWPPHr+5WhpqbZn747WBKBwofuJ+79w8gaHg/KCKax8kXc9uJju+RjM6yhqkO5Qf5qdk4bhh82w0XA/JuBzIYv7aUjQGsMaEamofJ6dBv5wxDiQtKaxmIPAz6iIMpYp22u+j0/meJYRjmbrZpTZ2WWI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065064; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=beYazo7+KT6p5AVpp4PTS6g02l6domx936I8CKegK8M=; b=TCTxvJzRcNEPHP7bfggx1b022P6YWHVlHsus5xfQF8k1UEcCKFQW4KX70AfSgwEJxhb8B6GItPDZ3zhwKoRkojufOjJFZdheS9i+GVLkxr0p7VQQoaIxAy+BUwh+bmkK8LXiQymkT33STFd7Sme4CbmUDHRmw62jDRD/KsNQRqI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065064439188.7389808918473; Thu, 25 Jul 2019 07:31:04 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 115658553D; Thu, 25 Jul 2019 14:31: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 B56B8608A5; Thu, 25 Jul 2019 14:31: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 517E818045CE; Thu, 25 Jul 2019 14:31:02 +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 x6PEUn61012729 for ; Thu, 25 Jul 2019 10:30:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id B50A21018A0D; Thu, 25 Jul 2019 14:30:49 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B032B10190A2 for ; Thu, 25 Jul 2019 14:30:47 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B306E30A8841 for ; Thu, 25 Jul 2019 14:30:46 +0000 (UTC) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PETiFT135547 for ; Thu, 25 Jul 2019 10:30:45 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2tye288kk6-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:45 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:44 +0100 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:42 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUf2u30605750 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:41 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89A37BE04F; Thu, 25 Jul 2019 14:30:41 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2EEF2BE05A; Thu, 25 Jul 2019 14:30:41 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:41 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:16 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-0012-0000-0000-000017564E1F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237265; UDB=6.00652184; IPR=6.01018639; MB=3.00027885; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:43 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-0013-0000-0000-00005836658C Message-Id: <20190725143033.1176271-3-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 25 Jul 2019 14:30:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 25 Jul 2019 14:30:46 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 02/19] tests: Add already existing test case tpm-emulator-tpm2 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 25 Jul 2019 14:31:03 +0000 (UTC) Add an already existing test case tpm-emulator-tpm2 to qemuxml2xmltest.c Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/qemuxml2xmltest.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 09c86eda2a..f9e1151906 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -655,6 +655,7 @@ mymain(void) DO_TEST("tpm-passthrough", NONE); DO_TEST("tpm-passthrough-crb", NONE); DO_TEST("tpm-emulator", NONE); + DO_TEST("tpm-emulator-tpm2", NONE); =20 DO_TEST("metadata", NONE); DO_TEST("metadata-duplicate", NONE); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065067; cv=none; d=zoho.com; s=zohoarc; b=lJoasH7l/4DJ2Zi2GU/C9PghpbnOlXw7QnATPzwCZaakXd48J0Xni5ZXE7GDjls4lehIpK2+u4RNUHXaxkxRAdX+UzWv47q8TX+i8UlVE1VWoi1MBLFcoVsms/W0ccZbgJL22b8vlLnk7FAQPp4iKbo3dY0cKaR8il4yEsSZJv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065067; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=RolAP20CbV3yqty8YQ0L1RHc8k4IxR51U7eK3Nje+KU=; b=klFNk0GMOkKrIbiBzHtiPEzOStiQj5jlomndIEW62MauXQ4diX7PTsxAmA+PPgjavkqn/aDWDMXLzTL/Bocwtt4OiDqwInc1IVV6eIY9k3ix5l2gGTzEKcIUHKaish8NrVx5/0Y/ExZmbrZRVb7NdZY+E0oYbkjGNT/NbdIu/BI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156406506788159.27895263364837; Thu, 25 Jul 2019 07:31:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 730C130C34CA; Thu, 25 Jul 2019 14:31:06 +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 418425DEA8; Thu, 25 Jul 2019 14:31: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 F088118045DB; Thu, 25 Jul 2019 14:31:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6PEUrpl012788 for ; Thu, 25 Jul 2019 10:30:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6184C19D7E; Thu, 25 Jul 2019 14:30:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 59D6319D71 for ; Thu, 25 Jul 2019 14:30:48 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4434D330265 for ; Thu, 25 Jul 2019 14:30:47 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PETfs4042616 for ; Thu, 25 Jul 2019 10:30:46 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tydm02861-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:45 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:45 +0100 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:43 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUgMm47251864 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:42 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0BAABBE053; Thu, 25 Jul 2019 14:30:42 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A4B46BE051; Thu, 25 Jul 2019 14:30:41 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:41 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:17 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-0012-0000-0000-000017564E21 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237265; UDB=6.00652184; IPR=6.01018639; MB=3.00027885; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:44 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-0013-0000-0000-00005836658D Message-Id: <20190725143033.1176271-4-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 25 Jul 2019 14:30:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 25 Jul 2019 14:30:47 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 03/19] conf: Extend TPM XML parser with encryption support 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 25 Jul 2019 14:31:07 +0000 (UTC) Extend the TPM device XML parser and XML generator with emulator state encryption support. Signed-off-by: Stefan Berger Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/schemas/domaincommon.rng | 11 +++++++++++ src/conf/domain_conf.c | 31 ++++++++++++++++++++++++++++++- src/conf/domain_conf.h | 2 ++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 763480440c..a0771da45b 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4317,6 +4317,7 @@ emulator + @@ -4346,6 +4347,16 @@ =20 + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0574c69a46..6673a323c6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13049,6 +13049,14 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPt= r xmlopt, * * * + * + * Emulator state encryption is supported with the following: + * + * + * + * + * + * */ static virDomainTPMDefPtr virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt, @@ -13063,6 +13071,7 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlop= t, VIR_AUTOFREE(char *) model =3D NULL; VIR_AUTOFREE(char *) backend =3D NULL; VIR_AUTOFREE(char *) version =3D NULL; + VIR_AUTOFREE(char *) secretuuid =3D NULL; VIR_AUTOFREE(xmlNodePtr *) backends =3D NULL; =20 if (VIR_ALLOC(def) < 0) @@ -13127,6 +13136,15 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlo= pt, def->data.passthrough.source.type =3D VIR_DOMAIN_CHR_TYPE_DEV; break; case VIR_DOMAIN_TPM_TYPE_EMULATOR: + secretuuid =3D virXPathString("string(./backend/encryption/@secret= )", ctxt); + if (secretuuid) { + if (virUUIDParse(secretuuid, def->data.emulator.secretuuid) < = 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to parse secret uuid '%s'"), secr= etuuid); + goto error; + } + def->data.emulator.hassecretuuid =3D true; + } break; case VIR_DOMAIN_TPM_TYPE_LAST: goto error; @@ -25953,8 +25971,19 @@ virDomainTPMDefFormat(virBufferPtr buf, virBufferAddLit(buf, "\n"); break; case VIR_DOMAIN_TPM_TYPE_EMULATOR: - virBufferAsprintf(buf, " version=3D'%s'/>\n", + virBufferAsprintf(buf, " version=3D'%s'", virDomainTPMVersionTypeToString(def->version)); + if (def->data.emulator.hassecretuuid) { + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, "\n", + virUUIDFormat(def->data.emulator.secretuuid, uuidstr)); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } else { + virBufferAddLit(buf, "/>\n"); + } break; case VIR_DOMAIN_TPM_TYPE_LAST: break; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 822f9af265..8092893c2a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1269,6 +1269,8 @@ struct _virDomainTPMDef { virDomainChrSourceDef source; char *storagepath; char *logfile; + unsigned char secretuuid[VIR_UUID_BUFLEN]; + bool hassecretuuid; } emulator; } data; }; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065064; cv=none; d=zoho.com; s=zohoarc; b=PPlAg/DFGsITW1Gb0u6e8c3CPgBlDbYHR7Qu/lGGAtNGOg8S81OVVXU7i4+uvtWgVQu0jDqPhEam4e0kbfKL+hFlTGVViYn2p4X9UvdXUm41SIctEV0/SZQVSq0cEKJLIy7Njopa3VrLH24dj9GayioXv5/UZtZnyhkKmu/ip6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065064; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=desDgqKIhTAzy7mHUH77cVZ86o4xx/EyqZ5qVncQxMk=; b=b04bkVJnJ9NWjhpukFWk/7I+RjwObAmJhXktmaD75oMTqvvJWpaRewRkaFbo7PxyIz1xUG09BcxXoyIoeMJWTvY9Bw5+rL2Ta6C12laAvZHu278eENmM6pl4ifAVasvHU+IQh3YZAq9+1LtbuE1iqk/4HH2J2R+Xn2pyLJK/0NM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065064361746.3609602606633; Thu, 25 Jul 2019 07:31:04 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 0E81430A7C64; Thu, 25 Jul 2019 14:31: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 B59A960C69; Thu, 25 Jul 2019 14:31: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 5192A18045CF; Thu, 25 Jul 2019 14:31:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6PEUrmb012798 for ; Thu, 25 Jul 2019 10:30:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7785D60619; Thu, 25 Jul 2019 14:30:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6EBAC6092D for ; Thu, 25 Jul 2019 14:30:49 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66A1D30C1337 for ; Thu, 25 Jul 2019 14:30:48 +0000 (UTC) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PEUFt9069124 for ; Thu, 25 Jul 2019 10:30:47 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2tycw9c170-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:47 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:46 +0100 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:43 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUgls34996694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:42 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 81F32BE05A; Thu, 25 Jul 2019 14:30:42 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 26731BE056; Thu, 25 Jul 2019 14:30:42 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:42 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:18 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-8235-0000-0000-00000EBE02DF X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237265; UDB=6.00652184; IPR=6.01018639; MB=3.00027886; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:44 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-8236-0000-0000-0000468AF217 Message-Id: <20190725143033.1176271-5-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 25 Jul 2019 14:30:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 25 Jul 2019 14:30:48 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 04/19] tests: Add test for TPM XML encryption parser and formatter 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 25 Jul 2019 14:31:03 +0000 (UTC) Add a test case for the TPM XML encryption parser and formatter. Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- .../tpm-emulator-tpm2-enc.xml | 32 +++++++++++++++++ .../tpm-emulator-tpm2-enc.xml | 36 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 3 files changed, 69 insertions(+) create mode 100644 tests/qemuxml2argvdata/tpm-emulator-tpm2-enc.xml create mode 100644 tests/qemuxml2xmloutdata/tpm-emulator-tpm2-enc.xml diff --git a/tests/qemuxml2argvdata/tpm-emulator-tpm2-enc.xml b/tests/qemux= ml2argvdata/tpm-emulator-tpm2-enc.xml new file mode 100644 index 0000000000..d889aae4f6 --- /dev/null +++ b/tests/qemuxml2argvdata/tpm-emulator-tpm2-enc.xml @@ -0,0 +1,32 @@ + + TPM-VM + 11d7cd22-da89-3094-6212-079a48a309a1 + 2097152 + 512288 + 1 + + hvm + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + + + + + + + + + diff --git a/tests/qemuxml2xmloutdata/tpm-emulator-tpm2-enc.xml b/tests/qem= uxml2xmloutdata/tpm-emulator-tpm2-enc.xml new file mode 100644 index 0000000000..8902725097 --- /dev/null +++ b/tests/qemuxml2xmloutdata/tpm-emulator-tpm2-enc.xml @@ -0,0 +1,36 @@ + + TPM-VM + 11d7cd22-da89-3094-6212-079a48a309a1 + 2097152 + 512288 + 1 + + hvm + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + + + + + + + + + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index f9e1151906..525eb9a740 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -656,6 +656,7 @@ mymain(void) DO_TEST("tpm-passthrough-crb", NONE); DO_TEST("tpm-emulator", NONE); DO_TEST("tpm-emulator-tpm2", NONE); + DO_TEST("tpm-emulator-tpm2-enc", NONE); =20 DO_TEST("metadata", NONE); DO_TEST("metadata-duplicate", NONE); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065073; cv=none; d=zoho.com; s=zohoarc; b=jBWQWlaqLX0WfNzYMRC0nKAfKCO0wPBiaTbmXz7Vci1o/kGQXUVH1tMk81WE3ntuRBCJbCHkGLCBL106KRdZ9aYfSm8tXw6OcQcBFxYl1rhcdkHje7xJZULGzxukBD9u+wnahQHI2MUiXQmJg7Kxkoeyjg6De0778jLEcSqS2KI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065073; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=e5H8sYbLvrelzujTZqbffrQisy4Hx5nRK5Ht4a0mzCA=; b=L4p59gYOP3/81DzbOnDsxq/cIle9JpImaXhHluUWb1ZCyvIxI5XB+LmX6X4JQUygi2/N41v+PpGV6ZDZ6tUV/a7SI0lL/q0fdQCwNOVIARRM7nwPa0APww1iLoRCIg977jkCSD1yY+P3AIFgh1ypQSjrTsjw//a5xpl9R3hH8O8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065073757727.034492387046; Thu, 25 Jul 2019 07:31:13 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 8CDCF307D974; Thu, 25 Jul 2019 14:31:12 +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 61C7860C69; Thu, 25 Jul 2019 14:31:12 +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 1943EE169; Thu, 25 Jul 2019 14:31:12 +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 x6PEUpL1012746 for ; Thu, 25 Jul 2019 10:30:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1D48610027BE; Thu, 25 Jul 2019 14:30:51 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 17C861001B33 for ; Thu, 25 Jul 2019 14:30:51 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DDA633DE1C for ; Thu, 25 Jul 2019 14:30:49 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PETgMg042684 for ; Thu, 25 Jul 2019 10:30:49 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tydm02891-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:49 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:47 +0100 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:43 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUh8n33227076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:43 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0A065BE054; Thu, 25 Jul 2019 14:30:43 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C4B8BE04F; Thu, 25 Jul 2019 14:30:42 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:42 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:19 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-0036-0000-0000-00000ADE51A9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237266; UDB=6.00652184; IPR=6.01018639; MB=3.00027885; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:45 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-0037-0000-0000-00004CBE14F3 Message-Id: <20190725143033.1176271-6-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 25 Jul 2019 14:30:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 25 Jul 2019 14:30:50 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 05/19] tests: Add tests for QEMU command line generation with encrypted TPM 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 25 Jul 2019 14:31:13 +0000 (UTC) The QEMU command line does not change when TPM state is encrypted compared to when it is plain. Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- .../tpm-emulator-tpm2-enc.x86_64-latest.args | 35 +++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 2 files changed, 36 insertions(+) create mode 100644 tests/qemuxml2argvdata/tpm-emulator-tpm2-enc.x86_64-lat= est.args diff --git a/tests/qemuxml2argvdata/tpm-emulator-tpm2-enc.x86_64-latest.arg= s b/tests/qemuxml2argvdata/tpm-emulator-tpm2-enc.x86_64-latest.args new file mode 100644 index 0000000000..3c8dc8e483 --- /dev/null +++ b/tests/qemuxml2argvdata/tpm-emulator-tpm2-enc.x86_64-latest.args @@ -0,0 +1,35 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-TPM-VM \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-TPM-VM/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-TPM-VM/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-TPM-VM/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DTPM-VM,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-TPM-VM/master-key.aes \ +-machine pc-i440fx-2.12,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 2048 \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 11d7cd22-da89-3094-6212-079a48a309a1 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot menu=3Don,strict=3Don \ +-device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ +-tpmdev emulator,id=3Dtpm-tpm0,chardev=3Dchrtpm \ +-chardev socket,id=3Dchrtpm,path=3D/dev/test \ +-device tpm-tis,tpmdev=3Dtpm-tpm0,id=3Dtpm0 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d6e6272518..c166fd18d6 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2107,6 +2107,7 @@ mymain(void) QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE= _TPM_TIS); DO_TEST_CAPS_LATEST("tpm-emulator"); DO_TEST_CAPS_LATEST("tpm-emulator-tpm2"); + DO_TEST_CAPS_LATEST("tpm-emulator-tpm2-enc"); =20 DO_TEST_PARSE_ERROR("pci-domain-invalid", NONE); DO_TEST_PARSE_ERROR("pci-bus-invalid", NONE); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065058; cv=none; d=zoho.com; s=zohoarc; b=J5cXo+JCskG/87KtuEQX/Zg+9AJv50ku9LJhdjdOHIvgyzz+U7RSvwTFj4cVq8y0w7iy70pR+LvHvNzfqrsnffIU1sSYXxFNL+VRMMMw++Ye/zsJeHBsTb5awq27tD3OnXLvOc6fYJEtwUGgmhWr97i7VXyQxLvbcjswJ5CO12s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065058; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=3DHZsLPNQ73y1jYYdCnClJzXOoAhbgnUPkf/Np1Xqus=; b=duArim2mHdbmcRZqmMvH0o0YkJi/DRCvDKKhvztQ9j+uaYwOGNquapS+CE5aIlsL9OvZoPW4J13Q5ycLte533WMu+wvdO8kvsL4bBAxVpx+DvlcKOPut76CdZkHOO0Vzyk3kw1gvGrewj7GOl+quPsLNedzhWJQKRDrc9LiBwIc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156406505865781.97771555360168; Thu, 25 Jul 2019 07:30:58 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 003A481DF6; Thu, 25 Jul 2019 14:30:57 +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 B6D4C665FA; Thu, 25 Jul 2019 14:30: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 67930E166; Thu, 25 Jul 2019 14:30:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6PEUrxw012773 for ; Thu, 25 Jul 2019 10:30:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id EFC7866A10; Thu, 25 Jul 2019 14:30:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E8DC179401 for ; Thu, 25 Jul 2019 14:30:50 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 45CB130805C4 for ; Thu, 25 Jul 2019 14:30:49 +0000 (UTC) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PEUAVT053261 for ; Thu, 25 Jul 2019 10:30:48 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tydjgt6k8-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:48 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:47 +0100 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:44 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUhOR56623428 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:43 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C036BE059; Thu, 25 Jul 2019 14:30:43 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 25315BE04F; Thu, 25 Jul 2019 14:30:43 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:43 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:20 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-0036-0000-0000-00000ADE51AA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237266; UDB=6.00652184; IPR=6.01018639; MB=3.00027885; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:46 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-0037-0000-0000-00004CBE14F5 Message-Id: <20190725143033.1176271-7-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 25 Jul 2019 14:30:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 25 Jul 2019 14:30:49 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 06/19] tpm: Move qemuTPMEmulatorInit to virTPMEmulatorInit in virtpm.c 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 25 Jul 2019 14:30:57 +0000 (UTC) Move qemuTPMEmulatorInit to virTPMEmulatorInit in virtpm.c and introduce a few functions to query the executables needed for virCommands. Add locking to protect the tool paths and return a copy of the tool paths to callers wanting to access them so that we can run the initialization function multiples time later on and detect when the executable gets update= d. Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau --- src/libvirt_private.syms | 4 ++ src/qemu/qemu_tpm.c | 90 ++++++----------------------- src/util/virtpm.c | 122 +++++++++++++++++++++++++++++++++++++++ src/util/virtpm.h | 5 ++ 4 files changed, 149 insertions(+), 72 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ff5a77b0e2..4cdbb80596 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3177,6 +3177,10 @@ virTimeStringThenRaw; =20 # util/virtpm.h virTPMCreateCancelPath; +virTPMEmulatorInit; +virTPMGetSwtpm; +virTPMGetSwtpmIoctl; +virTPMGetSwtpmSetup; =20 =20 # util/virtypedparam.h diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index cc8c69433b..7282b01bfe 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -41,79 +41,12 @@ #include "configmake.h" #include "dirname.h" #include "qemu_tpm.h" +#include "virtpm.h" =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 VIR_LOG_INIT("qemu.tpm"); =20 -/* - * executables for the swtpm; to be found on the host - */ -static char *swtpm_path; -static char *swtpm_setup; -static char *swtpm_ioctl; - -/* - * qemuTPMEmulatorInit - * - * Initialize the Emulator functions by searching for necessary - * executables that we will use to start and setup the swtpm - */ -static int -qemuTPMEmulatorInit(void) -{ - if (!swtpm_path) { - swtpm_path =3D virFindFileInPath("swtpm"); - if (!swtpm_path) { - virReportSystemError(ENOENT, "%s", - _("Unable to find 'swtpm' binary in $PATH= ")); - return -1; - } - if (!virFileIsExecutable(swtpm_path)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("TPM emulator %s is not an executable"), - swtpm_path); - VIR_FREE(swtpm_path); - return -1; - } - } - - if (!swtpm_setup) { - swtpm_setup =3D virFindFileInPath("swtpm_setup"); - if (!swtpm_setup) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not find 'swtpm_setup' in PATH")); - return -1; - } - if (!virFileIsExecutable(swtpm_setup)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("'%s' is not an executable"), - swtpm_setup); - VIR_FREE(swtpm_setup); - return -1; - } - } - - if (!swtpm_ioctl) { - swtpm_ioctl =3D virFindFileInPath("swtpm_ioctl"); - if (!swtpm_ioctl) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not find swtpm_ioctl in PATH")); - return -1; - } - if (!virFileIsExecutable(swtpm_ioctl)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("swtpm_ioctl program %s is not an executable"= ), - swtpm_ioctl); - VIR_FREE(swtpm_ioctl); - return -1; - } - } - - return 0; -} - - /* * qemuTPMCreateEmulatorStoragePath * @@ -345,12 +278,13 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir, pid_t *pid) { int ret; + VIR_AUTOFREE(char *) swtpm =3D virTPMGetSwtpm(); char *pidfile =3D qemuTPMEmulatorCreatePidFilename(swtpmStateDir, shortName); if (!pidfile) return -ENOMEM; =20 - ret =3D virPidFileReadPathIfAlive(pidfile, pid, swtpm_path); + ret =3D virPidFileReadPathIfAlive(pidfile, pid, swtpm); =20 VIR_FREE(pidfile); =20 @@ -386,7 +320,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm, { int ret =3D -1; =20 - if (qemuTPMEmulatorInit() < 0) + if (virTPMEmulatorInit() < 0) return -1; =20 /* create log dir ... allow 'tss' user to cd into it */ @@ -471,6 +405,10 @@ qemuTPMEmulatorRunSetup(const char *storagepath, int ret =3D -1; char uuid[VIR_UUID_STRING_BUFLEN]; char *vmid =3D NULL; + VIR_AUTOFREE(char *)swtpm_setup =3D virTPMGetSwtpmSetup(); + + if (!swtpm_setup) + return -1; =20 if (!privileged && tpmversion =3D=3D VIR_DOMAIN_TPM_VERSION_1_2) return virFileWriteStr(logfile, @@ -562,6 +500,10 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDefPtr tpm, virCommandPtr cmd =3D NULL; bool created =3D false; char *pidfile; + VIR_AUTOFREE(char *) swtpm =3D virTPMGetSwtpm(); + + if (!swtpm) + return NULL; =20 if (qemuTPMCreateEmulatorStorage(tpm->data.emulator.storagepath, &created, swtpm_user, swtpm_group) < = 0) @@ -575,7 +517,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDefPtr tpm, =20 unlink(tpm->data.emulator.source.data.nix.path); =20 - cmd =3D virCommandNew(swtpm_path); + cmd =3D virCommandNew(swtpm); if (!cmd) goto error; =20 @@ -639,8 +581,12 @@ qemuTPMEmulatorStop(const char *swtpmStateDir, virCommandPtr cmd; char *pathname; char *errbuf =3D NULL; + VIR_AUTOFREE(char *) swtpm_ioctl =3D virTPMGetSwtpmIoctl(); + + if (!swtpm_ioctl) + return; =20 - if (qemuTPMEmulatorInit() < 0) + if (virTPMEmulatorInit() < 0) return; =20 if (!(pathname =3D qemuTPMCreateEmulatorSocket(swtpmStateDir, shortNam= e))) diff --git a/src/util/virtpm.c b/src/util/virtpm.c index 583b9a64a4..d35848d2f2 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -72,3 +72,125 @@ virTPMCreateCancelPath(const char *devpath) cleanup: return path; } + +/* + * executables for the swtpm; to be found on the host + */ +static virMutex swtpm_tools_lock =3D VIR_MUTEX_INITIALIZER; +static char *swtpm_path; +static char *swtpm_setup; +static char *swtpm_ioctl; + +char * +virTPMGetSwtpm(void) +{ + char *s; + + if (!swtpm_path && virTPMEmulatorInit() < 0) + return NULL; + + virMutexLock(&swtpm_tools_lock); + ignore_value(VIR_STRDUP(s, swtpm_path)); + virMutexUnlock(&swtpm_tools_lock); + + return s; +} + +char * +virTPMGetSwtpmSetup(void) +{ + char *s; + + if (!swtpm_setup && virTPMEmulatorInit() < 0) + return NULL; + + virMutexLock(&swtpm_tools_lock); + ignore_value(VIR_STRDUP(s, swtpm_setup)); + virMutexUnlock(&swtpm_tools_lock); + + return s; +} + +char * +virTPMGetSwtpmIoctl(void) +{ + char *s; + + if (!swtpm_ioctl && virTPMEmulatorInit() < 0) + return NULL; + + virMutexLock(&swtpm_tools_lock); + ignore_value(VIR_STRDUP(s, swtpm_ioctl)); + virMutexUnlock(&swtpm_tools_lock); + + return s; +} + +/* + * virTPMEmulatorInit + * + * Initialize the Emulator functions by searching for necessary + * executables that we will use to start and setup the swtpm + */ +int +virTPMEmulatorInit(void) +{ + int ret =3D -1; + + virMutexLock(&swtpm_tools_lock); + + if (!swtpm_path) { + swtpm_path =3D virFindFileInPath("swtpm"); + if (!swtpm_path) { + virReportSystemError(ENOENT, "%s", + _("Unable to find 'swtpm' binary in $PATH= ")); + goto cleanup; + } + if (!virFileIsExecutable(swtpm_path)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("TPM emulator %s is not an executable"), + swtpm_path); + VIR_FREE(swtpm_path); + goto cleanup; + } + } + + if (!swtpm_setup) { + swtpm_setup =3D virFindFileInPath("swtpm_setup"); + if (!swtpm_setup) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not find 'swtpm_setup' in PATH")); + goto cleanup; + } + if (!virFileIsExecutable(swtpm_setup)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("'%s' is not an executable"), + swtpm_setup); + VIR_FREE(swtpm_setup); + goto cleanup; + } + } + + if (!swtpm_ioctl) { + swtpm_ioctl =3D virFindFileInPath("swtpm_ioctl"); + if (!swtpm_ioctl) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not find swtpm_ioctl in PATH")); + goto cleanup; + } + if (!virFileIsExecutable(swtpm_ioctl)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("swtpm_ioctl program %s is not an executable"= ), + swtpm_ioctl); + VIR_FREE(swtpm_ioctl); + goto cleanup; + } + } + + ret =3D 0; + + cleanup: + virMutexUnlock(&swtpm_tools_lock); + + return ret; +} diff --git a/src/util/virtpm.h b/src/util/virtpm.h index 4408bdb217..2311f04ae5 100644 --- a/src/util/virtpm.h +++ b/src/util/virtpm.h @@ -21,3 +21,8 @@ #pragma once =20 char *virTPMCreateCancelPath(const char *devpath) ATTRIBUTE_NOINLINE; + +char *virTPMGetSwtpm(void); +char *virTPMGetSwtpmSetup(void); +char *virTPMGetSwtpmIoctl(void); +int virTPMEmulatorInit(void); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065064; cv=none; d=zoho.com; s=zohoarc; b=GpK5x0nECBFWIPjYVc5C+E0OAkp3fpvJVsckpIwl6UGNvrDxtlMQvsqYBbJJ9am9ZG0R/vdUNn8Nf5StxZ6aQ2ArtePsrqagyRmgt6BjvIFE79RNN3dpWq2KJS7FSjBQrqD0DscQ9PoFMWH/I5C4SYblbeosfZfLyKbtGxMAzbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065064; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=FOX2RZZ6Vq9knM14K8xJskedluhmKDS+PtTOVjQSB00=; b=D6VAiHtviGsc488oguGDfaziboAZQXFbgfxoh81PsNrYT9Z3+CFDmTtOFnDEFBY/1kMDnKhwOitVmEDDOwCbNB1Nzj28d2ZCaPcsfnQLJETCTrBEpkAdViY400g7WMlbYL0KaYXMA5XAm9IZrbKd7gShtmimaUH5r2QwriAzTqQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065064204557.4789479177462; Thu, 25 Jul 2019 07:31:04 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 0EFA34E92A; Thu, 25 Jul 2019 14:31: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 CBE9C63627; Thu, 25 Jul 2019 14:31: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 5045A180020A; Thu, 25 Jul 2019 14:31:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6PEUpQx012745 for ; Thu, 25 Jul 2019 10:30:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1CB4360A35; Thu, 25 Jul 2019 14:30:51 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 154AC608A5 for ; Thu, 25 Jul 2019 14:30:48 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0CEB630A7C76 for ; Thu, 25 Jul 2019 14:30:48 +0000 (UTC) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PEU2u7023783 for ; Thu, 25 Jul 2019 10:30:47 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tyc60x6my-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:47 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:46 +0100 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:45 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUi4h15401346 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:44 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F043BE051; Thu, 25 Jul 2019 14:30:44 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A6A0ABE056; Thu, 25 Jul 2019 14:30:43 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:43 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:21 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-0012-0000-0000-000017564E23 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237265; UDB=6.00652184; IPR=6.01018639; MB=3.00027885; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:46 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-0013-0000-0000-000058366595 Message-Id: <20190725143033.1176271-8-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=855 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 25 Jul 2019 14:30:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 25 Jul 2019 14:30:48 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 07/19] tpm: Refactor virTPMEmulatorInit to use loop 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 25 Jul 2019 14:31:03 +0000 (UTC) Refactor virTPMEmulatorInit to use a loop with parameters. This allows for easier extension later on. Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau --- src/util/virtpm.c | 82 +++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 45 deletions(-) diff --git a/src/util/virtpm.c b/src/util/virtpm.c index d35848d2f2..6df225f4e4 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -136,54 +136,46 @@ int virTPMEmulatorInit(void) { int ret =3D -1; - - virMutexLock(&swtpm_tools_lock); - - if (!swtpm_path) { - swtpm_path =3D virFindFileInPath("swtpm"); - if (!swtpm_path) { - virReportSystemError(ENOENT, "%s", - _("Unable to find 'swtpm' binary in $PATH= ")); - goto cleanup; - } - if (!virFileIsExecutable(swtpm_path)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("TPM emulator %s is not an executable"), - swtpm_path); - VIR_FREE(swtpm_path); - goto cleanup; + static const struct { + const char *name; + char **path; + } prgs[] =3D { + { + .name =3D "swtpm", + .path =3D &swtpm_path, + }, + { + .name =3D "swtpm_setup", + .path =3D &swtpm_setup, + }, + { + .name =3D "swtpm_ioctl", + .path =3D &swtpm_ioctl, } - } + }; + size_t i; =20 - if (!swtpm_setup) { - swtpm_setup =3D virFindFileInPath("swtpm_setup"); - if (!swtpm_setup) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not find 'swtpm_setup' in PATH")); - goto cleanup; - } - if (!virFileIsExecutable(swtpm_setup)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("'%s' is not an executable"), - swtpm_setup); - VIR_FREE(swtpm_setup); - goto cleanup; - } - } + virMutexLock(&swtpm_tools_lock); =20 - if (!swtpm_ioctl) { - swtpm_ioctl =3D virFindFileInPath("swtpm_ioctl"); - if (!swtpm_ioctl) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not find swtpm_ioctl in PATH")); - goto cleanup; - } - if (!virFileIsExecutable(swtpm_ioctl)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("swtpm_ioctl program %s is not an executable"= ), - swtpm_ioctl); - VIR_FREE(swtpm_ioctl); - goto cleanup; + for (i =3D 0; i < ARRAY_CARDINALITY(prgs); i++) { + VIR_AUTOFREE(char *) path =3D NULL; + bool findit =3D *prgs[i].path =3D=3D NULL; + + if (findit) { + path =3D virFindFileInPath(prgs[i].name); + if (!path) { + virReportSystemError(ENOENT, + _("Unable to find '%s' binary in $PATH"), + prgs[i].name); + goto cleanup; + } + if (!virFileIsExecutable(path)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%s is not an executable"), + path); + goto cleanup; + } + *prgs[i].path =3D path; } } =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065067; cv=none; d=zoho.com; s=zohoarc; b=SNCAVAgtwJeYpHDmT19+AG2xWDDo2TnxB0s8DxAzkpmV+9WalaEJz5dHxXu1lr6xq8Xu1jUHj4BSQH2GM6dFyD7ZCWHPNE/e54BVL2dOLxwTdrEn7V5gRd9DEjxuq/MVRCUZpPy801VyZuClhTxa7T7O/nP61QQRURiOlqvNlYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065067; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=TuVN9uZCB8MFC8UpuCztkIVeIiPwlkt9BOVz2BF+KPg=; b=iJVUnAfwriwUKnvMf4Kz218oz3H45ovjggdHaB5aHhpNOhKVgOqNen/FG9TAMf42JaqLPO63GuCAGxgeCI0XSrZrikriy1uLFdXYNnd1uwWkL4wIRN1Fj6T9Ke1rZpGJqQBEgWiRj+uNKfeDyxosVRrNTSZ7GWZfyZr9SO3y0xY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065067384748.5508275568034; Thu, 25 Jul 2019 07:31:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 45A3081DE0; Thu, 25 Jul 2019 14:31: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 1BA4610027BE; Thu, 25 Jul 2019 14:31: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 C938FE161; Thu, 25 Jul 2019 14:31:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6PEUo7V012739 for ; Thu, 25 Jul 2019 10:30:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 261D35DE6F; Thu, 25 Jul 2019 14:30:50 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1FAF85DE88 for ; Thu, 25 Jul 2019 14:30:50 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8286BA3B60 for ; Thu, 25 Jul 2019 14:30:49 +0000 (UTC) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PEULq3122140 for ; Thu, 25 Jul 2019 10:30:49 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tyc3nppfv-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:48 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:47 +0100 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:45 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUiSG57540904 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:44 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7ADEABE04F; Thu, 25 Jul 2019 14:30:44 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 29889BE054; Thu, 25 Jul 2019 14:30:44 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:44 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:22 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-0036-0000-0000-00000ADE51AB X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237266; UDB=6.00652184; IPR=6.01018639; MB=3.00027885; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:46 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-0037-0000-0000-00004CBE14F9 Message-Id: <20190725143033.1176271-9-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=884 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 25 Jul 2019 14:30:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 25 Jul 2019 14:30:49 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 08/19] tpm: Check whether previously found executables were updated 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 25 Jul 2019 14:31:06 +0000 (UTC) Check whether previously found executables were updated and if so look for them again. This helps to use updated features of swtpm and its tools upon updating them. Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau --- src/qemu/qemu_tpm.c | 1 + src/util/virtpm.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 7282b01bfe..9f1e7e20ba 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -20,6 +20,7 @@ =20 #include =20 +#include #include #include #include diff --git a/src/util/virtpm.c b/src/util/virtpm.c index 6df225f4e4..bef6cff3dd 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -78,8 +78,13 @@ virTPMCreateCancelPath(const char *devpath) */ static virMutex swtpm_tools_lock =3D VIR_MUTEX_INITIALIZER; static char *swtpm_path; +static struct stat swtpm_stat; + static char *swtpm_setup; +static struct stat swtpm_setup_stat; + static char *swtpm_ioctl; +static struct stat swtpm_ioctl_stat; =20 char * virTPMGetSwtpm(void) @@ -139,18 +144,22 @@ virTPMEmulatorInit(void) static const struct { const char *name; char **path; + struct stat *stat; } prgs[] =3D { { .name =3D "swtpm", .path =3D &swtpm_path, + .stat =3D &swtpm_stat, }, { .name =3D "swtpm_setup", .path =3D &swtpm_setup, + .stat =3D &swtpm_setup_stat, }, { .name =3D "swtpm_ioctl", .path =3D &swtpm_ioctl, + .stat =3D &swtpm_ioctl_stat, } }; size_t i; @@ -160,8 +169,27 @@ virTPMEmulatorInit(void) for (i =3D 0; i < ARRAY_CARDINALITY(prgs); i++) { VIR_AUTOFREE(char *) path =3D NULL; bool findit =3D *prgs[i].path =3D=3D NULL; + struct stat statbuf; + char *tmp; + + if (!findit) { + /* has executables changed? */ + if (stat(*prgs[i].path, &statbuf) < 0) + findit =3D true; + + if (!findit && + memcmp(&statbuf.st_mtim, + &prgs[i].stat->st_mtime, + sizeof(statbuf.st_mtim))) { + findit =3D true; + } + } =20 if (findit) { + tmp =3D *prgs[i].path; + VIR_FREE(tmp); + *prgs[i].path =3D NULL; + path =3D virFindFileInPath(prgs[i].name); if (!path) { virReportSystemError(ENOENT, @@ -175,7 +203,13 @@ virTPMEmulatorInit(void) path); goto cleanup; } + if (stat(path, prgs[i].stat) < 0) { + virReportSystemError(errno, + _("Could not stat %s"), path); + goto cleanup; + } *prgs[i].path =3D path; + path =3D NULL; } } =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065081; cv=none; d=zoho.com; s=zohoarc; b=Ks4oX/xU338YgCWfeNfsvF6BcnOEnpiZTuVr0Kut715YRsZVfZSTxcK/E3gLdGUxzyxmaVB6Jl+YYWYKZy22nbRGTa+fV1jzoLEymVc/6fT9cevF4hH06Ga+otdRwk0m4YSKT4QTSD/DIgcS76tk5DJUIzbWCOPoDoMyS5f0KXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065081; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=HcmL3Kt26nJYwwtqyWs5l4iIug1OaLAKI5iuX6i9K4U=; b=X4JgNAhhCWsvRiAZ0uM9W9037SNkA6lKatHIqYxTUQ4zVxjHsydRPqQxLkP3p8RiKakvhFqR6kMZmGE5xJXgMrwtJpXOThNZfedNW+8zOsfFkkqiiCdvFU5EkB4cK+LuUG270OtrP2+xtk9NYIuibhkZHIGmWkeP1ez8iFw9Yac= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065081276950.5828142815357; Thu, 25 Jul 2019 07:31:21 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 1728430C62AC; Thu, 25 Jul 2019 14:31: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 DEE7E60852; Thu, 25 Jul 2019 14:31: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 9D869E169; Thu, 25 Jul 2019 14:31:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6PEUquK012768 for ; Thu, 25 Jul 2019 10:30:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 990D75DD92; Thu, 25 Jul 2019 14:30:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 936085DDA3 for ; Thu, 25 Jul 2019 14:30:52 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CAD8C307D868 for ; Thu, 25 Jul 2019 14:30:50 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PETiMM138484 for ; Thu, 25 Jul 2019 10:30:50 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2tyckj5985-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:49 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:48 +0100 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:46 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUjRf23724496 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:45 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 12930BE04F; Thu, 25 Jul 2019 14:30:45 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9FDBABE054; Thu, 25 Jul 2019 14:30:44 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:44 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:23 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-0012-0000-0000-000017564E24 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237265; UDB=6.00652184; IPR=6.01018639; MB=3.00027885; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:47 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-0013-0000-0000-000058366599 Message-Id: <20190725143033.1176271-10-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 25 Jul 2019 14:30:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 25 Jul 2019 14:30:51 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 09/19] tpm: Parse the capabilities supported by swtpm and swtpm_setup 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 25 Jul 2019 14:31:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Run 'swtpm socket --print-capabilities' and 'swtpm_setup --print-capabilities' to get the JSON object of the features the programs are supporting and parse them into a bitmap. Signed-off-by: Stefan Berger --- include/libvirt/virterror.h | 2 + src/libvirt_private.syms | 2 + src/util/virerror.c | 2 + src/util/virtpm.c | 136 +++++++++++++++++++++++++++++++++++- src/util/virtpm.h | 15 ++++ 5 files changed, 155 insertions(+), 2 deletions(-) diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 102a2573bf..6f4110185a 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -134,6 +134,8 @@ typedef enum { VIR_FROM_FIREWALLD =3D 68, /* Error from firewalld */ VIR_FROM_DOMAIN_CHECKPOINT =3D 69, /* Error from domain checkpoint */ =20 + VIR_FROM_TPM =3D 70, /* Error from TPM */ + # ifdef VIR_ENUM_SENTINELS VIR_ERR_DOMAIN_LAST # endif diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4cdbb80596..cf80ea3e44 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3181,6 +3181,8 @@ virTPMEmulatorInit; virTPMGetSwtpm; virTPMGetSwtpmIoctl; virTPMGetSwtpmSetup; +virTPMSwtpmFeatureTypeFromString; +virTPMSwtpmSetupFeatureTypeFromString; =20 =20 # util/virtypedparam.h diff --git a/src/util/virerror.c b/src/util/virerror.c index dfba8c5712..77f76a9abf 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -142,6 +142,8 @@ VIR_ENUM_IMPL(virErrorDomain, "Resource control", "FirewallD", "Domain Checkpoint", + + "TPM", /* 70 */ ); =20 =20 diff --git a/src/util/virtpm.c b/src/util/virtpm.c index bef6cff3dd..99abbf3f8b 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -27,8 +27,24 @@ #include "viralloc.h" #include "virfile.h" #include "virtpm.h" +#include "vircommand.h" +#include "virbitmap.h" +#include "virjson.h" +#include "virlog.h" =20 -#define VIR_FROM_THIS VIR_FROM_NONE +#define VIR_FROM_THIS VIR_FROM_TPM + +VIR_LOG_INIT("util.tpm"); + +VIR_ENUM_IMPL(virTPMSwtpmFeature, + VIR_TPM_SWTPM_FEATURE_LAST, + "cmdarg-pwd-fd", +); + +VIR_ENUM_IMPL(virTPMSwtpmSetupFeature, + VIR_TPM_SWTPM_SETUP_FEATURE_LAST, + "cmdarg-pwdfile-fd", +); =20 /** * virTPMCreateCancelPath: @@ -74,18 +90,23 @@ virTPMCreateCancelPath(const char *devpath) } =20 /* - * executables for the swtpm; to be found on the host + * executables for the swtpm; to be found on the host along with + * capabilties bitmap */ static virMutex swtpm_tools_lock =3D VIR_MUTEX_INITIALIZER; static char *swtpm_path; static struct stat swtpm_stat; +static virBitmapPtr swtpm_caps; =20 static char *swtpm_setup; static struct stat swtpm_setup_stat; +static virBitmapPtr swtpm_setup_caps; =20 static char *swtpm_ioctl; static struct stat swtpm_ioctl_stat; =20 +typedef int (*TypeFromStringFn)(const char *); + char * virTPMGetSwtpm(void) { @@ -131,6 +152,101 @@ virTPMGetSwtpmIoctl(void) return s; } =20 +/* virTPMExecGetCaps + * + * Execute the prepared command and parse the returned JSON object + * to get the capabilities supported by the executable. + * A JSON object like this is expected: + * + * { + * "type": "swtpm", + * "features": [ + * "cmdarg-seccomp", + * "cmdarg-key-fd", + * "cmdarg-pwd-fd" + * ] + * } + */ +static virBitmapPtr +virTPMExecGetCaps(virCommandPtr cmd, + TypeFromStringFn typeFromStringFn) +{ + int exitstatus; + virBitmapPtr bitmap; + VIR_AUTOFREE(char *) outbuf =3D NULL; + VIR_AUTOPTR(virJSONValue) json =3D NULL; + virJSONValuePtr featureList; + virJSONValuePtr item; + size_t idx; + const char *str; + int typ; + + virCommandSetOutputBuffer(cmd, &outbuf); + if (virCommandRun(cmd, &exitstatus) < 0) + return NULL; + + if (!(bitmap =3D virBitmapNewEmpty())) + return NULL; + + /* older version does not support --print-capabilties -- that's fine */ + if (exitstatus !=3D 0) { + VIR_DEBUG("Found swtpm that doesn't support --print-capabilities"); + return bitmap; + } + + json =3D virJSONValueFromString(outbuf); + if (!json) + goto error_bad_json; + + featureList =3D virJSONValueObjectGetArray(json, "features"); + if (!featureList) + goto error_bad_json; + + if (!virJSONValueIsArray(featureList)) + goto error_bad_json; + + for (idx =3D 0; idx < virJSONValueArraySize(featureList); idx++) { + item =3D virJSONValueArrayGet(featureList, idx); + if (!item) + continue; + + str =3D virJSONValueGetString(item); + if (!str) + goto error_bad_json; + typ =3D typeFromStringFn(str); + if (typ < 0) + continue; + + if (virBitmapSetBitExpand(bitmap, typ) < 0) + goto cleanup; + } + + cleanup: + return bitmap; + + error_bad_json: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected JSON format: %s"), outbuf); + goto cleanup; +} + +static virBitmapPtr +virTPMGetCaps(TypeFromStringFn typeFromStringFn, + const char *exec, const char *param1) +{ + VIR_AUTOPTR(virCommand) cmd =3D NULL; + + if (!(cmd =3D virCommandNew(exec))) + return NULL; + + if (param1) + virCommandAddArg(cmd, param1); + virCommandAddArg(cmd, "--print-capabilities"); + virCommandClearCaps(cmd); + + return virTPMExecGetCaps(cmd, typeFromStringFn); +} + /* * virTPMEmulatorInit * @@ -145,16 +261,24 @@ virTPMEmulatorInit(void) const char *name; char **path; struct stat *stat; + const char *parm; + virBitmapPtr *caps; + TypeFromStringFn typeFromStringFn; } prgs[] =3D { { .name =3D "swtpm", .path =3D &swtpm_path, .stat =3D &swtpm_stat, + .parm =3D "socket", + .caps =3D &swtpm_caps, + .typeFromStringFn =3D virTPMSwtpmFeatureTypeFromString, }, { .name =3D "swtpm_setup", .path =3D &swtpm_setup, .stat =3D &swtpm_setup_stat, + .caps =3D &swtpm_setup_caps, + .typeFromStringFn =3D virTPMSwtpmSetupFeatureTypeFromString, }, { .name =3D "swtpm_ioctl", @@ -209,6 +333,14 @@ virTPMEmulatorInit(void) goto cleanup; } *prgs[i].path =3D path; + + if (prgs[i].caps) { + *prgs[i].caps =3D virTPMGetCaps(prgs[i].typeFromStringFn, + path, prgs[i].parm); + path =3D NULL; + if (!*prgs[i].caps) + goto cleanup; + } path =3D NULL; } } diff --git a/src/util/virtpm.h b/src/util/virtpm.h index 2311f04ae5..157b43ff17 100644 --- a/src/util/virtpm.h +++ b/src/util/virtpm.h @@ -26,3 +26,18 @@ char *virTPMGetSwtpm(void); char *virTPMGetSwtpmSetup(void); char *virTPMGetSwtpmIoctl(void); int virTPMEmulatorInit(void); + +typedef enum { + VIR_TPM_SWTPM_FEATURE_CMDARG_PWD_FD, + + VIR_TPM_SWTPM_FEATURE_LAST +} virTPMSwtpmFeature; + +typedef enum { + VIR_TPM_SWTPM_SETUP_FEATURE_CMDARG_PWDFILE_FD, + + VIR_TPM_SWTPM_SETUP_FEATURE_LAST +} virTPMSwtpmSetupFeature; + +VIR_ENUM_DECL(virTPMSwtpmFeature); +VIR_ENUM_DECL(virTPMSwtpmSetupFeature); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065077; cv=none; d=zoho.com; s=zohoarc; b=nWiu2DZB7VdOGvZ1H76IdxAVg164nETVpbsgHfk++sNOLhGbXL8nyvP5KRUtW+NVE09eAQXctPRbS1ckeEBY1tdSxcQvlWOu0iGGXGSKv+5ctk7/a+x+h1QD/W5WaoRfvIYHVunbw3PjBryP4sc+R4I/CwkwIVDsfuvSEqkEsSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065077; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=6H8YPeH/RQm0t8pzZZ4R3yFhNV8vWmVF0gAxAGSyuQc=; b=mS4r/bwKpCST6bfRLbpV8c4YHEnVQkn7v33DJv7VSlxk8d5CHbrHSvQsJuObJZiR8RIjVKOIl/SXFV8kMLoOrFxQjUMPKtlZwKjfOoGC143new+UOMwflgVAmmSJSh6LRgBlcCh9ZofFtKX5swWkKz5St+TCcUxiNC22MiwJvWM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065077292497.001692240574; Thu, 25 Jul 2019 07:31:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2AD28307D850; Thu, 25 Jul 2019 14:31:16 +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 03A8D10018F9; Thu, 25 Jul 2019 14:31: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 B904E18045DD; Thu, 25 Jul 2019 14:31:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6PEUqqM012763 for ; Thu, 25 Jul 2019 10:30:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 73DD4608A5; Thu, 25 Jul 2019 14:30:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C9246092D for ; Thu, 25 Jul 2019 14:30:52 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E3AA30C34D3 for ; Thu, 25 Jul 2019 14:30:51 +0000 (UTC) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PEThdx135484 for ; Thu, 25 Jul 2019 10:30:51 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0b-001b2d01.pphosted.com with ESMTP id 2tye288krc-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:50 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:50 +0100 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:46 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUj2G58655110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:45 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89B4FBE056; Thu, 25 Jul 2019 14:30:45 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2D183BE051; Thu, 25 Jul 2019 14:30:45 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:45 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:24 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-0036-0000-0000-00000ADE51B2 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237266; UDB=6.00652184; IPR=6.01018639; MB=3.00027885; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-0037-0000-0000-00004CBE14FE Message-Id: <20190725143033.1176271-11-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 25 Jul 2019 14:30:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 25 Jul 2019 14:30:51 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 10/19] utils: Implement function to pass a buffer to send via a fd to virCommand 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 25 Jul 2019 14:31:16 +0000 (UTC) Implement virCommandSetSendBuffer() that allows the caller to pass a file descriptor and buffer to virCommand. virCommand will write the buffer into the file descriptor. That file descriptor could be the write end of a pipe or one of the file descriptors of a socketpair. The other file descriptor should be passed to the launched process to read the data from. Only implement the function to allocate memory for send buffers and to free them later on. Signed-off-by: Stefan Berger Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libvirt_private.syms | 1 + src/util/vircommand.c | 76 ++++++++++++++++++++++++++++++++++++++++ src/util/vircommand.h | 5 +++ 3 files changed, 82 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index cf80ea3e44..e6249caa80 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1725,6 +1725,7 @@ virCommandSetOutputFD; virCommandSetPidFile; virCommandSetPreExecHook; virCommandSetSELinuxLabel; +virCommandSetSendBuffer; virCommandSetUID; virCommandSetUmask; virCommandSetWorkingDirectory; diff --git a/src/util/vircommand.c b/src/util/vircommand.c index e10ca3eb7c..5dee730826 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -76,6 +76,16 @@ struct _virCommandFD { unsigned int flags; }; =20 +typedef struct _virCommandSendBuffer virCommandSendBuffer; +typedef virCommandSendBuffer *virCommandSendBufferPtr; + +struct _virCommandSendBuffer { + int fd; + unsigned char *buffer; + size_t buflen; + off_t offset; +}; + struct _virCommand { int has_error; /* ENOMEM on allocation failure, -1 for anything else. = */ =20 @@ -135,6 +145,9 @@ struct _virCommand { char *appArmorProfile; #endif int mask; + + virCommandSendBufferPtr sendBuffers; + size_t numSendBuffers; }; =20 /* See virCommandSetDryRun for description for this variable */ @@ -1728,6 +1741,67 @@ virCommandSetWorkingDirectory(virCommandPtr cmd, con= st char *pwd) } =20 =20 +static int +virCommandGetNumSendBuffers(virCommandPtr cmd) +{ + return cmd->numSendBuffers; +} + + +static void +virCommandFreeSendBuffers(virCommandPtr cmd) +{ + size_t i; + + for (i =3D 0; i < virCommandGetNumSendBuffers(cmd); i++) { + VIR_FORCE_CLOSE(cmd->sendBuffers[i].fd); + VIR_FREE(cmd->sendBuffers[i].buffer); + } + VIR_FREE(cmd->sendBuffers); +} + + +/** + * virCommandSetSendBuffer + * @cmd: the command to modify + * + * Pass a buffer to virCommand that will be written into the + * given file descriptor. The buffer will be freed automatically + * and the file descriptor closed. + */ +int +virCommandSetSendBuffer(virCommandPtr cmd, + int fd, + unsigned char *buffer, size_t buflen) +{ + size_t i =3D virCommandGetNumSendBuffers(cmd); + + if (!cmd || cmd->has_error) + return -1; + + if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { + virReportSystemError(errno, "%s", + _("fcntl failed to set O_NONBLOCK")); + cmd->has_error =3D errno; + return -1; + } + + if (VIR_REALLOC_N(cmd->sendBuffers, i + 1) < 0) { + cmd->has_error =3D ENOMEM; + return -1; + } + + cmd->sendBuffers[i].fd =3D fd; + cmd->sendBuffers[i].buffer =3D buffer; + cmd->sendBuffers[i].buflen =3D buflen; + cmd->sendBuffers[i].offset =3D 0; + + cmd->numSendBuffers++; + + return 0; +} + + /** * virCommandSetInputBuffer: * @cmd: the command to modify @@ -2867,6 +2941,8 @@ virCommandFree(virCommandPtr cmd) VIR_FREE(cmd->appArmorProfile); #endif =20 + virCommandFreeSendBuffers(cmd); + VIR_FREE(cmd); } =20 diff --git a/src/util/vircommand.h b/src/util/vircommand.h index 2a9ee5cdc7..c2abc7b2c3 100644 --- a/src/util/vircommand.h +++ b/src/util/vircommand.h @@ -146,6 +146,11 @@ void virCommandAddArgList(virCommandPtr cmd, void virCommandSetWorkingDirectory(virCommandPtr cmd, const char *pwd) ATTRIBUTE_NONNULL(2); =20 +int virCommandSetSendBuffer(virCommandPtr cmd, + int fd, + unsigned char *buffer, size_t buflen) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); + void virCommandSetInputBuffer(virCommandPtr cmd, const char *inbuf) ATTRIBUTE_NONNULL(2); =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065084; cv=none; d=zoho.com; s=zohoarc; b=IWOZKo2bDQ7KqRhAnpHoWnEKS07fL9HVOBsBGXmy8iTgV6JuSTpwyftFrG+2a6G4pp0dWlU5GxoEEpTbcEdgLagzXaxEXHOnikrA7in2PmlBq8JY5NK8BYM/ES+X6Gtpf/ccyLEzBauigQcH50AjuSaxyREUlCqPqMBaWSj8Qkk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065084; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=lLbxtexfPOKUSic+Pfou+4qdj9fOl56Pphp44YLqAFY=; b=ZjSn3B42+ihBBklzy/c/QNW1HtjzRdmN7yxoNb9K3cU+gq6MzxGHpL+5cEXgqYFTAFw8L4FoAj/xvcQ3gy17zD2E6FUYh+MuzdYab3YU+YdfDna8+Ka2UN14Cd3BrEfSdBpa9/VBSV/Rahns10rFdsZW7utlVYVue8M0kme+/2E= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065084496155.36370432501235; Thu, 25 Jul 2019 07:31:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57C11C05E760; Thu, 25 Jul 2019 14:31:23 +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 356821001281; Thu, 25 Jul 2019 14:31:23 +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 E6439E16F; Thu, 25 Jul 2019 14:31:22 +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 x6PEUr0e012778 for ; Thu, 25 Jul 2019 10:30:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 19DF6665FF; Thu, 25 Jul 2019 14:30:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F0EA665FC for ; Thu, 25 Jul 2019 14:30:50 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39B0C335EC for ; Thu, 25 Jul 2019 14:30:50 +0000 (UTC) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PEUNwW122269 for ; Thu, 25 Jul 2019 10:30:49 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tyc3nppgy-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:49 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:49 +0100 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:47 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUkZa53346566 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:46 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 09C87BE04F; Thu, 25 Jul 2019 14:30:46 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A4488BE058; Thu, 25 Jul 2019 14:30:45 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:45 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:25 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-0016-0000-0000-000009D44E5A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237265; UDB=6.00652184; IPR=6.01018639; MB=3.00027885; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-0017-0000-0000-0000442940E3 Message-Id: <20190725143033.1176271-12-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=764 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 25 Jul 2019 14:30:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 25 Jul 2019 14:30:50 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 11/19] utils: Convert pollfd array to be allocated 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 25 Jul 2019 14:31:23 +0000 (UTC) Convert the struct pollfd *fds to be allocated rather than residing on the stack. This prepares it for the next patch where the size of the array of fds becomes dynamic. Signed-off-by: Stefan Berger Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/vircommand.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 5dee730826..8bbaced721 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -2124,6 +2124,7 @@ virCommandProcessIO(virCommandPtr cmd) size_t inlen =3D 0, outlen =3D 0, errlen =3D 0; size_t inoff =3D 0; int ret =3D 0; + VIR_AUTOFREE(struct pollfd *) fds =3D NULL; =20 if (dryRunBuffer || dryRunCallback) { VIR_DEBUG("Dry run requested, skipping I/O processing"); @@ -2155,9 +2156,11 @@ virCommandProcessIO(virCommandPtr cmd) goto cleanup; ret =3D -1; =20 + if (VIR_ALLOC_N(fds, 3) < 0) + goto cleanup; + for (;;) { size_t i; - struct pollfd fds[3]; int nfds =3D 0; =20 if (cmd->inpipe !=3D -1) { --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065067; cv=none; d=zoho.com; s=zohoarc; b=kwpaFWFUnSbCjLLAozvinriBM8pLc/C24dMESub9ymQFraV1ifDVHQ7Cks0vmDxCWy486t0hg2ivXq4jqqbJ2VVBHozBDgYNeJrIuj0MsKGeS77Fkdb7ZbdHIiJ+kX3OmgAWd7NJZO4cPHRmkkmBV+5kc1x3GJtHFPu3Ntk+efE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065067; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=skHhGAvacQA/o/jaSh0ttWxDwZWUNQ+R8SVXyrlatro=; b=HlOZ+8OG7ShtUpG+iKE0+ymAZxq38mzsJu/a0ibIyz+zAGZw80KyrcTug69C5XgCp5B726HvN/Ps82vee+zDttYcYLGhOr7rE6G/V3hKdvpZBQ/khsDAVWJCsln24Buu/hsKd0vKE0HRttZ6ikrB/TQy2icBtiB9zfZhIe1kyuE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156406506775824.444157956984327; Thu, 25 Jul 2019 07:31:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A3C283083339; Thu, 25 Jul 2019 14:31: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 781C35DD92; Thu, 25 Jul 2019 14:31: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 36E2EE167; Thu, 25 Jul 2019 14:31:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6PEUt8f012821 for ; Thu, 25 Jul 2019 10:30:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id AB70060C69; Thu, 25 Jul 2019 14:30:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A393460C6C for ; Thu, 25 Jul 2019 14:30:53 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 109F681F13 for ; Thu, 25 Jul 2019 14:30:53 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PETiMP138484 for ; Thu, 25 Jul 2019 10:30:52 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 2tyckj59as-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:51 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:50 +0100 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:47 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUkZT56951088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:46 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7DE27BE04F; Thu, 25 Jul 2019 14:30:46 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 241EABE059; Thu, 25 Jul 2019 14:30:46 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:46 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:26 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-0004-0000-0000-0000152E913B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237265; UDB=6.00652184; IPR=6.01018639; MB=3.00027885; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:49 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-0005-0000-0000-00008C9B2875 Message-Id: <20190725143033.1176271-13-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=900 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 25 Jul 2019 14:30:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 25 Jul 2019 14:30:53 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 12/19] utils: Mark inpipe as non-blocking 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 25 Jul 2019 14:31:07 +0000 (UTC) Mark a virCommand's inpipe (write-end of pipe) as non-blocking so that it will never block when we were to try to write too many bytes to it while it doesn't have the capacity to hold them. Signed-off-by: Stefan Berger Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/vircommand.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 8bbaced721..d63990b53a 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -2520,6 +2520,13 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid) } cmd->infd =3D infd[0]; cmd->inpipe =3D infd[1]; + if (fcntl(cmd->inpipe, F_SETFL, O_NONBLOCK) < 0) { + virReportSystemError(errno, "%s", + _("fcntl failed to set O_NONBLOCK")); + cmd->has_error =3D -1; + ret =3D -1; + goto cleanup; + } } else if ((cmd->inbuf && cmd->infd =3D=3D -1) || (cmd->outbuf && cmd->outfdptr !=3D &cmd->outfd) || (cmd->errbuf && cmd->errfdptr !=3D &cmd->errfd)) { --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065100; cv=none; d=zoho.com; s=zohoarc; b=UXsitl19RSho2/mSMyoi1v06CVvPedFJDljXQz9vAKGDw6BbTIvclKZQ+xYDFp/Oy6Hjn+C90may+rEywX33R/tlPpi5XoB6X9Q1i15jVvXNRnZx0Mh0nwXDMhBZU16ttvjSVB5NGyM97u1w435iLT/laEQEpZtXN3apUqneMx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065100; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=yYRKGc6bLG0uQu9p03DT/PVyaItwwJQ/bxTlyy4NavQ=; b=iMQuN+vU+3eHfM6jeC0XP7rDcoPSQgbB1Fn4njPlfsPKHv411nED25eVIFXnt/qiGi1YN5fAT998dO1K3fKP8ClMVyInWfCTpa/y091l1KomJzxaekp3OOUIdBrcvycGYPidUPm9kvdXobzd+kqweI+C2JP2zhW9KiAqSvN2BSw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065100507575.1466153640852; Thu, 25 Jul 2019 07:31:40 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 9CD8A300C72E; Thu, 25 Jul 2019 14:31: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 669FA7A012; Thu, 25 Jul 2019 14:31: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 21170E177; Thu, 25 Jul 2019 14:31:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6PEUtwR012820 for ; Thu, 25 Jul 2019 10:30:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id A9A1960C68; Thu, 25 Jul 2019 14:30:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E93860C6B for ; Thu, 25 Jul 2019 14:30:52 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0B7630C34D5 for ; Thu, 25 Jul 2019 14:30:51 +0000 (UTC) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PETha8135485 for ; Thu, 25 Jul 2019 10:30:51 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2tye288krq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:51 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:50 +0100 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:48 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUl1I53018914 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:47 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F2C80BE058; Thu, 25 Jul 2019 14:30:46 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 98402BE051; Thu, 25 Jul 2019 14:30:46 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:46 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:27 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-8235-0000-0000-00000EBE02EA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237265; UDB=6.00652184; IPR=6.01018639; MB=3.00027886; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:49 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-8236-0000-0000-0000468AF22E Message-Id: <20190725143033.1176271-14-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=983 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 25 Jul 2019 14:30:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 25 Jul 2019 14:30:52 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 13/19] utils: Extend virCommandProcessIO to include the send buffers 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 25 Jul 2019 14:31:39 +0000 (UTC) Extend virCommandProcessIO to include the send buffers in the poll loop. Signed-off-by: Stefan Berger Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/vircommand.c | 62 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index d63990b53a..a66e0ba4a2 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1802,6 +1802,61 @@ virCommandSetSendBuffer(virCommandPtr cmd, } =20 =20 +static int +virCommandSendBuffersFillPollfd(virCommandPtr cmd, + struct pollfd *fds, + int startidx) +{ + size_t i, j; + + for (i =3D 0, j =3D 0; i < virCommandGetNumSendBuffers(cmd); i++) { + if (cmd->sendBuffers[i].fd >=3D 0) { + fds[startidx + j].fd =3D cmd->sendBuffers[i].fd; + fds[startidx + j].events =3D POLLOUT; + fds[startidx + j].revents =3D 0; + j++; + } + } + + return j; +} + + +static int +virCommandSendBuffersHandlePoll(virCommandPtr cmd, + struct pollfd *fds) +{ + size_t i; + ssize_t done; + + for (i =3D 0; i < virCommandGetNumSendBuffers(cmd); i++) { + if (fds->fd =3D=3D cmd->sendBuffers[i].fd) + break; + } + if (i =3D=3D virCommandGetNumSendBuffers(cmd)) + return 0; + + done =3D write(fds->fd, + cmd->sendBuffers[i].buffer + cmd->sendBuffers[i].offset, + cmd->sendBuffers[i].buflen - cmd->sendBuffers[i].offset); + if (done < 0) { + if (errno =3D=3D EPIPE) { + VIR_DEBUG("child closed PIPE early, ignoring EPIPE " + "on fd %d", cmd->sendBuffers[i].fd); + VIR_FORCE_CLOSE(cmd->sendBuffers[i].fd); + } else if (errno !=3D EINTR && errno !=3D EAGAIN) { + virReportSystemError(errno, "%s", + _("unable to write to child input")); + return -1; + } + } else { + cmd->sendBuffers[i].offset +=3D done; + if (cmd->sendBuffers[i].offset =3D=3D cmd->sendBuffers[i].buflen) + VIR_FORCE_CLOSE(cmd->sendBuffers[i].fd); + } + return 0; +} + /** * virCommandSetInputBuffer: * @cmd: the command to modify @@ -2156,7 +2211,7 @@ virCommandProcessIO(virCommandPtr cmd) goto cleanup; ret =3D -1; =20 - if (VIR_ALLOC_N(fds, 3) < 0) + if (VIR_ALLOC_N(fds, 3 + virCommandGetNumSendBuffers(cmd)) < 0) goto cleanup; =20 for (;;) { @@ -2182,6 +2237,8 @@ virCommandProcessIO(virCommandPtr cmd) nfds++; } =20 + nfds +=3D virCommandSendBuffersFillPollfd(cmd, fds, nfds); + if (nfds =3D=3D 0) break; =20 @@ -2254,6 +2311,9 @@ virCommandProcessIO(virCommandPtr cmd) if (inoff =3D=3D inlen) VIR_FORCE_CLOSE(cmd->inpipe); } + } else if (fds[i].revents & (POLLOUT | POLLHUP | POLLERR)) { + if (virCommandSendBuffersHandlePoll(cmd, &fds[i]) < 0) + goto cleanup; } } } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065073; cv=none; d=zoho.com; s=zohoarc; b=Z9xKEyN2AUizQOCMHrmLf1K8XRGi/SJrgT7F3jTlk87oxwqyCGTC9p1xeO/Cb9CZVrmVQxXFsht8GiWpbbdRPm93LleFHuU3nQaiTrGBoePcixSo0hS0JrW21OSPuyulV/zetKAKtAf5y2T8cKh6xn2kaGPaA5af8ad/bX8Speo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065073; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=CqgYon06c3+rDVnr1SGx+03v1W1KI/+Am0nj6GHtQH8=; b=BvaRsoKEx1naujKZg7o4z/ulwzKg8f5ywuDZZb/Aa9Yoxpp53FwFcO13A48Xn7i6ISqtl0EVaEabyqkuc2WySS1dpt9iK1dA094iQX2r1HCeK7Wf0u4AfuH9hJ23npI3JxmMbvcTexv79/6fjEzYc8nhZlt34XHymBeCvy637jk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065073811867.9603905047336; Thu, 25 Jul 2019 07:31:13 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 84F4C2CD7E6; Thu, 25 Jul 2019 14:31:12 +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 5D47D62667; Thu, 25 Jul 2019 14:31:12 +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 1D96A1800208; Thu, 25 Jul 2019 14:31:12 +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 x6PEUtDE012830 for ; Thu, 25 Jul 2019 10:30:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id D87E0665FC; Thu, 25 Jul 2019 14:30:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D289B665FA for ; Thu, 25 Jul 2019 14:30:54 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 60120335E7 for ; Thu, 25 Jul 2019 14:30:53 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PETiMQ138484 for ; Thu, 25 Jul 2019 10:30:52 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 2tyckj59aw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:51 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:50 +0100 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:48 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUlFc54460682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:47 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F74DBE051; Thu, 25 Jul 2019 14:30:47 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 19482BE054; Thu, 25 Jul 2019 14:30:47 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:47 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:28 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-0004-0000-0000-0000152E913D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237265; UDB=6.00652184; IPR=6.01018639; MB=3.00027885; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:50 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-0005-0000-0000-00008C9B287A Message-Id: <20190725143033.1176271-15-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 25 Jul 2019 14:30:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 25 Jul 2019 14:30:53 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 14/19] tests: Extend command test to transfer large data to process on multiple fds 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 25 Jul 2019 14:31:13 +0000 (UTC) Add a test case to commandtest.c to test the transfer of data to a process who received the read-end of pipes' file descriptors. Transfer large (128 kb) byte streams. Extend the commandhelper.c with support for --readfd command line parameter and convert the data receive loop to use poll and receive data on multiple file descriptors (up to 3) and read data into distinct buffers that we grow while adding more (string) data. Signed-off-by: Stefan Berger Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/commandhelper.c | 70 +++++++++++++++++++++++--- tests/commandtest.c | 113 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 6 deletions(-) diff --git a/tests/commandhelper.c b/tests/commandhelper.c index 32ebeeaef2..1312f3ee52 100644 --- a/tests/commandhelper.c +++ b/tests/commandhelper.c @@ -23,6 +23,7 @@ #include #include #include +#include =20 #include "internal.h" #define NO_LIBVIRT @@ -62,13 +63,27 @@ int main(int argc, char **argv) { char *cwd; FILE *log =3D fopen(abs_builddir "/commandhelper.log", "w"); int ret =3D EXIT_FAILURE; + int readfds[3] =3D { STDIN_FILENO, }; + int numreadfds =3D 1; + struct pollfd fds[3]; + int numpollfds =3D 0; + char *buffers[3] =3D {NULL, NULL, NULL}; + size_t buflen[3] =3D {0, 0, 0}; + char c; =20 if (!log) return ret; =20 - for (i =3D 1; i < argc; i++) + for (i =3D 1; i < argc; i++) { fprintf(log, "ARG:%s\n", argv[i]); =20 + if (STREQ(argv[i - 1], "--readfd") && + sscanf(argv[i], "%u%c", &readfds[numreadfds++], &c) !=3D 1) { + printf("Could not parse fd %s\n", argv[i]); + goto cleanup; + } + } + origenv =3D environ; n =3D 0; while (*origenv !=3D NULL) { @@ -134,15 +149,56 @@ int main(int argc, char **argv) { fprintf(stderr, "BEGIN STDERR\n"); fflush(stderr); =20 + for (i =3D 0; i < numreadfds; i++) { + fds[numpollfds].fd =3D readfds[i]; + fds[numpollfds].events =3D POLLIN; + fds[numpollfds].revents =3D 0; + numpollfds++; + } + for (;;) { - got =3D read(STDIN_FILENO, buf, sizeof(buf)); - if (got < 0) + unsigned ctr =3D 0; + + if (poll(fds, numpollfds, -1) < 0) { + printf("poll failed: %s\n", strerror(errno)); goto cleanup; - if (got =3D=3D 0) + } + + for (i =3D 0; i < numpollfds; i++) { + if (fds[i].revents & (POLLIN | POLLHUP | POLLERR)) { + fds[i].revents =3D 0; + + got =3D read(fds[i].fd, buf, sizeof(buf)); + if (got < 0) + goto cleanup; + if (got =3D=3D 0) { + /* do not want to hear from this fd anymore */ + fds[i].events =3D 0; + } else { + buffers[i] =3D realloc(buffers[i], buflen[i] + got); + if (!buf[i]) { + fprintf(stdout, "Out of memory!\n"); + goto cleanup; + } + memcpy(buffers[i] + buflen[i], buf, got); + buflen[i] +=3D got; + } + } + } + for (i =3D 0; i < numpollfds; i++) { + if (fds[i].events) { + ctr++; + break; + } + } + if (ctr =3D=3D 0) break; - if (write(STDOUT_FILENO, buf, got) !=3D got) + } + + for (i =3D 0; i < numpollfds; i++) { + if (write(STDOUT_FILENO, buffers[i], buflen[i]) !=3D buflen[i]) goto cleanup; - if (write(STDERR_FILENO, buf, got) !=3D got) + if (write(STDERR_FILENO, buffers[i], buflen[i]) !=3D buflen[i]) goto cleanup; } =20 @@ -154,6 +210,8 @@ int main(int argc, char **argv) { ret =3D EXIT_SUCCESS; =20 cleanup: + for (i =3D 0; i < ARRAY_CARDINALITY(buffers); i++) + free(buffers[i]); fclose(log); free(newenv); return ret; diff --git a/tests/commandtest.c b/tests/commandtest.c index ce0832fb0c..991c0572b0 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -1139,6 +1139,118 @@ static int test26(const void *unused ATTRIBUTE_UNUS= ED) return ret; } =20 +static int test27(const void *unused ATTRIBUTE_UNUSED) +{ + virCommandPtr cmd =3D virCommandNew(abs_builddir "/commandhelper"); + int pipe1[2]; + int pipe2[2]; + int ret =3D -1; + size_t buflen =3D 1024 * 128; + char *buffer0 =3D NULL; + char *buffer1 =3D NULL; + char *buffer2 =3D NULL; + char *outactual =3D NULL; + char *erractual =3D NULL; + char *outexpect =3D NULL; +# define TEST27_OUTEXPECT_TEMP "BEGIN STDOUT\n" \ + "%s%s%s" \ + "END STDOUT\n" + char *errexpect =3D NULL; +# define TEST27_ERREXPECT_TEMP "BEGIN STDERR\n" \ + "%s%s%s" \ + "END STDERR\n" + + if (VIR_ALLOC_N(buffer0, buflen) < 0 || + VIR_ALLOC_N(buffer1, buflen) < 0 || + VIR_ALLOC_N(buffer2, buflen) < 0) + goto cleanup; + + memset(buffer0, 'H', buflen - 2); + buffer0[buflen - 2] =3D '\n'; + buffer0[buflen - 1] =3D 0; + + memset(buffer1, '1', buflen - 2); + buffer1[buflen - 2] =3D '\n'; + buffer1[buflen - 1] =3D 0; + + memset(buffer2, '2', buflen - 2); + buffer2[buflen - 2] =3D '\n'; + buffer2[buflen - 1] =3D 0; + + if (virAsprintf(&outexpect, TEST27_OUTEXPECT_TEMP, + buffer0, buffer1, buffer2) < 0 || + virAsprintf(&errexpect, TEST27_ERREXPECT_TEMP, + buffer0, buffer1, buffer2) < 0) { + printf("Could not virAsprintf expected output\n"); + goto cleanup; + } + + if (pipe(pipe1) < 0 || pipe(pipe2) < 0) { + printf("Could not create pipe: %s\n", strerror(errno)); + goto cleanup; + } + + if (virCommandSetSendBuffer(cmd, pipe1[1], + (unsigned char *)buffer1, buflen - 1) < 0 || + virCommandSetSendBuffer(cmd, pipe2[1], + (unsigned char *)buffer2, buflen - 1) < 0) { + printf("Could not set send buffers\n"); + goto cleanup; + } + pipe1[1] =3D 0; + pipe2[1] =3D 0; + buffer1 =3D NULL; + buffer2 =3D NULL; + + virCommandAddArg(cmd, "--readfd"); + virCommandAddArgFormat(cmd, "%d", pipe1[0]); + virCommandPassFD(cmd, pipe1[0], 0); + + virCommandAddArg(cmd, "--readfd"); + virCommandAddArgFormat(cmd, "%d", pipe2[0]); + virCommandPassFD(cmd, pipe2[0], 0); + + virCommandSetInputBuffer(cmd, buffer0); + virCommandSetOutputBuffer(cmd, &outactual); + virCommandSetErrorBuffer(cmd, &erractual); + + if (virCommandRun(cmd, NULL) < 0) { + printf("Cannot run child %s\n", virGetLastErrorMessage()); + goto cleanup; + } + + virCommandFree(cmd); + + if (!outactual || !erractual) + goto cleanup; + + if (STRNEQ(outactual, outexpect)) { + virTestDifference(stderr, outexpect, outactual); + goto cleanup; + } + if (STRNEQ(erractual, errexpect)) { + virTestDifference(stderr, errexpect, erractual); + goto cleanup; + } + + ret =3D 0; + + cleanup: + VIR_FORCE_CLOSE(pipe1[0]); + VIR_FORCE_CLOSE(pipe2[0]); + VIR_FORCE_CLOSE(pipe1[1]); + VIR_FORCE_CLOSE(pipe2[1]); + VIR_FREE(buffer0); + VIR_FREE(buffer1); + VIR_FREE(buffer2); + VIR_FREE(outactual); + VIR_FREE(erractual); + VIR_FREE(outexpect); + VIR_FREE(errexpect); + + return ret; +} + static void virCommandThreadWorker(void *opaque) { virCommandTestDataPtr test =3D opaque; @@ -1292,6 +1404,7 @@ mymain(void) DO_TEST(test23); DO_TEST(test25); DO_TEST(test26); + DO_TEST(test27); =20 virMutexLock(&test->lock); if (test->running) { --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065087; cv=none; d=zoho.com; s=zohoarc; b=ldeoPoiQlMXde3/FrTjJNesABfaZqUfndOvMu3dPlWw0cl52HZ50pwjt6XoN9rHBPTr23Ls7LxBifmGWA/JhxOm4WZxqZPcT2PbDpXmslBeTIZOkFlYoLeF+Zjdb6Uutj0eXM4PTPPjrR4tdEljPXBWaTTmuHrIQf+O1uPDJQDM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065087; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=Wcl6AsBHXKgp40i/wYL03Tbk4xHBh/n3I/+JqnnmFD4=; b=ZGnVdVVSM2nrFJZF9b4L70eMLLV04xt2STR6Y9FmjJWsgotO2ZNOzFnug7+4SWjQvbuekRb3XHRWD6PiRdXuiB/4AKMOM7jO/wBWOBOTDsM9WbY9hGsvqwj0ISUSmUcXX2m2ul7j6QUYcb3Adjv+e+caGRqZ4f6fHCbuyZvksvY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065087847561.8574659440826; Thu, 25 Jul 2019 07:31:27 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id A314430805C4; Thu, 25 Jul 2019 14:31:26 +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 777725FCB9; Thu, 25 Jul 2019 14:31:26 +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 3B05EE172; Thu, 25 Jul 2019 14:31:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6PEUrmq012789 for ; Thu, 25 Jul 2019 10:30:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6639519D71; Thu, 25 Jul 2019 14:30:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 36B8719C7F; Thu, 25 Jul 2019 14:30:52 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E1A6B81F19; Thu, 25 Jul 2019 14:30:50 +0000 (UTC) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PEU25n136288; Thu, 25 Jul 2019 10:30:50 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0b-001b2d01.pphosted.com with ESMTP id 2tydmrj49r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jul 2019 10:30:49 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x6PEUn9b020732; Thu, 25 Jul 2019 14:30:49 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma02wdc.us.ibm.com with ESMTP id 2tx61mg521-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jul 2019 14:30:49 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUm0X33423712 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:48 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 109D4BE053; Thu, 25 Jul 2019 14:30:48 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9A76ABE04F; Thu, 25 Jul 2019 14:30:47 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:47 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:29 -0400 Message-Id: <20190725143033.1176271-16-stefanb@linux.vnet.ibm.com> In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 25 Jul 2019 14:30:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 25 Jul 2019 14:30:51 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 15/19] tpm: Use fd to pass password to swtpm_setup and swtpm 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 25 Jul 2019 14:31:27 +0000 (UTC) Allow vTPM state encryption when swtpm_setup and swtpm support passing a passphrase using a file descriptor. This patch enables the encryption of the vTPM state only. It does not encrypt the state during migration, so the destination secret does not need to have the same password at this point. Signed-off-by: Stefan Berger Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libvirt_private.syms | 2 + src/qemu/qemu_tpm.c | 110 ++++++++++++++++++++++++++++++++++++++- src/util/virtpm.c | 16 ++++++ src/util/virtpm.h | 3 ++ 4 files changed, 129 insertions(+), 2 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e6249caa80..a8d65e4318 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3182,7 +3182,9 @@ virTPMEmulatorInit; virTPMGetSwtpm; virTPMGetSwtpmIoctl; virTPMGetSwtpmSetup; +virTPMSwtpmCapsGet; virTPMSwtpmFeatureTypeFromString; +virTPMSwtpmSetupCapsGet; virTPMSwtpmSetupFeatureTypeFromString; =20 =20 diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 9f1e7e20ba..27a31efe50 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -43,6 +43,7 @@ #include "dirname.h" #include "qemu_tpm.h" #include "virtpm.h" +#include "secret_util.h" =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 @@ -373,6 +374,66 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm, return ret; } =20 +/* + * qemuTPMSetupEncryption + * + * @secretuuid: The UUID with the secret holding passphrase + * @cmd: the virCommand to transfer the secret to + * + * Returns file descriptor representing the read-end of a pipe. + * The passphrase can be read from this pipe. Returns < 0 in case + * of error. + * + * This function reads the passphrase and writes it into the + * write-end of a pipe so that the read-end of the pipe can be + * passed to the emulator for reading the passphrase from. + */ +static int +qemuTPMSetupEncryption(const unsigned char *secretuuid, + virCommandPtr cmd) +{ + int ret =3D -1; + int pipefd[2] =3D { -1, -1 }; + virConnectPtr conn; + VIR_AUTOFREE(uint8_t *) secret =3D NULL; + size_t secret_len; + virSecretLookupTypeDef seclookupdef =3D { + .type =3D VIR_SECRET_LOOKUP_TYPE_UUID, + }; + + conn =3D virGetConnectSecret(); + if (!conn) + return -1; + + memcpy(seclookupdef.u.uuid, secretuuid, sizeof(seclookupdef.u.uuid)); + if (virSecretGetSecretString(conn, &seclookupdef, + VIR_SECRET_USAGE_TYPE_VTPM, + &secret, &secret_len) < 0) + goto error; + + if (pipe(pipefd) =3D=3D -1) { + virReportSystemError(errno, "%s", + _("Unable to create pipe")); + goto error; + } + + if (virCommandSetSendBuffer(cmd, pipefd[1], secret, secret_len) < 0) + goto error; + + secret =3D NULL; + ret =3D pipefd[0]; + + cleanup: + virObjectUnref(conn); + + return ret; + + error: + VIR_FORCE_CLOSE(pipefd[1]); + VIR_FORCE_CLOSE(pipefd[0]); + + goto cleanup; +} =20 /* * qemuTPMEmulatorRunSetup @@ -387,6 +448,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm, * @logfile: The file to write the log into; it must be writable * for the user given by userid or 'tss' * @tpmversion: The version of the TPM, either a TPM 1.2 or TPM 2 + * @encryption: pointer to virStorageEncryption holding secret * * Setup the external swtpm by creating endorsement key and * certificates for it. @@ -399,7 +461,8 @@ qemuTPMEmulatorRunSetup(const char *storagepath, uid_t swtpm_user, gid_t swtpm_group, const char *logfile, - const virDomainTPMVersion tpmversion) + const virDomainTPMVersion tpmversion, + const unsigned char *secretuuid) { virCommandPtr cmd =3D NULL; int exitstatus; @@ -407,6 +470,7 @@ qemuTPMEmulatorRunSetup(const char *storagepath, char uuid[VIR_UUID_STRING_BUFLEN]; char *vmid =3D NULL; VIR_AUTOFREE(char *)swtpm_setup =3D virTPMGetSwtpmSetup(); + VIR_AUTOCLOSE pwdfile_fd =3D -1; =20 if (!swtpm_setup) return -1; @@ -439,6 +503,23 @@ qemuTPMEmulatorRunSetup(const char *storagepath, break; } =20 + if (secretuuid) { + if (!virTPMSwtpmSetupCapsGet( + VIR_TPM_SWTPM_SETUP_FEATURE_CMDARG_PWDFILE_FD)) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, + _("%s does not support passing a passphrase using a file " + "descriptor"), virTPMGetSwtpmSetup()); + goto cleanup; + } + if ((pwdfile_fd =3D qemuTPMSetupEncryption(secretuuid, cmd)) < 0) + goto cleanup; + + virCommandAddArg(cmd, "--pwdfile-fd"); + virCommandAddArgFormat(cmd, "%d", pwdfile_fd); + virCommandAddArgList(cmd, "--cipher", "aes-256-cbc", NULL); + virCommandPassFD(cmd, pwdfile_fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT= ); + pwdfile_fd =3D -1; + } =20 virCommandAddArgList(cmd, "--tpm-state", storagepath, @@ -502,6 +583,8 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDefPtr tpm, bool created =3D false; char *pidfile; VIR_AUTOFREE(char *) swtpm =3D virTPMGetSwtpm(); + VIR_AUTOCLOSE pwdfile_fd =3D -1; + const unsigned char *secretuuid =3D NULL; =20 if (!swtpm) return NULL; @@ -510,10 +593,14 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDefPtr tpm, &created, swtpm_user, swtpm_group) < = 0) return NULL; =20 + if (tpm->data.emulator.hassecretuuid) + secretuuid =3D tpm->data.emulator.secretuuid; + if (created && qemuTPMEmulatorRunSetup(tpm->data.emulator.storagepath, vmname, vm= uuid, privileged, swtpm_user, swtpm_group, - tpm->data.emulator.logfile, tpm->version) = < 0) + tpm->data.emulator.logfile, tpm->version, + secretuuid) < 0) goto error; =20 unlink(tpm->data.emulator.source.data.nix.path); @@ -556,6 +643,25 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDefPtr tpm, virCommandAddArgFormat(cmd, "file=3D%s", pidfile); VIR_FREE(pidfile); =20 + if (tpm->data.emulator.hassecretuuid) { + if (!virTPMSwtpmCapsGet(VIR_TPM_SWTPM_FEATURE_CMDARG_PWD_FD)) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, + _("%s does not support passing passphrase via file descr= iptor"), + virTPMGetSwtpm()); + goto error; + } + + pwdfile_fd =3D qemuTPMSetupEncryption(tpm->data.emulator.secretuui= d, cmd); + if (pwdfile_fd) + goto error; + + virCommandAddArg(cmd, "--key"); + virCommandAddArgFormat(cmd, "pwdfd=3D%d,mode=3Daes-256-cbc", + pwdfile_fd); + virCommandPassFD(cmd, pwdfile_fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT= ); + pwdfile_fd =3D -1; + } + return cmd; =20 error: diff --git a/src/util/virtpm.c b/src/util/virtpm.c index 99abbf3f8b..52094d911e 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -352,3 +352,19 @@ virTPMEmulatorInit(void) =20 return ret; } + +bool +virTPMSwtpmCapsGet(unsigned int cap) +{ + if (virTPMEmulatorInit() < 0) + return false; + return virBitmapIsBitSet(swtpm_caps, cap); +} + +bool +virTPMSwtpmSetupCapsGet(unsigned int cap) +{ + if (virTPMEmulatorInit() < 0) + return false; + return virBitmapIsBitSet(swtpm_setup_caps, cap); +} diff --git a/src/util/virtpm.h b/src/util/virtpm.h index 157b43ff17..50948aac9a 100644 --- a/src/util/virtpm.h +++ b/src/util/virtpm.h @@ -27,6 +27,9 @@ char *virTPMGetSwtpmSetup(void); char *virTPMGetSwtpmIoctl(void); int virTPMEmulatorInit(void); =20 +bool virTPMSwtpmCapsGet(unsigned int cap); +bool virTPMSwtpmSetupCapsGet(unsigned int cap); + typedef enum { VIR_TPM_SWTPM_FEATURE_CMDARG_PWD_FD, =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065103; cv=none; d=zoho.com; s=zohoarc; b=CC3vt5DMXCdxyiM6OrY0zUSqeK5l9SIqjRq/31EvNqDQE7cAtG569ufAlm0ZoFeS52Dhz/szE3LxKsAoSlcHiarwScdZAMjD1iDaquRQTukdOX4S7hmKWN1Kv/fEoXERuey3c5jSLbZq/Z59KEeOHzEEAszKUxkJVVV1rfrGHWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065103; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=RwREbSqDVMzNtEp9o/H+1vMptsTKoS4bXWyLrjbEtk4=; b=jBmUdjsVWOJhiy4S2OzBSV3kIuLN83050xQAo+67mX/c+1b/pwsaf6ajdaHP1Ys8e5sYzipJe0d9EPf6c+ycMOOJzKArRwLzZkcfT0H20P9i0YMhG3OgXtP4TeAy0Wq5DH71rh1vHijjIuWg1nxy3uhwPkhR+k4BQsWVaHjoAyY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065103084753.3204568474029; Thu, 25 Jul 2019 07:31:43 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id E172A30A7C60; Thu, 25 Jul 2019 14:31:41 +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 B83087A007; Thu, 25 Jul 2019 14:31:41 +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 7C8B8180BACE; Thu, 25 Jul 2019 14:31:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6PEVGwr012952 for ; Thu, 25 Jul 2019 10:31:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7142A5C6DF; Thu, 25 Jul 2019 14:31:16 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 69E395C6E7 for ; Thu, 25 Jul 2019 14:31:11 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E03C63DBC5 for ; Thu, 25 Jul 2019 14:31:10 +0000 (UTC) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PEUvwh120004 for ; Thu, 25 Jul 2019 10:31:10 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tychh5dhm-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:31:04 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:52 +0100 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:49 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUmrW31457712 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:48 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 85CDABE04F; Thu, 25 Jul 2019 14:30:48 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B181BE054; Thu, 25 Jul 2019 14:30:48 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:48 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:30 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-8235-0000-0000-00000EBE02EB X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237265; UDB=6.00652184; IPR=6.01018639; MB=3.00027886; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:50 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-8236-0000-0000-0000468AF234 Message-Id: <20190725143033.1176271-17-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=828 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 25 Jul 2019 14:31:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 25 Jul 2019 14:31:11 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 16/19] tpm: Pass migration key passphrase via fd to swtpm 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 25 Jul 2019 14:31:42 +0000 (UTC) This patch now passes the passphrase as a migration key to swtpm. This now encrypts the state of the TPM while a VM is migrated between hosts or when suspended into a file. Since the migration key secret is the same as the state encryption secret, this now requires that the migration destination host has the same secret value. Signed-off-by: Stefan Berger Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_tpm.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 27a31efe50..7efd635831 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -584,6 +584,7 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDefPtr tpm, char *pidfile; VIR_AUTOFREE(char *) swtpm =3D virTPMGetSwtpm(); VIR_AUTOCLOSE pwdfile_fd =3D -1; + VIR_AUTOCLOSE migpwdfile_fd =3D -1; const unsigned char *secretuuid =3D NULL; =20 if (!swtpm) @@ -653,6 +654,9 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDefPtr tpm, =20 pwdfile_fd =3D qemuTPMSetupEncryption(tpm->data.emulator.secretuui= d, cmd); if (pwdfile_fd) + migpwdfile_fd =3D qemuTPMSetupEncryption(tpm->data.emulator.secret= uuid, + cmd); + if (pwdfile_fd < 0 || migpwdfile_fd < 0) goto error; =20 virCommandAddArg(cmd, "--key"); @@ -660,6 +664,12 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDefPtr tpm, pwdfile_fd); virCommandPassFD(cmd, pwdfile_fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT= ); pwdfile_fd =3D -1; + + virCommandAddArg(cmd, "--migration-key"); + virCommandAddArgFormat(cmd, "pwdfd=3D%d,mode=3Daes-256-cbc", + migpwdfile_fd); + virCommandPassFD(cmd, migpwdfile_fd, VIR_COMMAND_PASS_FD_CLOSE_PAR= ENT); + migpwdfile_fd =3D -1; } =20 return cmd; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065094; cv=none; d=zoho.com; s=zohoarc; b=bQ3NssCWNNZptgwkBHeK6HvjEzUU4sW/HQZCBxckPR/WmO09OCR6yCMqWFi7TcPNS4RuoRLhQj0i65YfnO8gS3m8QCqu9MBb1ZUWDlwWm0aCMzGMABb1ZQgd6sPkDOGD9nw6ws9zCQNsc6uOHXnQ005L9qYQU8O20kUKE2LvO+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065094; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=/3I9cIHu6+wm8RyCZfzVr3LFqRF3dAh4RhePH3LfJAc=; b=WmMq+rGn7+ib0H+fn67+8pv55ZIVmpX9UQMdRrnyC5Lr7fkgSDqZI58rj1lKXUfOGjA97OXtitVbH0MsK/meW1z0P3J4hDTaNql3uTeQMMK2xjaTxN/r4XOqBLG+s7UaFe0RmwMAVlRLqlj30358vlDg1T2v47FYvgb0WpRnlLc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065094841101.63664549638554; Thu, 25 Jul 2019 07:31:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 94FDE30C34DE; Thu, 25 Jul 2019 14:31:33 +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 6A1811019616; Thu, 25 Jul 2019 14:31:33 +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 2C94618045E4; Thu, 25 Jul 2019 14:31: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 x6PEUtvq012815 for ; Thu, 25 Jul 2019 10:30:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 74B3C1001281; Thu, 25 Jul 2019 14:30:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6DE0F1001B32 for ; Thu, 25 Jul 2019 14:30:55 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3991F81DE9 for ; Thu, 25 Jul 2019 14:30:54 +0000 (UTC) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PEUNjb122274 for ; Thu, 25 Jul 2019 10:30:53 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tyc3nppna-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Jul 2019 10:30:53 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jul 2019 15:30:52 +0100 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Jul 2019 15:30:50 +0100 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUnmE60883324 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:49 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 098C3BE053; Thu, 25 Jul 2019 14:30:49 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A0535BE051; Thu, 25 Jul 2019 14:30:48 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:48 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:31 -0400 In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19072514-0004-0000-0000-0000152E913F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011491; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237265; UDB=6.00652184; IPR=6.01018639; MB=3.00027885; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-25 14:30:51 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072514-0005-0000-0000-00008C9B2881 Message-Id: <20190725143033.1176271-18-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 25 Jul 2019 14:30:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 25 Jul 2019 14:30:54 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 17/19] tpm: Check TPM XML device configuration changes after edit 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 25 Jul 2019 14:31:34 +0000 (UTC) Since swtpm does not support getting started without password once it was created with encryption enabled, we don't allow encryption to be removed. Similarly, we do not allow encryption to be added once swtpm has run. We also prevent chaning the type of the TPM backend since the encrypted state is still around and the next time one was to switch back to the emulator backend and forgot the encryption the TPM would not work. Signed-off-by: Stefan Berger Reviewed-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 56 +++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 4 +++ src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 28 ++++++++++++++++++++ src/qemu/qemu_extdevice.c | 2 +- src/qemu/qemu_extdevice.h | 3 +++ 6 files changed, 93 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6673a323c6..d60ef81061 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31430,3 +31430,59 @@ virDomainGraphicsNeedsAutoRenderNode(const virDoma= inGraphicsDef *graphics) =20 return true; } + + +static int +virDomainCheckTPMChanges(virDomainDefPtr def, + virDomainDefPtr newDef) +{ + bool oldEnc, newEnc; + + if (!def->tpm) + return 0; + + switch (def->tpm->type) { + case VIR_DOMAIN_TPM_TYPE_EMULATOR: + if (virFileExists(def->tpm->data.emulator.storagepath)) { + /* VM has been started */ + /* Once a VM was started with an encrypted state we allow + * less configuration changes. + */ + oldEnc =3D def->tpm->data.emulator.hassecretuuid; + if (oldEnc && def->tpm->type !=3D newDef->tpm->type) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Changing the type of TPM is not allowed"= )); + return -1; + } + if (oldEnc && !newDef->tpm) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Removing an encrypted TPM is not allowed= ")); + return -1; + } + newEnc =3D newDef->tpm->data.emulator.hassecretuuid; + if (oldEnc !=3D newEnc) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("TPM state encryption cannot be changed " + "once VM was started")); + return -1; + } + } + break; + case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: + case VIR_DOMAIN_TPM_TYPE_LAST: + break; + } + + return 0; +} + + +int +virDomainCheckDeviceChanges(virDomainDefPtr def, + virDomainDefPtr newDef) +{ + if (!def || !newDef) + return 0; + + return virDomainCheckTPMChanges(def, newDef); +} diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8092893c2a..285fa6c496 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3636,3 +3636,7 @@ virDomainGraphicsGetRenderNode(const virDomainGraphic= sDef *graphics); =20 bool virDomainGraphicsNeedsAutoRenderNode(const virDomainGraphicsDef *graphics); + +int +virDomainCheckDeviceChanges(virDomainDefPtr def, virDomainDefPtr newDef) + ATTRIBUTE_NONNULL(2); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a8d65e4318..e1526031a5 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -205,6 +205,7 @@ virDomainBootTypeFromString; virDomainBootTypeToString; virDomainCapabilitiesPolicyTypeToString; virDomainCapsFeatureTypeToString; +virDomainCheckDeviceChanges; virDomainChrConsoleTargetTypeFromString; virDomainChrConsoleTargetTypeToString; virDomainChrDefForeach; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e7720fbd99..9110d15cca 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -52,6 +52,7 @@ #include "qemu_migration_params.h" #include "qemu_blockjob.h" #include "qemu_security.h" +#include "qemu_extdevice.h" =20 #include "virerror.h" #include "virlog.h" @@ -7600,6 +7601,30 @@ qemuDomainCreate(virDomainPtr dom) return qemuDomainCreateWithFlags(dom, 0); } =20 +static int +qemuDomainCheckDeviceChanges(virQEMUDriverPtr driver, + virDomainDefPtr def) +{ + virDomainObjPtr vm; + int ret; + + vm =3D virDomainObjListFindByUUID(driver->domains, def->uuid); + if (!vm) + return 0; + + if (qemuExtDevicesInitPaths(driver, vm->def) < 0) { + ret =3D -1; + goto cleanup; + } + + ret =3D virDomainCheckDeviceChanges(vm->def, def); + + cleanup: + virDomainObjEndAPI(&vm); + + return ret; +} + static virDomainPtr qemuDomainDefineXMLFlags(virConnectPtr conn, const char *xml, @@ -7636,6 +7661,9 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0) goto cleanup; =20 + if (qemuDomainCheckDeviceChanges(driver, def) < 0) + goto cleanup; + if (!(vm =3D virDomainObjListAdd(driver->domains, def, driver->xmlopt, 0, &oldDef))) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index a21caefaba..e576bca165 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -79,7 +79,7 @@ qemuExtDeviceLogCommand(qemuDomainLogContextPtr logCtxt, * stored and we can remove directories and files in case of domain XML * changes. */ -static int +int qemuExtDevicesInitPaths(virQEMUDriverPtr driver, virDomainDefPtr def) { diff --git a/src/qemu/qemu_extdevice.h b/src/qemu/qemu_extdevice.h index a72e05ce63..bbdb9a1cc2 100644 --- a/src/qemu/qemu_extdevice.h +++ b/src/qemu/qemu_extdevice.h @@ -53,3 +53,6 @@ bool qemuExtDevicesHasDevice(virDomainDefPtr def); int qemuExtDevicesSetupCgroup(virQEMUDriverPtr driver, virDomainDefPtr def, virCgroupPtr cgroup); + +int qemuExtDevicesInitPaths(virQEMUDriverPtr driver, + virDomainDefPtr def); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065091; cv=none; d=zoho.com; s=zohoarc; b=MxRz5PePYETOiQD559QbNIDFiV0mexEv2ZErOUcARsCygi/JdAr6lLk5BuBaJKfHAR6QOzGZMI8BDfUKeG403bbco66XZZepvOcUe7DVRSNwbJvMY8ahmuL9oqdEyC/Pf3wa3tTXn7/6eeaHoqjgHxCdOb6qFVIhJxSqXSICr0A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065091; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=S0TQ8yQAE1kDWdO5jfPwUWzKv82DCJ+hvV4GhL9vGRo=; b=kxcO3SjH51tdRXNJHC0R5M5MVFnAKmpWOa5xQEr2fsZtRPLeQSb8ucoXHzuba+18L99ijBD7x1Ke0iBF5wy4ktVshFcfZfHOdA3lto54wWI7yJilQ35kORUOZ9ZyfHk9HutKVciozHj58rreHyFHcTu7GAn4MqfPmrEx4adzRo4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065091543269.3871717057938; Thu, 25 Jul 2019 07:31:31 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 3675B821C3; Thu, 25 Jul 2019 14:31:30 +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 09ABD6661A; Thu, 25 Jul 2019 14:31:30 +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 BAD1218045E0; Thu, 25 Jul 2019 14:31:29 +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 x6PEUsQ8012808 for ; Thu, 25 Jul 2019 10:30:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 869BA1017E3B; Thu, 25 Jul 2019 14:30:54 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 788361001B32; Thu, 25 Jul 2019 14:30:54 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2181F882EF; Thu, 25 Jul 2019 14:30:53 +0000 (UTC) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PEUFm9069141; Thu, 25 Jul 2019 10:30:52 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 2tycw9c1br-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jul 2019 10:30:52 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x6PEULVo004050; Thu, 25 Jul 2019 14:30:51 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma03dal.us.ibm.com with ESMTP id 2tx61nf90w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jul 2019 14:30:51 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUnp446596450 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:49 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8031EBE051; Thu, 25 Jul 2019 14:30:49 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2455EBE056; Thu, 25 Jul 2019 14:30:49 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:49 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:32 -0400 Message-Id: <20190725143033.1176271-19-stefanb@linux.vnet.ibm.com> In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=15 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 25 Jul 2019 14:30:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 25 Jul 2019 14:30:53 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 18/19] docs: Extend Secret XML documentation with vtpm usage type 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 25 Jul 2019 14:31:30 +0000 (UTC) Extend the Secret XML documentation with vtpm usage type. Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/formatsecret.html.in | 61 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/docs/formatsecret.html.in b/docs/formatsecret.html.in index defbe71731..8d0630a7c3 100644 --- a/docs/formatsecret.html.in +++ b/docs/formatsecret.html.in @@ -42,8 +42,8 @@ Specifies what this secret is used for. A mandatory type attribute specifies the usage category, currently only volume, ceph, iscsi, - and tls are defined. Specific usage categories - are described below. + tls, and vtpm are defined. Specific usage + categories are described below. =20 @@ -322,6 +322,63 @@ Secret 718c71bd-67b5-4a2b-87ec-a24e8ca200dc created
 # MYSECRET=3D`printf %s "letmein" | base64`
 # virsh secret-set-value 718c71bd-67b5-4a2b-87ec-a24e8ca200dc $MYSECRET
+Secret value set
+
+    
+ +

Usage type "vtpm"

+ +

+ This secret is associated with a virtualized TPM (vTPM) and serves + as a passphrase for deriving a key from for encrypting the state + of the vTPM. + The <usage type=3D'vtpm'> element must contain + a single name element that specifies a usage name + for the secret. The vTPM secret can then be used by UUID or by + this usage name via the <encryption> element of + a tpm when using an + emulator. + Since 5.6.0. The following is an example + of the steps to be taken. First create a vtpm-secret.xml file: <= /p> + +

+# cat vtpm-secret.xml
+<secret ephemeral=3D'no' private=3D'yes'>
+   <description>sample vTPM secret</description>
+   <usage type=3D'vtpm'>
+      <name>VTPM_example</name>
+   </usage>
+</secret>
+
+# virsh secret-define vtpm-secret.xml
+Secret 6dd3e4a5-1d76-44ce-961f-f119f5aad935 created
+
+# virsh secret-list
+ UUID                                   Usage
+--------------------------------------------------------------------------=
--------------
+ 6dd3e4a5-1d76-44ce-961f-f119f5aad935   vtpm VTPM_example
+
+#
+
+    
+ +

+ A secret may also be defined via the + + virSecretDefineXML API. + + Once the secret is defined, a secret value will need to be set. The + secret would be the passphrase used to decrypt the vTPM state. + The following is a simple example of using + virsh secret-set-value to set the secret value. The + + virSecretSetValue API may also be used to set + a more secure secret without using printable/readable characters. +

+ +
+# MYSECRET=3D`printf %s "open sesame" | base64`
+# virsh secret-set-value 6dd3e4a5-1d76-44ce-961f-f119f5aad935 $MYSECRET
 Secret value set
=20
     
--=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 05:50:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564065077; cv=none; d=zoho.com; s=zohoarc; b=iCKABf9KKd3n4eRq210YO2nqBgcnxCRBJ1HlcL2bn6+SXam9Td7QycHXxTMwZMRC49TZfMeNfA/Daqy3dTXzRkw5xjBsXXejEfQfXT90RaQzselbB5tpg5DUSfUdLarXv6eAZ2pbWDNDkAJx/ImuCPB6hf1qMfUapAE1raR7Ctw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564065077; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=ITJc0S/BzRW5EWGx0IVQ0WAEVi/1uK9EtAif8buE27M=; b=lLzjSEBSpRY63S/dh97+yr/H8gBtg97pjVhhCqRa8qsDmOgUS5gqG0PT4VljNjJTHbuhqpJNY1XJep1XgXS+sP4QPHL1xb9qrWUoCqE/5WJzs/jk2A3ksm5NH5O85gcncVWbT6dRxMW+/e3m99i5i1gJCt3t3BzFOWkVii/ZAAU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564065077385935.2419741805331; Thu, 25 Jul 2019 07:31:17 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 3064030C62A7; Thu, 25 Jul 2019 14:31: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 F3A2719723; Thu, 25 Jul 2019 14:31:15 +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 B5823E16E; Thu, 25 Jul 2019 14:31:15 +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 x6PEUutS012838 for ; Thu, 25 Jul 2019 10:30:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id C333261B9D; Thu, 25 Jul 2019 14:30:56 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DB4961B89; Thu, 25 Jul 2019 14:30:53 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E755F300D1C9; Thu, 25 Jul 2019 14:30:52 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6PETe1K042519; Thu, 25 Jul 2019 10:30:52 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tydm028dk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jul 2019 10:30:52 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x6PEUpKM020737; Thu, 25 Jul 2019 14:30:51 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma02wdc.us.ibm.com with ESMTP id 2tx61mg522-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jul 2019 14:30:51 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6PEUoNZ26542388 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 14:30:50 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 01785BE056; Thu, 25 Jul 2019 14:30:50 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B51FBE054; Thu, 25 Jul 2019 14:30:49 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 25 Jul 2019 14:30:49 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com Date: Thu, 25 Jul 2019 10:30:33 -0400 Message-Id: <20190725143033.1176271-20-stefanb@linux.vnet.ibm.com> In-Reply-To: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> References: <20190725143033.1176271-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-25_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=15 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250169 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 25 Jul 2019 14:30:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 25 Jul 2019 14:30:53 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger Subject: [libvirt] [PATCH v6 19/19] docs: Extend TPM docs with new encryption element 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 25 Jul 2019 14:31:16 +0000 (UTC) Describe the encryption element in the TPM's domain XML. Signed-off-by: Stefan Berger Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/formatdomain.html.in | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 1d57729394..1938bd875c 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -8215,6 +8215,9 @@ qemu-kvm -net nic,model=3D? /dev/null TPM functionality for each VM. QEMU talks to it over a Unix socket. = With the emulator device type each guest gets its own private TPM. 'emulator' since 4.5.0 + The state of the TPM emulator can be encrypted by providing an + encryption element. + 'encryption' since 5.6.0

Example: usage of the TPM Emulator @@ -8224,6 +8227,7 @@ qemu-kvm -net nic,model=3D? /dev/null <devices> <tpm model=3D'tpm-tis'> <backend type=3D'emulator' version=3D'2.0'> + <encryption secret=3D'6dd3e4a5-1d76-44ce-961f-f119f5aad935'/> </backend> </tpm> </devices> @@ -8286,6 +8290,14 @@ qemu-kvm -net nic,model=3D? /dev/null

  • '2.0' : creates a TPM 2.0
  • +
    encryption
    +
    +

    + The encryption element allows the state of a TPM em= ulator + to be encrypted. The secret must reference a secret= object + that holds the passphrase from which the encryption key will be = derived. +

    +
    =20

    NVRAM device

    --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list