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

[win-pv-devel] [PATCH v3] Add registry setting for removable capability of PDOs



From: Owen Smith <owen.smith-Sxgqhf6Nn4DQT0dZR+AlfA@xxxxxxxxxxxxxxxx>

Setting "Removable" to 0 under the key
HKLM/System/CurrentControlSet/services/XENBUS/Parameters/<PDO-Name>
will disable the PDOs removable and surprise removable capability.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 msbuild.bat      | 10 +++++++++-
 src/xenbus/pdo.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/msbuild.bat b/msbuild.bat
index 1b1fbc8..f3f10ac 100644
--- a/msbuild.bat
+++ b/msbuild.bat
@@ -1,7 +1,15 @@
 call "%VS%\VC\vcvarsall.bat" x86
 @echo on
-msbuild.exe /m:1 /p:Configuration="%CONFIGURATION%" /p:Platform="%PLATFORM%" 
/t:"%TARGET%" %EXTRA% %FILE%
+
+cov-build --dir cov_dir msbuild.exe /m:1 /p:Configuration="%CONFIGURATION%" 
/p:Platform="%PLATFORM%" /t:"%TARGET%" %EXTRA% %FILE%
+
 if errorlevel 1 goto error
+
+cov-analyze --dir cov_dir -j auto --aggressiveness-level high --security 
--concurrency --preview --all --rule --enable-fnptr --strip-path c:\git\xenbus
+
+cov-commit-defects --dir cov_dir --host dagu-4.uk.xensource.com --port 8080 
--user windows --password coverity --stream %PLATFORM%
+
+
 exit 0
 
 :error
diff --git a/src/xenbus/pdo.c b/src/xenbus/pdo.c
index ad0d4de..65f63e5 100644
--- a/src/xenbus/pdo.c
+++ b/src/xenbus/pdo.c
@@ -45,6 +45,7 @@
 #include "bus.h"
 #include "driver.h"
 #include "thread.h"
+#include "registry.h"
 #include "dbg_print.h"
 #include "assert.h"
 
@@ -64,6 +65,8 @@ struct _XENBUS_PDO {
     BOOLEAN                     Missing;
     const CHAR                  *Reason;
 
+    BOOLEAN                     Removable;
+
     PULONG                      Revision;
     ULONG                       Count;
 
@@ -254,6 +257,45 @@ PdoGetName(
     return __PdoGetName(Pdo);
 }
 
+static FORCEINLINE VOID
+__PdoSetRemovable(
+    IN  PXENBUS_PDO     Pdo
+    )
+{
+    HANDLE              ParametersKey;
+    HANDLE              Key;
+    ULONG               Value;
+    NTSTATUS            status;
+
+    Value = 1;
+
+    ParametersKey = DriverGetParametersKey();
+
+    status = RegistryOpenSubKey(ParametersKey,
+                                __PdoGetName(Pdo),
+                                KEY_READ,
+                                &Key);
+    if (!NT_SUCCESS(status))
+        goto done;
+
+    (VOID) RegistryQueryDwordValue(Key,
+                                   "Removable",
+                                   &Value);
+
+    RegistryCloseKey(Key);
+
+done:
+    Pdo->Removable = (Value != 0) ? TRUE : FALSE;
+}
+
+static FORCEINLINE BOOLEAN
+__PdoIsRemovable(
+    IN  PXENBUS_PDO     Pdo
+    )
+{
+    return Pdo->Removable;
+}
+
 static NTSTATUS
 PdoAddRevision(
     IN  PXENBUS_PDO Pdo,
@@ -1119,15 +1161,16 @@ PdoQueryCapabilities(
     Capabilities->DeviceD2 = 0;
     Capabilities->LockSupported = 0;
     Capabilities->EjectSupported = 0;
-    Capabilities->Removable = 1;
     Capabilities->DockDevice = 0;
     Capabilities->UniqueID = 1;
     Capabilities->SilentInstall = 1;
     Capabilities->RawDeviceOK = 0;
-    Capabilities->SurpriseRemovalOK = 1;
     Capabilities->HardwareDisabled = 0;
     Capabilities->NoDisplayInUI = 0;
 
+    Capabilities->Removable = __PdoIsRemovable(Pdo) ? 1 : 0;
+    Capabilities->SurpriseRemovalOK = Capabilities->Removable;
+
     Capabilities->Address = 0xffffffff;
     Capabilities->UINumber = 0xffffffff;
 
@@ -2092,6 +2135,7 @@ PdoCreate(
         goto fail4;
 
     __PdoSetName(Pdo, Name);
+    __PdoSetRemovable(Pdo);
 
     status = PdoSetRevisions(Pdo);
     if (!NT_SUCCESS(status))
@@ -2132,6 +2176,8 @@ fail6:
 fail5:
     Error("fail5\n");
 
+    Pdo->Removable = FALSE;
+
     ThreadAlert(Pdo->DevicePowerThread);
     ThreadJoin(Pdo->DevicePowerThread);
     Pdo->DevicePowerThread = NULL;
@@ -2196,6 +2242,8 @@ PdoDestroy(
     Pdo->Revision = NULL;
     Pdo->Count = 0;
 
+    Pdo->Removable = FALSE;
+
     ThreadAlert(Pdo->DevicePowerThread);
     ThreadJoin(Pdo->DevicePowerThread);
     Pdo->DevicePowerThread = NULL;
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

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