xen_pv_domain_build="no"
xen_pci_passthrough=""
xen_restrict_target="no"
+xen_libdevicemodel="no"
linux_aio=""
cap_ng=""
attr=""
then
xen_restrict_target="yes"
fi
+
+ if
+ cat > $TMPC <<EOF &&
+#include <xendevicemodel.h>
+int main(void) {
+ xendevicemodel_handle *dm;
+
+ dm = xendevicemodel_open(NULL, 0, 0, NULL);
+ xendevicemodel_shutdown(dm);
+ return 0;
+}
+EOF
+ compile_prog "" "-lxendevicemodel"
+ then
+ xen_libdevicemodel="yes"
+ libs_softmmu="$libs_softmmu -lxendevicemodel"
+ fi
fi
if test "$xen" = "yes" ; then
echo "xen ctrl version $xen_ctrl_version"
echo "xen restricted $xen_restrict_target"
+ echo "xen dm lib $xen_libdevicemodel"
echo "pv dom build $xen_pv_domain_build"
fi
echo "brlapi support $brlapi"
if test "$xen_restrict_target" = "yes" ; then
echo "CONFIG_XEN_RESTRICT_TARGET=y" >> $config_host_mak
fi
+ if test "$xen_libdevicemodel" = "yes" ; then
+ echo "CONFIG_XEN_LIBDEVICEMODEL=y" >> $config_host_mak
+ fi
fi
if test "$linux_aio" = "yes" ; then
echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
}
#endif
+#ifdef CONFIG_XEN_LIBDEVICEMODEL
+
+#include <xendevicemodel.h>
+
+#else
+
+typedef xc_interface xendevicemodel_handle;
+
+/* Assumes r (returns restriction status of the handle) is non-NULL in
+ * all actual callers */
+#define xendevicemodel_open(l, d, f, r) ({ *r = ENOSYS; xen_xc; })
+
+#define xendevicemodel_shutdown(h) \
+ xc_domain_shutdown(h, xen_domid, SHUTDOWN_poweroff)
+#define xendevicemodel_reboot(h) \
+ xc_domain_shutdown(h, xen_domid, SHUTDOWN_reboot)
+
+#define xendevicemodel_s3_suspend(h) \
+ xc_set_hvm_param(h, xen_domid, HVM_PARAM_ACPI_S_STATE, 3);
+#define xendevicemodel_s3_awaken(h) \
+ xc_set_hvm_param(h, xen_domid, HVM_PARAM_ACPI_S_STATE, 0);
+
+#endif
+
/* Xen before 4.6 */
#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 460
static MemoryRegion ram_memory, ram_640k, ram_lo, ram_hi;
static MemoryRegion *framebuffer;
static bool xen_in_migration;
+static xendevicemodel_handle *xen_dm = NULL;
/* Compatibility with older version */
xc_hvm_inject_msi(xen_xc, xen_domid, addr, data);
}
-static void xen_suspend_notifier(Notifier *notifier, void *data)
+static void xen_suspend_notifier(Notifier *n, void *data)
{
- xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 3);
+ xendevicemodel_s3_suspend(xen_dm);
}
/* Xen Interrupt Controller */
{
int sts;
- sts = xc_domain_shutdown(xen_xc, xen_domid,
- reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff);
+ sts = (reboot ?
+ xendevicemodel_reboot(xen_dm) :
+ xendevicemodel_shutdown(xen_dm));
if (sts != 0) {
- fprintf(stderr, "xc_domain_shutdown failed to issue %s, "
- "sts %d, %s\n", reboot ? "reboot" : "poweroff",
+ fprintf(stderr, "failed to issue %s, sts %d, %s\n",
+ reboot ? "reboot" : "poweroff",
sts, strerror(errno));
} else {
fprintf(stderr, "Issued domain %d %s\n", xen_domid,
free(entries);
}
-static void xen_wakeup_notifier(Notifier *notifier, void *data)
+static void xen_wakeup_notifier(Notifier *n, void *data)
{
- xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0);
+ xendevicemodel_s3_awaken(xen_dm);
}
static bool xen_restrict_targets = true; /* XXX configurable? */
error_report("restricting %s handle failed: %d: %s",
which, errnoval, strerror(errnoval));
+
return true;
}
xen_pfn_t bufioreq_pfn;
evtchn_port_t bufioreq_evtchn;
XenIOState *state;
+ int dm_restrict_errno;
state = g_malloc0(sizeof (XenIOState));
if (rc < 0 && xen_restrict_target_failure_is_fatal("xenforeignmemory", errno))
goto err;
+ xen_dm = xendevicemodel_open(NULL, xen_domid, 0, &dm_restrict_errno);
+ if (!xen_dm) {
+ perror("xen: dm handle create");
+ goto err;
+ }
+ if (dm_restrict_errno &&
+ xen_restrict_target_failure_is_fatal("xendevicemodel", dm_restrict_errno))
+ goto err;
+
rc = xen_create_ioreq_server(xen_xc, xen_domid, &state->ioservid);
if (rc < 0) {
perror("xen: ioreq server create");