qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 04/11] qemu-options: finesse the recommendations around -bloc


From: Thomas Huth
Subject: Re: [PATCH 04/11] qemu-options: finesse the recommendations around -blockdev
Date: Mon, 3 Apr 2023 18:31:04 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0

On 03/04/2023 16.55, Markus Armbruster wrote:
Alex Bennée <alex.bennee@linaro.org> writes:

Markus Armbruster <armbru@redhat.com> writes:

Alex Bennée <alex.bennee@linaro.org> writes:
...
I was under the impression things like -hda wouldn't work say on an Arm
machine because you don't know what sort of interface you might be
using and -hda implies IDE. Where is this macro substitution done?

qemu_init() calls drive_add() for all these options.

drive_add(TYPE, INDEX, FILE, OPTSTR) creates a QemuOpts in group
"drive".  It sets "if" to if_name[TYPE] unless TYPE is IF_DEFAULT,
"index" to INDEX unless it's negative, and "file" to FILE unless it's
null.  Then it parses OPTSTR on top.

For -hdX, the call looks like

                 drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg,
                           HD_OPTS);

We pass IF_DEFAULT, so "if" remains unset.  "index" is set to 0 for
-hda, 1, for -hdb and so forth.  "file" is set to the option argument.
Since HD_OPTS is "media=disk", we set "media" to "disk".

The QemuOpts in config group "drive" get passed to drive_new() via
drive_init_func().  Unset "if" defaults to the current machine's class's
block_default_type.

If a machine doesn't set this member explicitly, it remains zero, which
is IF_NONE.  Documented in blockdev.h:

     typedef enum {
         IF_DEFAULT = -1,            /* for use with drive_add() only */
         /*
          * IF_NONE must be zero, because we want MachineClass member
--->     * block_default_type to default-initialize to IF_NONE
          */
         IF_NONE = 0,
         IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, 
IF_XEN,
         IF_COUNT
     } BlockInterfaceType;

Questions?

How's the average user supposed to know that? Our qemu-options.hx just says: "-hda/-hdb file use 'file' as IDE hard disk 0/1 image"...

 Thomas




reply via email to

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