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

[PATCH xenbus 09/12] Slightly modify the way balloon initialization is done in fdo.c



From: Paul Durrant <pdurrant@xxxxxxxxxx>

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 <pdurrant@xxxxxxxxxx>
---
 src/xenbus/fdo.c | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index 831ff463d6ce..231748f14bdf 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;
-- 
2.17.1




 


Rackspace

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