博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nova中的localfs
阅读量:4213 次
发布时间:2019-05-26

本文共 1568 字,大约阅读时间需要 5 分钟。

使用guestfs 可以在不用mount的情况下直接处理虚拟机的镜像文件,而使用localfs的话就需要将虚拟机的镜像文件mount到host中才能编辑镜像文件.localfs的实现路径为E:\nova\nova\virt\disk\vfs\localfs.pyclass VFSLocalFS(vfs.VFS):    def __init__(self, image, partition=None, imgdir=None):        """Create a new local VFS instance        :param image: instance of nova.virt.image.model.Image        :param partition: the partition number of access        :param imgdir: the directory to mount the image at        """        super(VFSLocalFS, self).__init__(image, partition)		#从其__init__函数可以看出会指定要mount的路径imgdir.        self.imgdir = imgdir        self.mount = None    def setup(self, mount=True):        self.imgdir = tempfile.mkdtemp(prefix="openstack-vfs-localfs")        try:			#将虚拟机镜像文件mount到host中            mnt = mount_api.Mount.instance_for_format(self.image,                                                      self.imgdir,            #默认mount 为true                                         self.partition)            if mount:				#检查是否mount成功                if not mnt.do_mount():                    raise exception.NovaException(mnt.error)			#保存mount结果            self.mount = mnt        except Exception as e:            with excutils.save_and_reraise_exception():                LOG.debug("Failed to mount image: %(ex)s", {'ex': e})                self.teardown() def get_image_fs(self):		#这样在使用的时候,会先调用get_image_fs得到已经mount到host的路径,然后就可以直接编辑镜像文件了.		        if self.mount.device or self.mount.get_dev():            out, err = nova.privsep.fs.get_filesystem_type(self.mount.device)            return out.strip()        return ""

转载地址:http://jrjmi.baihongyu.com/

你可能感兴趣的文章
[hive]优化策略
查看>>
c++14现代内存管理
查看>>
右值引用,move语义和完美转发
查看>>
c++使用宏检测类是否包含某个函数或者变量属性
查看>>
CSS之Multi-columns的column-gap和column-rule
查看>>
CSS之Multi-columns的跨列
查看>>
CSS之浮动(一)
查看>>
CSS之浮动(二)
查看>>
AtomicInteger源码解析
查看>>
CopyOnWriteArraySet源码学习
查看>>
Openfiler 配置 NFS 示例
查看>>
Oracle 11.2.0.1 RAC GRID 无法启动 : Oracle High Availability Services startup failed
查看>>
Oracle 18c 单实例安装手册 详细截图版
查看>>
Oracle Linux 6.1 + Oracle 11.2.0.1 RAC + RAW 安装文档
查看>>
Oracle 11g 新特性 -- Online Patching (Hot Patching 热补丁)说明
查看>>
Oracle 11g 新特性 -- ASM 增强 说明
查看>>
Oracle 11g 新特性 -- Database Replay (重演) 说明
查看>>
Oracle 11g 新特性 -- 自动诊断资料档案库(ADR) 说明
查看>>
Oracle 11g 新特性 -- RMAN Data Recovery Advisor(DRA) 说明
查看>>
CSDN博客之星 投票说明
查看>>