In this paper we consider a PDE-constrained optimization problem where an H1 regularization control term is introduced. We address both timeindependent and time-dependent versions. We introduce bound constraints on the state, and show how these can be handled by a Moreau-Yosida penalty function. We propose Krylov solvers and preconditioners for the different problems and illustrate their perfor...