虛擬機作快照加速: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'), --