mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-31 17:05:16 +00:00
qemu_tpm: do not delete parent directory for custom source
When the vTPM source path is specified, such as: <source type=".." path="/my/tpm"/> Do not delete the parent directory, but only the given file/dir. Fixes: commit f1304cc566 ("qemu_tpm: handle file/block storage source") Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Tested-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
958283a21f
commit
062a2c07cc
@ -214,9 +214,31 @@ qemuTPMEmulatorCreateStorage(virDomainTPMDef *tpm,
|
||||
static void
|
||||
qemuTPMEmulatorDeleteStorage(virDomainTPMDef *tpm)
|
||||
{
|
||||
g_autofree char *path = g_path_get_dirname(tpm->data.emulator.source_path);
|
||||
const char *source_path = tpm->data.emulator.source_path;
|
||||
|
||||
ignore_value(virFileDeleteTree(path));
|
||||
switch (tpm->data.emulator.source_type) {
|
||||
case VIR_DOMAIN_TPM_SOURCE_TYPE_FILE: {
|
||||
if (unlink(source_path) && errno != ENOENT)
|
||||
virReportSystemError(errno,
|
||||
_("Cannot delete file '%1$s'"),
|
||||
source_path);
|
||||
break;
|
||||
}
|
||||
|
||||
case VIR_DOMAIN_TPM_SOURCE_TYPE_DIR: {
|
||||
ignore_value(virFileDeleteTree(source_path));
|
||||
break;
|
||||
}
|
||||
|
||||
case VIR_DOMAIN_TPM_SOURCE_TYPE_DEFAULT:
|
||||
case VIR_DOMAIN_TPM_SOURCE_TYPE_LAST:
|
||||
default: {
|
||||
g_autofree char *vm_uuid_dir = g_path_get_dirname(source_path);
|
||||
|
||||
ignore_value(virFileDeleteTree(vm_uuid_dir));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user