[gPXE] [PATCH] [virtio] Add virtio block device sanboot support
Stefan Hajnoczi
stefanha at gmail.com
Tue Jan 5 15:46:45 EST 2010
This patch adds virtio block device support alongside the existing iSCSI,
ATA-over-Ethernet, and ramdisk block devices. The virtio block device provides
storage in virtualized environments.
Using this patch, a gPXE option ROM can boot a QEMU/KVM virtual machine
directly from a virtio block device.
Here is an example QEMU invocation:
qemu -drive if=virtio,file=debian.qcow2 -option-rom gpxe/src/bin/1af41001.rom
SANBOOT_PROTO_VIRTIO_BLK must be defined in config/general.h to enable this
feature. The gPXE option ROM must be built for PCI ID 1af4:1001.
The sanboot gPXE command is used with the virtio_blk: root path scheme. The
virtio block device instance is identified by its PCI bus, device, and function
(there could be multiple virtio block devices).
gPXE> sanboot virtio_blk:PCI00:04.0
Perhaps the first available device should be chosen if virtio_blk: is given
without PCI bus, device, and function. I am open to suggestions on how virtio
block device option ROMs should work.
I have successfully booted Debian testing i386 and FreeDOS 0.84-pre2 under QEMU
0.11.0.
Note that QEMU/KVM can boot from a virtio block device using a separate
non-virtio interface (-drive if=virtio,boot=on,[...]). This gPXE patch
provides a native virtio block implementation.
While developing this feature, I noticed that the AoE sanboot code leaves a
pointer to a stack value around after it returns. A commit to fix this is
included.
Stefan Hajnoczi (2):
[sanboot] Prevent leaking a stack reference for "keep-san" AoE
[virtio] Add virtio block device sanboot support
src/arch/i386/interface/pcbios/aoeboot.c | 54 +++--
src/arch/i386/interface/pcbios/virtio_blkboot.c | 70 ++++++
src/config/config.c | 3 +
src/config/general.h | 1 +
src/drivers/block/virtio-blk.c | 271 +++++++++++++++++++++++
src/drivers/block/virtio-blk.h | 30 +++
src/include/gpxe/errfile.h | 2 +
src/include/gpxe/virtblk.h | 37 +++
8 files changed, 447 insertions(+), 21 deletions(-)
create mode 100644 src/arch/i386/interface/pcbios/virtio_blkboot.c
create mode 100644 src/drivers/block/virtio-blk.c
create mode 100644 src/drivers/block/virtio-blk.h
create mode 100644 src/include/gpxe/virtblk.h
More information about the gPXE
mailing list