Density-Functional Perturbation Theory for Quasi-Harmonic Calculations