All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Benoît Canet" <benoit.canet@irqsave.net>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com,
	Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] How to introduce bs->node_name ?
Date: Wed, 30 Oct 2013 14:49:32 +0100	[thread overview]
Message-ID: <87eh72eumr.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <20131028154038.GG2890@irqsave.net> ("Benoît Canet"'s message of "Mon, 28 Oct 2013 16:40:39 +0100")

[Note cc: Eric & Luiz, because this also relates to QMP]

Benoît Canet <benoit.canet@irqsave.net> writes:

> Hi list,
>
> After a discussion on irc we have two potential solution in order to introduce
> a new bs->node_name member in order to be able to manipulate the graph from the
> monitors.
>
> The first one is to make the QMP device parameter of the block commands optional
> and add the node-name parameter as a second optional parameter.
> This is Markus prefered solution and Eric is ok with making mandatory parameters
> optional in QMP.
>
> The second one suggested by Kevin Would be to add some magic to the new
> node_name member by making it equal to device_name for backends and then making
> the qmp commands operate only on node-names.

Needs elaboration.  Let me try.

Currently, a BlockDriverState (short: BDS) has a device_name only when
it's a root of a BDS tree.  These roots are the drives defined with
-drive & friends.  There's code relying on "device_name implies root,
and vice versa".

We're working on giving the user much more control over how block
drivers are combined into backends.  One aspect of that is we need a way
for users to refer to a BDS.  Elsewhere in QEMU, we let users tack IDs
to stuff they create.  The new node_name suggested by Benoît is exactly
that.

Another aspect is that we're going to create a BlockBackend (short: BB)
object that captures the stuff now in BDS that is really about the whole
backend (and thus is used only in root BDSes now).

Semantically, device_name belongs to the whole backend, so it should
move into BB.

So far, QMP commands identify the object to be worked on by its
device_name, typically as parameter "device".  Consequently, they can
only work on roots now.

This is just fine for QMP commands that want to work on a backend.

It's not fine for QMP commands that want to work on an arbitrary,
possibly non-root BDS.

The first proposal is to add another parameter, say "id".  Users can
then refer either to an arbitrary BDS by "id", or (for backward
compatibility) to the root BDS by "device".  When the code sees
"device", it'll look up the BB, then fetch its root BDS.

CON: Existing parameter "device" becomes compatibility cruft.

PRO: Clean and obvious semantics (in my opinion).

The second proposal is to press the existing parameter "device" into
service for referring to BDS node_name.

To keep backward compatibility, we obviously need to ensure that
whenever the old code accepts a value of "device", the new code accepts
it as well, and both resolve it to the same BDS.

What about situations where the old code rejects a value of "device"?
The new code may resolve it to a non-root BDS that happens to have that
ID...

What about dynamic reconfiguration changing the root?  Example: a
synchronous snapshot splices in a QCOW2, which becomes the new root.  In
the current code, device_name refers to the new root.  Wouldn't that
require the BDS ID of the old root moves to the new root?  But that
would mean BDS IDs change!

To be honest, this scares me.  I've been burned by convenience magic and
compatibility magic often enough already.

> My personnal suggestion would be that non specified node-name would be set to
> "undefined" meaning that no operation could occur on this bs.

Yes, that's how IDs work elsewhere.

> For QMP access the device_name is accessed via bdrv_find() in a few place in
> blockdev.
>
> Here are the occurences of it:

[QMP and HMP code using bdrv_find() snipped]

I think we should review with the QMP schema first, code second.

> Very few of them operate on what is destined to become block backend and most of
> them should be able to operate on nodes of the graph;
>
> What solution do you prefer ?

Should be obvious by now :)

  parent reply	other threads:[~2013-10-30 13:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-28 15:40 [Qemu-devel] How to introduce bs->node_name ? Benoît Canet
2013-10-29  1:03 ` Fam Zheng
2013-10-30 13:49 ` Markus Armbruster [this message]
2013-10-30 19:25   ` Eric Blake
2013-11-01 14:51     ` Luiz Capitulino
2013-11-01 14:59       ` Eric Blake
2013-11-01 15:12         ` Luiz Capitulino
2013-11-04 11:13           ` Kevin Wolf
2013-11-04 13:51             ` Luiz Capitulino
2013-11-04  9:31   ` Stefan Hajnoczi
2013-11-04  9:48     ` Fam Zheng
2013-11-04 11:06       ` Kevin Wolf
2013-11-04 11:33         ` Fam Zheng
2013-11-07 18:50           ` Benoît Canet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eh72eumr.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=benoit.canet@irqsave.net \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.