From nobody Sun May 5 13:50:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1639087487933573.7086060156796; Thu, 9 Dec 2021 14:04:47 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-91-vOzY6WTFO1O3w96D1yvaMg-1; Thu, 09 Dec 2021 17:04:44 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF739190B2AF; Thu, 9 Dec 2021 22:04:37 +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 2A7A85BE16; Thu, 9 Dec 2021 22:04:36 +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 2E0C01809CB8; Thu, 9 Dec 2021 22:04:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B9M4S9V012937 for ; Thu, 9 Dec 2021 17:04:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1C70A40CFD07; Thu, 9 Dec 2021 22:04:28 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 16A574010FDD for ; Thu, 9 Dec 2021 22:04:28 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED2CB800B28 for ; Thu, 9 Dec 2021 22:04:27 +0000 (UTC) Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-225-bWHbr0zZP9mspXJhgbkgow-1; Thu, 09 Dec 2021 17:04:25 -0500 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01lp2059.outbound.protection.outlook.com [104.47.0.59]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-6-ajVb_8ObNi-IFlGu7azDJA-1; Thu, 09 Dec 2021 23:04:23 +0100 Received: from AM0PR04MB4899.eurprd04.prod.outlook.com (2603:10a6:208:c5::16) by AM0PR04MB4897.eurprd04.prod.outlook.com (2603:10a6:208:c8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12; Thu, 9 Dec 2021 22:04:22 +0000 Received: from AM0PR04MB4899.eurprd04.prod.outlook.com ([fe80::2491:2b2f:154a:acf3]) by AM0PR04MB4899.eurprd04.prod.outlook.com ([fe80::2491:2b2f:154a:acf3%5]) with mapi id 15.20.4755.025; Thu, 9 Dec 2021 22:04:22 +0000 Received: from localhost (75.169.28.116) by AM6P194CA0079.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Thu, 9 Dec 2021 22:04:21 +0000 X-MC-Unique: vOzY6WTFO1O3w96D1yvaMg-1 X-MC-Unique: bWHbr0zZP9mspXJhgbkgow-1 X-MC-Unique: ajVb_8ObNi-IFlGu7azDJA-1 From: Jim Fehlig To: libvir-list@redhat.com Subject: [PATCH V2 1/3] libvirt: Introduce virDomainSetLaunchSecurityState public API Date: Thu, 9 Dec 2021 15:04:13 -0700 Message-ID: <20211209220415.22039-2-jfehlig@suse.com> In-Reply-To: <20211209220415.22039-1-jfehlig@suse.com> References: <20211209220415.22039-1-jfehlig@suse.com> X-ClientProxiedBy: AM6P194CA0079.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::20) To AM0PR04MB4899.eurprd04.prod.outlook.com (2603:10a6:208:c5::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 53fdf0c5-075c-4915-8461-08d9bb5fdb0e X-MS-TrafficTypeDiagnostic: AM0PR04MB4897:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: WhheNLtx3HNjkIbE4We721jdxkvM8Mdpl7AHfizdAENpd/Dhpb27OhQzTTxC52dNnm9KfD5tWRNnLIxQ5u+70Yq9ZbKAT75O/DfvHuUgCQrE/Vhmeq7Oi9GUNnGIu+dGmRdD2qDzMiONmBKvUJ0A2SC1fWKspJcBP2FUz4LrNh0EsGQcWq1o+nV/dh+MSVKbmmmvv5t3e2GV9fikPAfWdFINf9C+7d1o1kVSn9VYrEEmrY58RvjLlteM6HkLa6GbEuIbGamSYlHMdqhl4hsHvj5tjehXpeCfSj3oEY400JgSg/DBaVPkSFG0pT+m7Zy2k93lyLMEMuUEhuYbrJwewy6roBoTHvJcZJVh4jgdsqxOw4DyvGQFqxh9QCyrr4+7+0IzSARgbFSZqCdkc0RvnMHT4PrqcrbLRJ/FXu83gFBe/74Wwkksnz/w5GHjfhzMVTY4I8mQuxyxoKH8VHZ3xd5WFOgvJS2LYt6WvyB5wHJtLVadfatR3ZJk/5KzFhjzU5stABC94yUL968WafUnNnM9miYlYR0l6D2RCmHaStHkYKR1BfKsIGwki667vJ187tasQwy3iave7lZLetahQgGupLRWjJ3tMEDlOKpEG0fCfRFhDsxdoXnFSRkLBltUPWaJaIQUbvM6jnX6gRvVjUcF+BqpK0mn4ybEwB5YyVc/K1pkTzMhRS0uVBEyhlpRLfduHY+bUqpDTqvPa/urzgekML6+KrdQ8havRGNusT0brlIORTEmbx574Xlp0xSnciYgjW2uLRExqsG/p+mCtStQ5bMtgLxAAt+Jc0D7DU1ws7LRR57jRq+sEuWZ+uSY X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB4899.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6666004)(6916009)(83380400001)(186003)(956004)(2616005)(6496006)(26005)(66946007)(66476007)(66556008)(8936002)(36756003)(6486002)(966005)(316002)(1076003)(38100700002)(2906002)(508600001)(8676002)(86362001)(5660300002)(145543001)(213903007); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?MybC143CV2A0brCb8flJN8zZ7KTKLhWBAuok5BV8i3p6VXNS6o4mR5/j9EzE?= =?us-ascii?Q?ysc6bopqmXJjpiJcSIldz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ascii?Q?mZrX8YX7csGoKJdPifPFRBhseQv6Xjs3iFA1FB3xkFDnsMpFABLa972clzpv?= =?us-ascii?Q?Lxrcfx+0Y3m2lbSlIurShJMjYRoEH9ZDoN8V9NSwiVOiJY6kDcywSknujIuz?= =?us-ascii?Q?xLu4RBm8a19tMxMVaLHxB6N0fi5c9+fkT04GxjupKpSVSagXCxN02hMwmaVF?= =?us-ascii?Q?l86OlyL08wCMmITWTCPX4/VhlHxus4P09EKW3GbvpnxDMYa8kYyQq7MHdsBN?= =?us-ascii?Q?uln7pXRrpn+xxvsvE1I0u2Kukeg+RI6DZ1VUHu4U5rg8hqihF6S9lerwcBWT?= =?us-ascii?Q?drtISTXrzB1qjscYMrhPaITSsAmq9dx3xFUg7DG1ZOi8TnAGrlyODjZr7BWd?= =?us-ascii?Q?+M5xf2FferxnPPfTihSQAjMzPl1wq9Lzb4mx3l3ErfkvmgMdWs91cCRH3dfy?= =?us-ascii?Q?jC1GZyd8XgXwO7LY25Ajj0zZMG5pJjFaMrnZenz2e3RMrogSNanwJB58t66c?= =?us-ascii?Q?NsPGdGo4sQMFQUtM2TL+tZXlIZr0ZBkPwT3CtcDTJIvVbHBImGTGuwg7LDC/?= =?us-ascii?Q?EGm8O2UDFomxg6f+unYlL7GybnncuhopBKgVvJc3LyxxJ6hxecxhrvG7AVWg?= =?us-ascii?Q?7x7gXXnLTLnjh+W/lAYiWLIXIwHkKK7iilnDTtOzZv83rvi1fN8TaPgfVSW/?= =?us-ascii?Q?qqJMgbrD8Z7KBxjVibhbSuY=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53fdf0c5-075c-4915-8461-08d9bb5fdb0e X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB4899.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 22:04:22.3740 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TvCo86fjI7PAIgdPbALdqJucJXEQev/bIe9jxcj8yK9MACY1Pwb7LCZtcf2lisihlGR+guVwZ7Uz8UDjE7a54g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4897 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 1B9M4S9V012937 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1639087489061100001 Content-Type: text/plain; charset="utf-8" This API allows setting a launch secret within a guests's memory. The launch secret is created by the guest owner after retrieving and verifying the launch measurement with virDomainGetLaunchSecurityInfo. The API uses virTypedParameter for input, allowing it to be expanded to support other confidential computing technologies. In the case of SEV, a basic guest launch workflow is described in the SEV API spec in section "1.3.1 Launch" https://www.amd.com/system/files/TechDocs/55766_SEV-KM_API_Specification.pdf Signed-off-by: Jim Fehlig Reviewed-by: Daniel P. Berrang=C3=A9 --- include/libvirt/libvirt-domain.h | 35 ++++++++++++++++++ src/driver-hypervisor.h | 7 ++++ src/libvirt-domain.c | 62 ++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 +++ 4 files changed, 109 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index d0dd11ab01..9e7f72e214 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5101,11 +5101,46 @@ int virDomainSetLifecycleAction(virDomainPtr domain, */ # define VIR_DOMAIN_LAUNCH_SECURITY_SEV_MEASUREMENT "sev-measurement" =20 +/** + * VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_HEADER: + * + * A macro used to represent the SEV launch secret header. The secret head= er + * is a base64-encoded VIR_TYPED_PARAM_STRING containing artifacts needed = by + * the SEV firmware to recover the plain text of the launch secret. See + * section "6.6 LAUNCH_SECRET" in the SEV API specification for a detailed + * description of the secret header. + */ +# define VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_HEADER "sev-secret-header" + +/** + * VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET: + * + * A macro used to represent the SEV launch secret. The secret is a + * base64-encoded VIR_TYPED_PARAM_STRING containing an encrypted launch + * secret. The secret is created by the domain owner after the SEV launch + * measurement is retrieved and verified. + */ +# define VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET "sev-secret" + +/** + * VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_SET_ADDRESS: + * + * A macro used to represent the physical address within the guest's memory + * where the secret will be set, as VIR_TYPED_PARAM_ULLONG. If not specifi= ed, + * the address will be determined by the hypervisor. + */ +# define VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_SET_ADDRESS "sev-secret-set= -address" + int virDomainGetLaunchSecurityInfo(virDomainPtr domain, virTypedParameterPtr *params, int *nparams, unsigned int flags); =20 +int virDomainSetLaunchSecurityState(virDomainPtr domain, + virTypedParameterPtr params, + int nparams, + unsigned int flags); + typedef enum { VIR_DOMAIN_GUEST_INFO_USERS =3D (1 << 0), /* return active users */ VIR_DOMAIN_GUEST_INFO_OS =3D (1 << 1), /* return OS information */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index d642af8a37..c83fb648a2 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1333,6 +1333,12 @@ typedef int int *nparams, unsigned int flags); =20 +typedef int +(*virDrvDomainSetLaunchSecurityState)(virDomainPtr domain, + virTypedParameterPtr params, + int nparams, + unsigned int flags); + typedef virDomainCheckpointPtr (*virDrvDomainCheckpointCreateXML)(virDomainPtr domain, const char *xmlDesc, @@ -1661,6 +1667,7 @@ struct _virHypervisorDriver { virDrvConnectBaselineHypervisorCPU connectBaselineHypervisorCPU; virDrvNodeGetSEVInfo nodeGetSEVInfo; virDrvDomainGetLaunchSecurityInfo domainGetLaunchSecurityInfo; + virDrvDomainSetLaunchSecurityState domainSetLaunchSecurityState; virDrvDomainCheckpointCreateXML domainCheckpointCreateXML; virDrvDomainCheckpointGetXMLDesc domainCheckpointGetXMLDesc; virDrvDomainListAllCheckpoints domainListAllCheckpoints; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 5708ff839b..82b0822d12 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12844,6 +12844,68 @@ int virDomainGetLaunchSecurityInfo(virDomainPtr do= main, } =20 =20 +/** + * virDomainSetLaunchSecurityState: + * @domain: a domain object + * @params: pointer to launch security parameter objects + * @nparams: number of launch security parameters + * @flags: currently used, set to 0. + * + * Set a launch security secret in the guest's memory. The guest must be + * in a paused state, e.g. in state VIR_DOMIAN_PAUSED as reported by + * virDomainGetState. On success, the guest can be transitioned to a + * running state. On failure, the guest should be destroyed. + * + * A basic guest attestation process can be achieved by: + * - Start a secure guest in the paused state by passing VIR_DOMAIN_START_= PAUSED + * to one of the virDomainCreate APIs + * - Retrieve the guest launch measurement with virDomainGetLaunchSecurity= Info + * - Verify launch measurement and generate a secret for the guest + * - Set the secret in the guest's memory with virDomainSetLaunchSecurityS= tate + * - Start running the guest with virDomainResume + * + * See VIR_DOMAIN_LAUNCH_SECURITY_* for a detailed description of accepted + * launch security parameters. + * + * Returns -1 in case of failure, 0 in case of success. + */ +int virDomainSetLaunchSecurityState(virDomainPtr domain, + virTypedParameterPtr params, + int nparams, + unsigned int flags) +{ + virConnectPtr conn =3D domain->conn; + + VIR_DOMAIN_DEBUG(domain, "params=3D%p, nparams=3D%d flags=3D0x%x", + params, nparams, flags); + VIR_TYPED_PARAMS_DEBUG(params, nparams); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + virCheckNonNullArgGoto(params, error); + virCheckPositiveArgGoto(nparams, error); + virCheckReadOnlyGoto(domain->conn->flags, error); + + if (virTypedParameterValidateSet(conn, params, nparams) < 0) + goto error; + + if (conn->driver->domainSetLaunchSecurityState) { + int ret; + ret =3D conn->driver->domainSetLaunchSecurityState(domain, params, + nparams, flags); + if (ret < 0) + goto error; + return ret; + } + virReportUnsupportedError(); + + error: + virDispatchError(domain->conn); + return -1; +} + + /** * virDomainAgentSetResponseTimeout: * @domain: a domain object diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 788a967df7..f93692c427 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -911,4 +911,9 @@ LIBVIRT_7.8.0 { virNetworkCreateXMLFlags; } LIBVIRT_7.7.0; =20 +LIBVIRT_8.0.0 { + global: + virDomainSetLaunchSecurityState; +} LIBVIRT_7.8.0; + # .... define new API here using predicted next version number .... --=20 2.34.1 From nobody Sun May 5 13:50:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1639087623614128.0167109918799; Thu, 9 Dec 2021 14:07:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-551-LKIF_0xdOmqV8WYjYE6NdA-1; Thu, 09 Dec 2021 17:07:01 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9AAAE1927800; Thu, 9 Dec 2021 22:06:55 +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 805FB45D7C; Thu, 9 Dec 2021 22:06:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 570E31806D1D; Thu, 9 Dec 2021 22:06:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B9M4UVq012942 for ; Thu, 9 Dec 2021 17:04:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id AFD17492CA4; Thu, 9 Dec 2021 22:04:30 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA4A7492CA3 for ; Thu, 9 Dec 2021 22:04:30 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8995A3C0014A for ; Thu, 9 Dec 2021 22:04:30 +0000 (UTC) Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-449-3Dv70upiMsGCdQjZjd2QZQ-1; Thu, 09 Dec 2021 17:04:28 -0500 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01lp2054.outbound.protection.outlook.com [104.47.0.54]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-10-ntGyaR7GPR2TBZw6sAV3IQ-1; Thu, 09 Dec 2021 23:04:26 +0100 Received: from AM0PR04MB4899.eurprd04.prod.outlook.com (2603:10a6:208:c5::16) by AM0PR04MB4897.eurprd04.prod.outlook.com (2603:10a6:208:c8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12; Thu, 9 Dec 2021 22:04:25 +0000 Received: from AM0PR04MB4899.eurprd04.prod.outlook.com ([fe80::2491:2b2f:154a:acf3]) by AM0PR04MB4899.eurprd04.prod.outlook.com ([fe80::2491:2b2f:154a:acf3%5]) with mapi id 15.20.4755.025; Thu, 9 Dec 2021 22:04:25 +0000 Received: from localhost (75.169.28.116) by AM6P194CA0087.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::28) with Microsoft SMTP Server (version=TLS1_2, cipher=) via Frontend Transport; Thu, 9 Dec 2021 22:04:24 +0000 X-MC-Unique: LKIF_0xdOmqV8WYjYE6NdA-1 X-MC-Unique: 3Dv70upiMsGCdQjZjd2QZQ-1 X-MC-Unique: ntGyaR7GPR2TBZw6sAV3IQ-1 From: Jim Fehlig To: libvir-list@redhat.com Subject: [PATCH V2 2/3] remote: Add RPC support for the virDomainSetLaunchSecurityState API Date: Thu, 9 Dec 2021 15:04:14 -0700 Message-ID: <20211209220415.22039-3-jfehlig@suse.com> In-Reply-To: <20211209220415.22039-1-jfehlig@suse.com> References: <20211209220415.22039-1-jfehlig@suse.com> X-ClientProxiedBy: AM6P194CA0087.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::28) To AM0PR04MB4899.eurprd04.prod.outlook.com (2603:10a6:208:c5::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fbdce2dd-77e2-4c19-ef75-08d9bb5fdce8 X-MS-TrafficTypeDiagnostic: AM0PR04MB4897:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:116 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: /DgG3XXGCDPteN4yAlj0jL47rqsze2jBCr7PxEH8DDuUlwIPmws9ezoQS2PMShDMlEWZyBVuDA11UdxhFnakF3mlcKqZDlEm64ubgBzPS3Ww9NoXjbsTySBFF0FVbJ0YhmQxMt+XkE06KA8GjTS1Gu6/AiPK17vjXZfbtxLM+JDoCRJwGwwjkVRhFAsfi/D130ImQt1/WObL7ryCNAl9TuA5sewipKErvN+vt4LnBiicWftWv5ds5N3AEYamQR9Np4qCjfDTJihZ8AbuLVnmqnIvmhj1u4JKdzBls3Ax9OycT05P+HHaFHz0qHKYoA8EmohTCGejQkcZwqGyjUN5J/p3ezd0mIQDHU4SaHvgeTB5yUYVgzL4IyJmlHZbx7cV0y04NpoxNic/nUK8tnntSlYfR22PQCrnuu6Fi73GC8SbHFYrZ7oEMLQsSIiwkYeEP2TSIBr1eLoETfm7E75Gc+AgMk4uzgQHmb+eo9644H5nUWNGwm66pNa0Q3PoQI13SU1Q6YulUWyVMMIuBSbl31Cra6Taf6YhJ7HBMFFNmRmX5+3p6Akx6RiX9bxqVGMMntrEhjlrOMgviUnEy67WzVaD5tht0wfG9VfS7yhaGiOjqb/gCVN5F1Gu3qxpZQc+yx8G4ECbSW2UPjPXxAr+4PliIN9gE1A7Fxh/ykQVR0d4JelBITVmyPE4weiB0R6vm1igYCIRpIYccSjS6/QSmW3OKktiP/ZoHtRuhlkbZ4s= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB4899.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6666004)(6916009)(83380400001)(186003)(450100002)(956004)(2616005)(6496006)(26005)(66946007)(66476007)(66556008)(8936002)(36756003)(6486002)(316002)(1076003)(38100700002)(2906002)(4326008)(508600001)(8676002)(86362001)(5660300002)(145543001)(213903007); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?JcbXpTXsYS0Txj4+xbUliy7s6K5Sb9Q6+uFDL7MIs4ZVjcjM6aphmQLI3Dh+?= =?us-ascii?Q?MC4pCSzIaQ6niBQVfPwWGUi4xBz8GFB6T0f6ygy/YyrjFwlC6OvIpZmjfRqD?= =?us-ascii?Q?lLODHzCC0JtCu7VGUX3xkKjf4lB4AXToK+Txaf/MBJi/Rb3S99Ze301mtTww?= =?us-ascii?Q?ZLfusOOCqs9jQ/3TGdYk+Gag/nmgzaoQsHhcU133s8xx/vdQMYHj4i6XD70Z?= =?us-ascii?Q?JxbzQVABJHNZhvgKS3h/xG7AwcTeg/j6ffUS4G8w+SA/thNe9xHd9zCUF3d+?= =?us-ascii?Q?49B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NDpo?= =?us-ascii?Q?PIz7vPLFY8AOKcRb73xi9OoRw+99QyoGJ/1RQRd525Ecdg++M6HtQx52nZSq?= =?us-ascii?Q?Ud0gGzCQ36lKIxGg0nTZWoPH2QXdXMChhhRV3kLRfVEEek6UBSz45KekKUL9?= =?us-ascii?Q?tVCGvCD/bWQ2lvdLXeh9PXyqFjGhUFyqu1IDGcEiXAiCWbyIhxzZdi6j61D6?= =?us-ascii?Q?VcPHTBh+FoKTmtY+RPx1c1YNx+Jkh/fykt9STQEu4r7FxIGgDGYozzYyeqto?= =?us-ascii?Q?xSomCF+IJJvXpyEc4L/B1b02mhLhlcrGju5PliXTdF9Onfv0PoUVp14iwYhi?= =?us-ascii?Q?W86wC7fZ/Go4L6/XubWpaKNSv6GoFLeo4hLLhI0YpU4bXgP4/PlZlKsJCymr?= =?us-ascii?Q?LTx6AY4TxgRkThXEwNclp6BjqvPeP8tCotDGTz5/T3ug5qc6641uVoiFQupC?= =?us-ascii?Q?sgM8nxueUE0WeF0E28pcKL8=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: fbdce2dd-77e2-4c19-ef75-08d9bb5fdce8 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB4899.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 22:04:25.4988 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uHmxkMYxyvYSW5k4xxvzjlcSm87cRw27+OPzIYb11SlACXNYRMu4gMGatxaEuf5CiFbKwcUkXvyYb8KMgAD9ng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4897 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 1B9M4UVq012942 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1639087624246100001 Signed-off-by: Jim Fehlig Reviewed-by: Daniel P. Berrang=C3=A9 --- src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 17 ++++++++++++++++- src/remote_protocol-structs | 9 +++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 235c406a5a..604239951c 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8574,6 +8574,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainAuthorizedSSHKeysSet =3D remoteDomainAuthorizedSSHKeysSet, /* 6= .10.0 */ .domainGetMessages =3D remoteDomainGetMessages, /* 7.1.0 */ .domainStartDirtyRateCalc =3D remoteDomainStartDirtyRateCalc, /* 7.2.0= */ + .domainSetLaunchSecurityState =3D remoteDomainSetLaunchSecurityState, = /* 8.0.0 */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 60010778ca..4f13cef662 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -272,6 +272,9 @@ const REMOTE_NODE_SEV_INFO_MAX =3D 64; /* Upper limit on number of launch security information entries */ const REMOTE_DOMAIN_LAUNCH_SECURITY_INFO_PARAMS_MAX =3D 64; =20 +/* Upper limit on number of launch security state entries */ +const REMOTE_DOMAIN_LAUNCH_SECURITY_STATE_PARAMS_MAX =3D 64; + /* Upper limit on number of parameters describing a guest */ const REMOTE_DOMAIN_GUEST_INFO_PARAMS_MAX =3D 2048; =20 @@ -3642,6 +3645,12 @@ struct remote_domain_get_launch_security_info_ret { remote_typed_param params; }; =20 +struct remote_domain_set_launch_security_state_args { + remote_nonnull_domain dom; + remote_typed_param params; + unsigned int flags; +}; + /* nwfilter binding */ =20 struct remote_nwfilter_binding_lookup_by_port_dev_args { @@ -6905,5 +6914,11 @@ enum remote_procedure { * @generate: both * @acl: none */ - REMOTE_PROC_DOMAIN_EVENT_MEMORY_DEVICE_SIZE_CHANGE =3D 438 + REMOTE_PROC_DOMAIN_EVENT_MEMORY_DEVICE_SIZE_CHANGE =3D 438, + + /** + * @generate: both + * @acl: domain:write + */ + REMOTE_PROC_DOMAIN_SET_LAUNCH_SECURITY_STATE =3D 439 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index dbef4ace79..d88176781d 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3005,6 +3005,14 @@ struct remote_domain_get_launch_security_info_ret { remote_typed_param * params_val; } params; }; +struct remote_domain_set_launch_security_state_args { + remote_nonnull_domain dom; + struct { + u_int params_len; + remote_typed_param * params_val; + } params; + u_int flags; +}; struct remote_nwfilter_binding_lookup_by_port_dev_args { remote_nonnull_string name; }; @@ -3680,4 +3688,5 @@ enum remote_procedure { REMOTE_PROC_NODE_DEVICE_IS_ACTIVE =3D 436, REMOTE_PROC_NETWORK_CREATE_XML_FLAGS =3D 437, REMOTE_PROC_DOMAIN_EVENT_MEMORY_DEVICE_SIZE_CHANGE =3D 438, + REMOTE_PROC_DOMAIN_SET_LAUNCH_SECURITY_STATE =3D 439, }; --=20 2.34.1 From nobody Sun May 5 13:50:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639087503595763.3829504847411; Thu, 9 Dec 2021 14:05:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-40-lfQ0aleGOcGJX9_XEM20WQ-1; Thu, 09 Dec 2021 17:04:59 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 68B148042FB; Thu, 9 Dec 2021 22:04:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3BD4D5BE0F; Thu, 9 Dec 2021 22:04:54 +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 745001809CBA; Thu, 9 Dec 2021 22:04:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B9M4XW3012961 for ; Thu, 9 Dec 2021 17:04:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 46B8D1121315; Thu, 9 Dec 2021 22:04:33 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 41C191121314 for ; Thu, 9 Dec 2021 22:04:33 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26B108011A5 for ; Thu, 9 Dec 2021 22:04:33 +0000 (UTC) Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-170-I6Bs3tbbOlO_0wyrQ7a1rw-1; Thu, 09 Dec 2021 17:04:31 -0500 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01lp2052.outbound.protection.outlook.com [104.47.0.52]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-12-4QSGBKDEMAu8xzVkg9aZ6w-1; Thu, 09 Dec 2021 23:04:29 +0100 Received: from AM0PR04MB4899.eurprd04.prod.outlook.com (2603:10a6:208:c5::16) by AM0PR04MB4897.eurprd04.prod.outlook.com (2603:10a6:208:c8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12; Thu, 9 Dec 2021 22:04:28 +0000 Received: from AM0PR04MB4899.eurprd04.prod.outlook.com ([fe80::2491:2b2f:154a:acf3]) by AM0PR04MB4899.eurprd04.prod.outlook.com ([fe80::2491:2b2f:154a:acf3%5]) with mapi id 15.20.4755.025; Thu, 9 Dec 2021 22:04:28 +0000 Received: from localhost (75.169.28.116) by AM6P194CA0102.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Thu, 9 Dec 2021 22:04:27 +0000 X-MC-Unique: lfQ0aleGOcGJX9_XEM20WQ-1 X-MC-Unique: I6Bs3tbbOlO_0wyrQ7a1rw-1 X-MC-Unique: 4QSGBKDEMAu8xzVkg9aZ6w-1 From: Jim Fehlig To: libvir-list@redhat.com Subject: [PATCH V2 3/3] qemu: Implement the virDomainSetLaunchSecurityState API Date: Thu, 9 Dec 2021 15:04:15 -0700 Message-ID: <20211209220415.22039-4-jfehlig@suse.com> In-Reply-To: <20211209220415.22039-1-jfehlig@suse.com> References: <20211209220415.22039-1-jfehlig@suse.com> X-ClientProxiedBy: AM6P194CA0102.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::43) To AM0PR04MB4899.eurprd04.prod.outlook.com (2603:10a6:208:c5::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ef7723e-333e-4d68-97d8-08d9bb5fde9f X-MS-TrafficTypeDiagnostic: AM0PR04MB4897:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:34 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: jOVQ0pdLX+fUcDsr7o7ThSqRxvc5BFhJHot9iRMVH8sVbZrYhqMZPtDSB2RhRNH4G/2PIMR5uc+zyJzeBtarBZdYg/gde4sRUqkVyazXf4hXVPTkKJKNQU0v75KZfSDtSEhWy7BDtOL441xwsBNSUffe64sb7C+OCXLqwFMpuP1g9bzCUgYRa3cCv9gqGhAyeLpwGOSq6/YbGmt1gpkbdJ4ZMrKTYO9GGY7TT0LCW+RMckcwzt5akkJe0xjxQ0vbphkYwCkQchwcjoIdwhKkOyaJi41taFKOpeSzV8uyxsYHfszOR++S7bo7gOCQ9HO+MJ0hjAYyazdmmG32K4zc7bHLY1faqWwiH5+DcB1lMIYpWfao/tUTARuRBon2h9A9Ghp1ICB0ramTMAcwpCO19sH9FugL/5IahUG41wlpR8fPYXzy5/rKK1NUZEGDaZlDpUISW8Do3S/UcVkwjnKTFhNqB0NxS0HFjvpARaA8y2oUzPM/ZWAlGJW8bQDgD/Es72ljQOnmpcu+bE7SDiKE20n/viPNvCTwieYRPCT/VywcVgstd326dWeefNUQpI/55ca6GjfZ+dEpOuwAsMIDWQUfWVbiPerXMT6pqVxGtBS9Z1flkdEdNJSuUrcLz6yVkulukipDXnU8pR2VGp9LSVxyRsDrb4Usa9eOL++COo8vbKOj1yU7WqU+S9heVL1kZ1cOfCerWDNKnZot1rPzxwyRFrkZCsd73RAeO/Ho200= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB4899.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6666004)(6916009)(83380400001)(186003)(956004)(2616005)(6496006)(26005)(66946007)(66476007)(66556008)(8936002)(36756003)(6486002)(316002)(1076003)(38100700002)(2906002)(508600001)(8676002)(86362001)(5660300002)(145543001)(213903007); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?9IW3ib+49Gdo5TvETL23808yHpBG6JFiGK9LgOuRET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J7M390r3Z6vw1Lo+lsQt13hn3dIeWFFxyvhRjdiB4?= =?us-ascii?Q?55UxOBkfNtDvPoO5oTld7tnqNmpaJjojMssROjN6yfAvhC2ZCP9avm/TeyDS?= =?us-ascii?Q?1U9sdyZyPl34nHdaeMfDbLNE5cp9DZaXMIuAd4Oa5TXcAeBjAvPXhp8aVpXU?= =?us-ascii?Q?C/oKErudOgWA3XElY3HC9sc1t0o5xNM9jird6FdMhRRnrmOc1q3CJEWKQ2eR?= =?us-ascii?Q?bQJfKPMP+iwfWlX5hbNY9ez6pp3a0ba3CHWIqk6dyKYKYrDSP8FuKV2Lc6K1?= =?us-ascii?Q?lSj2xDK7ECVfCyLR0q5+o9HlCcDvWkhCEXyu3Bm2lczhjInmo+azDJXz3SBZ?= =?us-ascii?Q?qG4xWrMu8VQY9gv1NngU9Onph0orlJ/XwU5H9Z6JsXDz2qPkqiTBN2KPeU/7?= =?us-ascii?Q?aQPtulqxqgEyxSF8rV5yHhfKOGC8YU+ZGHRfjLLNatggW4WszSRnDHy9crTM?= =?us-ascii?Q?mBISe3+pN3SPRWgJRp3LLvlBtGYXIlo32Gh59IE3zmd3yOgmIsR36aPKoU9F?= =?us-ascii?Q?r6F5mcwOh6pHfZPU0p4MVZug3nDmeiQ65sddRxXsJiyl5CJtIow14ow2A+q9?= =?us-ascii?Q?YKA9rrRBgjwA2LqBsYD6ktgsJcQc2/E7XrF/fMKft84jS2IloK85wPt2K354?= =?us-ascii?Q?Tpa9OkbXGPcbaUSUZtpUF++rQUPjNHQiB4usm0L383Bz1fS2uReD/a3AfdXO?= =?us-ascii?Q?BWB/UMW3tfmqcc16H6fi3II=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ef7723e-333e-4d68-97d8-08d9bb5fde9f X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB4899.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 22:04:28.3736 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jzc4DwP8TT0cEgE4TR3TxadOviaj5TTXsJkwyEEz9EvkHUJvumwMM0oeWGom6f6lF1QzvzJcj3EJLnQ7cxRvoQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4897 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 1B9M4XW3012961 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1639087504817100001 Content-Type: text/plain; charset="utf-8" Set a launch secret in guest memory using the sev-inject-launch-secret QMP API. Only supported for SEV-enabled guests in a paused state. Signed-off-by: Jim Fehlig --- src/qemu/qemu_driver.c | 88 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor.c | 14 ++++++ src/qemu/qemu_monitor.h | 7 +++ src/qemu/qemu_monitor_json.c | 45 ++++++++++++++++++ src/qemu/qemu_monitor_json.h | 6 +++ 5 files changed, 160 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8093b8f69b..b38a246d37 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20042,6 +20042,93 @@ qemuDomainGetLaunchSecurityInfo(virDomainPtr domai= n, return ret; } =20 + +static int +qemuDomainSetLaunchSecurityState(virDomainPtr domain, + virTypedParameterPtr params, + int nparams, + unsigned int flags) +{ + virQEMUDriver *driver =3D domain->conn->privateData; + virDomainObj *vm; + int ret =3D -1; + int rc; + size_t i; + g_autofree char *secrethdr =3D NULL; + g_autofree char *secret =3D NULL; + unsigned long long setaddr =3D 0; + bool hasSetaddr =3D false; + int state; + + virCheckFlags(0, -1); + if (virTypedParamsValidate(params, nparams, + VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_HEADE= R, + VIR_TYPED_PARAM_STRING, + VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET, + VIR_TYPED_PARAM_STRING, + VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_SET_A= DDRESS, + VIR_TYPED_PARAM_ULLONG, + NULL) < 0) + return -1; + + if (!(vm =3D qemuDomainObjFromDomain(domain))) + goto cleanup; + + if (virDomainSetLaunchSecurityStateEnsureACL(domain->conn, vm->def) < = 0) + goto cleanup; + + /* Currently only SEV is supported */ + if (!vm->def->sec || + vm->def->sec->sectype !=3D VIR_DOMAIN_LAUNCH_SECURITY_SEV) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("setting a launch secret is only supported in SEV= -enabled domains")); + goto cleanup; + } + + for (i =3D 0; i < nparams; i++) { + virTypedParameterPtr param =3D ¶ms[i]; + + if (STREQ(param->field, VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_HEAD= ER)) { + secrethdr =3D g_strdup(param->value.s); + } else if (STREQ(param->field, VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECR= ET)) { + secret =3D g_strdup(param->value.s); + } else if (STREQ(param->field, VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECR= ET_SET_ADDRESS)) { + setaddr =3D param->value.ul; + hasSetaddr =3D true; + } + } + + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + + if (virDomainObjCheckActive(vm) < 0) + goto endjob; + + state =3D virDomainObjGetState(vm, NULL); + if (state !=3D VIR_DOMAIN_PAUSED) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain must be in a paused state")); + goto endjob; + } + + qemuDomainObjEnterMonitor(driver, vm); + rc =3D qemuMonitorSetLaunchSecurityState(QEMU_DOMAIN_PRIVATE(vm)->mon, + secrethdr, secret, setaddr, has= Setaddr); + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) + goto endjob; + + ret =3D 0; + + endjob: + qemuDomainObjEndJob(driver, vm); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + static const unsigned int qemuDomainGetGuestInfoSupportedTypes =3D VIR_DOMAIN_GUEST_INFO_USERS | VIR_DOMAIN_GUEST_INFO_OS | @@ -20915,6 +21002,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainAuthorizedSSHKeysSet =3D qemuDomainAuthorizedSSHKeysSet, /* 6.1= 0.0 */ .domainGetMessages =3D qemuDomainGetMessages, /* 7.1.0 */ .domainStartDirtyRateCalc =3D qemuDomainStartDirtyRateCalc, /* 7.2.0 */ + .domainSetLaunchSecurityState =3D qemuDomainSetLaunchSecurityState, /*= 8.0.0 */ }; =20 =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 75e0e4ed92..b1de6383f4 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4366,6 +4366,20 @@ qemuMonitorGetSEVMeasurement(qemuMonitor *mon) } =20 =20 +int +qemuMonitorSetLaunchSecurityState(qemuMonitor *mon, + const char *secrethdr, + const char *secret, + unsigned long long setaddr, + bool hasSetaddr) +{ + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONSetLaunchSecurityState(mon, secrethdr, secret, + setaddr, hasSetaddr); +} + + int qemuMonitorGetPRManagerInfo(qemuMonitor *mon, GHashTable **retinfo) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index edc2b01a66..621d785d80 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1445,6 +1445,13 @@ int qemuMonitorBlockdevMediumInsert(qemuMonitor *mon, char * qemuMonitorGetSEVMeasurement(qemuMonitor *mon); =20 +int +qemuMonitorSetLaunchSecurityState(qemuMonitor *mon, + const char *secrethdr, + const char *secret, + unsigned long long setaddr, + bool hasSetaddr); + typedef struct _qemuMonitorPRManagerInfo qemuMonitorPRManagerInfo; struct _qemuMonitorPRManagerInfo { bool connected; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e00d785c20..f3efc3fe79 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8216,6 +8216,51 @@ qemuMonitorJSONGetSEVMeasurement(qemuMonitor *mon) } =20 =20 +/** + * Set a launch secret in guest memory + * + * Example JSON: + * + * { "execute" : "sev-inject-launch-secret", + * "data": { "packet-header": "str", "secret": "str", "gpa": "uint64" } } + * + * The guest physical address (gpa) parameter is optional + */ +int +qemuMonitorJSONSetLaunchSecurityState(qemuMonitor *mon, + const char *secrethdr, + const char *secret, + unsigned long long setaddr, + bool hasSetaddr) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + + if (hasSetaddr) { + cmd =3D qemuMonitorJSONMakeCommand("sev-inject-launch-secret", + "s:packet-header", secrethdr, + "s:secret", secret, + "U:gpa", setaddr, + NULL); + } else { + cmd =3D qemuMonitorJSONMakeCommand("sev-inject-launch-secret", + "s:packet-header", secrethdr, + "s:secret", secret, + NULL); + } + if (cmd =3D=3D NULL) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + return -1; + + return 0; +} + + /* * Example return data * diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 0984717675..8b9d3a2a77 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -369,6 +369,12 @@ int qemuMonitorJSONSystemWakeup(qemuMonitor *mon); =20 char *qemuMonitorJSONGetSEVMeasurement(qemuMonitor *mon); =20 +int qemuMonitorJSONSetLaunchSecurityState(qemuMonitor *mon, + const char *secrethdr, + const char *secret, + unsigned long long setaddr, + bool hasSetaddr); + int qemuMonitorJSONGetVersion(qemuMonitor *mon, int *major, int *minor, --=20 2.34.1