From 78225bd90f7e2bc083c4b46d4b9fe8d28a0198bc Mon Sep 17 00:00:00 2001
From: Yi Li <yili@winhong.com>
Date: Thu, 7 Jan 2016 15:48:01 -0500
Subject: [PATCH] Don't Update the viridian flag for Linux.

Some HVM Linux OS can't boot When update viridian to true by guest tools.
The Viridian is just for Windows OS.

Signed-off-by: Yi Li <yili@winhong.com>
---
 ocaml/xapi/xapi_guest_agent.ml | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ocaml/xapi/xapi_guest_agent.ml b/ocaml/xapi/xapi_guest_agent.ml
index 5431f8a..5906e18 100644
--- a/ocaml/xapi/xapi_guest_agent.ml
+++ b/ocaml/xapi/xapi_guest_agent.ml
@@ -249,10 +249,16 @@ let all (lookup: string -> string option) (list: string -> string list) ~__conte
 	  (* Update the 'up to date' flag afterwards *)
 	  let gmr = Db.VM_guest_metrics.get_record_internal ~__context ~self:gm in
 	  let up_to_date = Xapi_pv_driver_version.is_up_to_date (Xapi_pv_driver_version.of_guest_metrics (Some gmr)) in
+	  let os_version = gmr.Db_actions.vM_guest_metrics_os_version in
+	  let is_windows =
+		try List.assoc "distro" os_version = "windows"
+		with Not_found -> false
+	  in
 	  Db.VM_guest_metrics.set_PV_drivers_up_to_date ~__context ~self:gm ~value:up_to_date;
 
 	  (* CA-18034: If viridian flag isn't in there and we have current PV drivers then shove it in the metadata for next boot... *)
-	  if up_to_date then begin
+	  (* HVM linux import from other platform has no viridian flag, Don't set it True, or Some hvm linux will boot hang.*)
+	  if up_to_date && is_windows then begin
 		  let platform = Db.VM.get_platform ~__context ~self in
 		  if not(List.mem_assoc Xapi_globs.viridian_key_name platform) then begin
 			  info "Setting VM %s platform:%s <- %s" (Ref.string_of self) Xapi_globs.viridian_key_name Xapi_globs.default_viridian_key_value;
-- 
1.7.12.4

