Resonant excitation of disk oscillations in deformed disks. VII. Stability criterion in MHD systems