virtual machine survey

31
VIRTUAL MACHINE SURVEY 志志 2009.09.15

Upload: santo

Post on 23-Feb-2016

72 views

Category:

Documents


0 download

DESCRIPTION

志豪 2009.09.15. Virtual machine survey. Categories of Virtual Machine Virtual Machine manager: Xen Xen architecture Xen component Xen API XenAccess Library reference. Outline. Full virtualization VMware Workstation , VirtualBox Hardware-assisted virtualization Xen , Linux KVM - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Virtual machine survey

VIRTUAL MACHINE SURVEY志豪 2009.09.15

Page 2: Virtual machine survey

OUTLINE Categories of Virtual Machine Virtual Machine manager: Xen Xen architecture Xen component Xen API XenAccess Library reference

Page 3: Virtual machine survey

CATEGORIES OF VIRTUAL MACHINE Full virtualization

VMware Workstation, VirtualBox Hardware-assisted virtualization

Xen, Linux KVM Partial virtualization

Paravirtualization Operating system-level virtualization

OpenVZ

Page 4: Virtual machine survey

VIRTUAL MACHINE - XEN Virtualization

Para-virtualization 64-bit architecture 32-bit architecture with PAE

[root@linux ~]# cat /proc/cpuinfo | grep flags flags : fpu tsc msr pae mce cx8 mtrr mca cmov pat pse36 mmx fxsr sse up

Page 5: Virtual machine survey

VIRTUAL MACHINE - XEN Virtualization

Full-virtualization Virtualization Technolegy (Intel) SVM (AMD)

在 Intel Core 2 Duo 的 CPU 主機上面測試 CPU 旗標: [root@linux ~]# cat /proc/cpuinfo | grep flags flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc up pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm

Page 6: Virtual machine survey

XEN ARCHITECTURE

Page 7: Virtual machine survey

XEN COMPONENTS Xen Hypervisor Domain 0 Domain Management and Control (Xen

DM&C) Domain U (Dom U) PV Guest Domain U (Dom U) HVM Guest

Page 8: Virtual machine survey

XEN COMPONENTS Xen Hypervisor

Page 9: Virtual machine survey

XEN COMPONENTS Domain 0

Page 10: Virtual machine survey

XEN COMPONENTS Domain U

PV Guest

Page 11: Virtual machine survey

XEN COMPONENTS Domain U

HVM Guest

Page 12: Virtual machine survey

XEN COMPONENTS Domain Management and Control

Xend Libxenctrl

Page 13: Virtual machine survey

XEN COMPONENTS Domain Management and Control

Xm Xenstored Qemu-dm Xen Virtual Firmware Xen Operation

Page 14: Virtual machine survey

XEN COMPONENTS Domain 0 and Domain U

Communication

Page 15: Virtual machine survey

XENAPI Xen Management Architecture

Page 16: Virtual machine survey

XENAPI XenAPI Class Hierarchy

Page 17: Virtual machine survey

XENAPI REQUIREMENT Xen installed and running libxml2 libcurl2 modify configuration

Page 18: Virtual machine survey

MODIFY CONFIGURATIONIn /etc/xen/xend-config.sxp:

(xen-api-server ( (9363 pam ‘^localhost$ example\\.com$’) (9367 pam '' /etc/xen/xen-api.key /etc/xen/xen-api.crt) (unix none)))

Xen-API XML-RPC overHTTP / TCP on port 9363,using PAM and anallowed-hosts specifier

HTTP over TLS over TCP onport 9367, using PAM andthe specified keys

Xen-API XML-RPC over aUnix domain socket at/var/run/xend/xen-api.sock,unauthenticated

Page 19: Virtual machine survey

XENAPI BASIC EXAMPLExmlInitParser();xen_init();curl_global_init(CURL_GLOBAL_ALL);xen_session *session =

xen_session_login_with_password(call_func, NULL, username, password);xen_vm vm;if (!xen_vm_get_by_uuid(session, &vm, uuid)) {

/* Error */}xen_vm_record *vm_record;if (!xen_vm_get_record(session, &vm_record, vm)) {

/* Error */}if (!xen_vm_start(session, vm)) {

/* Error */}

Page 20: Virtual machine survey

XENACCESS LIBRARY

Page 21: Virtual machine survey

XENACCESS LIBRARY Configuration file

/etc/xenaccess.conf Data structure

xa_instance xa_linux_taskaddr xa_windows_peb

XenAccess API definition xenaccess.h

Page 22: Virtual machine survey

XENACCESS LIBRARY /etc/xenaccess.conf

Fedora-HVM { sysmap = "/boot/System.map-2.6.18-

1.2798.fc6"; ostype = "Linux"; linux_tasks = 268; linux_mm = 276; linux_pid = 312; linux_pgd = 40; linux_addr = 132; }

Page 23: Virtual machine survey

XENACCESS LIBRARY Code sample ( process-list )

#include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/mman.h> #include <stdio.h> #include <xenaccess/xenaccess.h> #include <xenaccess/xa_private.h>

Page 24: Virtual machine survey

XENACCESS LIBRARY Code sample ( process-list )

#define TASKS_OFFSET 24 * 4 #define PID_OFFSET 39 * 4 #define NAME_OFFSET 108 * 4 #define ActiveProcessLinks_OFFSET 0x88 #define UniqueProcessId_OFFSET 0x84 #define ImageFileName_OFFSET 0x174

Page 25: Virtual machine survey

XENACCESS LIBRARY Code sample ( process-list )

uint32_t dom = atoi(argv[1]); if (xa_init_vm_id_strict(dom, &xai) == XA_FAILURE){ perror("failed to init XenAccess library"); goto error_exit; }

Page 26: Virtual machine survey

XENACCESS LIBRARY Code sample ( process-list )

memory = xa_access_kernel_sym(&xai, "init_task", &offset, PROT_READ); memcpy(&next_process, memory + offset + TASKS_OFFSET, 4); list_head = next_process; munmap(memory, xai.page_size);

Page 27: Virtual machine survey

XENACCESS LIBRARY Code sample ( process-list )

while (1){ memory = xa_access_kernel_va(&xai, next_process, &offset, PROT_READ); memcpy(&next_process, memory + offset, 4); if (list_head == next_process){ break; } name = (char *) (memory + offset + NAME_OFFSET - TASKS_OFFSET); memcpy(&pid, memory + offset + PID_OFFSET - TASKS_OFFSET, 4); printf("[%5d] %s\n", pid, name); munmap(memory, xai.page_size); }

Page 28: Virtual machine survey

XENACCESS LIBRARY Code sample ( process-list )

if (memory) munmap(memory, xai.page_size); xa_destroy(&xai);

Page 29: Virtual machine survey

XENACCESS LIBRARY Running the example

[root@bluemoon libxa]# xm list Name ID Mem(MiB)VCPUs State Time(s) Domain-0 0 1229 2 r----- 137356.4 Fedora-HVM 4 384 1 -b---- 2292.6 fc5 5 384 1 -b---- 15.4 [root@bluemoon libxa]#

Page 30: Virtual machine survey

XENACCESS LIBRARY Running the example

[root@bluemoon examples]# ./process-list 5 [ 1] init [ 2] migration/0 [ 3] ksoftirqd/0 [ 4] watchdog/0 [ 5] events/0 [ 6] khelper [ 7] kthread [ 8] xenwatch [ 9] xenbus [ 15] kblockd/0 [ 57] pdflush [ 58] pdflush [ 60] aio/0 [ 59] kswapd0 [ 578] kseriod [ 685] kpsmoused [ 710] khubd [ 978] dhclient [ 1006] syslogd [ 1009] klogd [ 1021] sshd [ 1027] mingetty