Choose $\alpha$ as the generalized coordinate, so $y_\text{COM}=\frac{1}{2}L \sin\alpha$, and $x_B=L\cos\alpha$.
Then $\delta y_\text{COM}=\frac{1}{2}L \cos\alpha \,\delta\alpha$, and $\delta x_B=L\sin\alpha \,\delta\alpha$$\delta x_B=-L\sin\alpha \,\delta\alpha$. Substitute into the equation.