[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:34:49 +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=NwfW94LWPISt3K54OoyJE1xD90RBjnjXP5sgI2RsCfSBwTJuVizV16+MtMPYlNqPs1FHvP6LC8i6SSdkvsZy/vQhh0E+wBaUV5rP6GzLp6UblY4iiLro/0gvLX4ENRq77dIeuyEdzfsCQ6Rr8D/sobSmJLPTA/m7UJmYhKLrG7lY5UotncD1nFauarEx5hTLD1Yj0lxtuleX8XvHYVu0uKFLud0Fn6hasw1iKnJXw0ei/4fMRJ1WdGDiPS8XatWtByiemq4hCLCgfyF22bqoZj8H5fxF4tgluCCe4hikW6KwkC56ODI1oaeXW1blW2LmL8FpD5Je+tLB46ZFDJLBCw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UqX7ogQ+6o0W/G7QL4Y4j/39MtfO/ojSKgcFjjDl/5XlKlXvZ2JFIdoVLeBJ/s1U4q4xYWbg6GJgy/xs2AOpSd1yKy+C4n/QMJaL6BrH4b9LLtHCV4/L5WCm9P8pjACWzq/sEjLuYV/srr4FSDCgkbZB4rshh4N2zlVgAa9yJRYgP3VWRHGRP9xkcBYZGrp1XX/VbAAVEwDm1Ii7+2hUBAHsiC4DXmi2NHNiK3jZai7ofTmGgT3qHrWcYVsqTKR+5sHVt2sRqslndyyZ8QT29z0kUKPTNbirDfiN+vbB3kuEokbX7qqyXYLGkra/2OUeu9LlUU/mzfHC1JXlaAbuoQ==
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Delivery-date: Mon, 21 Jun 2021 15:34:55 +0000
  • Ironport-hdrordr: A9a23:VpC/Za9QUztlSiNae9huk+AiI+orL9Y04lQ7vn2ZKSY5TiVXra CTdZUgpHvJYVMqMk3I9uruBEDtex3hHP1OkOws1NWZLWrbUQKTRekP0WKL+Vbd8kbFh4xgPM lbEpSXCLfLfCVHZcSR2njFLz73quP3j5xBho3lvglQpRkBUdAG0+/gYDzraXGfQmN9dPwEPa vZ3OVrjRy6d08aa8yqb0N1JdQq97Xw5evbiQdtPW9e1DWz
  • Ironport-sdr: O8xvItoWWJGcuYLsxp0E6WeXQ3R3o9gGd1UoOcQ4rze/VHMvd6/PjbtCj+sRRjzlY+jQDiIc6t 6rviZXuFVe9Me5O+Bp/F+hZAR0ZEO7X3ZrTU0uk+ZeMY4IEsfQkRRbcsLxVcQ34mMjkhZoLzKU vDnGypPPZqsx9JpsGkHfP5j15rxs4Pz7qK9+OdEYSoburDWWV0WmYjoOLwK4hSkF4+BTooCasS 5JDleoWSQp5MbikX/nAvrDU/JsFIz4yNjGUZB7zCbK/qk+rHd7tuQTJBEoksyL3wG2qHDPt11j Z0M=
  • 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®.