From nobody Mon Feb 9 07:57:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606762701; cv=none; d=zohomail.com; s=zohoarc; b=ToOiCRb25b1aK8x7+aNsd0oKTGgB0O96iNhzuxReTSfE7imhDmb+4fdyQmn0Eg73L+5GriilbyI02uP3oUwndbUG3Pgu1B8NdOdw7ZFjyc9Oqe5J3ACQ42jHomfbBQJzO09Jfl0uR9U8yu1MjrgGwfb/vZDTVEbR3Pb9Ea6TOT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606762701; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bj7BR1JheP4sQm/ShDeKb+vxqpAZzUFoQjR92knbdSQ=; b=O5DUR6l2mNjzZSyD8ruY+kJlum67HV2uOCG+Pqb4TL5o52tGtULTgw8/HLNMQ+hxInWELl0VPx0Lb+YReZwE11CoUTyZxdwL5pszENw+JxYGxT8/+cpHSdRuzJLjeiRs+lbENmScuWo4QYSSrmcdM/2xf0S8JjMxCPtEcMeCpUA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1606762701764290.71890392664227; Mon, 30 Nov 2020 10:58:21 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-AKE9aDJ6OyuRxu3hgPDkYw-1; Mon, 30 Nov 2020 13:56:21 -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 B9A361005E4D; Mon, 30 Nov 2020 18:56:08 +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 9993B63BA7; Mon, 30 Nov 2020 18:56:08 +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 652731809CA3; Mon, 30 Nov 2020 18:56:08 +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 0AUIu5b7014343 for ; Mon, 30 Nov 2020 13:56:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 45A7C60C69; Mon, 30 Nov 2020 18:56:05 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BBC860C67 for ; Mon, 30 Nov 2020 18:56:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606762700; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bj7BR1JheP4sQm/ShDeKb+vxqpAZzUFoQjR92knbdSQ=; b=eGgSiT4K0IPf4yywV4DcFc2KZR8FiiX2lSCpAKT6oCfLY7v+ZyDRmq1wb7+1czcR2ZmI01 J56KTEK1nJAdwcO+lpnHzsFoy9JWnPlhYNWcWaeCfSUz7VgOj3Bg+H5Aln6POAJJPd0QgE IeDtnLZw3jslOBV/oQUGkmcZQqXE1BM= X-MC-Unique: AKE9aDJ6OyuRxu3hgPDkYw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/24] qemu: command: Generate commandline of 'sev0' sev-guest object via JSON Date: Mon, 30 Nov 2020 19:55:27 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" While the 'sev0' sev-guest object will never be hotplugged, but we want to generate it through JSON so that we'll be able to validate all parameters of '-object' against the QAPI schema once 'object-add' is qapified in qemu. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 32 +++++++++++-------- ...v-missing-platform-info.x86_64-2.12.0.args | 2 +- .../launch-security-sev.x86_64-2.12.0.args | 2 +- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 86b3c3d642..feec884e85 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9341,9 +9341,11 @@ static int qemuBuildSEVCommandLine(virDomainObjPtr vm, virCommandPtr cmd, virDomainSEVDefPtr sev) { + g_autoptr(virJSONValue) props =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; qemuDomainObjPrivatePtr priv =3D vm->privateData; - char *path =3D NULL; + g_autofree char *dhpath =3D NULL; + g_autofree char *sessionpath =3D NULL; if (!sev) return 0; @@ -9351,21 +9353,23 @@ qemuBuildSEVCommandLine(virDomainObjPtr vm, virComm= andPtr cmd, VIR_DEBUG("policy=3D0x%x cbitpos=3D%d reduced_phys_bits=3D%d", sev->policy, sev->cbitpos, sev->reduced_phys_bits); - virBufferAsprintf(&buf, "sev-guest,id=3Dsev0,cbitpos=3D%d", sev->cbitp= os); - virBufferAsprintf(&buf, ",reduced-phys-bits=3D%d", sev->reduced_phys_b= its); - virBufferAsprintf(&buf, ",policy=3D0x%x", sev->policy); + if (sev->dh_cert) + dhpath =3D g_strdup_printf("%s/dh_cert.base64", priv->libDir); - if (sev->dh_cert) { - path =3D g_strdup_printf("%s/dh_cert.base64", priv->libDir); - virBufferAsprintf(&buf, ",dh-cert-file=3D%s", path); - VIR_FREE(path); - } + if (sev->session) + sessionpath =3D g_strdup_printf("%s/session.base64", priv->libDir); - if (sev->session) { - path =3D g_strdup_printf("%s/session.base64", priv->libDir); - virBufferAsprintf(&buf, ",session-file=3D%s", path); - VIR_FREE(path); - } + if (qemuMonitorCreateObjectProps(&props, "sev-guest", "sev0", + "u:cbitpos", sev->cbitpos, + "u:reduced-phys-bits", sev->reduced_p= hys_bits, + "u:policy", sev->policy, + "S:dh-cert-file", dhpath, + "S:session-file", sessionpath, + NULL) < 0) + return -1; + + if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0) + return -1; virCommandAddArg(cmd, "-object"); virCommandAddArgBuffer(cmd, &buf); diff --git a/tests/qemuxml2argvdata/launch-security-sev-missing-platform-in= fo.x86_64-2.12.0.args b/tests/qemuxml2argvdata/launch-security-sev-missing-= platform-info.x86_64-2.12.0.args index 378c3b681c..9fad85737a 100644 --- a/tests/qemuxml2argvdata/launch-security-sev-missing-platform-info.x86_= 64-2.12.0.args +++ b/tests/qemuxml2argvdata/launch-security-sev-missing-platform-info.x86_= 64-2.12.0.args @@ -29,7 +29,7 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --object sev-guest,id=3Dsev0,cbitpos=3D47,reduced-phys-bits=3D1,policy=3D0x= 1,\ +-object sev-guest,id=3Dsev0,cbitpos=3D47,reduced-phys-bits=3D1,policy=3D1,\ dh-cert-file=3D/tmp/lib/domain--1-QEMUGuest1/dh_cert.base64,\ session-file=3D/tmp/lib/domain--1-QEMUGuest1/session.base64 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ diff --git a/tests/qemuxml2argvdata/launch-security-sev.x86_64-2.12.0.args = b/tests/qemuxml2argvdata/launch-security-sev.x86_64-2.12.0.args index 378c3b681c..9fad85737a 100644 --- a/tests/qemuxml2argvdata/launch-security-sev.x86_64-2.12.0.args +++ b/tests/qemuxml2argvdata/launch-security-sev.x86_64-2.12.0.args @@ -29,7 +29,7 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ --object sev-guest,id=3Dsev0,cbitpos=3D47,reduced-phys-bits=3D1,policy=3D0x= 1,\ +-object sev-guest,id=3Dsev0,cbitpos=3D47,reduced-phys-bits=3D1,policy=3D1,\ dh-cert-file=3D/tmp/lib/domain--1-QEMUGuest1/dh_cert.base64,\ session-file=3D/tmp/lib/domain--1-QEMUGuest1/session.base64 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ --=20 2.28.0