Switch pointer gadget to non-blocking

Writes to the pointer gadget can hang if the host has no cursor. Using
non-blocking mode prevents this hanging. Also prevent repeated error
logging due to pointer write failures in this case.

Change-Id: I9c423a4a0af4b37a69ae20650b86a6266e5b4b41
Signed-off-by: Eddie James <eajames@linux.ibm.com>
diff --git a/ikvm_input.cpp b/ikvm_input.cpp
index fbe917b..202b761 100644
--- a/ikvm_input.cpp
+++ b/ikvm_input.cpp
@@ -23,6 +23,7 @@
 using namespace sdbusplus::xyz::openbmc_project::Common::File::Error;
 
 Input::Input(const std::string& kbdPath, const std::string& ptrPath) :
+    pointerError(false), sendKeyboard(false), sendPointer(false),
     keyboardFd(-1), pointerFd(-1), keyboardReport{0}, pointerReport{0},
     keyboardPath(kbdPath), pointerPath(ptrPath)
 {
@@ -42,7 +43,7 @@
 
     if (!pointerPath.empty())
     {
-        pointerFd = open(pointerPath.c_str(), O_RDWR | O_CLOEXEC);
+        pointerFd = open(pointerPath.c_str(), O_RDWR | O_CLOEXEC | O_NONBLOCK);
         if (pointerFd < 0)
         {
             log<level::ERR>("Failed to open input device",
@@ -218,8 +219,12 @@
         if (write(pointerFd, pointerReport, PTR_REPORT_LENGTH) !=
             PTR_REPORT_LENGTH)
         {
-            log<level::ERR>("Failed to write pointer report",
-                            entry("ERROR=%s", strerror(errno)));
+            if (!pointerError)
+            {
+                log<level::ERR>("Failed to write pointer report",
+                                entry("ERROR=%s", strerror(errno)));
+                pointerError = true;
+            }
         }
 
         sendPointer = false;