當前位置: 首頁>>代碼示例>>Python>>正文


Python libvirt.VIR_DOMAIN_CORE_DUMP_FORMAT_RAW屬性代碼示例

本文整理匯總了Python中libvirt.VIR_DOMAIN_CORE_DUMP_FORMAT_RAW屬性的典型用法代碼示例。如果您正苦於以下問題:Python libvirt.VIR_DOMAIN_CORE_DUMP_FORMAT_RAW屬性的具體用法?Python libvirt.VIR_DOMAIN_CORE_DUMP_FORMAT_RAW怎麽用?Python libvirt.VIR_DOMAIN_CORE_DUMP_FORMAT_RAW使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在libvirt的用法示例。


在下文中一共展示了libvirt.VIR_DOMAIN_CORE_DUMP_FORMAT_RAW屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_CORE_DUMP_FORMAT_RAW [as 別名]
def main(args):
    vm_name = args['<vm_name>']
    # get domain from libvirt
    con = libvirt.open('qemu:///system')
    domain = con.lookupByName(vm_name)

    path = os.path.join(os.getcwd(), '{}.raw'.format(vm_name))
    with open(path, 'w') as f:
        # chmod to be r/w by everyone
        os.chmod(path, stat.S_IRUSR | stat.S_IWUSR |
                                stat.S_IRGRP | stat.S_IWGRP |
                                stat.S_IROTH | stat.S_IWOTH)
        # take a ram dump
        flags = libvirt.VIR_DUMP_MEMORY_ONLY
        dumpformat = libvirt.VIR_DOMAIN_CORE_DUMP_FORMAT_RAW
        domain.coreDumpWithFormat(path, dumpformat, flags) 
開發者ID:KVM-VMI,項目名稱:nitro,代碼行數:18,代碼來源:memdump.py

示例2: dump_memory

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_CORE_DUMP_FORMAT_RAW [as 別名]
def dump_memory(self, event):
        # take temporary memory dump
        # we need to create our own tmp_dir
        # otherwise the dumpfile will be owned by libvirt
        # and we don't have the permission to remove it in /tmp
        with TemporaryDirectory() as tmp_dir:
            with NamedTemporaryFile(dir=tmp_dir, delete=not self.keep_dump) as ram_dump:
                # chmod to be r/w by everyone
                # before libvirt takes ownership
                os.chmod(ram_dump.name,
                         stat.S_IRUSR | stat.S_IWUSR
                         | stat.S_IRGRP | stat.S_IWGRP
                         | stat.S_IROTH | stat.S_IWOTH)
                # take dump
                self.logger.info('Dumping %s physical memory to %s',
                                 self.context.domain.name(), ram_dump.name)
                flags = libvirt.VIR_DUMP_MEMORY_ONLY
                dumpformat = libvirt.VIR_DOMAIN_CORE_DUMP_FORMAT_RAW
                self.context.domain.coreDumpWithFormat(ram_dump.name, dumpformat, flags)
                # trigger event
                self.context.trigger('memory_dumped', memdump_path=ram_dump.name)
                if self.keep_dump:
                    self.logger.info("Keeping memory dump at %s", self.keep_dump_path)
                    shutil.move(ram_dump.name, str(self.keep_dump_path)) 
開發者ID:Wenzel,項目名稱:oswatcher,代碼行數:26,代碼來源:memory.py

示例3: memory_snapshot

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_CORE_DUMP_FORMAT_RAW [as 別名]
def memory_snapshot(context, memory_dump_path, compress):
    # fix issue with libvirt's API
    open(memory_dump_path, 'a').close()  # touch file to set permissions

    dump_flag = libvirt.VIR_DUMP_MEMORY_ONLY
    if compress:
        dump_format = libvirt.VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_ZLIB
    else:
        dump_format = libvirt.VIR_DOMAIN_CORE_DUMP_FORMAT_RAW

    context.domain.coreDumpWithFormat(memory_dump_path, dump_format, dump_flag) 
開發者ID:F-Secure,項目名稱:see,代碼行數:13,代碼來源:memory.py

示例4: load_symbols

# 需要導入模塊: import libvirt [as 別名]
# 或者: from libvirt import VIR_DOMAIN_CORE_DUMP_FORMAT_RAW [as 別名]
def load_symbols(self):
        # we need to put the ram dump in our own directory
        # because otherwise it will be created in /tmp
        # and later owned by root
        with TemporaryDirectory() as tmp_dir:
            with NamedTemporaryFile(dir=tmp_dir) as ram_dump:
                # chmod to be r/w by everyone
                os.chmod(ram_dump.name,
                         stat.S_IRUSR | stat.S_IWUSR |
                         stat.S_IRGRP | stat.S_IWGRP |
                         stat.S_IROTH | stat.S_IWOTH)
                # take a ram dump
                logging.info('Dumping physical memory to %s', ram_dump.name)
                flags = libvirt.VIR_DUMP_MEMORY_ONLY
                dumpformat = libvirt.VIR_DOMAIN_CORE_DUMP_FORMAT_RAW
                self.domain.coreDumpWithFormat(ram_dump.name, dumpformat, flags)
                # build symbols.py absolute path
                script_dir = os.path.dirname(os.path.realpath(__file__))
                symbols_script_path = os.path.join(script_dir,
                                                   GETSYMBOLS_SCRIPT)
                # call rekall on ram dump
                logging.info('Extracting symbols with Rekall')
                python2 = shutil.which('python2')
                symbols_process = [python2, symbols_script_path, ram_dump.name]
                output = subprocess.check_output(symbols_process)
        logging.info('Loading symbols')
        # load output as json
        symbols = json.loads(output.decode('utf-8'))
        # load ssdt entries
        nt_ssdt = {'ServiceTable': {}, 'ArgumentTable': {}}
        win32k_ssdt = {'ServiceTable': {}, 'ArgumentTable': {}}
        self.sdt = [nt_ssdt, win32k_ssdt]
        cur_ssdt = None
        for e in symbols['syscall_table']:
            if isinstance(e, list) and e[0] == 'r':
                if e[1]["divider"] is not None:
                    # new table
                    m = re.match(r'Table ([0-9]) @ .*', e[1]["divider"])
                    idx = int(m.group(1))
                    cur_ssdt = self.sdt[idx]['ServiceTable']
                else:
                    entry = e[1]["entry"]
                    full_name = e[1]["symbol"]["symbol"]
                    # add entry  to our current ssdt
                    cur_ssdt[entry] = full_name
        # save rekall symbols
        self.symbols = symbols 
開發者ID:KVM-VMI,項目名稱:nitro,代碼行數:49,代碼來源:backend.py


注:本文中的libvirt.VIR_DOMAIN_CORE_DUMP_FORMAT_RAW屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。