Solution (source code)

= Solution

Put
$$
q=\mu-(1+r)S_0,\qquad h=m-(1+r)x.
$$
For a risky holding vector $\theta$ and the remaining wealth in the bank,
$$
X_1=(1+r)x+\theta^T(S_1-(1+r)S_0),
$$
so
$$
\mathbb E X_1=(1+r)x+\theta^Tq,\qquad
\operatorname{Var}(X_1)=\theta^TV\theta.
$$
When $V$ is nonsingular it is positive definite. Cauchy--Schwarz in the
$V$ inner product gives
$$
(\theta^Tq)^2
\leq(\theta^TV\theta)(q^TV^{-1}q),
$$
with equality exactly when $\theta=\lambda V^{-1}q$. Under
$\theta^Tq=h$,
$$
\boxed{\theta^*=
\frac{h}{q^TV^{-1}q}V^{-1}q,\qquad
\min\operatorname{Var}(X_1)
=\frac{h^2}{q^TV^{-1}q}}.
$$

For the constraint $\mathbb E X_1\geq m$, if $h\leq0$ the zero risky portfolio is feasible and the minimum variance is zero. If $h>0$, the inequality binds and the preceding optimizer and minimum apply.