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

Re: [win-pv-devel] [PATCH] Handle ActiveLocationInformation value not found


  • To: Owen Smith <owen.smith@xxxxxxxxxx>, "win-pv-devel@xxxxxxxxxxxxxxxxxxxx" <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Paul Durrant <Paul.Durrant@xxxxxxxxxx>
  • Date: Tue, 20 Aug 2019 10:31:55 +0000
  • Accept-language: en-GB, en-US
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=Paul.Durrant@xxxxxxxxxx; spf=Pass smtp.mailfrom=Paul.Durrant@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Tue, 20 Aug 2019 10:32:04 +0000
  • Ironport-sdr: YENAFdlTfhKPt0mUVgsQ4KcmSZSeCxWOd6/BpnTQrq3cT3T7x8LiYrQAuvQrOXh0ePo0ihhapt 5jbVzTc9kA+076InDlTr7vmFym0nIwSe5Dy4NaFJrEB7X+q6B5Bc87+ebwAryH23mjAid76gey 8iK/uhdEX/E2vpF3zALuCvmChiy8AHDAA1hF/0oP9doHxhwe7W1HVfLl5bLsgrPnBTNNvA+5IB J4/yIHN0VbfncaSj5vJL1FQIRPMB0uH9XF0+7CKts8mNMR9kkVYTOG7AM1G4ucPjCPOfwaFoK9 KF0=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
  • Thread-index: AQHVVpo41VmAHsgu/EG+sBWbUwUR8qcD16yw
  • Thread-topic: [win-pv-devel] [PATCH] Handle ActiveLocationInformation value not found

> -----Original Message-----
> From: win-pv-devel <win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On Behalf Of 
> Owen Smith
> Sent: 19 August 2019 15:26
> To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Owen Smith <owen.smith@xxxxxxxxxx>
> Subject: [win-pv-devel] [PATCH] Handle ActiveLocationInformation value not 
> found
> 
> v8.2 drivers do not set ActiveLocationInformation, so when upgrading
> xenbus to v9.0, xenfilt fails during PdoSetDeviceInformation.
> 
> Allow xenfilt to handle missing ActiveLocationInformation, and make
> xenbus add ActiveLocationInformation and ActiveInstanceID, if missing,
> for the active device.
> 
> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>

Acked-by: Paul Durrant <paul.durrant@xxxxxxxxxx>

> ---
>  src/xenbus/driver.c | 84 
> +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  src/xenbus/driver.h |  7 +++++
>  src/xenbus/fdo.c    |  4 +++
>  src/xenfilt/pdo.c   | 15 +++++-----
>  4 files changed, 102 insertions(+), 8 deletions(-)
> 
> diff --git a/src/xenbus/driver.c b/src/xenbus/driver.c
> index c49a7de..a1c7b56 100644
> --- a/src/xenbus/driver.c
> +++ b/src/xenbus/driver.c
> @@ -532,6 +532,90 @@ fail1:
>      return status;
>  }
> 
> +NTSTATUS
> +DriverUpdateActive(
> +    IN  PCHAR   DeviceID,
> +    IN  PCHAR   InstanceID,
> +    IN  PCHAR   LocationInformation
> +    )
> +{
> +    HANDLE      ActiveKey;
> +    ANSI_STRING Ansi[2];
> +    PCHAR       ActiveInstanceID;
> +    PCHAR       ActiveLocationInformation;
> +    NTSTATUS    status;
> +
> +    Trace("====>\n");
> +
> +    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
> +
> +    status = RegistryOpenSubKey(NULL,
> +                                ACTIVE_PATH,
> +                                KEY_ALL_ACCESS,
> +                                &ActiveKey);
> +    if (!NT_SUCCESS(status))
> +        goto fail1;
> +
> +    status = STATUS_UNSUCCESSFUL;
> +    if (__DriverIsDeviceLegacy(DeviceID) &&
> +        __DriverIsVendorDevicePresent())
> +        goto fail2;
> +
> +    RtlZeroMemory(Ansi, sizeof (ANSI_STRING) * 2);
> +
> +    status = DriverGetActive("InstanceID", &ActiveInstanceID);
> +    if (NT_SUCCESS(status)) {
> +        ExFreePool(ActiveInstanceID);
> +    } else {
> +        RtlInitAnsiString(&Ansi[0], InstanceID);
> +
> +        status = RegistryUpdateSzValue(ActiveKey,
> +                                       "ActiveInstanceID",
> +                                       REG_SZ,
> +                                       Ansi);
> +        if (!NT_SUCCESS(status))
> +            goto fail3;
> +    }
> +
> +    status = DriverGetActive("LocationInformation", 
> &ActiveLocationInformation);
> +    if (NT_SUCCESS(status)) {
> +        ExFreePool(ActiveLocationInformation);
> +    } else {
> +        RtlInitAnsiString(&Ansi[0], LocationInformation);
> +
> +        status = RegistryUpdateSzValue(ActiveKey,
> +                                       "ActiveLocationInformation",
> +                                       REG_SZ,
> +                                       Ansi);
> +        if (!NT_SUCCESS(status))
> +            goto fail4;
> +    }
> +
> +    Info("%s\\%s: %s\n", DeviceID, InstanceID, LocationInformation);
> +
> +    RegistryCloseKey(ActiveKey);
> +
> +    Trace("<====\n");
> +
> +    return STATUS_SUCCESS;
> +
> +fail4:
> +    Error("fail4\n");
> +
> +fail3:
> +    Error("fail3\n");
> +
> +fail2:
> +    Error("fail2\n");
> +
> +    RegistryCloseKey(ActiveKey);
> +
> +fail1:
> +    Error("fail1 (%08x)\n", status);
> +
> +    return status;
> +}
> +
>  NTSTATUS
>  DriverClearActive(
>      VOID
> diff --git a/src/xenbus/driver.h b/src/xenbus/driver.h
> index 3875b42..55ec97b 100644
> --- a/src/xenbus/driver.h
> +++ b/src/xenbus/driver.h
> @@ -77,6 +77,13 @@ DriverSetActive(
>      IN  PCHAR   LocationInformation
>      );
> 
> +NTSTATUS
> +DriverUpdateActive(
> +    IN  PCHAR   DeviceID,
> +    IN  PCHAR   InstanceID,
> +    IN  PCHAR   LocationInformation
> +    );
> +
>  NTSTATUS
>  DriverClearActive(
>      VOID
> diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
> index 60201fc..7047f6a 100644
> --- a/src/xenbus/fdo.c
> +++ b/src/xenbus/fdo.c
> @@ -745,6 +745,10 @@ FdoSetActive(
>      status = DriverGetActive("DeviceID", &ActiveDeviceID);
>      if (NT_SUCCESS(status)) {
>          Fdo->Active = (_stricmp(DeviceID, ActiveDeviceID) == 0) ? TRUE : 
> FALSE;
> +
> +        if (Fdo->Active)
> +            (VOID) DriverUpdateActive(DeviceID, InstanceID, 
> LocationInformation);
> +
>          ExFreePool(ActiveDeviceID);
>      } else {
>          status = DriverSetActive(DeviceID, InstanceID, LocationInformation);
> diff --git a/src/xenfilt/pdo.c b/src/xenfilt/pdo.c
> index 9fba36c..37b4a45 100644
> --- a/src/xenfilt/pdo.c
> +++ b/src/xenfilt/pdo.c
> @@ -289,8 +289,13 @@ PdoSetDeviceInformation(
> 
>          status = DriverGetActive("LocationInformation",
>                                   &LocationInformation);
> -        if (!NT_SUCCESS(status))
> -            goto fail3;
> +        if (!NT_SUCCESS(status)) {
> +            status = DriverQueryDeviceText(Pdo->LowerDeviceObject,
> +                                           DeviceTextLocationInformation,
> +                                           &LocationInformation);
> +            if (!NT_SUCCESS(status))
> +                LocationInformation = NULL;
> +        }
>      } else {
>          status = DriverQueryId(Pdo->LowerDeviceObject,
>                                 BusQueryInstanceID,
> @@ -311,12 +316,6 @@ PdoSetDeviceInformation(
> 
>      return STATUS_SUCCESS;
> 
> -fail3:
> -    Error("fail3\n");
> -
> -    ASSERT(Pdo->Active);
> -    ExFreePool(InstanceID);
> -
>  fail2:
>      Error("fail2\n");
> 
> --
> 2.16.2.windows.1
> 
> 
> _______________________________________________
> win-pv-devel mailing list
> win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> https://lists.xenproject.org/mailman/listinfo/win-pv-devel
_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/win-pv-devel

 


Rackspace

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