From: Paul Durrant Date: Thu, 19 Nov 2020 09:58:11 +0000 (+0000) Subject: Slightly modify the way balloon initialization is done in fdo.c X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=568f24fdff93caf82a05ce6f2d62f61098f00d07;p=pvdrivers%2Fwin%2Fxenbus.git Slightly modify the way balloon initialization is done in fdo.c Currently only one system start option "XEN:BALLOON=" modifies the behaviour of FDO creation. A subsequent patch will add another option. This patch is to avoid inconsistency in the code when that is done. The FdoIsBalloonEnabled() function is replaced with FdoBalloonInitialize(), which inlines what FdoCreate() would previously have done when FdoIsBalloonEnabled() returned TRUE. A matching FdoBalloonTeardown() function is also introduced for the sake of symmetry. Signed-off-by: Paul Durrant --- diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c index 831ff46..231748f 100644 --- a/src/xenbus/fdo.c +++ b/src/xenbus/fdo.c @@ -5431,8 +5431,8 @@ __FdoFreeBuffer( Fdo->Buffer = NULL; } -static BOOLEAN -FdoIsBalloonEnabled( +static NTSTATUS +FdoBalloonInitialize( IN PXENBUS_FDO Fdo ) { @@ -5442,8 +5442,6 @@ FdoIsBalloonEnabled( BOOLEAN Enabled; NTSTATUS status; - UNREFERENCED_PARAMETER(Fdo); - Enabled = TRUE; status = RegistryQuerySystemStartOption(Key, &Option); @@ -5458,9 +5456,22 @@ FdoIsBalloonEnabled( RegistryFreeSzValue(Option); done: - return Enabled; + return Enabled ? + BalloonInitialize(Fdo, &Fdo->BalloonContext) : + STATUS_SUCCESS; } +static VOID +FdoBalloonTeardown( + IN PXENBUS_FDO Fdo + ) +{ + if (Fdo->BalloonContext == NULL) + return; + + BalloonTeardown(Fdo->BalloonContext); + Fdo->BalloonContext = NULL; +} NTSTATUS FdoCreate( IN PDEVICE_OBJECT PhysicalDeviceObject @@ -5581,11 +5592,9 @@ FdoCreate( if (!NT_SUCCESS(status)) goto fail19; - if (FdoIsBalloonEnabled(Fdo)) { - status = BalloonInitialize(Fdo, &Fdo->BalloonContext); - if (!NT_SUCCESS(status)) - goto fail20; - } + status = FdoBalloonInitialize(Fdo); + if (!NT_SUCCESS(status)) + goto fail20; status = DebugGetInterface(__FdoGetDebugContext(Fdo), XENBUS_DEBUG_INTERFACE_VERSION_MAX, @@ -5826,10 +5835,7 @@ FdoDestroy( RtlZeroMemory(&Fdo->DebugInterface, sizeof (XENBUS_DEBUG_INTERFACE)); - if (Fdo->BalloonContext != NULL) { - BalloonTeardown(Fdo->BalloonContext); - Fdo->BalloonContext = NULL; - } + FdoBalloonTeardown(Fdo); UnplugTeardown(Fdo->UnplugContext); Fdo->UnplugContext = NULL;