+++ /dev/null
-/* Copyright (c) Citrix Systems 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.
- */
-
-/*! \file emulated_interface.h
- \brief XENFILT EMULATED Interface
-
- This interface provides primitives to determine whether emulated
- devices or disks are present in the VM
-*/
-
-#ifndef _XENFILT_EMULATED_INTERFACE_H
-#define _XENFILT_EMULATED_INTERFACE_H
-
-#ifndef _WINDLL
-
-/*! \typedef XENFILT_EMULATED_ACQUIRE
- \brief Acquire a reference to the EMULATED interface
-
- \param Interface The interface header
-*/
-typedef NTSTATUS
-(*XENFILT_EMULATED_ACQUIRE)(
- IN PINTERFACE Interface
- );
-
-/*! \typedef XENFILT_EMULATED_RELEASE
- \brief Release a reference to the EMULATED interface
-
- \param Interface The interface header
-*/
-typedef VOID
-(*XENFILT_EMULATED_RELEASE)(
- IN PINTERFACE Interface
- );
-
-/*! \typedef XENFILT_EMULATED_IS_DEVICE_PRESENT
- \brief Determine whether a given device is present in the VM
-
- \param Interface The interface header
- \param DeviceID The DeviceID of the device
- \param InstanceID The (un-prefixed) InstanceID of the device or
- NULL to match any device instance
- \return TRUE if the specified device is present in the system or
- FALSE if it is not
-*/
-typedef BOOLEAN
-(*XENFILT_EMULATED_IS_DEVICE_PRESENT)(
- IN PVOID Context,
- IN PCHAR DeviceID,
- IN PCHAR InstanceID OPTIONAL
- );
-
-/*! \typedef XENFILT_EMULATED_IS_DISK_PRESENT
- \brief Determine whether a given disk is present in the VM
-
- \param Interface The interface header
- \param Controller The controller index of the HBA
- \param Target The target index of the disk
- \param Lun The Logical Unit Number of the disk within the target
- \return TRUE if the specified disk is present in the system or
- FALSE if it is not
-*/
-typedef BOOLEAN
-(*XENFILT_EMULATED_IS_DISK_PRESENT)(
- IN PVOID Context,
- IN ULONG Controller,
- IN ULONG Target,
- IN ULONG Lun
- );
-
-// {959027A1-FCCE-4E78-BCF4-637384F499C5}
-DEFINE_GUID(GUID_XENFILT_EMULATED_INTERFACE,
-0x959027a1, 0xfcce, 0x4e78, 0xbc, 0xf4, 0x63, 0x73, 0x84, 0xf4, 0x99, 0xc5);
-
-/*! \struct _XENFILT_EMULATED_INTERFACE_V1
- \brief EMULATED interface version 1
- \ingroup interfaces
-*/
-struct _XENFILT_EMULATED_INTERFACE_V1 {
- INTERFACE Interface;
- XENFILT_EMULATED_ACQUIRE EmulatedAcquire;
- XENFILT_EMULATED_RELEASE EmulatedRelease;
- XENFILT_EMULATED_IS_DEVICE_PRESENT EmulatedIsDevicePresent;
- XENFILT_EMULATED_IS_DISK_PRESENT EmulatedIsDiskPresent;
-};
-
-typedef struct _XENFILT_EMULATED_INTERFACE_V1 XENFILT_EMULATED_INTERFACE, *PXENFILT_EMULATED_INTERFACE;
-
-/*! \def XENFILT_EMULATED
- \brief Macro at assist in method invocation
-*/
-#define XENFILT_EMULATED(_Method, _Interface, ...) \
- (_Interface)->Emulated ## _Method((PINTERFACE)(_Interface), __VA_ARGS__)
-
-#endif // _WINDLL
-
-#define XENFILT_EMULATED_INTERFACE_VERSION_MIN 1
-#define XENFILT_EMULATED_INTERFACE_VERSION_MAX 1
-
-#endif // _XENFILT_EMULATED_INTERFACE_H
-
--- /dev/null
+/* Copyright (c) Citrix Systems 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.
+ */
+
+/*! \file unplug_interface.h
+ \brief XENBUS UNPLUG Interface
+
+ This interface provides a method to request emulated device unplug
+*/
+
+#ifndef _XENBUS_UNPLUG_INTERFACE_H
+#define _XENBUS_UNPLUG_INTERFACE_H
+
+#ifndef _WINDLL
+
+/*! \typedef XENBUS_UNPLUG_ACQUIRE
+ \brief Acquire a reference to the UNPLUG interface
+
+ \param Interface The interface header
+*/
+typedef NTSTATUS
+(*XENBUS_UNPLUG_ACQUIRE)(
+ IN PINTERFACE Interface
+ );
+
+/*! \typedef XENBUS_UNPLUG_RELEASE
+ \brief Release a reference to the UNPLUG interface
+
+ \param Interface The interface header
+*/
+typedef VOID
+(*XENBUS_UNPLUG_RELEASE)(
+ IN PINTERFACE Interface
+ );
+
+/*! \enum _XENBUS_UNPLUG_DEVICE_TYPE
+ \brief Type of device to be unplugged
+*/
+typedef enum _XENBUS_UNPLUG_DEVICE_TYPE {
+ XENBUS_UNPLUG_DEVICE_TYPE_INVALID = 0,
+ XENBUS_UNPLUG_DEVICE_TYPE_NICS, /*!< NICs */
+ XENBUS_UNPLUG_DEVICE_TYPE_DISKS, /*!< Disks */
+} XENBUS_UNPLUG_DEVICE_TYPE, *PXENBUS_UNPLUG_DEVICE_TYPE;
+
+/*! \typedef XENBUS_UNPLUG_REQUEST
+ \brief Request unplug of a type of emulated device
+
+ \param Interface The interface header
+ \param Type The type of device
+ \param Make Set to TRUE if the request is being made, FALSE if it is
+ being revoked.
+*/
+typedef VOID
+(*XENBUS_UNPLUG_REQUEST)(
+ IN PINTERFACE Interface,
+ IN XENBUS_UNPLUG_DEVICE_TYPE Type,
+ IN BOOLEAN Make
+ );
+
+// {73db6517-3d06-4937-989f-199b7501e229}
+DEFINE_GUID(GUID_XENBUS_UNPLUG_INTERFACE,
+0x73db6517, 0x3d06, 0x4937, 0x98, 0x9f, 0x19, 0x9b, 0x75, 0x01, 0xe2, 0x29);
+
+/*! \struct _XENBUS_UNPLUG_INTERFACE_V1
+ \brief UNPLUG interface version 1
+ \ingroup interfaces
+*/
+struct _XENBUS_UNPLUG_INTERFACE_V1 {
+ INTERFACE Interface;
+ XENBUS_UNPLUG_ACQUIRE UnplugAcquire;
+ XENBUS_UNPLUG_RELEASE UnplugRelease;
+ XENBUS_UNPLUG_REQUEST UnplugRequest;
+};
+
+typedef struct _XENBUS_UNPLUG_INTERFACE_V1 XENBUS_UNPLUG_INTERFACE, *PXENBUS_UNPLUG_INTERFACE;
+
+/*! \def XENBUS_UNPLUG
+ \brief Macro at assist in method invocation
+*/
+#define XENBUS_UNPLUG(_Method, _Interface, ...) \
+ (_Interface)->Unplug ## _Method((PINTERFACE)(_Interface), __VA_ARGS__)
+
+#endif // _WINDLL
+
+#define XENBUS_UNPLUG_INTERFACE_VERSION_MIN 1
+#define XENBUS_UNPLUG_INTERFACE_VERSION_MAX 1
+
+#endif // _XENBUS_UNPLUG_INTERFACE_H
+
; DisplayName Section DeviceID
; ----------- ------- --------
-%XenVifDesc% =XenVif_Inst, XENBUS\VEN_XSC000&DEV_VIF&REV_08000008
-%XenVifDesc% =XenVif_Inst, XENBUS\VEN_XS0001&DEV_VIF&REV_08000008
-%XenVifDesc% =XenVif_Inst, XENBUS\VEN_XS0002&DEV_VIF&REV_08000008
+%XenVifDesc% =XenVif_Inst, XENBUS\VEN_XSC000&DEV_VIF&REV_08000009
+%XenVifDesc% =XenVif_Inst, XENBUS\VEN_XS0001&DEV_VIF&REV_08000009
+%XenVifDesc% =XenVif_Inst, XENBUS\VEN_XS0002&DEV_VIF&REV_08000009
[XenVif_Inst]
CopyFiles=XenVif_Copyfiles
#include <store_interface.h>
#include <gnttab_interface.h>
#include <suspend_interface.h>
-#include <emulated_interface.h>
+#include <unplug_interface.h>
#include "driver.h"
#include "registry.h"
XENBUS_RANGE_SET_INTERFACE RangeSetInterface;
XENBUS_CACHE_INTERFACE CacheInterface;
XENBUS_GNTTAB_INTERFACE GnttabInterface;
+ XENBUS_UNPLUG_INTERFACE UnplugInterface;
PXENBUS_SUSPEND_CALLBACK SuspendCallbackLate;
};
DEFINE_FDO_GET_INTERFACE(RangeSet, PXENBUS_RANGE_SET_INTERFACE)
DEFINE_FDO_GET_INTERFACE(Cache, PXENBUS_CACHE_INTERFACE)
DEFINE_FDO_GET_INTERFACE(Gnttab, PXENBUS_GNTTAB_INTERFACE)
+DEFINE_FDO_GET_INTERFACE(Unplug, PXENBUS_UNPLUG_INTERFACE)
NTSTATUS
FdoCreate(
if (!NT_SUCCESS(status))
goto fail13;
+ status = FDO_QUERY_INTERFACE(Fdo,
+ XENBUS,
+ UNPLUG,
+ (PINTERFACE)&Fdo->UnplugInterface,
+ sizeof (Fdo->UnplugInterface),
+ FALSE);
+ if (!NT_SUCCESS(status))
+ goto fail14;
+
Dx->Fdo = Fdo;
InitializeMutex(&Fdo->Mutex);
FunctionDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
return STATUS_SUCCESS;
+fail14:
+ Error("fail14\n");
+
+ RtlZeroMemory(&Fdo->UnplugInterface,
+ sizeof (XENBUS_UNPLUG_INTERFACE));
+
fail13:
Error("fail13\n");
Dx->Fdo = NULL;
+ RtlZeroMemory(&Fdo->UnplugInterface,
+ sizeof (XENBUS_UNPLUG_INTERFACE));
+
RtlZeroMemory(&Fdo->GnttabInterface,
sizeof (XENBUS_GNTTAB_INTERFACE));
#include <range_set_interface.h>
#include <cache_interface.h>
#include <gnttab_interface.h>
-#include <emulated_interface.h>
+#include <unplug_interface.h>
#include "driver.h"
#include "types.h"
DECLARE_FDO_GET_INTERFACE(RangeSet, PXENBUS_RANGE_SET_INTERFACE)
DECLARE_FDO_GET_INTERFACE(Cache, PXENBUS_CACHE_INTERFACE)
DECLARE_FDO_GET_INTERFACE(Gnttab, PXENBUS_GNTTAB_INTERFACE)
-DECLARE_FDO_GET_INTERFACE(Emulated, PXENFILT_EMULATED_INTERFACE)
+DECLARE_FDO_GET_INTERFACE(Unplug, PXENBUS_UNPLUG_INTERFACE)
extern NTSTATUS
FdoCreate(
#include <bcrypt.h>
#include <xen.h>
-#include <store_interface.h>
-#include <emulated_interface.h>
+#include <suspend_interface.h>
+#include <unplug_interface.h>
#include "names.h"
#include "fdo.h"
XENBUS_SUSPEND_INTERFACE SuspendInterface;
PXENBUS_SUSPEND_CALLBACK SuspendCallbackLate;
+ XENBUS_UNPLUG_INTERFACE UnplugInterface;
+
PXENVIF_FRONTEND Frontend;
PXENVIF_VIF_CONTEXT VifContext;
KeLowerIrql(Irql);
+ XENBUS_UNPLUG(Request,
+ &Pdo->UnplugInterface,
+ XENBUS_UNPLUG_DEVICE_TYPE_NICS,
+ TRUE);
+
return STATUS_SUCCESS;
fail3:
ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+ XENBUS_UNPLUG(Request,
+ &Pdo->UnplugInterface,
+ XENBUS_UNPLUG_DEVICE_TYPE_NICS,
+ FALSE);
+
KeRaiseIrql(DISPATCH_LEVEL, &Irql);
XENBUS_SUSPEND(Deregister,
if (DriverIsRebootRequested())
goto fail1;
+ status = XENBUS_UNPLUG(Acquire, &Pdo->UnplugInterface);
+ if (!NT_SUCCESS(status))
+ goto fail2;
+
status = RegistryOpenSoftwareKey(__PdoGetDeviceObject(Pdo),
KEY_ALL_ACCESS,
&Key);
if (!NT_SUCCESS(status))
- goto fail2;
+ goto fail3;
status = __PdoSetCurrentAddress(Pdo, Key);
if (!NT_SUCCESS(status))
- goto fail3;
+ goto fail4;
status = LinkGetRoutineAddress("netio.sys",
"GetIfTable2",
(PVOID *)&__GetIfTable2);
if (!NT_SUCCESS(status))
- goto fail4;
+ goto fail5;
status = LinkGetRoutineAddress("netio.sys",
"FreeMibTable",
(PVOID *)&__FreeMibTable);
if (!NT_SUCCESS(status))
- goto fail5;
+ goto fail6;
status = __GetIfTable2(&Table);
if (!NT_SUCCESS(status))
- goto fail6;
+ goto fail7;
//
// Look for a network interface with the same permanent address
continue;
status = STATUS_UNSUCCESSFUL;
- goto fail7;
+ goto fail8;
}
//
status = PdoD3ToD0(Pdo);
if (!NT_SUCCESS(status))
- goto fail8;
+ goto fail9;
__PdoSetDevicePnpState(Pdo, Started);
return STATUS_SUCCESS;
-fail8:
- Error("fail8\n");
+fail9:
+ Error("fail9\n");
__FreeMibTable(Table);
goto fail6;
-fail7:
- Error("fail7\n");
+fail8:
+ Error("fail8\n");
(VOID) SettingsSave(Key,
Row->Alias,
&Row->InterfaceGuid,
&Row->InterfaceLuid);
+ XENBUS_UNPLUG(Request,
+ &Pdo->UnplugInterface,
+ XENBUS_UNPLUG_DEVICE_TYPE_NICS,
+ TRUE);
+
DriverRequestReboot();
__FreeMibTable(Table);
+fail7:
+ Error("fail7\n");
+
fail6:
Error("fail6\n");
fail5:
Error("fail5\n");
+ RtlZeroMemory(&Pdo->CurrentAddress, sizeof (ETHERNET_ADDRESS));
+
fail4:
Error("fail4\n");
- RtlZeroMemory(&Pdo->CurrentAddress, sizeof (ETHERNET_ADDRESS));
+ RegistryCloseKey(Key);
fail3:
Error("fail3\n");
- RegistryCloseKey(Key);
+ XENBUS_UNPLUG(Release, &Pdo->UnplugInterface);
fail2:
Error("fail2\n");
RtlZeroMemory(&Pdo->CurrentAddress, sizeof (ETHERNET_ADDRESS));
+ XENBUS_UNPLUG(Release, &Pdo->UnplugInterface);
+
__PdoSetDevicePnpState(Pdo, Stopped);
status = STATUS_SUCCESS;
done:
RtlZeroMemory(&Pdo->CurrentAddress, sizeof (ETHERNET_ADDRESS));
+ XENBUS_UNPLUG(Release, &Pdo->UnplugInterface);
+
NeedInvalidate = FALSE;
FdoAcquireMutex(Fdo);
if (!NT_SUCCESS(status))
goto fail9;
- FdoGetSuspendInterface(Fdo,&Pdo->SuspendInterface);
+ FdoGetSuspendInterface(Fdo, &Pdo->SuspendInterface);
+ FdoGetUnplugInterface(Fdo, &Pdo->UnplugInterface);
Dx->Pdo = Pdo;
Dx->Pdo = NULL;
+ RtlZeroMemory(&Pdo->UnplugInterface,
+ sizeof (XENBUS_UNPLUG_INTERFACE));
+
RtlZeroMemory(&Pdo->SuspendInterface,
sizeof (XENBUS_SUSPEND_INTERFACE));
Dx->Pdo = NULL;
+ RtlZeroMemory(&Pdo->UnplugInterface,
+ sizeof (XENBUS_UNPLUG_INTERFACE));
+
RtlZeroMemory(&Pdo->SuspendInterface,
sizeof (XENBUS_SUSPEND_INTERFACE));