0

I am trying to understand the difference between these two drive arguments:

  1. -drive file=drive.qcow2
  2. -device virtio-blk-device,drive=hd -drive file=drive.qcow2,if=none,id=hd

The first pattern boots (Debian) fine with qemu-system-(i386, x86_64, aarch64, ...) but not with qemu-system-(arm, riscv64). For arm and riscv64, I have to use the second argument pattern.

I am trying to understand what is happening here (not just make it work). What does the first lack that is supplied by the second.

BTW: it seems to the be the same situation with -nic user,model=virtio-net-pci vs. -device virtio-net-device,netdev=net -netdev user,id=net

Update: add boot log diff...

Attached is an image that shows a diff between the two console boot logs. On the left is the successful run (argument pattern #2). On the right is the one that fails to boot (argument pattern #1). Looks like the kernel simply doesn't find the hardware device.

boot diff

1 Answers1

0

Using the Qemu monitor and the info qtree command, I discovered that argument pattern #1 puts the device on a PCI bus:

  dev: gpex-pcihost, id ""
    ...
    bus: pcie.0
      type PCIE
      dev: virtio-blk-pci, id ""
        ...

And argument pattern #2 puts it on a virtio-mmio

  dev: virtio-mmio, id ""
    ...
    bus: virtio-mmio-bus.31
      type virtio-mmio-bus
      dev: virtio-blk-device, id ""
        drive = "hd"
        ...  

With this new information, I found this Qemu-devel mailing list post that answers my question directly:

You need to specify things longhand with the virtio-blk-device etc devices, because the shortcuts all assume virtio is PCI. So in this case:

-drive if=none,file=root,id=foo
-device virtio-blk-device,drive=foo

-- PMM

So the answer is: shortcut arguments (such as "-drive" without "-device") assume virtio is PCI