From owner-svn-src-all@freebsd.org Fri Aug 21 15:53:10 2015 Return-Path: Delivered-To: svn-src-all@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 B30F49BF1E2; Fri, 21 Aug 2015 15:53:10 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.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 9BEB3AF0; Fri, 21 Aug 2015 15:53:10 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7LFrATY047238; Fri, 21 Aug 2015 15:53:10 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7LFr9RB047233; Fri, 21 Aug 2015 15:53:09 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201508211553.t7LFr9RB047233@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: Roger Pau Monné Date: Fri, 21 Aug 2015 15:53:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r286999 - in head/sys: dev/xen/blkfront dev/xen/netfront x86/xen xen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Aug 2015 15:53:10 -0000 Author: royger Date: Fri Aug 21 15:53:08 2015 New Revision: 286999 URL: https://svnweb.freebsd.org/changeset/base/286999 Log: xen: allow disabling PV disks and nics Introduce two new loader tunnables that can be used to disable PV disks and PV nics at boot time. They default to 0 and should be set to 1 (or any number different than 0) in order to disable the PV devices: hw.xen.disable_pv_disks=1 hw.xen.disable_pv_nics=1 In /boot/loader.conf will disable both PV disks and nics. Sponsored by: Citrix Systems R&D Tested by: Karl Pielorz MFC after: 1 week Modified: head/sys/dev/xen/blkfront/blkfront.c head/sys/dev/xen/netfront/netfront.c head/sys/x86/xen/hvm.c head/sys/xen/xen-os.h Modified: head/sys/dev/xen/blkfront/blkfront.c ============================================================================== --- head/sys/dev/xen/blkfront/blkfront.c Fri Aug 21 15:30:50 2015 (r286998) +++ head/sys/dev/xen/blkfront/blkfront.c Fri Aug 21 15:53:08 2015 (r286999) @@ -1366,6 +1366,9 @@ xbd_probe(device_t dev) if (strcmp(xenbus_get_type(dev), "vbd") != 0) return (ENXIO); + if (xen_hvm_domain() && xen_disable_pv_disks != 0) + return (ENXIO); + if (xen_hvm_domain()) { int error; char *type; Modified: head/sys/dev/xen/netfront/netfront.c ============================================================================== --- head/sys/dev/xen/netfront/netfront.c Fri Aug 21 15:30:50 2015 (r286998) +++ head/sys/dev/xen/netfront/netfront.c Fri Aug 21 15:53:08 2015 (r286999) @@ -445,6 +445,9 @@ static int netfront_probe(device_t dev) { + if (xen_hvm_domain() && xen_disable_pv_nics != 0) + return (ENXIO); + if (!strcmp(xenbus_get_type(dev), "vif")) { device_set_desc(dev, "Virtual Network Interface"); return (0); Modified: head/sys/x86/xen/hvm.c ============================================================================== --- head/sys/x86/xen/hvm.c Fri Aug 21 15:30:50 2015 (r286998) +++ head/sys/x86/xen/hvm.c Fri Aug 21 15:53:08 2015 (r286999) @@ -100,8 +100,15 @@ DPCPU_DEFINE(struct vcpu_info *, vcpu_in shared_info_t *HYPERVISOR_shared_info; start_info_t *HYPERVISOR_start_info; + +/*------------------------------ Sysctl tunables -----------------------------*/ +int xen_disable_pv_disks = 0; +int xen_disable_pv_nics = 0; +TUNABLE_INT("hw.xen.disable_pv_disks", &xen_disable_pv_disks); +TUNABLE_INT("hw.xen.disable_pv_nics", &xen_disable_pv_nics); + #ifdef SMP -/* XEN diverged cpu operations */ +/*---------------------- XEN diverged cpu operations -------------------------*/ static void xen_hvm_cpu_resume(void) { @@ -256,21 +263,34 @@ enum { static void xen_hvm_disable_emulated_devices(void) { + u_short disable_devs = 0; if (xen_pv_domain()) { /* * No emulated devices in the PV case, so no need to unplug * anything. */ + if (xen_disable_pv_disks != 0 || xen_disable_pv_nics != 0) + printf("PV devices cannot be disabled in PV guests\n"); return; } if (inw(XEN_MAGIC_IOPORT) != XMI_MAGIC) return; - if (bootverbose) - printf("XEN: Disabling emulated block and network devices\n"); - outw(XEN_MAGIC_IOPORT, XMI_UNPLUG_IDE_DISKS|XMI_UNPLUG_NICS); + if (xen_disable_pv_disks == 0) { + if (bootverbose) + printf("XEN: disabling emulated disks\n"); + disable_devs |= XMI_UNPLUG_IDE_DISKS; + } + if (xen_disable_pv_nics == 0) { + if (bootverbose) + printf("XEN: disabling emulated nics\n"); + disable_devs |= XMI_UNPLUG_NICS; + } + + if (disable_devs != 0) + outw(XEN_MAGIC_IOPORT, disable_devs); } static void Modified: head/sys/xen/xen-os.h ============================================================================== --- head/sys/xen/xen-os.h Fri Aug 21 15:30:50 2015 (r286998) +++ head/sys/xen/xen-os.h Fri Aug 21 15:53:08 2015 (r286999) @@ -56,6 +56,9 @@ extern start_info_t *HYPERVISOR_start_in /* XXX: we need to get rid of this and use HYPERVISOR_start_info directly */ extern char *console_page; +extern int xen_disable_pv_disks; +extern int xen_disable_pv_nics; + enum xen_domain_type { XEN_NATIVE, /* running on bare hardware */ XEN_PV_DOMAIN, /* running in a PV domain */