qdev-ify virtio-blk.

First user of the new drive property.  With this patch applied host
and guest config can be specified separately, like this:

  -drive if=none,id=disk1,file=/path/to/disk.img
  -device virtio-blk-pci,drive=disk1

You can set any property for virtio-blk-pci now.  You can set the pci
address via addr=.  You can switch the device into 0.10 compat mode
using class=0x0180.  As this is per device you can have one 0.10 and one
0.11 virtio block device in a single virtual machine.

Old syntax continues to work.  Internally it does the same as the two
lines above though.  One side effect this has is a different
initialization order, which might result in a different pci address
being assigned by default.

Long term plan here is to have this working for all block devices, i.e.
once all scsi is properly qdev-ified you will be able to do something
like this:

  -drive if=none,id=sda,file=/path/to/disk.img
  -device lsi,id=lsi,addr=<pciaddr>
  -device scsi-disk,drive=sda,bus=lsi.0,lun=<n>

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Message-Id:
This commit is contained in:
Gerd Hoffmann 2009-07-31 12:25:41 +02:00 committed by Anthony Liguori
parent 14b41872fd
commit d176c495b6
8 changed files with 25 additions and 44 deletions

View file

@ -157,7 +157,6 @@ static void mpc8544ds_init(ram_addr_t ram_size,
const char *cpu_model)
{
PCIBus *pci_bus;
PCIDevice *pci_dev;
CPUState *env;
uint64_t elf_entry;
uint64_t elf_lowaddr;
@ -172,7 +171,6 @@ static void mpc8544ds_init(ram_addr_t ram_size,
unsigned int pci_irq_nrs[4] = {1, 2, 3, 4};
qemu_irq *irqs, *mpic, *pci_irqs;
SerialState * serial[2];
DriveInfo *dinfo;
/* Setup CPU */
env = cpu_ppc_init("e500v2_v30");
@ -217,15 +215,6 @@ static void mpc8544ds_init(ram_addr_t ram_size,
isa_mmio_init(MPC8544_PCI_IO, MPC8544_PCI_IOLEN);
if (pci_bus) {
int unit_id = 0;
/* Add virtio block devices. */
while ((dinfo = drive_get(IF_VIRTIO, 0, unit_id)) != NULL) {
pci_dev = pci_create("virtio-blk-pci", dinfo->devaddr);
qdev_init(&pci_dev->qdev);
unit_id++;
}
/* Register network interfaces. */
for (i = 0; i < nb_nics; i++) {
pci_nic_init(&nd_table[i], "virtio", NULL);