Received: from eggs.gnu.org ([2001:4830:134:3::10]:59726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZortX-0003La-SJ for qemu-devel@nongnu.org; Wed, 21 Oct 2015 07:49:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZortW-0006cg-DV for qemu-devel@nongnu.org; Wed, 21 Oct 2015 07:49:27 -0400 From: Alberto Garcia In-Reply-To: <1445270025-22999-32-git-send-email-mreitz@redhat.com> References: <1445270025-22999-1-git-send-email-mreitz@redhat.com> <1445270025-22999-32-git-send-email-mreitz@redhat.com> Date: Wed, 21 Oct 2015 13:49:14 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH v7 31/39] blockdev: Add blockdev-insert-medium List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-block@nongnu.org Cc: Kevin Wolf , John Snow , Markus Armbruster , qemu-devel@nongnu.org, Stefan Hajnoczi On Mon 19 Oct 2015 05:53:37 PM CEST, Max Reitz wrote: > And a helper function for that, which directly takes a pointer to the > BDS to be inserted instead of its node-name (which will be used for > implementing 'change' using blockdev-insert-medium). Shouldn't this update bdrv_states? Consider this scenario: 1) We add a drive and eject its BDS { "execute": "blockdev-add", "arguments": { "options": { "driver": "qcow2", "file": { "driver": "file", "filename": "/tmp/hd0.img"}, "id": "drive0" }}} { "execute": "eject", "arguments": {"device": "drive0"}} 2) We create a new BDS and insert it in drive0 { "execute": "blockdev-add", "arguments": { "options": { "driver": "qcow2", "file": { "driver": "file", "filename": "/tmp/hd0.img"}, "node-name": "hd0" }}} { "execute": "blockdev-insert-medium", "arguments": { "device": "drive0", "node-name": "hd0" }} 3) Now we try to create a snapshot... { "execute": "blockdev-snapshot-sync", "arguments": { "device": "drive0", "snapshot-file": "/tmp/new.img", "format": "qcow2" }} {"error": {"class": "GenericError", "desc": "The feature 'snapshot' is not enabled"}} Ooops! It seems that this is because the new node hd0 is not in the bdrv_states list. 4) Let's try to create a mirror instead { "execute": "drive-mirror", "arguments": { "device": "drive0", "target": "/tmp/new.img", "sync": "top"}} {"return": {}} {"timestamp": {"seconds": 1445427560, "microseconds": 765993}, "event": "BLOCK_JOB_READY", "data": {"device": "drive0", "len": 0, "offset": 0, "speed": 0, "type": "mirror"}} 5) Ok, the block job is ready, so let's complete it: { "execute": "query-block-jobs" } {"return": []} Ooops! Again, hd0 is not in bdrv_states so QEMU cannot find the block job. 6) Anyway, we only need the backend name in order to complete a block job, so surely we can do it even if it's not in the list: { "execute": "block-job-complete", "arguments": { "device": "drive0"}} Segmentation fault That's QTAILQ_INSERT_BEFORE() in change_parent_backing_link(). This code assumes that since the 'from' BDS is attached to a backend, it must also be in bdrv_states. Berto