The Zimbabwean government will seek legislation to bar its former military commander, Lt. Gen. Peter Walls, from returning to Zimbabwe, Prime Minister Robert Mugabe announced today in Salisbury. Walls, a citizen of Zimbabwe, is now in Britain on vacation.

It was the second disciplinary move against Walls for his remarks last month that were critical of Zimbabwe's prospects under black rule.

Walls, 54, formally relieved Sept. 17 of his post as chairman of Zimbabwe's joint high command. He effectively left at the end of July, pending his retirment from military services in December.

The new move would be the harshest action against any white former Rhodesian since Mugabe came to power last April. It is likely to raise fears among the estimated 200,000 whites, many of whom like Walls were born in what is now Zimbabwe, about their legal protections under the new constitution.

Mugabe told Zimbabwe's Senate that the legal powers he would request to prevent Walls from returning were intended to deal only with the controversial general. "This is going to affect Gen. Walls. The government does not intend to act arbitrarily," Mugabe said.

Although there has been little sympathy for Walls among whites, most of whom believed his remarks indiscreet, the new action could arouse sympathy for him.

The move is likely to be highly popular among blacks, who were enraged at Walls' expressed lack of faith in Mugabe's government. It could relieve some of the political pressures on Mugabe from the several thousand ex-guerrillas who have grown increasingly restless in holding camps while they await integration into a unified defense force.

Among them are many followers of Mugabe's minister of manpower and planning, who is to go on trial in November for the murder of a white farmer.

Ex-guerrillas in recent weeks have been involved in several armed attacks on isolated farms and police outposts. Reports from Salisbury today say a white farmer was killed in an attack on his farm by dissident ex-guerrillas.