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

RE: [PATCH 4/6] Add emulated type override per device ID


  • To: "paul@xxxxxxx" <paul@xxxxxxx>, "win-pv-devel@xxxxxxxxxxxxxxxxxxxx" <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Mon, 21 Jun 2021 15:36:51 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l0RAHzJQ4BSan3rNslM4yEmsd+wnEzElqEJcB4zT5Ds=; b=YqATkVcAO7lcA5WT51luU2sRGST4+jpME7PHfsexuKVFr2n31RcYSQRPg4F2eyNVxOa1asMxvMXS5gt7qMd9Ha6CE1bhQVS64pX0w+YwXHumF0O343KmQCcj/4FqqTE+7jt4ocUV8N19HfSzUZbDnhRm2fgM/DzOYwPUh1/9DCXGP9zSmpao+KyPViTrsFsGDo10rFVAqYI7QfIqDvQN/mDTuhvna0X1/dgCbQFFdvqZZqc6IQ91u3zt9rK0lKG18X8Yjk93n3fLy9OPaxcz7HW53kRUYw1gK+vvuuAJpmD7ZdX5OkRoBolo6KtnXkEP2e8fhjCQxPS6R+j5I5v64Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lp22Vfr/N6O+TobgGLcMBiy/3uG3UpANIiEXHESJlT9GTSjKupul/YCXHeMmi+WAPnmXM5VyCayjnds81x29AQBybO0NMOafi+VFn0YIe4osgkegAUimUETTgcgybl8tHvUKDHIvcbfUccmmpNL2qpNp6nVVZz9zM40sWZNPg+V5j0Ixz5Yq7V4SKXX1l041+5UfhD9OPqmavxtWvy6drAXQlpeuRJS2RWQowWVbgVQw3SR93IcrJTHKQsbzdI5KwaYKaY3Pm23d2Hgq+VLJKCQ6zIxaUVwEw1Mj+KzDOCt4DkkakiB4z+gGS/3cJeooVNaBM/kjyapEvBBdKiJAYw==
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Delivery-date: Mon, 21 Jun 2021 15:36:59 +0000
  • Ironport-hdrordr: A9a23:R6KItKA3XrNk7kDlHeglsceALOsnbusQ8zAXPh9KJiC9I/b1qy nxppkmPEfP+UwssQIb6K290c67MDzhHP9OkMUs1NKZMjUO11HYSr2KgbGSoAEIXheOjdK1tp 0QPZSWaueAdGSS5PySiGLTcrYdKZu8gdiVbI/lvi9QpGpRGsRdBnJCe2Gm+zpNNW177PQCZf ihz/sCgwDlVWUcb8y9CHVAdfPEvcf3mJXvZgNDLwI76SGV5AnYqYLSIly95FMzQjlPybAt/S zuiAri/JiutPm911v1y3LT1ZJLg9Hso+EzRPBky/JlaQkEuDzYIbiJaIfy+AzdZ9vfr2rCpe O84SvI+f4DrU85MFvF+CcFkDOQrArGo0WStmNwx0GT+vARDQhKdfZplMZXdADU5FEnu8w52K VX33iBv54SFh/Ymj/hjuK4Hy2Cu3DE10bKq9RjxkC3kLFuHYN5vMga5gdYAZ0AFCX15MQuF/ RvFtjV4LJTfUmBZ37Us2FzyJj0N05DVCuuUwwHoIiYwjJWlHd2ww8Rw9EehG4J8NY4R4Nf7+ rJP6x0nPVFT9MQb6h6GOAdKPHHQVAlgSi8R156BG6XWZ3vF0i92KIf0Y9FkN1CIqZ4vKfasK 6xIm+wm1RCCn7TNQ==
  • Ironport-sdr: ZumQcb6ghB7W/5+ugXgKKmI+QACa9n2AydOUZUACYR3QHu5CtrF+V6OfmyyR9ZJB/OtIDyyfAk L/78Ms1ydi6aT9u2wHBD77ldm/YecmyJCRMjH1MeQONioZv/jHiMPbhoYCPsNmkrhkluQHU3RN eAavs12YRnt61sPQkSjDw+PoUTvzB2WbzEZm8IXkYFtIfh+rA0QKSbb9CHhvTGwkAASDHIDq0f aPBGCzKc5sUm8av6ccgASllTzNdGNMi7O+pNaPF0CK7xuD2Oh2eb3lp2RBlI6KrkG9XndAEMi9 Qos=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
  • Thread-index: AQHXY3UR5WYpS/Vu8kORMlgE0RWa2qseg9MAgAAawIA=
  • Thread-topic: [PATCH 4/6] Add emulated type override per device ID

-----Original Message-----
From: win-pv-devel <win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On Behalf Of 
Paul Durrant
Sent: Monday, June 21, 2021 2:57 PM
To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
Subject: Re: [PATCH 4/6] Add emulated type override per device ID

[CAUTION - EXTERNAL EMAIL] DO NOT reply, click links, or open attachments 
unless you have verified the sender and know the content is safe.

On 17/06/2021 13:33, Owen Smith wrote:
> Add the option to override a device nodes emulated type for a specific 
> device ID, and adds the NVME type.
> Specific HardwareIDs may be associated with a more specific type than 
> 'Device'.
> Add a way of specifying a particular HardwareID as an emulated NVMe 
> controller so that when XenVbd queries if a disk is present, XenFilt 
> can respond correctly if either its emulated IDE disk or emulated NVMe disk 
> is present.
> Certain upgrade situations could leave the unplug key empty (so the 
> emulated NVMe device is in use), and this could lead to XenVbd not 
> identifying the emulated NVMe disk and proceeding to connect to the 
> backend (which could already be in use by the emulated NVMe disk). 
> This situation leads to a recovery prompt "A required device isn't connected 
> or can't be accessed"
> 
> Note: this patch doesnt define the HardwareID(s) associated with 
> emulated NVMe devices, as this is dependent on the VM configuration.

Could we not use CompatibleIDs and look for "PCI\\CC_010802" (or perhaps even 
drop the 02)?

   Paul


I'll rework this patch and the follow up patch (that defines the override for 
the QEMU NVMe controller) based on CompatibleIDs

Owen

> 
> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
> ---
>   src/xenfilt/driver.c   | 20 +++++++++++++----
>   src/xenfilt/driver.h   |  5 +++++
>   src/xenfilt/emulated.c | 48 ++++++++++++++++++++++++++++++++++++++++
>   src/xenfilt/emulated.h |  3 ++-
>   src/xenfilt/pdo.c      | 50 ++++++++++++++++++++++++++++++++++++++++++
>   5 files changed, 121 insertions(+), 5 deletions(-)
> 
> diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c index 
> e9e6673..e25c208 100644
> --- a/src/xenfilt/driver.c
> +++ b/src/xenfilt/driver.c
> @@ -723,6 +723,21 @@ fail1:
>       return status;
>   }
>   
> +XENFILT_EMULATED_OBJECT_TYPE
> +DriverParseEmulatedType(
> +    IN  PANSI_STRING                Ansi
> +    )
> +{
> +    if (_strnicmp(Ansi->Buffer, "PCI", Ansi->Length) == 0)
> +        return XENFILT_EMULATED_OBJECT_TYPE_PCI;
> +    else if (_strnicmp(Ansi->Buffer, "IDE", Ansi->Length) == 0)
> +        return XENFILT_EMULATED_OBJECT_TYPE_IDE;
> +    else if (_strnicmp(Ansi->Buffer, "NVME", Ansi->Length) == 0)
> +        return XENFILT_EMULATED_OBJECT_TYPE_NVME;
> +
> +    return XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN;
> +}
> +
>   static XENFILT_EMULATED_OBJECT_TYPE
>   DriverGetEmulatedType(
>       IN  PCHAR                       Id
> @@ -753,10 +768,7 @@ DriverGetEmulatedType(
>           if (NT_SUCCESS(status)) {
>               Info("MATCH: %s -> %Z\n", &Id[Index], Ansi);
>   
> -            if (_strnicmp(Ansi->Buffer, "PCI", Ansi->Length) == 0)
> -                Type = XENFILT_EMULATED_OBJECT_TYPE_PCI;
> -            else if (_strnicmp(Ansi->Buffer, "IDE", Ansi->Length) == 0)
> -                Type = XENFILT_EMULATED_OBJECT_TYPE_IDE;
> +            Type = DriverParseEmulatedType(Ansi);
>   
>               RegistryFreeSzValue(Ansi);
>           } else {
> diff --git a/src/xenfilt/driver.h b/src/xenfilt/driver.h index 
> 286580b..ee656c8 100644
> --- a/src/xenfilt/driver.h
> +++ b/src/xenfilt/driver.h
> @@ -90,6 +90,11 @@ DriverQueryDeviceText(
>   
>   #include "emulated.h"
>   
> +XENFILT_EMULATED_OBJECT_TYPE
> +DriverParseEmulatedType(
> +    IN  PANSI_STRING                Ansi
> +    );
> +
>   PXENFILT_EMULATED_CONTEXT
>   DriverGetEmulatedContext(
>       VOID
> diff --git a/src/xenfilt/emulated.c b/src/xenfilt/emulated.c index 
> 827c905..df8cbaf 100644
> --- a/src/xenfilt/emulated.c
> +++ b/src/xenfilt/emulated.c
> @@ -52,9 +52,15 @@ typedef struct _XENFILT_EMULATED_DISK_DATA {
>       ULONG   Index;
>   } XENFILT_EMULATED_DISK_DATA, *PXENFILT_EMULATED_DISK_DATA;
>   
> +typedef struct _XENFILT_EMULATED_NVME_DATA {
> +    ULONG   StartIndex;
> +    ULONG   EndIndex;
> +} XENFILT_EMULATED_NVME_DATA, *PXENFILT_EMULATED_NVME_DATA;
> +
>   typedef union _XENFILT_EMULATED_OBJECT_DATA {
>       XENFILT_EMULATED_DEVICE_DATA Device;
>       XENFILT_EMULATED_DISK_DATA   Disk;
> +    XENFILT_EMULATED_NVME_DATA   Nvme;
>   } XENFILT_EMULATED_OBJECT_DATA, *PXENFILT_EMULATED_OBJECT_DATA;
>   
>   struct _XENFILT_EMULATED_OBJECT {
> @@ -189,6 +195,34 @@ fail1:
>       return status;
>   }
>   
> +static NTSTATUS
> +EmulatedSetObjectNvmeData(
> +    IN  PXENFILT_EMULATED_OBJECT        EmulatedObject,
> +    IN  XENFILT_EMULATED_OBJECT_TYPE    Type,
> +    IN  PCHAR                           DeviceID,
> +    IN  PCHAR                           InstanceID
> +    )
> +{
> +    NTSTATUS                            status;
> +
> +    UNREFERENCED_PARAMETER(DeviceID);
> +    UNREFERENCED_PARAMETER(InstanceID);
> +
> +    status = STATUS_INVALID_PARAMETER;
> +    if (Type != XENFILT_EMULATED_OBJECT_TYPE_NVME)
> +        goto fail1;
> +
> +    EmulatedObject->Data.Nvme.StartIndex = 0;
> +    EmulatedObject->Data.Nvme.EndIndex = 3;
> +
> +    return STATUS_SUCCESS;
> +
> +fail1:
> +    Error("fail1 (%08x)\n", status);
> +
> +    return status;
> +}
> +
>   NTSTATUS
>   EmulatedAddObject(
>       IN  PXENFILT_EMULATED_CONTEXT       Context,
> @@ -224,6 +258,13 @@ EmulatedAddObject(
>                                              InstanceID);
>           break;
>   
> +    case XENFILT_EMULATED_OBJECT_TYPE_NVME:
> +        status = EmulatedSetObjectNvmeData(*EmulatedObject,
> +                                           Type,
> +                                           DeviceID,
> +                                           InstanceID);
> +        break;
> +
>       default:
>           status = STATUS_INVALID_PARAMETER;
>           break;
> @@ -339,6 +380,13 @@ EmulatedIsDiskPresent(
>               break;
>           }
>   
> +        if (EmulatedObject->Type == XENFILT_EMULATED_OBJECT_TYPE_NVME &&
> +            Index >= EmulatedObject->Data.Nvme.StartIndex &&
> +            Index <= EmulatedObject->Data.Nvme.EndIndex) {
> +            Trace("FOUND\n");
> +            break;
> +        }
> +
>           ListEntry = ListEntry->Flink;
>       }
>   
> diff --git a/src/xenfilt/emulated.h b/src/xenfilt/emulated.h index 
> 57edee2..499e43c 100644
> --- a/src/xenfilt/emulated.h
> +++ b/src/xenfilt/emulated.h
> @@ -41,7 +41,8 @@ typedef struct _XENFILT_EMULATED_CONTEXT 
> XENFILT_EMULATED_CONTEXT, *PXENFILT_EMU
>   typedef enum _XENFILT_EMULATED_OBJECT_TYPE {
>       XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN = 0,
>       XENFILT_EMULATED_OBJECT_TYPE_PCI,
> -    XENFILT_EMULATED_OBJECT_TYPE_IDE
> +    XENFILT_EMULATED_OBJECT_TYPE_IDE,
> +    XENFILT_EMULATED_OBJECT_TYPE_NVME
>   } XENFILT_EMULATED_OBJECT_TYPE, *PXENFILT_EMULATED_OBJECT_TYPE;
>   
>   typedef struct _XENFILT_EMULATED_OBJECT XENFILT_EMULATED_OBJECT, 
> *PXENFILT_EMULATED_OBJECT; diff --git a/src/xenfilt/pdo.c 
> b/src/xenfilt/pdo.c index 0f6e6ce..b0e0e0f 100644
> --- a/src/xenfilt/pdo.c
> +++ b/src/xenfilt/pdo.c
> @@ -42,6 +42,7 @@
>   #include "pdo.h"
>   #include "thread.h"
>   #include "driver.h"
> +#include "registry.h"
>   #include "dbg_print.h"
>   #include "assert.h"
>   #include "util.h"
> @@ -251,6 +252,54 @@ __PdoGetFdo(
>       return Pdo->Fdo;
>   }
>   
> +
> +static FORCEINLINE NTSTATUS
> +__PdoGetEmulatedTypeOverride(
> +    IN  PXENFILT_PDO                Pdo,
> +    IN  PCHAR                       DeviceID
> +    )
> +{
> +    XENFILT_EMULATED_OBJECT_TYPE    Type;
> +    PANSI_STRING                    Ansi;
> +    HANDLE                          ParametersKey;
> +    HANDLE                          OverrideKey;
> +    NTSTATUS                        status;
> +
> +    ParametersKey = DriverGetParametersKey();
> +
> +    status = RegistryOpenSubKey(ParametersKey,
> +                                "Override",
> +                                GENERIC_READ,
> +                                &OverrideKey);
> +    if (!NT_SUCCESS(status))
> +        goto fail1;
> +
> +    status = RegistryQuerySzValue(OverrideKey,
> +                                  DeviceID,
> +                                  NULL,
> +                                  &Ansi);
> +    if (!NT_SUCCESS(status))
> +        goto fail2;
> +
> +    Type = DriverParseEmulatedType(Ansi);
> +    if (Type != XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN) {
> +        Info("%s = %Z\n", DeviceID, Ansi);
> +        Pdo->Type = Type;
> +    }
> +
> +    RegistryFreeSzValue(Ansi);
> +
> +    RegistryCloseKey(OverrideKey);
> +
> +    return STATUS_SUCCESS;
> +
> +fail2:
> +    RegistryCloseKey(OverrideKey);
> +
> +fail1:
> +    return status;
> +}
> +
>   static NTSTATUS
>   PdoSetDeviceInformation(
>       IN  PXENFILT_PDO    Pdo
> @@ -313,6 +362,7 @@ PdoSetDeviceInformation(
>       Dx->DeviceID = DeviceID;
>       Dx->InstanceID = InstanceID;
>       Dx->LocationInformation = LocationInformation;
> +    (VOID) __PdoGetEmulatedTypeOverride(Pdo, DeviceID);
>   
>       return STATUS_SUCCESS;
>   
> 



 


Rackspace

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