Luke 22:
35 Then Jesus asked them, “When I sent you without purse, bag or sandals, did you lack anything?”
“Nothing,” they answered.
36He said to them, “But now if you have a purse, take it, and also a bag; and if you don’t have a sword, sell your cloak and buy one. 37 It is written: ‘And he was numbered with the transgressors’ ; and I tell you that this must be fulfilled in me. Yes, what is written about me is reaching its fulfillment.”
Is Jesus telling his disciples to buy swords?
I don't think so. The sword here is a metaphor for the coming violence. Jesus warns his disciples that times have changed. He will be crucified and it is not going to be peaceful for them. They need to be prepared for the coming violence but not literally with swords.
38 The disciples said, “See, Lord, here are two swords.”
How come two of them already had swords on their person when they gathered for the last supper?
We know that Peter carries one:
John 18:10
Then Simon Peter, who had a sword, drew it and struck the high priest's servant, cutting off his right ear. (The servant's name was Malchus.)
Two disciples carry swords for daily routine purposes. The swords are not there for the special purpose of defending Jesus from the coming arrest.
Barnes
Are two swords - The Galileans, it is said, often went armed. The Essenes did so also. The reason was that the country was full of robbers and wild beasts, and it was necessary to carry, in their travels, some means of defense. It seems that the disciples followed the customs of the country, and had with them some means of defense
Is Jesus advocating the use of physical violence?
No.
Luke 22:38
The disciples said, "See, Lord, here are two swords." "That's enough!" he replied.
Only 11 verses later:
49 When Jesus’ followers saw what was going to happen, they said, “Lord, should we strike with our swords?” 50And one of them struck the servant of the high priest, cutting off his right ear.
51But Jesus answered, “No more of this!” And he touched the man’s ear and healed him.
That's enough. No more of this. Jesus does not want violence.
What’s going on in the upper room on the night that Jesus was betrayed?
Good question. The situation was curious. Jesus began by warning the disciples about the coming days of violence (sword). The disciples interpreted him literally and pointed out the fact that they had two swords on hand. Jesus rebuked them but Peter didn't learn and used his sword later during the arrest. Jesus made it clear to Peter then: no violence. This is a curious case of the disciples misunderstanding Jesus.