China cannot afford to ruin its relationship with Saudi Arabia and Isreal.
China will support Iran, and its hands will be clean and dry while doing this job.
If there were ever any direct military confrontation btwn the US and Iran, Russia would likely be the one who directly supports Iran militarily, probably with secret deployment of its anti-air missile operators, just like what China did during the Vietnam war, while China would support Iran in indirect ways. (Again, just like what the USSR did during the Vietnam war.) It would be so because Russia and Iran are neighbors, technically speaking.
There is no need for China to form a military alliance with Iran, or with any other country that is bordered with either Russia or China for this matter.
There is a concrete security mechanism to address this issue. Iran is an Observer country of the SCO. Therefore,
the SCO is responsible for Iran's security in some way.
Many people may dispute this argument and are likely to point out that the SCO is not a military alliance in nature, as indicated in its Constitution. But these ppl should not forget two relevant facts. First, the SCO has only two true operators, China and Russia. Second, China and Russia have a bilateral cooperation treaty that covers many security issues concerning either country, regional stability and world peace. (中华人民共和国和俄罗斯联邦睦邻友好合作条约 )Therefore, either China or Russia has a national security issue resulting from outside military forces, it automatically becomes an security issue threatening both China and Russia, and the two countries will have to respond cooperatively by the said bilateral treaty. Since Iran is Russia's neighbor, any US military action directly against Iran can be considered a threat to Russia's security and stability, thus a threat to China's security and stability according to the said Sino-Russia treaty. Since China and Russia are the real operators of the SCO, an strong SCO response to support Iran against the US, proposed by Russia and China, will be a done deal, regardless what the SCO Constitution says about itself and whether all SCO member countries will go with China and Russia.
Even if Iran were not an SCO Observer, the same mechanism could still be activated as long as China and Russia decide to punish the US. The same mechanism can be activated in security issues resulting from N.K., Thailand, Myanmar, or Vietnam,...etc. (Although N.K. is a litter bit different as it has a bilateral treaty with China.) Just remember, the SCO can be re-shaped by the Sino-Russia bilateral treaty and any security issue in the SCO region may potentially prompt China and Russia to respond collectively.