반응형
작성일: 2024년 2월 16일

 

VirtualBox가 돌아가는 Linux Baremetal 장비에 Desktop GUI를 사용할 수 없는 경우가 있다.

그런 경우는 VirtualBox CLI(명령행 인터페이스)를 이용하여 VM을 관리해야 한다.

VirtualBox CLI에 관해 자세한 내용을 확인하고 싶다면, 아래 Oracle VirtualBox 공식 메뉴얼을 읽는 것을 추천한다.

 

    [ 참고 문서: Controlling VirtualBox from the Command Line ]

    https://www.oracle.com/technical-resources/articles/it-infrastructure/admin-manage-vbox-cli.html

 

내가 자주 사용하는 VBoxManage CLI 명령만 추려 보면 아래와 같다.

 

##
## 전체 VM instance 리스트를 보기
##   (참고: Shutdown 상태의 VM까지 모두 보여준다.)
##
$ VBoxManage list vms
"MyExampleVM" {e8904c82-aaaa-bbbb-cccc-dddddbcb0f3}
"SejongVM"    {e8904c82-aaaa-bbbb-cccc-dddddbcb0f5}
"JeonjoVM"    {e8904c82-aaaa-bbbb-cccc-dddddbcb0f7}


$ VBoxManage list vms -l   ## 상세 정보를 보기
... 출력 내용 생략 ...

##
## 현재 동작하고 있는 전체 VM instance 리스트를 보기
##
$ VBoxManage list runningvms
"MyExampleVM" {e8904c82-aaaa-bbbb-cccc-dddddbcb0f3}
"SejongVM"    {e8904c82-aaaa-bbbb-cccc-dddddbcb0f5}


##
## 특정 VM instance에 대한 상세한 정보를 보기
##
$ VBoxManage showvminfo MyExampleVM


##
## 새로운 VM instance 생성하기
##
$ VBoxManage list ostypes    ## VirtualBox가 제공하는 OS Type 목록을 보여준다.
ID:          OpenSUSE_64
Description: openSUSE (64-bit)
Family ID:   Linux
Family Desc: Linux
64 bit:      true

ID:          Ubuntu_64
Description: Ubuntu (64-bit)
Family ID:   Linux
Family Desc: Linux
64 bit:      true
... 이하 생략 ...


$ VBoxManage createvm  --name MyNewUbuntuVM --ostype Ubuntu_64 --register
... 출력 내용 생략 ...


##
## VM Properties 설정하기
##
$ VBoxManage modifyvm  MyNewUbuntuVM --cpus 2 --memory 2048 --vram 12


##
## Virtual Network Adapter 설정하기
##
$ VBoxManage modifyvm  MyNewUbuntuVM --nic1 bridged --bridgeadapter1 eth0


##
## VM instance를 구동하기
##
$ VBoxManage startvm  MyNewUbuntuVM
또는
$ VBoxManage startvm  MyNewUbuntuVM --type headless   ## 화면으로 출력되는게 없도록 VM 구동


##
## VM instance를 강제 종료하기
##
$ VBoxManage controlvm  MyNewUbuntuVM  poweroff

 

 

 


 

반응형
작성일: 2024년 3월 28일

 

Oracle Cloud Infra(OCI)에서 VM instance를 생성하는 것은 Web Console에서 권고값을 따라

"다음", "OK" 같은 버튼만 누르면 쉽게 처리할 수 있다.

 

그런데 이렇게 생성한 VM instance에 SSH 접속하려고 하면, Oracle 매뉴얼처럼 수행했을 때 잘 안 된다.

SSH 접속이 안 되는 원인이 OS Image 마다 조금 달랐다.

 

참고: VM instance에 기본 로그인 계정 설정하기

    Oracle OCI Web Console에서 VM instance에 console 화면에 접근하려면,
    VM instance를 생성하는 시점에 cloud-init 스크립트에 Login 계정을 설정해야 한다. (ID, Password 등)
    아래 블로그에 자세한 방법과 예제가 있다. 예제를 보고 따라하면 된다.

    https://andrewpage.tistory.com/171

 

 

Case: "Oracle Linux 8 Image"를 이용하여 VM Instance를 만든 경우

 방화벽이 활성화되어 있어서 Source IP address가 동일 Subnet이 아닌 경우 SSH 접속이 막고 있다.

아래 명령을 수행해서 방화벽을 끄면 된다.

$ systemctl stop firewalld

$ systemctl disable firwalld

 

초기 작업을 위해 위와 같이 방화벽을 우선 끄고 SSH 접속하고, 어느 정도 Network과 관련한 설정을 변경하고 나면 

다시 firewalld 서비스를 활성화해야 한다. (보안을 위해서 꼭 잊지 말고 해야 한다)

 

 

Case: "Ubuntu 22.04 Image"를 이용하여 VM Instance를 만든 경우

Ubuntu 22.04 VM instance는 다행히 Ubuntu Firewall 서비스가 꺼져 있다.

그런데 Netfilter가 특정 몇개 Port를 제외하고 모두 Reject 하도록 설정되어 있다.

그러므로 Netfilter의 Rule을 조정할 필요가 있다. (아래 명령을 참고)

$ iptables -F

 

그리고 아래와 같이 iptables rule을 다시 구성했다. 

아래 스크립트 중에서 "FIXME" 라고 코멘트 추가한 부분을 참고하면 된다.

$ cat /etc/iptables/rules.v4

# CLOUD_IMG: This file was created/modified by the Cloud Image build process
# iptables configuration for Oracle Cloud Infrastructure

# See the Oracle-Provided Images section in the Oracle Cloud Infrastructure
# documentation for security impact of modifying or removing these rule

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [463:49013]
:InstanceServices - [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p udp --sport 123 -j ACCEPT

## FIXME: Domain Name Server 접근을 허용하는 Rule 추가
-I INPUT -p udp -m udp --dport 53 -j ACCEPT

## FIXME: SSH 접속할 포트를 변경
-A INPUT -p tcp -m state --state NEW -m tcp --dport 2022 -j ACCEPT 

-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited

... 이하 생략 ...

 

위와 같이 /etc/iptables/rules.v4 를 수정하고, 깔끔하게 VM instance를 Restart하고 SSH를 접속해보자~

잘 접속될 것이다. ^^

 


 

반응형

 


 

작성일: 2023년 9월 19일

 

어찌저찌 하다가 얻어 걸린 정보라서 메모를 해둔다.  (곧 까먹을 것 같아서...)

 

##
## Google 검색어 입력란(Text Box)에 아래 문장을 입력하고 검색하기.
##

intitle:index.of ios parent directory bin

 

위 검색어로 검색하면, 아래와 같은 결과가 출력될 것이다.

 

 

검색 결과에 여러 웹 사이트가 있지만, 아래 웹 사이트 가장 괜찮은 것 같다.

 

 

Index of /pustaka/docs/GNS3/images

 

lms.onnocenter.or.id

 

위 웹 사이트에서 CISCO C7200 Router에 대한 ios를 다운로드한 후, 아래 동영상을 보면서 따라하면 아주 쉽게 GNS3에 Router Image를 등록할 수 있다.

 

 

 

 

반응형

 

작성일: 2024년 2월 16일

 

 

Openstack에서 VM Instance를 새로 생성할 때, OS에 설정할 내용이 있다면 User Data를 입력하면 편하다.

(VM instance의 user datainit-cloud, cloud-init 스크립트라는 용어로 불리는 경우도 있다)

아래와 같이 예제를 보고, 필요한 부문만 조금씩 바꾸어 사용하는 것을 추천~

 

#cloud-config

ssh_pwauth: True

ssh_authorized_keys:
  - ssh-rsa AAA...SDvz sejong@xx.yy.com
  - ssh-rsa AAB...QTuo alphaa@aa.bb.com

chpasswd:
  list: |
     root:myxxyyzzroot
     ubuntu:myubuntuxxyyzz
     cloud-user:myxxyyzz
  expire: False
    
locale: en_US.UTF-8

# timezone: America/New_York
timezone: Asia/Seoul

bootcmd:
 - echo "My command at system booting" >> /var/my-cmd.txt

runcmd:
 - echo "My command example" >> /var/my-cmd.txt
 - apt install locales
 - locale-gen en_US.UTF-8
 - locale-gen ko_KR.UTF-8

 

위 예제는 root, ubuntu, cloud-user 등 3개 계정의 Password를 변경하고, timezone을 서울로 설정하고, Locale(언어)를 English로 설정하는 예제이다.

 

 


 

 

더 자세한 내용은 아래 Web Docs를 참고하자 !!!

 

Red Hat 문서

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_cloud-init_for_rhel_8/configuring-cloud-init_cloud-content

 

다양한 cloud-init 설정 예제 문서

https://ko.linux-console.net/?p=8814

 

'CentOS' 카테고리의 다른 글

Hugepage 설정 절차  (0) 2022.08.02
YUM 또는 DNF Repository 추가 방법  (0) 2022.06.22
CPU Pinning 예제 코드  (0) 2022.06.17
Install Ansible AWX (version 17.1.0)  (0) 2021.11.16
How to use Ansible and Playbook  (0) 2021.11.12
반응형

 



virsh, virt-install 명령 테스트한 날짜: 2023년 3월 6일

 

KVM을 사용하다보면, Virt-Manager라는 GUI 툴이 조작하기 편해서 계속 Virt-Manager만 사용하게 된다.

그런데 가끔 SSH 터미널만 사용할 수 있는 환경이거나 CLI Command만 이용해서 Script를 작성할 때는 virsh를 꼭 사용해야 한다.

 

Virtual Machine 생성하기 (그리고 VM에 OS 설치하기)

##
##  2023년 1월에 실제 Ubuntu 설치할 때 사용했던 명령.
##   참고: --disk 옵션에 기존에 사용했던 qcow image file을 사용하면 kernel을 못 찾는다는 에러 발생.
##        원인은 아직 모르겠음.
##   참고: 아래 명령을 수행하고 대략 55초 정도 지나야 Console에 text message가 출력된다.
##        (내가 사용한 HW Spec: i7-11700, 64GB)
##        따라서 느긋하게 기다려야 제대로 설치가 가능하다.
##

## 참고: size 단위는 GB.

## Case: OS 설치하면서 VM instance 시작하기
##       (주의: OS 설치하면서 VM start 할 때는 --osinfo 옵션을 빼야 한다.)

$ virt-install \
  --name my-vm \
  --ram 4096 \
  --vcpus 2 \
  --disk /mnt/sda1/virtual_storage/waas.qcow2,size=100 \
  --disk /mnt/hdd0/virtual_machine/harbor-2nd-storage.qcow2,size=500 \
  --graphics none \
  --network network=br-ex \
  --console pty,target.type=virtio \
  --autoconsole text \
  --location /home/iso/ubuntu-22.04.1-live-server-amd64.iso
 


## Case: 기존 사용했던 VM 이미지를 이용하여 VM instance 기동하기.

$ virt-install \
  --import \               ## 기존 VM image 파일을 이용하겠다는 옵션
  --osinfo ubuntu22.04 \   ## 이 osinfo 옵션을 꼭 추가해야 한다.
  --name my-vm \
  --ram 4096 \
  --vcpus 2 \
  --disk /mnt/sda1/virtual_storage/waas.qcow2,size=100 \
  --graphics none \
  --network network=br-ex \
  --console pty,target.type=virtio \
  --autoconsole text

  
  
##
## CPU Pinning, Hugepages 설정이 필요해서 사용했던 명령.
##

$ virt-install --import \
  --name my-machine \
  --vcpus 4 \
## CPU Pinning  
  --cpuset=2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32 \
  --memory=4096 \
## Hugepages  
  --memorybacking hugepages=on \
  --numatune 0 \
  --disk /mydir/my-machine.qcow2 \
  --network bridge=my-br \
  --network bridge=ems-br \
  --os-variant rhel7.9 \
  --noautoconsole
  
  
  ##
  ## 주의:
  ##  아래 --osinfo, --os-variant 옵션을 사용하면 VM instance 생성할 때 오류가 발생한다.
  ##  꼭 필요한 옵션이 아니니까, 아래 2가지 옵션을 사용하지 않는 것이 좋다. (2023년 1월 현재)
  ##    --osinfo ubuntu22.04
  ##    --os-variant ubuntu22.04
  ##
  
  
  ##
  ## 주의:
  ##  VM instance 내부에서 OS 설치가 끝나고, 자동 reboot되어야 하는게 정상이지만
  ##  가끔 OS termination 단계에서 실패하고 멈춘 경우가 있다.
  ##  reboot 시도 후 30초 후에도 console 화면의 변화가 없다면
  ##  과감하게 VM instance destroy를 시도한다.  (아래 명령을 사용)
  ##  
  $  
  ##

 

위 `virt-install` 명령을 실행하면, 바로 아래 화면이 출력되고

이 화면에서 대략 55~60초 정도 기다려야 다음 설치 화면으로 넘어간다.

 

 

위 화면에서 대략 55~60초 정도 기다리면, 드디어 아래와 같이 OS 설치 시작 화면이 나온다.

 

 

비록 Text Terminal 이지만, 조금이라도 예쁜 설치 화면을 원하면 "rich mode"를 선택한다.

이후부터는 일반적인 Ubuntu OS 설치 절차와 같다.

 

 

 

 

 

 

Virtual Machine 목록 보기

$  virsh list --all
 Id   Name     State
-------------------------
 1    x-node   running
 -    am0      shut off
 -    aw0      shut off
 -    aw1      shut off
 $

 

 

Virtual Machine 기동하기

##
## am0 가상 머신을 기동하기
##

$  virsh start am0
Domain am0 started


##
## am0 가상 머신이 기동되었는지 확인하기
##

$  virsh list --all
 Id   Name     State
-------------------------
 1    x-node   running
 2    am0      running
 -    aw0      shut off
 -    aw1      shut off
$

 

 

Virtual Machine 종료하기

##
## Graceful Termination of VM instance
## (참고로, 아래 숫자 2는 VM의 ID이다)
##

$  virsh shutdown 2
Domain 2 is being shutdown

$


##
## VM instance 강제 종료
## (참고로, 아래 숫자 2는 VM의 ID이다)
##

$ virsh destroy 2


##
## VM instance 삭제하기
##
$ virsh undefine vm-name

 

 

Virtual Machine의  Console에 접속하기

$  virsh console x-node
Connected to domain x-node
Escape character is ^]

CentOS Linux 8
x-node login: root
Password: ......

[root@x-node ~]# _

 

 

qcow2 image file size 조정 (resize)

##
## 원하는 size로 vm image를 재조정할 수 있다.
## 최초에 작게 만들어진 volume image 용량을 더 크게 늘리기 위해서 사용한다.
##

$ qemu-img  resize  myvm.qcow2  100G


##
##  아래 명령과 같이 수행하여 기존 VM image에서 빈 공간을 제거하고 size를 줄일 수 있다.
##  보통 qcow2 파일을 다른 장비로 옮길 때, vm image size를 줄이기 위한 용도로 사용된다.
##  참고: 원본 qcow2 이미지 파일은 유지되므로 별도로 백업하지 않아도 된다.
 
$  qemu-img convert -O qcow2 source_image.qcow2 shrunk_image.qcow2


##
## volume image 정보를 열람한다.
##

$ qemu-img  info    myvm.qcow2

 

 

qcow2 image 파일 생성하기

##
## 만약 qcow2 type의 virtual volume을 만들고 싶다면 아래와 같이 명령을 수행.
## Volume size는 250GB로 지정했지만, 실제로는 qcow2 파일에 meta data만 생성하기 때문에
## 실제 사이느는 1MB 밖에 안 되고, 시간도 3초 정도 밖에 안 걸린다.
##

$  qemu-img  create  -f qcow2  my-virtual-volume.qcow2  250G

 

 

VM의 OS Type 전체 목록 열람하기

$  virt-install --osinfo list
...
ubuntu-lts-latest, ubuntu-stable-latest, ubuntu22.04, ubuntujammy
ubuntu21.10, ubuntuimpish
ubuntu21.04, ubuntuhirsute
ubuntu20.10, ubuntugroovy
ubuntu20.04, ubuntufocal
...
$

 

 

기존 VM instance에 disk 추가하기

$ virsh edit my-vm

... 중간 생략 ...

  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' discard='unmap'/>
      <source file='/var/lib/libvirt/images/my-vm-a.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
    </disk>
    ##
    ## FIXME: 이 부분을 추가한다.
    ##
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/opt/virtual_storage/vol_01.qcow2'/>
      <target dev='vdb' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
    </disk>
    
... 중간 생략 ...

$ virsh reboot my-vm

## 또는 아래와 같이 hypervisor를 restart한다.

$ systemctl restart libvirt-bin

 

위 방식과 다르게 virt-install 명령으로 disk를 추가하여 VM instance를 재시작한다.

virt-install \
  --import \
  --name my-vm \
  --osinfo ubuntu22.04 \
  --ram 2048 \
  --vcpus 2 \
  --disk  /opt/virtual_machine/my-vm.qcow2 \
  --disk  /opt/virtual_machine/my-new-disk.qcow2 \
  --graphics none \
  --network network=br-ex \
  --console pty,target.type=virtio \
  --autoconsole text

 

 

 

 

 


 

게시물 작성자: sejong.jeonjo@gmail.com

 

반응형

 

KVM, OpenStack, Kubernetes, OCP 등을 사용하다보면 VM에서 또는 Container 내부에서 CPU를 Pinning하거나 NUMA Node를 지정해야 할 경우가 있는데, 이런 CPU Pinning 설정/관리에 대한 내용을 기록해볼까~~~하고 마음을 먹었다. 그러나 너무 잘 작성한 블로그와 WebDocs가 있어서 그냥 Link만 걸어두기로 마음을 바꾸었다. :)

 

 

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/virtualization/ch33s08

 

33.8. Setting KVM processor affinities Red Hat Enterprise Linux 5 | Red Hat Customer Portal

The Red Hat Customer Portal delivers the knowledge, expertise, and guidance available through your Red Hat subscription.

access.redhat.com

 

 

 

https://mhsamsal.wordpress.com/2020/05/12/how-to-perform-cpu-pinning-for-kvm-virtual-machines-and-docker-containers/

 

How to Perform CPU Pinning for KVM Virtual Machines and Docker Containers

Note: This post provides technical details for our paper “The Art of CPU-Pinning: Evaluating and Improving the Performance of Virtualization and Containerization Platforms” published in…

mhsamsal.wordpress.com

 

 

 

https://superuser.com/questions/1519358/qemu-kvm-cpu-pinning

 

QEMU/KVM cpu pinning

I have set up my VM with pci passthrough and now I am trying to set up cpupinning. How do I verify that it does in fact work? My config regarding cpu parameters: ... <vcpu placement="static">...

superuser.com

 

 

반응형

 

 

구성 환경

 

Host OS: Ubuntu

Hypervisor: KVM

VM(Guest): CentOS, Ubuntu, CoreOS 등 (Linux 계열)

 

 

우선 아래의 Web Docs를 보고 설정 및 테스트해보고, 잘 동작하면 여기에 테스트한 내용을 기록할 예정이다.

 

https://help.ubuntu.com/community/KVM%20-%20Using%20Hugepages

 

KVM - Using Hugepages - Community Help Wiki

Introduction The computer memory is divided in pages. The standard page size on most systems is 4KB. To keep track on what information is stored in which page, the system uses a page table. Searching in this page table is (in computer terms) a time costly

help.ubuntu.com

 

 

블로그 작성자: sejong.jeonjo@gmail.com

 

반응형

 

 

Host OS가 Ubuntu 20.04이고, 이 Host에 KVM을 설치했다.

그리고 이 KVM에서 PCI passthrough를 사용하는 방법을 정리해봤다.

 

 

참고: 이론적인 내용은 아래 블로그가 아주 쉽게 설명하고 있다.

https://www.nepirity.com/blog/kvm-gpu-passthrough/

 

KVM 기반의 GPU Passthrough 환경 - 네피리티

KVM 기반의 GPU Passthrough 환경 KVM 기반의 Hypervisor 에서 하드웨어 장치를 직접 Virtual Machine에게 할당하는 PassThrough 를 소개하고 환경 설정 방법에 대해서 설명드리도록 하겠습니다. PCI Passthrough는 NIC,

www.nepirity.com

 

 

 

 

PCI passthrough 사용을 위한 Host OS 설정

 

PCI passthrough를 사용하기 위해 아래 명령과 같이 Host OS를 설정한다.

 

##
## Grub 설정
##

$  cat /etc/default/grub

... 중간 생략 ...

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_iommu=on intel_iommu=igfx_off iommu=pt vfio-pci.ids=8086:1572"

... 중간 생략 ...

$  reboot

...
...
...


##
## Host OS가 Booting 되면, 아래와 같이 PCI에 관한 로그를 확인한다. "iommu=pt" 설정 확인
##

$  dmesg | grep -i vfio
[    0.000000] Command line: BOOT_IMAGE=/vmlinuz-5.4.0-94-generic root=UUID=7824a9ea-e59b-4796-9e23-75e3d909a001 ro quiet splash intel_iommu=on intel_iommu=igfx_off iommu=pt vfio-pci.ids=8086:1572 vt.handoff=7
[    4.136218] Kernel command line: BOOT_IMAGE=/vmlinuz-5.4.0-94-generic root=UUID=7824a9ea-e59b-4796-9e23-75e3d909a001 ro quiet splash intel_iommu=on intel_iommu=igfx_off iommu=pt vfio-pci.ids=8086:1572 vt.handoff=7
[   10.734658] VFIO - User Level meta-driver version: 0.3
[   10.814142] vfio_pci: add [8086:1572[ffffffff:ffffffff]] class 0x000000/00000000

...
...
...


$  lspci -k

... 중간 생략 ...

12:00.0 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 02)
        Subsystem: Hewlett-Packard Company Ethernet 10Gb 2-port 562SFP+ Adapter
        Kernel driver in use: vfio-pci
        Kernel modules: i40e
12:00.1 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 02)
        Subsystem: Hewlett-Packard Company Ethernet 10Gb 562SFP+ Adapter
        Kernel driver in use: vfio-pci
        Kernel modules: i40e

... 중간 생략 ...

$

 

 

PCI passthrough 사용을 위한 KVM 설정

 

##
## PCI passthrough할 NIC이 x710 드라이버를 사용한다고 가정하고
## 아래 설정 절차를 진행했다.
##

$  lspci | grep -i x710
12:00.0 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 02)
12:00.1 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 02)
af:00.0 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 02)
af:00.1 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 02)
$

##
## 위 출력된 내용 중에서 왼쪽 컬럼의 
##  12:00.0 
##  12:00.1
##  af:00.0
##  af:00.1
## 이 값을 이용하여 아래와 같이 KVM이 관리하는 device list를 확인한다.
##
##  참고:
##    nodedev-list로 출력된 device들은 모든 VM에서 공유해서 사용하는 device이므로
##    특정 VM에서 PCI device를 독점적으로 점유하려면, 아래 device를 KVM에서 detach하고
##    특정 VM의 HW에 아래 PCI device를 추가해주어야 PCI passthrough 효과를 얻을 수 있다.
##

$  virsh nodedev-list | grep 12_00
pci_0000_12_00_0
pci_0000_12_00_1
$  virsh nodedev-list | grep af_00
pci_0000_af_00_0
pci_0000_af_00_1
$

##
## PCI 슬롯 번호로 host에 등록된 PCI장비의 이름을 확인후 이 이름을 바탕으로 device 상제 정보를 확인한다.
## 아래 출력 내용 중에서 bus, slot, function 번호 확인 => KVM에서 VM의 device 추가할 때 필요하다.
##



root@bmt:~# virsh nodedev-dumpxml pci_0000_12_00_0
<device>
  <name>pci_0000_12_00_0</name>
  <path>/sys/devices/pci0000:11/0000:11:00.0/0000:12:00.0</path>
  <parent>pci_0000_11_00_0</parent>
  <driver>
    <name>vfio-pci</name>
  </driver>
  <capability type='pci'>
    <class>0x020000</class>
    <domain>0</domain>
    <bus>18</bus>
    <slot>0</slot>
    <function>0</function>
    <product id='0x1572'>Ethernet Controller X710 for 10GbE SFP+</product>
    <vendor id='0x8086'>Intel Corporation</vendor>
    <capability type='virt_functions' maxCount='64'/>
    <iommuGroup number='38'>
      <address domain='0x0000' bus='0x12' slot='0x00' function='0x0'/>
    </iommuGroup>
    <numa node='0'/>
    <pci-express>
      <link validity='cap' port='0' speed='8' width='8'/>
      <link validity='sta' speed='8' width='8'/>
    </pci-express>
  </capability>
</device>


root@bmt:~# virsh nodedev-dumpxml pci_0000_12_00_1
<device>
  <name>pci_0000_12_00_1</name>
  <path>/sys/devices/pci0000:11/0000:11:00.0/0000:12:00.1</path>
  <parent>pci_0000_11_00_0</parent>
  <driver>
    <name>vfio-pci</name>
  </driver>
  <capability type='pci'>
    <class>0x020000</class>
    <domain>0</domain>
    <bus>18</bus>
    <slot>0</slot>
    <function>1</function>
    <product id='0x1572'>Ethernet Controller X710 for 10GbE SFP+</product>
    <vendor id='0x8086'>Intel Corporation</vendor>
    <capability type='virt_functions' maxCount='64'/>
    <iommuGroup number='39'>
      <address domain='0x0000' bus='0x12' slot='0x00' function='0x1'/>
    </iommuGroup>
    <numa node='0'/>
    <pci-express>
      <link validity='cap' port='0' speed='8' width='8'/>
      <link validity='sta' speed='8' width='8'/>
    </pci-express>
  </capability>
</device>


root@bmt:~# virsh nodedev-dumpxml pci_0000_af_00_0
<device>
  <name>pci_0000_af_00_0</name>
  <path>/sys/devices/pci0000:ae/0000:ae:00.0/0000:af:00.0</path>
  <parent>pci_0000_ae_00_0</parent>
  <driver>
    <name>vfio-pci</name>
  </driver>
  <capability type='pci'>
    <class>0x020000</class>
    <domain>0</domain>
    <bus>175</bus>
    <slot>0</slot>
    <function>0</function>
    <product id='0x1572'>Ethernet Controller X710 for 10GbE SFP+</product>
    <vendor id='0x8086'>Intel Corporation</vendor>
    <capability type='virt_functions' maxCount='64'/>
    <iommuGroup number='151'>
      <address domain='0x0000' bus='0xaf' slot='0x00' function='0x0'/>
    </iommuGroup>
    <pci-express>
      <link validity='cap' port='0' speed='8' width='8'/>
      <link validity='sta' speed='8' width='8'/>
    </pci-express>
  </capability>
</device>


root@bmt:~# virsh nodedev-dumpxml pci_0000_af_00_1
<device>
  <name>pci_0000_af_00_1</name>
  <path>/sys/devices/pci0000:ae/0000:ae:00.0/0000:af:00.1</path>
  <parent>pci_0000_ae_00_0</parent>
  <driver>
    <name>vfio-pci</name>
  </driver>
  <capability type='pci'>
    <class>0x020000</class>
    <domain>0</domain>
    <bus>175</bus>
    <slot>0</slot>
    <function>1</function>
    <product id='0x1572'>Ethernet Controller X710 for 10GbE SFP+</product>
    <vendor id='0x8086'>Intel Corporation</vendor>
    <capability type='virt_functions' maxCount='64'/>
    <iommuGroup number='152'>
      <address domain='0x0000' bus='0xaf' slot='0x00' function='0x1'/>
    </iommuGroup>
    <pci-express>
      <link validity='cap' port='0' speed='8' width='8'/>
      <link validity='sta' speed='8' width='8'/>
    </pci-express>
  </capability>
</device>


##
## Host에서 위의 PCI Device를 detach한다.
##   참고: Host에 Attach된 nodedev는 VM에 Mount가 불가능하여 Detach해야 한다.
##        즉, 특정 VM에서만 위 PCI 장치를 전용해서 사용해야 하기 때문에
##        다수의 VM이 위 PCI 장비를 공유하지 못하도록 싹을 뽑아 버린다고 생각하면 된다.
##

$  virsh nodedev-detach pci_0000_12_00_0
Device pci_0000_12_00_0 detached

$  virsh nodedev-detach pci_0000_12_00_1
Device pci_0000_12_00_1 detached

 

위와 같이 KVM에서 Host 머신의 PCI 장치를 Detach했으면, 아래 KVM Virtual Manager 화면에서

특정 Virtual Machine 의 설정 화면을 열어본다.

그리고 이 Virtual Machine에 PCI Device를 추가한다. (아래 화면의 설정 순서를 따라할 것!!!) 

 

 

KVM Virt-Manager 에서 특정 VM의 HW 설정

 

위 설정 화면에서 [Finish] 버튼을 누르면, 아래 화면처럼 새로 추가한 PCI 장치 정보를 볼 수 있다.

 

 

VM의 HW 목록 및 설정 정보를 확인

 

 

 

위와 같이 Virtual Machine이 설정된 후에 VM 내부에서는 SR-IOV 구성까지 해야 NIC에 여러 VF를 생성하고, Application Process가 VF를 사용할 수 있을 것이다. (이후 과정에 나중에 테스트하면서 다시 기록할 생각이다) 

 

 

'Ubuntu' 카테고리의 다른 글

Epoch & Unix Time변환 (Date 변환)  (0) 2022.07.07
KVM의 VM에서 Hugepage 사용하기  (0) 2022.01.13
rc.local 활성 설정 (Ubuntu, CentOS)  (0) 2021.12.28
추가 장착한 Disk Mount  (0) 2021.12.28
Root 계정의 SSH 로그인 허용  (0) 2021.12.28

+ Recent posts