KVM : Use VirtualBMC2024/05/10 |
Install VirtualBMC to enable IPMI commands to Virtual machines. |
|
[1] | Install VirtualBMC on KVM Host. |
root@dlp:~#
apt -y install python3-pip python3-venv ipmitool # create Python virtual environment under the [/opt/virtualbmc] root@dlp:~# python3 -m venv --system-site-packages /opt/virtualbmc
# install VirtualBMC root@dlp:~# /opt/virtualbmc/bin/pip3 install virtualbmc # create new [Unit] Description=Virtual BMC Service After=network.target libvirtd.service [Service] Type=simple ExecStart=/opt/virtualbmc/bin/vbmcd --foreground ExecStop=/bin/kill -HUP $MAINPID User=root Group=root [Install] WantedBy=multi-user.target # show status (OK if no error is shown) root@dlp:~# /opt/virtualbmc/bin/vbmc list
|
[2] | Set VirtualBMC to virtual machines. |
root@dlp:~# virsh list --all Id Name State ----------------------- - rx-7 shut off - rx-8 shut off # set VirtualBMC to a VM [rx-7] # for [port], [username], [password], it's OK to set any values you like root@dlp:~# /opt/virtualbmc/bin/vbmc add rx-7 --port 6230 --username vbmcadmin --password adminpassword
/opt/virtualbmc/bin/vbmc list +-------------+--------+---------+------+ | Domain name | Status | Address | Port | +-------------+--------+---------+------+ | rx-7 | down | :: | 6230 | +-------------+--------+---------+------+ # start VirtualBMC root@dlp:~# /opt/virtualbmc/bin/vbmc start rx-7
/opt/virtualbmc/bin/vbmc list +-------------+---------+---------+------+ | Domain name | Status | Address | Port | +-------------+---------+---------+------+ | rx-7 | running | :: | 6230 | +-------------+---------+---------+------+root@dlp:~# /opt/virtualbmc/bin/vbmc show rx-7 +-----------------------+----------------+ | Property | Value | +-----------------------+----------------+ | active | True | | address | :: | | domain_name | rx-7 | | libvirt_sasl_password | *** | | libvirt_sasl_username | None | | libvirt_uri | qemu:///system | | password | *** | | port | 6230 | | status | running | | username | vbmcadmin | +-----------------------+----------------+ # show status of power on [rx-7] via VirtualBMC root@dlp:~# ipmitool -I lanplus -H 127.0.0.1 -p 6230 -U vbmcadmin -P adminpassword power status Chassis Power is off # power on via VirtualBMC root@dlp:~# ipmitool -I lanplus -H 127.0.0.1 -p 6230 -U vbmcadmin -P adminpassword power on Chassis Power Control: Up/On virsh list --all Id Name State ----------------------- 3 rx-7 running - rx-8 shut off # power off via VirtualBMC root@dlp:~# ipmitool -I lanplus -H 127.0.0.1 -p 6230 -U vbmcadmin -P adminpassword power off Chassis Power Control: Down/Off virsh list --all Id Name State ----------------------- - rx-7 shut off - rx-8 shut off |
[3] | If you'd like to use VirtualBMC not on KVM Host but on other Hosts, configure like follows. For SSH key-pair settings, it had better to change sshd setting to [PermitRootLogin prohibit-password] after setting key-pair. |
# generate SSH key-pair and set to own host root@dlp:~# ssh-keygen -q -N "" Enter file in which to save the key (/root/.ssh/id_ed25519): root@dlp:~# mv ~/.ssh/id_ed25519.pub ~/.ssh/authorized_keys
root@dlp:~#
root@dlp:~# ssh 10.0.0.30 hostname dlp.srv.world virsh list --all Id Name State ----------------------- - rx-7 shut off - rx-8 shut off # set VirtualBMC to [rx-8] # for [--libvirt-uri], specify KVM Host root@dlp:~# /opt/virtualbmc/bin/vbmc add rx-8 --port 6231 --username vbmcadmin --password adminpassword --libvirt-uri qemu+ssh://root@10.0.0.30/system root@dlp:~# /opt/virtualbmc/bin/vbmc start rx-8
/opt/virtualbmc/bin/vbmc list +-------------+---------+---------+------+ | Domain name | Status | Address | Port | +-------------+---------+---------+------+ | rx-7 | running | :: | 6230 | | rx-8 | running | :: | 6231 | +-------------+---------+---------+------+root@dlp:~# /opt/virtualbmc/bin/vbmc show rx-8 +-----------------------+----------------------------------+ | Property | Value | +-----------------------+----------------------------------+ | active | True | | address | :: | | domain_name | rx-8 | | libvirt_sasl_password | *** | | libvirt_sasl_username | None | | libvirt_uri | qemu+ssh://root@10.0.0.30/system | | password | *** | | port | 6231 | | status | running | | username | vbmcadmin | +-----------------------+----------------------------------+ # that's OK
# for SSH key-pair generated on KVM Host, # it needs to transfer private-key [id_ed25519] to the Hosts you'd like to use VirtualBMC # for example, execute ipmitool on [rx-7] host to [rx-8] host root@rx-7:~# ll .ssh total 20 drwx------ 2 root root 4096 May 10 04:04 ./ drwx------ 5 root root 4096 May 10 01:02 ../ -rw------- 1 root root 0 May 9 08:15 authorized_keys -rw------- 1 root root 411 May 10 04:04 id_ed25519 -rw------- 1 root root 978 May 10 04:03 known_hosts -rw-r--r-- 1 root root 142 May 10 04:03 known_hosts.old
root@rx-7:~#
ssh 10.0.0.30 hostname dlp.srv.world
root@rx-7:~#
ipmitool -I lanplus -H 10.0.0.30 -p 6231 -U vbmcadmin -P adminpassword power status Chassis Power is off
root@rx-7:~#
root@rx-7:~# ipmitool -I lanplus -H 10.0.0.30 -p 6231 -U vbmcadmin -P adminpassword power on Chassis Power Control: Up/On ssh 10.0.0.30 "virsh list" Id Name State ---------------------- 4 rx-7 running 5 rx-8 running |
Sponsored Link |