|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] [RFC] Interface compatibility example - for comment.
This patch is an example of implementing *client-side* interface
compatibility, in addition to the existing server-side mechanism.
Two-way interface compatiblity would reduce the number of cases
where we need to increment the Device-ID, which is likely to
reduce the frequency of upgrade problems, and/or lost IP configuration.
Further details on exact compatibility and upgrade cases solved by this
pending (tests currently in progress).
Signed-off-by: Martin Harvey <martin.harvey@xxxxxxxxxx>
---
include/cache_interface.h | 2 +-
include/evtchn_interface.h | 2 +-
include/gnttab_interface.h | 2 +-
include/interface_compat.h | 119 +++++++++++++++++++++++
include/interface_compat_xeniface.h | 81 +++++++++++++++
include/shared_info_interface.h | 2 +-
include/store_interface.h | 2 +-
include/suspend_interface.h | 2 +-
src/xeniface/fdo.c | 70 +++++--------
src/xeniface/fdo.h | 13 +--
src/xeniface/interface_compat.c | 117 ++++++++++++++++++++++
src/xeniface/interface_compat_xeniface.c | 68 +++++++++++++
vs2015/xeniface/xeniface.vcxproj | 2 +
vs2017/xeniface/xeniface.vcxproj | 2 +
vs2019/xeniface/xeniface.vcxproj | 2 +
15 files changed, 430 insertions(+), 56 deletions(-)
create mode 100644 include/interface_compat.h
create mode 100644 include/interface_compat_xeniface.h
create mode 100644 src/xeniface/interface_compat.c
create mode 100644 src/xeniface/interface_compat_xeniface.c
diff --git a/include/cache_interface.h b/include/cache_interface.h
index 048e06b..48e0809 100644
--- a/include/cache_interface.h
+++ b/include/cache_interface.h
@@ -253,7 +253,7 @@ typedef struct _XENBUS_CACHE_INTERFACE_V2
XENBUS_CACHE_INTERFACE, *PXENBUS_CACHE
\brief Macro at assist in method invocation
*/
#define XENBUS_CACHE(_Method, _Interface, ...) \
- (_Interface)->Cache ## _Method((PINTERFACE)(_Interface), __VA_ARGS__)
+ (_Interface)->CompatInterface.Cache ##
_Method((PINTERFACE)(&(_Interface)->CompatInterface), __VA_ARGS__)
#endif // _WINDLL
diff --git a/include/evtchn_interface.h b/include/evtchn_interface.h
index dbe8745..6eee5bd 100644
--- a/include/evtchn_interface.h
+++ b/include/evtchn_interface.h
@@ -350,7 +350,7 @@ typedef struct _XENBUS_EVTCHN_INTERFACE_V9
XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVT
\brief Macro at assist in method invocation
*/
#define XENBUS_EVTCHN(_Method, _Interface, ...) \
- (_Interface)->Evtchn ## _Method((PINTERFACE)(_Interface), __VA_ARGS__)
+ (_Interface)->CompatInterface.Evtchn ##
_Method((PINTERFACE)(&(_Interface)->CompatInterface), __VA_ARGS__)
#endif // _WINDLL
diff --git a/include/gnttab_interface.h b/include/gnttab_interface.h
index 865c4f3..09fa970 100644
--- a/include/gnttab_interface.h
+++ b/include/gnttab_interface.h
@@ -292,7 +292,7 @@ typedef struct _XENBUS_GNTTAB_INTERFACE_V4
XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNT
\brief Macro at assist in method invocation
*/
#define XENBUS_GNTTAB(_Method, _Interface, ...) \
- (_Interface)->Gnttab ## _Method((PINTERFACE)(_Interface), __VA_ARGS__)
+ (_Interface)->CompatInterface.Gnttab ##
_Method((PINTERFACE)(&(_Interface)->CompatInterface), __VA_ARGS__)
#endif // _WINDLL
diff --git a/include/interface_compat.h b/include/interface_compat.h
new file mode 100644
index 0000000..c91ceb6
--- /dev/null
+++ b/include/interface_compat.h
@@ -0,0 +1,119 @@
+/* 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 interface_compat.h
+ \brief Common interface compatibility functions, allowing for client side
stubbing and xlation of interfaces.
+*/
+
+#ifndef _INTERFACE_COMPAT_H
+#define _INTERFACE_COMPAT_H
+
+struct _XEN_INTERFACE_COMPAT{
+ PINTERFACE ImportedInterface;
+ ULONG ImportedInterfaceMaxSize;
+ PINTERFACE CompatInterface;
+ ULONG CompatInterfaceMaxSize;
+};
+
+typedef struct _XEN_INTERFACE_COMPAT XEN_INTERFACE_COMPAT,
*PXEN_INTERFACE_COMPAT;
+
+#define DEFINE_COMPAT_STRUCT(_ProviderName,_InterfaceName)
\
+
\
+typedef struct _ ## _ProviderName ## _ ## _InterfaceName ##_INTERFACE_COMPAT {
\
+ XEN_INTERFACE_COMPAT Compat;
\
+ _ProviderName ## _ ## _InterfaceName ## _INTERFACE
ImportedInterface; \
+ _ProviderName ## _ ## _InterfaceName ## _INTERFACE
CompatInterface; \
+} _ProviderName ## _ ## _InterfaceName ## _INTERFACE_COMPAT, *P ##
_ProviderName ## _ ## _InterfaceName ## _INTERFACE_COMPAT;
+
+#define DECL_COMPAT_INIT(_ProviderName,_InterfaceName)
\
+VOID _ProviderName ## ## _ ## _InterfaceName ## _ ## CompatInit (
\
+ IN OUT PXEN_INTERFACE_COMPAT IntfCompat
\
+);
+
+#define IMPL_COMPAT_INIT(_ProviderName,_InterfaceName)
\
+VOID _ProviderName ## ## _ ## _InterfaceName ## _ ## CompatInit (
\
+ IN OUT PXEN_INTERFACE_COMPAT IntfCompat
\
+) {
\
+ P ## _ProviderName ## _ ## _InterfaceName ## _INTERFACE_COMPAT FullCompat;
\
+ FullCompat = (P ## _ProviderName ## _ ## _InterfaceName ##
_INTERFACE_COMPAT) IntfCompat; \
+ FullCompat->Compat.ImportedInterface =
(PINTERFACE)&FullCompat->ImportedInterface;
\
+ FullCompat->Compat.ImportedInterfaceMaxSize =
sizeof(FullCompat->ImportedInterface); \
+ FullCompat->Compat.CompatInterface =
(PINTERFACE)&FullCompat->CompatInterface;
\
+ FullCompat->Compat.CompatInterfaceMaxSize =
sizeof(FullCompat->CompatInterface);
\
+ RtlZeroMemory(&FullCompat->ImportedInterface,
sizeof(FullCompat->ImportedInterface)); \
+ RtlZeroMemory(&FullCompat->CompatInterface,
sizeof(FullCompat->CompatInterface));
\
+}
+
+#define DECL_FIXUP(_ProviderName, _InterfaceName)
\
+NTSTATUS _ProviderName ## _ ## _InterfaceName ## _ ## CompatFixup (
\
+ IN OUT PXEN_INTERFACE_COMPAT IntfCompat
\
+);
+
+#define IMPL_NULL_FIXUP(_ProviderName, _InterfaceName)
\
+NTSTATUS _ProviderName ## _ ##_InterfaceName ## _ ## CompatFixup (
\
+ IN OUT PXEN_INTERFACE_COMPAT IntfCompat
\
+) {
\
+ UNREFERENCED_PARAMETER(IntfCompat);
\
+ return STATUS_INTERNAL_ERROR;
\
+}
+
+/* Encapsulated query function */
+typedef NTSTATUS (*XEN_COMPAT_QUERY_FUNC) (
+ IN PVOID Fdo, /* e.g. PXENIFACE_FDO,
PXENVIF_FDO, etc. */
+ IN const GUID *Guid, /* As in existing Query for
interface functions ... */
+ IN ULONG Version,
+ OUT PINTERFACE Interface,
+ IN ULONG Size,
+ IN BOOLEAN Optional
+ );
+
+/* Helper fixup function */
+typedef NTSTATUS (*XEN_COMPAT_FIXUP_FUNC) (
+ IN OUT PXEN_INTERFACE_COMPAT IntfCompat
+ );
+
+/* Helper init function */
+typedef VOID (*XEN_COMPAT_INIT_FUNC) (
+ IN OUT PXEN_INTERFACE_COMPAT IntfCompat
+);
+
+NTSTATUS FdoQueryInterfaceCompat(
+ IN XEN_COMPAT_INIT_FUNC CompatInit,
+ IN XEN_COMPAT_QUERY_FUNC InterfaceQuery,
+ IN XEN_COMPAT_FIXUP_FUNC CompatFixup,
+ IN PVOID FdoStruct,
+ IN const GUID *Guid,
+ IN ULONG VersionMax,
+ IN ULONG VersionMin,
+ IN BOOLEAN Optional,
+ IN OUT PXEN_INTERFACE_COMPAT IntfCompat);
+
+#endif
\ No newline at end of file
diff --git a/include/interface_compat_xeniface.h
b/include/interface_compat_xeniface.h
new file mode 100644
index 0000000..7f45a17
--- /dev/null
+++ b/include/interface_compat_xeniface.h
@@ -0,0 +1,81 @@
+/* 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 interface_compat_xeniface.h
+ \brief Xeniface specific interface compatibility functions.
+*/
+
+#ifndef _INTERFACE_COMPAT_XENIFACE_H
+#define _INTERFACE_COMPAT_XENIFACE_H
+
+#include <interface_compat.h>
+#include <store_interface.h>
+#include <suspend_interface.h>
+#include <shared_info_interface.h>
+#include <evtchn_interface.h>
+#include <gnttab_interface.h>
+
+#define FDO_QUERY_INTERFACE_COMPAT(
\
+ _Fdo,
\
+ _ProviderName,
\
+ _InterfaceName,
\
+ _Optional,
\
+ _Compat)
\
+ FdoQueryInterfaceCompat(
\
+ _ProviderName ## _ ## _InterfaceName ## _ ## CompatInit,
\
+ FdoQueryInterface,
\
+ _ProviderName ## _ ## _InterfaceName ## _ ##
CompatFixup, \
+ (_Fdo),
\
+ &GUID_ ## _ProviderName ## _ ## _InterfaceName ##
_INTERFACE, \
+ _ProviderName ## _ ## _InterfaceName ##
_INTERFACE_VERSION_MAX, \
+ _ProviderName ## _ ## _InterfaceName ##
_INTERFACE_VERSION_MIN, \
+ (_Optional),
\
+ &(_Compat)->Compat)
+
+DEFINE_COMPAT_STRUCT(XENBUS, STORE); /*
XENBUS_STORE_INTERFACE_COMPAT */
+DEFINE_COMPAT_STRUCT(XENBUS, SUSPEND); /*
XENBUS_SUSPEND_INTERFACE_COMPAT */
+DEFINE_COMPAT_STRUCT(XENBUS, SHARED_INFO); /*
XENBUS_SHARED_INFO_INTERFACE_COMPAT */
+DEFINE_COMPAT_STRUCT(XENBUS, EVTCHN); /*
XENBUS_EVTCHN_INTERFACE_COMPAT */
+DEFINE_COMPAT_STRUCT(XENBUS, GNTTAB); /*
XENBUS_GNTTAB_INTERFACE_COMPAT */
+
+DECL_COMPAT_INIT(XENBUS, STORE);
+DECL_COMPAT_INIT(XENBUS, SUSPEND);
+DECL_COMPAT_INIT(XENBUS, SHARED_INFO);
+DECL_COMPAT_INIT(XENBUS, EVTCHN);
+DECL_COMPAT_INIT(XENBUS, GNTTAB);
+
+DECL_FIXUP(XENBUS, STORE);
+DECL_FIXUP(XENBUS, SUSPEND);
+DECL_FIXUP(XENBUS, SHARED_INFO);
+DECL_FIXUP(XENBUS, EVTCHN);
+DECL_FIXUP(XENBUS, GNTTAB);
+
+#endif
\ No newline at end of file
diff --git a/include/shared_info_interface.h b/include/shared_info_interface.h
index 27910b0..fba90c7 100644
--- a/include/shared_info_interface.h
+++ b/include/shared_info_interface.h
@@ -200,7 +200,7 @@ typedef struct _XENBUS_SHARED_INFO_INTERFACE_V4
XENBUS_SHARED_INFO_INTERFACE, *P
\brief Macro at assist in method invocation
*/
#define XENBUS_SHARED_INFO(_Method, _Interface, ...) \
- (_Interface)->SharedInfo ## _Method((PINTERFACE)(_Interface), __VA_ARGS__)
+ (_Interface)->CompatInterface.SharedInfo ##
_Method((PINTERFACE)(&(_Interface)->CompatInterface), __VA_ARGS__)
#endif // _WINDLL
diff --git a/include/store_interface.h b/include/store_interface.h
index e1251dd..084da60 100644
--- a/include/store_interface.h
+++ b/include/store_interface.h
@@ -317,7 +317,7 @@ typedef struct _XENBUS_STORE_INTERFACE_V2
XENBUS_STORE_INTERFACE, *PXENBUS_STORE
\brief Macro at assist in method invocation
*/
#define XENBUS_STORE(_Method, _Interface, ...) \
- (_Interface)->Store ## _Method((PINTERFACE)(_Interface), __VA_ARGS__)
+ (_Interface)->CompatInterface.Store ##
_Method((PINTERFACE)(&(_Interface)->CompatInterface), __VA_ARGS__)
#endif // _WINDLL
diff --git a/include/suspend_interface.h b/include/suspend_interface.h
index cbe11ab..6fdb777 100644
--- a/include/suspend_interface.h
+++ b/include/suspend_interface.h
@@ -166,7 +166,7 @@ typedef struct _XENBUS_SUSPEND_INTERFACE_V1
XENBUS_SUSPEND_INTERFACE, *PXENBUS_S
\brief Macro at assist in method invocation
*/
#define XENBUS_SUSPEND(_Method, _Interface, ...) \
- (_Interface)-> ## _Method((PINTERFACE)(_Interface), __VA_ARGS__)
+ (_Interface)->CompatInterface. ##
_Method((PINTERFACE)(&(_Interface)->CompatInterface), __VA_ARGS__)
#endif // _WINDLL
diff --git a/src/xeniface/fdo.c b/src/xeniface/fdo.c
index 6aabf96..cb16477 100644
--- a/src/xeniface/fdo.c
+++ b/src/xeniface/fdo.c
@@ -55,6 +55,7 @@
#include "wmi.h"
#include "xeniface_ioctls.h"
#include "irp_queue.h"
+#include "interface_compat_xeniface.h"
#define FDO_POOL 'ODF'
@@ -2447,20 +2448,6 @@ fail1:
return status;
}
-#define FDO_QUERY_INTERFACE(
\
- _Fdo,
\
- _ProviderName,
\
- _InterfaceName,
\
- _Interface,
\
- _Size,
\
- _Optional)
\
- FdoQueryInterface((_Fdo),
\
- &GUID_ ## _ProviderName ## _ ## _InterfaceName ##
_INTERFACE, \
- _ProviderName ## _ ## _InterfaceName ##
_INTERFACE_VERSION_MAX, \
- (_Interface),
\
- (_Size),
\
- (_Optional))
-
NTSTATUS
FdoCreate(
IN PDEVICE_OBJECT PhysicalDeviceObject
@@ -2535,48 +2522,43 @@ FdoCreate(
if (!NT_SUCCESS(status))
goto fail7;
- status = FDO_QUERY_INTERFACE(Fdo,
+ status = FDO_QUERY_INTERFACE_COMPAT(Fdo,
XENBUS,
SUSPEND,
- (PINTERFACE)&Fdo->SuspendInterface,
- sizeof (Fdo->SuspendInterface),
- FALSE);
+ FALSE,
+ &Fdo->SuspendInterface);
if (!NT_SUCCESS(status))
goto fail8;
- status = FDO_QUERY_INTERFACE(Fdo,
+ status = FDO_QUERY_INTERFACE_COMPAT(Fdo,
XENBUS,
SHARED_INFO,
- (PINTERFACE)&Fdo->SharedInfoInterface,
- sizeof (Fdo->SharedInfoInterface),
- FALSE);
+ FALSE,
+ &Fdo->SharedInfoInterface);
if (!NT_SUCCESS(status))
goto fail9;
- status = FDO_QUERY_INTERFACE(Fdo,
+ status = FDO_QUERY_INTERFACE_COMPAT(Fdo,
XENBUS,
STORE,
- (PINTERFACE)&Fdo->StoreInterface,
- sizeof (Fdo->StoreInterface),
- FALSE);
+ FALSE,
+ &Fdo->StoreInterface);
if (!NT_SUCCESS(status))
goto fail10;
- status = FDO_QUERY_INTERFACE(Fdo,
+ status = FDO_QUERY_INTERFACE_COMPAT(Fdo,
XENBUS,
EVTCHN,
- (PINTERFACE)&Fdo->EvtchnInterface,
- sizeof (Fdo->EvtchnInterface),
- FALSE);
+ FALSE,
+ &Fdo->EvtchnInterface);
if (!NT_SUCCESS(status))
goto fail11;
- status = FDO_QUERY_INTERFACE(Fdo,
+ status = FDO_QUERY_INTERFACE_COMPAT(Fdo,
XENBUS,
GNTTAB,
- (PINTERFACE)&Fdo->GnttabInterface,
- sizeof (Fdo->GnttabInterface),
- FALSE);
+ FALSE,
+ &Fdo->GnttabInterface);
if (!NT_SUCCESS(status))
goto fail12;
@@ -2662,31 +2644,31 @@ fail13:
Error("fail13\n");
RtlZeroMemory(&Fdo->GnttabInterface,
- sizeof (XENBUS_GNTTAB_INTERFACE));
+ sizeof (Fdo->GnttabInterface));
fail12:
Error("fail12\n");
RtlZeroMemory(&Fdo->EvtchnInterface,
- sizeof (XENBUS_EVTCHN_INTERFACE));
+ sizeof (Fdo->EvtchnInterface));
fail11:
Error("fail11\n");
RtlZeroMemory(&Fdo->StoreInterface,
- sizeof (XENBUS_STORE_INTERFACE));
+ sizeof (Fdo->StoreInterface));
fail10:
Error("fail10\n");
RtlZeroMemory(&Fdo->SharedInfoInterface,
- sizeof (XENBUS_SHARED_INFO_INTERFACE));
+ sizeof (Fdo->SharedInfoInterface));
fail9:
Error("fail8\n");
RtlZeroMemory(&Fdo->SuspendInterface,
- sizeof (XENBUS_SUSPEND_INTERFACE));
+ sizeof (Fdo->SuspendInterface));
fail8:
Error("fail8\n");
@@ -2780,19 +2762,19 @@ FdoDestroy(
Fdo->InterfacesAcquired = FALSE;
RtlZeroMemory(&Fdo->GnttabInterface,
- sizeof (XENBUS_GNTTAB_INTERFACE));
+ sizeof (Fdo->GnttabInterface));
RtlZeroMemory(&Fdo->EvtchnInterface,
- sizeof (XENBUS_EVTCHN_INTERFACE));
+ sizeof (Fdo->EvtchnInterface));
RtlZeroMemory(&Fdo->StoreInterface,
- sizeof (XENBUS_STORE_INTERFACE));
+ sizeof (Fdo->StoreInterface));
RtlZeroMemory(&Fdo->SharedInfoInterface,
- sizeof (XENBUS_SHARED_INFO_INTERFACE));
+ sizeof (Fdo->SharedInfoInterface));
RtlZeroMemory(&Fdo->SuspendInterface,
- sizeof (XENBUS_SUSPEND_INTERFACE));
+ sizeof (Fdo->SuspendInterface));
ThreadAlert(Fdo->registryThread);
ThreadJoin(Fdo->registryThread);
diff --git a/src/xeniface/fdo.h b/src/xeniface/fdo.h
index 1fedc09..7f3f237 100644
--- a/src/xeniface/fdo.h
+++ b/src/xeniface/fdo.h
@@ -38,6 +38,7 @@
#include <gnttab_interface.h>
#include <suspend_interface.h>
#include <shared_info_interface.h>
+#include <interface_compat_xeniface.h>
#include "driver.h"
#include "types.h"
@@ -75,12 +76,12 @@ typedef struct _XENIFACE_FDO {
FDO_RESOURCE Resource[RESOURCE_COUNT];
- XENBUS_STORE_INTERFACE StoreInterface;
- XENBUS_SUSPEND_INTERFACE SuspendInterface;
- XENBUS_SHARED_INFO_INTERFACE SharedInfoInterface;
- XENBUS_EVTCHN_INTERFACE EvtchnInterface;
- XENBUS_GNTTAB_INTERFACE GnttabInterface;
- PXENBUS_SUSPEND_CALLBACK SuspendCallbackLate;
+ XENBUS_STORE_INTERFACE_COMPAT StoreInterface;
+ XENBUS_SUSPEND_INTERFACE_COMPAT SuspendInterface;
+ XENBUS_SHARED_INFO_INTERFACE_COMPAT SharedInfoInterface;
+ XENBUS_EVTCHN_INTERFACE_COMPAT EvtchnInterface;
+ XENBUS_GNTTAB_INTERFACE_COMPAT GnttabInterface;
+ PXENBUS_SUSPEND_CALLBACK SuspendCallbackLate;
BOOLEAN InterfacesAcquired;
diff --git a/src/xeniface/interface_compat.c b/src/xeniface/interface_compat.c
new file mode 100644
index 0000000..794eac5
--- /dev/null
+++ b/src/xeniface/interface_compat.c
@@ -0,0 +1,117 @@
+/* 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 interface_compat.c
+ \brief Common interface compatibility functions, allowing for client side
stubbing and xlation of interfaces.
+*/
+
+#include <ntifs.h>
+#include "interface_compat.h"
+#include "log.h"
+
+NTSTATUS FdoQueryInterfaceCompat(
+ IN XEN_COMPAT_INIT_FUNC CompatInit,
+ IN XEN_COMPAT_QUERY_FUNC InterfaceQuery,
+ IN XEN_COMPAT_FIXUP_FUNC CompatFixup,
+ IN PVOID FdoStruct,
+ IN const GUID *Guid,
+ IN ULONG VersionMax,
+ IN ULONG VersionMin,
+ IN BOOLEAN Optional,
+ IN OUT PXEN_INTERFACE_COMPAT IntfCompat)
+{
+ NTSTATUS status = STATUS_INVALID_PARAMETER;
+ ULONG QueryVersion;
+
+ if ((CompatInit == NULL) ||
+ (InterfaceQuery == NULL) ||
+ (CompatFixup == NULL) ||
+ (IntfCompat == NULL) ||
+ (VersionMin > VersionMax))
+ goto fail1;
+
+ CompatInit(IntfCompat);
+
+ QueryVersion = VersionMax;
+ while (!NT_SUCCESS(status)){
+ status = InterfaceQuery(FdoStruct,
+ Guid,
+ QueryVersion,
+ IntfCompat->ImportedInterface,
+ IntfCompat->ImportedInterfaceMaxSize,
+ FALSE);
+ if (!NT_SUCCESS(status)) {
+ if (QueryVersion > VersionMin)
+ QueryVersion--;
+ else
+ break;
+ }
+ }
+ if (!NT_SUCCESS(status)) {
+ if (status == STATUS_NOT_SUPPORTED && Optional) {
+ status = STATUS_SUCCESS;
+ goto done;
+ }
+ goto fail2;
+ }
+
+ if (QueryVersion == VersionMax) {
+ if ((IntfCompat->ImportedInterface->Size >
IntfCompat->ImportedInterfaceMaxSize) ||
+ (IntfCompat->ImportedInterface->Size >
IntfCompat->CompatInterfaceMaxSize)) {
+ status = STATUS_INTERNAL_ERROR;
+ goto fail3;
+ }
+ RtlCopyMemory(IntfCompat->CompatInterface,
IntfCompat->ImportedInterface, IntfCompat->ImportedInterface->Size);
+ } else {
+ status = CompatFixup(IntfCompat);
+ if (!NT_SUCCESS(status))
+ goto fail4;
+ }
+
+done:
+ return status;
+
+fail4:
+ Error("fail4\n");
+
+fail3:
+ Error("fail3\n");
+
+fail2:
+ Error("fail2\n");
+
+fail1:
+ Error("fail1 (%08x)\n", status);
+
+ return status;
+}
+
+
diff --git a/src/xeniface/interface_compat_xeniface.c
b/src/xeniface/interface_compat_xeniface.c
new file mode 100644
index 0000000..33f6be9
--- /dev/null
+++ b/src/xeniface/interface_compat_xeniface.c
@@ -0,0 +1,68 @@
+/* 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 interface_compat_xeniface.c
+ \brief Xeniface specific interface compatibility functions.
+*/
+
+#include <ntifs.h>
+#include <interface_compat.h>
+#include <interface_compat_xeniface.h>
+
+IMPL_COMPAT_INIT(XENBUS, STORE);
+IMPL_COMPAT_INIT(XENBUS, SUSPEND);
+IMPL_COMPAT_INIT(XENBUS, SHARED_INFO);
+IMPL_COMPAT_INIT(XENBUS, EVTCHN);
+IMPL_COMPAT_INIT(XENBUS, GNTTAB);
+
+IMPL_NULL_FIXUP(XENBUS, STORE);
+IMPL_NULL_FIXUP(XENBUS, SUSPEND);
+
+NTSTATUS XENBUS_SHARED_INFO_CompatFixup (
+ IN OUT PXEN_INTERFACE_COMPAT IntfCompat
+) {
+ UNREFERENCED_PARAMETER(IntfCompat);
+ return STATUS_NOT_IMPLEMENTED; /* TODO - Implement compatibility layer
once got basics running.*/
+}
+
+NTSTATUS XENBUS_EVTCHN_CompatFixup (
+ IN OUT PXEN_INTERFACE_COMPAT IntfCompat
+) {
+ UNREFERENCED_PARAMETER(IntfCompat);
+ return STATUS_NOT_IMPLEMENTED; /* TODO - Implement compatibility layer
once got basics running.*/
+}
+
+NTSTATUS XENBUS_GNTTAB_CompatFixup (
+ IN OUT PXEN_INTERFACE_COMPAT IntfCompat
+) {
+ UNREFERENCED_PARAMETER(IntfCompat);
+ return STATUS_NOT_IMPLEMENTED; /* TODO - Implement compatibility layer
once got basics running.*/
+}
diff --git a/vs2015/xeniface/xeniface.vcxproj b/vs2015/xeniface/xeniface.vcxproj
index 4ac4d50..4392637 100644
--- a/vs2015/xeniface/xeniface.vcxproj
+++ b/vs2015/xeniface/xeniface.vcxproj
@@ -63,6 +63,8 @@
<ClCompile Include="..\..\src\xeniface\ioctl_gnttab.c" />
<ClCompile Include="..\..\src\xeniface\ioctl_store.c" />
<ClCompile Include="..\..\src\xeniface\irp_queue.c" />
+ <ClCompile Include="..\..\src\xeniface\interface_compat.c" />
+ <ClCompile Include="..\..\src\xeniface\interface_compat_xeniface.c" />
</ItemGroup>
<ItemGroup>
<Mofcomp Include="../../src/xeniface/wmi.mof">
diff --git a/vs2017/xeniface/xeniface.vcxproj b/vs2017/xeniface/xeniface.vcxproj
index ab74b40..0bf9bf2 100644
--- a/vs2017/xeniface/xeniface.vcxproj
+++ b/vs2017/xeniface/xeniface.vcxproj
@@ -71,6 +71,8 @@
<ClCompile Include="..\..\src\xeniface\ioctl_gnttab.c" />
<ClCompile Include="..\..\src\xeniface\ioctl_store.c" />
<ClCompile Include="..\..\src\xeniface\irp_queue.c" />
+ <ClCompile Include="..\..\src\xeniface\interface_compat.c" />
+ <ClCompile Include="..\..\src\xeniface\interface_compat_xeniface.c" />
</ItemGroup>
<ItemGroup>
<Mofcomp Include="../../src/xeniface/wmi.mof">
diff --git a/vs2019/xeniface/xeniface.vcxproj b/vs2019/xeniface/xeniface.vcxproj
index b9756dd..5472f08 100644
--- a/vs2019/xeniface/xeniface.vcxproj
+++ b/vs2019/xeniface/xeniface.vcxproj
@@ -79,6 +79,8 @@
<ClCompile Include="..\..\src\xeniface\ioctl_gnttab.c" />
<ClCompile Include="..\..\src\xeniface\ioctl_store.c" />
<ClCompile Include="..\..\src\xeniface\irp_queue.c" />
+ <ClCompile Include="..\..\src\xeniface\interface_compat.c" />
+ <ClCompile Include="..\..\src\xeniface\interface_compat_xeniface.c" />
</ItemGroup>
<ItemGroup>
<Mofcomp Include="../../src/xeniface/wmi.mof">
--
2.25.0.windows.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |