xc_domain_save: Do not poll-wait for guest to shutdown -- it should
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 9 Sep 2008 14:33:27 +0000 (15:33 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 9 Sep 2008 14:33:27 +0000 (15:33 +0100)
already be suspended when the (*suspend)() function returns.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
tools/libxc/xc_domain_save.c

index dae4a75df9adc345fef3a415084097db3880893c..c6e1c23c32ddc6394610865be152c68043506551 100644 (file)
@@ -341,69 +341,20 @@ static int analysis_phase(int xc_handle, uint32_t domid, int p2m_size,
 static int suspend_and_state(int (*suspend)(void), int xc_handle, int io_fd,
                              int dom, xc_dominfo_t *info)
 {
-    int i = 0;
-
     if ( !(*suspend)() )
     {
         ERROR("Suspend request failed");
         return -1;
     }
 
- retry:
-
-    if ( xc_domain_getinfo(xc_handle, dom, 1, info) != 1 )
-    {
-        ERROR("Could not get domain info");
-        return -1;
-    }
-
-    if ( info->dying )
+    if ( (xc_domain_getinfo(xc_handle, dom, 1, info) != 1) ||
+         !info->shutdown || (info->shutdown_reason != SHUTDOWN_suspend) )
     {
-        ERROR("domain is dying");
+        ERROR("Domain not in suspended state");
         return -1;
     }
 
-    if ( info->crashed )
-    {
-        ERROR("domain has crashed");
-        return -1;
-    }
-
-    if ( info->shutdown )
-    {
-        switch ( info->shutdown_reason )
-        {
-        case SHUTDOWN_poweroff:
-        case SHUTDOWN_reboot:
-            ERROR("domain has shut down");
-            return -1;
-        case SHUTDOWN_suspend:
-            return 0;
-        case SHUTDOWN_crash:
-            ERROR("domain has crashed");
-            return -1;
-        }
-    }
-
-    if ( info->paused )
-    {
-        /* Try unpausing domain, wait, and retest. */
-        xc_domain_unpause( xc_handle, dom );
-        ERROR("Domain was paused. Wait and re-test.");
-        usleep(10000); /* 10ms */
-        goto retry;
-    }
-
-    if ( ++i < 100 )
-    {
-        ERROR("Retry suspend domain");
-        usleep(10000); /* 10ms */
-        goto retry;
-    }
-
-    ERROR("Unable to suspend domain.");
-
-    return -1;
+    return 0;
 }
 
 /*