diff app/controllers/vncviewer_controller.php @ 1:eb4fee3d9bb8

added StoragePools management functions (storage_controller)
author Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp>
date Wed, 27 Jul 2011 00:00:25 +0900
parents 261e66bd5a0c
children
line wrap: on
line diff
--- a/app/controllers/vncviewer_controller.php	Sun Jul 24 21:08:31 2011 +0900
+++ b/app/controllers/vncviewer_controller.php	Wed Jul 27 00:00:25 2011 +0900
@@ -8,6 +8,7 @@
 	public static $ERROR_TABLE = array(
 				0 => "uuid is required to process this action",
 				1 => "vnc is not supported.",
+				2 => "domain is inactive.",
 			);
 
 	public function exec()
@@ -18,7 +19,12 @@
 
 		$con = WebVirtUtil::GetConnection();
 		$dom = libvirt_domain_lookup_by_uuid_string($con,$this->params['url']['uuid']);
-		$xml = simplexml_load_string(libvirt_domain_get_xml_desc($dom));
+		$info = libvirt_domain_get_info($dom);
+		if($info["state"] != VIR_DOMAIN_RUNNING){
+			$this->redirect(array("action" => "error","?" => array("e" => 2)),200,true);
+		}
+
+		$xml = simplexml_load_string(libvirt_domain_get_xml_desc($dom,null));
 
 		$port = -1;
 		foreach($xml->devices->graphics as $graphic){
@@ -41,7 +47,7 @@
 	{
 		if(isset($this->params["url"]["e"])){
 			$e = (int)$this->params["url"]["e"];
-			trigger_error(self::$ERROR_TABLE[$e]);
+			$this->set("content",self::$ERROR_TABLE[$e]);
 		}
 	}
 }