From c4171ad58f61f72f5f6c6c8e711a7bcc19d20f75 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 4 Sep 2012 15:34:35 +0100 Subject: shutdown: Add 'check_for_errors' hint along the shutdown path. This hint tells the backend whether anyone cares about errors when the appliance is shut down. Currently this only has any effect on the libvirt backend, where it controls whether or not we use the VIR_DOMAIN_DESTROY_GRACEFUL flag. --- src/launch-libvirt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/launch-libvirt.c') diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c index 04431641..37113633 100644 --- a/src/launch-libvirt.c +++ b/src/launch-libvirt.c @@ -1139,18 +1139,20 @@ ignore_errors (void *ignore, virErrorPtr ignore2) } static int -shutdown_libvirt (guestfs_h *g) +shutdown_libvirt (guestfs_h *g, int check_for_errors) { virConnectPtr conn = g->virt.connv; virDomainPtr dom = g->virt.domv; int ret = 0; + int flags; /* Note that we can be called back very early in launch (specifically * from launch_libvirt itself), when conn and dom might be NULL. */ if (dom != NULL) { - if (virDomainDestroyFlags (dom, VIR_DOMAIN_DESTROY_GRACEFUL) == -1) { + flags = check_for_errors ? VIR_DOMAIN_DESTROY_GRACEFUL : 0; + if (virDomainDestroyFlags (dom, flags) == -1) { libvirt_error (g, _("could not destroy libvirt domain")); ret = -1; } @@ -1220,7 +1222,7 @@ launch_libvirt (guestfs_h *g, const char *arg) } static int -shutdown_libvirt (guestfs_h *g) +shutdown_libvirt (guestfs_h *g, int check_for_errors) { NOT_IMPL (-1); } -- cgit