<div>hi:</div><div>    请教个cinder的问题。</div><div>    使用本地的lvm做cinder的物理存储。猜测lvm相关的代码在cinder-8.0.0\cinder\volume\drivers\lvm.py里面。</div><div>但是没有调用lvm的lvcreate命令:</div><div><div>    def _create_volume(self, name, size, lvm_type, mirror_count, vg=None):</div><div>        vg_ref = self.vg</div><div>        if vg is not None:</div><div>            vg_ref = vg</div><div><br></div><div>        vg_ref.create_volume(name, size, lvm_type, mirror_count)</div></div><div><br></div><div>真正干活的lvcreate是在:<span style="line-height: 1.5;"></span></div><div>[root@opentest stack]# vi ./nova/nova/virt/libvirt/storage/lvm.py</div><div>from oslo_concurrency import processutils</div><div>from oslo_log import log as logging</div><div>from oslo_utils import units</div><div>import six</div><div><br></div><div>import nova.conf</div><div>from nova import exception</div><div>from nova.i18n import _</div><div>from nova.i18n import _LW</div><div>from nova.virt.libvirt import utils</div><div><br></div><div>CONF = nova.conf.CONF</div><div>LOG = logging.getLogger(__name__)</div><div><br></div><div>def create_volume(vg, lv, size, sparse=False):</div><div>    """Create LVM image.</div><div>    Creates a LVM image with given size.</div><div>    :param vg: existing volume group which should hold this image</div><div>    :param lv: name for this image (logical volume)</div><div>    :size: size of image in bytes</div><div>    :sparse: create sparse logical volume</div><div>    """</div><div>    if sparse:</div><div>        preallocated_space = 64 * units.Mi</div><div>        check_size(vg, lv, preallocated_space)</div><div>        if free_space < size:</div><div>            LOG.warning(_LW('Volume group %(vg)s will not be able'</div><div>                         ' to hold sparse volume %(lv)s.'</div><div>                         ' Virtual volume size is %(size)d bytes,'</div><div>                         ' but free space on volume group is'</div><div>                         ' only %(free_space)db.'),</div><div>                        {'vg': vg,</div><div>                         'free_space': free_space,</div><div>                         'size': size,</div><div>                         'lv': lv})</div><div><br></div><div>        cmd = ('lvcreate', '-L', '%db' % preallocated_space,</div><div>                '--virtualsize', '%db' % size, '-n', lv, vg)</div><div><br></div><div>很奇怪啊,难道nova使用lvm时,不是cinder来干活么?</div><div>这与Laying Cinder Block (Volumes) In OpenStack, Part 1: The Basics很比一致啊,看里面的图,cinder的绿线是做管理命令。https://cloudarchitectmusings.com/2013/11/18/laying-cinder-block-volumes-in-openstack-part-1-the-basics/</div><div><img src="cid:B3A94E1C@E94F575D.54B8BA57.jpg" filesize="92047"></div><div><br></div>