qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -drive syntax


From: Kevin Shell
Subject: Re: -drive syntax
Date: Fri, 16 Oct 2020 08:12:31 +0800

On Thu, Oct 15, 2020 at 09:58:02AM +0200, Max Reitz wrote:
> 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.
>
Understand now.
I have seen drive=SOMEID, netdev=SOMEID ... with the -device directive

> 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
>
So, creating a drive object is a two step process for qemu,
if={ide, scsi, sd, mtd, floppy, pflash, virtio} is just a shortcut?

exp.
first step is to define the drive object with
-drive file=FILE,id=ID,if=none

second step is to attach the drive object to the device backend
-device {ide, scsi, sd, mtd, floppy, pflash, virtio DEVICE},drive=ID

Is my understanding right here?


> > 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
>
This looks a lot like my understanding above.
Is my understanding correct again?

> Hope that helps.
>

Thanks for your kink help. :-)

--
kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]