A spate of deadly knife attacks and other apparently random acts of violence in the past few days has rattled the Chinese government.