Just the opposite. Kim's doing what he needs to do in order to survive. The cold war is over, and global communism is dead. Forget what you learned before, because the old equation has changed. While the Koreans and Chinese have historical ties, it's hardly one of master and servant.
The new relationship is simply. China wants to be a big power, and every step they take in that direction takes them further away from North Korea.
North Korea wants to survive, and they can't count on the old Communist powers to back them anymore. Nuclear weapons are they only way to scare the world into compliance.
I partially agree with you. Yes, Kim Jung-Il is doing what he thinks he needs to, for whatever 'reasons'. (maybe just his legacy, who knows)
But I see N.K. as the surrogate that performs dirty work that China doesn't want to be directly identified with (and therefore keeps attention on N.K. and not China, and allows China to look like it's playing as an ally with it's international business partners) and as the buffer zone (or no man's land) between China and S. Korea/U.S. They have N.K. at the end of a long leash. The Chinese can hold them away, thereby distancing themselves and appearing as though N.K. is a totally independent entity. If necessary, they will squash Kim Jung-Il, and put someone in place that listens better.