From owner-svn-src-stable@FreeBSD.ORG Fri Jul 18 07:18:38 2014 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 531A8C13; Fri, 18 Jul 2014 07:18:38 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 25F782234; Fri, 18 Jul 2014 07:18:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6I7IcQI090833; Fri, 18 Jul 2014 07:18:38 GMT (envelope-from royger@svn.freebsd.org) Received: (from royger@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s6I7Icma090832; Fri, 18 Jul 2014 07:18:38 GMT (envelope-from royger@svn.freebsd.org) Message-Id: <201407180718.s6I7Icma090832@svn.freebsd.org> From: Roger Pau Monné Date: Fri, 18 Jul 2014 07:18:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r268832 - stable/9/sys/dev/xen/blkfront X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jul 2014 07:18:38 -0000 Author: royger Date: Fri Jul 18 07:18:37 2014 New Revision: 268832 URL: http://svnweb.freebsd.org/changeset/base/268832 Log: MFC r256423: Allow FreeBSD to be booted from CDROM media on XenServer 6.2 and prior releases. PR: 164630 Modified: stable/9/sys/dev/xen/blkfront/blkfront.c Modified: stable/9/sys/dev/xen/blkfront/blkfront.c ============================================================================== --- stable/9/sys/dev/xen/blkfront/blkfront.c Fri Jul 18 06:58:01 2014 (r268831) +++ stable/9/sys/dev/xen/blkfront/blkfront.c Fri Jul 18 07:18:37 2014 (r268832) @@ -399,14 +399,44 @@ xb_dump(void *arg, void *virtual, vm_off static int blkfront_probe(device_t dev) { +#ifdef XENHVM + int error; + char *type; +#endif - if (!strcmp(xenbus_get_type(dev), "vbd")) { - device_set_desc(dev, "Virtual Block Device"); - device_quiet(dev); - return (0); + if (strcmp(xenbus_get_type(dev), "vbd") != 0) + return (ENXIO); + +#ifdef XENHVM + /* + * 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); +#endif - return (ENXIO); + device_set_desc(dev, "Virtual Block Device"); + device_quiet(dev); + return (0); } static void