]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: XenPvBlkDxe: handle empty cdrom drives
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>
Wed, 21 Oct 2015 12:44:12 +0000 (12:44 +0000)
committerlersek <lersek@Edk2>
Wed, 21 Oct 2015 12:44:12 +0000 (12:44 +0000)
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 <stefano.stabellini@eu.citrix.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18651 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/XenPvBlkDxe/BlockFront.c

index 256ac55f251538f0a089b4cfc029757a5f83f2ba..d07e980990562ed56c39b901abdeee2594373433 100644 (file)
@@ -169,6 +169,7 @@ XenPvBlockFrontInitialization (
   XEN_BLOCK_FRONT_DEVICE *Dev;\r
   XenbusState State;\r
   UINT64 Value;\r
+  CHAR8 *Params;\r
 \r
   ASSERT (NodeName != NULL);\r
 \r
@@ -186,6 +187,20 @@ XenPvBlockFrontInitialization (
   }\r
   FreePool (DeviceType);\r
 \r
+  if (Dev->MediaInfo.CdRom) {\r
+    Status = XenBusIo->XsBackendRead (XenBusIo, XST_NIL, "params", (VOID**)&Params);\r
+    if (Status != XENSTORE_STATUS_SUCCESS) {\r
+      DEBUG ((EFI_D_ERROR, "%a: Failed to read params (%d)\n", __FUNCTION__, Status));\r
+      goto Error;\r
+    }\r
+    if (AsciiStrLen (Params) == 0 || AsciiStrCmp (Params, "aio:") == 0) {\r
+      FreePool (Params);\r
+      DEBUG ((EFI_D_INFO, "%a: Empty cdrom\n", __FUNCTION__));\r
+      goto Error;\r
+    }\r
+    FreePool (Params);\r
+  }\r
+\r
   Status = XenBusReadUint64 (XenBusIo, "backend-id", FALSE, &Value);\r
   if (Status != XENSTORE_STATUS_SUCCESS || Value > MAX_UINT16) {\r
     DEBUG ((EFI_D_ERROR, "XenPvBlk: Failed to get backend-id (%d)\n",\r