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

Re: [PATCH] Add UseConsole parameter to disable default console


  • To: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>, "win-pv-devel@xxxxxxxxxxxxxxxxxxxx" <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Mon, 26 Oct 2026 10:14:37 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=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=EaVewx4TUrMMTRnAtlPpaz3tGKR8yApyHwXfF1SLv3w=; b=NZTOZiZ9kZNIUG7STLSWWvoAyTZTkvjhF9x7GHkweoeLRhLlUSMsIgKPIl8fBxUs1FimLBsU6q37hAENEVIrLExmv5P8wBIXgIqy28FB57vUiaVUOdHUiIsbmAn+tD7h1rbeQLTIe45wt1+5F/GUg3HiI22gRPCG3ez9k2WiL8ZoIkjDjSLjFBXC9FcZf6bdGukfGN7wlO/Bkm7DVaFq2ragkJEzf6YXLPVayuHqKnE5My61tl72WMONCMzhbY10FJzKG31HBOUOxRXoANFyitFWMiXfhpWnRI05jIHWqait+KRGtGtghG1gaPaMzGjlvl918muZquN58jCilZ5ieg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i+HG1PX1Bped+7MueGc0kOVNbbBgJov0oV+mqSpMgWdHA1evTFB3ImgmEyPYxQncYbfo1PJDJOdlNF0nyv7hMVwaSMrkUoE+nocgZK6pAW/mtgWVCVyFtPnDMK/Mq8ylLE0iET1ec2ZaIutCOiepYpGIJvL/JNu1ce+61GZPJmXNUvBAsN/hPEuGPWQkUKTPOn4Fmow5hKXm9/D6uw2ZaSZ1XbKC/BToqzNQblj72pKqfjczX57Odoph0vmjeMGtvlzePSUbwM0Re7jxShPOpGUIB0mCfVXksrILr29nMetk51DOOz9yDwCuZBGc8pFv54oU3Y4DKbkSJJTYqNlnLA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Delivery-date: Mon, 26 Oct 2026 10:14:45 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
  • Msip_labels:
  • Thread-index: AQHdZRdnsgXsHTe+9UuY0/QI3ZURircPmdno
  • Thread-topic: [PATCH] Add UseConsole parameter to disable default console

By setting "UseConsole" = 1, the default console (and CONSOLE) interface will 
fail.
The default console's PDO will still be created, but any attempt to call 
CreateFile will
fail, so I'd assume any alternate use would need to manage the default console 
ring
itself. Non-default console's PDOs are unaffected.

Owen


________________________________________
From: win-pv-devel <win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx> on behalf of Tu 
Dinh <ngoc-tu.dinh@xxxxxxxxxx>
Sent: 26 October 2026 6:57 AM
To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
Cc: Tu Dinh
Subject: [PATCH] Add UseConsole parameter to disable default console

In some cases, we may want to assign the default console to something
else (e.g. a debug transport). So add a parameter to allow disabling it.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
 src/xenbus/console.c | 68 ++++++++++++++++++++++++++++++--------------
 1 file changed, 47 insertions(+), 21 deletions(-)

diff --git a/src/xenbus/console.c b/src/xenbus/console.c
index 2d747cb..0bfe504 100644
--- a/src/xenbus/console.c
+++ b/src/xenbus/console.c
@@ -43,6 +43,8 @@
 #include "dbg_print.h"
 #include "assert.h"
 #include "util.h"
+#include "driver.h"
+#include "registry.h"

 #define CONSOLE_WAKEUP_MAGIC 'EKAW'

@@ -71,6 +73,7 @@ struct _XENBUS_CONSOLE_CONTEXT {
     XENBUS_DEBUG_INTERFACE      DebugInterface;
     PXENBUS_SUSPEND_CALLBACK    SuspendCallbackLate;
     PXENBUS_DEBUG_CALLBACK      DebugCallback;
+    BOOLEAN                     UseConsole;
     BOOLEAN                     Enabled;
 };

@@ -692,13 +695,17 @@ ConsoleAcquire(

     Trace("====>\n");

+    status = STATUS_NOT_SUPPORTED;
+    if (!Context->UseConsole)
+        goto fail1;
+
     status = XENBUS_GNTTAB(Acquire, &Context->GnttabInterface);
     if (!NT_SUCCESS(status))
-        goto fail1;
+        goto fail2;

     status = ConsoleGetAddress(Context, &Address);
     if (!NT_SUCCESS(status))
-        goto fail2;
+        goto fail3;

     Context->Address = Address;
     Context->Shared = (struct xencons_interface 
*)MmMapIoSpace(Context->Address,
@@ -706,19 +713,19 @@ ConsoleAcquire(
                                                                MmCached);
     status = STATUS_UNSUCCESSFUL;
     if (Context->Shared == NULL)
-        goto fail3;
+        goto fail4;

     status = XENBUS_EVTCHN(Acquire, &Context->EvtchnInterface);
     if (!NT_SUCCESS(status))
-        goto fail4;
+        goto fail5;

     status = ConsoleEnable(Context);
     if (!NT_SUCCESS(status))
-        goto fail5;
+        goto fail6;

     status = XENBUS_SUSPEND(Acquire, &Context->SuspendInterface);
     if (!NT_SUCCESS(status))
-        goto fail6;
+        goto fail7;

     status = XENBUS_SUSPEND(Register,
                             &Context->SuspendInterface,
@@ -727,11 +734,11 @@ ConsoleAcquire(
                             Context,
                             &Context->SuspendCallbackLate);
     if (!NT_SUCCESS(status))
-        goto fail7;
+        goto fail8;

     status = XENBUS_DEBUG(Acquire, &Context->DebugInterface);
     if (!NT_SUCCESS(status))
-        goto fail8;
+        goto fail9;

     status = XENBUS_DEBUG(Register,
                           &Context->DebugInterface,
@@ -740,7 +747,7 @@ ConsoleAcquire(
                           Context,
                           &Context->DebugCallback);
     if (!NT_SUCCESS(status))
-        goto fail9;
+        goto fail10;

     Trace("<====\n");

@@ -749,50 +756,53 @@ done:

     return STATUS_SUCCESS;

-fail9:
-    Error("fail9\n");
+fail10:
+    Error("fail10\n");

     XENBUS_DEBUG(Release, &Context->DebugInterface);

-fail8:
-    Error("fail8\n");
+fail9:
+    Error("fail9\n");

     XENBUS_SUSPEND(Deregister,
                    &Context->SuspendInterface,
                    Context->SuspendCallbackLate);
     Context->SuspendCallbackLate = NULL;

+fail8:
+    Error("fail8\n");
+
+    XENBUS_SUSPEND(Release, &Context->SuspendInterface);
+
 fail7:
     Error("fail7\n");

-    XENBUS_SUSPEND(Release, &Context->SuspendInterface);
+    ConsoleDisable(Context);

 fail6:
     Error("fail6\n");

-    ConsoleDisable(Context);
+    XENBUS_EVTCHN(Release, &Context->EvtchnInterface);

 fail5:
     Error("fail5\n");

-    XENBUS_EVTCHN(Release, &Context->EvtchnInterface);
+    MmUnmapIoSpace(Context->Shared, PAGE_SIZE);
+    Context->Shared = NULL;

 fail4:
     Error("fail4\n");

-    MmUnmapIoSpace(Context->Shared, PAGE_SIZE);
-    Context->Shared = NULL;
+    Context->Address.QuadPart = 0;

 fail3:
     Error("fail3\n");

-    Context->Address.QuadPart = 0;
+    XENBUS_GNTTAB(Release, &Context->GnttabInterface);

 fail2:
     Error("fail2\n");

-    XENBUS_GNTTAB(Release, &Context->GnttabInterface);
-
 fail1:
     Error("fail1 (%08x)\n", status);

@@ -872,6 +882,8 @@ ConsoleInitialize(
     _Outptr_ PXENBUS_CONSOLE_CONTEXT    *Context
     )
 {
+    HANDLE                              ParametersKey;
+    ULONG                               UseConsole;
     NTSTATUS                            status;

     Trace("====>\n");
@@ -917,6 +929,19 @@ ConsoleInitialize(

     KeInitializeDpc(&(*Context)->Dpc, ConsoleDpc, *Context);

+    ParametersKey = DriverGetParametersKey();
+
+    status = RegistryQueryDwordValue(ParametersKey,
+                                     "UseConsole",
+                                     &UseConsole);
+    if (!NT_SUCCESS(status))
+        UseConsole = 1;
+
+    (*Context)->UseConsole = (UseConsole != 0) ? TRUE : FALSE;
+
+    if (!(*Context)->UseConsole)
+        Info("DISABLED\n");
+
     (*Context)->Fdo = Fdo;

     Trace("<====\n");
@@ -988,6 +1013,7 @@ ConsoleTeardown(
     Context->Dpcs = 0;
     Context->Events = 0;

+    Context->UseConsole = FALSE;
     Context->Fdo = NULL;

     RtlZeroMemory(&Context->Dpc, sizeof (KDPC));
--
2.56.0.windows.3



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



 


Rackspace

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