I only just thought about this recently.
The US is a free country so, regardless of tensions, we let foreigners in to live here if they find a way. So we have a lot of Chinese immigrants despite everything going on.
So if China and the US, for instance, declared war, what happens to the Chinese immigrants legally? China is a dictatorship so it's not hard to believe they would just immediately kill or leverage the lives of any US students or tourists stuck there. But would we do anything to subvert the notion the US is a democracy in times of war? Would we
A) Forcibly deport them
B) Make it so they cannot leave. They retain permanent residence until the war ends.
C) Do absolutely nothing, really
This is important because a time of war with nations would mean it would be hell for foreigners to be living in an opposing nation with hate crimes on the rise. They would want to go back home, most of the time.