From ce3f707af51b95251992d5cdfd825f93b5564ea8 Mon Sep 17 00:00:00 2001 From: Nikolay Shirokovskiy Date: Mon, 14 Feb 2022 15:19:51 +0300 Subject: [PATCH] libvirt: introduce VIR_DOMAIN_DESTROY_REMOVE_LOGS flag If this flag is set on calling virDomainDestroyFlags flags then remove per domain logs if possible. This can be used by libguestfs to delete logs for temporary domain. Otherwise such logs will stay wasting disk resources. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Michal Privoznik --- include/libvirt/libvirt-domain.h | 1 + src/libvirt-domain.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 2d5718301e..1275f4530d 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1237,6 +1237,7 @@ int virDomainDestroy (virDomainPtr domain); typedef enum { VIR_DOMAIN_DESTROY_DEFAULT = 0, /* Default behavior - could lead to data loss!! */ VIR_DOMAIN_DESTROY_GRACEFUL = 1 << 0, /* only SIGTERM, no SIGKILL */ + VIR_DOMAIN_DESTROY_REMOVE_LOGS = 1 << 1, /* remove VM logs on destroy */ } virDomainDestroyFlagsValues; int virDomainDestroyFlags (virDomainPtr domain, diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 53efb60406..cbd7902d2d 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -524,6 +524,12 @@ virDomainDestroy(virDomainPtr domain) * timeout; at that time, the management application can decide if * calling again without VIR_DOMAIN_DESTROY_GRACEFUL is appropriate. * + * If VIR_DOMAIN_DESTROY_REMOVE_LOGS flag is set then domain specific + * logs will be deleted as well if there are any. Note that not all + * deployments are be supported. For example in case of QEMU driver + * this flags is noop if virtlogd is not used for handling QEMU + * process output. + * * Another alternative which may produce cleaner results for the * guest's disks is to use virDomainShutdown() instead, but that * depends on guest support (some hypervisor/guest combinations may