From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
qemu-block@nongnu.org, "Max Reitz" <mreitz@redhat.com>,
"Keith Busch" <keith.busch@intel.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Laszlo Ersek" <lersek@redhat.com>
Subject: Re: [Qemu-devel] [Qemu-block] [RFC] nvme: how to support multiple namespaces
Date: Wed, 26 Jun 2019 06:46:46 +0200 [thread overview]
Message-ID: <87o92lkl6x.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20190625164726.GB21148@apples.localdomain> (Klaus Birkelund's message of "Tue, 25 Jun 2019 18:47:26 +0200")
Cc: QOM maintainers in case I'm talking nonsense about QOM.
Klaus Birkelund <klaus@birkelund.eu> writes:
> On Tue, Jun 25, 2019 at 07:51:29AM +0200, Markus Armbruster wrote:
>> Laszlo Ersek <lersek@redhat.com> writes:
>>
>> > On 06/24/19 12:18, Kevin Wolf wrote:
>> >> Am 24.06.2019 um 10:01 hat Klaus Birkelund geschrieben:
>> >>> On Thu, Jun 20, 2019 at 05:37:24PM +0200, Laszlo Ersek wrote:
>> >>>> On 06/17/19 10:12, Klaus Birkelund wrote:
>> >>>>> Hi all,
>> >>>>>
>> >>>>> I'm thinking about how to support multiple namespaces in the NVMe
>> >>>>> device. My first idea was to add a "namespaces" property array to the
>> >>>>> device that references blockdevs, but as Laszlo writes below, this might
>> >>>>> not be the best idea. It also makes it troublesome to add per-namespace
>> >>>>> parameters (which is something I will be required to do for other
>> >>>>> reasons). Some of you might remember my first attempt at this that
>> >>>>> included adding a new block driver (derived from raw) that could be
>> >>>>> given certain parameters that would then be stored in the image. But I
>> >>>>> understand that this is a no-go, and I can see why.
>> >>>>>
>> >>>>> I guess the optimal way would be such that the parameters was something
>> >>>>> like:
>> >>>>>
>> >>>>> -blockdev raw,node-name=blk_ns1,file.driver=file,file.filename=blk_ns1.img
>> >>>>> -blockdev raw,node-name=blk_ns2,file.driver=file,file.filename=blk_ns2.img
>> >>>>> -device nvme-ns,drive=blk_ns1,ns-specific-options (nsfeat,mc,dlfeat)...
>> >>>>> -device nvme-ns,drive=blk_ns2,...
>> >>>>> -device nvme,...
>> >>>>>
>> >>>>> My question is how to state the parent/child relationship between the
>> >>>>> nvme and nvme-ns devices. I've been looking at how ide and virtio does
>> >>>>> this, and maybe a "bus" is the right way to go?
>> >>>>
>> >>>> I've added Markus to the address list, because of this question. No
>> >>>> other (new) comments from me on the thread starter at this time, just
>> >>>> keeping the full context.
>> >>>>
>> >>>
>> >>> Hi all,
>> >>>
>> >>> I've succesfully implemented this by introducing a new 'nvme-ns' device
>> >>> model. The nvme device creates a bus named from the device id ('id'
>> >>> parameter) and the nvme-ns devices are then registered on this.
>> >>>
>> >>> This results in an nvme device being creates like this (two namespaces
>> >>> example):
>> >>>
>> >>> -drive file=nvme0n1.img,if=none,id=disk1
>> >>> -drive file=nvme0n2.img,if=none,id=disk2
>> >>> -device nvme,serial=deadbeef,id=nvme0
>> >>> -device nvme-ns,drive=disk1,bus=nvme0,nsid=1
>> >>> -device nvme-ns,drive=disk2,bus=nvme0,nsid=2
>> >>>
>> >>> How does that look as a way forward?
>> >>
>> >> This looks very similar to what other devices do (one bus controller
>> >> that has multiple devices on its but), so I like it.
>>
>> Devices can be wired together without a bus intermediary. You
>> definitely want a bus when the physical connection you model has one.
>> If not, a bus may be useful anyway, say because it provides a convenient
>> way to encapsulate the connection model, or to support -device bus=...
>>
>
> I'm not sure how to wire it together without the bus abstraction? So
> I'll stick with the bus for now. It *is* extremely convenient!
As far as I can tell offhand, a common use of bus-less connections
between devices is wiring together composite devices. Example:
static void designware_pcie_host_init(Object *obj)
{
DesignwarePCIEHost *s = DESIGNWARE_PCIE_HOST(obj);
DesignwarePCIERoot *root = &s->root;
object_initialize_child(obj, "root", root, sizeof(*root),
TYPE_DESIGNWARE_PCIE_ROOT, &error_abort, NULL);
qdev_prop_set_int32(DEVICE(root), "addr", PCI_DEVFN(0, 0));
qdev_prop_set_bit(DEVICE(root), "multifunction", false);
}
This creates a TYPE_DESIGNWARE_PCIE_ROOT device "within" the
TYPE_DESIGNWARE_PCIE_HOST device.
Bus-less connections between separate devices (i.e. neither device is a
part of the other) are also possible. But I'm failing at grep right
now. Here's an example for connecting a device to a machine:
static void mch_realize(PCIDevice *d, Error **errp)
{
int i;
MCHPCIState *mch = MCH_PCI_DEVICE(d);
[...]
object_property_add_const_link(qdev_get_machine(), "smram",
OBJECT(&mch->smram), &error_abort);
[...]
}
Paolo, can you provide guidance on when to use a bus, and when not to?
next prev parent reply other threads:[~2019-06-26 4:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-17 8:12 [Qemu-devel] [RFC] nvme: how to support multiple namespaces Klaus Birkelund
2019-06-20 15:37 ` Laszlo Ersek
2019-06-24 8:01 ` [Qemu-devel] [Qemu-block] " Klaus Birkelund
2019-06-24 10:18 ` Kevin Wolf
2019-06-24 20:46 ` Laszlo Ersek
2019-06-25 5:51 ` Markus Armbruster
2019-06-25 16:47 ` Klaus Birkelund
2019-06-26 4:46 ` Markus Armbruster [this message]
2019-06-26 10:14 ` Paolo Bonzini
2019-06-26 16:57 ` Klaus Birkelund
2019-06-25 7:24 ` Kevin Wolf
2019-06-25 16:45 ` Klaus Birkelund
2019-06-26 4:54 ` Markus Armbruster
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=87o92lkl6x.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=ehabkost@redhat.com \
--cc=keith.busch@intel.com \
--cc=kwolf@redhat.com \
--cc=lersek@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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.