Your example does work (using -blockdev), but I can't get it to work with
-drive.
$ qemu-system-x86_64 \
-drive id=d01,file=disk1.img,format=qcow2 \
-device drive=d01,serial=s01,driver=virtio-blk,index=1,share-rw=on \
-device drive=d01,serial=s01,driver=virtio-blk,index=2,share-rw=on
warning: TCG doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]
qemu-system-x86_64: -device drive=d01,serial=s01,driver=virtio-blk,index=1,share-rw=on: Drive 'd01' is already in use because it has been automatically connected to another device (did you need 'if=none' in the drive options?)
## ok, fix that error, add 'if=none' to the -drive.
$ qemu-system-x86_64 \
-drive id=d01,file=disk1.img,format=qcow2,if=none \
-device virtio-blk,drive=d01,serial=s01,index=1,share-rw=on \
-device virtio-blk,drive=d01,serial=s01,index=2,share-rw=on
qemu-system-x86_64: -device drive=d01,serial=s01,driver=virtio-blk,index=1,share-rw=on: Property '.index' not found
## ok, index belongs on the -drive (which I should have known from
## the past, but which seems not the right place). Try that anyway.
$ qemu-system-x86_64 \
-drive id=d01,file=disk1.img,format=qcow2,if=none,index=1 \
-device virtio-blk,drive=d01,serial=s01,share-rw=on \
-device virtio-blk,drive=d01,serial=s01,share-rw=on
qemu-system-x86_64: -device drive=d01,serial=s01,driver=virtio-blk,share-rw=on: Drive 'd01' is already in use by another device
## Huh? Isn't that what I said to explicitly allow with share-rw=on?
Note that I've also tried with 'format=raw'. Is there something I'm
missing to try to use -drive and -device ?
Lastly (if you're still reading), how do you specify the format of
the file to -blockdev ? adding 'format=qcow2' makes qemu complain that
"'format' is unexpected".
Your example does work (using -blockdev), but I can't get it to work with
-drive.
$ qemu-system-x86_64 \ file=disk1. img,format= qcow2 \ serial= s01,driver= virtio- blk,index= 1,share- rw=on \ serial= s01,driver= virtio- blk,index= 2,share- rw=on serial= s01,driver= virtio- blk,index= 1,share- rw=on: Drive 'd01' is already in use because it has been automatically connected to another device (did you need 'if=none' in the drive options?)
-drive id=d01,
-device drive=d01,
-device drive=d01,
warning: TCG doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]
qemu-system-x86_64: -device drive=d01,
## ok, fix that error, add 'if=none' to the -drive.
$ qemu-system-x86_64 \ file=disk1. img,format= qcow2,if= none \ blk,drive= d01,serial= s01,index= 1,share- rw=on \ blk,drive= d01,serial= s01,index= 2,share- rw=on serial= s01,driver= virtio- blk,index= 1,share- rw=on: Property '.index' not found
-drive id=d01,
-device virtio-
-device virtio-
qemu-system-x86_64: -device drive=d01,
## ok, index belongs on the -drive (which I should have known from
## the past, but which seems not the right place). Try that anyway.
$ qemu-system-x86_64 \ file=disk1. img,format= qcow2,if= none,index= 1 \ blk,drive= d01,serial= s01,share- rw=on \ blk,drive= d01,serial= s01,share- rw=on serial= s01,driver= virtio- blk,share- rw=on: Drive 'd01' is already in use by another device
-drive id=d01,
-device virtio-
-device virtio-
qemu-system-x86_64: -device drive=d01,
## Huh? Isn't that what I said to explicitly allow with share-rw=on?
Note that I've also tried with 'format=raw'. Is there something I'm
missing to try to use -drive and -device ?
Lastly (if you're still reading), how do you specify the format of
the file to -blockdev ? adding 'format=qcow2' makes qemu complain that
"'format' is unexpected".
Thanks for your time.