Arming at the irrational resource allocation problem in the Xen virtualization platform, this paper proposes two resource scheduling optimization algorithms: the fine-grained algorithm and the coarse-grained algorithm. The fine grained algorithm is mainly for resource allocation of single physical node, which dynamically adjusts the allocated resource amount of each virtual machine according to its resource utilization, and appropriately increases the resource amount for the virtual machines whose resource utilization are high and reduces the resource amount for those whose resource utilization is low, thus improves resource utilization efficiency and avoids unnecessary virtual machine migrations. The coarse-grained algorithm focuses on the load imbalance problem among multiple physical nodes in a cluster, and applies the particle swarm optimization technique to select some virtual machines on the hot physical machines and then immigrates it to the most suitable cold physical machines in a cluster system, thereby solving load imbalance problem of the cluster system and avoiding high load physical machines downtime. Experiments show that the proposed two scheduling optimization algorithms can effectively solve the resource allocation irrational problem of virtual machines and have better adaptability and application prospects.