qemu-discuss
[Top][All Lists]
Advanced

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

Re: equivalent to "-drive if=ide,id=disk0....."


From: Kevin Wolf
Subject: Re: equivalent to "-drive if=ide,id=disk0....."
Date: Tue, 28 Jul 2020 13:06:48 +0200

Am 27.07.2020 um 23:50 hat Kashyap Chamarthy geschrieben:
> [Cc: qemu-block]
> 
> On Mon, Jul 27, 2020 at 05:11:15PM +0800, Derek Su wrote:
> > Hello,
> > 
> > I'm trying to replace "-drive if=ide,id=disk0....." with "-blockdev
> > '{"node-name": "top-node",...."
> > The "id" is the name of BlockBackend, and the "node-name" is the name
> > of the BDS tree's root.
> > Is there any equivalent for "id" when use "-blockdev '{"node-name":
> > "top-node",...." ?
> 
> IIUC, specifying 'node-name' should be sufficient.  Also, you don't need
> to specify JSON syntax on the command-line; you can 'flatten it' (see
> below).

Indeed, naming BlockBackends is a legacy thing. You should never need
it. Guest devices can be created like -device ide-hd,drive=<node-name>
and QMP commands either accept node names (if they are about the
backend) or the ID of the guest device (if they are about the frontend).

> On 'id' vs. 'node-name', from the documentation of `blockdev-add`,
> https://git.qemu.org/gitweb.cgi?p=qemu.git;a=blob;f=qapi/block-core.json#l4032
> 
>     # Creates a new block device. If the @id option is given at the top 
> level, a
>     # BlockBackend will be created; otherwise, @node-name is mandatory at the 
> top
>     # level and no BlockBackend will be created.

This is actually a documentation bug. @id doesn't exist, blockdev-add
never creates a BlockBackend. This was different in the very first
versions of the patches to add blockdev-add and we probably just forgot
to update the documentation after removing it.

> And here's a minimal working example that I use with '-blockdev'
> 
> /usr/bin/qemu-system-x86_64        \
>     -display none                  \
>     -no-user-config                \
>     -nodefaults                    \
>     -serial  stdio                 \
>     -cpu host                      \
>     -smp 1,maxcpus=2               \
>     -machine q35,accel=kvm,usb=off \
>     -m 2048                        \
>     -blockdev 
> node-name=node-Base,driver=qcow2,file.driver=file,file.filename=./base.qcow2 \
>     -device virtio-blk,drive=node-Base,id=virtio0 \

Yes, this works. Another option is to define each block node separately:

    ...
    -blockdev node-name=base-file,driver=file,filename=base.qcow2 \
    -blockdev node-name=base,driver=qcow2,file=base-file \
    ...

Kevin




reply via email to

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