# # Copyright (C) 2006-2011 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. # NETWORK_DEVICES_MENU:=Network Devices define KernelPackage/sis190 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=SiS 190 Fast/Gigabit Ethernet support DEPENDS:=@PCI_SUPPORT +kmod-mii KCONFIG:=CONFIG_SIS190 FILES:=$(LINUX_DIR)/drivers/net/ethernet/sis/sis190.ko AUTOLOAD:=$(call AutoProbe,sis190) endef $(eval $(call KernelPackage,sis190)) define KernelPackage/skge SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=SysKonnect Yukon support DEPENDS:=@PCI_SUPPORT KCONFIG:=CONFIG_SKGE \ CONFIG_SKGE_DEBUG=n \ CONFIG_SKGE_GENESIS=n FILES:=$(LINUX_DIR)/drivers/net/ethernet/marvell/skge.ko AUTOLOAD:=$(call AutoProbe,skge) endef $(eval $(call KernelPackage,skge)) define KernelPackage/atl2 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Atheros L2 Fast Ethernet support DEPENDS:=@PCI_SUPPORT KCONFIG:=CONFIG_ATL2 FILES:=$(LINUX_DIR)/drivers/net/ethernet/atheros/atlx/atl2.ko AUTOLOAD:=$(call AutoProbe,atl2) endef $(eval $(call KernelPackage,atl2)) define KernelPackage/atl1 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Atheros L1 Gigabit Ethernet support DEPENDS:=@PCI_SUPPORT +kmod-mii KCONFIG:=CONFIG_ATL1 FILES:=$(LINUX_DIR)/drivers/net/ethernet/atheros/atlx/atl1.ko AUTOLOAD:=$(call AutoProbe,atl1) endef $(eval $(call KernelPackage,atl1)) define KernelPackage/atl1c SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Atheros L1C DEPENDS:=@PCI_SUPPORT KCONFIG:=CONFIG_ATL1C FILES:=$(LINUX_DIR)/drivers/net/ethernet/atheros/atl1c/atl1c.ko AUTOLOAD:=$(call AutoProbe,atl1c) endef $(eval $(call KernelPackage,atl1c)) define KernelPackage/atl1e SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Atheros L1E DEPENDS:=@PCI_SUPPORT KCONFIG:=CONFIG_ATL1E FILES:=$(LINUX_DIR)/drivers/net/ethernet/atheros/atl1e/atl1e.ko AUTOLOAD:=$(call AutoProbe,atl1e) endef $(eval $(call KernelPackage,atl1e)) define KernelPackage/libphy SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=PHY library KCONFIG:=CONFIG_PHYLIB FILES:=$(LINUX_DIR)/drivers/net/phy/libphy.ko AUTOLOAD:=$(call AutoLoad,15,libphy,1) endef define KernelPackage/libphy/description PHY library endef $(eval $(call KernelPackage,libphy)) define KernelPackage/mii SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=MII library KCONFIG:=CONFIG_MII FILES:=$(LINUX_DIR)/drivers/net/mii.ko AUTOLOAD:=$(call AutoLoad,15,mii,1) endef define KernelPackage/mii/description MII library endef $(eval $(call KernelPackage,mii)) define KernelPackage/et131x SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Agere ET131x Gigabit Ethernet driver URL:=http://sourceforge.net/projects/et131x FILES:= \ $(LINUX_DIR)/drivers/net/ethernet/agere/et131x.ko KCONFIG:= \ CONFIG_ET131X \ CONFIG_ET131X_DEBUG=n DEPENDS:=@PCI_SUPPORT +kmod-libphy AUTOLOAD:=$(call AutoProbe,et131x) endef define KernelPackage/et131x/description This package contains the et131x kernel module endef $(eval $(call KernelPackage,et131x)) define KernelPackage/gw16083 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Gateworks Ventana Ethernet Expansion Mezzanine driver URL:=http://www.gateworks.com FILES:=$(LINUX_DIR)/drivers/net/phy/gw16083.ko KCONFIG:=CONFIG_GATEWORKS_GW16083 DEPENDS:=@TARGET_imx6 @PCI_SUPPORT +kmod-libphy +kmod-igb AUTOLOAD:=$(call AutoLoad,36,gw16083) endef define KernelPackage/gw16083/description This package contains the gw16083 kernel module for supporting the Gateworks Ventana Ethernet Expansion Mezzanine. endef $(eval $(call KernelPackage,gw16083)) define KernelPackage/phylib-broadcom SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Broadcom Ethernet PHY library KCONFIG:=CONFIG_BCM_NET_PHYLIB HIDDEN:=1 DEPENDS:=+kmod-libphy FILES:=$(LINUX_DIR)/drivers/net/phy/bcm-phy-lib.ko AUTOLOAD:=$(call AutoLoad,17,bcm-phy-lib) endef $(eval $(call KernelPackage,phylib-broadcom)) define KernelPackage/phy-broadcom SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Broadcom Ethernet PHY driver KCONFIG:=CONFIG_BROADCOM_PHY DEPENDS:=+kmod-libphy +kmod-phylib-broadcom FILES:=$(LINUX_DIR)/drivers/net/phy/broadcom.ko AUTOLOAD:=$(call AutoLoad,18,broadcom) endef define KernelPackage/phy-broadcom/description Currently supports the BCM5411, BCM5421, BCM5461, BCM5464, BCM5481, BCM5482 and BCM57780 PHYs. endef $(eval $(call KernelPackage,phy-broadcom)) define KernelPackage/swconfig SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=switch configuration API DEPENDS:=+kmod-libphy KCONFIG:=CONFIG_SWCONFIG FILES:=$(LINUX_DIR)/drivers/net/phy/swconfig.ko AUTOLOAD:=$(call AutoLoad,41,swconfig) endef define KernelPackage/swconfig/description Switch configuration API module endef $(eval $(call KernelPackage,swconfig)) define KernelPackage/switch-mvsw61xx SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Marvell 88E61xx switch support DEPENDS:=+kmod-swconfig KCONFIG:=CONFIG_MVSW61XX_PHY FILES:=$(LINUX_DIR)/drivers/net/phy/mvsw61xx.ko AUTOLOAD:=$(call AutoLoad,42,mvsw61xx) endef define KernelPackage/switch-mvsw61xx/description Marvell 88E61xx switch support endef $(eval $(call KernelPackage,switch-mvsw61xx)) define KernelPackage/switch-ip17xx SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=IC+ IP17XX switch support DEPENDS:=+kmod-swconfig KCONFIG:=CONFIG_IP17XX_PHY FILES:=$(LINUX_DIR)/drivers/net/phy/ip17xx.ko AUTOLOAD:=$(call AutoLoad,42,ip17xx) endef define KernelPackage/switch-ip17xx/description IC+ IP175C/IP178C switch support endef $(eval $(call KernelPackage,switch-ip17xx)) define KernelPackage/switch-rtl8366-smi SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Realtek RTL8366 SMI switch interface support DEPENDS:=@GPIO_SUPPORT +kmod-swconfig KCONFIG:=CONFIG_RTL8366_SMI FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8366_smi.ko AUTOLOAD:=$(call AutoLoad,42,rtl8366_smi) endef define KernelPackage/switch-rtl8366_smi/description Realtek RTL8366 series SMI switch interface support endef $(eval $(call KernelPackage,switch-rtl8366-smi)) define KernelPackage/switch-rtl8366rb SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Realtek RTL8366RB switch support DEPENDS:=+kmod-switch-rtl8366-smi KCONFIG:=CONFIG_RTL8366RB_PHY FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8366rb.ko AUTOLOAD:=$(call AutoLoad,43,rtl8366rb) endef define KernelPackage/switch-rtl8366rb/description Realtek RTL8366RB switch support endef $(eval $(call KernelPackage,switch-rtl8366rb)) define KernelPackage/switch-rtl8366s SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Realtek RTL8366S switch support DEPENDS:=+kmod-switch-rtl8366-smi KCONFIG:=CONFIG_RTL8366S_PHY FILES:=$(LINUX_DIR)/drivers/net/phy/rtl8366s.ko AUTOLOAD:=$(call AutoLoad,43,rtl8366s) endef define KernelPackage/switch-rtl8366s/description Realtek RTL8366S switch support endef $(eval $(call KernelPackage,switch-rtl8366s)) define KernelPackage/natsemi SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=National Semiconductor DP8381x series DEPENDS:=@PCI_SUPPORT KCONFIG:=CONFIG_NATSEMI FILES:=$(LINUX_DIR)/drivers/net/ethernet/natsemi/natsemi.ko AUTOLOAD:=$(call AutoLoad,20,natsemi) endef define KernelPackage/natsemi/description Kernel modules for National Semiconductor DP8381x series PCI Ethernet adapters. endef $(eval $(call KernelPackage,natsemi)) define KernelPackage/r6040 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=RDC Fast-Ethernet support DEPENDS:=@PCI_SUPPORT +kmod-libphy KCONFIG:=CONFIG_R6040 \ CONFIG_R6040_NAPI=y FILES:=$(LINUX_DIR)/drivers/net/ethernet/rdc/r6040.ko AUTOLOAD:=$(call AutoProbe,r6040) endef define KernelPackage/r6040/description Kernel modules for RDC Fast-Ethernet adapters. endef $(eval $(call KernelPackage,r6040)) define KernelPackage/sis900 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=SiS 900 Ethernet support DEPENDS:=@PCI_SUPPORT +kmod-mii KCONFIG:=CONFIG_SIS900 FILES:=$(LINUX_DIR)/drivers/net/ethernet/sis/sis900.ko AUTOLOAD:=$(call AutoProbe,sis900) endef define KernelPackage/sis900/description Kernel modules for Sis 900 Ethernet adapters. endef $(eval $(call KernelPackage,sis900)) define KernelPackage/sky2 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=SysKonnect Yukon2 support DEPENDS:=@PCI_SUPPORT KCONFIG:=CONFIG_SKY2 FILES:=$(LINUX_DIR)/drivers/net/ethernet/marvell/sky2.ko AUTOLOAD:=$(call AutoProbe,sky2) endef define KernelPackage/sky2/description This driver supports Gigabit Ethernet adapters based on the Marvell Yukon 2 chipset: Marvell 88E8021/88E8022/88E8035/88E8036/88E8038/88E8050/88E8052/ 88E8053/88E8055/88E8061/88E8062, SysKonnect SK-9E21D/SK-9S21 There is companion driver for the older Marvell Yukon and Genesis based adapters: skge. endef $(eval $(call KernelPackage,sky2)) define KernelPackage/via-rhine SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Via Rhine ethernet support DEPENDS:=@PCI_SUPPORT +kmod-mii KCONFIG:=CONFIG_VIA_RHINE \ CONFIG_VIA_RHINE_MMIO=y FILES:=$(LINUX_DIR)/drivers/net/ethernet/via/via-rhine.ko AUTOLOAD:=$(call AutoProbe,via-rhine) endef define KernelPackage/via-rhine/description Kernel modules for Via Rhine Ethernet chipsets endef $(eval $(call KernelPackage,via-rhine)) define KernelPackage/via-velocity SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=VIA Velocity Gigabit Ethernet Adapter kernel support DEPENDS:=@TARGET_ixp4xx||TARGET_mpc83xx||PCI_SUPPORT +kmod-lib-crc-ccitt KCONFIG:=CONFIG_VIA_VELOCITY FILES:=$(LINUX_DIR)/drivers/net/ethernet/via/via-velocity.ko AUTOLOAD:=$(call AutoProbe,via-velocity) endef define KernelPackage/via-velocity/description Kernel modules for VIA Velocity Gigabit Ethernet chipsets endef $(eval $(call KernelPackage,via-velocity)) define KernelPackage/8139too SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=RealTek RTL-8139 PCI Fast Ethernet Adapter kernel support DEPENDS:=@PCI_SUPPORT +kmod-mii KCONFIG:=CONFIG_8139TOO \ CONFIG_8139TOO_PIO=y \ CONFIG_8139TOO_TUNE_TWISTER=n \ CONFIG_8139TOO_8129=n \ CONFIG_8139_OLD_RX_RESET=n FILES:=$(LINUX_DIR)/drivers/net/ethernet/realtek/8139too.ko AUTOLOAD:=$(call AutoProbe,8139too) endef define KernelPackage/8139too/description Kernel modules for RealTek RTL-8139 PCI Fast Ethernet adapters endef $(eval $(call KernelPackage,8139too)) define KernelPackage/8139cp SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=RealTek RTL-8139C+ PCI Fast Ethernet Adapter kernel support DEPENDS:=@PCI_SUPPORT +kmod-mii KCONFIG:=CONFIG_8139CP FILES:=$(LINUX_DIR)/drivers/net/ethernet/realtek/8139cp.ko AUTOLOAD:=$(call AutoProbe,8139cp) endef define KernelPackage/8139cp/description Kernel module for RealTek RTL-8139C+ PCI Fast Ethernet adapters endef $(eval $(call KernelPackage,8139cp)) define KernelPackage/r8169 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=RealTek RTL-8169 PCI Gigabit Ethernet Adapter kernel support DEPENDS:=@PCI_SUPPORT +kmod-mii +r8169-firmware KCONFIG:=CONFIG_R8169 \ CONFIG_R8169_NAPI=y \ CONFIG_R8169_VLAN=n FILES:=$(LINUX_DIR)/drivers/net/ethernet/realtek/r8169.ko AUTOLOAD:=$(call AutoProbe,r8169) endef define KernelPackage/r8169/description Kernel modules for RealTek RTL-8169 PCI Gigabit Ethernet adapters endef $(eval $(call KernelPackage,r8169)) define KernelPackage/ne2k-pci SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=ne2k-pci Ethernet Adapter kernel support DEPENDS:=@PCI_SUPPORT KCONFIG:=CONFIG_NE2K_PCI FILES:= \ $(LINUX_DIR)/drivers/net/ethernet/8390/ne2k-pci.ko \ $(LINUX_DIR)/drivers/net/ethernet/8390/8390.ko AUTOLOAD:=$(call AutoProbe,8390 ne2k-pci) endef define KernelPackage/ne2k-pci/description Kernel modules for NE2000 PCI Ethernet Adapter kernel endef $(eval $(call KernelPackage,ne2k-pci)) define KernelPackage/e100 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Intel(R) PRO/100+ cards kernel support DEPENDS:=@PCI_SUPPORT +kmod-mii KCONFIG:=CONFIG_E100 FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/e100.ko AUTOLOAD:=$(call AutoProbe,e100) endef define KernelPackage/e100/description Kernel modules for Intel(R) PRO/100+ Ethernet adapters endef define KernelPackage/e100/install $(INSTALL_DIR) $(1)/lib/firmware/e100 $(INSTALL_DATA) $(LINUX_DIR)/firmware/e100/d101m_ucode.bin $(1)/lib/firmware/e100/ $(INSTALL_DATA) $(LINUX_DIR)/firmware/e100/d101s_ucode.bin $(1)/lib/firmware/e100/ $(INSTALL_DATA) $(LINUX_DIR)/firmware/e100/d102e_ucode.bin $(1)/lib/firmware/e100/ endef $(eval $(call KernelPackage,e100)) define KernelPackage/e1000 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Intel(R) PRO/1000 PCI cards kernel support DEPENDS:=@PCI_SUPPORT KCONFIG:=CONFIG_E1000 \ CONFIG_E1000_DISABLE_PACKET_SPLIT=n \ CONFIG_E1000_NAPI=y FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/e1000/e1000.ko AUTOLOAD:=$(call AutoLoad,35,e1000) endef define KernelPackage/e1000/description Kernel modules for Intel(R) PRO/1000 PCI Ethernet adapters. endef $(eval $(call KernelPackage,e1000)) define KernelPackage/e1000e SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Intel(R) PRO/1000 PCIe cards kernel support DEPENDS:=@PCIE_SUPPORT +kmod-ptp KCONFIG:=CONFIG_E1000E FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/e1000e/e1000e.ko AUTOLOAD:=$(call AutoProbe,e1000e) endef define KernelPackage/e1000e/description Kernel modules for Intel(R) PRO/1000 PCIe Ethernet adapters. endef $(eval $(call KernelPackage,e1000e)) define KernelPackage/igb SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support DEPENDS:=@PCI_SUPPORT +kmod-i2c-algo-bit +kmod-ptp KCONFIG:=CONFIG_IGB \ CONFIG_IGB_HWMON=n \ CONFIG_IGB_DCA=n FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/igb/igb.ko AUTOLOAD:=$(call AutoLoad,35,igb) endef define KernelPackage/igb/description Kernel modules for Intel(R) 82575/82576 PCI-Express Gigabit Ethernet adapters. endef $(eval $(call KernelPackage,igb)) define KernelPackage/b44 TITLE:=Broadcom 44xx driver KCONFIG:=CONFIG_B44 DEPENDS:=@PCI_SUPPORT @!TARGET_brcm47xx_mips74k +!TARGET_brcm47xx:kmod-ssb +kmod-mii +kmod-libphy SUBMENU:=$(NETWORK_DEVICES_MENU) FILES:=$(LINUX_DIR)/drivers/net/ethernet/broadcom/b44.ko AUTOLOAD:=$(call AutoLoad,19,b44,1) endef define KernelPackage/b44/description Kernel modules for Broadcom 44xx Ethernet adapters. endef $(eval $(call KernelPackage,b44)) define KernelPackage/3c59x SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=3Com 3c590/3c900 series (592/595/597) Vortex/Boomerang DEPENDS:=@PCI_SUPPORT +kmod-mii KCONFIG:=CONFIG_VORTEX FILES:=$(LINUX_DIR)/drivers/net/ethernet/3com/3c59x.ko AUTOLOAD:=$(call AutoProbe,3c59x) endef define KernelPackage/3c59x/description This option enables driver support for a large number of 10mbps and 10/100mbps EISA, PCI and PCMCIA 3Com Ethernet adapters: - "Vortex" (Fast EtherLink 3c590/3c592/3c595/3c597) EISA and PCI - "Boomerang" (EtherLink XL 3c900 or 3c905) PCI - "Cyclone" (3c540/3c900/3c905/3c980/3c575/3c656) PCI and Cardbus - "Tornado" (3c905) PCI - "Hurricane" (3c555/3cSOHO) PCI endef $(eval $(call KernelPackage,3c59x)) define KernelPackage/pcnet32 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=AMD PCnet32 PCI support DEPENDS:=@(PCI_SUPPORT||TARGET_malta) +kmod-mii KCONFIG:=CONFIG_PCNET32 FILES:=$(LINUX_DIR)/drivers/net/ethernet/amd/pcnet32.ko AUTOLOAD:=$(call AutoProbe,pcnet32) endef define KernelPackage/pcnet32/description Kernel modules for AMD PCnet32 Ethernet adapters endef $(eval $(call KernelPackage,pcnet32)) define KernelPackage/tg3 TITLE:=Broadcom Tigon3 Gigabit Ethernet KCONFIG:=CONFIG_TIGON3 DEPENDS:=+!TARGET_brcm47xx:kmod-libphy +kmod-hwmon-core +kmod-ptp SUBMENU:=$(NETWORK_DEVICES_MENU) FILES:=$(LINUX_DIR)/drivers/net/ethernet/broadcom/tg3.ko AUTOLOAD:=$(call AutoLoad,19,tg3,1) endef define KernelPackage/tg3/description Kernel modules for Broadcom Tigon3 Gigabit Ethernet adapters endef $(eval $(call KernelPackage,tg3)) define KernelPackage/hfcpci TITLE:=HFC PCI cards (single port) support for mISDN KCONFIG:=CONFIG_MISDN_HFCPCI DEPENDS:=+kmod-misdn SUBMENU:=$(NETWORK_DEVICES_MENU) FILES:=$(LINUX_DIR)/drivers/isdn/hardware/mISDN/hfcpci.ko AUTOLOAD:=$(call AutoLoad,31,hfcpci) endef define KernelPackage/hfcpci/description Kernel modules for Cologne AG's HFC pci cards (single port) using the mISDN V2 stack endef $(eval $(call KernelPackage,hfcpci)) define KernelPackage/hfcmulti TITLE:=HFC multiport cards (HFC-4S/8S/E1) support for mISDN KCONFIG:=CONFIG_MISDN_HFCMULTI DEPENDS:=+kmod-misdn SUBMENU:=$(NETWORK_DEVICES_MENU) FILES:=$(LINUX_DIR)/drivers/isdn/hardware/mISDN/hfcmulti.ko AUTOLOAD:=$(call AutoLoad,31,hfcmulti) endef define KernelPackage/hfcmulti/description Kernel modules for Cologne AG's HFC multiport cards (HFC-4S/8S/E1) using the mISDN V2 stack endef $(eval $(call KernelPackage,hfcmulti)) define KernelPackage/gigaset SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Siemens Gigaset support for isdn4linux DEPENDS:=@USB_SUPPORT +kmod-isdn4linux +kmod-lib-crc-ccitt +kmod-usb-core URL:=http://gigaset307x.sourceforge.net/ KCONFIG:= \ CONFIG_ISDN_DRV_GIGASET \ CONFIG_GIGASET_BASE \ CONFIG_GIGASET_M101 \ CONFIG_GIGASET_M105 \ CONFIG_GIGASET_UNDOCREQ=y \ CONFIG_GIGASET_I4L=y FILES:= \ $(LINUX_DIR)/drivers/isdn/gigaset/gigaset.ko \ $(LINUX_DIR)/drivers/isdn/gigaset/bas_gigaset.ko \ $(LINUX_DIR)/drivers/isdn/gigaset/ser_gigaset.ko \ $(LINUX_DIR)/drivers/isdn/gigaset/usb_gigaset.ko AUTOLOAD:=$(call AutoProbe,gigaset bas_gigaset ser_gigaset usb_gigaset) endef define KernelPackage/gigaset/description This driver supports the Siemens Gigaset SX205/255 family of ISDN DECT bases, including the predecessors Gigaset 3070/3075 and 4170/4175 and their T-Com versions Sinus 45isdn and Sinus 721X. endef $(eval $(call KernelPackage,gigaset)) define KernelPackage/macvlan SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=MAC-VLAN support KCONFIG:=CONFIG_MACVLAN FILES:=$(LINUX_DIR)/drivers/net/macvlan.ko AUTOLOAD:=$(call AutoProbe,macvlan) endef define KernelPackage/macvlan/description A kernel module which allows one to create virtual interfaces that map packets to or from specific MAC addresses to a particular interface endef $(eval $(call KernelPackage,macvlan)) define KernelPackage/tulip TITLE:=Tulip family network device support DEPENDS:=@PCI_SUPPORT +kmod-mii SUBMENU:=$(NETWORK_DEVICES_MENU) KCONFIG:= \ CONFIG_NET_TULIP=y \ CONFIG_DE2104X \ CONFIG_DE2104X_DSL=0 \ CONFIG_TULIP \ CONFIG_TULIP_MWI=y \ CONFIG_TULIP_MMIO=y \ CONFIG_TULIP_NAPI=y \ CONFIG_TULIP_NAPI_HW_MITIGATION=y \ CONFIG_DE4X5=n \ CONFIG_WINBOND_840 \ CONFIG_DM9102 \ CONFIG_ULI526X FILES:= \ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/tulip.ko \ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/de2104x.ko \ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/dmfe.ko \ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/uli526x.ko \ $(LINUX_DIR)/drivers/net/ethernet/dec/tulip/winbond-840.ko AUTOLOAD:=$(call AutoProbe,tulip) endef define KernelPackage/tulip/description Kernel modules for the Tulip family of network cards, including DECchip Tulip, DIGITAL EtherWORKS, Winbond W89c840, Davicom DM910x/DM980x and ULi M526x controller support. endef $(eval $(call KernelPackage,tulip)) define KernelPackage/solos-pci SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Solos ADSL2+ multiport modem DEPENDS:=@PCI_SUPPORT +kmod-atm KCONFIG:=CONFIG_ATM_SOLOS FILES:=$(LINUX_DIR)/drivers/atm/solos-pci.ko AUTOLOAD:=$(call AutoProbe,solos-pci) endef define KernelPackage/solos-pci/description Kernel module for Traverse Technologies' Solos PCI cards and Geos ADSL2+ x86 motherboard endef $(eval $(call KernelPackage,solos-pci)) define KernelPackage/dummy SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Dummy network device KCONFIG:=CONFIG_DUMMY FILES:=$(LINUX_DIR)/drivers/net/dummy.ko AUTOLOAD:=$(call AutoLoad,34,dummy) endef define KernelPackage/dummy/description The dummy network device endef $(eval $(call KernelPackage,dummy)) define KernelPackage/ifb SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Intermediate Functional Block support KCONFIG:= \ CONFIG_IFB \ CONFIG_NET_CLS=y FILES:=$(LINUX_DIR)/drivers/net/ifb.ko AUTOLOAD:=$(call AutoLoad,34,ifb) endef define KernelPackage/ifb/description The Intermediate Functional Block endef $(eval $(call KernelPackage,ifb)) define KernelPackage/dm9000 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Davicom 9000 Ethernet support DEPENDS:=@PCI_SUPPORT +kmod-mii KCONFIG:=CONFIG_DM9000 \ CONFIG_DM9000_DEBUGLEVEL=4 \ CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL=y FILES:=$(LINUX_DIR)/drivers/net/ethernet/davicom/dm9000.ko AUTOLOAD:=$(call AutoLoad,34,dm9000) endef define KernelPackage/dm9000/description Kernel driver for Davicom 9000 Ethernet adapters. endef $(eval $(call KernelPackage,dm9000)) define KernelPackage/forcedeth SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=nForce Ethernet support DEPENDS:=@PCI_SUPPORT KCONFIG:=CONFIG_FORCEDETH FILES:=$(LINUX_DIR)/drivers/net/ethernet/nvidia/forcedeth.ko AUTOLOAD:=$(call AutoProbe,forcedeth) endef define KernelPackage/forcedeth/description Kernel driver for Nvidia Ethernet support endef $(eval $(call KernelPackage,forcedeth)) define KernelPackage/of-mdio SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=OpenFirmware MDIO support DEPENDS:=+kmod-libphy KCONFIG:=CONFIG_OF_MDIO FILES:=$(LINUX_DIR)/drivers/of/of_mdio.ko AUTOLOAD:=$(call AutoLoad,41,of_mdio) endef define KernelPackage/of-mdio/description Kernel driver for OpenFirmware MDIO support endef $(eval $(call KernelPackage,of-mdio)) define KernelPackage/fsl-pq-mdio SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Freescale PQ MDIO bus support DEPENDS:=@TARGET_mpc85xx +kmod-of-mdio KCONFIG:=CONFIG_FSL_PQ_MDIO FILES:=$(LINUX_DIR)/drivers/net/ethernet/freescale/fsl_pq_mdio.ko AUTOLOAD:=$(call AutoLoad,42,fsl_pq_mdio) endef define KernelPackage/fsl-pq-mdio/description Kernel driver for the Freescale PQ MDIO bus endef $(eval $(call KernelPackage,fsl-pq-mdio)) define KernelPackage/gianfar SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Gianfar Ethernet support DEPENDS:=@TARGET_mpc85xx +kmod-fsl-pq-mdio KCONFIG:=CONFIG_GIANFAR FILES:=$(LINUX_DIR)/drivers/net/ethernet/freescale/gianfar_driver.ko AUTOLOAD:=$(call AutoProbe,gianfar_driver) endef define KernelPackage/gianfar/description Kernel driver for Freescale Gianfar Ethernet support endef $(eval $(call KernelPackage,gianfar)) define KernelPackage/vmxnet3 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=VMware VMXNET3 ethernet driver DEPENDS:=@PCI_SUPPORT KCONFIG:=CONFIG_VMXNET3 FILES:=$(LINUX_DIR)/drivers/net/vmxnet3/vmxnet3.ko AUTOLOAD:=$(call AutoLoad,35,vmxnet3) endef define KernelPackage/vmxnet3/description Kernel modules for VMware VMXNET3 ethernet adapters. endef $(eval $(call KernelPackage,vmxnet3)) define KernelPackage/spi-ks8995 SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Micrel/Kendin KS8995 Ethernet switch control FILES:=$(LINUX_DIR)/drivers/net/phy/spi_ks8995.ko KCONFIG:=CONFIG_MICREL_KS8995MA \ CONFIG_SPI=y \ CONFIG_SPI_MASTER=y AUTOLOAD:=$(call AutoLoad,50,spi_ks8995) endef define KernelPackage/spi-ks8995/description Kernel module for Micrel/Kendin KS8995 ethernet switch endef $(eval $(call KernelPackage,spi-ks8995)) href='#n593'>593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060
/******************************************************************************
* Xc.c
*
* Copyright (c) 2003-2004, K A Fraser (University of Cambridge)
*/
#include <Python.h>
#include <xenctrl.h>
#include <xenguest.h>
#include <zlib.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/mman.h>
#include <netdb.h>
#include <arpa/inet.h>
#include "xenctrl.h"
#include <xen/elfnote.h>
#include "xc_dom.h"
#include <xen/hvm/hvm_info_table.h>
#include <xen/hvm/params.h>
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
/* Needed for Python versions earlier than 2.3. */
#ifndef PyMODINIT_FUNC
#define PyMODINIT_FUNC DL_EXPORT(void)
#endif
#define PKG "xen.lowlevel.xc"
#define CLS "xc"
static PyObject *xc_error_obj, *zero;
typedef struct {
PyObject_HEAD;
int xc_handle;
} XcObject;
static PyObject *dom_op(XcObject *self, PyObject *args,
int (*fn)(int, uint32_t));
static PyObject *pyxc_error_to_exception(void)
{
PyObject *pyerr;
const xc_error *err = xc_get_last_error();
const char *desc = xc_error_code_to_desc(err->code);
if ( err->code == XC_ERROR_NONE )
return PyErr_SetFromErrno(xc_error_obj);
if ( err->message[0] != '\0' )
pyerr = Py_BuildValue("(iss)", err->code, desc, err->message);
else
pyerr = Py_BuildValue("(is)", err->code, desc);
xc_clear_last_error();
if ( pyerr != NULL )
{
PyErr_SetObject(xc_error_obj, pyerr);
Py_DECREF(pyerr);
}
return NULL;
}
static PyObject *pyxc_domain_dumpcore(XcObject *self, PyObject *args)
{
uint32_t dom;
char *corefile;
if ( !PyArg_ParseTuple(args, "is", &dom, &corefile) )
return NULL;
if ( (corefile == NULL) || (corefile[0] == '\0') )
return NULL;
if ( xc_domain_dumpcore(self->xc_handle, dom, corefile) != 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_handle(XcObject *self)
{
return PyInt_FromLong(self->xc_handle);
}
static PyObject *pyxc_domain_create(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom = 0, ssidref = 0, flags = 0, target = 0;
int ret, i;
PyObject *pyhandle = NULL;
xen_domain_handle_t handle = {
0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef,
0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef };
static char *kwd_list[] = { "domid", "ssidref", "handle", "flags", "target", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iiOii", kwd_list,
&dom, &ssidref, &pyhandle, &flags, &target))
return NULL;
if ( pyhandle != NULL )
{
if ( !PyList_Check(pyhandle) ||
(PyList_Size(pyhandle) != sizeof(xen_domain_handle_t)) )
goto out_exception;
for ( i = 0; i < sizeof(xen_domain_handle_t); i++ )
{
PyObject *p = PyList_GetItem(pyhandle, i);
if ( !PyInt_Check(p) )
goto out_exception;
handle[i] = (uint8_t)PyInt_AsLong(p);
}
}
if ( (ret = xc_domain_create(self->xc_handle, ssidref,
handle, flags, &dom)) < 0 )
return pyxc_error_to_exception();
if ( target )
if ( (ret = xc_domain_set_target(self->xc_handle, dom, target)) < 0 )
return pyxc_error_to_exception();
return PyInt_FromLong(dom);
out_exception:
errno = EINVAL;
PyErr_SetFromErrno(xc_error_obj);
return NULL;
}
static PyObject *pyxc_domain_max_vcpus(XcObject *self, PyObject *args)
{
uint32_t dom, max;
if (!PyArg_ParseTuple(args, "ii", &dom, &max))
return NULL;
if (xc_domain_max_vcpus(self->xc_handle, dom, max) != 0)
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_domain_pause(XcObject *self, PyObject *args)
{
return dom_op(self, args, xc_domain_pause);
}
static PyObject *pyxc_domain_unpause(XcObject *self, PyObject *args)
{
return dom_op(self, args, xc_domain_unpause);
}
static PyObject *pyxc_domain_destroy_hook(XcObject *self, PyObject *args)
{
#ifdef __ia64__
dom_op(self, args, xc_ia64_save_to_nvram);
#endif
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_domain_destroy(XcObject *self, PyObject *args)
{
return dom_op(self, args, xc_domain_destroy);
}
static PyObject *pyxc_domain_shutdown(XcObject *self, PyObject *args)
{
uint32_t dom, reason;
if ( !PyArg_ParseTuple(args, "ii", &dom, &reason) )
return NULL;
if ( xc_domain_shutdown(self->xc_handle, dom, reason) != 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_domain_resume(XcObject *self, PyObject *args)
{
uint32_t dom;
int fast;
if ( !PyArg_ParseTuple(args, "ii", &dom, &fast) )
return NULL;
if ( xc_domain_resume(self->xc_handle, dom, fast) != 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_vcpu_setaffinity(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom;
int vcpu = 0, i;
uint64_t cpumap = ~0ULL;
PyObject *cpulist = NULL;
static char *kwd_list[] = { "domid", "vcpu", "cpumap", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|iO", kwd_list,
&dom, &vcpu, &cpulist) )
return NULL;
if ( (cpulist != NULL) && PyList_Check(cpulist) )
{
cpumap = 0ULL;
for ( i = 0; i < PyList_Size(cpulist); i++ )
{
long cpu = PyInt_AsLong(PyList_GetItem(cpulist, i));
if ( cpu >= 64 )
{
errno = EINVAL;
PyErr_SetFromErrno(xc_error_obj);
return NULL;
}
cpumap |= (uint64_t)1 << cpu;
}
}
if ( xc_vcpu_setaffinity(self->xc_handle, dom, vcpu, cpumap) != 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_domain_sethandle(XcObject *self, PyObject *args)
{
int i;
uint32_t dom;
PyObject *pyhandle;
xen_domain_handle_t handle;
if (!PyArg_ParseTuple(args, "iO", &dom, &pyhandle))
return NULL;
if ( !PyList_Check(pyhandle) ||
(PyList_Size(pyhandle) != sizeof(xen_domain_handle_t)) )
{
goto out_exception;
}
for ( i = 0; i < sizeof(xen_domain_handle_t); i++ )
{
PyObject *p = PyList_GetItem(pyhandle, i);
if ( !PyInt_Check(p) )
goto out_exception;
handle[i] = (uint8_t)PyInt_AsLong(p);
}
if (xc_domain_sethandle(self->xc_handle, dom, handle) < 0)
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
out_exception:
PyErr_SetFromErrno(xc_error_obj);
return NULL;
}
static PyObject *pyxc_domain_getinfo(XcObject *self,
PyObject *args,
PyObject *kwds)
{
PyObject *list, *info_dict, *pyhandle;
uint32_t first_dom = 0;
int max_doms = 1024, nr_doms, i, j;
xc_dominfo_t *info;
static char *kwd_list[] = { "first_dom", "max_doms", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwd_list,
&first_dom, &max_doms) )
return NULL;
info = calloc(max_doms, sizeof(xc_dominfo_t));
if (info == NULL)
return PyErr_NoMemory();
nr_doms = xc_domain_getinfo(self->xc_handle, first_dom, max_doms, info);
if (nr_doms < 0)
{
free(info);
return pyxc_error_to_exception();
}
list = PyList_New(nr_doms);
for ( i = 0 ; i < nr_doms; i++ )
{
info_dict = Py_BuildValue(
"{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i"
",s:L,s:L,s:L,s:i,s:i}",
"domid", (int)info[i].domid,
"online_vcpus", info[i].nr_online_vcpus,
"max_vcpu_id", info[i].max_vcpu_id,
"hvm", info[i].hvm,
"dying", info[i].dying,
"crashed", info[i].crashed,
"shutdown", info[i].shutdown,
"paused", info[i].paused,
"blocked", info[i].blocked,
"running", info[i].running,
"mem_kb", (long long)info[i].nr_pages*(XC_PAGE_SIZE/1024),
"cpu_time", (long long)info[i].cpu_time,
"maxmem_kb", (long long)info[i].max_memkb,
"ssidref", (int)info[i].ssidref,
"shutdown_reason", info[i].shutdown_reason);
pyhandle = PyList_New(sizeof(xen_domain_handle_t));
if ( (pyhandle == NULL) || (info_dict == NULL) )
{
Py_DECREF(list);
if ( pyhandle != NULL ) { Py_DECREF(pyhandle); }
if ( info_dict != NULL ) { Py_DECREF(info_dict); }
free(info);
return NULL;
}
for ( j = 0; j < sizeof(xen_domain_handle_t); j++ )
PyList_SetItem(pyhandle, j, PyInt_FromLong(info[i].handle[j]));
PyDict_SetItemString(info_dict, "handle", pyhandle);
Py_DECREF(pyhandle);
PyList_SetItem(list, i, info_dict);
}
free(info);
return list;
}
static PyObject *pyxc_vcpu_getinfo(XcObject *self,
PyObject *args,
PyObject *kwds)
{
PyObject *info_dict, *cpulist;
uint32_t dom, vcpu = 0;
xc_vcpuinfo_t info;
int rc, i;
uint64_t cpumap;
static char *kwd_list[] = { "domid", "vcpu", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
&dom, &vcpu) )
return NULL;
rc = xc_vcpu_getinfo(self->xc_handle, dom, vcpu, &info);
if ( rc < 0 )
return pyxc_error_to_exception();
rc = xc_vcpu_getaffinity(self->xc_handle, dom, vcpu, &cpumap);
if ( rc < 0 )
return pyxc_error_to_exception();
info_dict = Py_BuildValue("{s:i,s:i,s:i,s:L,s:i}",
"online", info.online,
"blocked", info.blocked,
"running", info.running,
"cpu_time", info.cpu_time,
"cpu", info.cpu);
cpulist = PyList_New(0);
for ( i = 0; cpumap != 0; i++ )
{
if ( cpumap & 1 )
PyList_Append(cpulist, PyInt_FromLong(i));
cpumap >>= 1;
}
PyDict_SetItemString(info_dict, "cpumap", cpulist);
Py_DECREF(cpulist);
return info_dict;
}
static PyObject *pyxc_linux_build(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t domid;
struct xc_dom_image *dom;
char *image, *ramdisk = NULL, *cmdline = "", *features = NULL;
int flags = 0;
int store_evtchn, console_evtchn;
int vhpt = 0;
unsigned int mem_mb;
unsigned long store_mfn = 0;
unsigned long console_mfn = 0;
PyObject* elfnote_dict;
PyObject* elfnote = NULL;
PyObject* ret;
int i;
static char *kwd_list[] = { "domid", "store_evtchn", "memsize",
"console_evtchn", "image",
/* optional */
"ramdisk", "cmdline", "flags",
"features", "vhpt", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssisi", kwd_list,
&domid, &store_evtchn, &mem_mb,
&console_evtchn, &image,
/* optional */
&ramdisk, &cmdline, &flags,
&features, &vhpt) )
return NULL;
xc_dom_loginit();
if (!(dom = xc_dom_allocate(cmdline, features)))
return pyxc_error_to_exception();
/* for IA64 */
dom->vhpt_size_log2 = vhpt;
if ( xc_dom_linux_build(self->xc_handle, dom, domid, mem_mb, image,
ramdisk, flags, store_evtchn, &store_mfn,
console_evtchn, &console_mfn) != 0 ) {
goto out;
}
if ( !(elfnote_dict = PyDict_New()) )
goto out;
for ( i = 0; i < ARRAY_SIZE(dom->parms.elf_notes); i++ )
{
switch ( dom->parms.elf_notes[i].type )
{
case XEN_ENT_NONE:
continue;
case XEN_ENT_LONG:
elfnote = Py_BuildValue("k", dom->parms.elf_notes[i].data.num);
break;
case XEN_ENT_STR:
elfnote = Py_BuildValue("s", dom->parms.elf_notes[i].data.str);
break;
}
PyDict_SetItemString(elfnote_dict,
dom->parms.elf_notes[i].name,
elfnote);
Py_DECREF(elfnote);
}
ret = Py_BuildValue("{s:i,s:i,s:N}",
"store_mfn", store_mfn,
"console_mfn", console_mfn,
"notes", elfnote_dict);
if ( dom->arch_hooks->native_protocol )
{
PyObject *native_protocol =
Py_BuildValue("s", dom->arch_hooks->native_protocol);
PyDict_SetItemString(ret, "native_protocol", native_protocol);
Py_DECREF(native_protocol);
}
xc_dom_release(dom);
return ret;
out:
xc_dom_release(dom);
return pyxc_error_to_exception();
}
static PyObject *pyxc_get_hvm_param(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom;
int param;
unsigned long value;
static char *kwd_list[] = { "domid", "param", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
&dom, ¶m) )
return NULL;
if ( xc_get_hvm_param(self->xc_handle, dom, param, &value) != 0 )
return pyxc_error_to_exception();
return PyLong_FromUnsignedLong(value);
}
static PyObject *pyxc_set_hvm_param(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom;
int param;
uint64_t value;
static char *kwd_list[] = { "domid", "param", "value", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiL", kwd_list,
&dom, ¶m, &value) )
return NULL;
if ( xc_set_hvm_param(self->xc_handle, dom, param, value) != 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static int token_value(char *token)
{
token = strchr(token, 'x') + 1;
return strtol(token, NULL, 16);
}
static int next_bdf(char **str, int *seg, int *bus, int *dev, int *func)
{
char *token;
if ( !(*str) || !strchr(*str, ',') )
return 0;
token = *str;
*seg = token_value(token);
token = strchr(token, ',') + 1;
*bus = token_value(token);
token = strchr(token, ',') + 1;
*dev = token_value(token);
token = strchr(token, ',') + 1;
*func = token_value(token);
token = strchr(token, ',');
*str = token ? token + 1 : NULL;
return 1;
}
static PyObject *pyxc_test_assign_device(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom;
char *pci_str;
int32_t bdf = 0;
int seg, bus, dev, func;
static char *kwd_list[] = { "domid", "pci", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list,
&dom, &pci_str) )
return NULL;
while ( next_bdf(&pci_str, &seg, &bus, &dev, &func) )
{
bdf |= (bus & 0xff) << 16;
bdf |= (dev & 0x1f) << 11;
bdf |= (func & 0x7) << 8;
if ( xc_test_assign_device(self->xc_handle, dom, bdf) != 0 )
{
if (errno == ENOSYS)
bdf = -1;
break;
}
bdf = 0;
}
return Py_BuildValue("i", bdf);
}
static PyObject *pyxc_assign_device(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom;
char *pci_str;
int32_t bdf = 0;
int seg, bus, dev, func;
static char *kwd_list[] = { "domid", "pci", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list,
&dom, &pci_str) )
return NULL;
while ( next_bdf(&pci_str, &seg, &bus, &dev, &func) )
{
bdf |= (bus & 0xff) << 16;
bdf |= (dev & 0x1f) << 11;
bdf |= (func & 0x7) << 8;
if ( xc_assign_device(self->xc_handle, dom, bdf) != 0 )
{
if (errno == ENOSYS)
bdf = -1;
break;
}
bdf = 0;
}
return Py_BuildValue("i", bdf);
}
static PyObject *pyxc_deassign_device(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom;
char *pci_str;
int32_t bdf = 0;
int seg, bus, dev, func;
static char *kwd_list[] = { "domid", "pci", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list,
&dom, &pci_str) )
return NULL;
while ( next_bdf(&pci_str, &seg, &bus, &dev, &func) )
{
bdf |= (bus & 0xff) << 16;
bdf |= (dev & 0x1f) << 11;
bdf |= (func & 0x7) << 8;
if ( xc_deassign_device(self->xc_handle, dom, bdf) != 0 )
{
if (errno == ENOSYS)
bdf = -1;
break;
}
bdf = 0;
}
return Py_BuildValue("i", bdf);
}
static PyObject *pyxc_get_device_group(XcObject *self,
PyObject *args)
{
domid_t domid;
uint32_t bdf = 0;
uint32_t max_sdevs, num_sdevs;
int seg, bus, dev, func, rc, i;
PyObject *Pystr;
char *group_str;
char dev_str[9];
uint32_t *sdev_array;
if ( !PyArg_ParseTuple(args, "iiiii", &domid, &seg, &bus, &dev, &func) )
return NULL;
/* Maximum allowed siblings device number per group */
max_sdevs = 1024;
sdev_array = calloc(max_sdevs, sizeof(*sdev_array));
if (sdev_array == NULL)
return PyErr_NoMemory();
bdf |= (bus & 0xff) << 16;
bdf |= (dev & 0x1f) << 11;
bdf |= (func & 0x7) << 8;
rc = xc_get_device_group(self->xc_handle,
domid, bdf, max_sdevs, &num_sdevs, sdev_array);
if ( rc < 0 )
{
free(sdev_array);
return pyxc_error_to_exception();
}
if ( !num_sdevs )
{
free(sdev_array);
return Py_BuildValue("s", "");
}
group_str = calloc(num_sdevs, sizeof(dev_str));
if (group_str == NULL)
return PyErr_NoMemory();
for ( i = 0; i < num_sdevs; i++ )
{
bus = (sdev_array[i] >> 16) & 0xff;
dev = (sdev_array[i] >> 11) & 0x1f;
func = (sdev_array[i] >> 8) & 0x7;
snprintf(dev_str, sizeof(dev_str), "%02x:%02x.%x,", bus, dev, func);
strcat(group_str, dev_str);
}
Pystr = Py_BuildValue("s", group_str);
free(sdev_array);
free(group_str);
return Pystr;
}
#ifdef __ia64__
static PyObject *pyxc_nvram_init(XcObject *self,
PyObject *args)
{
char *dom_name;
uint32_t dom;
if ( !PyArg_ParseTuple(args, "si", &dom_name, &dom) )
return NULL;
xc_ia64_nvram_init(self->xc_handle, dom_name, dom);
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_set_os_type(XcObject *self,
PyObject *args)
{
char *os_type;
uint32_t dom;
if ( !PyArg_ParseTuple(args, "si", &os_type, &dom) )
return NULL;
xc_ia64_set_os_type(self->xc_handle, os_type, dom);
Py_INCREF(zero);
return zero;
}
#endif /* __ia64__ */
#if defined(__i386__) || defined(__x86_64__)
static void pyxc_dom_extract_cpuid(PyObject *config,
char **regs)
{
const char *regs_extract[4] = { "eax", "ebx", "ecx", "edx" };
PyObject *obj;
int i;
memset(regs, 0, 4*sizeof(*regs));
if ( !PyDict_Check(config) )
return;
for ( i = 0; i < 4; i++ )
if ( (obj = PyDict_GetItemString(config, regs_extract[i])) != NULL )
regs[i] = PyString_AS_STRING(obj);
}
static PyObject *pyxc_create_cpuid_dict(char **regs)
{
const char *regs_extract[4] = { "eax", "ebx", "ecx", "edx" };
PyObject *dict;
int i;
dict = PyDict_New();
for ( i = 0; i < 4; i++ )
{
if ( regs[i] == NULL )
continue;
PyDict_SetItemString(dict, regs_extract[i],
PyString_FromString(regs[i]));
free(regs[i]);
regs[i] = NULL;
}
return dict;
}
static PyObject *pyxc_dom_check_cpuid(XcObject *self,
PyObject *args)
{
PyObject *sub_input, *config;
unsigned int input[2];
char *regs[4], *regs_transform[4];
if ( !PyArg_ParseTuple(args, "iOO", &input[0], &sub_input, &config) )
return NULL;
pyxc_dom_extract_cpuid(config, regs);
input[1] = XEN_CPUID_INPUT_UNUSED;
if ( PyLong_Check(sub_input) )
input[1] = PyLong_AsUnsignedLong(sub_input);
if ( xc_cpuid_check(self->xc_handle, input,
(const char **)regs, regs_transform) )
return pyxc_error_to_exception();
return pyxc_create_cpuid_dict(regs_transform);
}
static PyObject *pyxc_dom_set_policy_cpuid(XcObject *self,
PyObject *args)
{
domid_t domid;
if ( !PyArg_ParseTuple(args, "i", &domid) )
return NULL;
if ( xc_cpuid_apply_policy(self->xc_handle, domid) )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_dom_set_cpuid(XcObject *self,
PyObject *args)
{
domid_t domid;
PyObject *sub_input, *config;
unsigned int input[2];
char *regs[4], *regs_transform[4];
if ( !PyArg_ParseTuple(args, "IIOO", &domid,
&input[0], &sub_input, &config) )
return NULL;
pyxc_dom_extract_cpuid(config, regs);
input[1] = XEN_CPUID_INPUT_UNUSED;
if ( PyLong_Check(sub_input) )
input[1] = PyLong_AsUnsignedLong(sub_input);
if ( xc_cpuid_set(self->xc_handle, domid, input, (const char **)regs,
regs_transform) )
return pyxc_error_to_exception();
return pyxc_create_cpuid_dict(regs_transform);
}
static PyObject *pyxc_dom_set_machine_address_size(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom, width;
if (!PyArg_ParseTuple(args, "ii", &dom, &width))
return NULL;
if (xc_domain_set_machine_address_size(self->xc_handle, dom, width) != 0)
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_dom_suppress_spurious_page_faults(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom;
if (!PyArg_ParseTuple(args, "i", &dom))
return NULL;
if (xc_domain_suppress_spurious_page_faults(self->xc_handle, dom) != 0)
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
#endif /* __i386__ || __x86_64__ */
static PyObject *pyxc_hvm_build(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom;
#if !defined(__ia64__)
struct hvm_info_table *va_hvm;
uint8_t *va_map, sum;
int i;
#endif
char *image;
int memsize, vcpus = 1, acpi = 0, apic = 1;
static char *kwd_list[] = { "domid",
"memsize", "image", "vcpus", "acpi",
"apic", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iii", kwd_list,
&dom, &memsize,
&image, &vcpus, &acpi, &apic) )
return NULL;
if ( xc_hvm_build(self->xc_handle, dom, memsize, image) != 0 )
return pyxc_error_to_exception();
#if !defined(__ia64__)
/* Set up the HVM info table. */
va_map = xc_map_foreign_range(self->xc_handle, dom, XC_PAGE_SIZE,
PROT_READ | PROT_WRITE,
HVM_INFO_PFN);
if ( va_map == NULL )
return PyErr_SetFromErrno(xc_error_obj);
va_hvm = (struct hvm_info_table *)(va_map + HVM_INFO_OFFSET);
memset(va_hvm, 0, sizeof(*va_hvm));
strncpy(va_hvm->signature, "HVM INFO", 8);
va_hvm->length = sizeof(struct hvm_info_table);
va_hvm->acpi_enabled = acpi;
va_hvm->apic_mode = apic;
va_hvm->nr_vcpus = vcpus;
for ( i = 0, sum = 0; i < va_hvm->length; i++ )
sum += ((uint8_t *)va_hvm)[i];
va_hvm->checksum = -sum;
munmap(va_map, XC_PAGE_SIZE);
#endif
return Py_BuildValue("{}");
}
static PyObject *pyxc_evtchn_alloc_unbound(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom, remote_dom;
int port;
static char *kwd_list[] = { "domid", "remote_dom", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
&dom, &remote_dom) )
return NULL;
if ( (port = xc_evtchn_alloc_unbound(self->xc_handle, dom, remote_dom)) < 0 )
return pyxc_error_to_exception();
return PyInt_FromLong(port);
}
static PyObject *pyxc_evtchn_reset(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom;
static char *kwd_list[] = { "dom", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
return NULL;
if ( xc_evtchn_reset(self->xc_handle, dom) < 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_physdev_map_pirq(PyObject *self,
PyObject *args,
PyObject *kwds)
{
XcObject *xc = (XcObject *)self;
uint32_t dom;
int index, pirq, ret;
static char *kwd_list[] = {"domid", "index", "pirq", NULL};
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iii", kwd_list,
&dom, &index, &pirq) )
return NULL;
ret = xc_physdev_map_pirq(xc->xc_handle, dom, index, &pirq);
if ( ret != 0 )
return pyxc_error_to_exception();
return PyLong_FromUnsignedLong(pirq);
}
static PyObject *pyxc_physdev_pci_access_modify(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom;
int bus, dev, func, enable, ret;
static char *kwd_list[] = { "domid", "bus", "dev", "func", "enable", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiii", kwd_list,
&dom, &bus, &dev, &func, &enable) )
return NULL;
ret = xc_physdev_pci_access_modify(
self->xc_handle, dom, bus, dev, func, enable);
if ( ret != 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_readconsolering(XcObject *self,
PyObject *args,
PyObject *kwds)
{
unsigned int clear = 0, index = 0, incremental = 0;
char _str[32768], *str = _str;
unsigned int count = 32768;
int ret;
static char *kwd_list[] = { "clear", "index", "incremental", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iii", kwd_list,
&clear, &index, &incremental) )
return NULL;
ret = xc_readconsolering(self->xc_handle, &str, &count, clear,
incremental, &index);
if ( ret < 0 )
return pyxc_error_to_exception();
return PyString_FromStringAndSize(str, count);
}
static unsigned long pages_to_kib(unsigned long pages)
{
return pages * (XC_PAGE_SIZE / 1024);
}
static PyObject *pyxc_pages_to_kib(XcObject *self, PyObject *args)
{
unsigned long pages;
if (!PyArg_ParseTuple(args, "l", &pages))
return NULL;
return PyLong_FromUnsignedLong(pages_to_kib(pages));
}
static PyObject *pyxc_physinfo(XcObject *self)
{
#define MAX_CPU_ID 255
xc_physinfo_t info;
char cpu_cap[128], virt_caps[128], *p;
int i, j, max_cpu_id;
uint64_t free_heap;
PyObject *ret_obj, *node_to_cpu_obj, *node_to_memory_obj;
xc_cpu_to_node_t map[MAX_CPU_ID + 1];
const char *virtcap_names[] = { "hvm", "hvm_directio" };
set_xen_guest_handle(info.cpu_to_node, map);
info.max_cpu_id = MAX_CPU_ID;
if ( xc_physinfo(self->xc_handle, &info) != 0 )
return pyxc_error_to_exception();
p = cpu_cap;
*p = '\0';
for ( i = 0; i < sizeof(info.hw_cap)/4; i++ )
p += sprintf(p, "%08x:", info.hw_cap[i]);
*(p-1) = 0;
p = virt_caps;
*p = '\0';
for ( i = 0; i < 2; i++ )
if ( (info.capabilities >> i) & 1 )
p += sprintf(p, "%s ", virtcap_names[i]);
if ( p != virt_caps )
*(p-1) = '\0';
ret_obj = Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:l,s:l,s:l,s:i,s:s:s:s}",
"nr_nodes", info.nr_nodes,
"max_cpu_id", info.max_cpu_id,
"threads_per_core", info.threads_per_core,
"cores_per_socket", info.cores_per_socket,
"nr_cpus", info.nr_cpus,
"total_memory", pages_to_kib(info.total_pages),
"free_memory", pages_to_kib(info.free_pages),
"scrub_memory", pages_to_kib(info.scrub_pages),
"cpu_khz", info.cpu_khz,
"hw_caps", cpu_cap,
"virt_caps", virt_caps);
max_cpu_id = info.max_cpu_id;
if ( max_cpu_id > MAX_CPU_ID )
max_cpu_id = MAX_CPU_ID;
/* Construct node-to-cpu lists. */
node_to_cpu_obj = PyList_New(0);
/* Make a list for each node. */
for ( i = 0; i < info.nr_nodes; i++ )
{
PyObject *cpus = PyList_New(0);
for ( j = 0; j <= max_cpu_id; j++ )
if ( i == map[j])
PyList_Append(cpus, PyInt_FromLong(j));
PyList_Append(node_to_cpu_obj, cpus);
}
node_to_memory_obj = PyList_New(0);
for ( i = 0; i < info.nr_nodes; i++ )
{
xc_availheap(self->xc_handle, 0, 0, i, &free_heap);
PyList_Append(node_to_memory_obj,
PyInt_FromLong(free_heap / 1024));
}
PyDict_SetItemString(ret_obj, "node_to_cpu", node_to_cpu_obj);
PyDict_SetItemString(ret_obj, "node_to_memory", node_to_memory_obj);
return ret_obj;
#undef MAX_CPU_ID
}
static PyObject *pyxc_xeninfo(XcObject *self)
{
xen_extraversion_t xen_extra;
xen_compile_info_t xen_cc;
xen_changeset_info_t xen_chgset;
xen_capabilities_info_t xen_caps;
xen_platform_parameters_t p_parms;
long xen_version;
long xen_pagesize;
char str[128];
xen_version = xc_version(self->xc_handle, XENVER_version, NULL);
if ( xc_version(self->xc_handle, XENVER_extraversion, &xen_extra) != 0 )
return pyxc_error_to_exception();
if ( xc_version(self->xc_handle, XENVER_compile_info, &xen_cc) != 0 )
return pyxc_error_to_exception();
if ( xc_version(self->xc_handle, XENVER_changeset, &xen_chgset) != 0 )
return pyxc_error_to_exception();
if ( xc_version(self->xc_handle, XENVER_capabilities, &xen_caps) != 0 )
return pyxc_error_to_exception();
if ( xc_version(self->xc_handle, XENVER_platform_parameters, &p_parms) != 0 )
return pyxc_error_to_exception();
snprintf(str, sizeof(str), "virt_start=0x%lx", p_parms.virt_start);
xen_pagesize = xc_version(self->xc_handle, XENVER_pagesize, NULL);
if (xen_pagesize < 0 )
return pyxc_error_to_exception();
return Py_BuildValue("{s:i,s:i,s:s,s:s,s:i,s:s,s:s,s:s,s:s,s:s,s:s}",
"xen_major", xen_version >> 16,
"xen_minor", (xen_version & 0xffff),
"xen_extra", xen_extra,
"xen_caps", xen_caps,
"xen_pagesize", xen_pagesize,
"platform_params", str,
"xen_changeset", xen_chgset,
"cc_compiler", xen_cc.compiler,
"cc_compile_by", xen_cc.compile_by,
"cc_compile_domain", xen_cc.compile_domain,
"cc_compile_date", xen_cc.compile_date);
}
static PyObject *pyxc_sedf_domain_set(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t domid;
uint64_t period, slice, latency;
uint16_t extratime, weight;
static char *kwd_list[] = { "domid", "period", "slice",
"latency", "extratime", "weight",NULL };
if( !PyArg_ParseTupleAndKeywords(args, kwds, "iLLLhh", kwd_list,
&domid, &period, &slice,
&latency, &extratime, &weight) )
return NULL;
if ( xc_sedf_domain_set(self->xc_handle, domid, period,
slice, latency, extratime,weight) != 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_sedf_domain_get(XcObject *self, PyObject *args)
{
uint32_t domid;
uint64_t period, slice,latency;
uint16_t weight, extratime;
if(!PyArg_ParseTuple(args, "i", &domid))
return NULL;
if (xc_sedf_domain_get(self->xc_handle, domid, &period,
&slice,&latency,&extratime,&weight))
return pyxc_error_to_exception();
return Py_BuildValue("{s:i,s:L,s:L,s:L,s:i,s:i}",
"domid", domid,
"period", period,
"slice", slice,
"latency", latency,
"extratime", extratime,
"weight", weight);
}
static PyObject *pyxc_shadow_control(PyObject *self,
PyObject *args,
PyObject *kwds)
{
XcObject *xc = (XcObject *)self;
uint32_t dom;
int op=0;
static char *kwd_list[] = { "dom", "op", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
&dom, &op) )
return NULL;
if ( xc_shadow_control(xc->xc_handle, dom, op, NULL, 0, NULL, 0, NULL)
< 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_shadow_mem_control(PyObject *self,
PyObject *args,
PyObject *kwds)
{
XcObject *xc = (XcObject *)self;
int op;
uint32_t dom;
int mbarg = -1;
unsigned long mb;
static char *kwd_list[] = { "dom", "mb", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
&dom, &mbarg) )
return NULL;
if ( mbarg < 0 )
op = XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION;
else
{
mb = mbarg;
op = XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION;
}
if ( xc_shadow_control(xc->xc_handle, dom, op, NULL, 0, &mb, 0, NULL) < 0 )
return pyxc_error_to_exception();
mbarg = mb;
return Py_BuildValue("i", mbarg);
}
static PyObject *pyxc_sched_id_get(XcObject *self) {
int sched_id;
if (xc_sched_id(self->xc_handle, &sched_id) != 0)
return PyErr_SetFromErrno(xc_error_obj);
return Py_BuildValue("i", sched_id);
}
static PyObject *pyxc_sched_credit_domain_set(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t domid;
uint16_t weight;
uint16_t cap;
static char *kwd_list[] = { "domid", "weight", "cap", NULL };
static char kwd_type[] = "I|HH";
struct xen_domctl_sched_credit sdom;
weight = 0;
cap = (uint16_t)~0U;
if( !PyArg_ParseTupleAndKeywords(args, kwds, kwd_type, kwd_list,
&domid, &weight, &cap) )
return NULL;
sdom.weight = weight;
sdom.cap = cap;
if ( xc_sched_credit_domain_set(self->xc_handle, domid, &sdom) != 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_sched_credit_domain_get(XcObject *self, PyObject *args)
{
uint32_t domid;
struct xen_domctl_sched_credit sdom;
if( !PyArg_ParseTuple(args, "I", &domid) )
return NULL;
if ( xc_sched_credit_domain_get(self->xc_handle, domid, &sdom) != 0 )
return pyxc_error_to_exception();
return Py_BuildValue("{s:H,s:H}",
"weight", sdom.weight,
"cap", sdom.cap);
}
static PyObject *pyxc_domain_setmaxmem(XcObject *self, PyObject *args)
{
uint32_t dom;
unsigned int maxmem_kb;
if (!PyArg_ParseTuple(args, "ii", &dom, &maxmem_kb))
return NULL;
if (xc_domain_setmaxmem(self->xc_handle, dom, maxmem_kb) != 0)
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_domain_set_memmap_limit(XcObject *self, PyObject *args)
{
uint32_t dom;
unsigned int maplimit_kb;
if ( !PyArg_ParseTuple(args, "ii", &dom, &maplimit_kb) )
return NULL;
if ( xc_domain_set_memmap_limit(self->xc_handle, dom, maplimit_kb) != 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_domain_ioport_permission(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom;
int first_port, nr_ports, allow_access, ret;
static char *kwd_list[] = { "domid", "first_port", "nr_ports", "allow_access", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiii", kwd_list,
&dom, &first_port, &nr_ports, &allow_access) )
return NULL;
ret = xc_domain_ioport_permission(
self->xc_handle, dom, first_port, nr_ports, allow_access);
if ( ret != 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_domain_irq_permission(PyObject *self,
PyObject *args,
PyObject *kwds)
{
XcObject *xc = (XcObject *)self;
uint32_t dom;
int pirq, allow_access, ret;
static char *kwd_list[] = { "domid", "pirq", "allow_access", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iii", kwd_list,
&dom, &pirq, &allow_access) )
return NULL;
ret = xc_domain_irq_permission(
xc->xc_handle, dom, pirq, allow_access);
if ( ret != 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_domain_iomem_permission(PyObject *self,
PyObject *args,
PyObject *kwds)
{
XcObject *xc = (XcObject *)self;
uint32_t dom;
unsigned long first_pfn, nr_pfns, allow_access, ret;
static char *kwd_list[] = { "domid", "first_pfn", "nr_pfns", "allow_access", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "illi", kwd_list,
&dom, &first_pfn, &nr_pfns, &allow_access) )
return NULL;
ret = xc_domain_iomem_permission(
xc->xc_handle, dom, first_pfn, nr_pfns, allow_access);
if ( ret != 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_domain_set_time_offset(XcObject *self, PyObject *args)
{
uint32_t dom;
int32_t offset;
if (!PyArg_ParseTuple(args, "ii", &dom, &offset))
return NULL;
if (xc_domain_set_time_offset(self->xc_handle, dom, offset) != 0)
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_domain_send_trigger(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom;
int trigger, vcpu = 0;
static char *kwd_list[] = { "domid", "trigger", "vcpu", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii|i", kwd_list,
&dom, &trigger, &vcpu) )
return NULL;
if (xc_domain_send_trigger(self->xc_handle, dom, trigger, vcpu) != 0)
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_send_debug_keys(XcObject *self,
PyObject *args,
PyObject *kwds)
{
char *keys;
static char *kwd_list[] = { "keys", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "s", kwd_list, &keys) )
return NULL;
if ( xc_send_debug_keys(self->xc_handle, keys) != 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *dom_op(XcObject *self, PyObject *args,
int (*fn)(int, uint32_t))
{
uint32_t dom;
if (!PyArg_ParseTuple(args, "i", &dom))
return NULL;
if (fn(self->xc_handle, dom) != 0)
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyMethodDef pyxc_methods[] = {
{ "handle",
(PyCFunction)pyxc_handle,
METH_NOARGS, "\n"
"Query the xc control interface file descriptor.\n\n"
"Returns: [int] file descriptor\n" },
{ "domain_create",
(PyCFunction)pyxc_domain_create,
METH_VARARGS | METH_KEYWORDS, "\n"
"Create a new domain.\n"
" dom [int, 0]: Domain identifier to use (allocated if zero).\n"
"Returns: [int] new domain identifier; -1 on error.\n" },
{ "domain_max_vcpus",
(PyCFunction)pyxc_domain_max_vcpus,
METH_VARARGS, "\n"
"Set the maximum number of VCPUs a domain may create.\n"
" dom [int, 0]: Domain identifier to use.\n"
" max [int, 0]: New maximum number of VCPUs in domain.\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_dumpcore",
(PyCFunction)pyxc_domain_dumpcore,
METH_VARARGS, "\n"
"Dump core of a domain.\n"
" dom [int]: Identifier of domain to dump core of.\n"
" corefile [string]: Name of corefile to be created.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_pause",
(PyCFunction)pyxc_domain_pause,
METH_VARARGS, "\n"
"Temporarily pause execution of a domain.\n"
" dom [int]: Identifier of domain to be paused.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_unpause",
(PyCFunction)pyxc_domain_unpause,
METH_VARARGS, "\n"
"(Re)start execution of a domain.\n"
" dom [int]: Identifier of domain to be unpaused.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_destroy",
(PyCFunction)pyxc_domain_destroy,
METH_VARARGS, "\n"
"Destroy a domain.\n"
" dom [int]: Identifier of domain to be destroyed.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_destroy_hook",
(PyCFunction)pyxc_domain_destroy_hook,
METH_VARARGS, "\n"
"Add a hook for arch stuff before destroy a domain.\n"
" dom [int]: Identifier of domain to be destroyed.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_resume",
(PyCFunction)pyxc_domain_resume,
METH_VARARGS, "\n"
"Resume execution of a suspended domain.\n"
" dom [int]: Identifier of domain to be resumed.\n"
" fast [int]: Use cooperative resume.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_shutdown",
(PyCFunction)pyxc_domain_shutdown,
METH_VARARGS, "\n"
"Shutdown a domain.\n"
" dom [int, 0]: Domain identifier to use.\n"
" reason [int, 0]: Reason for shutdown.\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "vcpu_setaffinity",
(PyCFunction)pyxc_vcpu_setaffinity,
METH_VARARGS | METH_KEYWORDS, "\n"
"Pin a VCPU to a specified set CPUs.\n"
" dom [int]: Identifier of domain to which VCPU belongs.\n"
" vcpu [int, 0]: VCPU being pinned.\n"
" cpumap [list, []]: list of usable CPUs.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_sethandle",
(PyCFunction)pyxc_domain_sethandle,
METH_VARARGS, "\n"
"Set domain's opaque handle.\n"
" dom [int]: Identifier of domain.\n"
" handle [list of 16 ints]: New opaque handle.\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_getinfo",
(PyCFunction)pyxc_domain_getinfo,
METH_VARARGS | METH_KEYWORDS, "\n"
"Get information regarding a set of domains, in increasing id order.\n"
" first_dom [int, 0]: First domain to retrieve info about.\n"
" max_doms [int, 1024]: Maximum number of domains to retrieve info"
" about.\n\n"
"Returns: [list of dicts] if list length is less than 'max_doms'\n"
" parameter then there was an error, or the end of the\n"
" domain-id space was reached.\n"
" dom [int]: Identifier of domain to which this info pertains\n"
" cpu [int]: CPU to which this domain is bound\n"
" vcpus [int]: Number of Virtual CPUS in this domain\n"
" dying [int]: Bool - is the domain dying?\n"
" crashed [int]: Bool - has the domain crashed?\n"
" shutdown [int]: Bool - has the domain shut itself down?\n"
" paused [int]: Bool - is the domain paused by control software?\n"
" blocked [int]: Bool - is the domain blocked waiting for an event?\n"
" running [int]: Bool - is the domain currently running?\n"
" mem_kb [int]: Memory reservation, in kilobytes\n"
" maxmem_kb [int]: Maximum memory limit, in kilobytes\n"
" cpu_time [long]: CPU time consumed, in nanoseconds\n"
" shutdown_reason [int]: Numeric code from guest OS, explaining "
"reason why it shut itself down.\n" },
{ "vcpu_getinfo",
(PyCFunction)pyxc_vcpu_getinfo,
METH_VARARGS | METH_KEYWORDS, "\n"
"Get information regarding a VCPU.\n"
" dom [int]: Domain to retrieve info about.\n"
" vcpu [int, 0]: VCPU to retrieve info about.\n\n"
"Returns: [dict]\n"
" online [int]: Bool - Is this VCPU currently online?\n"
" blocked [int]: Bool - Is this VCPU blocked waiting for an event?\n"
" running [int]: Bool - Is this VCPU currently running on a CPU?\n"
" cpu_time [long]: CPU time consumed, in nanoseconds\n"
" cpumap [int]: Bitmap of CPUs this VCPU can run on\n"
" cpu [int]: CPU that this VCPU is currently bound to\n" },
{ "linux_build",
(PyCFunction)pyxc_linux_build,
METH_VARARGS | METH_KEYWORDS, "\n"
"Build a new Linux guest OS.\n"
" dom [int]: Identifier of domain to build into.\n"
" image [str]: Name of kernel image file. May be gzipped.\n"
" ramdisk [str, n/a]: Name of ramdisk file, if any.\n"
" cmdline [str, n/a]: Kernel parameters, if any.\n\n"
" vcpus [int, 1]: Number of Virtual CPUS in domain.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "hvm_build",
(PyCFunction)pyxc_hvm_build,
METH_VARARGS | METH_KEYWORDS, "\n"
"Build a new HVM guest OS.\n"
" dom [int]: Identifier of domain to build into.\n"
" image [str]: Name of HVM loader image file.\n"
" vcpus [int, 1]: Number of Virtual CPUS in domain.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "hvm_get_param",
(PyCFunction)pyxc_get_hvm_param,
METH_VARARGS | METH_KEYWORDS, "\n"
"get a parameter of HVM guest OS.\n"
" dom [int]: Identifier of domain to build into.\n"
" param [int]: No. of HVM param.\n"
"Returns: [long] value of the param.\n" },
{ "hvm_set_param",
(PyCFunction)pyxc_set_hvm_param,
METH_VARARGS | METH_KEYWORDS, "\n"
"set a parameter of HVM guest OS.\n"
" dom [int]: Identifier of domain to build into.\n"
" param [int]: No. of HVM param.\n"
" value [long]: Value of param.\n"
"Returns: [int] 0 on success.\n" },
{ "get_device_group",
(PyCFunction)pyxc_get_device_group,
METH_VARARGS, "\n"
"get sibling devices infomation.\n"
" dom [int]: Domain to assign device to.\n"
" seg [int]: PCI segment.\n"
" bus [int]: PCI bus.\n"
" dev [int]: PCI dev.\n"
" func [int]: PCI func.\n"
"Returns: [string]: Sibling devices \n" },
{ "test_assign_device",
(PyCFunction)pyxc_test_assign_device,
METH_VARARGS | METH_KEYWORDS, "\n"
"test device assignment with VT-d.\n"
" dom [int]: Identifier of domain to build into.\n"
" pci_str [str]: PCI devices.\n"
"Returns: [int] 0 on success, or device bdf that can't be assigned.\n" },
{ "assign_device",
(PyCFunction)pyxc_assign_device,
METH_VARARGS | METH_KEYWORDS, "\n"
"Assign device to IOMMU domain.\n"
" dom [int]: Domain to assign device to.\n"
" pci_str [str]: PCI devices.\n"
"Returns: [int] 0 on success, or device bdf that can't be assigned.\n" },
{ "deassign_device",
(PyCFunction)pyxc_deassign_device,
METH_VARARGS | METH_KEYWORDS, "\n"
"Deassign device from IOMMU domain.\n"
" dom [int]: Domain to deassign device from.\n"
" pci_str [str]: PCI devices.\n"
"Returns: [int] 0 on success, or device bdf that can't be deassigned.\n" },
{ "sched_id_get",
(PyCFunction)pyxc_sched_id_get,
METH_NOARGS, "\n"
"Get the current scheduler type in use.\n"
"Returns: [int] sched_id.\n" },
{ "sedf_domain_set",
(PyCFunction)pyxc_sedf_domain_set,
METH_KEYWORDS, "\n"
"Set the scheduling parameters for a domain when running with Atropos.\n"
" dom [int]: domain to set\n"
" period [long]: domain's scheduling period\n"
" slice [long]: domain's slice per period\n"
" latency [long]: domain's wakeup latency hint\n"
" extratime [int]: domain aware of extratime?\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "sedf_domain_get",
(PyCFunction)pyxc_sedf_domain_get,
METH_VARARGS, "\n"
"Get the current scheduling parameters for a domain when running with\n"
"the Atropos scheduler."
" dom [int]: domain to query\n"
"Returns: [dict]\n"
" domain [int]: domain ID\n"
" period [long]: scheduler period\n"
" slice [long]: CPU reservation per period\n"
" latency [long]: domain's wakeup latency hint\n"
" extratime [int]: domain aware of extratime?\n"},
{ "sched_credit_domain_set",
(PyCFunction)pyxc_sched_credit_domain_set,
METH_KEYWORDS, "\n"
"Set the scheduling parameters for a domain when running with the\n"
"SMP credit scheduler.\n"
" domid [int]: domain id to set\n"
" weight [short]: domain's scheduling weight\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "sched_credit_domain_get",
(PyCFunction)pyxc_sched_credit_domain_get,
METH_VARARGS, "\n"
"Get the scheduling parameters for a domain when running with the\n"
"SMP credit scheduler.\n"
" domid [int]: domain id to get\n"
"Returns: [dict]\n"
" weight [short]: domain's scheduling weight\n"},
{ "evtchn_alloc_unbound",
(PyCFunction)pyxc_evtchn_alloc_unbound,
METH_VARARGS | METH_KEYWORDS, "\n"
"Allocate an unbound port that will await a remote connection.\n"
" dom [int]: Domain whose port space to allocate from.\n"
" remote_dom [int]: Remote domain to accept connections from.\n\n"
"Returns: [int] Unbound event-channel port.\n" },
{ "evtchn_reset",
(PyCFunction)pyxc_evtchn_reset,
METH_VARARGS | METH_KEYWORDS, "\n"
"Reset all connections.\n"
" dom [int]: Domain to reset.\n" },
{ "physdev_map_pirq",
(PyCFunction)pyxc_physdev_map_pirq,
METH_VARARGS | METH_KEYWORDS, "\n"
"map physical irq to guest pirq.\n"
" dom [int]: Identifier of domain to map for.\n"
" index [int]: physical irq.\n"
" pirq [int]: guest pirq.\n"
"Returns: [long] value of the param.\n" },
{ "physdev_pci_access_modify",
(PyCFunction)pyxc_physdev_pci_access_modify,
METH_VARARGS | METH_KEYWORDS, "\n"
"Allow a domain access to a PCI device\n"
" dom [int]: Identifier of domain to be allowed access.\n"
" bus [int]: PCI bus\n"
" dev [int]: PCI slot\n"
" func [int]: PCI function\n"
" enable [int]: Non-zero means enable access; else disable access\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "readconsolering",
(PyCFunction)pyxc_readconsolering,
METH_VARARGS | METH_KEYWORDS, "\n"
"Read Xen's console ring.\n"
" clear [int, 0]: Bool - clear the ring after reading from it?\n\n"
"Returns: [str] string is empty on failure.\n" },
{ "physinfo",
(PyCFunction)pyxc_physinfo,
METH_NOARGS, "\n"
"Get information about the physical host machine\n"
"Returns [dict]: information about the hardware"
" [None]: on failure.\n" },
{ "xeninfo",
(PyCFunction)pyxc_xeninfo,
METH_NOARGS, "\n"
"Get information about the Xen host\n"
"Returns [dict]: information about Xen"
" [None]: on failure.\n" },
{ "shadow_control",
(PyCFunction)pyxc_shadow_control,
METH_VARARGS | METH_KEYWORDS, "\n"
"Set parameter for shadow pagetable interface\n"
" dom [int]: Identifier of domain.\n"
" op [int, 0]: operation\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "shadow_mem_control",
(PyCFunction)pyxc_shadow_mem_control,
METH_VARARGS | METH_KEYWORDS, "\n"
"Set or read shadow pagetable memory use\n"
" dom [int]: Identifier of domain.\n"
" mb [int, -1]: MB of shadow memory this domain should have.\n\n"
"Returns: [int] MB of shadow memory in use by this domain.\n" },
{ "domain_setmaxmem",
(PyCFunction)pyxc_domain_setmaxmem,
METH_VARARGS, "\n"
"Set a domain's memory limit\n"
" dom [int]: Identifier of domain.\n"
" maxmem_kb [int]: .\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_set_memmap_limit",
(PyCFunction)pyxc_domain_set_memmap_limit,
METH_VARARGS, "\n"
"Set a domain's physical memory mappping limit\n"
" dom [int]: Identifier of domain.\n"
" map_limitkb [int]: .\n"
"Returns: [int] 0 on success; -1 on error.\n" },
#ifdef __ia64__
{ "nvram_init",
(PyCFunction)pyxc_nvram_init,
METH_VARARGS, "\n"
"Init nvram in IA64 platform\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "set_os_type",
(PyCFunction)pyxc_set_os_type,
METH_VARARGS, "\n"
"Set guest OS type on IA64 platform\n"
"Returns: [int] 0 on success; -1 on error.\n" },
#endif /* __ia64__ */
{ "domain_ioport_permission",
(PyCFunction)pyxc_domain_ioport_permission,
METH_VARARGS | METH_KEYWORDS, "\n"
"Allow a domain access to a range of IO ports\n"
" dom [int]: Identifier of domain to be allowed access.\n"
" first_port [int]: First IO port\n"
" nr_ports [int]: Number of IO ports\n"
" allow_access [int]: Non-zero means enable access; else disable access\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_irq_permission",
(PyCFunction)pyxc_domain_irq_permission,
METH_VARARGS | METH_KEYWORDS, "\n"
"Allow a domain access to a physical IRQ\n"
" dom [int]: Identifier of domain to be allowed access.\n"
" pirq [int]: The Physical IRQ\n"
" allow_access [int]: Non-zero means enable access; else disable access\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_iomem_permission",
(PyCFunction)pyxc_domain_iomem_permission,
METH_VARARGS | METH_KEYWORDS, "\n"
"Allow a domain access to a range of IO memory pages\n"
" dom [int]: Identifier of domain to be allowed access.\n"
" first_pfn [long]: First page of I/O Memory\n"
" nr_pfns [long]: Number of pages of I/O Memory (>0)\n"
" allow_access [int]: Non-zero means enable access; else disable access\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "pages_to_kib",
(PyCFunction)pyxc_pages_to_kib,
METH_VARARGS, "\n"
"Returns: [int]: The size in KiB of memory spanning the given number "
"of pages.\n" },
{ "domain_set_time_offset",
(PyCFunction)pyxc_domain_set_time_offset,
METH_VARARGS, "\n"
"Set a domain's time offset to Dom0's localtime\n"
" dom [int]: Domain whose time offset is being set.\n"
" offset [int]: Time offset from UTC in seconds.\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_send_trigger",
(PyCFunction)pyxc_domain_send_trigger,
METH_VARARGS | METH_KEYWORDS, "\n"
"Send trigger to a domain.\n"
" dom [int]: Identifier of domain to be sent trigger.\n"
" trigger [int]: Trigger type number.\n"
" vcpu [int]: VCPU to be sent trigger.\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "send_debug_keys",
(PyCFunction)pyxc_send_debug_keys,
METH_VARARGS | METH_KEYWORDS, "\n"
"Inject debug keys into Xen.\n"
" keys [str]: String of keys to inject.\n" },
#if defined(__i386__) || defined(__x86_64__)
{ "domain_check_cpuid",
(PyCFunction)pyxc_dom_check_cpuid,
METH_VARARGS, "\n"
"Apply checks to host CPUID.\n"
" input [long]: Input for cpuid instruction (eax)\n"
" sub_input [long]: Second input (optional, may be None) for cpuid "
" instruction (ecx)\n"
" config [dict]: Dictionary of register\n"
" config [dict]: Dictionary of register, use for checking\n\n"
"Returns: [int] 0 on success; exception on error.\n" },
{ "domain_set_cpuid",
(PyCFunction)pyxc_dom_set_cpuid,
METH_VARARGS, "\n"
"Set cpuid response for an input and a domain.\n"
" dom [int]: Identifier of domain.\n"
" input [long]: Input for cpuid instruction (eax)\n"
" sub_input [long]: Second input (optional, may be None) for cpuid "
" instruction (ecx)\n"
" config [dict]: Dictionary of register\n\n"
"Returns: [int] 0 on success; exception on error.\n" },
{ "domain_set_policy_cpuid",
(PyCFunction)pyxc_dom_set_policy_cpuid,
METH_VARARGS, "\n"
"Set the default cpuid policy for a domain.\n"
" dom [int]: Identifier of domain.\n\n"
"Returns: [int] 0 on success; exception on error.\n" },
{ "domain_set_machine_address_size",
(PyCFunction)pyxc_dom_set_machine_address_size,
METH_VARARGS, "\n"
"Set maximum machine address size for this domain.\n"
" dom [int]: Identifier of domain.\n"
" width [int]: Maximum machine address width.\n" },
{ "domain_suppress_spurious_page_faults",
(PyCFunction)pyxc_dom_suppress_spurious_page_faults,
METH_VARARGS, "\n"
"Do not propagate spurious page faults to this guest.\n"
" dom [int]: Identifier of domain.\n" },
#endif
{ NULL, NULL, 0, NULL }
};
static PyObject *PyXc_getattr(PyObject *obj, char *name)
{
return Py_FindMethod(pyxc_methods, obj, name);
}
static PyObject *PyXc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
XcObject *self = (XcObject *)type->tp_alloc(type, 0);
if (self == NULL)
return NULL;
self->xc_handle = -1;
return (PyObject *)self;
}
static int
PyXc_init(XcObject *self, PyObject *args, PyObject *kwds)
{
if ((self->xc_handle = xc_interface_open()) == -1) {
pyxc_error_to_exception();
return -1;
}
return 0;
}
static void PyXc_dealloc(XcObject *self)
{
if (self->xc_handle != -1) {
xc_interface_close(self->xc_handle);
self->xc_handle = -1;
}
self->ob_type->tp_free((PyObject *)self);
}
static PyTypeObject PyXcType = {
PyObject_HEAD_INIT(NULL)
0,
PKG "." CLS,
sizeof(XcObject),
0,
(destructor)PyXc_dealloc, /* tp_dealloc */
NULL, /* tp_print */
PyXc_getattr, /* tp_getattr */
NULL, /* tp_setattr */
NULL, /* tp_compare */
NULL, /* tp_repr */
NULL, /* tp_as_number */
NULL, /* tp_as_sequence */
NULL, /* tp_as_mapping */
NULL, /* tp_hash */
NULL, /* tp_call */
NULL, /* tp_str */
NULL, /* tp_getattro */
NULL, /* tp_setattro */
NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"Xen client connections", /* tp_doc */
NULL, /* tp_traverse */
NULL, /* tp_clear */
NULL, /* tp_richcompare */
0, /* tp_weaklistoffset */