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

Re: [win-pv-devel] [PATCH 1/2] Add registry setting for removable capability of PDOs



> -----Original Message-----
> From: win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx [mailto:win-pv-devel-
> bounces@xxxxxxxxxxxxxxxxxxxx] On Behalf Of Paul Durrant
> Sent: 28 November 2014 14:29
> To: Owen Smith; win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Owen Smith
> Subject: Re: [win-pv-devel] [PATCH 1/2] Add registry setting for removable
> capability of PDOs
> 
> > -----Original Message-----
> > From: Owen Smith [mailto:owen.smith@xxxxxxxxxx]
> > Sent: 28 November 2014 13:37
> > To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> > Cc: Paul Durrant; Owen Smith
> > Subject: [PATCH 1/2] Add registry setting for removable capability of PDOs
> >
> > 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>
> > ---
> >  src/xenbus/pdo.c | 47
> > +++++++++++++++++++++++++++++++++++++++++++++--
> >  1 file changed, 45 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/xenbus/pdo.c b/src/xenbus/pdo.c
> > index ad0d4de..9e84ccd 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"
> >
> > @@ -61,6 +62,7 @@ struct _XENBUS_PDO {
> >      PIRP                        DevicePowerIrp;
> >
> >      PXENBUS_FDO                 Fdo;
> > +    BOOLEAN                     Removable;
> >      BOOLEAN                     Missing;
> >      const CHAR                  *Reason;
> >
> > @@ -1119,12 +1121,12 @@ PdoQueryCapabilities(
> >      Capabilities->DeviceD2 = 0;
> >      Capabilities->LockSupported = 0;
> >      Capabilities->EjectSupported = 0;
> > -    Capabilities->Removable = 1;
> > +    Capabilities->Removable = !!Pdo->Removable;
> >      Capabilities->DockDevice = 0;
> >      Capabilities->UniqueID = 1;
> >      Capabilities->SilentInstall = 1;
> >      Capabilities->RawDeviceOK = 0;
> > -    Capabilities->SurpriseRemovalOK = 1;
> > +    Capabilities->SurpriseRemovalOK = !!Pdo->Removable;
> >      Capabilities->HardwareDisabled = 0;
> >      Capabilities->NoDisplayInUI = 0;
> >
> > @@ -2041,6 +2043,43 @@ PdoSuspend(
> >      UNREFERENCED_PARAMETER(Pdo);
> >  }
> >
> > +static FORCEINLINE VOID
> > +__PdoReadRegistryFlags(
> > +    IN  PXENBUS_PDO     Pdo
> > +    )
> > +{
> > +    HANDLE              ParametersKey;
> > +    HANDLE              Key;
> > +    ULONG               Value;
> > +    NTSTATUS            status;
> > +
> > +    ParametersKey = DriverGetParametersKey();
> > +    if (ParametersKey == NULL)
> > +        goto fail1;
> > +
> > +    status = RegistryOpenSubKey(ParametersKey,
> > +                                __PdoGetName(Pdo),
> > +                                KEY_READ,
> > +                                &Key);
> > +    if (!NT_SUCCESS(status))
> > +        goto fail2;
> > +
> > +    status = RegistryQueryDwordValue(Key,
> > +                                     "Removable",
> > +                                     &Value);
> > +    if (!NT_SUCCESS(status))
> > +        Value = 1;
> > +
> > +    Pdo->Removable = !!Value;
> > +
> > +    RegistryCloseKey(Key);
> > +    return;
> > +
> > +fail2:
> > +fail1:
> > +    Pdo->Removable = TRUE;
> > +}
> > +
> >  NTSTATUS
> >  PdoCreate(
> >      IN  PXENBUS_FDO     Fdo,
> > @@ -2092,6 +2131,7 @@ PdoCreate(
> >          goto fail4;
> >
> >      __PdoSetName(Pdo, Name);
> > +    __PdoReadRegistryFlags(Pdo);
> 
> I'm not reading this once at creation time is necessarily a good idea - I 
> think it
> may cause problems with un-installation of the bus driver so it may be
> necessary to sample in the IRP handler so the flag can be dynamically
> adjusted. I'll re-work the patch myself.
> 

After offline discussion with Owen, I agree that reading once at creation time 
is ok so I'll post v3 which is the same as this code with some minor cosmetic 
tweaks.

  Paul

>   Paul
> 
> >
> >      status = PdoSetRevisions(Pdo);
> >      if (!NT_SUCCESS(status))
> > @@ -2132,6 +2172,8 @@ fail6:
> >  fail5:
> >      Error("fail5\n");
> >
> > +    Pdo->Removable = FALSE;
> > +
> >      ThreadAlert(Pdo->DevicePowerThread);
> >      ThreadJoin(Pdo->DevicePowerThread);
> >      Pdo->DevicePowerThread = NULL;
> > @@ -2195,6 +2237,7 @@ PdoDestroy(
> >      __PdoFree(Pdo->Revision);
> >      Pdo->Revision = NULL;
> >      Pdo->Count = 0;
> > +    Pdo->Removable = FALSE;
> >
> >      ThreadAlert(Pdo->DevicePowerThread);
> >      ThreadJoin(Pdo->DevicePowerThread);
> > --
> > 1.9.4.msysgit.1
> 
> 
> _______________________________________________
> win-pv-devel mailing list
> win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel

_______________________________________________
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®.