1f5e5c334SAlan Carew /*- 2f5e5c334SAlan Carew * BSD LICENSE 3f5e5c334SAlan Carew * 4f5e5c334SAlan Carew * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. 5f5e5c334SAlan Carew * All rights reserved. 6f5e5c334SAlan Carew * 7f5e5c334SAlan Carew * Redistribution and use in source and binary forms, with or without 8f5e5c334SAlan Carew * modification, are permitted provided that the following conditions 9f5e5c334SAlan Carew * are met: 10f5e5c334SAlan Carew * 11f5e5c334SAlan Carew * * Redistributions of source code must retain the above copyright 12f5e5c334SAlan Carew * notice, this list of conditions and the following disclaimer. 13f5e5c334SAlan Carew * * Redistributions in binary form must reproduce the above copyright 14f5e5c334SAlan Carew * notice, this list of conditions and the following disclaimer in 15f5e5c334SAlan Carew * the documentation and/or other materials provided with the 16f5e5c334SAlan Carew * distribution. 17f5e5c334SAlan Carew * * Neither the name of Intel Corporation nor the names of its 18f5e5c334SAlan Carew * contributors may be used to endorse or promote products derived 19f5e5c334SAlan Carew * from this software without specific prior written permission. 20f5e5c334SAlan Carew * 21f5e5c334SAlan Carew * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22f5e5c334SAlan Carew * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23f5e5c334SAlan Carew * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24f5e5c334SAlan Carew * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25f5e5c334SAlan Carew * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26f5e5c334SAlan Carew * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27f5e5c334SAlan Carew * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28f5e5c334SAlan Carew * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29f5e5c334SAlan Carew * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30f5e5c334SAlan Carew * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31f5e5c334SAlan Carew * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32f5e5c334SAlan Carew */ 33f5e5c334SAlan Carew 34f5e5c334SAlan Carew /* 35f5e5c334SAlan Carew #include <stdio.h> 36f5e5c334SAlan Carew #include <string.h> 37f5e5c334SAlan Carew #include <stdint.h> 38f5e5c334SAlan Carew #include <errno.h> 39f5e5c334SAlan Carew #include <sys/epoll.h> 40f5e5c334SAlan Carew #include <fcntl.h> 41f5e5c334SAlan Carew #include <unistd.h> 42f5e5c334SAlan Carew #include <stdlib.h> 43f5e5c334SAlan Carew #include <unistd.h> 44f5e5c334SAlan Carew #include <errno.h> 45f5e5c334SAlan Carew */ 46f5e5c334SAlan Carew #include <signal.h> 47f5e5c334SAlan Carew 48f5e5c334SAlan Carew #include <rte_lcore.h> 49f5e5c334SAlan Carew #include <rte_power.h> 50f5e5c334SAlan Carew #include <rte_debug.h> 51f5e5c334SAlan Carew #include <rte_config.h> 52f5e5c334SAlan Carew 53f5e5c334SAlan Carew #include "vm_power_cli_guest.h" 54f5e5c334SAlan Carew 55f5e5c334SAlan Carew static void 56f5e5c334SAlan Carew sig_handler(int signo) 57f5e5c334SAlan Carew { 58f5e5c334SAlan Carew printf("Received signal %d, exiting...\n", signo); 59f5e5c334SAlan Carew unsigned lcore_id; 60f5e5c334SAlan Carew 61f5e5c334SAlan Carew RTE_LCORE_FOREACH(lcore_id) { 62f5e5c334SAlan Carew rte_power_exit(lcore_id); 63f5e5c334SAlan Carew } 64f5e5c334SAlan Carew 65f5e5c334SAlan Carew } 66f5e5c334SAlan Carew 67f5e5c334SAlan Carew int 68*98a16481SDavid Marchand main(int argc, char **argv) 69f5e5c334SAlan Carew { 70f5e5c334SAlan Carew int ret; 71f5e5c334SAlan Carew unsigned lcore_id; 72f5e5c334SAlan Carew 73f5e5c334SAlan Carew ret = rte_eal_init(argc, argv); 74f5e5c334SAlan Carew if (ret < 0) 75f5e5c334SAlan Carew rte_panic("Cannot init EAL\n"); 76f5e5c334SAlan Carew 77f5e5c334SAlan Carew signal(SIGINT, sig_handler); 78f5e5c334SAlan Carew signal(SIGTERM, sig_handler); 79f5e5c334SAlan Carew 80f5e5c334SAlan Carew rte_power_set_env(PM_ENV_KVM_VM); 81f5e5c334SAlan Carew RTE_LCORE_FOREACH(lcore_id) { 82f5e5c334SAlan Carew rte_power_init(lcore_id); 83f5e5c334SAlan Carew } 84f5e5c334SAlan Carew run_cli(NULL); 85f5e5c334SAlan Carew 86f5e5c334SAlan Carew return 0; 87f5e5c334SAlan Carew } 88