summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgibbs <gibbs@FreeBSD.org>2013-10-18 22:48:38 +0000
committergibbs <gibbs@FreeBSD.org>2013-10-18 22:48:38 +0000
commit084ebbef83ad0a31d7aa6099c1eedad33eba707d (patch)
tree5579bd1d8daff6a336aa80365ac454e3c71fb9a3
parent9ad9e387e9806be0093be97b2e0952a7fab968e9 (diff)
downloadFreeBSD-src-084ebbef83ad0a31d7aa6099c1eedad33eba707d.zip
FreeBSD-src-084ebbef83ad0a31d7aa6099c1eedad33eba707d.tar.gz
MFC: r256425
Centralize the detection logic for the Hyper-V hypervisor. Submitted by: Roger Pau Monné Sponsored by: Citrix Systems R&D Reviewed by: gibbs, grehan Approved by: re (gjb) sys/sys/systm.h: * Add a new VM_GUEST type, VM_GUEST_HV (HyperV guest). sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c: sys/dev/hyperv/vmbus/hv_hv.c: sys/dev/hyperv/stordisengage/hv_ata_pci_disengage.c: * Set vm_guest to VM_GUEST_HV and use that on other HyperV related devices instead of cloning the cpuid hypervisor check. * Cleanup the vmbus_identify function.
-rw-r--r--sys/dev/xen/blkfront/blkfront.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/sys/dev/xen/blkfront/blkfront.c b/sys/dev/xen/blkfront/blkfront.c
index feb79a1..92b5f35 100644
--- a/sys/dev/xen/blkfront/blkfront.c
+++ b/sys/dev/xen/blkfront/blkfront.c
@@ -1381,14 +1381,42 @@ xbd_closing(device_t dev)
static int
xbd_probe(device_t dev)
{
+ if (strcmp(xenbus_get_type(dev), "vbd") != 0)
+ return (ENXIO);
- if (!strcmp(xenbus_get_type(dev), "vbd")) {
- device_set_desc(dev, "Virtual Block Device");
- device_quiet(dev);
- return (0);
+ if (xen_hvm_domain()) {
+ int error;
+ char *type;
+
+ /*
+ * When running in an HVM domain, IDE disk emulation is
+ * disabled early in boot so that native drivers will
+ * not see emulated hardware. However, CDROM device
+ * emulation cannot be disabled.
+ *
+ * Through use of FreeBSD's vm_guest and xen_hvm_domain()
+ * APIs, we could modify the native CDROM driver to fail its
+ * probe when running under Xen. Unfortunatlely, the PV
+ * CDROM support in XenServer (up through at least version
+ * 6.2) isn't functional, so we instead rely on the emulated
+ * CDROM instance, and fail to attach the PV one here in
+ * the blkfront driver.
+ */
+ error = xs_read(XST_NIL, xenbus_get_node(dev),
+ "device-type", NULL, (void **) &type);
+ if (error)
+ return (ENXIO);
+
+ if (strncmp(type, "cdrom", 5) == 0) {
+ free(type, M_XENSTORE);
+ return (ENXIO);
+ }
+ free(type, M_XENSTORE);
}
- return (ENXIO);
+ device_set_desc(dev, "Virtual Block Device");
+ device_quiet(dev);
+ return (0);
}
/*
OpenPOWER on IntegriCloud