Cloud computing technology has gained the attention of researchers in recent years. Almost every application is using cloud computing in one way or another. Virtualization allows running many virtual machines on a single physical computer by sharing its resources. Users can store their data on datacenter and run their applications from anywhere using the internet and pay as per service level agreement documents accordingly. It leads to an increase in demand for cloud services and may decrease the quality of service. This paper presents a priority-based selection of virtual machines by cloud service provider. The virtual machines in the cloud datacenter are configured as Amazon EC2 and algorithm is simulated in cloud-sim simulator. The results justify that proposed priority-based virtual machine algorithm shortens the makespan, by 11.43 % and 5.81 %, average waiting time by 28.80 % and 24.50%, and cost of using the virtual machine by 21.24% and 11.54% as compared to FCFS and ACO respectively, hence improving quality of service.