Until recently, China hasn't liked to take a direct approach to many aspects of international affairs. So they influence countries like North Korea, Pakistan, and Iran as tools to achieve their political aims.
They aren't whole-hearted supporters of all aspects of the North Korean regime, frankly, I'd say that they don't really care about what happens in North Korea, as long as they are achieving their foreign policy goals.
A collapsed NK state creates more trouble for China in the form of refugees than a still-functioning one, so we see enough aid for them to keep functioning.
An occasional diplomatic poke in the eye to the US helps China too, but that's a want, not a need. Don't confuse the rhetoric with the reality.
I think they let a US/SK operation clean up while issuing various diplomatic missives decrying the violence, then wrangle a treaty barring major military installations or exercises in northern areas of, and establishing free trade with, the reunified Korea.
Nationalist pride, sure, that's been a constant through any cohesive nation's history. Koreans aren't Chinese, though, and the leaders of China are too smart to look for a "short, victorious war" on the Korean peninsula..
They don't even have an idealogical interest -- we throw around the word "communist", but North Korea's modern ideologies are so far removed from Chinese communism that it's practically apples and oranges.
And the Cold War is long over, nobody's out to "eradicate" or even "contain" communism. US-Chinese relations are strained, but not hostile, and they know we wouldn't be looking to cross the Yalu.
In the late 1970s, Deng Xiaopeng killed off the last group of leaders trying to keep that sentiment alive (the Gang of Four) and since then they've been all pragmatism, all the time. Any talk of communism is window-dressing, their regime is ideologically committed to doing what's practical.
So even aside from the cost-benefit, they have no ideological incentive to throw their lot in with the North Korean gov't. As I said upthread, the reason they give them aid right now is because a refugee crisis in Manchuria would be inconvenient. Pragmatism.
North Korea still relies on the PRC's tolerance and patronage, and the PRC doesn't prefer any outcome that boosts the influence of the US and South Korea. But the PRC's influence and patience with North Korea are limited. Some of the Wikileaks cables indicate China has begun backing away from the regime:
http://www.guardian.co.uk/world/2010/nov/29/wikileaks-cables...