Who was emir of Qazvin?