  We study the gas metallicity of quasar hosts using cosmological hydrodynamic
simulations of the Lambda-cold dark matter model. Galaxy formation in the
simulations is coupled with a prescription for black hole activity enabling us
to study the evolution of the metal enrichment in quasar hosts and hence
explore the relationship between star/spheroid formation and black hole
growth/activity. We find a steep radial metallicity gradient in quasar host
galaxies, with gas metallicities close to solar values in the outer parts but
becoming supersolar in the center. The hosts of the rare bright quasars at
z~5-6 have star formation rates of several hundred solar masses per year and
halo masses of order ~10^12 solar masses. Already at these redshifts they have
supersolar (Z ~2-3 solar) central metallicities, with a mild dependence of
metallicity on luminosity, consistent with observed trends. The mean value of
metallicity is sensitive to the assumed quasar lifetime, providing a useful new
probe of this parameter. We find that lifetimes from 10^7-4x10^7yr are favored
by comparison to observational data. In both the models and observations, the
rate of evolution of the mean quasar metallicity as a function of redshift is
generally flat out to z ~ 4-5. Beyond the observed redshift range and out to
redshift z ~ 6-8, we predict a slow decline of the mean central metallicity
towards solar and slightly subsolar values as we approach the epoch of the
first significant star formation activity
