虚拟机作快照加速:python
[root@controller-39 ~]# vim /usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py cfg.StrOpt('snapshots_directory', default='$instances_path/snapshots', help='Location where libvirt driver will store snapshots ' 'before uploading them to p_w_picpath service'), CONF = cfg.CONF CONF.register_opts(libvirt_opts, 'libvirt') # 能够看出nova.conf中能够配置虚拟机作快照(默认全量快照),快照上传到glance以前的过渡目录(好比:配置在ssd盘上)。
启动虚拟机加速:git
# openstack第一次启动虚拟机的时候会从glance拉镜像到本地(默认是$instances_path/_base) # 第二次以一样的镜像启动虚拟机的时候就直接从$p_w_picpath_cache_directory_name/_base启动了 # 一样,若是base目录是ssd的话,启动虚拟机快是理所应当的。 # 下面的patch就是把虚拟机的base目录变成一个nova.conf的配置选项。 --- virt/p_w_picpathcache.py | 4 ++++ virt/libvirt/p_w_picpathbackend.py | 3 ++- virt/libvirt/p_w_picpathcache.py | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/virt/p_w_picpathcache.py b/virt/p_w_picpathcache.py index b63013f..593a48e 100644 --- a/virt/p_w_picpathcache.py +++ b/virt/p_w_picpathcache.py @@ -29,6 +29,10 @@ p_w_picpathcache_opts = [ 'This is NOT the full path - just a folder name. ' 'For per-compute-host cached p_w_picpaths, set to _base_$my_ip', deprecated_name='base_dir_name'), + cfg.StrOpt('p_w_picpath_cache_directory_name', + default='/var/lib/nova/instances', + help='Where cached p_w_picpaths are stored under cache directory. ', + deprecated_name='base_dir'), cfg.BoolOpt('remove_unused_base_p_w_picpaths', default=True, help='Should unused base p_w_picpaths be removed?', diff --git a/virt/libvirt/p_w_picpathbackend.py b/virt/libvirt/p_w_picpathbackend.py index 6511496..8c0b887 100644 --- a/virt/libvirt/p_w_picpathbackend.py +++ b/virt/libvirt/p_w_picpathbackend.py @@ -84,6 +84,7 @@ __p_w_picpathbackend_opts = [ CONF = cfg.CONF CONF.register_opts(__p_w_picpathbackend_opts, 'libvirt') CONF.import_opt('p_w_picpath_cache_subdirectory_name', 'nova.virt.p_w_picpathcache') +CONF.import_opt('p_w_picpath_cache_directory_name', 'nova.virt.p_w_picpathcache') CONF.import_opt('preallocate_p_w_picpaths', 'nova.virt.driver') LOG = logging.getLogger(__name__) @@ -181,7 +182,7 @@ class Image(object): def fetch_func_sync(target, *args, **kwargs): fetch_func(target=target, *args, **kwargs) - base_dir = os.path.join(CONF.instances_path, + base_dir = os.path.join(CONF.p_w_picpath_cache_directory_name, CONF.p_w_picpath_cache_subdirectory_name) if not os.path.exists(base_dir): fileutils.ensure_tree(base_dir) diff --git a/virt/libvirt/p_w_picpathcache.py b/virt/libvirt/p_w_picpathcache.py index 5320bad..e1453de 100644 --- a/virt/libvirt/p_w_picpathcache.py +++ b/virt/libvirt/p_w_picpathcache.py @@ -72,6 +72,7 @@ CONF = cfg.CONF CONF.register_opts(p_w_picpathcache_opts, 'libvirt') CONF.import_opt('instances_path', 'nova.compute.manager') CONF.import_opt('p_w_picpath_cache_subdirectory_name', 'nova.virt.p_w_picpathcache') +CONF.import_opt('p_w_picpath_cache_directory_name', 'nova.virt.p_w_picpathcache') def get_cache_fname(p_w_picpaths, key): @@ -578,7 +579,7 @@ class ImageCacheManager(p_w_picpathcache.ImageCacheManager): # cache to the instance directory. Files ending in _sm are no longer # created, but may remain from previous versions. - base_dir = os.path.join(CONF.instances_path, + base_dir = os.path.join(CONF.p_w_picpath_cache_directory_name, CONF.p_w_picpath_cache_subdirectory_name) if not os.path.exists(base_dir): LOG.debug(_('Skipping verification, no base directory at %s'), --