Nationalism is a virtue because it is part of your identity just as much as your skin colour and gender or any other demographic. It allows you to pull together and tackle social problems. Nationalism also allows you to criticise societal inequalities and address them. The problem is not with nationalism but rather with patriotism which Wilde described as a virtue of the vicious, which requires your loyalty no matter what happens
Pride for the country I hail from gives me a unique identity. My skin colour, personality, language, my english accent all these will notify me as Indian and anyone who meets me outside India would easily identify me. This identity is because I belong to this Nation. Nationalism in my opinion is in some way love for my countrymen. Of course it should not mean I hate other country men but I would automatically reach out to my countrymen more than others.
Yes nationalism is definitely a virtue when it is reasonable. Having pride in your country is an important factor for all citizens of that country. You should be proud of where you live because you are a part of it. Nationalism promotes civil actions. It encourages people to be more of a part in their community which helps increase the acknowledgement of the needs of the people residing in the nation.
Nationalism is a strong sense of pride in a person's home country. This leads to higher rates of voting and increased individual participation in the community. Nationalism does not mean that you agree with everything the government does. It does mean that you are willing to self-sacrifice, support your nation and get involved to change the things that are not working.
There's nothing wrong with taking a little national pride in your country, as long as the nationalism is placed properly. It's okay to support the troops while disagreeing with policies enacted by the commander-in-chief. It's okay to salute the flag and then protest at a rally. There's nothing wrong with writing to your senator and then voting for the opposite party the next day. Nationalism is a virtue that can be expressed in many ways.
A reasonable amount of nationalism can be a virtue, as it expresses love and pride in one's country. That is not inherently a bad thing. It becomes bad when love of one's own country becomes hatred of other countries, or when one sees only the good and fails to see the bad about one's own country. If these perils are avoided, then there is nothing wrong with nationalism, and it can lead to people who think positively and are proud. People like that will be much more wiling and able to tackle the world's problems than downtrodden, apathetic people.
A virtue can also be construed as "moral." Supporting a country does not always result in morality. For example, stating allegiance to a state that kills people for their beliefs is not virtuous. Neither is ignoring a country's major faults in exchange for minor benefits. Although I do concede that loyalty to a country can be deemed virtuous in many situations, nationalism itself is not a virtue. Nationalism sparks other virtues into existence, such as acceptance, commitment, and loyalty.