Closed hector-cao closed 1 month ago
Thank you for reporting us your feedback!
The internal ticket has been created: https://warthogs.atlassian.net/browse/PEK-1286.
This message was autogenerated
More details after a deeper analysis:
When we create a TD with virsh create
, if the seclabel
is not specified in the configuration, libvirt will automatically generate seclabel
tags, for example given current configuration of the Ubuntu libvirt package, we use apparmor
, per consequence, we will find following tags in the TD conf (output of virsh edit <domain>
):
<seclabel type='dynamic' model='apparmor' relabel='yes'>
<label>libvirt-f4d02a54-6cd5-4e1a-be2b-7c5a2f3e06f4</label>
<imagelabel>libvirt-f4d02a54-6cd5-4e1a-be2b-7c5a2f3e06f4</imagelabel>
</seclabel>
When we reboot the TD with virsh reboot
, the seclabel tags are released, you can find here the call stack:
...
qemuProcessHandleShutdown
qemuProcessShutdownOrReboot
qemuProcessHardReboot
qemuProcessStop
qemuSecurityReleaseLabel / virSecurityManagerReleaseLabel
-> call hook: AppArmorReleaseSecurityLabel
When the TD is started again, libvirts checks the security driver tags and see the apparmor
seclabel has the model set to null
(because it has been freed). libvirt issues the error log and declares the TD reboot fails and destroys the TD.
To fix the issue, we can avoid releasing the seclabel tags if we are doing a hardReboot
(this reboot mode has been added especially for TDX
), here is the patch:
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 9471bbdb4..e1ede63c5 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8785,7 +8785,10 @@ void qemuProcessStop(virQEMUDriver *driver,
}
}
- qemuSecurityReleaseLabel(driver->securityManager, vm->def);
+ /** if hardReboot, do not release seclabel tags */
+ if (!priv->hardReboot) {
+ qemuSecurityReleaseLabel(driver->securityManager, vm->def);
+ }
/* clear all private data entries which are no longer needed */
qemuDomainObjPrivateDataClear(priv);
this issue has been fixed in the libvirt version 10.0.0-2ubuntu8.3+tdx1.2
, closing ...
Describe the bug
When we use the
tdvirsh
tool that comes along with this repo, we can successfully reboot the TD by issuingtdvirsh reboot <domain-id>
.However, if we use the traditionnal
virsh
tool, the TD does not reboot well and gets destroyed (disappears fromvirsh list --all
)We can see in the libvirtd log an error message:
To Reproduce
1) Use
virsh create <conf>
to create a TD Theconf
file is an instanciation of the template fileguest-tools/trust_domain.xml.template
with the variablesDOMAIN
andOVERLAY_IMG_PATH
set to appropriate values. 2) Usevirsh list --all
to confirm that the TD has been successfully created and is inrunning
state 3) Usevirsh console <id>
to wait for the TD to fully boot up (login prompt) 4) Usevirsh reboot <domain-id>
to reboot the TD 5) Check that the TD disappears usingvirsh list --all
NB: To reproduce the issue, it is important to wait for the TD to fully boot up (by using the step 3)
Expected behavior
virsh reboot
would successfully reboot the TDSystem report
Git ref
Operating system details
Kernel version
TDX kernel logs
TDX CPU instruction support
Model specific registers (MSRs)
CPU details
QEMU package details
Libvirt package details
OVMF package details
sgx-dcap-pccs package details
tdx-qgs package details
sgx-ra-service package details
sgx-pck-id-retrieval-tool package details
QGSD service status
PCCS service status
MPA registration logs (last 30 lines)