[PATCH 3/3] tools: support --remove-logs flag on destroing domain

Nikolay Shirokovskiy nshirokovskiy at virtuozzo.com
Mon Feb 14 12:19:53 UTC 2022


Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy at virtuozzo.com>
---
 docs/manpages/virsh.rst | 7 ++++++-
 tools/virsh-domain.c    | 8 +++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index dd534c10cb..6946d033d5 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -1563,7 +1563,7 @@ destroy
 
 ::
 
-   destroy domain [--graceful]
+   destroy domain [--graceful] [--remove-logs]
 
 Immediately terminate the domain *domain*.  This doesn't give the domain
 OS any chance to react, and it's the equivalent of ripping the power
@@ -1582,6 +1582,11 @@ If *--graceful* is specified, don't resort to extreme measures
 (e.g. SIGKILL) when the guest doesn't stop after a reasonable timeout;
 return an error instead.
 
+If *--remove-logs* is specified, remove per *domain* log files. Not all
+deployment configuration can be supported.
+
+In case of QEMU the flag is only supported if virlogd is used to handle QEMU
+process output. Otherwise the flag is ignored.
 
 
 domblkerror
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index b56f6a90f5..72e05b71a1 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -8220,6 +8220,10 @@ static const vshCmdOptDef opts_destroy[] = {
      .type = VSH_OT_BOOL,
      .help = N_("terminate gracefully")
     },
+    {.name = "remove-logs",
+     .type = VSH_OT_BOOL,
+     .help = N_("remove domain logs")
+    },
     {.name = NULL}
 };
 
@@ -8236,9 +8240,11 @@ cmdDestroy(vshControl *ctl, const vshCmd *cmd)
 
     if (vshCommandOptBool(cmd, "graceful"))
        flags |= VIR_DOMAIN_DESTROY_GRACEFUL;
+    if (vshCommandOptBool(cmd, "remove-logs"))
+       flags |= VIR_DOMAIN_DESTROY_REMOVE_LOGS;
 
     if (flags)
-       result = virDomainDestroyFlags(dom, VIR_DOMAIN_DESTROY_GRACEFUL);
+       result = virDomainDestroyFlags(dom, flags);
     else
        result = virDomainDestroy(dom);
 
-- 
2.31.1




More information about the libvir-list mailing list