From: Stefan Hajnoczi <stefanha@gmail.com>
To: Stefano Panella <stefano.panella@citrix.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] block-layer: questions on manipulation of internal nodes
Date: Fri, 16 Mar 2018 15:55:27 +0000 [thread overview]
Message-ID: <20180316155527.GC21347@stefanha-x1.localdomain> (raw)
In-Reply-To: <1521040041089.43942@citrix.com>
[-- Attachment #1: Type: text/plain, Size: 3742 bytes --]
On Wed, Mar 14, 2018 at 03:07:21PM +0000, Stefano Panella wrote:
> Hi everybody,
>
> I am a relatively new user of qemu block layer. I am interested in it mainly because it looks very powerful and general and I am hoping to integrate it on our product and to contribute to it for new usecases.
>
> I have existing use cases where we work with a model of a disk process per VM disk and I am experimenting with qemu and qmp to build something similar.
>
> At the moment I have managed to build a new binary, called qemu-dp (probably should be called qemu-bl for block layer) which is basically starting as a qmp server and accepting qmp block layer commands to operate on disks.
>
> just to give you an example this is the kind of thing I am doing:
>
> EXTERNALLY:
> /usr/lib64/xen/bin/qemu-img create -f qcow2 -o size=1M /root/a
> /usr/lib64/xen/bin/qemu-img create -f qcow2 -b /root/a -o size=1M /root/b
> /usr/lib64/xen/bin/qemu-img create -f qcow2 -b /root/b -o size=1M /root/c
> /usr/lib64/xen/bin/qemu-img create -f qcow2 -b /root/c -o size=1M /root/d
> /usr/lib64/xen/bin/qemu-img create -f qcow2 -b /root/d -o size=1M /root/e
>
> let's assume there were some data in every layer....
>
> Than:
>
> USING QMP:
> { "execute": "qmp_capabilities" }
> {
> "execute": "blockdev-add",
> "arguments": {
> "driver": "qcow2",
> "node-name": "qemu_node",
> "discard": "unmap",
> "cache": {
> "direct": true
> },
> "file": {
> "driver": "file",
> "filename": "/root/e"
> }
> }
> }
>
> {
> "execute": "nbd-server-start",
> "arguments": {
> "addr": {
> "type": "unix",
> "data": {
> "path": "/tmp/nbd.test1"
> }
> }
> }
> }
>
> {
> "execute": "nbd-server-add",
> "arguments": {
> "device": "qemu_node",
> "writable": true
> }
> }
>
> after this the chain looks like:
>
> a < b < c < d < e < NBD_server
>
> now I make a full copy of b and c which I call b1 and c1 and for example I run externally qemu-img commit c1 -> b1 while qemu-dp has still the chain opened.
>
> I would now like to send a qmp command to tell qemu-dp to hold any IO from the NBD_server and forget about a, b, c and insert b1 as d's child, like this:
>
> a < b1 < d < e < NBD_server
Holding I/O is done via bdrv_drained_begin/end() and most block-related
monitor commands should use it.
> I have tried to implement this qmp command and looked at
>
> qmp_change_backing_file()
> qmp_x_blockdev_change()
> https://lists.gnu.org/archive/html/qemu-devel/2017-08/msg02660.html
>
> but did not figure out a way of doing that yet...
>
> I suspect my problem is that I am still very confused about the semantics of the object model in the block layer, the ref counting, the graph manipulation, the monitor etc. etc.
>
> I have tried to have some interactive chats on irc and they have been very useful so far (thanks again stefanha, kwolf, berto, eblake) but maybe a proper email would be a good starting point as stefanha has suggested.
>
> Please if somebody could point me to a bit of code to achieve my example that would be great, otherwise if there is no code for that kind of functionality, it would be good to have a little guide on the sequence of block primiteve I should call and on which node, including refs, locking, drain, caches, reopen etc...
blockdev-add and related APIs are still under development and incomplete.
Manos' block-insert-node is probably closest to what you need, so I
would start there.
I'm not clear enough on what exactly is necessary on top of Manos' patch
without doing the work myself, so I'm afraid I can't give a detailed
sequence of steps you need to take.
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
prev parent reply other threads:[~2018-03-16 15:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-14 15:07 [Qemu-devel] block-layer: questions on manipulation of internal nodes Stefano Panella
2018-03-16 15:55 ` Stefan Hajnoczi [this message]
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=20180316155527.GC21347@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=stefano.panella@citrix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).