[5870] Add virtio-blk support
Revision: 5870
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5870 Author: aliguori Date: 2008-12-04 19:52:44 +0000 (Thu, 04 Dec 2008)
Log Message:
-----------
Add virtio-blk support
Virtio-blk is a paravirtual block device based on VirtIO. It can be used by specifying the if=virtio parameter to the -drive parameter.
When using -enable-kvm, it can achieve very good performance compared to IDE or SCSI.
Modified Paths:
--------------
trunk/Makefile.target
trunk/hw/pc.c
trunk/qemu-doc.texi
trunk/sysemu.h
trunk/vl.c
Added Paths:
-----------
trunk/hw/virtio-blk.c
trunk/hw/virtio-blk.h
Modified: trunk/Makefile.target
===================================================================
Makefile.target +2 -2
@@ -665,7 +665,7 @@ OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o # virtio support -OBJS+= virtio.o +OBJS+= virtio.o virtio-blk.o CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE endif ifeq ($(TARGET_BASE_ARCH), ppc)
@@ -684,7 +684,7 @@ # PowerPC 4xx boards OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o # virtio support -OBJS+= virtio.o +OBJS+= virtio.o virtio-blk.o endif ifeq ($(TARGET_BASE_ARCH), mips) OBJS+= mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o
Modified: trunk/hw/pc.c
===================================================================
hw/pc.c +13 -0
@@ -33,6 +33,7 @@#include "boards.h" #include "console.h" #include "fw_cfg.h" +#include "virtio-blk.h" /* output Bochs bios info messages */ //#define DEBUG_BIOS
@@ -1092,6 +1093,18 @@ } } } + +/* Add virtio block devices */ +if (pci_enabled) { +int index; +int unit_id =0 ; + +while ((index =drive_get_index (IF_VIRTIO ,0 , unit_id)) !=-1 ) { +virtio_blk_init (pci_bus,0x1AF4 ,0x1001 , + drives_table[index].bdrv); + unit_id++; + } + } } static void pc_init_pci(ram_addr_t ram_size, int vga_ram_size,
Added: trunk/hw/virtio-blk.c
===================================================================
hw/virtio-blk.c +248 -0
248 lines not on this page · raw message
Added: trunk/hw/virtio-blk.h
===================================================================
hw/virtio-blk.h +76 -0
76 lines not on this page · raw message
Modified: trunk/qemu-doc.texi
===================================================================
qemu-doc.texi +1 -1
@@ -253,7 +253,7 @@ (for instance, "file=my,,file" to use file "my,file"). @item if=@var{interface} This option defines on which type on interface the drive is connected. -Available types are: ide, scsi, sd, mtd, floppy, pflash. +Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio. @item bus=@var{bus},unit=@var{unit} These options define where is connected the drive by defining the bus number and the unit id.
Modified: trunk/sysemu.h
===================================================================
sysemu.h +1 -1
@@ -123,7 +123,7 @@#endif typedef enum { -IF_IDE ,IF_SCSI ,IF_FLOPPY ,IF_PFLASH ,IF_MTD ,IF_SD +IF_IDE ,IF_SCSI ,IF_FLOPPY ,IF_PFLASH ,IF_MTD ,IF_SD ,IF_VIRTIO }BlockInterfaceType ; typedef struct DriveInfo {
Modified: trunk/vl.c
===================================================================
vl.c +5 -1
@@ -2267,7 +2267,10 @@ }else if (!strcmp (buf,"sd" )) { type =IF_SD ; max_devs =0 ; - }else { + }else if (!strcmp (buf,"virtio" )) { + type =IF_VIRTIO ; + max_devs =0 ; + }else {fprintf (stderr,"qemu: '%s' unsupported bus type '%s'\n" , str, buf);return -1 ; }
@@ -2474,6 +2477,7 @@break ;case IF_PFLASH :case IF_MTD : +case IF_VIRTIO :break ; }if (!file[0 ])