AWS EC2 miễn phí xài Xen hypervisor phải không?

Bàn ủi con gà chạy bằng than ngày xưa – Hình minh họa.

AWS có cái tên gọi bóng bẩy, màu mè, không đụng hàng cho dịch vụ máy ảo của họ là Elastic Compute viết tắt là EC2.

AWS EC2 nghe có vẻ lạ lẫm với nhiều người, nhất là những người tưởng điện toán đám mây là cái gì đó ghê gớm lắm nhưng thực ra nó không hơn gì máy ảo chạy trên VirtualBox hay VMware Workstation hay Hyper V trên máy tính của bạn cả.

Bây giờ chúng ta hãy cùng tìm hiểu xem máy ảo EC2 chạy hệ điều hành Amazon Linux 2023 do chính họ đóng gói lại từ Fedora xài công nghệ ảo hóa gì.

À thì ra AWS xài Xen hypervisor để tạo ra các máy ảo EC2 miễn phí họ gọi là Free tier.

Lệnh Linux kiểm tra EC2 chạy bằng công nghệ ảo hóa Xen hypervisor ở các hình dưới.

# cat /etc/os-release 
NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023.3.20240312"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/amazon-linux-2023/"
DOCUMENTATION_URL="https://docs.aws.amazon.com/linux/"
SUPPORT_URL="https://aws.amazon.com/premiumsupport/"
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
VENDOR_NAME="AWS"
VENDOR_URL="https://aws.amazon.com/"
SUPPORT_END="2028-03-15"

# systemd-detect-virt 
xen

# dmidecode | egrep 'Vendor|Manufacturer|Product Name|Manufacturer'
        Vendor: Xen
        Manufacturer: Xen
        Product Name: HVM domU
        Manufacturer: Xen
        Manufacturer: Intel
        Manufacturer: Not Specified

Xen hypervisor ra đời tháng 10 năm 2003 cách đây hơn 20 năm phiên bản mới nhất là 4.18.

Xen hypervisor được xếp vào dạng ảo hóa loại 1, tức là chạy trực tiếp trên phần cứng vật lí.

Hiện tại thì EC2 chạy với Xen hypervisor version 4.11.

# dmesg | grep -i xen
[    0.000000] DMI: Xen HVM domU, BIOS 4.11.amazon 08/24/2006
[    0.000000] Hypervisor detected: Xen HVM
[    0.000000] Xen version 4.11.
[    0.000000] platform_pci_unplug: Netfront and the Xen platform PCI driver have been compiled for this kernel: unplug emulated NICs.
[    0.000000] platform_pci_unplug: Blkfront and the Xen platform PCI driver have been compiled for this kernel: unplug emulated disks.
[    0.029604] ACPI: RSDP 0x00000000000EA020 000024 (v02 Xen   )
[    0.029608] ACPI: XSDT 0x00000000FC00C780 000054 (v01 Xen    HVM      00000000 HVML 00000000)
[    0.029614] ACPI: FACP 0x00000000FC00C440 0000F4 (v04 Xen    HVM      00000000 HVML 00000000)
[    0.029619] ACPI: DSDT 0x00000000FC003940 008A7E (v02 Xen    HVM      00000000 INTL 20090123)
[    0.029627] ACPI: APIC 0x00000000FC00C540 0000D8 (v02 Xen    HVM      00000000 HVML 00000000)
[    0.029630] ACPI: HPET 0x00000000FC00C690 000038 (v01 Xen    HVM      00000000 HVML 00000000)
[    0.029633] ACPI: WAET 0x00000000FC00C6D0 000028 (v01 Xen    HVM      00000000 HVML 00000000)
[    0.029636] ACPI: SSDT 0x00000000FC00C700 000031 (v02 Xen    HVM      00000000 INTL 20090123)
[    0.029638] ACPI: SSDT 0x00000000FC00C740 000033 (v02 Xen    HVM      00000000 INTL 20090123)
[    0.036645] Booting paravirtualized kernel on Xen HVM
[    0.042214] xen: PV spinlocks enabled
[    0.057833] xen:events: Using 2-level ABI
[    0.057974] xen:events: Xen HVM callback vector for event delivery is enabled
[    0.194358] clocksource: xen: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns
[    0.194372] Xen: using vcpuop timer interface
[    0.194382] installing Xen timer for CPU 0
[    0.241471] xen: --> pirq=16 -> irq=9 (gsi=9)
[    0.305637] xen:balloon: Initialising balloon driver
[    0.316952] clocksource: Switched to clocksource xen
[    0.317269] xen: --> pirq=17 -> irq=8 (gsi=8)
[    0.317311] xen: --> pirq=18 -> irq=12 (gsi=12)
[    0.317342] xen: --> pirq=19 -> irq=1 (gsi=1)
[    0.317376] xen: --> pirq=20 -> irq=6 (gsi=6)
[    0.317414] xen: --> pirq=21 -> irq=4 (gsi=4)
[    0.397714] xen: --> pirq=22 -> irq=28 (gsi=28)
[    0.397887] xen:grant_table: Grant tables using version 1 layout
[    0.449623] xen_netfront: Initialising Xen virtual ethernet driver
[    0.657444] systemd[1]: Detected virtualization xen.
[    3.257767] systemd[1]: Detected virtualization xen.

# hostnamectl 
 Static hostname: ip-172-31-12-156.ap-southeast-1.compute.internal
       Icon name: computer-vm
         Chassis: vm 🖴
      Machine ID: 0424d7564fc24bd4a4fe96ae0c605c92
         Boot ID: a4f450ef4aa34c58a53b828d30f0bcc7
  Virtualization: xen
Operating System: Amazon Linux 2023.3.20240312
     CPE OS Name: cpe:2.3:o:amazon:amazon_linux:2023
          Kernel: Linux 6.1.79-99.164.amzn2023.x86_64
    Architecture: x86-64
 Hardware Vendor: Xen
  Hardware Model: HVM domU
Firmware Version: 4.11.amazon
 
# lspci 
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 01)
00:02.0 VGA compatible controller: Cirrus Logic GD 5446
00:03.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)

# lscpu 
Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         46 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  1
  On-line CPU(s) list:   0
Vendor ID:               GenuineIntel
  BIOS Vendor ID:        Intel
  Model name:            Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
    CPU family:          6
    Model:               63
    Thread(s) per core:  1
    Core(s) per socket:  1
    Socket(s):           1
    Stepping:            2
    BogoMIPS:            4800.01
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_go
                         od nopl xtopology cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f
                         16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti fsgsbase bmi1 avx2 smep bmi2 erms invpcid xsaveopt
Virtualization features: 
  Hypervisor vendor:     Xen
  Virtualization type:   full
Caches (sum of all):     
  L1d:                   32 KiB (1 instance)
  L1i:                   32 KiB (1 instance)
  L2:                    256 KiB (1 instance)
  L3:                    30 MiB (1 instance)
NUMA:                    
  NUMA node(s):          1
  NUMA node0 CPU(s):     0
Vulnerabilities:         
  Gather data sampling:  Not affected
  Itlb multihit:         KVM: Mitigation: VMX unsupported
  L1tf:                  Mitigation; PTE Inversion
  Mds:                   Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
  Meltdown:              Mitigation; PTI
  Mmio stale data:       Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
  Retbleed:              Not affected
  Spec rstack overflow:  Not affected
  Spec store bypass:     Vulnerable
  Spectre v1:            Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:            Mitigation; Retpolines, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected
  Srbds:                 Not affected
  Tsx async abort:       Not affected

# lsirq 
IRQ TOTAL NAME
HYP 25320 Hypervisor callback interrupts
 48 14298 xen-percpu -virq timer0
 55  6842 xen-dyn-lateeoi -event blkif
 56  3958 xen-dyn-lateeoi -event enX0
 54   297 xen-dyn -event xenbus
  4   152 xen-pirq 4-ioapic-edge ttyS0
  0     7 IO-APIC 2-edge timer
  8     2 xen-pirq 8-ioapic-edge rtc0
MCP     2 Machine check polls
 12     1 xen-pirq 12-ioapic-edge i8042
  1     0 xen-pirq 1-ioapic-edge i8042
  9     0 xen-pirq 9-ioapic-level acpi
 14     0 IO-APIC 14-edge ata_piix
 15     0 IO-APIC 15-edge ata_piix
 49     0 xen-percpu -ipi resched0
 50     0 xen-percpu -ipi callfunc0
 51     0 xen-percpu -virq debug0
 52     0 xen-percpu -ipi callfuncsingle0
 53     0 xen-percpu -ipi spinlock0
NMI     0 Non-maskable interrupts
LOC     0 Local timer interrupts
SPU     0 Spurious interrupts
PMI     0 Performance monitoring interrupts
IWI     0 IRQ work interrupts
RTR     0 APIC ICR read retries
RES     0 Rescheduling interrupts
CAL     0 Function call interrupts
TLB     0 TLB shootdowns
TRM     0 Thermal event interrupts
THR     0 Threshold APIC interrupts
DFR     0 Deferred Error APIC interrupts
MCE     0 Machine check exceptions
ERR     0 
MIS     0 
PIN     0 Posted-interrupt notification event
NPI     0 Nested posted-interrupt event
PIW     0 Posted-interrupt wakeup event

# lshw 
ip-172-31-12-156.ap-southeast-1.compute.internal
    description: Computer
    product: HVM domU
    vendor: Xen
    version: 4.11.amazon
    serial: ec298699-40d5-d471-896a-eafffe803d6a
    width: 64 bits
    capabilities: smbios-2.7 dmi-2.7 vsyscall32
    configuration: boot=normal uuid=ec298699-40d5-d471-896a-eafffe803d6a
  *-core
       description: Motherboard
       physical id: 0
     *-firmware
          description: BIOS
          vendor: Xen
          physical id: 0
          version: 4.11.amazon
          date: 08/24/2006
          size: 96KiB
          capabilities: pci edd
     *-cpu
          description: CPU
          product: Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
          vendor: Intel Corp.
          physical id: 401
          bus info: cpu@0
          version: 6.63.2
          slot: CPU 1
          size: 2400MHz
          capacity: 2400MHz
          width: 64 bits
          capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp x86-64 constant_tsc rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti fsgsbase bmi1 avx2 smep bmi2 erms invpcid xsaveopt
          configuration: microcode=73
     *-memory
          description: System Memory
          physical id: 1000
          size: 1GiB
          capacity: 1GiB
          capabilities: ecc
          configuration: errordetection=multi-bit-ecc
        *-bank
             description: DIMM RAM
             physical id: 0
             slot: DIMM 0
             size: 1GiB
             width: 64 bits
     *-pci
          description: Host bridge
          product: 440FX - 82441FX PMC [Natoma]
          vendor: Intel Corporation
          physical id: 100
          bus info: pci@0000:00:00.0
          version: 02
          width: 32 bits
          clock: 33MHz
        *-isa
             description: ISA bridge
             product: 82371SB PIIX3 ISA [Natoma/Triton II]
             vendor: Intel Corporation
             physical id: 1
             bus info: pci@0000:00:01.0
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: isa
             configuration: latency=0
           *-pnp00:00
                product: PnP device PNP0c02
                physical id: 0
                capabilities: pnp
                configuration: driver=system
           *-pnp00:01
                product: PnP device PNP0c02
                physical id: 1
                capabilities: pnp
                configuration: driver=system
           *-pnp00:02
                product: PnP device PNP0b00
                physical id: 2
                capabilities: pnp
                configuration: driver=rtc_cmos
           *-pnp00:03
                product: PnP device PNP0f13
                physical id: 3
                capabilities: pnp
                configuration: driver=i8042 aux
           *-pnp00:04
                product: PnP device PNP0303
                physical id: 4
                capabilities: pnp
                configuration: driver=i8042 kbd
           *-pnp00:05
                product: PnP device PNP0700
                physical id: 5
                capabilities: pnp
           *-pnp00:06
                product: PnP device PNP0501
                physical id: 6
                capabilities: pnp
                configuration: driver=serial
           *-pnp00:07
                product: PnP device PNP0c02
                physical id: 7
                capabilities: pnp
                configuration: driver=system
        *-ide
             description: IDE interface
             product: 82371SB PIIX3 IDE [Natoma/Triton II]
             vendor: Intel Corporation
             physical id: 1.1
             bus info: pci@0000:00:01.1
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: ide isa_compat_mode bus_master
             configuration: driver=ata_piix latency=64
             resources: irq:0 ioport:1f0(size=8) ioport:3f6 ioport:170(size=8) ioport:376 ioport:c100(size=16)
        *-bridge UNCLAIMED
             description: Bridge
             product: 82371AB/EB/MB PIIX4 ACPI
             vendor: Intel Corporation
             physical id: 1.3
             bus info: pci@0000:00:01.3
             version: 01
             width: 32 bits
             clock: 33MHz
             capabilities: bridge
             configuration: latency=0
        *-display UNCLAIMED
             description: VGA compatible controller
             product: GD 5446
             vendor: Cirrus Logic
             physical id: 2
             bus info: pci@0000:00:02.0
             version: 00
             width: 32 bits
             clock: 33MHz
             capabilities: vga_controller
             configuration: latency=0
             resources: memory:f0000000-f1ffffff memory:f3000000-f3000fff memory:c0000-dffff
        *-generic
             description: Unassigned class
             product: Xen Platform Device
             vendor: XenSource, Inc.
             physical id: 3
             bus info: pci@0000:00:03.0
             version: 01
             width: 32 bits
             clock: 33MHz
             configuration: driver=xen-platform-pci latency=0
             resources: irq:28 ioport:c000(size=256) memory:f2000000-f2ffffff
  *-input:0
       product: Power Button
       physical id: 1
       logical name: input0
       logical name: /dev/input/event0
       capabilities: platform
  *-input:1
       product: Sleep Button
       physical id: 2
       logical name: input1
       logical name: /dev/input/event1
       capabilities: platform
  *-network
       description: Ethernet interface
       physical id: 3
       logical name: enX0
       serial: 02:b9:c0:11:06:1f
       capabilities: ethernet physical
       configuration: broadcast=yes driver=vif driverversion=6.1.79-99.164.amzn2023.x86_64 ip=172.31.12.156 link=yes multicast=yes