From owner-svn-src-stable@freebsd.org Fri Oct 14 03:11:32 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A8570C11E99; Fri, 14 Oct 2016 03:11:32 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 5FEF7FB2; Fri, 14 Oct 2016 03:11:32 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E3BVtG067125; Fri, 14 Oct 2016 03:11:31 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E3BVeN067123; Fri, 14 Oct 2016 03:11:31 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140311.u9E3BVeN067123@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 03:11:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307253 - in stable/10/sys: cam/ata sys X-SVN-Group: stable-10 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.23 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, 14 Oct 2016 03:11:32 -0000 Author: sephe Date: Fri Oct 14 03:11:31 2016 New Revision: 307253 URL: https://svnweb.freebsd.org/changeset/base/307253 Log: MFC 306396 cam/ata: Allow drivers to veto ATA disk attachment. This eventhandler is mainly used by VMs, e.g. Hyper-V, whose disk controllers share the disks with the simulated ATA controllers. Submitted by: Hongjiang Zhang Discussed with: mav Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7693 Modified: stable/10/sys/cam/ata/ata_xpt.c stable/10/sys/sys/eventhandler.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ata/ata_xpt.c ============================================================================== --- stable/10/sys/cam/ata/ata_xpt.c Fri Oct 14 03:00:53 2016 (r307252) +++ stable/10/sys/cam/ata/ata_xpt.c Fri Oct 14 03:11:31 2016 (r307253) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -827,12 +828,24 @@ noerror: { struct ccb_pathinq cpi; int16_t *ptr; + int veto = 0; ident_buf = &softc->ident_data; for (ptr = (int16_t *)ident_buf; ptr < (int16_t *)ident_buf + sizeof(struct ata_params)/2; ptr++) { *ptr = le16toh(*ptr); } + + /* + * Allow others to veto this ATA disk attachment. This + * is mainly used by VMs, whose disk controllers may + * share the disks with the simulated ATA controllers. + */ + EVENTHANDLER_INVOKE(ada_probe_veto, path, ident_buf, &veto); + if (veto) { + goto device_fail; + } + if (strncmp(ident_buf->model, "FX", 2) && strncmp(ident_buf->model, "NEC", 3) && strncmp(ident_buf->model, "Pioneer", 7) && Modified: stable/10/sys/sys/eventhandler.h ============================================================================== --- stable/10/sys/sys/eventhandler.h Fri Oct 14 03:00:53 2016 (r307252) +++ stable/10/sys/sys/eventhandler.h Fri Oct 14 03:11:31 2016 (r307253) @@ -283,4 +283,11 @@ typedef void (*unregister_framebuffer_fn EVENTHANDLER_DECLARE(register_framebuffer, register_framebuffer_fn); EVENTHANDLER_DECLARE(unregister_framebuffer, unregister_framebuffer_fn); +/* Veto ada attachment */ +struct cam_path; +struct ata_params; +typedef void (*ada_probe_veto_fn)(void *, struct cam_path *, + struct ata_params *, int *); +EVENTHANDLER_DECLARE(ada_probe_veto, ada_probe_veto_fn); + #endif /* SYS_EVENTHANDLER_H */