From win-pv-devel-bounces@lists.xenproject.org Thu Feb 05 12:31:07 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 05 Feb 2026 12:31:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1221887.1530000 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vnyVm-0007JU-0w; Thu, 05 Feb 2026 12:31:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1221887.1530000; Thu, 05 Feb 2026 12:31:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vnyVl-0007JN-UT; Thu, 05 Feb 2026 12:31:05 +0000
Received: by outflank-mailman (input) for mailman id 1221887;
 Thu, 05 Feb 2026 12:31:05 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Kpnm=AJ=bounce.vates.tech=bounce-md_30504962.69848d81.v1-b257d083c6d4407281e18c6637db1d39@srs-se1.protection.inumbo.net>)
 id 1vnyVl-0007JE-4h
 for win-pv-devel@lists.xenproject.org; Thu, 05 Feb 2026 12:31:05 +0000
Received: from mail134-16.atl141.mandrillapp.com
 (mail134-16.atl141.mandrillapp.com [198.2.134.16])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 85fbbcc1-028e-11f1-9ccf-f158ae23cfc8;
 Thu, 05 Feb 2026 13:30:59 +0100 (CET)
Received: from pmta10.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail134-16.atl141.mandrillapp.com (Mailchimp) with ESMTP id
 4f6Gm13RGHzB5p54K
 for <win-pv-devel@lists.xenproject.org>; Thu,  5 Feb 2026 12:30:57 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 b257d083c6d4407281e18c6637db1d39; Thu, 05 Feb 2026 12:30:57 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 85fbbcc1-028e-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770294657; x=1770564657;
	bh=8agfVMxZYYiWvuOagupP6+pHOCalD650Zyh0Ah5LjbY=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=wsvazus00acCfcxr5A7sJ0tx/jDra32q0i/N+9Khl5RbJpc1A8UpBMDgXlF3ip6oi
	 6LOYgN2ZVVwZT+bHeT5oNH1U2gSrdirzcUf2j2GAYbB6wlkNh7ut8hungzkj7dDm47
	 X2exFeli28jasMLBZ1Y5Oz8/FA3xVHc5PBJFmd/hUZWYwNnEpscvg4Ze2fKy1AiCRR
	 LrSfc/yLpQONMUfp8+RYEMOLXo161Y8WyWtO2f/QzRdPphMkSTQMktjZuU6jqsI76H
	 aVJ1IyXcQi4o8b4nuLF73IEle7Kcyw1RtQJfpoxt+WjSvpK7wKJDjQNuntMHp5/3Bf
	 TaB4n88rvJ6xQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770294657; x=1770555157; i=ngoc-tu.dinh@vates.tech;
	bh=8agfVMxZYYiWvuOagupP6+pHOCalD650Zyh0Ah5LjbY=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=Oxy5gCXmOh3JWDSQE+dL3Rc9eA3cig4Il5l6e0IWllxA8AmCcgVgAv091qM0unL2f
	 4RT0MaJLte4BLEHr+XMmY3zH8HyEde7KfCCYeChAfn2PuzUe0cic1Xwj1QcKORtaVO
	 hhYFAYIkYex9mrdWfnGdbDbK5KomEb0+nBfk8GO5jBVk9jDNQuI2mzf52C/1c6EPl3
	 T+AJjw1s+coMdT6rTfKvjrKhhcaZtSwRsly8jNrJLm9l7ly3ZoGprXXLmdqSms41OO
	 WEH9iYzj5M4RSmRw23G6byQsenMwipMAtSlRbVDswF3/mEEAkx2F+KxbgEYmdFdk1H
	 Qjqdtz4mRbceQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH]=20Fix=20display=20of=20bugcheck=20context=20registers?=
X-Mailer: git-send-email 2.51.2.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770294656569
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@cloud.com>
Message-Id: <20260205123051.1463-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.b257d083c6d4407281e18c6637db1d39?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260205:md
Date: Thu, 05 Feb 2026 12:30:57 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

The string formats did not specify a size and so caused these registers
to be truncated.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xen/bug_check.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/xen/bug_check.c b/src/xen/bug_check.c
index e0681e5..cc77ef0 100644
--- a/src/xen/bug_check.c
+++ b/src/xen/bug_check.c
@@ -309,71 +309,71 @@ BugCheckDumpContext(
                   Context->EFlags);
 
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RDI = %016X\n",
+                  "%s|BUGCHECK: - RDI = %016llX\n",
                   __MODULE__,
                   Context->Rdi);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RSI = %016X\n",
+                  "%s|BUGCHECK: - RSI = %016llX\n",
                   __MODULE__,
                   Context->Rsi);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RBX = %016X\n",
+                  "%s|BUGCHECK: - RBX = %016llX\n",
                   __MODULE__,
                   Context->Rbx);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RDX = %016X\n",
+                  "%s|BUGCHECK: - RDX = %016llX\n",
                   __MODULE__,
                   Context->Rdx);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RCX = %016X\n",
+                  "%s|BUGCHECK: - RCX = %016llX\n",
                   __MODULE__,
                   Context->Rcx);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RAX = %016X\n",
+                  "%s|BUGCHECK: - RAX = %016llX\n",
                   __MODULE__,
                   Context->Rax);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RBP = %016X\n",
+                  "%s|BUGCHECK: - RBP = %016llX\n",
                   __MODULE__,
                   Context->Rbp);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RIP = %016X\n",
+                  "%s|BUGCHECK: - RIP = %016llX\n",
                   __MODULE__,
                   Context->Rip);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RSP = %016X\n",
+                  "%s|BUGCHECK: - RSP = %016llX\n",
                   __MODULE__,
                   Context->Rsp);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R8 = %016X\n",
+                  "%s|BUGCHECK: - R8 = %016llX\n",
                   __MODULE__,
                   Context->R8);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R9 = %016X\n",
+                  "%s|BUGCHECK: - R9 = %016llX\n",
                   __MODULE__,
                   Context->R9);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R10 = %016X\n",
+                  "%s|BUGCHECK: - R10 = %016llX\n",
                   __MODULE__,
                   Context->R10);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R11 = %016X\n",
+                  "%s|BUGCHECK: - R11 = %016llX\n",
                   __MODULE__,
                   Context->R11);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R12 = %016X\n",
+                  "%s|BUGCHECK: - R12 = %016llX\n",
                   __MODULE__,
                   Context->R12);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R13 = %016X\n",
+                  "%s|BUGCHECK: - R13 = %016llX\n",
                   __MODULE__,
                   Context->R13);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R14 = %016X\n",
+                  "%s|BUGCHECK: - R14 = %016llX\n",
                   __MODULE__,
                   Context->R14);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R15 = %016X\n",
+                  "%s|BUGCHECK: - R15 = %016llX\n",
                   __MODULE__,
                   Context->R15);
     } __except (EXCEPTION_EXECUTE_HANDLER) {
@@ -572,7 +572,7 @@ BugCheckStackDump(
 
             if (Name != NULL)
                 LogPrintf(LOG_LEVEL_CRITICAL,
-                          "%s|BUGCHECK: %016X: (%016X %016X %016X %016X) %s + %p\n",
+                          "%s|BUGCHECK: %016llX: (%016llX %016llX %016llX %016llX) %s + %p\n",
                           __MODULE__,
                           RSP,
                           Parameter[0],
@@ -583,7 +583,7 @@ BugCheckStackDump(
                           (PVOID)Offset);
             else
                 LogPrintf(LOG_LEVEL_CRITICAL,
-                          "%s|BUGCHECK: %016X: (%016X %016X %016X %016X) %p\n",
+                          "%s|BUGCHECK: %016llX: (%016llX %016llX %016llX %016llX) %p\n",
                           __MODULE__,
                           RSP,
                           Parameter[0],
-- 
2.51.2.windows.1



--
 | Vates

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 06 07:27:12 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 06 Feb 2026 07:27:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1222830.1530514 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voGFC-0006iu-Hs; Fri, 06 Feb 2026 07:27:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1222830.1530514; Fri, 06 Feb 2026 07:27:10 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voGFC-0006in-FG; Fri, 06 Feb 2026 07:27:10 +0000
Received: by outflank-mailman (input) for mailman id 1222830;
 Fri, 06 Feb 2026 07:27:09 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gVqx=AK=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1voGFB-0006ih-G5
 for win-pv-devel@lists.xenproject.org; Fri, 06 Feb 2026 07:27:09 +0000
Received: from SA9PR02CU001.outbound.protection.outlook.com
 (mail-southcentralusazlp170130001.outbound.protection.outlook.com
 [2a01:111:f403:c10c::1])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 3a70fd59-032d-11f1-9ccf-f158ae23cfc8;
 Fri, 06 Feb 2026 08:27:02 +0100 (CET)
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by LV5PR03MB8362.namprd03.prod.outlook.com (2603:10b6:408:35e::21)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9587.15; Fri, 6 Feb
 2026 07:26:59 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9587.013; Fri, 6 Feb 2026
 07:26:58 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 3a70fd59-032d-11f1-9ccf-f158ae23cfc8
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=PMsunnjtqVve2BPvM75kFnp9souw/m3aa99CC4RlvrLUUpAg+F6xJV3cH9Wsv17gPplfZXWTInh+oeFKXKKJuqPJu8lN8Ta28UBfhZZzai/J5xL0I+L+40h1818WA8XAmmF3l/7FKeSr1hbQ1lzUHFwlweqLyLaBwYpx96q/fyFdZCdoLULvWaW7GWHIB1V3HrQWUDC6iuMeKu9g3SEbWfYtMpCfx0DlcHZcNJ43pwhLBIGerCmcjs+rresxRT39/9nA7yfEahwSr1+EeANqEMhQgOyP0JQSL6fnGUXGBkd0+ItkzjJhuTCdgrysM/96UT6fMFyXsYhRnPMrddtnNA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector10001;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=9epFQIWu9tlnQGoUTyE465QEAn/jiLJYqPwzF18RcHc=;
 b=EMTby8MBhWTdl9yvIJ4ptq8qNF/KcageOWOqgzelDfj2hJiiG3zEzjKCffDu48YLiFmEtE21KzR8FiTYC9AxINTs/RdgaDZl+DD1wk79dAFQCl/3YQUG4AKmtDsFb/b4ZvqqjOBCjHFUlvGtepnOqnVmCSrEWQ3BTh9+Ix70HmqnXl4ktTI+vDVo4saeYwm5QWS2WY9KkZGdlmtS4nfWkrJLWnsfx57PmKCdf1qvwCkkCrtAmaXK0KT5+XXvIx00WcVQR6AkaKYxs2tFSmBhNtfaW9syDJXZHzhgFLO74VSnsdJnbwW34VsQ8rj1Vgmd/KVh6wPmDyO99AI+z7LjWA==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=9epFQIWu9tlnQGoUTyE465QEAn/jiLJYqPwzF18RcHc=;
 b=k0qHM5J503vLBxlVjpadzO8UoMkgvLs4FOWE21yHXQiVM6gijK5y7aV8B2jU8t27iyKLU5IqP6ks45jEX0K8VkQ4zpkBSIL+0PeIS6hEMV6ulzCyXwHuW1IX6zXkIPhXoRdGwa0ZpzUd49Q0fMt0Ouo3CbRNoCGEe6SK6kQza+I=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@cloud.com>
Subject: Re: [PATCH] Fix display of bugcheck context registers
Thread-Topic: [PATCH] Fix display of bugcheck context registers
Thread-Index: AQHclptTYgNoZdSbZE+KMx/2wBUWT7V1RpMh
Date: Fri, 6 Feb 2026 07:26:58 +0000
Message-ID:
 <SA6PR03MB776052F7C81AEBB4B237E509FE66A@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <20260205123051.1463-1-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260205123051.1463-1-ngoc-tu.dinh@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|LV5PR03MB8362:EE_
x-ms-office365-filtering-correlation-id: 44233ba4-3b71-4084-3329-08de65511cd6
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|366016|376014|38070700021;
x-microsoft-antispam-message-info:
 =?us-ascii?Q?wIUP1PJM0Qcn/KdXn8zOq5COivE/ZZl72E19LjZE/wpp6QPupFbkCJgTRHXT?=
 =?us-ascii?Q?MQi0it/JG/I55fbXOlJ7k1KZEoyWYCs0mGQScvrqM7kJScRySCFpvzek1MHD?=
 =?us-ascii?Q?BRePk2EBlba9A5vzOjHS6wvevE/Wt+FOnkgpLW4TFTdHWbYQ7492IxLfceAD?=
 =?us-ascii?Q?Qfo9szjH+9B7NlY1aB9ovW7P1oe2KL0JWrFPXBWW7zZoqupD5Se07d58++H+?=
 =?us-ascii?Q?F/27+Y7pQON+NLNr/4zRc7oZjwv1LPq+1xy9r9l2FpabXkoc4w7HLWyMa8q1?=
 =?us-ascii?Q?y2/oyivyWBD1cPS3EPYxGAQ1MYwuqA7vStnCdDXi4hhRU82/exvNY4BRNIuW?=
 =?us-ascii?Q?0638qPg7PtDsxP6CNP1SLkM1yDn5K8ltqydQTMaGTFsemeunU/hO4gdSxiu/?=
 =?us-ascii?Q?hER2GMGX6tjeB216j5srLYwWZPlTMjnfcny8LwQjrIpmkgcgrPqgjzxQw9qO?=
 =?us-ascii?Q?TN2vnm/o2nTYTr207zPkB6P4OQ4fyJmSP1YjopU7b0cbyVJIYxK8B+3WYBWr?=
 =?us-ascii?Q?M+mmR1hbuiifu+0sEnLGUVcVhX9gQh7F0CwX1+HWY5faETv03QhHZdtgxA6M?=
 =?us-ascii?Q?ggpvKmCOq2Qs9uPJDAI1qFWqI1S6dv4S6MqQnU/OLi4G81DW2xVfCndtj9/K?=
 =?us-ascii?Q?sB9VMO0SHMJRr5AsvEZ9K7dcCGroma+A0E4La49Vb5/2ojCzlqMb1ofBMZAf?=
 =?us-ascii?Q?pnXEyWWj2kez/xy5qK1HBYNXHl7zJLMQBz1Yv1IkqB0WCWe0kJ2FSCDuDaDq?=
 =?us-ascii?Q?IkRpxd/295puT3PJsFRzqLGGyU6M72wIzORNGL+Zd67lR/cvMl7A8hDN7dkJ?=
 =?us-ascii?Q?JzbQjb5NuTX7v0TxZB2RkI5edO4HshHHiYQ8XkfFvnzBZQkvpjmDwEakfouP?=
 =?us-ascii?Q?B39m7w5Z8N+ao95y+/nZpbJsBDKw+vvSlzORt/G1iGrd/EEVY8jmkLVA+anX?=
 =?us-ascii?Q?iw66drea3O06EOgf4LebcWjHx2OZm5Bus21YGfp6ZMcVPuR63i0sH6xdX1/9?=
 =?us-ascii?Q?Ti70umU9WU3YPB7msYPuEyBBgvYUPYEN4WhEPhV2pO4ov/En/PmxgDqh4DRG?=
 =?us-ascii?Q?1MVjyfLY/nqUesKsHIUSBWAkVIT6+meGtDJF40hM88y5LzK1+NnNZNsSxvnS?=
 =?us-ascii?Q?QW8AkLbx6PFqj2lfJBfn3kSwfrbLEDdwr3S9VuLSrpi7YL5vOkqiJjNRcmOd?=
 =?us-ascii?Q?JAbU863Mhqb9Cd2kXIAVlm6Bu2v7xIQLMgwr5rNAs9fF+y0reyw+iKbXScW2?=
 =?us-ascii?Q?OoUiohFyyuaA2f1o2vktR3Z6kCanz4lD5rqabTIp3Dh41pfpfE8seTGmd3Bj?=
 =?us-ascii?Q?LyL8q1en0nhSZ0p8B8X7MC0ssOkU8LoXSegRxc4YciTJUB7az7w8r6mPOS/E?=
 =?us-ascii?Q?CeVuWdlfX9Vzzcg0MJSRtS6PaIfoznPi8vtlE39k+2S15sDJNSxTOYEkgJ4V?=
 =?us-ascii?Q?4bAfdWRRU8NJgPk/9dq0knuw6E7gYs8kdWEW9E0/WRkIpStfiOKrvJfNMRPz?=
 =?us-ascii?Q?7JAUy3xUW2T1TiaPfOSjZeJ6cgInQflAYgYo9iciLt3diWifb9LP59PFUpEK?=
 =?us-ascii?Q?8jwWpZ/YToibvvH53oM=3D?=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(38070700021);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?8WRJJzV9FeeMGcF2JzL4wqxyzQ4Yjb+cLSvES4XEpsZpTny324XPDvV8Z5Pt?=
 =?us-ascii?Q?utVpOK6Uw9+YmlvbkRBIgESwhT9M69AMNu3cw9tiwz1Betz6U2wSv/oCoJWt?=
 =?us-ascii?Q?ZqRZSOnEuISJJRYX8IGHEKd5k8cMh2u4b9f4BfeVEWNOvZgtpC8p/rTBkL6H?=
 =?us-ascii?Q?RmIZ95AkjGS0Vo28kCTLlXy2pXwMEsrUhvKfjD9hhscgolQ2c6TL+8W7/CY9?=
 =?us-ascii?Q?2NRQHZYWR8pyIOyUnKvDUiGm6mbrtszuiWHg1ucpXFjKupgEa6C1kLeu3O9C?=
 =?us-ascii?Q?7S93gxLdgYcHhyWprRK04mX/hBilzL44ra6cAtq8hPqdND9TN01xb/qPt0r6?=
 =?us-ascii?Q?7gY1u2IJy7Z8ZZ9uwP9QBgfXXjbdXXivHVzeCGq9aCFy0107pUzSRJa4916a?=
 =?us-ascii?Q?EpvNBphtdkHTQt37wArZZW2PoJiM7awBE6/NcyRBF4L/38tL+Z+FlYz1kKkK?=
 =?us-ascii?Q?nZkU8W0COyU7aKM8lcr3Xs3LkMBDB0fXm5Q2181oWOEt0TK9KHdnDPfzcKHM?=
 =?us-ascii?Q?iXE1ecLwR32b8/w+966eiPsGSwbB4k4Q8PgQLnq1UaPXKmD5H3ZPC6Tjlwjj?=
 =?us-ascii?Q?cPyPLg/lh/n66Nk1MIHNq6dHN3Rvhi/UblkRhP6C3Q+CJBb6EfYSCv++8Us5?=
 =?us-ascii?Q?JUqfSwp/xLckg4c0bqkLxzEmkt3jzy7G+i9segoyVAwNQoQoNgzcAXi5o2tk?=
 =?us-ascii?Q?cWB7F6jGJyjLsqM4JlIDgr3TW79BN+JlZQeJsxySXI/Mrh2+l6i6mNHxXiuH?=
 =?us-ascii?Q?WuZKgnrSqHzxJx3QpL4Xxzc+gxbykqT1TnagaPRH6EEQ9ZUKpqZfA06fqBqo?=
 =?us-ascii?Q?vBzOkaVpPrLnKbDKZNJE9kIcJMpsz1nS3CJ0mMscArM78pNpf1jGWA8w764S?=
 =?us-ascii?Q?TZgidBhfXkEkFUCz9tauBMdh+HQh6CPDeY1aRt6MZsrqUsA0Zgn5bJubbZRu?=
 =?us-ascii?Q?8TsPUvcm3063vBRzX7gbOyy5zJklJyvzIkMW/l8PVrsGqyTS5sKZ2msJb5R5?=
 =?us-ascii?Q?gaLsXrnRG0/eeDQhUn0W1gm9C2D/PwBj5h8UxpfkmsjC9Y1FrHz83a3L9RsS?=
 =?us-ascii?Q?mp62uh9aIbpntNXRce7i6wc0A7GsfywzLekCw3Ri724X8f+WgoAhTQmUpWYw?=
 =?us-ascii?Q?yzbmb40duEJXak9ykRoBcHIJHPEDacLWHp7FExKa1WIhBGZ4v8yKE4NqHlLc?=
 =?us-ascii?Q?eEwK0KQQ/zLuBHf/GIxI0y5iPiZQSkDQlxfcYse3MAACb9B9za6+jfJ97mRW?=
 =?us-ascii?Q?/SnJaP8/tiKBtsyJVtMMCB98oIJRzt3Kw/CUZqdACY63gSUdtlIQNzoyCCJ2?=
 =?us-ascii?Q?bg5D+TxZGshfuREKFoqHUu5FRvNu3PEvUISo3yE5wBIYj6z6d4tea35C300i?=
 =?us-ascii?Q?ywZudAbOdJWtSiJNY4kV5VBCHEzBWf3e5unLDpLPfdo0JfWVNQ6HDO5JBtKW?=
 =?us-ascii?Q?I7qkSb9MuySqKCp21qP4X17PorjErGJImhTH0kqfzX8GSrg2HXsKm/4FdyUX?=
 =?us-ascii?Q?YAD9p3dfa+YX/gKaQ+Rjry27Y5BWf017S4hp+FIg+7uNKdMzDNZBUKFrAzv5?=
 =?us-ascii?Q?DZs5wOwIcbwX3wQhw9Orjj8wILd25OqSfP5RUpuIwGPjZj424k+u7q2JUT/a?=
 =?us-ascii?Q?yTJ98ofnAsHuDuWn7PIAWXYYmz+oDTA0IYW0xc7jb5LanRjWQnAQ+ycJYJgY?=
 =?us-ascii?Q?Pv1iTaliZE163Ip9wLuzCKBQHpCnw+UjVjJuq6Sj80ghUvCV?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 44233ba4-3b71-4084-3329-08de65511cd6
X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Feb 2026 07:26:58.3160
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: rTd/S832p0Dvsa5my+4uchvM/6mjLhSvl7P8CkO43mLbGdiZyf/8CaeOr2bzntFrvvqeA1T4i5yHAa6//HB7OA==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV5PR03MB8362

Reviewed-by: Owen Smith <owen.smith@citrix.com>

________________________________________
From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> on behalf of=
 Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 05 February 2026 12:30 PM
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh; Owen Smith
Subject: [PATCH] Fix display of bugcheck context registers

The string formats did not specify a size and so caused these registers
to be truncated.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xen/bug_check.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/xen/bug_check.c b/src/xen/bug_check.c
index e0681e5..cc77ef0 100644
--- a/src/xen/bug_check.c
+++ b/src/xen/bug_check.c
@@ -309,71 +309,71 @@ BugCheckDumpContext(
                   Context->EFlags);

         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RDI =3D %016X\n",
+                  "%s|BUGCHECK: - RDI =3D %016llX\n",
                   __MODULE__,
                   Context->Rdi);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RSI =3D %016X\n",
+                  "%s|BUGCHECK: - RSI =3D %016llX\n",
                   __MODULE__,
                   Context->Rsi);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RBX =3D %016X\n",
+                  "%s|BUGCHECK: - RBX =3D %016llX\n",
                   __MODULE__,
                   Context->Rbx);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RDX =3D %016X\n",
+                  "%s|BUGCHECK: - RDX =3D %016llX\n",
                   __MODULE__,
                   Context->Rdx);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RCX =3D %016X\n",
+                  "%s|BUGCHECK: - RCX =3D %016llX\n",
                   __MODULE__,
                   Context->Rcx);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RAX =3D %016X\n",
+                  "%s|BUGCHECK: - RAX =3D %016llX\n",
                   __MODULE__,
                   Context->Rax);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RBP =3D %016X\n",
+                  "%s|BUGCHECK: - RBP =3D %016llX\n",
                   __MODULE__,
                   Context->Rbp);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RIP =3D %016X\n",
+                  "%s|BUGCHECK: - RIP =3D %016llX\n",
                   __MODULE__,
                   Context->Rip);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - RSP =3D %016X\n",
+                  "%s|BUGCHECK: - RSP =3D %016llX\n",
                   __MODULE__,
                   Context->Rsp);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R8 =3D %016X\n",
+                  "%s|BUGCHECK: - R8 =3D %016llX\n",
                   __MODULE__,
                   Context->R8);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R9 =3D %016X\n",
+                  "%s|BUGCHECK: - R9 =3D %016llX\n",
                   __MODULE__,
                   Context->R9);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R10 =3D %016X\n",
+                  "%s|BUGCHECK: - R10 =3D %016llX\n",
                   __MODULE__,
                   Context->R10);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R11 =3D %016X\n",
+                  "%s|BUGCHECK: - R11 =3D %016llX\n",
                   __MODULE__,
                   Context->R11);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R12 =3D %016X\n",
+                  "%s|BUGCHECK: - R12 =3D %016llX\n",
                   __MODULE__,
                   Context->R12);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R13 =3D %016X\n",
+                  "%s|BUGCHECK: - R13 =3D %016llX\n",
                   __MODULE__,
                   Context->R13);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R14 =3D %016X\n",
+                  "%s|BUGCHECK: - R14 =3D %016llX\n",
                   __MODULE__,
                   Context->R14);
         LogPrintf(LOG_LEVEL_CRITICAL,
-                  "%s|BUGCHECK: - R15 =3D %016X\n",
+                  "%s|BUGCHECK: - R15 =3D %016llX\n",
                   __MODULE__,
                   Context->R15);
     } __except (EXCEPTION_EXECUTE_HANDLER) {
@@ -572,7 +572,7 @@ BugCheckStackDump(

             if (Name !=3D NULL)
                 LogPrintf(LOG_LEVEL_CRITICAL,
-                          "%s|BUGCHECK: %016X: (%016X %016X %016X %016X) %=
s + %p\n",
+                          "%s|BUGCHECK: %016llX: (%016llX %016llX %016llX =
%016llX) %s + %p\n",
                           __MODULE__,
                           RSP,
                           Parameter[0],
@@ -583,7 +583,7 @@ BugCheckStackDump(
                           (PVOID)Offset);
             else
                 LogPrintf(LOG_LEVEL_CRITICAL,
-                          "%s|BUGCHECK: %016X: (%016X %016X %016X %016X) %=
p\n",
+                          "%s|BUGCHECK: %016llX: (%016llX %016llX %016llX =
%016llX) %p\n",
                           __MODULE__,
                           RSP,
                           Parameter[0],
--
2.51.2.windows.1



--
 | Vates

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




From win-pv-devel-bounces@lists.xenproject.org Fri Feb 06 08:45:35 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 06 Feb 2026 08:45:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1222917.1530600 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voHT5-0003iL-1r; Fri, 06 Feb 2026 08:45:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1222917.1530600; Fri, 06 Feb 2026 08:45:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voHT4-0003iD-V6; Fri, 06 Feb 2026 08:45:34 +0000
Received: by outflank-mailman (input) for mailman id 1222917;
 Fri, 06 Feb 2026 08:45:33 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gVqx=AK=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1voHT2-0003hw-Vv
 for win-pv-devel@lists.xenproject.org; Fri, 06 Feb 2026 08:45:32 +0000
Received: from na1pdmzitismtp02.tibco.com (na1pdmzitismtp02.tibco.com
 [160.101.131.9]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 3153bd35-0338-11f1-b161-2bf370ae4941;
 Fri, 06 Feb 2026 09:45:31 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id 0C36A81392E1;
 Fri,  6 Feb 2026 03:45:08 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 3153bd35-0338-11f1-b161-2bf370ae4941
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 1/5] Update my email address
Date: Fri,  6 Feb 2026 08:45:20 +0000
Message-ID: <20260206084525.1356-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Update MAINTAINERS to reference the correct email address.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2b07abc..ee22cc8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -43,6 +43,6 @@ We also request you follow these basic guidelines:
 Maintainers List
 ----------------
 
-* Owen Smith <owen.smith@cloud.com>
+* Owen Smith <owen.smith@citrix.com>
 
 * Tu Dinh <ngoc-tu.dinh@vates.tech>
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 06 08:45:35 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 06 Feb 2026 08:45:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1222918.1530605 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voHT5-0003ie-6B; Fri, 06 Feb 2026 08:45:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1222918.1530605; Fri, 06 Feb 2026 08:45:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voHT4-0003iO-WB; Fri, 06 Feb 2026 08:45:34 +0000
Received: by outflank-mailman (input) for mailman id 1222918;
 Fri, 06 Feb 2026 08:45:33 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gVqx=AK=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1voHT3-0003hw-KT
 for win-pv-devel@lists.xenproject.org; Fri, 06 Feb 2026 08:45:33 +0000
Received: from na1pdmzitismtp02.tibco.com (na1pdmzitismtp02.tibco.com
 [160.101.131.9]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 31a64a85-0338-11f1-b161-2bf370ae4941;
 Fri, 06 Feb 2026 09:45:31 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id A4D1581392E5;
 Fri,  6 Feb 2026 03:45:09 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 31a64a85-0338-11f1-b161-2bf370ae4941
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 2/5] Refactor monitor.c registry enumeration
Date: Fri,  6 Feb 2026 08:45:21 +0000
Message-ID: <20260206084525.1356-2-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <20260206084525.1356-1-owen.smith@citrix.com>
References: <20260206084525.1356-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Move registry enumeration code into a function, using a callback that is called
for each sub key of the specified key.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 149 ++++++++++++++++++++++++++++--------------
 1 file changed, 100 insertions(+), 49 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 1154de5..52311aa 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -856,23 +856,25 @@ fail1:
     return;
 }
 
-static VOID
-CheckRequestSubKeys(
-    VOID
+typedef BOOLEAN(*PREGENUM_FUNC)(HKEY, PTSTR, PVOID);
+
+static HRESULT
+RegEnumSubKeys(
+    _In_ HKEY           BaseKey,
+    _In_ PREGENUM_FUNC  Callback,
+    _In_opt_ PVOID      Context
     )
 {
-    PMONITOR_CONTEXT    Context = &MonitorContext;
     DWORD               SubKeys;
     DWORD               MaxSubKeyLength;
     DWORD               SubKeyLength;
     PTSTR               SubKeyName;
     DWORD               Index;
-    HKEY                SubKey;
     HRESULT             Error;
 
     Log("====>");
 
-    Error = RegQueryInfoKey(Context->RequestKey,
+    Error = RegQueryInfoKey(BaseKey,
                             NULL,
                             NULL,
                             NULL,
@@ -896,14 +898,10 @@ CheckRequestSubKeys(
         goto fail2;
 
     for (Index = 0; Index < SubKeys; Index++) {
-        DWORD   Length;
-        DWORD   Type;
-        DWORD   Reboot;
-
         SubKeyLength = MaxSubKeyLength + sizeof (TCHAR);
         memset(SubKeyName, 0, SubKeyLength);
 
-        Error = RegEnumKeyEx(Context->RequestKey,
+        Error = RegEnumKeyEx(BaseKey,
                              Index,
                              (LPTSTR)SubKeyName,
                              &SubKeyLength,
@@ -918,59 +916,112 @@ CheckRequestSubKeys(
 
         Log("%s", SubKeyName);
 
-        Error = RegOpenKeyEx(Context->RequestKey,
-                             SubKeyName,
-                             0,
-                             KEY_READ,
-                             &SubKey);
-        if (Error != ERROR_SUCCESS)
-            continue;
+        if (!Callback(BaseKey, SubKeyName, Context))
+            break;
+    }
 
-        Length = sizeof (DWORD);
-        Error = RegQueryValueEx(SubKey,
-                                "Reboot",
-                                NULL,
-                                &Type,
-                                (LPBYTE)&Reboot,
-                                &Length);
-        if (Error != ERROR_SUCCESS ||
-            Type != REG_DWORD)
-            goto loop;
+    free(SubKeyName);
 
-        if (Reboot != 0)
-            goto found;
+    return ERROR_SUCCESS;
 
-loop:
-        RegCloseKey(SubKey);
+fail3:
+    Log("fail3");
+
+    free(SubKeyName);
+
+fail2:
+    Log("fail2");
+
+fail1:
+    Error = GetLastError();
+
+    {
+        PTSTR   Message;
+        Message = GetErrorMessage(Error);
+        Log("fail1 (%s)", Message);
+        LocalFree(Message);
     }
 
-    Error = RegDeleteValue(Context->ParametersKey,
-                           "RebootCount");
-    if (Error == ERROR_SUCCESS)
-        (VOID) RegFlushKey(Context->ParametersKey);
+    return Error;
+}
 
-    goto done;
+static BOOLEAN
+CheckRequestSubKey(
+    _In_ HKEY           BaseKey,
+    _In_ PTSTR          SubKeyName,
+    _In_opt_ PVOID      Context
+    )
+{
+    DWORD               Length;
+    DWORD               Reboot;
+    DWORD               Type;
+    HKEY                SubKey;
+    HRESULT             Error;
+    PBOOLEAN            Found = (PBOOLEAN)Context;
 
-found:
-    RegCloseKey(SubKey);
+    Error = RegOpenKeyEx(BaseKey,
+                         SubKeyName,
+                         0,
+                         KEY_READ,
+                         &SubKey);
+    if (Error != ERROR_SUCCESS)
+        return TRUE;
+
+    Length = sizeof (DWORD);
+    Error = RegQueryValueEx(SubKey,
+                            "Reboot",
+                            NULL,
+                            &Type,
+                            (LPBYTE)&Reboot,
+                            &Length);
+    if (Error != ERROR_SUCCESS ||
+        Type != REG_DWORD)
+        goto loop;
+
+    if (Reboot == 0)
+        goto loop;
 
-    if (!Context->RebootRequestedBy)
+    if (Found != NULL)
+        *Found = TRUE;
+
+    if (!MonitorContext.RebootRequestedBy)
         TryAutoReboot(SubKeyName);
 
-done:
-    free(SubKeyName);
+loop:
+    RegCloseKey(SubKey);
 
-    Log("<====");
+    return (Found != NULL) ? !(*Found) : TRUE;
+}
 
-    return;
+static VOID
+CheckRequestSubKeys(
+    VOID
+    )
+{
+    PMONITOR_CONTEXT    Context = &MonitorContext;
+    BOOLEAN             Found;
+    HRESULT             Error;
 
-fail3:
-    Log("fail3");
+    Log("====>");
 
-    free(SubKeyName);
+    Found = FALSE;
 
-fail2:
-    Log("fail2");
+    Error = RegEnumSubKeys(Context->RequestKey,
+                           CheckRequestSubKey,
+                           &Found);
+    if (Error != ERROR_SUCCESS)
+        goto fail1;
+
+    if (!Found) {
+        Error = RegDeleteValue(Context->ParametersKey,
+                               "RebootCount");
+        if (Error == ERROR_SUCCESS)
+            (VOID) RegFlushKey(Context->ParametersKey);
+    }
+
+    Log("<====");
+
+    return;
 
 fail1:
     Error = GetLastError();
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 06 08:45:35 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 06 Feb 2026 08:45:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1222919.1530608 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voHT5-0003j4-8T; Fri, 06 Feb 2026 08:45:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1222919.1530608; Fri, 06 Feb 2026 08:45:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voHT5-0003il-2H; Fri, 06 Feb 2026 08:45:35 +0000
Received: by outflank-mailman (input) for mailman id 1222919;
 Fri, 06 Feb 2026 08:45:34 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gVqx=AK=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1voHT4-0003hw-KU
 for win-pv-devel@lists.xenproject.org; Fri, 06 Feb 2026 08:45:34 +0000
Received: from na1pdmzitismtp02.tibco.com (na1pdmzitismtp02.tibco.com
 [160.101.131.9]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 32bf6b65-0338-11f1-b161-2bf370ae4941;
 Fri, 06 Feb 2026 09:45:33 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id 6F04981392E1;
 Fri,  6 Feb 2026 03:45:11 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 32bf6b65-0338-11f1-b161-2bf370ae4941
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>,
	david ambu <david.preetham@cloud.com>
Subject: [PATCH 5/5] Replace RegisterEventSource with TraceLoggingRegister
Date: Fri,  6 Feb 2026 08:45:24 +0000
Message-ID: <20260206084525.1356-5-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <20260206084525.1356-1-owen.smith@citrix.com>
References: <20260206084525.1356-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

- Added TraceLogging levels for Information and Error events.
- Replaced RegisterEventSource due to potential security issues.

Signed-off-by: david ambu <david.preetham@cloud.com>

* defined seperate macros for Info and Error logging
* use a switch on log level, rather than if/else

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 290 ++++++++++++++++++++++--------------------
 1 file changed, 150 insertions(+), 140 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 77d7dd8..a9b69f3 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -40,6 +40,8 @@
 #include <powrprof.h>
 #include <malloc.h>
 #include <assert.h>
+#include <TraceLoggingProvider.h>
+#include <winmeta.h>
 
 #include <version.h>
 
@@ -56,7 +58,6 @@ typedef struct _MONITOR_CONTEXT {
     SERVICE_STATUS          Status;
     SERVICE_STATUS_HANDLE   Service;
     HKEY                    ParametersKey;
-    HANDLE                  EventLog;
     HANDLE                  StopEvent;
     HANDLE                  RequestEvent;
     HANDLE                  Timer;
@@ -96,17 +97,25 @@ MONITOR_CONTEXT MonitorContext;
 #define STORAGE_CLASS_GUID \
         "{4d36e97b-e325-11ce-bfc1-08002be10318}"
 
+TRACELOGGING_DEFINE_PROVIDER(g_xenbus_monitor,
+                             MONITOR_NAME,
+                             //{E8ADEEB7-6DD1-447E-A49B-A6571CC74039}
+                             (0xe8adeeb7, 0x6dd1, 0x447e, 0xa4, 0x9b, 0xa6, 0x57, 0x1c, 0xc7, 0x40, 0x39)
+                            );
+
+typedef enum {
+    LOG_INFO,
+    LOG_ERROR
+} LOG_LEVEL;
+
 static VOID
 #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
 __Log(
+    _In_ LOG_LEVEL      Level,
     _In_ PCSTR          Format,
     ...
     )
 {
-#if DBG
-    PMONITOR_CONTEXT    Context = &MonitorContext;
-    const TCHAR         *Strings[1];
-#endif
     TCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
     va_list             Arguments;
     size_t              Length;
@@ -133,24 +142,31 @@ __Log(
 
     OutputDebugString(Buffer);
 
-#if DBG
-    Strings[0] = Buffer;
-
-    if (Context->EventLog != NULL)
-        ReportEvent(Context->EventLog,
-                    EVENTLOG_INFORMATION_TYPE,
-                    0,
-                    MONITOR_LOG,
-                    NULL,
-                    ARRAYSIZE(Strings),
-                    0,
-                    Strings,
-                    NULL);
-#endif
+    switch (Level) {
+    case LOG_INFO:
+        TraceLoggingWrite(g_xenbus_monitor,
+            "Information",
+            TraceLoggingLevel(WINEVENT_LEVEL_INFO),
+            TraceLoggingString(Buffer, "Info")
+        );
+        break;
+    case LOG_ERROR:
+        TraceLoggingWrite(g_xenbus_monitor,
+            "Error",
+            TraceLoggingLevel(WINEVENT_LEVEL_ERROR),
+            TraceLoggingString(Buffer, "Error")
+        );
+        break;
+    default:
+        break;
+    }
 }
 
-#define Log(_Format, ...) \
-        __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
+#define LogInfo(_Format, ...) \
+        __Log(LOG_INFO, __MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
+
+#define LogError(_Format, ...) \
+        __Log(LOG_ERROR, __MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
 
 static PTSTR
 GetErrorMessage(
@@ -215,7 +231,7 @@ ReportStatus(
     BOOL                Success;
     HRESULT             Error;
 
-    Log("====> (%s)", ServiceStateName(CurrentState));
+    LogInfo("====> (%s)", ServiceStateName(CurrentState));
 
     Context->Status.dwCurrentState = CurrentState;
     Context->Status.dwWin32ExitCode = Win32ExitCode;
@@ -239,7 +255,7 @@ ReportStatus(
     if (!Success)
         goto fail1;
 
-    Log("<====");
+    LogInfo("<====");
 
     return;
 
@@ -249,7 +265,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -326,11 +342,11 @@ DoReboot(
     _In_ DWORD  Timeout
     )
 {
-    Log("waiting for pending install events...");
+    LogInfo("waiting for pending install events...");
 
     (VOID) CM_WaitNoPendingInstallEvents(INFINITE);
 
-    Log("initiating shutdown...");
+    LogInfo("initiating shutdown...");
 
 #pragma prefast(suppress:28159)
     (VOID) InitiateSystemShutdownEx(NULL,
@@ -366,7 +382,7 @@ GetPromptTimeout(
         Type != REG_DWORD)
         Value = 0;
 
-    Log("%u", Value);
+    LogInfo("%u", Value);
 
     return Value;
 }
@@ -445,18 +461,18 @@ GetDisplayName(
     return DisplayName;
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
     free(DisplayName);
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     RegCloseKey(ServiceKey);
 
@@ -466,7 +482,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -531,7 +547,7 @@ DoPromptForReboot(
         WTS_CONNECTSTATE_CLASS  State = SessionInfo[Index].State;
         DWORD                   Response;
 
-        Log("[%u]: %s [%s]",
+        LogInfo("[%u]: %s [%s]",
             SessionId,
             Name,
             WTSStateName(State));
@@ -565,7 +581,7 @@ DoPromptForReboot(
     return ERROR_SUCCESS;
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
     *Prompt->PResponse = 0;
 
 fail1:
@@ -598,7 +614,7 @@ PromptForReboot(
         return;
     Context->RebootPrompted = TRUE;
 
-    Log("====> (%s)", DriverName);
+    LogInfo("====> (%s)", DriverName);
 
     Prompt = calloc(1, sizeof (REBOOT_PROMPT));
     if (Prompt == NULL) {
@@ -665,20 +681,20 @@ PromptForReboot(
     return;
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
     free(DisplayName);
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -772,7 +788,7 @@ TryAutoReboot(
     if (RebootCount >= AutoReboot)
         goto prompt;
 
-    Log("AutoRebooting (reboot %u of %u)\n",
+    LogInfo("AutoRebooting (reboot %u of %u)\n",
         RebootCount,
         AutoReboot);
 
@@ -844,18 +860,18 @@ done:
     return;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(DisplayName);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -878,7 +894,7 @@ RegEnumSubKeys(
     DWORD               Index;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     Error = RegQueryInfoKey(BaseKey,
                             NULL,
@@ -920,7 +936,7 @@ RegEnumSubKeys(
             goto fail3;
         }
 
-        Log("%s", SubKeyName);
+        LogInfo("%s", SubKeyName);
 
         if (!Callback(BaseKey, SubKeyName, Context))
             break;
@@ -931,12 +947,12 @@ RegEnumSubKeys(
     return ERROR_SUCCESS;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(SubKeyName);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -944,7 +960,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1008,7 +1024,7 @@ CheckRequestSubKeys(
     BOOLEAN             Found;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     Found = FALSE;
 
@@ -1025,7 +1041,7 @@ CheckRequestSubKeys(
             (VOID) RegFlushKey(Context->ParametersKey);
     }
 
-    Log("<====");
+    LogInfo("<====");
 
     return;
 
@@ -1035,7 +1051,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -1048,7 +1064,7 @@ CheckRequestKey(
     PMONITOR_CONTEXT    Context = &MonitorContext;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     CheckRequestSubKeys();
 
@@ -1061,7 +1077,7 @@ CheckRequestKey(
     if (Error != ERROR_SUCCESS)
         goto fail1;
 
-    Log("<====");
+    LogInfo("<====");
 
     return;
 
@@ -1071,7 +1087,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -1086,7 +1102,7 @@ AcquireShutdownPrivilege(
     BOOL                Success;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     New.PrivilegeCount = 1;
 
@@ -1118,17 +1134,17 @@ AcquireShutdownPrivilege(
 
     CloseHandle(Token);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     CloseHandle(Token);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1136,7 +1152,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1194,20 +1210,20 @@ GetRequestKeyName(
         goto fail4;
     }
 
-    Log("%s", *RequestKeyName);
+    LogInfo("%s", *RequestKeyName);
 
     return TRUE;
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(*RequestKeyName);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1215,7 +1231,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1321,37 +1337,37 @@ GetDialogParameters(
     return TRUE;
 
 fail10:
-    Log("fail10");
+    LogError("fail10");
 
 fail9:
-    Log("fail9");
+    LogError("fail9");
 
     free(Context->Question);
 
 fail8:
-    Log("fail8");
+    LogError("fail8");
 
 fail7:
-    Log("fail7");
+    LogError("fail7");
 
 fail6:
-    Log("fail6");
+    LogError("fail6");
 
     free(Context->Text);
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(Context->Title);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1359,7 +1375,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1392,7 +1408,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1494,24 +1510,24 @@ done:
     return TRUE;
 
 fail6:
-    Log("fail6");
+    LogError("fail6");
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(Value);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
-    Log("fail1");
+    LogError("fail1");
 
     return TRUE;
 }
@@ -1574,10 +1590,10 @@ RemoveAllStartOverrides(
     return TRUE;
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
-    Log("fail1");
+    LogError("fail1");
 
     return FALSE;
 }
@@ -1597,7 +1613,10 @@ MonitorMain(
     UNREFERENCED_PARAMETER(argc);
     UNREFERENCED_PARAMETER(argv);
 
-    Log("====>");
+    if (TraceLoggingRegister(g_xenbus_monitor) != ERROR_SUCCESS)
+        LogInfo("TraceLoggingRegister failed");
+
+    LogInfo("====>");
 
     (VOID) RemoveStartOverride("stornvme");
     (VOID) RemoveAllStartOverrides();
@@ -1620,11 +1639,6 @@ MonitorMain(
     if (Context->Service == NULL)
         goto fail3;
 
-    Context->EventLog = RegisterEventSource(NULL,
-                                            MONITOR_NAME);
-    if (Context->EventLog == NULL)
-        goto fail4;
-
     Context->Status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
     Context->Status.dwServiceSpecificExitCode = 0;
 
@@ -1636,26 +1650,26 @@ MonitorMain(
                                      NULL);
 
     if (Context->StopEvent == NULL)
-        goto fail5;
+        goto fail4;
 
     Context->RequestEvent = CreateEvent(NULL,
                                         TRUE,
                                         FALSE,
                                         NULL);
     if (Context->RequestEvent == NULL)
-        goto fail6;
+        goto fail5;
 
     Context->ResponseEvent = CreateEvent(NULL,
                                          FALSE,
                                          FALSE,
                                          NULL);
     if (Context->ResponseEvent == NULL)
-        goto fail7;
+        goto fail6;
     Context->Response = 0;
 
     Success = GetRequestKeyName(&RequestKeyName);
     if (!Success)
-        goto fail8;
+        goto fail7;
 
     Error = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
                            RequestKeyName,
@@ -1667,15 +1681,15 @@ MonitorMain(
                            &Context->RequestKey,
                            NULL);
     if (Error != ERROR_SUCCESS)
-        goto fail9;
+        goto fail8;
 
     Success = GetDialogParameters();
     if (!Success)
-        goto fail10;
+        goto fail9;
 
     Context->Timer = CreateWaitableTimer(NULL, FALSE, NULL);
     if (Context->Timer == NULL)
-        goto fail11;
+        goto fail10;
 
     DueTime.QuadPart = -10000LL * REBOOT_RETRY_DELAY;
 
@@ -1686,7 +1700,7 @@ MonitorMain(
                                NULL,
                                FALSE);
     if (!Success)
-        goto fail12;
+        goto fail11;
 
     SetEvent(Context->RequestEvent);
 
@@ -1701,12 +1715,12 @@ MonitorMain(
         Events[2] = Context->ResponseEvent;
         Events[3] = Context->Timer;
 
-        Log("waiting (%u)...", ARRAYSIZE(Events));
+        LogInfo("waiting (%u)...", ARRAYSIZE(Events));
         Object = WaitForMultipleObjects(ARRAYSIZE(Events),
                                         Events,
                                         FALSE,
                                         INFINITE);
-        Log("awake");
+        LogInfo("awake");
 
         switch (Object) {
         case WAIT_OBJECT_0:
@@ -1752,65 +1766,59 @@ done:
 
     ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
 
-    (VOID) DeregisterEventSource(Context->EventLog);
-
     RegCloseKey(Context->ParametersKey);
 
     (VOID) RemoveStartOverride("stornvme");
     (VOID) RemoveAllStartOverrides();
 
-    Log("<====");
+    LogInfo("<====");
 
+    TraceLoggingUnregister(g_xenbus_monitor);
     return;
 
-fail12:
-    Log("fail12");
+fail11:
+    LogError("fail11");
 
     CloseHandle(Context->Timer);
 
-fail11:
-    Log("fail11");
-
 fail10:
-    Log("fail10");
-
-    RegCloseKey(Context->RequestKey);
+    LogError("fail10");
 
 fail9:
-    Log("fail9");
+    LogError("fail9");
 
-    free(RequestKeyName);
+    RegCloseKey(Context->RequestKey);
 
 fail8:
-    Log("fail8");
+    LogError("fail8");
 
-    CloseHandle(Context->ResponseEvent);
+    free(RequestKeyName);
 
 fail7:
-    Log("fail7");
+    LogError("fail7");
 
-    CloseHandle(Context->RequestEvent);
+    CloseHandle(Context->ResponseEvent);
 
 fail6:
-    Log("fail6");
+    LogError("fail6");
 
-    CloseHandle(Context->StopEvent);
+    CloseHandle(Context->RequestEvent);
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
-    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
-
-    (VOID) DeregisterEventSource(Context->EventLog);
+    CloseHandle(Context->StopEvent);
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
+
+    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     RegCloseKey(Context->ParametersKey);
 
@@ -1820,9 +1828,11 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
+
+    TraceLoggingUnregister(g_xenbus_monitor);
 }
 
 static BOOL
@@ -1835,7 +1845,7 @@ MonitorCreate(
     TCHAR       Path[MAX_PATH];
     HRESULT     Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     if(!GetModuleFileName(NULL, Path, MAX_PATH))
         goto fail1;
@@ -1867,17 +1877,17 @@ MonitorCreate(
     CloseServiceHandle(Service);
     CloseServiceHandle(SCManager);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     CloseServiceHandle(SCManager);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1885,7 +1895,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1903,7 +1913,7 @@ MonitorDelete(
     SERVICE_STATUS      Status;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     SCManager = OpenSCManager(NULL,
                               NULL,
@@ -1934,20 +1944,20 @@ MonitorDelete(
     CloseServiceHandle(Service);
     CloseServiceHandle(SCManager);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     CloseServiceHandle(Service);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     CloseServiceHandle(SCManager);
 
@@ -1957,7 +1967,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1975,14 +1985,14 @@ MonitorEntry(
     };
     HRESULT             Error;
 
-    Log("%s (%s) ====>",
+    LogInfo("%s (%s) ====>",
         MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
         DAY_STR "/" MONTH_STR "/" YEAR_STR);
 
     if (!StartServiceCtrlDispatcher(Table))
         goto fail1;
 
-    Log("%s (%s) <====",
+    LogInfo("%s (%s) <====",
         MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
         DAY_STR "/" MONTH_STR "/" YEAR_STR);
 
@@ -1994,7 +2004,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 06 08:45:46 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 06 Feb 2026 08:45:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1222921.1530611 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voHTG-0003qD-6d; Fri, 06 Feb 2026 08:45:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1222921.1530611; Fri, 06 Feb 2026 08:45:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voHTG-0003q8-44; Fri, 06 Feb 2026 08:45:46 +0000
Received: by outflank-mailman (input) for mailman id 1222921;
 Fri, 06 Feb 2026 08:45:45 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gVqx=AK=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1voHTF-0003hq-3z
 for win-pv-devel@lists.xenproject.org; Fri, 06 Feb 2026 08:45:45 +0000
Received: from na1pdmzitismtp02.tibco.com (na1pdmzitismtp02.tibco.com
 [160.101.131.9]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 31f95882-0338-11f1-9ccf-f158ae23cfc8;
 Fri, 06 Feb 2026 09:45:33 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id 416C581392E6;
 Fri,  6 Feb 2026 03:45:10 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 31f95882-0338-11f1-9ccf-f158ae23cfc8
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 3/5] Remove StartOverride from all PCI storage adapters
Date: Fri,  6 Feb 2026 08:45:22 +0000
Message-ID: <20260206084525.1356-3-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <20260206084525.1356-1-owen.smith@citrix.com>
References: <20260206084525.1356-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Its possible to install non-Microsoft NVMe drivers on the emulated
NVMe device. During upgrades, the VM requires a reboot using the emulated
devices, but if the driver assigned for the emulated device has a StartOverride
setting, then its likely not started which results in a 0x7B bugcheck.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 191 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 191 insertions(+)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 52311aa..61945f0 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -90,6 +90,12 @@ MONITOR_CONTEXT MonitorContext;
 #define PARAMETERS_KEY(_Service) \
         SERVICE_KEY(_Service) ## "\\Parameters"
 
+#define ENUM_KEY(_Class) \
+        "SYSTEM\\CurrentControlSet\\Enum\\" ## _Class
+
+#define STORAGE_CLASS_GUID \
+        "{4d36e97b-e325-11ce-bfc1-08002be10318}"
+
 static VOID
 #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
 __Log(
@@ -1393,6 +1399,189 @@ fail1:
     return FALSE;
 }
 
+static BOOLEAN
+RemoveStartOverrideInstance(
+    _In_ HKEY           BaseKey,
+    _In_ PTSTR          SubKeyName,
+    _In_opt_ PVOID      Context
+    )
+{
+    DWORD               Type;
+    PTSTR               Value;
+    DWORD               ValueLength;
+    DWORD               MaxValueLength;
+    HKEY                SubKey;
+    HRESULT             Error;
+
+    UNREFERENCED_PARAMETER(Context);
+
+    Error = RegOpenKeyEx(BaseKey,
+                         SubKeyName,
+                         0,
+                         KEY_READ,
+                         &SubKey);
+    if (Error != ERROR_SUCCESS)
+        return TRUE;
+
+    Error = RegQueryInfoKey(SubKey,
+                            NULL,
+                            NULL,
+                            NULL,
+                            NULL,
+                            NULL,
+                            NULL,
+                            NULL,
+                            NULL,
+                            &MaxValueLength,
+                            NULL,
+                            NULL);
+    if (Error != ERROR_SUCCESS) {
+        SetLastError(Error);
+        goto fail1;
+    }
+
+    ValueLength = MaxValueLength + sizeof (TCHAR);
+
+    Value = calloc(1, ValueLength);
+    if (Value == NULL)
+        goto fail2;
+
+    Error = RegQueryValueEx(SubKey,
+                            "ClassGUID",
+                            NULL,
+                            &Type,
+                            (LPBYTE)Value,
+                            &ValueLength);
+    if (Error != ERROR_SUCCESS) {
+        SetLastError(Error);
+        goto fail3;
+    }
+
+    if (Type != REG_SZ) {
+        SetLastError(ERROR_BAD_FORMAT);
+        goto fail4;
+    }
+
+    if (_tcsnicmp(Value, STORAGE_CLASS_GUID, ValueLength) != 0)
+        goto done;
+
+    ValueLength = MaxValueLength + sizeof (TCHAR);
+    memset(Value, 0, ValueLength);
+
+    Error = RegQueryValueEx(SubKey,
+                            "Service",
+                            NULL,
+                            &Type,
+                            (LPBYTE)Value,
+                            &ValueLength);
+    if (Error != ERROR_SUCCESS) {
+        SetLastError(Error);
+        goto fail5;
+    }
+
+    if (Type != REG_SZ) {
+        SetLastError(ERROR_BAD_FORMAT);
+        goto fail6;
+    }
+
+    RemoveStartOverride(Value);
+
+done:
+    free(Value);
+
+    RegCloseKey(SubKey);
+
+    return TRUE;
+
+fail6:
+    Log("fail6");
+
+fail5:
+    Log("fail5");
+
+fail4:
+    Log("fail4");
+
+fail3:
+    Log("fail3");
+
+    free(Value);
+
+fail2:
+    Log("fail2");
+
+fail1:
+    Log("fail1");
+
+    return TRUE;
+}
+
+static BOOLEAN
+RemoveStartOverrideDevice(
+    _In_ HKEY           BaseKey,
+    _In_ PTSTR          SubKeyName,
+    _In_opt_ PVOID      Context
+    )
+{
+    HKEY                SubKey;
+    HRESULT             Error;
+
+    UNREFERENCED_PARAMETER(Context);
+
+    Error = RegOpenKeyEx(BaseKey,
+                         SubKeyName,
+                         0,
+                         KEY_READ,
+                         &SubKey);
+    if (Error != ERROR_SUCCESS)
+        return TRUE;
+
+    (VOID) RegEnumSubKeys(SubKey,
+                          RemoveStartOverrideInstance,
+                          NULL);
+
+    RegCloseKey(SubKey);
+
+    return TRUE;
+}
+
+static BOOL
+RemoveAllStartOverrides(
+    VOID
+    )
+{
+    HKEY            EnumKey;
+    HRESULT         Error;
+
+    Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+                         ENUM_KEY("PCI"),
+                         0,
+                         KEY_READ,
+                         &EnumKey);
+    if (Error != ERROR_SUCCESS) {
+        goto fail1;
+    }
+
+    Error = RegEnumSubKeys(EnumKey,
+                           RemoveStartOverrideDevice,
+                           NULL);
+    if (Error != ERROR_SUCCESS) {
+        goto fail2;
+    }
+
+    RegCloseKey(EnumKey);
+
+    return TRUE;
+
+fail2:
+    Log("fail2");
+
+fail1:
+    Log("fail1");
+
+    return FALSE;
+}
+
 VOID WINAPI
 MonitorMain(
     _In_    DWORD       argc,
@@ -1411,6 +1600,7 @@ MonitorMain(
     Log("====>");
 
     (VOID) RemoveStartOverride("stornvme");
+    (VOID) RemoveAllStartOverrides();
 
     Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                          PARAMETERS_KEY(__MODULE__),
@@ -1565,6 +1755,7 @@ done:
 
     CloseHandle(Context->ParametersKey);
     (VOID) RemoveStartOverride("stornvme");
+    (VOID) RemoveAllStartOverrides();
 
     Log("<====");
 
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 06 08:45:48 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 06 Feb 2026 08:45:48 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1222927.1530615 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voHTI-0003sp-7m; Fri, 06 Feb 2026 08:45:48 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1222927.1530615; Fri, 06 Feb 2026 08:45:48 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voHTI-0003si-5B; Fri, 06 Feb 2026 08:45:48 +0000
Received: by outflank-mailman (input) for mailman id 1222927;
 Fri, 06 Feb 2026 08:45:47 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gVqx=AK=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1voHTH-0003hq-3z
 for win-pv-devel@lists.xenproject.org; Fri, 06 Feb 2026 08:45:47 +0000
Received: from na1pdmzitismtp02.tibco.com (na1pdmzitismtp02.tibco.com
 [160.101.131.9]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 325880b3-0338-11f1-9ccf-f158ae23cfc8;
 Fri, 06 Feb 2026 09:45:33 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id D138181392DC;
 Fri,  6 Feb 2026 03:45:10 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 325880b3-0338-11f1-9ccf-f158ae23cfc8
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: david ambu <david.preetham@cloud.com>
Subject: [PATCH 4/5] registry: use RegCloseKey for RequestKey and ParametersKey
Date: Fri,  6 Feb 2026 08:45:23 +0000
Message-ID: <20260206084525.1356-4-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <20260206084525.1356-1-owen.smith@citrix.com>
References: <20260206084525.1356-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

From: david ambu <david.preetham@cloud.com>

CloseHandle silently fails for HKEY.

Signed-off-by: david ambu <david.preetham@cloud.com>
---
 src/monitor/monitor.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 61945f0..77d7dd8 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1743,7 +1743,8 @@ done:
     free(Context->Question);
     free(Context->Text);
     free(Context->Title);
-    CloseHandle(Context->RequestKey);
+
+    RegCloseKey(Context->RequestKey);
     free(RequestKeyName);
     CloseHandle(Context->ResponseEvent);
     CloseHandle(Context->RequestEvent);
@@ -1753,7 +1754,8 @@ done:
 
     (VOID) DeregisterEventSource(Context->EventLog);
 
-    CloseHandle(Context->ParametersKey);
+    RegCloseKey(Context->ParametersKey);
+
     (VOID) RemoveStartOverride("stornvme");
     (VOID) RemoveAllStartOverrides();
 
@@ -1772,7 +1774,7 @@ fail11:
 fail10:
     Log("fail10");
 
-    CloseHandle(Context->RequestKey);
+    RegCloseKey(Context->RequestKey);
 
 fail9:
     Log("fail9");
@@ -1810,7 +1812,7 @@ fail3:
 fail2:
     Log("fail2");
 
-    CloseHandle(Context->ParametersKey);
+    RegCloseKey(Context->ParametersKey);
 
 fail1:
     Error = GetLastError();
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 06 08:54:33 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 06 Feb 2026 08:54:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1222961.1530619 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voHbk-00058c-Rz; Fri, 06 Feb 2026 08:54:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1222961.1530619; Fri, 06 Feb 2026 08:54:32 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voHbk-00058V-PQ; Fri, 06 Feb 2026 08:54:32 +0000
Received: by outflank-mailman (input) for mailman id 1222961;
 Fri, 06 Feb 2026 08:54:32 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gVqx=AK=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1voHbk-00058P-0m
 for win-pv-devel@lists.xenproject.org; Fri, 06 Feb 2026 08:54:32 +0000
Received: from na1pdmzitismtp01.tibco.com (na1pdmzitismtp01.corp.cloud.com
 [160.101.131.8]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 7224f451-0339-11f1-9ccf-f158ae23cfc8;
 Fri, 06 Feb 2026 09:54:29 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp01.tibco.com (Postfix) with ESMTP id ECFB342067D3;
 Fri,  6 Feb 2026 03:54:17 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7224f451-0339-11f1-9ccf-f158ae23cfc8
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH XenIface] Remove attempts to open ParametersKey for WRITE
Date: Fri,  6 Feb 2026 08:54:24 +0000
Message-ID: <20260206085425.1397-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Registry isolation prevents drivers from openning the parameters key
for WRITE access, as this key is restricted to read only access.
This call currently fails without issue, remove the attempt to write,
the calling thread and all callers.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/xeniface/fdo.c | 132 +++------------------------------------------
 src/xeniface/fdo.h |   3 --
 src/xeniface/wmi.c |   1 -
 3 files changed, 8 insertions(+), 128 deletions(-)

diff --git a/src/xeniface/fdo.c b/src/xeniface/fdo.c
index a2cb713..ec56e42 100644
--- a/src/xeniface/fdo.c
+++ b/src/xeniface/fdo.c
@@ -61,106 +61,6 @@
 
 #define MAXNAMELEN  128
 
-static NTSTATUS
-FdoInitialiseXSRegistryEntries(
-    IN PXENIFACE_FDO        Fdo
-    )
-{
-    ANSI_STRING             Ansi[2];
-    HANDLE                  Key;
-    PCHAR                   Value;
-    NTSTATUS                status;
-
-    NT_ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
-
-    status = XENBUS_STORE(Read,
-                          &Fdo->StoreInterface,
-                          NULL,
-                          NULL,
-                          "/mh/boot-time/management-mac-address",
-                          &Value);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = RegistryOpenParametersKey(KEY_WRITE, &Key);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    RtlInitAnsiString(&Ansi[0], Value);
-    RtlZeroMemory(&Ansi[1], sizeof(ANSI_STRING));
-
-    status = RegistryUpdateSzValue(Key,
-                                   "MgmtMacAddr",
-                                   REG_SZ,
-                                   &Ansi[0]);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    RegistryCloseKey(Key);
-
-    XENBUS_STORE(Free, &Fdo->StoreInterface, Value);
-
-    return STATUS_SUCCESS;
-
-fail3:
-    Error("fail3\n");
-
-    RegistryCloseKey(Key);
-
-fail2:
-    Error("fail2\n");
-
-    XENBUS_STORE(Free, &Fdo->StoreInterface, Value);
-
-fail1:
-    Error("fail1 %08x\n", status);
-
-    return status;
-}
-
-#define REGISTRY_WRITE_EVENT 0
-#define REGISTRY_THREAD_END_EVENT 1
-#define REGISTRY_EVENTS 2
-
-static NTSTATUS FdoRegistryThreadHandler(IN  PXENIFACE_THREAD  Self,
-                                         IN  PVOID StartContext) {
-    KEVENT* threadevents[REGISTRY_EVENTS];
-    PXENIFACE_FDO Fdo = (PXENIFACE_FDO)StartContext;
-    NTSTATUS status;
-
-    PKEVENT             Event;
-
-    Event = ThreadGetEvent(Self);
-
-    threadevents[REGISTRY_WRITE_EVENT] = &Fdo->registryWriteEvent;
-    threadevents[REGISTRY_THREAD_END_EVENT] = Event;
-
-    for(;;) {
-
-        status = KeWaitForMultipleObjects(REGISTRY_EVENTS, (PVOID *)threadevents, WaitAny, Executive, KernelMode, TRUE, NULL, NULL);
-        if ((status>=STATUS_WAIT_0) && (status < STATUS_WAIT_0+REGISTRY_EVENTS)) {
-            if (status == STATUS_WAIT_0+REGISTRY_WRITE_EVENT) {
-                Info("WriteRegistry\n");
-                (VOID) FdoInitialiseXSRegistryEntries(Fdo);
-                KeClearEvent(threadevents[REGISTRY_WRITE_EVENT]);
-            }
-            if (status == STATUS_WAIT_0+REGISTRY_THREAD_END_EVENT) {
-                if (ThreadIsAlerted(Self))
-                    return STATUS_SUCCESS;
-                KeClearEvent(threadevents[REGISTRY_THREAD_END_EVENT]);
-            }
-
-        }
-        else if (!NT_SUCCESS(status)) {
-            Error("Registry handler thread failed %x\n", status);
-            return status;
-        }
-    }
-
-}
-
-
-
 static FORCEINLINE PVOID
 __FdoAllocate(
     IN  ULONG   Length
@@ -2563,17 +2463,9 @@ FdoCreate(
     InitializeListHead(&Dx->ListEntry);
     Fdo->References = 1;
 
-    (VOID) FdoInitialiseXSRegistryEntries(Fdo);
-
-    KeInitializeEvent(&Fdo->registryWriteEvent, NotificationEvent, FALSE);
-
-    status = ThreadCreate(FdoRegistryThreadHandler, Fdo, &Fdo->registryThread);
-    if (!NT_SUCCESS(status))
-        goto fail13;
-
     status = WmiInitialize(Fdo);
     if (!NT_SUCCESS(status))
-        goto fail14;
+        goto fail13;
 
     KeInitializeSpinLock(&Fdo->StoreWatchLock);
     InitializeListHead(&Fdo->StoreWatchList);
@@ -2597,7 +2489,7 @@ FdoCreate(
                                CsqReleaseLock,
                                CsqCompleteCanceledIrp);
     if (!NT_SUCCESS(status))
-        goto fail15;
+        goto fail14;
 
     Info("%p (%s)\n",
          FunctionDeviceObject,
@@ -2608,8 +2500,8 @@ FdoCreate(
 
     return STATUS_SUCCESS;
 
-fail15:
-    Error("fail15\n");
+fail14:
+    Error("fail14\n");
 
     RtlZeroMemory(&Fdo->GnttabCacheLock, sizeof (KSPIN_LOCK));
     ASSERT(IsListEmpty(&Fdo->IrpList));
@@ -2630,16 +2522,13 @@ fail15:
 
     WmiTeardown(Fdo);
 
-fail14:
-    Error("fail14\n");
-
-    ThreadAlert(Fdo->registryThread);
-    ThreadJoin(Fdo->registryThread);
-    Fdo->registryThread = NULL;
-
 fail13:
     Error("fail13\n");
 
+    RtlZeroMemory(&Fdo->Mutex, sizeof(XENIFACE_MUTEX));
+    RtlZeroMemory(&Dx->ListEntry, sizeof(LIST_ENTRY));
+    Fdo->References = 0;
+
     RtlZeroMemory(&Fdo->GnttabInterface,
                   sizeof (XENBUS_GNTTAB_INTERFACE));
 
@@ -2773,10 +2662,6 @@ FdoDestroy(
     RtlZeroMemory(&Fdo->SuspendInterface,
                   sizeof (XENBUS_SUSPEND_INTERFACE));
 
-    ThreadAlert(Fdo->registryThread);
-    ThreadJoin(Fdo->registryThread);
-    Fdo->registryThread = NULL;
-
     ThreadAlert(Fdo->DevicePowerThread);
     ThreadJoin(Fdo->DevicePowerThread);
     Fdo->DevicePowerThread = NULL;
@@ -2793,7 +2678,6 @@ FdoDestroy(
     Fdo->Dx = NULL;
 
     WmiTeardown(Fdo);
-    RtlZeroMemory(&Fdo->registryWriteEvent, sizeof(KEVENT));
 
     RtlFreeUnicodeString(&Fdo->InterfaceName);
     RtlZeroMemory(&Fdo->InterfaceName,sizeof(UNICODE_STRING));
diff --git a/src/xeniface/fdo.h b/src/xeniface/fdo.h
index b7b86d7..9867756 100644
--- a/src/xeniface/fdo.h
+++ b/src/xeniface/fdo.h
@@ -110,9 +110,6 @@ typedef struct _XENIFACE_FDO {
     XENIFACE_MUTEX                  SessionLock;
     LIST_ENTRY                      SessionHead;
 
-    PXENIFACE_THREAD                registryThread;
-    KEVENT                          registryWriteEvent;
-
     UNICODE_STRING                  SuggestedInstanceName;
 
     UNICODE_STRING                  InterfaceName;
diff --git a/src/xeniface/wmi.c b/src/xeniface/wmi.c
index 95b4bb1..ccc2ab0 100644
--- a/src/xeniface/wmi.c
+++ b/src/xeniface/wmi.c
@@ -3122,7 +3122,6 @@ WmiFireSuspendEvent(
     )
 {
     Info("Ready to unsuspend Event\n");
-    KeSetEvent(&Fdo->registryWriteEvent, IO_NO_INCREMENT, FALSE);
 
     if (!Fdo->WmiReady)
         return;
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 06 08:57:21 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 06 Feb 2026 08:57:21 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1222969.1530624 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voHeS-0005Db-3Q; Fri, 06 Feb 2026 08:57:20 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1222969.1530624; Fri, 06 Feb 2026 08:57:20 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voHeS-0005DU-0V; Fri, 06 Feb 2026 08:57:20 +0000
Received: by outflank-mailman (input) for mailman id 1222969;
 Fri, 06 Feb 2026 08:57:18 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gVqx=AK=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1voHeQ-0005DO-N6
 for win-pv-devel@lists.xenproject.org; Fri, 06 Feb 2026 08:57:18 +0000
Received: from BL0PR03CU003.outbound.protection.outlook.com
 (mail-eastusazlp170120007.outbound.protection.outlook.com
 [2a01:111:f403:c101::7])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id d3bd318a-0339-11f1-9ccf-f158ae23cfc8;
 Fri, 06 Feb 2026 09:57:12 +0100 (CET)
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by IA3PR03MB7739.namprd03.prod.outlook.com (2603:10b6:208:503::10)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9587.14; Fri, 6 Feb
 2026 08:57:09 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9587.013; Fri, 6 Feb 2026
 08:57:09 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: d3bd318a-0339-11f1-9ccf-f158ae23cfc8
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=Bkmg0VfGJtH1ej0Zu7qJqLmTzCe2cD7T/dY6kR8B1kPbfioEUTaVtWXjqJDTtqDk/FGFXeHPSbuH4/JbOm9JXxr0QDvjjV83EDdWOmBCJA9v0MfJRIRAuxYr/9STRLQ/+PnpVkqOFafmk9+aqjEQIucGb9ptX/I+EJ9N1S/PkXPlA4gALuHrBeR+DP/rchpandAolXq3v8iYTPpLUNoFPDDR8SGkYfvxh6jBIXKiboLpXcBCy/ckBEV6nFcq6CkaEmvWZe9QXn62GsE+ox1rTDKBZQn1p94xm6LJHlwMCfgIkNntHsUvTE6R73a5oHxCaFclDwEvBmqIi7U08KlUQA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector10001;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=nwYMz+wibSXYbIm52k3WgDyDEZ/SImRaStsuSXJ6PG4=;
 b=jOPrf3Dms7jhVgO5VCei05PVzfHRAa5kSJJiG0u8hnRAlJ0H6Bv0qbU4thCRVS4YSm1DHL6Oc7nfPYcHLonre77W8gaNZqLcjKxrtcxRG/+6yc0W8ne3hg+UTgrUUXBLmm8+iDDxmHsLDObEuL0T9Dq2Bk5kmM0b3f+ew+i2toHZTPvuILkotXfgcPmFFj+P5+eev8+FdjmMKVtncEW3vP2YOGskq/YGVa29GT5ph3X1ACQO9tiUr13c4csWYf3oWrhNxLJLXrFhvtep66z+cxsz53eRyK6Twh4FSmP2Qa1UNYK5J0eN7TiefKkCz/nbcQiqzuT4YJn9XiKJ6MtnbQ==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=nwYMz+wibSXYbIm52k3WgDyDEZ/SImRaStsuSXJ6PG4=;
 b=r1NlieppH69vVGW11FCsoiWVaEH5yf8lJk25yzTLwK9Od1G3C1eemAPfGFlvleGH3ZHx4evElIQS9NSjX+xatr4L5znkLQbU40NOGofTuJImY8HVVSNO+7I4D9kCsjBfn4I95DjNMo37tw6QasloSGwo5fUc5NjH8IcRxo2yuO8=
From: Owen Smith <owen.smith@citrix.com>
To: "win-pv-devel@lists.xenproject.org" <win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH 1/5] Update my email address
Thread-Topic: [PATCH 1/5] Update my email address
Thread-Index: AQHcl0T0ZnFAhPI4n0yyqzxTvQXzcLV1XnyL
Date: Fri, 6 Feb 2026 08:57:09 +0000
Message-ID:
 <SA6PR03MB77609B10AC0A5678A6129D4EFE66A@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <20260206084525.1356-1-owen.smith@citrix.com>
In-Reply-To: <20260206084525.1356-1-owen.smith@citrix.com>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|IA3PR03MB7739:EE_
x-ms-office365-filtering-correlation-id: 1f2429d4-75e7-41cd-7cf7-08de655db626
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|376014|366016|1800799024|38070700021|7053199007;
x-microsoft-antispam-message-info:
 =?us-ascii?Q?WxJg47OogSKuQYI7f8FnHSx3at/AGuj7kII/JZEoB1EcIWC1rYk5jiEeDTnv?=
 =?us-ascii?Q?O7zpYSDjGdr+KcghTzuLrjgoENHMgQZQkQg1KCVWmAk1cW/of1QTQsuiVtC0?=
 =?us-ascii?Q?cV4TRXIDNgqKwWtM1hAiBJu7jOQoPQyMs5onLCJI5+VZ38Fgi+AgOkFk/N9k?=
 =?us-ascii?Q?BOwmI0c8nsWjCuN+VgzlgTDaUdUULGp9Wt1CHOSk6KVHpjIwghim8sEB4UVr?=
 =?us-ascii?Q?NmCIFp9K2pLaXPgq9PIfn88XosV47+6gtSwOLIfd2rjr5j/Prz8TIxkqLi99?=
 =?us-ascii?Q?InhS0bZgG6wJISlheWXaXCbg1QXEAjBdFZ/pbXqDVarzbqFiMS6qpkSUMFcP?=
 =?us-ascii?Q?tnkjJbGSa2DtSdv5A3M20kddJg2T4EuLTEEDlloBgwNlwERVQ602vzAGHoMT?=
 =?us-ascii?Q?TnKJdBErZ/lQIaQ1eoCPltiQoBtH6WtiQzg+pe3S7pYWFYOirv/H6Tb3+hlt?=
 =?us-ascii?Q?zM6gP7Qyi0ge+UHq/Lz7FpJZSioQvDjeqk8bly7ZcaDuvP31SO4oCmKY3EhO?=
 =?us-ascii?Q?HcJ6AhHypXfmDLhi05mrUQtnvfDKMMlZ4sf/aMbvrJVWAKdTOGapDrku8V0H?=
 =?us-ascii?Q?XxrRnEEV2q0Z1rkmWtgLqQ3vvArPqpHP8cPkWy8snBA8q4Wmw/be/oCTC5Xw?=
 =?us-ascii?Q?G/UeLOeRhtEctv4Pa25dcYBVRV5yEeHleI5Yf9Vq5H5iGNmd4DT+x4kfDTph?=
 =?us-ascii?Q?DDhca3WnlAdfKWRxuEsCXXzfSQQlQZ7lEAnL+WC921moWk9IdfWgvgL9qMJJ?=
 =?us-ascii?Q?1sN00mkHspO12oSv3pVS5Ok482KJ6Ci7P162K1Sdagasz4yOreICM2k51aPH?=
 =?us-ascii?Q?CrQeYkjqNZU1v0b/TXwfo+CYbeW8nC09SgQb/qHEQc9NorsLNmEohoPDkNDf?=
 =?us-ascii?Q?7hxZ8jdLrqhyZEZZf6haDmiYqGDmqZ6hhgVlM6sc9yX8Ao9NyDovKlQrNlaK?=
 =?us-ascii?Q?JEY731O4GORn7NiSLsU7C2wLiud5vk4BevKyG8BgqbHbWmZCotAstuX86WPV?=
 =?us-ascii?Q?Zyq+QsX4oiUitPxmILSxkXuF8o5m5cq95y//e46Jd1Re9aIad7RmHEj/jqeQ?=
 =?us-ascii?Q?KS912Utd+RNx41e6Th00qXbsPJquPcwCMHslNBYBvCE1dayjdPLzBq6NnThw?=
 =?us-ascii?Q?K32qWHeXg8yKtN2rFVc69BYZFoLBe7X60MvxHsyj3d5n8ajePSfxHPBKJ+F8?=
 =?us-ascii?Q?gOFY5/63xdjupvFxPX2yw8XC7sqbtnXrwF6nP8qWT1rc84FcZkMjZ2y1NDeZ?=
 =?us-ascii?Q?wTFRp20mU7iwM3JfZxpQ4eP7kUVzuxSthYVf2mW1+X5Q23/LLLCkcEkht2aY?=
 =?us-ascii?Q?v1jtXtn6kkwZ+sENi03L/f1BBiaryKMGWGSrGyy++qQYKLIWh09IX63xGudK?=
 =?us-ascii?Q?7B10AZdvNgQbSYCfIR+xzaHG4+Xv7D2o+wqlp9TKyFXhVLoPmFGcjAebBUVc?=
 =?us-ascii?Q?lEgZA8k+kAncOoVQqEZmDrQhWqJetHckjDnQnIqB2PFlEnNe4hKJbIEGdE6F?=
 =?us-ascii?Q?u0Vgb9Gw4PLfCZlLs6lW90JcPqbDFH+atXErXOkwPIc6UuNZkwUZrEZMc9Ie?=
 =?us-ascii?Q?VQcdJJjodTNZ5lXUP0QegPol5V5Y62ZKZ1QIaqK8g7oIjrqGOOanv0OJ3S6O?=
 =?us-ascii?Q?nrpnG4fVGrm1cBSbzzyGcZA=3D?=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(38070700021)(7053199007);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?FyTstpFJwh4lYYk/hU+sF70DpiHvEc2TNsaLCNpq+fKwdlj012T5g2Uqqx1Q?=
 =?us-ascii?Q?G9qJDr+Uw2f1mJUDCHRH5IwcOmstUHUJGGEXb0rhAn30KjjCK/+gNfSHsAx2?=
 =?us-ascii?Q?41lOZrYfMwgi9Nw4YOdT9t4o++wsmuWHOGFboaYmkoPQkLn+NbHX6NqVjlDC?=
 =?us-ascii?Q?+fQ9+7nTuLPXr9kcZu7qE6mbbO37rkPDDOA5s1Fsb9WtOnva4v7zN4cqeSgx?=
 =?us-ascii?Q?ZrEP51156SRbNrRJiC1xMdy9/1ZlciUojN0E11NICap3B4/PCUk3H1evsleb?=
 =?us-ascii?Q?86Z59KqFPW4ffTGi6HrJuq2SpRvtWsltbZqrwCPH7mViJmjIk4WtQnpG7NrY?=
 =?us-ascii?Q?dQKtda4UTbmAQ1CrpNJVtcTWqbYjGEJblLEGtOiacZj3KnvILfrIAoF3hxYn?=
 =?us-ascii?Q?sauOpPCHvjruPkQWytVAh3pxTIn9mKvBDEMvy7dKvrMT4dzISNEaSltE8DFC?=
 =?us-ascii?Q?i8hJAMxnOXFtr41gPJAXusxGwdCYZnSUtzNKdVTmYhWpFkauCTwVq8R4VMuH?=
 =?us-ascii?Q?ouAV76NYOuOyDHK7BOl/WucsaEt6zWfHC8OeUPmj9yuR0imIy4wvaJRzzu6I?=
 =?us-ascii?Q?11vLBnZyLua0S+EmQBOjx92QX7jHOfXSRY/BWYkxMm0CPdds+BQNIDws10Rb?=
 =?us-ascii?Q?L0OHuc0IbvJY+5/0RRGTkHPX3aa5ciE/ImoMUbPArnRfP42Myw7iqS3JustI?=
 =?us-ascii?Q?5f9cZ2V/RNzJz+YnKN25Wd4GB3/+7o4tJub23vykA+dPiM8bkcU8dGedYDSr?=
 =?us-ascii?Q?y7IHQOBsFcj/B62MqgkMj0DtAe6O9Zt+Im4lk2FZ84DhYfltELShp5TsGMyl?=
 =?us-ascii?Q?H6wXzc+dsewby9OPad8j5y+zKhSiGfvAQ5PMOMab1eLaqSWrtAYsfhwqiwe7?=
 =?us-ascii?Q?e4mjXw7MC1gKRxZTWERTgoH2aTczQK3kBo+Ygi+w8Okz1MqLq+pxcAX2fu7S?=
 =?us-ascii?Q?jVLrUhWs0prAa3xgw7oNWs6j4KQK+QgZUk5MG+MDw6AxvMM0Nycn7NUlB1Gy?=
 =?us-ascii?Q?qxwJe4XU6YS9w80ME1Vn08VI2VtZfafpMKhX8vC/Bxvxdl4IJ3ckF0W8SANy?=
 =?us-ascii?Q?3DVf1c/cdUlYros/sDs0Z+Adi+KWVmgLnehZhuKn+DnqtjWGiEnAhXdFtMUK?=
 =?us-ascii?Q?Fj7nlSoaAB6V5Rpz744xSuXSJHKlQ7WGo0l8IHnAPFxs0eYyWoPvT7CSWBdI?=
 =?us-ascii?Q?Wa8mwoYsEtAQMPDhRXN+8xR9YzkWu8x10ZyZisUsRrqAbr72cVxdwR2/C8dl?=
 =?us-ascii?Q?BVhEB25F//QvV9o3G9BWjn+ETnNNt8nlGM5Q0VY5esDHMfNjU1J9kQPzRPHU?=
 =?us-ascii?Q?KTaxFCWB1DFoplclEa6yaehU6a81/1lRED47aQ6uGwT81JIwi6L6cKT1kirD?=
 =?us-ascii?Q?/uAiWdLVZmvCv+WIR8ormzADa51t+wIjRE78CUlyuQseWYD/SA09L6qbk8RX?=
 =?us-ascii?Q?o8cPhUlvo73pW9w/O2SlRnVgjznjsDqN4h6JLapNEjWJ3eRnHRJireZK2+RD?=
 =?us-ascii?Q?MSQXtTXFwCYMqLblDy04KBMKf9Ktk3MSyye5Hh4Gy1KIesgg0W9qFxABb5q3?=
 =?us-ascii?Q?bctXTy/4exx3zeJWAVCsVF1m1YjiR67J4vpaqF0tq6lE2hk5UUZdXxIvNPqL?=
 =?us-ascii?Q?mpyuHT8y7fB/ACuEKjjyUHoQxk6lMMS++SoLCUT2pgx8f3EoBM8w1naxCS1u?=
 =?us-ascii?Q?7D/n69Nv47A91kCtl8eRdgMpgtLXefY6M19SLGBBSLmTFpEFZZVF1AlrkzY4?=
 =?us-ascii?Q?yff3jkc8LQ=3D=3D?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 1f2429d4-75e7-41cd-7cf7-08de655db626
X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Feb 2026 08:57:09.4941
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: tmQP2rqxMoz3iAKsIfGu4CNpSYbWmbyOcprnHZeuAjHpqWeNo1zJhm0EW+7Y8EGUvGimOr3Ca0jWlscBJoeAJg==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR03MB7739

I will update all repos with this change, rather than send each patch to th=
e list

Owen

________________________________________
From: Owen Smith <owen.smith@citrix.com>
Sent: 06 February 2026 8:45 AM
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith
Subject: [PATCH 1/5] Update my email address

Update MAINTAINERS to reference the correct email address.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2b07abc..ee22cc8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -43,6 +43,6 @@ We also request you follow these basic guidelines:
 Maintainers List
 ----------------

-* Owen Smith <owen.smith@cloud.com>
+* Owen Smith <owen.smith@citrix.com>

 * Tu Dinh <ngoc-tu.dinh@vates.tech>
--
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 06 10:34:27 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 06 Feb 2026 10:34:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1223097.1530729 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voJAQ-00050l-Iv; Fri, 06 Feb 2026 10:34:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1223097.1530729; Fri, 06 Feb 2026 10:34:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voJAQ-00050e-GJ; Fri, 06 Feb 2026 10:34:26 +0000
Received: by outflank-mailman (input) for mailman id 1223097;
 Fri, 06 Feb 2026 10:34:25 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=+pcL=AK=bounce.vates.tech=bounce-md_30504962.6985c3ac.v1-cc3bd290554c407fbf32e1be32eea53b@srs-se1.protection.inumbo.net>)
 id 1voJAP-00050Y-Kk
 for win-pv-devel@lists.xenproject.org; Fri, 06 Feb 2026 10:34:25 +0000
Received: from mail177-22.suw61.mandrillapp.com
 (mail177-22.suw61.mandrillapp.com [198.2.177.22])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 66070026-0347-11f1-b161-2bf370ae4941;
 Fri, 06 Feb 2026 11:34:23 +0100 (CET)
Received: from pmta14.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail177-22.suw61.mandrillapp.com (Mailchimp) with ESMTP id
 4f6r706Ns6zGlsp6v
 for <win-pv-devel@lists.xenproject.org>; Fri,  6 Feb 2026 10:34:20 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 cc3bd290554c407fbf32e1be32eea53b; Fri, 06 Feb 2026 10:34:20 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 66070026-0347-11f1-b161-2bf370ae4941
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770374060; x=1770644060;
	bh=h33P9FnlVbFvV0C6T8w7TGDecWOEEEAf9UGDyipEndo=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=cWaQqfkn/5g3YhCNSMUxepNXZHMhcPLyBPRfUW8UxUchkLUfb1ontp3h3HQiAyiRa
	 21N5gO+gVpyuEfmxf3QyBrU0MB2ZUsXZSjaeA1yfEwOm8wNpM+vjKI024Ru/n8E0XF
	 b0qQ3iMf99vYudItpgq72IFTWy1N0FloLKW8K28WndxUtm3jkuE1lH+8MOCKFt7haF
	 g6nJ2CLGDGK1QhaQbT5vKtnqneX6MkN3ck27g+iyKdiB3t7/39jl0tOmAVlKPVMXlK
	 4NbDg9dw8of9Gn4rZyBhKM8Fv54do1zhv8R8jVwWnKBjNCepwMV1L/oX0DvDAV2Mzb
	 b4SKshsXzcYng==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770374060; x=1770634560; i=ngoc-tu.dinh@vates.tech;
	bh=h33P9FnlVbFvV0C6T8w7TGDecWOEEEAf9UGDyipEndo=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=VMA6zufB11CqPQxolspq+ITd+pQ69F7UumMcWzfRdV0hY9tof3+ASOcY4lCRMxJPT
	 n6Hg9jbFzODVWpFIU0kl+TUc7musI7XIUK9E0qbj+qpuJT7wcfK4qsgGvhsuLWyWO1
	 aivDUYVkBWqTfqJwXlbSsGh0aA4omvaCENRVawi0l6x7Hmn5MFVVZQhaG9fGq+KYAG
	 MeoByPJQy6DGF7Tzqbh9fvgzxJfgUuZsfAmwfvhnqyo6eYVoo6ZEopcZohE6EAtT0m
	 igDS/gT5q8IMklda2EAbDNh2kRnQCBIKITYOjMLM8hyD9svoXeS5dFSE0oDY2z+4U/
	 q48TfRnjOb3PQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=203/5]=20Remove=20StartOverride=20from=20all=20PCI=20storage=20adapters?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770374058410
Message-Id: <bfef4669-1ce8-4c17-9f38-5767aae90d39@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
References: <20260206084525.1356-1-owen.smith@citrix.com> <20260206084525.1356-3-owen.smith@citrix.com>
In-Reply-To: <20260206084525.1356-3-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.cc3bd290554c407fbf32e1be32eea53b?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260206:md
Date: Fri, 06 Feb 2026 10:34:20 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 06/02/2026 09:45, Owen Smith wrote:
> Its possible to install non-Microsoft NVMe drivers on the emulated
> NVMe device. During upgrades, the VM requires a reboot using the emulated
> devices, but if the driver assigned for the emulated device has a StartOverride
> setting, then its likely not started which results in a 0x7B bugcheck.
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>


Enum key is explicitly reserved by Microsoft and should not be accessed 
directly:
https://learn.microsoft.com/en-us/windows-hardware/drivers/install/hklm-system-currentcontrolset-enum-registry-tree

I think SetupAPI/CM API should be used instead.

> ---
>   src/monitor/monitor.c | 191 ++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 191 insertions(+)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 52311aa..61945f0 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -90,6 +90,12 @@ MONITOR_CONTEXT MonitorContext;
>   #define PARAMETERS_KEY(_Service) \
>           SERVICE_KEY(_Service) ## "\\Parameters"
>   
> +#define ENUM_KEY(_Class) \
> +        "SYSTEM\\CurrentControlSet\\Enum\\" ## _Class
> +
> +#define STORAGE_CLASS_GUID \
> +        "{4d36e97b-e325-11ce-bfc1-08002be10318}"
> +

Perhaps GUID_DEVCLASS_HDC should be checked as well.

>   static VOID
>   #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
>   __Log(
> @@ -1393,6 +1399,189 @@ fail1:
>       return FALSE;
>   }
>   
> +static BOOLEAN
> +RemoveStartOverrideInstance(
> +    _In_ HKEY           BaseKey,
> +    _In_ PTSTR          SubKeyName,
> +    _In_opt_ PVOID      Context
> +    )
> +{
> +    DWORD               Type;
> +    PTSTR               Value;
> +    DWORD               ValueLength;
> +    DWORD               MaxValueLength;
> +    HKEY                SubKey;
> +    HRESULT             Error;
> +
> +    UNREFERENCED_PARAMETER(Context);
> +
> +    Error = RegOpenKeyEx(BaseKey,
> +                         SubKeyName,
> +                         0,
> +                         KEY_READ,
> +                         &SubKey);
> +    if (Error != ERROR_SUCCESS)
> +        return TRUE;
> +
> +    Error = RegQueryInfoKey(SubKey,
> +                            NULL,
> +                            NULL,
> +                            NULL,
> +                            NULL,
> +                            NULL,
> +                            NULL,
> +                            NULL,
> +                            NULL,
> +                            &MaxValueLength,
> +                            NULL,
> +                            NULL);
> +    if (Error != ERROR_SUCCESS) {
> +        SetLastError(Error);
> +        goto fail1;
> +    }
> +
> +    ValueLength = MaxValueLength + sizeof (TCHAR);
> +
> +    Value = calloc(1, ValueLength);
> +    if (Value == NULL)
> +        goto fail2;
> +
> +    Error = RegQueryValueEx(SubKey,
> +                            "ClassGUID",
> +                            NULL,
> +                            &Type,
> +                            (LPBYTE)Value,
> +                            &ValueLength);
> +    if (Error != ERROR_SUCCESS) {
> +        SetLastError(Error);
> +        goto fail3;
> +    }
> +
> +    if (Type != REG_SZ) {
> +        SetLastError(ERROR_BAD_FORMAT);
> +        goto fail4;
> +    }
> +
> +    if (_tcsnicmp(Value, STORAGE_CLASS_GUID, ValueLength) != 0)
> +        goto done;
> +
> +    ValueLength = MaxValueLength + sizeof (TCHAR);
> +    memset(Value, 0, ValueLength);
> +
> +    Error = RegQueryValueEx(SubKey,
> +                            "Service",
> +                            NULL,
> +                            &Type,
> +                            (LPBYTE)Value,
> +                            &ValueLength);
> +    if (Error != ERROR_SUCCESS) {
> +        SetLastError(Error);
> +        goto fail5;
> +    }
> +
> +    if (Type != REG_SZ) {
> +        SetLastError(ERROR_BAD_FORMAT);
> +        goto fail6;
> +    }
> +
> +    RemoveStartOverride(Value);
> +
> +done:
> +    free(Value);
> +
> +    RegCloseKey(SubKey);
> +
> +    return TRUE;
> +
> +fail6:
> +    Log("fail6");
> +
> +fail5:
> +    Log("fail5");
> +
> +fail4:
> +    Log("fail4");
> +
> +fail3:
> +    Log("fail3");
> +
> +    free(Value);
> +
> +fail2:
> +    Log("fail2");
> +
> +fail1:
> +    Log("fail1");
> +
> +    return TRUE;
> +}
> +
> +static BOOLEAN
> +RemoveStartOverrideDevice(
> +    _In_ HKEY           BaseKey,
> +    _In_ PTSTR          SubKeyName,
> +    _In_opt_ PVOID      Context
> +    )
> +{
> +    HKEY                SubKey;
> +    HRESULT             Error;
> +
> +    UNREFERENCED_PARAMETER(Context);
> +
> +    Error = RegOpenKeyEx(BaseKey,
> +                         SubKeyName,
> +                         0,
> +                         KEY_READ,
> +                         &SubKey);
> +    if (Error != ERROR_SUCCESS)
> +        return TRUE;
> +
> +    (VOID) RegEnumSubKeys(SubKey,
> +                          RemoveStartOverrideInstance,
> +                          NULL);
> +
> +    RegCloseKey(SubKey);
> +
> +    return TRUE;
> +}
> +
> +static BOOL
> +RemoveAllStartOverrides(
> +    VOID
> +    )
> +{
> +    HKEY            EnumKey;
> +    HRESULT         Error;
> +
> +    Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
> +                         ENUM_KEY("PCI"),
> +                         0,
> +                         KEY_READ,
> +                         &EnumKey);
> +    if (Error != ERROR_SUCCESS) {
> +        goto fail1;
> +    }
> +
> +    Error = RegEnumSubKeys(EnumKey,
> +                           RemoveStartOverrideDevice,
> +                           NULL);
> +    if (Error != ERROR_SUCCESS) {
> +        goto fail2;
> +    }
> +
> +    RegCloseKey(EnumKey);
> +
> +    return TRUE;
> +
> +fail2:
> +    Log("fail2");
> +
> +fail1:
> +    Log("fail1");
> +
> +    return FALSE;
> +}
> +
>   VOID WINAPI
>   MonitorMain(
>       _In_    DWORD       argc,
> @@ -1411,6 +1600,7 @@ MonitorMain(
>       Log("====>");
>   
>       (VOID) RemoveStartOverride("stornvme");
> +    (VOID) RemoveAllStartOverrides();
>   
>       Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
>                            PARAMETERS_KEY(__MODULE__),
> @@ -1565,6 +1755,7 @@ done:
>   
>       CloseHandle(Context->ParametersKey);
>       (VOID) RemoveStartOverride("stornvme");
> +    (VOID) RemoveAllStartOverrides();
>   
>       Log("<====");
>   



--
 | Vates

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 06 10:35:31 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 06 Feb 2026 10:35:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1223098.1530734 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voJBT-000543-ML; Fri, 06 Feb 2026 10:35:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1223098.1530734; Fri, 06 Feb 2026 10:35:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voJBT-00053w-JM; Fri, 06 Feb 2026 10:35:31 +0000
Received: by outflank-mailman (input) for mailman id 1223098;
 Fri, 06 Feb 2026 10:35:31 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=dLMZ=AK=bounce.vates.tech=bounce-md_30504962.6985c3ef.v1-834edd6f1f254c55a8415eb77a983ae0@srs-se1.protection.inumbo.net>)
 id 1voJBS-00053q-Ux
 for win-pv-devel@lists.xenproject.org; Fri, 06 Feb 2026 10:35:30 +0000
Received: from mail132-5.atl131.mandrillapp.com
 (mail132-5.atl131.mandrillapp.com [198.2.132.5])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 8e377690-0347-11f1-b161-2bf370ae4941;
 Fri, 06 Feb 2026 11:35:29 +0100 (CET)
Received: from pmta09.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail132-5.atl131.mandrillapp.com (Mailchimp) with ESMTP id
 4f6r8H6wCjzG0CBhY
 for <win-pv-devel@lists.xenproject.org>; Fri,  6 Feb 2026 10:35:27 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 834edd6f1f254c55a8415eb77a983ae0; Fri, 06 Feb 2026 10:35:27 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 8e377690-0347-11f1-b161-2bf370ae4941
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770374128; x=1770644128;
	bh=rUdTBi1O5yVEWjc2nZSdo6K8OSEnAJpqYWkFN8Jj7Pc=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=Cq/gmzmxVg3M5UnVetvDXgjnDypqgGZ5dF9WQRhpGDSb2nE2K0GMqjVxA131A6zh7
	 gLQMiLN16XylCbm/AWWwPT54NLFN0bIaaiODIp3prU5ygZzQvwuwpr0uwBWMW3AvY4
	 4zoyEQHPZlb1i/deNq0p97WliuuLmaExSb42r2vZvKaxLRRwuodLkV19hBogi7a+nR
	 q9CrgsHkzCFqVcv67ONnl9x60khyZ/GluYNhAQsKwePSuvE39E3V8/4w4Ryaxa9bFH
	 FMon1bCKc+OwHyre4/u1FBPTdeDLRmsem874pyxTkA7lT055bHGoPuEerZuz1423yh
	 0IHHp9dr50Ytg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770374128; x=1770634628; i=ngoc-tu.dinh@vates.tech;
	bh=rUdTBi1O5yVEWjc2nZSdo6K8OSEnAJpqYWkFN8Jj7Pc=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=kbyQs/uFfUo403AV3KjkPmJ9Nc6hwgWAHg+kCxIDILqqlzO76c6y+sxiRQtNtAz4u
	 4QQTcHVY+CLZ0SSdlRBhwVuz0+wAAlGrKWa4DroY91LLbW+f8nYERHI8xow/nqMX+0
	 C43aNNSVwdV29trjT6XFWJOvtr+1qYPGOuYt2SgW3/EpAd/vAVPA6y0dqnfzlM9RVp
	 k9Vit5UvS090Ma+nUU75RUsIwL+4haiuZVBRzWRPA/u21/3/qyOUorPPjimWdpuYYZ
	 jNzXYeRBnjYkwD+Phmrj9YAW4vm9wd2j35XIXIsLLmBv3xlSjmcX2PYypGbmEsouLt
	 T3qcanHEJmcmw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=201/5]=20Update=20my=20email=20address?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770374127123
Message-Id: <a18b1a75-5938-4055-a23f-ce5c3627af91@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
References: <20260206084525.1356-1-owen.smith@citrix.com>
In-Reply-To: <20260206084525.1356-1-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.834edd6f1f254c55a8415eb77a983ae0?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260206:md
Date: Fri, 06 Feb 2026 10:35:27 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 06/02/2026 09:45, Owen Smith wrote:
> Update MAINTAINERS to reference the correct email address.
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>
> ---
>   MAINTAINERS | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 2b07abc..ee22cc8 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -43,6 +43,6 @@ We also request you follow these basic guidelines:
>   Maintainers List
>   ----------------
>   
> -* Owen Smith <owen.smith@cloud.com>
> +* Owen Smith <owen.smith@citrix.com>
>   
>   * Tu Dinh <ngoc-tu.dinh@vates.tech>

MAINTAINERS:

Acked-by: Tu Dinh <ngoc-tu.dinh@vates.tech>


--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 06 10:54:10 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 06 Feb 2026 10:54:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1223118.1530751 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voJTS-0007rr-82; Fri, 06 Feb 2026 10:54:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1223118.1530751; Fri, 06 Feb 2026 10:54:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voJTS-0007rk-5U; Fri, 06 Feb 2026 10:54:06 +0000
Received: by outflank-mailman (input) for mailman id 1223118;
 Fri, 06 Feb 2026 10:54:05 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Vkrp=AK=bounce.vates.tech=bounce-md_30504962.6985c849.v1-c1238bb54f4a4bc7b691b3846446c2d4@srs-se1.protection.inumbo.net>)
 id 1voJTR-0007re-1E
 for win-pv-devel@lists.xenproject.org; Fri, 06 Feb 2026 10:54:05 +0000
Received: from mail177-22.suw61.mandrillapp.com
 (mail177-22.suw61.mandrillapp.com [198.2.177.22])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 25c130f3-034a-11f1-b161-2bf370ae4941;
 Fri, 06 Feb 2026 11:54:03 +0100 (CET)
Received: from pmta14.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail177-22.suw61.mandrillapp.com (Mailchimp) with ESMTP id
 4f6rYj2FqRzGlsp5V
 for <win-pv-devel@lists.xenproject.org>; Fri,  6 Feb 2026 10:54:01 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 c1238bb54f4a4bc7b691b3846446c2d4; Fri, 06 Feb 2026 10:54:01 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 25c130f3-034a-11f1-b161-2bf370ae4941
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770375241; x=1770645241;
	bh=SMyn5wircGVylwPG2aRrEV2CUjZympPjvt1ybbdcJsA=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=Ax67DbqWVN9Vx+isGau0gXVIS1eG1Gal57qK/jZuKSK8bBxbPa9Kk0hebeDG8Bf//
	 IwNa6uaGesJ6cPNWCq868sEWM5zK57FmPJBrpiM6GkQTCLubGw/qQyewR3seOeqjlk
	 c0EppMLTrf81enp6PgspoJd+5QJFvFe/savXIH0UlH1pXTpn1BFQ7c2KntNxvH3eGJ
	 zx1uemLsKftRrsnF8Fa+V8buJXCi/O55GLXCXQcPdnNpVcx4Uz4KOWFGpE1114h9Vo
	 267irv0dFY4Rof4mKfrcadGafZO0qNsvBLr8ZTCs3IOclfy2oa2pIT5EYhfdjaI8jq
	 ZZYp9dcskmtow==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770375241; x=1770635741; i=ngoc-tu.dinh@vates.tech;
	bh=SMyn5wircGVylwPG2aRrEV2CUjZympPjvt1ybbdcJsA=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=PKESMSEP/i0DL9G47sf8Z6LSYPmJQ6Jh9+GwiJ+gSvhpF4okmqGlYTNDqhUIBbPzX
	 IhwIWieOTSaPivkZ3Tu38wO80pYAHx5K/6pG0NhqjjHWfrXXPy1wnKtYiBwpeD7rJo
	 7rp0uv9B2VxFAWPTYtaINzrbQfFpd85I6ozn2nQXiPerVYA24+bXPVLvBMMvEzkBFC
	 KOi180V8rInHJ/ggC6XkLOD486WaAhSwa4EMdUegwa4wmUObxC4bGTSdIC/1zp66l/
	 Es43OOT/JtuppHU2sNGRxbk/WAyy3l2+M/bBykiLAzZUFRgXhjRLySv8WWjm5sbCHh
	 AY7jefAQQRrKA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=205/5]=20Replace=20RegisterEventSource=20with=20TraceLoggingRegister?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770375240436
Message-Id: <c8822cc4-06e2-4e84-b1a7-f052828c12d4@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
Cc: "david ambu" <david.preetham@cloud.com>
References: <20260206084525.1356-1-owen.smith@citrix.com> <20260206084525.1356-5-owen.smith@citrix.com>
In-Reply-To: <20260206084525.1356-5-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.c1238bb54f4a4bc7b691b3846446c2d4?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260206:md
Date: Fri, 06 Feb 2026 10:54:01 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 06/02/2026 09:45, Owen Smith wrote:
> - Added TraceLogging levels for Information and Error events.
> - Replaced RegisterEventSource due to potential security issues.
> 

Could you add some comments to explain the potential issue with 
RegisterEventSource?

> Signed-off-by: david ambu <david.preetham@cloud.com>
> 
> * defined seperate macros for Info and Error logging
> * use a switch on log level, rather than if/else
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

I think it'd be great if you could provide similar patches for 
xencons_monitor and xenagent as well.

> ---
>   src/monitor/monitor.c | 290 ++++++++++++++++++++++--------------------
>   1 file changed, 150 insertions(+), 140 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 77d7dd8..a9b69f3 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -40,6 +40,8 @@
>   #include <powrprof.h>
>   #include <malloc.h>
>   #include <assert.h>
> +#include <TraceLoggingProvider.h>
> +#include <winmeta.h>
>   
>   #include <version.h>
>   
> @@ -56,7 +58,6 @@ typedef struct _MONITOR_CONTEXT {
>       SERVICE_STATUS          Status;
>       SERVICE_STATUS_HANDLE   Service;
>       HKEY                    ParametersKey;
> -    HANDLE                  EventLog;
>       HANDLE                  StopEvent;
>       HANDLE                  RequestEvent;
>       HANDLE                  Timer;
> @@ -96,17 +97,25 @@ MONITOR_CONTEXT MonitorContext;
>   #define STORAGE_CLASS_GUID \
>           "{4d36e97b-e325-11ce-bfc1-08002be10318}"
>   
> +TRACELOGGING_DEFINE_PROVIDER(g_xenbus_monitor,


The provider handle name should use the same convention as other global 
variables (e.g. MonitorTraceLoggingProvider).

> +                             MONITOR_NAME,
> +                             //{E8ADEEB7-6DD1-447E-A49B-A6571CC74039}
> +                             (0xe8adeeb7, 0x6dd1, 0x447e, 0xa4, 0x9b, 0xa6, 0x57, 0x1c, 0xc7, 0x40, 0x39)

Is it worth having a DEFINE_GUID for this somewhere?

> +                            );
> +
> +typedef enum {
> +    LOG_INFO,
> +    LOG_ERROR
> +} LOG_LEVEL;
> +
>   static VOID
>   #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
>   __Log(
> +    _In_ LOG_LEVEL      Level,
>       _In_ PCSTR          Format,
>       ...
>       )
>   {
> -#if DBG
> -    PMONITOR_CONTEXT    Context = &MonitorContext;
> -    const TCHAR         *Strings[1];
> -#endif
>       TCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
>       va_list             Arguments;
>       size_t              Length;
> @@ -133,24 +142,31 @@ __Log(
>   
>       OutputDebugString(Buffer);
>   
> -#if DBG
> -    Strings[0] = Buffer;
> -
> -    if (Context->EventLog != NULL)
> -        ReportEvent(Context->EventLog,
> -                    EVENTLOG_INFORMATION_TYPE,
> -                    0,
> -                    MONITOR_LOG,
> -                    NULL,
> -                    ARRAYSIZE(Strings),
> -                    0,
> -                    Strings,
> -                    NULL);
> -#endif
> +    switch (Level) {
> +    case LOG_INFO:
> +        TraceLoggingWrite(g_xenbus_monitor,
> +            "Information",
> +            TraceLoggingLevel(WINEVENT_LEVEL_INFO),
> +            TraceLoggingString(Buffer, "Info")

Buffer is a PTSTR, so we should have an appropriate #define for 
TraceLoggingString.

> +        );
> +        break;
> +    case LOG_ERROR:
> +        TraceLoggingWrite(g_xenbus_monitor,
> +            "Error",
> +            TraceLoggingLevel(WINEVENT_LEVEL_ERROR),
> +            TraceLoggingString(Buffer, "Error")
> +        );
> +        break;
> +    default:
> +        break;
> +    }
>   }
>   
> -#define Log(_Format, ...) \
> -        __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
> +#define LogInfo(_Format, ...) \
> +        __Log(LOG_INFO, __MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
> +
> +#define LogError(_Format, ...) \
> +        __Log(LOG_ERROR, __MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
>   
>   static PTSTR
>   GetErrorMessage(
> @@ -215,7 +231,7 @@ ReportStatus(
>       BOOL                Success;
>       HRESULT             Error;
>   
> -    Log("====> (%s)", ServiceStateName(CurrentState));
> +    LogInfo("====> (%s)", ServiceStateName(CurrentState));
>   
>       Context->Status.dwCurrentState = CurrentState;
>       Context->Status.dwWin32ExitCode = Win32ExitCode;
> @@ -239,7 +255,7 @@ ReportStatus(
>       if (!Success)
>           goto fail1;
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return;
>   
> @@ -249,7 +265,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   }
> @@ -326,11 +342,11 @@ DoReboot(
>       _In_ DWORD  Timeout
>       )
>   {
> -    Log("waiting for pending install events...");
> +    LogInfo("waiting for pending install events...");
>   
>       (VOID) CM_WaitNoPendingInstallEvents(INFINITE);
>   
> -    Log("initiating shutdown...");
> +    LogInfo("initiating shutdown...");
>   
>   #pragma prefast(suppress:28159)
>       (VOID) InitiateSystemShutdownEx(NULL,
> @@ -366,7 +382,7 @@ GetPromptTimeout(
>           Type != REG_DWORD)
>           Value = 0;
>   
> -    Log("%u", Value);
> +    LogInfo("%u", Value);
>   
>       return Value;
>   }
> @@ -445,18 +461,18 @@ GetDisplayName(
>       return DisplayName;
>   
>   fail5:
> -    Log("fail5");
> +    LogError("fail5");
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>       free(DisplayName);
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>       RegCloseKey(ServiceKey);
>   
> @@ -466,7 +482,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -531,7 +547,7 @@ DoPromptForReboot(
>           WTS_CONNECTSTATE_CLASS  State = SessionInfo[Index].State;
>           DWORD                   Response;
>   
> -        Log("[%u]: %s [%s]",
> +        LogInfo("[%u]: %s [%s]",
>               SessionId,
>               Name,
>               WTSStateName(State));

Could you align the arguments here (and elsewhere)?

> @@ -565,7 +581,7 @@ DoPromptForReboot(
>       return ERROR_SUCCESS;
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>       *Prompt->PResponse = 0;
>   
>   fail1:
> @@ -598,7 +614,7 @@ PromptForReboot(
>           return;
>       Context->RebootPrompted = TRUE;
>   
> -    Log("====> (%s)", DriverName);
> +    LogInfo("====> (%s)", DriverName);
>   
>       Prompt = calloc(1, sizeof (REBOOT_PROMPT));
>       if (Prompt == NULL) {
> @@ -665,20 +681,20 @@ PromptForReboot(
>       return;
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>       free(DisplayName);
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -772,7 +788,7 @@ TryAutoReboot(
>       if (RebootCount >= AutoReboot)
>           goto prompt;
>   
> -    Log("AutoRebooting (reboot %u of %u)\n",
> +    LogInfo("AutoRebooting (reboot %u of %u)\n",
>           RebootCount,
>           AutoReboot);
>   
> @@ -844,18 +860,18 @@ done:
>       return;
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       free(DisplayName);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -878,7 +894,7 @@ RegEnumSubKeys(
>       DWORD               Index;
>       HRESULT             Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       Error = RegQueryInfoKey(BaseKey,
>                               NULL,
> @@ -920,7 +936,7 @@ RegEnumSubKeys(
>               goto fail3;
>           }
>   
> -        Log("%s", SubKeyName);
> +        LogInfo("%s", SubKeyName);
>   
>           if (!Callback(BaseKey, SubKeyName, Context))
>               break;
> @@ -931,12 +947,12 @@ RegEnumSubKeys(
>       return ERROR_SUCCESS;
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       free(SubKeyName);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -944,7 +960,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1008,7 +1024,7 @@ CheckRequestSubKeys(
>       BOOLEAN             Found;
>       HRESULT             Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       Found = FALSE;
>   
> @@ -1025,7 +1041,7 @@ CheckRequestSubKeys(
>               (VOID) RegFlushKey(Context->ParametersKey);
>       }
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return;
>   
> @@ -1035,7 +1051,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   }
> @@ -1048,7 +1064,7 @@ CheckRequestKey(
>       PMONITOR_CONTEXT    Context = &MonitorContext;
>       HRESULT             Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       CheckRequestSubKeys();
>   
> @@ -1061,7 +1077,7 @@ CheckRequestKey(
>       if (Error != ERROR_SUCCESS)
>           goto fail1;
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return;
>   
> @@ -1071,7 +1087,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   }
> @@ -1086,7 +1102,7 @@ AcquireShutdownPrivilege(
>       BOOL                Success;
>       HRESULT             Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       New.PrivilegeCount = 1;
>   
> @@ -1118,17 +1134,17 @@ AcquireShutdownPrivilege(
>   
>       CloseHandle(Token);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return TRUE;
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       CloseHandle(Token);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -1136,7 +1152,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1194,20 +1210,20 @@ GetRequestKeyName(
>           goto fail4;
>       }
>   
> -    Log("%s", *RequestKeyName);
> +    LogInfo("%s", *RequestKeyName);
>   
>       return TRUE;
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       free(*RequestKeyName);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -1215,7 +1231,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1321,37 +1337,37 @@ GetDialogParameters(
>       return TRUE;
>   
>   fail10:
> -    Log("fail10");
> +    LogError("fail10");
>   
>   fail9:
> -    Log("fail9");
> +    LogError("fail9");
>   
>       free(Context->Question);
>   
>   fail8:
> -    Log("fail8");
> +    LogError("fail8");
>   
>   fail7:
> -    Log("fail7");
> +    LogError("fail7");
>   
>   fail6:
> -    Log("fail6");
> +    LogError("fail6");
>   
>       free(Context->Text);
>   
>   fail5:
> -    Log("fail5");
> +    LogError("fail5");
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       free(Context->Title);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -1359,7 +1375,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1392,7 +1408,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1494,24 +1510,24 @@ done:
>       return TRUE;
>   
>   fail6:
> -    Log("fail6");
> +    LogError("fail6");
>   
>   fail5:
> -    Log("fail5");
> +    LogError("fail5");
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       free(Value);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
> -    Log("fail1");
> +    LogError("fail1");
>   
>       return TRUE;
>   }
> @@ -1574,10 +1590,10 @@ RemoveAllStartOverrides(
>       return TRUE;
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
> -    Log("fail1");
> +    LogError("fail1");
>   
>       return FALSE;
>   }
> @@ -1597,7 +1613,10 @@ MonitorMain(
>       UNREFERENCED_PARAMETER(argc);
>       UNREFERENCED_PARAMETER(argv);
>   
> -    Log("====>");
> +    if (TraceLoggingRegister(g_xenbus_monitor) != ERROR_SUCCESS)
> +        LogInfo("TraceLoggingRegister failed");
> +
> +    LogInfo("====>");
>   
>       (VOID) RemoveStartOverride("stornvme");
>       (VOID) RemoveAllStartOverrides();
> @@ -1620,11 +1639,6 @@ MonitorMain(
>       if (Context->Service == NULL)
>           goto fail3;
>   
> -    Context->EventLog = RegisterEventSource(NULL,
> -                                            MONITOR_NAME);
> -    if (Context->EventLog == NULL)
> -        goto fail4;
> -
>       Context->Status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
>       Context->Status.dwServiceSpecificExitCode = 0;
>   
> @@ -1636,26 +1650,26 @@ MonitorMain(
>                                        NULL);
>   
>       if (Context->StopEvent == NULL)
> -        goto fail5;
> +        goto fail4;
>   
>       Context->RequestEvent = CreateEvent(NULL,
>                                           TRUE,
>                                           FALSE,
>                                           NULL);
>       if (Context->RequestEvent == NULL)
> -        goto fail6;
> +        goto fail5;
>   
>       Context->ResponseEvent = CreateEvent(NULL,
>                                            FALSE,
>                                            FALSE,
>                                            NULL);
>       if (Context->ResponseEvent == NULL)
> -        goto fail7;
> +        goto fail6;
>       Context->Response = 0;
>   
>       Success = GetRequestKeyName(&RequestKeyName);
>       if (!Success)
> -        goto fail8;
> +        goto fail7;
>   
>       Error = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
>                              RequestKeyName,
> @@ -1667,15 +1681,15 @@ MonitorMain(
>                              &Context->RequestKey,
>                              NULL);
>       if (Error != ERROR_SUCCESS)
> -        goto fail9;
> +        goto fail8;
>   
>       Success = GetDialogParameters();
>       if (!Success)
> -        goto fail10;
> +        goto fail9;
>   
>       Context->Timer = CreateWaitableTimer(NULL, FALSE, NULL);
>       if (Context->Timer == NULL)
> -        goto fail11;
> +        goto fail10;
>   
>       DueTime.QuadPart = -10000LL * REBOOT_RETRY_DELAY;
>   
> @@ -1686,7 +1700,7 @@ MonitorMain(
>                                  NULL,
>                                  FALSE);
>       if (!Success)
> -        goto fail12;
> +        goto fail11;
>   
>       SetEvent(Context->RequestEvent);
>   
> @@ -1701,12 +1715,12 @@ MonitorMain(
>           Events[2] = Context->ResponseEvent;
>           Events[3] = Context->Timer;
>   
> -        Log("waiting (%u)...", ARRAYSIZE(Events));
> +        LogInfo("waiting (%u)...", ARRAYSIZE(Events));
>           Object = WaitForMultipleObjects(ARRAYSIZE(Events),
>                                           Events,
>                                           FALSE,
>                                           INFINITE);
> -        Log("awake");
> +        LogInfo("awake");
>   
>           switch (Object) {
>           case WAIT_OBJECT_0:
> @@ -1752,65 +1766,59 @@ done:
>   
>       ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
>   
> -    (VOID) DeregisterEventSource(Context->EventLog);
> -
>       RegCloseKey(Context->ParametersKey);
>   
>       (VOID) RemoveStartOverride("stornvme");
>       (VOID) RemoveAllStartOverrides();
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
> +    TraceLoggingUnregister(g_xenbus_monitor);
>       return;
>   
> -fail12:
> -    Log("fail12");
> +fail11:
> +    LogError("fail11");
>   
>       CloseHandle(Context->Timer);
>   
> -fail11:
> -    Log("fail11");
> -
>   fail10:
> -    Log("fail10");
> -
> -    RegCloseKey(Context->RequestKey);
> +    LogError("fail10");
>   
>   fail9:
> -    Log("fail9");
> +    LogError("fail9");
>   
> -    free(RequestKeyName);
> +    RegCloseKey(Context->RequestKey);
>   
>   fail8:
> -    Log("fail8");
> +    LogError("fail8");
>   
> -    CloseHandle(Context->ResponseEvent);
> +    free(RequestKeyName);
>   
>   fail7:
> -    Log("fail7");
> +    LogError("fail7");
>   
> -    CloseHandle(Context->RequestEvent);
> +    CloseHandle(Context->ResponseEvent);
>   
>   fail6:
> -    Log("fail6");
> +    LogError("fail6");
>   
> -    CloseHandle(Context->StopEvent);
> +    CloseHandle(Context->RequestEvent);
>   
>   fail5:
> -    Log("fail5");
> +    LogError("fail5");
>   
> -    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
> -
> -    (VOID) DeregisterEventSource(Context->EventLog);
> +    CloseHandle(Context->StopEvent);
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
> +
> +    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>       RegCloseKey(Context->ParametersKey);
>   
> @@ -1820,9 +1828,11 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
> +
> +    TraceLoggingUnregister(g_xenbus_monitor);
>   }
>   
>   static BOOL
> @@ -1835,7 +1845,7 @@ MonitorCreate(
>       TCHAR       Path[MAX_PATH];
>       HRESULT     Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       if(!GetModuleFileName(NULL, Path, MAX_PATH))
>           goto fail1;
> @@ -1867,17 +1877,17 @@ MonitorCreate(
>       CloseServiceHandle(Service);
>       CloseServiceHandle(SCManager);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return TRUE;
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       CloseServiceHandle(SCManager);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -1885,7 +1895,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1903,7 +1913,7 @@ MonitorDelete(
>       SERVICE_STATUS      Status;
>       HRESULT             Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       SCManager = OpenSCManager(NULL,
>                                 NULL,
> @@ -1934,20 +1944,20 @@ MonitorDelete(
>       CloseServiceHandle(Service);
>       CloseServiceHandle(SCManager);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return TRUE;
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       CloseServiceHandle(Service);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>       CloseServiceHandle(SCManager);
>   
> @@ -1957,7 +1967,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1975,14 +1985,14 @@ MonitorEntry(
>       };
>       HRESULT             Error;
>   
> -    Log("%s (%s) ====>",
> +    LogInfo("%s (%s) ====>",
>           MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
>           DAY_STR "/" MONTH_STR "/" YEAR_STR);
>   
>       if (!StartServiceCtrlDispatcher(Table))
>           goto fail1;
>   
> -    Log("%s (%s) <====",
> +    LogInfo("%s (%s) <====",
>           MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
>           DAY_STR "/" MONTH_STR "/" YEAR_STR);
>   
> @@ -1994,7 +2004,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 06 11:11:34 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 06 Feb 2026 11:11:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1223122.1530756 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voJkL-0001iV-8f; Fri, 06 Feb 2026 11:11:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1223122.1530756; Fri, 06 Feb 2026 11:11:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voJkL-0001iN-5k; Fri, 06 Feb 2026 11:11:33 +0000
Received: by outflank-mailman (input) for mailman id 1223122;
 Fri, 06 Feb 2026 11:11:32 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=93QJ=AK=bounce.vates.tech=bounce-md_30504962.6985cc5b.v1-970e53115b374e728125c295699ec730@srs-se1.protection.inumbo.net>)
 id 1voJkJ-0001iE-QI
 for win-pv-devel@lists.xenproject.org; Fri, 06 Feb 2026 11:11:31 +0000
Received: from mail132-5.atl131.mandrillapp.com
 (mail132-5.atl131.mandrillapp.com [198.2.132.5])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 9334e482-034c-11f1-9ccf-f158ae23cfc8;
 Fri, 06 Feb 2026 12:11:25 +0100 (CET)
Received: from pmta09.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail132-5.atl131.mandrillapp.com (Mailchimp) with ESMTP id
 4f6rxl4ycczG0CJv0
 for <win-pv-devel@lists.xenproject.org>; Fri,  6 Feb 2026 11:11:23 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 970e53115b374e728125c295699ec730; Fri, 06 Feb 2026 11:11:23 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 9334e482-034c-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770376283; x=1770646283;
	bh=gQmAKN2qbJrhNS9nKHeOnUHfH9cwfHvWGvAcoX/0KQc=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=ex05sdhYGYCjSWgs4PoFgfaiS+0XBjBNQccDvVo8w1hYou+38oCkfl/cQIkAZ7wXj
	 LQOJfhJR1SD4Gw66jYHqjT3CYZsXQvZ09vfcWAaBtfQmubU0a5VZkqUQa8mwVMNhMT
	 pLW5ThV6YLNsBSGINM9adbW1j1E/SGyF28hA0Xh2pMgs3FEF0z14Y8lon02P06mecW
	 vaVZvht6kLiId8VfDOBKqiELo9Ewh2c3EYUnB2aQjv17lPqrUCjQzTyj14EriJgdBO
	 fB4JpW7RLRTG3DdjieVFwbV6oRLduT+i3kaL6To1iF9VQvJFwyHjZmKfPn/So29HeD
	 ba+xUi5C2HkMQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770376283; x=1770636783; i=ngoc-tu.dinh@vates.tech;
	bh=gQmAKN2qbJrhNS9nKHeOnUHfH9cwfHvWGvAcoX/0KQc=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=raPiHNeJalA3e1pfT4EPn9GJIugu5eMhrNu48dhaq8zGNzQQsibinJ+O6MXc4bHzY
	 CdQ5PllkhqqsWN0g6Ow0EAyna+6Ne/8gELnbdIC86nT3RYmjhBW9i18VeiE0iuF/0i
	 a07F/wJLP3HH5r5Ll58+l7tx6D7fDqVnyl4h6x54AIJp0/BGWTmV6IfPCrF0Dr3s2u
	 aoHOzILLtH7boP3NpIIjE4qmzdihHVZ0Q2eua8xczUesxZD9LoGQdtc108Mzj+zDc1
	 oP1div6xLKTxCD89glHjI94oE2y+IMeYWFqWFbH+mAUBjDQVzwx8TOd+dEpu1pG/83
	 F6nyergCE08Dw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=204/5]=20registry:=20use=20RegCloseKey=20for=20RequestKey=20and=20ParametersKey?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770376282605
Message-Id: <913a9fad-af24-4a21-8c07-ff0c8bc22462@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
Cc: "david ambu" <david.preetham@cloud.com>
References: <20260206084525.1356-1-owen.smith@citrix.com> <20260206084525.1356-4-owen.smith@citrix.com>
In-Reply-To: <20260206084525.1356-4-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.970e53115b374e728125c295699ec730?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260206:md
Date: Fri, 06 Feb 2026 11:11:23 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 06/02/2026 09:45, Owen Smith wrote:
> From: david ambu <david.preetham@cloud.com>
> 
> CloseHandle silently fails for HKEY.
> 
> Signed-off-by: david ambu <david.preetham@cloud.com>

IMO this could go in ahead of the other changes.

As such, it should be moved first so that it's not blocked by the other 
patches.

Could you fix this for Xencons as well?

> ---
>   src/monitor/monitor.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 61945f0..77d7dd8 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -1743,7 +1743,8 @@ done:
>       free(Context->Question);
>       free(Context->Text);
>       free(Context->Title);
> -    CloseHandle(Context->RequestKey);
> +
> +    RegCloseKey(Context->RequestKey);
>       free(RequestKeyName);
>       CloseHandle(Context->ResponseEvent);
>       CloseHandle(Context->RequestEvent);
> @@ -1753,7 +1754,8 @@ done:
>   
>       (VOID) DeregisterEventSource(Context->EventLog);
>   
> -    CloseHandle(Context->ParametersKey);
> +    RegCloseKey(Context->ParametersKey);
> +
>       (VOID) RemoveStartOverride("stornvme");
>       (VOID) RemoveAllStartOverrides();
>   
> @@ -1772,7 +1774,7 @@ fail11:
>   fail10:
>       Log("fail10");
>   
> -    CloseHandle(Context->RequestKey);
> +    RegCloseKey(Context->RequestKey);
>   
>   fail9:
>       Log("fail9");
> @@ -1810,7 +1812,7 @@ fail3:
>   fail2:
>       Log("fail2");
>   
> -    CloseHandle(Context->ParametersKey);
> +    RegCloseKey(Context->ParametersKey);
>   
>   fail1:
>       Error = GetLastError();



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 06 17:10:53 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 06 Feb 2026 17:10:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1223683.1531134 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voPM3-0007OT-E5; Fri, 06 Feb 2026 17:10:51 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1223683.1531134; Fri, 06 Feb 2026 17:10:51 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1voPM3-0007OM-B7; Fri, 06 Feb 2026 17:10:51 +0000
Received: by outflank-mailman (input) for mailman id 1223683;
 Fri, 06 Feb 2026 17:10:50 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=50Sn=AK=bounce.vates.tech=bounce-md_30504962.69862096.v1-02f2ac86d08a4564ae6d361b61937a37@srs-se1.protection.inumbo.net>)
 id 1voPM2-0007OF-Ii
 for win-pv-devel@lists.xenproject.org; Fri, 06 Feb 2026 17:10:50 +0000
Received: from mail177-22.suw61.mandrillapp.com
 (mail177-22.suw61.mandrillapp.com [198.2.177.22])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id c7b7c0ae-037e-11f1-b161-2bf370ae4941;
 Fri, 06 Feb 2026 18:10:48 +0100 (CET)
Received: from pmta14.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail177-22.suw61.mandrillapp.com (Mailchimp) with ESMTP id
 4f70wQ6SxGzGlsp4C
 for <win-pv-devel@lists.xenproject.org>; Fri,  6 Feb 2026 17:10:46 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 02f2ac86d08a4564ae6d361b61937a37; Fri, 06 Feb 2026 17:10:46 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: c7b7c0ae-037e-11f1-b161-2bf370ae4941
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770397846; x=1770667846;
	bh=d7ierzIFGqa+kWAAzo1wT5xRHdXowNpWdRuDNMMOOHo=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=mHIHzQo6h/hSiDkjQa6B2Oui+Q0c1pWM1v+YgB63JWYfwshJoA0sZhvMCJ/kPgyw5
	 Tvh5ZVMWpE/AukPPrTvFSOZv6fmFTeB9BcehwqtESerocI+Vd3yAuSIrSuyk/ajwHb
	 RuYd43t6kHyiRqFJImavEuKWeZu2ae4DKPR4Aln4fK7Z3QX4zxthJ6QAU4J1jgFYkC
	 ZGSyxjmrBgZVkSqK+Q/vzf+xpilogbpXjyUrpyqwCbrZ74A1uLp2nbjf7VdyGobmYP
	 oHw0FMG6Bxhk1FYBj8OQMeKVi6HFYxn0r6NkfvBU9g+5434z2BR7b/vSQQoxsTIlOD
	 1y0FNhGFWeTkA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770397846; x=1770658346; i=ngoc-tu.dinh@vates.tech;
	bh=d7ierzIFGqa+kWAAzo1wT5xRHdXowNpWdRuDNMMOOHo=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=J7evlh916IlLnUYmDlVo54XxkCLkvItIdv4Po2OP4IpF2w0wdL9D6IIjQR60e/alm
	 8wq5tec4Zb7w55Gi9CzlIZzP5sydSUo9lGkdQDa+JtIRkd5dsq7fkIMdUlq2aYPvIb
	 K9Aazy+EMcKO2c7X/NjnSbRZDIdRw0u3ewbTRHEOs1uxx7Q7wRanweJmnafgepDJxO
	 BJIIeUmISrNqqOjIvfkfTZTRNSNaxXbmIvkTEAzcxovUBksTunL/H9ayxjmkMBgf2P
	 TyTAlECEm2qLT+qjngLlqnkhfRDlhrzFB2tiBvI1ueW8A0FKFEpxmBgJHc/bHimCo3
	 EirIZ6Rad9NSA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=20XenIface]=20Remove=20attempts=20to=20open=20ParametersKey=20for=20WRITE?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770397845961
Message-Id: <24ccf2fd-0fbc-4ed6-8f58-5632cfb2a807@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
References: <20260206085425.1397-1-owen.smith@citrix.com>
In-Reply-To: <20260206085425.1397-1-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.02f2ac86d08a4564ae6d361b61937a37?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260206:md
Date: Fri, 06 Feb 2026 17:10:46 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 06/02/2026 09:54, Owen Smith wrote:
> Registry isolation prevents drivers from openning the parameters key
> for WRITE access, as this key is restricted to read only access.
> This call currently fails without issue, remove the attempt to write,
> the calling thread and all callers.
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Reviewed-by: Tu Dinh <ngoc-tu.dinh@vates.tech>

> ---
>   src/xeniface/fdo.c | 132 +++------------------------------------------
>   src/xeniface/fdo.h |   3 --
>   src/xeniface/wmi.c |   1 -
>   3 files changed, 8 insertions(+), 128 deletions(-)
> 
> diff --git a/src/xeniface/fdo.c b/src/xeniface/fdo.c
> index a2cb713..ec56e42 100644
> --- a/src/xeniface/fdo.c
> +++ b/src/xeniface/fdo.c
> @@ -61,106 +61,6 @@
>   
>   #define MAXNAMELEN  128
>   
> -static NTSTATUS
> -FdoInitialiseXSRegistryEntries(
> -    IN PXENIFACE_FDO        Fdo
> -    )
> -{
> -    ANSI_STRING             Ansi[2];
> -    HANDLE                  Key;
> -    PCHAR                   Value;
> -    NTSTATUS                status;
> -
> -    NT_ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
> -
> -    status = XENBUS_STORE(Read,
> -                          &Fdo->StoreInterface,
> -                          NULL,
> -                          NULL,
> -                          "/mh/boot-time/management-mac-address",
> -                          &Value);
> -    if (!NT_SUCCESS(status))
> -        goto fail1;
> -
> -    status = RegistryOpenParametersKey(KEY_WRITE, &Key);
> -    if (!NT_SUCCESS(status))
> -        goto fail2;
> -
> -    RtlInitAnsiString(&Ansi[0], Value);
> -    RtlZeroMemory(&Ansi[1], sizeof(ANSI_STRING));
> -
> -    status = RegistryUpdateSzValue(Key,
> -                                   "MgmtMacAddr",
> -                                   REG_SZ,
> -                                   &Ansi[0]);
> -    if (!NT_SUCCESS(status))
> -        goto fail3;
> -
> -    RegistryCloseKey(Key);
> -
> -    XENBUS_STORE(Free, &Fdo->StoreInterface, Value);
> -
> -    return STATUS_SUCCESS;
> -
> -fail3:
> -    Error("fail3\n");
> -
> -    RegistryCloseKey(Key);
> -
> -fail2:
> -    Error("fail2\n");
> -
> -    XENBUS_STORE(Free, &Fdo->StoreInterface, Value);
> -
> -fail1:
> -    Error("fail1 %08x\n", status);
> -
> -    return status;
> -}
> -
> -#define REGISTRY_WRITE_EVENT 0
> -#define REGISTRY_THREAD_END_EVENT 1
> -#define REGISTRY_EVENTS 2
> -
> -static NTSTATUS FdoRegistryThreadHandler(IN  PXENIFACE_THREAD  Self,
> -                                         IN  PVOID StartContext) {
> -    KEVENT* threadevents[REGISTRY_EVENTS];
> -    PXENIFACE_FDO Fdo = (PXENIFACE_FDO)StartContext;
> -    NTSTATUS status;
> -
> -    PKEVENT             Event;
> -
> -    Event = ThreadGetEvent(Self);
> -
> -    threadevents[REGISTRY_WRITE_EVENT] = &Fdo->registryWriteEvent;
> -    threadevents[REGISTRY_THREAD_END_EVENT] = Event;
> -
> -    for(;;) {
> -
> -        status = KeWaitForMultipleObjects(REGISTRY_EVENTS, (PVOID *)threadevents, WaitAny, Executive, KernelMode, TRUE, NULL, NULL);
> -        if ((status>=STATUS_WAIT_0) && (status < STATUS_WAIT_0+REGISTRY_EVENTS)) {
> -            if (status == STATUS_WAIT_0+REGISTRY_WRITE_EVENT) {
> -                Info("WriteRegistry\n");
> -                (VOID) FdoInitialiseXSRegistryEntries(Fdo);
> -                KeClearEvent(threadevents[REGISTRY_WRITE_EVENT]);
> -            }
> -            if (status == STATUS_WAIT_0+REGISTRY_THREAD_END_EVENT) {
> -                if (ThreadIsAlerted(Self))
> -                    return STATUS_SUCCESS;
> -                KeClearEvent(threadevents[REGISTRY_THREAD_END_EVENT]);
> -            }
> -
> -        }
> -        else if (!NT_SUCCESS(status)) {
> -            Error("Registry handler thread failed %x\n", status);
> -            return status;
> -        }
> -    }
> -
> -}
> -
> -
> -
>   static FORCEINLINE PVOID
>   __FdoAllocate(
>       IN  ULONG   Length
> @@ -2563,17 +2463,9 @@ FdoCreate(
>       InitializeListHead(&Dx->ListEntry);
>       Fdo->References = 1;
>   
> -    (VOID) FdoInitialiseXSRegistryEntries(Fdo);
> -
> -    KeInitializeEvent(&Fdo->registryWriteEvent, NotificationEvent, FALSE);
> -
> -    status = ThreadCreate(FdoRegistryThreadHandler, Fdo, &Fdo->registryThread);
> -    if (!NT_SUCCESS(status))
> -        goto fail13;
> -
>       status = WmiInitialize(Fdo);
>       if (!NT_SUCCESS(status))
> -        goto fail14;
> +        goto fail13;
>   
>       KeInitializeSpinLock(&Fdo->StoreWatchLock);
>       InitializeListHead(&Fdo->StoreWatchList);
> @@ -2597,7 +2489,7 @@ FdoCreate(
>                                  CsqReleaseLock,
>                                  CsqCompleteCanceledIrp);
>       if (!NT_SUCCESS(status))
> -        goto fail15;
> +        goto fail14;
>   
>       Info("%p (%s)\n",
>            FunctionDeviceObject,
> @@ -2608,8 +2500,8 @@ FdoCreate(
>   
>       return STATUS_SUCCESS;
>   
> -fail15:
> -    Error("fail15\n");
> +fail14:
> +    Error("fail14\n");
>   
>       RtlZeroMemory(&Fdo->GnttabCacheLock, sizeof (KSPIN_LOCK));
>       ASSERT(IsListEmpty(&Fdo->IrpList));
> @@ -2630,16 +2522,13 @@ fail15:
>   
>       WmiTeardown(Fdo);
>   
> -fail14:
> -    Error("fail14\n");
> -
> -    ThreadAlert(Fdo->registryThread);
> -    ThreadJoin(Fdo->registryThread);
> -    Fdo->registryThread = NULL;
> -
>   fail13:
>       Error("fail13\n");
>   
> +    RtlZeroMemory(&Fdo->Mutex, sizeof(XENIFACE_MUTEX));
> +    RtlZeroMemory(&Dx->ListEntry, sizeof(LIST_ENTRY));
> +    Fdo->References = 0;
> +
>       RtlZeroMemory(&Fdo->GnttabInterface,
>                     sizeof (XENBUS_GNTTAB_INTERFACE));
>   
> @@ -2773,10 +2662,6 @@ FdoDestroy(
>       RtlZeroMemory(&Fdo->SuspendInterface,
>                     sizeof (XENBUS_SUSPEND_INTERFACE));
>   
> -    ThreadAlert(Fdo->registryThread);
> -    ThreadJoin(Fdo->registryThread);
> -    Fdo->registryThread = NULL;
> -
>       ThreadAlert(Fdo->DevicePowerThread);
>       ThreadJoin(Fdo->DevicePowerThread);
>       Fdo->DevicePowerThread = NULL;
> @@ -2793,7 +2678,6 @@ FdoDestroy(
>       Fdo->Dx = NULL;
>   
>       WmiTeardown(Fdo);
> -    RtlZeroMemory(&Fdo->registryWriteEvent, sizeof(KEVENT));
>   
>       RtlFreeUnicodeString(&Fdo->InterfaceName);
>       RtlZeroMemory(&Fdo->InterfaceName,sizeof(UNICODE_STRING));
> diff --git a/src/xeniface/fdo.h b/src/xeniface/fdo.h
> index b7b86d7..9867756 100644
> --- a/src/xeniface/fdo.h
> +++ b/src/xeniface/fdo.h
> @@ -110,9 +110,6 @@ typedef struct _XENIFACE_FDO {
>       XENIFACE_MUTEX                  SessionLock;
>       LIST_ENTRY                      SessionHead;
>   
> -    PXENIFACE_THREAD                registryThread;
> -    KEVENT                          registryWriteEvent;
> -
>       UNICODE_STRING                  SuggestedInstanceName;
>   
>       UNICODE_STRING                  InterfaceName;
> diff --git a/src/xeniface/wmi.c b/src/xeniface/wmi.c
> index 95b4bb1..ccc2ab0 100644
> --- a/src/xeniface/wmi.c
> +++ b/src/xeniface/wmi.c
> @@ -3122,7 +3122,6 @@ WmiFireSuspendEvent(
>       )
>   {
>       Info("Ready to unsuspend Event\n");
> -    KeSetEvent(&Fdo->registryWriteEvent, IO_NO_INCREMENT, FALSE);
>   
>       if (!Fdo->WmiReady)
>           return;



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 09 14:02:41 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 09 Feb 2026 14:02:41 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1225408.1531898 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vpRqZ-0001s9-KO; Mon, 09 Feb 2026 14:02:39 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1225408.1531898; Mon, 09 Feb 2026 14:02:39 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vpRqZ-0001s2-HW; Mon, 09 Feb 2026 14:02:39 +0000
Received: by outflank-mailman (input) for mailman id 1225408;
 Mon, 09 Feb 2026 14:02:38 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=4dFI=AN=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vpRqY-0001rt-MO
 for win-pv-devel@lists.xenproject.org; Mon, 09 Feb 2026 14:02:38 +0000
Received: from MW6PR02CU001.outbound.protection.outlook.com
 (mail-westus2azlp170120002.outbound.protection.outlook.com
 [2a01:111:f403:c007::2])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id f9022e36-05bf-11f1-9ccf-f158ae23cfc8;
 Mon, 09 Feb 2026 15:02:32 +0100 (CET)
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by BN5PR03MB8042.namprd03.prod.outlook.com (2603:10b6:408:2aa::14)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9587.17; Mon, 9 Feb
 2026 14:02:27 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9587.016; Mon, 9 Feb 2026
 14:02:27 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: f9022e36-05bf-11f1-9ccf-f158ae23cfc8
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=OoZW/9e9qD28SV1CPGmNmFrYxID/gsVQbHxU5qGXBf4i1RLk9x6zvh6Q7XuBW0Sp+AbRtC9t7mNRoTkMka/0ZpVBr64eT0Sdp/O5qf165NLleFWCwa9uqMLraPvLJpFN8HgqbfeELdFOV/2eWL/LDrfD1b9ID8gWddb7AyD+bW+IZBVBxafUtxXu8TGAGfIiVgp0Mv7XOLLb+RMXOtBXYFhPSLm+ie/RVcAm7KGUrR0HZbLIezpAFHH/wZ6Q5I2DMiCkKwHapaxemuQxdWoEtdqpxV1+YXIe1TPpxd6StL3iNC+fliY3GZ9N8SwSKHGCMnF0H5XWOc0JNFiXQMT+mQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector10001;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=mk/GPFDNCvr77DGlZQ3BlamcJm6keQ4g/+cG8aQ3d7U=;
 b=ZGpTuLw95srzRPWuZx8h91zNm9AfHkg7GjoUw6vLIdd6Wm7VYYQfBpAW6/0FBARy+bBwZcYBr4MlKNtdJpHkIzX5TNhLl4Pn9Guvh2uPnsb7a3+0Fl+L7RraqDahyuU1W9ItF3xin1i3A+l8TSdjVEjmBraSV2qocx2SL+G/uGTQ4srietnSo5CRpYk5TYq+wOx5BZUy2QIFajrtt/uRZrO3vrwGCfRCpYizod5XanBCYzvNbLWk3wHQu41kZqJ8vdxkw0/hyepNcJbWP6xuc7/m/cI62jJN0DpBDthjw/flq4GAGQWRX259bD6SuiKh1f+de9G+0XkyLmwz8+dOPw==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=mk/GPFDNCvr77DGlZQ3BlamcJm6keQ4g/+cG8aQ3d7U=;
 b=Eg8hBrVbL5daSubAK2Mz6XdFRmqB8jAyQkxFbJItgQdFuGqsnjeyJOmpN1W04ec/vby6H1uMpjeGG0v4g7UrKN0MieWKv+hO5cKTorWNaY9dmmi4SfysfnySDUOLxMzfhfOrtKbw3JSvOl75VGj3TqFh4+dYKr6tvT0LVfMZKvg=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
CC: david ambu <david.preetham@cloud.com>
Subject: Re: [PATCH 5/5] Replace RegisterEventSource with TraceLoggingRegister
Thread-Topic: [PATCH 5/5] Replace RegisterEventSource with
 TraceLoggingRegister
Thread-Index: AQHcl0T31r+8us63wEKZLAFQEO/a57V1f0IAgAS1O+I=
Date: Mon, 9 Feb 2026 14:02:27 +0000
Message-ID:
 <SA6PR03MB776023723AA7D371ED0F3652FE65A@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <20260206084525.1356-1-owen.smith@citrix.com>
 <20260206084525.1356-5-owen.smith@citrix.com>
 <c8822cc4-06e2-4e84-b1a7-f052828c12d4@vates.tech>
In-Reply-To: <c8822cc4-06e2-4e84-b1a7-f052828c12d4@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|BN5PR03MB8042:EE_
x-ms-office365-filtering-correlation-id: c2631645-f5c8-4ca7-9697-08de67e3db7c
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;ARA:13230040|366016|376014|1800799024|38070700021;
x-microsoft-antispam-message-info:
 =?iso-8859-1?Q?HY4HdAgSI0hAvn3eVQUupOIom4D0PDjA9c/mI3l9sKQjeJlNZ6lheVNVSG?=
 =?iso-8859-1?Q?2gNvEBrXaxh0+IU2qQLHLeOcKm8X0W6lzsx1yJrZ5sg7fyrwG5MxWP/p07?=
 =?iso-8859-1?Q?d33I26pHE1dGeVPjsUv+2VIayUanhWfL3wJoKYm9b6vTMNweCVrTo+bTgL?=
 =?iso-8859-1?Q?mKB+0viWRGYDDxKMZVC8iZBUD7TjUl0rlnWpUAaibZsQJb7WIchOgf9UcJ?=
 =?iso-8859-1?Q?YBMXJyCwH3JxBGhFvl1LgSafXI8TV1oS+uLByh1gR40Pk8yQSZ/ljMoMsH?=
 =?iso-8859-1?Q?T8OL8FIZ/AwzjzZjkyxp57+IBX5IMjYrbq4Nmg86PrMxN6gxdOdOeYHRKn?=
 =?iso-8859-1?Q?6e9E1TClebZYblxyNQvOXv6bqsvX+WQyR0N4K42RncdSj4Cv6WCGXG0SxZ?=
 =?iso-8859-1?Q?1tvWLxjupmF+0OR+D6pJhNgK42Z+wWRNAqgetfdJRGdp8mRSs06U5VYJGO?=
 =?iso-8859-1?Q?ZTEta8z6z56nMZ/5+U2I+TiHfNjj1yGdWZXppaeoSbHzZM93EKrpuA5BqS?=
 =?iso-8859-1?Q?Ehk23Q39UJ6qBkyoqqdXd41mL5RvR52HhvsOxovTRNC+qm3zFLGcdCFgPg?=
 =?iso-8859-1?Q?M3bD2nNgAlGMfaucWSVjw1wla2sFOZFegXKJJ+RevUZ7GJGzxn6mLJeTT0?=
 =?iso-8859-1?Q?2yim5PILxfhBrTsV/PSJrdxwLKER1yHhnNU6c7KNlbpMphDG7ru7J4mFVA?=
 =?iso-8859-1?Q?vj1mgR5jZiRQ+lT4cv2VAHOAHNo+ZlFoV0tFkKmic2dqxxRm7fd/dx1Akx?=
 =?iso-8859-1?Q?7W2ALi9lo5bMCx7YzI1Q56nszypcrUwPzupo4LXGL/5RISriWTu50MSt+a?=
 =?iso-8859-1?Q?EkFeticC9dlweeCM6tw3LcnX/4tsifX4WzY3KeGgShrcSnRvA6AesYgWrK?=
 =?iso-8859-1?Q?LtyMofSDQtc32IaMR29ZmwMPo4HVylHHu40uyoEDxIF6qnQA2sZCby5YWk?=
 =?iso-8859-1?Q?RlMWysqN2DrXH8kROFkUefnjkrviSOkilog+q/u5teiCJ4CjJSyKHtrbVo?=
 =?iso-8859-1?Q?utl+4uB6atgxKXBUcd+XV+f4D2EVbioY24DJJJeQ9ukCsMU3hKOS17NB5h?=
 =?iso-8859-1?Q?sd6O4ByAb+jU7cKzJjTzh6mowqRQCCTfft5zvRXG1o2R/7G14996HyPbA/?=
 =?iso-8859-1?Q?vZMID3Z+xcHpNxGOf4Q6r5+Oc/+bvPibgOdhBVaRfctA71T0DUUZv3SQGp?=
 =?iso-8859-1?Q?wcd5ik8LwsTIaQRtlbYQw1qiuiaudO7BydSxk7+04/h82p3tb0SBQEjoFI?=
 =?iso-8859-1?Q?V/2FqIyEPWwAb5StEeAI7D2Zg4Ph2FW3cTT0SbDLLaGV1RFUcQSFieNyWA?=
 =?iso-8859-1?Q?pyI5vBkbS5l2yAUqt7+9ybMdTNr/s0hzVgIjoZwrBpo0V8WX6XVbtPglmc?=
 =?iso-8859-1?Q?3gzO4FMMO9zUjTLUsYEzQWhY5myUvw/GDBcK335CGtNH1+0hvFnNCN4xAu?=
 =?iso-8859-1?Q?hs19XsZAkxLurvD8+Y1dPDYVf9QEpLvbNP1nK9x3rnwHXEh9cPJUQihXTq?=
 =?iso-8859-1?Q?GgPyoIQZS67papsoj3nNRS/ylsIes9202f1kCccheUvErXxUPMOzjyx2hg?=
 =?iso-8859-1?Q?5LC2tHNzSo0lgSQDbXH3/5BDe7KWKOFjk7quTqU8lEwBJ5Y/trIC2L+d+4?=
 =?iso-8859-1?Q?qcrxwwrBLvHYJ08XvwNAwbiJwugtrxVhAx9Sroo2qRh3mLYFTOEnMlzsz6?=
 =?iso-8859-1?Q?HOpBQL1UFhgbWnJRK9M=3D?=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(1800799024)(38070700021);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?iso-8859-1?Q?Tn+Y2R7usJsLSSLorQ0UiDxp9nsdMuUlhcko4HdFe/kJsOBPDR7Ib8Lf0N?=
 =?iso-8859-1?Q?FttbOIRP/YOXSP4aX4fKmnMj6BplyzOzaBZVjkHmlveOVC7KYcY/eG2KLh?=
 =?iso-8859-1?Q?by2RA6ufufJ7EFG9IT2bZ9YPWO/Vt4ZfLf6U88cqgkgFOBye4AXMPModCc?=
 =?iso-8859-1?Q?ZKLjWaZXMwdcNh9KLAbrk8w7LyLBtxWQwIxI9/LwaJE9Uj0OCS51AITrXU?=
 =?iso-8859-1?Q?diTo8DafgWn0McJYlkCuspqf388CV2M6lEeVR+0cJ37mOwBnwGmVftSV33?=
 =?iso-8859-1?Q?vtpyPvG7kyQJb62LsAhBNNnuHjdw0NAG2cUc3xnpBONGNo4wnhpsghMhiy?=
 =?iso-8859-1?Q?UAYKvyoV0SSxXpgSlTHRMXa6l9OX8hiCq9+Q/VQ2o5d3RwCDKKD1l1WbeN?=
 =?iso-8859-1?Q?h5LOOQhI+TySsx7ruC4Okt2gLSB7UqqzA9X/3RVU97mBseFaxi5kG0MjuD?=
 =?iso-8859-1?Q?z/iFP2TbFxHpgleaO3Obq/ZJwWLAV5WbZklodT/SRRXkcDp+8Xa8p9niuZ?=
 =?iso-8859-1?Q?8VXYY/JP3dYNUwBYVUef9h8Y5rQeSfGl38uCu5f/8Irk/Gis2nDSW22Pi9?=
 =?iso-8859-1?Q?Fx+Vbju7ONYGa7YETSKqBqTUe5EH0q2iAYs9/KP31ef7+nqIihX00uNLZq?=
 =?iso-8859-1?Q?dCppBAllLhUalVC10NO/vcRCI+PlH2XsG5036whS+fjRU1GNfk7isGgQse?=
 =?iso-8859-1?Q?66EkpuqEsl+eiMmXHavKJ+oKgjBCGa7IXRLqOMCLNG2T26DIGtkN9+vxYm?=
 =?iso-8859-1?Q?R87suLJNAggderi8P0HS2cAv5bKzmRwzdeKYn7OacoM/YnWyWb7gZS2QHN?=
 =?iso-8859-1?Q?EsPKG0qrHffhtF2sTIKj/iaZQvOz1WsXRJ+OK7/UdkSzxdWu4OR0eWRs+a?=
 =?iso-8859-1?Q?bpat1u+jAbwqKXTp99TmQd/+cXb0y1rqovEdnemhA51ClccaF23vUni3LT?=
 =?iso-8859-1?Q?8z9dnSWA90AILXazYNd9qgPiVrATl6vplHPN5CVcWTME/mXd44nNlIuNpt?=
 =?iso-8859-1?Q?ohuXKuB8z1JccAqAR5fyZAcbQy3qv8jEbUxdO5Hg0ysYLBKGTlpc6DEyo2?=
 =?iso-8859-1?Q?xupyhhBAZOf0gnywJoQiWnW5cMwbxtvRqsHHNZbfXVczxT+WSz/OgBcrOW?=
 =?iso-8859-1?Q?fbospk1rs4fNt0YC/IfKtvDcKnwJeUUjBa9cT3MuxacKaR9lCJWDyUSzc0?=
 =?iso-8859-1?Q?+TCu5DvtpHi0rj1LWzoKH1J7/3G2xT50p87nBzQAI3l4AJR3zwQ9pLRtEl?=
 =?iso-8859-1?Q?4wf/Ju+WjiZsoyFQzLvB1kJnHrBJSoq1+1l1nrZuoObSe6uu6ewWFZPtst?=
 =?iso-8859-1?Q?YfmUncwZo2WOE1g07xstuDS5Zyb+sZZNBmVogaPG4amKCjpuYQqVGt1no5?=
 =?iso-8859-1?Q?NVkSNUlMtONqq3ds3pzfVlfKpkCb8cS+kUGBbpGEcaIMnQg+oNoLTboJpo?=
 =?iso-8859-1?Q?bcNrPnvYTLCOr/P88QSqgsIK8QPgeRrnxLuxFvKiDJR+INtLZwEh0uRo7M?=
 =?iso-8859-1?Q?q6KhRhohmwoVWvSscl5OyEhfJbZ1eEOPfMwgjz3/dH0YBsrzdMcMHd0AhQ?=
 =?iso-8859-1?Q?dEnHZ8Q8DLR+PjzRbw32fCYuswoqlNDW+ovBUo0ruWa163J+X3KubEv0tC?=
 =?iso-8859-1?Q?ly9xwwu19Js5Mn+XNYoVZVlenhhSm//vTjhmLGzQfBOqLSWBEaICqVe8ua?=
 =?iso-8859-1?Q?hx9Ez+Wi0WADuorOZ1o9l/5iEFjRm3y1PbGCpkvZRGfelle+5DuolpykOk?=
 =?iso-8859-1?Q?TRlVSuS7sh5BC/aiLHCM2ZyJvK+EauFkAt1v64maJmsO3lEwPy3Iqj+veQ?=
 =?iso-8859-1?Q?TfYKKR/gsA=3D=3D?=
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: c2631645-f5c8-4ca7-9697-08de67e3db7c
X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Feb 2026 14:02:27.0591
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: GMQlgivrpfbTzZ/4rdeM1tcb2Eu6t6TxuobP9/tJsms4+jNwav5dvW8FAjgrP8gnArHxGa/rUFhaTOB9t+iFmQ==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN5PR03MB8042

> Could you add some comments to explain the potential issue with=0A=
> RegisterEventSource?=0A=
=0A=
RegisterEventSource is marked deprecated - CodeQL detected this issue=0A=
https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/28735-ba=
nned-crimson-api-usage=0A=
I will add a comment to this effect.=0A=
=0A=
> I think it'd be great if you could provide similar patches for=0A=
> xencons_monitor and xenagent as well.=0A=
=0A=
Similar patches will be created for the other user mode components.=0A=
=0A=
>> ---=0A=
>> +TRACELOGGING_DEFINE_PROVIDER(g_xenbus_monitor,=0A=
>=0A=
>=0A=
>The provider handle name should use the same convention as other global=0A=
>variables (e.g. MonitorTraceLoggingProvider).=0A=
>=0A=
>> +                             MONITOR_NAME,=0A=
>> +                             //{E8ADEEB7-6DD1-447E-A49B-A6571CC74039}=
=0A=
>> +                             (0xe8adeeb7, 0x6dd1, 0x447e, 0xa4, 0x9b, 0=
xa6, 0x57, 0x1c, 0xc7, 0x40, 0x39)=0A=
>=0A=
>Is it worth having a DEFINE_GUID for this somewhere?=0A=
=0A=
This is how the macro is documented - I'd assume the macro will internally =
define the guid correctly,=0A=
using DEFINE_GUID will cause issues with the trace macro's expansion.=0A=
=0A=
>> +    case LOG_INFO:=0A=
>> +        TraceLoggingWrite(g_xenbus_monitor,=0A=
>> +            "Information",=0A=
>> +            TraceLoggingLevel(WINEVENT_LEVEL_INFO),=0A=
>> +            TraceLoggingString(Buffer, "Info")=0A=
>=0A=
>Buffer is a PTSTR, so we should have an appropriate #define for=0A=
>TraceLoggingString.=0A=
=0A=
=0A=
>> -        Log("[%u]: %s [%s]",=0A=
>> +        LogInfo("[%u]: %s [%s]",=0A=
>>               SessionId,=0A=
>>               Name,=0A=
>>               WTSStateName(State));=0A=
>=0A=
>Could you align the arguments here (and elsewhere)?=0A=
=0A=
Sure=0A=
=0A=
=0A=
=0A=
Owen=0A=
=0A=


From win-pv-devel-bounces@lists.xenproject.org Mon Feb 09 14:08:22 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 09 Feb 2026 14:08:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1225410.1531901 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vpRw5-000272-1Q; Mon, 09 Feb 2026 14:08:21 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1225410.1531901; Mon, 09 Feb 2026 14:08:21 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vpRw4-00026v-VH; Mon, 09 Feb 2026 14:08:20 +0000
Received: by outflank-mailman (input) for mailman id 1225410;
 Mon, 09 Feb 2026 14:08:20 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ycMC=AN=bounce.vates.tech=bounce-md_30504962.6989ea4b.v1-dcab59c1f708455e8db8488cb08b53d6@srs-se1.protection.inumbo.net>)
 id 1vpRw4-00026p-AQ
 for win-pv-devel@lists.xenproject.org; Mon, 09 Feb 2026 14:08:20 +0000
Received: from mail177-22.suw61.mandrillapp.com
 (mail177-22.suw61.mandrillapp.com [198.2.177.22])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id c553e1c4-05c0-11f1-9ccf-f158ae23cfc8;
 Mon, 09 Feb 2026 15:08:13 +0100 (CET)
Received: from pmta14.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail177-22.suw61.mandrillapp.com (Mailchimp) with ESMTP id
 4f8mkN0PCSzGlsp12
 for <win-pv-devel@lists.xenproject.org>; Mon,  9 Feb 2026 14:08:12 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 dcab59c1f708455e8db8488cb08b53d6; Mon, 09 Feb 2026 14:08:11 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: c553e1c4-05c0-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770646092; x=1770916092;
	bh=8LRBQanG7qV4RUnH6XItVr3OFhZHNGKd6MzE06AUFWA=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=SkjM1Pi8iZaVYGXic5FuIY36BSwgoOI7qHl4L2aBymuSLjaoAtWObNGUpARXTi31G
	 IPmGvHEFp0TA6obKBWJFGrp/Fh+8FUlRnHUwei53eAN+u64lo8nCfkzkRdy7N0x+7I
	 tWTIH2eU30T7SJ666F5/yimOjXHwm/TGIK+Fo1HCL1USDAs3tZIT+FcU6LGXKHyVN+
	 qu81mbCH/IsTqH/Q93LKe35U+IYIcQ4Y988AXyZ5g17JE3a0t56iykeRcS0oxyIbxF
	 9LODsRnEc1GAUw7CqIAW+VHCksgpZGySZW6JQ+GtCHdaStYgJNJd7i9UF6+83S0oEO
	 CrtIy6nGoXlnA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770646092; x=1770906592; i=ngoc-tu.dinh@vates.tech;
	bh=8LRBQanG7qV4RUnH6XItVr3OFhZHNGKd6MzE06AUFWA=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=GuUeW6T6Vqlp81RFAqpNb0+MofJWLRuwO/dIAwJwEuWR522RwEe6m14X281wE1kce
	 jrMrtDyvFDJcs1qhhvM9AWA/zZoSuk4WQaQdMm6DWqISXQV9JLXWOSaECjo6rhU6uH
	 Hv3B2blWVxA+59Pvanmnzr0gtDVeWFZjIuJDLVSXqWSiAym8Lu0TK+wKKIucU19XxO
	 9JQ+s9rqj3ijcjkrWFuVLRorQz98O0zHm/TsLnGm+lrFE4fMes77TS9NxrN920zZiZ
	 VRAznfSwBXqUR6ch9VgfyewvybCRwCfRPKpu3H/ep+sMr2NbtEvzmEDCK63rexchXI
	 J0suW6OGfHBYg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=205/5]=20Replace=20RegisterEventSource=20with=20TraceLoggingRegister?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770646091131
Message-Id: <068c1989-cf8e-42d6-b6f7-b2effea5f7dd@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
Cc: "david ambu" <david.preetham@cloud.com>
References: <20260206084525.1356-1-owen.smith@citrix.com> <20260206084525.1356-5-owen.smith@citrix.com> <c8822cc4-06e2-4e84-b1a7-f052828c12d4@vates.tech> <SA6PR03MB776023723AA7D371ED0F3652FE65A@SA6PR03MB7760.namprd03.prod.outlook.com>
In-Reply-To: <SA6PR03MB776023723AA7D371ED0F3652FE65A@SA6PR03MB7760.namprd03.prod.outlook.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.dcab59c1f708455e8db8488cb08b53d6?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260209:md
Date: Mon, 09 Feb 2026 14:08:11 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 09/02/2026 15:03, Owen Smith wrote:
>> Could you add some comments to explain the potential issue with
>> RegisterEventSource?
> 
> RegisterEventSource is marked deprecated - CodeQL detected this issue
> https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/28735-banned-crimson-api-usage
> I will add a comment to this effect.
> 
>> I think it'd be great if you could provide similar patches for
>> xencons_monitor and xenagent as well.
> 
> Similar patches will be created for the other user mode components.
> 
>>> ---
>>> +TRACELOGGING_DEFINE_PROVIDER(g_xenbus_monitor,
>>
>>
>> The provider handle name should use the same convention as other global
>> variables (e.g. MonitorTraceLoggingProvider).
>>
>>> +                             MONITOR_NAME,
>>> +                             //{E8ADEEB7-6DD1-447E-A49B-A6571CC74039}
>>> +                             (0xe8adeeb7, 0x6dd1, 0x447e, 0xa4, 0x9b, 0xa6, 0x57, 0x1c, 0xc7, 0x40, 0x39)
>>
>> Is it worth having a DEFINE_GUID for this somewhere?
> 
> This is how the macro is documented - I'd assume the macro will internally define the guid correctly,
> using DEFINE_GUID will cause issues with the trace macro's expansion.
> 

I see, thanks. Was the GUID generated from MONITOR_NAME using the code 
given in TraceLoggingProvider.h or was it randomly generated?

Also, a codestyle nit: the parentheses of function calls are attached to 
the last argument:

     ...,
     MONITOR_NAME,
     //{E8ADEEB7-6DD1-447E-A49B-A6571CC74039}
     (0xe8adeeb7, 0x6dd1, 0x447e, 0xa4, 0x9b, 0xa6, 0x57, 0x1c, 0xc7, 
0x40, 0x39));

(and in the TraceLoggingWrite calls elsewhere)

>>> +    case LOG_INFO:
>>> +        TraceLoggingWrite(g_xenbus_monitor,
>>> +            "Information",
>>> +            TraceLoggingLevel(WINEVENT_LEVEL_INFO),
>>> +            TraceLoggingString(Buffer, "Info")
>>
>> Buffer is a PTSTR, so we should have an appropriate #define for
>> TraceLoggingString.
> 
> 
>>> -        Log("[%u]: %s [%s]",
>>> +        LogInfo("[%u]: %s [%s]",
>>>                SessionId,
>>>                Name,
>>>                WTSStateName(State));
>>
>> Could you align the arguments here (and elsewhere)?
> 
> Sure
> 
> 
> 
> Owen
> 
> 



--
 | Vates

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Feb 11 10:08:49 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Feb 2026 10:08:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1227169.1533514 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq79M-0005OX-Bm; Wed, 11 Feb 2026 10:08:48 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1227169.1533514; Wed, 11 Feb 2026 10:08:48 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq79M-0005OP-96; Wed, 11 Feb 2026 10:08:48 +0000
Received: by outflank-mailman (input) for mailman id 1227169;
 Wed, 11 Feb 2026 10:08:47 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=5A6a=AP=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vq79K-0005Ml-VX
 for win-pv-devel@lists.xenproject.org; Wed, 11 Feb 2026 10:08:46 +0000
Received: from na1pdmzitismtp02.tibco.com (na1pdmzitismtp02.tibco.com
 [160.101.131.9]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id a1a574f7-0731-11f1-9ccf-f158ae23cfc8;
 Wed, 11 Feb 2026 11:08:38 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id 5E1B3819ADC8;
 Wed, 11 Feb 2026 05:08:13 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: a1a574f7-0731-11f1-9ccf-f158ae23cfc8
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>,
	david ambu <david.preetham@cloud.com>
Subject: [PATCH 1/3] registry: use RegCloseKey for RequestKey and ParametersKey
Date: Wed, 11 Feb 2026 10:08:03 +0000
Message-ID: <20260211100806.1648-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <913a9fad-af24-4a21-8c07-ff0c8bc22462@vates.tech>
References: <913a9fad-af24-4a21-8c07-ff0c8bc22462@vates.tech>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

CloseHandle silently fails for HKEY.

Signed-off-by: david ambu <david.preetham@cloud.com>

Refactored to before other patches

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 1154de5..347bef0 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1502,7 +1502,7 @@ done:
     free(Context->Question);
     free(Context->Text);
     free(Context->Title);
-    CloseHandle(Context->RequestKey);
+    RegCloseKey(Context->RequestKey);
     free(RequestKeyName);
     CloseHandle(Context->ResponseEvent);
     CloseHandle(Context->RequestEvent);
@@ -1512,7 +1512,7 @@ done:
 
     (VOID) DeregisterEventSource(Context->EventLog);
 
-    CloseHandle(Context->ParametersKey);
+    RegCloseKey(Context->ParametersKey);
     (VOID) RemoveStartOverride("stornvme");
 
     Log("<====");
@@ -1530,7 +1530,7 @@ fail11:
 fail10:
     Log("fail10");
 
-    CloseHandle(Context->RequestKey);
+    RegCloseKey(Context->RequestKey);
 
 fail9:
     Log("fail9");
@@ -1568,7 +1568,7 @@ fail3:
 fail2:
     Log("fail2");
 
-    CloseHandle(Context->ParametersKey);
+    RegCloseKey(Context->ParametersKey);
 
 fail1:
     Error = GetLastError();
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Wed Feb 11 10:08:54 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Feb 2026 10:08:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1227171.1533518 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq79S-0005RY-Cp; Wed, 11 Feb 2026 10:08:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1227171.1533518; Wed, 11 Feb 2026 10:08:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq79S-0005RP-AR; Wed, 11 Feb 2026 10:08:54 +0000
Received: by outflank-mailman (input) for mailman id 1227171;
 Wed, 11 Feb 2026 10:08:53 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=5A6a=AP=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vq79R-0005Ml-0Z
 for win-pv-devel@lists.xenproject.org; Wed, 11 Feb 2026 10:08:53 +0000
Received: from na1pdmzitismtp02.tibco.com (na1pdmzitismtp02.tibco.com
 [160.101.131.9]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id a26783b8-0731-11f1-9ccf-f158ae23cfc8;
 Wed, 11 Feb 2026 11:08:39 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id BB84181C2BE6;
 Wed, 11 Feb 2026 05:08:14 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: a26783b8-0731-11f1-9ccf-f158ae23cfc8
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 3/3] Remove StartOverride from all storage adapters
Date: Wed, 11 Feb 2026 10:08:05 +0000
Message-ID: <20260211100806.1648-3-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <20260211100806.1648-1-owen.smith@citrix.com>
References: <913a9fad-af24-4a21-8c07-ff0c8bc22462@vates.tech>
 <20260211100806.1648-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Its possible to install non-Microsoft NVMe drivers on the emulated
NVMe device. During upgrades, the VM requires a reboot using the emulated
devices, but if the driver assigned for the emulated device has a StartOverride
setting, then its likely not started which results in a 0x7B bugcheck.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c                        | 67 +++++++++++++++++---
 vs2019/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
 vs2022/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
 3 files changed, 59 insertions(+), 12 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 700f196..eb1be91 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -42,6 +42,8 @@
 #include <assert.h>
 #include <TraceLoggingProvider.h>
 #include <winmeta.h>
+#include <setupapi.h>
+#include <devguid.h>
 
 #include <version.h>
 
@@ -1328,7 +1330,7 @@ fail1:
     return FALSE;
 }
 
-static BOOL
+static VOID
 RemoveStartOverride(
     _In_ PTSTR          DriverName
     )
@@ -1336,17 +1338,61 @@ RemoveStartOverride(
     TCHAR               KeyName[MAX_PATH];
     HRESULT             Error;
 
+    LogInfo("%s", DriverName);
+
     Error = StringCbPrintf(KeyName,
                            MAX_PATH,
                            SERVICES_KEY "\\%s\\StartOverride",
                            DriverName);
     assert(SUCCEEDED(Error));
 
-    Error = RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
-    if (Error != ERROR_SUCCESS)
+    (VOID) RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
+}
+
+static VOID
+RemoveStartOverrideForClass(
+    _In_ const GUID*    Guid
+    )
+{
+    HRESULT             Error;
+    HDEVINFO            hDevInfo;
+    DWORD               Index;
+    SP_DEVINFO_DATA     devInfoData;
+
+    hDevInfo = SetupDiGetClassDevs(Guid,
+                                   NULL,
+                                   NULL,
+                                   0);
+    if (hDevInfo == INVALID_HANDLE_VALUE)
         goto fail1;
 
-    return TRUE;
+    memset(&devInfoData, 0, sizeof(devInfoData));
+    devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
+
+    for (Index = 0;
+         SetupDiEnumDeviceInfo(hDevInfo, Index, &devInfoData);
+         ++Index) {
+        TCHAR           Buffer[MAX_PATH];
+        memset(Buffer, 0, sizeof(Buffer));
+
+        if (SetupDiGetDeviceRegistryProperty(hDevInfo,
+                                             &devInfoData,
+                                             SPDRP_SERVICE,
+                                             NULL,
+                                             (PBYTE)Buffer,
+                                             sizeof(Buffer),
+                                             NULL)) {
+            Buffer[MAX_PATH - 1] = _T('\0');
+            RemoveStartOverride(Buffer);
+        }
+
+        memset(&devInfoData, 0, sizeof(devInfoData));
+        devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
+    }
+
+    SetupDiDestroyDeviceInfoList(hDevInfo);
+
+    return;
 
 fail1:
     Error = GetLastError();
@@ -1357,8 +1403,6 @@ fail1:
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
-
-    return FALSE;
 }
 
 VOID WINAPI
@@ -1381,7 +1425,8 @@ MonitorMain(
 
     LogInfo("====>");
 
-    (VOID) RemoveStartOverride("stornvme");
+    RemoveStartOverride("stornvme");
+    RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
 
     Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                          PARAMETERS_KEY(__MODULE__),
@@ -1525,10 +1570,12 @@ done:
     CloseHandle(Context->RequestEvent);
     CloseHandle(Context->StopEvent);
 
-    ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
-
     RegCloseKey(Context->ParametersKey);
-    (VOID) RemoveStartOverride("stornvme");
+
+    RemoveStartOverride("stornvme");
+    RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
+
+    ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
 
     LogInfo("<====");
 
diff --git a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
index 3b44e29..df1fd58 100644
--- a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
+++ b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
@@ -34,7 +34,7 @@
       <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <CETCompat>true</CETCompat>
       <GenerateMapFile>true</GenerateMapFile>
       <MapExports>true</MapExports>
diff --git a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
index 484fa1c..196a744 100644
--- a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
+++ b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
@@ -34,7 +34,7 @@
       <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <CETCompat>true</CETCompat>
       <GenerateMapFile>true</GenerateMapFile>
       <MapExports>true</MapExports>
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Wed Feb 11 10:08:56 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Feb 2026 10:08:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1227173.1533521 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq79U-0005Vw-Ed; Wed, 11 Feb 2026 10:08:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1227173.1533521; Wed, 11 Feb 2026 10:08:56 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq79U-0005Vp-Bj; Wed, 11 Feb 2026 10:08:56 +0000
Received: by outflank-mailman (input) for mailman id 1227173;
 Wed, 11 Feb 2026 10:08:55 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=5A6a=AP=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vq79T-0005Ml-0i
 for win-pv-devel@lists.xenproject.org; Wed, 11 Feb 2026 10:08:55 +0000
Received: from na1pdmzitismtp02.tibco.com (na1pdmzitismtp02.tibco.com
 [160.101.131.9]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id a218cecb-0731-11f1-9ccf-f158ae23cfc8;
 Wed, 11 Feb 2026 11:08:38 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id 1452381C2BEE;
 Wed, 11 Feb 2026 05:08:13 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: a218cecb-0731-11f1-9ccf-f158ae23cfc8
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>,
	david ambu <david.preetham@cloud.com>
Subject: [PATCH 2/3] Replace RegisterEventSource with TraceLoggingRegister
Date: Wed, 11 Feb 2026 10:08:04 +0000
Message-ID: <20260211100806.1648-2-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <20260211100806.1648-1-owen.smith@citrix.com>
References: <913a9fad-af24-4a21-8c07-ff0c8bc22462@vates.tech>
 <20260211100806.1648-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

- Added TraceLogging levels for Information and Error events.
- Replaced RegisterEventSource due to potential security issues.
  This issue was raised by CodeQL 2.20.1,
  "RegisterEventSourceA has been marked deprecated as it is a legacy
   tracing API. Please migrate to modern Event Tracing for Windows APIs."
see: https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/28735-banned-crimson-api-usage

Signed-off-by: david ambu <david.preetham@cloud.com>

* defined seperate macros for Info and Error logging
* use a switch on log level, rather than if/else

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 292 ++++++++++++++++++++++--------------------
 1 file changed, 153 insertions(+), 139 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 347bef0..700f196 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -40,6 +40,8 @@
 #include <powrprof.h>
 #include <malloc.h>
 #include <assert.h>
+#include <TraceLoggingProvider.h>
+#include <winmeta.h>
 
 #include <version.h>
 
@@ -56,7 +58,6 @@ typedef struct _MONITOR_CONTEXT {
     SERVICE_STATUS          Status;
     SERVICE_STATUS_HANDLE   Service;
     HKEY                    ParametersKey;
-    HANDLE                  EventLog;
     HANDLE                  StopEvent;
     HANDLE                  RequestEvent;
     HANDLE                  Timer;
@@ -90,17 +91,30 @@ MONITOR_CONTEXT MonitorContext;
 #define PARAMETERS_KEY(_Service) \
         SERVICE_KEY(_Service) ## "\\Parameters"
 
+TRACELOGGING_DEFINE_PROVIDER(MonitorTraceLoggingProvider,
+                             MONITOR_NAME,
+                             //{54F99C5B-76EC-5F84-3F97-4C9F40AA0F1A}
+                             (0x54f99c5b, 0x76ec, 0x5f84, 0x3f, 0x97, 0x4c, 0x9f, 0x40, 0xaa, 0x0f, 0x1a));
+
+typedef enum {
+    LOG_INFO,
+    LOG_ERROR
+} LOG_LEVEL;
+
+#ifdef UNICODE
+#define TraceLoggingStringT(_buf, _name)    TraceLoggingWideString(_buf, _name)
+#else
+#define TraceLoggingStringT(_buf, _name)    TraceLoggingString(_buf, _name)
+#endif
+
 static VOID
 #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
 __Log(
+    _In_ LOG_LEVEL      Level,
     _In_ PCSTR          Format,
     ...
     )
 {
-#if DBG
-    PMONITOR_CONTEXT    Context = &MonitorContext;
-    const TCHAR         *Strings[1];
-#endif
     TCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
     va_list             Arguments;
     size_t              Length;
@@ -127,24 +141,29 @@ __Log(
 
     OutputDebugString(Buffer);
 
-#if DBG
-    Strings[0] = Buffer;
-
-    if (Context->EventLog != NULL)
-        ReportEvent(Context->EventLog,
-                    EVENTLOG_INFORMATION_TYPE,
-                    0,
-                    MONITOR_LOG,
-                    NULL,
-                    ARRAYSIZE(Strings),
-                    0,
-                    Strings,
-                    NULL);
-#endif
+    switch (Level) {
+    case LOG_INFO:
+        TraceLoggingWrite(MonitorTraceLoggingProvider,
+                          _T("Information"),
+                          TraceLoggingLevel(WINEVENT_LEVEL_INFO),
+                          TraceLoggingStringT(Buffer, _T("Info")));
+        break;
+    case LOG_ERROR:
+        TraceLoggingWrite(MonitorTraceLoggingProvider,
+                          _T("Error"),
+                          TraceLoggingLevel(WINEVENT_LEVEL_ERROR),
+                          TraceLoggingStringT(Buffer, _T("Error")));
+        break;
+    default:
+        break;
+    }
 }
 
-#define Log(_Format, ...) \
-        __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
+#define LogInfo(_Format, ...) \
+        __Log(LOG_INFO, __MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
+
+#define LogError(_Format, ...) \
+        __Log(LOG_ERROR, __MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
 
 static PTSTR
 GetErrorMessage(
@@ -209,7 +228,7 @@ ReportStatus(
     BOOL                Success;
     HRESULT             Error;
 
-    Log("====> (%s)", ServiceStateName(CurrentState));
+    LogInfo("====> (%s)", ServiceStateName(CurrentState));
 
     Context->Status.dwCurrentState = CurrentState;
     Context->Status.dwWin32ExitCode = Win32ExitCode;
@@ -233,7 +252,7 @@ ReportStatus(
     if (!Success)
         goto fail1;
 
-    Log("<====");
+    LogInfo("<====");
 
     return;
 
@@ -243,7 +262,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -320,11 +339,11 @@ DoReboot(
     _In_ DWORD  Timeout
     )
 {
-    Log("waiting for pending install events...");
+    LogInfo("waiting for pending install events...");
 
     (VOID) CM_WaitNoPendingInstallEvents(INFINITE);
 
-    Log("initiating shutdown...");
+    LogInfo("initiating shutdown...");
 
 #pragma prefast(suppress:28159)
     (VOID) InitiateSystemShutdownEx(NULL,
@@ -360,7 +379,7 @@ GetPromptTimeout(
         Type != REG_DWORD)
         Value = 0;
 
-    Log("%u", Value);
+    LogInfo("%u", Value);
 
     return Value;
 }
@@ -439,18 +458,18 @@ GetDisplayName(
     return DisplayName;
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
     free(DisplayName);
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     RegCloseKey(ServiceKey);
 
@@ -460,7 +479,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -525,10 +544,10 @@ DoPromptForReboot(
         WTS_CONNECTSTATE_CLASS  State = SessionInfo[Index].State;
         DWORD                   Response;
 
-        Log("[%u]: %s [%s]",
-            SessionId,
-            Name,
-            WTSStateName(State));
+        LogInfo("[%u]: %s [%s]",
+                SessionId,
+                Name,
+                WTSStateName(State));
 
         if (State != WTSActive)
             continue;
@@ -559,7 +578,7 @@ DoPromptForReboot(
     return ERROR_SUCCESS;
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
     *Prompt->PResponse = 0;
 
 fail1:
@@ -592,7 +611,7 @@ PromptForReboot(
         return;
     Context->RebootPrompted = TRUE;
 
-    Log("====> (%s)", DriverName);
+    LogInfo("====> (%s)", DriverName);
 
     Prompt = calloc(1, sizeof (REBOOT_PROMPT));
     if (Prompt == NULL) {
@@ -659,20 +678,20 @@ PromptForReboot(
     return;
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
     free(DisplayName);
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -766,9 +785,9 @@ TryAutoReboot(
     if (RebootCount >= AutoReboot)
         goto prompt;
 
-    Log("AutoRebooting (reboot %u of %u)\n",
-        RebootCount,
-        AutoReboot);
+    LogInfo("AutoRebooting (reboot %u of %u)\n",
+            RebootCount,
+            AutoReboot);
 
     ++RebootCount;
 
@@ -838,18 +857,18 @@ done:
     return;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(DisplayName);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -870,7 +889,7 @@ CheckRequestSubKeys(
     HKEY                SubKey;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     Error = RegQueryInfoKey(Context->RequestKey,
                             NULL,
@@ -916,7 +935,7 @@ CheckRequestSubKeys(
             goto fail3;
         }
 
-        Log("%s", SubKeyName);
+        LogInfo("%s", SubKeyName);
 
         Error = RegOpenKeyEx(Context->RequestKey,
                              SubKeyName,
@@ -960,17 +979,17 @@ found:
 done:
     free(SubKeyName);
 
-    Log("<====");
+    LogInfo("<====");
 
     return;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(SubKeyName);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -978,7 +997,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -991,7 +1010,7 @@ CheckRequestKey(
     PMONITOR_CONTEXT    Context = &MonitorContext;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     CheckRequestSubKeys();
 
@@ -1004,7 +1023,7 @@ CheckRequestKey(
     if (Error != ERROR_SUCCESS)
         goto fail1;
 
-    Log("<====");
+    LogInfo("<====");
 
     return;
 
@@ -1014,7 +1033,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -1029,7 +1048,7 @@ AcquireShutdownPrivilege(
     BOOL                Success;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     New.PrivilegeCount = 1;
 
@@ -1061,17 +1080,17 @@ AcquireShutdownPrivilege(
 
     CloseHandle(Token);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     CloseHandle(Token);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1079,7 +1098,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1137,20 +1156,20 @@ GetRequestKeyName(
         goto fail4;
     }
 
-    Log("%s", *RequestKeyName);
+    LogInfo("%s", *RequestKeyName);
 
     return TRUE;
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(*RequestKeyName);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1158,7 +1177,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1264,37 +1283,37 @@ GetDialogParameters(
     return TRUE;
 
 fail10:
-    Log("fail10");
+    LogError("fail10");
 
 fail9:
-    Log("fail9");
+    LogError("fail9");
 
     free(Context->Question);
 
 fail8:
-    Log("fail8");
+    LogError("fail8");
 
 fail7:
-    Log("fail7");
+    LogError("fail7");
 
 fail6:
-    Log("fail6");
+    LogError("fail6");
 
     free(Context->Text);
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(Context->Title);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1302,7 +1321,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1335,7 +1354,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1357,7 +1376,10 @@ MonitorMain(
     UNREFERENCED_PARAMETER(argc);
     UNREFERENCED_PARAMETER(argv);
 
-    Log("====>");
+    if (TraceLoggingRegister(MonitorTraceLoggingProvider) != ERROR_SUCCESS)
+        LogInfo("TraceLoggingRegister failed");
+
+    LogInfo("====>");
 
     (VOID) RemoveStartOverride("stornvme");
 
@@ -1379,11 +1401,6 @@ MonitorMain(
     if (Context->Service == NULL)
         goto fail3;
 
-    Context->EventLog = RegisterEventSource(NULL,
-                                            MONITOR_NAME);
-    if (Context->EventLog == NULL)
-        goto fail4;
-
     Context->Status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
     Context->Status.dwServiceSpecificExitCode = 0;
 
@@ -1395,26 +1412,26 @@ MonitorMain(
                                      NULL);
 
     if (Context->StopEvent == NULL)
-        goto fail5;
+        goto fail4;
 
     Context->RequestEvent = CreateEvent(NULL,
                                         TRUE,
                                         FALSE,
                                         NULL);
     if (Context->RequestEvent == NULL)
-        goto fail6;
+        goto fail5;
 
     Context->ResponseEvent = CreateEvent(NULL,
                                          FALSE,
                                          FALSE,
                                          NULL);
     if (Context->ResponseEvent == NULL)
-        goto fail7;
+        goto fail6;
     Context->Response = 0;
 
     Success = GetRequestKeyName(&RequestKeyName);
     if (!Success)
-        goto fail8;
+        goto fail7;
 
     Error = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
                            RequestKeyName,
@@ -1426,15 +1443,15 @@ MonitorMain(
                            &Context->RequestKey,
                            NULL);
     if (Error != ERROR_SUCCESS)
-        goto fail9;
+        goto fail8;
 
     Success = GetDialogParameters();
     if (!Success)
-        goto fail10;
+        goto fail9;
 
     Context->Timer = CreateWaitableTimer(NULL, FALSE, NULL);
     if (Context->Timer == NULL)
-        goto fail11;
+        goto fail10;
 
     DueTime.QuadPart = -10000LL * REBOOT_RETRY_DELAY;
 
@@ -1445,7 +1462,7 @@ MonitorMain(
                                NULL,
                                FALSE);
     if (!Success)
-        goto fail12;
+        goto fail11;
 
     SetEvent(Context->RequestEvent);
 
@@ -1460,12 +1477,12 @@ MonitorMain(
         Events[2] = Context->ResponseEvent;
         Events[3] = Context->Timer;
 
-        Log("waiting (%u)...", ARRAYSIZE(Events));
+        LogInfo("waiting (%u)...", ARRAYSIZE(Events));
         Object = WaitForMultipleObjects(ARRAYSIZE(Events),
                                         Events,
                                         FALSE,
                                         INFINITE);
-        Log("awake");
+        LogInfo("awake");
 
         switch (Object) {
         case WAIT_OBJECT_0:
@@ -1510,63 +1527,58 @@ done:
 
     ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
 
-    (VOID) DeregisterEventSource(Context->EventLog);
-
     RegCloseKey(Context->ParametersKey);
     (VOID) RemoveStartOverride("stornvme");
 
-    Log("<====");
+    LogInfo("<====");
+
+    TraceLoggingUnregister(MonitorTraceLoggingProvider);
 
     return;
 
-fail12:
-    Log("fail12");
+fail11:
+    LogError("fail11");
 
     CloseHandle(Context->Timer);
 
-fail11:
-    Log("fail11");
-
 fail10:
-    Log("fail10");
-
-    RegCloseKey(Context->RequestKey);
+    LogError("fail10");
 
 fail9:
-    Log("fail9");
+    LogError("fail9");
 
-    free(RequestKeyName);
+    RegCloseKey(Context->RequestKey);
 
 fail8:
-    Log("fail8");
+    LogError("fail8");
 
-    CloseHandle(Context->ResponseEvent);
+    free(RequestKeyName);
 
 fail7:
-    Log("fail7");
+    LogError("fail7");
 
-    CloseHandle(Context->RequestEvent);
+    CloseHandle(Context->ResponseEvent);
 
 fail6:
-    Log("fail6");
+    LogError("fail6");
 
-    CloseHandle(Context->StopEvent);
+    CloseHandle(Context->RequestEvent);
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
-    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
-
-    (VOID) DeregisterEventSource(Context->EventLog);
+    CloseHandle(Context->StopEvent);
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
+
+    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     RegCloseKey(Context->ParametersKey);
 
@@ -1576,9 +1588,11 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
+
+    TraceLoggingUnregister(MonitorTraceLoggingProvider);
 }
 
 static BOOL
@@ -1591,7 +1605,7 @@ MonitorCreate(
     TCHAR       Path[MAX_PATH];
     HRESULT     Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     if(!GetModuleFileName(NULL, Path, MAX_PATH))
         goto fail1;
@@ -1623,17 +1637,17 @@ MonitorCreate(
     CloseServiceHandle(Service);
     CloseServiceHandle(SCManager);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     CloseServiceHandle(SCManager);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1641,7 +1655,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1659,7 +1673,7 @@ MonitorDelete(
     SERVICE_STATUS      Status;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     SCManager = OpenSCManager(NULL,
                               NULL,
@@ -1690,20 +1704,20 @@ MonitorDelete(
     CloseServiceHandle(Service);
     CloseServiceHandle(SCManager);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     CloseServiceHandle(Service);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     CloseServiceHandle(SCManager);
 
@@ -1713,7 +1727,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1731,16 +1745,16 @@ MonitorEntry(
     };
     HRESULT             Error;
 
-    Log("%s (%s) ====>",
-        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-        DAY_STR "/" MONTH_STR "/" YEAR_STR);
+    LogInfo("%s (%s) ====>",
+            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
+            DAY_STR "/" MONTH_STR "/" YEAR_STR);
 
     if (!StartServiceCtrlDispatcher(Table))
         goto fail1;
 
-    Log("%s (%s) <====",
-        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-        DAY_STR "/" MONTH_STR "/" YEAR_STR);
+    LogInfo("%s (%s) <====",
+            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
+            DAY_STR "/" MONTH_STR "/" YEAR_STR);
 
     return TRUE;
 
@@ -1750,7 +1764,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Wed Feb 11 10:45:59 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Feb 2026 10:45:59 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1227216.1533535 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq7jK-0002QU-5o; Wed, 11 Feb 2026 10:45:58 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1227216.1533535; Wed, 11 Feb 2026 10:45:58 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq7jK-0002QN-36; Wed, 11 Feb 2026 10:45:58 +0000
Received: by outflank-mailman (input) for mailman id 1227216;
 Wed, 11 Feb 2026 10:45:56 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZTT8=AP=bounce.vates.tech=bounce-md_30504962.698c5ddb.v1-c3e50c71104a456594c133e3779c885c@srs-se1.protection.inumbo.net>)
 id 1vq7jG-0002QH-HW
 for win-pv-devel@lists.xenproject.org; Wed, 11 Feb 2026 10:45:56 +0000
Received: from mail177-22.suw61.mandrillapp.com
 (mail177-22.suw61.mandrillapp.com [198.2.177.22])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id d364ddfd-0736-11f1-9ccf-f158ae23cfc8;
 Wed, 11 Feb 2026 11:45:49 +0100 (CET)
Received: from pmta14.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail177-22.suw61.mandrillapp.com (Mailchimp) with ESMTP id
 4f9w7v3PRczGlspDj
 for <win-pv-devel@lists.xenproject.org>; Wed, 11 Feb 2026 10:45:47 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 c3e50c71104a456594c133e3779c885c; Wed, 11 Feb 2026 10:45:47 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: d364ddfd-0736-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770806747; x=1771076747;
	bh=V+zWgSHkOTMMk1lV2Mjpo7Nx9qXuDCGobMI/BhmqFoM=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=POAtQIsuaPOnbqhiwpgT+joyO+SyNIxyMJlmBModqx8ZRCXL14/1mIkvfa8mP3wF0
	 d7NaBLDADp0r/xosbiZYwc4xLy5xNQvsynGqOQnvDqbAjuFsJL5pDzM1td7AmHzkU8
	 1ru3Kv8ePkVeu6VU2D+ZBfvc7UhXTTj9nu0gLlxjNTzd+CxyvCQo0+kV4lSUGrpRGV
	 Uson3j2H/CQvJx/gcG4EPbCzVylHPeK+V3DubnbMfkHfNE0a5W5dWjyxxXGYRLcRic
	 Dm9/8zjmAZWArXQY0iGv99+45nEWerhhmFbrULdajnIU5otZnnI+2k1aunZ8sOSCeF
	 GOZb3hEpBzVoA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770806747; x=1771067247; i=ngoc-tu.dinh@vates.tech;
	bh=V+zWgSHkOTMMk1lV2Mjpo7Nx9qXuDCGobMI/BhmqFoM=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=RbP/ktNvo/ub/j8tPD3dVd9J0TV9Mrlsbm75IrLWT/pZH9XaWHEKg+2eAbPLOx3a5
	 FlVCL/c0fmxCCaLQPRZN/lTWBiiUoV5HSUpFjgfqh1g+77SNXTjpW7EwenfQCJu7Yn
	 AK4tzrohxZ8PjvYJxbtaet1KYW7+M/RtWsI5PcA8Hxu8L8L3sC/sIsQyAqRxBrfUyf
	 34PFokQLgko/OpX8bmwedO+mxuRqHszJi93ArEZrKDKDg/NPio2dX33G73CttBQTyz
	 U29Ul6VrCMiZxYh+lKp5MA/dZCaQDn4YmmPXKhQsd0ItPiv8Pz3q8XWeHt+vtDjLUV
	 3SPMJIMgSdfOA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=201/3]=20registry:=20use=20RegCloseKey=20for=20RequestKey=20and=20ParametersKey?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770806746092
Message-Id: <4e9db704-ea1e-4eca-b97d-b71465c86b80@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
Cc: "david ambu" <david.preetham@cloud.com>
References: <913a9fad-af24-4a21-8c07-ff0c8bc22462@vates.tech> <20260211100806.1648-1-owen.smith@citrix.com>
In-Reply-To: <20260211100806.1648-1-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.c3e50c71104a456594c133e3779c885c?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260211:md
Date: Wed, 11 Feb 2026 10:45:47 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 11/02/2026 11:08, Owen Smith wrote:
> CloseHandle silently fails for HKEY.
> 
> Signed-off-by: david ambu <david.preetham@cloud.com>
> 
> Refactored to before other patches
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Reviewed-by: Tu Dinh <ngoc-tu.dinh@vates.tech>

> ---
>   src/monitor/monitor.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 1154de5..347bef0 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -1502,7 +1502,7 @@ done:
>       free(Context->Question);
>       free(Context->Text);
>       free(Context->Title);
> -    CloseHandle(Context->RequestKey);
> +    RegCloseKey(Context->RequestKey);
>       free(RequestKeyName);
>       CloseHandle(Context->ResponseEvent);
>       CloseHandle(Context->RequestEvent);
> @@ -1512,7 +1512,7 @@ done:
>   
>       (VOID) DeregisterEventSource(Context->EventLog);
>   
> -    CloseHandle(Context->ParametersKey);
> +    RegCloseKey(Context->ParametersKey);
>       (VOID) RemoveStartOverride("stornvme");
>   
>       Log("<====");
> @@ -1530,7 +1530,7 @@ fail11:
>   fail10:
>       Log("fail10");
>   
> -    CloseHandle(Context->RequestKey);
> +    RegCloseKey(Context->RequestKey);
>   
>   fail9:
>       Log("fail9");
> @@ -1568,7 +1568,7 @@ fail3:
>   fail2:
>       Log("fail2");
>   
> -    CloseHandle(Context->ParametersKey);
> +    RegCloseKey(Context->ParametersKey);
>   
>   fail1:
>       Error = GetLastError();



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Feb 11 10:58:41 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Feb 2026 10:58:41 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1227288.1533631 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq7vc-0008K9-IY; Wed, 11 Feb 2026 10:58:40 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1227288.1533631; Wed, 11 Feb 2026 10:58:40 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq7vc-0008K2-Fp; Wed, 11 Feb 2026 10:58:40 +0000
Received: by outflank-mailman (input) for mailman id 1227288;
 Wed, 11 Feb 2026 10:58:39 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=5A6a=AP=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vq7vb-0008Jw-Fi
 for win-pv-devel@lists.xenproject.org; Wed, 11 Feb 2026 10:58:39 +0000
Received: from BL0PR03CU003.outbound.protection.outlook.com
 (mail-eastusazlp170120007.outbound.protection.outlook.com
 [2a01:111:f403:c101::7])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 9bb6762f-0738-11f1-9ccf-f158ae23cfc8;
 Wed, 11 Feb 2026 11:58:33 +0100 (CET)
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by DS7PR03MB8193.namprd03.prod.outlook.com (2603:10b6:8:263::18) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9587.15; Wed, 11 Feb
 2026 10:58:31 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9611.008; Wed, 11 Feb 2026
 10:58:30 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 9bb6762f-0738-11f1-9ccf-f158ae23cfc8
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=EoCVXmlXwccM7FyigKMiGNClxNycKrkT6lnUV40ckMDoO6pZ5Bfut0Qzj4qCVrW1NLJyPfcRthn/2Nc/7AK5+hd9diFmrpu8b2wqaTnF3Hf1ahWrOu2l7LVYtxMrAvkXkxjo6F48cKFHkTmZ6p3PaAe8QvnYtTquXokr+L04U1Uy8lv/weT6om+NUvhLTfxHYAWggb21yp6VURw+wX+gBfRmaE++JcjVI4BajT1g0SeBFVZ95v9uGXPgJ6uy/6uTFwK85HMEpIrJG7QWRFt/WSz8KXezNXFKZbunjyk4bdWYfoIcc4QE0Gr93Ll+8arsWqUTpz2ejPjrOFjMI9DbHw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector10001;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=v0MmG55hR5TPdQjzSGUtyMpeLavU8xP+k8rlUw5Irmw=;
 b=zJk+BnYwravXKvOGyKmX1YS9xOioFL4ECf8U7pnX5xFye0s9wCZfbM/Nl45HOpngw2mB0D25HYh+UQSaRDcdZXKDa5onXO5kfBo5d0VGcwqF372VF+IzRObChQYnXTW89oMMqkNutY4bJ/1ktDVv8N0y5AxTAbLNaPIdUqUZxDl8Zfs7ULWECaJucqgU9jsFE1D5yNyLWy1boI7A/J11yN4+oot/0bY5q035slDnz2IqE7+d0W6jzQkUoEpgXmQxygNzVO/dQil20CM1KyG/h48omqBfXK3bW1vfYAhyR1qyB8SOmNG/Q0VmG/WmbYGDQYB1M1dw/q26NwCPh+cubQ==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=v0MmG55hR5TPdQjzSGUtyMpeLavU8xP+k8rlUw5Irmw=;
 b=MvcIeGMfWu+dCS/ZtoAQi5Ad+mteiVb6ZRIXfMJ5ShUngU2UsbLlaLIUtIkuFpWcv9lNTL75z194bCZdxvnMXNZdEeE3MzloZBEvS1BLnjNwWGKX4EUEIxp2q0/XnsWYp9x6LL7l1z4aMZTGLdhyogLbps0v2aUh/bzkhJrf5Jk=
From: Owen Smith <owen.smith@citrix.com>
To: "win-pv-devel@lists.xenproject.org" <win-pv-devel@lists.xenproject.org>
CC: david ambu <david.preetham@cloud.com>
Subject: Re: [PATCH 2/3] Replace RegisterEventSource with TraceLoggingRegister
Thread-Topic: [PATCH 2/3] Replace RegisterEventSource with
 TraceLoggingRegister
Thread-Index: AQHcmz5mNp8kb2Irvki4rayj3g0el7V9U7k5
Date: Wed, 11 Feb 2026 10:58:30 +0000
Message-ID:
 <SA6PR03MB776068F99B256F3B02618D28FE63A@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <913a9fad-af24-4a21-8c07-ff0c8bc22462@vates.tech>
 <20260211100806.1648-1-owen.smith@citrix.com>
 <20260211100806.1648-2-owen.smith@citrix.com>
In-Reply-To: <20260211100806.1648-2-owen.smith@citrix.com>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|DS7PR03MB8193:EE_
x-ms-office365-filtering-correlation-id: cf3ca9af-a03e-4bdd-5995-08de695c7e2f
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|1800799024|366016|376014|38070700021|7142099003;
x-microsoft-antispam-message-info:
 =?us-ascii?Q?jvoixDGR8I2GpwpCYU91+YCKkBl6Ta1/aH2mrHq1oKmHsUnDsmYRnS8i4rBY?=
 =?us-ascii?Q?QF8QJyyLsQS5UAQqG/vwNrsHJF+FdLNHGS1j7RPLSEOyZSO1FYKD0OvzleyO?=
 =?us-ascii?Q?B6iSEv9TejYq8eUj4d9MhgD2EUZc4i39Nt+hunyrq++Ch1tB/Fav++eY+gj2?=
 =?us-ascii?Q?N/tIxAC19oRYdJqPtZfhrjl2VivoVTj94h1JqwBW8pwAGOilNHyIficKPYs6?=
 =?us-ascii?Q?3XPcZYZLqTZbA34xUOK/DMAEXRgQ0Kyk4JFOSuWecNi1ZofYZSmztpkLQk6i?=
 =?us-ascii?Q?eY1txwZjfwL5+zvtjpZrfqKGgP1sYHNW8PulIG5Y4hF7QuDcrrzXRvvc+ZBA?=
 =?us-ascii?Q?NiZsQccg3wd8wAbIaaJLChE9rrzUBRXVXuwY3pVRmn/RQnRQsbbwAkPYEAFn?=
 =?us-ascii?Q?qKs6BGLubDdp/c5o2axFVK94HlO5PAduDuoz25YyAd9iHMV78sKbIoW5GngT?=
 =?us-ascii?Q?UfzkJLkPQH5qqu1Xt4/FMs3ZM8nk7I/TB1x0L73B4bvSbXBWoNBmxJv6BviS?=
 =?us-ascii?Q?rJ7A749bReo6DSQQeswbyEwCAMNlHcFBpTAhck0GLXL9aNM9SE8KZnFu0q+v?=
 =?us-ascii?Q?eIbGZgks8DKXLrq2ZEd9u4WWtfQgQjW0/W0aVXlGtO2R3aY9eM0z29neGhcw?=
 =?us-ascii?Q?R+cb55wsj97nzHR/M2zgEIFG9lZaE185UJsAU7ZQw2+ZryE3KCSQUgOqWgk+?=
 =?us-ascii?Q?TLHRMNZ+7zhVcFzrt2ALgM/7qHFFaxV/5UjMjH6Lyj8j9zccU124ShWQHnoU?=
 =?us-ascii?Q?8WFXa1p+xeCKepzDltBAioJzb5hF7X2y39aSch/bf8GBEf2z4uT8zD8a0Q9v?=
 =?us-ascii?Q?dVMX66ccr2ZJ0uedJGs+CI3zXZ/B2zxaGtC1/IzaZ+bQ2owIN3tzkkszXTNl?=
 =?us-ascii?Q?dxYvRxKr0yE+RS+iZKDdWlRbW7rWLBecWtmc4+JgNMVO/v7yTB9wsTsmJZhW?=
 =?us-ascii?Q?BIw20HDgu7vWsbhVywZWOjBkq6qqdViRQBGkiVkBHQsy2PMewqR71k1eIIFh?=
 =?us-ascii?Q?ogA4khmz08H8qxF3WjNBejgP9Y2sr7kOmECnpNCWc/ikSx/YdN4OkuqwJKYk?=
 =?us-ascii?Q?UvdGi4s1oDNsvaUhvjZg/5rETuQXwOHMCrAxxrwWCisG6Xb+3fXwse/QM0pG?=
 =?us-ascii?Q?otq/7eR9PoauPFv+hPvevrWTMPzKEywTU5U51SCjkqu8YzxfHHmR/16/oCZz?=
 =?us-ascii?Q?r2ONF1oGGaI1sUcNP4hiCYaH74sx9RuuVZVrmp4+iAhC+3X7JrODM3qnerzp?=
 =?us-ascii?Q?+jYPflO3LWRxyQHtukgC/XLV4yoEUnTXlrhdwQYb17dfDkME5zsZhdturcxI?=
 =?us-ascii?Q?IAHGjZ1FzqcQCDvXFNi9Xh37vJe3sPNv4W0eufRLjOoCjHXYpplR97AUSpUF?=
 =?us-ascii?Q?MdxSQAcAjE03H1949He3dDFWmseCH6gSrN/JC9gtQrrpcLGU5JGLgsDBKZlK?=
 =?us-ascii?Q?H9XLQSwFs/S4UgfHDv+iJOsRLvcVSOKXd+bNijamxWUDitz089SvA1BZ+Ioo?=
 =?us-ascii?Q?KIMa7JylYXndDOiP/0vx91nLjpZBvwI3NwH5N0Gv7aC5Fqs9AZnnn/tJrUF9?=
 =?us-ascii?Q?QRmhIoDVz9/TLEULQHgTcj9+lrTK287Fw1ebpd1OJltxEv4tntuai7ThMHTt?=
 =?us-ascii?Q?oIsVlH4roE9J3szzKjq9Fs0=3D?=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(38070700021)(7142099003);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?kwVxlvAYBjGCrJALb7g52snIZl4+BAtWDdfBHUeogLcOpBYjgImZxPSVYDEj?=
 =?us-ascii?Q?jfSUJchJG0oc6GfxhokXmxPONBTadN4Pr5T3t9gnHMj5v+oqDMOShZvpltJO?=
 =?us-ascii?Q?1U7S9K0YiPhywOBquvep/LdWAX6GvamvMiAQ3+z6+akt3vIx3gsIp9qv9J/x?=
 =?us-ascii?Q?rr4RM1fAV0yYGcp2hHuNM+2qZguGZLc02FB0uH55XGeAowwy6A/NbH7L/VD7?=
 =?us-ascii?Q?icEB98PCKHfbG2xvMB02kG20912LP2VobL6fPkE+u2xa0RmamI6mlhkyVXM1?=
 =?us-ascii?Q?mZ2jmbmeGatH5VlQNjjXm5OaxLrTQhj5E8FtEAJh6RvjGLhTDpLj5jLKo65q?=
 =?us-ascii?Q?J1N+vfOyoNnPxyu1uIJRDDirJ0X0JLsEdGXDgKOn629cyvccrCN1GpsUK/dG?=
 =?us-ascii?Q?rhBmh+Rmvg5YlXk9KC/wbodvpP4uOXawfOt3+6nko7lg6G38wm/00AeItpZS?=
 =?us-ascii?Q?uv7jyoj9R9gDt51orJf+PBN+cH0P/WXjwdqJU7bqX4cbvyxmjKm2j/WKx5cx?=
 =?us-ascii?Q?qsxjJB296DUAG7fNCqAToK4HDrTOh/BdaULKB2lWPVb5zojOTIXjaov7Gi3N?=
 =?us-ascii?Q?k9I+gbDyTb/m/9/iRDdAIfGXdBBCPKGUf4tUBoY70go+Sgrqbw02H6CucJS0?=
 =?us-ascii?Q?PiH/HOheoHnGP6uMAOMQt+lQu47a8BEZ8Ba0ng6Tp5kLpn/P9mjuSmCa3E/a?=
 =?us-ascii?Q?HEs8ys90lkgrDnT6TxOxUj2UVTnnltdMmhLhfOZ3ezD019sJTQ/+nykpdyAE?=
 =?us-ascii?Q?50LQPlIabXOok2TitYV3gB2HPIy5NV4BIL2IhOD2lS5FqNhylyKX0+jf/J1X?=
 =?us-ascii?Q?BvvvuDxx+u2EsKPuyfl+mlSM45XOINB/GwqBcZZs7ghecc0YINPerEf5xOEP?=
 =?us-ascii?Q?LJaKaWtWQCH7JCXDD/Po9OfTbwraAcVpiVtGEZt+7GE707GPqSlq7I7jNJcI?=
 =?us-ascii?Q?bEfvtNwtWbD7Y7ekHffamlt9zKwBNY6pPuLI5BJGPvTzcA/gdE1eZHpmfZ1s?=
 =?us-ascii?Q?K+GCph/3vMorWQ1ClWtLl3NjHa/+rRMkA1K+jEAaxaNbsPdPbXVwSP6EtTS0?=
 =?us-ascii?Q?067GP7KFLTH4FB368KRErQhG56X3LwSCOqKCdpi6iYLx6KiZUDUmUOqeCgj0?=
 =?us-ascii?Q?cHYgCXD7kucnh6SlC8dsQpSUpDXbHqALTOnYRBH2/UISEEsejkv0/ntHw8/0?=
 =?us-ascii?Q?7TtSQnVrDThpuneBH3JWopglqG2WtC3bEToXrZvzJPzEUoJ4jeA21slP8oqh?=
 =?us-ascii?Q?7285FMCBezdu8CbRnAj69lGHes3S5QL9eKldxIbtq3mGhXx9zWh//5oQLVFs?=
 =?us-ascii?Q?GEBarn8pMSVYzuIXXX0kmGVQLWZ/wUMLE0zqoHimoQxGratu+/dSUX/tx+zQ?=
 =?us-ascii?Q?4PfUpGYSqho0vHzJg+sItGSIJEU0t6l9OrhLMbUd5XOVr2vhYexvf4plUwMp?=
 =?us-ascii?Q?qd1ANzrauT9GJ5Jf0OdpA4PYhnw55yuV4INGXClgs3oslgF4w7s0WJguL/kg?=
 =?us-ascii?Q?LO4kqg2b7356R0yLucSndgm0J7pHkPMT/VIfU/TXyDf59dfJiKkVIwhrC3LH?=
 =?us-ascii?Q?A1JmDD5LyaDmXj4EmWBCsI+2DExWO4vOmdunt7qSlweg+fy+kFyVaJMk0/6G?=
 =?us-ascii?Q?TJDEWebUDbl1LrbCT8Gbj0bVOcGi5gxLBwue5XRNbKsVdR58nOba+EcsyrCh?=
 =?us-ascii?Q?+VJWyoUKqMxHPFbikaPeN0KARvhgLCvdgwMSYnj6I/y0Zx9jqbn4WqEyI5q6?=
 =?us-ascii?Q?ZrE8MOs61A=3D=3D?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: cf3ca9af-a03e-4bdd-5995-08de695c7e2f
X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Feb 2026 10:58:30.8022
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: A2SL9HNUrX7mUan3dGeK0KOjPKZ2C0USFXWXxiyxrlHohHpzmwCAnXLmtWYbjOHih1zgaZgJYHeuGX2kGVkoSg==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB8193

The trace guid was regenerated using the hashing method described
https://learn.microsoft.com/en-us/windows/win32/api/traceloggingprovider/nf=
-traceloggingprovider-tracelogging_define_provider
I should have added that to the commit message and will do this before any =
commit

Owen

________________________________________
From: Owen Smith <owen.smith@citrix.com>
Sent: 11 February 2026 10:08 AM
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith; david ambu
Subject: [PATCH 2/3] Replace RegisterEventSource with TraceLoggingRegister

- Added TraceLogging levels for Information and Error events.
- Replaced RegisterEventSource due to potential security issues.
  This issue was raised by CodeQL 2.20.1,
  "RegisterEventSourceA has been marked deprecated as it is a legacy
   tracing API. Please migrate to modern Event Tracing for Windows APIs."
see: https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/287=
35-banned-crimson-api-usage

Signed-off-by: david ambu <david.preetham@cloud.com>

* defined seperate macros for Info and Error logging
* use a switch on log level, rather than if/else

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 292 ++++++++++++++++++++++--------------------
 1 file changed, 153 insertions(+), 139 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 347bef0..700f196 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -40,6 +40,8 @@
 #include <powrprof.h>
 #include <malloc.h>
 #include <assert.h>
+#include <TraceLoggingProvider.h>
+#include <winmeta.h>

 #include <version.h>

@@ -56,7 +58,6 @@ typedef struct _MONITOR_CONTEXT {
     SERVICE_STATUS          Status;
     SERVICE_STATUS_HANDLE   Service;
     HKEY                    ParametersKey;
-    HANDLE                  EventLog;
     HANDLE                  StopEvent;
     HANDLE                  RequestEvent;
     HANDLE                  Timer;
@@ -90,17 +91,30 @@ MONITOR_CONTEXT MonitorContext;
 #define PARAMETERS_KEY(_Service) \
         SERVICE_KEY(_Service) ## "\\Parameters"

+TRACELOGGING_DEFINE_PROVIDER(MonitorTraceLoggingProvider,
+                             MONITOR_NAME,
+                             //{54F99C5B-76EC-5F84-3F97-4C9F40AA0F1A}
+                             (0x54f99c5b, 0x76ec, 0x5f84, 0x3f, 0x97, 0x4c=
, 0x9f, 0x40, 0xaa, 0x0f, 0x1a));
+
+typedef enum {
+    LOG_INFO,
+    LOG_ERROR
+} LOG_LEVEL;
+
+#ifdef UNICODE
+#define TraceLoggingStringT(_buf, _name)    TraceLoggingWideString(_buf, _=
name)
+#else
+#define TraceLoggingStringT(_buf, _name)    TraceLoggingString(_buf, _name=
)
+#endif
+
 static VOID
 #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exc=
eeds /analyze:stacksize'1024'
 __Log(
+    _In_ LOG_LEVEL      Level,
     _In_ PCSTR          Format,
     ...
     )
 {
-#if DBG
-    PMONITOR_CONTEXT    Context =3D &MonitorContext;
-    const TCHAR         *Strings[1];
-#endif
     TCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
     va_list             Arguments;
     size_t              Length;
@@ -127,24 +141,29 @@ __Log(

     OutputDebugString(Buffer);

-#if DBG
-    Strings[0] =3D Buffer;
-
-    if (Context->EventLog !=3D NULL)
-        ReportEvent(Context->EventLog,
-                    EVENTLOG_INFORMATION_TYPE,
-                    0,
-                    MONITOR_LOG,
-                    NULL,
-                    ARRAYSIZE(Strings),
-                    0,
-                    Strings,
-                    NULL);
-#endif
+    switch (Level) {
+    case LOG_INFO:
+        TraceLoggingWrite(MonitorTraceLoggingProvider,
+                          _T("Information"),
+                          TraceLoggingLevel(WINEVENT_LEVEL_INFO),
+                          TraceLoggingStringT(Buffer, _T("Info")));
+        break;
+    case LOG_ERROR:
+        TraceLoggingWrite(MonitorTraceLoggingProvider,
+                          _T("Error"),
+                          TraceLoggingLevel(WINEVENT_LEVEL_ERROR),
+                          TraceLoggingStringT(Buffer, _T("Error")));
+        break;
+    default:
+        break;
+    }
 }

-#define Log(_Format, ...) \
-        __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
+#define LogInfo(_Format, ...) \
+        __Log(LOG_INFO, __MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARG=
S__)
+
+#define LogError(_Format, ...) \
+        __Log(LOG_ERROR, __MODULE__ "|" __FUNCTION__ ": " _Format, __VA_AR=
GS__)

 static PTSTR
 GetErrorMessage(
@@ -209,7 +228,7 @@ ReportStatus(
     BOOL                Success;
     HRESULT             Error;

-    Log("=3D=3D=3D=3D> (%s)", ServiceStateName(CurrentState));
+    LogInfo("=3D=3D=3D=3D> (%s)", ServiceStateName(CurrentState));

     Context->Status.dwCurrentState =3D CurrentState;
     Context->Status.dwWin32ExitCode =3D Win32ExitCode;
@@ -233,7 +252,7 @@ ReportStatus(
     if (!Success)
         goto fail1;

-    Log("<=3D=3D=3D=3D");
+    LogInfo("<=3D=3D=3D=3D");

     return;

@@ -243,7 +262,7 @@ fail1:
     {
         PTSTR   Message;
         Message =3D GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -320,11 +339,11 @@ DoReboot(
     _In_ DWORD  Timeout
     )
 {
-    Log("waiting for pending install events...");
+    LogInfo("waiting for pending install events...");

     (VOID) CM_WaitNoPendingInstallEvents(INFINITE);

-    Log("initiating shutdown...");
+    LogInfo("initiating shutdown...");

 #pragma prefast(suppress:28159)
     (VOID) InitiateSystemShutdownEx(NULL,
@@ -360,7 +379,7 @@ GetPromptTimeout(
         Type !=3D REG_DWORD)
         Value =3D 0;

-    Log("%u", Value);
+    LogInfo("%u", Value);

     return Value;
 }
@@ -439,18 +458,18 @@ GetDisplayName(
     return DisplayName;

 fail5:
-    Log("fail5");
+    LogError("fail5");

 fail4:
-    Log("fail4");
+    LogError("fail4");

     free(DisplayName);

 fail3:
-    Log("fail3");
+    LogError("fail3");

 fail2:
-    Log("fail2");
+    LogError("fail2");

     RegCloseKey(ServiceKey);

@@ -460,7 +479,7 @@ fail1:
     {
         PTSTR   Message;
         Message =3D GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -525,10 +544,10 @@ DoPromptForReboot(
         WTS_CONNECTSTATE_CLASS  State =3D SessionInfo[Index].State;
         DWORD                   Response;

-        Log("[%u]: %s [%s]",
-            SessionId,
-            Name,
-            WTSStateName(State));
+        LogInfo("[%u]: %s [%s]",
+                SessionId,
+                Name,
+                WTSStateName(State));

         if (State !=3D WTSActive)
             continue;
@@ -559,7 +578,7 @@ DoPromptForReboot(
     return ERROR_SUCCESS;

 fail2:
-    Log("fail2");
+    LogError("fail2");
     *Prompt->PResponse =3D 0;

 fail1:
@@ -592,7 +611,7 @@ PromptForReboot(
         return;
     Context->RebootPrompted =3D TRUE;

-    Log("=3D=3D=3D=3D> (%s)", DriverName);
+    LogInfo("=3D=3D=3D=3D> (%s)", DriverName);

     Prompt =3D calloc(1, sizeof (REBOOT_PROMPT));
     if (Prompt =3D=3D NULL) {
@@ -659,20 +678,20 @@ PromptForReboot(
     return;

 fail4:
-    Log("fail4");
+    LogError("fail4");
     free(DisplayName);

 fail3:
-    Log("fail3");
+    LogError("fail3");

 fail2:
-    Log("fail2");
+    LogError("fail2");

 fail1:
     {
         PTSTR   Message;
         Message =3D GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -766,9 +785,9 @@ TryAutoReboot(
     if (RebootCount >=3D AutoReboot)
         goto prompt;

-    Log("AutoRebooting (reboot %u of %u)\n",
-        RebootCount,
-        AutoReboot);
+    LogInfo("AutoRebooting (reboot %u of %u)\n",
+            RebootCount,
+            AutoReboot);

     ++RebootCount;

@@ -838,18 +857,18 @@ done:
     return;

 fail3:
-    Log("fail3");
+    LogError("fail3");

     free(DisplayName);

 fail2:
-    Log("fail2");
+    LogError("fail2");

 fail1:
     {
         PTSTR   Message;
         Message =3D GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -870,7 +889,7 @@ CheckRequestSubKeys(
     HKEY                SubKey;
     HRESULT             Error;

-    Log("=3D=3D=3D=3D>");
+    LogInfo("=3D=3D=3D=3D>");

     Error =3D RegQueryInfoKey(Context->RequestKey,
                             NULL,
@@ -916,7 +935,7 @@ CheckRequestSubKeys(
             goto fail3;
         }

-        Log("%s", SubKeyName);
+        LogInfo("%s", SubKeyName);

         Error =3D RegOpenKeyEx(Context->RequestKey,
                              SubKeyName,
@@ -960,17 +979,17 @@ found:
 done:
     free(SubKeyName);

-    Log("<=3D=3D=3D=3D");
+    LogInfo("<=3D=3D=3D=3D");

     return;

 fail3:
-    Log("fail3");
+    LogError("fail3");

     free(SubKeyName);

 fail2:
-    Log("fail2");
+    LogError("fail2");

 fail1:
     Error =3D GetLastError();
@@ -978,7 +997,7 @@ fail1:
     {
         PTSTR   Message;
         Message =3D GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -991,7 +1010,7 @@ CheckRequestKey(
     PMONITOR_CONTEXT    Context =3D &MonitorContext;
     HRESULT             Error;

-    Log("=3D=3D=3D=3D>");
+    LogInfo("=3D=3D=3D=3D>");

     CheckRequestSubKeys();

@@ -1004,7 +1023,7 @@ CheckRequestKey(
     if (Error !=3D ERROR_SUCCESS)
         goto fail1;

-    Log("<=3D=3D=3D=3D");
+    LogInfo("<=3D=3D=3D=3D");

     return;

@@ -1014,7 +1033,7 @@ fail1:
     {
         PTSTR   Message;
         Message =3D GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -1029,7 +1048,7 @@ AcquireShutdownPrivilege(
     BOOL                Success;
     HRESULT             Error;

-    Log("=3D=3D=3D=3D>");
+    LogInfo("=3D=3D=3D=3D>");

     New.PrivilegeCount =3D 1;

@@ -1061,17 +1080,17 @@ AcquireShutdownPrivilege(

     CloseHandle(Token);

-    Log("<=3D=3D=3D=3D");
+    LogInfo("<=3D=3D=3D=3D");

     return TRUE;

 fail3:
-    Log("fail3");
+    LogError("fail3");

     CloseHandle(Token);

 fail2:
-    Log("fail2");
+    LogError("fail2");

 fail1:
     Error =3D GetLastError();
@@ -1079,7 +1098,7 @@ fail1:
     {
         PTSTR   Message;
         Message =3D GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -1137,20 +1156,20 @@ GetRequestKeyName(
         goto fail4;
     }

-    Log("%s", *RequestKeyName);
+    LogInfo("%s", *RequestKeyName);

     return TRUE;

 fail4:
-    Log("fail4");
+    LogError("fail4");

 fail3:
-    Log("fail3");
+    LogError("fail3");

     free(*RequestKeyName);

 fail2:
-    Log("fail2");
+    LogError("fail2");

 fail1:
     Error =3D GetLastError();
@@ -1158,7 +1177,7 @@ fail1:
     {
         PTSTR   Message;
         Message =3D GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -1264,37 +1283,37 @@ GetDialogParameters(
     return TRUE;

 fail10:
-    Log("fail10");
+    LogError("fail10");

 fail9:
-    Log("fail9");
+    LogError("fail9");

     free(Context->Question);

 fail8:
-    Log("fail8");
+    LogError("fail8");

 fail7:
-    Log("fail7");
+    LogError("fail7");

 fail6:
-    Log("fail6");
+    LogError("fail6");

     free(Context->Text);

 fail5:
-    Log("fail5");
+    LogError("fail5");

 fail4:
-    Log("fail4");
+    LogError("fail4");

 fail3:
-    Log("fail3");
+    LogError("fail3");

     free(Context->Title);

 fail2:
-    Log("fail2");
+    LogError("fail2");

 fail1:
     Error =3D GetLastError();
@@ -1302,7 +1321,7 @@ fail1:
     {
         PTSTR   Message;
         Message =3D GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -1335,7 +1354,7 @@ fail1:
     {
         PTSTR   Message;
         Message =3D GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -1357,7 +1376,10 @@ MonitorMain(
     UNREFERENCED_PARAMETER(argc);
     UNREFERENCED_PARAMETER(argv);

-    Log("=3D=3D=3D=3D>");
+    if (TraceLoggingRegister(MonitorTraceLoggingProvider) !=3D ERROR_SUCCE=
SS)
+        LogInfo("TraceLoggingRegister failed");
+
+    LogInfo("=3D=3D=3D=3D>");

     (VOID) RemoveStartOverride("stornvme");

@@ -1379,11 +1401,6 @@ MonitorMain(
     if (Context->Service =3D=3D NULL)
         goto fail3;

-    Context->EventLog =3D RegisterEventSource(NULL,
-                                            MONITOR_NAME);
-    if (Context->EventLog =3D=3D NULL)
-        goto fail4;
-
     Context->Status.dwServiceType =3D SERVICE_WIN32_OWN_PROCESS;
     Context->Status.dwServiceSpecificExitCode =3D 0;

@@ -1395,26 +1412,26 @@ MonitorMain(
                                      NULL);

     if (Context->StopEvent =3D=3D NULL)
-        goto fail5;
+        goto fail4;

     Context->RequestEvent =3D CreateEvent(NULL,
                                         TRUE,
                                         FALSE,
                                         NULL);
     if (Context->RequestEvent =3D=3D NULL)
-        goto fail6;
+        goto fail5;

     Context->ResponseEvent =3D CreateEvent(NULL,
                                          FALSE,
                                          FALSE,
                                          NULL);
     if (Context->ResponseEvent =3D=3D NULL)
-        goto fail7;
+        goto fail6;
     Context->Response =3D 0;

     Success =3D GetRequestKeyName(&RequestKeyName);
     if (!Success)
-        goto fail8;
+        goto fail7;

     Error =3D RegCreateKeyEx(HKEY_LOCAL_MACHINE,
                            RequestKeyName,
@@ -1426,15 +1443,15 @@ MonitorMain(
                            &Context->RequestKey,
                            NULL);
     if (Error !=3D ERROR_SUCCESS)
-        goto fail9;
+        goto fail8;

     Success =3D GetDialogParameters();
     if (!Success)
-        goto fail10;
+        goto fail9;

     Context->Timer =3D CreateWaitableTimer(NULL, FALSE, NULL);
     if (Context->Timer =3D=3D NULL)
-        goto fail11;
+        goto fail10;

     DueTime.QuadPart =3D -10000LL * REBOOT_RETRY_DELAY;

@@ -1445,7 +1462,7 @@ MonitorMain(
                                NULL,
                                FALSE);
     if (!Success)
-        goto fail12;
+        goto fail11;

     SetEvent(Context->RequestEvent);

@@ -1460,12 +1477,12 @@ MonitorMain(
         Events[2] =3D Context->ResponseEvent;
         Events[3] =3D Context->Timer;

-        Log("waiting (%u)...", ARRAYSIZE(Events));
+        LogInfo("waiting (%u)...", ARRAYSIZE(Events));
         Object =3D WaitForMultipleObjects(ARRAYSIZE(Events),
                                         Events,
                                         FALSE,
                                         INFINITE);
-        Log("awake");
+        LogInfo("awake");

         switch (Object) {
         case WAIT_OBJECT_0:
@@ -1510,63 +1527,58 @@ done:

     ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);

-    (VOID) DeregisterEventSource(Context->EventLog);
-
     RegCloseKey(Context->ParametersKey);
     (VOID) RemoveStartOverride("stornvme");

-    Log("<=3D=3D=3D=3D");
+    LogInfo("<=3D=3D=3D=3D");
+
+    TraceLoggingUnregister(MonitorTraceLoggingProvider);

     return;

-fail12:
-    Log("fail12");
+fail11:
+    LogError("fail11");

     CloseHandle(Context->Timer);

-fail11:
-    Log("fail11");
-
 fail10:
-    Log("fail10");
-
-    RegCloseKey(Context->RequestKey);
+    LogError("fail10");

 fail9:
-    Log("fail9");
+    LogError("fail9");

-    free(RequestKeyName);
+    RegCloseKey(Context->RequestKey);

 fail8:
-    Log("fail8");
+    LogError("fail8");

-    CloseHandle(Context->ResponseEvent);
+    free(RequestKeyName);

 fail7:
-    Log("fail7");
+    LogError("fail7");

-    CloseHandle(Context->RequestEvent);
+    CloseHandle(Context->ResponseEvent);

 fail6:
-    Log("fail6");
+    LogError("fail6");

-    CloseHandle(Context->StopEvent);
+    CloseHandle(Context->RequestEvent);

 fail5:
-    Log("fail5");
+    LogError("fail5");

-    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
-
-    (VOID) DeregisterEventSource(Context->EventLog);
+    CloseHandle(Context->StopEvent);

 fail4:
-    Log("fail4");
+    LogError("fail4");
+
+    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);

 fail3:
-    Log("fail3");
+    LogError("fail3");

 fail2:
-    Log("fail2");
+    LogError("fail2");

     RegCloseKey(Context->ParametersKey);

@@ -1576,9 +1588,11 @@ fail1:
     {
         PTSTR   Message;
         Message =3D GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
+
+    TraceLoggingUnregister(MonitorTraceLoggingProvider);
 }

 static BOOL
@@ -1591,7 +1605,7 @@ MonitorCreate(
     TCHAR       Path[MAX_PATH];
     HRESULT     Error;

-    Log("=3D=3D=3D=3D>");
+    LogInfo("=3D=3D=3D=3D>");

     if(!GetModuleFileName(NULL, Path, MAX_PATH))
         goto fail1;
@@ -1623,17 +1637,17 @@ MonitorCreate(
     CloseServiceHandle(Service);
     CloseServiceHandle(SCManager);

-    Log("<=3D=3D=3D=3D");
+    LogInfo("<=3D=3D=3D=3D");

     return TRUE;

 fail3:
-    Log("fail3");
+    LogError("fail3");

     CloseServiceHandle(SCManager);

 fail2:
-    Log("fail2");
+    LogError("fail2");

 fail1:
     Error =3D GetLastError();
@@ -1641,7 +1655,7 @@ fail1:
     {
         PTSTR   Message;
         Message =3D GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -1659,7 +1673,7 @@ MonitorDelete(
     SERVICE_STATUS      Status;
     HRESULT             Error;

-    Log("=3D=3D=3D=3D>");
+    LogInfo("=3D=3D=3D=3D>");

     SCManager =3D OpenSCManager(NULL,
                               NULL,
@@ -1690,20 +1704,20 @@ MonitorDelete(
     CloseServiceHandle(Service);
     CloseServiceHandle(SCManager);

-    Log("<=3D=3D=3D=3D");
+    LogInfo("<=3D=3D=3D=3D");

     return TRUE;

 fail4:
-    Log("fail4");
+    LogError("fail4");

 fail3:
-    Log("fail3");
+    LogError("fail3");

     CloseServiceHandle(Service);

 fail2:
-    Log("fail2");
+    LogError("fail2");

     CloseServiceHandle(SCManager);

@@ -1713,7 +1727,7 @@ fail1:
     {
         PTSTR   Message;
         Message =3D GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -1731,16 +1745,16 @@ MonitorEntry(
     };
     HRESULT             Error;

-    Log("%s (%s) =3D=3D=3D=3D>",
-        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." =
BUILD_NUMBER_STR,
-        DAY_STR "/" MONTH_STR "/" YEAR_STR);
+    LogInfo("%s (%s) =3D=3D=3D=3D>",
+            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR =
"." BUILD_NUMBER_STR,
+            DAY_STR "/" MONTH_STR "/" YEAR_STR);

     if (!StartServiceCtrlDispatcher(Table))
         goto fail1;

-    Log("%s (%s) <=3D=3D=3D=3D",
-        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." =
BUILD_NUMBER_STR,
-        DAY_STR "/" MONTH_STR "/" YEAR_STR);
+    LogInfo("%s (%s) <=3D=3D=3D=3D",
+            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR =
"." BUILD_NUMBER_STR,
+            DAY_STR "/" MONTH_STR "/" YEAR_STR);

     return TRUE;

@@ -1750,7 +1764,7 @@ fail1:
     {
         PTSTR   Message;
         Message =3D GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

--
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Wed Feb 11 12:10:46 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Feb 2026 12:10:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1227427.1533810 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq93M-0007CH-Pf; Wed, 11 Feb 2026 12:10:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1227427.1533810; Wed, 11 Feb 2026 12:10:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq93M-0007CA-MT; Wed, 11 Feb 2026 12:10:44 +0000
Received: by outflank-mailman (input) for mailman id 1227427;
 Wed, 11 Feb 2026 12:10:43 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=l1yI=AP=bounce.vates.tech=bounce-md_30504962.698c71bb.v1-4c55bfbef8fb41b9b7aa227547a87963@srs-se1.protection.inumbo.net>)
 id 1vq93L-0007C4-8m
 for win-pv-devel@lists.xenproject.org; Wed, 11 Feb 2026 12:10:43 +0000
Received: from mail132-5.atl131.mandrillapp.com
 (mail132-5.atl131.mandrillapp.com [198.2.132.5])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id ac4c56d8-0742-11f1-9ccf-f158ae23cfc8;
 Wed, 11 Feb 2026 13:10:37 +0100 (CET)
Received: from pmta09.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail132-5.atl131.mandrillapp.com (Mailchimp) with ESMTP id
 4f9y1l49Y4zG0CXhT
 for <win-pv-devel@lists.xenproject.org>; Wed, 11 Feb 2026 12:10:35 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 4c55bfbef8fb41b9b7aa227547a87963; Wed, 11 Feb 2026 12:10:35 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ac4c56d8-0742-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770811835; x=1771081835;
	bh=aMTO/TZBdaC224aRecoCnJygIXOnDY4EyeONzWNnVos=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=OI7TSHayxOq6QYAy9/K228liGn42jsCjuHxbTkxKbyu4JCKBYZRilLZNOGLxwTMR2
	 sdiO9McouocZlik8/Gs/cZsK48po/jfMQ/bbaODcgeIHccOWOzAX4g4XVp6ivhEUU5
	 nvS+7eD2LIwHqSrW/Rix+qR8zzX7ash551/HsLXyfQpFcO62o1sAMJPzim2BRmWaO7
	 7ge8OsVic+SnGsrhCNuffBnNZZVO683J7kytfDp5xx292qFVUY/eaRhHpVhIrL8kAh
	 vpt67V7k/gL0LVAsqbmNHof1KbBU/eMGp7hsFPNjIMnxct92Fm9LlbxrAU2DOkp1YC
	 Ajr0YWYiduBYg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770811835; x=1771072335; i=ngoc-tu.dinh@vates.tech;
	bh=aMTO/TZBdaC224aRecoCnJygIXOnDY4EyeONzWNnVos=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=JnUyAj0ucjAvlUtSo0pSEHa8tRaI65Pe4Eei8HJsfIcsvuLO5Uwn68Pc9uwVf4TvV
	 XMxuR3/zdGfy/Euh9d44q2a2klHPeFIbZlL0E8aTTPR+Mj7aUsffEg+OsHz0cBzmuc
	 XiQMWxKka2eSAEokMZup/6eQPVk188k5JRnjhN5jj+XKUUQzBMxNWyDQiix1LL1rHM
	 Et2X8BJ4M88xwDhgPbJGvKQAR6UsL06elEIZu2GhyKom3AUjuaF5oI0/OB2Jqoh+AR
	 Y0WhKwZQm+UyMsbL/3G/c8vCA+XxbREF9qKR8yjdQ0Euo+HXNrpv0mXlx2eMxPVg5F
	 zAItVAWA2GSCQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=202/3]=20Replace=20RegisterEventSource=20with=20TraceLoggingRegister?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770811834490
Message-Id: <30100241-36e8-4b32-b303-19ef3da4b692@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
Cc: "david ambu" <david.preetham@cloud.com>
References: <913a9fad-af24-4a21-8c07-ff0c8bc22462@vates.tech> <20260211100806.1648-1-owen.smith@citrix.com> <20260211100806.1648-2-owen.smith@citrix.com>
In-Reply-To: <20260211100806.1648-2-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.4c55bfbef8fb41b9b7aa227547a87963?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260211:md
Date: Wed, 11 Feb 2026 12:10:35 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 11/02/2026 11:08, Owen Smith wrote:
> - Added TraceLogging levels for Information and Error events.
> - Replaced RegisterEventSource due to potential security issues.
>    This issue was raised by CodeQL 2.20.1,
>    "RegisterEventSourceA has been marked deprecated as it is a legacy
>     tracing API. Please migrate to modern Event Tracing for Windows APIs."
> see: https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/28735-banned-crimson-api-usage
> 
> Signed-off-by: david ambu <david.preetham@cloud.com>
> 
> * defined seperate macros for Info and Error logging
> * use a switch on log level, rather than if/else
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

On 11/02/2026 11:58, Owen Smith wrote:
 > The trace guid was regenerated using the hashing method described
 > 
https://learn.microsoft.com/en-us/windows/win32/api/traceloggingprovider/nf-traceloggingprovider-tracelogging_define_provider
 > I should have added that to the commit message and will do this 
before any commit
 >
 > Owen
Thanks. Are the log events meant to be captured via ETW instead of being 
written to the system log? I had to use Wireshark to capture them.

> ---
>   src/monitor/monitor.c | 292 ++++++++++++++++++++++--------------------
>   1 file changed, 153 insertions(+), 139 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 347bef0..700f196 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -40,6 +40,8 @@
>   #include <powrprof.h>
>   #include <malloc.h>
>   #include <assert.h>
> +#include <TraceLoggingProvider.h>
> +#include <winmeta.h>
>   
>   #include <version.h>
>   
> @@ -56,7 +58,6 @@ typedef struct _MONITOR_CONTEXT {
>       SERVICE_STATUS          Status;
>       SERVICE_STATUS_HANDLE   Service;
>       HKEY                    ParametersKey;
> -    HANDLE                  EventLog;
>       HANDLE                  StopEvent;
>       HANDLE                  RequestEvent;
>       HANDLE                  Timer;
> @@ -90,17 +91,30 @@ MONITOR_CONTEXT MonitorContext;
>   #define PARAMETERS_KEY(_Service) \
>           SERVICE_KEY(_Service) ## "\\Parameters"
>   
> +TRACELOGGING_DEFINE_PROVIDER(MonitorTraceLoggingProvider,
> +                             MONITOR_NAME,
> +                             //{54F99C5B-76EC-5F84-3F97-4C9F40AA0F1A}
> +                             (0x54f99c5b, 0x76ec, 0x5f84, 0x3f, 0x97, 0x4c, 0x9f, 0x40, 0xaa, 0x0f, 0x1a));
> +
> +typedef enum {
> +    LOG_INFO,
> +    LOG_ERROR
> +} LOG_LEVEL;
> +
> +#ifdef UNICODE
> +#define TraceLoggingStringT(_buf, _name)    TraceLoggingWideString(_buf, _name)
> +#else
> +#define TraceLoggingStringT(_buf, _name)    TraceLoggingString(_buf, _name)
> +#endif
> +
>   static VOID
>   #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
>   __Log(
> +    _In_ LOG_LEVEL      Level,
>       _In_ PCSTR          Format,
>       ...
>       )
>   {
> -#if DBG
> -    PMONITOR_CONTEXT    Context = &MonitorContext;
> -    const TCHAR         *Strings[1];
> -#endif
>       TCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
>       va_list             Arguments;
>       size_t              Length;
> @@ -127,24 +141,29 @@ __Log(
>   
>       OutputDebugString(Buffer);
>   
> -#if DBG
> -    Strings[0] = Buffer;
> -
> -    if (Context->EventLog != NULL)
> -        ReportEvent(Context->EventLog,
> -                    EVENTLOG_INFORMATION_TYPE,
> -                    0,
> -                    MONITOR_LOG,
> -                    NULL,
> -                    ARRAYSIZE(Strings),
> -                    0,
> -                    Strings,
> -                    NULL);
> -#endif
> +    switch (Level) {
> +    case LOG_INFO:
> +        TraceLoggingWrite(MonitorTraceLoggingProvider,
> +                          _T("Information"),
> +                          TraceLoggingLevel(WINEVENT_LEVEL_INFO),
> +                          TraceLoggingStringT(Buffer, _T("Info")));
> +        break;
> +    case LOG_ERROR:
> +        TraceLoggingWrite(MonitorTraceLoggingProvider,
> +                          _T("Error"),
> +                          TraceLoggingLevel(WINEVENT_LEVEL_ERROR),
> +                          TraceLoggingStringT(Buffer, _T("Error")));
> +        break;
> +    default:
> +        break;
> +    }
>   }
>   
> -#define Log(_Format, ...) \
> -        __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
> +#define LogInfo(_Format, ...) \
> +        __Log(LOG_INFO, __MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
> +
> +#define LogError(_Format, ...) \
> +        __Log(LOG_ERROR, __MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)

I think the log message should be wrapped in _T() here.
More generally, xenbus_monitor is not ready for -DUNICODE.
There are places (like ServiceStateName/WTSStateName) where the strings 
being passed to Log*() are not TSTRs.
Same with several uses of StringCbPrintf.
But I'm fine with fixing those in a separate series.

>   
>   static PTSTR
>   GetErrorMessage(
> @@ -209,7 +228,7 @@ ReportStatus(
>       BOOL                Success;
>       HRESULT             Error;
>   
> -    Log("====> (%s)", ServiceStateName(CurrentState));
> +    LogInfo("====> (%s)", ServiceStateName(CurrentState));
>   
>       Context->Status.dwCurrentState = CurrentState;
>       Context->Status.dwWin32ExitCode = Win32ExitCode;
> @@ -233,7 +252,7 @@ ReportStatus(
>       if (!Success)
>           goto fail1;
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return;
>   
> @@ -243,7 +262,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   }
> @@ -320,11 +339,11 @@ DoReboot(
>       _In_ DWORD  Timeout
>       )
>   {
> -    Log("waiting for pending install events...");
> +    LogInfo("waiting for pending install events...");
>   
>       (VOID) CM_WaitNoPendingInstallEvents(INFINITE);
>   
> -    Log("initiating shutdown...");
> +    LogInfo("initiating shutdown...");
>   
>   #pragma prefast(suppress:28159)
>       (VOID) InitiateSystemShutdownEx(NULL,
> @@ -360,7 +379,7 @@ GetPromptTimeout(
>           Type != REG_DWORD)
>           Value = 0;
>   
> -    Log("%u", Value);
> +    LogInfo("%u", Value);
>   
>       return Value;
>   }
> @@ -439,18 +458,18 @@ GetDisplayName(
>       return DisplayName;
>   
>   fail5:
> -    Log("fail5");
> +    LogError("fail5");
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>       free(DisplayName);
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>       RegCloseKey(ServiceKey);
>   
> @@ -460,7 +479,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -525,10 +544,10 @@ DoPromptForReboot(
>           WTS_CONNECTSTATE_CLASS  State = SessionInfo[Index].State;
>           DWORD                   Response;
>   
> -        Log("[%u]: %s [%s]",
> -            SessionId,
> -            Name,
> -            WTSStateName(State));
> +        LogInfo("[%u]: %s [%s]",
> +                SessionId,
> +                Name,
> +                WTSStateName(State));
>   
>           if (State != WTSActive)
>               continue;
> @@ -559,7 +578,7 @@ DoPromptForReboot(
>       return ERROR_SUCCESS;
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>       *Prompt->PResponse = 0;
>   
>   fail1:
> @@ -592,7 +611,7 @@ PromptForReboot(
>           return;
>       Context->RebootPrompted = TRUE;
>   
> -    Log("====> (%s)", DriverName);
> +    LogInfo("====> (%s)", DriverName);
>   
>       Prompt = calloc(1, sizeof (REBOOT_PROMPT));
>       if (Prompt == NULL) {
> @@ -659,20 +678,20 @@ PromptForReboot(
>       return;
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>       free(DisplayName);
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -766,9 +785,9 @@ TryAutoReboot(
>       if (RebootCount >= AutoReboot)
>           goto prompt;
>   
> -    Log("AutoRebooting (reboot %u of %u)\n",
> -        RebootCount,
> -        AutoReboot);
> +    LogInfo("AutoRebooting (reboot %u of %u)\n",
> +            RebootCount,
> +            AutoReboot);
>   
>       ++RebootCount;
>   
> @@ -838,18 +857,18 @@ done:
>       return;
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       free(DisplayName);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -870,7 +889,7 @@ CheckRequestSubKeys(
>       HKEY                SubKey;
>       HRESULT             Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       Error = RegQueryInfoKey(Context->RequestKey,
>                               NULL,
> @@ -916,7 +935,7 @@ CheckRequestSubKeys(
>               goto fail3;
>           }
>   
> -        Log("%s", SubKeyName);
> +        LogInfo("%s", SubKeyName);
>   
>           Error = RegOpenKeyEx(Context->RequestKey,
>                                SubKeyName,
> @@ -960,17 +979,17 @@ found:
>   done:
>       free(SubKeyName);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return;
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       free(SubKeyName);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -978,7 +997,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   }
> @@ -991,7 +1010,7 @@ CheckRequestKey(
>       PMONITOR_CONTEXT    Context = &MonitorContext;
>       HRESULT             Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       CheckRequestSubKeys();
>   
> @@ -1004,7 +1023,7 @@ CheckRequestKey(
>       if (Error != ERROR_SUCCESS)
>           goto fail1;
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return;
>   
> @@ -1014,7 +1033,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   }
> @@ -1029,7 +1048,7 @@ AcquireShutdownPrivilege(
>       BOOL                Success;
>       HRESULT             Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       New.PrivilegeCount = 1;
>   
> @@ -1061,17 +1080,17 @@ AcquireShutdownPrivilege(
>   
>       CloseHandle(Token);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return TRUE;
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       CloseHandle(Token);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -1079,7 +1098,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1137,20 +1156,20 @@ GetRequestKeyName(
>           goto fail4;
>       }
>   
> -    Log("%s", *RequestKeyName);
> +    LogInfo("%s", *RequestKeyName);
>   
>       return TRUE;
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       free(*RequestKeyName);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -1158,7 +1177,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1264,37 +1283,37 @@ GetDialogParameters(
>       return TRUE;
>   
>   fail10:
> -    Log("fail10");
> +    LogError("fail10");
>   
>   fail9:
> -    Log("fail9");
> +    LogError("fail9");
>   
>       free(Context->Question);
>   
>   fail8:
> -    Log("fail8");
> +    LogError("fail8");
>   
>   fail7:
> -    Log("fail7");
> +    LogError("fail7");
>   
>   fail6:
> -    Log("fail6");
> +    LogError("fail6");
>   
>       free(Context->Text);
>   
>   fail5:
> -    Log("fail5");
> +    LogError("fail5");
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       free(Context->Title);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -1302,7 +1321,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1335,7 +1354,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1357,7 +1376,10 @@ MonitorMain(
>       UNREFERENCED_PARAMETER(argc);
>       UNREFERENCED_PARAMETER(argv);
>   
> -    Log("====>");
> +    if (TraceLoggingRegister(MonitorTraceLoggingProvider) != ERROR_SUCCESS)
> +        LogInfo("TraceLoggingRegister failed");
> +
> +    LogInfo("====>");
>   
>       (VOID) RemoveStartOverride("stornvme");
>   
> @@ -1379,11 +1401,6 @@ MonitorMain(
>       if (Context->Service == NULL)
>           goto fail3;
>   
> -    Context->EventLog = RegisterEventSource(NULL,
> -                                            MONITOR_NAME);
> -    if (Context->EventLog == NULL)
> -        goto fail4;
> -
>       Context->Status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
>       Context->Status.dwServiceSpecificExitCode = 0;
>   
> @@ -1395,26 +1412,26 @@ MonitorMain(
>                                        NULL);
>   
>       if (Context->StopEvent == NULL)
> -        goto fail5;
> +        goto fail4;
>   
>       Context->RequestEvent = CreateEvent(NULL,
>                                           TRUE,
>                                           FALSE,
>                                           NULL);
>       if (Context->RequestEvent == NULL)
> -        goto fail6;
> +        goto fail5;
>   
>       Context->ResponseEvent = CreateEvent(NULL,
>                                            FALSE,
>                                            FALSE,
>                                            NULL);
>       if (Context->ResponseEvent == NULL)
> -        goto fail7;
> +        goto fail6;
>       Context->Response = 0;
>   
>       Success = GetRequestKeyName(&RequestKeyName);
>       if (!Success)
> -        goto fail8;
> +        goto fail7;
>   
>       Error = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
>                              RequestKeyName,
> @@ -1426,15 +1443,15 @@ MonitorMain(
>                              &Context->RequestKey,
>                              NULL);
>       if (Error != ERROR_SUCCESS)
> -        goto fail9;
> +        goto fail8;
>   
>       Success = GetDialogParameters();
>       if (!Success)
> -        goto fail10;
> +        goto fail9;
>   
>       Context->Timer = CreateWaitableTimer(NULL, FALSE, NULL);
>       if (Context->Timer == NULL)
> -        goto fail11;
> +        goto fail10;
>   
>       DueTime.QuadPart = -10000LL * REBOOT_RETRY_DELAY;
>   
> @@ -1445,7 +1462,7 @@ MonitorMain(
>                                  NULL,
>                                  FALSE);
>       if (!Success)
> -        goto fail12;
> +        goto fail11;
>   
>       SetEvent(Context->RequestEvent);
>   
> @@ -1460,12 +1477,12 @@ MonitorMain(
>           Events[2] = Context->ResponseEvent;
>           Events[3] = Context->Timer;
>   
> -        Log("waiting (%u)...", ARRAYSIZE(Events));
> +        LogInfo("waiting (%u)...", ARRAYSIZE(Events));
>           Object = WaitForMultipleObjects(ARRAYSIZE(Events),
>                                           Events,
>                                           FALSE,
>                                           INFINITE);
> -        Log("awake");
> +        LogInfo("awake");
>   
>           switch (Object) {
>           case WAIT_OBJECT_0:
> @@ -1510,63 +1527,58 @@ done:
>   
>       ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
>   
> -    (VOID) DeregisterEventSource(Context->EventLog);
> -
>       RegCloseKey(Context->ParametersKey);
>       (VOID) RemoveStartOverride("stornvme");
>   
> -    Log("<====");
> +    LogInfo("<====");
> +
> +    TraceLoggingUnregister(MonitorTraceLoggingProvider);
>   
>       return;
>   
> -fail12:
> -    Log("fail12");
> +fail11:
> +    LogError("fail11");
>   
>       CloseHandle(Context->Timer);
>   
> -fail11:
> -    Log("fail11");
> -
>   fail10:
> -    Log("fail10");
> -
> -    RegCloseKey(Context->RequestKey);
> +    LogError("fail10");
>   
>   fail9:
> -    Log("fail9");
> +    LogError("fail9");
>   
> -    free(RequestKeyName);
> +    RegCloseKey(Context->RequestKey);
>   
>   fail8:
> -    Log("fail8");
> +    LogError("fail8");
>   
> -    CloseHandle(Context->ResponseEvent);
> +    free(RequestKeyName);
>   
>   fail7:
> -    Log("fail7");
> +    LogError("fail7");
>   
> -    CloseHandle(Context->RequestEvent);
> +    CloseHandle(Context->ResponseEvent);
>   
>   fail6:
> -    Log("fail6");
> +    LogError("fail6");
>   
> -    CloseHandle(Context->StopEvent);
> +    CloseHandle(Context->RequestEvent);
>   
>   fail5:
> -    Log("fail5");
> +    LogError("fail5");
>   
> -    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
> -
> -    (VOID) DeregisterEventSource(Context->EventLog);
> +    CloseHandle(Context->StopEvent);
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
> +
> +    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>       RegCloseKey(Context->ParametersKey);
>   
> @@ -1576,9 +1588,11 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
> +
> +    TraceLoggingUnregister(MonitorTraceLoggingProvider);
>   }
>   
>   static BOOL
> @@ -1591,7 +1605,7 @@ MonitorCreate(
>       TCHAR       Path[MAX_PATH];
>       HRESULT     Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       if(!GetModuleFileName(NULL, Path, MAX_PATH))
>           goto fail1;
> @@ -1623,17 +1637,17 @@ MonitorCreate(
>       CloseServiceHandle(Service);
>       CloseServiceHandle(SCManager);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return TRUE;
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       CloseServiceHandle(SCManager);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -1641,7 +1655,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1659,7 +1673,7 @@ MonitorDelete(
>       SERVICE_STATUS      Status;
>       HRESULT             Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       SCManager = OpenSCManager(NULL,
>                                 NULL,
> @@ -1690,20 +1704,20 @@ MonitorDelete(
>       CloseServiceHandle(Service);
>       CloseServiceHandle(SCManager);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return TRUE;
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       CloseServiceHandle(Service);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>       CloseServiceHandle(SCManager);
>   
> @@ -1713,7 +1727,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1731,16 +1745,16 @@ MonitorEntry(
>       };
>       HRESULT             Error;
>   
> -    Log("%s (%s) ====>",
> -        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
> -        DAY_STR "/" MONTH_STR "/" YEAR_STR);
> +    LogInfo("%s (%s) ====>",
> +            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
> +            DAY_STR "/" MONTH_STR "/" YEAR_STR);
>   
>       if (!StartServiceCtrlDispatcher(Table))
>           goto fail1;
>   
> -    Log("%s (%s) <====",
> -        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
> -        DAY_STR "/" MONTH_STR "/" YEAR_STR);
> +    LogInfo("%s (%s) <====",
> +            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
> +            DAY_STR "/" MONTH_STR "/" YEAR_STR);
>   
>       return TRUE;
>   
> @@ -1750,7 +1764,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Feb 11 12:22:58 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Feb 2026 12:22:58 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1227431.1533814 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq9FB-0008Qa-KV; Wed, 11 Feb 2026 12:22:57 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1227431.1533814; Wed, 11 Feb 2026 12:22:57 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq9FB-0008QT-HZ; Wed, 11 Feb 2026 12:22:57 +0000
Received: by outflank-mailman (input) for mailman id 1227431;
 Wed, 11 Feb 2026 12:22:56 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=q5cY=AP=bounce.vates.tech=bounce-md_30504962.698c749c.v1-a62a03d770204b368043f25e2b970a38@srs-se1.protection.inumbo.net>)
 id 1vq9FA-0008QN-B6
 for win-pv-devel@lists.xenproject.org; Wed, 11 Feb 2026 12:22:56 +0000
Received: from mail177-22.suw61.mandrillapp.com
 (mail177-22.suw61.mandrillapp.com [198.2.177.22])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 634272a5-0744-11f1-b162-2bf370ae4941;
 Wed, 11 Feb 2026 13:22:54 +0100 (CET)
Received: from pmta14.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail177-22.suw61.mandrillapp.com (Mailchimp) with ESMTP id
 4f9yHw29qRzGlsp6w
 for <win-pv-devel@lists.xenproject.org>; Wed, 11 Feb 2026 12:22:52 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 a62a03d770204b368043f25e2b970a38; Wed, 11 Feb 2026 12:22:52 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 634272a5-0744-11f1-b162-2bf370ae4941
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770812572; x=1771082572;
	bh=VSTc5GdMCAd1YquVCsgw4tNbOmarCG+D+eryfXyJAiU=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=JH38J8yxHB446XcmfBavm+nlhaU8dlXIhKfXxroYQbm11plbFiZbGEB5Kt23gkgX0
	 VbFz2wO5s8T4U8w1rgrDTould1YdrpPuUYcDJx1nzxY6Yjt9RnFHss7oUuqQJrcHC6
	 mrGLUWgSYev/tttXrf1Nwu6QI8bULTlL6oD53WM2YQe7LVrAausuobZzn5grcQ7jCb
	 lLuTD2v0qvszr0g3ISMyOFbfIt09dR8D5k6vATZ4/Jf2hKZeDK1JujSRekq9aRM2F5
	 dk2XD6m/++tolHJtIbCL0b1DWjkBt1nY30pjAggAipZdTIvFvJkUYxnFSeh2LnDc+s
	 dWYmHqqBdsORg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770812572; x=1771073072; i=ngoc-tu.dinh@vates.tech;
	bh=VSTc5GdMCAd1YquVCsgw4tNbOmarCG+D+eryfXyJAiU=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=GMCojMUpDP2uKCrWZHVtju7aSY1mlFXeoYQ3EadyJlkEOuZzfgwYv7YqMac1vtmil
	 4wa2AiLOUfWPo0AC3f7KFRN93C20nSTAcBS2YDnVeXsMl+/F+6DjxVdQArUATepv1K
	 MxeU3zDjvCT7GVloOAJev1dDwvFwszW1dwN4qJ5CKn1+kT57GshHHC/KrNWOwbT9GK
	 16Ot1US3k/E7qffKb2n0bTKnnto9Z7BnRXUyonbNP8ohJtbGqinUCMWdvfZGexL6NU
	 hp0fJIFoCywG6aPLAD2vBr9o1ZQGLzfSd4kiIRXdqdp/j7zdprOiJYo8TiTcvOipkT
	 Ltcn2BcE2yo2A==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=203/3]=20Remove=20StartOverride=20from=20all=20storage=20adapters?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770812571507
Message-Id: <a120896e-c765-4c52-b055-c9d10fadeb10@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
References: <913a9fad-af24-4a21-8c07-ff0c8bc22462@vates.tech> <20260211100806.1648-1-owen.smith@citrix.com> <20260211100806.1648-3-owen.smith@citrix.com>
In-Reply-To: <20260211100806.1648-3-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.a62a03d770204b368043f25e2b970a38?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260211:md
Date: Wed, 11 Feb 2026 12:22:52 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 11/02/2026 11:08, Owen Smith wrote:
> Its possible to install non-Microsoft NVMe drivers on the emulated
> NVMe device. During upgrades, the VM requires a reboot using the emulated
> devices, but if the driver assigned for the emulated device has a StartOverride
> setting, then its likely not started which results in a 0x7B bugcheck.
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>
> ---
>   src/monitor/monitor.c                        | 67 +++++++++++++++++---
>   vs2019/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
>   vs2022/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
>   3 files changed, 59 insertions(+), 12 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 700f196..eb1be91 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -42,6 +42,8 @@
>   #include <assert.h>
>   #include <TraceLoggingProvider.h>
>   #include <winmeta.h>
> +#include <setupapi.h>
> +#include <devguid.h>
>   
>   #include <version.h>
>   
> @@ -1328,7 +1330,7 @@ fail1:
>       return FALSE;
>   }
>   
> -static BOOL
> +static VOID
>   RemoveStartOverride(
>       _In_ PTSTR          DriverName
>       )
> @@ -1336,17 +1338,61 @@ RemoveStartOverride(
>       TCHAR               KeyName[MAX_PATH];
>       HRESULT             Error;
>   
> +    LogInfo("%s", DriverName);
> +
>       Error = StringCbPrintf(KeyName,
>                              MAX_PATH,
>                              SERVICES_KEY "\\%s\\StartOverride",

As this is new code, could you wrap this in _T please?

>                              DriverName);
>       assert(SUCCEEDED(Error));
>   
> -    Error = RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
> -    if (Error != ERROR_SUCCESS)
> +    (VOID) RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
> +}
> +
> +static VOID
> +RemoveStartOverrideForClass(
> +    _In_ const GUID*    Guid
> +    )
> +{
> +    HRESULT             Error;
> +    HDEVINFO            hDevInfo;
> +    DWORD               Index;
> +    SP_DEVINFO_DATA     devInfoData;

Nit: DevInfo and DevInfoData would better fit the naming convention

> +
> +    hDevInfo = SetupDiGetClassDevs(Guid,
> +                                   NULL,
> +                                   NULL,
> +                                   0);
> +    if (hDevInfo == INVALID_HANDLE_VALUE)
>           goto fail1;
>   
> -    return TRUE;
> +    memset(&devInfoData, 0, sizeof(devInfoData));
> +    devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
> +
> +    for (Index = 0;
> +         SetupDiEnumDeviceInfo(hDevInfo, Index, &devInfoData);
> +         ++Index) {
> +        TCHAR           Buffer[MAX_PATH];
> +        memset(Buffer, 0, sizeof(Buffer));
> +
> +        if (SetupDiGetDeviceRegistryProperty(hDevInfo,
> +                                             &devInfoData,
> +                                             SPDRP_SERVICE,
> +                                             NULL,
> +                                             (PBYTE)Buffer,
> +                                             sizeof(Buffer),
> +                                             NULL)) {
> +            Buffer[MAX_PATH - 1] = _T('\0');
> +            RemoveStartOverride(Buffer);
> +        }
> +
> +        memset(&devInfoData, 0, sizeof(devInfoData));
> +        devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
> +    }
> +
> +    SetupDiDestroyDeviceInfoList(hDevInfo);
> +
> +    return;
>   
>   fail1:
>       Error = GetLastError();
> @@ -1357,8 +1403,6 @@ fail1:
>           LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
> -
> -    return FALSE;
>   }
>   
>   VOID WINAPI
> @@ -1381,7 +1425,8 @@ MonitorMain(
>   
>       LogInfo("====>");
>   
> -    (VOID) RemoveStartOverride("stornvme");
> +    RemoveStartOverride("stornvme");
> +    RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
>   
>       Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
>                            PARAMETERS_KEY(__MODULE__),
> @@ -1525,10 +1570,12 @@ done:
>       CloseHandle(Context->RequestEvent);
>       CloseHandle(Context->StopEvent);
>   
> -    ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
> -
>       RegCloseKey(Context->ParametersKey);
> -    (VOID) RemoveStartOverride("stornvme");
> +
> +    RemoveStartOverride("stornvme");

I don't think RemoveStartOverride("stornvme") is still explicitly needed 
since it's already covered by the SCSIAdapter class even in native NVMe 
mode.

> +    RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
> +
> +    ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
>   
>       LogInfo("<====");
>   
> diff --git a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> index 3b44e29..df1fd58 100644
> --- a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> +++ b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> @@ -34,7 +34,7 @@
>         <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
>       </ClCompile>
>       <Link>
> -      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
> +      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
>         <CETCompat>true</CETCompat>
>         <GenerateMapFile>true</GenerateMapFile>
>         <MapExports>true</MapExports>
> diff --git a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> index 484fa1c..196a744 100644
> --- a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> +++ b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> @@ -34,7 +34,7 @@
>         <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
>       </ClCompile>
>       <Link>
> -      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
> +      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
>         <CETCompat>true</CETCompat>
>         <GenerateMapFile>true</GenerateMapFile>
>         <MapExports>true</MapExports>



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Feb 11 12:30:08 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 11 Feb 2026 12:30:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1227444.1533828 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq9M7-0001iX-CD; Wed, 11 Feb 2026 12:30:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1227444.1533828; Wed, 11 Feb 2026 12:30:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vq9M7-0001iA-9R; Wed, 11 Feb 2026 12:30:07 +0000
Received: by outflank-mailman (input) for mailman id 1227444;
 Wed, 11 Feb 2026 12:30:05 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Svtf=AP=bounce.vates.tech=bounce-md_30504962.698c7644.v1-af4d93deff9e4422905e66710bdf56ef@srs-se1.protection.inumbo.net>)
 id 1vq9M5-00016c-Cw
 for win-pv-devel@lists.xenproject.org; Wed, 11 Feb 2026 12:30:05 +0000
Received: from mail132-5.atl131.mandrillapp.com
 (mail132-5.atl131.mandrillapp.com [198.2.132.5])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 6058eabc-0745-11f1-9ccf-f158ae23cfc8;
 Wed, 11 Feb 2026 13:29:58 +0100 (CET)
Received: from pmta09.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail132-5.atl131.mandrillapp.com (Mailchimp) with ESMTP id
 4f9yS41hcdzG0CXhp
 for <win-pv-devel@lists.xenproject.org>; Wed, 11 Feb 2026 12:29:56 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 af4d93deff9e4422905e66710bdf56ef; Wed, 11 Feb 2026 12:29:56 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 6058eabc-0745-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770812996; x=1771082996;
	bh=hzX1g87jQ65MkhSn1sIUcyQJFPQYt+63y8a5pRcr3dk=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=d0n6iVxpQ1XWCNRr+9aqzyDGlIpDDByctmzaSNiHzCkn94fxxIRmwraupUy8ZTuuQ
	 GPsOJoNm/GE1Mr3FhK9DeINEC54DR2xznzeWlIO98xAhHVhH76jGOJPKBvtdXC8oUp
	 Ef8SdSx/TQPrV7fOwJSbh+60bQGsyM4e444yxvJGJaLvtqev2zHTmpHybAF0MQe+D0
	 NrsEJtOry7L941gGOnRFz8G2eFGWXaCFSQQcnLiShQGY9ObKYguU1DHjKrML3jcnSa
	 KZbICSnMwItdV5+lEq+v8237ChmhjCunkbY+x26Rft4ytbwQtBIy5Wl5K/RIXaCn7T
	 F7yoYKzlf3s1w==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770812996; x=1771073496; i=ngoc-tu.dinh@vates.tech;
	bh=hzX1g87jQ65MkhSn1sIUcyQJFPQYt+63y8a5pRcr3dk=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=kspFbESDuptE01yET3XD8czBpl7Wph1sYdJEQYBcUcZGpWYb342DFjtm/b49UwyLz
	 zvF/MYyy4zeLpHEO2/accCSoPnlu0GVpNBU8QiMOJZW2b7dqC1ruzBv+XuUnIPoaBA
	 UUtXKLok6ScIbPotPGsy8BgQYCl1EQ9E29sKjVmEpJoLwUvTrJ0iRYX9bYc6I3RW0w
	 jQRjdA56/6hI2c4ac0Gr8OkD5x60bzr1Q/JneWPkBZSwnnG267+7s/F5gDNpo1tGri
	 c4EpwD6Ag00LevgeJuSsg0wqg66fpV9QYPPAjAY5EjE79VBbZgKcapcLjNkUbEMQUX
	 ZoMAY/rovgp5g==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=202/5]=20Refactor=20monitor.c=20registry=20enumeration?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770812995338
Message-Id: <fce9c950-9d8a-4ea3-b2f3-4ff937d131c2@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
References: <20260206084525.1356-1-owen.smith@citrix.com> <20260206084525.1356-2-owen.smith@citrix.com>
In-Reply-To: <20260206084525.1356-2-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.af4d93deff9e4422905e66710bdf56ef?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260211:md
Date: Wed, 11 Feb 2026 12:29:56 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Hi,

On 06/02/2026 09:45, Owen Smith wrote:
> Move registry enumeration code into a function, using a callback that is called
> for each sub key of the specified key.
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Could you rebase this patch in your next series? I haven't had the time 
to look at this in detail.

Thanks,

> ---
>   src/monitor/monitor.c | 149 ++++++++++++++++++++++++++++--------------
>   1 file changed, 100 insertions(+), 49 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 1154de5..52311aa 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -856,23 +856,25 @@ fail1:
>       return;
>   }
>   
> -static VOID
> -CheckRequestSubKeys(
> -    VOID
> +typedef BOOLEAN(*PREGENUM_FUNC)(HKEY, PTSTR, PVOID);
> +
> +static HRESULT
> +RegEnumSubKeys(
> +    _In_ HKEY           BaseKey,
> +    _In_ PREGENUM_FUNC  Callback,
> +    _In_opt_ PVOID      Context
>       )
>   {
> -    PMONITOR_CONTEXT    Context = &MonitorContext;
>       DWORD               SubKeys;
>       DWORD               MaxSubKeyLength;
>       DWORD               SubKeyLength;
>       PTSTR               SubKeyName;
>       DWORD               Index;
> -    HKEY                SubKey;
>       HRESULT             Error;
>   
>       Log("====>");
>   
> -    Error = RegQueryInfoKey(Context->RequestKey,
> +    Error = RegQueryInfoKey(BaseKey,
>                               NULL,
>                               NULL,
>                               NULL,
> @@ -896,14 +898,10 @@ CheckRequestSubKeys(
>           goto fail2;
>   
>       for (Index = 0; Index < SubKeys; Index++) {
> -        DWORD   Length;
> -        DWORD   Type;
> -        DWORD   Reboot;
> -
>           SubKeyLength = MaxSubKeyLength + sizeof (TCHAR);
>           memset(SubKeyName, 0, SubKeyLength);
>   
> -        Error = RegEnumKeyEx(Context->RequestKey,
> +        Error = RegEnumKeyEx(BaseKey,
>                                Index,
>                                (LPTSTR)SubKeyName,
>                                &SubKeyLength,
> @@ -918,59 +916,112 @@ CheckRequestSubKeys(
>   
>           Log("%s", SubKeyName);
>   
> -        Error = RegOpenKeyEx(Context->RequestKey,
> -                             SubKeyName,
> -                             0,
> -                             KEY_READ,
> -                             &SubKey);
> -        if (Error != ERROR_SUCCESS)
> -            continue;
> +        if (!Callback(BaseKey, SubKeyName, Context))
> +            break;
> +    }
>   
> -        Length = sizeof (DWORD);
> -        Error = RegQueryValueEx(SubKey,
> -                                "Reboot",
> -                                NULL,
> -                                &Type,
> -                                (LPBYTE)&Reboot,
> -                                &Length);
> -        if (Error != ERROR_SUCCESS ||
> -            Type != REG_DWORD)
> -            goto loop;
> +    free(SubKeyName);
>   
> -        if (Reboot != 0)
> -            goto found;
> +    return ERROR_SUCCESS;
>   
> -loop:
> -        RegCloseKey(SubKey);
> +fail3:
> +    Log("fail3");
> +
> +    free(SubKeyName);
> +
> +fail2:
> +    Log("fail2");
> +
> +fail1:
> +    Error = GetLastError();
> +
> +    {
> +        PTSTR   Message;
> +        Message = GetErrorMessage(Error);
> +        Log("fail1 (%s)", Message);
> +        LocalFree(Message);
>       }
>   
> -    Error = RegDeleteValue(Context->ParametersKey,
> -                           "RebootCount");
> -    if (Error == ERROR_SUCCESS)
> -        (VOID) RegFlushKey(Context->ParametersKey);
> +    return Error;
> +}
>   
> -    goto done;
> +static BOOLEAN
> +CheckRequestSubKey(
> +    _In_ HKEY           BaseKey,
> +    _In_ PTSTR          SubKeyName,
> +    _In_opt_ PVOID      Context
> +    )
> +{
> +    DWORD               Length;
> +    DWORD               Reboot;
> +    DWORD               Type;
> +    HKEY                SubKey;
> +    HRESULT             Error;
> +    PBOOLEAN            Found = (PBOOLEAN)Context;
>   
> -found:
> -    RegCloseKey(SubKey);
> +    Error = RegOpenKeyEx(BaseKey,
> +                         SubKeyName,
> +                         0,
> +                         KEY_READ,
> +                         &SubKey);
> +    if (Error != ERROR_SUCCESS)
> +        return TRUE;
> +
> +    Length = sizeof (DWORD);
> +    Error = RegQueryValueEx(SubKey,
> +                            "Reboot",
> +                            NULL,
> +                            &Type,
> +                            (LPBYTE)&Reboot,
> +                            &Length);
> +    if (Error != ERROR_SUCCESS ||
> +        Type != REG_DWORD)
> +        goto loop;
> +
> +    if (Reboot == 0)
> +        goto loop;
>   
> -    if (!Context->RebootRequestedBy)
> +    if (Found != NULL)
> +        *Found = TRUE;
> +
> +    if (!MonitorContext.RebootRequestedBy)
>           TryAutoReboot(SubKeyName);
>   
> -done:
> -    free(SubKeyName);
> +loop:
> +    RegCloseKey(SubKey);
>   
> -    Log("<====");
> +    return (Found != NULL) ? !(*Found) : TRUE;
> +}
>   
> -    return;
> +static VOID
> +CheckRequestSubKeys(
> +    VOID
> +    )
> +{
> +    PMONITOR_CONTEXT    Context = &MonitorContext;
> +    BOOLEAN             Found;
> +    HRESULT             Error;
>   
> -fail3:
> -    Log("fail3");
> +    Log("====>");
>   
> -    free(SubKeyName);
> +    Found = FALSE;
>   
> -fail2:
> -    Log("fail2");
> +    Error = RegEnumSubKeys(Context->RequestKey,
> +                           CheckRequestSubKey,
> +                           &Found);
> +    if (Error != ERROR_SUCCESS)
> +        goto fail1;
> +
> +    if (!Found) {
> +        Error = RegDeleteValue(Context->ParametersKey,
> +                               "RebootCount");
> +        if (Error == ERROR_SUCCESS)
> +            (VOID) RegFlushKey(Context->ParametersKey);
> +    }
> +
> +    Log("<====");
> +
> +    return;
>   
>   fail1:
>       Error = GetLastError();



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 13:44:15 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 13:44:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1230963.1536321 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtSw-000412-90; Fri, 13 Feb 2026 13:44:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1230963.1536321; Fri, 13 Feb 2026 13:44:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtSw-00040v-6Q; Fri, 13 Feb 2026 13:44:14 +0000
Received: by outflank-mailman (input) for mailman id 1230963;
 Fri, 13 Feb 2026 13:44:12 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=wBIX=AR=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vqtSu-00040m-RR
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 13:44:12 +0000
Received: from na1pdmzitismtp02.tibco.com (unknown [160.101.131.9])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 12c911d0-08e2-11f1-b163-2bf370ae4941;
 Fri, 13 Feb 2026 14:44:11 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id DF76381D3BAB;
 Fri, 13 Feb 2026 08:43:44 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 12c911d0-08e2-11f1-b163-2bf370ae4941
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 4/4] Remove StartOverride from all storage adapters
Date: Fri, 13 Feb 2026 13:44:02 +0000
Message-ID: <20260213134403.475-4-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <20260213134403.475-1-owen.smith@citrix.com>
References: <a120896e-c765-4c52-b055-c9d10fadeb10@vates.tech>
 <20260213134403.475-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Its possible to install non-Microsoft NVMe drivers on the emulated
NVMe device. During upgrades, the VM requires a reboot using the emulated
devices, but if the driver assigned for the emulated device has a StartOverride
setting, then its likely not started which results in a 0x7B bugcheck.

Also reports SERVICE_STOPPED after clearing any StartOverride values

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c                        | 64 +++++++++++++++++---
 vs2019/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
 vs2022/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
 3 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index c568d54..9bfb1f6 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -42,6 +42,8 @@
 #include <assert.h>
 #include <TraceLoggingProvider.h>
 #include <winmeta.h>
+#include <setupapi.h>
+#include <devguid.h>
 
 #include <version.h>
 
@@ -1326,7 +1328,7 @@ fail1:
     return FALSE;
 }
 
-static BOOL
+static VOID
 RemoveStartOverride(
     _In_ PTSTR          DriverName
     )
@@ -1334,17 +1336,61 @@ RemoveStartOverride(
     TCHAR               KeyName[MAX_PATH];
     HRESULT             Error;
 
+    LogInfo("%s", DriverName);
+
     Error = StringCchPrintf(KeyName,
                             MAX_PATH,
                             _T(SERVICES_KEY "\\%s\\StartOverride"),
                             DriverName);
     assert(SUCCEEDED(Error));
 
-    Error = RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
-    if (Error != ERROR_SUCCESS)
+    (VOID) RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
+}
+
+static VOID
+RemoveStartOverrideForClass(
+    _In_ const GUID*    Guid
+    )
+{
+    HRESULT             Error;
+    HDEVINFO            DevInfo;
+    DWORD               Index;
+    SP_DEVINFO_DATA     DevInfoData;
+
+    DevInfo = SetupDiGetClassDevs(Guid,
+                                  NULL,
+                                  NULL,
+                                  0);
+    if (DevInfo == INVALID_HANDLE_VALUE)
         goto fail1;
 
-    return TRUE;
+    memset(&DevInfoData, 0, sizeof(DevInfoData));
+    DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
+
+    for (Index = 0;
+         SetupDiEnumDeviceInfo(DevInfo, Index, &DevInfoData);
+         ++Index) {
+        TCHAR           Buffer[MAX_PATH];
+        memset(Buffer, 0, sizeof(Buffer));
+
+        if (SetupDiGetDeviceRegistryProperty(DevInfo,
+                                             &DevInfoData,
+                                             SPDRP_SERVICE,
+                                             NULL,
+                                             (PBYTE)Buffer,
+                                             sizeof(Buffer),
+                                             NULL)) {
+            Buffer[MAX_PATH - 1] = _T('\0');
+            RemoveStartOverride(Buffer);
+        }
+
+        memset(&DevInfoData, 0, sizeof(DevInfoData));
+        DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
+    }
+
+    SetupDiDestroyDeviceInfoList(DevInfo);
+
+    return;
 
 fail1:
     Error = GetLastError();
@@ -1355,8 +1401,6 @@ fail1:
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
-
-    return FALSE;
 }
 
 VOID WINAPI
@@ -1379,7 +1423,7 @@ MonitorMain(
 
     LogInfo("====>");
 
-    (VOID) RemoveStartOverride(_T("stornvme"));
+    RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
 
     Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                          _T(PARAMETERS_KEY(__MODULE__)),
@@ -1523,10 +1567,10 @@ done:
     CloseHandle(Context->RequestEvent);
     CloseHandle(Context->StopEvent);
 
-    ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
-
     RegCloseKey(Context->ParametersKey);
-    (VOID) RemoveStartOverride(_T("stornvme"));
+    RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
+
+    ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
 
     LogInfo("<====");
 
diff --git a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
index 3b44e29..df1fd58 100644
--- a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
+++ b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
@@ -34,7 +34,7 @@
       <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <CETCompat>true</CETCompat>
       <GenerateMapFile>true</GenerateMapFile>
       <MapExports>true</MapExports>
diff --git a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
index 484fa1c..196a744 100644
--- a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
+++ b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
@@ -34,7 +34,7 @@
       <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <CETCompat>true</CETCompat>
       <GenerateMapFile>true</GenerateMapFile>
       <MapExports>true</MapExports>
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 13:44:16 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 13:44:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1230964.1536328 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtSy-00043Q-C5; Fri, 13 Feb 2026 13:44:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1230964.1536328; Fri, 13 Feb 2026 13:44:16 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtSy-00043F-7h; Fri, 13 Feb 2026 13:44:16 +0000
Received: by outflank-mailman (input) for mailman id 1230964;
 Fri, 13 Feb 2026 13:44:14 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=wBIX=AR=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vqtSw-000426-Sf
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 13:44:14 +0000
Received: from na1pdmzitismtp02.tibco.com (unknown [160.101.131.9])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 11bd0865-08e2-11f1-9ccf-f158ae23cfc8;
 Fri, 13 Feb 2026 14:44:09 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id E564281D3BA9;
 Fri, 13 Feb 2026 08:43:42 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 11bd0865-08e2-11f1-9ccf-f158ae23cfc8
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>,
	david ambu <david.preetham@cloud.com>
Subject: [PATCH 1/4] registry: use RegCloseKey for RequestKey and ParametersKey
Date: Fri, 13 Feb 2026 13:43:59 +0000
Message-ID: <20260213134403.475-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <a120896e-c765-4c52-b055-c9d10fadeb10@vates.tech>
References: <a120896e-c765-4c52-b055-c9d10fadeb10@vates.tech>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

CloseHandle silently fails for HKEY.

Signed-off-by: david ambu <david.preetham@cloud.com>

Refactored to before other patches

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 1154de5..347bef0 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1502,7 +1502,7 @@ done:
     free(Context->Question);
     free(Context->Text);
     free(Context->Title);
-    CloseHandle(Context->RequestKey);
+    RegCloseKey(Context->RequestKey);
     free(RequestKeyName);
     CloseHandle(Context->ResponseEvent);
     CloseHandle(Context->RequestEvent);
@@ -1512,7 +1512,7 @@ done:
 
     (VOID) DeregisterEventSource(Context->EventLog);
 
-    CloseHandle(Context->ParametersKey);
+    RegCloseKey(Context->ParametersKey);
     (VOID) RemoveStartOverride("stornvme");
 
     Log("<====");
@@ -1530,7 +1530,7 @@ fail11:
 fail10:
     Log("fail10");
 
-    CloseHandle(Context->RequestKey);
+    RegCloseKey(Context->RequestKey);
 
 fail9:
     Log("fail9");
@@ -1568,7 +1568,7 @@ fail3:
 fail2:
     Log("fail2");
 
-    CloseHandle(Context->ParametersKey);
+    RegCloseKey(Context->ParametersKey);
 
 fail1:
     Error = GetLastError();
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 13:44:17 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 13:44:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1230965.1536331 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtSz-00045Z-CK; Fri, 13 Feb 2026 13:44:17 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1230965.1536331; Fri, 13 Feb 2026 13:44:17 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtSz-00045R-8s; Fri, 13 Feb 2026 13:44:17 +0000
Received: by outflank-mailman (input) for mailman id 1230965;
 Fri, 13 Feb 2026 13:44:15 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=wBIX=AR=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vqtSx-000426-Fp
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 13:44:15 +0000
Received: from na1pdmzitismtp02.tibco.com (unknown [160.101.131.9])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 12789a02-08e2-11f1-9ccf-f158ae23cfc8;
 Fri, 13 Feb 2026 14:44:09 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id 4EFA281D3BAC;
 Fri, 13 Feb 2026 08:43:44 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 12789a02-08e2-11f1-9ccf-f158ae23cfc8
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 3/4] Fix inconsistent TCHAR handling
Date: Fri, 13 Feb 2026 13:44:01 +0000
Message-ID: <20260213134403.475-3-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <20260213134403.475-1-owen.smith@citrix.com>
References: <a120896e-c765-4c52-b055-c9d10fadeb10@vates.tech>
 <20260213134403.475-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

* Wrap strings with _T()
* Fix ServiceStateName and WTSStateName to return PCTSTR
* Use 'Length' for character counts, and 'Size' for byte counts
  when calling StringCch* and StringCb* functions
* Fix _tWinMain to use LPTSTR

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 174 +++++++++++++++++++++---------------------
 1 file changed, 86 insertions(+), 88 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 49b05ad..c568d54 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -184,9 +184,9 @@ GetErrorMessage(
                        NULL))
         return NULL;
 
-    for (Index = 0; Message[Index] != '\0'; Index++) {
-        if (Message[Index] == '\r' || Message[Index] == '\n') {
-            Message[Index] = '\0';
+    for (Index = 0; Message[Index] != _T('\0'); Index++) {
+        if (Message[Index] == _T('\r') || Message[Index] == _T('\n')) {
+            Message[Index] = _T('\0');
             break;
         }
     }
@@ -194,14 +194,14 @@ GetErrorMessage(
     return Message;
 }
 
-static PCSTR
+static PCTSTR
 ServiceStateName(
     _In_ DWORD  State
     )
 {
 #define _STATE_NAME(_State) \
     case SERVICE_ ## _State: \
-        return #_State
+        return _T(#_State)
 
     switch (State) {
     _STATE_NAME(START_PENDING);
@@ -212,7 +212,7 @@ ServiceStateName(
         break;
     }
 
-    return "UNKNOWN";
+    return _T("UNKNOWN");
 
 #undef  _STATE_NAME
 }
@@ -304,14 +304,14 @@ MonitorCtrlHandlerEx(
     return ERROR_CALL_NOT_IMPLEMENTED;
 }
 
-static PCSTR
+static PCTSTR
 WTSStateName(
     _In_ DWORD  State
     )
 {
 #define _STATE_NAME(_State) \
     case WTS ## _State: \
-        return #_State
+        return _T(#_State)
 
     switch (State) {
     _STATE_NAME(Active);
@@ -328,7 +328,7 @@ WTSStateName(
         break;
     }
 
-    return "UNKNOWN";
+    return _T("UNKNOWN");
 
 #undef  _STATE_NAME
 }
@@ -370,7 +370,7 @@ GetPromptTimeout(
     ValueLength = sizeof (Value);
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "PromptTimeout",
+                            _T("PromptTimeout"),
                             NULL,
                             &Type,
                             (LPBYTE)&Value,
@@ -400,7 +400,7 @@ GetDisplayName(
 
     Result = StringCbPrintf(ServiceKeyName,
                             MAX_PATH,
-                            SERVICES_KEY "\\%s",
+                            _T(SERVICES_KEY "\\%s"),
                             DriverName);
     assert(SUCCEEDED(Result));
 
@@ -438,7 +438,7 @@ GetDisplayName(
         goto fail3;
 
     Error = RegQueryValueEx(ServiceKey,
-                            "DisplayName",
+                            _T("DisplayName"),
                             NULL,
                             &Type,
                             (LPBYTE)DisplayName,
@@ -519,10 +519,8 @@ DoPromptForReboot(
 
     Error = ERROR_SUCCESS;
 
-    TitleLength = (DWORD)((_tcslen(Prompt->Title) +
-                           1) * sizeof (TCHAR));
-    TextLength = (DWORD)((_tcslen(Prompt->Text) +
-                           1) * sizeof (TCHAR));
+    TitleLength = (DWORD)(_tcslen(Prompt->Title) + 1);
+    TextLength = (DWORD)(_tcslen(Prompt->Text) + 1);
 
     Success = WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
                                    0,
@@ -555,9 +553,9 @@ DoPromptForReboot(
         Success = WTSSendMessage(WTS_CURRENT_SERVER_HANDLE,
                                  SessionId,
                                  Prompt->Title,
-                                 TitleLength,
+                                 TitleLength * sizeof(TCHAR),
                                  Prompt->Text,
-                                 TextLength,
+                                 TextLength * sizeof(TCHAR),
                                  MB_YESNO | MB_ICONEXCLAMATION,
                                  Timeout,
                                  &Response,
@@ -639,25 +637,25 @@ PromptForReboot(
     else
         Description++;
 
-    TextLength = (DWORD)((_tcslen(Description) +
-                          1 + // ' '
-                          _tcslen(Context->Text) +
-                          1 + // ' '
-                          _tcslen(Context->Question) +
-                          1) * sizeof (TCHAR));
+    TextLength = (DWORD)(_tcslen(Description) +
+                         1 + // ' '
+                         _tcslen(Context->Text) +
+                         1 + // ' '
+                         _tcslen(Context->Question) +
+                         1);
 
-    Prompt->Text = calloc(1, TextLength);
+    Prompt->Text = calloc(1, TextLength * sizeof(TCHAR));
     if (Prompt->Text == NULL) {
         Error = ERROR_OUTOFMEMORY;
         goto fail4;
     }
 
-    Result = StringCbPrintf(Prompt->Text,
-                            TextLength,
-                            TEXT("%s %s %s"),
-                            Description,
-                            Context->Text,
-                            Context->Question);
+    Result = StringCchPrintf(Prompt->Text,
+                             TextLength,
+                             TEXT("%s %s %s"),
+                             Description,
+                             Context->Text,
+                             Context->Question);
     assert(SUCCEEDED(Result));
 
     PromptThread = CreateThread(NULL,
@@ -758,7 +756,7 @@ TryAutoReboot(
     Length = sizeof (DWORD);
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "AutoReboot",
+                            _T("AutoReboot"),
                             NULL,
                             &Type,
                             (LPBYTE)&AutoReboot,
@@ -773,7 +771,7 @@ TryAutoReboot(
     Length = sizeof (DWORD);
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "RebootCount",
+                            _T("RebootCount"),
                             NULL,
                             &Type,
                             (LPBYTE)&RebootCount,
@@ -792,7 +790,7 @@ TryAutoReboot(
     ++RebootCount;
 
     (VOID) RegSetValueEx(Context->ParametersKey,
-                         "RebootCount",
+                         _T("RebootCount"),
                          0,
                          REG_DWORD,
                          (const BYTE*)&RebootCount,
@@ -801,7 +799,7 @@ TryAutoReboot(
     (VOID) RegFlushKey(Context->ParametersKey);
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "AutoRebootTimeout",
+                            _T("AutoRebootTimeout"),
                             NULL,
                             &Type,
                             (LPBYTE)&Timeout,
@@ -822,22 +820,22 @@ TryAutoReboot(
     else
         Description++;
 
-    TextLength = (DWORD)((_tcslen(Description) +
-                          1 + // ' '
-                          _tcslen(Context->Text) +
-                          1) * sizeof (TCHAR));
+    TextLength = (DWORD)(_tcslen(Description) +
+                         1 + // ' '
+                         _tcslen(Context->Text) +
+                         1);
 
-    Text = calloc(1, TextLength);
+    Text = calloc(1, TextLength * sizeof(TCHAR));
     if (Text == NULL) {
         SetLastError(ERROR_OUTOFMEMORY);
         goto fail3;
     }
 
-    Result = StringCbPrintf(Text,
-                            TextLength,
-                            TEXT("%s %s"),
-                            Description,
-                            Context->Text);
+    Result = StringCchPrintf(Text,
+                             TextLength,
+                             TEXT("%s %s"),
+                             Description,
+                             Context->Text);
     assert(SUCCEEDED(Result));
 
     free(DisplayName);
@@ -908,9 +906,9 @@ CheckRequestSubKeys(
         goto fail1;
     }
 
-    SubKeyLength = MaxSubKeyLength + sizeof (TCHAR);
+    SubKeyLength = MaxSubKeyLength + 1;
 
-    SubKeyName = calloc(1, SubKeyLength);
+    SubKeyName = calloc(1, SubKeyLength * sizeof(TCHAR));
     if (SubKeyName == NULL)
         goto fail2;
 
@@ -919,8 +917,8 @@ CheckRequestSubKeys(
         DWORD   Type;
         DWORD   Reboot;
 
-        SubKeyLength = MaxSubKeyLength + sizeof (TCHAR);
-        memset(SubKeyName, 0, SubKeyLength);
+        SubKeyLength = MaxSubKeyLength + 1;
+        memset(SubKeyName, 0, SubKeyLength * sizeof(TCHAR));
 
         Error = RegEnumKeyEx(Context->RequestKey,
                              Index,
@@ -947,7 +945,7 @@ CheckRequestSubKeys(
 
         Length = sizeof (DWORD);
         Error = RegQueryValueEx(SubKey,
-                                "Reboot",
+                                _T("Reboot"),
                                 NULL,
                                 &Type,
                                 (LPBYTE)&Reboot,
@@ -964,7 +962,7 @@ loop:
     }
 
     Error = RegDeleteValue(Context->ParametersKey,
-                           "RebootCount");
+                           _T("RebootCount"));
     if (Error == ERROR_SUCCESS)
         (VOID) RegFlushKey(Context->ParametersKey);
 
@@ -1113,7 +1111,7 @@ GetRequestKeyName(
 {
     PMONITOR_CONTEXT            Context = &MonitorContext;
     DWORD                       MaxValueLength;
-    DWORD                       RequestKeyNameLength;
+    DWORD                       RequestKeyNameSize;
     DWORD                       Type;
     HRESULT                     Error;
 
@@ -1134,18 +1132,18 @@ GetRequestKeyName(
         goto fail1;
     }
 
-    RequestKeyNameLength = MaxValueLength + sizeof (TCHAR);
+    RequestKeyNameSize = (MaxValueLength + 1) * sizeof(TCHAR);
 
-    *RequestKeyName = calloc(1, RequestKeyNameLength);
+    *RequestKeyName = calloc(1, RequestKeyNameSize);
     if (*RequestKeyName == NULL)
         goto fail2;
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "RequestKey",
+                            _T("RequestKey"),
                             NULL,
                             &Type,
                             (LPBYTE)(*RequestKeyName),
-                            &RequestKeyNameLength);
+                            &RequestKeyNameSize);
     if (Error != ERROR_SUCCESS) {
         SetLastError(Error);
         goto fail3;
@@ -1191,9 +1189,9 @@ GetDialogParameters(
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
     DWORD               MaxValueLength;
-    DWORD               TitleLength;
-    DWORD               TextLength;
-    DWORD               QuestionLength;
+    DWORD               TitleSize;
+    DWORD               TextSize;
+    DWORD               QuestionSize;
     DWORD               Type;
     HRESULT             Error;
 
@@ -1214,18 +1212,18 @@ GetDialogParameters(
         goto fail1;
     }
 
-    TitleLength = MaxValueLength + sizeof (TCHAR);
+    TitleSize = (MaxValueLength + 1) * sizeof(TCHAR);
 
-    Context->Title = calloc(1, TitleLength);
+    Context->Title = calloc(1, TitleSize);
     if (Context == NULL)
         goto fail2;
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "DialogTitle",
+                            _T("DialogTitle"),
                             NULL,
                             &Type,
                             (LPBYTE)Context->Title,
-                            &TitleLength);
+                            &TitleSize);
     if (Error != ERROR_SUCCESS) {
         SetLastError(Error);
         goto fail3;
@@ -1236,18 +1234,18 @@ GetDialogParameters(
         goto fail4;
     }
 
-    TextLength = MaxValueLength + sizeof (TCHAR);
+    TextSize = (MaxValueLength + 1) * sizeof (TCHAR);
 
-    Context->Text = calloc(1, TextLength);
+    Context->Text = calloc(1, TextSize);
     if (Context == NULL)
         goto fail5;
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "DialogText",
+                            _T("DialogText"),
                             NULL,
                             &Type,
                             (LPBYTE)Context->Text,
-                            &TextLength);
+                            &TextSize);
     if (Error != ERROR_SUCCESS) {
         SetLastError(Error);
         goto fail6;
@@ -1258,18 +1256,18 @@ GetDialogParameters(
         goto fail7;
     }
 
-    QuestionLength = MaxValueLength + sizeof (TCHAR);
+    QuestionSize = (MaxValueLength + 1) * sizeof (TCHAR);
 
-    Context->Question = calloc(1, QuestionLength);
+    Context->Question = calloc(1, QuestionSize);
     if (Context == NULL)
         goto fail8;
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "DialogQuestion",
+                            _T("DialogQuestion"),
                             NULL,
                             &Type,
                             (LPBYTE)Context->Question,
-                            &QuestionLength);
+                            &QuestionSize);
     if (Error != ERROR_SUCCESS) {
         SetLastError(Error);
         goto fail9;
@@ -1336,10 +1334,10 @@ RemoveStartOverride(
     TCHAR               KeyName[MAX_PATH];
     HRESULT             Error;
 
-    Error = StringCbPrintf(KeyName,
-                           MAX_PATH,
-                           SERVICES_KEY "\\%s\\StartOverride",
-                           DriverName);
+    Error = StringCchPrintf(KeyName,
+                            MAX_PATH,
+                            _T(SERVICES_KEY "\\%s\\StartOverride"),
+                            DriverName);
     assert(SUCCEEDED(Error));
 
     Error = RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
@@ -1381,10 +1379,10 @@ MonitorMain(
 
     LogInfo("====>");
 
-    (VOID) RemoveStartOverride("stornvme");
+    (VOID) RemoveStartOverride(_T("stornvme"));
 
     Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
-                         PARAMETERS_KEY(__MODULE__),
+                         _T(PARAMETERS_KEY(__MODULE__)),
                          0,
                          KEY_READ,
                          &Context->ParametersKey);
@@ -1395,7 +1393,7 @@ MonitorMain(
     if (!Success)
         goto fail2;
 
-    Context->Service = RegisterServiceCtrlHandlerEx(MONITOR_NAME,
+    Context->Service = RegisterServiceCtrlHandlerEx(_T(MONITOR_NAME),
                                                     MonitorCtrlHandlerEx,
                                                     NULL);
     if (Context->Service == NULL)
@@ -1528,7 +1526,7 @@ done:
     ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
 
     RegCloseKey(Context->ParametersKey);
-    (VOID) RemoveStartOverride("stornvme");
+    (VOID) RemoveStartOverride(_T("stornvme"));
 
     LogInfo("<====");
 
@@ -1618,8 +1616,8 @@ MonitorCreate(
         goto fail2;
 
     Service = CreateService(SCManager,
-                            MONITOR_NAME,
-                            MONITOR_DISPLAYNAME,
+                            _T(MONITOR_NAME),
+                            _T(MONITOR_DISPLAYNAME),
                             SERVICE_ALL_ACCESS,
                             SERVICE_WIN32_OWN_PROCESS,
                             SERVICE_AUTO_START,
@@ -1683,7 +1681,7 @@ MonitorDelete(
         goto fail1;
 
     Service = OpenService(SCManager,
-                          MONITOR_NAME,
+                          _T(MONITOR_NAME),
                           SERVICE_ALL_ACCESS);
 
     if (Service == NULL)
@@ -1740,21 +1738,21 @@ MonitorEntry(
     )
 {
     SERVICE_TABLE_ENTRY Table[] = {
-        { MONITOR_NAME, MonitorMain },
+        { _T(MONITOR_NAME), MonitorMain },
         { NULL, NULL }
     };
     HRESULT             Error;
 
     LogInfo("%s (%s) ====>",
-            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-            DAY_STR "/" MONTH_STR "/" YEAR_STR);
+            _T(MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR),
+            _T(DAY_STR "/" MONTH_STR "/" YEAR_STR));
 
     if (!StartServiceCtrlDispatcher(Table))
         goto fail1;
 
     LogInfo("%s (%s) <====",
-            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-            DAY_STR "/" MONTH_STR "/" YEAR_STR);
+            _T(MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR),
+            _T(DAY_STR "/" MONTH_STR "/" YEAR_STR));
 
     return TRUE;
 
@@ -1775,7 +1773,7 @@ int CALLBACK
 _tWinMain(
     _In_        HINSTANCE   Current,
     _In_opt_    HINSTANCE   Previous,
-    _In_        LPSTR       CmdLine,
+    _In_        LPTSTR      CmdLine,
     _In_        int         CmdShow
     )
 {
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 13:44:22 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 13:44:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1230966.1536333 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtT4-00048C-D5; Fri, 13 Feb 2026 13:44:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1230966.1536333; Fri, 13 Feb 2026 13:44:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtT4-000485-AF; Fri, 13 Feb 2026 13:44:22 +0000
Received: by outflank-mailman (input) for mailman id 1230966;
 Fri, 13 Feb 2026 13:44:21 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=wBIX=AR=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vqtT2-000426-Tr
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 13:44:21 +0000
Received: from na1pdmzitismtp02.tibco.com (unknown [160.101.131.9])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 121e69b3-08e2-11f1-9ccf-f158ae23cfc8;
 Fri, 13 Feb 2026 14:44:09 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id 9BC6381D3BAA;
 Fri, 13 Feb 2026 08:43:43 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 121e69b3-08e2-11f1-9ccf-f158ae23cfc8
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>,
	david ambu <david.preetham@cloud.com>
Subject: [PATCH 2/4] Replace RegisterEventSource with TraceLoggingRegister
Date: Fri, 13 Feb 2026 13:44:00 +0000
Message-ID: <20260213134403.475-2-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <20260213134403.475-1-owen.smith@citrix.com>
References: <a120896e-c765-4c52-b055-c9d10fadeb10@vates.tech>
 <20260213134403.475-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

- Added TraceLogging levels for Information and Error events.
- Replaced RegisterEventSource due to potential security issues.
  This issue was raised by CodeQL 2.20.1,
  "RegisterEventSourceA has been marked deprecated as it is a legacy
   tracing API. Please migrate to modern Event Tracing for Windows APIs."
see: https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/28735-banned-crimson-api-usage

  Event Tracing logging needs to be captured using an ETW trace logger

Signed-off-by: david ambu <david.preetham@cloud.com>

* defined seperate macros for Info and Error logging
* use a switch on log level, rather than if/else
* Change __Log call to take a PCTSTR, and wrap format string with _T() in macros

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 300 ++++++++++++++++++++++--------------------
 1 file changed, 157 insertions(+), 143 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 347bef0..49b05ad 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -40,6 +40,8 @@
 #include <powrprof.h>
 #include <malloc.h>
 #include <assert.h>
+#include <TraceLoggingProvider.h>
+#include <winmeta.h>
 
 #include <version.h>
 
@@ -56,7 +58,6 @@ typedef struct _MONITOR_CONTEXT {
     SERVICE_STATUS          Status;
     SERVICE_STATUS_HANDLE   Service;
     HKEY                    ParametersKey;
-    HANDLE                  EventLog;
     HANDLE                  StopEvent;
     HANDLE                  RequestEvent;
     HANDLE                  Timer;
@@ -90,17 +91,30 @@ MONITOR_CONTEXT MonitorContext;
 #define PARAMETERS_KEY(_Service) \
         SERVICE_KEY(_Service) ## "\\Parameters"
 
+TRACELOGGING_DEFINE_PROVIDER(MonitorTraceLoggingProvider,
+                             MONITOR_NAME,
+                             //{54F99C5B-76EC-5F84-3F97-4C9F40AA0F1A}
+                             (0x54f99c5b, 0x76ec, 0x5f84, 0x3f, 0x97, 0x4c, 0x9f, 0x40, 0xaa, 0x0f, 0x1a));
+
+typedef enum {
+    LOG_INFO,
+    LOG_ERROR
+} LOG_LEVEL;
+
+#ifdef UNICODE
+#define TraceLoggingStringT(_buf, _name)    TraceLoggingWideString(_buf, _name)
+#else
+#define TraceLoggingStringT(_buf, _name)    TraceLoggingString(_buf, _name)
+#endif
+
 static VOID
 #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
 __Log(
-    _In_ PCSTR          Format,
+    _In_ LOG_LEVEL      Level,
+    _In_ PCTSTR         Format,
     ...
     )
 {
-#if DBG
-    PMONITOR_CONTEXT    Context = &MonitorContext;
-    const TCHAR         *Strings[1];
-#endif
     TCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
     va_list             Arguments;
     size_t              Length;
@@ -121,30 +135,35 @@ __Log(
 
     _Analysis_assume_(Length < MAXIMUM_BUFFER_SIZE);
     _Analysis_assume_(Length >= 2);
-    Buffer[Length] = '\0';
-    Buffer[Length - 1] = '\n';
-    Buffer[Length - 2] = '\r';
+    Buffer[Length] = _T('\0');
+    Buffer[Length - 1] = _T('\n');
+    Buffer[Length - 2] = _T('\r');
 
     OutputDebugString(Buffer);
 
-#if DBG
-    Strings[0] = Buffer;
-
-    if (Context->EventLog != NULL)
-        ReportEvent(Context->EventLog,
-                    EVENTLOG_INFORMATION_TYPE,
-                    0,
-                    MONITOR_LOG,
-                    NULL,
-                    ARRAYSIZE(Strings),
-                    0,
-                    Strings,
-                    NULL);
-#endif
+    switch (Level) {
+    case LOG_INFO:
+        TraceLoggingWrite(MonitorTraceLoggingProvider,
+                          "Information",
+                          TraceLoggingLevel(WINEVENT_LEVEL_INFO),
+                          TraceLoggingStringT(Buffer, "Info"));
+        break;
+    case LOG_ERROR:
+        TraceLoggingWrite(MonitorTraceLoggingProvider,
+                          "Error",
+                          TraceLoggingLevel(WINEVENT_LEVEL_ERROR),
+                          TraceLoggingStringT(Buffer, "Error"));
+        break;
+    default:
+        break;
+    }
 }
 
-#define Log(_Format, ...) \
-        __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
+#define LogInfo(_Format, ...) \
+        __Log(LOG_INFO, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
+
+#define LogError(_Format, ...) \
+        __Log(LOG_ERROR, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
 
 static PTSTR
 GetErrorMessage(
@@ -209,7 +228,7 @@ ReportStatus(
     BOOL                Success;
     HRESULT             Error;
 
-    Log("====> (%s)", ServiceStateName(CurrentState));
+    LogInfo("====> (%s)", ServiceStateName(CurrentState));
 
     Context->Status.dwCurrentState = CurrentState;
     Context->Status.dwWin32ExitCode = Win32ExitCode;
@@ -233,7 +252,7 @@ ReportStatus(
     if (!Success)
         goto fail1;
 
-    Log("<====");
+    LogInfo("<====");
 
     return;
 
@@ -243,7 +262,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -320,11 +339,11 @@ DoReboot(
     _In_ DWORD  Timeout
     )
 {
-    Log("waiting for pending install events...");
+    LogInfo("waiting for pending install events...");
 
     (VOID) CM_WaitNoPendingInstallEvents(INFINITE);
 
-    Log("initiating shutdown...");
+    LogInfo("initiating shutdown...");
 
 #pragma prefast(suppress:28159)
     (VOID) InitiateSystemShutdownEx(NULL,
@@ -360,7 +379,7 @@ GetPromptTimeout(
         Type != REG_DWORD)
         Value = 0;
 
-    Log("%u", Value);
+    LogInfo("%u", Value);
 
     return Value;
 }
@@ -439,18 +458,18 @@ GetDisplayName(
     return DisplayName;
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
     free(DisplayName);
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     RegCloseKey(ServiceKey);
 
@@ -460,7 +479,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -525,10 +544,10 @@ DoPromptForReboot(
         WTS_CONNECTSTATE_CLASS  State = SessionInfo[Index].State;
         DWORD                   Response;
 
-        Log("[%u]: %s [%s]",
-            SessionId,
-            Name,
-            WTSStateName(State));
+        LogInfo("[%u]: %s [%s]",
+                SessionId,
+                Name,
+                WTSStateName(State));
 
         if (State != WTSActive)
             continue;
@@ -559,7 +578,7 @@ DoPromptForReboot(
     return ERROR_SUCCESS;
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
     *Prompt->PResponse = 0;
 
 fail1:
@@ -592,7 +611,7 @@ PromptForReboot(
         return;
     Context->RebootPrompted = TRUE;
 
-    Log("====> (%s)", DriverName);
+    LogInfo("====> (%s)", DriverName);
 
     Prompt = calloc(1, sizeof (REBOOT_PROMPT));
     if (Prompt == NULL) {
@@ -659,20 +678,20 @@ PromptForReboot(
     return;
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
     free(DisplayName);
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -766,9 +785,9 @@ TryAutoReboot(
     if (RebootCount >= AutoReboot)
         goto prompt;
 
-    Log("AutoRebooting (reboot %u of %u)\n",
-        RebootCount,
-        AutoReboot);
+    LogInfo("AutoRebooting (reboot %u of %u)\n",
+            RebootCount,
+            AutoReboot);
 
     ++RebootCount;
 
@@ -838,18 +857,18 @@ done:
     return;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(DisplayName);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -870,7 +889,7 @@ CheckRequestSubKeys(
     HKEY                SubKey;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     Error = RegQueryInfoKey(Context->RequestKey,
                             NULL,
@@ -916,7 +935,7 @@ CheckRequestSubKeys(
             goto fail3;
         }
 
-        Log("%s", SubKeyName);
+        LogInfo("%s", SubKeyName);
 
         Error = RegOpenKeyEx(Context->RequestKey,
                              SubKeyName,
@@ -960,17 +979,17 @@ found:
 done:
     free(SubKeyName);
 
-    Log("<====");
+    LogInfo("<====");
 
     return;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(SubKeyName);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -978,7 +997,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -991,7 +1010,7 @@ CheckRequestKey(
     PMONITOR_CONTEXT    Context = &MonitorContext;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     CheckRequestSubKeys();
 
@@ -1004,7 +1023,7 @@ CheckRequestKey(
     if (Error != ERROR_SUCCESS)
         goto fail1;
 
-    Log("<====");
+    LogInfo("<====");
 
     return;
 
@@ -1014,7 +1033,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -1029,7 +1048,7 @@ AcquireShutdownPrivilege(
     BOOL                Success;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     New.PrivilegeCount = 1;
 
@@ -1061,17 +1080,17 @@ AcquireShutdownPrivilege(
 
     CloseHandle(Token);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     CloseHandle(Token);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1079,7 +1098,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1137,20 +1156,20 @@ GetRequestKeyName(
         goto fail4;
     }
 
-    Log("%s", *RequestKeyName);
+    LogInfo("%s", *RequestKeyName);
 
     return TRUE;
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(*RequestKeyName);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1158,7 +1177,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1264,37 +1283,37 @@ GetDialogParameters(
     return TRUE;
 
 fail10:
-    Log("fail10");
+    LogError("fail10");
 
 fail9:
-    Log("fail9");
+    LogError("fail9");
 
     free(Context->Question);
 
 fail8:
-    Log("fail8");
+    LogError("fail8");
 
 fail7:
-    Log("fail7");
+    LogError("fail7");
 
 fail6:
-    Log("fail6");
+    LogError("fail6");
 
     free(Context->Text);
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(Context->Title);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1302,7 +1321,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1335,7 +1354,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1357,7 +1376,10 @@ MonitorMain(
     UNREFERENCED_PARAMETER(argc);
     UNREFERENCED_PARAMETER(argv);
 
-    Log("====>");
+    if (TraceLoggingRegister(MonitorTraceLoggingProvider) != ERROR_SUCCESS)
+        LogInfo("TraceLoggingRegister failed");
+
+    LogInfo("====>");
 
     (VOID) RemoveStartOverride("stornvme");
 
@@ -1379,11 +1401,6 @@ MonitorMain(
     if (Context->Service == NULL)
         goto fail3;
 
-    Context->EventLog = RegisterEventSource(NULL,
-                                            MONITOR_NAME);
-    if (Context->EventLog == NULL)
-        goto fail4;
-
     Context->Status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
     Context->Status.dwServiceSpecificExitCode = 0;
 
@@ -1395,26 +1412,26 @@ MonitorMain(
                                      NULL);
 
     if (Context->StopEvent == NULL)
-        goto fail5;
+        goto fail4;
 
     Context->RequestEvent = CreateEvent(NULL,
                                         TRUE,
                                         FALSE,
                                         NULL);
     if (Context->RequestEvent == NULL)
-        goto fail6;
+        goto fail5;
 
     Context->ResponseEvent = CreateEvent(NULL,
                                          FALSE,
                                          FALSE,
                                          NULL);
     if (Context->ResponseEvent == NULL)
-        goto fail7;
+        goto fail6;
     Context->Response = 0;
 
     Success = GetRequestKeyName(&RequestKeyName);
     if (!Success)
-        goto fail8;
+        goto fail7;
 
     Error = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
                            RequestKeyName,
@@ -1426,15 +1443,15 @@ MonitorMain(
                            &Context->RequestKey,
                            NULL);
     if (Error != ERROR_SUCCESS)
-        goto fail9;
+        goto fail8;
 
     Success = GetDialogParameters();
     if (!Success)
-        goto fail10;
+        goto fail9;
 
     Context->Timer = CreateWaitableTimer(NULL, FALSE, NULL);
     if (Context->Timer == NULL)
-        goto fail11;
+        goto fail10;
 
     DueTime.QuadPart = -10000LL * REBOOT_RETRY_DELAY;
 
@@ -1445,7 +1462,7 @@ MonitorMain(
                                NULL,
                                FALSE);
     if (!Success)
-        goto fail12;
+        goto fail11;
 
     SetEvent(Context->RequestEvent);
 
@@ -1460,12 +1477,12 @@ MonitorMain(
         Events[2] = Context->ResponseEvent;
         Events[3] = Context->Timer;
 
-        Log("waiting (%u)...", ARRAYSIZE(Events));
+        LogInfo("waiting (%u)...", ARRAYSIZE(Events));
         Object = WaitForMultipleObjects(ARRAYSIZE(Events),
                                         Events,
                                         FALSE,
                                         INFINITE);
-        Log("awake");
+        LogInfo("awake");
 
         switch (Object) {
         case WAIT_OBJECT_0:
@@ -1510,63 +1527,58 @@ done:
 
     ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
 
-    (VOID) DeregisterEventSource(Context->EventLog);
-
     RegCloseKey(Context->ParametersKey);
     (VOID) RemoveStartOverride("stornvme");
 
-    Log("<====");
+    LogInfo("<====");
+
+    TraceLoggingUnregister(MonitorTraceLoggingProvider);
 
     return;
 
-fail12:
-    Log("fail12");
+fail11:
+    LogError("fail11");
 
     CloseHandle(Context->Timer);
 
-fail11:
-    Log("fail11");
-
 fail10:
-    Log("fail10");
-
-    RegCloseKey(Context->RequestKey);
+    LogError("fail10");
 
 fail9:
-    Log("fail9");
+    LogError("fail9");
 
-    free(RequestKeyName);
+    RegCloseKey(Context->RequestKey);
 
 fail8:
-    Log("fail8");
+    LogError("fail8");
 
-    CloseHandle(Context->ResponseEvent);
+    free(RequestKeyName);
 
 fail7:
-    Log("fail7");
+    LogError("fail7");
 
-    CloseHandle(Context->RequestEvent);
+    CloseHandle(Context->ResponseEvent);
 
 fail6:
-    Log("fail6");
+    LogError("fail6");
 
-    CloseHandle(Context->StopEvent);
+    CloseHandle(Context->RequestEvent);
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
-    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
-
-    (VOID) DeregisterEventSource(Context->EventLog);
+    CloseHandle(Context->StopEvent);
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
+
+    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     RegCloseKey(Context->ParametersKey);
 
@@ -1576,9 +1588,11 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
+
+    TraceLoggingUnregister(MonitorTraceLoggingProvider);
 }
 
 static BOOL
@@ -1591,7 +1605,7 @@ MonitorCreate(
     TCHAR       Path[MAX_PATH];
     HRESULT     Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     if(!GetModuleFileName(NULL, Path, MAX_PATH))
         goto fail1;
@@ -1623,17 +1637,17 @@ MonitorCreate(
     CloseServiceHandle(Service);
     CloseServiceHandle(SCManager);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     CloseServiceHandle(SCManager);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1641,7 +1655,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1659,7 +1673,7 @@ MonitorDelete(
     SERVICE_STATUS      Status;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     SCManager = OpenSCManager(NULL,
                               NULL,
@@ -1690,20 +1704,20 @@ MonitorDelete(
     CloseServiceHandle(Service);
     CloseServiceHandle(SCManager);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     CloseServiceHandle(Service);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     CloseServiceHandle(SCManager);
 
@@ -1713,7 +1727,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1731,16 +1745,16 @@ MonitorEntry(
     };
     HRESULT             Error;
 
-    Log("%s (%s) ====>",
-        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-        DAY_STR "/" MONTH_STR "/" YEAR_STR);
+    LogInfo("%s (%s) ====>",
+            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
+            DAY_STR "/" MONTH_STR "/" YEAR_STR);
 
     if (!StartServiceCtrlDispatcher(Table))
         goto fail1;
 
-    Log("%s (%s) <====",
-        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-        DAY_STR "/" MONTH_STR "/" YEAR_STR);
+    LogInfo("%s (%s) <====",
+            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
+            DAY_STR "/" MONTH_STR "/" YEAR_STR);
 
     return TRUE;
 
@@ -1750,7 +1764,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 13:45:43 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 13:45:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1230991.1536337 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtUN-0004GS-Hc; Fri, 13 Feb 2026 13:45:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1230991.1536337; Fri, 13 Feb 2026 13:45:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtUN-0004GL-FA; Fri, 13 Feb 2026 13:45:43 +0000
Received: by outflank-mailman (input) for mailman id 1230991;
 Fri, 13 Feb 2026 13:45:42 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=MXTl=AR=bounce.vates.tech=bounce-md_30504962.698f2afe.v1-cfbd57fad158468ea377c45f6f67e6e3@srs-se1.protection.inumbo.net>)
 id 1vqtUM-0004GF-D2
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 13:45:42 +0000
Received: from mail145-20.atl61.mandrillapp.com
 (mail145-20.atl61.mandrillapp.com [198.2.145.20])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 461d007e-08e2-11f1-9ccf-f158ae23cfc8;
 Fri, 13 Feb 2026 14:45:36 +0100 (CET)
Received: from pmta06.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail145-20.atl61.mandrillapp.com (Mailchimp) with ESMTP id
 4fCD2Q4nwBzCf9VvP
 for <win-pv-devel@lists.xenproject.org>; Fri, 13 Feb 2026 13:45:34 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 cfbd57fad158468ea377c45f6f67e6e3; Fri, 13 Feb 2026 13:45:34 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 461d007e-08e2-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770990334; x=1771260334;
	bh=+E90hdxrT8i26S+49EQO3XypUhzvtwC7KtXUSm6+ymI=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=eDXjL/BQ9aba3qroo/vpRdjOF2iAhAwl6EwawYWYPrkKq+MPrEbiws+bQqiMj2xBB
	 jmIrfiP/FTUPl8eF2HAo8WULWiBejhNixlqiBF92dp0NWHx/Y7dzl4XmD+0RK42bMX
	 PsyL06DADB5IKNFVxBuqNRZmpkK89IJi246pjPAmxYEFwKfNV/njZwMl05Tcr+3aAc
	 luXfCDc46h0Dule2OVrTwEm82U27kTlTfjTHafkKfugWyJyO+6IRQEuDn047RTOYrk
	 +/HVlGkNRe4UND88oLtrjwikaIpSWDl/7HLAY+ejFkg+dGmE06+2osffooR9p698dh
	 M4P+PELwT4VCg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770990334; x=1771250834; i=ngoc-tu.dinh@vates.tech;
	bh=+E90hdxrT8i26S+49EQO3XypUhzvtwC7KtXUSm6+ymI=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=dLHb6J8mtrIsgxy582U3kmdRGHKCNXBr7ACKiqJ6F6eDQ9JjQkN2pXa1J7eMM3GCO
	 677sEomGlamyd++bzqHx2GScjvRCRC+8lSc8qj61ytsEY1ZNkhqbsUbe/zxDo8HDDk
	 5JYcWWMbSZ/fqZwVXNiOXDK0+MAilRRsICdIl84iCVSAYHwi2eUvlKzAzaa4oNvLbg
	 3J0VcDjk5yPIsWAEGkV389vhG73M2EHzhjya1Wdr56whAec74XM3eWxTWUFxJADG7f
	 8KFLMZa7Z6jSCguEj81CsYq+UzOti+ZVLg1i2XW7zISWuY3bvmVcDinLCsS6vLRlXp
	 Jk6HQx82axcMQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=204/4]=20Remove=20StartOverride=20from=20all=20storage=20adapters?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770990333781
Message-Id: <115ea978-df6e-463d-a967-25f33d6564d7@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
References: <a120896e-c765-4c52-b055-c9d10fadeb10@vates.tech> <20260213134403.475-1-owen.smith@citrix.com> <20260213134403.475-4-owen.smith@citrix.com>
In-Reply-To: <20260213134403.475-4-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.cfbd57fad158468ea377c45f6f67e6e3?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260213:md
Date: Fri, 13 Feb 2026 13:45:34 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 13/02/2026 14:44, Owen Smith wrote:
> Its possible to install non-Microsoft NVMe drivers on the emulated
> NVMe device. During upgrades, the VM requires a reboot using the emulated
> devices, but if the driver assigned for the emulated device has a StartOverride
> setting, then its likely not started which results in a 0x7B bugcheck.
> 
> Also reports SERVICE_STOPPED after clearing any StartOverride values
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Hi,

Could you send them as a new series? It's quite hard to see which 
patches are the new ones

> ---
>   src/monitor/monitor.c                        | 64 +++++++++++++++++---
>   vs2019/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
>   vs2022/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
>   3 files changed, 56 insertions(+), 12 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index c568d54..9bfb1f6 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -42,6 +42,8 @@
>   #include <assert.h>
>   #include <TraceLoggingProvider.h>
>   #include <winmeta.h>
> +#include <setupapi.h>
> +#include <devguid.h>
>   
>   #include <version.h>
>   
> @@ -1326,7 +1328,7 @@ fail1:
>       return FALSE;
>   }
>   
> -static BOOL
> +static VOID
>   RemoveStartOverride(
>       _In_ PTSTR          DriverName
>       )
> @@ -1334,17 +1336,61 @@ RemoveStartOverride(
>       TCHAR               KeyName[MAX_PATH];
>       HRESULT             Error;
>   
> +    LogInfo("%s", DriverName);
> +
>       Error = StringCchPrintf(KeyName,
>                               MAX_PATH,
>                               _T(SERVICES_KEY "\\%s\\StartOverride"),
>                               DriverName);
>       assert(SUCCEEDED(Error));
>   
> -    Error = RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
> -    if (Error != ERROR_SUCCESS)
> +    (VOID) RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
> +}
> +
> +static VOID
> +RemoveStartOverrideForClass(
> +    _In_ const GUID*    Guid
> +    )
> +{
> +    HRESULT             Error;
> +    HDEVINFO            DevInfo;
> +    DWORD               Index;
> +    SP_DEVINFO_DATA     DevInfoData;
> +
> +    DevInfo = SetupDiGetClassDevs(Guid,
> +                                  NULL,
> +                                  NULL,
> +                                  0);
> +    if (DevInfo == INVALID_HANDLE_VALUE)
>           goto fail1;
>   
> -    return TRUE;
> +    memset(&DevInfoData, 0, sizeof(DevInfoData));
> +    DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
> +
> +    for (Index = 0;
> +         SetupDiEnumDeviceInfo(DevInfo, Index, &DevInfoData);
> +         ++Index) {
> +        TCHAR           Buffer[MAX_PATH];
> +        memset(Buffer, 0, sizeof(Buffer));
> +
> +        if (SetupDiGetDeviceRegistryProperty(DevInfo,
> +                                             &DevInfoData,
> +                                             SPDRP_SERVICE,
> +                                             NULL,
> +                                             (PBYTE)Buffer,
> +                                             sizeof(Buffer),
> +                                             NULL)) {
> +            Buffer[MAX_PATH - 1] = _T('\0');
> +            RemoveStartOverride(Buffer);
> +        }
> +
> +        memset(&DevInfoData, 0, sizeof(DevInfoData));
> +        DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
> +    }
> +
> +    SetupDiDestroyDeviceInfoList(DevInfo);
> +
> +    return;
>   
>   fail1:
>       Error = GetLastError();
> @@ -1355,8 +1401,6 @@ fail1:
>           LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
> -
> -    return FALSE;
>   }
>   
>   VOID WINAPI
> @@ -1379,7 +1423,7 @@ MonitorMain(
>   
>       LogInfo("====>");
>   
> -    (VOID) RemoveStartOverride(_T("stornvme"));
> +    RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
>   
>       Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
>                            _T(PARAMETERS_KEY(__MODULE__)),
> @@ -1523,10 +1567,10 @@ done:
>       CloseHandle(Context->RequestEvent);
>       CloseHandle(Context->StopEvent);
>   
> -    ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
> -
>       RegCloseKey(Context->ParametersKey);
> -    (VOID) RemoveStartOverride(_T("stornvme"));
> +    RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
> +
> +    ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
>   
>       LogInfo("<====");
>   
> diff --git a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> index 3b44e29..df1fd58 100644
> --- a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> +++ b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> @@ -34,7 +34,7 @@
>         <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
>       </ClCompile>
>       <Link>
> -      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
> +      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
>         <CETCompat>true</CETCompat>
>         <GenerateMapFile>true</GenerateMapFile>
>         <MapExports>true</MapExports>
> diff --git a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> index 484fa1c..196a744 100644
> --- a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> +++ b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> @@ -34,7 +34,7 @@
>         <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
>       </ClCompile>
>       <Link>
> -      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
> +      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
>         <CETCompat>true</CETCompat>
>         <GenerateMapFile>true</GenerateMapFile>
>         <MapExports>true</MapExports>



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 13:45:52 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 13:45:52 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1230992.1536342 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtUW-0004Iy-JY; Fri, 13 Feb 2026 13:45:52 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1230992.1536342; Fri, 13 Feb 2026 13:45:52 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtUW-0004Ir-Gm; Fri, 13 Feb 2026 13:45:52 +0000
Received: by outflank-mailman (input) for mailman id 1230992;
 Fri, 13 Feb 2026 13:45:51 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=wBIX=AR=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vqtUV-0004GF-M4
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 13:45:51 +0000
Received: from CH5PR02CU005.outbound.protection.outlook.com
 (mail-northcentralusazlp170120005.outbound.protection.outlook.com
 [2a01:111:f403:c105::5])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 4df2774d-08e2-11f1-9ccf-f158ae23cfc8;
 Fri, 13 Feb 2026 14:45:49 +0100 (CET)
Received: from MN6PR03MB7744.namprd03.prod.outlook.com (2603:10b6:208:4ef::8)
 by CO1PR03MB5732.namprd03.prod.outlook.com (2603:10b6:303:97::23)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9611.10; Fri, 13 Feb
 2026 13:45:45 +0000
Received: from MN6PR03MB7744.namprd03.prod.outlook.com
 ([fe80::7172:3a7e:11a2:19ea]) by MN6PR03MB7744.namprd03.prod.outlook.com
 ([fe80::7172:3a7e:11a2:19ea%6]) with mapi id 15.20.9611.012; Fri, 13 Feb 2026
 13:45:44 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 4df2774d-08e2-11f1-9ccf-f158ae23cfc8
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=SuHRs7iW3aSJvnuTDDc2vc5Ld0DYQYbYsZOkOI+Qwl6p5pIJ10TzabkMGgrCBLCC7sa+hqIL2c9y6w+GM/3sFR1LONPLeJuCMtFA7MktB8M+jM2QQ9U8ZM86mlFCBmJhtTRPUlAGJRo/MXdg5/B67Zvwh3KAKheaJ51VF+zF7y9IxPXnRSXaIaWEFaL5hMD8VXX/bFxXm8kkBFu3KO7n/cQQ4nGJ2XggXqv2x4K5FAkYPqnu9cIryAJs/1H9r8K5WTt1sUzRiut+H3B0sRWLJKYOGCa7RZJxO4z1Gryyzm4mtyddNl2CEzU6q3fK/K6p9EIKtshAKwG2MvsfC1gubQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector10001;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=yIT5GLk5rW3fDZNSDqCGIzrh7GeleWQuUScJs++7TqY=;
 b=AYgrau991Koz4l8xgrHlth/dhTAM/wiBwuwFpYs+qTpvKoHi/Tk/kj7nLM4aovU/fnIkX3IVbWPIjxBvuZTYuwFDKNAgLy5YuQYc05Grb94dn9VXp8mqvScoKnzOfbJr6gIQKcEEdLBhLylTp6tQbNvx+4nqoilRjqjcgrJ4H2zna3l0cO02rHxln9GT2/Sl0IcZ8Vtj97nxTrxdtV0Z8+K+wYR0eXq3FPY71IPax2pi528N33K7GwjcT91QKaUp7N4z19C4H7SoCGUzlp7CMIdWU9uwbxDbWC5EL5AiHZ4VkxeXGDKH7CQ8GQGhLSPD3SJVHPJgXMBnugzk59J/1g==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=yIT5GLk5rW3fDZNSDqCGIzrh7GeleWQuUScJs++7TqY=;
 b=TO+MjBcmc9cjXHxJxgcRajNjllQ6+dUZBmj9dFM8n6ifHMYvTX5qpnT0D728GdAKv/k5dzobdFKUH1GEvm3WtUumm//wOkvah3VZ14rBbo/EvoyMst9fQNZHDCne6j8NSsSZn+u0ZWzoNbxGEYe100km3rLGZqyTMzQUYP0rtBU=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH 2/5] Refactor monitor.c registry enumeration
Thread-Topic: [PATCH 2/5] Refactor monitor.c registry enumeration
Thread-Index: AQHcl0T1V8TQgvlWOkKV6i1uSCIc1rV9dbeAgAM5fsY=
Date: Fri, 13 Feb 2026 13:45:44 +0000
Message-ID:
 <MN6PR03MB774454DD1C0C75F2896E9B20FE61A@MN6PR03MB7744.namprd03.prod.outlook.com>
References: <20260206084525.1356-1-owen.smith@citrix.com>
 <20260206084525.1356-2-owen.smith@citrix.com>
 <fce9c950-9d8a-4ea3-b2f3-4ff937d131c2@vates.tech>
In-Reply-To: <fce9c950-9d8a-4ea3-b2f3-4ff937d131c2@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: MN6PR03MB7744:EE_|CO1PR03MB5732:EE_
x-ms-office365-filtering-correlation-id: c1fac4fc-0d13-49c9-2899-08de6b062fc7
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;ARA:13230040|366016|1800799024|376014|38070700021;
x-microsoft-antispam-message-info:
 =?us-ascii?Q?AO7eIEK3Hs5S0JKLUMazx37EIsIqeIymGxIuQyhrlqTRRfrY1fy2wzzVO81x?=
 =?us-ascii?Q?w/l+LQVqd8e/Lbp2eUzHvW8AnWrCFZ8bD/5+lpmAD8Q8QBj5Jw3PtZ499beo?=
 =?us-ascii?Q?xU8/dlcQtRKybbL6LD7Bm72J7BFobs/ulntxUjxOWLYzR56KmYDn519KWZ4m?=
 =?us-ascii?Q?MrWAO1nvvPLFx4KfsP3sR4ZtguuHHuq0ZSa+YiBs8/KbnEwsfpgKyr6pHSOL?=
 =?us-ascii?Q?dMXXYBnBvDtrgV4KvP8+NyjwzZFQ4hwe0KOujAfa4gHpRSF9WXwtnsBUWXeD?=
 =?us-ascii?Q?FkyGRA6SWaWPHREIjqWwUSo5nmzwIlkk57PK5b3pE+3btahusYPENSBrGJ/q?=
 =?us-ascii?Q?AgI08g9mrwIjgVZFKfF8/dkZLnknQzTwDwvUFIiEgPXJd7TCWfdT8xid+cMu?=
 =?us-ascii?Q?3PPRKF5duRf/R4Kbl6qJWlaWFbOG9O0ac6idXV+ZTofeVsUSubJPIJukrvdP?=
 =?us-ascii?Q?d97L+JHDF4HPRjeaUIvEw0JOVSeupCcwRwk3waTWJ6RoI1s9csv1E8cu+GX/?=
 =?us-ascii?Q?xswaeswUO0kAi60sTkP+/inCXYpYnJhDWdowZmZK6woyhKBvh418VpjsiZVD?=
 =?us-ascii?Q?weJogXYLnW/v9YhjwZcFs61CPDNMfNdBQjcw25+wvSfHrUCfbQkTWXaj6JXY?=
 =?us-ascii?Q?jQv0J7KSRGLzCX5q/b65day04J2hMeCuWLdc/5XGOiQZTjCjdhwWJAnwXr9F?=
 =?us-ascii?Q?koyIP+OvtbNlP7sBSeUVHGRI7Ho/bgElHF09nrxnd15g/eA5tZtNCRGSIXV6?=
 =?us-ascii?Q?40/1BR4gde+2XykjP9Oj+S8vAgNJu2N/aEokPZyE84LWcuRuUkt1CKMumZDj?=
 =?us-ascii?Q?ayfdjI7eCz1MOY/mBGHTMKoEosrEmGPtiwQyT6NrgvxVEZjYtbBSxAXtTuuW?=
 =?us-ascii?Q?Ae1wRLkT89ZK/ZIhdXd6bZF/wtQ70A17blZc0KNELfv1o+gO0aBtzsh8ts6Y?=
 =?us-ascii?Q?gozqNRUqbaL2ayJZIZ+zUjvlps2UyFNsJNK2AYbzfcYTeNunws0L3UTer537?=
 =?us-ascii?Q?n99TKD+PPsnqhdKgjLaExm3bwxwi3HjayJcwo73ee5CXruV8/mqwHbYNmcwi?=
 =?us-ascii?Q?L8vE7xYFQpOLCbGRBzojLn9s1ZAphE99Q0v0ErjmhyGMXibdQ/6nWNc2vqgp?=
 =?us-ascii?Q?HpXWqvaXsgbpryG1QKN40zh6dyTJfq8FMKV+8VSuuUhqbltNfAdpi9t49KnY?=
 =?us-ascii?Q?kqiJY8HFXbhyhZh19xk4T24eZXMaQ27t7UZAjOuWQkenJuXjwSUZbD2JKPEF?=
 =?us-ascii?Q?3shryyiyjy1RML3AlrxYPjHapKS3vrM7r96rG/0M6MxFiU8IrXWUCrv8UFmI?=
 =?us-ascii?Q?GtIQrlV/0MAH7Q42FCiLPpIZldpUmEQxS49CYZv4Lj09lVhE1NUDnV9y4x7L?=
 =?us-ascii?Q?481TwLJWDjAxY1T29/KM0/RfhWgnP2ng51FD0pKWWmst1XiwFZcSjTatt4WY?=
 =?us-ascii?Q?EXrg61/LIWuOXPXDjLMeMw6/BtIaM088P3qFySba8YfxPMhCeooSoFne4YKT?=
 =?us-ascii?Q?X/yBaWSgfTgUbgTVqGOgdxyDLp4SgdmuQ8DskH5VGH2z5DUJUanFvMiyqXcM?=
 =?us-ascii?Q?I8lFg0PD8+U8o3/GwAI=3D?=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN6PR03MB7744.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(38070700021);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?eoeLI338EK6fcwx4gMlxWWs3IMaALU6INdx6y5gb5ueNJvr7U09MzTbwlKbu?=
 =?us-ascii?Q?cnkGsTchJlSEf7lsoAUbPKa4MzmMlPbFO9zufrsdUi6GFtxlV8Q9Au6D7ZgT?=
 =?us-ascii?Q?DNS/2s95KPuEUyJn5s5wsThHQhioCnTbd1MUeQwbfxn+04ACWHkBLkk0+RX2?=
 =?us-ascii?Q?DwU8kMDoeK0OoHC76pZWmldcqqs49CGHMPOAVuIw9nwEbUd2ink3yjps8x5P?=
 =?us-ascii?Q?gOcc1w2Vow7UUyN73ODtCXw7qD2cVUvPNuuhp92biohBKDKl5bXCKvbW3gBf?=
 =?us-ascii?Q?dF2HmbnFGOxv6NxYBk8VVadTNlQpLstLMWgPYkIQZ6mmMUNfI9PZmBkUqtIl?=
 =?us-ascii?Q?xHw9ynNCTz2RKoG2BsKBrOl0Ynkq7E8ApVKhQq+HHH3JwWLCElaDVchhaBxG?=
 =?us-ascii?Q?nnUiQOLrJ9cUYZkXoIvNz8Dl1nghJNfAqAIN8coZVe2nRWncJtdkpBl+Y8bA?=
 =?us-ascii?Q?X2TX9iC4WfleUqAWa0DcVHGWxkpLoFLW0vHWqXIWQJKv0aZxHTT3jot3EZbL?=
 =?us-ascii?Q?1hoBLI2jMMI08lQZ5mibMF7C4/9nSzqGRpKAfVpCGtUGMJKcpbwmVwj8MimO?=
 =?us-ascii?Q?foE67v1tFIiWfEy5W0BZYaGn7lCqhR7MhxMkmGGSL0gHXfYAo7YLjzOs4+9u?=
 =?us-ascii?Q?K75Xu4krtipe0tZEFQfKujOuiKRVt9wVX/tTrafdryCWPea6qi9XDWhfb5IV?=
 =?us-ascii?Q?L+sj/u3vzAMGc37/meiBb7sU7sEorewc4owS1DSBOyB4qgo8Ldt5Qh92H8Z+?=
 =?us-ascii?Q?63KsSBXO6WMJh0LX2KAOZeXvvFq2qEM3oYQxs1p2oSxsMjaBrK/ZIbAgI5nz?=
 =?us-ascii?Q?7JiLk6bTSec0fLgTzaNoJ8DIKzWgnE0V01UraNriLVW6vmS6Bg0FvexWSKqk?=
 =?us-ascii?Q?7T2kezhVsfnx4IrRaU+vyKLFC9NMkubGCXGTs50zsqfXl2ELnya+PYTTOCwm?=
 =?us-ascii?Q?x2UUvUNt3xznXWazEiiZxHgwO3JsuHQlMQ+BHQur0WO6qfBhZlLKFMSiJGyj?=
 =?us-ascii?Q?itma8R8UoCpkDI6/DZ6k/4bjiNtQWtdtO9vVrY7QEDP+wCyVOs+tl21xE7tV?=
 =?us-ascii?Q?umq2bPkwuPjMjRcwdIkNmzJvEuY2MQtAf+Ux5uIcDOyw+NmaBJSZqn21ElmU?=
 =?us-ascii?Q?OGl//ZN9y6tOY9HLxqRGIJtfORwV0y0EepRgWULY0u5GaMQVluIA4YjOWOpz?=
 =?us-ascii?Q?RbsT4XT8YLBwBynpnYVtJAo+J3usucud9LW3uh8czOJOLoiOgfw/j0Oa3feH?=
 =?us-ascii?Q?MKqKYt5PN5xcH6EQY93eqYqP9qRbLLb2hmT8yNMtvN/RyVQcAZ2uFCLU0Vqi?=
 =?us-ascii?Q?cTW9DPNrtaM0B5q++xwW66jQECydXuxtpi4PfPCiQW2D7n0d0fGLVHUh/HD5?=
 =?us-ascii?Q?NHneuiGTzaLd4bowjfkMo12GwLseW0cgciMQy16DW/s5QmdGo66WIrsJxc6V?=
 =?us-ascii?Q?fcCUiSr/fUoeCCej9ydNu0iY/mfFJtBHR3zy0NUGpl2eD6iRvjvRJaVn9ktV?=
 =?us-ascii?Q?bJ/1QKRJA2+DxgK2H3tZNH92+Xk6c4V2VFLxmMgmzvpuHa1vvQHrTfKRFz6g?=
 =?us-ascii?Q?SnoQh3pzA9vVyL8rLfbfywAPO03ePdns5R7ZvNHZVDkXoC2a/r005Paq65iF?=
 =?us-ascii?Q?Dg72asQJ1FsNXIYWtr+r5VSvcp8+34wJXnVsshrFrPbH9OZzCX3KpC3gEW+G?=
 =?us-ascii?Q?qpwswlswXSZjbOkNJVWNHabDslo/YyWEKCvEfy9EaDRY/2ur?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: MN6PR03MB7744.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: c1fac4fc-0d13-49c9-2899-08de6b062fc7
X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Feb 2026 13:45:44.8438
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: LCGZ+jdh+Ye6Wa1l47BSroKEV/SEXoFtuo0d6FtaQM5UfwsRQ7IUQemZshzwf8hS1TxJUKg3ROY2HS/IhhYzIg==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR03MB5732

Since the change to remove StartOverride values moved from registry enumera=
tion
to using SetupApi, this patch wasnt immediately required
I dropped this patch, to focus on the cleanup

Owen

________________________________________
From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> on behalf of=
 Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 11 February 2026 12:29 PM
To: Owen Smith; win-pv-devel@lists.xenproject.org
Subject: Re: [PATCH 2/5] Refactor monitor.c registry enumeration

Hi,

On 06/02/2026 09:45, Owen Smith wrote:
> Move registry enumeration code into a function, using a callback that is =
called
> for each sub key of the specified key.
>
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Could you rebase this patch in your next series? I haven't had the time
to look at this in detail.

Thanks,

> ---
>   src/monitor/monitor.c | 149 ++++++++++++++++++++++++++++--------------
>   1 file changed, 100 insertions(+), 49 deletions(-)
>
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 1154de5..52311aa 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -856,23 +856,25 @@ fail1:
>       return;
>   }
>
> -static VOID
> -CheckRequestSubKeys(
> -    VOID
> +typedef BOOLEAN(*PREGENUM_FUNC)(HKEY, PTSTR, PVOID);
> +
> +static HRESULT
> +RegEnumSubKeys(
> +    _In_ HKEY           BaseKey,
> +    _In_ PREGENUM_FUNC  Callback,
> +    _In_opt_ PVOID      Context
>       )
>   {
> -    PMONITOR_CONTEXT    Context =3D &MonitorContext;
>       DWORD               SubKeys;
>       DWORD               MaxSubKeyLength;
>       DWORD               SubKeyLength;
>       PTSTR               SubKeyName;
>       DWORD               Index;
> -    HKEY                SubKey;
>       HRESULT             Error;
>
>       Log("=3D=3D=3D=3D>");
>
> -    Error =3D RegQueryInfoKey(Context->RequestKey,
> +    Error =3D RegQueryInfoKey(BaseKey,
>                               NULL,
>                               NULL,
>                               NULL,
> @@ -896,14 +898,10 @@ CheckRequestSubKeys(
>           goto fail2;
>
>       for (Index =3D 0; Index < SubKeys; Index++) {
> -        DWORD   Length;
> -        DWORD   Type;
> -        DWORD   Reboot;
> -
>           SubKeyLength =3D MaxSubKeyLength + sizeof (TCHAR);
>           memset(SubKeyName, 0, SubKeyLength);
>
> -        Error =3D RegEnumKeyEx(Context->RequestKey,
> +        Error =3D RegEnumKeyEx(BaseKey,
>                                Index,
>                                (LPTSTR)SubKeyName,
>                                &SubKeyLength,
> @@ -918,59 +916,112 @@ CheckRequestSubKeys(
>
>           Log("%s", SubKeyName);
>
> -        Error =3D RegOpenKeyEx(Context->RequestKey,
> -                             SubKeyName,
> -                             0,
> -                             KEY_READ,
> -                             &SubKey);
> -        if (Error !=3D ERROR_SUCCESS)
> -            continue;
> +        if (!Callback(BaseKey, SubKeyName, Context))
> +            break;
> +    }
>
> -        Length =3D sizeof (DWORD);
> -        Error =3D RegQueryValueEx(SubKey,
> -                                "Reboot",
> -                                NULL,
> -                                &Type,
> -                                (LPBYTE)&Reboot,
> -                                &Length);
> -        if (Error !=3D ERROR_SUCCESS ||
> -            Type !=3D REG_DWORD)
> -            goto loop;
> +    free(SubKeyName);
>
> -        if (Reboot !=3D 0)
> -            goto found;
> +    return ERROR_SUCCESS;
>
> -loop:
> -        RegCloseKey(SubKey);
> +fail3:
> +    Log("fail3");
> +
> +    free(SubKeyName);
> +
> +fail2:
> +    Log("fail2");
> +
> +fail1:
> +    Error =3D GetLastError();
> +
> +    {
> +        PTSTR   Message;
> +        Message =3D GetErrorMessage(Error);
> +        Log("fail1 (%s)", Message);
> +        LocalFree(Message);
>       }
>
> -    Error =3D RegDeleteValue(Context->ParametersKey,
> -                           "RebootCount");
> -    if (Error =3D=3D ERROR_SUCCESS)
> -        (VOID) RegFlushKey(Context->ParametersKey);
> +    return Error;
> +}
>
> -    goto done;
> +static BOOLEAN
> +CheckRequestSubKey(
> +    _In_ HKEY           BaseKey,
> +    _In_ PTSTR          SubKeyName,
> +    _In_opt_ PVOID      Context
> +    )
> +{
> +    DWORD               Length;
> +    DWORD               Reboot;
> +    DWORD               Type;
> +    HKEY                SubKey;
> +    HRESULT             Error;
> +    PBOOLEAN            Found =3D (PBOOLEAN)Context;
>
> -found:
> -    RegCloseKey(SubKey);
> +    Error =3D RegOpenKeyEx(BaseKey,
> +                         SubKeyName,
> +                         0,
> +                         KEY_READ,
> +                         &SubKey);
> +    if (Error !=3D ERROR_SUCCESS)
> +        return TRUE;
> +
> +    Length =3D sizeof (DWORD);
> +    Error =3D RegQueryValueEx(SubKey,
> +                            "Reboot",
> +                            NULL,
> +                            &Type,
> +                            (LPBYTE)&Reboot,
> +                            &Length);
> +    if (Error !=3D ERROR_SUCCESS ||
> +        Type !=3D REG_DWORD)
> +        goto loop;
> +
> +    if (Reboot =3D=3D 0)
> +        goto loop;
>
> -    if (!Context->RebootRequestedBy)
> +    if (Found !=3D NULL)
> +        *Found =3D TRUE;
> +
> +    if (!MonitorContext.RebootRequestedBy)
>           TryAutoReboot(SubKeyName);
>
> -done:
> -    free(SubKeyName);
> +loop:
> +    RegCloseKey(SubKey);
>
> -    Log("<=3D=3D=3D=3D");
> +    return (Found !=3D NULL) ? !(*Found) : TRUE;
> +}
>
> -    return;
> +static VOID
> +CheckRequestSubKeys(
> +    VOID
> +    )
> +{
> +    PMONITOR_CONTEXT    Context =3D &MonitorContext;
> +    BOOLEAN             Found;
> +    HRESULT             Error;
>
> -fail3:
> -    Log("fail3");
> +    Log("=3D=3D=3D=3D>");
>
> -    free(SubKeyName);
> +    Found =3D FALSE;
>
> -fail2:
> -    Log("fail2");
> +    Error =3D RegEnumSubKeys(Context->RequestKey,
> +                           CheckRequestSubKey,
> +                           &Found);
> +    if (Error !=3D ERROR_SUCCESS)
> +        goto fail1;
> +
> +    if (!Found) {
> +        Error =3D RegDeleteValue(Context->ParametersKey,
> +                               "RebootCount");
> +        if (Error =3D=3D ERROR_SUCCESS)
> +            (VOID) RegFlushKey(Context->ParametersKey);
> +    }
> +
> +    Log("<=3D=3D=3D=3D");
> +
> +    return;
>
>   fail1:
>       Error =3D GetLastError();



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 13:49:55 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 13:49:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1231000.1536345 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtYQ-0004hb-Ti; Fri, 13 Feb 2026 13:49:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1231000.1536345; Fri, 13 Feb 2026 13:49:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtYQ-0004hU-R4; Fri, 13 Feb 2026 13:49:54 +0000
Received: by outflank-mailman (input) for mailman id 1231000;
 Fri, 13 Feb 2026 13:49:54 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=wBIX=AR=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vqtYQ-0004hN-0E
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 13:49:54 +0000
Received: from BL2PR02CU003.outbound.protection.outlook.com
 (mail-eastusazlp17011000f.outbound.protection.outlook.com
 [2a01:111:f403:c100::f])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ded7e93b-08e2-11f1-b163-2bf370ae4941;
 Fri, 13 Feb 2026 14:49:52 +0100 (CET)
Received: from MN6PR03MB7744.namprd03.prod.outlook.com (2603:10b6:208:4ef::8)
 by SA1PR03MB6529.namprd03.prod.outlook.com (2603:10b6:806:1c4::7)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9611.13; Fri, 13 Feb
 2026 13:49:48 +0000
Received: from MN6PR03MB7744.namprd03.prod.outlook.com
 ([fe80::7172:3a7e:11a2:19ea]) by MN6PR03MB7744.namprd03.prod.outlook.com
 ([fe80::7172:3a7e:11a2:19ea%6]) with mapi id 15.20.9611.012; Fri, 13 Feb 2026
 13:49:48 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ded7e93b-08e2-11f1-b163-2bf370ae4941
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=N/qW+5ozODQQ3eeedHxKJPTkYHawB4WgiXHH8kC+OpXb9JpZfdOP1+7WkLH2TNyQhBauIH8V3BcGBPjwRYyhC+n/CwpvHFKH4eO2Zf0e1HwpbRLs7w23ieBjDZwT9bs0BLPP+nRkLAlp4nknpIgIV1OvYBuWyTxVA8il6sdXK1WlaiTWllrtI5rb27dr0N+bAZNGVFHHdOPucGIaMcNP7yKXT0zEU3KlGyX6Cu/OO0dSzj1bu/7tBUXJVH5lFw7XLIs7PW8LO507ZX1e+EVmg7CtqVpNlT/ymNrtFnV2JAKP22Xsvzvof+J3KqSO3taiflnqAOM60QDmUxCb2Tsu1w==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector10001;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=xIiBiG6Sxy8nGNrkrBfJSrazH2UIOiEaRQeRR/ki99Y=;
 b=QFKaKuCNinHMZUta57GWCMAkOU2036cBQlNKu2hVn0hdnOD276fdfZRKFM2sgRsnsq7CAtZi1JSKerSFmXjARJzgsBgNhRhZzZta+zMUCM58ict+KXKORPW4leiTqH0zrtCgjkBz5s59/L7/gSNyoLX815ubxjLkwa4AFYA5T0E8gsEtghsK9GRKjPB2Es699f/PAnODjuVXOuilcqe03PoHbbofwe+pQs9BIj7dB8Dlsh5ksaLKnh9yYd7a2BOgCFwQ6eOFencweSf+5OUJIv8SHF68cQ2HSt3SNEBY4IlxMrwQJGVaZpQFifpSA07YSm8zsHCf1JIRZxqY4yI5pg==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=xIiBiG6Sxy8nGNrkrBfJSrazH2UIOiEaRQeRR/ki99Y=;
 b=gYeIFLHOep0PmlfLBcmRlvnkzluLwvow3X+QIme5CEjB7VNl9zZFYTNZLxVpq5MYBpjyw/W+ulE8ZiCxRl8JFSjvRDToQJ55Iyylq2QidVd41jvMh/IkC7iwoaTgKLnKfFyfj3dErKYLy6rfhVgy+kqz0VQ0DXtm7tN0qNuyQJI=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH 3/3] Remove StartOverride from all storage adapters
Thread-Topic: [PATCH 3/3] Remove StartOverride from all storage adapters
Thread-Index: AQHcmz5ladZUiJgp/kKbH46Q7bTFlbV9a8wAgAM75M0=
Date: Fri, 13 Feb 2026 13:49:48 +0000
Message-ID:
 <MN6PR03MB77442BB60D6B43B130F10856FE61A@MN6PR03MB7744.namprd03.prod.outlook.com>
References: <913a9fad-af24-4a21-8c07-ff0c8bc22462@vates.tech>
 <20260211100806.1648-1-owen.smith@citrix.com>
 <20260211100806.1648-3-owen.smith@citrix.com>
 <a120896e-c765-4c52-b055-c9d10fadeb10@vates.tech>
In-Reply-To: <a120896e-c765-4c52-b055-c9d10fadeb10@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: MN6PR03MB7744:EE_|SA1PR03MB6529:EE_
x-ms-office365-filtering-correlation-id: 7200905a-7059-4bc0-661d-08de6b06c0f1
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;ARA:13230040|376014|366016|1800799024|38070700021;
x-microsoft-antispam-message-info:
 =?us-ascii?Q?LZaFKkNCWuyWMT1R0GunwJbSYnYPG7ZbeupFNWtM0hgK939SpdWqi9GupxY6?=
 =?us-ascii?Q?vdzbr3gTHj6lp5KWf1N9eMZj152pmflV7tFVnj1C5BaOPOvKEZiyeUd5AZps?=
 =?us-ascii?Q?zV8vm6bY7t+K+c6o9bLKYDdleSCgRfSg9J0lYeXLMMngR7ZvfDarEfZkSmOo?=
 =?us-ascii?Q?GbweOAEXMb8uZU+30DoJK5FYdxtqlt70HBiaLo0vXD5J50vzjXTMGK2XSzFu?=
 =?us-ascii?Q?HdFeajFjvELmE8QqHJ+0ne3yAWKR6pzk37ivQu1lletZt0YYVwmNhuhAJg5e?=
 =?us-ascii?Q?qYJPeAhvWYFS8NJDHYVDh0gPmGLAwpFlLcvT9GbPlhhs8DddbQB8PHD8eTEX?=
 =?us-ascii?Q?P8ZTjaNHrDZ7PY3rX294RGXnEWmjlJjB4py6VHPQlGUZhGB7MA7rc0p2iqFv?=
 =?us-ascii?Q?YhfNLec//o0M75BreqsWYXpxljDLWqVe3ek0GzEZUoyBhxea6HyFoscZFwS3?=
 =?us-ascii?Q?ojqAcFUS8YqusQ8ABDUrdjDe1mrEfRxMPA4EzdZ2QjLLHXjCPgtKFuLytdwi?=
 =?us-ascii?Q?CK++XU1C1PDt/7MGOdNznH2PeaPkgVgPKFJcGWqEs42/JffMiFEYlawpWNXC?=
 =?us-ascii?Q?ZYrYoxZ2aPngeoxrdk1pOSczfBDIGUwQDFHAJKc/kUjQte1hUYI2PjxoMIW3?=
 =?us-ascii?Q?B5hhXNBXrJ7XZYaAuJ0i9Bw7MV+8Nuk5NIaL1LKYJlvz3Z36/sSuvYjaO/P/?=
 =?us-ascii?Q?sSSYthgld0QtKR9lGWdVGyzKYN/nnG7jf7Q426WbQy4f1L/wbTiuxutsLNzj?=
 =?us-ascii?Q?01OZ871YlO40AR+g9fk+XSdXegr4G4d+NFmfGcuHaZqywOpI/9XhDLI33DIj?=
 =?us-ascii?Q?sdErUU747mIitIvoIEKB8773DTRHh7kKO3PdT+RtM6SroVndO/SuJNOcM7Kz?=
 =?us-ascii?Q?R5/mIUu+m1gychhH6+I1VjO68+m2wsfQ5KfQmBwqVbL5YfaJsx1JcnGwhfCR?=
 =?us-ascii?Q?zWpNh8iSi791vx3pFwF3MajuxWFP52yHei9Ky4DyckoTgWkhhUeNvlhqcT0m?=
 =?us-ascii?Q?LQYubv4UhCjcMl7fsK6nfoMnqtTFAyQrgf9eSpbhn7QDzF+nNhb9/4BrC43z?=
 =?us-ascii?Q?UvqrGTT6dEfIvvsRa5dDJdbiIM/FIEkwp6Icj3JJhC5xXqyMxphjS/x6MCFA?=
 =?us-ascii?Q?KFIELDiaCr1OMS21RcWvz9f5u6Vu3wuOa4N1uw8UIQRHYHlcG7mUoy0b2cW6?=
 =?us-ascii?Q?1ulY/8bh2OAOQNNM8KS8MSFnKXw+eDz4REaHNrmm2RX9XiBf1EF9Llqcdsl5?=
 =?us-ascii?Q?ux2EHTokCp6v7TGpt6UP5WRHm56L08s+HqYBCCeEore/DHnsjpOTQopdGc4Y?=
 =?us-ascii?Q?T8kQmEtbYm89aZXO4fKvQ0FKsnWBNr48Kv5veBX2iZ5fVYS8QR6oOUJFCQVv?=
 =?us-ascii?Q?cU0I0rcg45lTWos+PzL1iAlB/RzW/GcHnGEu8mshiFIQK8GBQ2iejMCrYk92?=
 =?us-ascii?Q?gmej3S+DSDgdGr4aCYlj8yBYvbh36D252r9UgclZtAT47mG+7NES4EnSkbTW?=
 =?us-ascii?Q?Krubn/Nl3PTlc+fr3OjPX0YEn94a4iLq4XVC/1v3CCZ9AF2wceAZK1uWCVs5?=
 =?us-ascii?Q?axX1Qum84NI1DBz+ZLk=3D?=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN6PR03MB7744.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(38070700021);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?J61mGGuQMLANAsKtJyt51K/HWAbxQ+GltdY5aGptXlmzoKYm4cH6UZXw9NpF?=
 =?us-ascii?Q?V+F2r8U1mHgJCrMqyFKOivRSdBDOq7EM6vKWLQoko00NoBJiR2TkCaNqccVW?=
 =?us-ascii?Q?NYIh3mC0eLBpvOPmBbbUv3x1qflysIxg6ByA47cfShmLQLd7o3odZ9U4Z3ez?=
 =?us-ascii?Q?4J8bfBIIIbxzDEw9tmxKIlIignCGUyhUXteDw/HKOM9p3125xkODDTd3+BOH?=
 =?us-ascii?Q?7qNfxIXNh5dRAfmA33el8WDjl6v8QdMvZrG36ctz5dE3bb1jZ4sNjHpV88ld?=
 =?us-ascii?Q?HsC1LdhCTaO8VpgifGCJdw4ngPmkzA5MULscljuKd6+nbmpO9OM4ClLivRce?=
 =?us-ascii?Q?DPvCe3IWDJhWj5hu9UotXsEI9FFBe2tzf3AjCbIcgqUjK9m3DT4TWT5DvGhD?=
 =?us-ascii?Q?ZkP6RqpSwQHkwtmRAeer8JZkTqnpPcd++eVbv4LWdttBd0VzzqfWDUZM9bIR?=
 =?us-ascii?Q?WvXynJnc+JxlC7a0sgy/aInpOUMEZNpe8pFLEDMN5BBqIjikw5dstn0w5rKU?=
 =?us-ascii?Q?o3MKW3YF//9Q9VQEEZBSKvXcSMGYvbXPp04nzD4iP9yvZRaPQ/NWxhsTBToF?=
 =?us-ascii?Q?BMkguX1/42E32qo6u6qqqYkg9sQVpd5wcMflQYewoUQWHucVr7v0X8iWaDsp?=
 =?us-ascii?Q?l4vWx1KSihSksmnq9cIZJviPs6BC7P/z58ArSabL19EkHMv8bn+4AYfvZvtD?=
 =?us-ascii?Q?+B6Cp9jxjHPm51A9T9hHP1J1hsGX2wrhrqFRsLrHhxiMHuibBbdVx9pzBNCQ?=
 =?us-ascii?Q?fIuzSiMXXrMs4TqWLjoKvDJQkCiUxvXFQRQ+r0I8rgSDzwfxuiBnW+Dd3KO8?=
 =?us-ascii?Q?AQdGq/kZtDjQVovgl8Zg+t7ncU5zW4mFHn2Th7TNo/qC0CjHAd8PrrxDHSFB?=
 =?us-ascii?Q?NwvM8ywS3vm64FHLN09UOQQZRZKvvRyLurMHf+FbqoJ9OkM+TNNx7gX5ww8D?=
 =?us-ascii?Q?eCaJjjpqQN8x++bAJgcbTxJfTxp/70J7OV4Jm4X6/tfys9wxvLMpQswkpvJg?=
 =?us-ascii?Q?6Wd+Jg7zmOtl9lRYQe7P9m+cnc3UkmQdZM8jrH1yPkB4x1ciKp3bN98v2Bze?=
 =?us-ascii?Q?2D2eSFaw7Q8HXALzc3rP17AmWpAWRitRAhv5yjA+3P5pUA/M7AXnZFUVaYOq?=
 =?us-ascii?Q?8DdiKONKLonec+pQRnvG1kIzhgj0/Wp4s7MJ0yl2LlG6CpwaYvJBfhoYXot0?=
 =?us-ascii?Q?N65unqt0uT+oDiAcO6u7BK8MWEzLkImCkoxTj+m+KcPzdJEbFB2DytG5XEr5?=
 =?us-ascii?Q?MlyTKKSKrP5dVfuKYOhSTLR62nPkkaWHms2gVCP4kvVoWGM94R5bo/zhBy7s?=
 =?us-ascii?Q?3azBhBkJmZFXqB7/bezVf1bsxgV17VDc6MRxr5lGIqDfzG2LdIw6TxQt9II9?=
 =?us-ascii?Q?FqrAMrGY45QK8rkVhfDrIX2PBPM6GmudD5Yrg+Gmg6XwGaS63AxOGF4d9k57?=
 =?us-ascii?Q?jIj7dH+WtIrVxCNg2ZYgx9aHNdftGmBGaeF14gzmexOMrvpkuW78DK7sDCs1?=
 =?us-ascii?Q?7BOdTeGYDqNPbqEAgJCDF2ssakz+wJaMi7fqrOYKvqn5JoXrmiT0HrtK/TSZ?=
 =?us-ascii?Q?uBF0X9EAE/ebeGGW7lUvagT+gBlNVUirqicJ+T8OYYB9qxIxXUkeAS7aCaSl?=
 =?us-ascii?Q?eDlF1BXqWcLW0yu1Zj8e9Z4R5KgyepH0cEjNSFYeVW+rWtzJYiB0vEsuXr/q?=
 =?us-ascii?Q?cCzSshAXt4LGJdVENPjiwKghufhFKeK5IeK8GSCwiOMBW/NG?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: MN6PR03MB7744.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 7200905a-7059-4bc0-661d-08de6b06c0f1
X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Feb 2026 13:49:48.3675
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: bT18i93JHlz9m0XoKKghFEbc1okoGmemac2TQHdhsANn/2B/rvqLkIgygCvSLC/nz2fYflzEhtMsrZ1P0Ix6RQ==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR03MB6529

> > +
> > +    RemoveStartOverride("stornvme");
>
> I don't think RemoveStartOverride("stornvme") is still explicitly needed
> since it's already covered by the SCSIAdapter class even in native NVMe
> mode.

stornvme isnt explicitly required here - the setupapi enumeration will remo=
ve
StartOverride from stornvme if its the service responsible for the emulated=
 NVMe
device - there is a problem if stornvme is not the service responsible for =
emulated
NVMe, and that driver is uninstalled, though this is a general issue with u=
ninstalling
drivers on the boot storage device (e.g. uninstalling iaStorAC -> stornvme =
will not
remove stornvme's StartOverride and result in a 0x7B bugcheck. This will ha=
ppen
even if Xen drivers are never installed on the VM, and could potentially ha=
ppen on
baremetal)

Owen

________________________________________
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 11 February 2026 12:22 PM
To: Owen Smith; win-pv-devel@lists.xenproject.org
Subject: Re: [PATCH 3/3] Remove StartOverride from all storage adapters

On 11/02/2026 11:08, Owen Smith wrote:
> Its possible to install non-Microsoft NVMe drivers on the emulated
> NVMe device. During upgrades, the VM requires a reboot using the emulated
> devices, but if the driver assigned for the emulated device has a StartOv=
erride
> setting, then its likely not started which results in a 0x7B bugcheck.
>
> Signed-off-by: Owen Smith <owen.smith@citrix.com>
> ---
>   src/monitor/monitor.c                        | 67 +++++++++++++++++---
>   vs2019/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
>   vs2022/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
>   3 files changed, 59 insertions(+), 12 deletions(-)
>
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 700f196..eb1be91 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -42,6 +42,8 @@
>   #include <assert.h>
>   #include <TraceLoggingProvider.h>
>   #include <winmeta.h>
> +#include <setupapi.h>
> +#include <devguid.h>
>
>   #include <version.h>
>
> @@ -1328,7 +1330,7 @@ fail1:
>       return FALSE;
>   }
>
> -static BOOL
> +static VOID
>   RemoveStartOverride(
>       _In_ PTSTR          DriverName
>       )
> @@ -1336,17 +1338,61 @@ RemoveStartOverride(
>       TCHAR               KeyName[MAX_PATH];
>       HRESULT             Error;
>
> +    LogInfo("%s", DriverName);
> +
>       Error =3D StringCbPrintf(KeyName,
>                              MAX_PATH,
>                              SERVICES_KEY "\\%s\\StartOverride",

As this is new code, could you wrap this in _T please?

>                              DriverName);
>       assert(SUCCEEDED(Error));
>
> -    Error =3D RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
> -    if (Error !=3D ERROR_SUCCESS)
> +    (VOID) RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
> +}
> +
> +static VOID
> +RemoveStartOverrideForClass(
> +    _In_ const GUID*    Guid
> +    )
> +{
> +    HRESULT             Error;
> +    HDEVINFO            hDevInfo;
> +    DWORD               Index;
> +    SP_DEVINFO_DATA     devInfoData;

Nit: DevInfo and DevInfoData would better fit the naming convention

> +
> +    hDevInfo =3D SetupDiGetClassDevs(Guid,
> +                                   NULL,
> +                                   NULL,
> +                                   0);
> +    if (hDevInfo =3D=3D INVALID_HANDLE_VALUE)
>           goto fail1;
>
> -    return TRUE;
> +    memset(&devInfoData, 0, sizeof(devInfoData));
> +    devInfoData.cbSize =3D sizeof(SP_DEVINFO_DATA);
> +
> +    for (Index =3D 0;
> +         SetupDiEnumDeviceInfo(hDevInfo, Index, &devInfoData);
> +         ++Index) {
> +        TCHAR           Buffer[MAX_PATH];
> +        memset(Buffer, 0, sizeof(Buffer));
> +
> +        if (SetupDiGetDeviceRegistryProperty(hDevInfo,
> +                                             &devInfoData,
> +                                             SPDRP_SERVICE,
> +                                             NULL,
> +                                             (PBYTE)Buffer,
> +                                             sizeof(Buffer),
> +                                             NULL)) {
> +            Buffer[MAX_PATH - 1] =3D _T('\0');
> +            RemoveStartOverride(Buffer);
> +        }
> +
> +        memset(&devInfoData, 0, sizeof(devInfoData));
> +        devInfoData.cbSize =3D sizeof(SP_DEVINFO_DATA);
> +    }
> +
> +    SetupDiDestroyDeviceInfoList(hDevInfo);
> +
> +    return;
>
>   fail1:
>       Error =3D GetLastError();
> @@ -1357,8 +1403,6 @@ fail1:
>           LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
> -
> -    return FALSE;
>   }
>
>   VOID WINAPI
> @@ -1381,7 +1425,8 @@ MonitorMain(
>
>       LogInfo("=3D=3D=3D=3D>");
>
> -    (VOID) RemoveStartOverride("stornvme");
> +    RemoveStartOverride("stornvme");
> +    RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
>
>       Error =3D RegOpenKeyEx(HKEY_LOCAL_MACHINE,
>                            PARAMETERS_KEY(__MODULE__),
> @@ -1525,10 +1570,12 @@ done:
>       CloseHandle(Context->RequestEvent);
>       CloseHandle(Context->StopEvent);
>
> -    ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
> -
>       RegCloseKey(Context->ParametersKey);
> -    (VOID) RemoveStartOverride("stornvme");
> +
> +    RemoveStartOverride("stornvme");

I don't think RemoveStartOverride("stornvme") is still explicitly needed
since it's already covered by the SCSIAdapter class even in native NVMe
mode.

> +    RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
> +
> +    ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
>
>       LogInfo("<=3D=3D=3D=3D");
>
> diff --git a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj b/vs2019/xenbus=
_monitor/xenbus_monitor.vcxproj
> index 3b44e29..df1fd58 100644
> --- a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> +++ b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> @@ -34,7 +34,7 @@
>         <RuntimeLibrary Condition=3D"'$(UseDebugLibraries)'=3D=3D'false'"=
>MultiThreaded</RuntimeLibrary>
>       </ClCompile>
>       <Link>
> -      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(A=
dditionalDependencies)</AdditionalDependencies>
> +      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;set=
upapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
>         <CETCompat>true</CETCompat>
>         <GenerateMapFile>true</GenerateMapFile>
>         <MapExports>true</MapExports>
> diff --git a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj b/vs2022/xenbus=
_monitor/xenbus_monitor.vcxproj
> index 484fa1c..196a744 100644
> --- a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> +++ b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> @@ -34,7 +34,7 @@
>         <RuntimeLibrary Condition=3D"'$(UseDebugLibraries)'=3D=3D'false'"=
>MultiThreaded</RuntimeLibrary>
>       </ClCompile>
>       <Link>
> -      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(A=
dditionalDependencies)</AdditionalDependencies>
> +      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;set=
upapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
>         <CETCompat>true</CETCompat>
>         <GenerateMapFile>true</GenerateMapFile>
>         <MapExports>true</MapExports>



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 13:50:19 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 13:50:19 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1231003.1536351 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtYp-0005i0-1E; Fri, 13 Feb 2026 13:50:19 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1231003.1536351; Fri, 13 Feb 2026 13:50:19 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtYo-0005hn-U5; Fri, 13 Feb 2026 13:50:18 +0000
Received: by outflank-mailman (input) for mailman id 1231003;
 Fri, 13 Feb 2026 13:50:18 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=wBIX=AR=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vqtYo-0004hN-De
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 13:50:18 +0000
Received: from na1pdmzitismtp02.tibco.com (unknown [160.101.131.9])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id edd285e9-08e2-11f1-b163-2bf370ae4941;
 Fri, 13 Feb 2026 14:50:17 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id 3F44681D391D;
 Fri, 13 Feb 2026 08:49:52 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: edd285e9-08e2-11f1-b163-2bf370ae4941
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>,
	david ambu <david.preetham@cloud.com>
Subject: [PATCH 1/4] registry: use RegCloseKey for RequestKey and ParametersKey
Date: Fri, 13 Feb 2026 13:50:09 +0000
Message-ID: <20260213135013.1136-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

CloseHandle silently fails for HKEY.

Signed-off-by: david ambu <david.preetham@cloud.com>

Refactored to before other patches

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 1154de5..347bef0 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1502,7 +1502,7 @@ done:
     free(Context->Question);
     free(Context->Text);
     free(Context->Title);
-    CloseHandle(Context->RequestKey);
+    RegCloseKey(Context->RequestKey);
     free(RequestKeyName);
     CloseHandle(Context->ResponseEvent);
     CloseHandle(Context->RequestEvent);
@@ -1512,7 +1512,7 @@ done:
 
     (VOID) DeregisterEventSource(Context->EventLog);
 
-    CloseHandle(Context->ParametersKey);
+    RegCloseKey(Context->ParametersKey);
     (VOID) RemoveStartOverride("stornvme");
 
     Log("<====");
@@ -1530,7 +1530,7 @@ fail11:
 fail10:
     Log("fail10");
 
-    CloseHandle(Context->RequestKey);
+    RegCloseKey(Context->RequestKey);
 
 fail9:
     Log("fail9");
@@ -1568,7 +1568,7 @@ fail3:
 fail2:
     Log("fail2");
 
-    CloseHandle(Context->ParametersKey);
+    RegCloseKey(Context->ParametersKey);
 
 fail1:
     Error = GetLastError();
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 13:50:20 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 13:50:20 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1231004.1536354 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtYq-0005jU-1u; Fri, 13 Feb 2026 13:50:20 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1231004.1536354; Fri, 13 Feb 2026 13:50:20 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtYp-0005jN-VG; Fri, 13 Feb 2026 13:50:19 +0000
Received: by outflank-mailman (input) for mailman id 1231004;
 Fri, 13 Feb 2026 13:50:19 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=wBIX=AR=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vqtYp-0004hN-Do
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 13:50:19 +0000
Received: from na1pdmzitismtp02.tibco.com (unknown [160.101.131.9])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id ee40496d-08e2-11f1-b163-2bf370ae4941;
 Fri, 13 Feb 2026 14:50:18 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id EF49781D391E;
 Fri, 13 Feb 2026 08:49:52 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ee40496d-08e2-11f1-b163-2bf370ae4941
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>,
	david ambu <david.preetham@cloud.com>
Subject: [PATCH 2/4] Replace RegisterEventSource with TraceLoggingRegister
Date: Fri, 13 Feb 2026 13:50:10 +0000
Message-ID: <20260213135013.1136-2-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <20260213135013.1136-1-owen.smith@citrix.com>
References: <20260213135013.1136-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

- Added TraceLogging levels for Information and Error events.
- Replaced RegisterEventSource due to potential security issues.
  This issue was raised by CodeQL 2.20.1,
  "RegisterEventSourceA has been marked deprecated as it is a legacy
   tracing API. Please migrate to modern Event Tracing for Windows APIs."
see: https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/28735-banned-crimson-api-usage

  Event Tracing logging needs to be captured using an ETW trace logger

Signed-off-by: david ambu <david.preetham@cloud.com>

* defined seperate macros for Info and Error logging
* use a switch on log level, rather than if/else
* Change __Log call to take a PCTSTR, and wrap format string with _T() in macros

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 300 ++++++++++++++++++++++--------------------
 1 file changed, 157 insertions(+), 143 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 347bef0..49b05ad 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -40,6 +40,8 @@
 #include <powrprof.h>
 #include <malloc.h>
 #include <assert.h>
+#include <TraceLoggingProvider.h>
+#include <winmeta.h>
 
 #include <version.h>
 
@@ -56,7 +58,6 @@ typedef struct _MONITOR_CONTEXT {
     SERVICE_STATUS          Status;
     SERVICE_STATUS_HANDLE   Service;
     HKEY                    ParametersKey;
-    HANDLE                  EventLog;
     HANDLE                  StopEvent;
     HANDLE                  RequestEvent;
     HANDLE                  Timer;
@@ -90,17 +91,30 @@ MONITOR_CONTEXT MonitorContext;
 #define PARAMETERS_KEY(_Service) \
         SERVICE_KEY(_Service) ## "\\Parameters"
 
+TRACELOGGING_DEFINE_PROVIDER(MonitorTraceLoggingProvider,
+                             MONITOR_NAME,
+                             //{54F99C5B-76EC-5F84-3F97-4C9F40AA0F1A}
+                             (0x54f99c5b, 0x76ec, 0x5f84, 0x3f, 0x97, 0x4c, 0x9f, 0x40, 0xaa, 0x0f, 0x1a));
+
+typedef enum {
+    LOG_INFO,
+    LOG_ERROR
+} LOG_LEVEL;
+
+#ifdef UNICODE
+#define TraceLoggingStringT(_buf, _name)    TraceLoggingWideString(_buf, _name)
+#else
+#define TraceLoggingStringT(_buf, _name)    TraceLoggingString(_buf, _name)
+#endif
+
 static VOID
 #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
 __Log(
-    _In_ PCSTR          Format,
+    _In_ LOG_LEVEL      Level,
+    _In_ PCTSTR         Format,
     ...
     )
 {
-#if DBG
-    PMONITOR_CONTEXT    Context = &MonitorContext;
-    const TCHAR         *Strings[1];
-#endif
     TCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
     va_list             Arguments;
     size_t              Length;
@@ -121,30 +135,35 @@ __Log(
 
     _Analysis_assume_(Length < MAXIMUM_BUFFER_SIZE);
     _Analysis_assume_(Length >= 2);
-    Buffer[Length] = '\0';
-    Buffer[Length - 1] = '\n';
-    Buffer[Length - 2] = '\r';
+    Buffer[Length] = _T('\0');
+    Buffer[Length - 1] = _T('\n');
+    Buffer[Length - 2] = _T('\r');
 
     OutputDebugString(Buffer);
 
-#if DBG
-    Strings[0] = Buffer;
-
-    if (Context->EventLog != NULL)
-        ReportEvent(Context->EventLog,
-                    EVENTLOG_INFORMATION_TYPE,
-                    0,
-                    MONITOR_LOG,
-                    NULL,
-                    ARRAYSIZE(Strings),
-                    0,
-                    Strings,
-                    NULL);
-#endif
+    switch (Level) {
+    case LOG_INFO:
+        TraceLoggingWrite(MonitorTraceLoggingProvider,
+                          "Information",
+                          TraceLoggingLevel(WINEVENT_LEVEL_INFO),
+                          TraceLoggingStringT(Buffer, "Info"));
+        break;
+    case LOG_ERROR:
+        TraceLoggingWrite(MonitorTraceLoggingProvider,
+                          "Error",
+                          TraceLoggingLevel(WINEVENT_LEVEL_ERROR),
+                          TraceLoggingStringT(Buffer, "Error"));
+        break;
+    default:
+        break;
+    }
 }
 
-#define Log(_Format, ...) \
-        __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
+#define LogInfo(_Format, ...) \
+        __Log(LOG_INFO, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
+
+#define LogError(_Format, ...) \
+        __Log(LOG_ERROR, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
 
 static PTSTR
 GetErrorMessage(
@@ -209,7 +228,7 @@ ReportStatus(
     BOOL                Success;
     HRESULT             Error;
 
-    Log("====> (%s)", ServiceStateName(CurrentState));
+    LogInfo("====> (%s)", ServiceStateName(CurrentState));
 
     Context->Status.dwCurrentState = CurrentState;
     Context->Status.dwWin32ExitCode = Win32ExitCode;
@@ -233,7 +252,7 @@ ReportStatus(
     if (!Success)
         goto fail1;
 
-    Log("<====");
+    LogInfo("<====");
 
     return;
 
@@ -243,7 +262,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -320,11 +339,11 @@ DoReboot(
     _In_ DWORD  Timeout
     )
 {
-    Log("waiting for pending install events...");
+    LogInfo("waiting for pending install events...");
 
     (VOID) CM_WaitNoPendingInstallEvents(INFINITE);
 
-    Log("initiating shutdown...");
+    LogInfo("initiating shutdown...");
 
 #pragma prefast(suppress:28159)
     (VOID) InitiateSystemShutdownEx(NULL,
@@ -360,7 +379,7 @@ GetPromptTimeout(
         Type != REG_DWORD)
         Value = 0;
 
-    Log("%u", Value);
+    LogInfo("%u", Value);
 
     return Value;
 }
@@ -439,18 +458,18 @@ GetDisplayName(
     return DisplayName;
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
     free(DisplayName);
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     RegCloseKey(ServiceKey);
 
@@ -460,7 +479,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -525,10 +544,10 @@ DoPromptForReboot(
         WTS_CONNECTSTATE_CLASS  State = SessionInfo[Index].State;
         DWORD                   Response;
 
-        Log("[%u]: %s [%s]",
-            SessionId,
-            Name,
-            WTSStateName(State));
+        LogInfo("[%u]: %s [%s]",
+                SessionId,
+                Name,
+                WTSStateName(State));
 
         if (State != WTSActive)
             continue;
@@ -559,7 +578,7 @@ DoPromptForReboot(
     return ERROR_SUCCESS;
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
     *Prompt->PResponse = 0;
 
 fail1:
@@ -592,7 +611,7 @@ PromptForReboot(
         return;
     Context->RebootPrompted = TRUE;
 
-    Log("====> (%s)", DriverName);
+    LogInfo("====> (%s)", DriverName);
 
     Prompt = calloc(1, sizeof (REBOOT_PROMPT));
     if (Prompt == NULL) {
@@ -659,20 +678,20 @@ PromptForReboot(
     return;
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
     free(DisplayName);
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -766,9 +785,9 @@ TryAutoReboot(
     if (RebootCount >= AutoReboot)
         goto prompt;
 
-    Log("AutoRebooting (reboot %u of %u)\n",
-        RebootCount,
-        AutoReboot);
+    LogInfo("AutoRebooting (reboot %u of %u)\n",
+            RebootCount,
+            AutoReboot);
 
     ++RebootCount;
 
@@ -838,18 +857,18 @@ done:
     return;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(DisplayName);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -870,7 +889,7 @@ CheckRequestSubKeys(
     HKEY                SubKey;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     Error = RegQueryInfoKey(Context->RequestKey,
                             NULL,
@@ -916,7 +935,7 @@ CheckRequestSubKeys(
             goto fail3;
         }
 
-        Log("%s", SubKeyName);
+        LogInfo("%s", SubKeyName);
 
         Error = RegOpenKeyEx(Context->RequestKey,
                              SubKeyName,
@@ -960,17 +979,17 @@ found:
 done:
     free(SubKeyName);
 
-    Log("<====");
+    LogInfo("<====");
 
     return;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(SubKeyName);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -978,7 +997,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -991,7 +1010,7 @@ CheckRequestKey(
     PMONITOR_CONTEXT    Context = &MonitorContext;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     CheckRequestSubKeys();
 
@@ -1004,7 +1023,7 @@ CheckRequestKey(
     if (Error != ERROR_SUCCESS)
         goto fail1;
 
-    Log("<====");
+    LogInfo("<====");
 
     return;
 
@@ -1014,7 +1033,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -1029,7 +1048,7 @@ AcquireShutdownPrivilege(
     BOOL                Success;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     New.PrivilegeCount = 1;
 
@@ -1061,17 +1080,17 @@ AcquireShutdownPrivilege(
 
     CloseHandle(Token);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     CloseHandle(Token);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1079,7 +1098,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1137,20 +1156,20 @@ GetRequestKeyName(
         goto fail4;
     }
 
-    Log("%s", *RequestKeyName);
+    LogInfo("%s", *RequestKeyName);
 
     return TRUE;
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(*RequestKeyName);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1158,7 +1177,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1264,37 +1283,37 @@ GetDialogParameters(
     return TRUE;
 
 fail10:
-    Log("fail10");
+    LogError("fail10");
 
 fail9:
-    Log("fail9");
+    LogError("fail9");
 
     free(Context->Question);
 
 fail8:
-    Log("fail8");
+    LogError("fail8");
 
 fail7:
-    Log("fail7");
+    LogError("fail7");
 
 fail6:
-    Log("fail6");
+    LogError("fail6");
 
     free(Context->Text);
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(Context->Title);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1302,7 +1321,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1335,7 +1354,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1357,7 +1376,10 @@ MonitorMain(
     UNREFERENCED_PARAMETER(argc);
     UNREFERENCED_PARAMETER(argv);
 
-    Log("====>");
+    if (TraceLoggingRegister(MonitorTraceLoggingProvider) != ERROR_SUCCESS)
+        LogInfo("TraceLoggingRegister failed");
+
+    LogInfo("====>");
 
     (VOID) RemoveStartOverride("stornvme");
 
@@ -1379,11 +1401,6 @@ MonitorMain(
     if (Context->Service == NULL)
         goto fail3;
 
-    Context->EventLog = RegisterEventSource(NULL,
-                                            MONITOR_NAME);
-    if (Context->EventLog == NULL)
-        goto fail4;
-
     Context->Status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
     Context->Status.dwServiceSpecificExitCode = 0;
 
@@ -1395,26 +1412,26 @@ MonitorMain(
                                      NULL);
 
     if (Context->StopEvent == NULL)
-        goto fail5;
+        goto fail4;
 
     Context->RequestEvent = CreateEvent(NULL,
                                         TRUE,
                                         FALSE,
                                         NULL);
     if (Context->RequestEvent == NULL)
-        goto fail6;
+        goto fail5;
 
     Context->ResponseEvent = CreateEvent(NULL,
                                          FALSE,
                                          FALSE,
                                          NULL);
     if (Context->ResponseEvent == NULL)
-        goto fail7;
+        goto fail6;
     Context->Response = 0;
 
     Success = GetRequestKeyName(&RequestKeyName);
     if (!Success)
-        goto fail8;
+        goto fail7;
 
     Error = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
                            RequestKeyName,
@@ -1426,15 +1443,15 @@ MonitorMain(
                            &Context->RequestKey,
                            NULL);
     if (Error != ERROR_SUCCESS)
-        goto fail9;
+        goto fail8;
 
     Success = GetDialogParameters();
     if (!Success)
-        goto fail10;
+        goto fail9;
 
     Context->Timer = CreateWaitableTimer(NULL, FALSE, NULL);
     if (Context->Timer == NULL)
-        goto fail11;
+        goto fail10;
 
     DueTime.QuadPart = -10000LL * REBOOT_RETRY_DELAY;
 
@@ -1445,7 +1462,7 @@ MonitorMain(
                                NULL,
                                FALSE);
     if (!Success)
-        goto fail12;
+        goto fail11;
 
     SetEvent(Context->RequestEvent);
 
@@ -1460,12 +1477,12 @@ MonitorMain(
         Events[2] = Context->ResponseEvent;
         Events[3] = Context->Timer;
 
-        Log("waiting (%u)...", ARRAYSIZE(Events));
+        LogInfo("waiting (%u)...", ARRAYSIZE(Events));
         Object = WaitForMultipleObjects(ARRAYSIZE(Events),
                                         Events,
                                         FALSE,
                                         INFINITE);
-        Log("awake");
+        LogInfo("awake");
 
         switch (Object) {
         case WAIT_OBJECT_0:
@@ -1510,63 +1527,58 @@ done:
 
     ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
 
-    (VOID) DeregisterEventSource(Context->EventLog);
-
     RegCloseKey(Context->ParametersKey);
     (VOID) RemoveStartOverride("stornvme");
 
-    Log("<====");
+    LogInfo("<====");
+
+    TraceLoggingUnregister(MonitorTraceLoggingProvider);
 
     return;
 
-fail12:
-    Log("fail12");
+fail11:
+    LogError("fail11");
 
     CloseHandle(Context->Timer);
 
-fail11:
-    Log("fail11");
-
 fail10:
-    Log("fail10");
-
-    RegCloseKey(Context->RequestKey);
+    LogError("fail10");
 
 fail9:
-    Log("fail9");
+    LogError("fail9");
 
-    free(RequestKeyName);
+    RegCloseKey(Context->RequestKey);
 
 fail8:
-    Log("fail8");
+    LogError("fail8");
 
-    CloseHandle(Context->ResponseEvent);
+    free(RequestKeyName);
 
 fail7:
-    Log("fail7");
+    LogError("fail7");
 
-    CloseHandle(Context->RequestEvent);
+    CloseHandle(Context->ResponseEvent);
 
 fail6:
-    Log("fail6");
+    LogError("fail6");
 
-    CloseHandle(Context->StopEvent);
+    CloseHandle(Context->RequestEvent);
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
-    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
-
-    (VOID) DeregisterEventSource(Context->EventLog);
+    CloseHandle(Context->StopEvent);
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
+
+    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     RegCloseKey(Context->ParametersKey);
 
@@ -1576,9 +1588,11 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
+
+    TraceLoggingUnregister(MonitorTraceLoggingProvider);
 }
 
 static BOOL
@@ -1591,7 +1605,7 @@ MonitorCreate(
     TCHAR       Path[MAX_PATH];
     HRESULT     Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     if(!GetModuleFileName(NULL, Path, MAX_PATH))
         goto fail1;
@@ -1623,17 +1637,17 @@ MonitorCreate(
     CloseServiceHandle(Service);
     CloseServiceHandle(SCManager);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     CloseServiceHandle(SCManager);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1641,7 +1655,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1659,7 +1673,7 @@ MonitorDelete(
     SERVICE_STATUS      Status;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     SCManager = OpenSCManager(NULL,
                               NULL,
@@ -1690,20 +1704,20 @@ MonitorDelete(
     CloseServiceHandle(Service);
     CloseServiceHandle(SCManager);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     CloseServiceHandle(Service);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     CloseServiceHandle(SCManager);
 
@@ -1713,7 +1727,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1731,16 +1745,16 @@ MonitorEntry(
     };
     HRESULT             Error;
 
-    Log("%s (%s) ====>",
-        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-        DAY_STR "/" MONTH_STR "/" YEAR_STR);
+    LogInfo("%s (%s) ====>",
+            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
+            DAY_STR "/" MONTH_STR "/" YEAR_STR);
 
     if (!StartServiceCtrlDispatcher(Table))
         goto fail1;
 
-    Log("%s (%s) <====",
-        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-        DAY_STR "/" MONTH_STR "/" YEAR_STR);
+    LogInfo("%s (%s) <====",
+            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
+            DAY_STR "/" MONTH_STR "/" YEAR_STR);
 
     return TRUE;
 
@@ -1750,7 +1764,7 @@ fail1:
     {
         PTSTR   Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 13:50:22 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 13:50:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1231005.1536357 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtYs-0005lU-31; Fri, 13 Feb 2026 13:50:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1231005.1536357; Fri, 13 Feb 2026 13:50:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtYs-0005lN-0J; Fri, 13 Feb 2026 13:50:22 +0000
Received: by outflank-mailman (input) for mailman id 1231005;
 Fri, 13 Feb 2026 13:50:21 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=wBIX=AR=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vqtYr-0005hT-Ap
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 13:50:21 +0000
Received: from na1pdmzitismtp02.tibco.com (na1pdmzitismtp02.tibco.com
 [160.101.131.9]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id eea7cf1e-08e2-11f1-9ccf-f158ae23cfc8;
 Fri, 13 Feb 2026 14:50:19 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id A6E3381D3BB8;
 Fri, 13 Feb 2026 08:49:53 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: eea7cf1e-08e2-11f1-9ccf-f158ae23cfc8
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 3/4] Fix inconsistent TCHAR handling
Date: Fri, 13 Feb 2026 13:50:11 +0000
Message-ID: <20260213135013.1136-3-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <20260213135013.1136-1-owen.smith@citrix.com>
References: <20260213135013.1136-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

* Wrap strings with _T()
* Fix ServiceStateName and WTSStateName to return PCTSTR
* Use 'Length' for character counts, and 'Size' for byte counts
  when calling StringCch* and StringCb* functions
* Fix _tWinMain to use LPTSTR

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c | 174 +++++++++++++++++++++---------------------
 1 file changed, 86 insertions(+), 88 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 49b05ad..c568d54 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -184,9 +184,9 @@ GetErrorMessage(
                        NULL))
         return NULL;
 
-    for (Index = 0; Message[Index] != '\0'; Index++) {
-        if (Message[Index] == '\r' || Message[Index] == '\n') {
-            Message[Index] = '\0';
+    for (Index = 0; Message[Index] != _T('\0'); Index++) {
+        if (Message[Index] == _T('\r') || Message[Index] == _T('\n')) {
+            Message[Index] = _T('\0');
             break;
         }
     }
@@ -194,14 +194,14 @@ GetErrorMessage(
     return Message;
 }
 
-static PCSTR
+static PCTSTR
 ServiceStateName(
     _In_ DWORD  State
     )
 {
 #define _STATE_NAME(_State) \
     case SERVICE_ ## _State: \
-        return #_State
+        return _T(#_State)
 
     switch (State) {
     _STATE_NAME(START_PENDING);
@@ -212,7 +212,7 @@ ServiceStateName(
         break;
     }
 
-    return "UNKNOWN";
+    return _T("UNKNOWN");
 
 #undef  _STATE_NAME
 }
@@ -304,14 +304,14 @@ MonitorCtrlHandlerEx(
     return ERROR_CALL_NOT_IMPLEMENTED;
 }
 
-static PCSTR
+static PCTSTR
 WTSStateName(
     _In_ DWORD  State
     )
 {
 #define _STATE_NAME(_State) \
     case WTS ## _State: \
-        return #_State
+        return _T(#_State)
 
     switch (State) {
     _STATE_NAME(Active);
@@ -328,7 +328,7 @@ WTSStateName(
         break;
     }
 
-    return "UNKNOWN";
+    return _T("UNKNOWN");
 
 #undef  _STATE_NAME
 }
@@ -370,7 +370,7 @@ GetPromptTimeout(
     ValueLength = sizeof (Value);
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "PromptTimeout",
+                            _T("PromptTimeout"),
                             NULL,
                             &Type,
                             (LPBYTE)&Value,
@@ -400,7 +400,7 @@ GetDisplayName(
 
     Result = StringCbPrintf(ServiceKeyName,
                             MAX_PATH,
-                            SERVICES_KEY "\\%s",
+                            _T(SERVICES_KEY "\\%s"),
                             DriverName);
     assert(SUCCEEDED(Result));
 
@@ -438,7 +438,7 @@ GetDisplayName(
         goto fail3;
 
     Error = RegQueryValueEx(ServiceKey,
-                            "DisplayName",
+                            _T("DisplayName"),
                             NULL,
                             &Type,
                             (LPBYTE)DisplayName,
@@ -519,10 +519,8 @@ DoPromptForReboot(
 
     Error = ERROR_SUCCESS;
 
-    TitleLength = (DWORD)((_tcslen(Prompt->Title) +
-                           1) * sizeof (TCHAR));
-    TextLength = (DWORD)((_tcslen(Prompt->Text) +
-                           1) * sizeof (TCHAR));
+    TitleLength = (DWORD)(_tcslen(Prompt->Title) + 1);
+    TextLength = (DWORD)(_tcslen(Prompt->Text) + 1);
 
     Success = WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
                                    0,
@@ -555,9 +553,9 @@ DoPromptForReboot(
         Success = WTSSendMessage(WTS_CURRENT_SERVER_HANDLE,
                                  SessionId,
                                  Prompt->Title,
-                                 TitleLength,
+                                 TitleLength * sizeof(TCHAR),
                                  Prompt->Text,
-                                 TextLength,
+                                 TextLength * sizeof(TCHAR),
                                  MB_YESNO | MB_ICONEXCLAMATION,
                                  Timeout,
                                  &Response,
@@ -639,25 +637,25 @@ PromptForReboot(
     else
         Description++;
 
-    TextLength = (DWORD)((_tcslen(Description) +
-                          1 + // ' '
-                          _tcslen(Context->Text) +
-                          1 + // ' '
-                          _tcslen(Context->Question) +
-                          1) * sizeof (TCHAR));
+    TextLength = (DWORD)(_tcslen(Description) +
+                         1 + // ' '
+                         _tcslen(Context->Text) +
+                         1 + // ' '
+                         _tcslen(Context->Question) +
+                         1);
 
-    Prompt->Text = calloc(1, TextLength);
+    Prompt->Text = calloc(1, TextLength * sizeof(TCHAR));
     if (Prompt->Text == NULL) {
         Error = ERROR_OUTOFMEMORY;
         goto fail4;
     }
 
-    Result = StringCbPrintf(Prompt->Text,
-                            TextLength,
-                            TEXT("%s %s %s"),
-                            Description,
-                            Context->Text,
-                            Context->Question);
+    Result = StringCchPrintf(Prompt->Text,
+                             TextLength,
+                             TEXT("%s %s %s"),
+                             Description,
+                             Context->Text,
+                             Context->Question);
     assert(SUCCEEDED(Result));
 
     PromptThread = CreateThread(NULL,
@@ -758,7 +756,7 @@ TryAutoReboot(
     Length = sizeof (DWORD);
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "AutoReboot",
+                            _T("AutoReboot"),
                             NULL,
                             &Type,
                             (LPBYTE)&AutoReboot,
@@ -773,7 +771,7 @@ TryAutoReboot(
     Length = sizeof (DWORD);
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "RebootCount",
+                            _T("RebootCount"),
                             NULL,
                             &Type,
                             (LPBYTE)&RebootCount,
@@ -792,7 +790,7 @@ TryAutoReboot(
     ++RebootCount;
 
     (VOID) RegSetValueEx(Context->ParametersKey,
-                         "RebootCount",
+                         _T("RebootCount"),
                          0,
                          REG_DWORD,
                          (const BYTE*)&RebootCount,
@@ -801,7 +799,7 @@ TryAutoReboot(
     (VOID) RegFlushKey(Context->ParametersKey);
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "AutoRebootTimeout",
+                            _T("AutoRebootTimeout"),
                             NULL,
                             &Type,
                             (LPBYTE)&Timeout,
@@ -822,22 +820,22 @@ TryAutoReboot(
     else
         Description++;
 
-    TextLength = (DWORD)((_tcslen(Description) +
-                          1 + // ' '
-                          _tcslen(Context->Text) +
-                          1) * sizeof (TCHAR));
+    TextLength = (DWORD)(_tcslen(Description) +
+                         1 + // ' '
+                         _tcslen(Context->Text) +
+                         1);
 
-    Text = calloc(1, TextLength);
+    Text = calloc(1, TextLength * sizeof(TCHAR));
     if (Text == NULL) {
         SetLastError(ERROR_OUTOFMEMORY);
         goto fail3;
     }
 
-    Result = StringCbPrintf(Text,
-                            TextLength,
-                            TEXT("%s %s"),
-                            Description,
-                            Context->Text);
+    Result = StringCchPrintf(Text,
+                             TextLength,
+                             TEXT("%s %s"),
+                             Description,
+                             Context->Text);
     assert(SUCCEEDED(Result));
 
     free(DisplayName);
@@ -908,9 +906,9 @@ CheckRequestSubKeys(
         goto fail1;
     }
 
-    SubKeyLength = MaxSubKeyLength + sizeof (TCHAR);
+    SubKeyLength = MaxSubKeyLength + 1;
 
-    SubKeyName = calloc(1, SubKeyLength);
+    SubKeyName = calloc(1, SubKeyLength * sizeof(TCHAR));
     if (SubKeyName == NULL)
         goto fail2;
 
@@ -919,8 +917,8 @@ CheckRequestSubKeys(
         DWORD   Type;
         DWORD   Reboot;
 
-        SubKeyLength = MaxSubKeyLength + sizeof (TCHAR);
-        memset(SubKeyName, 0, SubKeyLength);
+        SubKeyLength = MaxSubKeyLength + 1;
+        memset(SubKeyName, 0, SubKeyLength * sizeof(TCHAR));
 
         Error = RegEnumKeyEx(Context->RequestKey,
                              Index,
@@ -947,7 +945,7 @@ CheckRequestSubKeys(
 
         Length = sizeof (DWORD);
         Error = RegQueryValueEx(SubKey,
-                                "Reboot",
+                                _T("Reboot"),
                                 NULL,
                                 &Type,
                                 (LPBYTE)&Reboot,
@@ -964,7 +962,7 @@ loop:
     }
 
     Error = RegDeleteValue(Context->ParametersKey,
-                           "RebootCount");
+                           _T("RebootCount"));
     if (Error == ERROR_SUCCESS)
         (VOID) RegFlushKey(Context->ParametersKey);
 
@@ -1113,7 +1111,7 @@ GetRequestKeyName(
 {
     PMONITOR_CONTEXT            Context = &MonitorContext;
     DWORD                       MaxValueLength;
-    DWORD                       RequestKeyNameLength;
+    DWORD                       RequestKeyNameSize;
     DWORD                       Type;
     HRESULT                     Error;
 
@@ -1134,18 +1132,18 @@ GetRequestKeyName(
         goto fail1;
     }
 
-    RequestKeyNameLength = MaxValueLength + sizeof (TCHAR);
+    RequestKeyNameSize = (MaxValueLength + 1) * sizeof(TCHAR);
 
-    *RequestKeyName = calloc(1, RequestKeyNameLength);
+    *RequestKeyName = calloc(1, RequestKeyNameSize);
     if (*RequestKeyName == NULL)
         goto fail2;
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "RequestKey",
+                            _T("RequestKey"),
                             NULL,
                             &Type,
                             (LPBYTE)(*RequestKeyName),
-                            &RequestKeyNameLength);
+                            &RequestKeyNameSize);
     if (Error != ERROR_SUCCESS) {
         SetLastError(Error);
         goto fail3;
@@ -1191,9 +1189,9 @@ GetDialogParameters(
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
     DWORD               MaxValueLength;
-    DWORD               TitleLength;
-    DWORD               TextLength;
-    DWORD               QuestionLength;
+    DWORD               TitleSize;
+    DWORD               TextSize;
+    DWORD               QuestionSize;
     DWORD               Type;
     HRESULT             Error;
 
@@ -1214,18 +1212,18 @@ GetDialogParameters(
         goto fail1;
     }
 
-    TitleLength = MaxValueLength + sizeof (TCHAR);
+    TitleSize = (MaxValueLength + 1) * sizeof(TCHAR);
 
-    Context->Title = calloc(1, TitleLength);
+    Context->Title = calloc(1, TitleSize);
     if (Context == NULL)
         goto fail2;
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "DialogTitle",
+                            _T("DialogTitle"),
                             NULL,
                             &Type,
                             (LPBYTE)Context->Title,
-                            &TitleLength);
+                            &TitleSize);
     if (Error != ERROR_SUCCESS) {
         SetLastError(Error);
         goto fail3;
@@ -1236,18 +1234,18 @@ GetDialogParameters(
         goto fail4;
     }
 
-    TextLength = MaxValueLength + sizeof (TCHAR);
+    TextSize = (MaxValueLength + 1) * sizeof (TCHAR);
 
-    Context->Text = calloc(1, TextLength);
+    Context->Text = calloc(1, TextSize);
     if (Context == NULL)
         goto fail5;
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "DialogText",
+                            _T("DialogText"),
                             NULL,
                             &Type,
                             (LPBYTE)Context->Text,
-                            &TextLength);
+                            &TextSize);
     if (Error != ERROR_SUCCESS) {
         SetLastError(Error);
         goto fail6;
@@ -1258,18 +1256,18 @@ GetDialogParameters(
         goto fail7;
     }
 
-    QuestionLength = MaxValueLength + sizeof (TCHAR);
+    QuestionSize = (MaxValueLength + 1) * sizeof (TCHAR);
 
-    Context->Question = calloc(1, QuestionLength);
+    Context->Question = calloc(1, QuestionSize);
     if (Context == NULL)
         goto fail8;
 
     Error = RegQueryValueEx(Context->ParametersKey,
-                            "DialogQuestion",
+                            _T("DialogQuestion"),
                             NULL,
                             &Type,
                             (LPBYTE)Context->Question,
-                            &QuestionLength);
+                            &QuestionSize);
     if (Error != ERROR_SUCCESS) {
         SetLastError(Error);
         goto fail9;
@@ -1336,10 +1334,10 @@ RemoveStartOverride(
     TCHAR               KeyName[MAX_PATH];
     HRESULT             Error;
 
-    Error = StringCbPrintf(KeyName,
-                           MAX_PATH,
-                           SERVICES_KEY "\\%s\\StartOverride",
-                           DriverName);
+    Error = StringCchPrintf(KeyName,
+                            MAX_PATH,
+                            _T(SERVICES_KEY "\\%s\\StartOverride"),
+                            DriverName);
     assert(SUCCEEDED(Error));
 
     Error = RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
@@ -1381,10 +1379,10 @@ MonitorMain(
 
     LogInfo("====>");
 
-    (VOID) RemoveStartOverride("stornvme");
+    (VOID) RemoveStartOverride(_T("stornvme"));
 
     Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
-                         PARAMETERS_KEY(__MODULE__),
+                         _T(PARAMETERS_KEY(__MODULE__)),
                          0,
                          KEY_READ,
                          &Context->ParametersKey);
@@ -1395,7 +1393,7 @@ MonitorMain(
     if (!Success)
         goto fail2;
 
-    Context->Service = RegisterServiceCtrlHandlerEx(MONITOR_NAME,
+    Context->Service = RegisterServiceCtrlHandlerEx(_T(MONITOR_NAME),
                                                     MonitorCtrlHandlerEx,
                                                     NULL);
     if (Context->Service == NULL)
@@ -1528,7 +1526,7 @@ done:
     ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
 
     RegCloseKey(Context->ParametersKey);
-    (VOID) RemoveStartOverride("stornvme");
+    (VOID) RemoveStartOverride(_T("stornvme"));
 
     LogInfo("<====");
 
@@ -1618,8 +1616,8 @@ MonitorCreate(
         goto fail2;
 
     Service = CreateService(SCManager,
-                            MONITOR_NAME,
-                            MONITOR_DISPLAYNAME,
+                            _T(MONITOR_NAME),
+                            _T(MONITOR_DISPLAYNAME),
                             SERVICE_ALL_ACCESS,
                             SERVICE_WIN32_OWN_PROCESS,
                             SERVICE_AUTO_START,
@@ -1683,7 +1681,7 @@ MonitorDelete(
         goto fail1;
 
     Service = OpenService(SCManager,
-                          MONITOR_NAME,
+                          _T(MONITOR_NAME),
                           SERVICE_ALL_ACCESS);
 
     if (Service == NULL)
@@ -1740,21 +1738,21 @@ MonitorEntry(
     )
 {
     SERVICE_TABLE_ENTRY Table[] = {
-        { MONITOR_NAME, MonitorMain },
+        { _T(MONITOR_NAME), MonitorMain },
         { NULL, NULL }
     };
     HRESULT             Error;
 
     LogInfo("%s (%s) ====>",
-            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-            DAY_STR "/" MONTH_STR "/" YEAR_STR);
+            _T(MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR),
+            _T(DAY_STR "/" MONTH_STR "/" YEAR_STR));
 
     if (!StartServiceCtrlDispatcher(Table))
         goto fail1;
 
     LogInfo("%s (%s) <====",
-            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-            DAY_STR "/" MONTH_STR "/" YEAR_STR);
+            _T(MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR),
+            _T(DAY_STR "/" MONTH_STR "/" YEAR_STR));
 
     return TRUE;
 
@@ -1775,7 +1773,7 @@ int CALLBACK
 _tWinMain(
     _In_        HINSTANCE   Current,
     _In_opt_    HINSTANCE   Previous,
-    _In_        LPSTR       CmdLine,
+    _In_        LPTSTR      CmdLine,
     _In_        int         CmdShow
     )
 {
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 13:50:23 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 13:50:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1231006.1536362 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtYt-0005nT-57; Fri, 13 Feb 2026 13:50:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1231006.1536362; Fri, 13 Feb 2026 13:50:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqtYt-0005nH-2C; Fri, 13 Feb 2026 13:50:23 +0000
Received: by outflank-mailman (input) for mailman id 1231006;
 Fri, 13 Feb 2026 13:50:22 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=wBIX=AR=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vqtYs-0005hT-Ar
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 13:50:22 +0000
Received: from na1pdmzitismtp02.tibco.com (na1pdmzitismtp02.tibco.com
 [160.101.131.9]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id eeff6654-08e2-11f1-9ccf-f158ae23cfc8;
 Fri, 13 Feb 2026 14:50:19 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id 4581281D3BB0;
 Fri, 13 Feb 2026 08:49:54 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: eeff6654-08e2-11f1-9ccf-f158ae23cfc8
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 4/4] Remove StartOverride from all storage adapters
Date: Fri, 13 Feb 2026 13:50:12 +0000
Message-ID: <20260213135013.1136-4-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <20260213135013.1136-1-owen.smith@citrix.com>
References: <20260213135013.1136-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Its possible to install non-Microsoft NVMe drivers on the emulated
NVMe device. During upgrades, the VM requires a reboot using the emulated
devices, but if the driver assigned for the emulated device has a StartOverride
setting, then its likely not started which results in a 0x7B bugcheck.

Also reports SERVICE_STOPPED after clearing any StartOverride values

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/monitor/monitor.c                        | 64 +++++++++++++++++---
 vs2019/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
 vs2022/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
 3 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index c568d54..9bfb1f6 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -42,6 +42,8 @@
 #include <assert.h>
 #include <TraceLoggingProvider.h>
 #include <winmeta.h>
+#include <setupapi.h>
+#include <devguid.h>
 
 #include <version.h>
 
@@ -1326,7 +1328,7 @@ fail1:
     return FALSE;
 }
 
-static BOOL
+static VOID
 RemoveStartOverride(
     _In_ PTSTR          DriverName
     )
@@ -1334,17 +1336,61 @@ RemoveStartOverride(
     TCHAR               KeyName[MAX_PATH];
     HRESULT             Error;
 
+    LogInfo("%s", DriverName);
+
     Error = StringCchPrintf(KeyName,
                             MAX_PATH,
                             _T(SERVICES_KEY "\\%s\\StartOverride"),
                             DriverName);
     assert(SUCCEEDED(Error));
 
-    Error = RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
-    if (Error != ERROR_SUCCESS)
+    (VOID) RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
+}
+
+static VOID
+RemoveStartOverrideForClass(
+    _In_ const GUID*    Guid
+    )
+{
+    HRESULT             Error;
+    HDEVINFO            DevInfo;
+    DWORD               Index;
+    SP_DEVINFO_DATA     DevInfoData;
+
+    DevInfo = SetupDiGetClassDevs(Guid,
+                                  NULL,
+                                  NULL,
+                                  0);
+    if (DevInfo == INVALID_HANDLE_VALUE)
         goto fail1;
 
-    return TRUE;
+    memset(&DevInfoData, 0, sizeof(DevInfoData));
+    DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
+
+    for (Index = 0;
+         SetupDiEnumDeviceInfo(DevInfo, Index, &DevInfoData);
+         ++Index) {
+        TCHAR           Buffer[MAX_PATH];
+        memset(Buffer, 0, sizeof(Buffer));
+
+        if (SetupDiGetDeviceRegistryProperty(DevInfo,
+                                             &DevInfoData,
+                                             SPDRP_SERVICE,
+                                             NULL,
+                                             (PBYTE)Buffer,
+                                             sizeof(Buffer),
+                                             NULL)) {
+            Buffer[MAX_PATH - 1] = _T('\0');
+            RemoveStartOverride(Buffer);
+        }
+
+        memset(&DevInfoData, 0, sizeof(DevInfoData));
+        DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
+    }
+
+    SetupDiDestroyDeviceInfoList(DevInfo);
+
+    return;
 
 fail1:
     Error = GetLastError();
@@ -1355,8 +1401,6 @@ fail1:
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
-
-    return FALSE;
 }
 
 VOID WINAPI
@@ -1379,7 +1423,7 @@ MonitorMain(
 
     LogInfo("====>");
 
-    (VOID) RemoveStartOverride(_T("stornvme"));
+    RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
 
     Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                          _T(PARAMETERS_KEY(__MODULE__)),
@@ -1523,10 +1567,10 @@ done:
     CloseHandle(Context->RequestEvent);
     CloseHandle(Context->StopEvent);
 
-    ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
-
     RegCloseKey(Context->ParametersKey);
-    (VOID) RemoveStartOverride(_T("stornvme"));
+    RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
+
+    ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
 
     LogInfo("<====");
 
diff --git a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
index 3b44e29..df1fd58 100644
--- a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
+++ b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
@@ -34,7 +34,7 @@
       <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <CETCompat>true</CETCompat>
       <GenerateMapFile>true</GenerateMapFile>
       <MapExports>true</MapExports>
diff --git a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
index 484fa1c..196a744 100644
--- a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
+++ b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
@@ -34,7 +34,7 @@
       <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <CETCompat>true</CETCompat>
       <GenerateMapFile>true</GenerateMapFile>
       <MapExports>true</MapExports>
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 14:54:10 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 14:54:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1231155.1536436 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vquYb-0000hX-Af; Fri, 13 Feb 2026 14:54:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1231155.1536436; Fri, 13 Feb 2026 14:54:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vquYb-0000hQ-7o; Fri, 13 Feb 2026 14:54:09 +0000
Received: by outflank-mailman (input) for mailman id 1231155;
 Fri, 13 Feb 2026 14:54:07 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TK4l=AR=bounce.vates.tech=bounce-md_30504962.698f3b07.v1-c9818a5ce451423bb755d2041ec0f1bc@srs-se1.protection.inumbo.net>)
 id 1vquYZ-0000hD-6n
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 14:54:07 +0000
Received: from mail145-20.atl61.mandrillapp.com
 (mail145-20.atl61.mandrillapp.com [198.2.145.20])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id d4e1e891-08eb-11f1-9ccf-f158ae23cfc8;
 Fri, 13 Feb 2026 15:54:01 +0100 (CET)
Received: from pmta06.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail145-20.atl61.mandrillapp.com (Mailchimp) with ESMTP id
 4fCFYM45K3zCf9KNF
 for <win-pv-devel@lists.xenproject.org>; Fri, 13 Feb 2026 14:53:59 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 c9818a5ce451423bb755d2041ec0f1bc; Fri, 13 Feb 2026 14:53:59 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: d4e1e891-08eb-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770994439; x=1771264439;
	bh=Y7MqA5IGpNbu+YlG0Dq6elh5Q8XC/cZaYRKizcHE94s=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=CqNPo4OxV+v6iAnzPFGc+M50IFSaLiXjbNsO9Fn5RQkQoq3mdXc30zFiC8BShUgxe
	 Fz3RfE/gmrXJTyYJpGrN5TuHjTrWvIbez/gL+/7EmYKmumZyNwie4K5UAEvoGw97HP
	 L6JX3enw18CUH2gxJF28eG/nSmdZUIr4Rt90oeOQiWXAdoJprzW679LygFxYil9EaC
	 GecnNGOoEqpUINaNLsnehCGw0bH23J9dlICtwShIBrc7UzQwDmN6S+knv4EL5CrF0f
	 o5NJpje2+GSCgQQQ84SrHq2Ltuit2oRfLZ1ipkXDwDnKgR0rKheF4ERQe+OfIrLbcZ
	 CCC0ybXGGyQGw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770994439; x=1771254939; i=ngoc-tu.dinh@vates.tech;
	bh=Y7MqA5IGpNbu+YlG0Dq6elh5Q8XC/cZaYRKizcHE94s=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=tEANGwMQh7uoW6BFWK3eMn5IFVxoCaJeZlrxA7XDhxOwF+Hhq+hoyv4llUVpPBjnM
	 6ExmDLRuF76KSgvxfNJczTSzhoeV8JHl8lMDVGVkL0gDoHhH/Km0V/nypAlgH05dJg
	 /Vh2Q4GVggDJSXbf+QA3Ko4jzq2yjiVHCCu2Leyb7av3E1pUvqJLKzj3FwVu95gkA3
	 TTIgVdfXDpMpKlJ8ZDuJxMCNGSKDdahpSbzd8zqtUiNmlfjBCMFNpgDiNW1dnjcBrX
	 PqOvWjXUMRX0o/x/VcM3il9LfIAO+csjPfUo51mDpJs+c5r1lMCNogigGQdwvk7jm0
	 F8U9PjpAm6A8A==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=201/4]=20registry:=20use=20RegCloseKey=20for=20RequestKey=20and=20ParametersKey?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770994438360
Message-Id: <554da1cf-3fb4-414b-a6a6-1c3343162f10@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
Cc: "david ambu" <david.preetham@cloud.com>
References: <20260213135013.1136-1-owen.smith@citrix.com>
In-Reply-To: <20260213135013.1136-1-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.c9818a5ce451423bb755d2041ec0f1bc?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260213:md
Date: Fri, 13 Feb 2026 14:53:59 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 13/02/2026 14:50, Owen Smith wrote:
> CloseHandle silently fails for HKEY.
> 
> Signed-off-by: david ambu <david.preetham@cloud.com>
> 
> Refactored to before other patches
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Reviewed-by: Tu Dinh <ngoc-tu.dinh@vates.tech>

> ---
>   src/monitor/monitor.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 1154de5..347bef0 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -1502,7 +1502,7 @@ done:
>       free(Context->Question);
>       free(Context->Text);
>       free(Context->Title);
> -    CloseHandle(Context->RequestKey);
> +    RegCloseKey(Context->RequestKey);
>       free(RequestKeyName);
>       CloseHandle(Context->ResponseEvent);
>       CloseHandle(Context->RequestEvent);
> @@ -1512,7 +1512,7 @@ done:
>   
>       (VOID) DeregisterEventSource(Context->EventLog);
>   
> -    CloseHandle(Context->ParametersKey);
> +    RegCloseKey(Context->ParametersKey);
>       (VOID) RemoveStartOverride("stornvme");
>   
>       Log("<====");
> @@ -1530,7 +1530,7 @@ fail11:
>   fail10:
>       Log("fail10");
>   
> -    CloseHandle(Context->RequestKey);
> +    RegCloseKey(Context->RequestKey);
>   
>   fail9:
>       Log("fail9");
> @@ -1568,7 +1568,7 @@ fail3:
>   fail2:
>       Log("fail2");
>   
> -    CloseHandle(Context->ParametersKey);
> +    RegCloseKey(Context->ParametersKey);
>   
>   fail1:
>       Error = GetLastError();



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 14:55:15 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 14:55:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1231157.1536440 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vquZf-0000nb-Ek; Fri, 13 Feb 2026 14:55:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1231157.1536440; Fri, 13 Feb 2026 14:55:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vquZf-0000nT-BL; Fri, 13 Feb 2026 14:55:15 +0000
Received: by outflank-mailman (input) for mailman id 1231157;
 Fri, 13 Feb 2026 14:55:14 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=w+ia=AR=bounce.vates.tech=bounce-md_30504962.698f3b4d.v1-cc4ee267b2084e69a6aff3a4129b016c@srs-se1.protection.inumbo.net>)
 id 1vquZd-0000nJ-Ra
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 14:55:13 +0000
Received: from mail145-20.atl61.mandrillapp.com
 (mail145-20.atl61.mandrillapp.com [198.2.145.20])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id fe43a89d-08eb-11f1-9ccf-f158ae23cfc8;
 Fri, 13 Feb 2026 15:55:10 +0100 (CET)
Received: from pmta06.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail145-20.atl61.mandrillapp.com (Mailchimp) with ESMTP id
 4fCFZj2CRvzCf9KSK
 for <win-pv-devel@lists.xenproject.org>; Fri, 13 Feb 2026 14:55:09 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 cc4ee267b2084e69a6aff3a4129b016c; Fri, 13 Feb 2026 14:55:09 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fe43a89d-08eb-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770994509; x=1771264509;
	bh=Us/Bri3GbMIFC+c6DKDm8heDEspl8vQo0rBDls5uxJ0=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=WgoA025tlKAyO9S1FXeaMNrCTAxSdh1yX0Z5w0fi1/ee2Nr7rE2bXkS7/Lz6eFIXP
	 p7zprOcYT2f5UT/exhzDf0IqoIY9cu1HLlbslrZ0oNxG0tPCg3s5uklhkl4diGYRf9
	 xoFLvV1jxLAXGl+NbyDyH4N2q5l719ywB99/a0uYqALD6j1jrmUgoPZLnkhlCoFdcV
	 /vrb0SsZFBMva+Bd0zmxaaxo+fGxNW2H7W7DwobF31FOxp/bK8PUWY8z1m/LLhOY1m
	 rh3doPP4GN/T0HRQBttGcZ8lJCBXxIu1xXDAXahLncKC21TYaFbxYPizqqP9McK4DC
	 UTa1YHNioNIUg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770994509; x=1771255009; i=ngoc-tu.dinh@vates.tech;
	bh=Us/Bri3GbMIFC+c6DKDm8heDEspl8vQo0rBDls5uxJ0=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=Au8S76P5Rf/JUC/4Odd10XKucQsttOjbnjqj/YfiRnOS9VVAuyd/0+3pZ3gB4t2Y6
	 h9SatrIW8v9xexwIqLGc8z1fwmmlCYG+mzovIbGiJiJvTF9s2GRuWwRTx9NS2HpwV9
	 ZOiDjcFe/ir/Mwwvmz1p7OOX9fIL2jbHtdS2tEHkwj1H60iE9+mrV3KQsH51F/lpqV
	 bq2vmmXgqHEAz31nxSfwhzyBKhItjAgAJ7AUhwsSmRrJcVozsQNxSYl4sw5jOsEk7D
	 eKFlbZV1mfiIIy5YKKnY1IvxuiRyUeyp98/10h764fIj8VebO4feRgslDk2qyw67VC
	 IRKzZ9gu+xBYg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=202/4]=20Replace=20RegisterEventSource=20with=20TraceLoggingRegister?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770994508399
Message-Id: <88a6a480-154a-44e1-8ad9-c5c3cff886b5@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
Cc: "david ambu" <david.preetham@cloud.com>
References: <20260213135013.1136-1-owen.smith@citrix.com> <20260213135013.1136-2-owen.smith@citrix.com>
In-Reply-To: <20260213135013.1136-2-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.cc4ee267b2084e69a6aff3a4129b016c?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260213:md
Date: Fri, 13 Feb 2026 14:55:09 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 13/02/2026 14:50, Owen Smith wrote:
> - Added TraceLogging levels for Information and Error events.
> - Replaced RegisterEventSource due to potential security issues.
>    This issue was raised by CodeQL 2.20.1,
>    "RegisterEventSourceA has been marked deprecated as it is a legacy
>     tracing API. Please migrate to modern Event Tracing for Windows APIs."
> see: https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/28735-banned-crimson-api-usage
> 
>    Event Tracing logging needs to be captured using an ETW trace logger
> 
> Signed-off-by: david ambu <david.preetham@cloud.com>
> 
> * defined seperate macros for Info and Error logging
> * use a switch on log level, rather than if/else
> * Change __Log call to take a PCTSTR, and wrap format string with _T() in macros
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Reviewed-by: Tu Dinh <ngoc-tu.dinh@vates.tech>

> ---
>   src/monitor/monitor.c | 300 ++++++++++++++++++++++--------------------
>   1 file changed, 157 insertions(+), 143 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 347bef0..49b05ad 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -40,6 +40,8 @@
>   #include <powrprof.h>
>   #include <malloc.h>
>   #include <assert.h>
> +#include <TraceLoggingProvider.h>
> +#include <winmeta.h>
>   
>   #include <version.h>
>   
> @@ -56,7 +58,6 @@ typedef struct _MONITOR_CONTEXT {
>       SERVICE_STATUS          Status;
>       SERVICE_STATUS_HANDLE   Service;
>       HKEY                    ParametersKey;
> -    HANDLE                  EventLog;
>       HANDLE                  StopEvent;
>       HANDLE                  RequestEvent;
>       HANDLE                  Timer;
> @@ -90,17 +91,30 @@ MONITOR_CONTEXT MonitorContext;
>   #define PARAMETERS_KEY(_Service) \
>           SERVICE_KEY(_Service) ## "\\Parameters"
>   
> +TRACELOGGING_DEFINE_PROVIDER(MonitorTraceLoggingProvider,
> +                             MONITOR_NAME,
> +                             //{54F99C5B-76EC-5F84-3F97-4C9F40AA0F1A}
> +                             (0x54f99c5b, 0x76ec, 0x5f84, 0x3f, 0x97, 0x4c, 0x9f, 0x40, 0xaa, 0x0f, 0x1a));
> +
> +typedef enum {
> +    LOG_INFO,
> +    LOG_ERROR
> +} LOG_LEVEL;
> +
> +#ifdef UNICODE
> +#define TraceLoggingStringT(_buf, _name)    TraceLoggingWideString(_buf, _name)
> +#else
> +#define TraceLoggingStringT(_buf, _name)    TraceLoggingString(_buf, _name)
> +#endif
> +
>   static VOID
>   #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
>   __Log(
> -    _In_ PCSTR          Format,
> +    _In_ LOG_LEVEL      Level,
> +    _In_ PCTSTR         Format,
>       ...
>       )
>   {
> -#if DBG
> -    PMONITOR_CONTEXT    Context = &MonitorContext;
> -    const TCHAR         *Strings[1];
> -#endif
>       TCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
>       va_list             Arguments;
>       size_t              Length;
> @@ -121,30 +135,35 @@ __Log(
>   
>       _Analysis_assume_(Length < MAXIMUM_BUFFER_SIZE);
>       _Analysis_assume_(Length >= 2);
> -    Buffer[Length] = '\0';
> -    Buffer[Length - 1] = '\n';
> -    Buffer[Length - 2] = '\r';
> +    Buffer[Length] = _T('\0');
> +    Buffer[Length - 1] = _T('\n');
> +    Buffer[Length - 2] = _T('\r');
>   
>       OutputDebugString(Buffer);
>   
> -#if DBG
> -    Strings[0] = Buffer;
> -
> -    if (Context->EventLog != NULL)
> -        ReportEvent(Context->EventLog,
> -                    EVENTLOG_INFORMATION_TYPE,
> -                    0,
> -                    MONITOR_LOG,
> -                    NULL,
> -                    ARRAYSIZE(Strings),
> -                    0,
> -                    Strings,
> -                    NULL);
> -#endif
> +    switch (Level) {
> +    case LOG_INFO:
> +        TraceLoggingWrite(MonitorTraceLoggingProvider,
> +                          "Information",
> +                          TraceLoggingLevel(WINEVENT_LEVEL_INFO),
> +                          TraceLoggingStringT(Buffer, "Info"));
> +        break;
> +    case LOG_ERROR:
> +        TraceLoggingWrite(MonitorTraceLoggingProvider,
> +                          "Error",
> +                          TraceLoggingLevel(WINEVENT_LEVEL_ERROR),
> +                          TraceLoggingStringT(Buffer, "Error"));
> +        break;
> +    default:
> +        break;
> +    }
>   }
>   
> -#define Log(_Format, ...) \
> -        __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
> +#define LogInfo(_Format, ...) \
> +        __Log(LOG_INFO, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
> +
> +#define LogError(_Format, ...) \
> +        __Log(LOG_ERROR, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
>   
>   static PTSTR
>   GetErrorMessage(
> @@ -209,7 +228,7 @@ ReportStatus(
>       BOOL                Success;
>       HRESULT             Error;
>   
> -    Log("====> (%s)", ServiceStateName(CurrentState));
> +    LogInfo("====> (%s)", ServiceStateName(CurrentState));
>   
>       Context->Status.dwCurrentState = CurrentState;
>       Context->Status.dwWin32ExitCode = Win32ExitCode;
> @@ -233,7 +252,7 @@ ReportStatus(
>       if (!Success)
>           goto fail1;
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return;
>   
> @@ -243,7 +262,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   }
> @@ -320,11 +339,11 @@ DoReboot(
>       _In_ DWORD  Timeout
>       )
>   {
> -    Log("waiting for pending install events...");
> +    LogInfo("waiting for pending install events...");
>   
>       (VOID) CM_WaitNoPendingInstallEvents(INFINITE);
>   
> -    Log("initiating shutdown...");
> +    LogInfo("initiating shutdown...");
>   
>   #pragma prefast(suppress:28159)
>       (VOID) InitiateSystemShutdownEx(NULL,
> @@ -360,7 +379,7 @@ GetPromptTimeout(
>           Type != REG_DWORD)
>           Value = 0;
>   
> -    Log("%u", Value);
> +    LogInfo("%u", Value);
>   
>       return Value;
>   }
> @@ -439,18 +458,18 @@ GetDisplayName(
>       return DisplayName;
>   
>   fail5:
> -    Log("fail5");
> +    LogError("fail5");
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>       free(DisplayName);
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>       RegCloseKey(ServiceKey);
>   
> @@ -460,7 +479,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -525,10 +544,10 @@ DoPromptForReboot(
>           WTS_CONNECTSTATE_CLASS  State = SessionInfo[Index].State;
>           DWORD                   Response;
>   
> -        Log("[%u]: %s [%s]",
> -            SessionId,
> -            Name,
> -            WTSStateName(State));
> +        LogInfo("[%u]: %s [%s]",
> +                SessionId,
> +                Name,
> +                WTSStateName(State));
>   
>           if (State != WTSActive)
>               continue;
> @@ -559,7 +578,7 @@ DoPromptForReboot(
>       return ERROR_SUCCESS;
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>       *Prompt->PResponse = 0;
>   
>   fail1:
> @@ -592,7 +611,7 @@ PromptForReboot(
>           return;
>       Context->RebootPrompted = TRUE;
>   
> -    Log("====> (%s)", DriverName);
> +    LogInfo("====> (%s)", DriverName);
>   
>       Prompt = calloc(1, sizeof (REBOOT_PROMPT));
>       if (Prompt == NULL) {
> @@ -659,20 +678,20 @@ PromptForReboot(
>       return;
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>       free(DisplayName);
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -766,9 +785,9 @@ TryAutoReboot(
>       if (RebootCount >= AutoReboot)
>           goto prompt;
>   
> -    Log("AutoRebooting (reboot %u of %u)\n",
> -        RebootCount,
> -        AutoReboot);
> +    LogInfo("AutoRebooting (reboot %u of %u)\n",
> +            RebootCount,
> +            AutoReboot);
>   
>       ++RebootCount;
>   
> @@ -838,18 +857,18 @@ done:
>       return;
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       free(DisplayName);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -870,7 +889,7 @@ CheckRequestSubKeys(
>       HKEY                SubKey;
>       HRESULT             Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       Error = RegQueryInfoKey(Context->RequestKey,
>                               NULL,
> @@ -916,7 +935,7 @@ CheckRequestSubKeys(
>               goto fail3;
>           }
>   
> -        Log("%s", SubKeyName);
> +        LogInfo("%s", SubKeyName);
>   
>           Error = RegOpenKeyEx(Context->RequestKey,
>                                SubKeyName,
> @@ -960,17 +979,17 @@ found:
>   done:
>       free(SubKeyName);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return;
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       free(SubKeyName);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -978,7 +997,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   }
> @@ -991,7 +1010,7 @@ CheckRequestKey(
>       PMONITOR_CONTEXT    Context = &MonitorContext;
>       HRESULT             Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       CheckRequestSubKeys();
>   
> @@ -1004,7 +1023,7 @@ CheckRequestKey(
>       if (Error != ERROR_SUCCESS)
>           goto fail1;
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return;
>   
> @@ -1014,7 +1033,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   }
> @@ -1029,7 +1048,7 @@ AcquireShutdownPrivilege(
>       BOOL                Success;
>       HRESULT             Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       New.PrivilegeCount = 1;
>   
> @@ -1061,17 +1080,17 @@ AcquireShutdownPrivilege(
>   
>       CloseHandle(Token);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return TRUE;
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       CloseHandle(Token);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -1079,7 +1098,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1137,20 +1156,20 @@ GetRequestKeyName(
>           goto fail4;
>       }
>   
> -    Log("%s", *RequestKeyName);
> +    LogInfo("%s", *RequestKeyName);
>   
>       return TRUE;
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       free(*RequestKeyName);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -1158,7 +1177,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1264,37 +1283,37 @@ GetDialogParameters(
>       return TRUE;
>   
>   fail10:
> -    Log("fail10");
> +    LogError("fail10");
>   
>   fail9:
> -    Log("fail9");
> +    LogError("fail9");
>   
>       free(Context->Question);
>   
>   fail8:
> -    Log("fail8");
> +    LogError("fail8");
>   
>   fail7:
> -    Log("fail7");
> +    LogError("fail7");
>   
>   fail6:
> -    Log("fail6");
> +    LogError("fail6");
>   
>       free(Context->Text);
>   
>   fail5:
> -    Log("fail5");
> +    LogError("fail5");
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       free(Context->Title);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -1302,7 +1321,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1335,7 +1354,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1357,7 +1376,10 @@ MonitorMain(
>       UNREFERENCED_PARAMETER(argc);
>       UNREFERENCED_PARAMETER(argv);
>   
> -    Log("====>");
> +    if (TraceLoggingRegister(MonitorTraceLoggingProvider) != ERROR_SUCCESS)
> +        LogInfo("TraceLoggingRegister failed");
> +
> +    LogInfo("====>");
>   
>       (VOID) RemoveStartOverride("stornvme");
>   
> @@ -1379,11 +1401,6 @@ MonitorMain(
>       if (Context->Service == NULL)
>           goto fail3;
>   
> -    Context->EventLog = RegisterEventSource(NULL,
> -                                            MONITOR_NAME);
> -    if (Context->EventLog == NULL)
> -        goto fail4;
> -
>       Context->Status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
>       Context->Status.dwServiceSpecificExitCode = 0;
>   
> @@ -1395,26 +1412,26 @@ MonitorMain(
>                                        NULL);
>   
>       if (Context->StopEvent == NULL)
> -        goto fail5;
> +        goto fail4;
>   
>       Context->RequestEvent = CreateEvent(NULL,
>                                           TRUE,
>                                           FALSE,
>                                           NULL);
>       if (Context->RequestEvent == NULL)
> -        goto fail6;
> +        goto fail5;
>   
>       Context->ResponseEvent = CreateEvent(NULL,
>                                            FALSE,
>                                            FALSE,
>                                            NULL);
>       if (Context->ResponseEvent == NULL)
> -        goto fail7;
> +        goto fail6;
>       Context->Response = 0;
>   
>       Success = GetRequestKeyName(&RequestKeyName);
>       if (!Success)
> -        goto fail8;
> +        goto fail7;
>   
>       Error = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
>                              RequestKeyName,
> @@ -1426,15 +1443,15 @@ MonitorMain(
>                              &Context->RequestKey,
>                              NULL);
>       if (Error != ERROR_SUCCESS)
> -        goto fail9;
> +        goto fail8;
>   
>       Success = GetDialogParameters();
>       if (!Success)
> -        goto fail10;
> +        goto fail9;
>   
>       Context->Timer = CreateWaitableTimer(NULL, FALSE, NULL);
>       if (Context->Timer == NULL)
> -        goto fail11;
> +        goto fail10;
>   
>       DueTime.QuadPart = -10000LL * REBOOT_RETRY_DELAY;
>   
> @@ -1445,7 +1462,7 @@ MonitorMain(
>                                  NULL,
>                                  FALSE);
>       if (!Success)
> -        goto fail12;
> +        goto fail11;
>   
>       SetEvent(Context->RequestEvent);
>   
> @@ -1460,12 +1477,12 @@ MonitorMain(
>           Events[2] = Context->ResponseEvent;
>           Events[3] = Context->Timer;
>   
> -        Log("waiting (%u)...", ARRAYSIZE(Events));
> +        LogInfo("waiting (%u)...", ARRAYSIZE(Events));
>           Object = WaitForMultipleObjects(ARRAYSIZE(Events),
>                                           Events,
>                                           FALSE,
>                                           INFINITE);
> -        Log("awake");
> +        LogInfo("awake");
>   
>           switch (Object) {
>           case WAIT_OBJECT_0:
> @@ -1510,63 +1527,58 @@ done:
>   
>       ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
>   
> -    (VOID) DeregisterEventSource(Context->EventLog);
> -
>       RegCloseKey(Context->ParametersKey);
>       (VOID) RemoveStartOverride("stornvme");
>   
> -    Log("<====");
> +    LogInfo("<====");
> +
> +    TraceLoggingUnregister(MonitorTraceLoggingProvider);
>   
>       return;
>   
> -fail12:
> -    Log("fail12");
> +fail11:
> +    LogError("fail11");
>   
>       CloseHandle(Context->Timer);
>   
> -fail11:
> -    Log("fail11");
> -
>   fail10:
> -    Log("fail10");
> -
> -    RegCloseKey(Context->RequestKey);
> +    LogError("fail10");
>   
>   fail9:
> -    Log("fail9");
> +    LogError("fail9");
>   
> -    free(RequestKeyName);
> +    RegCloseKey(Context->RequestKey);
>   
>   fail8:
> -    Log("fail8");
> +    LogError("fail8");
>   
> -    CloseHandle(Context->ResponseEvent);
> +    free(RequestKeyName);
>   
>   fail7:
> -    Log("fail7");
> +    LogError("fail7");
>   
> -    CloseHandle(Context->RequestEvent);
> +    CloseHandle(Context->ResponseEvent);
>   
>   fail6:
> -    Log("fail6");
> +    LogError("fail6");
>   
> -    CloseHandle(Context->StopEvent);
> +    CloseHandle(Context->RequestEvent);
>   
>   fail5:
> -    Log("fail5");
> +    LogError("fail5");
>   
> -    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
> -
> -    (VOID) DeregisterEventSource(Context->EventLog);
> +    CloseHandle(Context->StopEvent);
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
> +
> +    ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>       RegCloseKey(Context->ParametersKey);
>   
> @@ -1576,9 +1588,11 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
> +
> +    TraceLoggingUnregister(MonitorTraceLoggingProvider);
>   }
>   
>   static BOOL
> @@ -1591,7 +1605,7 @@ MonitorCreate(
>       TCHAR       Path[MAX_PATH];
>       HRESULT     Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       if(!GetModuleFileName(NULL, Path, MAX_PATH))
>           goto fail1;
> @@ -1623,17 +1637,17 @@ MonitorCreate(
>       CloseServiceHandle(Service);
>       CloseServiceHandle(SCManager);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return TRUE;
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       CloseServiceHandle(SCManager);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -1641,7 +1655,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1659,7 +1673,7 @@ MonitorDelete(
>       SERVICE_STATUS      Status;
>       HRESULT             Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       SCManager = OpenSCManager(NULL,
>                                 NULL,
> @@ -1690,20 +1704,20 @@ MonitorDelete(
>       CloseServiceHandle(Service);
>       CloseServiceHandle(SCManager);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return TRUE;
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       CloseServiceHandle(Service);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>       CloseServiceHandle(SCManager);
>   
> @@ -1713,7 +1727,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1731,16 +1745,16 @@ MonitorEntry(
>       };
>       HRESULT             Error;
>   
> -    Log("%s (%s) ====>",
> -        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
> -        DAY_STR "/" MONTH_STR "/" YEAR_STR);
> +    LogInfo("%s (%s) ====>",
> +            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
> +            DAY_STR "/" MONTH_STR "/" YEAR_STR);
>   
>       if (!StartServiceCtrlDispatcher(Table))
>           goto fail1;
>   
> -    Log("%s (%s) <====",
> -        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
> -        DAY_STR "/" MONTH_STR "/" YEAR_STR);
> +    LogInfo("%s (%s) <====",
> +            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
> +            DAY_STR "/" MONTH_STR "/" YEAR_STR);
>   
>       return TRUE;
>   
> @@ -1750,7 +1764,7 @@ fail1:
>       {
>           PTSTR   Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 14:55:23 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 14:55:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1231158.1536443 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vquZn-0000qQ-GK; Fri, 13 Feb 2026 14:55:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1231158.1536443; Fri, 13 Feb 2026 14:55:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vquZn-0000qJ-Db; Fri, 13 Feb 2026 14:55:23 +0000
Received: by outflank-mailman (input) for mailman id 1231158;
 Fri, 13 Feb 2026 14:55:22 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=T9Dl=AR=bounce.vates.tech=bounce-md_30504962.698f3b56.v1-3a9337e1af6647a1a3c228158c710f4b@srs-se1.protection.inumbo.net>)
 id 1vquZm-0000nJ-5f
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 14:55:22 +0000
Received: from mail187-15.suw11.mandrillapp.com
 (mail187-15.suw11.mandrillapp.com [198.2.187.15])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 03ad4505-08ec-11f1-9ccf-f158ae23cfc8;
 Fri, 13 Feb 2026 15:55:19 +0100 (CET)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-15.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fCFZt1w1NzPm0j4f
 for <win-pv-devel@lists.xenproject.org>; Fri, 13 Feb 2026 14:55:18 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 3a9337e1af6647a1a3c228158c710f4b; Fri, 13 Feb 2026 14:55:18 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 03ad4505-08ec-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770994518; x=1771264518;
	bh=O3guEUIrPgQD1FbYBg+OunanQxPzaSsnUdXuaVYU3ig=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=Pe9iewS00Yt6KtfO1v8Deg2MDp7cMseZTB8rL136knWRbjNPhDAOYvi670jimaDb/
	 vbqZrN7RK6fhh7XO/CFc9CAaHfqiEKTMZIWkEa13Un860SgRU4tmfMocHVEJX1GMHH
	 L+a+Tmlc1MmMypZcVkKAWsU77K7O9H3uClyOTWumQ6lGvSKFnFQGQio2x36Q87fyv1
	 B7Bc6AvRY8T4cCb+Kt5/89QxNvD847MhlcqDtjnNFC0vuURLtm54bURTeWjchKKe9P
	 akF5w6cnVSr7izXO4LBX9Ky7G8XGZVuCwhg2IhIoJvthcMEnRat+MtYuSt0xCQ1YsO
	 QuSU0Xj0ruvSQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770994518; x=1771255018; i=ngoc-tu.dinh@vates.tech;
	bh=O3guEUIrPgQD1FbYBg+OunanQxPzaSsnUdXuaVYU3ig=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=sZXzX6b6WISJRK1xYq40nelR2nMycnCku5fz+fHL3ocHb7GkZf5NDWsaQWRz83A2N
	 dK/eXZUPBrvpZ56w2HQEYscxX5DANSqeRn+6m+gVrtiIPq1yMKTCZeq2RGTMnbH+ci
	 Eo4rDOM+QOY666tzIpY9yPSWK07ZxuPntzxVZvKoCa14i2fcBwUexdqIOP87ItpnPn
	 uCgRQWoV4uBjHqU745+L77cupGNPQslof9YxPJSKHlWh1F+jxyK13G33SoQcOZ3C8u
	 8vu2E8MtqszL7sSe1/0a1gwHl0Qh4sWZxYo+gGK65tRuWU6sMidzuP3k1tkp9KmeBS
	 KS6Hcy2Pq3bAw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=203/4]=20Fix=20inconsistent=20TCHAR=20handling?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770994517469
Message-Id: <7cd561db-7437-498c-a00b-69ca0db4545d@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
References: <20260213135013.1136-1-owen.smith@citrix.com> <20260213135013.1136-3-owen.smith@citrix.com>
In-Reply-To: <20260213135013.1136-3-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.3a9337e1af6647a1a3c228158c710f4b?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260213:md
Date: Fri, 13 Feb 2026 14:55:18 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 13/02/2026 14:50, Owen Smith wrote:
> * Wrap strings with _T()
> * Fix ServiceStateName and WTSStateName to return PCTSTR
> * Use 'Length' for character counts, and 'Size' for byte counts
>    when calling StringCch* and StringCb* functions
> * Fix _tWinMain to use LPTSTR
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Reviewed-by: Tu Dinh <ngoc-tu.dinh@vates.tech>

> ---
>   src/monitor/monitor.c | 174 +++++++++++++++++++++---------------------
>   1 file changed, 86 insertions(+), 88 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 49b05ad..c568d54 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -184,9 +184,9 @@ GetErrorMessage(
>                          NULL))
>           return NULL;
>   
> -    for (Index = 0; Message[Index] != '\0'; Index++) {
> -        if (Message[Index] == '\r' || Message[Index] == '\n') {
> -            Message[Index] = '\0';
> +    for (Index = 0; Message[Index] != _T('\0'); Index++) {
> +        if (Message[Index] == _T('\r') || Message[Index] == _T('\n')) {
> +            Message[Index] = _T('\0');
>               break;
>           }
>       }
> @@ -194,14 +194,14 @@ GetErrorMessage(
>       return Message;
>   }
>   
> -static PCSTR
> +static PCTSTR
>   ServiceStateName(
>       _In_ DWORD  State
>       )
>   {
>   #define _STATE_NAME(_State) \
>       case SERVICE_ ## _State: \
> -        return #_State
> +        return _T(#_State)
>   
>       switch (State) {
>       _STATE_NAME(START_PENDING);
> @@ -212,7 +212,7 @@ ServiceStateName(
>           break;
>       }
>   
> -    return "UNKNOWN";
> +    return _T("UNKNOWN");
>   
>   #undef  _STATE_NAME
>   }
> @@ -304,14 +304,14 @@ MonitorCtrlHandlerEx(
>       return ERROR_CALL_NOT_IMPLEMENTED;
>   }
>   
> -static PCSTR
> +static PCTSTR
>   WTSStateName(
>       _In_ DWORD  State
>       )
>   {
>   #define _STATE_NAME(_State) \
>       case WTS ## _State: \
> -        return #_State
> +        return _T(#_State)
>   
>       switch (State) {
>       _STATE_NAME(Active);
> @@ -328,7 +328,7 @@ WTSStateName(
>           break;
>       }
>   
> -    return "UNKNOWN";
> +    return _T("UNKNOWN");
>   
>   #undef  _STATE_NAME
>   }
> @@ -370,7 +370,7 @@ GetPromptTimeout(
>       ValueLength = sizeof (Value);
>   
>       Error = RegQueryValueEx(Context->ParametersKey,
> -                            "PromptTimeout",
> +                            _T("PromptTimeout"),
>                               NULL,
>                               &Type,
>                               (LPBYTE)&Value,
> @@ -400,7 +400,7 @@ GetDisplayName(
>   
>       Result = StringCbPrintf(ServiceKeyName,
>                               MAX_PATH,
> -                            SERVICES_KEY "\\%s",
> +                            _T(SERVICES_KEY "\\%s"),
>                               DriverName);
>       assert(SUCCEEDED(Result));
>   
> @@ -438,7 +438,7 @@ GetDisplayName(
>           goto fail3;
>   
>       Error = RegQueryValueEx(ServiceKey,
> -                            "DisplayName",
> +                            _T("DisplayName"),
>                               NULL,
>                               &Type,
>                               (LPBYTE)DisplayName,
> @@ -519,10 +519,8 @@ DoPromptForReboot(
>   
>       Error = ERROR_SUCCESS;
>   
> -    TitleLength = (DWORD)((_tcslen(Prompt->Title) +
> -                           1) * sizeof (TCHAR));
> -    TextLength = (DWORD)((_tcslen(Prompt->Text) +
> -                           1) * sizeof (TCHAR));
> +    TitleLength = (DWORD)(_tcslen(Prompt->Title) + 1);
> +    TextLength = (DWORD)(_tcslen(Prompt->Text) + 1);
>   
>       Success = WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
>                                      0,
> @@ -555,9 +553,9 @@ DoPromptForReboot(
>           Success = WTSSendMessage(WTS_CURRENT_SERVER_HANDLE,
>                                    SessionId,
>                                    Prompt->Title,
> -                                 TitleLength,
> +                                 TitleLength * sizeof(TCHAR),
>                                    Prompt->Text,
> -                                 TextLength,
> +                                 TextLength * sizeof(TCHAR),
>                                    MB_YESNO | MB_ICONEXCLAMATION,
>                                    Timeout,
>                                    &Response,
> @@ -639,25 +637,25 @@ PromptForReboot(
>       else
>           Description++;
>   
> -    TextLength = (DWORD)((_tcslen(Description) +
> -                          1 + // ' '
> -                          _tcslen(Context->Text) +
> -                          1 + // ' '
> -                          _tcslen(Context->Question) +
> -                          1) * sizeof (TCHAR));
> +    TextLength = (DWORD)(_tcslen(Description) +
> +                         1 + // ' '
> +                         _tcslen(Context->Text) +
> +                         1 + // ' '
> +                         _tcslen(Context->Question) +
> +                         1);
>   
> -    Prompt->Text = calloc(1, TextLength);
> +    Prompt->Text = calloc(1, TextLength * sizeof(TCHAR));
>       if (Prompt->Text == NULL) {
>           Error = ERROR_OUTOFMEMORY;
>           goto fail4;
>       }
>   
> -    Result = StringCbPrintf(Prompt->Text,
> -                            TextLength,
> -                            TEXT("%s %s %s"),
> -                            Description,
> -                            Context->Text,
> -                            Context->Question);
> +    Result = StringCchPrintf(Prompt->Text,
> +                             TextLength,
> +                             TEXT("%s %s %s"),
> +                             Description,
> +                             Context->Text,
> +                             Context->Question);
>       assert(SUCCEEDED(Result));
>   
>       PromptThread = CreateThread(NULL,
> @@ -758,7 +756,7 @@ TryAutoReboot(
>       Length = sizeof (DWORD);
>   
>       Error = RegQueryValueEx(Context->ParametersKey,
> -                            "AutoReboot",
> +                            _T("AutoReboot"),
>                               NULL,
>                               &Type,
>                               (LPBYTE)&AutoReboot,
> @@ -773,7 +771,7 @@ TryAutoReboot(
>       Length = sizeof (DWORD);
>   
>       Error = RegQueryValueEx(Context->ParametersKey,
> -                            "RebootCount",
> +                            _T("RebootCount"),
>                               NULL,
>                               &Type,
>                               (LPBYTE)&RebootCount,
> @@ -792,7 +790,7 @@ TryAutoReboot(
>       ++RebootCount;
>   
>       (VOID) RegSetValueEx(Context->ParametersKey,
> -                         "RebootCount",
> +                         _T("RebootCount"),
>                            0,
>                            REG_DWORD,
>                            (const BYTE*)&RebootCount,
> @@ -801,7 +799,7 @@ TryAutoReboot(
>       (VOID) RegFlushKey(Context->ParametersKey);
>   
>       Error = RegQueryValueEx(Context->ParametersKey,
> -                            "AutoRebootTimeout",
> +                            _T("AutoRebootTimeout"),
>                               NULL,
>                               &Type,
>                               (LPBYTE)&Timeout,
> @@ -822,22 +820,22 @@ TryAutoReboot(
>       else
>           Description++;
>   
> -    TextLength = (DWORD)((_tcslen(Description) +
> -                          1 + // ' '
> -                          _tcslen(Context->Text) +
> -                          1) * sizeof (TCHAR));
> +    TextLength = (DWORD)(_tcslen(Description) +
> +                         1 + // ' '
> +                         _tcslen(Context->Text) +
> +                         1);
>   
> -    Text = calloc(1, TextLength);
> +    Text = calloc(1, TextLength * sizeof(TCHAR));
>       if (Text == NULL) {
>           SetLastError(ERROR_OUTOFMEMORY);
>           goto fail3;
>       }
>   
> -    Result = StringCbPrintf(Text,
> -                            TextLength,
> -                            TEXT("%s %s"),
> -                            Description,
> -                            Context->Text);
> +    Result = StringCchPrintf(Text,
> +                             TextLength,
> +                             TEXT("%s %s"),
> +                             Description,
> +                             Context->Text);
>       assert(SUCCEEDED(Result));
>   
>       free(DisplayName);
> @@ -908,9 +906,9 @@ CheckRequestSubKeys(
>           goto fail1;
>       }
>   
> -    SubKeyLength = MaxSubKeyLength + sizeof (TCHAR);
> +    SubKeyLength = MaxSubKeyLength + 1;
>   
> -    SubKeyName = calloc(1, SubKeyLength);
> +    SubKeyName = calloc(1, SubKeyLength * sizeof(TCHAR));
>       if (SubKeyName == NULL)
>           goto fail2;
>   
> @@ -919,8 +917,8 @@ CheckRequestSubKeys(
>           DWORD   Type;
>           DWORD   Reboot;
>   
> -        SubKeyLength = MaxSubKeyLength + sizeof (TCHAR);
> -        memset(SubKeyName, 0, SubKeyLength);
> +        SubKeyLength = MaxSubKeyLength + 1;
> +        memset(SubKeyName, 0, SubKeyLength * sizeof(TCHAR));
>   
>           Error = RegEnumKeyEx(Context->RequestKey,
>                                Index,
> @@ -947,7 +945,7 @@ CheckRequestSubKeys(
>   
>           Length = sizeof (DWORD);
>           Error = RegQueryValueEx(SubKey,
> -                                "Reboot",
> +                                _T("Reboot"),
>                                   NULL,
>                                   &Type,
>                                   (LPBYTE)&Reboot,
> @@ -964,7 +962,7 @@ loop:
>       }
>   
>       Error = RegDeleteValue(Context->ParametersKey,
> -                           "RebootCount");
> +                           _T("RebootCount"));
>       if (Error == ERROR_SUCCESS)
>           (VOID) RegFlushKey(Context->ParametersKey);
>   
> @@ -1113,7 +1111,7 @@ GetRequestKeyName(
>   {
>       PMONITOR_CONTEXT            Context = &MonitorContext;
>       DWORD                       MaxValueLength;
> -    DWORD                       RequestKeyNameLength;
> +    DWORD                       RequestKeyNameSize;
>       DWORD                       Type;
>       HRESULT                     Error;
>   
> @@ -1134,18 +1132,18 @@ GetRequestKeyName(
>           goto fail1;
>       }
>   
> -    RequestKeyNameLength = MaxValueLength + sizeof (TCHAR);
> +    RequestKeyNameSize = (MaxValueLength + 1) * sizeof(TCHAR);
>   
> -    *RequestKeyName = calloc(1, RequestKeyNameLength);
> +    *RequestKeyName = calloc(1, RequestKeyNameSize);
>       if (*RequestKeyName == NULL)
>           goto fail2;
>   
>       Error = RegQueryValueEx(Context->ParametersKey,
> -                            "RequestKey",
> +                            _T("RequestKey"),
>                               NULL,
>                               &Type,
>                               (LPBYTE)(*RequestKeyName),
> -                            &RequestKeyNameLength);
> +                            &RequestKeyNameSize);
>       if (Error != ERROR_SUCCESS) {
>           SetLastError(Error);
>           goto fail3;
> @@ -1191,9 +1189,9 @@ GetDialogParameters(
>   {
>       PMONITOR_CONTEXT    Context = &MonitorContext;
>       DWORD               MaxValueLength;
> -    DWORD               TitleLength;
> -    DWORD               TextLength;
> -    DWORD               QuestionLength;
> +    DWORD               TitleSize;
> +    DWORD               TextSize;
> +    DWORD               QuestionSize;
>       DWORD               Type;
>       HRESULT             Error;
>   
> @@ -1214,18 +1212,18 @@ GetDialogParameters(
>           goto fail1;
>       }
>   
> -    TitleLength = MaxValueLength + sizeof (TCHAR);
> +    TitleSize = (MaxValueLength + 1) * sizeof(TCHAR);
>   
> -    Context->Title = calloc(1, TitleLength);
> +    Context->Title = calloc(1, TitleSize);
>       if (Context == NULL)
>           goto fail2;
>   
>       Error = RegQueryValueEx(Context->ParametersKey,
> -                            "DialogTitle",
> +                            _T("DialogTitle"),
>                               NULL,
>                               &Type,
>                               (LPBYTE)Context->Title,
> -                            &TitleLength);
> +                            &TitleSize);
>       if (Error != ERROR_SUCCESS) {
>           SetLastError(Error);
>           goto fail3;
> @@ -1236,18 +1234,18 @@ GetDialogParameters(
>           goto fail4;
>       }
>   
> -    TextLength = MaxValueLength + sizeof (TCHAR);
> +    TextSize = (MaxValueLength + 1) * sizeof (TCHAR);
>   
> -    Context->Text = calloc(1, TextLength);
> +    Context->Text = calloc(1, TextSize);
>       if (Context == NULL)
>           goto fail5;
>   
>       Error = RegQueryValueEx(Context->ParametersKey,
> -                            "DialogText",
> +                            _T("DialogText"),
>                               NULL,
>                               &Type,
>                               (LPBYTE)Context->Text,
> -                            &TextLength);
> +                            &TextSize);
>       if (Error != ERROR_SUCCESS) {
>           SetLastError(Error);
>           goto fail6;
> @@ -1258,18 +1256,18 @@ GetDialogParameters(
>           goto fail7;
>       }
>   
> -    QuestionLength = MaxValueLength + sizeof (TCHAR);
> +    QuestionSize = (MaxValueLength + 1) * sizeof (TCHAR);
>   
> -    Context->Question = calloc(1, QuestionLength);
> +    Context->Question = calloc(1, QuestionSize);
>       if (Context == NULL)
>           goto fail8;
>   
>       Error = RegQueryValueEx(Context->ParametersKey,
> -                            "DialogQuestion",
> +                            _T("DialogQuestion"),
>                               NULL,
>                               &Type,
>                               (LPBYTE)Context->Question,
> -                            &QuestionLength);
> +                            &QuestionSize);
>       if (Error != ERROR_SUCCESS) {
>           SetLastError(Error);
>           goto fail9;
> @@ -1336,10 +1334,10 @@ RemoveStartOverride(
>       TCHAR               KeyName[MAX_PATH];
>       HRESULT             Error;
>   
> -    Error = StringCbPrintf(KeyName,
> -                           MAX_PATH,
> -                           SERVICES_KEY "\\%s\\StartOverride",
> -                           DriverName);
> +    Error = StringCchPrintf(KeyName,
> +                            MAX_PATH,
> +                            _T(SERVICES_KEY "\\%s\\StartOverride"),
> +                            DriverName);
>       assert(SUCCEEDED(Error));
>   
>       Error = RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
> @@ -1381,10 +1379,10 @@ MonitorMain(
>   
>       LogInfo("====>");
>   
> -    (VOID) RemoveStartOverride("stornvme");
> +    (VOID) RemoveStartOverride(_T("stornvme"));
>   
>       Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
> -                         PARAMETERS_KEY(__MODULE__),
> +                         _T(PARAMETERS_KEY(__MODULE__)),
>                            0,
>                            KEY_READ,
>                            &Context->ParametersKey);
> @@ -1395,7 +1393,7 @@ MonitorMain(
>       if (!Success)
>           goto fail2;
>   
> -    Context->Service = RegisterServiceCtrlHandlerEx(MONITOR_NAME,
> +    Context->Service = RegisterServiceCtrlHandlerEx(_T(MONITOR_NAME),
>                                                       MonitorCtrlHandlerEx,
>                                                       NULL);
>       if (Context->Service == NULL)
> @@ -1528,7 +1526,7 @@ done:
>       ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
>   
>       RegCloseKey(Context->ParametersKey);
> -    (VOID) RemoveStartOverride("stornvme");
> +    (VOID) RemoveStartOverride(_T("stornvme"));
>   
>       LogInfo("<====");
>   
> @@ -1618,8 +1616,8 @@ MonitorCreate(
>           goto fail2;
>   
>       Service = CreateService(SCManager,
> -                            MONITOR_NAME,
> -                            MONITOR_DISPLAYNAME,
> +                            _T(MONITOR_NAME),
> +                            _T(MONITOR_DISPLAYNAME),
>                               SERVICE_ALL_ACCESS,
>                               SERVICE_WIN32_OWN_PROCESS,
>                               SERVICE_AUTO_START,
> @@ -1683,7 +1681,7 @@ MonitorDelete(
>           goto fail1;
>   
>       Service = OpenService(SCManager,
> -                          MONITOR_NAME,
> +                          _T(MONITOR_NAME),
>                             SERVICE_ALL_ACCESS);
>   
>       if (Service == NULL)
> @@ -1740,21 +1738,21 @@ MonitorEntry(
>       )
>   {
>       SERVICE_TABLE_ENTRY Table[] = {
> -        { MONITOR_NAME, MonitorMain },
> +        { _T(MONITOR_NAME), MonitorMain },
>           { NULL, NULL }
>       };
>       HRESULT             Error;
>   
>       LogInfo("%s (%s) ====>",
> -            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
> -            DAY_STR "/" MONTH_STR "/" YEAR_STR);
> +            _T(MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR),
> +            _T(DAY_STR "/" MONTH_STR "/" YEAR_STR));
>   
>       if (!StartServiceCtrlDispatcher(Table))
>           goto fail1;
>   
>       LogInfo("%s (%s) <====",
> -            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
> -            DAY_STR "/" MONTH_STR "/" YEAR_STR);
> +            _T(MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR),
> +            _T(DAY_STR "/" MONTH_STR "/" YEAR_STR));
>   
>       return TRUE;
>   
> @@ -1775,7 +1773,7 @@ int CALLBACK
>   _tWinMain(
>       _In_        HINSTANCE   Current,
>       _In_opt_    HINSTANCE   Previous,
> -    _In_        LPSTR       CmdLine,
> +    _In_        LPTSTR      CmdLine,
>       _In_        int         CmdShow
>       )
>   {



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 13 14:55:39 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 13 Feb 2026 14:55:39 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1231160.1536448 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqua3-0000u8-I6; Fri, 13 Feb 2026 14:55:39 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1231160.1536448; Fri, 13 Feb 2026 14:55:39 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vqua3-0000u1-FO; Fri, 13 Feb 2026 14:55:39 +0000
Received: by outflank-mailman (input) for mailman id 1231160;
 Fri, 13 Feb 2026 14:55:38 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=EKZO=AR=bounce.vates.tech=bounce-md_30504962.698f3b67.v1-c6f04fa711e243b697f73c0593838a69@srs-se1.protection.inumbo.net>)
 id 1vqua2-0000tn-Cv
 for win-pv-devel@lists.xenproject.org; Fri, 13 Feb 2026 14:55:38 +0000
Received: from mail187-15.suw11.mandrillapp.com
 (mail187-15.suw11.mandrillapp.com [198.2.187.15])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 0daf8a1d-08ec-11f1-b163-2bf370ae4941;
 Fri, 13 Feb 2026 15:55:36 +0100 (CET)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-15.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fCFbC2DBnzPm0cLB
 for <win-pv-devel@lists.xenproject.org>; Fri, 13 Feb 2026 14:55:35 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 c6f04fa711e243b697f73c0593838a69; Fri, 13 Feb 2026 14:55:35 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 0daf8a1d-08ec-11f1-b163-2bf370ae4941
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1770994535; x=1771264535;
	bh=b9qI0f4j8F80Vm/D2uCVpfgfmCG8ep0dC2eB1oq8Qk4=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=SAxGGlBEWJngJc1Vb3s+nReUiY35RAc/FM0+QLugjlFMWh+RLnsoENsKRYo3VZdMp
	 uwRc+gbr1v9SoLSoUcAl2fvwJftISsVHqSj1wGL+xW32QD010UNDpJ1LvpPIU5HqiE
	 +Fj5UkPKWVfJNMXpQ+lAaQGAWSNanpksAxzpRhuHO169H0AknrjXD0v9ohmSD4v4ZT
	 77c/iNitY3ipGkM+PcO1zGqCmMO6e0EpMexN9WTeVQu+ZAhfmNrNd6V0wO0jIaTU8r
	 kjTWS7acvEm6lTnoDeNjOWM7bnaw5qxYSQSuj+OkWTIZUS+YiTgKZcR9WExK+foTPJ
	 tQAnD9vqq2kYg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1770994535; x=1771255035; i=ngoc-tu.dinh@vates.tech;
	bh=b9qI0f4j8F80Vm/D2uCVpfgfmCG8ep0dC2eB1oq8Qk4=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=YN5PhkSKUdTa48LjUc75EXHRinUrLq2J31DI5uXce3PlrHOSkQnKnGKbgnHvCPs64
	 gxGh7Hsj9eR9UDIztL0PYSGa9vaU4XP136Q2HTdLCIBk3+jsuSxByWhS9zFOtyoD0w
	 mfpJEkDmOjq2PUrRaCuZgWN87VrmYU6p9A0ODK3ChL0VLCVq5s544JpgH+57Bz9dxK
	 4jxawMiouHl+olo13LbsU+NeVCB8aTQPDfyq5NXN5v1Wg/oYbNaVBVHgT/ZNGGVPEe
	 mqxn5oRY8faFDUxWCnJ5T+82iyTkr7WzwgMhQ9lECuhvO8zu3kFQ01qPtNzhQFHOBr
	 4dVpy1uIR/fiQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=204/4]=20Remove=20StartOverride=20from=20all=20storage=20adapters?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1770994534592
Message-Id: <63eeaf00-38c9-4390-94b4-e5413b59e47d@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
References: <20260213135013.1136-1-owen.smith@citrix.com> <20260213135013.1136-4-owen.smith@citrix.com>
In-Reply-To: <20260213135013.1136-4-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.c6f04fa711e243b697f73c0593838a69?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260213:md
Date: Fri, 13 Feb 2026 14:55:35 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 13/02/2026 14:50, Owen Smith wrote:
> Its possible to install non-Microsoft NVMe drivers on the emulated
> NVMe device. During upgrades, the VM requires a reboot using the emulated
> devices, but if the driver assigned for the emulated device has a StartOverride
> setting, then its likely not started which results in a 0x7B bugcheck.
> 
> Also reports SERVICE_STOPPED after clearing any StartOverride values
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Reviewed-by: Tu Dinh <ngoc-tu.dinh@vates.tech>

> ---
>   src/monitor/monitor.c                        | 64 +++++++++++++++++---
>   vs2019/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
>   vs2022/xenbus_monitor/xenbus_monitor.vcxproj |  2 +-
>   3 files changed, 56 insertions(+), 12 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index c568d54..9bfb1f6 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -42,6 +42,8 @@
>   #include <assert.h>
>   #include <TraceLoggingProvider.h>
>   #include <winmeta.h>
> +#include <setupapi.h>
> +#include <devguid.h>
>   
>   #include <version.h>
>   
> @@ -1326,7 +1328,7 @@ fail1:
>       return FALSE;
>   }
>   
> -static BOOL
> +static VOID
>   RemoveStartOverride(
>       _In_ PTSTR          DriverName
>       )
> @@ -1334,17 +1336,61 @@ RemoveStartOverride(
>       TCHAR               KeyName[MAX_PATH];
>       HRESULT             Error;
>   
> +    LogInfo("%s", DriverName);
> +
>       Error = StringCchPrintf(KeyName,
>                               MAX_PATH,
>                               _T(SERVICES_KEY "\\%s\\StartOverride"),
>                               DriverName);
>       assert(SUCCEEDED(Error));
>   
> -    Error = RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
> -    if (Error != ERROR_SUCCESS)
> +    (VOID) RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
> +}
> +
> +static VOID
> +RemoveStartOverrideForClass(
> +    _In_ const GUID*    Guid
> +    )
> +{
> +    HRESULT             Error;
> +    HDEVINFO            DevInfo;
> +    DWORD               Index;
> +    SP_DEVINFO_DATA     DevInfoData;
> +
> +    DevInfo = SetupDiGetClassDevs(Guid,
> +                                  NULL,
> +                                  NULL,
> +                                  0);
> +    if (DevInfo == INVALID_HANDLE_VALUE)
>           goto fail1;
>   
> -    return TRUE;
> +    memset(&DevInfoData, 0, sizeof(DevInfoData));
> +    DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
> +
> +    for (Index = 0;
> +         SetupDiEnumDeviceInfo(DevInfo, Index, &DevInfoData);
> +         ++Index) {
> +        TCHAR           Buffer[MAX_PATH];
> +        memset(Buffer, 0, sizeof(Buffer));
> +
> +        if (SetupDiGetDeviceRegistryProperty(DevInfo,
> +                                             &DevInfoData,
> +                                             SPDRP_SERVICE,
> +                                             NULL,
> +                                             (PBYTE)Buffer,
> +                                             sizeof(Buffer),
> +                                             NULL)) {
> +            Buffer[MAX_PATH - 1] = _T('\0');
> +            RemoveStartOverride(Buffer);
> +        }
> +
> +        memset(&DevInfoData, 0, sizeof(DevInfoData));
> +        DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
> +    }
> +
> +    SetupDiDestroyDeviceInfoList(DevInfo);
> +
> +    return;
>   
>   fail1:
>       Error = GetLastError();
> @@ -1355,8 +1401,6 @@ fail1:
>           LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
> -
> -    return FALSE;
>   }
>   
>   VOID WINAPI
> @@ -1379,7 +1423,7 @@ MonitorMain(
>   
>       LogInfo("====>");
>   
> -    (VOID) RemoveStartOverride(_T("stornvme"));
> +    RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
>   
>       Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
>                            _T(PARAMETERS_KEY(__MODULE__)),
> @@ -1523,10 +1567,10 @@ done:
>       CloseHandle(Context->RequestEvent);
>       CloseHandle(Context->StopEvent);
>   
> -    ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
> -
>       RegCloseKey(Context->ParametersKey);
> -    (VOID) RemoveStartOverride(_T("stornvme"));
> +    RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
> +
> +    ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
>   
>       LogInfo("<====");
>   
> diff --git a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> index 3b44e29..df1fd58 100644
> --- a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> +++ b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> @@ -34,7 +34,7 @@
>         <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
>       </ClCompile>
>       <Link>
> -      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
> +      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
>         <CETCompat>true</CETCompat>
>         <GenerateMapFile>true</GenerateMapFile>
>         <MapExports>true</MapExports>
> diff --git a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> index 484fa1c..196a744 100644
> --- a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> +++ b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> @@ -34,7 +34,7 @@
>         <RuntimeLibrary Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
>       </ClCompile>
>       <Link>
> -      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
> +      <AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
>         <CETCompat>true</CETCompat>
>         <GenerateMapFile>true</GenerateMapFile>
>         <MapExports>true</MapExports>



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Feb 19 14:40:05 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 19 Feb 2026 14:40:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1236392.1539121 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vt5CG-0005WT-0p; Thu, 19 Feb 2026 14:40:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1236392.1539121; Thu, 19 Feb 2026 14:40:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vt5CF-0005W2-Tx; Thu, 19 Feb 2026 14:40:03 +0000
Received: by outflank-mailman (input) for mailman id 1236392;
 Thu, 19 Feb 2026 14:40:03 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=df5y=AX=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vt5CE-0005FZ-WB
 for win-pv-devel@lists.xenproject.org; Thu, 19 Feb 2026 14:40:02 +0000
Received: from na1pdmzitismtp02.tibco.com (na1pdmzitismtp02.tibco.com
 [160.101.131.9]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id ddd5255e-0da0-11f1-9ccf-f158ae23cfc8;
 Thu, 19 Feb 2026 15:40:00 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id 34A2681D7361;
 Thu, 19 Feb 2026 09:39:31 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ddd5255e-0da0-11f1-9ccf-f158ae23cfc8
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>,
	Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 1/3] XenDisk: Report Discard support by issuing an Inquiry
Date: Thu, 19 Feb 2026 14:39:51 +0000
Message-ID: <20260219143954.1450-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

From: Owen Smith <owen.smith@cloud.com>

When XenDisk starts, issue an inquiry to determine the status of discard
support in the backend. If the backend exposes discard support, allow
XenDisk to respond to the appropriate property requests, and forward the
trim requests to XenVbd.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/xendisk/pdo.c | 88 ++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 84 insertions(+), 4 deletions(-)

diff --git a/src/xendisk/pdo.c b/src/xendisk/pdo.c
index f714efb..5d40a13 100644
--- a/src/xendisk/pdo.c
+++ b/src/xendisk/pdo.c
@@ -63,6 +63,7 @@ struct _XENDISK_PDO {
     PXENDISK_FDO                Fdo;
 
     BOOLEAN                     InterceptTrim;
+    BOOLEAN                     DiscardSupported;
     ULONG                       SectorSize;
     ULONG                       PhysSectorSize;
 };
@@ -519,6 +520,72 @@ fail1:
     return status;
 }
 
+static NTSTATUS
+PdoSendInquiryB0Synchronous(
+    IN  PXENDISK_PDO        Pdo,
+    OUT PBOOLEAN            Supported
+    )
+{
+    SCSI_REQUEST_BLOCK      Srb;
+    PCDB                    Cdb;
+    PVPD_BLOCK_LIMITS_PAGE  BlockLimits;
+    ULONG                   Length;
+    NTSTATUS                status;
+
+    Trace("====>\n");
+
+    Length = sizeof(VPD_BLOCK_LIMITS_PAGE);
+    *Supported = FALSE;
+
+    status = STATUS_NO_MEMORY;
+    BlockLimits = __PdoAllocate(Length);
+    if (BlockLimits == NULL)
+        goto fail1;
+
+    RtlZeroMemory(&Srb, sizeof(SCSI_REQUEST_BLOCK));
+    Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
+    Srb.SrbFlags = 0;
+    Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
+    Srb.DataBuffer = BlockLimits;
+    Srb.DataTransferLength = Length;
+    Srb.TimeOutValue = (ULONG)-1;
+    Srb.CdbLength = 6;
+
+    Cdb = (PCDB)&Srb.Cdb[0];
+    Cdb->CDB6INQUIRY3.OperationCode = SCSIOP_INQUIRY;
+    Cdb->CDB6INQUIRY3.PageCode = 0xB0;
+    Cdb->CDB6INQUIRY3.EnableVitalProductData = 1;
+    Cdb->CDB6INQUIRY3.AllocationLength = (UCHAR)Length;
+
+    status = PdoSendAwaitSrb(Pdo, &Srb);
+    if (!NT_SUCCESS(status))
+        goto fail2;
+
+    status = STATUS_UNSUCCESSFUL;
+    if (Srb.DataTransferLength < Length)
+        goto fail3;
+
+    *Supported = BlockLimits->UGAValid;
+
+    __PdoFree(BlockLimits);
+
+    Trace("<====\n");
+    return STATUS_SUCCESS;
+
+fail3:
+    Error("fail3\n");
+
+fail2:
+    Error("fail2\n");
+
+    __PdoFree(BlockLimits);
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
 static NTSTATUS
 PdoSendTrimSynchronous(
     IN  PXENDISK_PDO            Pdo,
@@ -674,7 +741,7 @@ PdoQueryProperty(
 
     switch (Query->PropertyId) {
     case StorageDeviceTrimProperty:
-        if (!Pdo->InterceptTrim) {
+        if (!Pdo->InterceptTrim || !Pdo->DiscardSupported) {
             status = PdoForwardIrpAndForget(Pdo, Irp);
             break;
         }
@@ -753,7 +820,7 @@ PdoManageDataSetAttributes(
 
     switch (Attributes->Action) {
     case DeviceDsmAction_Trim:
-        if (!Pdo->InterceptTrim) {
+        if (!Pdo->InterceptTrim || !Pdo->DiscardSupported) {
             status = PdoForwardIrpAndForget(Pdo, Irp);
             break;
         }
@@ -830,6 +897,7 @@ PdoStartDevice(
     ULONG               PhysSectorSize;
     ULONG64             SectorCount;
     ULONG64             Size;
+    BOOLEAN             DiscardSupported;
     POWER_STATE         PowerState;
     NTSTATUS            status;
 
@@ -848,14 +916,22 @@ PdoStartDevice(
     if (!NT_SUCCESS(status))
         goto fail3;
 
+    status = PdoSendInquiryB0Synchronous(Pdo,
+                                         &DiscardSupported);
+    if (!NT_SUCCESS(status))
+        goto fail4;
+
     Pdo->SectorSize = SectorSize;
     Pdo->PhysSectorSize = PhysSectorSize;
+    Pdo->DiscardSupported = DiscardSupported;
 
     Size = SectorSize * SectorCount;
     Size >>= 20; // Scale to megabytes
 
-    Verbose("%s: %luMB (%uB sectors)\n",
-            __PdoGetName(Pdo), Size, SectorSize);
+    Verbose("%s: %luMB (%uB sectors)%s%s\n",
+            __PdoGetName(Pdo), Size, SectorSize,
+            Pdo->DiscardSupported ? " DISCARD" : "",
+            Pdo->InterceptTrim ? "" : " (VETOED)");
 
     __PdoSetSystemPowerState(Pdo, PowerSystemWorking);
     __PdoSetDevicePowerState(Pdo, PowerDeviceD0);
@@ -874,6 +950,9 @@ PdoStartDevice(
 
     return STATUS_SUCCESS;
 
+fail4:
+    Error("fail4\n");
+
 fail3:
     Error("fail3\n");
 
@@ -1904,6 +1983,7 @@ PdoDestroy(
     Dx->Pdo = NULL;
 
     Pdo->InterceptTrim = FALSE;
+    Pdo->DiscardSupported = FALSE;
 
     RtlZeroMemory(Pdo->Name, sizeof (Pdo->Name));
 
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Thu Feb 19 14:40:05 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 19 Feb 2026 14:40:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1236393.1539125 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vt5CH-0005jj-1m; Thu, 19 Feb 2026 14:40:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1236393.1539125; Thu, 19 Feb 2026 14:40:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vt5CG-0005jG-V4; Thu, 19 Feb 2026 14:40:04 +0000
Received: by outflank-mailman (input) for mailman id 1236393;
 Thu, 19 Feb 2026 14:40:03 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=df5y=AX=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vt5CF-0005FZ-Ka
 for win-pv-devel@lists.xenproject.org; Thu, 19 Feb 2026 14:40:03 +0000
Received: from na1pdmzitismtp02.tibco.com (na1pdmzitismtp02.tibco.com
 [160.101.131.9]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id de771970-0da0-11f1-9ccf-f158ae23cfc8;
 Thu, 19 Feb 2026 15:40:01 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id 65F2E81D7362;
 Thu, 19 Feb 2026 09:39:32 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: de771970-0da0-11f1-9ccf-f158ae23cfc8
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
Subject: [PATCH 2/3] Refactor Features and DiskInfo
Date: Thu, 19 Feb 2026 14:39:52 +0000
Message-ID: <20260219143954.1450-2-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <20260219143954.1450-1-owen.smith@citrix.com>
References: <20260219143954.1450-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

From: Owen Smith <owen.smith@cloud.com>

Make the XENVBD_FEATURES structure contain ring protocol related
feature flags and values, including which ring operations the backend
exposes to the frontend. The backend may fail any operation with
BLKIF_OP_ENOTSUPP, which instructs the frontend to stop issuing these
operations, and in response the frontend will disable the associated
feature flags.

Make the XENVBD_DISKINFO structure contain the backend storage
parameters, such as disk size, physical layout and disk specific flags.

Zeroing the XENVBD_FEATURES structure and re-reading it on connection
will allow feature flags to be modified when the backend changes.

Signed-off-by: Owen Smith <owen.smith@cloud.com>
---
 src/xenvbd/frontend.c | 203 ++++++++++++++++++------------------------
 src/xenvbd/frontend.h |  12 +--
 src/xenvbd/ring.c     |   2 +-
 src/xenvbd/target.c   |   8 +-
 4 files changed, 99 insertions(+), 126 deletions(-)

diff --git a/src/xenvbd/frontend.c b/src/xenvbd/frontend.c
index 9f157fe..912fc7e 100644
--- a/src/xenvbd/frontend.c
+++ b/src/xenvbd/frontend.c
@@ -184,7 +184,7 @@ FrontendGetDiscard(
     IN  PXENVBD_FRONTEND    Frontend
     )
 {
-    return Frontend->DiskInfo.Discard;
+    return Frontend->Features.Discard;
 }
 //FRONTEND_GET_PROPERTY(FlushCache, BOOLEAN)
 BOOLEAN
@@ -192,7 +192,7 @@ FrontendGetFlushCache(
     IN  PXENVBD_FRONTEND    Frontend
     )
 {
-    return Frontend->DiskInfo.FlushCache;
+    return Frontend->Features.FlushCache;
 }
 //FRONTEND_GET_PROPERTY(Barrier, BOOLEAN)
 BOOLEAN
@@ -200,7 +200,7 @@ FrontendGetBarrier(
     IN  PXENVBD_FRONTEND    Frontend
     )
 {
-    return Frontend->DiskInfo.Barrier;
+    return Frontend->Features.Barrier;
 }
 FRONTEND_GET_PROPERTY(MaxQueues, ULONG)
 FRONTEND_GET_PROPERTY(NumQueues, ULONG)
@@ -240,15 +240,15 @@ FrontendRemoveFeature(
     switch (BlkifOperation) {
     case BLKIF_OP_FLUSH_DISKCACHE:
         Verbose("FLUSH_DISKCACHE\n");
-        Frontend->DiskInfo.FlushCache = FALSE;
+        Frontend->Features.FlushCache = FALSE;
         break;
     case BLKIF_OP_WRITE_BARRIER:    
         Verbose("WRITE_BARRIER\n");
-        Frontend->DiskInfo.Barrier = FALSE;
+        Frontend->Features.Barrier = FALSE;
         break;
     case BLKIF_OP_DISCARD:
         Verbose("DISCARD\n");
-        Frontend->DiskInfo.Discard = FALSE;
+        Frontend->Features.Discard = FALSE;
         break;
     case BLKIF_OP_INDIRECT:
         Verbose("INDIRECT\n");
@@ -824,10 +824,78 @@ __Units(
     return "GB";
 }
 
-__drv_requiresIRQL(DISPATCH_LEVEL)
-static VOID
-__ReadDiskInfo(
-    __in  PXENVBD_FRONTEND  Frontend
+static FORCEINLINE VOID
+FrontendReadFeatures(
+    IN  PXENVBD_FRONTEND    Frontend
+    )
+{
+    BOOLEAN                 DiscardFeature = FALSE;
+    BOOLEAN                 DiscardEnable = TRUE;
+
+    FrontendReadFeature(Frontend,
+                        FeatureRemovable,
+                        &Frontend->Features.Removable);
+    FrontendReadValue32(Frontend,
+                        FeatureMaxIndirectSegments,
+                        TRUE,
+                        &Frontend->Features.Indirect);
+    FrontendReadFeature(Frontend,
+                        FeaturePersistent,
+                        &Frontend->Features.Persistent);
+    FrontendReadFeature(Frontend,
+                        FeatureBarrier,
+                        &Frontend->Features.Barrier);
+    FrontendReadFeature(Frontend,
+                        FeatureFlushCache,
+                        &Frontend->Features.FlushCache);
+
+    FrontendReadFeature(Frontend,
+                        FeatureDiscard,
+                        &DiscardFeature);
+    FrontendReadFeature(Frontend,
+                        FeatureDiscardEnable,
+                        &DiscardEnable);
+    Frontend->Features.Discard = DiscardFeature && DiscardEnable;
+
+    FrontendReadFeature(Frontend,
+                        FeatureDiscardSecure,
+                        &Frontend->Features.DiscardSecure);
+    FrontendReadValue32(Frontend,
+                        FeatureDiscardAlignment,
+                        TRUE,
+                        &Frontend->Features.DiscardAlignment);
+    FrontendReadValue32(Frontend,
+                        FeatureDiscardGranularity,
+                        TRUE,
+                        &Frontend->Features.DiscardGranularity);
+
+    Verbose("Target[%d] : Features: %s%s%s%s%s%s\n",
+            Frontend->TargetId,
+            Frontend->Features.Persistent ? "PERSISTENT " : "",
+            Frontend->Features.Indirect > 0 ? "INDIRECT " : "",
+            Frontend->Features.Removable ? "REMOVABLE " : "",
+            Frontend->Features.Barrier ? "BARRIER " : "",
+            Frontend->Features.FlushCache ? "FLUSH " : "",
+            Frontend->Features.Discard ? "DISCARD " : "");
+
+    if (Frontend->Features.Indirect) {
+        Verbose("Target[%d] : INDIRECT %x\n",
+                    Frontend->TargetId,
+                    Frontend->Features.Indirect);
+    }
+
+    if (Frontend->Features.Discard) {
+        Verbose("Target[%d] : DISCARD %s%x/%x\n",
+                    Frontend->TargetId,
+                    Frontend->Features.DiscardSecure ? "SECURE " : "",
+                    Frontend->Features.DiscardAlignment,
+                    Frontend->Features.DiscardGranularity);
+    }
+}
+
+static FORCEINLINE VOID
+FrontendReadDiskInfo(
+    IN  PXENVBD_FRONTEND    Frontend
     )
 {
     BOOLEAN                 Changed;
@@ -873,92 +941,6 @@ __ReadDiskInfo(
           Frontend->DiskInfo.DiskInfo);
 }
 
-static FORCEINLINE VOID
-FrontendReadFeatures(
-    IN  PXENVBD_FRONTEND    Frontend
-    )
-{
-    BOOLEAN                 Changed;
-
-    Changed = FrontendReadFeature(Frontend,
-                                  FeatureRemovable,
-                                  &Frontend->Features.Removable);
-    Changed |= FrontendReadValue32(Frontend,
-                                   FeatureMaxIndirectSegments,
-                                   TRUE,
-                                   &Frontend->Features.Indirect);
-    Changed |= FrontendReadFeature(Frontend,
-                                   FeaturePersistent,
-                                   &Frontend->Features.Persistent);
-
-    if (!Changed)
-        return;
-
-    Verbose("Target[%d] : Features: %s%s%s\n",
-            Frontend->TargetId,
-            Frontend->Features.Persistent ? "PERSISTENT " : "",
-            Frontend->Features.Indirect ? "INDIRECT " : "",
-            Frontend->Features.Removable ? "REMOVABLE" : "");
-
-    if (Frontend->Features.Indirect) {
-        Verbose("Target[%d] : INDIRECT %x\n",
-                    Frontend->TargetId,
-                    Frontend->Features.Indirect);
-    }
-}
-
-static FORCEINLINE VOID
-FrontendReadDiskInfo(
-    IN  PXENVBD_FRONTEND    Frontend
-    )
-{
-    BOOLEAN                 DiscardFeature = FALSE;
-    BOOLEAN                 DiscardEnable = TRUE;
-
-    FrontendReadFeature(Frontend,
-                        FeatureBarrier,
-                        &Frontend->DiskInfo.Barrier);
-    FrontendReadFeature(Frontend,
-                        FeatureFlushCache,
-                        &Frontend->DiskInfo.FlushCache);
-
-    // discard related
-    FrontendReadFeature(Frontend,
-                        FeatureDiscard,
-                        &DiscardFeature);
-    FrontendReadFeature(Frontend,
-                        FeatureDiscardEnable,
-                        &DiscardEnable);
-
-    Frontend->DiskInfo.Discard = DiscardFeature && DiscardEnable;
-
-    FrontendReadFeature(Frontend,
-                        FeatureDiscardSecure,
-                        &Frontend->DiskInfo.DiscardSecure);
-    FrontendReadValue32(Frontend,
-                        FeatureDiscardAlignment,
-                        TRUE,
-                        &Frontend->DiskInfo.DiscardAlignment);
-    FrontendReadValue32(Frontend,
-                        FeatureDiscardGranularity,
-                        TRUE,
-                        &Frontend->DiskInfo.DiscardGranularity);
-
-    Verbose("Target[%d] : Features: %s%s%s\n",
-                Frontend->TargetId,
-                Frontend->DiskInfo.Barrier ? "BARRIER " : "",
-                Frontend->DiskInfo.FlushCache ?  "FLUSH " : "",
-                Frontend->DiskInfo.Discard ? "DISCARD " : "");
-
-    if (Frontend->DiskInfo.Discard) {
-        Verbose("Target[%d] : DISCARD %s%x/%x\n",
-                    Frontend->TargetId,
-                    Frontend->DiskInfo.DiscardSecure ? "SECURE " : "",
-                    Frontend->DiskInfo.DiscardAlignment,
-                    Frontend->DiskInfo.DiscardGranularity);
-    }
-}
-
 static FORCEINLINE VOID
 FrontendReadInquiryOverrides(
     IN  PXENVBD_FRONTEND    Frontend
@@ -1142,8 +1124,6 @@ FrontendPrepare(
             Frontend->BackendDomain,
             Frontend->BackendPath);
 
-    FrontendReadFeatures(Frontend);
-    
     return STATUS_SUCCESS;
 
 fail7:
@@ -1314,7 +1294,6 @@ abort:
         goto fail6;
 
     // read disk info
-    __ReadDiskInfo(Frontend);
     FrontendReadDiskInfo(Frontend);
 
     // read inquiry data
@@ -1332,6 +1311,7 @@ abort:
 
 fail7:
     Error("Fail7\n");
+    RtlZeroMemory(&Frontend->Features, sizeof(XENVBD_FEATURES));
 fail6:
     Error("Fail6\n");
 fail5:
@@ -1370,14 +1350,7 @@ FrontendDisconnect(
     Frontend->Page83.Data = NULL;
     Frontend->Page83.Size = 0;
 
-    // clear some disk info values, so they can be re-read on connect
-    // allows migration to a backend with different supported features
-    Frontend->DiskInfo.Barrier = FALSE;
-    Frontend->DiskInfo.FlushCache = FALSE;
-    Frontend->DiskInfo.Discard = FALSE;
-    Frontend->DiskInfo.DiscardSecure = FALSE;
-    Frontend->DiskInfo.DiscardAlignment = 0;
-    Frontend->DiskInfo.DiscardGranularity = 0;
+    RtlZeroMemory(&Frontend->Features, sizeof(XENVBD_FEATURES));
 }
 __drv_requiresIRQL(DISPATCH_LEVEL)
 static FORCEINLINE VOID
@@ -1649,9 +1622,9 @@ FrontendDebugCallback(
                  Frontend->Features.Persistent ? "PERSISTENT " : "",
                  Frontend->Features.Indirect > 0 ? "INDIRECT " : "",
                  Frontend->Features.Removable ? "REMOVABLE " : "",
-                 Frontend->DiskInfo.Barrier ? "BARRIER " : "",
-                 Frontend->DiskInfo.FlushCache ? "FLUSH " : "",
-                 Frontend->DiskInfo.Discard ? "DISCARD " : "");
+                 Frontend->Features.Barrier ? "BARRIER " : "",
+                 Frontend->Features.FlushCache ? "FLUSH " : "",
+                 Frontend->Features.Discard ? "DISCARD " : "");
 
     if (Frontend->Features.Indirect > 0) {
         XENBUS_DEBUG(Printf,
@@ -1659,13 +1632,13 @@ FrontendDebugCallback(
                      "INDIRECT %x\n",
                      Frontend->Features.Indirect);
     }
-    if (Frontend->DiskInfo.Discard) {
+    if (Frontend->Features.Discard) {
         XENBUS_DEBUG(Printf,
                      &Frontend->DebugInterface,
                      "DISCARD %s%x/%x\n",
-                     Frontend->DiskInfo.DiscardSecure ? "SECURE " : "",
-                     Frontend->DiskInfo.DiscardAlignment,
-                     Frontend->DiskInfo.DiscardGranularity);
+                     Frontend->Features.DiscardSecure ? "SECURE " : "",
+                     Frontend->Features.DiscardAlignment,
+                     Frontend->Features.DiscardGranularity);
     }
 
     XENBUS_DEBUG(Printf,
@@ -1834,7 +1807,7 @@ FrontendBackend(
         KeAcquireSpinLock(&Frontend->StateLock, &Irql);
         // Only attempt this if Active, Active is set/cleared on D3->D0/D0->D3
         if (Frontend->Active) {
-            __ReadDiskInfo(Frontend);
+            FrontendReadDiskInfo(Frontend);
             __CheckBackendForEject(Frontend);
         }
         KeReleaseSpinLock(&Frontend->StateLock, Irql);
diff --git a/src/xenvbd/frontend.h b/src/xenvbd/frontend.h
index a83c1f0..34f91b4 100644
--- a/src/xenvbd/frontend.h
+++ b/src/xenvbd/frontend.h
@@ -56,6 +56,12 @@ typedef struct _XENVBD_FEATURES {
     ULONG                       Indirect;
     BOOLEAN                     Persistent;
     BOOLEAN                     Removable;
+    BOOLEAN                     Barrier;
+    BOOLEAN                     FlushCache;
+    BOOLEAN                     Discard;
+    BOOLEAN                     DiscardSecure;
+    ULONG                       DiscardAlignment;
+    ULONG                       DiscardGranularity;
 } XENVBD_FEATURES, *PXENVBD_FEATURES;
 
 typedef struct _XENVBD_DISKINFO {
@@ -63,12 +69,6 @@ typedef struct _XENVBD_DISKINFO {
     ULONG                       SectorSize;
     ULONG                       PhysSectorSize;
     ULONG                       DiskInfo;
-    BOOLEAN                     Barrier;
-    BOOLEAN                     FlushCache;
-    BOOLEAN                     Discard;
-    BOOLEAN                     DiscardSecure;
-    ULONG                       DiscardAlignment;
-    ULONG                       DiscardGranularity;
 } XENVBD_DISKINFO, *PXENVBD_DISKINFO;
 
 typedef struct _XENVBD_FRONTEND XENVBD_FRONTEND, *PXENVBD_FRONTEND;
diff --git a/src/xenvbd/ring.c b/src/xenvbd/ring.c
index 86a71ac..50f8d58 100644
--- a/src/xenvbd/ring.c
+++ b/src/xenvbd/ring.c
@@ -914,7 +914,7 @@ BlkifRingPrepareSyncCache(
     InitializeListHead(&List);
     Srb->SrbStatus = SRB_STATUS_PENDING;
 
-    if (FrontendGetDiskInfo(Frontend)->FlushCache)
+    if (FrontendGetFeatures(Frontend)->FlushCache)
         Operation = BLKIF_OP_FLUSH_DISKCACHE;
     else
         Operation = BLKIF_OP_WRITE_BARRIER;
diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index f07ee8b..a07fc45 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -806,7 +806,7 @@ TargetInquiryB0(
     IN  PSCSI_REQUEST_BLOCK Srb
     )
 {
-    PXENVBD_DISKINFO        DiskInfo = FrontendGetDiskInfo(Target->Frontend);
+    PXENVBD_FEATURES        Features = FrontendGetFeatures(Target->Frontend);
     PVPD_BLOCK_LIMITS_PAGE  Data = Srb->DataBuffer;
     ULONG                   Length = Srb->DataTransferLength;
 
@@ -822,10 +822,10 @@ TargetInquiryB0(
     Data->PageCode = 0xB0;
     Data->PageLength[1] = 0x3C; // as per spec
 
-    *(PULONG)Data->OptimalUnmapGranularity = _byteswap_ulong(DiskInfo->DiscardGranularity);
-    *(PULONG)Data->UnmapGranularityAlignment = _byteswap_ulong(DiskInfo->DiscardAlignment);
+    *(PULONG)Data->OptimalUnmapGranularity = _byteswap_ulong(Features->DiscardGranularity);
+    *(PULONG)Data->UnmapGranularityAlignment = _byteswap_ulong(Features->DiscardAlignment);
     // alignment is only valid if a granularity has been set
-    Data->UGAValid = (DiskInfo->DiscardGranularity != 0) ? 1 : 0;
+    Data->UGAValid = (Features->DiscardGranularity != 0) ? 1 : 0;
 
     Srb->DataTransferLength = sizeof(VPD_BLOCK_LIMITS_PAGE);
     Srb->SrbStatus = SRB_STATUS_SUCCESS;
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Thu Feb 19 14:40:06 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 19 Feb 2026 14:40:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1236394.1539128 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vt5CI-0005rO-3B; Thu, 19 Feb 2026 14:40:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1236394.1539128; Thu, 19 Feb 2026 14:40:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vt5CH-0005rG-WE; Thu, 19 Feb 2026 14:40:06 +0000
Received: by outflank-mailman (input) for mailman id 1236394;
 Thu, 19 Feb 2026 14:40:05 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=df5y=AX=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vt5CH-0005f2-1E
 for win-pv-devel@lists.xenproject.org; Thu, 19 Feb 2026 14:40:05 +0000
Received: from na1pdmzitismtp02.tibco.com (na1pdmzitismtp02.tibco.com
 [160.101.131.9]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id df39b0aa-0da0-11f1-b164-2bf370ae4941;
 Thu, 19 Feb 2026 15:40:03 +0100 (CET)
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id 8728581D7358;
 Thu, 19 Feb 2026 09:39:33 -0500 (EST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: df39b0aa-0da0-11f1-b164-2bf370ae4941
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 3/3] Use NT Safe String printf in log.c
Date: Thu, 19 Feb 2026 14:39:53 +0000
Message-ID: <20260219143954.1450-3-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <20260219143954.1450-1-owen.smith@citrix.com>
References: <20260219143954.1450-1-owen.smith@citrix.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

CodeQL generates a warning about using sprintf(). Switch to using
RtlStringCbPrintf() when formatting debug messages.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/xencrsh/log.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/xencrsh/log.c b/src/xencrsh/log.c
index a1e8a5a..dd91d5e 100644
--- a/src/xencrsh/log.c
+++ b/src/xencrsh/log.c
@@ -34,6 +34,7 @@
 #include "driver.h"
 #include "assert.h"
 #include <stdio.h>
+#include <ntstrsafe.h>
 
 static PVOID Port12 = ((PVOID)(ULONG_PTR)0x12);
 
@@ -254,8 +255,7 @@ LogVDebug(
 {
     static CHAR Buffer[256];
 
-#pragma warning(suppress : 28719) // SDV
-    sprintf(Buffer, "%s|%s|%s:", Module, __Mode(), Function);
+    RtlStringCbPrintfA(Buffer, sizeof(Buffer), "%s|%s|%s:", Module, __Mode(), Function);
     Buffer[255] = 0;
 
     vDbgPrintExWithPrefix(Buffer,
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 20 09:14:08 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 20 Feb 2026 09:14:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1236950.1539423 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vtMaN-0007YS-DH; Fri, 20 Feb 2026 09:14:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1236950.1539423; Fri, 20 Feb 2026 09:14:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vtMaN-0007YL-AO; Fri, 20 Feb 2026 09:14:07 +0000
Received: by outflank-mailman (input) for mailman id 1236950;
 Fri, 20 Feb 2026 09:14:06 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=MIOy=AY=bounce.vates.tech=bounce-md_30504962.699825d9.v1-709c9ef7fa3647c180551635a1ae0415@srs-se1.protection.inumbo.net>)
 id 1vtMaM-0007YE-3l
 for win-pv-devel@lists.xenproject.org; Fri, 20 Feb 2026 09:14:06 +0000
Received: from mail186-12.suw21.mandrillapp.com
 (mail186-12.suw21.mandrillapp.com [198.2.186.12])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 7f6ff400-0e3c-11f1-9ccf-f158ae23cfc8;
 Fri, 20 Feb 2026 10:14:03 +0100 (CET)
Received: from pmta10.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail186-12.suw21.mandrillapp.com (Mailchimp) with ESMTP id
 4fHPgs5PHcz705mFT
 for <win-pv-devel@lists.xenproject.org>; Fri, 20 Feb 2026 09:14:01 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 709c9ef7fa3647c180551635a1ae0415; Fri, 20 Feb 2026 09:14:01 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7f6ff400-0e3c-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1771578841; x=1771848841;
	bh=Sj76qT/hz9I/5XTBkdV2L7etdaJEO02Z+w5LNNWUloc=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=EhOKeoe0Ercf6UM4uUgRhMgDzAjP561TDGRQNFd9rIDGa7Q5yiwcyl/fgOweqE5tF
	 6JhJYtSUymM4RmUwBzUIDHg+1jkSb6bSe1JyOI42mHkIso4mi9nKhLaM1DWEZqZBIK
	 PngtU0yV0XZ5QThXfb8rSYO8gNrinxzYsfQHlEr/Cg6QePZFyUKk/vQDFj44OamGNV
	 beLMCm2rioXen7EVAzl1TEGOqROXB6vYXIO6WRamsRfRO4mzHokiRmBef3r4BkhU3v
	 wcD3apYiWcJIvQrFTRSdY3+R8/Ttoc3G9ushux1Ujjgze4lS5YOSC1EykHJxxsjk9w
	 3V5GNM/1DE8rQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1771578841; x=1771839341; i=ngoc-tu.dinh@vates.tech;
	bh=Sj76qT/hz9I/5XTBkdV2L7etdaJEO02Z+w5LNNWUloc=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=t1LQFGFXhAmBnoloPMZljNGmNzwev8895PiiGbr1CLvDzvDvEteZCKtM4rLUYq326
	 Oyn/+7vkyY6tkJIG0ZFlXoL9dmi/2RtpDEFsZNytCUWQEzRXR6s74p88BwGSGXFOod
	 +Fnv2N/Q2hL/UXLX1wgMr6AE5gzpboapDCqnllWAWD2G+eeA82WUDPlTW5VeZO3Tat
	 x7Bxcsqy2UgoSKDeWRFN4cKbZ3R8D7BM1SlVLSIfM0NIOCmOVs0+JAKvrIzSLktoYe
	 TPqiV6XdGC14oZ0WgDszxQRmrdE0dov9RlZ3CMzqofLjF1GaraDI85cPRmttZxdzfC
	 wtx2m0e7j1xkQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=203/3]=20Use=20NT=20Safe=20String=20printf=20in=20log.c?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1771578840790
Message-Id: <b0d85113-ac74-4b16-807d-0f6cf2b735ee@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
References: <20260219143954.1450-1-owen.smith@citrix.com> <20260219143954.1450-3-owen.smith@citrix.com>
In-Reply-To: <20260219143954.1450-3-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.709c9ef7fa3647c180551635a1ae0415?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260220:md
Date: Fri, 20 Feb 2026 09:14:01 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Hi,

On 19/02/2026 15:40, Owen Smith wrote:
> CodeQL generates a warning about using sprintf(). Switch to using
> RtlStringCbPrintf() when formatting debug messages.
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Please check the return status of RtlStringCbPrintfA, as only 
STATUS_SUCCESS and STATUS_BUFFER_OVERFLOW guarantee a valid printable 
string.

Also, could you please wrap the patch to 80 chars?

> ---
>   src/xencrsh/log.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/xencrsh/log.c b/src/xencrsh/log.c
> index a1e8a5a..dd91d5e 100644
> --- a/src/xencrsh/log.c
> +++ b/src/xencrsh/log.c
> @@ -34,6 +34,7 @@
>   #include "driver.h"
>   #include "assert.h"
>   #include <stdio.h>
> +#include <ntstrsafe.h>
>   
>   static PVOID Port12 = ((PVOID)(ULONG_PTR)0x12);
>   
> @@ -254,8 +255,7 @@ LogVDebug(
>   {
>       static CHAR Buffer[256];
>   
> -#pragma warning(suppress : 28719) // SDV
> -    sprintf(Buffer, "%s|%s|%s:", Module, __Mode(), Function);
> +    RtlStringCbPrintfA(Buffer, sizeof(Buffer), "%s|%s|%s:", Module, __Mode(), Function);
>       Buffer[255] = 0;
>   
>       vDbgPrintExWithPrefix(Buffer,



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 20 09:41:08 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 20 Feb 2026 09:41:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1236962.1539437 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vtN0V-0003WE-Fa; Fri, 20 Feb 2026 09:41:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1236962.1539437; Fri, 20 Feb 2026 09:41:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vtN0V-0003W7-D0; Fri, 20 Feb 2026 09:41:07 +0000
Received: by outflank-mailman (input) for mailman id 1236962;
 Fri, 20 Feb 2026 09:41:06 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Z0F8=AY=bounce.vates.tech=bounce-md_30504962.69982c2f.v1-b63969a0e01a4770a2456890f213f593@srs-se1.protection.inumbo.net>)
 id 1vtN0U-0003W1-7e
 for win-pv-devel@lists.xenproject.org; Fri, 20 Feb 2026 09:41:06 +0000
Received: from mail186-12.suw21.mandrillapp.com
 (mail186-12.suw21.mandrillapp.com [198.2.186.12])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 45d3907f-0e40-11f1-b164-2bf370ae4941;
 Fri, 20 Feb 2026 10:41:04 +0100 (CET)
Received: from pmta10.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail186-12.suw21.mandrillapp.com (Mailchimp) with ESMTP id
 4fHQH31Pn7z705mFK
 for <win-pv-devel@lists.xenproject.org>; Fri, 20 Feb 2026 09:41:03 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 b63969a0e01a4770a2456890f213f593; Fri, 20 Feb 2026 09:41:03 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 45d3907f-0e40-11f1-b164-2bf370ae4941
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1771580463; x=1771850463;
	bh=Um3lP0HLG9wpaJkqQAMWV79MhYo4Z+F471lMLX5KZA8=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=KGcfrNsN/0qdpRUZ+8a6d3c50LtSWQ9s+Ikspp1Cmt46Gas5/T6Xu1JKSEqq7O37v
	 KJuxBYNO3Yna6dg2A/7h0JUeIYYpNpxJ0YMEDvrethe5e6T7GVRe5zgyD3Yld+dSp/
	 WYl8yxHUK54sML2Pl+qhdhDP+SIrcnKk8+pGXPktd/N89h8Dh+wci0QQqYHJHDFyG9
	 vazzr6hNj2RRq+ryqeWl0LS4Jpadp9dsFtdDmzYukkqZV47DE2BdxUQKicLX4bAa6R
	 uMfe8N2lAG3C9/weteAuQOWFHjrc1K7O8A+/ubwlS6utTI9Nr+iO1A5k8LDQ5TWIDJ
	 0YCMElCWYHesw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1771580463; x=1771840963; i=ngoc-tu.dinh@vates.tech;
	bh=Um3lP0HLG9wpaJkqQAMWV79MhYo4Z+F471lMLX5KZA8=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=MVfETiJBL13QTAtL8V6TLI2r8yw79k/WII/XPAOUJByse1ECdCC5OdxJYMXV+YIge
	 6l1o/9AFIcuUjZJVpHVXGKQJvsnEuM4v3bWxUHF96gAcYvGXhqHfi2gczg8C9lP6qJ
	 CCRiwfgfwlTstHMq7V5uGySOK/mcOd3aAXwGXfvLyd2NyfBf9wxUkAGNvT8bHV6aGL
	 SeiF3Ca6bSVNbQHpvZGcQBVYwR+HfQ5wpuSF5HSgdqi3ItH67azP4mipJxPI0QMyvs
	 h+vyiU1pH+X0r/NEdUecEinqnVVW7aSt70QZTs72p8PrpMXdLEL2zTV0k6m0D0Mcoz
	 KKStc3mFcGaFg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=202/3]=20Refactor=20Features=20and=20DiskInfo?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1771580462122
Message-Id: <3cba674b-ef05-421f-abd4-c092523f2df0@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
Cc: "Owen Smith" <owen.smith@cloud.com>
References: <20260219143954.1450-1-owen.smith@citrix.com> <20260219143954.1450-2-owen.smith@citrix.com>
In-Reply-To: <20260219143954.1450-2-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.b63969a0e01a4770a2456890f213f593?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260220:md
Date: Fri, 20 Feb 2026 09:41:03 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 19/02/2026 15:40, Owen Smith wrote:
> From: Owen Smith <owen.smith@cloud.com>
> 
> Make the XENVBD_FEATURES structure contain ring protocol related
> feature flags and values, including which ring operations the backend
> exposes to the frontend. The backend may fail any operation with
> BLKIF_OP_ENOTSUPP, which instructs the frontend to stop issuing these
> operations, and in response the frontend will disable the associated
> feature flags.
> 
> Make the XENVBD_DISKINFO structure contain the backend storage
> parameters, such as disk size, physical layout and disk specific flags.
> 
> Zeroing the XENVBD_FEATURES structure and re-reading it on connection
> will allow feature flags to be modified when the backend changes.
> 
> Signed-off-by: Owen Smith <owen.smith@cloud.com>

Reviewed-by: Tu Dinh <ngoc-tu.dinh@vates.tech>

Could you remove 
FrontendGetDiscard/FrontendGetFlushCache/FrontendGetBarrier now that 
they have been replaced by FrontendGetFeatures? I think that'll also 
help us replace the manually-implemented FrontendGet* functions with 
FRONTEND_GET_PROPERTY as it once was.

> ---
>   src/xenvbd/frontend.c | 203 ++++++++++++++++++------------------------
>   src/xenvbd/frontend.h |  12 +--
>   src/xenvbd/ring.c     |   2 +-
>   src/xenvbd/target.c   |   8 +-
>   4 files changed, 99 insertions(+), 126 deletions(-)
> 
> diff --git a/src/xenvbd/frontend.c b/src/xenvbd/frontend.c
> index 9f157fe..912fc7e 100644
> --- a/src/xenvbd/frontend.c
> +++ b/src/xenvbd/frontend.c
> @@ -184,7 +184,7 @@ FrontendGetDiscard(
>       IN  PXENVBD_FRONTEND    Frontend
>       )
>   {
> -    return Frontend->DiskInfo.Discard;
> +    return Frontend->Features.Discard;
>   }
>   //FRONTEND_GET_PROPERTY(FlushCache, BOOLEAN)
>   BOOLEAN
> @@ -192,7 +192,7 @@ FrontendGetFlushCache(
>       IN  PXENVBD_FRONTEND    Frontend
>       )
>   {
> -    return Frontend->DiskInfo.FlushCache;
> +    return Frontend->Features.FlushCache;
>   }
>   //FRONTEND_GET_PROPERTY(Barrier, BOOLEAN)
>   BOOLEAN
> @@ -200,7 +200,7 @@ FrontendGetBarrier(
>       IN  PXENVBD_FRONTEND    Frontend
>       )
>   {
> -    return Frontend->DiskInfo.Barrier;
> +    return Frontend->Features.Barrier;
>   }
>   FRONTEND_GET_PROPERTY(MaxQueues, ULONG)
>   FRONTEND_GET_PROPERTY(NumQueues, ULONG)
> @@ -240,15 +240,15 @@ FrontendRemoveFeature(
>       switch (BlkifOperation) {
>       case BLKIF_OP_FLUSH_DISKCACHE:
>           Verbose("FLUSH_DISKCACHE\n");
> -        Frontend->DiskInfo.FlushCache = FALSE;
> +        Frontend->Features.FlushCache = FALSE;
>           break;
>       case BLKIF_OP_WRITE_BARRIER:
>           Verbose("WRITE_BARRIER\n");
> -        Frontend->DiskInfo.Barrier = FALSE;
> +        Frontend->Features.Barrier = FALSE;
>           break;
>       case BLKIF_OP_DISCARD:
>           Verbose("DISCARD\n");
> -        Frontend->DiskInfo.Discard = FALSE;
> +        Frontend->Features.Discard = FALSE;
>           break;
>       case BLKIF_OP_INDIRECT:
>           Verbose("INDIRECT\n");
> @@ -824,10 +824,78 @@ __Units(
>       return "GB";
>   }
>   
> -__drv_requiresIRQL(DISPATCH_LEVEL)
> -static VOID
> -__ReadDiskInfo(
> -    __in  PXENVBD_FRONTEND  Frontend
> +static FORCEINLINE VOID
> +FrontendReadFeatures(
> +    IN  PXENVBD_FRONTEND    Frontend
> +    )
> +{
> +    BOOLEAN                 DiscardFeature = FALSE;
> +    BOOLEAN                 DiscardEnable = TRUE;
> +
> +    FrontendReadFeature(Frontend,
> +                        FeatureRemovable,
> +                        &Frontend->Features.Removable);
> +    FrontendReadValue32(Frontend,
> +                        FeatureMaxIndirectSegments,
> +                        TRUE,
> +                        &Frontend->Features.Indirect);
> +    FrontendReadFeature(Frontend,
> +                        FeaturePersistent,
> +                        &Frontend->Features.Persistent);
> +    FrontendReadFeature(Frontend,
> +                        FeatureBarrier,
> +                        &Frontend->Features.Barrier);
> +    FrontendReadFeature(Frontend,
> +                        FeatureFlushCache,
> +                        &Frontend->Features.FlushCache);
> +
> +    FrontendReadFeature(Frontend,
> +                        FeatureDiscard,
> +                        &DiscardFeature);
> +    FrontendReadFeature(Frontend,
> +                        FeatureDiscardEnable,
> +                        &DiscardEnable);
> +    Frontend->Features.Discard = DiscardFeature && DiscardEnable;
> +
> +    FrontendReadFeature(Frontend,
> +                        FeatureDiscardSecure,
> +                        &Frontend->Features.DiscardSecure);
> +    FrontendReadValue32(Frontend,
> +                        FeatureDiscardAlignment,
> +                        TRUE,
> +                        &Frontend->Features.DiscardAlignment);
> +    FrontendReadValue32(Frontend,
> +                        FeatureDiscardGranularity,
> +                        TRUE,
> +                        &Frontend->Features.DiscardGranularity);
> +
> +    Verbose("Target[%d] : Features: %s%s%s%s%s%s\n",
> +            Frontend->TargetId,
> +            Frontend->Features.Persistent ? "PERSISTENT " : "",
> +            Frontend->Features.Indirect > 0 ? "INDIRECT " : "",
> +            Frontend->Features.Removable ? "REMOVABLE " : "",
> +            Frontend->Features.Barrier ? "BARRIER " : "",
> +            Frontend->Features.FlushCache ? "FLUSH " : "",
> +            Frontend->Features.Discard ? "DISCARD " : "");
> +
> +    if (Frontend->Features.Indirect) {
> +        Verbose("Target[%d] : INDIRECT %x\n",
> +                    Frontend->TargetId,
> +                    Frontend->Features.Indirect);
> +    }
> +
> +    if (Frontend->Features.Discard) {
> +        Verbose("Target[%d] : DISCARD %s%x/%x\n",
> +                    Frontend->TargetId,
> +                    Frontend->Features.DiscardSecure ? "SECURE " : "",
> +                    Frontend->Features.DiscardAlignment,
> +                    Frontend->Features.DiscardGranularity);
> +    }
> +}
> +
> +static FORCEINLINE VOID
> +FrontendReadDiskInfo(
> +    IN  PXENVBD_FRONTEND    Frontend
>       )
>   {
>       BOOLEAN                 Changed;
> @@ -873,92 +941,6 @@ __ReadDiskInfo(
>             Frontend->DiskInfo.DiskInfo);
>   }
>   
> -static FORCEINLINE VOID
> -FrontendReadFeatures(
> -    IN  PXENVBD_FRONTEND    Frontend
> -    )
> -{
> -    BOOLEAN                 Changed;
> -
> -    Changed = FrontendReadFeature(Frontend,
> -                                  FeatureRemovable,
> -                                  &Frontend->Features.Removable);
> -    Changed |= FrontendReadValue32(Frontend,
> -                                   FeatureMaxIndirectSegments,
> -                                   TRUE,
> -                                   &Frontend->Features.Indirect);
> -    Changed |= FrontendReadFeature(Frontend,
> -                                   FeaturePersistent,
> -                                   &Frontend->Features.Persistent);
> -
> -    if (!Changed)
> -        return;
> -
> -    Verbose("Target[%d] : Features: %s%s%s\n",
> -            Frontend->TargetId,
> -            Frontend->Features.Persistent ? "PERSISTENT " : "",
> -            Frontend->Features.Indirect ? "INDIRECT " : "",
> -            Frontend->Features.Removable ? "REMOVABLE" : "");
> -
> -    if (Frontend->Features.Indirect) {
> -        Verbose("Target[%d] : INDIRECT %x\n",
> -                    Frontend->TargetId,
> -                    Frontend->Features.Indirect);
> -    }
> -}
> -
> -static FORCEINLINE VOID
> -FrontendReadDiskInfo(
> -    IN  PXENVBD_FRONTEND    Frontend
> -    )
> -{
> -    BOOLEAN                 DiscardFeature = FALSE;
> -    BOOLEAN                 DiscardEnable = TRUE;
> -
> -    FrontendReadFeature(Frontend,
> -                        FeatureBarrier,
> -                        &Frontend->DiskInfo.Barrier);
> -    FrontendReadFeature(Frontend,
> -                        FeatureFlushCache,
> -                        &Frontend->DiskInfo.FlushCache);
> -
> -    // discard related
> -    FrontendReadFeature(Frontend,
> -                        FeatureDiscard,
> -                        &DiscardFeature);
> -    FrontendReadFeature(Frontend,
> -                        FeatureDiscardEnable,
> -                        &DiscardEnable);
> -
> -    Frontend->DiskInfo.Discard = DiscardFeature && DiscardEnable;
> -
> -    FrontendReadFeature(Frontend,
> -                        FeatureDiscardSecure,
> -                        &Frontend->DiskInfo.DiscardSecure);
> -    FrontendReadValue32(Frontend,
> -                        FeatureDiscardAlignment,
> -                        TRUE,
> -                        &Frontend->DiskInfo.DiscardAlignment);
> -    FrontendReadValue32(Frontend,
> -                        FeatureDiscardGranularity,
> -                        TRUE,
> -                        &Frontend->DiskInfo.DiscardGranularity);
> -
> -    Verbose("Target[%d] : Features: %s%s%s\n",
> -                Frontend->TargetId,
> -                Frontend->DiskInfo.Barrier ? "BARRIER " : "",
> -                Frontend->DiskInfo.FlushCache ?  "FLUSH " : "",
> -                Frontend->DiskInfo.Discard ? "DISCARD " : "");
> -
> -    if (Frontend->DiskInfo.Discard) {
> -        Verbose("Target[%d] : DISCARD %s%x/%x\n",
> -                    Frontend->TargetId,
> -                    Frontend->DiskInfo.DiscardSecure ? "SECURE " : "",
> -                    Frontend->DiskInfo.DiscardAlignment,
> -                    Frontend->DiskInfo.DiscardGranularity);
> -    }
> -}
> -
>   static FORCEINLINE VOID
>   FrontendReadInquiryOverrides(
>       IN  PXENVBD_FRONTEND    Frontend
> @@ -1142,8 +1124,6 @@ FrontendPrepare(
>               Frontend->BackendDomain,
>               Frontend->BackendPath);
>   
> -    FrontendReadFeatures(Frontend);
> -
>       return STATUS_SUCCESS;
>   
>   fail7:
> @@ -1314,7 +1294,6 @@ abort:
>           goto fail6;
>   
>       // read disk info
> -    __ReadDiskInfo(Frontend);
>       FrontendReadDiskInfo(Frontend);
>   
>       // read inquiry data
> @@ -1332,6 +1311,7 @@ abort:
>   
>   fail7:
>       Error("Fail7\n");
> +    RtlZeroMemory(&Frontend->Features, sizeof(XENVBD_FEATURES));
>   fail6:
>       Error("Fail6\n");
>   fail5:
> @@ -1370,14 +1350,7 @@ FrontendDisconnect(
>       Frontend->Page83.Data = NULL;
>       Frontend->Page83.Size = 0;
>   
> -    // clear some disk info values, so they can be re-read on connect
> -    // allows migration to a backend with different supported features
> -    Frontend->DiskInfo.Barrier = FALSE;
> -    Frontend->DiskInfo.FlushCache = FALSE;
> -    Frontend->DiskInfo.Discard = FALSE;
> -    Frontend->DiskInfo.DiscardSecure = FALSE;
> -    Frontend->DiskInfo.DiscardAlignment = 0;
> -    Frontend->DiskInfo.DiscardGranularity = 0;
> +    RtlZeroMemory(&Frontend->Features, sizeof(XENVBD_FEATURES));
>   }
>   __drv_requiresIRQL(DISPATCH_LEVEL)
>   static FORCEINLINE VOID
> @@ -1649,9 +1622,9 @@ FrontendDebugCallback(
>                    Frontend->Features.Persistent ? "PERSISTENT " : "",
>                    Frontend->Features.Indirect > 0 ? "INDIRECT " : "",
>                    Frontend->Features.Removable ? "REMOVABLE " : "",
> -                 Frontend->DiskInfo.Barrier ? "BARRIER " : "",
> -                 Frontend->DiskInfo.FlushCache ? "FLUSH " : "",
> -                 Frontend->DiskInfo.Discard ? "DISCARD " : "");
> +                 Frontend->Features.Barrier ? "BARRIER " : "",
> +                 Frontend->Features.FlushCache ? "FLUSH " : "",
> +                 Frontend->Features.Discard ? "DISCARD " : "");
>   
>       if (Frontend->Features.Indirect > 0) {
>           XENBUS_DEBUG(Printf,
> @@ -1659,13 +1632,13 @@ FrontendDebugCallback(
>                        "INDIRECT %x\n",
>                        Frontend->Features.Indirect);
>       }
> -    if (Frontend->DiskInfo.Discard) {
> +    if (Frontend->Features.Discard) {
>           XENBUS_DEBUG(Printf,
>                        &Frontend->DebugInterface,
>                        "DISCARD %s%x/%x\n",
> -                     Frontend->DiskInfo.DiscardSecure ? "SECURE " : "",
> -                     Frontend->DiskInfo.DiscardAlignment,
> -                     Frontend->DiskInfo.DiscardGranularity);
> +                     Frontend->Features.DiscardSecure ? "SECURE " : "",
> +                     Frontend->Features.DiscardAlignment,
> +                     Frontend->Features.DiscardGranularity);
>       }
>   
>       XENBUS_DEBUG(Printf,
> @@ -1834,7 +1807,7 @@ FrontendBackend(
>           KeAcquireSpinLock(&Frontend->StateLock, &Irql);
>           // Only attempt this if Active, Active is set/cleared on D3->D0/D0->D3
>           if (Frontend->Active) {
> -            __ReadDiskInfo(Frontend);
> +            FrontendReadDiskInfo(Frontend);
>               __CheckBackendForEject(Frontend);
>           }
>           KeReleaseSpinLock(&Frontend->StateLock, Irql);
> diff --git a/src/xenvbd/frontend.h b/src/xenvbd/frontend.h
> index a83c1f0..34f91b4 100644
> --- a/src/xenvbd/frontend.h
> +++ b/src/xenvbd/frontend.h
> @@ -56,6 +56,12 @@ typedef struct _XENVBD_FEATURES {
>       ULONG                       Indirect;
>       BOOLEAN                     Persistent;
>       BOOLEAN                     Removable;
> +    BOOLEAN                     Barrier;
> +    BOOLEAN                     FlushCache;
> +    BOOLEAN                     Discard;
> +    BOOLEAN                     DiscardSecure;
> +    ULONG                       DiscardAlignment;
> +    ULONG                       DiscardGranularity;
>   } XENVBD_FEATURES, *PXENVBD_FEATURES;
>   
>   typedef struct _XENVBD_DISKINFO {
> @@ -63,12 +69,6 @@ typedef struct _XENVBD_DISKINFO {
>       ULONG                       SectorSize;
>       ULONG                       PhysSectorSize;
>       ULONG                       DiskInfo;
> -    BOOLEAN                     Barrier;
> -    BOOLEAN                     FlushCache;
> -    BOOLEAN                     Discard;
> -    BOOLEAN                     DiscardSecure;
> -    ULONG                       DiscardAlignment;
> -    ULONG                       DiscardGranularity;
>   } XENVBD_DISKINFO, *PXENVBD_DISKINFO;
>   
>   typedef struct _XENVBD_FRONTEND XENVBD_FRONTEND, *PXENVBD_FRONTEND;
> diff --git a/src/xenvbd/ring.c b/src/xenvbd/ring.c
> index 86a71ac..50f8d58 100644
> --- a/src/xenvbd/ring.c
> +++ b/src/xenvbd/ring.c
> @@ -914,7 +914,7 @@ BlkifRingPrepareSyncCache(
>       InitializeListHead(&List);
>       Srb->SrbStatus = SRB_STATUS_PENDING;
>   
> -    if (FrontendGetDiskInfo(Frontend)->FlushCache)
> +    if (FrontendGetFeatures(Frontend)->FlushCache)
>           Operation = BLKIF_OP_FLUSH_DISKCACHE;
>       else
>           Operation = BLKIF_OP_WRITE_BARRIER;
> diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
> index f07ee8b..a07fc45 100644
> --- a/src/xenvbd/target.c
> +++ b/src/xenvbd/target.c
> @@ -806,7 +806,7 @@ TargetInquiryB0(
>       IN  PSCSI_REQUEST_BLOCK Srb
>       )
>   {
> -    PXENVBD_DISKINFO        DiskInfo = FrontendGetDiskInfo(Target->Frontend);
> +    PXENVBD_FEATURES        Features = FrontendGetFeatures(Target->Frontend);
>       PVPD_BLOCK_LIMITS_PAGE  Data = Srb->DataBuffer;
>       ULONG                   Length = Srb->DataTransferLength;
>   
> @@ -822,10 +822,10 @@ TargetInquiryB0(
>       Data->PageCode = 0xB0;
>       Data->PageLength[1] = 0x3C; // as per spec
>   
> -    *(PULONG)Data->OptimalUnmapGranularity = _byteswap_ulong(DiskInfo->DiscardGranularity);
> -    *(PULONG)Data->UnmapGranularityAlignment = _byteswap_ulong(DiskInfo->DiscardAlignment);
> +    *(PULONG)Data->OptimalUnmapGranularity = _byteswap_ulong(Features->DiscardGranularity);
> +    *(PULONG)Data->UnmapGranularityAlignment = _byteswap_ulong(Features->DiscardAlignment);
>       // alignment is only valid if a granularity has been set
> -    Data->UGAValid = (DiskInfo->DiscardGranularity != 0) ? 1 : 0;
> +    Data->UGAValid = (Features->DiscardGranularity != 0) ? 1 : 0;
>   
>       Srb->DataTransferLength = sizeof(VPD_BLOCK_LIMITS_PAGE);
>       Srb->SrbStatus = SRB_STATUS_SUCCESS;



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 20 09:59:14 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 20 Feb 2026 09:59:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1236968.1539440 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vtNI1-00052y-Ni; Fri, 20 Feb 2026 09:59:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1236968.1539440; Fri, 20 Feb 2026 09:59:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vtNI1-00052r-LG; Fri, 20 Feb 2026 09:59:13 +0000
Received: by outflank-mailman (input) for mailman id 1236968;
 Fri, 20 Feb 2026 09:59:11 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=UO+k=AY=bounce.vates.tech=bounce-md_30504962.6998306c.v1-f663a13e695841e783df83c26375591c@srs-se1.protection.inumbo.net>)
 id 1vtNHz-00052U-Lo
 for win-pv-devel@lists.xenproject.org; Fri, 20 Feb 2026 09:59:11 +0000
Received: from mail186-12.suw21.mandrillapp.com
 (mail186-12.suw21.mandrillapp.com [198.2.186.12])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id cca8b199-0e42-11f1-b164-2bf370ae4941;
 Fri, 20 Feb 2026 10:59:09 +0100 (CET)
Received: from pmta10.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail186-12.suw21.mandrillapp.com (Mailchimp) with ESMTP id
 4fHQgw39xGz705kfl
 for <win-pv-devel@lists.xenproject.org>; Fri, 20 Feb 2026 09:59:08 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 f663a13e695841e783df83c26375591c; Fri, 20 Feb 2026 09:59:08 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: cca8b199-0e42-11f1-b164-2bf370ae4941
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1771581548; x=1771851548;
	bh=9VpoScZXPlfHTx4XsMBXFsZeqkwfTLOssPUxnkJ16YI=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=hFchlDbPoxYb8f3q0+9pvFwrl89XkVaTTFc3PFNWiN5SWYiUoPXtYswWC5meN1DMI
	 KXdKgOCrSPJV+NsuEDf8YRr+fLGanlL7rIOjGJpINPh2V8ENUnMLCZb6yU4SVlQfoU
	 VtQh4trXBk6QdD4a9bgrKNtWPYpeuFQrRBJ/sD6e3ow/cQBE8YYZuvmXZ0USOWjtWk
	 +6OM1N7vKTHuODjpOBbl12Lhi8PFxmWtcjP7wxGoHzXZGEr1inUtja2PdkdPIAjnxH
	 nmI8ZWj+8YvJtrVdqbIERmC2weSmMvN8z1ZJTzH+aWh1Fi4lqNCo1Naz8mzfaJtREP
	 /2nNs83hUoEpw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1771581548; x=1771842048; i=ngoc-tu.dinh@vates.tech;
	bh=9VpoScZXPlfHTx4XsMBXFsZeqkwfTLOssPUxnkJ16YI=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=nyesf9VMjGiK2VG/YGO/ftYwmvzefpa0ZoMfzYhblF7lk5xFV2XVTPGNpW3IsAPt6
	 HhCYWO3OJNyIE+5AUSsjTLu1gSZBJzBhBFrmtyTdIYbHRtQ0q5Qa0TO+eaXG0up6QV
	 YqTEX2S+/HP+xv12FDtP94FxXrWbsvrP54cDdisHnsMynUKhfq4Ph+7QzkKubQy7zo
	 08C+mFWM3e5UnyjrycD/cjHfnSiuTpYy0Rl9aYm9RFXezjZsKvjRChkJqD8ftPxngG
	 bKGGFOYcTQU4By2j+WPEjwkgdezduuVO56nAmBEDvl9/RYRVr8mg8gREJ523NCvLEL
	 sjUeL/NQdbILQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=201/3]=20XenDisk:=20Report=20Discard=20support=20by=20issuing=20an=20Inquiry?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1771581547490
Message-Id: <57028849-659b-42e0-8b1f-64522b3e798e@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
Cc: "Owen Smith" <owen.smith@cloud.com>
References: <20260219143954.1450-1-owen.smith@citrix.com>
In-Reply-To: <20260219143954.1450-1-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.f663a13e695841e783df83c26375591c?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260220:md
Date: Fri, 20 Feb 2026 09:59:08 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 19/02/2026 15:40, Owen Smith wrote:
> From: Owen Smith <owen.smith@cloud.com>
> 
> When XenDisk starts, issue an inquiry to determine the status of discard
> support in the backend. If the backend exposes discard support, allow
> XenDisk to respond to the appropriate property requests, and forward the
> trim requests to XenVbd.
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

I might have missed something, but isn't this already done in xenvbd's 
TargetUnmap, and so xendisk shouldn't need to probe this by itself?

Also, at this point I wonder which other feature could we remove from 
xendisk and fold into xenvbd instead.

> ---
>   src/xendisk/pdo.c | 88 ++++++++++++++++++++++++++++++++++++++++++++---
>   1 file changed, 84 insertions(+), 4 deletions(-)
> 
> diff --git a/src/xendisk/pdo.c b/src/xendisk/pdo.c
> index f714efb..5d40a13 100644
> --- a/src/xendisk/pdo.c
> +++ b/src/xendisk/pdo.c
> @@ -63,6 +63,7 @@ struct _XENDISK_PDO {
>       PXENDISK_FDO                Fdo;
>   
>       BOOLEAN                     InterceptTrim;
> +    BOOLEAN                     DiscardSupported;
>       ULONG                       SectorSize;
>       ULONG                       PhysSectorSize;
>   };
> @@ -519,6 +520,72 @@ fail1:
>       return status;
>   }
>   
> +static NTSTATUS
> +PdoSendInquiryB0Synchronous(
> +    IN  PXENDISK_PDO        Pdo,
> +    OUT PBOOLEAN            Supported
> +    )
> +{
> +    SCSI_REQUEST_BLOCK      Srb;
> +    PCDB                    Cdb;
> +    PVPD_BLOCK_LIMITS_PAGE  BlockLimits;
> +    ULONG                   Length;
> +    NTSTATUS                status;
> +
> +    Trace("====>\n");
> +
> +    Length = sizeof(VPD_BLOCK_LIMITS_PAGE);
> +    *Supported = FALSE;
> +
> +    status = STATUS_NO_MEMORY;
> +    BlockLimits = __PdoAllocate(Length);
> +    if (BlockLimits == NULL)
> +        goto fail1;
> +
> +    RtlZeroMemory(&Srb, sizeof(SCSI_REQUEST_BLOCK));
> +    Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
> +    Srb.SrbFlags = 0;
> +    Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
> +    Srb.DataBuffer = BlockLimits;
> +    Srb.DataTransferLength = Length;
> +    Srb.TimeOutValue = (ULONG)-1;
> +    Srb.CdbLength = 6;
> +
> +    Cdb = (PCDB)&Srb.Cdb[0];
> +    Cdb->CDB6INQUIRY3.OperationCode = SCSIOP_INQUIRY;
> +    Cdb->CDB6INQUIRY3.PageCode = 0xB0;
> +    Cdb->CDB6INQUIRY3.EnableVitalProductData = 1;
> +    Cdb->CDB6INQUIRY3.AllocationLength = (UCHAR)Length;
> +
> +    status = PdoSendAwaitSrb(Pdo, &Srb);
> +    if (!NT_SUCCESS(status))
> +        goto fail2;
> +
> +    status = STATUS_UNSUCCESSFUL;
> +    if (Srb.DataTransferLength < Length)
> +        goto fail3;
> +
> +    *Supported = BlockLimits->UGAValid;
> +
> +    __PdoFree(BlockLimits);
> +
> +    Trace("<====\n");
> +    return STATUS_SUCCESS;
> +
> +fail3:
> +    Error("fail3\n");
> +
> +fail2:
> +    Error("fail2\n");
> +
> +    __PdoFree(BlockLimits);
> +
> +fail1:
> +    Error("fail1 (%08x)\n", status);
> +
> +    return status;
> +}
> +
>   static NTSTATUS
>   PdoSendTrimSynchronous(
>       IN  PXENDISK_PDO            Pdo,
> @@ -674,7 +741,7 @@ PdoQueryProperty(
>   
>       switch (Query->PropertyId) {
>       case StorageDeviceTrimProperty:
> -        if (!Pdo->InterceptTrim) {
> +        if (!Pdo->InterceptTrim || !Pdo->DiscardSupported) {
>               status = PdoForwardIrpAndForget(Pdo, Irp);
>               break;
>           }
> @@ -753,7 +820,7 @@ PdoManageDataSetAttributes(
>   
>       switch (Attributes->Action) {
>       case DeviceDsmAction_Trim:
> -        if (!Pdo->InterceptTrim) {
> +        if (!Pdo->InterceptTrim || !Pdo->DiscardSupported) {
>               status = PdoForwardIrpAndForget(Pdo, Irp);
>               break;
>           }
> @@ -830,6 +897,7 @@ PdoStartDevice(
>       ULONG               PhysSectorSize;
>       ULONG64             SectorCount;
>       ULONG64             Size;
> +    BOOLEAN             DiscardSupported;
>       POWER_STATE         PowerState;
>       NTSTATUS            status;
>   
> @@ -848,14 +916,22 @@ PdoStartDevice(
>       if (!NT_SUCCESS(status))
>           goto fail3;
>   
> +    status = PdoSendInquiryB0Synchronous(Pdo,
> +                                         &DiscardSupported);
> +    if (!NT_SUCCESS(status))
> +        goto fail4;
> +
>       Pdo->SectorSize = SectorSize;
>       Pdo->PhysSectorSize = PhysSectorSize;
> +    Pdo->DiscardSupported = DiscardSupported;
>   
>       Size = SectorSize * SectorCount;
>       Size >>= 20; // Scale to megabytes
>   
> -    Verbose("%s: %luMB (%uB sectors)\n",
> -            __PdoGetName(Pdo), Size, SectorSize);
> +    Verbose("%s: %luMB (%uB sectors)%s%s\n",
> +            __PdoGetName(Pdo), Size, SectorSize,
> +            Pdo->DiscardSupported ? " DISCARD" : "",
> +            Pdo->InterceptTrim ? "" : " (VETOED)");
>   
>       __PdoSetSystemPowerState(Pdo, PowerSystemWorking);
>       __PdoSetDevicePowerState(Pdo, PowerDeviceD0);
> @@ -874,6 +950,9 @@ PdoStartDevice(
>   
>       return STATUS_SUCCESS;
>   
> +fail4:
> +    Error("fail4\n");
> +
>   fail3:
>       Error("fail3\n");
>   
> @@ -1904,6 +1983,7 @@ PdoDestroy(
>       Dx->Pdo = NULL;
>   
>       Pdo->InterceptTrim = FALSE;
> +    Pdo->DiscardSupported = FALSE;
>   
>       RtlZeroMemory(Pdo->Name, sizeof (Pdo->Name));
>   



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Feb 24 15:10:32 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 24 Feb 2026 15:10:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1240148.1541636 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vuu3T-0004M2-2W; Tue, 24 Feb 2026 15:10:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1240148.1541636; Tue, 24 Feb 2026 15:10:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vuu3S-0004Lv-W2; Tue, 24 Feb 2026 15:10:30 +0000
Received: by outflank-mailman (input) for mailman id 1240148;
 Tue, 24 Feb 2026 15:10:29 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Fveg=A4=citrix.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1vuu3R-0004Lp-JA
 for win-pv-devel@lists.xenproject.org; Tue, 24 Feb 2026 15:10:29 +0000
Received: from SJ2PR03CU001.outbound.protection.outlook.com
 (mail-westusazlp170120002.outbound.protection.outlook.com
 [2a01:111:f403:c001::2])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id f02664e5-1192-11f1-9ccf-f158ae23cfc8;
 Tue, 24 Feb 2026 16:10:24 +0100 (CET)
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by DS7PR03MB5607.namprd03.prod.outlook.com (2603:10b6:5:2ce::21) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9632.15; Tue, 24 Feb
 2026 15:10:17 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9632.017; Tue, 24 Feb 2026
 15:10:15 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: f02664e5-1192-11f1-9ccf-f158ae23cfc8
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=roaxyYjck05Xq2v3bnpZJUqzOSOKYSmCO8aCDCZwYk7vCNpWWh/a7OVEBiEANpO2RHEZYH/GhKm2A6gSz3McE5W/pxxJXUMWE1CFmVcGGyguOlFwbIhhEgCYzT9VktOx7s/8Wj2/5fw4BG6koljmRaW0/RL2EjthIMvJu98tS2fbMmnV755dfLajnIvM8KniIXnJ0L8QQUBolNM4iq+LlsDfnOIWj2GMe7EnqFQcqPqzxlO8k+uWUN+iLK7QUgirAq4jqFMHAWJ3ksQ2/xcNJ8v0Jz00Mj4GNpeO1LEd8IYWMrpACXAyJiwsMYYEKxJS9iUR84pgVhTR47pBcs/kdg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector10001;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=UsTfvAYMOR94OuVonO3HuQoboAndvw3SLhB3z7Yylrk=;
 b=LXCH4Cc2F4JF+lfk1YXLw3ugWAFJefeRYGpQfnnrBYPggk2f1fSD/6LYI++7zOxyNL8GTkLjhcTN5sdxUl/bQHb3NxX5G0NtDwbjphTVz8vMgUOePA3cGiDtueKoXAEPu5ZojHSUCl1qIB1L5tJjVnDD2LiWWn2uNq5cbaykrSdhhss6erR1VxHzSmQVqdru3FIEJLa49LCPgRlRvdcM+7Zj6artjfDjp4m5p+LI+Gp2qNlPKuMRSTo0gkYkKoBAF4oMqbqQkhMRRnvNoFdqT3Bcme41MxnM1xl5bPlPJbdEQImKZQD99E77Q7RGXxPGE1OALc1NZPF77bhDpk+yWA==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=UsTfvAYMOR94OuVonO3HuQoboAndvw3SLhB3z7Yylrk=;
 b=z8X0iCri/bAseVuftN5YCgrHOAfZS48Cbqf73vAmYL69Sxw0a8TujFVkXEfArVal94+78neSd7pyYQGcWD/SdYVxaqbjvYjka2LbqSljLpxnEoBtLYRPKhQ32YFrYB6I+Ep7/J640YFp7emn16zQoLNnev/BAoGHsItX195tVfQ=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@cloud.com>
Subject: Re: [PATCH 1/3] XenDisk: Report Discard support by issuing an Inquiry
Thread-Topic: [PATCH 1/3] XenDisk: Report Discard support by issuing an
 Inquiry
Thread-Index: AQHcoa2igq790CK2pEeqs28w9wVVLrWLW8AAgAafWVk=
Date: Tue, 24 Feb 2026 15:10:15 +0000
Message-ID:
 <SA6PR03MB776095746FA6DC011AF0450FFE74A@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <20260219143954.1450-1-owen.smith@citrix.com>
 <57028849-659b-42e0-8b1f-64522b3e798e@vates.tech>
In-Reply-To: <57028849-659b-42e0-8b1f-64522b3e798e@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|DS7PR03MB5607:EE_
x-ms-office365-filtering-correlation-id: 0f4f51ce-945b-4eb6-8148-08de73b6d0d2
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|1800799024|366016|376014|38070700021|3613699012;
x-microsoft-antispam-message-info:
 =?iso-8859-1?Q?LuEVC42sZu1HzAI1uMroh0AxO6TLUrsZXPn2kbVNuhpF9hRmDfo8BHrtP+?=
 =?iso-8859-1?Q?IJXZKU3RzqIzd/ZYO5Vvq8b23C300RcmWlv0CQ2LxPxSIfbThT3jgvynRh?=
 =?iso-8859-1?Q?2Os+iCb94jVFs97pD4O4/c6egNclZ4drC2bNsXIggoHg5sEUusBPKfPjh/?=
 =?iso-8859-1?Q?jGMzxlm29A1dkTJRqm+gHWP7rxevKSvBeCMGXKuWaLYctoXmBBUodk8ZtO?=
 =?iso-8859-1?Q?S3Uce4MCR3JRMLultXhSIhdRdZIaIJNM1D1jIPOIP9plJucvB4T/mdqljp?=
 =?iso-8859-1?Q?5G+j6DznPHNLV7TUsE5mHnM2xM6wH9fyqyaxBaa+jtqKe1JzDYjOO8nasH?=
 =?iso-8859-1?Q?U2nIDO6SrRv6ExIXECLS+OSqxEhJzbInXVUng7i39TVJGCg0MVa5ETmRQ9?=
 =?iso-8859-1?Q?8V2lFfkx25idzkBK8HM4+Mx0ygcA+/n299s7ZZOx15DF0ESw69zWJrEDZ3?=
 =?iso-8859-1?Q?9tkEFi+0RcOZzMYB/XbAIlaLPqY/GF+Ez0Fon47iE6nhDHWsW5DHYEZbXs?=
 =?iso-8859-1?Q?2aWFLXNJFQDs2x8gU5+bNTEcOmm7Mi7kJ2R9AskVpEEYlH0fNd0QW+Cwep?=
 =?iso-8859-1?Q?7F4RV42y7B6M3VuZ6ll3ijOICc5ntBxDtTsb8SbD/GOmKwoLUz9BhOU0lP?=
 =?iso-8859-1?Q?nfNeOWt9hRarY1aQmvB7ywd3oV7AoeXQtuFIiZhvEX9pZnN/VgCpSdrueh?=
 =?iso-8859-1?Q?6Fac10c1JeUWwam8n2NljWPZB9xA9IS+PerOuyBkG2bSZ0imS3FH20uLSa?=
 =?iso-8859-1?Q?g0VrB+BEVXAJxQln8SidIsPyreK5P8Wjhfi0349TV86mRiBZdbnPvsNR2z?=
 =?iso-8859-1?Q?bWgMpBf8nJAuGpMbC/4CmQuSo7xJCxaTaB/dSW7+gYFPGetpn7hL341bNK?=
 =?iso-8859-1?Q?XugVIj2YN9cX4DI2bCDXg6rEHlzNQkrQjdZNsTWP/0HmYjoIlT4C7SlZKS?=
 =?iso-8859-1?Q?IYm0DycCGW/KLfbHfRTcgcX5+DGBYXrtyNXMbeRvu4O62AJLejuLDGK90j?=
 =?iso-8859-1?Q?b4Kae5V+UiMTz3sfptREN2FpzPD27qYCV4jUL/enCkP3hrQIhsDTc3JBrt?=
 =?iso-8859-1?Q?4Ej8k2OICaSo8nm0hlklWJ9dQQykDR3pg7qEgVX093uX5uCdH9ifXpkq4R?=
 =?iso-8859-1?Q?1ZHJSa2qD/hypu6rLmks3dy5JRDbO+O8fdtttgtGm0pOMcjgK39TI+n2kT?=
 =?iso-8859-1?Q?V6/HF4WMrDMMdNzG6nQuBcV6qQhh2vB3Rxj51TH4Oaw0cU/gBNMCzgC8nR?=
 =?iso-8859-1?Q?waRDiws0vU3TKhCYlTyqqz1sJwfmBCVqlYTcUTeiBtQHIFjyN0E94ziQei?=
 =?iso-8859-1?Q?64PgO918L7XRDqf8WhXbATBNXTZLtz0nXCzu8JIx9Wy6PRBhlTqJrMbe9t?=
 =?iso-8859-1?Q?uH0Q/hKxV6BsVEeqbOQ2GDcClcEud0WbX6r9BVjMpUW50oISUC+ZhGzgel?=
 =?iso-8859-1?Q?aXYVK+IHzndsmyzKt5DmemrrdVjA8JVU1fkHdti+QdLuMH/f3MXzIoDZoW?=
 =?iso-8859-1?Q?pvJP+bmpj5Ir+pOfX5yJ6UsUGT7z0D354oTNini8xFHTZeDEljilDKs5XD?=
 =?iso-8859-1?Q?nqNAF0UT3iTwVvD4kFXggM7GbwZf4YcpEZ1qoN29SCaADbfAMQWH9f9+LR?=
 =?iso-8859-1?Q?SCzMPZtPI3oYzoVZ5Oq2r0HNvCFsKW/QYqBEdU0M6G7kB9516pTSao/kvf?=
 =?iso-8859-1?Q?OpiW53Rsh5cEVhrEiecneZVvMTwTugssSNKCbleo?=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(38070700021)(3613699012);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?iso-8859-1?Q?T6dilcGk35Meg/tFPnhhlizJ5An1SK07vOwkvrcJkFW1SG800+YOQT8gHK?=
 =?iso-8859-1?Q?6xxqPzZAuwHvpT6J0f5qWFLSDrZpdFDZi7mcMz01NmOm0TQSG3XJU8rvuV?=
 =?iso-8859-1?Q?N6MSNP8dDMv1/9GaoYuaZoJGHt3n2vo1saIBCPH23da8rXiB9Jo50OzTU4?=
 =?iso-8859-1?Q?uQrh0wdCnQAA9ctwpquSPZNm4P/wIR65P1h9pnzTGz2Yf72jXs+14lc7Bh?=
 =?iso-8859-1?Q?kKl5BYBbzfO7K4bsBgsiuSjcqLJ53WMiRbBtIj5lhv+EAQdaZDeTYW77cd?=
 =?iso-8859-1?Q?pBpiF8gHbn1idaz0rmihM57pc3RFFWKxZFSLQex7wvxJ7BU/rxEejZ+28x?=
 =?iso-8859-1?Q?MdSLmTV8l+nlMpqcVglsmL7z5G/KtJutDtWVYLB0+poF/vIfwoMfnx+Tfp?=
 =?iso-8859-1?Q?E0BDzVQnTA+hqaK4OMwdWpQhDST6G2U8GznU3jC+ob7p2CGiXooq3+Lqa6?=
 =?iso-8859-1?Q?qkwqeJNY+kFR5oSB2gpEXFQqlUr4rXgc/umUJm9F6TEDG25c4PzEcXHYO6?=
 =?iso-8859-1?Q?pXUZOiTwJ2Eap1ZuYMBqmCCMDJ04yEydWl9XtciP3brHApRtqBHUc08FeA?=
 =?iso-8859-1?Q?TAfwN561pznZ7lqjo6NXTZ7xpH+L3/xZeiutIhD0sFC/QgFw3x3naq90l/?=
 =?iso-8859-1?Q?3QJX7E1Yt7UXZDAk1VRtesvvxtYgPObYS/H64EKnFWAcjeLAtCDQtqpjna?=
 =?iso-8859-1?Q?Ukj5Gk+pZKaPLuqUkP/JYRlbTUVS0V5QMtu0uUw7nCKh7HB9DW71xboW0k?=
 =?iso-8859-1?Q?20tTpw8aHuUDt9OLCKaaTGgUmWFEcYskFfC9YD589NKL2L//Ks0rbe+waw?=
 =?iso-8859-1?Q?rMPMCGpNOhVprBysujcpGAOaG7Tif2Q0ogpR11JMM+HozXv3bsWYVMuwTE?=
 =?iso-8859-1?Q?37mBADXCKwOYWSnzvf3A2LAwssi5JoTHXNrSO07fxltpFlfpbxUEZrJjrC?=
 =?iso-8859-1?Q?sreBX0dPFd7+1OzfrCEAii03WDtHZrv1PlUIZxvGLl/QCbcwX5R+3z+pj7?=
 =?iso-8859-1?Q?MDrwLfdrhoUalBGyJG+hW3kfX1FX+CPLjuSdZ373MaxdQmQjl0ZjnfMhDS?=
 =?iso-8859-1?Q?qANs5aLbXnbiqnDd4fVZmLhd2Cxh9Rbxe1wrhL8UFs/cGDw8RXT31cYLau?=
 =?iso-8859-1?Q?tNtOC4UxQa16EPmvtKPCcIhCN+rHgrnB+H1bDK4RG1zyJy0l0zGOR7UvYu?=
 =?iso-8859-1?Q?HHZIIt1D3JeB+0ld8mrlWBKgULd3xaqBoplJz978GLUrawyJeiKn8BAhVF?=
 =?iso-8859-1?Q?Wvq99XxnNl5gJ9okh++5vbpYJNoJiQrh7c+GcLtLJuFafbMlaj23YtUgw5?=
 =?iso-8859-1?Q?0N+e7WzBXj9/N04qn/EhzBqBhMRY5641Qb26+MgZtyQqZNrUV2OhlVqkJf?=
 =?iso-8859-1?Q?mjGGMtzFr48+W41Xfw1tRahY9XMVJ0HsGdvs3vCsG5XHLNEdZxKEkLoV93?=
 =?iso-8859-1?Q?XZn7OPz0lIFT3vwnd9ClbZRACJe3fEnknijc/v76o3L7X9TfOHisUYwcR1?=
 =?iso-8859-1?Q?YKxUt9pSt5cT0LcZbjTOqAs7o3XKb3tZuEIageOt+vpCsdU3TVMohqKq8j?=
 =?iso-8859-1?Q?FqYwKnsVVTeHuBunciUqOC9Zec0N2BPsZyGkwrbu3G+QfeE8odbBJyPMG5?=
 =?iso-8859-1?Q?8FQzn9nol50+hnTKhtVJtuLnp0hTPEDwV7BsQHGefqgBZfGG/Qzm6oE+Gg?=
 =?iso-8859-1?Q?kb8eoWaneyic9XZgxHkFLjFdfR7cf2dtPcCR9gCltdL2UyoIV6YbKuCi2e?=
 =?iso-8859-1?Q?od2in5duMq66YDUK1hNirL7nGRO70iUVK81dNN+RDnmpKT?=
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 0f4f51ce-945b-4eb6-8148-08de73b6d0d2
X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Feb 2026 15:10:15.7349
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: oHbZoSXjDmTaXn02oq+hDMh7f60qksVFpPEQDSBn3WtONQaFrdfwQz7oTu16WXWM8J07Tj58KHoBeRnx7AMscQ==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB5607

> From: Owen Smith <owen.smith@cloud.com>=0A=
>=0A=
> When XenDisk starts, issue an inquiry to determine the status of discard=
=0A=
> support in the backend. If the backend exposes discard support, allow=0A=
> XenDisk to respond to the appropriate property requests, and forward the=
=0A=
> trim requests to XenVbd.=0A=
>=0A=
> Signed-off-by: Owen Smith <owen.smith@citrix.com>=0A=
=0A=
I might have missed something, but isn't this already done in xenvbd's=0A=
TargetUnmap, and so xendisk shouldn't need to probe this by itself?=0A=
=0A=
Also, at this point I wonder which other feature could we remove from=0A=
xendisk and fold into xenvbd instead.=0A=
=0A=
=0A=
=0A=
IIRC, storport didnt expose discard support correctly, and we needed =0A=
xendisk to intercept discard requests and build the SRBs which pass=0A=
through storport.=0A=
This patch allows xendisk to query xenvbd's (and the backend's) support=0A=
for discard, and skips parsing discard requests for a backend that doesnt=
=0A=
support them.=0A=
=0A=
Owen=


From win-pv-devel-bounces@lists.xenproject.org Tue Feb 24 18:55:11 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 24 Feb 2026 18:55:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1240240.1541689 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vuxYr-00012P-VY; Tue, 24 Feb 2026 18:55:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1240240.1541689; Tue, 24 Feb 2026 18:55:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vuxYr-00012H-St; Tue, 24 Feb 2026 18:55:09 +0000
Received: by outflank-mailman (input) for mailman id 1240240;
 Tue, 24 Feb 2026 18:55:08 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=adGY=A4=bounce.vates.tech=bounce-md_30504962.699df407.v1-d62faf9af0814d5cad4971d82716d883@srs-se1.protection.inumbo.net>)
 id 1vuxYq-00012B-Gb
 for win-pv-devel@lists.xenproject.org; Tue, 24 Feb 2026 18:55:08 +0000
Received: from mail187-10.suw11.mandrillapp.com
 (mail187-10.suw11.mandrillapp.com [198.2.187.10])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 53fe3f8d-11b2-11f1-b164-2bf370ae4941;
 Tue, 24 Feb 2026 19:55:06 +0100 (CET)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-10.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fL6NR0sVbz5QlFqL
 for <win-pv-devel@lists.xenproject.org>; Tue, 24 Feb 2026 18:55:03 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 d62faf9af0814d5cad4971d82716d883; Tue, 24 Feb 2026 18:55:03 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 53fe3f8d-11b2-11f1-b164-2bf370ae4941
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1771959303; x=1772229303;
	bh=akuwsseroVqPCm1HVATz4uxN8bJR13g+j52U0EyNP2M=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=0OFR9lhF+qaCNKzcCZ/N2TZKzWb1NmJ3qt3y1hDgug8h2z6pW/DO3vCNIkUcnsIn2
	 4L63bPX7g1KNMe+eOEBg28Pp1Scgb3VhWRj3pCEQhzrBBlLEAIz7clD2q/UcuZOUr3
	 LaWml0Y++w849gAt3gfmZqsSJdQHCklcLGBE049iSlEWrd2aDYV4iBchABLteZkyP0
	 0DmHDwW9jsYpNLEezTWCII84v3WtxR2EjU4CaYYhEMWEHn7wzqiXekUbOt+l6MhRXP
	 hWgOZCd5M2Irpz0toB7UyIiAm4nuqz14AUGjOwcH9ZVc0TT0mzCGmM3/GFrQ50BgzY
	 12kFguA3W8zrg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1771959303; x=1772219803; i=ngoc-tu.dinh@vates.tech;
	bh=akuwsseroVqPCm1HVATz4uxN8bJR13g+j52U0EyNP2M=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=KX/LH0iBWjGdJPD3bfAcCBbfIOUoMdomaAfAAN6YPgqf7L0bykPb8CMNdi+KqETo3
	 gQ42Cdq3AvTSOqOkqx0oS6xr5SZGxAdFnsqkqdXdxm7sj2SSrEwtMF/q2Hcq6XB2ZQ
	 S/7QB9VeVH1AbGl6DYtsG6aeIxapoMkE6aaocKGZXiG/aLzEDF5+E4KF9qel5oIA1f
	 GFmOITs61tUJEGXBbvVGsU6hMY++HJMce7zaHJ6J1iQ6HLU93+ZfTtU4qraBlOTax2
	 nPf2GbsEqWwBB4m9ojZ69pSoepr+IS5cDJ+r4Ru9vs/ExhrZ5/50lKKxroghAD6+la
	 mYnrYaGy01cjg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=201/3]=20XenDisk:=20Report=20Discard=20support=20by=20issuing=20an=20Inquiry?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1771959301790
Message-Id: <99acb218-8380-43db-b4be-0ae5a1a9f027@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
Cc: "Owen Smith" <owen.smith@cloud.com>
References: <20260219143954.1450-1-owen.smith@citrix.com> <57028849-659b-42e0-8b1f-64522b3e798e@vates.tech> <SA6PR03MB776095746FA6DC011AF0450FFE74A@SA6PR03MB7760.namprd03.prod.outlook.com>
In-Reply-To: <SA6PR03MB776095746FA6DC011AF0450FFE74A@SA6PR03MB7760.namprd03.prod.outlook.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.d62faf9af0814d5cad4971d82716d883?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260224:md
Date: Tue, 24 Feb 2026 18:55:03 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 24/02/2026 16:10, Owen Smith wrote:
>> From: Owen Smith <owen.smith@cloud.com>
>>
>> When XenDisk starts, issue an inquiry to determine the status of discard
>> support in the backend. If the backend exposes discard support, allow
>> XenDisk to respond to the appropriate property requests, and forward the
>> trim requests to XenVbd.
>>
>> Signed-off-by: Owen Smith <owen.smith@citrix.com>
> 
> I might have missed something, but isn't this already done in xenvbd's
> TargetUnmap, and so xendisk shouldn't need to probe this by itself?
> 
> Also, at this point I wonder which other feature could we remove from
> xendisk and fold into xenvbd instead.
> 
> 
> 
> IIRC, storport didnt expose discard support correctly, and we needed
> xendisk to intercept discard requests and build the SRBs which pass
> through storport.
> This patch allows xendisk to query xenvbd's (and the backend's) support
> for discard, and skips parsing discard requests for a backend that doesnt
> support them.
> 
> Owen

I think this has already been fixed in Server 2012 [1]? xenvbd should be 
able to process IOCTLs directly via SRB_FUNCTION_IO_CONTROL instead of 
needing a filter driver. I don't know if it needs to implement 
IOCTL_STORAGE_QUERY_PROPERTY on top of reporting the right SCSI VPD 
page, but the storahci example doesn't seem to need it to support 
SCSIOP_UNMAP.

This patch also seems to have broken TRIM reporting since TargetUnmap is 
no longer reached, and `fsutil fsinfo sectorInfo` now reports "Trim Not 
Supported".
I think it's because if the initial TRIM probe fails, xendisk 
unconditionally forwards the StorageDeviceTrimProperty IRP down to 
xenvbd which doesn't know how to handle it, and then classpnp falls back 
to detecting LBProvisioningData.LBPU (which is also not supported) instead.
So xendisk still has to lie about StorageDeviceTrimProperty (as with the 
previous behavior) in order to keep the previous behavior of silently 
swallowing unsupported operations.
This is also important to keep advertising the disk as SSD and avoid 
automatic defragmentation (as Windows will assume the drive to be HDD 
and defrag anyway if TRIM is not supported)

[1] 
https://learn.microsoft.com/en-us/windows/compatibility/new-api-allows-apps-to-send-trim-and-unmap-hints



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Feb 26 10:59:54 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 26 Feb 2026 10:59:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1241412.1542446 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vvZ61-0007pi-2I; Thu, 26 Feb 2026 10:59:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1241412.1542446; Thu, 26 Feb 2026 10:59:53 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vvZ60-0007pa-Vk; Thu, 26 Feb 2026 10:59:52 +0000
Received: by outflank-mailman (input) for mailman id 1241412;
 Thu, 26 Feb 2026 10:59:51 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=8OGu=A6=bounce.vates.tech=bounce-md_30504962.69a027a2.v1-32e84c68283344feace5164b56d054b4@srs-se1.protection.inumbo.net>)
 id 1vvZ5z-0007pS-59
 for win-pv-devel@lists.xenproject.org; Thu, 26 Feb 2026 10:59:51 +0000
Received: from mail187-10.suw11.mandrillapp.com
 (mail187-10.suw11.mandrillapp.com [198.2.187.10])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 439f884c-1302-11f1-b164-2bf370ae4941;
 Thu, 26 Feb 2026 11:59:49 +0100 (CET)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-10.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fM7l61ynKz5QkLc4
 for <win-pv-devel@lists.xenproject.org>; Thu, 26 Feb 2026 10:59:46 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 32e84c68283344feace5164b56d054b4; Thu, 26 Feb 2026 10:59:46 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 439f884c-1302-11f1-b164-2bf370ae4941
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1772103586; x=1772373586;
	bh=m7IvLpDweN5yO2W6/wTfDs8I5gBqBkUhcIuhIJUIfd8=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=b6LNLKwxptVm+hHmvTU0alP96heriAivFXzmyp8+4+1OrqdNPrBakSFNJlGDFvEcg
	 meKW1lADu8VNdWicvx+2YJhbZty7Gl/bxc58F2HJGpDzieCfKZct+O1NM/eBhsYHSj
	 edgdRzTDCsjbb0pzyUNL2w3ugUBI57bC3rznGudEq+LXsxuint9fyX4gPAhtpglLB1
	 LaSnOJM/UMSJwdHry6SZxncdnpSGOYW8C0/DWLnphNYeDFQK8RZQVBU3W6IXUPv0BG
	 SmOhyqodcPTR+HtydBMPUjqCJku1U9RqoQApgRknH3LST/P7yKEs3K+HW4edddMPdQ
	 6gs3QGam8NlpA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1772103586; x=1772364086; i=ngoc-tu.dinh@vates.tech;
	bh=m7IvLpDweN5yO2W6/wTfDs8I5gBqBkUhcIuhIJUIfd8=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=oahfQC18oQL9hT5NO96Ne2MOVkyK1+5D28GX5WPlwIHd69pkqEmXTNGJWHrbJtroS
	 LJ2oQCkfUL24z3Ctb58FJk8n+Dr4nnAuoFzLN0G+r3KOZXaEfELFMlyRn7gYv8D3cZ
	 XWjbukq4FNcuDMrVIsCIb43q8xvLm/OKIhy8w4A6+9aknPivP9aAFdw09FWrDn9oUe
	 nx53/0KV5nfsh1w6UsXd44E+35szEpbAj/oJigxFfw8RLDHAu6slDoXr5+HrjaNbYu
	 YUEMb1cI6CT9uPq/cYr2Rl73BEdAUea5nuB9FQiyGLhHbRlLEfivNei30oK8jGasKz
	 1Epg86Vr0avJA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[RFC=20PATCH=200/6]=20Remove=20XenDisk?=
X-Mailer: git-send-email 2.51.2.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1772103585444
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260226105922.1916-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.32e84c68283344feace5164b56d054b4?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260226:md
Date: Thu, 26 Feb 2026 10:59:46 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

XenDisk currently performs 3 tasks on behalf of XenVbd:
1. Report StorageDeviceTrimProperty;
2. Intercept and implement IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES;
3. Report sector sizes via StorageAccessAlignmentProperty.

The 2 previous tasks are already handled by Classpnp, although discards
sent to XenVbd were effectively broken without XenDisk.

The 3rd task works without XenDisk, as pre-boot injecting of physical-
sector-size on Server 2025 via XenStore provides the expected outcome.

This series attempts to fix XenVbd to not require XenDisk to operate:
* Report the 0xB2 VPD page and the LBPU bit, used by Classpnp to detect
  unmap support;
* Provide the appropriate unmap information reporting in VPD Block
  Limits whereas it was missing previously, since this information is
  required if LBPU is enabled;
* For correctness's sake, add a check for Service Action in the Read
  Capacity 16 handler, as its opcode is shared with several other
  service actions.

Before starting the fixes, add a few refactoring to use Storport
declarations instead of inline VPD page codes.

These patches are meant to be applied on top of the "Refactor Features
and DiskInfo" patch. They have been lightly tested so far.

Tu Dinh (6):
  Stop inlining the VPD page list in TargetInquiry00
  Stop inlining VPD page codes
  Report max unmap LBA and block descriptor counts
  Report VPD 0xB2 Logical Block Provisioning
  Check Service Action when handling Read Capacity 16
  Remove XenDisk

 include/xencdb.h                    |    8 +
 msbuild.ps1                         |    2 +-
 src/xendisk/assert.h                |  220 ---
 src/xendisk/debug.h                 |   95 --
 src/xendisk/driver.c                |  283 ----
 src/xendisk/driver.h                |   76 -
 src/xendisk/fdo.c                   | 1618 ----------------------
 src/xendisk/fdo.h                   |   84 --
 src/xendisk/mutex.h                 |  114 --
 src/xendisk/pdo.c                   | 2000 ---------------------------
 src/xendisk/pdo.h                   |   77 --
 src/xendisk/registry.c              | 1564 ---------------------
 src/xendisk/registry.h              |  211 ---
 src/xendisk/thread.c                |  226 ---
 src/xendisk/thread.h                |   75 -
 src/xendisk/types.h                 |   54 -
 src/xendisk/xendisk.rc              |   57 -
 src/xenvbd.inf                      |  118 +-
 src/xenvbd/target.c                 |  142 +-
 vs2019/package/package.vcxproj      |    3 -
 vs2019/xendisk/xendisk.vcxproj      |   83 --
 vs2019/xendisk/xendisk.vcxproj.user |    8 -
 vs2019/xenvbd.sln                   |   14 -
 vs2022/package/package.vcxproj      |    3 -
 vs2022/xendisk/xendisk.vcxproj      |   76 -
 vs2022/xendisk/xendisk.vcxproj.user |    8 -
 vs2022/xenvbd.sln                   |   10 -
 27 files changed, 174 insertions(+), 7055 deletions(-)
 delete mode 100644 src/xendisk/assert.h
 delete mode 100644 src/xendisk/debug.h
 delete mode 100644 src/xendisk/driver.c
 delete mode 100644 src/xendisk/driver.h
 delete mode 100644 src/xendisk/fdo.c
 delete mode 100644 src/xendisk/fdo.h
 delete mode 100644 src/xendisk/mutex.h
 delete mode 100644 src/xendisk/pdo.c
 delete mode 100644 src/xendisk/pdo.h
 delete mode 100644 src/xendisk/registry.c
 delete mode 100644 src/xendisk/registry.h
 delete mode 100644 src/xendisk/thread.c
 delete mode 100644 src/xendisk/thread.h
 delete mode 100644 src/xendisk/types.h
 delete mode 100644 src/xendisk/xendisk.rc
 delete mode 100644 vs2019/xendisk/xendisk.vcxproj
 delete mode 100644 vs2019/xendisk/xendisk.vcxproj.user
 delete mode 100644 vs2022/xendisk/xendisk.vcxproj
 delete mode 100644 vs2022/xendisk/xendisk.vcxproj.user

-- 
2.51.2.windows.1



--
 | Vates

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Feb 26 10:59:55 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 26 Feb 2026 10:59:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1241413.1542449 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vvZ63-0007rD-37; Thu, 26 Feb 2026 10:59:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1241413.1542449; Thu, 26 Feb 2026 10:59:55 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vvZ63-0007r6-0f; Thu, 26 Feb 2026 10:59:55 +0000
Received: by outflank-mailman (input) for mailman id 1241413;
 Thu, 26 Feb 2026 10:59:54 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=HiWG=A6=bounce.vates.tech=bounce-md_30504962.69a027a2.v1-4c3c52b1192e4afeba24d174c8c4bee5@srs-se1.protection.inumbo.net>)
 id 1vvZ62-0007ql-6j
 for win-pv-devel@lists.xenproject.org; Thu, 26 Feb 2026 10:59:54 +0000
Received: from mail187-10.suw11.mandrillapp.com
 (mail187-10.suw11.mandrillapp.com [198.2.187.10])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 45e076e5-1302-11f1-9ccf-f158ae23cfc8;
 Thu, 26 Feb 2026 11:59:51 +0100 (CET)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-10.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fM7l700Qmz5QkLd3
 for <win-pv-devel@lists.xenproject.org>; Thu, 26 Feb 2026 10:59:47 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 4c3c52b1192e4afeba24d174c8c4bee5; Thu, 26 Feb 2026 10:59:46 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 45e076e5-1302-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1772103587; x=1772373587;
	bh=6ZV7eVo3NPNnYldpOTlXd8uzRra4YhVkF3QnocSqIGE=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=V8fmaIvoLbis6t1ridjswy9orQl2HSTitf7Gg9ebVzgNl/rylC1sO18I4qLX/t8m8
	 /0YpSTGg+b42lZRaNzuGStvlZafr/2p4+WO9WXtDqoEPR13JP1UInFHQ4/m7uTvcBv
	 lxhZXFa7qPNiH/Hbe0RZCRUsDtHLhOEyryGjFQf8jZqYRbMXurBlwchXHix6wUj/eU
	 M9yFKeGmZNS8JLKJPFNm+1C/FS2Qdi0czMD40q/00GhxWl/bf2q6UqWKg8Z249Vykt
	 9XYbWcXC83LrzMYA9Kw5qlJNH+0DylzC+g0gnxq6IKNkbBEMotLb7zz9Cnwp5wA5fw
	 U4Nv4ZHLNPfog==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1772103587; x=1772364087; i=ngoc-tu.dinh@vates.tech;
	bh=6ZV7eVo3NPNnYldpOTlXd8uzRra4YhVkF3QnocSqIGE=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=EU3s9Gcc0BBR8iZ1wdibURPj3tU/04uA3Sn7phCNGWKvF4X4y046Whnq+t41OnN62
	 /OAq69xXQqA2gYbEKWy4OTXF1Mi+yU0frihzLDShZanBczaOSNRD8aBAPsU03XErMm
	 ymS8DTFxPv761QPS3hxktLIb+DsJW6wvSZZaJlvFlRM7HmsrdP6OO/WzH1GRpjVnyq
	 D52atpR8dNDpd+ytop3m5y6SAdel96/hbsb5//fwyhoW9YSDgjmj/g4p7AmtSzkWSN
	 VQPdJB1/wa2G0lN2v4tmLsoCPWTlYm4uyce5d9SvqiUjYQPIOrHBv7U9wbPpjMbtbG
	 JBWhPFs/kCo9A==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[RFC=20PATCH=201/6]=20Stop=20inlining=20the=20VPD=20page=20list=20in=20TargetInquiry00?=
X-Mailer: git-send-email 2.51.2.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1772103585852
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260226105922.1916-2-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260226105922.1916-1-ngoc-tu.dinh@vates.tech>
References: <20260226105922.1916-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.4c3c52b1192e4afeba24d174c8c4bee5?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260226:md
Date: Thu, 26 Feb 2026 10:59:46 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Define a SupportedPages array containing all supported VPD pages so that
we could check its size later.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenvbd/target.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index a07fc45..5a6c7be 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -674,6 +674,14 @@ TargetInquiryStd(
     Srb->SrbStatus = SRB_STATUS_SUCCESS;
 }
 
+static const UCHAR SupportedPages[] = {
+    VPD_SUPPORTED_PAGES,
+    VPD_SERIAL_NUMBER,
+    VPD_DEVICE_IDENTIFIERS,
+    VPD_BLOCK_LIMITS,
+    VPD_BLOCK_DEVICE_CHARACTERISTICS,
+};
+
 static FORCEINLINE VOID
 TargetInquiry00(
     IN  PXENVBD_TARGET          Target,
@@ -691,17 +699,16 @@ TargetInquiry00(
         return;
     RtlZeroMemory(Data, Length);
 
-    if (Length < 9)
+    if (Length < sizeof(VPD_SUPPORTED_PAGES_PAGE) + sizeof(SupportedPages))
         return;
 
-    Data->PageLength = 5;
-    Data->SupportedPageList[0] = 0x00;
-    Data->SupportedPageList[1] = 0x80;
-    Data->SupportedPageList[2] = 0x83;
-    Data->SupportedPageList[3] = 0xB0;
-    Data->SupportedPageList[4] = 0xB1;
+    Data->PageLength = sizeof(SupportedPages);
+    RtlCopyMemory(Data->SupportedPageList,
+                  SupportedPages,
+                  sizeof(SupportedPages));
 
-    Srb->DataTransferLength = 9;
+    Srb->DataTransferLength = sizeof(VPD_SUPPORTED_PAGES_PAGE) +
+        Data->PageLength;
     Srb->SrbStatus = SRB_STATUS_SUCCESS;
 }
 
-- 
2.51.2.windows.1



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Feb 26 10:59:56 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 26 Feb 2026 10:59:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1241414.1542453 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vvZ64-0007sm-4U; Thu, 26 Feb 2026 10:59:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1241414.1542453; Thu, 26 Feb 2026 10:59:56 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vvZ64-0007sf-1q; Thu, 26 Feb 2026 10:59:56 +0000
Received: by outflank-mailman (input) for mailman id 1241414;
 Thu, 26 Feb 2026 10:59:54 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=/WW6=A6=bounce.vates.tech=bounce-md_30504962.69a027a2.v1-b41e2a7265914a3f83f2b011897be4e3@srs-se1.protection.inumbo.net>)
 id 1vvZ62-0007ql-Qp
 for win-pv-devel@lists.xenproject.org; Thu, 26 Feb 2026 10:59:54 +0000
Received: from mail187-10.suw11.mandrillapp.com
 (mail187-10.suw11.mandrillapp.com [198.2.187.10])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 43d20040-1302-11f1-9ccf-f158ae23cfc8;
 Thu, 26 Feb 2026 11:59:49 +0100 (CET)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-10.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fM7l654B7z5QkLV1
 for <win-pv-devel@lists.xenproject.org>; Thu, 26 Feb 2026 10:59:46 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 b41e2a7265914a3f83f2b011897be4e3; Thu, 26 Feb 2026 10:59:46 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 43d20040-1302-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1772103586; x=1772373586;
	bh=QBgHiWyn35utNeNtpIi4JUPu/16IgSGl1REME/0kT2g=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=c6p9IyzRiCMuhttxWQ9E3kaW9k2L/AOUx0U2wPfAwLsxh6QMzQ4f/VXBHtreFz8SX
	 QgAXAkoy2aLfN7g8NxBrIiWjFFYf9PNFB0TilU3K0t/lvrvKKe6cdaO9+kMUTmFhLs
	 1MKv6n9sE9/2soMUsbhwronYZA0/hkyLO480K/89gy2H40qbeOFcmAvFCXyMPbKwlF
	 Q8JNleZz1+lUQDA/bY+fnW6O83zvpkboa/7mOynyiqRIAAuOBIYy/fFRtc4AAU7Msk
	 qXqoiuaFW9FpTRAyCJzeFwKe2tCVoqYqwC1iyeJBGeK0JNFxws9NTu+32Y6ql/mdCH
	 MSuA5bJrr/jpw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1772103586; x=1772364086; i=ngoc-tu.dinh@vates.tech;
	bh=QBgHiWyn35utNeNtpIi4JUPu/16IgSGl1REME/0kT2g=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=NCYXMMSHljF4RcrYOoWLnKQLG3nEEhD2g6XPpzz0CB8o7YrE2bzZOY1KUkAlsYdKR
	 Ig6mrpE+LeiBdDFrFErMYhpembytby2bTqJ81TxlaLXtLXq9F0GaDfFV1noDv4ez0V
	 1ifjV1bG7hXslLoYFsoqMGeBT3y5PLWQ9S+5+7Nv4Ngh3ybGVBP0/Q0PCS9fCPG6Gk
	 QaFP8kFB/8TuN+lsh9buUJSmMpYlMsBo/e2FhI7gXjqVnLsHS0dmMA7VZ+EwAUIJ/d
	 nEhiCp3TqkaG5J6RvofsC+EJkzWRSFdtEm7ioyAc8Bgt0I9XxBpGyD16GBDrT8clLC
	 iBoHZ9z7AdWAg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[RFC=20PATCH=202/6]=20Stop=20inlining=20VPD=20page=20codes?=
X-Mailer: git-send-email 2.51.2.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1772103586078
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260226105922.1916-3-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260226105922.1916-1-ngoc-tu.dinh@vates.tech>
References: <20260226105922.1916-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.b41e2a7265914a3f83f2b011897be4e3?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260226:md
Date: Thu, 26 Feb 2026 10:59:46 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Use the constants from Storport.h instead.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenvbd/target.c | 40 ++++++++++++++++++++++++++++------------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index 5a6c7be..1c6944f 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -741,7 +741,7 @@ TargetInquiry80(
         if (Length < sizeof(VPD_SERIAL_NUMBER_PAGE) + 4)
             return;
 
-        Data->PageCode      = 0x80;
+        Data->PageCode      = VPD_SERIAL_NUMBER;
         Data->PageLength    = 4;
         (VOID) RtlStringCbPrintfA(Serial,
                                   sizeof(Serial),
@@ -787,7 +787,7 @@ TargetInquiry83(
                      sizeof(VPD_IDENTIFICATION_DESCRIPTOR) + 16)
             return;
 
-        Data->PageCode = 0x83;
+        Data->PageCode = VPD_DEVICE_IDENTIFIERS;
         Data->PageLength = sizeof(VPD_IDENTIFICATION_DESCRIPTOR) + 16;
 
         Id->CodeSet         = VpdCodeSetAscii;
@@ -826,7 +826,7 @@ TargetInquiryB0(
     if (Length < sizeof(VPD_BLOCK_LIMITS_PAGE))
         return;
 
-    Data->PageCode = 0xB0;
+    Data->PageCode = VPD_BLOCK_LIMITS;
     Data->PageLength[1] = 0x3C; // as per spec
 
     *(PULONG)Data->OptimalUnmapGranularity = _byteswap_ulong(Features->DiscardGranularity);
@@ -859,7 +859,7 @@ TargetInquiryB1(
     if (Length < sizeof(VPD_BLOCK_DEVICE_CHARACTERISTICS_PAGE))
         return;
 
-    Data->PageCode = 0xB1;
+    Data->PageCode = VPD_BLOCK_DEVICE_CHARACTERISTICS;
     Data->PageLength = 0x3C; // as per spec
 
     Data->MediumRotationRateMsb = 0;
@@ -877,17 +877,33 @@ TargetInquiry(
 {
     if (Cdb_EVPD(Srb)) {
         switch (Cdb_PageCode(Srb)) {
-        case 0x00:  TargetInquiry00(Target, Srb);       break;
-        case 0x80:  TargetInquiry80(Target, Srb);       break;
-        case 0x83:  TargetInquiry83(Target, Srb);       break;
-        case 0xB0:  TargetInquiryB0(Target, Srb);       break;
-        case 0xB1:  TargetInquiryB1(Target, Srb);       break;
-        default:    Srb->SrbStatus = SRB_STATUS_ERROR;  break;
+        case VPD_SUPPORTED_PAGES:
+            TargetInquiry00(Target, Srb);
+            break;
+        case VPD_SERIAL_NUMBER:
+            TargetInquiry80(Target, Srb);
+            break;
+        case VPD_DEVICE_IDENTIFIERS:
+            TargetInquiry83(Target, Srb);
+            break;
+        case VPD_BLOCK_LIMITS:
+            TargetInquiryB0(Target, Srb);
+            break;
+        case VPD_BLOCK_DEVICE_CHARACTERISTICS:
+            TargetInquiryB1(Target, Srb);
+            break;
+        default:
+            Srb->SrbStatus = SRB_STATUS_ERROR;
+            break;
         }
     } else {
         switch (Cdb_PageCode(Srb)) {
-        case 0x00:  TargetInquiryStd(Target, Srb);      break;
-        default:    Srb->SrbStatus = SRB_STATUS_ERROR;  break;
+        case VPD_SUPPORTED_PAGES:
+            TargetInquiryStd(Target, Srb);
+            break;
+        default:
+            Srb->SrbStatus = SRB_STATUS_ERROR;
+            break;
         }
     }
 }
-- 
2.51.2.windows.1



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Feb 26 10:59:57 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 26 Feb 2026 10:59:57 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1241415.1542458 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vvZ65-0007uN-5h; Thu, 26 Feb 2026 10:59:57 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1241415.1542458; Thu, 26 Feb 2026 10:59:57 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vvZ65-0007uG-32; Thu, 26 Feb 2026 10:59:57 +0000
Received: by outflank-mailman (input) for mailman id 1241415;
 Thu, 26 Feb 2026 10:59:55 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Hk2n=A6=bounce.vates.tech=bounce-md_30504962.69a027a3.v1-b35888f54d764072ae4133360c478b07@srs-se1.protection.inumbo.net>)
 id 1vvZ63-0007ql-Qu
 for win-pv-devel@lists.xenproject.org; Thu, 26 Feb 2026 10:59:55 +0000
Received: from mail187-10.suw11.mandrillapp.com
 (mail187-10.suw11.mandrillapp.com [198.2.187.10])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 479ab6d3-1302-11f1-9ccf-f158ae23cfc8;
 Thu, 26 Feb 2026 11:59:53 +0100 (CET)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-10.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fM7l72WLLz5QkLcN
 for <win-pv-devel@lists.xenproject.org>; Thu, 26 Feb 2026 10:59:47 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 b35888f54d764072ae4133360c478b07; Thu, 26 Feb 2026 10:59:47 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 479ab6d3-1302-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1772103587; x=1772373587;
	bh=DU/VAZRG+0E5zgkdmdwFu5v5uDkaY7moDnNTwopb/P0=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=XyskH6wuYRjpFvjsmA0LmZBj3jhZf2gLsrF2ApunDVjh6zW1xTvbtLxJ+0yqaWH5D
	 5dD2av4Q2dgu/IcV0dhf6cqZn7DiUAH1sGuXdbAoY02k2pf2ZhOCzPXvgjfj6ZB+S9
	 fnwwKJx+qTRdL0/eYloiDlefXx6J37LjAzQkru0F3p/EFc5GmsD6bpxsVD+ZQxx/ll
	 P+QDG6+OQnk8LrH1uG9HuMR2/lsNJakN/RkHQd4cRPL6jvJFXWdLph8hcblYVCTqhH
	 wfmANx3dh4DCDR5OI8V7KTzQVIG5jRrt9qrQuDa6E/mjuMsTqhgxmrk6rvKfNa6jlq
	 WdVbV8sNlFFlg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1772103587; x=1772364087; i=ngoc-tu.dinh@vates.tech;
	bh=DU/VAZRG+0E5zgkdmdwFu5v5uDkaY7moDnNTwopb/P0=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=BL9raZXPvBOIZ5NFUJcI3Jw7I2biyyCpLF/7M9xRJA79KHo0N22ykM4pMExUZgSW/
	 5/pp1TbLyZiOJF67e0nfGZmXkPJQaVeo7ATKmGWEF3J+BqI1F4slUrAQZUgNpwl5oI
	 +hQk8C0zl3mQA5lYQ0kKSdPT1It1yLzdDIIX1RAjfqcyCskwinDSg1x4+aYvtDMY7t
	 BzaY0FztR4yGHsMwbelOIwehleVUZxWfthFfKgJlhYWFN8QUymMK5h6Avq7DiQ8tY3
	 KPF4ef98Zo819iXakc+kWKWYz0yiIDwxx1fOj6Z4WwrXfU/NXeFH1cotAzzLryvwI5
	 2RIGj8jSZ5/nw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[RFC=20PATCH=205/6]=20Check=20Service=20Action=20when=20handling=20Read=20Capacity=2016?=
X-Mailer: git-send-email 2.51.2.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1772103586718
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260226105922.1916-6-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260226105922.1916-1-ngoc-tu.dinh@vates.tech>
References: <20260226105922.1916-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.b35888f54d764072ae4133360c478b07?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260226:md
Date: Thu, 26 Feb 2026 10:59:47 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Read Capacity 16 shares the same opcode with other Service Action In 16
subcommands.

Add an explicit check for SERVICE_ACTION_READ_CAPACITY16.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 include/xencdb.h    |  8 ++++++++
 src/xenvbd/target.c | 26 ++++++++++++++++++++++++--
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/include/xencdb.h b/include/xencdb.h
index 492d50d..594e9fe 100644
--- a/include/xencdb.h
+++ b/include/xencdb.h
@@ -261,6 +261,14 @@ FORCEINLINE UCHAR Cdb_EVPD(const SCSI_REQUEST_BLOCK* const srb)
     return Cdb_EVPDRaw(srb->CdbLength, srb->Cdb);
 }
 
+FORCEINLINE UCHAR Cdb_ServiceAction(const SCSI_REQUEST_BLOCK* const srb)
+{
+    if (srb->CdbLength > 6)
+        return srb->Cdb[1] & 0x1F;
+    else
+        return 0;
+}
+
 FORCEINLINE const char* Cdb_OperationName(UCHAR op)
 {
 #define _SCSIOP_NAME(x) case x: return #x;
diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index 3d48ade..2cae479 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -636,6 +636,28 @@ fail1:
     Error("fail1\n");
 }
 
+static DECLSPEC_NOINLINE VOID
+TargetServiceActionIn16(
+    IN  PXENVBD_TARGET      Target,
+    IN  PSCSI_REQUEST_BLOCK Srb
+    )
+{
+    UCHAR                   ServiceAction = Cdb_ServiceAction(Srb);
+
+    switch (ServiceAction){
+    case SERVICE_ACTION_READ_CAPACITY16:
+        TargetReadCapacity16(Target, Srb);
+        return;
+    default:
+        Trace("Target[%d] : Unsupported SCSIOP_SERVICE_ACTION_IN16 "
+              "service action (%02hhx)\n",
+              TargetGetTargetId(Target),
+              ServiceAction);
+        Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
+        break;
+    }
+}
+
 static FORCEINLINE VOID
 TargetInquiryStd(
     IN  PXENVBD_TARGET      Target,
@@ -1063,8 +1085,8 @@ TargetStartIo(
         TargetReadCapacity(Target, Srb);
         break;
 
-    case SCSIOP_READ_CAPACITY16:
-        TargetReadCapacity16(Target, Srb);
+    case SCSIOP_SERVICE_ACTION_IN16:
+        TargetServiceActionIn16(Target, Srb);
         break;
 
     case SCSIOP_MEDIUM_REMOVAL:
-- 
2.51.2.windows.1



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Feb 26 10:59:57 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 26 Feb 2026 10:59:57 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1241416.1542462 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vvZ65-0007us-9G; Thu, 26 Feb 2026 10:59:57 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1241416.1542462; Thu, 26 Feb 2026 10:59:57 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vvZ65-0007uU-4B; Thu, 26 Feb 2026 10:59:57 +0000
Received: by outflank-mailman (input) for mailman id 1241416;
 Thu, 26 Feb 2026 10:59:55 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=JDx+=A6=bounce.vates.tech=bounce-md_30504962.69a027a4.v1-4b1ceea5a3da40468a527fb35809a298@srs-se1.protection.inumbo.net>)
 id 1vvZ63-0007pS-R9
 for win-pv-devel@lists.xenproject.org; Thu, 26 Feb 2026 10:59:55 +0000
Received: from mail187-10.suw11.mandrillapp.com
 (mail187-10.suw11.mandrillapp.com [198.2.187.10])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 47f497c7-1302-11f1-b164-2bf370ae4941;
 Thu, 26 Feb 2026 11:59:55 +0100 (CET)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-10.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fM7l80Twqz5QkLd9
 for <win-pv-devel@lists.xenproject.org>; Thu, 26 Feb 2026 10:59:48 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 4b1ceea5a3da40468a527fb35809a298; Thu, 26 Feb 2026 10:59:48 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 47f497c7-1302-11f1-b164-2bf370ae4941
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1772103588; x=1772373588;
	bh=5Os+j2cYBvDScSyLyZpddz2dYajyJkFYkaF7FqKnQr8=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=Pn1MT4cLkkLQaZFmhSo5qJU3YUdgE3mGl5fQrXpRTIGFRonAlTkaZZLTUBHPYNiUK
	 WPIGXyP6Nky0F0zT+LploLqH13ETqkCOJSfyKOW9O5bivq2e1Sgw7YXL3LYBsugtkl
	 /KdH1q5qT/xw+KeczrS+xUsamIVWKy6eNJHCjb8h7aJ9X1iVgXaTqhnLZAlq0zxlrM
	 n71D+UEsMZILhtxyRpGTVZHAVSNLSjLqRZql3j0t1jjRNUeKGppK5hdaBCdqLWmxtq
	 q1LqKPBaA89yX6O+xiA6RCX0QtcRS9+yJ8rFRdhfLuCgFKaI9HJTanAfdmni+5uhwA
	 VKFEx97sxKj3Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1772103588; x=1772364088; i=ngoc-tu.dinh@vates.tech;
	bh=5Os+j2cYBvDScSyLyZpddz2dYajyJkFYkaF7FqKnQr8=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=BLDgMfAPjMTNO/GfS72rCvINGj+Aa9D6Rp9cw37KdLFxwP8dE+tEuqbxf8ddTU1Vu
	 2LZp93E43SsHeFErwhuRNGzWJyM8jSvwg03bW5chIRpoI+cTvi/6t3cJQtDLGSao7E
	 NFheXxhzY1/2PSDRuxHsbDVasnxODILdQaZQ6aaq/30j60bh0WLgep0hLG3J1/a2tz
	 Q5zNhccr4qG4QbTLv0H53iTaBBjOIw1o+u1GpUgCJvyxAoArS8i8sLJrSPwZNWvc2I
	 08QECq08FMVckVtyyyNmCYWOG9dwhuEldwnnenFjAxkFurzPxDBWuvBCIHK3fW5geM
	 UzSHx9F0R003g==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[RFC=20PATCH=204/6]=20Report=20VPD=200xB2=20Logical=20Block=20Provisioning?=
X-Mailer: git-send-email 2.51.2.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1772103586498
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260226105922.1916-5-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260226105922.1916-1-ngoc-tu.dinh@vates.tech>
References: <20260226105922.1916-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.4b1ceea5a3da40468a527fb35809a298?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260226:md
Date: Thu, 26 Feb 2026 10:59:48 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

This VPD page is required for the detection of discard features by
Classpnp.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenvbd/target.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index 5109281..3d48ade 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -680,6 +680,7 @@ static const UCHAR SupportedPages[] = {
     VPD_DEVICE_IDENTIFIERS,
     VPD_BLOCK_LIMITS,
     VPD_BLOCK_DEVICE_CHARACTERISTICS,
+    VPD_LOGICAL_BLOCK_PROVISIONING,
 };
 
 static FORCEINLINE VOID
@@ -879,6 +880,39 @@ TargetInquiryB1(
     Srb->SrbStatus = SRB_STATUS_SUCCESS;
 }
 
+static VOID
+TargetInquiryB2(
+    IN  PXENVBD_TARGET                      Target,
+    IN  PSCSI_REQUEST_BLOCK                 Srb
+    )
+{
+    PVPD_LOGICAL_BLOCK_PROVISIONING_PAGE    Data = Srb->DataBuffer;
+    ULONG                                   Length = Srb->DataTransferLength;
+
+    UNREFERENCED_PARAMETER(Target);
+
+    Srb->SrbStatus = SRB_STATUS_ERROR;
+
+    if (Data == NULL)
+        return;
+
+    RtlZeroMemory(Data, Length);
+
+    if (Length < sizeof(VPD_LOGICAL_BLOCK_PROVISIONING_PAGE))
+        return;
+
+    Data->PageCode = VPD_LOGICAL_BLOCK_PROVISIONING;
+    Data->PageLength[1] = 4;
+
+    // Even if the current backend doesn't support discard, we might want to
+    // offer discard again when the backend changes. So we have to say that
+    // discard is unconditionally supported here.
+    Data->LBPU = 1;
+
+    Srb->DataTransferLength = sizeof(VPD_LOGICAL_BLOCK_PROVISIONING_PAGE);
+    Srb->SrbStatus = SRB_STATUS_SUCCESS;
+}
+
 static DECLSPEC_NOINLINE VOID
 TargetInquiry(
     IN  PXENVBD_TARGET      Target,
@@ -902,6 +936,9 @@ TargetInquiry(
         case VPD_BLOCK_DEVICE_CHARACTERISTICS:
             TargetInquiryB1(Target, Srb);
             break;
+        case VPD_LOGICAL_BLOCK_PROVISIONING:
+            TargetInquiryB2(Target, Srb);
+            break;
         default:
             Srb->SrbStatus = SRB_STATUS_ERROR;
             break;
-- 
2.51.2.windows.1



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Feb 26 10:59:59 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 26 Feb 2026 10:59:59 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1241417.1542465 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vvZ67-0007yM-93; Thu, 26 Feb 2026 10:59:59 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1241417.1542465; Thu, 26 Feb 2026 10:59:59 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vvZ67-0007yF-6U; Thu, 26 Feb 2026 10:59:59 +0000
Received: by outflank-mailman (input) for mailman id 1241417;
 Thu, 26 Feb 2026 10:59:57 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=x777=A6=bounce.vates.tech=bounce-md_30504962.69a027a2.v1-8165606049994d4f955bd916fac91db6@srs-se1.protection.inumbo.net>)
 id 1vvZ65-0007pS-M9
 for win-pv-devel@lists.xenproject.org; Thu, 26 Feb 2026 10:59:57 +0000
Received: from mail186-12.suw21.mandrillapp.com
 (mail186-12.suw21.mandrillapp.com [198.2.186.12])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 43b63f0e-1302-11f1-b164-2bf370ae4941;
 Thu, 26 Feb 2026 11:59:49 +0100 (CET)
Received: from pmta10.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail186-12.suw21.mandrillapp.com (Mailchimp) with ESMTP id
 4fM7l66SWgz705b4q
 for <win-pv-devel@lists.xenproject.org>; Thu, 26 Feb 2026 10:59:46 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 8165606049994d4f955bd916fac91db6; Thu, 26 Feb 2026 10:59:46 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 43b63f0e-1302-11f1-b164-2bf370ae4941
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1772103586; x=1772373586;
	bh=JvQOjhVZEWXh4hPHb8oNeLVIbTbseENLcR5i0j2XJK0=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=SLH1VoORa30FvFounk03JA5cn3HJTkdjwlc9qPoKIiyubc3xVNqGvnSnTCLcwvmYG
	 PWeINfjMb1pgdSRsjeSzzdJL8h9t4BaBI3/Zjvg6YWIBo8mt70FwRmNafnWUeLCEFI
	 yKOx2MmQcH6kJV3cM5wjIU1u9aCno3jvOtMOAKQJIPjsTagv1TevCaEJLSows0SCj9
	 2f0eji/IjjzQ1hMFZKPyAN7mtaLvNXDRmfcE26s7lSste/FeO0WQAr+b/So0ZcIbvC
	 5jJfdjxyiebmJlWlAUQCa3VCh+6EG9dv1tXx6joXlqOm2IGbS2NQoPrWxIhkfaTbXI
	 jeJDjaAMQeZ/w==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1772103586; x=1772364086; i=ngoc-tu.dinh@vates.tech;
	bh=JvQOjhVZEWXh4hPHb8oNeLVIbTbseENLcR5i0j2XJK0=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=Ihm4ISDRy79no6V9+AY6fDbx6X3p1d+vMsy7w+kqzow6OBEFctbTgBBX9jF5mswG2
	 E8HkuLfBJBxf/YlKrLTJbtdOPF9H1R8r0SHjjYi50EVWdYsoAdR8oZn0BbYzpbk4z8
	 d1Kn3uocEhqA/l+S0Oa8FVN6klBhmZ43V9+0V6q+vTMHoQYQdfwaCGKUjy92/xAlxn
	 JlfD33O1vsGCHVSluSnBBK6L/GideI2cIVB9uG0VISZJhKrbYZOuVkEp4q+d0BhcaR
	 Io4ZBGHmWFTBqTS8tJpMkHg+QvhszDe8LlSE88oQzO8od3gNydSDgnihCUK3ZVXCxD
	 G7uPiRM1n2KOw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[RFC=20PATCH=203/6]=20Report=20max=20unmap=20LBA=20and=20block=20descriptor=20counts?=
X-Mailer: git-send-email 2.51.2.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1772103586287
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260226105922.1916-4-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260226105922.1916-1-ngoc-tu.dinh@vates.tech>
References: <20260226105922.1916-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.8165606049994d4f955bd916fac91db6?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260226:md
Date: Thu, 26 Feb 2026 10:59:46 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

These values are needed in the Block Limits VPD page in order to show
that unmap is supported.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenvbd/target.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index 1c6944f..5109281 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -829,6 +829,16 @@ TargetInquiryB0(
     Data->PageCode = VPD_BLOCK_LIMITS;
     Data->PageLength[1] = 0x3C; // as per spec
 
+    *(PULONG)Data->MaximumUnmapLBACount = _byteswap_ulong(ULONG_MAX);
+    /*
+     * Each discarded extent requires its own BLKIF_OP_DISCARD request. We don't
+     * want to consume the entire ring at once, but the optimal value might not
+     * be 1 either.
+     * Since the ring can hold anywhere from 32 requests (with 1 ring page) to
+     * 512 requests (using XENVBD_MAX_RING_PAGE_ORDER), use 8 as a conservative
+     * default.
+     */
+    *(PULONG)Data->MaximumUnmapBlockDescriptorCount = _byteswap_ulong(8);
     *(PULONG)Data->OptimalUnmapGranularity = _byteswap_ulong(Features->DiscardGranularity);
     *(PULONG)Data->UnmapGranularityAlignment = _byteswap_ulong(Features->DiscardAlignment);
     // alignment is only valid if a granularity has been set
-- 
2.51.2.windows.1



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Feb 26 11:00:02 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 26 Feb 2026 11:00:02 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1241418.1542470 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vvZ6A-00086j-CC; Thu, 26 Feb 2026 11:00:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1241418.1542470; Thu, 26 Feb 2026 11:00:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1vvZ6A-00085u-8I; Thu, 26 Feb 2026 11:00:02 +0000
Received: by outflank-mailman (input) for mailman id 1241418;
 Thu, 26 Feb 2026 11:00:00 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=lrJL=A6=bounce.vates.tech=bounce-md_30504962.69a027a4.v1-0656da1815a04b238109afdda7b168c7@srs-se1.protection.inumbo.net>)
 id 1vvZ67-0007ql-Co
 for win-pv-devel@lists.xenproject.org; Thu, 26 Feb 2026 11:00:00 +0000
Received: from mail187-10.suw11.mandrillapp.com
 (mail187-10.suw11.mandrillapp.com [198.2.187.10])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 48b4bc26-1302-11f1-9ccf-f158ae23cfc8;
 Thu, 26 Feb 2026 11:59:55 +0100 (CET)
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-10.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fM7l83JPmz5QkLfS
 for <win-pv-devel@lists.xenproject.org>; Thu, 26 Feb 2026 10:59:48 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 0656da1815a04b238109afdda7b168c7; Thu, 26 Feb 2026 10:59:48 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 48b4bc26-1302-11f1-9ccf-f158ae23cfc8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1772103588; x=1772373588;
	bh=Qn1h+Wkp/R7Y6Ck7sBMbKLbWjKtIIfN4RubvqjFX/YY=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=S9zHploO6wtxveusUbesy3LB2wQJqbQP5tRe+3hgBEC20Z4epHh+wa8faDlnIBnGP
	 Fg2UmgC7v3pMNzLNDM5jfhofX12HVYZ9Kl/LmcdgM0p34y+n7RUM+fDPCk5uGc82qK
	 ZULekBiKCY32Wape14+7UNy18QgtUCzpYrNWG6SXKlBGV0z9Cq0ViT3JxRVfSQtjU3
	 dl2mxE+vIv5cl7lSGcByyB5aZ4J723y9YSFLVGvUr3OErhvLCaDPjTY2b6CQH/+tvI
	 nqO9LgoTQ1A5vQJpIGGoJxHxw1GF/eTwpATaO9/z0edo0ueAmaOGEJLyYN3wxsVWur
	 f941ZZbLLqDXA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1772103588; x=1772364088; i=ngoc-tu.dinh@vates.tech;
	bh=Qn1h+Wkp/R7Y6Ck7sBMbKLbWjKtIIfN4RubvqjFX/YY=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=KryQycds75f0nmcHVdjUmHKqpaFrASEgvHJcVytikiwgBrYr9o8BSC5leife+Ywis
	 6tWjuuXvYrkEYufJI/4AfZMII7YelRs5Nw0PNOY4blJvL9GY7EDNLU5FMhNIqWpovf
	 pIMziPpsDgDnByc8xC9s7I4fa54EWqhG7pOYo7NQSCMolm1RX/lha3cwl0pNQR3S/Q
	 A9N4b+RciXup9oLMVLBGAlTJOT7A4HHUrnzm8F0wQSEnVZtu3Hi99raAUM7FOyDErR
	 y0F3ndH/IZ0OC2gYtu2oVBazX+lxXora/KbEhjRH8exc8MYEyCCGc840tKGsUrEE7S
	 11nNT1IDv9xaw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[RFC=20PATCH=206/6]=20Remove=20XenDisk?=
X-Mailer: git-send-email 2.51.2.windows.1
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1772103587251
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260226105922.1916-7-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260226105922.1916-1-ngoc-tu.dinh@vates.tech>
References: <20260226105922.1916-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.0656da1815a04b238109afdda7b168c7?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260226:md
Date: Thu, 26 Feb 2026 10:59:48 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Windows 8/Server 2012 natively support SCSIOP_UNMAP. XenVbd now also
correctly handles the reporting to enable unmap support. As such, the
functionality provided by XenDisk is no longer needed.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 msbuild.ps1                         |    2 +-
 src/xendisk/assert.h                |  220 ---
 src/xendisk/debug.h                 |   95 --
 src/xendisk/driver.c                |  283 ----
 src/xendisk/driver.h                |   76 -
 src/xendisk/fdo.c                   | 1618 ----------------------
 src/xendisk/fdo.h                   |   84 --
 src/xendisk/mutex.h                 |  114 --
 src/xendisk/pdo.c                   | 2000 ---------------------------
 src/xendisk/pdo.h                   |   77 --
 src/xendisk/registry.c              | 1564 ---------------------
 src/xendisk/registry.h              |  211 ---
 src/xendisk/thread.c                |  226 ---
 src/xendisk/thread.h                |   75 -
 src/xendisk/types.h                 |   54 -
 src/xendisk/xendisk.rc              |   57 -
 src/xenvbd.inf                      |  118 +-
 src/xenvbd/target.c                 |    6 +-
 vs2019/package/package.vcxproj      |    3 -
 vs2019/xendisk/xendisk.vcxproj      |   83 --
 vs2019/xendisk/xendisk.vcxproj.user |    8 -
 vs2019/xenvbd.sln                   |   14 -
 vs2022/package/package.vcxproj      |    3 -
 vs2022/xendisk/xendisk.vcxproj      |   76 -
 vs2022/xendisk/xendisk.vcxproj.user |    8 -
 vs2022/xenvbd.sln                   |   10 -
 26 files changed, 52 insertions(+), 7033 deletions(-)
 delete mode 100644 src/xendisk/assert.h
 delete mode 100644 src/xendisk/debug.h
 delete mode 100644 src/xendisk/driver.c
 delete mode 100644 src/xendisk/driver.h
 delete mode 100644 src/xendisk/fdo.c
 delete mode 100644 src/xendisk/fdo.h
 delete mode 100644 src/xendisk/mutex.h
 delete mode 100644 src/xendisk/pdo.c
 delete mode 100644 src/xendisk/pdo.h
 delete mode 100644 src/xendisk/registry.c
 delete mode 100644 src/xendisk/registry.h
 delete mode 100644 src/xendisk/thread.c
 delete mode 100644 src/xendisk/thread.h
 delete mode 100644 src/xendisk/types.h
 delete mode 100644 src/xendisk/xendisk.rc
 delete mode 100644 vs2019/xendisk/xendisk.vcxproj
 delete mode 100644 vs2019/xendisk/xendisk.vcxproj.user
 delete mode 100644 vs2022/xendisk/xendisk.vcxproj
 delete mode 100644 vs2022/xendisk/xendisk.vcxproj.user

diff --git a/msbuild.ps1 b/msbuild.ps1
index f904873..493aac9 100644
--- a/msbuild.ps1
+++ b/msbuild.ps1
@@ -18,7 +18,7 @@ param(
 #
 $SolutionName = "xenvbd.sln"
 $ArchivePath = "xenvbd"
-$ProjectList = @( "xencrsh", "xendisk", "xenvbd" )
+$ProjectList = @( "xencrsh", "xenvbd" )
 
 #
 # Functions
diff --git a/src/xendisk/assert.h b/src/xendisk/assert.h
deleted file mode 100644
index 6b17c12..0000000
--- a/src/xendisk/assert.h
+++ /dev/null
@@ -1,220 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _XENDISK_ASSERT_H
-#define _XENDISK_ASSERT_H
-
-#include <ntddk.h>
-
-#include "debug.h"
-
-static FORCEINLINE VOID
-__BugCheck(
-    __in  ULONG       Code,
-    __in_opt ULONG_PTR   Parameter1,
-    __in_opt ULONG_PTR   Parameter2,
-    __in_opt ULONG_PTR   Parameter3,
-    __in_opt ULONG_PTR   Parameter4
-    )
-{
-#pragma prefast(suppress:28159)
-    KeBugCheckEx(Code,
-                 Parameter1,
-                 Parameter2,
-                 Parameter3,
-                 Parameter4);
-}
-
-#define ASSERTION_FAILURE   0x0000DEAD
-
-
-#define BUG(_TEXT)                                              \
-        do {                                                    \
-            const CHAR  *_Text = (_TEXT);                       \
-            const CHAR  *_File = __FILE__;                      \
-            ULONG       _Line = __LINE__;                       \
-                                                                \
-            Error("BUG: " _TEXT "\n");                          \
-            __BugCheck(ASSERTION_FAILURE,                       \
-                       (ULONG_PTR)_Text,                        \
-                       (ULONG_PTR)_File,                        \
-                       (ULONG_PTR)_Line,                        \
-                       0);                                      \
-        } while (FALSE)
-
-#define BUG_MSG(_TEXT1, _TEXT2)                                 \
-        do {                                                    \
-            const CHAR  *_Text1 = (_TEXT1);                     \
-            const CHAR  *_Text2 = (_TEXT2);                     \
-            const CHAR  *_File = __FILE__;                      \
-            ULONG       _Line = __LINE__;                       \
-                                                                \
-            Error("BUG: " _TEXT1 " %s\n", _Text2);              \
-            __BugCheck(ASSERTION_FAILURE,                       \
-                       (ULONG_PTR)_Text1,                       \
-                       (ULONG_PTR)_File,                        \
-                       (ULONG_PTR)_Line,                        \
-                       (ULONG_PTR)_Text2);                      \
-        } while (FALSE)
-
-#define BUG_ON(_EXP)                           \
-        if (_EXP) BUG(#_EXP)
-
-#define BUG_ON_MSG(_EXP, _TEXT)                \
-        if (_EXP) BUG_MSG(#_EXP, _TEXT)
-
-#if DBG
-
-#define __NT_ASSERT(_EXP)                                       \
-        ((!(_EXP)) ?                                            \
-        (Error("ASSERTION FAILED: " #_EXP "\n"),                \
-         __annotation(L"Debug", L"AssertFail", L#_EXP),         \
-         DbgRaiseAssertionFailure(), FALSE) :                   \
-        TRUE)
-
-#define __NT_ASSERT_MSG(_EXP, _TEXT)                            \
-        ((!(_EXP)) ?                                            \
-        (Error("ASSERTION FAILED: " #_EXP " " #_TEXT "\n"),     \
-         __annotation(L"Debug", L"AssertFail", L#_EXP),         \
-         DbgRaiseAssertionFailure(), FALSE) :                   \
-        TRUE)
-
-#define __ASSERT(_EXP)              __NT_ASSERT(_EXP)
-#define __ASSERT_MSG(_EXP, _TEXT)   __NT_ASSERT_MSG(_EXP, _TEXT)
-
-#else   // DBG
-
-#define __ASSERT(_EXP)              BUG_ON(!(_EXP))
-#define __ASSERT_MSG(_EXP, _TEXT)   BUG_ON_MSG(!(_EXP), _TEXT)
-
-#endif  // DBG
-
-#undef  ASSERT
-
-#define ASSERT(_EXP)                    \
-        do {                            \
-            __ASSERT(_EXP);             \
-            __analysis_assume(_EXP);    \
-        } while (FALSE)
-
-#define ASSERT_MSG(_EXP, _TEXT)         \
-        do {                            \
-            __ASSERT_MSG(_EXP, _TEXT);  \
-            __analysis_assume(_EXP);    \
-        } while (FALSE)
-
-#define ASSERT3U(_X, _OP, _Y)                       \
-        do {                                        \
-            ULONGLONG   _Lval = (ULONGLONG)(_X);    \
-            ULONGLONG   _Rval = (ULONGLONG)(_Y);    \
-            if (!(_Lval _OP _Rval)) {               \
-                Error("%s = %llu\n", #_X, _Lval);   \
-                Error("%s = %llu\n", #_Y, _Rval);   \
-                ASSERT(_X _OP _Y);                  \
-            }                                       \
-        } while (FALSE)
-
-#define ASSERT3S(_X, _OP, _Y)                       \
-        do {                                        \
-            LONGLONG    _Lval = (LONGLONG)(_X);     \
-            LONGLONG    _Rval = (LONGLONG)(_Y);     \
-            if (!(_Lval _OP _Rval)) {               \
-                Error("%s = %lld\n", #_X, _Lval);   \
-                Error("%s = %lld\n", #_Y, _Rval);   \
-                ASSERT(_X _OP _Y);                  \
-            }                                       \
-        } while (FALSE)
-
-#define ASSERT3P(_X, _OP, _Y)                       \
-        do {                                        \
-            PVOID   _Lval = (PVOID)(_X);            \
-            PVOID   _Rval = (PVOID)(_Y);            \
-            if (!(_Lval _OP _Rval)) {               \
-                Error("%s = %p\n", #_X, _Lval);     \
-                Error("%s = %p\n", #_Y, _Rval);     \
-                ASSERT(_X _OP _Y);                  \
-            }                                       \
-        } while (FALSE)
-
-#define ASSERTREFCOUNT(_X, _OP, _Y, _Z)             \
-        do {                                        \
-            LONG    _L = (LONG)(_X);                \
-            LONG    _R = (LONG)(_Y);                \
-            if (!(_L _OP _R)) {                     \
-                Error("%s:%s = %d\n", (_Z), #_X, _L); \
-                Error("%s:%s = %d\n", (_Z), #_Y, _R); \
-                ASSERT_MSG(_X _OP _Y, (_Z));        \
-            }                                       \
-        } while (FALSE)
-
-#ifndef TEST_MEMORY
-#define TEST_MEMORY DBG
-#endif
-
-#if TEST_MEMORY
-
-__checkReturn
-static __inline BOOLEAN
-_IsZeroMemory(
-    __in const PCHAR Caller,
-    __in const PCHAR Name,
-    __in PVOID       Buffer,
-    __in ULONG       Length
-    )
-{
-    ULONG           Offset;
-
-    Offset = 0;
-    while (Offset < Length) {
-        if (*((PUCHAR)Buffer + Offset) != 0) {
-            Error("%s: non-zero byte in %s (0x%p+0x%x)\n", Caller, Name, Buffer, Offset);
-            return FALSE;
-        }
-        Offset++;
-    }
-
-    return TRUE;
-}
-
-#define IsZeroMemory(_Buffer, _Length) \
-        _IsZeroMemory(__FUNCTION__, #_Buffer, (_Buffer), (_Length))
-
-#else   // TEST_MEMORY
-
-#define IsZeroMemory(_Buffer, _Length)  TRUE
-
-#endif  // TEST_MEMORY
-
-#define IMPLY(_X, _Y)   (!(_X) || (_Y))
-#define EQUIV(_X, _Y)   (IMPLY((_X), (_Y)) && IMPLY((_Y), (_X)))
-
-#endif  // _XENDISK_ASSERT_H
diff --git a/src/xendisk/debug.h b/src/xendisk/debug.h
deleted file mode 100644
index f921fec..0000000
--- a/src/xendisk/debug.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _DEBUG_H
-#define _DEBUG_H
-
-#include <ntddk.h>
-#include <stdarg.h>
-
-#define stringify_literal(_text) #_text
-#define stringify(_text) stringify_literal(_text)
-#define __MODULE__ stringify(PROJECT)
-
-// DEBUG_FILTER_MASKs
-// Set these to see relevant output
-// ERROR        0x00000001
-// WARNING      0x00000002
-// TRACE        0x00000004
-// INFO         0x00000008
-
-#pragma warning(disable:4127)   // conditional expression is constant
-
-//
-// Debug Output and Logging
-//
-static __inline VOID
-__DebugMessage(
-    __in    ULONG       Level,
-    __in __nullterminated const CHAR  *Prefix,
-    __in __nullterminated const CHAR  *Format,
-    ...
-    )
-{
-    va_list         Arguments;
-
-    va_start(Arguments, Format);
-
-#pragma prefast(suppress:6001) // Using uninitialized memory
-    vDbgPrintExWithPrefix(Prefix,
-                          DPFLTR_IHVDRIVER_ID,
-                          Level,
-                          Format,
-                          Arguments);
-    va_end(Arguments);
-}
-
-#define Error(...)  \
-        __DebugMessage(DPFLTR_ERROR_LEVEL, __MODULE__ "|" __FUNCTION__ ":", __VA_ARGS__)
-
-#define Warning(...)  \
-        __DebugMessage(DPFLTR_WARNING_LEVEL, __MODULE__ "|" __FUNCTION__ ":", __VA_ARGS__)
-
-#if DBG
-#define Trace(...)  \
-        __DebugMessage(DPFLTR_TRACE_LEVEL, __MODULE__ "|" __FUNCTION__ ":", __VA_ARGS__)
-#else   // DBG
-#define Trace(...) \
-        (VOID)(__VA_ARGS__)
-#endif  // DBG
-
-#define Verbose(...) \
-        __DebugMessage(DPFLTR_INFO_LEVEL, __MODULE__ "|" __FUNCTION__ ":", __VA_ARGS__)
-
-#include "assert.h"
-
-#endif  // _DEBUG_H
diff --git a/src/xendisk/driver.c b/src/xendisk/driver.c
deleted file mode 100644
index e30b75c..0000000
--- a/src/xendisk/driver.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <ntddk.h>
-
-#include "registry.h"
-#include "driver.h"
-#include "util.h"
-#include "debug.h"
-#include "assert.h"
-
-#include <version.h>
-
-typedef struct _XENDISK_DRIVER {
-    PDRIVER_OBJECT  DriverObject;
-    HANDLE          ParametersKey;
-} XENDISK_DRIVER, *PXENDISK_DRIVER;
-
-static XENDISK_DRIVER   Driver;
-
-static FORCEINLINE VOID
-__DriverSetDriverObject(
-    IN  PDRIVER_OBJECT  DriverObject
-    )
-{
-    Driver.DriverObject = DriverObject;
-}
-
-static FORCEINLINE PDRIVER_OBJECT
-__DriverGetDriverObject(
-    VOID
-    )
-{
-    return Driver.DriverObject;
-}
-
-PDRIVER_OBJECT
-DriverGetDriverObject(
-    VOID
-    )
-{
-    return __DriverGetDriverObject();
-}
-
-static FORCEINLINE VOID
-__DriverSetParametersKey(
-    IN  HANDLE  Key
-    )
-{
-    Driver.ParametersKey = Key;
-}
-
-static FORCEINLINE HANDLE
-__DriverGetParametersKey(
-    VOID
-    )
-{
-    return Driver.ParametersKey;
-}
-
-HANDLE
-DriverGetParametersKey(
-    VOID
-    )
-{
-    return __DriverGetParametersKey();
-}
-
-DRIVER_UNLOAD   DriverUnload;
-
-VOID
-DriverUnload(
-    IN  PDRIVER_OBJECT  DriverObject
-    )
-{
-    HANDLE              ParametersKey;
-
-    ASSERT3P(DriverObject, ==, __DriverGetDriverObject());
-
-    Trace("====>\n");
-
-    ParametersKey = __DriverGetParametersKey();
-    __DriverSetParametersKey(NULL);
-
-    RegistryCloseKey(ParametersKey);
-
-    RegistryTeardown();
-
-    Verbose("XENDISK %d.%d.%d (%d) (%02d.%02d.%04d)\n",
-            MAJOR_VERSION,
-            MINOR_VERSION,
-            MICRO_VERSION,
-            BUILD_NUMBER,
-            DAY,
-            MONTH,
-            YEAR);
-
-    __DriverSetDriverObject(NULL);
-
-    ASSERT(IsZeroMemory(&Driver, sizeof (XENDISK_DRIVER)));
-
-    Trace("<====\n");
-}
-
-DRIVER_ADD_DEVICE   AddDevice;
-
-NTSTATUS
-#pragma prefast(suppress:28152) // Does not clear DO_DEVICE_INITIALIZING
-AddDevice(
-    IN  PDRIVER_OBJECT  DriverObject,
-    IN  PDEVICE_OBJECT  PhysicalDeviceObject
-    )
-{
-    NTSTATUS            status;
-
-    ASSERT3P(DriverObject, ==, __DriverGetDriverObject());
-
-    status = FdoCreate(PhysicalDeviceObject);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    return STATUS_SUCCESS;
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return status;
-}
-
-DRIVER_DISPATCH Dispatch;
-
-NTSTATUS
-Dispatch(
-    IN PDEVICE_OBJECT   DeviceObject,
-    IN PIRP             Irp
-    )
-{
-    PXENDISK_DX         Dx;
-    NTSTATUS            status;
-
-    Dx = (PXENDISK_DX)DeviceObject->DeviceExtension;
-    ASSERT3P(Dx->DeviceObject, ==, DeviceObject);
-
-    if (Dx->DevicePnpState == Deleted) {
-        PIO_STACK_LOCATION  StackLocation = IoGetCurrentIrpStackLocation(Irp);
-        UCHAR               MajorFunction = StackLocation->MajorFunction;
-        UCHAR               MinorFunction = StackLocation->MinorFunction;
-
-        status = STATUS_NO_SUCH_DEVICE;
-
-        if (MajorFunction == IRP_MJ_PNP) {
-            /* FDO and PDO deletions can block after being marked deleted, but before IoDeleteDevice */
-            if (MinorFunction == IRP_MN_SURPRISE_REMOVAL || MinorFunction == IRP_MN_REMOVE_DEVICE)
-                status = STATUS_SUCCESS;
-
-            ASSERT((MinorFunction != IRP_MN_CANCEL_REMOVE_DEVICE) && (MinorFunction != IRP_MN_CANCEL_STOP_DEVICE));
-        }
-
-        Irp->IoStatus.Status = status;
-        IoCompleteRequest(Irp, IO_NO_INCREMENT);
-        goto done;
-    }
-
-    status = STATUS_NOT_SUPPORTED;
-    switch (Dx->Type) {
-    case PHYSICAL_DEVICE_OBJECT: {
-        PXENDISK_PDO    Pdo = Dx->Pdo;
-
-        status = PdoDispatch(Pdo, Irp);
-        break;
-    }
-    case FUNCTION_DEVICE_OBJECT: {
-        PXENDISK_FDO    Fdo = Dx->Fdo;
-
-        status = FdoDispatch(Fdo, Irp);
-        break;
-    }
-    default:
-        ASSERT(FALSE);
-        break;
-    }
-
-done:
-    return status;
-}
-
-DRIVER_INITIALIZE   DriverEntry;
-
-NTSTATUS
-DriverEntry(
-    IN  PDRIVER_OBJECT  DriverObject,
-    IN  PUNICODE_STRING RegistryPath
-    )
-{
-    HANDLE              ParametersKey;
-    ULONG               Index;
-    NTSTATUS            status;
-
-    ASSERT3P(__DriverGetDriverObject(), ==, NULL);
-    UNREFERENCED_PARAMETER(RegistryPath);
-
-    ExInitializeDriverRuntime(DrvRtPoolNxOptIn);
-
-    Trace("====>\n");
-
-    __DriverSetDriverObject(DriverObject);
-
-    DriverObject->DriverUnload = DriverUnload;
-
-    Verbose("XENDISK %d.%d.%d (%d) (%02d.%02d.%04d)\n",
-            MAJOR_VERSION,
-            MINOR_VERSION,
-            MICRO_VERSION,
-            BUILD_NUMBER,
-            DAY,
-            MONTH,
-            YEAR);
-
-    status = RegistryInitialize(DriverObject, RegistryPath);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = RegistryOpenParametersKey(KEY_READ, &ParametersKey);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    __DriverSetParametersKey(ParametersKey);
-
-    DriverObject->DriverExtension->AddDevice = AddDevice;
-
-    for (Index = 0; Index <= IRP_MJ_MAXIMUM_FUNCTION; Index++) {
-#pragma prefast(suppress:28169) // No __drv_dispatchType annotation
-#pragma prefast(suppress:28168) // No matching __drv_dispatchType annotation for IRP_MJ_CREATE
-        DriverObject->MajorFunction[Index] = Dispatch;
-    }
-
-    Trace("<====\n");
-
-    return STATUS_SUCCESS;
-
-fail2:
-    Error("fail2\n");
-
-    RegistryTeardown();
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    __DriverSetDriverObject(NULL);
-
-    ASSERT(IsZeroMemory(&Driver, sizeof (XENDISK_DRIVER)));
-
-    return status;
-}
diff --git a/src/xendisk/driver.h b/src/xendisk/driver.h
deleted file mode 100644
index 7e2c20c..0000000
--- a/src/xendisk/driver.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _XENDISK_DRIVER_H
-#define _XENDISK_DRIVER_H
-
-#include "fdo.h"
-#include "pdo.h"
-
-extern PDRIVER_OBJECT
-DriverGetDriverObject(
-    VOID
-    );
-
-extern HANDLE
-DriverGetParametersKey(
-    VOID
-    );
-
-#define MAX_DEVICE_ID_LEN   200
-
-#pragma warning(push)
-#pragma warning(disable:4201) // nonstandard extension used : nameless struct/union
-
-typedef struct _XENDISK_DX {
-    PDEVICE_OBJECT      DeviceObject;
-    DEVICE_OBJECT_TYPE  Type;
-
-    DEVICE_PNP_STATE    DevicePnpState;
-    DEVICE_PNP_STATE    PreviousDevicePnpState;
-
-    SYSTEM_POWER_STATE  SystemPowerState;
-    DEVICE_POWER_STATE  DevicePowerState;
-
-    IO_REMOVE_LOCK      RemoveLock;
-
-    LIST_ENTRY          ListEntry;
-
-    union {
-        PXENDISK_FDO    Fdo;
-        PXENDISK_PDO    Pdo;
-    };
-} XENDISK_DX, *PXENDISK_DX;
-
-#pragma warning(pop)
-
-#endif // _XENDISK_DRIVER_H
diff --git a/src/xendisk/fdo.c b/src/xendisk/fdo.c
deleted file mode 100644
index ef8b30d..0000000
--- a/src/xendisk/fdo.c
+++ /dev/null
@@ -1,1618 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#define INITGUID 1
-
-#include <ntddk.h>
-#include <wdmguid.h>
-#include <ntstrsafe.h>
-#include <stdlib.h>
-#include <names.h>
-
-#include "driver.h"
-#include "fdo.h"
-#include "pdo.h"
-#include "thread.h"
-#include "mutex.h"
-#include "debug.h"
-#include "assert.h"
-#include "util.h"
-
-#define FDO_TAG 'ODF'
-
-struct _XENDISK_FDO {
-    PXENDISK_DX                     Dx;
-    PDEVICE_OBJECT                  LowerDeviceObject;
-    PDEVICE_OBJECT                  PhysicalDeviceObject;
-
-    MUTEX                           Mutex;
-    ULONG                           References;
-};
-
-static FORCEINLINE PVOID
-__FdoAllocate(
-    IN  ULONG   Length
-    )
-{
-    return __AllocatePoolWithTag(NonPagedPool, Length, FDO_TAG);
-}
-
-static FORCEINLINE VOID
-__FdoFree(
-    IN  PVOID   Buffer
-    )
-{
-    __FreePoolWithTag(Buffer, FDO_TAG);
-}
-
-static FORCEINLINE VOID
-__FdoSetDevicePnpState(
-    IN  PXENDISK_FDO        Fdo,
-    IN  DEVICE_PNP_STATE    State
-    )
-{
-    PXENDISK_DX             Dx = Fdo->Dx;
-
-    // We can never transition out of the deleted state
-    ASSERT(Dx->DevicePnpState != Deleted || State == Deleted);
-
-    Dx->PreviousDevicePnpState = Dx->DevicePnpState;
-    Dx->DevicePnpState = State;
-}
-
-static FORCEINLINE VOID
-__FdoRestoreDevicePnpState(
-    IN  PXENDISK_FDO        Fdo,
-    IN  DEVICE_PNP_STATE    State
-    )
-{
-    PXENDISK_DX             Dx = Fdo->Dx;
-
-    if (Dx->DevicePnpState == State)
-        Dx->DevicePnpState = Dx->PreviousDevicePnpState;
-}
-
-static FORCEINLINE DEVICE_PNP_STATE
-__FdoGetDevicePnpState(
-    IN  PXENDISK_FDO    Fdo
-    )
-{
-    PXENDISK_DX         Dx = Fdo->Dx;
-
-    return Dx->DevicePnpState;
-}
-
-static FORCEINLINE VOID
-__FdoSetDevicePowerState(
-    IN  PXENDISK_FDO        Fdo,
-    IN  DEVICE_POWER_STATE  State
-    )
-{
-    PXENDISK_DX             Dx = Fdo->Dx;
-
-    Dx->DevicePowerState = State;
-}
-
-static FORCEINLINE DEVICE_POWER_STATE
-__FdoGetDevicePowerState(
-    IN  PXENDISK_FDO    Fdo
-    )
-{
-    PXENDISK_DX         Dx = Fdo->Dx;
-
-    return Dx->DevicePowerState;
-}
-
-static FORCEINLINE VOID
-__FdoSetSystemPowerState(
-    IN  PXENDISK_FDO        Fdo,
-    IN  SYSTEM_POWER_STATE  State
-    )
-{
-    PXENDISK_DX              Dx = Fdo->Dx;
-
-    Dx->SystemPowerState = State;
-}
-
-static FORCEINLINE SYSTEM_POWER_STATE
-__FdoGetSystemPowerState(
-    IN  PXENDISK_FDO    Fdo
-    )
-{
-    PXENDISK_DX         Dx = Fdo->Dx;
-
-    return Dx->SystemPowerState;
-}
-
-static FORCEINLINE PDEVICE_OBJECT
-__FdoGetPhysicalDeviceObject(
-    IN  PXENDISK_FDO    Fdo
-    )
-{
-    return Fdo->PhysicalDeviceObject;
-}
-
-PDEVICE_OBJECT
-FdoGetPhysicalDeviceObject(
-    IN  PXENDISK_FDO    Fdo
-    )
-{
-    return __FdoGetPhysicalDeviceObject(Fdo);
-}
-
-VOID
-FdoAddPhysicalDeviceObject(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PDEVICE_OBJECT  DeviceObject
-    )
-{
-    PXENDISK_DX         Dx;
-
-    Dx = (PXENDISK_DX)DeviceObject->DeviceExtension;
-    ASSERT3U(Dx->Type, ==, PHYSICAL_DEVICE_OBJECT);
-
-    InsertTailList(&Fdo->Dx->ListEntry, &Dx->ListEntry);
-    ASSERT3U(Fdo->References, !=, 0);
-    Fdo->References++;
-}
-
-VOID
-FdoRemovePhysicalDeviceObject(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PDEVICE_OBJECT  DeviceObject
-    )
-{
-    PXENDISK_DX         Dx;
-
-    Dx = (PXENDISK_DX)DeviceObject->DeviceExtension;
-    ASSERT3U(Dx->Type, ==, PHYSICAL_DEVICE_OBJECT);
-
-    RemoveEntryList(&Dx->ListEntry);
-    ASSERT3U(Fdo->References, !=, 0);
-    --Fdo->References;
-}
-
-static FORCEINLINE VOID
-__FdoAcquireMutex(
-    IN  PXENDISK_FDO     Fdo
-    )
-{
-    AcquireMutex(&Fdo->Mutex);
-}
-
-VOID
-FdoAcquireMutex(
-    IN  PXENDISK_FDO     Fdo
-    )
-{
-    __FdoAcquireMutex(Fdo);
-}
-
-static FORCEINLINE VOID
-__FdoReleaseMutex(
-    IN  PXENDISK_FDO     Fdo
-    )
-{
-    ReleaseMutex(&Fdo->Mutex);
-}
-
-VOID
-FdoReleaseMutex(
-    IN  PXENDISK_FDO     Fdo
-    )
-{
-    __FdoReleaseMutex(Fdo);
-
-    if (Fdo->References == 0)
-        FdoDestroy(Fdo);
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-FdoQueryIdCompletion(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PKEVENT             Event = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-    UNREFERENCED_PARAMETER(Irp);
-
-    KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
-
-    return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-static NTSTATUS
-FdoQueryId(
-    IN  PXENDISK_FDO        Fdo,
-    IN  PDEVICE_OBJECT      DeviceObject,
-    IN  BUS_QUERY_ID_TYPE   Type,
-    OUT PCHAR               Id
-    )
-{
-    PIRP                    Irp;
-    KEVENT                  Event;
-    PIO_STACK_LOCATION      StackLocation;
-    NTSTATUS                status;
-
-    UNREFERENCED_PARAMETER(Fdo);
-
-    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
-
-    Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
-
-    status = STATUS_INSUFFICIENT_RESOURCES;
-    if (Irp == NULL)
-        goto fail1;
-
-    StackLocation = IoGetNextIrpStackLocation(Irp);
-
-    StackLocation->MajorFunction = IRP_MJ_PNP;
-    StackLocation->MinorFunction = IRP_MN_QUERY_ID;
-    StackLocation->Flags = 0;
-    StackLocation->Parameters.QueryId.IdType = Type;
-    StackLocation->DeviceObject = DeviceObject;
-    StackLocation->FileObject = NULL;
-
-    KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
-    IoSetCompletionRoutine(Irp,
-                           FdoQueryIdCompletion,
-                           &Event,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    // Default completion status
-    Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
-
-    status = IoCallDriver(DeviceObject, Irp);
-    if (status == STATUS_PENDING) {
-        (VOID) KeWaitForSingleObject(&Event,
-                                     Executive,
-                                     KernelMode,
-                                     FALSE,
-                                     NULL);
-        status = Irp->IoStatus.Status;
-    } else {
-        ASSERT3U(status, ==, Irp->IoStatus.Status);
-    }
-
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    status = RtlStringCbPrintfA(Id,
-                                MAX_DEVICE_ID_LEN,
-                                "%ws",
-                                (PWCHAR)Irp->IoStatus.Information);
-    ASSERT(NT_SUCCESS(status));
-
-    ExFreePool((PVOID)Irp->IoStatus.Information);
-
-    IoFreeIrp(Irp);
-
-    return STATUS_SUCCESS;
-
-fail2:
-    IoFreeIrp(Irp);
-
-fail1:
-    return status;
-}
-
-static NTSTATUS
-FdoAddDevice(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PDEVICE_OBJECT  PhysicalDeviceObject
-    )
-{
-    CHAR                DeviceID[MAX_DEVICE_ID_LEN];
-    CHAR                InstanceID[MAX_DEVICE_ID_LEN];
-    NTSTATUS            status;
-
-    status = FdoQueryId(Fdo,
-                        PhysicalDeviceObject,
-                        BusQueryDeviceID,
-                        DeviceID);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = FdoQueryId(Fdo,
-                        PhysicalDeviceObject,
-                        BusQueryInstanceID,
-                        InstanceID);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    status = PdoCreate(Fdo,
-                       PhysicalDeviceObject,
-                       DeviceID,
-                       InstanceID);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    return STATUS_SUCCESS;
-
-fail3:
-fail2:
-fail1:
-    return status;
-}
-
-static FORCEINLINE VOID
-__FdoEnumerate(
-    IN  PXENDISK_FDO        Fdo,
-    IN  PDEVICE_RELATIONS   Relations
-    )
-{
-    PDEVICE_OBJECT          *PhysicalDeviceObject;
-    ULONG                   Count;
-    PLIST_ENTRY             ListEntry;
-    ULONG                   Index;
-    NTSTATUS                status;
-
-    Count = Relations->Count;
-    ASSERT(Count != 0);
-
-    PhysicalDeviceObject = __FdoAllocate(sizeof (PDEVICE_OBJECT) * Count);
-
-    status = STATUS_NO_MEMORY;
-    if (PhysicalDeviceObject == NULL)
-        goto fail1;
-
-    RtlCopyMemory(PhysicalDeviceObject,
-                  Relations->Objects,
-                  sizeof (PDEVICE_OBJECT) * Count);
-
-    // Remove any PDOs that do not appear in the device list
-    ListEntry = Fdo->Dx->ListEntry.Flink;
-    while (ListEntry != &Fdo->Dx->ListEntry) {
-        PLIST_ENTRY     Next = ListEntry->Flink;
-        PXENDISK_DX     Dx = CONTAINING_RECORD(ListEntry, XENDISK_DX, ListEntry);
-        PXENDISK_PDO    Pdo = Dx->Pdo;
-
-        for (Index = 0; Index < Count; Index++) {
-            if (PdoGetPhysicalDeviceObject(Pdo) == PhysicalDeviceObject[Index]) {
-#pragma prefast(suppress:6387)  // PhysicalDeviceObject[Index] could be NULL
-                PhysicalDeviceObject[Index] = NULL; // avoid duplication
-                break;
-            }
-        }
-
-        ListEntry = Next;
-    }
-
-    // Walk the list and create PDO filters for any new devices
-    for (Index = 0; Index < Count; Index++) {
-#pragma warning(suppress:6385)  // Reading invalid data from 'PhysicalDeviceObject'
-        if (PhysicalDeviceObject[Index] != NULL) {
-            (VOID) FdoAddDevice(Fdo,
-                                PhysicalDeviceObject[Index]);
-        }
-    }
-
-    __FdoFree(PhysicalDeviceObject);
-    return;
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__FdoForwardIrpSynchronously(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PKEVENT             Event = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-    UNREFERENCED_PARAMETER(Irp);
-
-    KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
-
-    return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-static NTSTATUS
-FdoForwardIrpSynchronously(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    KEVENT              Event;
-    NTSTATUS            status;
-
-    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
-
-    KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __FdoForwardIrpSynchronously,
-                           &Event,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-    if (status == STATUS_PENDING) {
-        (VOID) KeWaitForSingleObject(&Event,
-                                     Executive,
-                                     KernelMode,
-                                     FALSE,
-                                     NULL);
-        status = Irp->IoStatus.Status;
-    } else {
-        ASSERT3U(status, ==, Irp->IoStatus.Status);
-    }
-
-    return status;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-FdoStartDevice(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    POWER_STATE         PowerState;
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = FdoForwardIrpSynchronously(Fdo, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    __FdoSetSystemPowerState(Fdo, PowerSystemWorking);
-    __FdoSetDevicePowerState(Fdo, PowerDeviceD0);
-
-    PowerState.DeviceState = PowerDeviceD0;
-    PoSetPowerState(Fdo->Dx->DeviceObject,
-                    DevicePowerState,
-                    PowerState);
-
-    __FdoSetDevicePnpState(Fdo, Started);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-
-fail2:
-    Error("fail2\n");
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__FdoQueryStopDevice(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-FdoQueryStopDevice(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    __FdoSetDevicePnpState(Fdo, StopPending);
-    Irp->IoStatus.Status = STATUS_SUCCESS;
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __FdoQueryStopDevice,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-
-    return status;
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__FdoCancelStopDevice(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-FdoCancelStopDevice(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    Irp->IoStatus.Status = STATUS_SUCCESS;
-
-    __FdoRestoreDevicePnpState(Fdo, StopPending);
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __FdoCancelStopDevice,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-
-    return status;
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__FdoStopDevice(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-FdoStopDevice(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    POWER_STATE         PowerState;
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    if (__FdoGetDevicePowerState(Fdo) != PowerDeviceD0)
-        goto done;
-
-    PowerState.DeviceState = PowerDeviceD3;
-    PoSetPowerState(Fdo->Dx->DeviceObject,
-                    DevicePowerState,
-                    PowerState);
-
-    __FdoSetDevicePowerState(Fdo, PowerDeviceD3);
-    __FdoSetSystemPowerState(Fdo, PowerSystemShutdown);
-
-done:
-    __FdoSetDevicePnpState(Fdo, Stopped);
-    Irp->IoStatus.Status = STATUS_SUCCESS;
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __FdoStopDevice,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-
-    return status;
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__FdoQueryRemoveDevice(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-FdoQueryRemoveDevice(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    __FdoSetDevicePnpState(Fdo, RemovePending);
-    Irp->IoStatus.Status = STATUS_SUCCESS;
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __FdoQueryRemoveDevice,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-
-    return status;
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__FdoCancelRemoveDevice(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-FdoCancelRemoveDevice(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    __FdoRestoreDevicePnpState(Fdo, RemovePending);
-    Irp->IoStatus.Status = STATUS_SUCCESS;
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __FdoCancelRemoveDevice,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-
-    return status;
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__FdoSurpriseRemoval(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-FdoSurpriseRemoval(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    __FdoSetDevicePnpState(Fdo, SurpriseRemovePending);
-    Irp->IoStatus.Status = STATUS_SUCCESS;
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __FdoSurpriseRemoval,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-
-    return status;
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-FdoRemoveDevice(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    POWER_STATE         PowerState;
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    if (__FdoGetDevicePowerState(Fdo) != PowerDeviceD0)
-        goto done;
-
-    PowerState.DeviceState = PowerDeviceD3;
-    PoSetPowerState(Fdo->Dx->DeviceObject,
-                    DevicePowerState,
-                    PowerState);
-
-    __FdoSetDevicePowerState(Fdo, PowerDeviceD3);
-    __FdoSetSystemPowerState(Fdo, PowerSystemShutdown);
-
-done:
-    __FdoSetDevicePnpState(Fdo, Deleted);
-
-    IoReleaseRemoveLockAndWait(&Fdo->Dx->RemoveLock, Irp);
-
-    status = FdoForwardIrpSynchronously(Fdo, Irp);
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    __FdoAcquireMutex(Fdo);
-    ASSERT3U(Fdo->References, !=, 0);
-    --Fdo->References;
-    __FdoReleaseMutex(Fdo);
-
-    if (Fdo->References == 0)
-        FdoDestroy(Fdo);
-
-    return status;
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__FdoQueryDeviceRelations(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PKEVENT             Event = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-    UNREFERENCED_PARAMETER(Irp);
-
-    KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
-
-    return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-FdoQueryDeviceRelations(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    KEVENT              Event;
-    PIO_STACK_LOCATION  StackLocation;
-    PDEVICE_RELATIONS   Relations;
-    PLIST_ENTRY         ListEntry;
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __FdoQueryDeviceRelations,
-                           &Event,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-    if (status == STATUS_PENDING) {
-        (VOID) KeWaitForSingleObject(&Event,
-                                     Executive,
-                                     KernelMode,
-                                     FALSE,
-                                     NULL);
-        status = Irp->IoStatus.Status;
-    } else {
-        ASSERT3U(status, ==, Irp->IoStatus.Status);
-    }
-
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    if (StackLocation->Parameters.QueryDeviceRelations.Type != BusRelations)
-        goto done;
-
-    Relations = (PDEVICE_RELATIONS)Irp->IoStatus.Information;
-
-    __FdoAcquireMutex(Fdo);
-
-    if (Relations->Count != 0)
-        __FdoEnumerate(Fdo, Relations);
-
-    for (ListEntry = Fdo->Dx->ListEntry.Flink;
-         ListEntry != &Fdo->Dx->ListEntry;
-         ListEntry = ListEntry->Flink) {
-        PXENDISK_DX     Dx = CONTAINING_RECORD(ListEntry, XENDISK_DX, ListEntry);
-        PXENDISK_PDO    Pdo = Dx->Pdo;
-
-        ASSERT3U(Dx->Type, ==, PHYSICAL_DEVICE_OBJECT);
-
-        if (PdoGetDevicePnpState(Pdo) == Present)
-            PdoSetDevicePnpState(Pdo, Enumerated);
-    }
-
-    __FdoReleaseMutex(Fdo);
-
-    Trace("%d PDO(s)\n", Relations->Count);
-
-    status = STATUS_SUCCESS;
-
-done:
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-
-fail2:
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__FdoDispatchPnp(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-FdoDispatchPnp(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    UCHAR               MinorFunction;
-    NTSTATUS            status;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    MinorFunction = StackLocation->MinorFunction;
-
-    switch (StackLocation->MinorFunction) {
-    case IRP_MN_START_DEVICE:
-        status = FdoStartDevice(Fdo, Irp);
-        break;
-
-    case IRP_MN_QUERY_STOP_DEVICE:
-        status = FdoQueryStopDevice(Fdo, Irp);
-        break;
-
-    case IRP_MN_CANCEL_STOP_DEVICE:
-        status = FdoCancelStopDevice(Fdo, Irp);
-        break;
-
-    case IRP_MN_STOP_DEVICE:
-        status = FdoStopDevice(Fdo, Irp);
-        break;
-
-    case IRP_MN_QUERY_REMOVE_DEVICE:
-        status = FdoQueryRemoveDevice(Fdo, Irp);
-        break;
-
-    case IRP_MN_SURPRISE_REMOVAL:
-        status = FdoSurpriseRemoval(Fdo, Irp);
-        break;
-
-    case IRP_MN_REMOVE_DEVICE:
-        status = FdoRemoveDevice(Fdo, Irp);
-        break;
-
-    case IRP_MN_CANCEL_REMOVE_DEVICE:
-        status = FdoCancelRemoveDevice(Fdo, Irp);
-        break;
-
-    case IRP_MN_QUERY_DEVICE_RELATIONS:
-        status = FdoQueryDeviceRelations(Fdo, Irp);
-        break;
-
-    default:
-        status = IoAcquireRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-        if (!NT_SUCCESS(status))
-            goto fail1;
-
-        IoCopyCurrentIrpStackLocationToNext(Irp);
-        IoSetCompletionRoutine(Irp,
-                               __FdoDispatchPnp,
-                               Fdo,
-                               TRUE,
-                               TRUE,
-                               TRUE);
-
-        status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-        break;
-    }
-
-    return status;
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-FdoSetDevicePowerUpComplete(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_FDO        Fdo = (PXENDISK_FDO) Context;
-    PIO_STACK_LOCATION  StackLocation;
-    POWER_STATE         PowerState;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    PowerState = StackLocation->Parameters.Power.State;
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    __FdoSetDevicePowerState(Fdo, PowerState.DeviceState);
-    PoSetPowerState(Fdo->Dx->DeviceObject,
-                    DevicePowerState,
-                    PowerState);
-
-    return STATUS_CONTINUE_COMPLETION;
-}
-
-static FORCEINLINE NTSTATUS
-__FdoSetDevicePowerUp(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           FdoSetDevicePowerUpComplete,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    return IoCallDriver(Fdo->LowerDeviceObject, Irp);
-}
-
-static FORCEINLINE NTSTATUS
-__FdoSetDevicePowerDown(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    POWER_STATE         PowerState;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    PowerState = StackLocation->Parameters.Power.State;
-
-    __FdoSetDevicePowerState(Fdo, PowerState.DeviceState);
-    PoSetPowerState(Fdo->Dx->DeviceObject,
-                    DevicePowerState,
-                    PowerState);
-
-    IoSkipCurrentIrpStackLocation(Irp);
-    return IoCallDriver(Fdo->LowerDeviceObject, Irp);
-}
-
-/* IRQL argnostic code, just mark power states.*/
-static FORCEINLINE NTSTATUS
-__FdoSetDevicePower(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    DEVICE_POWER_STATE  DeviceState;
-    POWER_ACTION        PowerAction;
-    NTSTATUS            status;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    DeviceState = StackLocation->Parameters.Power.State.DeviceState;
-    PowerAction = StackLocation->Parameters.Power.ShutdownType;
-
-    Trace("====> (%s:%s)\n",
-          PowerDeviceStateName(DeviceState),
-          PowerActionName(PowerAction));
-
-    if (DeviceState == __FdoGetDevicePowerState(Fdo)) {
-        IoSkipCurrentIrpStackLocation(Irp);
-        status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-        goto done;
-    }
-
-    status = (DeviceState < __FdoGetDevicePowerState(Fdo)) ?
-             __FdoSetDevicePowerUp(Fdo, Irp) :
-             __FdoSetDevicePowerDown(Fdo, Irp);
-
-done:
-    Trace("<==== (%s:%s)(%08x)\n",
-          PowerDeviceStateName(DeviceState),
-          PowerActionName(PowerAction),
-          status);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-FdoSetSystemPowerUpComplete(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_FDO        Fdo = (PXENDISK_FDO) Context;
-    PIO_STACK_LOCATION  StackLocation;
-    SYSTEM_POWER_STATE  SystemState;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    SystemState = StackLocation->Parameters.Power.State.SystemState;
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    __FdoSetSystemPowerState(Fdo, SystemState);
-
-    return STATUS_CONTINUE_COMPLETION;
-}
-
-static FORCEINLINE NTSTATUS
-__FdoSetSystemPowerUp(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           FdoSetSystemPowerUpComplete,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    return IoCallDriver(Fdo->LowerDeviceObject, Irp);
-}
-
-static FORCEINLINE NTSTATUS
-__FdoSetSystemPowerDown(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    SYSTEM_POWER_STATE  SystemState;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    SystemState = StackLocation->Parameters.Power.State.SystemState;
-
-    __FdoSetSystemPowerState(Fdo, SystemState);
-
-    IoSkipCurrentIrpStackLocation(Irp);
-    return IoCallDriver(Fdo->LowerDeviceObject, Irp);
-}
-
-static FORCEINLINE NTSTATUS
-__FdoSetSystemPower(
-    IN  PXENDISK_FDO     Fdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    SYSTEM_POWER_STATE  SystemState;
-    POWER_ACTION        PowerAction;
-    NTSTATUS            status;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    SystemState = StackLocation->Parameters.Power.State.SystemState;
-    PowerAction = StackLocation->Parameters.Power.ShutdownType;
-
-    Trace("====> (%s:%s)\n",
-          PowerSystemStateName(SystemState),
-          PowerActionName(PowerAction));
-
-    if (SystemState == __FdoGetSystemPowerState(Fdo)) {
-        IoSkipCurrentIrpStackLocation(Irp);
-        status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-        goto done;
-    }
-
-    status = (SystemState < __FdoGetSystemPowerState(Fdo)) ?
-             __FdoSetSystemPowerUp(Fdo, Irp) :
-             __FdoSetSystemPowerDown(Fdo, Irp);
-
-done:
-    Trace("<==== (%s:%s)(%08x)\n",
-          PowerSystemStateName(SystemState),
-          PowerActionName(PowerAction),
-          status);
-
-    return status;
-}
-
-static NTSTATUS
-FdoDevicePower(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    NTSTATUS            status;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-
-    switch (StackLocation->MinorFunction) {
-    case IRP_MN_SET_POWER:
-        status = __FdoSetDevicePower(Fdo, Irp);
-        break;
-
-    default:
-        IoSkipCurrentIrpStackLocation(Irp);
-        status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-        break;
-    }
-
-    return status;
-}
-
-static NTSTATUS
-FdoSystemPower(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    NTSTATUS            status;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-
-    switch (StackLocation->MinorFunction) {
-    case IRP_MN_SET_POWER:
-        status = __FdoSetSystemPower(Fdo, Irp);
-        break;
-
-    default:
-        IoSkipCurrentIrpStackLocation(Irp);
-        status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-        break;
-    }
-
-    return status;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-FdoDispatchPower(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    POWER_STATE_TYPE    PowerType;
-    NTSTATUS            status;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    PowerType = StackLocation->Parameters.Power.Type;
-
-    switch (PowerType) {
-    case DevicePowerState:
-        status = FdoDevicePower(Fdo, Irp);
-        break;
-
-    case SystemPowerState:
-        status = FdoSystemPower(Fdo, Irp);
-        break;
-
-    default:
-        IoSkipCurrentIrpStackLocation(Irp);
-        status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-        break;
-    }
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__FdoDispatchDefault(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_FDO        Fdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-FdoDispatchDefault(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Fdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __FdoDispatchDefault,
-                           Fdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Fdo->LowerDeviceObject, Irp);
-
-    return status;
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-NTSTATUS
-FdoDispatch(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    NTSTATUS            status;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-
-    switch (StackLocation->MajorFunction) {
-    case IRP_MJ_PNP:
-        status = FdoDispatchPnp(Fdo, Irp);
-        break;
-
-    case IRP_MJ_POWER:
-        status = FdoDispatchPower(Fdo, Irp);
-        break;
-
-    default:
-        status = FdoDispatchDefault(Fdo, Irp);
-        break;
-    }
-
-    return status;
-}
-
-NTSTATUS
-FdoCreate(
-    IN  PDEVICE_OBJECT  PhysicalDeviceObject
-    )
-{
-    PDEVICE_OBJECT      LowerDeviceObject;
-    ULONG               DeviceType;
-    PDEVICE_OBJECT      FilterDeviceObject;
-    PXENDISK_DX         Dx;
-    PXENDISK_FDO        Fdo;
-    NTSTATUS            status;
-
-    LowerDeviceObject = IoGetAttachedDeviceReference(PhysicalDeviceObject);
-    DeviceType = LowerDeviceObject->DeviceType;
-    ObDereferenceObject(LowerDeviceObject);
-
-#pragma prefast(suppress:28197) // Possibly leaking memory 'FilterDeviceObject'
-    status = IoCreateDevice(DriverGetDriverObject(),
-                            sizeof (XENDISK_DX),
-                            NULL,
-                            DeviceType,
-                            FILE_DEVICE_SECURE_OPEN,
-                            FALSE,
-                            &FilterDeviceObject);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    Dx = (PXENDISK_DX)FilterDeviceObject->DeviceExtension;
-    RtlZeroMemory(Dx, sizeof (XENDISK_DX));
-
-    Dx->Type = FUNCTION_DEVICE_OBJECT;
-    Dx->DeviceObject = FilterDeviceObject;
-    Dx->DevicePnpState = Added;
-    Dx->SystemPowerState = PowerSystemShutdown;
-    Dx->DevicePowerState = PowerDeviceD3;
-
-    IoInitializeRemoveLock(&Dx->RemoveLock, FDO_TAG, 0, 0);
-
-    Fdo = __FdoAllocate(sizeof (XENDISK_FDO));
-
-    status = STATUS_NO_MEMORY;
-    if (Fdo == NULL)
-        goto fail2;
-
-    LowerDeviceObject = IoAttachDeviceToDeviceStack(FilterDeviceObject,
-                                                    PhysicalDeviceObject);
-
-    status = STATUS_UNSUCCESSFUL;
-    if (LowerDeviceObject == NULL)
-        goto fail3;
-
-    Fdo->Dx = Dx;
-    Fdo->PhysicalDeviceObject = PhysicalDeviceObject;
-    Fdo->LowerDeviceObject = LowerDeviceObject;
-
-    InitializeMutex(&Fdo->Mutex);
-    InitializeListHead(&Dx->ListEntry);
-    Fdo->References = 1;
-
-    Verbose("%p\n", FilterDeviceObject);
-
-    Dx->Fdo = Fdo;
-
-#pragma prefast(suppress:28182)  // Dereferencing NULL pointer
-    FilterDeviceObject->DeviceType = LowerDeviceObject->DeviceType;
-    FilterDeviceObject->Characteristics = LowerDeviceObject->Characteristics;
-
-    FilterDeviceObject->Flags |= LowerDeviceObject->Flags;
-    FilterDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
-
-    return STATUS_SUCCESS;
-
-fail3:
-    Error("fail3\n");
-
-    ASSERT(IsZeroMemory(Fdo, sizeof (XENDISK_FDO)));
-    __FdoFree(Fdo);
-
-fail2:
-    Error("fail2\n");
-
-    IoDeleteDevice(FilterDeviceObject);
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return status;
-}
-
-VOID
-FdoDestroy(
-    IN  PXENDISK_FDO    Fdo
-    )
-{
-    PDEVICE_OBJECT      LowerDeviceObject = Fdo->LowerDeviceObject;
-    PXENDISK_DX         Dx = Fdo->Dx;
-    PDEVICE_OBJECT      FilterDeviceObject = Dx->DeviceObject;
-
-    ASSERT(IsListEmpty(&Dx->ListEntry));
-    ASSERT3U(Fdo->References, ==, 0);
-    ASSERT3U(__FdoGetDevicePnpState(Fdo), ==, Deleted);
-
-    Dx->Fdo = NULL;
-
-    RtlZeroMemory(&Fdo->Mutex, sizeof (MUTEX));
-
-    Fdo->LowerDeviceObject = NULL;
-    Fdo->PhysicalDeviceObject = NULL;
-    Fdo->Dx = NULL;
-
-    IoDetachDevice(LowerDeviceObject);
-
-    ASSERT(IsZeroMemory(Fdo, sizeof (XENDISK_FDO)));
-    __FdoFree(Fdo);
-
-    IoDeleteDevice(FilterDeviceObject);
-}
diff --git a/src/xendisk/fdo.h b/src/xendisk/fdo.h
deleted file mode 100644
index dad27ea..0000000
--- a/src/xendisk/fdo.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _XENDISK_FDO_H
-#define _XENDISK_FDO_H
-
-#include <ntddk.h>
-#include "types.h"
-
-typedef struct _XENDISK_FDO XENDISK_FDO, *PXENDISK_FDO;
-
-extern VOID
-FdoAddPhysicalDeviceObject(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PDEVICE_OBJECT  DeviceObject
-    );
-
-extern VOID
-FdoRemovePhysicalDeviceObject(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PDEVICE_OBJECT  DeviceObject
-    );
-
-extern VOID
-FdoAcquireMutex(
-    IN  PXENDISK_FDO     Fdo
-    );
-
-extern VOID
-FdoReleaseMutex(
-    IN  PXENDISK_FDO     Fdo
-    );
-
-extern PDEVICE_OBJECT
-FdoGetPhysicalDeviceObject(
-    IN  PXENDISK_FDO    Fdo
-    );
-
-extern NTSTATUS
-FdoDispatch(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PIRP            Irp
-    );
-
-extern NTSTATUS
-FdoCreate(
-    IN  PDEVICE_OBJECT  PhysicalDeviceObject
-    );
-
-extern VOID
-FdoDestroy(
-    IN  PXENDISK_FDO    Fdo
-    );
-
-#endif // _XENDISK_FDO_H
diff --git a/src/xendisk/mutex.h b/src/xendisk/mutex.h
deleted file mode 100644
index e8a82ba..0000000
--- a/src/xendisk/mutex.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _XENDISK_MUTEX_H
-#define _XENDISK_MUTEX_H
-
-#include <ntddk.h>
-
-#include "assert.h"
-
-typedef struct _MUTEX {
-    PKTHREAD    Owner;
-    KEVENT      Event;
-} MUTEX, *PMUTEX;
-
-static FORCEINLINE VOID
-InitializeMutex(
-    IN  PMUTEX  Mutex
-    )
-{
-    RtlZeroMemory(Mutex, sizeof (MUTEX));
-
-    KeInitializeEvent(&Mutex->Event, SynchronizationEvent, TRUE);
-}
-
-static FORCEINLINE BOOLEAN
-__drv_maxIRQL(PASSIVE_LEVEL)
-TryAcquireMutex(
-    IN  PMUTEX      Mutex
-    )
-{
-    LARGE_INTEGER   Timeout;
-    NTSTATUS        status;
-
-    Timeout.QuadPart = 0;
-
-    status = KeWaitForSingleObject(&Mutex->Event,
-                                   Executive,
-                                   KernelMode,
-                                   FALSE,
-                                   &Timeout);
-    if (status == STATUS_TIMEOUT)
-        return FALSE;
-
-    ASSERT(NT_SUCCESS(status));
-
-    ASSERT3P(Mutex->Owner, ==, NULL);
-    Mutex->Owner = KeGetCurrentThread();
-
-    return TRUE;
-}
-
-static FORCEINLINE VOID
-__drv_maxIRQL(PASSIVE_LEVEL)
-AcquireMutex(
-    IN  PMUTEX  Mutex
-    )
-{
-    NTSTATUS    status;
-
-    status = KeWaitForSingleObject(&Mutex->Event,
-                                   Executive,
-                                   KernelMode,
-                                   FALSE,
-                                   NULL);
-
-    ASSERT(NT_SUCCESS(status));
-
-    ASSERT3P(Mutex->Owner, ==, NULL);
-    Mutex->Owner = KeGetCurrentThread();
-}
-
-static FORCEINLINE VOID
-__drv_maxIRQL(PASSIVE_LEVEL)
-ReleaseMutex(
-    IN  PMUTEX  Mutex
-    )
-{
-    ASSERT3P(Mutex->Owner, ==, KeGetCurrentThread());
-    Mutex->Owner = NULL;
-
-    KeSetEvent(&Mutex->Event, IO_NO_INCREMENT, FALSE);
-}
-
-#endif  // _XENDISK_MUTEX_H
diff --git a/src/xendisk/pdo.c b/src/xendisk/pdo.c
deleted file mode 100644
index 9ff8733..0000000
--- a/src/xendisk/pdo.c
+++ /dev/null
@@ -1,2000 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#define INITGUID 1
-
-#include <ntddk.h>
-#include <wdmguid.h>
-#include <ntstrsafe.h>
-#include <stdlib.h>
-#include <storport.h>
-#include <Ntddstor.h>
-#include <Ntddscsi.h>
-#include <names.h>
-
-#include "fdo.h"
-#include "pdo.h"
-#include "driver.h"
-#include "registry.h"
-#include "thread.h"
-#include "debug.h"
-#include "assert.h"
-#include "util.h"
-
-#define PDO_TAG 'ODP'
-
-#define MAXNAMELEN  128
-
-struct _XENDISK_PDO {
-    PXENDISK_DX                 Dx;
-    PDEVICE_OBJECT              LowerDeviceObject;
-    PDEVICE_OBJECT              PhysicalDeviceObject;
-    CHAR                        Name[MAXNAMELEN];
-
-    PXENDISK_FDO                Fdo;
-
-    BOOLEAN                     InterceptTrim;
-    BOOLEAN                     DiscardSupported;
-    ULONG                       SectorSize;
-    ULONG                       PhysSectorSize;
-};
-
-static FORCEINLINE PVOID
-__PdoAllocate(
-    IN  ULONG   Length
-    )
-{
-    return __AllocatePoolWithTag(NonPagedPool, Length, PDO_TAG);
-}
-
-static FORCEINLINE VOID
-__PdoFree(
-    IN  PVOID   Buffer
-    )
-{
-    __FreePoolWithTag(Buffer, PDO_TAG);
-}
-
-static FORCEINLINE VOID
-__PdoSetDevicePnpState(
-    IN  PXENDISK_PDO        Pdo,
-    IN  DEVICE_PNP_STATE    State
-    )
-{
-    PXENDISK_DX             Dx = Pdo->Dx;
-
-    // We can never transition out of the deleted state
-    ASSERT(Dx->DevicePnpState != Deleted || State == Deleted);
-
-    Dx->PreviousDevicePnpState = Dx->DevicePnpState;
-    Dx->DevicePnpState = State;
-}
-
-VOID
-PdoSetDevicePnpState(
-    IN  PXENDISK_PDO        Pdo,
-    IN  DEVICE_PNP_STATE    State
-    )
-{
-    __PdoSetDevicePnpState(Pdo, State);
-}
-
-static FORCEINLINE VOID
-__PdoRestoreDevicePnpState(
-    IN  PXENDISK_PDO        Pdo,
-    IN  DEVICE_PNP_STATE    State
-    )
-{
-    PXENDISK_DX             Dx = Pdo->Dx;
-
-    if (Dx->DevicePnpState == State)
-        Dx->DevicePnpState = Dx->PreviousDevicePnpState;
-}
-
-static FORCEINLINE DEVICE_PNP_STATE
-__PdoGetDevicePnpState(
-    IN  PXENDISK_PDO    Pdo
-    )
-{
-    PXENDISK_DX         Dx = Pdo->Dx;
-
-    return Dx->DevicePnpState;
-}
-
-DEVICE_PNP_STATE
-PdoGetDevicePnpState(
-    IN  PXENDISK_PDO    Pdo
-    )
-{
-    return __PdoGetDevicePnpState(Pdo);
-}
-
-static FORCEINLINE VOID
-__PdoSetDevicePowerState(
-    IN  PXENDISK_PDO        Pdo,
-    IN  DEVICE_POWER_STATE  State
-    )
-{
-    PXENDISK_DX             Dx = Pdo->Dx;
-
-    Dx->DevicePowerState = State;
-}
-
-static FORCEINLINE DEVICE_POWER_STATE
-__PdoGetDevicePowerState(
-    IN  PXENDISK_PDO    Pdo
-    )
-{
-    PXENDISK_DX         Dx = Pdo->Dx;
-
-    return Dx->DevicePowerState;
-}
-
-static FORCEINLINE VOID
-__PdoSetSystemPowerState(
-    IN  PXENDISK_PDO        Pdo,
-    IN  SYSTEM_POWER_STATE  State
-    )
-{
-    PXENDISK_DX             Dx = Pdo->Dx;
-
-    Dx->SystemPowerState = State;
-}
-
-static FORCEINLINE SYSTEM_POWER_STATE
-__PdoGetSystemPowerState(
-    IN  PXENDISK_PDO    Pdo
-    )
-{
-    PXENDISK_DX         Dx = Pdo->Dx;
-
-    return Dx->SystemPowerState;
-}
-
-PDEVICE_OBJECT
-PdoGetPhysicalDeviceObject(
-    IN  PXENDISK_PDO    Pdo
-    )
-{
-    return Pdo->PhysicalDeviceObject;
-}
-
-static FORCEINLINE VOID
-__PdoLink(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PXENDISK_FDO    Fdo
-    )
-{
-    Pdo->Fdo = Fdo;
-    FdoAddPhysicalDeviceObject(Fdo, Pdo->Dx->DeviceObject);
-}
-
-static FORCEINLINE VOID
-__PdoUnlink(
-    IN  PXENDISK_PDO    Pdo
-    )
-{
-    PXENDISK_FDO        Fdo = Pdo->Fdo;
-
-    ASSERT(Fdo != NULL);
-
-    FdoRemovePhysicalDeviceObject(Fdo, Pdo->Dx->DeviceObject);
-
-    Pdo->Fdo = NULL;
-}
-
-static FORCEINLINE PXENDISK_FDO
-__PdoGetFdo(
-    IN  PXENDISK_PDO Pdo
-    )
-{
-    return Pdo->Fdo;
-}
-
-static FORCEINLINE VOID
-__PdoSetName(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PCHAR           DeviceID,
-    IN  PCHAR           InstanceID
-    )
-{
-    NTSTATUS            status;
-
-    status = RtlStringCbPrintfA(Pdo->Name,
-                                MAXNAMELEN,
-                                "%s\\%s",
-                                DeviceID,
-                                InstanceID);
-    ASSERT(NT_SUCCESS(status));
-}
-
-static FORCEINLINE PCHAR
-__PdoGetName(
-    IN  PXENDISK_PDO    Pdo
-    )
-{
-    return Pdo->Name;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__PdoForwardIrpSynchronously(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PKEVENT             Event = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-    UNREFERENCED_PARAMETER(Irp);
-
-    KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
-
-    return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-static NTSTATUS
-PdoForwardIrpSynchronously(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    KEVENT              Event;
-    NTSTATUS            status;
-
-    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
-
-    KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __PdoForwardIrpSynchronously,
-                           &Event,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-    if (status == STATUS_PENDING) {
-        (VOID) KeWaitForSingleObject(&Event,
-                                     Executive,
-                                     KernelMode,
-                                     FALSE,
-                                     NULL);
-        status = Irp->IoStatus.Status;
-    } else {
-        ASSERT3U(status, ==, Irp->IoStatus.Status);
-    }
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__PdoForwardIrpAndForget(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
-static NTSTATUS
-PdoForwardIrpAndForget(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                            __PdoForwardIrpAndForget,
-                            Pdo,
-                            TRUE,
-                            TRUE,
-                            TRUE);
-
-    return IoCallDriver(Pdo->LowerDeviceObject, Irp);
-}
-
-static NTSTATUS
-PdoCompleteIrp(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp,
-    IN  NTSTATUS        Status
-    )
-{
-    Irp->IoStatus.Status = Status;
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-    return Status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__PdoSendAwaitSrb(
-    IN  PDEVICE_OBJECT          DeviceObject,
-    IN  PIRP                    Irp,
-    IN  PVOID                   Context
-    )
-{
-    UNREFERENCED_PARAMETER(DeviceObject);
-    UNREFERENCED_PARAMETER(Context);
-
-    *(Irp->UserIosb) = Irp->IoStatus;
-
-    if (Irp->MdlAddress) {
-        MmUnlockPages(Irp->MdlAddress);
-        IoFreeMdl(Irp->MdlAddress);
-    }
-
-    KeSetEvent(Irp->UserEvent, IO_NO_INCREMENT, FALSE);
-
-    IoFreeIrp(Irp);
-    return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-static NTSTATUS
-PdoSendAwaitSrb(
-    IN  PXENDISK_PDO            Pdo,
-    IN  PSCSI_REQUEST_BLOCK     Srb
-    )
-{
-    PIRP                        Irp;
-    IO_STATUS_BLOCK             IoStatus;
-    KEVENT                      Event;
-    PIO_STACK_LOCATION          Stack;
-    NTSTATUS                    status;
-
-    KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
-    status = STATUS_NO_MEMORY;
-    Irp = IoAllocateIrp((CCHAR)(Pdo->LowerDeviceObject->StackSize + 1), FALSE);
-    if (Irp == NULL)
-        goto fail1;
-
-    Stack = IoGetNextIrpStackLocation(Irp);
-    Stack->MajorFunction = IRP_MJ_SCSI;
-    Stack->Parameters.Scsi.Srb = Srb;
-
-    IoSetCompletionRoutine(Irp,
-                            __PdoSendAwaitSrb,
-                            Srb,
-                            TRUE,
-                            TRUE,
-                            TRUE);
-    Irp->UserIosb = &IoStatus;
-    Irp->UserEvent = &Event;
-
-    Irp->MdlAddress = IoAllocateMdl(Srb->DataBuffer,
-                                    Srb->DataTransferLength,
-                                    FALSE,
-                                    FALSE,
-                                    Irp);
-    if (Irp->MdlAddress == NULL)
-        goto fail2;
-
-#pragma warning(disable:6320)
-    __try {
-        MmProbeAndLockPages(Irp->MdlAddress, KernelMode, IoWriteAccess);
-    } __except (EXCEPTION_EXECUTE_HANDLER) {
-        status = GetExceptionCode();
-
-        goto fail3;
-    }
-#pragma warning(default:6320)
-
-    Srb->OriginalRequest = Irp;
-
-    status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-    if (status == STATUS_PENDING) {
-        (VOID) KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
-        status = IoStatus.Status;
-    }
-
-    return status;
-
-fail3:
-    Error("fail3\n");
-
-    IoFreeMdl(Irp->MdlAddress);
-
-fail2:
-    Error("fail2\n");
-
-    IoFreeIrp(Irp);
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return status;
-}
-
-static NTSTATUS
-PdoSendReadCapacity16Synchronous(
-    IN  PXENDISK_PDO        Pdo,
-    OUT PULONG              SectorSize,
-    OUT PULONG              PhysSectorSize,
-    OUT PULONG64            SectorCount
-    )
-{
-    SCSI_REQUEST_BLOCK       Srb;
-    PCDB                     Cdb;
-    PREAD_CAPACITY16_DATA    Capacity;
-    ULONG                    Length;
-    NTSTATUS                 status;
-
-    Trace("====>\n");
-
-    Length = sizeof(READ_CAPACITY16_DATA);
-
-    status = STATUS_NO_MEMORY;
-    Capacity = __PdoAllocate(Length);
-    if (Capacity == NULL)
-        goto fail1;
-
-    RtlZeroMemory(&Srb, sizeof(SCSI_REQUEST_BLOCK));
-    Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
-    Srb.SrbFlags = 0;
-    Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
-    Srb.DataBuffer = Capacity;
-    Srb.DataTransferLength = Length;
-    Srb.TimeOutValue = (ULONG)-1;
-    Srb.CdbLength = 16;
-
-    Cdb = (PCDB)&Srb.Cdb[0];
-    Cdb->READ_CAPACITY16.OperationCode = SCSIOP_READ_CAPACITY16;
-    Cdb->READ_CAPACITY16.ServiceAction = SERVICE_ACTION_READ_CAPACITY16;
-    *(PULONG)Cdb->READ_CAPACITY16.AllocationLength = _byteswap_ulong(Length);
-
-    status = PdoSendAwaitSrb(Pdo, &Srb);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    status = STATUS_UNSUCCESSFUL;
-    if (Srb.DataTransferLength < Length)
-        goto fail3;
-
-    *SectorSize = _byteswap_ulong(Capacity->BytesPerBlock);
-    *PhysSectorSize = *SectorSize << Capacity->LogicalPerPhysicalExponent;
-    *SectorCount = _byteswap_uint64(Capacity->LogicalBlockAddress.QuadPart) + 1;
-
-    __PdoFree(Capacity);
-
-    Trace("<====\n");
-    return STATUS_SUCCESS;
-
-fail3:
-    Error("fail3\n");
-
-fail2:
-    Error("fail2\n");
-
-    __PdoFree(Capacity);
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return status;
-}
-
-static NTSTATUS
-PdoSendInquiryB0Synchronous(
-    IN  PXENDISK_PDO        Pdo,
-    OUT PBOOLEAN            Supported
-    )
-{
-    SCSI_REQUEST_BLOCK      Srb;
-    PCDB                    Cdb;
-    PVPD_BLOCK_LIMITS_PAGE  BlockLimits;
-    ULONG                   Length;
-    NTSTATUS                status;
-
-    Trace("====>\n");
-
-    Length = sizeof(VPD_BLOCK_LIMITS_PAGE);
-    *Supported = FALSE;
-
-    status = STATUS_NO_MEMORY;
-    BlockLimits = __PdoAllocate(Length);
-    if (BlockLimits == NULL)
-        goto fail1;
-
-    RtlZeroMemory(&Srb, sizeof(SCSI_REQUEST_BLOCK));
-    Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
-    Srb.SrbFlags = 0;
-    Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
-    Srb.DataBuffer = BlockLimits;
-    Srb.DataTransferLength = Length;
-    Srb.TimeOutValue = (ULONG)-1;
-    Srb.CdbLength = 6;
-
-    Cdb = (PCDB)&Srb.Cdb[0];
-    Cdb->CDB6INQUIRY3.OperationCode = SCSIOP_INQUIRY;
-    Cdb->CDB6INQUIRY3.PageCode = 0xB0;
-    Cdb->CDB6INQUIRY3.EnableVitalProductData = 1;
-    Cdb->CDB6INQUIRY3.AllocationLength = (UCHAR)Length;
-
-    status = PdoSendAwaitSrb(Pdo, &Srb);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    status = STATUS_UNSUCCESSFUL;
-    if (Srb.DataTransferLength < Length)
-        goto fail3;
-
-    *Supported = BlockLimits->UGAValid;
-
-    __PdoFree(BlockLimits);
-
-    Trace("<====\n");
-    return STATUS_SUCCESS;
-
-fail3:
-    Error("fail3\n");
-
-fail2:
-    Error("fail2\n");
-
-    __PdoFree(BlockLimits);
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return status;
-}
-
-static NTSTATUS
-PdoSendTrimSynchronous(
-    IN  PXENDISK_PDO            Pdo,
-    IN  PDEVICE_DATA_SET_RANGE  Ranges,
-    IN  ULONG                   Count
-    )
-{
-    SCSI_REQUEST_BLOCK          Srb;
-    PCDB                        Cdb;
-    PUNMAP_LIST_HEADER          Unmap;
-    ULONG                       Length;
-    ULONG                       Index;
-    NTSTATUS                    status;
-
-    Length = sizeof(UNMAP_LIST_HEADER) +
-             (Count * sizeof(UNMAP_BLOCK_DESCRIPTOR));
-
-    status = STATUS_NO_MEMORY;
-    Unmap = __PdoAllocate(Length);
-    if (Unmap == NULL)
-        goto fail1;
-
-    RtlZeroMemory(&Srb, sizeof(SCSI_REQUEST_BLOCK));
-    Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
-    Srb.SrbFlags = 0;
-    Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
-    Srb.DataBuffer = Unmap;
-    Srb.DataTransferLength = Length;
-    Srb.TimeOutValue = (ULONG)-1;
-    Srb.CdbLength = 10;
-
-    Cdb = (PCDB)&Srb.Cdb[0];
-    Cdb->UNMAP.OperationCode = SCSIOP_UNMAP;
-    *(PUSHORT)Cdb->UNMAP.AllocationLength = _byteswap_ushort((USHORT)Length);
-
-    *(PUSHORT)Unmap->DataLength = _byteswap_ushort((USHORT)(Length - FIELD_OFFSET(UNMAP_LIST_HEADER, BlockDescrDataLength)));
-    *(PUSHORT)Unmap->BlockDescrDataLength = _byteswap_ushort((USHORT)(Length - FIELD_OFFSET(UNMAP_LIST_HEADER, Descriptors[0])));
-
-    for (Index = 0; Index < Count; ++Index) {
-        PUNMAP_BLOCK_DESCRIPTOR Block = &Unmap->Descriptors[Index];
-        PDEVICE_DATA_SET_RANGE  Range = &Ranges[Index];
-
-        ULONG   LengthInSectors = (ULONG)(Range->LengthInBytes / Pdo->SectorSize);
-        ULONG64 OffsetInSectors = (ULONG64)(Range->StartingOffset / Pdo->SectorSize);
-
-        *(PULONG64)Block->StartingLba = _byteswap_uint64(OffsetInSectors);
-        *(PULONG)Block->LbaCount = _byteswap_ulong(LengthInSectors);
-    }
-
-    status = PdoSendAwaitSrb(Pdo, &Srb);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    __PdoFree(Unmap);
-    return status;
-
-fail2:
-    Error("fail2\n");
-
-    __PdoFree(Unmap);
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return status;
-}
-
-static const CHAR *
-PropertyIdName(
-    IN  STORAGE_PROPERTY_ID Id
-    )
-{
-#define _STORAGE_PROPERTY_NAME(_Id) \
-    case Storage ## _Id:            \
-        return #_Id;
-
-    switch (Id) {
-    _STORAGE_PROPERTY_NAME(DeviceProperty);
-    _STORAGE_PROPERTY_NAME(AdapterProperty);
-    _STORAGE_PROPERTY_NAME(DeviceIdProperty);
-    _STORAGE_PROPERTY_NAME(DeviceUniqueIdProperty);
-    _STORAGE_PROPERTY_NAME(DeviceWriteCacheProperty);
-    _STORAGE_PROPERTY_NAME(MiniportProperty);
-    _STORAGE_PROPERTY_NAME(AccessAlignmentProperty);
-    _STORAGE_PROPERTY_NAME(DeviceSeekPenaltyProperty);
-    _STORAGE_PROPERTY_NAME(DeviceTrimProperty);
-    _STORAGE_PROPERTY_NAME(DeviceWriteAggregationProperty);
-    _STORAGE_PROPERTY_NAME(DeviceDeviceTelemetryProperty);
-    _STORAGE_PROPERTY_NAME(DeviceLBProvisioningProperty);
-    _STORAGE_PROPERTY_NAME(DevicePowerProperty);
-    _STORAGE_PROPERTY_NAME(DeviceCopyOffloadProperty);
-    _STORAGE_PROPERTY_NAME(DeviceResiliencyProperty);
-    _STORAGE_PROPERTY_NAME(DeviceMediumProductType);
-    _STORAGE_PROPERTY_NAME(AdapterCryptoProperty);
-    _STORAGE_PROPERTY_NAME(DeviceIoCapabilityProperty);
-    _STORAGE_PROPERTY_NAME(AdapterProtocolSpecificProperty);
-    _STORAGE_PROPERTY_NAME(DeviceProtocolSpecificProperty);
-    _STORAGE_PROPERTY_NAME(AdapterTemperatureProperty);
-    _STORAGE_PROPERTY_NAME(DeviceTemperatureProperty);
-    _STORAGE_PROPERTY_NAME(AdapterPhysicalTopologyProperty);
-    _STORAGE_PROPERTY_NAME(DevicePhysicalTopologyProperty);
-    _STORAGE_PROPERTY_NAME(DeviceAttributesProperty);
-    default:
-        break;
-    }
-
-    return "UNKNOWN";
-
-#undef _STORAGE_PROPERTY_NAME
-}
-
-static const CHAR *
-QueryTypeName(
-    IN  STORAGE_QUERY_TYPE  Type
-    )
-{
-#define _STORAGE_QUERY_NAME(_Type)   \
-    case Property ## _Type ## Query: \
-        return #_Type;
-
-    switch (Type) {
-    _STORAGE_QUERY_NAME(Standard);
-    _STORAGE_QUERY_NAME(Exists);
-    _STORAGE_QUERY_NAME(Mask);
-    default:
-        break;
-    }
-
-    return "UNKNOWN";
-
-#undef _STORAGE_QUERY_NAME
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoQueryProperty(
-    IN  PXENDISK_PDO        Pdo,
-    IN  PIRP                Irp
-    )
-{
-    PIO_STACK_LOCATION      StackLocation;
-    PSTORAGE_PROPERTY_QUERY Query;
-    NTSTATUS                status;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-
-    if (StackLocation->Parameters.DeviceIoControl.InputBufferLength <
-        sizeof (STORAGE_PROPERTY_QUERY))
-        return PdoCompleteIrp(Pdo, Irp, STATUS_INFO_LENGTH_MISMATCH);
-
-    Query = Irp->AssociatedIrp.SystemBuffer;
-
-    Trace("%s %s\n", PropertyIdName(Query->PropertyId), QueryTypeName(Query->QueryType));
-
-    switch (Query->PropertyId) {
-    case StorageDeviceTrimProperty:
-        if (!Pdo->InterceptTrim || !Pdo->DiscardSupported) {
-            status = PdoForwardIrpAndForget(Pdo, Irp);
-            break;
-        }
-
-        if (Query->QueryType == PropertyStandardQuery) {
-            PDEVICE_TRIM_DESCRIPTOR Trim;
-
-            if (StackLocation->Parameters.DeviceIoControl.OutputBufferLength <
-                sizeof (DEVICE_TRIM_DESCRIPTOR))
-                return PdoCompleteIrp(Pdo, Irp, STATUS_BUFFER_OVERFLOW);
-
-            Trim = Irp->AssociatedIrp.SystemBuffer;
-
-            RtlZeroMemory(Trim, sizeof(DEVICE_TRIM_DESCRIPTOR));
-
-            Trim->Version = sizeof(DEVICE_TRIM_DESCRIPTOR);
-            Trim->Size = sizeof(DEVICE_TRIM_DESCRIPTOR);
-            Trim->TrimEnabled = TRUE;
-
-            Irp->IoStatus.Information = sizeof(DEVICE_TRIM_DESCRIPTOR);
-        } else {
-            Irp->IoStatus.Information = 0;
-        }
-
-        status = PdoCompleteIrp(Pdo, Irp, STATUS_SUCCESS);
-        break;
-
-    case StorageAccessAlignmentProperty: {
-        if (Query->QueryType == PropertyStandardQuery) {
-            PSTORAGE_ACCESS_ALIGNMENT_DESCRIPTOR AccessAlignment;
-
-            if (StackLocation->Parameters.DeviceIoControl.OutputBufferLength <
-                sizeof (STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR))
-                return PdoCompleteIrp(Pdo, Irp, STATUS_BUFFER_OVERFLOW);
-
-            AccessAlignment = Irp->AssociatedIrp.SystemBuffer;
-
-            RtlZeroMemory(AccessAlignment, sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR));
-
-            AccessAlignment->Version = sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR);
-            AccessAlignment->Size = sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR);
-            AccessAlignment->BytesPerCacheLine = 0;
-            AccessAlignment->BytesOffsetForCacheAlignment = 0;
-            AccessAlignment->BytesPerLogicalSector = Pdo->SectorSize;
-            AccessAlignment->BytesPerPhysicalSector = Pdo->PhysSectorSize;
-            AccessAlignment->BytesOffsetForSectorAlignment = 0;
-
-            Irp->IoStatus.Information = sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR);
-        } else {
-            Irp->IoStatus.Information = 0;
-        }
-
-        status = PdoCompleteIrp(Pdo, Irp, STATUS_SUCCESS);
-        break;
-    }
-    default:
-        status = PdoForwardIrpAndForget(Pdo, Irp);
-        break;
-    }
-
-    return status;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoManageDataSetAttributes(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    PDEVICE_MANAGE_DATA_SET_ATTRIBUTES  Attributes;
-    PDEVICE_DATA_SET_RANGE              Ranges;
-    ULONG                               NumRanges;
-    NTSTATUS                            status;
-
-    Attributes = Irp->AssociatedIrp.SystemBuffer;
-
-    switch (Attributes->Action) {
-    case DeviceDsmAction_Trim:
-        if (!Pdo->InterceptTrim || !Pdo->DiscardSupported) {
-            status = PdoForwardIrpAndForget(Pdo, Irp);
-            break;
-        }
-
-        Ranges = (PDEVICE_DATA_SET_RANGE)((PUCHAR)Attributes + Attributes->DataSetRangesOffset);
-        NumRanges = Attributes->DataSetRangesLength / sizeof(DEVICE_DATA_SET_RANGE);
-
-        status = PdoSendTrimSynchronous(Pdo, Ranges, NumRanges);
-
-        status = PdoCompleteIrp(Pdo, Irp, status);
-        break;
-
-    default:
-        status = PdoForwardIrpAndForget(Pdo, Irp);
-        break;
-    }
-
-    return status;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoDispatchControl(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    ULONG               ControlCode;
-    ULONG               Method;
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    ControlCode = StackLocation->Parameters.DeviceIoControl.IoControlCode;
-    Method = METHOD_FROM_CTL_CODE(ControlCode);
-
-    switch (ControlCode) {
-    case IOCTL_STORAGE_QUERY_PROPERTY:
-        ASSERT(Method == METHOD_BUFFERED);
-        status = PdoQueryProperty(Pdo, Irp);
-        break;
-
-    case IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES:
-        ASSERT(Method == METHOD_BUFFERED);
-        status = PdoManageDataSetAttributes(Pdo, Irp);
-        break;
-
-    default:
-        status = PdoForwardIrpAndForget(Pdo, Irp);
-        break;
-    }
-
-    return status;
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoStartDevice(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    ULONG               SectorSize;
-    ULONG               PhysSectorSize;
-    ULONG64             SectorCount;
-    ULONG64             Size;
-    BOOLEAN             DiscardSupported;
-    POWER_STATE         PowerState;
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = PdoForwardIrpSynchronously(Pdo, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    status = PdoSendReadCapacity16Synchronous(Pdo,
-                                              &SectorSize,
-                                              &PhysSectorSize,
-                                              &SectorCount);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    status = PdoSendInquiryB0Synchronous(Pdo,
-                                         &DiscardSupported);
-    if (!NT_SUCCESS(status))
-        goto fail4;
-
-    Pdo->SectorSize = SectorSize;
-    Pdo->PhysSectorSize = PhysSectorSize;
-    Pdo->DiscardSupported = DiscardSupported;
-
-    Size = SectorSize * SectorCount;
-    Size >>= 20; // Scale to megabytes
-
-    Verbose("%s: %luMB (%uB sectors)%s%s\n",
-            __PdoGetName(Pdo), Size, SectorSize,
-            Pdo->DiscardSupported ? " DISCARD" : "",
-            Pdo->InterceptTrim ? "" : " (VETOED)");
-
-    __PdoSetSystemPowerState(Pdo, PowerSystemWorking);
-    __PdoSetDevicePowerState(Pdo, PowerDeviceD0);
-
-    PowerState.DeviceState = PowerDeviceD0;
-    PoSetPowerState(Pdo->Dx->DeviceObject,
-                    DevicePowerState,
-                    PowerState);
-
-    __PdoSetDevicePnpState(Pdo, Started);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    Irp->IoStatus.Status = STATUS_SUCCESS;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return STATUS_SUCCESS;
-
-fail4:
-    Error("fail4\n");
-
-fail3:
-    Error("fail3\n");
-
-fail2:
-    Error("fail2\n");
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__PdoQueryStopDevice(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoQueryStopDevice(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    __PdoSetDevicePnpState(Pdo, StopPending);
-    Irp->IoStatus.Status = STATUS_SUCCESS;
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __PdoQueryStopDevice,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-
-    return status;
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__PdoCancelStopDevice(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoCancelStopDevice(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    Irp->IoStatus.Status = STATUS_SUCCESS;
-
-    __PdoRestoreDevicePnpState(Pdo, StopPending);
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __PdoCancelStopDevice,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-
-    return status;
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__PdoStopDevice(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    Pdo->PhysSectorSize = 0;
-    Pdo->SectorSize = 0;
-
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoStopDevice(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    POWER_STATE         PowerState;
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    if (__PdoGetDevicePowerState(Pdo) != PowerDeviceD0)
-        goto done;
-
-    __PdoSetDevicePowerState(Pdo, PowerDeviceD3);
-    __PdoSetSystemPowerState(Pdo, PowerSystemShutdown);
-
-    PowerState.DeviceState = PowerDeviceD3;
-    PoSetPowerState(Pdo->Dx->DeviceObject,
-                    DevicePowerState,
-                    PowerState);
-
-done:
-    __PdoSetDevicePnpState(Pdo, Stopped);
-    Irp->IoStatus.Status = STATUS_SUCCESS;
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __PdoStopDevice,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-
-    return status;
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__PdoQueryRemoveDevice(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoQueryRemoveDevice(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    __PdoSetDevicePnpState(Pdo, RemovePending);
-    Irp->IoStatus.Status = STATUS_SUCCESS;
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __PdoQueryRemoveDevice,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-
-    return status;
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__PdoCancelRemoveDevice(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoCancelRemoveDevice(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    __PdoRestoreDevicePnpState(Pdo, RemovePending);
-    Irp->IoStatus.Status = STATUS_SUCCESS;
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __PdoCancelRemoveDevice,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-
-    return status;
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__PdoSurpriseRemoval(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoSurpriseRemoval(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    __PdoSetDevicePnpState(Pdo, SurpriseRemovePending);
-    Irp->IoStatus.Status = STATUS_SUCCESS;
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __PdoSurpriseRemoval,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-
-    return status;
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoRemoveDevice(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    PXENDISK_FDO        Fdo = __PdoGetFdo(Pdo);
-    POWER_STATE         PowerState;
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    if (__PdoGetDevicePowerState(Pdo) != PowerDeviceD0)
-        goto done;
-
-    __PdoSetDevicePowerState(Pdo, PowerDeviceD3);
-    __PdoSetSystemPowerState(Pdo, PowerSystemShutdown);
-
-    PowerState.DeviceState = PowerDeviceD3;
-    PoSetPowerState(Pdo->Dx->DeviceObject,
-                    DevicePowerState,
-                    PowerState);
-
-done:
-    FdoAcquireMutex(Fdo);
-    __PdoSetDevicePnpState(Pdo, Deleted);
-    FdoReleaseMutex(Fdo);
-
-    IoReleaseRemoveLockAndWait(&Pdo->Dx->RemoveLock, Irp);
-
-    status = PdoForwardIrpSynchronously(Pdo, Irp);
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    Pdo->PhysSectorSize = 0;
-    Pdo->SectorSize = 0;
-
-    FdoAcquireMutex(Fdo);
-    PdoDestroy(Pdo);
-    FdoReleaseMutex(Fdo);
-
-    IoInvalidateDeviceRelations(FdoGetPhysicalDeviceObject(Fdo),
-                                BusRelations);
-
-    return status;
-
-fail1:
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoEject(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    PXENDISK_FDO        Fdo = __PdoGetFdo(Pdo);
-    NTSTATUS            status;
-
-    __PdoSetDevicePnpState(Pdo, Deleted);
-
-    status = PdoForwardIrpSynchronously(Pdo, Irp);
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    FdoAcquireMutex(Fdo);
-    PdoDestroy(Pdo);
-    FdoReleaseMutex(Fdo);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__PdoDispatchPnp(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoDispatchPnp(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    UCHAR               MinorFunction;
-    NTSTATUS            status;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    MinorFunction = StackLocation->MinorFunction;
-
-    switch (StackLocation->MinorFunction) {
-    case IRP_MN_START_DEVICE:
-        status = PdoStartDevice(Pdo, Irp);
-        break;
-
-    case IRP_MN_QUERY_STOP_DEVICE:
-        status = PdoQueryStopDevice(Pdo, Irp);
-        break;
-
-    case IRP_MN_CANCEL_STOP_DEVICE:
-        status = PdoCancelStopDevice(Pdo, Irp);
-        break;
-
-    case IRP_MN_STOP_DEVICE:
-        status = PdoStopDevice(Pdo, Irp);
-        break;
-
-    case IRP_MN_QUERY_REMOVE_DEVICE:
-        status = PdoQueryRemoveDevice(Pdo, Irp);
-        break;
-
-    case IRP_MN_SURPRISE_REMOVAL:
-        status = PdoSurpriseRemoval(Pdo, Irp);
-        break;
-
-    case IRP_MN_REMOVE_DEVICE:
-        status = PdoRemoveDevice(Pdo, Irp);
-        break;
-
-    case IRP_MN_CANCEL_REMOVE_DEVICE:
-        status = PdoCancelRemoveDevice(Pdo, Irp);
-        break;
-
-    case IRP_MN_EJECT:
-        status = PdoEject(Pdo, Irp);
-        break;
-
-    default:
-        status = IoAcquireRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-        if (!NT_SUCCESS(status))
-            goto fail1;
-
-        IoCopyCurrentIrpStackLocationToNext(Irp);
-        IoSetCompletionRoutine(Irp,
-                               __PdoDispatchPnp,
-                               Pdo,
-                               TRUE,
-                               TRUE,
-                               TRUE);
-
-        status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-        break;
-    }
-
-    return status;
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-PdoSetDevicePowerUpComplete(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_PDO        Pdo = (PXENDISK_PDO) Context;
-    PIO_STACK_LOCATION  StackLocation;
-    POWER_STATE         PowerState;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    PowerState = StackLocation->Parameters.Power.State;
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    __PdoSetDevicePowerState(Pdo, PowerState.DeviceState);
-    PoSetPowerState(Pdo->Dx->DeviceObject,
-                    DevicePowerState,
-                    PowerState);
-
-    return STATUS_CONTINUE_COMPLETION;
-}
-
-static FORCEINLINE NTSTATUS
-__PdoSetDevicePowerUp(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           PdoSetDevicePowerUpComplete,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    return IoCallDriver(Pdo->LowerDeviceObject, Irp);
-}
-
-static FORCEINLINE NTSTATUS
-__PdoSetDevicePowerDown(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    POWER_STATE         PowerState;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    PowerState = StackLocation->Parameters.Power.State;
-
-    __PdoSetDevicePowerState(Pdo, PowerState.DeviceState);
-    PoSetPowerState(Pdo->Dx->DeviceObject,
-                    DevicePowerState,
-                    PowerState);
-
-    IoSkipCurrentIrpStackLocation(Irp);
-    return IoCallDriver(Pdo->LowerDeviceObject, Irp);
-}
-
-static FORCEINLINE NTSTATUS
-__PdoSetDevicePower(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    DEVICE_POWER_STATE  DeviceState;
-    POWER_ACTION        PowerAction;
-    NTSTATUS            status;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    DeviceState = StackLocation->Parameters.Power.State.DeviceState;
-    PowerAction = StackLocation->Parameters.Power.ShutdownType;
-
-    Trace("====> (%s:%s)\n",
-          PowerDeviceStateName(DeviceState),
-          PowerActionName(PowerAction));
-
-    if (DeviceState == __PdoGetDevicePowerState(Pdo)) {
-        IoSkipCurrentIrpStackLocation(Irp);
-        status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-        goto done;
-    }
-
-    status = DeviceState < __PdoGetDevicePowerState(Pdo) ?
-             __PdoSetDevicePowerUp(Pdo, Irp) :
-             __PdoSetDevicePowerDown(Pdo, Irp);
-
-done:
-    Trace("<==== (%s:%s)(%08x)\n",
-          PowerDeviceStateName(DeviceState),
-          PowerActionName(PowerAction),
-          status);
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-PdoSetSystemPowerUpComplete(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_PDO        Pdo = (PXENDISK_PDO) Context;
-    PIO_STACK_LOCATION  StackLocation;
-    SYSTEM_POWER_STATE  SystemState;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    SystemState = StackLocation->Parameters.Power.State.SystemState;
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    __PdoSetSystemPowerState(Pdo, SystemState);
-
-    return STATUS_CONTINUE_COMPLETION;
-}
-
-static FORCEINLINE NTSTATUS
-__PdoSetSystemPowerUp(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           PdoSetSystemPowerUpComplete,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    return IoCallDriver(Pdo->LowerDeviceObject, Irp);
-}
-
-static FORCEINLINE NTSTATUS
-__PdoSetSystemPowerDown(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    SYSTEM_POWER_STATE  SystemState;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    SystemState = StackLocation->Parameters.Power.State.SystemState;
-
-    __PdoSetSystemPowerState(Pdo, SystemState);
-
-    IoSkipCurrentIrpStackLocation(Irp);
-    return IoCallDriver(Pdo->LowerDeviceObject, Irp);
-}
-
-static FORCEINLINE NTSTATUS
-__PdoSetSystemPower(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    SYSTEM_POWER_STATE  SystemState;
-    POWER_ACTION        PowerAction;
-    NTSTATUS            status;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    SystemState = StackLocation->Parameters.Power.State.SystemState;
-    PowerAction = StackLocation->Parameters.Power.ShutdownType;
-
-    Trace("====> (%s:%s)\n",
-          PowerSystemStateName(SystemState),
-          PowerActionName(PowerAction));
-
-    if (SystemState == __PdoGetSystemPowerState(Pdo)) {
-        IoSkipCurrentIrpStackLocation(Irp);
-        status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-        goto done;
-    }
-
-    status = SystemState < __PdoGetSystemPowerState(Pdo) ?
-             __PdoSetSystemPowerUp(Pdo, Irp) :
-             __PdoSetSystemPowerDown(Pdo, Irp);
-
-done:
-    Trace("<==== (%s:%s)(%08x)\n",
-          PowerSystemStateName(SystemState),
-          PowerActionName(PowerAction),
-          status);
-
-    return status;
-}
-
-static NTSTATUS
-PdoDevicePower(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    NTSTATUS            status;
-    PIO_STACK_LOCATION  StackLocation;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-
-    switch (StackLocation->MinorFunction) {
-    case IRP_MN_SET_POWER:
-        status = __PdoSetDevicePower(Pdo, Irp);
-        break;
-
-    default:
-        IoSkipCurrentIrpStackLocation(Irp);
-        status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-        break;
-    }
-
-    return status;
-}
-
-static NTSTATUS
-PdoSystemPower(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    NTSTATUS            status;
-    PIO_STACK_LOCATION  StackLocation;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-
-    switch (StackLocation->MinorFunction) {
-    case IRP_MN_SET_POWER:
-        status = __PdoSetSystemPower(Pdo, Irp);
-        break;
-
-    default:
-        IoSkipCurrentIrpStackLocation(Irp);
-        status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-        break;
-    }
-
-    return status;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoDispatchPower(
-    IN  PXENDISK_PDO   Pdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    POWER_STATE_TYPE    PowerType;
-    NTSTATUS            status;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    PowerType = StackLocation->Parameters.Power.Type;
-
-    switch (PowerType) {
-    case DevicePowerState:
-        status = PdoDevicePower(Pdo, Irp);
-        break;
-
-    case SystemPowerState:
-        status = PdoSystemPower(Pdo, Irp);
-        break;
-
-    default:
-        IoSkipCurrentIrpStackLocation(Irp);
-        status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-        break;
-    }
-
-    return status;
-}
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-__drv_sameIRQL
-static NTSTATUS
-__PdoDispatchDefault(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  PIRP            Irp,
-    IN  PVOID           Context
-    )
-{
-    PXENDISK_PDO        Pdo = Context;
-
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    if (Irp->PendingReturned)
-        IoMarkIrpPending(Irp);
-
-    IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-
-    return STATUS_SUCCESS;
-}
-
-static DECLSPEC_NOINLINE NTSTATUS
-PdoDispatchDefault(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    NTSTATUS            status;
-
-    status = IoAcquireRemoveLock(&Pdo->Dx->RemoveLock, Irp);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    IoCopyCurrentIrpStackLocationToNext(Irp);
-    IoSetCompletionRoutine(Irp,
-                           __PdoDispatchDefault,
-                           Pdo,
-                           TRUE,
-                           TRUE,
-                           TRUE);
-
-    status = IoCallDriver(Pdo->LowerDeviceObject, Irp);
-
-    return status;
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    Irp->IoStatus.Status = status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return status;
-}
-
-NTSTATUS
-PdoDispatch(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    NTSTATUS            status;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-
-    switch (StackLocation->MajorFunction) {
-    case IRP_MJ_DEVICE_CONTROL:
-        status = PdoDispatchControl(Pdo, Irp);
-        break;
-
-    case IRP_MJ_PNP:
-        status = PdoDispatchPnp(Pdo, Irp);
-        break;
-
-    case IRP_MJ_POWER:
-        status = PdoDispatchPower(Pdo, Irp);
-        break;
-
-    default:
-        status = PdoDispatchDefault(Pdo, Irp);
-        break;
-    }
-
-    return status;
-}
-
-NTSTATUS
-PdoCreate(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PDEVICE_OBJECT  PhysicalDeviceObject,
-    IN  PCHAR           DeviceID,
-    IN  PCHAR           InstanceID
-    )
-{
-    PDEVICE_OBJECT      LowerDeviceObject;
-    ULONG               DeviceType;
-    PDEVICE_OBJECT      FilterDeviceObject;
-    PXENDISK_DX         Dx;
-    PXENDISK_PDO        Pdo;
-    HANDLE              ParametersKey;
-    ULONG               InterceptTrim;
-    NTSTATUS            status;
-
-    LowerDeviceObject = IoGetAttachedDeviceReference(PhysicalDeviceObject);
-    DeviceType = LowerDeviceObject->DeviceType;
-    ObDereferenceObject(LowerDeviceObject);
-
-#pragma prefast(suppress:28197) // Possibly leaking memory 'PhysicalDeviceObject'
-    status = IoCreateDevice(DriverGetDriverObject(),
-                            sizeof(XENDISK_DX),
-                            NULL,
-                            DeviceType,
-                            FILE_DEVICE_SECURE_OPEN,
-                            FALSE,
-                            &FilterDeviceObject);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    Dx = (PXENDISK_DX)FilterDeviceObject->DeviceExtension;
-    RtlZeroMemory(Dx, sizeof (XENDISK_DX));
-
-    Dx->Type = PHYSICAL_DEVICE_OBJECT;
-    Dx->DeviceObject = FilterDeviceObject;
-    Dx->DevicePnpState = Present;
-    Dx->SystemPowerState = PowerSystemShutdown;
-    Dx->DevicePowerState = PowerDeviceD3;
-
-    IoInitializeRemoveLock(&Dx->RemoveLock, PDO_TAG, 0, 0);
-
-    Pdo = __PdoAllocate(sizeof (XENDISK_PDO));
-
-    status = STATUS_NO_MEMORY;
-    if (Pdo == NULL)
-        goto fail2;
-
-    LowerDeviceObject = IoAttachDeviceToDeviceStack(FilterDeviceObject,
-                                                    PhysicalDeviceObject);
-
-    status = STATUS_UNSUCCESSFUL;
-    if (LowerDeviceObject == NULL)
-        goto fail3;
-
-    Pdo->Dx = Dx;
-    Pdo->PhysicalDeviceObject = PhysicalDeviceObject;
-    Pdo->LowerDeviceObject = LowerDeviceObject;
-
-    __PdoSetName(Pdo, DeviceID, InstanceID);
-
-    ParametersKey = DriverGetParametersKey();
-
-    Pdo->InterceptTrim = TRUE;
-
-    status = RegistryQueryDwordValue(ParametersKey,
-                                     "InterceptTrim",
-                                     &InterceptTrim);
-    if (NT_SUCCESS(status))
-        Pdo->InterceptTrim = (InterceptTrim != 0) ? TRUE : FALSE;
-
-    Verbose("%p (%s)\n", FilterDeviceObject, __PdoGetName(Pdo));
-
-    Dx->Pdo = Pdo;
-
-#pragma prefast(suppress:28182) // Dereferencing NULL pointer
-    FilterDeviceObject->DeviceType = LowerDeviceObject->DeviceType;
-    FilterDeviceObject->Characteristics = LowerDeviceObject->Characteristics;
-
-    FilterDeviceObject->Flags |= LowerDeviceObject->Flags;
-    FilterDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
-
-    __PdoLink(Pdo, Fdo);
-
-    return STATUS_SUCCESS;
-
-fail3:
-    Error("fail3\n");
-
-    ASSERT(IsZeroMemory(Pdo, sizeof (XENDISK_PDO)));
-    __PdoFree(Pdo);
-
-fail2:
-    Error("fail2\n");
-
-    IoDeleteDevice(FilterDeviceObject);
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return status;
-}
-
-VOID
-PdoDestroy(
-    IN  PXENDISK_PDO    Pdo
-    )
-{
-    PDEVICE_OBJECT      LowerDeviceObject = Pdo->LowerDeviceObject;
-    PXENDISK_DX         Dx = Pdo->Dx;
-    PDEVICE_OBJECT      FilterDeviceObject = Dx->DeviceObject;
-
-    ASSERT3U(__PdoGetDevicePnpState(Pdo), ==, Deleted);
-
-    __PdoUnlink(Pdo);
-
-    Verbose("%s\n", __PdoGetName(Pdo));
-
-    Dx->Pdo = NULL;
-
-    Pdo->InterceptTrim = FALSE;
-    Pdo->DiscardSupported = FALSE;
-
-    RtlZeroMemory(Pdo->Name, sizeof (Pdo->Name));
-
-    Pdo->PhysicalDeviceObject = NULL;
-    Pdo->LowerDeviceObject = NULL;
-    Pdo->Dx = NULL;
-
-    IoDetachDevice(LowerDeviceObject);
-
-    ASSERT(IsZeroMemory(Pdo, sizeof (XENDISK_PDO)));
-    __PdoFree(Pdo);
-
-    IoDeleteDevice(FilterDeviceObject);
-}
diff --git a/src/xendisk/pdo.h b/src/xendisk/pdo.h
deleted file mode 100644
index 24e580a..0000000
--- a/src/xendisk/pdo.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _XENDISK_PDO_H
-#define _XENDISK_PDO_H
-
-#include <ntddk.h>
-#include "types.h"
-#include "fdo.h"
-
-typedef struct _XENDISK_PDO XENDISK_PDO, *PXENDISK_PDO;
-
-extern VOID
-PdoSetDevicePnpState(
-    IN  PXENDISK_PDO        Pdo,
-    IN  DEVICE_PNP_STATE    State
-    );
-
-extern DEVICE_PNP_STATE
-PdoGetDevicePnpState(
-    IN  PXENDISK_PDO    Pdo
-    );
-
-extern PDEVICE_OBJECT
-PdoGetPhysicalDeviceObject(
-    IN  PXENDISK_PDO    Pdo
-    );
-
-extern NTSTATUS
-PdoCreate(
-    IN  PXENDISK_FDO    Fdo,
-    IN  PDEVICE_OBJECT  PhysicalDeviceObject,
-    IN  PCHAR           DeviceID,
-    IN  PCHAR           InstanceID
-    );
-
-extern VOID
-PdoDestroy(
-    IN  PXENDISK_PDO    Pdo
-    );
-
-extern NTSTATUS
-PdoDispatch(
-    IN  PXENDISK_PDO    Pdo,
-    IN  PIRP            Irp
-    );
-
-#endif // _XENDISK_PDO_H
diff --git a/src/xendisk/registry.c b/src/xendisk/registry.c
deleted file mode 100644
index 03e93ac..0000000
--- a/src/xendisk/registry.c
+++ /dev/null
@@ -1,1564 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <ntddk.h>
-
-#include "registry.h"
-#include "assert.h"
-#include "util.h"
-
-#define REGISTRY_TAG 'GERX'
-
-static PDRIVER_OBJECT   RegistryDriverObject;
-static UNICODE_STRING   RegistryPath;
-
-typedef NTSTATUS(*IOOPENDRIVERREGISTRYKEY)(PDRIVER_OBJECT, DRIVER_REGKEY_TYPE, ACCESS_MASK, ULONG, PHANDLE);
-
-static IOOPENDRIVERREGISTRYKEY __IoOpenDriverRegistryKey;
-
-static FORCEINLINE PVOID
-__RegistryAllocate(
-    IN  ULONG   Length
-    )
-{
-    return __AllocatePoolWithTag(NonPagedPool, Length, REGISTRY_TAG);
-}
-
-static FORCEINLINE VOID
-__RegistryFree(
-    IN  PVOID   Buffer
-    )
-{
-    __FreePoolWithTag(Buffer, REGISTRY_TAG);
-}
-
-NTSTATUS
-#pragma prefast(suppress:28101) // unannotated DriverEntry function
-RegistryInitialize(
-    IN  PDRIVER_OBJECT  DriverObject,
-    IN  PUNICODE_STRING Path
-    )
-{
-    UNICODE_STRING      Unicode;
-    PVOID               Func;
-    NTSTATUS            status;
-
-    ASSERT3P(RegistryPath.Buffer, ==, NULL);
-
-    status = RtlUpcaseUnicodeString(&RegistryPath, Path, TRUE);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    ASSERT3P(RegistryDriverObject, ==, NULL);
-    RegistryDriverObject = DriverObject;
-
-    ASSERT3P(__IoOpenDriverRegistryKey, ==, NULL);
-    RtlInitUnicodeString(&Unicode, L"IoOpenDriverRegistryKey");
-
-    Func = MmGetSystemRoutineAddress(&Unicode);
-    if (Func != NULL)
-        __IoOpenDriverRegistryKey = (IOOPENDRIVERREGISTRYKEY)Func;
-
-    return STATUS_SUCCESS;
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return status;
-}
-
-VOID
-RegistryTeardown(
-    VOID
-    )
-{
-    __IoOpenDriverRegistryKey = NULL;
-
-    RegistryDriverObject = NULL;
-
-    RtlFreeUnicodeString(&RegistryPath);
-    RegistryPath.Buffer = NULL;
-    RegistryPath.MaximumLength = RegistryPath.Length = 0;
-}
-
-NTSTATUS
-RegistryOpenKey(
-    IN  HANDLE          Parent,
-    IN  PUNICODE_STRING Path,
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         Key
-    )
-{
-    OBJECT_ATTRIBUTES   Attributes;
-    NTSTATUS            status;
-
-    InitializeObjectAttributes(&Attributes,
-                               Path,
-                               OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
-                               Parent,
-                               NULL);
-
-    status = ZwOpenKey(Key,
-                       DesiredAccess,
-                       &Attributes);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    return STATUS_SUCCESS;
-
-fail1:
-    return status;
-}
-
-static NTSTATUS
-RegistryOpenRoot(
-    IN  PWCHAR          Path,
-    OUT PHANDLE         Parent,
-    OUT PWCHAR          *ChildPath
-    )
-{
-    const WCHAR         Prefix[] = L"\\Registry\\Machine\\";
-    ULONG               Length;
-    UNICODE_STRING      Unicode;
-    NTSTATUS            status;
-
-    Length = (ULONG)wcslen(Prefix);
-
-    status = STATUS_INVALID_PARAMETER;
-    if (_wcsnicmp(Path, Prefix, Length) != 0)
-        goto fail1;
-
-    RtlInitUnicodeString(&Unicode, Prefix);
-
-    status = RegistryOpenKey(NULL, &Unicode, KEY_ALL_ACCESS, Parent);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    *ChildPath = Path + Length;
-
-    return STATUS_SUCCESS;
-
-fail2:
-fail1:
-    return status;
-}
-
-NTSTATUS
-RegistryCreateKey(
-    IN  HANDLE          Parent,
-    IN  PUNICODE_STRING Path,
-    IN  ULONG           Options,
-    OUT PHANDLE         Key
-    )
-{
-    PWCHAR              Buffer;
-    HANDLE              Root;
-    PWCHAR              ChildPath;
-    PWCHAR              ChildName;
-    PWCHAR              Context;
-    HANDLE              Child;
-    NTSTATUS            status;
-
-    //
-    // UNICODE_STRINGs are not guaranteed to have NUL terminated
-    // buffers.
-    //
-
-    Buffer = __RegistryAllocate(Path->MaximumLength + sizeof (WCHAR));
-
-    status = STATUS_NO_MEMORY;
-    if (Buffer == NULL)
-        goto fail1;
-
-    RtlCopyMemory(Buffer, Path->Buffer, Path->Length);
-
-    Root = Parent;
-
-    if (Parent != NULL) {
-        ChildPath = Buffer;
-    } else {
-        status = RegistryOpenRoot(Buffer, &Parent, &ChildPath);
-        if (!NT_SUCCESS(status))
-            goto fail2;
-    }
-
-    ChildName = __wcstok_r(ChildPath, L"\\", &Context);
-
-    status = STATUS_INVALID_PARAMETER;
-    if (ChildName == NULL)
-        goto fail3;
-
-    Child = NULL;
-
-    while (ChildName != NULL) {
-        UNICODE_STRING      Unicode;
-        OBJECT_ATTRIBUTES   Attributes;
-
-        RtlInitUnicodeString(&Unicode, ChildName);
-
-        InitializeObjectAttributes(&Attributes,
-                                   &Unicode,
-                                   OBJ_CASE_INSENSITIVE |
-                                   OBJ_KERNEL_HANDLE |
-                                   OBJ_OPENIF,
-                                   Parent,
-                                   NULL);
-
-        status = ZwCreateKey(&Child,
-                             KEY_ALL_ACCESS,
-                             &Attributes,
-                             0,
-                             NULL,
-                             Options,
-                             NULL
-                             );
-        if (!NT_SUCCESS(status))
-            goto fail4;
-
-        ChildName = __wcstok_r(NULL, L"\\", &Context);
-
-        if (Parent != Root)
-            ZwClose(Parent);
-
-        Parent = Child;
-    }
-
-    ASSERT(Child != NULL);
-
-    *Key = Child;
-
-    __RegistryFree(Buffer);
-
-    return STATUS_SUCCESS;
-
-fail4:
-fail3:
-    if (Parent != Root)
-        ZwClose(Parent);
-
-fail2:
-    __RegistryFree(Buffer);
-
-fail1:
-    return status;
-}
-
-NTSTATUS
-RegistryOpenServiceKey(
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         Key
-    )
-{
-    return RegistryOpenKey(NULL, &RegistryPath, DesiredAccess, Key);
-}
-
-NTSTATUS
-RegistryCreateServiceKey(
-    OUT PHANDLE         Key
-    )
-{
-    return RegistryCreateKey(NULL, &RegistryPath, REG_OPTION_NON_VOLATILE, Key);
-}
-
-NTSTATUS
-RegistryOpenParametersKey(
-    IN  ACCESS_MASK DesiredAccess,
-    OUT PHANDLE     Key
-    )
-{
-    HANDLE              ServiceKey;
-    NTSTATUS            status;
-
-    if (__IoOpenDriverRegistryKey != NULL) {
-        status = __IoOpenDriverRegistryKey(RegistryDriverObject,
-                                           DriverRegKeyParameters,
-                                           DesiredAccess,
-                                           0,
-                                           Key);
-        if (!NT_SUCCESS(status))
-            goto fail1;
-
-        goto done;
-    }
-
-    status = RegistryOpenKey(NULL, &RegistryPath, DesiredAccess, &ServiceKey);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    status = RegistryOpenSubKey(ServiceKey, "Parameters", DesiredAccess, Key);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    RegistryCloseKey(ServiceKey);
-
-done:
-    return STATUS_SUCCESS;
-
-fail3:
-    Error("fail3\n");
-
-    RegistryCloseKey(ServiceKey);
-
-fail2:
-    Error("fail2\n");
-
-fail1:
-    Error("fail1 %08x\n", status);
-
-    return status;
-}
-
-NTSTATUS
-RegistryOpenSoftwareKey(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         Key
-    )
-{
-    NTSTATUS            status;
-
-    status = IoOpenDeviceRegistryKey(DeviceObject,
-                                     PLUGPLAY_REGKEY_DRIVER,
-                                     DesiredAccess,
-                                     Key);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    return STATUS_SUCCESS;
-
-fail1:
-    return status;
-}
-
-NTSTATUS
-RegistryOpenHardwareKey(
-    IN  PDEVICE_OBJECT      DeviceObject,
-    IN  ACCESS_MASK         DesiredAccess,
-    OUT PHANDLE             Key
-    )
-{
-    HANDLE                  SubKey;
-    ULONG                   Length;
-    PKEY_NAME_INFORMATION   Info;
-    PWCHAR                  Cursor;
-    UNICODE_STRING          Unicode;
-    NTSTATUS                status;
-
-    status = IoOpenDeviceRegistryKey(DeviceObject,
-                                     PLUGPLAY_REGKEY_DEVICE,
-                                     KEY_READ,
-                                     &SubKey);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    Length = 0;
-    status = ZwQueryKey(SubKey,
-                        KeyNameInformation,
-                        NULL,
-                        0,
-                        &Length);
-    if (status != STATUS_BUFFER_OVERFLOW &&
-        status != STATUS_BUFFER_TOO_SMALL)
-        goto fail2;
-
-#pragma prefast(suppress:6102)
-    Info = __RegistryAllocate(Length + sizeof (WCHAR));
-
-    status = STATUS_NO_MEMORY;
-    if (Info == NULL)
-        goto fail3;
-
-    status = ZwQueryKey(SubKey,
-                        KeyNameInformation,
-                        Info,
-                        Length,
-                        &Length);
-    if (!NT_SUCCESS(status))
-        goto fail4;
-
-    Info->Name[Info->NameLength / sizeof (WCHAR)] = '\0';
-
-    Cursor = wcsrchr(Info->Name, L'\\');
-    ASSERT(Cursor != NULL);
-
-    *Cursor = L'\0';
-
-    RtlInitUnicodeString(&Unicode, Info->Name);
-
-    status = RegistryOpenKey(NULL, &Unicode, DesiredAccess, Key);
-    if (!NT_SUCCESS(status))
-        goto fail5;
-
-    __RegistryFree(Info);
-
-    RegistryCloseKey(SubKey);
-
-    return STATUS_SUCCESS;
-
-fail5:
-fail4:
-    __RegistryFree(Info);
-
-fail3:
-fail2:
-    RegistryCloseKey(SubKey);
-
-fail1:
-    return status;
-}
-
-NTSTATUS
-RegistryOpenSubKey(
-    IN  PHANDLE         Key,
-    IN  PCHAR           Name,
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         SubKey
-    )
-{
-    ANSI_STRING         Ansi;
-    UNICODE_STRING      Unicode;
-    NTSTATUS            status;
-
-    RtlInitAnsiString(&Ansi, Name);
-
-    status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = RegistryOpenKey(Key, &Unicode, DesiredAccess, SubKey);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    RtlFreeUnicodeString(&Unicode);
-
-    return STATUS_SUCCESS;
-
-fail2:
-    RtlFreeUnicodeString(&Unicode);
-
-fail1:
-    return status;
-}
-
-NTSTATUS
-RegistryCreateSubKey(
-    IN  PHANDLE         Key,
-    IN  PCHAR           Name,
-    IN  ULONG           Options,
-    OUT PHANDLE         SubKey
-    )
-{
-    ANSI_STRING         Ansi;
-    UNICODE_STRING      Unicode;
-    NTSTATUS            status;
-
-    RtlInitAnsiString(&Ansi, Name);
-
-    status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = RegistryCreateKey(Key, &Unicode, Options, SubKey);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    RtlFreeUnicodeString(&Unicode);
-
-    return STATUS_SUCCESS;
-
-fail2:
-    RtlFreeUnicodeString(&Unicode);
-
-fail1:
-    return status;
-}
-
-NTSTATUS
-RegistryDeleteSubKey(
-    IN  PHANDLE         Key,
-    IN  PCHAR           Name
-    )
-{
-    ANSI_STRING         Ansi;
-    UNICODE_STRING      Unicode;
-    HANDLE              SubKey;
-    NTSTATUS            status;
-
-    RtlInitAnsiString(&Ansi, Name);
-
-    status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = RegistryOpenKey(Key, &Unicode, KEY_ALL_ACCESS, &SubKey);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    status = ZwDeleteKey(SubKey);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    ZwClose(SubKey);
-
-    (VOID) ZwFlushKey(Key);
-
-    RtlFreeUnicodeString(&Unicode);
-
-    return STATUS_SUCCESS;
-
-fail3:
-    ZwClose(SubKey);
-
-fail2:
-    RtlFreeUnicodeString(&Unicode);
-
-fail1:
-    return status;
-}
-
-NTSTATUS
-RegistryEnumerateSubKeys(
-    IN  HANDLE              Key,
-    IN  NTSTATUS            (*Callback)(PVOID, HANDLE, PANSI_STRING),
-    IN  PVOID               Context
-    )
-{
-    ULONG                   Size;
-    NTSTATUS                status;
-    PKEY_FULL_INFORMATION   Full;
-    PKEY_BASIC_INFORMATION  Basic;
-    ULONG                   Index;
-
-    status = ZwQueryKey(Key,
-                        KeyFullInformation,
-                        NULL,
-                        0,
-                        &Size);
-    if (status != STATUS_BUFFER_OVERFLOW &&
-        status != STATUS_BUFFER_TOO_SMALL)
-        goto fail1;
-
-#pragma prefast(suppress:6102)
-    Full = __RegistryAllocate(Size);
-
-    status = STATUS_NO_MEMORY;
-    if (Full == NULL)
-        goto fail2;
-
-    status = ZwQueryKey(Key,
-                        KeyFullInformation,
-                        Full,
-                        Size,
-                        &Size);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    Size = FIELD_OFFSET(KEY_BASIC_INFORMATION, Name) +
-           Full->MaxNameLen;
-
-    Basic = __RegistryAllocate(Size);
-    status = STATUS_NO_MEMORY;
-    if (Basic == NULL)
-        goto fail4;
-
-    for (Index = 0; Index < Full->SubKeys; Index++) {
-        ULONG           Ignore;
-        UNICODE_STRING  Unicode;
-        ANSI_STRING     Ansi;
-
-        status = ZwEnumerateKey(Key,
-                                Index,
-                                KeyBasicInformation,
-                                Basic,
-                                Size,
-                                &Ignore);
-        if (!NT_SUCCESS(status))
-            goto fail5;
-
-        Unicode.MaximumLength = (USHORT)Basic->NameLength;
-        Unicode.Buffer = Basic->Name;
-        Unicode.Length = (USHORT)Basic->NameLength;
-
-        Ansi.MaximumLength = (USHORT)((Basic->NameLength / sizeof (WCHAR)) + sizeof (CHAR));
-        Ansi.Buffer = __RegistryAllocate(Ansi.MaximumLength);
-
-        status = STATUS_NO_MEMORY;
-        if (Ansi.Buffer == NULL)
-            goto fail6;
-
-        status = RtlUnicodeStringToAnsiString(&Ansi, &Unicode, FALSE);
-        ASSERT(NT_SUCCESS(status));
-
-        Ansi.Length = (USHORT)(strlen(Ansi.Buffer) * sizeof (CHAR));
-
-        status = Callback(Context, Key, &Ansi);
-
-        __RegistryFree(Ansi.Buffer);
-        Ansi.Buffer = NULL;
-
-        if (!NT_SUCCESS(status))
-            goto fail7;
-    }
-
-    __RegistryFree(Basic);
-
-    __RegistryFree(Full);
-
-    return STATUS_SUCCESS;
-
-fail7:
-fail6:
-fail5:
-    __RegistryFree(Basic);
-
-fail4:
-fail3:
-    __RegistryFree(Full);
-
-fail2:
-fail1:
-    return status;
-}
-
-NTSTATUS
-RegistryEnumerateValues(
-    IN  HANDLE                      Key,
-    IN  NTSTATUS                    (*Callback)(PVOID, HANDLE, PANSI_STRING, ULONG),
-    IN  PVOID                       Context
-    )
-{
-    ULONG                           Size;
-    NTSTATUS                        status;
-    PKEY_FULL_INFORMATION           Full;
-    PKEY_VALUE_BASIC_INFORMATION    Basic;
-    ULONG                           Index;
-
-    status = ZwQueryKey(Key,
-                        KeyFullInformation,
-                        NULL,
-                        0,
-                        &Size);
-    if (status != STATUS_BUFFER_OVERFLOW &&
-        status != STATUS_BUFFER_TOO_SMALL)
-        goto fail1;
-
-#pragma prefast(suppress:6102)
-    Full = __RegistryAllocate(Size);
-
-    status = STATUS_NO_MEMORY;
-    if (Full == NULL)
-        goto fail2;
-
-    status = ZwQueryKey(Key,
-                        KeyFullInformation,
-                        Full,
-                        Size,
-                        &Size);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    Size = FIELD_OFFSET(KEY_VALUE_BASIC_INFORMATION, Name) +
-           Full->MaxValueNameLen;
-
-    Basic = __RegistryAllocate(Size);
-    status = STATUS_NO_MEMORY;
-    if (Basic == NULL)
-        goto fail4;
-
-    for (Index = 0; Index < Full->Values; Index++) {
-        ULONG           Ignore;
-        UNICODE_STRING  Unicode;
-        ANSI_STRING     Ansi;
-
-        status = ZwEnumerateValueKey(Key,
-                                     Index,
-                                     KeyValueBasicInformation,
-                                     Basic,
-                                     Size,
-                                     &Ignore);
-        if (!NT_SUCCESS(status))
-            goto fail5;
-
-        Unicode.MaximumLength = (USHORT)Basic->NameLength;
-        Unicode.Buffer = Basic->Name;
-        Unicode.Length = (USHORT)Basic->NameLength;
-
-        Ansi.MaximumLength = (USHORT)((Basic->NameLength / sizeof (WCHAR)) + sizeof (CHAR));
-        Ansi.Buffer = __RegistryAllocate(Ansi.MaximumLength);
-
-        status = RtlUnicodeStringToAnsiString(&Ansi, &Unicode, FALSE);
-        ASSERT(NT_SUCCESS(status));
-
-        Ansi.Length = (USHORT)(strlen(Ansi.Buffer) * sizeof (CHAR));
-
-        status = Callback(Context, Key, &Ansi, Basic->Type);
-
-        __RegistryFree(Ansi.Buffer);
-
-        if (!NT_SUCCESS(status))
-            goto fail6;
-    }
-
-    __RegistryFree(Basic);
-
-    __RegistryFree(Full);
-
-    return STATUS_SUCCESS;
-
-fail6:
-fail5:
-    __RegistryFree(Basic);
-
-fail4:
-fail3:
-    __RegistryFree(Full);
-
-fail2:
-fail1:
-    return status;
-}
-
-NTSTATUS
-RegistryDeleteValue(
-    IN  PHANDLE         Key,
-    IN  PCHAR           Name
-    )
-{
-    ANSI_STRING         Ansi;
-    UNICODE_STRING      Unicode;
-    NTSTATUS            status;
-
-    RtlInitAnsiString(&Ansi, Name);
-
-    status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = ZwDeleteValueKey(Key, &Unicode);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    RtlFreeUnicodeString(&Unicode);
-
-    (VOID) ZwFlushKey(Key);
-
-    return STATUS_SUCCESS;
-
-fail2:
-    RtlFreeUnicodeString(&Unicode);
-
-fail1:
-    return status;
-}
-
-NTSTATUS
-RegistryQueryDwordValue(
-    IN  HANDLE                      Key,
-    IN  PCHAR                       Name,
-    OUT PULONG                      Value
-    )
-{
-    ANSI_STRING                     Ansi;
-    UNICODE_STRING                  Unicode;
-    PKEY_VALUE_PARTIAL_INFORMATION  Partial;
-    ULONG                           Size;
-    NTSTATUS                        status;
-
-    RtlInitAnsiString(&Ansi, Name);
-
-    status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = ZwQueryValueKey(Key,
-                             &Unicode,
-                             KeyValuePartialInformation,
-                             NULL,
-                             0,
-                             &Size);
-    if (status != STATUS_BUFFER_OVERFLOW &&
-        status != STATUS_BUFFER_TOO_SMALL)
-        goto fail2;
-
-#pragma prefast(suppress:6102)
-    Partial = __RegistryAllocate(Size);
-
-    status = STATUS_NO_MEMORY;
-    if (Partial == NULL)
-        goto fail3;
-
-    status = ZwQueryValueKey(Key,
-                             &Unicode,
-                             KeyValuePartialInformation,
-                             Partial,
-                             Size,
-                             &Size);
-    if (!NT_SUCCESS(status))
-        goto fail4;
-
-    status = STATUS_INVALID_PARAMETER;
-    if (Partial->Type != REG_DWORD ||
-        Partial->DataLength != sizeof (ULONG))
-        goto fail5;
-
-    *Value = *(PULONG)Partial->Data;
-
-    __RegistryFree(Partial);
-
-    RtlFreeUnicodeString(&Unicode);
-
-    return STATUS_SUCCESS;
-
-fail5:
-fail4:
-    __RegistryFree(Partial);
-
-fail3:
-fail2:
-    RtlFreeUnicodeString(&Unicode);
-
-fail1:
-    return status;
-}
-
-NTSTATUS
-RegistryUpdateDwordValue(
-    IN  HANDLE                      Key,
-    IN  PCHAR                       Name,
-    IN  ULONG                       Value
-    )
-{
-    ANSI_STRING                     Ansi;
-    UNICODE_STRING                  Unicode;
-    PKEY_VALUE_PARTIAL_INFORMATION  Partial;
-    NTSTATUS                        status;
-
-    RtlInitAnsiString(&Ansi, Name);
-
-    status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    Partial = __RegistryAllocate(FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data) +
-                                 sizeof (ULONG));
-
-    status = STATUS_NO_MEMORY;
-    if (Partial == NULL)
-        goto fail2;
-
-    Partial->TitleIndex = 0;
-    Partial->Type = REG_DWORD;
-    Partial->DataLength = sizeof (ULONG);
-    *(PULONG)Partial->Data = Value;
-
-    status = ZwSetValueKey(Key,
-                           &Unicode,
-                           Partial->TitleIndex,
-                           Partial->Type,
-                           Partial->Data,
-                           Partial->DataLength);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    __RegistryFree(Partial);
-
-    (VOID) ZwFlushKey(Key);
-
-    RtlFreeUnicodeString(&Unicode);
-
-    return STATUS_SUCCESS;
-
-fail3:
-    __RegistryFree(Partial);
-
-fail2:
-    RtlFreeUnicodeString(&Unicode);
-
-fail1:
-
-    return status;
-}
-
-static PANSI_STRING
-RegistrySzToAnsi(
-    IN  PWCHAR      Buffer
-    )
-{
-    PANSI_STRING    Ansi;
-    ULONG           Length;
-    UNICODE_STRING  Unicode;
-    NTSTATUS        status;
-
-    Ansi = __RegistryAllocate(sizeof (ANSI_STRING) * 2);
-
-    status = STATUS_NO_MEMORY;
-    if (Ansi == NULL)
-        goto fail1;
-
-    Length = (ULONG)wcslen(Buffer);
-    Ansi[0].MaximumLength = (USHORT)(Length + 1) * sizeof (CHAR);
-    Ansi[0].Buffer = __RegistryAllocate(Ansi[0].MaximumLength);
-
-    status = STATUS_NO_MEMORY;
-    if (Ansi[0].Buffer == NULL)
-        goto fail2;
-
-    RtlInitUnicodeString(&Unicode, Buffer);
-    status = RtlUnicodeStringToAnsiString(&Ansi[0], &Unicode, FALSE);
-    ASSERT(NT_SUCCESS(status));
-
-    Ansi[0].Length = (USHORT)Length * sizeof (CHAR);
-
-    return Ansi;
-
-fail2:
-    __RegistryFree(Ansi);
-
-fail1:
-    return NULL;
-}
-
-static PANSI_STRING
-RegistryMultiSzToAnsi(
-    IN  PWCHAR      Buffer
-    )
-{
-    PANSI_STRING    Ansi;
-    LONG            Index;
-    LONG            Count;
-    NTSTATUS        status;
-
-    Index = 0;
-    Count = 0;
-    for (;;) {
-        ULONG   Length;
-
-        Length = (ULONG)wcslen(&Buffer[Index]);
-        if (Length == 0)
-            break;
-
-        Index += Length + 1;
-        Count++;
-    }
-
-    Ansi = __RegistryAllocate(sizeof (ANSI_STRING) * (Count + 1));
-
-    status = STATUS_NO_MEMORY;
-    if (Ansi == NULL)
-        goto fail1;
-
-    for (Index = 0; Index < Count; Index++) {
-        ULONG           Length;
-        UNICODE_STRING  Unicode;
-
-        Length = (ULONG)wcslen(Buffer);
-        Ansi[Index].MaximumLength = (USHORT)(Length + 1) * sizeof (CHAR);
-        Ansi[Index].Buffer = __RegistryAllocate(Ansi[Index].MaximumLength);
-
-        status = STATUS_NO_MEMORY;
-        if (Ansi[Index].Buffer == NULL)
-            goto fail2;
-
-        RtlInitUnicodeString(&Unicode, Buffer);
-
-        status = RtlUnicodeStringToAnsiString(&Ansi[Index], &Unicode, FALSE);
-        ASSERT(NT_SUCCESS(status));
-
-        Ansi[Index].Length = (USHORT)Length * sizeof (CHAR);
-        Buffer += Length + 1;
-    }
-
-    return Ansi;
-
-fail2:
-    while (--Index >= 0)
-        __RegistryFree(Ansi[Index].Buffer);
-
-    __RegistryFree(Ansi);
-
-fail1:
-    return NULL;
-}
-
-NTSTATUS
-RegistryQuerySzValue(
-    IN  HANDLE                      Key,
-    IN  PCHAR                       Name,
-    OUT PULONG                      Type OPTIONAL,
-    OUT PANSI_STRING                *Array
-    )
-{
-    ANSI_STRING                     Ansi;
-    UNICODE_STRING                  Unicode;
-    PKEY_VALUE_PARTIAL_INFORMATION  Value;
-    ULONG                           Size;
-    NTSTATUS                        status;
-
-    RtlInitAnsiString(&Ansi, Name);
-
-    status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = ZwQueryValueKey(Key,
-                             &Unicode,
-                             KeyValuePartialInformation,
-                             NULL,
-                             0,
-                             &Size);
-    if (status != STATUS_BUFFER_OVERFLOW &&
-        status != STATUS_BUFFER_TOO_SMALL)
-        goto fail2;
-
-#pragma prefast(suppress:6102)
-    Value = __RegistryAllocate(Size);
-
-    status = STATUS_NO_MEMORY;
-    if (Value == NULL)
-        goto fail3;
-
-    status = ZwQueryValueKey(Key,
-                             &Unicode,
-                             KeyValuePartialInformation,
-                             Value,
-                             Size,
-                             &Size);
-    if (!NT_SUCCESS(status))
-        goto fail4;
-
-    switch (Value->Type) {
-    case REG_SZ:
-        status = STATUS_NO_MEMORY;
-        *Array = RegistrySzToAnsi((PWCHAR)Value->Data);
-        break;
-
-    case REG_MULTI_SZ:
-        status = STATUS_NO_MEMORY;
-        *Array = RegistryMultiSzToAnsi((PWCHAR)Value->Data);
-        break;
-
-    default:
-        status = STATUS_INVALID_PARAMETER;
-        *Array = NULL;
-        break;
-    }
-
-    if (*Array == NULL)
-        goto fail5;
-
-    if (Type != NULL)
-        *Type = Value->Type;
-
-    __RegistryFree(Value);
-
-    RtlFreeUnicodeString(&Unicode);
-
-    return STATUS_SUCCESS;
-
-fail5:
-fail4:
-    __RegistryFree(Value);
-
-fail3:
-fail2:
-    RtlFreeUnicodeString(&Unicode);
-
-fail1:
-    return status;
-}
-
-NTSTATUS
-RegistryQueryBinaryValue(
-    IN  HANDLE                      Key,
-    IN  PCHAR                       Name,
-    OUT PVOID                       *Buffer,
-    OUT PULONG                      Length
-    )
-{
-    ANSI_STRING                     Ansi;
-    UNICODE_STRING                  Unicode;
-    PKEY_VALUE_PARTIAL_INFORMATION  Partial;
-    ULONG                           Size;
-    NTSTATUS                        status;
-
-    RtlInitAnsiString(&Ansi, Name);
-
-    status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = ZwQueryValueKey(Key,
-                             &Unicode,
-                             KeyValuePartialInformation,
-                             NULL,
-                             0,
-                             &Size);
-    if (status != STATUS_BUFFER_OVERFLOW &&
-        status != STATUS_BUFFER_TOO_SMALL)
-        goto fail2;
-
-#pragma prefast(suppress:6102)
-    Partial = __RegistryAllocate(Size);
-
-    status = STATUS_NO_MEMORY;
-    if (Partial == NULL)
-        goto fail3;
-
-    status = ZwQueryValueKey(Key,
-                             &Unicode,
-                             KeyValuePartialInformation,
-                             Partial,
-                             Size,
-                             &Size);
-    if (!NT_SUCCESS(status))
-        goto fail4;
-
-    switch (Partial->Type) {
-    case REG_BINARY:
-        *Buffer = __RegistryAllocate(Partial->DataLength);
-
-        status = STATUS_NO_MEMORY;
-        if (*Buffer == NULL)
-            break;
-
-        *Length = Partial->DataLength;
-        RtlCopyMemory(*Buffer, Partial->Data, Partial->DataLength);
-        break;
-
-    default:
-        status = STATUS_INVALID_PARAMETER;
-        *Buffer = NULL;
-        break;
-    }
-
-    if (*Buffer == NULL)
-        goto fail5;
-
-    __RegistryFree(Partial);
-
-    RtlFreeUnicodeString(&Unicode);
-
-    return STATUS_SUCCESS;
-
-fail5:
-fail4:
-    __RegistryFree(Partial);
-
-fail3:
-fail2:
-    RtlFreeUnicodeString(&Unicode);
-
-fail1:
-    return status;
-}
-
-NTSTATUS
-RegistryUpdateBinaryValue(
-    IN  HANDLE                      Key,
-    IN  PCHAR                       Name,
-    IN  PVOID                       Buffer,
-    IN  ULONG                       Length
-    )
-{
-    ANSI_STRING                     Ansi;
-    UNICODE_STRING                  Unicode;
-    PKEY_VALUE_PARTIAL_INFORMATION  Partial;
-    NTSTATUS                        status;
-
-    RtlInitAnsiString(&Ansi, Name);
-
-    status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    Partial = __RegistryAllocate(FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data) +
-                                 Length);
-
-    status = STATUS_NO_MEMORY;
-    if (Partial == NULL)
-        goto fail2;
-
-    Partial->TitleIndex = 0;
-    Partial->Type = REG_BINARY;
-    Partial->DataLength = Length;
-    RtlCopyMemory(Partial->Data, Buffer, Partial->DataLength);
-
-    status = ZwSetValueKey(Key,
-                           &Unicode,
-                           Partial->TitleIndex,
-                           Partial->Type,
-                           Partial->Data,
-                           Partial->DataLength);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    __RegistryFree(Partial);
-
-    (VOID) ZwFlushKey(Key);
-
-    RtlFreeUnicodeString(&Unicode);
-
-    return STATUS_SUCCESS;
-
-fail3:
-    __RegistryFree(Partial);
-
-fail2:
-    RtlFreeUnicodeString(&Unicode);
-
-fail1:
-
-    return status;
-}
-
-NTSTATUS
-RegistryQueryKeyName(
-    IN  HANDLE              Key,
-    OUT PANSI_STRING        *Array
-    )
-{
-    PKEY_NAME_INFORMATION   Value;
-    ULONG                   Size;
-    NTSTATUS                status;
-
-    status = ZwQueryKey(Key,
-                        KeyNameInformation,
-                        NULL,
-                        0,
-                        &Size);
-    if (status != STATUS_BUFFER_OVERFLOW &&
-        status != STATUS_BUFFER_TOO_SMALL)
-        goto fail1;
-
-    // Name information is not intrinsically NULL terminated
-#pragma prefast(suppress:6102)
-    Value = __RegistryAllocate(Size + sizeof (WCHAR));
-
-    status = STATUS_NO_MEMORY;
-    if (Value == NULL)
-        goto fail2;
-
-    status = ZwQueryKey(Key,
-                        KeyNameInformation,
-                        Value,
-                        Size,
-                        &Size);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    Value->Name[Value->NameLength / sizeof (WCHAR)] = L'\0';
-    *Array = RegistrySzToAnsi((PWCHAR)Value->Name);
-
-    status = STATUS_NO_MEMORY;
-    if (*Array == NULL)
-        goto fail4;
-
-    __RegistryFree(Value);
-
-    return STATUS_SUCCESS;
-
-fail4:
-fail3:
-    __RegistryFree(Value);
-
-fail2:
-fail1:
-    return status;
-}
-
-NTSTATUS
-RegistryQuerySystemStartOption(
-    IN  PCHAR                       Prefix,
-    OUT PANSI_STRING                *Value
-    )
-{
-    UNICODE_STRING                  Unicode;
-    HANDLE                          Key;
-    PANSI_STRING                    Ansi;
-    ULONG                           Length;
-    PCHAR                           Option;
-    PCHAR                           Context;
-    NTSTATUS                        status;
-
-    RtlInitUnicodeString(&Unicode, L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control");
-
-    status = RegistryOpenKey(NULL, &Unicode, KEY_READ, &Key);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = RegistryQuerySzValue(Key, "SystemStartOptions", NULL, &Ansi);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    // SystemStartOptions is a space separated list of options.
-    // Scan it looking for the one we want.
-    Length = (ULONG)strlen(Prefix);
-
-    Option = __strtok_r(Ansi[0].Buffer, " ", &Context);
-    while (Option != NULL) {
-        if (strncmp(Prefix, Option, Length) == 0)
-            goto found;
-
-        Option = __strtok_r(NULL, " ", &Context);
-    }
-
-    status = STATUS_OBJECT_NAME_NOT_FOUND;
-    goto fail3;
-
-found:
-    *Value = __RegistryAllocate(sizeof (ANSI_STRING) * 2);
-
-    status = STATUS_NO_MEMORY;
-    if (*Value == NULL)
-        goto fail4;
-
-    Length = (ULONG)strlen(Option);
-    (*Value)[0].MaximumLength = (USHORT)(Length + 1) * sizeof (CHAR);
-    (*Value)[0].Buffer = __RegistryAllocate((*Value)[0].MaximumLength);
-
-    status = STATUS_NO_MEMORY;
-    if ((*Value)[0].Buffer == NULL)
-        goto fail5;
-
-    RtlCopyMemory((*Value)[0].Buffer, Option, Length * sizeof (CHAR));
-
-    (*Value)[0].Length = (USHORT)Length * sizeof (CHAR);
-
-    RegistryFreeSzValue(Ansi);
-
-    ZwClose(Key);
-
-    return STATUS_SUCCESS;
-
-fail5:
-    __RegistryFree(*Value);
-
-fail4:
-fail3:
-    RegistryFreeSzValue(Ansi);
-
-fail2:
-    ZwClose(Key);
-
-fail1:
-    return status;
-}
-
-static PKEY_VALUE_PARTIAL_INFORMATION
-RegistryAnsiToSz(
-    PANSI_STRING                    Ansi
-    )
-{
-    ULONG                           Length;
-    PKEY_VALUE_PARTIAL_INFORMATION  Partial;
-    UNICODE_STRING                  Unicode;
-    NTSTATUS                        status;
-
-    Length = Ansi->Length + 1;
-    Partial = __RegistryAllocate(FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data) +
-                                 Length * sizeof (WCHAR));
-
-    status = STATUS_NO_MEMORY;
-    if (Partial == NULL)
-        goto fail1;
-
-    Partial->TitleIndex = 0;
-    Partial->Type = REG_SZ;
-    Partial->DataLength = Length * sizeof (WCHAR);
-
-    Unicode.MaximumLength = (UCHAR)Partial->DataLength;
-    Unicode.Buffer = (PWCHAR)Partial->Data;
-    Unicode.Length = 0;
-
-    status = RtlAnsiStringToUnicodeString(&Unicode, Ansi, FALSE);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    return Partial;
-
-fail2:
-    __RegistryFree(Partial);
-
-fail1:
-    return NULL;
-}
-
-static PKEY_VALUE_PARTIAL_INFORMATION
-RegistryAnsiToMultiSz(
-    PANSI_STRING                    Ansi
-    )
-{
-    ULONG                           Length;
-    ULONG                           Index;
-    PKEY_VALUE_PARTIAL_INFORMATION  Partial;
-    UNICODE_STRING                  Unicode;
-    NTSTATUS                        status;
-
-    Length = 1;
-    for (Index = 0; Ansi[Index].Buffer != NULL; Index++)
-        Length += Ansi[Index].Length + 1;
-
-    Partial = __RegistryAllocate(FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data) +
-                               Length * sizeof (WCHAR));
-
-    status = STATUS_NO_MEMORY;
-    if (Partial == NULL)
-        goto fail1;
-
-    Partial->TitleIndex = 0;
-    Partial->Type = REG_MULTI_SZ;
-    Partial->DataLength = Length * sizeof (WCHAR);
-
-    Unicode.MaximumLength = (USHORT)Partial->DataLength;
-    Unicode.Buffer = (PWCHAR)Partial->Data;
-    Unicode.Length = 0;
-
-    for (Index = 0; Ansi[Index].Buffer != NULL; Index++) {
-        status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi[Index], FALSE);
-        if (!NT_SUCCESS(status))
-            goto fail2;
-
-        Length = Unicode.Length / sizeof (WCHAR);
-
-        ASSERT3U(Unicode.MaximumLength, >=, (Length + 1) * sizeof (WCHAR));
-        Unicode.MaximumLength -= (USHORT)((Length + 1) * sizeof (WCHAR));
-        Unicode.Buffer += Length + 1;
-        Unicode.Length = 0;
-    }
-    *Unicode.Buffer = L'\0';
-
-    return Partial;
-
-fail2:
-    __RegistryFree(Partial);
-
-fail1:
-    return NULL;
-}
-
-NTSTATUS
-RegistryUpdateSzValue(
-    IN  HANDLE                      Key,
-    IN  PCHAR                       Name,
-    IN  ULONG                       Type,
-    IN  PANSI_STRING                Array
-    )
-{
-    ANSI_STRING                     Ansi;
-    UNICODE_STRING                  Unicode;
-    PKEY_VALUE_PARTIAL_INFORMATION  Partial;
-    NTSTATUS                        status;
-
-    RtlInitAnsiString(&Ansi, Name);
-
-    status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    switch (Type) {
-    case REG_SZ:
-        status = STATUS_NO_MEMORY;
-        Partial = RegistryAnsiToSz(Array);
-        break;
-
-    case REG_MULTI_SZ:
-        status = STATUS_NO_MEMORY;
-        Partial = RegistryAnsiToMultiSz(Array);
-        break;
-
-    default:
-        status = STATUS_INVALID_PARAMETER;
-        Partial = NULL;
-        break;
-    }
-
-    if (Partial == NULL)
-        goto fail2;
-
-    status = ZwSetValueKey(Key,
-                           &Unicode,
-                           Partial->TitleIndex,
-                           Partial->Type,
-                           Partial->Data,
-                           Partial->DataLength);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    __RegistryFree(Partial);
-
-    (VOID) ZwFlushKey(Key);
-
-    RtlFreeUnicodeString(&Unicode);
-
-    return STATUS_SUCCESS;
-
-fail3:
-    __RegistryFree(Partial);
-
-fail2:
-    RtlFreeUnicodeString(&Unicode);
-
-fail1:
-    return status;
-}
-
-VOID
-RegistryFreeSzValue(
-    IN  PANSI_STRING    Array
-    )
-{
-    ULONG               Index;
-
-    if (Array == NULL)
-        return;
-
-    for (Index = 0; Array[Index].Buffer != NULL; Index++)
-        __RegistryFree(Array[Index].Buffer);
-
-    __RegistryFree(Array);
-}
-
-VOID
-RegistryFreeBinaryValue(
-    IN  PVOID   Buffer
-    )
-{
-    __RegistryFree(Buffer);
-}
-
-VOID
-RegistryCloseKey(
-    IN  HANDLE  Key
-    )
-{
-    ZwClose(Key);
-}
diff --git a/src/xendisk/registry.h b/src/xendisk/registry.h
deleted file mode 100644
index b33eb81..0000000
--- a/src/xendisk/registry.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _XENDISK_REGISTRY_H
-#define _XENDISK_REGISTRY_H
-
-#include <ntddk.h>
-
-extern NTSTATUS
-RegistryInitialize(
-    IN  PDRIVER_OBJECT  DriverObject,
-    IN  PUNICODE_STRING Path
-    );
-
-extern VOID
-RegistryTeardown(
-    VOID
-    );
-
-extern NTSTATUS
-RegistryOpenKey(
-    IN  HANDLE          Parent,
-    IN  PUNICODE_STRING Path,
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         Key
-    );
-
-extern NTSTATUS
-RegistryCreateKey(
-    IN  HANDLE          Parent,
-    IN  PUNICODE_STRING Path,
-    IN  ULONG           Options,
-    OUT PHANDLE         Key
-    );
-
-extern NTSTATUS
-RegistryOpenServiceKey(
-    IN  ACCESS_MASK DesiredAccess,
-    OUT PHANDLE     Key
-    );
-
-extern NTSTATUS
-RegistryCreateServiceKey(
-    OUT PHANDLE     Key
-    );
-
-extern NTSTATUS
-RegistryOpenParametersKey(
-    IN  ACCESS_MASK DesiredAccess,
-    OUT PHANDLE     Key
-    );
-
-extern NTSTATUS
-RegistryOpenSoftwareKey(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         Key
-    );
-
-extern NTSTATUS
-RegistryOpenHardwareKey(
-    IN  PDEVICE_OBJECT  DeviceObject,
-    IN  ACCESS_MASK     DesiredAccess,
-    OUT PHANDLE         Key
-    );
-
-extern NTSTATUS
-RegistryOpenSubKey(
-    IN  HANDLE      Key,
-    IN  PCHAR       Name,
-    IN  ACCESS_MASK DesiredAccess,
-    OUT PHANDLE     SubKey
-    );
-
-extern NTSTATUS
-RegistryCreateSubKey(
-    IN  HANDLE      Key,
-    IN  PCHAR       Name,
-    IN  ULONG       Options,
-    OUT PHANDLE     SubKey
-    );
-
-extern NTSTATUS
-RegistryDeleteSubKey(
-    IN  HANDLE      Key,
-    IN  PCHAR       Name
-    );
-
-extern NTSTATUS
-RegistryEnumerateSubKeys(
-    IN  HANDLE      Key,
-    IN  NTSTATUS    (*Callback)(PVOID, HANDLE, PANSI_STRING),
-    IN  PVOID       Context
-    );
-
-extern NTSTATUS
-RegistryEnumerateValues(
-    IN  HANDLE      Key,
-    IN  NTSTATUS    (*Callback)(PVOID, HANDLE, PANSI_STRING, ULONG),
-    IN  PVOID       Context
-    );
-
-extern NTSTATUS
-RegistryDeleteValue(
-    IN  HANDLE      Key,
-    IN  PCHAR       Name
-    );
-
-extern NTSTATUS
-RegistryQueryDwordValue(
-    IN  HANDLE          Key,
-    IN  PCHAR           Name,
-    OUT PULONG          Value
-    );
-
-extern NTSTATUS
-RegistryUpdateDwordValue(
-    IN  HANDLE          Key,
-    IN  PCHAR           Name,
-    IN  ULONG           Value
-    );
-
-extern NTSTATUS
-RegistryQuerySzValue(
-    IN  HANDLE          Key,
-    IN  PCHAR           Name,
-    OUT PULONG          Type OPTIONAL,
-    OUT PANSI_STRING    *Array
-    );
-
-extern NTSTATUS
-RegistryQueryBinaryValue(
-    IN  HANDLE          Key,
-    IN  PCHAR           Name,
-    OUT PVOID           *Buffer,
-    OUT PULONG          Length
-    );
-
-extern NTSTATUS
-RegistryUpdateBinaryValue(
-    IN  HANDLE          Key,
-    IN  PCHAR           Name,
-    IN  PVOID           Buffer,
-    IN  ULONG           Length
-    );
-
-extern NTSTATUS
-RegistryQueryKeyName(
-    IN  HANDLE              Key,
-    OUT PANSI_STRING        *Array
-    );
-
-extern NTSTATUS
-RegistryQuerySystemStartOption(
-    IN  PCHAR           Name,
-    OUT PANSI_STRING    *Option
-    );
-
-extern VOID
-RegistryFreeSzValue(
-    IN  PANSI_STRING    Array
-    );
-
-extern VOID
-RegistryFreeBinaryValue(
-    IN  PVOID           Buffer
-    );
-
-extern NTSTATUS
-RegistryUpdateSzValue(
-    IN  HANDLE          Key,
-    IN  PCHAR           Name,
-    IN  ULONG           Type,
-    IN  PANSI_STRING    Array
-    );
-
-extern VOID
-RegistryCloseKey(
-    IN  HANDLE  Key
-    );
-
-#endif  // _XENDISK_REGISTRY_H
diff --git a/src/xendisk/thread.c b/src/xendisk/thread.c
deleted file mode 100644
index 044c104..0000000
--- a/src/xendisk/thread.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <ntddk.h>
-
-#include "thread.h"
-#include "debug.h"
-#include "assert.h"
-#include "util.h"
-
-#define THREAD_TAG 'ERHT'
-
-struct _XENDISK_THREAD {
-    XENDISK_THREAD_FUNCTION  Function;
-    PVOID                   Context;
-    KEVENT                  Event;
-    BOOLEAN                 Alerted;
-    LONG                    References;
-    PKTHREAD                Thread;
-};
-
-static FORCEINLINE PVOID
-__ThreadAllocate(
-    IN  ULONG   Length
-    )
-{
-    return __AllocatePoolWithTag(NonPagedPool, Length, THREAD_TAG);
-}
-
-static FORCEINLINE VOID
-__ThreadFree(
-    IN  PVOID   Buffer
-    )
-{
-    __FreePoolWithTag(Buffer, THREAD_TAG);
-}
-
-static FORCEINLINE VOID
-__ThreadWake(
-    IN  PXENDISK_THREAD Thread
-    )
-{
-    KeSetEvent(&Thread->Event, IO_NO_INCREMENT, FALSE);
-}
-
-VOID
-ThreadWake(
-    IN  PXENDISK_THREAD Thread
-    )
-{
-    __ThreadWake(Thread);
-}
-
-static FORCEINLINE VOID
-__ThreadAlert(
-    IN  PXENDISK_THREAD Thread
-    )
-{
-    Thread->Alerted = TRUE;
-    __ThreadWake(Thread);
-}
-
-VOID
-ThreadAlert(
-    IN  PXENDISK_THREAD Thread
-    )
-{
-    __ThreadAlert(Thread);
-}
-
-KSTART_ROUTINE  ThreadFunction;
-
-VOID
-ThreadFunction(
-    IN  PVOID       Argument
-    )
-{
-    PXENDISK_THREAD Self = Argument;
-    NTSTATUS        status;
-
-    status = Self->Function(Self, Self->Context);
-
-    if (InterlockedDecrement(&Self->References) == 0)
-        __ThreadFree(Self);
-
-    PsTerminateSystemThread(status);
-    // NOT REACHED
-}
-
-__drv_requiresIRQL(PASSIVE_LEVEL)
-NTSTATUS
-ThreadCreate(
-    IN  XENDISK_THREAD_FUNCTION Function,
-    IN  PVOID                   Context,
-    OUT PXENDISK_THREAD         *Thread
-    )
-{
-    HANDLE                      Handle;
-    NTSTATUS                    status;
-
-    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
-
-    (*Thread) = __ThreadAllocate(sizeof (XENDISK_THREAD));
-
-    status = STATUS_NO_MEMORY;
-    if (*Thread == NULL)
-        goto fail1;
-
-    (*Thread)->Function = Function;
-    (*Thread)->Context = Context;
-    (*Thread)->Alerted = FALSE;
-    (*Thread)->References = 2; // One for us, one for the thread function
-
-    KeInitializeEvent(&(*Thread)->Event, NotificationEvent, FALSE);
-
-    status = PsCreateSystemThread(&Handle,
-                                  STANDARD_RIGHTS_ALL | SPECIFIC_RIGHTS_ALL,
-                                  NULL,
-                                  NULL,
-                                  NULL,
-                                  ThreadFunction,
-                                  *Thread);
-    if (!NT_SUCCESS(status)) {
-        --(*Thread)->References;    // Fake thread function termination
-        goto fail2;
-    }
-
-    status = ObReferenceObjectByHandle(Handle,
-                                       SYNCHRONIZE,
-                                       *PsThreadType,
-                                       KernelMode,
-                                       &(*Thread)->Thread,
-                                       NULL);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    ZwClose(Handle);
-
-    return STATUS_SUCCESS;
-
-fail3:
-    Error("fail3\n");
-
-    __ThreadAlert(*Thread);
-    ZwClose(Handle);
-
-fail2:
-    Error("fail2\n");
-
-    if (InterlockedDecrement(&(*Thread)->References) == 0)
-        __ThreadFree(*Thread);
-
-    *Thread = NULL;
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return status;
-}
-
-PKEVENT
-ThreadGetEvent(
-    IN  PXENDISK_THREAD Thread
-    )
-{
-    return &Thread->Event;
-}
-
-BOOLEAN
-ThreadIsAlerted(
-    IN  PXENDISK_THREAD Thread
-    )
-{
-    return Thread->Alerted;
-}
-
-VOID
-ThreadJoin(
-    IN  PXENDISK_THREAD Thread
-    )
-{
-    LONG                References;
-
-    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
-    ASSERT3P(KeGetCurrentThread(), !=, Thread->Thread);
-
-    (VOID) KeWaitForSingleObject(Thread->Thread,
-                                 Executive,
-                                 KernelMode,
-                                 FALSE,
-                                 NULL);
-
-    References = InterlockedDecrement(&Thread->References);
-    ASSERT3U(References, ==, 0);
-
-    __ThreadFree(Thread);
-}
diff --git a/src/xendisk/thread.h b/src/xendisk/thread.h
deleted file mode 100644
index d778943..0000000
--- a/src/xendisk/thread.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _XENDISK_THREAD_H
-#define _XENDISK_THREAD_H
-
-#include <ntddk.h>
-
-typedef struct _XENDISK_THREAD XENDISK_THREAD, *PXENDISK_THREAD;
-
-typedef NTSTATUS (*XENDISK_THREAD_FUNCTION)(PXENDISK_THREAD, PVOID);
-
-__drv_requiresIRQL(PASSIVE_LEVEL)
-extern NTSTATUS
-ThreadCreate(
-    IN  XENDISK_THREAD_FUNCTION Function,
-    IN  PVOID                   Context,
-    OUT PXENDISK_THREAD         *Thread
-    );
-
-extern PKEVENT
-ThreadGetEvent(
-    IN  PXENDISK_THREAD Self
-    );
-
-extern BOOLEAN
-ThreadIsAlerted(
-    IN  PXENDISK_THREAD Self
-    );
-
-extern VOID
-ThreadWake(
-    IN  PXENDISK_THREAD Thread
-    );
-
-extern VOID
-ThreadAlert(
-    IN  PXENDISK_THREAD Thread
-    );
-
-extern VOID
-ThreadJoin(
-    IN  PXENDISK_THREAD Thread
-    );
-
-#endif  // _XENDISK_THREAD_H
diff --git a/src/xendisk/types.h b/src/xendisk/types.h
deleted file mode 100644
index 500c28c..0000000
--- a/src/xendisk/types.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _XENDISK_TYPES_H
-#define _XENDISK_TYPES_H
-
-typedef enum _DEVICE_OBJECT_TYPE {
-    PHYSICAL_DEVICE_OBJECT = 'ODP',
-    FUNCTION_DEVICE_OBJECT = 'ODF'
-} DEVICE_OBJECT_TYPE, *PDEVICE_OBJECT_TYPE;
-
-typedef enum _DEVICE_PNP_STATE {
-    Invalid = 0,
-    Present,        // PDO only
-    Enumerated,     // PDO only
-    Added,          // FDO only
-    Started,
-    StopPending,
-    Stopped,
-    RemovePending,
-    SurpriseRemovePending,
-    Deleted
-} DEVICE_PNP_STATE, *PDEVICE_PNP_STATE;
-
-#endif  // _XENDISK_TYPES_H
diff --git a/src/xendisk/xendisk.rc b/src/xendisk/xendisk.rc
deleted file mode 100644
index a863007..0000000
--- a/src/xendisk/xendisk.rc
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright (c) Xen Project.
- * Copyright (c) Cloud Software Group, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <windows.h>
-#include <ntverp.h>
-
-
-#undef VER_COMPANYNAME_STR
-#undef VER_PRODUCTNAME_STR
-#undef VER_PRODUCTVERSION
-#undef VER_PRODUCTVERSION_STR
-
-#include <version.h>
-
-#define	VER_COMPANYNAME_STR         VENDOR_NAME_STR
-#define VER_LEGALCOPYRIGHT_STR      COPYRIGHT_STR
-
-#define VER_PRODUCTNAME_STR         "XENDISK"
-#define VER_PRODUCTVERSION          MAJOR_VERSION,MINOR_VERSION,MICRO_VERSION,BUILD_NUMBER
-#define VER_PRODUCTVERSION_STR      MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR
-
-#define VER_INTERNALNAME_STR        "XENDISK.SYS"
-#define VER_FILEDESCRIPTION_STR     "XENDISK"
-
-#define VER_FILETYPE                VFT_DRV
-#define VER_FILESUBTYPE             VFT2_DRV_SYSTEM
-
-#include <common.ver>
diff --git a/src/xenvbd.inf b/src/xenvbd.inf
index 19e92c9..f5e1614 100644
--- a/src/xenvbd.inf
+++ b/src/xenvbd.inf
@@ -2,45 +2,45 @@
 ; Copyright (c) Cloud Software Group, Inc.
 ; All rights reserved.
 ;
-; Redistribution and use in source and binary forms, 
-; with or without modification, are permitted provided 
+; Redistribution and use in source and binary forms,
+; with or without modification, are permitted provided
 ; that the following conditions are met:
 ;
-; *   Redistributions of source code must retain the above 
-;     copyright notice, this list of conditions and the 
+; *   Redistributions of source code must retain the above
+;     copyright notice, this list of conditions and the
 ;     following disclaimer.
-; *   Redistributions in binary form must reproduce the above 
-;     copyright notice, this list of conditions and the 
-;     following disclaimer in the documentation and/or other 
+; *   Redistributions in binary form must reproduce the above
+;     copyright notice, this list of conditions and the
+;     following disclaimer in the documentation and/or other
 ;     materials provided with the distribution.
 ;
-; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
-; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
-; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
-; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
-; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
-; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-; BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
-; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
-; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
-; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
-; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+; CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+; BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 ; SUCH DAMAGE.
- 
-[Version] 
-Signature="$Windows NT$" 
+
+[Version]
+Signature="$Windows NT$"
 Class=SCSIAdapter
-ClassGUID={4D36E97B-E325-11CE-BFC1-08002BE10318} 
-Provider=%Vendor% 
+ClassGUID={4D36E97B-E325-11CE-BFC1-08002BE10318}
+Provider=%Vendor%
 CatalogFile=xenvbd.cat
 DriverVer=@INF_DATE@,@MAJOR_VERSION@.@MINOR_VERSION@.@MICRO_VERSION@.@BUILD_NUMBER@
 DriverPackageDisplayName=%DiskDesc%
 PnpLockdown=1
 
-[DestinationDirs] 
-DefaultDestDir=12 
+[DestinationDirs]
+DefaultDestDir=12
 
 [SourceDisksNames]
 0=%DiskDesc%
@@ -48,9 +48,8 @@ DefaultDestDir=12
 [SourceDisksFiles]
 xenvbd.sys=0,,
 xencrsh.sys=0,,
-xendisk.sys=0,,
 
-[Manufacturer] 
+[Manufacturer]
 %Vendor%=Inst,NT@INF_ARCH@
 
 [Inst.NT@INF_ARCH@]
@@ -59,7 +58,7 @@ XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VBD&REV_0900000B,\
 XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VBD&REV_0900000B,\
 XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VBD&REV_0900000B
 
-[XenVbd_Inst] 
+[XenVbd_Inst]
 CopyFiles=XenVbd_Copyfiles
 ; TODO: Remove during next PDO version bump
 FeatureScore=0xFE
@@ -67,43 +66,23 @@ FeatureScore=0xFE
 [XenVbd_Copyfiles]
 xenvbd.sys
 xencrsh.sys
-xendisk.sys
-
-[XenVbd_Inst.HW]
-AddReg=XenVbd_AddReg
-
-[XenVbd_AddReg]
-HKR,,"UpperFilters",0x00010000,"xendisk"
 
-[XenVbd_Inst.Services] 
+[XenVbd_Inst.Services]
 AddService=xenvbd,2,XenVbd_Service,
-AddService=xendisk,,XenDisk_Service,
 
-[XenDisk_Service]
-DisplayName=%XenDiskName%
+[XenVbd_Service]
+DisplayName=%XenVbdName%
 ServiceType=%SERVICE_KERNEL_DRIVER%
 StartType=%SERVICE_BOOT_START%
 ErrorControl=%SERVICE_ERROR_NORMAL%
-ServiceBinary=%12%\xendisk.sys
-LoadOrderGroup="Scsi Miniport"
-AddReg=XenDisk_Parameters
-
-[XenDisk_Parameters]
-HKR,"Parameters",,0x00000010
-
-[XenVbd_Service] 
-DisplayName=%XenVbdName%
-ServiceType=%SERVICE_KERNEL_DRIVER% 
-StartType=%SERVICE_BOOT_START% 
-ErrorControl=%SERVICE_ERROR_NORMAL% 
-ServiceBinary=%12%\xenvbd.sys 
+ServiceBinary=%12%\xenvbd.sys
 LoadOrderGroup="Scsi Miniport"
 AddReg=XenVbd_Parameters, XenVbd_Unplug, XenVbd_Extras
 
-[XenVbd_Parameters] 
+[XenVbd_Parameters]
 HKR,"Parameters",,0x00000010
-HKR,"Parameters","BusType",0x00010001,0x00000001 
-HKR,"Parameters\PnpInterface","5",0x00010001,0x00000001 
+HKR,"Parameters","BusType",0x00010001,0x00000001
+HKR,"Parameters\PnpInterface","5",0x00010001,0x00000001
 HKR,"Parameters","max-ring-page-order",0x00010001,0x00000001
 HKR,"Parameters","multi-queue-max-queues",0x00010001,0x00000002
 
@@ -120,23 +99,22 @@ HKLM,%DiskKey%,"TimeOutValue",0x00010001,120
 [Strings]
 
 Vendor = "@VENDOR_NAME@"
-DiskDesc = "@PRODUCT_NAME@ PV Storage Host Adapter Package" 
+DiskDesc = "@PRODUCT_NAME@ PV Storage Host Adapter Package"
 XenVbdName= "@PRODUCT_NAME@ PV Storage Host Adapter"
-XenDiskName= "@PRODUCT_NAME@ PV Storage Filter"
 UnplugKey="SYSTEM\CurrentControlSet\Services\XEN\Unplug"
 ForceUnplugKey="SYSTEM\CurrentControlSet\Services\XEN\ForceUnplug"
 PnpKey="SYSTEM\CurrentControlSet\Control\Pnp"
 PartMgrKey="SYSTEM\CurrentControlSet\Services\PartMgr\Parameters"
 DiskKey="SYSTEM\CurrentControlSet\Services\Disk"
 
-SERVICE_BOOT_START = 0x0 
-SERVICE_SYSTEM_START = 0x1 
-SERVICE_AUTO_START = 0x2 
-SERVICE_DEMAND_START = 0x3 
-SERVICE_DISABLED = 0x4 
-
-SERVICE_KERNEL_DRIVER = 0x1 
-SERVICE_ERROR_IGNORE = 0x0 
-SERVICE_ERROR_NORMAL = 0x1 
-SERVICE_ERROR_SEVERE = 0x2 
-SERVICE_ERROR_CRITICAL = 0x3 
+SERVICE_BOOT_START = 0x0
+SERVICE_SYSTEM_START = 0x1
+SERVICE_AUTO_START = 0x2
+SERVICE_DEMAND_START = 0x3
+SERVICE_DISABLED = 0x4
+
+SERVICE_KERNEL_DRIVER = 0x1
+SERVICE_ERROR_IGNORE = 0x0
+SERVICE_ERROR_NORMAL = 0x1
+SERVICE_ERROR_SEVERE = 0x2
+SERVICE_ERROR_CRITICAL = 0x3
diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index 2cae479..6929276 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -403,7 +403,7 @@ TargetModeSense(
 
     // Header
     Data->MediumType                = 0;
-    Data->DeviceSpecificParameter   = FrontendGetReadOnly(Target->Frontend) ? 
+    Data->DeviceSpecificParameter   = FrontendGetReadOnly(Target->Frontend) ?
                                                     MODE_DSP_WRITE_PROTECT : 0;
     Size = sizeof(MODE_PARAMETER_HEADER);
 
@@ -448,7 +448,7 @@ TargetModeSense10(
 
     // Header
     Data->MediumType                = 0;
-    Data->DeviceSpecificParameter   = FrontendGetReadOnly(Target->Frontend) ? 
+    Data->DeviceSpecificParameter   = FrontendGetReadOnly(Target->Frontend) ?
                                                     MODE_DSP_WRITE_PROTECT : 0;
     Size = sizeof(MODE_PARAMETER_HEADER10);
 
@@ -462,7 +462,7 @@ TargetModeSense10(
     ASSERT3U(ModeDataLength, <=, 65535 - (sizeof(MODE_PARAMETER_HEADER10) - 2));
     ASSERT3U(BlockDescrLength, <=, 65535);
 
-    *(PUSHORT)Data->ModeDataLength = _byteswap_ushort((USHORT)ModeDataLength + 
+    *(PUSHORT)Data->ModeDataLength = _byteswap_ushort((USHORT)ModeDataLength +
                                                       sizeof(MODE_PARAMETER_HEADER10) - 2);
     *(PUSHORT)Data->BlockDescriptorLength = _byteswap_ushort((USHORT)BlockDescrLength);
 
diff --git a/vs2019/package/package.vcxproj b/vs2019/package/package.vcxproj
index 764cfef..1a553d7 100644
--- a/vs2019/package/package.vcxproj
+++ b/vs2019/package/package.vcxproj
@@ -50,9 +50,6 @@
     <ProjectReference Include="..\xenvbd\xenvbd.vcxproj">
       <Project>{ef236371-3145-41b1-99c9-82b33e353f17}</Project>
     </ProjectReference>
-    <ProjectReference Include="..\xendisk\xendisk.vcxproj">
-      <Project>{d7411b2c-2c43-434d-9f56-e10a3d2f5bad}</Project>
-    </ProjectReference>
     <FilesToPackage Include="..\xenvbd.inf" />
   </ItemGroup>
   <ItemGroup Condition="Exists('$(DPINST_REDIST)')">
diff --git a/vs2019/xendisk/xendisk.vcxproj b/vs2019/xendisk/xendisk.vcxproj
deleted file mode 100644
index 25b195f..0000000
--- a/vs2019/xendisk/xendisk.vcxproj
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="..\configs.props" />
-  <PropertyGroup Label="PropertySheets">
-    <DriverType>WDM</DriverType>
-    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
-    <ConfigurationType>Driver</ConfigurationType>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}</ProjectGuid>
-  </PropertyGroup>
-  <Import Project="..\targets.props" />
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <PropertyGroup>
-    <EnableInf2cat>false</EnableInf2cat>
-    <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir>
-    <OutDir>..\$(ConfigurationName)\$(Platform)\</OutDir>
-  </PropertyGroup>
-  <ItemDefinitionGroup>
-    <ClCompile>
-      <AdditionalOptions>/ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions>
-      <AdditionalIncludeDirectories>..\..\include;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>PROJECT=$(ProjectName);POOL_NX_OPTIN=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <WarningLevel>EnableAllWarnings</WarningLevel>
-      <DisableSpecificWarnings>4061;4464;4548;4770;4711;4820;4668;4255;5045;6001;6054;26451;28196;30030;30029;%(DisableSpecificWarnings)</DisableSpecificWarnings>
-      <MultiProcessorCompilation>true</MultiProcessorCompilation>
-    </ClCompile>
-    <ResourceCompile>
-      <AdditionalIncludeDirectories>..\..\include;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-    </ResourceCompile>
-    <Link>
-      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
-      <AdditionalOptions>/INTEGRITYCHECK %(AdditionalOptions)</AdditionalOptions>
-      <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
-      <CETCompat>true</CETCompat>
-      <GenerateMapFile>true</GenerateMapFile>
-      <MapExports>true</MapExports>
-    </Link>
-    <DriverSign>
-      <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
-    </DriverSign>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
-    <ClCompile>
-      <PreprocessorDefinitions>__i386__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-    </ClCompile>
-    <Link>
-      <ImageHasSafeExceptionHandlers>true</ImageHasSafeExceptionHandlers>
-    </Link>  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
-    <ClCompile>
-      <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-    </ClCompile>
-    <Link>
-      <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)'=='Windows 10 Release'">
-    <ClCompile>
-      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
-      <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalOptions>/Qspectre %(AdditionalOptions)</AdditionalOptions>
-    </ClCompile>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <FilesToPackage Include="$(TargetPath)" />
-    <FilesToPackage Include="$(OutDir)$(TargetName).pdb" />
-    <FilesToPackage Include="$(OutDir)$(TargetName).map" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="../../src/xendisk/driver.c" />
-    <ClCompile Include="../../src/xendisk/fdo.c" />
-    <ClCompile Include="../../src/xendisk/pdo.c" />
-    <ClCompile Include="../../src/xendisk/registry.c" />
-    <ClCompile Include="../../src/xendisk/thread.c" />
-  </ItemGroup>
-  <ItemGroup>
-    <ResourceCompile Include="..\..\src\xendisk\xendisk.rc" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-</Project>
diff --git a/vs2019/xendisk/xendisk.vcxproj.user b/vs2019/xendisk/xendisk.vcxproj.user
deleted file mode 100644
index e1315db..0000000
--- a/vs2019/xendisk/xendisk.vcxproj.user
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <SignMode>TestSign</SignMode>
-    <TestCertificate>..\..\src\xenvbd.pfx</TestCertificate>
-    <TimeStampServer>http://timestamp.verisign.com/scripts/timstamp.dll</TimeStampServer>
-  </PropertyGroup>
-</Project>
diff --git a/vs2019/xenvbd.sln b/vs2019/xenvbd.sln
index 2b6a09e..1777096 100644
--- a/vs2019/xenvbd.sln
+++ b/vs2019/xenvbd.sln
@@ -15,17 +15,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xencrsh", "xencrsh\xencrsh.
 		{65FA97EA-A569-4FC1-BFE7-D68E109143F7} = {65FA97EA-A569-4FC1-BFE7-D68E109143F7}
 	EndProjectSection
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xendisk", "xendisk\xendisk.vcxproj", "{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}"
-	ProjectSection(ProjectDependencies) = postProject
-		{65FA97EA-A569-4FC1-BFE7-D68E109143F7} = {65FA97EA-A569-4FC1-BFE7-D68E109143F7}
-	EndProjectSection
-EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "package", "package\package.vcxproj", "{AB8DAED3-9D70-4907-99A3-C643F1FC1972}"
 	ProjectSection(ProjectDependencies) = postProject
 		{65FA97EA-A569-4FC1-BFE7-D68E109143F7} = {65FA97EA-A569-4FC1-BFE7-D68E109143F7}
 		{58F5BC43-B92E-4A2B-975D-0066EAB29092} = {58F5BC43-B92E-4A2B-975D-0066EAB29092}
 		{EF236371-3145-41B1-99C9-82B33E353F17} = {EF236371-3145-41B1-99C9-82B33E353F17}
-		{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD} = {D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}
 	EndProjectSection
 EndProject
 Global
@@ -44,14 +38,6 @@ Global
 		{65FA97EA-A569-4FC1-BFE7-D68E109143F7}.Windows 10 Release|Win32.Build.0 = Windows 10 Release|Win32
 		{65FA97EA-A569-4FC1-BFE7-D68E109143F7}.Windows 10 Release|x64.ActiveCfg = Windows 10 Release|x64
 		{65FA97EA-A569-4FC1-BFE7-D68E109143F7}.Windows 10 Release|x64.Build.0 = Windows 10 Release|x64
-		{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}.Windows 10 Debug|Win32.ActiveCfg = Windows 10 Debug|Win32
-		{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}.Windows 10 Debug|Win32.Build.0 = Windows 10 Debug|Win32
-		{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}.Windows 10 Debug|x64.ActiveCfg = Windows 10 Debug|x64
-		{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}.Windows 10 Debug|x64.Build.0 = Windows 10 Debug|x64
-		{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}.Windows 10 Release|Win32.ActiveCfg = Windows 10 Release|Win32
-		{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}.Windows 10 Release|Win32.Build.0 = Windows 10 Release|Win32
-		{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}.Windows 10 Release|x64.ActiveCfg = Windows 10 Release|x64
-		{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}.Windows 10 Release|x64.Build.0 = Windows 10 Release|x64
 		{EF236371-3145-41B1-99C9-82B33E353F17}.Windows 10 Debug|Win32.ActiveCfg = Windows 10 Debug|Win32
 		{EF236371-3145-41B1-99C9-82B33E353F17}.Windows 10 Debug|Win32.Build.0 = Windows 10 Debug|Win32
 		{EF236371-3145-41B1-99C9-82B33E353F17}.Windows 10 Debug|x64.ActiveCfg = Windows 10 Debug|x64
diff --git a/vs2022/package/package.vcxproj b/vs2022/package/package.vcxproj
index 2a7d9f2..9c7c813 100644
--- a/vs2022/package/package.vcxproj
+++ b/vs2022/package/package.vcxproj
@@ -49,9 +49,6 @@
     <ProjectReference Include="..\xenvbd\xenvbd.vcxproj">
       <Project>{ef236371-3145-41b1-99c9-82b33e353f17}</Project>
     </ProjectReference>
-    <ProjectReference Include="..\xendisk\xendisk.vcxproj">
-      <Project>{d7411b2c-2c43-434d-9f56-e10a3d2f5bad}</Project>
-    </ProjectReference>
     <FilesToPackage Include="..\xenvbd.inf" />
   </ItemGroup>
   <ItemGroup Condition="Exists('$(DPINST_REDIST)')">
diff --git a/vs2022/xendisk/xendisk.vcxproj b/vs2022/xendisk/xendisk.vcxproj
deleted file mode 100644
index d7df663..0000000
--- a/vs2022/xendisk/xendisk.vcxproj
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="..\configs.props" />
-  <PropertyGroup Label="PropertySheets">
-    <DriverType>WDM</DriverType>
-    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
-    <ConfigurationType>Driver</ConfigurationType>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}</ProjectGuid>
-  </PropertyGroup>
-  <Import Project="..\targets.props" />
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <PropertyGroup>
-    <EnableInf2cat>false</EnableInf2cat>
-    <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir>
-    <OutDir>..\$(ConfigurationName)\$(Platform)\</OutDir>
-  </PropertyGroup>
-  <ItemDefinitionGroup>
-    <ClCompile>
-      <AdditionalOptions>/ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions>
-      <AdditionalIncludeDirectories>..\..\include;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>PROJECT=$(ProjectName);POOL_NX_OPTIN=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <WarningLevel>EnableAllWarnings</WarningLevel>
-      <DisableSpecificWarnings>4061;4464;4548;4770;4711;4820;4668;4255;5045;6001;6054;26451;28196;30030;30029;%(DisableSpecificWarnings)</DisableSpecificWarnings>
-      <MultiProcessorCompilation>true</MultiProcessorCompilation>
-    </ClCompile>
-    <ResourceCompile>
-      <AdditionalIncludeDirectories>..\..\include;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-    </ResourceCompile>
-    <Link>
-      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
-      <AdditionalOptions>/INTEGRITYCHECK %(AdditionalOptions)</AdditionalOptions>
-      <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
-      <CETCompat>true</CETCompat>
-      <GenerateMapFile>true</GenerateMapFile>
-      <MapExports>true</MapExports>
-    </Link>
-    <DriverSign>
-      <FileDigestAlgorithm>sha256</FileDigestAlgorithm>
-    </DriverSign>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
-    <ClCompile>
-      <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-    </ClCompile>
-    <Link>
-      <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)'=='Windows 10 Release'">
-    <ClCompile>
-      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
-      <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalOptions>/Qspectre %(AdditionalOptions)</AdditionalOptions>
-    </ClCompile>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <FilesToPackage Include="$(TargetPath)" />
-    <FilesToPackage Include="$(OutDir)$(TargetName).pdb" />
-    <FilesToPackage Include="$(OutDir)$(TargetName).map" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="../../src/xendisk/driver.c" />
-    <ClCompile Include="../../src/xendisk/fdo.c" />
-    <ClCompile Include="../../src/xendisk/pdo.c" />
-    <ClCompile Include="../../src/xendisk/registry.c" />
-    <ClCompile Include="../../src/xendisk/thread.c" />
-  </ItemGroup>
-  <ItemGroup>
-    <ResourceCompile Include="..\..\src\xendisk\xendisk.rc" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-</Project>
diff --git a/vs2022/xendisk/xendisk.vcxproj.user b/vs2022/xendisk/xendisk.vcxproj.user
deleted file mode 100644
index e1315db..0000000
--- a/vs2022/xendisk/xendisk.vcxproj.user
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <SignMode>TestSign</SignMode>
-    <TestCertificate>..\..\src\xenvbd.pfx</TestCertificate>
-    <TimeStampServer>http://timestamp.verisign.com/scripts/timstamp.dll</TimeStampServer>
-  </PropertyGroup>
-</Project>
diff --git a/vs2022/xenvbd.sln b/vs2022/xenvbd.sln
index 407f395..a302a38 100644
--- a/vs2022/xenvbd.sln
+++ b/vs2022/xenvbd.sln
@@ -15,17 +15,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xencrsh", "xencrsh\xencrsh.
 		{65FA97EA-A569-4FC1-BFE7-D68E109143F7} = {65FA97EA-A569-4FC1-BFE7-D68E109143F7}
 	EndProjectSection
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xendisk", "xendisk\xendisk.vcxproj", "{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}"
-	ProjectSection(ProjectDependencies) = postProject
-		{65FA97EA-A569-4FC1-BFE7-D68E109143F7} = {65FA97EA-A569-4FC1-BFE7-D68E109143F7}
-	EndProjectSection
-EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "package", "package\package.vcxproj", "{AB8DAED3-9D70-4907-99A3-C643F1FC1972}"
 	ProjectSection(ProjectDependencies) = postProject
 		{65FA97EA-A569-4FC1-BFE7-D68E109143F7} = {65FA97EA-A569-4FC1-BFE7-D68E109143F7}
 		{58F5BC43-B92E-4A2B-975D-0066EAB29092} = {58F5BC43-B92E-4A2B-975D-0066EAB29092}
 		{EF236371-3145-41B1-99C9-82B33E353F17} = {EF236371-3145-41B1-99C9-82B33E353F17}
-		{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD} = {D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}
 	EndProjectSection
 EndProject
 Global
@@ -38,10 +32,6 @@ Global
 		{65FA97EA-A569-4FC1-BFE7-D68E109143F7}.Windows 10 Debug|x64.Build.0 = Windows 10 Debug|x64
 		{65FA97EA-A569-4FC1-BFE7-D68E109143F7}.Windows 10 Release|x64.ActiveCfg = Windows 10 Release|x64
 		{65FA97EA-A569-4FC1-BFE7-D68E109143F7}.Windows 10 Release|x64.Build.0 = Windows 10 Release|x64
-		{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}.Windows 10 Debug|x64.ActiveCfg = Windows 10 Debug|x64
-		{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}.Windows 10 Debug|x64.Build.0 = Windows 10 Debug|x64
-		{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}.Windows 10 Release|x64.ActiveCfg = Windows 10 Release|x64
-		{D7411B2C-2C43-434D-9F56-E10A3D2F5BAD}.Windows 10 Release|x64.Build.0 = Windows 10 Release|x64
 		{EF236371-3145-41B1-99C9-82B33E353F17}.Windows 10 Debug|x64.ActiveCfg = Windows 10 Debug|x64
 		{EF236371-3145-41B1-99C9-82B33E353F17}.Windows 10 Debug|x64.Build.0 = Windows 10 Debug|x64
 		{EF236371-3145-41B1-99C9-82B33E353F17}.Windows 10 Release|x64.ActiveCfg = Windows 10 Release|x64
-- 
2.51.2.windows.1



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



