The future 5G networks need to support different kinds of business and applications, so the cloud radio access networks (C-RAN) which can provide a centralized collaborative resource management gain through small base stations, and seamless handoff also can be achieved through the overlapping deployment of macro base stations and micro base stations has become one of the important directions in 5G networks. In this paper, we propose an optimization problem with the joint consideration of computing resources and radio resources under C-RAN. Our goal is to minimize system power consumption while ensuring user delay by dynamically adjusting the mapping among virtual machines (VMs) which are software defined in the baseband unit (BBU) pool, remote radio heads (RRHs) and user equipments (UEs). The proposed resource allocation problem is a mixed-integer nonlinear programming (MINLP) problem which is NP-hard. This paper presents an improved genetic algorithm to solve this problem. The simulation results show that the proposed resource allocation algorithm can effectively reduce the power consumption.