The general goal of this doc is to show how to use qemu, ipxe and tgt to test iscsi and iBFT.
There are loads of things that could be done to make this test environment. But for now, it just shows a simple case to show parameters necessary.
In examples here, the iscsi server is available at 192.168.1.10
. The qemu host system is available at 192.168.1.11
. We assume port 9999 is available to run a python simple web server.
If you have an existing iscsi system in place, you can use that. If you need to set one up, this documents how to do so with the tgt
package.
-
set some variables for later reference Set following variables for later reference and usage. an attempt is provided to get a default.
export TGT_IMAGES_D=/var/lib/tgt/images
-
install dependencies
sudo apt-get update && sudo apt-get install -qy itgt
-
add some iscsi target devices
Ubuntu's
/etc/tgt/targets.conf
containsinclude /etc/tgt/conf.d/*.conf
, which means you can just drop files into/etc/tgt/conf.d/
and have them read. So to add a target namedtarget-01
, just do:truncate --size 4G ${TGT_IMAGES_D}/target-01.img ./add-tgt-target target-01 truncate --size 4G ${TGT_IMAGES_D}/target-02.img ./add-tgt-target target-02
-
list targets
You should now be able to see the targets with both of the following. iscsiadm comes from
open-iscsi
package.sudo iscsiadm -m discovery -t sendtargets -p 192.168.1.10 sudo tgt-admin --show
-
install dependencies
sudo apt-get update sudo apt-get install -qy qemu-system-x86 qemu-utils ipxe
-
Provide a kernel and initrd
ipxe is a very powerful tool, supporting a lot of functionality. The ipxe
package provides an ipxe.lkrn
that can be provided to qemu -kernel
. The kernel command line then provided is read by ipxe as its config. So, you can do really neat things like:
-
Provide 'boot-initrd' and 'boot-kernel'.
boot-initrd and boot-kernel are a kernel/initrd pair. They can be downloaded from maas.ubuntu.com. If you have open-iscsi installed , likely the files in your /boot will work.
-
Run a simple web server to give ipxe the 'config' file.
This is not strictly necessary, you can put it all inline on the 'append', but this shows a powerful path of receiving configuration from a http endpoint.
python -m SimpleHTTPServer 9999
-
Run qemu system
qemu-system-x86_64 -enable-kvm -m 1024 -curses \ -device virtio-net-pci,netdev=net00 -netdev type=user,id=net00 \ -kernel /usr/lib/ipxe/ipxe.lkrn \ -append "dhcp && chain http://192.168.1.11:9999/config"
The system should now boot to initramfs that has a configured iBFT device. See /usr/share/doc/open-iscsi/README.Debian.gz for more information. Once inside, you can look around.
(initramfs) modprobe iscsi_ibft
[ 11.444414] iBFT detected.
(initramfs) cat /sys/firmware/ibft/target0/nic-assoc
0
(initramfs) cat /sys/firmware/ibft/target0/target-name
mytest
(initramfs) cat /sys/firmware/ibft/target0/port
3260
(initramfs) cat /sys/firmware/ibft/ethernet0/mac
52:54:00:12:34:56
(initramfs) for x in /sys/class/net/*/address; do echo $x; cat $x; done
/sys/class/net/eth0/address
52:54:00:12:34:56
/sys/class/net/lo/address
00:00:00:00:00:00
$ for f in $(find /sys/firmware/ibft/ -type f); do echo == $f ==; cat $f; done
== /sys/firmware/ibft/target0/lun ==
01000000
== /sys/firmware/ibft/target0/port ==
3260
== /sys/firmware/ibft/target0/target-name ==
inst-000-2
== /sys/firmware/ibft/target0/flags ==
3
== /sys/firmware/ibft/target0/index ==
0
== /sys/firmware/ibft/target0/chap-type ==
0
== /sys/firmware/ibft/target0/nic-assoc ==
0
== /sys/firmware/ibft/target0/ip-addr ==
192.168.1.10
== /sys/firmware/ibft/initiator/flags ==
3
== /sys/firmware/ibft/initiator/index ==
0
== /sys/firmware/ibft/initiator/initiator-name ==
iqn.2010-04.org.ipxe:00000000-0000-0000-0000-000000000000
== /sys/firmware/ibft/ethernet0/mac ==
52:54:00:12:34:56
== /sys/firmware/ibft/ethernet0/vlan ==
0
== /sys/firmware/ibft/ethernet0/flags ==
3
== /sys/firmware/ibft/ethernet0/index ==
0
== /sys/firmware/ibft/ethernet0/primary-dns ==
10.0.2.3
== /sys/firmware/ibft/ethernet0/subnet-mask ==
255.255.255.0
== /sys/firmware/ibft/ethernet0/gateway ==
10.0.2.2
== /sys/firmware/ibft/ethernet0/origin ==
3
== /sys/firmware/ibft/ethernet0/ip-addr ==
10.0.2.15
- current ipxe trunk is limited to setting up a single iBFT iscsi target. That limitation is documented on mailing list post. There are for patches available for 'multiple session support' available.