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 <nshirokovskiy@virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Nikolay Shirokovskiy 2022-02-14 15:19:51 +03:00 committed by Nikolay Shirokovskiy
parent 5e9d8f094c
commit ce3f707af5
2 changed files with 7 additions and 0 deletions

View File

@ -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,

View File

@ -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