根据最初的实验计划,新手小白继续尝试,本篇内容,为大家分享在openEuler中安装虚拟机。
本篇内容主要包含的内容如下:
01、启动libvirtd服务并设置开机自启;
02、创建存储池;
03、创建虚拟机磁盘空间;
04、创建虚拟机;
05、虚拟机的一些操作和命令;
06、登陆虚拟机系统。
参考文献如下:
https://www.hikunpeng.com/document/detail/zh/kunpengcpfs/ecosystemEnable/QEMU-KVM/kunpengkvm_03_0010.html
下面开始具体内容:
01、启动libvirtd服务并设置开机自启。
systemctl start libvirtd
systemctl enable libvirtd
启动libvirtd服务
在Linux系统中,libvirtd是管理虚拟化技术的一个关键组件,通常包括对KVM、QEMU等虚拟化技术的支持。
查看当前运行的服务:
[root@PengFei ~]# systemctl list-units --type=service --state=running
UNIT LOAD ACTIVE SUB DESCRIPTION
atd.service loaded active running Deferred execution scheduler
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
docker.service loaded active running Docker Application Container Engine
getty@tty1.service loaded active running Getty on tty1
gssproxy.service loaded active running GSSAPI Proxy Daemon
httpd.service loaded active running The Apache HTTP Server
irqbalance.service loaded active running irqbalance daemon
isulad.service loaded active running iSulad Application Container Engine
libstoragemgmt.service loaded active running libstoragemgmt plug-in server daemon
mdmonitor.service loaded active running MD array monitor
NetworkManager.service loaded active running Network Manager
php-fpm.service loaded active running The PHP FastCGI Process Manager
pmcd.service loaded active running Performance Metrics Collector Daemon
pmie.service loaded active running Performance Metrics Inference Engine
pmie_farm.service loaded active running pmie farm service
pmie_farm_check.service loaded active running Check and migrate non-primary pmie instances to pmie_farm
pmlogger.service loaded active running Performance Metrics Archive Logger
pmlogger_farm.service loaded active running pmlogger farm service
polkit.service loaded active running Authorization Manager
rasdaemon.service loaded active running RAS daemon to log the RAS events
rngd.service loaded active running Hardware RNG Entropy Gatherer Daemon
rpcbind.service loaded active running RPC Bind
rsyslog.service loaded active running System Logging Service
serial-getty@ttyAMA0.service loaded active running Serial Getty on ttyAMA0
sshd.service loaded active running OpenSSH server daemon
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running User Login Management
systemd-machined.service loaded active running Virtual Machine and Container Registration Service
systemd-udevd.service loaded active running Rule-based Manager for Device Events and Files
tuned.service loaded active running Dynamic System Tuning Daemon
zabbix_agentd.service loaded active running SYSV: zabbix_agentd
zb_daemon.service loaded active running zb_daemon.service
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
35 loaded units listed.
[root@PengFei ~]#
查看所有的服务
[root@PengFei ~]# systemctl list-units --type=service
UNITLOAD ACTIVE SUB DESCRIPTION >
atd.serviceloaded active running Deferred execution scheduler
auditd.serviceloaded active running Security Auditing Service
chronyd.serviceloaded active running NTP client/server
crond.serviceloaded active running Command Scheduler
dbus.serviceloaded active running D-Bus System Message Bus
dkms.serviceloaded active exited Builds and install new kernel modules through D>
docker.serviceloaded active running Docker Application Container Engine
dracut-shutdown.serviceloaded active exited Restore /run/initramfs on shutdown
getty@tty1.serviceloaded active running Getty on tty1
gssproxy.serviceloaded active running GSSAPI Proxy Daemon
httpd.serviceloaded active running The Apache HTTP Server
hwclock-save.serviceloaded active exited Update RTC With System Clock
irqbalance.serviceloaded active running irqbalance daemon
iscsi.serviceloaded active exited Login and scanning of iSCSI devices
isulad.serviceloaded active running iSulad Application Container Engine
kdump.serviceloaded active exited Crash recovery kernel arming
kmod-static-nodes.serviceloaded active exited Create List of Static Device Nodes
libstoragemgmt.serviceloaded active running libstoragemgmt plug-in server daemon
● lm_sensors.serviceloaded failed failed Hardware Monitoring Sensors
lvm-activate-openeuler.serviceloaded active exited/usr/sbin/lvm vgchange -aay --nohints openeuler
lvm2-monitor.serviceloaded active exited Monitoring of LVM2 mirrors, snapshots etc. usin>
mdmonitor.serviceloaded active running MD array monitor
netcf-transaction.serviceloaded active exited Rollback uncommitted netcf network config chang>
NetworkManager-wait-online.serviceloaded active exited Network Manager Wait Online
NetworkManager.serviceloaded active running Network Manager
openEuler-security.serviceloaded active exited openEuler Security Tool
opengauss.serviceloaded active exited Start openGauss server
php-fpm.serviceloaded active running The PHP FastCGI Process Manager
plymouth-quit-wait.serviceloaded active exited Hold until boot process finishes up
plymouth-quit.serviceloaded active exited Terminate Plymouth Boot Screen
plymouth-read-write.serviceloaded active exited Tell Plymouth To Write Out Runtime Data
plymouth-start.serviceloaded active exited Show Plymouth Boot Screen
pmcd.serviceloaded active running Performance Metrics Collector Daemon
pmie.serviceloaded active running Performance Metrics Inference Engine
pmie_farm.serviceloaded active running pmie farm service
pmlogger.serviceloaded active running Performance Metrics Archive Logger
pmlogger_farm.serviceloaded active running pmlogger farm service
polkit.serviceloaded active running Authorization Manager
rasdaemon.serviceloaded active running RAS daemon to log the RAS events
rngd.serviceloaded active running Hardware RNG Entropy Gatherer Daemon
rpc-statd-notify.serviceloaded active exited Notify NFS peers of a restart
rpcbind.serviceloaded active running RPC Bind
rsyslog.serviceloaded active running System Logging Service
serial-getty@ttyAMA0.serviceloaded active running Serial Getty on ttyAMA0
sshd.serviceloaded active running OpenSSH server daemon
sysstat.serviceloaded active exited Resets System Activity Logs
systemd-fsck-root.serviceloaded active exited File System Check on Root Device
systemd-fsck@dev-disk-by\x2duuid-abf87dad\x2d48b6\x2d425d\x2da776\x2d5e5a3bef4605.service loaded active exited File System Check on /dev/disk/by-uuid/abf87dad>
systemd-fsck@dev-disk-by\x2duuid-F4CD\x2d821E.service loaded active exited File System Check on /dev/disk/by-uuid/F4CD-821E
systemd-journal-flush.serviceloaded active exited Flush Journal to Persistent Storage
systemd-journald.serviceloaded active running Journal Service
systemd-logind.serviceloaded active running User Login Management
systemd-machined.serviceloaded active running Virtual Machine and Container Registration Serv>
systemd-random-seed.serviceloaded active exited Load/Save Random Seed
systemd-remount-fs.serviceloaded active exited Remount Root and Kernel File Systems
systemd-sysctl.serviceloaded active exited Apply Kernel Variables
systemd-tmpfiles-setup-dev.serviceloaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.serviceloaded active exited Create Volatile Files and Directories
systemd-udev-trigger.serviceloaded active exited Coldplug All udev Devices
systemd-udevd.serviceloaded active running Rule-based Manager for Device Events and Files
systemd-update-utmp.serviceloaded active exited Record System Boot/Shutdown in UTMP
systemd-user-sessions.serviceloaded active exited Permit User Sessions
systemd-vconsole-setup.serviceloaded active exited Setup Virtual Console
systemtap.serviceloaded active exited Run a configured list of systemtap scripts at s>
tuned.serviceloaded active running Dynamic System Tuning Daemon
vdo.serviceloaded active exited VDO volume services (provided for compatibility)
zabbix_agentd.serviceloaded active running SYSV: zabbix_agentd
zb_daemon.serviceloaded active running zb_daemon.service
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
68 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
[root@PengFei ~]#
[root@PengFei ~]# systemctl start libvirtd
[root@PengFei ~]# systemctl enable libvirtd
[root@PengFei ~]# systemctl list-units --type=service --state=running
UNIT LOAD ACTIVE SUB DESCRIPTION
atd.service loaded active running Deferred execution scheduler
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
docker.service loaded active running Docker Application Container Engine
getty@tty1.service loaded active running Getty on tty1
gssproxy.service loaded active running GSSAPI Proxy Daemon
httpd.service loaded active running The Apache HTTP Server
irqbalance.service loaded active running irqbalance daemon
isulad.service loaded active running iSulad Application Container Engine
libstoragemgmt.service loaded active running libstoragemgmt plug-in server daemon
libvirtd.service loaded active running Virtualization daemon
mdmonitor.service loaded active running MD array monitor
NetworkManager.service loaded active running Network Manager
php-fpm.service loaded active running The PHP FastCGI Process Manager
pmcd.service loaded active running Performance Metrics Collector Daemon
pmie.service loaded active running Performance Metrics Inference Engine
pmie_farm.service loaded active running pmie farm service
pmlogger.service loaded active running Performance Metrics Archive Logger
pmlogger_farm.service loaded active running pmlogger farm service
polkit.service loaded active running Authorization Manager
rasdaemon.service loaded active running RAS daemon to log the RAS events
rngd.service loaded active running Hardware RNG Entropy Gatherer Daemon
rpcbind.service loaded active running RPC Bind
rsyslog.service loaded active running System Logging Service
serial-getty@ttyAMA0.service loaded active running Serial Getty on ttyAMA0
sshd.service loaded active running OpenSSH server daemon
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running User Login Management
systemd-machined.service loaded active running Virtual Machine and Container Registration Service
systemd-udevd.service loaded active running Rule-based Manager for Device Events and Files
tuned.service loaded active running Dynamic System Tuning Daemon
zabbix_agentd.service loaded active running SYSV: zabbix_agentd
zb_daemon.service loaded active running zb_daemon.service
LOAD = Reflects whether the unit definition was properly loaded.
lines 1-38
[root@PengFei ~]#
02、创建存储池。
a、创建存储池目录,配置目录权限。
mkdir -p /home/kvm/images
chown root:root /home/kvm/images
chmod 755 /home/kvm/images
b、定义一个存储池并绑定目录,建立基于文件夹的存储池、激活、设置开机启动。
virsh pool-define-as StoragePool --type dir --target /home/kvm/images
virsh pool-build StoragePool
virsh pool-start StoragePool
virsh pool-autostart StoragePool
c、查看存储池信息。
virsh pool-info StoragePool
virsh pool-list
[root@PengFei ~]# mkdir -p /home/kvm/images
[root@PengFei ~]# cd /home/kvm/images
[root@PengFei images]# pwd
/home/kvm/images
[root@PengFei images]# chown root:root /home/kvm/images
[root@PengFei images]# chmod 755 /home/kvm/images
[root@PengFei images]# virsh pool-define-as StoragePool --type dir --target /home/kvm/images
Pool StoragePool defined
[root@PengFei images]# virsh pool-build StoragePool
Pool StoragePool built
[root@PengFei images]# virsh pool-start StoragePool
Pool StoragePool started
[root@PengFei images]# virsh pool-autostart StoragePool
Pool StoragePool marked as autostarted
[root@PengFei images]#
[root@PengFei images]# virsh pool-autostart StoragePool
Pool StoragePool marked as autostarted
[root@PengFei images]# virsh pool-info StoragePool
Name: StoragePool
UUID: 869a0803-2acc-4856-8dce-8d0de4b2c098
State: running
Persistent: yes
Autostart: yes
Capacity: 212.84 GiB
Allocation: 11.52 GiB
Available: 201.32 GiB
[root@PengFei images]# virsh pool-list
NameState Autostart
-----------------------------------
StoragePoolactive yes
[root@PengFei images]#
03、创建虚拟机磁盘空间。
a、创建卷。
创建名称为1.img的卷,所在存储池为StoragePool。
硬盘文件的格式必须为qcow2格式。
[root@PengFei ~]# virsh vol-create-as --pool StoragePool --name 1.img --capacity 20G --allocation 1G --format qcow2
Vol 1.img created
上述命令中创建的卷容量为20G,初始分配1G,文件格式类型为qcow2。具体可根据需要修改卷的大小和配置。
b、查看卷信息。
[root@PengFei ~]# virsh vol-info /home/kvm/images/1.img
Name: 1.img
Type: file
Capacity: 20.00 GiB
Allocation: 196.00 KiB
[root@PengFei ~]#
04、创建虚拟机。
a、准备iso文件
[root@PengFei download]# ll
total 71404
-rw-r--r--. 1 root root 509 May 12 22:18 4X01.txt
drwxrwxr-x. 2 opengauss opengauss 4096 Apr 18 17:53 docker
-rw-r--r--. 1 root root72777761 May 19 21:54 docker-28.1.1.tgz
-rw-r--r--. 1 root root 325123 Jun 5 2020 zip-1.19.0.tgz
[root@PengFei download]# wget https://mirror.nyist.edu.cn/openeuler/openEuler-24.03-LTS-SP1/ISO/aarch64/openEuler-24.03-LTS-SP1-aarch64-dvd.iso
--2025-06-05 20:26:17-- https://mirror.nyist.edu.cn/openeuler/openEuler-24.03-LTS-SP1/ISO/aarch64/openEuler-24.03-LTS-SP1-aarch64-dvd.iso
Resolving mirror.nyist.edu.cn (mirror.nyist.edu.cn)... 120.194.101.75, 222.139.215.198, 59.69.128.21, ...
Connecting to mirror.nyist.edu.cn (mirror.nyist.edu.cn)|120.194.101.75|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3885582336 (3.6G) [application/octet-stream]
Saving to: ‘openEuler-24.03-LTS-SP1-aarch64-dvd.iso’
openEuler-24.03-LTS-SP1-aarch64-dvd.iso100%[================================================================================>] 3.62G57.7MB/s in 74s
2025-06-05 20:27:31 (50.3 MB/s) - ‘openEuler-24.03-LTS-SP1-aarch64-dvd.iso’ saved [3885582336/3885582336]
[root@PengFei download]# ll
total 3865924
-rw-r--r--. 1 root root 509 May 12 22:18 4X01.txt
drwxrwxr-x. 2 opengauss opengauss 4096 Apr 18 17:53 docker
-rw-r--r--. 1 root root 72777761 May 19 21:54 docker-28.1.1.tgz
-rw-r--r-- 1 rootroot 3885582336 Dec 31 12:02 openEuler-24.03-LTS-SP1-aarch64-dvd.iso
-rw-r--r--. 1 root root 325123 Jun 5 2020 zip-1.19.0.tgz
[root@PengFei download]#
b、创建一个名为vm1的虚拟机,刚才已经将openEuler-24.03-LTS-SP1-aarch64-dvd.iso文件下载到“/download”路径下(非“/root”路径即可),执行如下命令开始创建虚拟机。
[root@PengFei download]# virt-install --name=vm1 --vcpus=4 --ram=8192 --disk path=/home/kvm/images/1.img,format=qcow2,size=20,bus=virtio --location /download/openEuler-24.03-LTS-SP1-aarch64-dvd.iso --network network=default --nographics
上述命令中为虚拟机分配了4个vCPU、8G内存,使用1.img作为系统卷。可根据实际需要修改虚拟机的规格和配置。
执行完成上述命令后,需要等待一段时间,随后将进入安装虚拟机的操作系统环节。
Starting install...
Retrieving file vmlinuz...| 12 MB 00:00:00
Retrieving file initrd.img...| 73 MB 00:00:00
Connected to domain vm1
Escape character is ^] (Ctrl + ])
EFI stub: Booting Linux Kernel...
EFI stub: EFI_RNG_PROTOCOL unavailable
EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
EFI stub: Generating empty DTB
EFI stub: Exiting boot services...
[ 0.000000][ T0] Booting Linux on physical CPU 0x0000000000 [0x411fd070]
[ 0.000000][ T0] Linux version 6.6.0-72.0.0.76.oe2403sp1.aarch64 (root@dc-64g.compass-ci) (gcc_old (GCC) 12.3.1 (openEuler 12.3.1-62.oe2403sp1), GNU ld (GNU Binutils) 2.41) #1 SMP Fri Dec 27 12:19:23 CST 2024
[ 0.000000][ T0] KASLR disabled due to lack of seed
[ 0.000000][ T0] efi: EFI v2.7 by EDK II


c、在安装虚拟机的操作系统环节中:
配置状态显示为“Processing...”的配置项表示正在进行自动配置。输入“r”回车后可以刷新当前状态。

自动配置结束后,针对所有带有“!”的选项,需要先输入选项对应的序号,再按回车,然后根据提示进行手动配置。
中间不小心中断,退出来了,到了这个界面。


感觉是没有装好系统的样子,但是进了虚拟机,有一个操作提示,也是有一个小的系统,于是乎,退出来,将image删除,将虚拟机关闭删除。
重新进行“b、创建一个名为vm1的虚拟机,刚才已经将openEuler-24.03-LTS-SP1-aarch64-dvd.iso文件下载到“/download”路径下(非“/root”路径即可),执行如下命令开始创建虚拟机。”主要是设置root的密码,还有 Installation Destination

d、按照指示完成所有配置后,输入“b”回车后开始安装。




e、系统安装完成后,登录系统。

05、虚拟机的一些操作和命令
查询主机上处于运行和暂停状态的虚拟机列表
[root@PengFei home]# virsh list
IdName State
----------------------
4vm1 running
查询主机上已经定义的所有虚拟机信息列表
[root@PengFei home]# virsh list --all
IdName State
----------------------
4vm1 running
查询一个创建好的虚拟机的基本信息
[root@PengFei home]# virsh dominfo vm1
Id: 4
Name: vm1
UUID: cb0077c8-1ba1-472f-a750-1069b4613324
OS Type: hvm
State: running
CPU(s): 4
CPU time: 1303.1s
Max memory: 8388608 KiB
Used memory: 8388608 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: none
Security DOI: 0
查询虚拟机的当前状态
[root@PengFei home]# virsh domstate vm1
running
查询虚拟机网卡信息
[root@PengFei home]# virsh domiflist vm1
InterfaceType Source ModelMAC
-------------------------------------------------------------
vnet0network default virtio52:54:00:9f:80:a0
查询虚拟机硬盘设备信息
[root@PengFei home]# virsh domblklist vm1
TargetSource
----------------------------------
vda/home/kvm/images/1.img
sda-
查询难虚拟机的vCPU数目
[root@PengFei home]# virsh vcpucount vm1
maximum config 4
maximum live 4
current config 4
current live 4
查询难虚拟机xml配置
[root@PengFei home]# virsh dumpxml vm1
<domain type='qemu' id='4'>
<name>vm1</name>
<uuid>cb0077c8-1ba1-472f-a750-1069b4613324</uuid>
<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>8388608</currentMemory>
<vcpu placement='static'>4</vcpu>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch='aarch64' machine='virt-6.2'>hvm</type>
<loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw</loader>
<nvram>/var/lib/libvirt/qemu/nvram/vm1_VARS.fd</nvram>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<gic version='2'/>
</features>
<cpu mode='custom' match='exact' check='none'>
<model fallback='forbid'>cortex-a57</model>
</cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/home/kvm/images/1.img' index='2'/>
<backingStore/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu'/>
<target dev='sda' bus='scsi'/>
<readonly/>
<alias name='scsi0-0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0' model='qemu-xhci' ports='15'>
<alias name='usb'/>
<address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
</controller>
<controller type='scsi' index='0' model='virtio-scsi'>
<alias name='scsi0'/>
<address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pcie-root'>
<alias name='pcie.0'/>
</controller>
<controller type='virtio-serial' index='0'>
<alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
</controller>
<controller type='pci' index='1' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='1' port='0x8'/>
<alias name='pci.1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
</controller>
<controller type='pci' index='2' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='2' port='0x9'/>
<alias name='pci.2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='pci' index='3' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='3' port='0xa'/>
<alias name='pci.3'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='4' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='4' port='0xb'/>
<alias name='pci.4'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/>
</controller>
<controller type='pci' index='5' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='5' port='0xc'/>
<alias name='pci.5'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x4'/>
</controller>
<controller type='pci' index='6' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='6' port='0xd'/>
<alias name='pci.6'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x5'/>
</controller>
<interface type='network'>
<mac address='52:54:00:9f:80:a0'/>
<source network='default' portid='2db90742-50bd-4101-a2f5-fa0e3f1e798f' bridge='virbr0'/>
<target dev='vnet0'/>
<model type='virtio'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/1'/>
<target type='system-serial' port='0'>
<model name='pl011'/>
</target>
<alias name='serial0'/>
</serial>
<console type='pty' tty='/dev/pts/1'>
<source path='/dev/pts/1'/>
<target type='serial' port='0'/>
<alias name='serial0'/>
</console>
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-4-vm1/org.qemu.guest_agent.0'/>
<target type='virtio' name='org.qemu.guest_agent.0' state='disconnected'/>
<alias name='channel0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
</devices>
<seclabel type='dynamic' model='dac' relabel='yes'>
<label>+107:+107</label>
<imagelabel>+107:+107</imagelabel>
</seclabel>
</domain>
[root@PengFei home]#
06、登陆虚拟机系统
[root@PengFei home]# virsh console vm1
Connected to domain vm1
Escape character is ^] (Ctrl + ])
显示信息
[root@localhost /]# uname -a
Linux localhost.localdomain 6.6.0-72.0.0.76.oe2403sp1.aarch64 #1 SMP Fri Dec 27 12:19:23 CST 2024 aarch64 aarch64 aarch64 GNU/Linux
[root@localhost /]# cat /etc/os-release
NAME="openEuler"
VERSION="24.03 (LTS-SP1)"
ID="openEuler"
VERSION_ID="24.03"
PRETTY_NAME="openEuler 24.03 (LTS-SP1)"
ANSI_COLOR="0;31"
[root@localhost /]#
ping测试
[root@localhost ~]# ping www.baidu.com
PING www.baidu.com (110.242.69.21) 56(84) bytes of data.
64 bytes from 110.242.69.21 (110.242.69.21): icmp_seq=1 ttl=42 time=56.6 ms
64 bytes from 110.242.69.21 (110.242.69.21): icmp_seq=2 ttl=42 time=41.1 ms
64 bytes from 110.242.69.21 (110.242.69.21): icmp_seq=3 ttl=42 time=40.8 ms
64 bytes from 110.242.69.21 (110.242.69.21): icmp_seq=4 ttl=42 time=42.4 ms
64 bytes from 110.242.69.21 (110.242.69.21): icmp_seq=5 ttl=42 time=40.9 ms
--- www.baidu.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4011ms
rtt min/avg/max/mdev = 40.817/44.345/56.598/6.152 ms
[root@localhost ~]#
退出虚拟机,ping虚拟机的ip地址:
[root@PengFei home]# cat /etc/os-release
NAME="openEuler"
VERSION="22.03 LTS"
ID="openEuler"
VERSION_ID="22.03"
PRETTY_NAME="openEuler 22.03 LTS"
ANSI_COLOR="0;31"
[root@PengFei home]# ping 192.168.122.47
PING 192.168.122.47 (192.168.122.47) 56(84) bytes of data.
64 bytes from 192.168.122.47: icmp_seq=1 ttl=64 time=3.86 ms
64 bytes from 192.168.122.47: icmp_seq=2 ttl=64 time=1.22 ms
64 bytes from 192.168.122.47: icmp_seq=3 ttl=64 time=1.49 ms
64 bytes from 192.168.122.47: icmp_seq=4 ttl=64 time=1.19 ms
64 bytes from 192.168.122.47: icmp_seq=5 ttl=64 time=1.11 ms
64 bytes from 192.168.122.47: icmp_seq=6 ttl=64 time=1.06 ms
64 bytes from 192.168.122.47: icmp_seq=7 ttl=64 time=1.19 ms
64 bytes from 192.168.122.47: icmp_seq=8 ttl=64 time=1.12 ms
^C
--- 192.168.122.47 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7010ms
rtt min/avg/max/mdev = 1.061/1.530/3.861/0.888 ms
[root@PengFei home]#
通过实验,对虚拟机的配置和使用有了一定的了解,但具体在实际过程中怎么使用,包括IP地址怎么去配置,怎么配置网络信息和网卡,怎么部署应用,等等一系列问题,zai比如怎么通过xshell工具来直接远程登录到虚拟机内部,还要继续学习。这篇先写到这里,继续加油。
根据最初的实验计划,新手小白继续尝试,本篇内容,为大家分享在openEuler中安装虚拟机。
本篇内容主要包含的内容如下:
01、启动libvirtd服务并设置开机自启;
02、创建存储池;
03、创建虚拟机磁盘空间;
04、创建虚拟机;
05、虚拟机的一些操作和命令;
06、登陆虚拟机系统。
参考文献如下:
https://www.hikunpeng.com/document/detail/zh/kunpengcpfs/ecosystemEnable/QEMU-KVM/kunpengkvm_03_0010.html
下面开始具体内容:
01、启动libvirtd服务并设置开机自启。
systemctl start libvirtd
systemctl enable libvirtd
启动libvirtd服务
在Linux系统中,libvirtd是管理虚拟化技术的一个关键组件,通常包括对KVM、QEMU等虚拟化技术的支持。
查看当前运行的服务:
[root@PengFei ~]# systemctl list-units --type=service --state=running
UNIT LOAD ACTIVE SUB DESCRIPTION
atd.service loaded active running Deferred execution scheduler
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
docker.service loaded active running Docker Application Container Engine
getty@tty1.service loaded active running Getty on tty1
gssproxy.service loaded active running GSSAPI Proxy Daemon
httpd.service loaded active running The Apache HTTP Server
irqbalance.service loaded active running irqbalance daemon
isulad.service loaded active running iSulad Application Container Engine
libstoragemgmt.service loaded active running libstoragemgmt plug-in server daemon
mdmonitor.service loaded active running MD array monitor
NetworkManager.service loaded active running Network Manager
php-fpm.service loaded active running The PHP FastCGI Process Manager
pmcd.service loaded active running Performance Metrics Collector Daemon
pmie.service loaded active running Performance Metrics Inference Engine
pmie_farm.service loaded active running pmie farm service
pmie_farm_check.service loaded active running Check and migrate non-primary pmie instances to pmie_farm
pmlogger.service loaded active running Performance Metrics Archive Logger
pmlogger_farm.service loaded active running pmlogger farm service
polkit.service loaded active running Authorization Manager
rasdaemon.service loaded active running RAS daemon to log the RAS events
rngd.service loaded active running Hardware RNG Entropy Gatherer Daemon
rpcbind.service loaded active running RPC Bind
rsyslog.service loaded active running System Logging Service
serial-getty@ttyAMA0.service loaded active running Serial Getty on ttyAMA0
sshd.service loaded active running OpenSSH server daemon
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running User Login Management
systemd-machined.service loaded active running Virtual Machine and Container Registration Service
systemd-udevd.service loaded active running Rule-based Manager for Device Events and Files
tuned.service loaded active running Dynamic System Tuning Daemon
zabbix_agentd.service loaded active running SYSV: zabbix_agentd
zb_daemon.service loaded active running zb_daemon.service
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
35 loaded units listed.
[root@PengFei ~]#
查看所有的服务
[root@PengFei ~]# systemctl list-units --type=service
UNITLOAD ACTIVE SUB DESCRIPTION >
atd.serviceloaded active running Deferred execution scheduler
auditd.serviceloaded active running Security Auditing Service
chronyd.serviceloaded active running NTP client/server
crond.serviceloaded active running Command Scheduler
dbus.serviceloaded active running D-Bus System Message Bus
dkms.serviceloaded active exited Builds and install new kernel modules through D>
docker.serviceloaded active running Docker Application Container Engine
dracut-shutdown.serviceloaded active exited Restore /run/initramfs on shutdown
getty@tty1.serviceloaded active running Getty on tty1
gssproxy.serviceloaded active running GSSAPI Proxy Daemon
httpd.serviceloaded active running The Apache HTTP Server
hwclock-save.serviceloaded active exited Update RTC With System Clock
irqbalance.serviceloaded active running irqbalance daemon
iscsi.serviceloaded active exited Login and scanning of iSCSI devices
isulad.serviceloaded active running iSulad Application Container Engine
kdump.serviceloaded active exited Crash recovery kernel arming
kmod-static-nodes.serviceloaded active exited Create List of Static Device Nodes
libstoragemgmt.serviceloaded active running libstoragemgmt plug-in server daemon
● lm_sensors.serviceloaded failed failed Hardware Monitoring Sensors
lvm-activate-openeuler.serviceloaded active exited/usr/sbin/lvm vgchange -aay --nohints openeuler
lvm2-monitor.serviceloaded active exited Monitoring of LVM2 mirrors, snapshots etc. usin>
mdmonitor.serviceloaded active running MD array monitor
netcf-transaction.serviceloaded active exited Rollback uncommitted netcf network config chang>
NetworkManager-wait-online.serviceloaded active exited Network Manager Wait Online
NetworkManager.serviceloaded active running Network Manager
openEuler-security.serviceloaded active exited openEuler Security Tool
opengauss.serviceloaded active exited Start openGauss server
php-fpm.serviceloaded active running The PHP FastCGI Process Manager
plymouth-quit-wait.serviceloaded active exited Hold until boot process finishes up
plymouth-quit.serviceloaded active exited Terminate Plymouth Boot Screen
plymouth-read-write.serviceloaded active exited Tell Plymouth To Write Out Runtime Data
plymouth-start.serviceloaded active exited Show Plymouth Boot Screen
pmcd.serviceloaded active running Performance Metrics Collector Daemon
pmie.serviceloaded active running Performance Metrics Inference Engine
pmie_farm.serviceloaded active running pmie farm service
pmlogger.serviceloaded active running Performance Metrics Archive Logger
pmlogger_farm.serviceloaded active running pmlogger farm service
polkit.serviceloaded active running Authorization Manager
rasdaemon.serviceloaded active running RAS daemon to log the RAS events
rngd.serviceloaded active running Hardware RNG Entropy Gatherer Daemon
rpc-statd-notify.serviceloaded active exited Notify NFS peers of a restart
rpcbind.serviceloaded active running RPC Bind
rsyslog.serviceloaded active running System Logging Service
serial-getty@ttyAMA0.serviceloaded active running Serial Getty on ttyAMA0
sshd.serviceloaded active running OpenSSH server daemon
sysstat.serviceloaded active exited Resets System Activity Logs
systemd-fsck-root.serviceloaded active exited File System Check on Root Device
systemd-fsck@dev-disk-by\x2duuid-abf87dad\x2d48b6\x2d425d\x2da776\x2d5e5a3bef4605.service loaded active exited File System Check on /dev/disk/by-uuid/abf87dad>
systemd-fsck@dev-disk-by\x2duuid-F4CD\x2d821E.service loaded active exited File System Check on /dev/disk/by-uuid/F4CD-821E
systemd-journal-flush.serviceloaded active exited Flush Journal to Persistent Storage
systemd-journald.serviceloaded active running Journal Service
systemd-logind.serviceloaded active running User Login Management
systemd-machined.serviceloaded active running Virtual Machine and Container Registration Serv>
systemd-random-seed.serviceloaded active exited Load/Save Random Seed
systemd-remount-fs.serviceloaded active exited Remount Root and Kernel File Systems
systemd-sysctl.serviceloaded active exited Apply Kernel Variables
systemd-tmpfiles-setup-dev.serviceloaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.serviceloaded active exited Create Volatile Files and Directories
systemd-udev-trigger.serviceloaded active exited Coldplug All udev Devices
systemd-udevd.serviceloaded active running Rule-based Manager for Device Events and Files
systemd-update-utmp.serviceloaded active exited Record System Boot/Shutdown in UTMP
systemd-user-sessions.serviceloaded active exited Permit User Sessions
systemd-vconsole-setup.serviceloaded active exited Setup Virtual Console
systemtap.serviceloaded active exited Run a configured list of systemtap scripts at s>
tuned.serviceloaded active running Dynamic System Tuning Daemon
vdo.serviceloaded active exited VDO volume services (provided for compatibility)
zabbix_agentd.serviceloaded active running SYSV: zabbix_agentd
zb_daemon.serviceloaded active running zb_daemon.service
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
68 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
[root@PengFei ~]#
[root@PengFei ~]# systemctl start libvirtd
[root@PengFei ~]# systemctl enable libvirtd
[root@PengFei ~]# systemctl list-units --type=service --state=running
UNIT LOAD ACTIVE SUB DESCRIPTION
atd.service loaded active running Deferred execution scheduler
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
docker.service loaded active running Docker Application Container Engine
getty@tty1.service loaded active running Getty on tty1
gssproxy.service loaded active running GSSAPI Proxy Daemon
httpd.service loaded active running The Apache HTTP Server
irqbalance.service loaded active running irqbalance daemon
isulad.service loaded active running iSulad Application Container Engine
libstoragemgmt.service loaded active running libstoragemgmt plug-in server daemon
libvirtd.service loaded active running Virtualization daemon
mdmonitor.service loaded active running MD array monitor
NetworkManager.service loaded active running Network Manager
php-fpm.service loaded active running The PHP FastCGI Process Manager
pmcd.service loaded active running Performance Metrics Collector Daemon
pmie.service loaded active running Performance Metrics Inference Engine
pmie_farm.service loaded active running pmie farm service
pmlogger.service loaded active running Performance Metrics Archive Logger
pmlogger_farm.service loaded active running pmlogger farm service
polkit.service loaded active running Authorization Manager
rasdaemon.service loaded active running RAS daemon to log the RAS events
rngd.service loaded active running Hardware RNG Entropy Gatherer Daemon
rpcbind.service loaded active running RPC Bind
rsyslog.service loaded active running System Logging Service
serial-getty@ttyAMA0.service loaded active running Serial Getty on ttyAMA0
sshd.service loaded active running OpenSSH server daemon
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running User Login Management
systemd-machined.service loaded active running Virtual Machine and Container Registration Service
systemd-udevd.service loaded active running Rule-based Manager for Device Events and Files
tuned.service loaded active running Dynamic System Tuning Daemon
zabbix_agentd.service loaded active running SYSV: zabbix_agentd
zb_daemon.service loaded active running zb_daemon.service
LOAD = Reflects whether the unit definition was properly loaded.
lines 1-38
[root@PengFei ~]#
02、创建存储池。
a、创建存储池目录,配置目录权限。
mkdir -p /home/kvm/images
chown root:root /home/kvm/images
chmod 755 /home/kvm/images
b、定义一个存储池并绑定目录,建立基于文件夹的存储池、激活、设置开机启动。
virsh pool-define-as StoragePool --type dir --target /home/kvm/images
virsh pool-build StoragePool
virsh pool-start StoragePool
virsh pool-autostart StoragePool
c、查看存储池信息。
virsh pool-info StoragePool
virsh pool-list
[root@PengFei ~]# mkdir -p /home/kvm/images
[root@PengFei ~]# cd /home/kvm/images
[root@PengFei images]# pwd
/home/kvm/images
[root@PengFei images]# chown root:root /home/kvm/images
[root@PengFei images]# chmod 755 /home/kvm/images
[root@PengFei images]# virsh pool-define-as StoragePool --type dir --target /home/kvm/images
Pool StoragePool defined
[root@PengFei images]# virsh pool-build StoragePool
Pool StoragePool built
[root@PengFei images]# virsh pool-start StoragePool
Pool StoragePool started
[root@PengFei images]# virsh pool-autostart StoragePool
Pool StoragePool marked as autostarted
[root@PengFei images]#
[root@PengFei images]# virsh pool-autostart StoragePool
Pool StoragePool marked as autostarted
[root@PengFei images]# virsh pool-info StoragePool
Name: StoragePool
UUID: 869a0803-2acc-4856-8dce-8d0de4b2c098
State: running
Persistent: yes
Autostart: yes
Capacity: 212.84 GiB
Allocation: 11.52 GiB
Available: 201.32 GiB
[root@PengFei images]# virsh pool-list
NameState Autostart
-----------------------------------
StoragePoolactive yes
[root@PengFei images]#
03、创建虚拟机磁盘空间。
a、创建卷。
创建名称为1.img的卷,所在存储池为StoragePool。
硬盘文件的格式必须为qcow2格式。
[root@PengFei ~]# virsh vol-create-as --pool StoragePool --name 1.img --capacity 20G --allocation 1G --format qcow2
Vol 1.img created
上述命令中创建的卷容量为20G,初始分配1G,文件格式类型为qcow2。具体可根据需要修改卷的大小和配置。
b、查看卷信息。
[root@PengFei ~]# virsh vol-info /home/kvm/images/1.img
Name: 1.img
Type: file
Capacity: 20.00 GiB
Allocation: 196.00 KiB
[root@PengFei ~]#
04、创建虚拟机。
a、准备iso文件
[root@PengFei download]# ll
total 71404
-rw-r--r--. 1 root root 509 May 12 22:18 4X01.txt
drwxrwxr-x. 2 opengauss opengauss 4096 Apr 18 17:53 docker
-rw-r--r--. 1 root root72777761 May 19 21:54 docker-28.1.1.tgz
-rw-r--r--. 1 root root 325123 Jun 5 2020 zip-1.19.0.tgz
[root@PengFei download]# wget https://mirror.nyist.edu.cn/openeuler/openEuler-24.03-LTS-SP1/ISO/aarch64/openEuler-24.03-LTS-SP1-aarch64-dvd.iso
--2025-06-05 20:26:17-- https://mirror.nyist.edu.cn/openeuler/openEuler-24.03-LTS-SP1/ISO/aarch64/openEuler-24.03-LTS-SP1-aarch64-dvd.iso
Resolving mirror.nyist.edu.cn (mirror.nyist.edu.cn)... 120.194.101.75, 222.139.215.198, 59.69.128.21, ...
Connecting to mirror.nyist.edu.cn (mirror.nyist.edu.cn)|120.194.101.75|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3885582336 (3.6G) [application/octet-stream]
Saving to: ‘openEuler-24.03-LTS-SP1-aarch64-dvd.iso’
openEuler-24.03-LTS-SP1-aarch64-dvd.iso100%[================================================================================>] 3.62G57.7MB/s in 74s
2025-06-05 20:27:31 (50.3 MB/s) - ‘openEuler-24.03-LTS-SP1-aarch64-dvd.iso’ saved [3885582336/3885582336]
[root@PengFei download]# ll
total 3865924
-rw-r--r--. 1 root root 509 May 12 22:18 4X01.txt
drwxrwxr-x. 2 opengauss opengauss 4096 Apr 18 17:53 docker
-rw-r--r--. 1 root root 72777761 May 19 21:54 docker-28.1.1.tgz
-rw-r--r-- 1 rootroot 3885582336 Dec 31 12:02 openEuler-24.03-LTS-SP1-aarch64-dvd.iso
-rw-r--r--. 1 root root 325123 Jun 5 2020 zip-1.19.0.tgz
[root@PengFei download]#
b、创建一个名为vm1的虚拟机,刚才已经将openEuler-24.03-LTS-SP1-aarch64-dvd.iso文件下载到“/download”路径下(非“/root”路径即可),执行如下命令开始创建虚拟机。
[root@PengFei download]# virt-install --name=vm1 --vcpus=4 --ram=8192 --disk path=/home/kvm/images/1.img,format=qcow2,size=20,bus=virtio --location /download/openEuler-24.03-LTS-SP1-aarch64-dvd.iso --network network=default --nographics
上述命令中为虚拟机分配了4个vCPU、8G内存,使用1.img作为系统卷。可根据实际需要修改虚拟机的规格和配置。
执行完成上述命令后,需要等待一段时间,随后将进入安装虚拟机的操作系统环节。
Starting install...
Retrieving file vmlinuz...| 12 MB 00:00:00
Retrieving file initrd.img...| 73 MB 00:00:00
Connected to domain vm1
Escape character is ^] (Ctrl + ])
EFI stub: Booting Linux Kernel...
EFI stub: EFI_RNG_PROTOCOL unavailable
EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
EFI stub: Generating empty DTB
EFI stub: Exiting boot services...
[ 0.000000][ T0] Booting Linux on physical CPU 0x0000000000 [0x411fd070]
[ 0.000000][ T0] Linux version 6.6.0-72.0.0.76.oe2403sp1.aarch64 (root@dc-64g.compass-ci) (gcc_old (GCC) 12.3.1 (openEuler 12.3.1-62.oe2403sp1), GNU ld (GNU Binutils) 2.41) #1 SMP Fri Dec 27 12:19:23 CST 2024
[ 0.000000][ T0] KASLR disabled due to lack of seed
[ 0.000000][ T0] efi: EFI v2.7 by EDK II
c、在安装虚拟机的操作系统环节中:
配置状态显示为“Processing...”的配置项表示正在进行自动配置。输入“r”回车后可以刷新当前状态。
自动配置结束后,针对所有带有“!”的选项,需要先输入选项对应的序号,再按回车,然后根据提示进行手动配置。
中间不小心中断,退出来了,到了这个界面。
感觉是没有装好系统的样子,但是进了虚拟机,有一个操作提示,也是有一个小的系统,于是乎,退出来,将image删除,将虚拟机关闭删除。
重新进行“b、创建一个名为vm1的虚拟机,刚才已经将openEuler-24.03-LTS-SP1-aarch64-dvd.iso文件下载到“/download”路径下(非“/root”路径即可),执行如下命令开始创建虚拟机。”主要是设置root的密码,还有 Installation Destination
d、按照指示完成所有配置后,输入“b”回车后开始安装。
e、系统安装完成后,登录系统。
05、虚拟机的一些操作和命令
查询主机上处于运行和暂停状态的虚拟机列表
[root@PengFei home]# virsh list
IdName State
----------------------
4vm1 running
查询主机上已经定义的所有虚拟机信息列表
[root@PengFei home]# virsh list --all
IdName State
----------------------
4vm1 running
查询一个创建好的虚拟机的基本信息
[root@PengFei home]# virsh dominfo vm1
Id: 4
Name: vm1
UUID: cb0077c8-1ba1-472f-a750-1069b4613324
OS Type: hvm
State: running
CPU(s): 4
CPU time: 1303.1s
Max memory: 8388608 KiB
Used memory: 8388608 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: none
Security DOI: 0
查询虚拟机的当前状态
[root@PengFei home]# virsh domstate vm1
running
查询虚拟机网卡信息
[root@PengFei home]# virsh domiflist vm1
InterfaceType Source ModelMAC
-------------------------------------------------------------
vnet0network default virtio52:54:00:9f:80:a0
查询虚拟机硬盘设备信息
[root@PengFei home]# virsh domblklist vm1
TargetSource
----------------------------------
vda/home/kvm/images/1.img
sda-
查询难虚拟机的vCPU数目
[root@PengFei home]# virsh vcpucount vm1
maximum config 4
maximum live 4
current config 4
current live 4
查询难虚拟机xml配置
[root@PengFei home]# virsh dumpxml vm1
<domain type='qemu' id='4'>
<name>vm1</name>
<uuid>cb0077c8-1ba1-472f-a750-1069b4613324</uuid>
<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>8388608</currentMemory>
<vcpu placement='static'>4</vcpu>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch='aarch64' machine='virt-6.2'>hvm</type>
<loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw</loader>
<nvram>/var/lib/libvirt/qemu/nvram/vm1_VARS.fd</nvram>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<gic version='2'/>
</features>
<cpu mode='custom' match='exact' check='none'>
<model fallback='forbid'>cortex-a57</model>
</cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/home/kvm/images/1.img' index='2'/>
<backingStore/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu'/>
<target dev='sda' bus='scsi'/>
<readonly/>
<alias name='scsi0-0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0' model='qemu-xhci' ports='15'>
<alias name='usb'/>
<address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
</controller>
<controller type='scsi' index='0' model='virtio-scsi'>
<alias name='scsi0'/>
<address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pcie-root'>
<alias name='pcie.0'/>
</controller>
<controller type='virtio-serial' index='0'>
<alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
</controller>
<controller type='pci' index='1' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='1' port='0x8'/>
<alias name='pci.1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
</controller>
<controller type='pci' index='2' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='2' port='0x9'/>
<alias name='pci.2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='pci' index='3' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='3' port='0xa'/>
<alias name='pci.3'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='4' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='4' port='0xb'/>
<alias name='pci.4'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/>
</controller>
<controller type='pci' index='5' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='5' port='0xc'/>
<alias name='pci.5'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x4'/>
</controller>
<controller type='pci' index='6' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='6' port='0xd'/>
<alias name='pci.6'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x5'/>
</controller>
<interface type='network'>
<mac address='52:54:00:9f:80:a0'/>
<source network='default' portid='2db90742-50bd-4101-a2f5-fa0e3f1e798f' bridge='virbr0'/>
<target dev='vnet0'/>
<model type='virtio'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/1'/>
<target type='system-serial' port='0'>
<model name='pl011'/>
</target>
<alias name='serial0'/>
</serial>
<console type='pty' tty='/dev/pts/1'>
<source path='/dev/pts/1'/>
<target type='serial' port='0'/>
<alias name='serial0'/>
</console>
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-4-vm1/org.qemu.guest_agent.0'/>
<target type='virtio' name='org.qemu.guest_agent.0' state='disconnected'/>
<alias name='channel0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
</devices>
<seclabel type='dynamic' model='dac' relabel='yes'>
<label>+107:+107</label>
<imagelabel>+107:+107</imagelabel>
</seclabel>
</domain>
[root@PengFei home]#
06、登陆虚拟机系统
[root@PengFei home]# virsh console vm1
Connected to domain vm1
Escape character is ^] (Ctrl + ])
显示信息
[root@localhost /]# uname -a
Linux localhost.localdomain 6.6.0-72.0.0.76.oe2403sp1.aarch64 #1 SMP Fri Dec 27 12:19:23 CST 2024 aarch64 aarch64 aarch64 GNU/Linux
[root@localhost /]# cat /etc/os-release
NAME="openEuler"
VERSION="24.03 (LTS-SP1)"
ID="openEuler"
VERSION_ID="24.03"
PRETTY_NAME="openEuler 24.03 (LTS-SP1)"
ANSI_COLOR="0;31"
[root@localhost /]#
ping测试
[root@localhost ~]# ping www.baidu.com
PING www.baidu.com (110.242.69.21) 56(84) bytes of data.
64 bytes from 110.242.69.21 (110.242.69.21): icmp_seq=1 ttl=42 time=56.6 ms
64 bytes from 110.242.69.21 (110.242.69.21): icmp_seq=2 ttl=42 time=41.1 ms
64 bytes from 110.242.69.21 (110.242.69.21): icmp_seq=3 ttl=42 time=40.8 ms
64 bytes from 110.242.69.21 (110.242.69.21): icmp_seq=4 ttl=42 time=42.4 ms
64 bytes from 110.242.69.21 (110.242.69.21): icmp_seq=5 ttl=42 time=40.9 ms
--- www.baidu.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4011ms
rtt min/avg/max/mdev = 40.817/44.345/56.598/6.152 ms
[root@localhost ~]#
退出虚拟机,ping虚拟机的ip地址:
[root@PengFei home]# cat /etc/os-release
NAME="openEuler"
VERSION="22.03 LTS"
ID="openEuler"
VERSION_ID="22.03"
PRETTY_NAME="openEuler 22.03 LTS"
ANSI_COLOR="0;31"
[root@PengFei home]# ping 192.168.122.47
PING 192.168.122.47 (192.168.122.47) 56(84) bytes of data.
64 bytes from 192.168.122.47: icmp_seq=1 ttl=64 time=3.86 ms
64 bytes from 192.168.122.47: icmp_seq=2 ttl=64 time=1.22 ms
64 bytes from 192.168.122.47: icmp_seq=3 ttl=64 time=1.49 ms
64 bytes from 192.168.122.47: icmp_seq=4 ttl=64 time=1.19 ms
64 bytes from 192.168.122.47: icmp_seq=5 ttl=64 time=1.11 ms
64 bytes from 192.168.122.47: icmp_seq=6 ttl=64 time=1.06 ms
64 bytes from 192.168.122.47: icmp_seq=7 ttl=64 time=1.19 ms
64 bytes from 192.168.122.47: icmp_seq=8 ttl=64 time=1.12 ms
^C
--- 192.168.122.47 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7010ms
rtt min/avg/max/mdev = 1.061/1.530/3.861/0.888 ms
[root@PengFei home]#
通过实验,对虚拟机的配置和使用有了一定的了解,但具体在实际过程中怎么使用,包括IP地址怎么去配置,怎么配置网络信息和网卡,怎么部署应用,等等一系列问题,zai比如怎么通过xshell工具来直接远程登录到虚拟机内部,还要继续学习。这篇先写到这里,继续加油。