|
虚拟机做快照加速:
1
2
3
4
5
6
7
8
9
| [iyunv@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 image service'),
CONF = cfg.CONF
CONF.register_opts(libvirt_opts, 'libvirt')
# 可以看出nova.conf中可以配置虚拟机做快照(默认全量快照),快照上传到glance之前的过渡目录(比如:配置在ssd盘上)。
|
启动虚拟机加速:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
| # openstack第一次启动虚拟机的时候会从glance拉镜像到本地(默认是$instances_path/_base)
# 第二次以同样的镜像启动虚拟机的时候就直接从$image_cache_directory_name/_base启动了
# 同样,如果base目录是ssd的话,启动虚拟机快是理所应当的。
# 下面的patch就是把虚拟机的base目录变成一个nova.conf的配置选项。
---
virt/imagecache.py | 4 ++++
virt/libvirt/imagebackend.py | 3 ++-
virt/libvirt/imagecache.py | 3 ++-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/virt/imagecache.py b/virt/imagecache.py
index b63013f..593a48e 100644
--- a/virt/imagecache.py
+++ b/virt/imagecache.py
@@ -29,6 +29,10 @@ imagecache_opts = [
'This is NOT the full path - just a folder name. '
'For per-compute-host cached images, set to _base_$my_ip',
deprecated_name='base_dir_name'),
+ cfg.StrOpt('image_cache_directory_name',
+ default='/var/lib/nova/instances',
+ help='Where cached images are stored under cache directory. ',
+ deprecated_name='base_dir'),
cfg.BoolOpt('remove_unused_base_images',
default=True,
help='Should unused base images be removed?',
diff --git a/virt/libvirt/imagebackend.py b/virt/libvirt/imagebackend.py
index 6511496..8c0b887 100644
--- a/virt/libvirt/imagebackend.py
+++ b/virt/libvirt/imagebackend.py
@@ -84,6 +84,7 @@ __imagebackend_opts = [
CONF = cfg.CONF
CONF.register_opts(__imagebackend_opts, 'libvirt')
CONF.import_opt('image_cache_subdirectory_name', 'nova.virt.imagecache')
+CONF.import_opt('image_cache_directory_name', 'nova.virt.imagecache')
CONF.import_opt('preallocate_images', '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.image_cache_directory_name,
CONF.image_cache_subdirectory_name)
if not os.path.exists(base_dir):
fileutils.ensure_tree(base_dir)
diff --git a/virt/libvirt/imagecache.py b/virt/libvirt/imagecache.py
index 5320bad..e1453de 100644
--- a/virt/libvirt/imagecache.py
+++ b/virt/libvirt/imagecache.py
@@ -72,6 +72,7 @@ CONF = cfg.CONF
CONF.register_opts(imagecache_opts, 'libvirt')
CONF.import_opt('instances_path', 'nova.compute.manager')
CONF.import_opt('image_cache_subdirectory_name', 'nova.virt.imagecache')
+CONF.import_opt('image_cache_directory_name', 'nova.virt.imagecache')
def get_cache_fname(images, key):
@@ -578,7 +579,7 @@ class ImageCacheManager(imagecache.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.image_cache_directory_name,
CONF.image_cache_subdirectory_name)
if not os.path.exists(base_dir):
LOG.debug(_('Skipping verification, no base directory at %s'),
--
|
|
|