Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.
  • Loading branch information...
commit 084ebbef83ad0a31d7aa6099c1eedad33eba707d 1 parent 9ad9e38
gibbs authored

Showing 1 changed file with 33 additions and 5 deletions. Show diff stats Hide diff stats

  1. +33 5 sys/dev/xen/blkfront/blkfront.c
38 sys/dev/xen/blkfront/blkfront.c
@@ -1381,14 +1381,42 @@ xbd_closing(device_t dev)
1381 1381 static int
1382 1382 xbd_probe(device_t dev)
1383 1383 {
  1384 + if (strcmp(xenbus_get_type(dev), "vbd") != 0)
  1385 + return (ENXIO);
1384 1386
1385   - if (!strcmp(xenbus_get_type(dev), "vbd")) {
1386   - device_set_desc(dev, "Virtual Block Device");
1387   - device_quiet(dev);
1388   - return (0);
  1387 + if (xen_hvm_domain()) {
  1388 + int error;
  1389 + char *type;
  1390 +
  1391 + /*
  1392 + * When running in an HVM domain, IDE disk emulation is
  1393 + * disabled early in boot so that native drivers will
  1394 + * not see emulated hardware. However, CDROM device
  1395 + * emulation cannot be disabled.
  1396 + *
  1397 + * Through use of FreeBSD's vm_guest and xen_hvm_domain()
  1398 + * APIs, we could modify the native CDROM driver to fail its
  1399 + * probe when running under Xen. Unfortunatlely, the PV
  1400 + * CDROM support in XenServer (up through at least version
  1401 + * 6.2) isn't functional, so we instead rely on the emulated
  1402 + * CDROM instance, and fail to attach the PV one here in
  1403 + * the blkfront driver.
  1404 + */
  1405 + error = xs_read(XST_NIL, xenbus_get_node(dev),
  1406 + "device-type", NULL, (void **) &type);
  1407 + if (error)
  1408 + return (ENXIO);
  1409 +
  1410 + if (strncmp(type, "cdrom", 5) == 0) {
  1411 + free(type, M_XENSTORE);
  1412 + return (ENXIO);
  1413 + }
  1414 + free(type, M_XENSTORE);
1389 1415 }
1390 1416
1391   - return (ENXIO);
  1417 + device_set_desc(dev, "Virtual Block Device");
  1418 + device_quiet(dev);
  1419 + return (0);
1392 1420 }
1393 1421
1394 1422 /*

0 comments on commit 084ebbe

Please sign in to comment.
Something went wrong with that request. Please try again.