[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH] throw HOST_CD_DRIVE_EMPTY if a disk attach failure occurs because of a missing CD



# HG changeset patch
# User David Scott <dave.scott@xxxxxxxxxxxxx>
# Date 1270636583 -3600
# Node ID 70508d7c64f84da1c1715abaada403f8aaf0a7b8
# Parent  9dd35e413e35877280587431cd367f81f4979fa5
CA-39745: When a failure to hotplug a disk is detected, check whether the 
underlying device was a physical CDROM with an empty drive. In this case throw 
HOST_CD_DRIVE_EMPTY.

Signed-off-by: David Scott <dave.scott@xxxxxxxxxxxxx>

diff -r 9dd35e413e35 -r 70508d7c64f8 ocaml/idl/api_errors.ml
--- a/ocaml/idl/api_errors.ml   Wed Apr 07 11:35:06 2010 +0100
+++ b/ocaml/idl/api_errors.ml   Wed Apr 07 11:36:23 2010 +0100
@@ -167,6 +167,7 @@
 let vdi_is_a_physical_device = "VDI_IS_A_PHYSICAL_DEVICE"
 let vdi_is_not_iso = "VDI_IS_NOT_ISO"
 let vbd_cds_must_be_readonly = "VBD_CDS_MUST_BE_READONLY"
+let host_cd_drive_empty = "HOST_CD_DRIVE_EMPTY"
 let vdi_not_available = "VDI_NOT_AVAILABLE"
 let vdi_location_missing = "VDI_LOCATION_MISSING"
 let vdi_missing = "VDI_MISSING"
diff -r 9dd35e413e35 -r 70508d7c64f8 ocaml/idl/datamodel.ml
--- a/ocaml/idl/datamodel.ml    Wed Apr 07 11:35:06 2010 +0100
+++ b/ocaml/idl/datamodel.ml    Wed Apr 07 11:36:23 2010 +0100
@@ -709,6 +709,8 @@
     ~doc:"The operation cannot be performed on physical device" ();
   error Api_errors.vdi_is_not_iso [ "vdi"; "type" ]
     ~doc:"This operation can only be performed on CD VDIs (iso files or CDROM 
drives)" ();
+  error Api_errors.host_cd_drive_empty [ ]
+         ~doc:"The host CDROM drive does not contain a valid CD" ();
   error Api_errors.vdi_in_use [ "vdi"; "operation" ]
     ~doc:"This operation cannot be performed because this VDI is in use by 
some other operation" ();
   error Api_errors.vdi_not_available [ "vdi" ]
diff -r 9dd35e413e35 -r 70508d7c64f8 ocaml/xapi/xapi_xenops_errors.ml
--- a/ocaml/xapi/xapi_xenops_errors.ml  Wed Apr 07 11:35:06 2010 +0100
+++ b/ocaml/xapi/xapi_xenops_errors.ml  Wed Apr 07 11:36:23 2010 +0100
@@ -48,6 +48,8 @@
       Server_error(internal_error, [ sprintf "device model failed to 
initialise: %s" msg ])
   | Device.Ioemu_failed_dying ->
       Server_error(internal_error, [ "internal error waiting for device model 
to stop (for either shutdown or suspend)" ])
+  | Device.Cdrom ->
+               Server_error(host_cd_drive_empty, [])
        
   | Domain.Restore_signature_mismatch ->
       Server_error(internal_error, [ "restore file signature mismatch: has 
suspend image been corrupted?" ])
diff -r 9dd35e413e35 -r 70508d7c64f8 ocaml/xenops-ts/OMakefile
--- a/ocaml/xenops-ts/OMakefile Wed Apr 07 11:35:06 2010 +0100
+++ b/ocaml/xenops-ts/OMakefile Wed Apr 07 11:36:23 2010 +0100
@@ -3,6 +3,6 @@
 OCAML_CLIBS      += $(XEN_OCAML_CLIBS)
 OCAML_LINK_FLAGS += $(XEN_OCAML_LINK_FLAGS)
 CFLAGS           += $(XEN_CFLAGS)
-OCAMLPACKS          = xc xs stdext log
+OCAMLPACKS          = xc xs stdext log cdrom
 
 OCamlProgram(runtest, runtest test ../xenops/xenvmlib)
diff -r 9dd35e413e35 -r 70508d7c64f8 ocaml/xenops/OMakefile
--- a/ocaml/xenops/OMakefile    Wed Apr 07 11:35:06 2010 +0100
+++ b/ocaml/xenops/OMakefile    Wed Apr 07 11:36:23 2010 +0100
@@ -4,7 +4,7 @@
 OCAML_LINK_FLAGS+= $(XEN_OCAML_LINK_FLAGS)
 CFLAGS          += $(XEN_CFLAGS)
 
-OCAMLPACKS     = threads xc xs stdext log
+OCAMLPACKS     = threads xc xs stdext log cdrom
 OCAMLFLAGS    += -thread
 
 LIBFILES = xenops_helpers xenbus balloon xenguestHelper domain hotplug device 
io statdev xal netman memory watch device_common squeeze squeeze_xen 
squeezed_rpc squeezed_state squeezed_rpc
diff -r 9dd35e413e35 -r 70508d7c64f8 ocaml/xenops/device.ml
--- a/ocaml/xenops/device.ml    Wed Apr 07 11:35:06 2010 +0100
+++ b/ocaml/xenops/device.ml    Wed Apr 07 11:36:23 2010 +0100
@@ -28,6 +28,8 @@
 exception Pause_token_mismatch
 exception Device_not_paused
 exception Device_not_found
+
+exception Cdrom
 
 module D = Debug.Debugger(struct let name = "xenops" end)
 open D
@@ -579,6 +581,20 @@
            debug "Caught Frontend_device_error: assuming it is safe to 
shutdown the backend";
            clean_shutdown ~xs device; (* assumes double-failure isn't possible 
*)
            release ~xs device;
+               (* Attempt to diagnose the error: the error from blkback ("2 
creating vbd structure")
+                  doesn't give much away. *)
+               if phystype = Phys then begin
+                 try
+                       (* Speculatively query the physical device as if a 
CDROM *)
+                         match Cdrom.query_cdrom_drive_status physpath with
+                         | Cdrom.DISC_OK -> () (* nothing unusual here *)
+                         | x -> 
+                                       error "CDROM device %s: %s" physpath 
(Cdrom.string_of_cdrom_drive_status x);
+                                       raise Cdrom
+                 with 
+                 | Cdrom as e' -> raise e'
+                 | _ -> () (* assume it wasn't a CDROM *)
+               end;
            raise e
        end;
        device
diff -r 9dd35e413e35 -r 70508d7c64f8 ocaml/xenops/device.mli
--- a/ocaml/xenops/device.mli   Wed Apr 07 11:35:06 2010 +0100
+++ b/ocaml/xenops/device.mli   Wed Apr 07 11:36:23 2010 +0100
@@ -21,6 +21,8 @@
 exception Pause_token_mismatch
 exception Device_not_paused
 exception Device_not_found
+
+exception Cdrom
 
 module Generic :
 sig
7 files changed, 25 insertions(+), 2 deletions(-)
ocaml/idl/api_errors.ml          |    1 +
ocaml/idl/datamodel.ml           |    2 ++
ocaml/xapi/xapi_xenops_errors.ml |    2 ++
ocaml/xenops-ts/OMakefile        |    2 +-
ocaml/xenops/OMakefile           |    2 +-
ocaml/xenops/device.ml           |   16 ++++++++++++++++
ocaml/xenops/device.mli          |    2 ++


Attachment: xen-api.hg.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.