xen_ctrl_version=""
xen_pv_domain_build="no"
xen_pci_passthrough=""
+xen_restrict_target="no"
linux_aio=""
cap_ng=""
attr=""
"which requires Xen support."
fi
+if test $xen_ctrl_version -ge 471 ; then
+ if
+ cat > $TMPC <<EOF &&
+#include <xenstore.h>
+#include <xenevtchn.h>
+#include <xenforeignmemory.h>
+int main(void) {
+ struct xs_handle *xsh;
+ xenforeignmemory_handle *xfmem;
+ xenevtchn_handle *xe;
+
+ xsh = xs_daemon_open();
+ xs_restrict(xsh, 0);
+
+ xfmem = xenforeignmemory_open(0, 0);
+ xenforeignmemory_restrict_target(xfmem, 0);
+
+ xe = xenevtchn_open(0, 0);
+ xenevtchn_restrict_target(xe, 0);
+
+ return 0;
+}
+EOF
+ compile_prog "" "$xen_stable_libs -lxenstore"
+ then
+ xen_restrict_target="yes"
+ fi
+fi
+
+
##########################################
# libtool probe
echo "xen support $xen"
if test "$xen" = "yes" ; then
echo "xen ctrl version $xen_ctrl_version"
+ echo "xen restricted $xen_restrict_target"
echo "pv dom build $xen_pv_domain_build"
fi
echo "brlapi support $brlapi"
if test "$xen_pv_domain_build" = "yes" ; then
echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
fi
+ if test "$xen_restrict_target" = "yes" ; then
+ echo "CONFIG_XEN_RESTRICT_TARGET=y" >> $config_host_mak
+ fi
fi
if test "$linux_aio" = "yes" ; then
echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
#endif
#endif
+#ifndef CONFIG_XEN_RESTRICT_TARGET
+
+/* xs_restrict has been available forever, no need to stub */
+
+static inline int xenevtchn_restrict_target(xenevtchn_handle *h, int d)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+static inline int xenforeignmemory_restrict_target(xenforeignmemory_handle *h, int d)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+#endif
+
#endif /* QEMU_HW_XEN_COMMON_H */
xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0);
}
+static bool xen_restrict_targets = true; /* XXX configurable? */
+
+/*
+ * Always logs.
+ *
+ * Returns true if the domain construction should be aborted.
+ */
+static bool xen_restrict_target_failure_is_fatal(const char *which, int errnoval)
+{
+ if (errnoval == ENOSYS) {
+ error_report("restricting %s handle not supported on this system",
+ which);
+ /* XXX should be fatal? Could be an option? */
+ return false;
+ }
+
+ error_report("restricting %s handle failed: %d: %s",
+ which, errnoval, strerror(errnoval));
+ return true;
+}
+
void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
{
int i, rc;
perror("xen: event channel open");
goto err;
}
+ rc = (xen_restrict_targets
+ ? xenevtchn_restrict_target(state->xce_handle, xen_domid)
+ : 0);
+ if (rc < 0 && xen_restrict_target_failure_is_fatal("evtchn", errno))
+ goto err;
state->xenstore = xs_daemon_open();
if (state->xenstore == NULL) {
perror("xen: xenstore open");
goto err;
}
+ rc = (xen_restrict_targets
+ ? xs_restrict(state->xenstore, xen_domid)
+ : 0);
+ if (rc < 0 && xen_restrict_target_failure_is_fatal("xenstore", errno))
+ goto err;
+
+ rc = (xen_restrict_targets
+ ? xenforeignmemory_restrict_target(xen_fmem, xen_domid)
+ : 0);
+ if (rc < 0 && xen_restrict_target_failure_is_fatal("xenforeignmemory", errno))
+ goto err;
rc = xen_create_ioreq_server(xen_xc, xen_domid, &state->ioservid);
if (rc < 0) {