Revision: 18651
          http://sourceforge.net/p/edk2/code/18651
Author:   lersek
Date:     2015-10-21 12:44:12 +0000 (Wed, 21 Oct 2015)
Log Message:
-----------
OvmfPkg: XenPvBlkDxe: handle empty cdrom drives

Empty cdroms are not going to connect, avoid waiting for the backend to
switch to state 4, which is never going to happen, and return
error instead from XenPvBlockFrontInitialization(). Detect an
empty cdrom by looking at the "params" node on xenstore, which is set to
"" or "aio:" for empty drives by libxl.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Stefano Stabellini <[email protected]>
Reviewed-by: Laszlo Ersek <[email protected]>

Modified Paths:
--------------
    trunk/edk2/OvmfPkg/XenPvBlkDxe/BlockFront.c

Modified: trunk/edk2/OvmfPkg/XenPvBlkDxe/BlockFront.c
===================================================================
--- trunk/edk2/OvmfPkg/XenPvBlkDxe/BlockFront.c 2015-10-21 06:10:57 UTC (rev 
18650)
+++ trunk/edk2/OvmfPkg/XenPvBlkDxe/BlockFront.c 2015-10-21 12:44:12 UTC (rev 
18651)
@@ -169,6 +169,7 @@
   XEN_BLOCK_FRONT_DEVICE *Dev;
   XenbusState State;
   UINT64 Value;
+  CHAR8 *Params;
 
   ASSERT (NodeName != NULL);
 
@@ -186,6 +187,20 @@
   }
   FreePool (DeviceType);
 
+  if (Dev->MediaInfo.CdRom) {
+    Status = XenBusIo->XsBackendRead (XenBusIo, XST_NIL, "params", 
(VOID**)&Params);
+    if (Status != XENSTORE_STATUS_SUCCESS) {
+      DEBUG ((EFI_D_ERROR, "%a: Failed to read params (%d)\n", __FUNCTION__, 
Status));
+      goto Error;
+    }
+    if (AsciiStrLen (Params) == 0 || AsciiStrCmp (Params, "aio:") == 0) {
+      FreePool (Params);
+      DEBUG ((EFI_D_INFO, "%a: Empty cdrom\n", __FUNCTION__));
+      goto Error;
+    }
+    FreePool (Params);
+  }
+
   Status = XenBusReadUint64 (XenBusIo, "backend-id", FALSE, &Value);
   if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT16) {
     DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to get backend-id (%d)\n",


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to