added booted?/boot methods
authorMartin Willi <martin@strongswan.org>
Tue, 7 Apr 2009 17:13:44 +0000 (17:13 -0000)
committerMartin Willi <martin@strongswan.org>
Tue, 7 Apr 2009 17:13:44 +0000 (17:13 -0000)
src/dumm/ext/lib/dumm.rb
src/dumm/ext/lib/dumm/guest.rb
src/dumm/mconsole.c

index d1450f5..ba1ccce 100644 (file)
@@ -28,7 +28,15 @@ module Dumm
     Bridge.each { |bridge|
       bridge.delete
     }
-    return nil
+    return Dumm
+  end
+  
+  # wait until all running guests have booted up
+  def boot
+    Guest.each {|g|
+           g.boot if g.running?
+    }
+    return Dumm
   end
 end
 
index a65a0a7..8f5abb5 100644 (file)
@@ -41,6 +41,23 @@ module Dumm
         i.delete
       }
     end
+    
+    # has the guest booted up?
+    def booted?
+      begin
+        exec("pgrep getty")
+      rescue
+        return false
+      end
+      return true
+    end
+    
+    # wait until the guest has booted
+    def boot
+      while not booted?
+        sleep(1)
+      end
+    end
   end
 end
 
index 02db5ab..72d6d1b 100644 (file)
@@ -147,8 +147,11 @@ static int request(private_mconsole_t *this, void(*cb)(void*,char*,size_t),
                        }
                        else if (reply.err)
                        {
-                               DBG1("received mconsole error %d: %*.s",
-                                        reply.err, reply.len, reply.data);
+                               if (reply.len && *reply.data)
+                               {
+                                       DBG1("received mconsole error %d: %*.s",
+                                                reply.err, reply.len, reply.data);
+                               }
                                break;
                        }
                }