90 lines
3.2 KiB
Diff
90 lines
3.2 KiB
Diff
|
|
From cbc574f26c7fa7d107a2827ea335a13c4b253726 Mon Sep 17 00:00:00 2001
|
||
|
|
From: panpingsheng <panpingsheng@hygon.cn>
|
||
|
|
Date: Fri, 8 Sep 2023 15:04:44 +0800
|
||
|
|
Subject: [PATCH] conf: qemu: add libvirt support reuse id for hygon CSV
|
||
|
|
|
||
|
|
csv xml format:
|
||
|
|
<launchSecurity type='sev'>
|
||
|
|
<policy>0x0081</policy>
|
||
|
|
<cbitpos>47</cbitpos>
|
||
|
|
<reducedPhysBits>5</reducedPhysBits>
|
||
|
|
<userid>usertest</userid>
|
||
|
|
</launchSecurity>
|
||
|
|
|
||
|
|
Signed-off-by: panpingsheng <panpingsheng@hygon.cn>
|
||
|
|
Signed-off-by: Xin Jiang <jiangxin@hygon.cn>
|
||
|
|
Signed-off-by: hanliyang <hanliyang@hygon.cn>
|
||
|
|
---
|
||
|
|
src/conf/domain_conf.c | 5 +++++
|
||
|
|
src/conf/domain_conf.h | 1 +
|
||
|
|
src/qemu/qemu_command.c | 4 ++++
|
||
|
|
3 files changed, 10 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
||
|
|
index db49355788..2be4706b03 100644
|
||
|
|
--- a/src/conf/domain_conf.c
|
||
|
|
+++ b/src/conf/domain_conf.c
|
||
|
|
@@ -3828,6 +3828,7 @@ virDomainSecDefFree(virDomainSecDef *def)
|
||
|
|
case VIR_DOMAIN_LAUNCH_SECURITY_SEV:
|
||
|
|
g_free(def->data.sev.dh_cert);
|
||
|
|
g_free(def->data.sev.session);
|
||
|
|
+ g_free(def->data.sev.user_id);
|
||
|
|
break;
|
||
|
|
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||
|
|
case VIR_DOMAIN_LAUNCH_SECURITY_CVM:
|
||
|
|
@@ -13547,6 +13548,7 @@ virDomainSEVDefParseXML(virDomainSEVDef *def,
|
||
|
|
|
||
|
|
def->dh_cert = virXPathString("string(./dhCert)", ctxt);
|
||
|
|
def->session = virXPathString("string(./session)", ctxt);
|
||
|
|
+ def->user_id = virXPathString("string(./userid)", ctxt);
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
@@ -26613,6 +26615,9 @@ virDomainSecDefFormat(virBuffer *buf, virDomainSecDef *sec)
|
||
|
|
if (sev->session)
|
||
|
|
virBufferEscapeString(&childBuf, "<session>%s</session>\n", sev->session);
|
||
|
|
|
||
|
|
+ if (sev->user_id)
|
||
|
|
+ virBufferEscapeString(&childBuf, "<userid>%s</userid>\n", sev->user_id);
|
||
|
|
+
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
|
||
|
|
index a687895726..c06ac9552c 100644
|
||
|
|
--- a/src/conf/domain_conf.h
|
||
|
|
+++ b/src/conf/domain_conf.h
|
||
|
|
@@ -2873,6 +2873,7 @@ struct _virDomainSEVDef {
|
||
|
|
bool haveReducedPhysBits;
|
||
|
|
unsigned int reduced_phys_bits;
|
||
|
|
virTristateBool kernel_hashes;
|
||
|
|
+ char *user_id;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct _virDomainSecDef {
|
||
|
|
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
||
|
|
index 6e16e65d54..d4a0d73aae 100644
|
||
|
|
--- a/src/qemu/qemu_command.c
|
||
|
|
+++ b/src/qemu/qemu_command.c
|
||
|
|
@@ -9718,6 +9718,9 @@ qemuBuildSEVCommandLine(virDomainObj *vm, virCommand *cmd,
|
||
|
|
VIR_DEBUG("policy=0x%x cbitpos=%d reduced_phys_bits=%d",
|
||
|
|
sev->policy, sev->cbitpos, sev->reduced_phys_bits);
|
||
|
|
|
||
|
|
+ if (sev->user_id)
|
||
|
|
+ VIR_DEBUG("user_id=%s", sev->user_id);
|
||
|
|
+
|
||
|
|
if (sev->dh_cert)
|
||
|
|
dhpath = g_strdup_printf("%s/dh_cert.base64", priv->libDir);
|
||
|
|
|
||
|
|
@@ -9728,6 +9731,7 @@ qemuBuildSEVCommandLine(virDomainObj *vm, virCommand *cmd,
|
||
|
|
"u:cbitpos", sev->cbitpos,
|
||
|
|
"u:reduced-phys-bits", sev->reduced_phys_bits,
|
||
|
|
"u:policy", sev->policy,
|
||
|
|
+ "S:user-id", sev->user_id,
|
||
|
|
"S:dh-cert-file", dhpath,
|
||
|
|
"S:session-file", sessionpath,
|
||
|
|
"T:kernel-hashes", sev->kernel_hashes,
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|