  It is commonly adopted that X-rays from O stars are produced deep inside the
stellar wind, and transported outwards through the bulk of the expanding matter
which attenuates the radiation and affects the shape of emission line profiles.
The ability of Chandra and XMM-Newton to resolve these lines spectroscopically
provided a stringent test for the theory of X-ray production. It turned out
that none of the existing models was able to reproduce the observations
consistently. The major caveat of these models was the underlying assumption of
a smooth stellar wind. Motivated by the various observational evidence that the
stellar winds are in fact structured, we present a 2-D model of a stochastic,
inhomogeneous wind. The X-ray radiative transfer is derived for such media. It
is shown that profiles from a clumped wind differ drastically from those
predicted by conventional homogeneous models. We review the up-to-date
observations of X-ray line profiles from stellar winds and present line fits
obtained from the inhomogeneous wind model. The necessity to account for
inhomogeneities in calculating the X-ray transport in massive star winds,
including for HMXB is highlighted.
