[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: -drive syntax
From: |
Max Reitz |
Subject: |
Re: -drive syntax |
Date: |
Thu, 15 Oct 2020 09:58:02 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 |
On 15.10.20 02:23, Kevin Shell wrote:
> Hello qemu users.
Hi,
> I have three questions about the -drive syntax.
>
> 1) I have see the syntax "-drive id=SOMEID",
> but the id option is not documented in the man page,
> what's the meaning of the id option and when to use it?
I think most objects you can create on the command line have an id
option that is later used to identify the object.
This becomes important for your second question:
> 2) what's the meaning of if=none and when to use it?
It’s discouraged to use -drive and define both a block device and a
guest device with it.
Simply speaking, a block device is qemu’s internal representation of a
disk image. It’s something that e.g. can be attached to guest devices
so they have something to store their data in.
A guest device is e.g. your SATA device in the guest.
Those are two separate entities, so ideally you’ll create them separately.
To create plain block devices (without a guest device), you can either
use -drive if=none, or -blockdev. -blockdev is more modern, but -drive
is simpler to use (in simple cases).
So in your example, these commands would look like this:
-drive if=none,id=disk1,file=disk1.qcow2
Or for -blockdev:
-blockdev '{ "node-name": "disk1",
"driver": "qcow2",
"file": {
"driver": "file",
"filename": "disk1.qcow2"
} }'
To create a guest device, the ID you were talking about in question 1
comes into play: You use -device and supply that ID through the “drive”
option, like so:
-device virtio-blk,drive=disk1
> 3) why there is no if=sata,
> is SATA disks treated as IDE/ATA disks?
Not sure, but you’ll probably just have to use the separated syntax I
was talking about above. Googling reveals that apparently you need to
create an AHCI (which acts as a bus) and then attach devices as IDE
disks to that bus:
-drive if=none,id=disk1,file=disk1.qcow2 \
-device ahci,id=ahci \
-device ide-hd,bus=ahci.0,drive=disk1
Hope that helps.
signature.asc
Description: OpenPGP digital signature
- -drive syntax, Kevin Shell, 2020/10/14
- Re: -drive syntax,
Max Reitz <=