From MAILER-DAEMON Tue Sep 01 01:52:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWeUe-0000T9-G7 for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 01:52:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58752) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWeUY-0000Si-Tz for qemu-block@nongnu.org; Tue, 01 Sep 2015 01:52:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWeUU-0005fQ-Lv for qemu-block@nongnu.org; Tue, 01 Sep 2015 01:52:22 -0400 Received: from [59.151.112.132] (port=28873 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWeUT-0005eW-Nj; Tue, 01 Sep 2015 01:52:18 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100226791" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 01 Sep 2015 13:55:17 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t815q3XF015436; Tue, 1 Sep 2015 13:52:03 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 1 Sep 2015 13:52:11 +0800 To: Eric Blake , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi References: <1439279489-13338-1-git-send-email-wency@cn.fujitsu.com> <1439279489-13338-6-git-send-email-wency@cn.fujitsu.com> <55E4A536.6040905@redhat.com> From: Wen Congyang Message-ID: <55E53CF2.1030605@cn.fujitsu.com> Date: Tue, 1 Sep 2015 13:51:46 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55E4A536.6040905@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Patch for-2.5 v2 5/6] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 05:52:27 -0000 On 09/01/2015 03:04 AM, Eric Blake wrote: > On 08/11/2015 01:51 AM, Wen Congyang wrote: >> Signed-off-by: Wen Congyang >> Signed-off-by: zhanghailiang >> Signed-off-by: Gonglei >> --- >> blockdev.c | 79 +++++++++++++++++++++++++++++++++++++++++++++= +++++++ >> qapi/block-core.json | 40 ++++++++++++++++++++++++++ >> qmp-commands.hx | 67 ++++++++++++++++++++++++++++++++++++++++++++ >> 3 files changed, 186 insertions(+) >> >=20 >> +void qmp_child_add(const char *device, BlockdevOptionsChild *options, >> + Error **errp) >> +{ >> + QmpOutputVisitor *ov =3D qmp_output_visitor_new(); >> + QObject *obj; >> + QDict *qdict; >> + Error *local_err =3D NULL; >> + >> + if (options->child->has_id || options->child->has_discard || >> + options->child->has_cache || options->child->has_aio || >> + options->child->has_rerror || options->child->has_werror || >> + options->child->has_read_only || options->child->has_detect_zer= oes) { >> + error_setg(errp, "id, discard, cache, aio, rerror, werror, read= only" >> + " and detect_zeroes cann't be used for child-add"); >=20 > s/cann't/can't/ >=20 > If they can't be used, then why not write the qapi so that they can't > even be provided? On the other hand, why can't they be used? Can't you > specify some of these options separately for different quorum children > when first creating a quorum, in which case you'd want to be able to do > likewise when adding a new member to the quorum? >=20 >> +++ b/qapi/block-core.json >> @@ -2122,3 +2122,43 @@ >> ## >> { 'command': 'block-set-write-threshold', >> 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } >> + >> +## >> +# @BlockdevOptionsChild >> +# >> +# Driver specific block device options for child block device. >> +# >> +# Since: 2.5 >> +## >> +{ 'struct': 'BlockdevOptionsChild', >> + 'data': { 'child': 'BlockdevOptions' } } >=20 > Do you need this struct? It causes extra nesting on the wire... >=20 >> + >> +## >> +# @child-add >> +# >> +# Add a new child to the parent BDS. Currently only the Quorum driver >> +# implements this feature. This is useful to fix a broken quorum child. >> +# >> +# @device: graph node name or id which the child will be added to. >> +# >> +# @options: the options to create child BDS. >> +# >> +# Since: 2.5 >> +## >> +{ 'command': 'child-add', >> + 'data' : { 'device': 'str', 'options': 'BlockdevOptionsChild' } } >=20 > ...Consider if you just did: >=20 > { 'command': 'child-add', > 'data': { 'device', 'str', 'child': 'BlockdevOptions' } } >=20 >> >> + >> +## >> +# @child-del >> +# >> +# Remove a child from the parent BDS. Currently only the Quorum driver >> +# implements this feature. This is useful to fix a broken quorum child. >=20 > Might also be worth mentioning that you can't remove a child if it would > bring the quorum below its threshold. >=20 >> +++ b/qmp-commands.hx >=20 >> +Add a child to a quorum node. >> + >> +This command is still a work in progress. It doesn't support all >> +block drivers. Stay away from it unless you want it to help with >> +its development. >=20 > Maybe we should name it 'x-child-add' for now, so that we aren't baking > ourselves into a corner. >=20 >> + >> +Arguments: >> + >> +- "device": the quorum's id or node name >> +- "options": the new child options >> + >> +Example: >> + >> +-> { "execute": "child-add", >> + "arguments": { >> + "device": "disk1", >> + "options" : { >> + "child": { >=20 > ...the simper command idea above would reduce one layer of {} nesting her= e. >=20 When we open a child BDS, the options for child BDS must have the same pref= ix, such as file.xxx, x-image.xxx, ... For hot-added child BDS, the prefix is "child=E2= =80=9C. If we don't use "options" here, the prefix "child" will be eaten in qmp_marshal_input_x= _child_add(). I am investigating how to solve it. Any suggestion is welcome. Thanks Wen Congyang From MAILER-DAEMON Tue Sep 01 02:02:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWeeM-0002oZ-SE for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 02:02:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWeeK-0002nL-JB for qemu-block@nongnu.org; Tue, 01 Sep 2015 02:02:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWeeG-0002vA-Iv for qemu-block@nongnu.org; Tue, 01 Sep 2015 02:02:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44224) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWeeG-0002uq-CH; Tue, 01 Sep 2015 02:02:24 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 5FB0596CA; Tue, 1 Sep 2015 06:02:23 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-39.ams2.redhat.com [10.36.116.39]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8162LkW022250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 1 Sep 2015 02:02:22 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 811F8303F90B; Tue, 1 Sep 2015 08:02:20 +0200 (CEST) From: Markus Armbruster To: John Snow References: <55DF2CDA.1070609@redhat.com> <55DF3F58.4070809@redhat.com> <87mvxb8sv9.fsf@blackfin.pond.sub.org> <55E4A2D2.4090000@redhat.com> Date: Tue, 01 Sep 2015 08:02:20 +0200 In-Reply-To: <55E4A2D2.4090000@redhat.com> (John Snow's message of "Mon, 31 Aug 2015 14:54:10 -0400") Message-ID: <87pp22brtf.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , QEMU Developers , Qemu-block Subject: Re: [Qemu-block] [Qemu-devel] hd-geo-test creates 4GB files on FSes that don't support sparse images, doesn't delete them on error X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 06:02:29 -0000 John Snow writes: > On 08/28/2015 09:06 AM, Markus Armbruster wrote: >> John Snow writes: >> >>> On 08/27/2015 11:29 AM, Eric Blake wrote: >>>> On 08/27/2015 09:17 AM, Peter Maydell wrote: >>>>> I've noticed recently that tests/hd-geo-test.c creates test disk >>>>> images which are 4GB in size, which is a problem if the filesystem >>>>> on the host doesn't support sparse files. In particular, OSX's HFS+ >>>>> doesn't have sparse file support, and Windows probably doesn't either. >>>> >>>> Windows NTFS supports sparse files (minimum hole size of 64k), but it >>>> can be a pain to set up, and while it saves disk space, it may actually >>>> slow your program down. >>>> >>>> [At one point cygwin created sparse files on windows by default, but >>>> because it was demonstrated to hurt performance in dealing with sparse >>>> files, because Windows doesn't handle sparse files efficiently, the >>>> cygwin defaults were switched so that it now requires an explicit opt-in >>>> mount option before even attempting sparse files] >>>> >>>>> Worse, if the test fails an assertion somewhere the test doesn't >>>>> clean up after itself and leaves a 4GB file lying around in /tmp/. >>>>> >>>>> It would be nice if we could skip these tests on filesystems that >>>>> don't have sparse file support... >>>> >>>> Or even where sparse files are supported but not default. >>>> >>> >>> Does this test *require* the raw format? >> >> If memory serves, the test doesn't require a specific format, only the >> size and the contents of the MBR matters. >> >>> Use tests/libqos/libqos.c mkqcow2 instead. I'll send a patch. >> >> Go right ahead. >> > > Oh, taking a look at it, it needs to writethat MBR data to the file > before it opens it. We don't have an existing qemu-io dependency here to > use. > > I could add it, but the line between iotest and qtest starts to get > pretty fuzzy. > > Thoughts? Let's go back to the original problem for a bit: (1) The test needs a big image, contents beyond the MBR doesn't matter. Image format doesn't matter, either. (2) On losing filesystem, this image takes up significant space, because we use "raw". (3) We fail to clean it up on failure. This is a general problem with tests creating files. Independently of what else we do, (3) is worth fixing. Make each test run in its own directory, create files only there, and have the test harness remove the directory. John suggested to attack (2) by using "qcow2", but that turns out to be a bit harder than anticipated: the infrastructure for creating such images isn't there. Options: (a) Create the infrastructure in qtests. (b) Move the test to iotests. (c) Create the image once and commit it to git. (d) Ignore the problem. Needing 8GiB for tests if your filesystem sucks isn't exactly horrible. But (3) really needs fixing then. We could try to attack (1) to mitigate. I don't remember why I picked 8GiB. Perhaps we can make the image somewhat smaller without compromising the test. Need to examine the geometry guessing code to figure that out. From MAILER-DAEMON Tue Sep 01 05:36:03 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWhz1-0002nR-Pm for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 05:36:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWhyy-0002mo-8l for qemu-block@nongnu.org; Tue, 01 Sep 2015 05:36:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWhyt-000834-Vo for qemu-block@nongnu.org; Tue, 01 Sep 2015 05:36:00 -0400 Received: from [59.151.112.132] (port=45911 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWhyt-00082H-2U; Tue, 01 Sep 2015 05:35:55 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100236130" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 01 Sep 2015 17:38:56 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t819Zg3a031080; Tue, 1 Sep 2015 17:35:42 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 1 Sep 2015 17:35:50 +0800 From: Wen Congyang To: Eric Blake , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi References: <1439279489-13338-1-git-send-email-wency@cn.fujitsu.com> <1439279489-13338-3-git-send-email-wency@cn.fujitsu.com> <55E48CBE.2020901@redhat.com> Message-ID: <55E5715D.5030009@cn.fujitsu.com> Date: Tue, 1 Sep 2015 17:35:25 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55E48CBE.2020901@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Patch for-2.5 v2 2/6] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 09:36:01 -0000 On 09/01/2015 01:19 AM, Eric Blake wrote: > On 08/11/2015 01:51 AM, Wen Congyang wrote: >> Signed-off-by: Wen Congyang >> Signed-off-by: zhanghailiang >> Signed-off-by: Gonglei >> Reviewed-by: Alberto Garcia >> --- >> qapi/block-core.json | 17 +++++++++++++++-- >> 1 file changed, 15 insertions(+), 2 deletions(-) >> >> diff --git a/qapi/block-core.json b/qapi/block-core.json >> index 7b2efb8..3ed8114 100644 >> --- a/qapi/block-core.json >> +++ b/qapi/block-core.json >> @@ -1383,7 +1383,7 @@ >> 'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device', >> 'host_floppy', 'http', 'https', 'null-aio', 'null-co', 'parallels', >> 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx', >> - 'vmdk', 'vpc', 'vvfat' ] } >> + 'vmdk', 'vpc', 'vvfat', 'nbd' ] } > > Please keep the list alphabetical. Also, this is missing documentation > (see how BlockDeviceInfo has listed which releases have added which > formats; so it should add a listing of 'nbd' in 2.5). > >> >> ## >> # @BlockdevOptionsBase >> @@ -1789,6 +1789,19 @@ >> '*read-pattern': 'QuorumReadPattern' } } >> >> ## >> +# @BlockdevOptionsNBD >> +# >> +# Driver specific block device options for NBD >> +# >> +# @export: #options the NBD export name >> +# >> +# Since: 2.5 >> +## >> +{ 'struct': 'BlockdevOptionsNBD', >> + 'base': 'InetSocketAddress', >> + 'data': { '*export': 'str' } } > > So does NBD really support a range of ports? Or is it an error to > specify 'to'? Perhaps what you should really be doing is making a > simpler base class for representing a single-port IP address, then > making InetSocketAddress a child class of the simpler one to add in > ranging, and make BlockdevOptionsNBD a child class of the simpler one to > add in an export name. NBD doesn;t support a range of ports. I will update it in the next version. > > Also, InetSocketAddress appears to be limited to IPv4 and IPv6 > addresses; but what about nbd+unix transport? It feels like you need a > flat union with a discriminator that describes what address family (IP > vs. unix socket) and then further details based on that discriminator. Hmm, It is SocketAddress, but it contains fd, which nbd doesn't support. Another problem is that: NBD doesn't support type. It check the key path and host: if (qdict_haskey(options, "path") == qdict_haskey(options, "host")) { if (qdict_haskey(options, "path")) { error_setg(errp, "path and host may not be used at the same time."); } else { error_setg(errp, "one of path and host must be specified."); } return; } s->client.is_unix = qdict_haskey(options, "path"); Update NBD to support it? Thanks Wen Congyang > >> + >> +## >> # @BlockdevOptions >> # >> # Options for creating a block device. >> @@ -1815,7 +1828,7 @@ >> 'http': 'BlockdevOptionsFile', >> 'https': 'BlockdevOptionsFile', >> # TODO iscsi: Wait for structured options >> -# TODO nbd: Should take InetSocketAddress for 'host'? >> + 'nbd': 'BlockdevOptionsNBD', > > So while you are indeed literally taking the TODO suggestion, I'm not > sure that the literal interpretation is the best. > > Remember, the current NBD source code accepts: > > if (is_unix) { > /* nbd+unix:///export?socket=path */ > if (uri->server || uri->port || strcmp(qp->p[0].name, "socket")) { > ret = -EINVAL; > goto out; > } > qdict_put(options, "path", qstring_from_str(qp->p[0].value)); > } else { > QString *host; > /* nbd[+tcp]://host[:port]/export */ > > and we want to be able to represent all of those possibilities in QMP. > From MAILER-DAEMON Tue Sep 01 07:31:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWjmg-0005zJ-52 for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 07:31:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWjmZ-0005qH-SD for qemu-block@nongnu.org; Tue, 01 Sep 2015 07:31:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWjmV-0001eF-Hr for qemu-block@nongnu.org; Tue, 01 Sep 2015 07:31:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWjmV-0001b0-BG; Tue, 01 Sep 2015 07:31:15 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 19EA9C1CC1ED; Tue, 1 Sep 2015 11:31:14 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-137.ams2.redhat.com [10.36.116.137]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t81BVBjg013975; Tue, 1 Sep 2015 07:31:12 -0400 Date: Tue, 1 Sep 2015 13:31:11 +0200 From: Kevin Wolf To: Eric Blake Message-ID: <20150901113111.GB4304@noname.redhat.com> References: <457103c2204e849aea3b83ffd78fad049d8d923d.1441014844.git.berto@igalia.com> <55E4B0CC.6070906@redhat.com> <55E4B374.70800@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wac7ysb48OaltWcw" Content-Disposition: inline In-Reply-To: <55E4B374.70800@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 1/1] block: Allow passing BlockdevOptions to blockdev-snapshot-sync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 11:31:24 -0000 --wac7ysb48OaltWcw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 31.08.2015 um 22:05 hat Eric Blake geschrieben: > On 08/31/2015 01:53 PM, Max Reitz wrote: >=20 > > Design question: Would it make sense to instead add a "reference" mode > > to blockdev-snapshot-sync where you can specify a BDS's node-name > > instead of snapshot-file to use an existing BDS as the new top layer, > > ideally an empty one? >=20 > Indeed - then blockdev-add can be used to create an unattached BDS (with > all appropriate options), and blockdev-snapshot-sync would then attach > that BDS as the snapshot-file that wraps an existing BDS (without > needing to worry about options). Yes, this is what we should do. The existing blockdev-snapshot-sync should really have been called something like drive-snapshot, it doesn't belong in the blockdev-* family of commands which works only with existing nodes. > >> +++ b/qapi/block-core.json > >> @@ -697,11 +697,18 @@ > >> # > >> # @mode: #optional whether and how QEMU should create a new image, de= fault is > >> # 'absolute-paths'. > >> +# > >> +# @options: #optional options for the new device, with the following > >> +# restrictions for the fields: 'driver' must match the value > >> +# of @format, > >=20 > > As said above, I'd rather make specifying both @options and @format > > exclusive. > >=20 > > Maybe there is even some QAPI magic to enforce that (and for > > 'node-name', too), I don't know... >=20 > Not that I know of at the moment, but not to say we can't add some. The > closest we can get is with a flat union, but that requires a > non-optional discriminator field. Maybe we can tweak qapi to make the > discriminator optional (with a default value). Thankfully, it sounds > like Markus' work on introspection would at least let management apps > learn about a new 'options' argument. Let's avoid such magic and instead add a new, clean blockdev-* style command. Maybe call it simply blockdev-snapshot; the -sync part was added because we knew it wouldn't be the final version of the command. Now we don't have any bdrv_open() in it any more that could by synchronous or asynchronous. Kevin --wac7ysb48OaltWcw Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJV5Yx/AAoJEH8JsnLIjy/WxhgQAMpktsgu2bA1xWaIZVHxxapt AMtT48yCY0tl2id8vq2wEHoGPmyHRpG3hqQ0ZWWYbeAtU/2eR21TiuBQLHYOK2m2 ib8t65e99B1/hRi/E58jUUVf5VftnZvZOWGtzelvBcGrPQUX9AHXpTkA9RMtZIwR wAO0lrFqMVrtfgcn6fyY2PjE6Jx6hE7u8IBo1u49BAroz1LerviMq9sGqPfseBUq XPqus218EtmVrmiqM0s+/ApJeI8i85XhxsVGjTqQcmfSocTGxQn6LMk9IRRcCBye B3wZgyrw1I0SWBSS764BrUGtK2ybg8ezllIRhMkPbcIJZAnY7eJbaUNVfB31Xk1G kSTvAq/xuWgCM3lrj3uW0eNIDGjttJefu56CRi+pDClLATdnTYqgQZk4JtMJEceD e3EWi7+q/zehbhQ4fWFx41Eeoc8nfB/RfJ9PY+W3JvFoobbuJSfEYxUolM8958d3 Q/JqOIWABWeRM6bOfbohWJNu5SdgbdK2oJtWYjLl8XIZuSwdyUlwMmFYm8WvBvvs AU15ohKedFtGvE3Qum1yOWsR8lXVjQDW50xAHBA2OQi62VlTUWv+2AhCILjhfMvk +4Aw13UdSdLWsztdq6bWXaUIwVIW+c1BmJECG78u39EYliWMlm44WTcoD2C7gGnp DJjy7G7WR+1pXXV2glre =wDFU -----END PGP SIGNATURE----- --wac7ysb48OaltWcw-- From MAILER-DAEMON Tue Sep 01 07:33:16 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWjoS-0008Bw-Rp for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 07:33:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWjoQ-0008BZ-FJ for qemu-block@nongnu.org; Tue, 01 Sep 2015 07:33:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWjoM-0002d4-DO for qemu-block@nongnu.org; Tue, 01 Sep 2015 07:33:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52419) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWjoM-0002cv-5s; Tue, 01 Sep 2015 07:33:10 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id CA942A202C; Tue, 1 Sep 2015 11:33:09 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-137.ams2.redhat.com [10.36.116.137]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t81BX7Kk011794; Tue, 1 Sep 2015 07:33:08 -0400 Date: Tue, 1 Sep 2015 13:33:07 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150901113307.GC4304@noname.redhat.com> References: <457103c2204e849aea3b83ffd78fad049d8d923d.1441014844.git.berto@igalia.com> <55E4B0CC.6070906@redhat.com> <55E4B374.70800@redhat.com> <55E4B513.5040600@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Fba/0zbH8Xs+Fj9o" Content-Disposition: inline In-Reply-To: <55E4B513.5040600@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 1/1] block: Allow passing BlockdevOptions to blockdev-snapshot-sync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 11:33:15 -0000 --Fba/0zbH8Xs+Fj9o Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 31.08.2015 um 22:12 hat Max Reitz geschrieben: > On 31.08.2015 22:05, Eric Blake wrote: > > On 08/31/2015 01:53 PM, Max Reitz wrote: > >=20 > >> Design question: Would it make sense to instead add a "reference" mode > >> to blockdev-snapshot-sync where you can specify a BDS's node-name > >> instead of snapshot-file to use an existing BDS as the new top layer, > >> ideally an empty one? > >=20 > > Indeed - then blockdev-add can be used to create an unattached BDS (with > > all appropriate options), and blockdev-snapshot-sync would then attach > > that BDS as the snapshot-file that wraps an existing BDS (without > > needing to worry about options). > >=20 > >> > >> What we'd then need is a QMP command for creating images. But as far as > >> I know we'll need that anyway sooner or later... > >=20 > > Can't blockdev-add already be used for that (at least, for supported > > file types)? If not, what would it take to get it there? >=20 > It would take a blockdev-create-image QMP command. :-) >=20 > blockdev-add only opens existing images, blockdev-create-image would > then create these so they can be opened using blockdev-add. >=20 > Similar to blockdev-add, it would probably have a single parameter, but > it'd be of a different type, called e.g. BlockdevCreateOptions, since it > has to reflect the creation options instead of the runtime options for > opening existing images. For instance, for qcow2 you could set the > refcount-bits value, but not the L2 cache size. Would be nice to have (especially because we would get a schema of the create options), but not absolutely necessary for a blockdev-* style snapshotting command. libvirt seems to cope just fine with calling qemu-img before going to the QMP monitor. Kevin --Fba/0zbH8Xs+Fj9o Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJV5YzzAAoJEH8JsnLIjy/WrOcP/RoKqC+iEW819uTtkNP5Mu58 mq206abV/5/BfMCFbRpM0AzGhHVdIq2FNKzzKQz6s2829j9Cx3eckI3RG9ogCKQF gYsHQH8vO0b49IT0v/kB9dKqZeDAYdDfFzDowpFbnjMptC2HLrxMTlIMtnDBEeAZ 8vXrrF/ePrs4uzmqrispxwClGQYY6H8cqqIgs25lpgx546/dWvjQCCxJKDq4s5Ro YMxct1cREUFj3ju4xEY5j8WIGwTIKLjWuj3vNuUCVGAHA6shyzPYF4MAr5fsDOq4 G9FdJUGHMVbJMcQp6y4/wMkJv4GlJUZF/4BVi7de7yo8QfkgrWP36h9xQ+SzXj2O EjmncQHF3P9/dfdd2peRC+i1JhOYDZfaPFvD997m9hVZ3m5Q4yUktg2/a91cuxA9 OxkhqbIyFvMfB6y2p/qUUBuPpocz8mx+w/ypfHbtfP2tJivwzsxOrhysXvnousx/ GOcFPU8OWXLlQ3lwFhxaF+HH4/JUWPmbvvZ+mnIRC9WOhoiQAiVENRC2/K5qiTdB cMRapmA5Sj4nYKQwnk/zeX6i3qafTZ3Wcr3ReZ8LL/+Wlc+KaB+6cyVpN/+WIfVj KV1XnMwooi3kKt0TbhygQX3KrZGXw4BfcuxKztA5DEyLUIT/FQuBju9UbZqTUmYo PgKlbgsYkFBVnzeHCXn2 =3cio -----END PGP SIGNATURE----- --Fba/0zbH8Xs+Fj9o-- From MAILER-DAEMON Tue Sep 01 08:07:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWkLJ-0003JN-8Q for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 08:07:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWkLD-0003HD-1C for qemu-block@nongnu.org; Tue, 01 Sep 2015 08:07:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWkL7-0006G2-Qs for qemu-block@nongnu.org; Tue, 01 Sep 2015 08:07:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48882) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWkL7-0006Ej-MD; Tue, 01 Sep 2015 08:07:01 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 49277341ADD; Tue, 1 Sep 2015 12:07:01 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-137.ams2.redhat.com [10.36.116.137]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t81C6w3C001992; Tue, 1 Sep 2015 08:06:59 -0400 Date: Tue, 1 Sep 2015 14:06:58 +0200 From: Kevin Wolf To: John Snow Message-ID: <20150901120658.GD4304@noname.redhat.com> References: <1436576710-10414-1-git-send-email-jsnow@redhat.com> <1436576710-10414-2-git-send-email-jsnow@redhat.com> <20150713101859.GB5893@noname.redhat.com> <55DBB5E6.3090503@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55DBB5E6.3090503@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, qemu-block@nongnu.org, hare@suse.de, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 1/2] atapi: abort transfers with 0 byte limits X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 12:07:11 -0000 Am 25.08.2015 um 02:25 hat John Snow geschrieben: > > > On 07/13/2015 06:18 AM, Kevin Wolf wrote: > > Am 11.07.2015 um 03:05 hat John Snow geschrieben: > >> We're supposed to abort on transfers like this, unless we fill > >> Word 125 of our IDENTIFY data with a default transfer size, which > >> we don't currently do. > >> > >> This is an ATA error, not a SCSI/ATAPI one. > >> See ATA8-ACS3 sections 7.17.6.49 or 7.21.5. > >> > >> If we don't do this, QEMU will loop forever trying to transfer > >> zero bytes, which isn't particularly useful. > >> > >> Signed-off-by: John Snow > > > > Of course, one could argue that for a clean separation between the ATA > > core and SCSI/ATAPI, this check should really be done in cmd_packet and > > ide_abort_command() could stay static. And in fact, I do think it's > > worthwhile to try getting a better separation in the mid term. > > > > However, for a 2.4 fix, this patch might be the right thing to do. > > > > The interesting part is that the SCSI command is already partially > > handled before the error is returned. The required assumption here is > > that the guest doesn't actually see any intermediate state between > > issuing the command and getting the abort, so it doesn't notice that we > > already started the command successfully. I _think_ that assumption > > holds true. > > > > Reviewed-by: Kevin Wolf > > > > Ping -- > > Do you still feel it's necessary we perform the abort in the IDE layer? I can hardly say that it's necessary, but it might be desirable. > This requires us to peek into the CDB and determine if the CDB will (or > will not) transfer any data. > > Is that sane? Is that worse than exporting ide_abort_command into the > ATAPI layer? No, core.c looking at the CDB is definitely not sane. > Pretty much either way, the ATA bits need to know about the SCSI packet, > or the ATAPI bits need to invoke core ATA functionality. > > It's sort of gross, since the spec unfortunately allows for this field > to be zero if the command does not transfer data. :( The only reasonable way to do this that I can think of offhand would be to return this information from ide_atapi_cmd(). Of course, the current structure of the code doesn't make this easy. But in theory it can be done if (and only if) no asynchronous operation is involved and the command is completed while ide_atapi_cmd() is running. As I said in my review above, we already make that assumption; if it weren't true, our current behaviour would be wrong. In order to actually implement things this way, we would need to first restructure the commands to move completion to ide_atapi_cmd() instead of duplicating it in each command; I already mentioned this as a possible improvement of the code in our private email thread. Kevin From MAILER-DAEMON Tue Sep 01 09:53:34 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWm0E-0005KT-Oq for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 09:53:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWm0C-0005JT-1n for qemu-block@nongnu.org; Tue, 01 Sep 2015 09:53:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWm06-000536-UO for qemu-block@nongnu.org; Tue, 01 Sep 2015 09:53:31 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:48878 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWm06-00052S-Jo for qemu-block@nongnu.org; Tue, 01 Sep 2015 09:53:26 -0400 Received: (qmail 29771 invoked by uid 89); 1 Sep 2015 13:53:23 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.7/20865. hbedv: 8.3.34.6/7.12.5.114. spamassassin: 3.4.0. Clear:RC:1(82.141.1.145):SA:0(-1.2/5.0):. Processed in 0.932408 secs); 01 Sep 2015 13:53:23 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 1 Sep 2015 13:53:21 -0000 X-GL_Whitelist: yes Received: from lieven-pc (lieven-pc.kamp-intra.net [172.21.12.60]) by dns.kamp-intra.net (Postfix) with ESMTP id E5BDAE005A; Tue, 1 Sep 2015 15:52:51 +0200 (CEST) Received: by lieven-pc (Postfix, from userid 1000) id 01DA220D36; Tue, 1 Sep 2015 15:52:36 +0200 (CEST) From: Peter Lieven To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 1 Sep 2015 15:52:30 +0200 Message-Id: <1441115550-26366-1-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, Peter Lieven Subject: [Qemu-block] [PATCH] ide/atapi: make PIO read requests async X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 13:53:33 -0000 PIO read requests on the ATAPI interface used to be sync blk requests. This has to siginificant drawbacks. First the main loop hangs util an I/O request is completed and secondly if the I/O request does not complete (e.g. due to an unresponsive storage) Qemu hangs completely. Signed-off-by: Peter Lieven --- hw/ide/atapi.c | 69 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 79dd167..95a5697 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -105,31 +105,51 @@ static void cd_data_to_raw(uint8_t *buf, int lba) memset(buf, 0, 288); } -static int cd_read_sector(IDEState *s, int lba, uint8_t *buf, int sector_size) +static void cd_read_sector_cb(void *opaque, int ret) { - int ret; + IDEState *s = opaque; - switch(sector_size) { - case 2048: - block_acct_start(blk_get_stats(s->blk), &s->acct, - 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); - ret = blk_read(s->blk, (int64_t)lba << 2, buf, 4); - block_acct_done(blk_get_stats(s->blk), &s->acct); - break; - case 2352: - block_acct_start(blk_get_stats(s->blk), &s->acct, - 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); - ret = blk_read(s->blk, (int64_t)lba << 2, buf + 16, 4); - block_acct_done(blk_get_stats(s->blk), &s->acct); - if (ret < 0) - return ret; - cd_data_to_raw(buf, lba); - break; - default: - ret = -EIO; - break; + block_acct_done(blk_get_stats(s->blk), &s->acct); + + if (ret < 0) { + ide_atapi_io_error(s, ret); + return; + } + + if (s->cd_sector_size == 2352) { + cd_data_to_raw(s->io_buffer, s->lba); } - return ret; + + s->lba++; + s->io_buffer_index = 0; + s->status &= ~BUSY_STAT; + + ide_atapi_cmd_reply_end(s); +} + +static int cd_read_sector(IDEState *s, int lba, void *buf, int sector_size) +{ + if (sector_size != 2048 && sector_size != 2352) { + return -EINVAL; + } + + s->iov.iov_base = buf; + if (sector_size == 2352) { + buf += 4; + } + + s->iov.iov_len = 4 * BDRV_SECTOR_SIZE; + qemu_iovec_init_external(&s->qiov, &s->iov, 1); + + if (blk_aio_readv(s->blk, (int64_t)lba << 2, &s->qiov, 4, + cd_read_sector_cb, s) == NULL) { + return -EIO; + } + + block_acct_start(blk_get_stats(s->blk), &s->acct, + 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); + s->status |= BUSY_STAT; + return 0; } void ide_atapi_cmd_ok(IDEState *s) @@ -190,10 +210,8 @@ void ide_atapi_cmd_reply_end(IDEState *s) ret = cd_read_sector(s, s->lba, s->io_buffer, s->cd_sector_size); if (ret < 0) { ide_atapi_io_error(s, ret); - return; } - s->lba++; - s->io_buffer_index = 0; + return; } if (s->elementary_transfer_size > 0) { /* there are some data left to transmit in this elementary @@ -275,7 +293,6 @@ static void ide_atapi_cmd_read_pio(IDEState *s, int lba, int nb_sectors, s->io_buffer_index = sector_size; s->cd_sector_size = sector_size; - s->status = READY_STAT | SEEK_STAT; ide_atapi_cmd_reply_end(s); } -- 1.9.1 From MAILER-DAEMON Tue Sep 01 10:23:36 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWmTI-0003L3-EP for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 10:23:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWmTD-0003Di-0r for qemu-block@nongnu.org; Tue, 01 Sep 2015 10:23:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWmT9-0004hm-QD for qemu-block@nongnu.org; Tue, 01 Sep 2015 10:23:31 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:24496 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWmT0-0004Bv-G8; Tue, 01 Sep 2015 10:23:18 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CSBgDzs+VV/5tjdVtdGQEBAYJ/gT2qLAEBAQEBAQUBgQsBknWHcgKBOzkTAQEBAQEBAYEKhCQBAQMBOj8FCwsOEyUPASwbBgESiCYMAcksAQEBAQEBAQMBAQEBAR2GLYQ+gQWFCweELAWMb4hSp2Emgg8cFoFAPDOCTQEBAQ X-IPAS-Result: A2CSBgDzs+VV/5tjdVtdGQEBAYJ/gT2qLAEBAQEBAQUBgQsBknWHcgKBOzkTAQEBAQEBAYEKhCQBAQMBOj8FCwsOEyUPASwbBgESiCYMAcksAQEBAQEBAQMBAQEBAR2GLYQ+gQWFCweELAWMb4hSp2Emgg8cFoFAPDOCTQEBAQ X-IronPort-AV: E=Sophos;i="5.17,449,1437429600"; d="scan'208";a="16076399" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 01 Sep 2015 16:22:25 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZWmS8-0007Oy-Mc; Tue, 01 Sep 2015 16:22:24 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZWmS8-0000vc-Hj; Tue, 01 Sep 2015 16:22:24 +0200 From: Alberto Garcia To: Kevin Wolf , Eric Blake In-Reply-To: <20150901113111.GB4304@noname.redhat.com> References: <457103c2204e849aea3b83ffd78fad049d8d923d.1441014844.git.berto@igalia.com> <55E4B0CC.6070906@redhat.com> <55E4B374.70800@redhat.com> <20150901113111.GB4304@noname.redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Tue, 01 Sep 2015 16:22:24 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 1/1] block: Allow passing BlockdevOptions to blockdev-snapshot-sync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 14:23:35 -0000 On Tue 01 Sep 2015 01:31:11 PM CEST, Kevin Wolf wrote: >> > Design question: Would it make sense to instead add a "reference" >> > mode to blockdev-snapshot-sync where you can specify a BDS's >> > node-name instead of snapshot-file to use an existing BDS as the >> > new top layer, ideally an empty one? >> >> Indeed - then blockdev-add can be used to create an unattached BDS >> (with all appropriate options), and blockdev-snapshot-sync would then >> attach that BDS as the snapshot-file that wraps an existing BDS >> (without needing to worry about options). > > Yes, this is what we should do. Sounds like a good idea, thanks for the feedback ! >> >> +# @options: #optional options for the new device, with the following >> >> +# restrictions for the fields: 'driver' must match the value >> >> +# of @format, >> > >> > As said above, I'd rather make specifying both @options and @format >> > exclusive. >> > >> > Maybe there is even some QAPI magic to enforce that (and for >> > 'node-name', too), I don't know... >> >> Not that I know of at the moment, but not to say we can't add some. The >> closest we can get is with a flat union, but that requires a >> non-optional discriminator field. Maybe we can tweak qapi to make the >> discriminator optional (with a default value). Thankfully, it sounds >> like Markus' work on introspection would at least let management apps >> learn about a new 'options' argument. This is not necessary if we go for the "reference" mode proposed by Markus, since the "options" parameter would disappear. > Let's avoid such magic and instead add a new, clean blockdev-* style > command. Maybe call it simply blockdev-snapshot; the -sync part was > added because we knew it wouldn't be the final version of the command. > Now we don't have any bdrv_open() in it any more that could by > synchronous or asynchronous. Would you then prefer me to create a new command instead of extending the existing one? What would be the benefit (other than a better name)? Berto From MAILER-DAEMON Tue Sep 01 10:40:21 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWmjV-0003vg-93 for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 10:40:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWmjJ-0003ot-VZ for qemu-block@nongnu.org; Tue, 01 Sep 2015 10:40:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWmjH-0006KW-9h for qemu-block@nongnu.org; Tue, 01 Sep 2015 10:40:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50967) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWmjH-0006IA-3W; Tue, 01 Sep 2015 10:40:07 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 363C5C1CC1CB; Tue, 1 Sep 2015 14:40:06 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-137.ams2.redhat.com [10.36.116.137]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t81Ee3B9018770; Tue, 1 Sep 2015 10:40:03 -0400 Date: Tue, 1 Sep 2015 16:40:02 +0200 From: Kevin Wolf To: Alberto Garcia Message-ID: <20150901144002.GF4304@noname.redhat.com> References: <457103c2204e849aea3b83ffd78fad049d8d923d.1441014844.git.berto@igalia.com> <55E4B0CC.6070906@redhat.com> <55E4B374.70800@redhat.com> <20150901113111.GB4304@noname.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 1/1] block: Allow passing BlockdevOptions to blockdev-snapshot-sync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 14:40:15 -0000 Am 01.09.2015 um 16:22 hat Alberto Garcia geschrieben: > On Tue 01 Sep 2015 01:31:11 PM CEST, Kevin Wolf wrote: > > >> > Design question: Would it make sense to instead add a "reference" > >> > mode to blockdev-snapshot-sync where you can specify a BDS's > >> > node-name instead of snapshot-file to use an existing BDS as the > >> > new top layer, ideally an empty one? > >> > >> Indeed - then blockdev-add can be used to create an unattached BDS > >> (with all appropriate options), and blockdev-snapshot-sync would then > >> attach that BDS as the snapshot-file that wraps an existing BDS > >> (without needing to worry about options). > > > > Yes, this is what we should do. > > Sounds like a good idea, thanks for the feedback ! > > >> >> +# @options: #optional options for the new device, with the following > >> >> +# restrictions for the fields: 'driver' must match the value > >> >> +# of @format, > >> > > >> > As said above, I'd rather make specifying both @options and @format > >> > exclusive. > >> > > >> > Maybe there is even some QAPI magic to enforce that (and for > >> > 'node-name', too), I don't know... > >> > >> Not that I know of at the moment, but not to say we can't add some. The > >> closest we can get is with a flat union, but that requires a > >> non-optional discriminator field. Maybe we can tweak qapi to make the > >> discriminator optional (with a default value). Thankfully, it sounds > >> like Markus' work on introspection would at least let management apps > >> learn about a new 'options' argument. > > This is not necessary if we go for the "reference" mode proposed by > Markus, since the "options" parameter would disappear. > > > Let's avoid such magic and instead add a new, clean blockdev-* style > > command. Maybe call it simply blockdev-snapshot; the -sync part was > > added because we knew it wouldn't be the final version of the command. > > Now we don't have any bdrv_open() in it any more that could by > > synchronous or asynchronous. > > Would you then prefer me to create a new command instead of extending > the existing one? What would be the benefit (other than a better name)? A clean interface. There is really little overlap with what we have: { 'struct': 'BlockdevSnapshot', 'data': { '*device': 'str', '*node-name': 'str', 'snapshot-file': 'str', '*snapshot-node-name': 'str', '*format': 'str', '*mode': 'NewImageMode' } } When you add an existing node which has been created with blockdev-add as a snapshot, you won't use snapshot-file, snapshot-node-name, format and mode. We would either have to make all of them optional and actually forbid them when a reference is given, or to ensure that they are consistent with the already existing node. That we have both device and node-name (and both marked as optional, while one of them is required) is also not in line with our current practise. If we went further that way, the schema wouldn't really be expressive any more because there would be too many hidden rules of which combinations are allowed and which aren't. What you really need for the version with a reference is just: { 'struct': 'BlockdevSnapshot', 'data': { 'device': 'str', 'snapshot': 'str' } } Where both arguments refer to a node by node-name or backend name. Kevin From MAILER-DAEMON Tue Sep 01 11:31:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWnWl-0007oC-Rn for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 11:31:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWnWj-0007lf-MU for qemu-block@nongnu.org; Tue, 01 Sep 2015 11:31:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWnWZ-0002JQ-Fq for qemu-block@nongnu.org; Tue, 01 Sep 2015 11:31:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37806) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWnWZ-0002Iw-5p; Tue, 01 Sep 2015 11:31:03 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 788CBC1CC1C3; Tue, 1 Sep 2015 15:31:02 +0000 (UTC) Received: from [10.3.113.115] (ovpn-113-115.phx2.redhat.com [10.3.113.115]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81FV16M005298; Tue, 1 Sep 2015 11:31:01 -0400 To: Wen Congyang , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi References: <1439279489-13338-1-git-send-email-wency@cn.fujitsu.com> <1439279489-13338-4-git-send-email-wency@cn.fujitsu.com> <55E4917A.9010703@redhat.com> <55E4F4FF.1000504@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E5C4B0.1080301@redhat.com> Date: Tue, 1 Sep 2015 09:30:56 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55E4F4FF.1000504@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="N03McC0HJxa7gaavOpUTDpIc603oG4j6M" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Patch for-2.5 v2 3/6] Add new block driver interface to add/delete a BDS's child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 15:31:14 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --N03McC0HJxa7gaavOpUTDpIc603oG4j6M Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/31/2015 06:44 PM, Wen Congyang wrote: >> >>> + * Hot add/remove a BDS's child. So the user can take a child offlin= e when >>> + * it is broken and take a new child online >>> + */ >>> +void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **er= rp) >>> +{ >>> + >>> + if (!bs->drv || !bs->drv->bdrv_add_child) { >>> + error_setg(errp, "The BDS %s doesn't support adding a child"= , >>> + bdrv_get_device_or_node_name(bs)); >>> + return; >>> + } >>> + >>> + bs->drv->bdrv_add_child(bs, options, errp); >> >> Should this also check that bs is not already a child of something? O= r >> a bit looser, we may want to allow a BDS to be a child of multiple tre= es >> (a common shared backing file), but we still definitely don't want to >> allow nonsensical loops such as trying to make a BDS be hot-added as i= ts >> own child. >> >=20 > hot-added BDS is a new BDS, but it is OK to check it here. I will updat= e it > in the next version. Design-wise, I think we really want to have the add-child operation be handed a pre-opened BDS, rather than the options dictionary to open the BDS itself. That is, we should use the existing blockdev-add (and enhance it to support everything) to open the BDS, and then this command should just attach that BDS as the new child (which is why it IS important that we validate that the new BDS being added doesn't create an invalid loop). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --N03McC0HJxa7gaavOpUTDpIc603oG4j6M Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5cSxAAoJEKeha0olJ0NqhOUH/R81m1zxYb82CRy8NbZDQS4i 86oh/qQ0AbOz8NAVMEzjwYMDh38IYdP1ddhPiZxb3tXMxkoQGe/jtqfjuMrZU4tX FdnTdSfOaG3afJYEeeSOXu1LZoc7yn/hX2h788Lygpo35XxNK6GysewudJ4dWTFz 3QJIdE22Y2MNBTUYwvpoiirxUQwi20RSWBPczXGQbTYopKbjxDettlvWmLfxphpK e4nweSxT09gVcvngFXjDKJ5U8X4mX6iXZRB3+e1WqevlrabOysZDUbztJETPfhGd wObNbJ3N7rTbHPv2kqFKzUkJu0nMm7zo9U2psrkYBhbkMzkC4kDcFUilTmpO/wU= =iYIR -----END PGP SIGNATURE----- --N03McC0HJxa7gaavOpUTDpIc603oG4j6M-- From MAILER-DAEMON Tue Sep 01 11:34:17 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWnZh-0001QG-Qo for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 11:34:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWnZg-0001Pf-0W for qemu-block@nongnu.org; Tue, 01 Sep 2015 11:34:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWnZd-0003Sl-8k for qemu-block@nongnu.org; Tue, 01 Sep 2015 11:34:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWnZd-0003Se-2z; Tue, 01 Sep 2015 11:34:13 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id AC5018EA30; Tue, 1 Sep 2015 15:34:12 +0000 (UTC) Received: from [10.3.113.115] (ovpn-113-115.phx2.redhat.com [10.3.113.115]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81FYBlU030341; Tue, 1 Sep 2015 11:34:11 -0400 To: Wen Congyang , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi References: <1439279489-13338-1-git-send-email-wency@cn.fujitsu.com> <1439279489-13338-6-git-send-email-wency@cn.fujitsu.com> <55E4A536.6040905@redhat.com> <55E4F767.1070602@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E5C572.7000606@redhat.com> Date: Tue, 1 Sep 2015 09:34:10 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55E4F767.1070602@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="AHDOqJPeOUEuhUEBc02bHADLrMU4DkvBj" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Patch for-2.5 v2 5/6] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 15:34:17 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --AHDOqJPeOUEuhUEBc02bHADLrMU4DkvBj Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/31/2015 06:55 PM, Wen Congyang wrote: >>> +This command is still a work in progress. It doesn't support all >>> +block drivers. Stay away from it unless you want it to help with >>> +its development. >> >> Maybe we should name it 'x-child-add' for now, so that we aren't bakin= g >> ourselves into a corner. >=20 > Do you mean the command name should be x-child-add? It is OK. Use of the 'x-' prefix means a command is experimental and may change or be withdrawn. It gives us a way to test if an interface is useful without committing to that interface long term. We've still got time before 2.5 to get blockdev-add working everywhere, in which case I think we are better off using blockdev-add to create a new unattached BDS and then have this command pass the node name to be made the new child, rather than all the options for opening the child from scratch. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --AHDOqJPeOUEuhUEBc02bHADLrMU4DkvBj Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5cVzAAoJEKeha0olJ0Nq4oAH/2i2pptorl0kXlNdeS94gXTr k1vvRqqNy9YsUsy4utkWnHaIguli7kpxLKlB/Nkl9bgeo7erOc1kZF+1thqQpJWk NLADAnzMN57JnCp6AuFWUxUQ727H57yZQWpajJoFFxXzVJe1bwXOJSRMFu4koFdL stnrx1BIRURGVPipnVtFvKhMTF5aGByKRwyZePmf3kX9tGogN47jRXqxG8N8oYRt WXVPSdsWFm1/gFyVShCADiNG1ADOjDDiPnnE7PPubT4oLFX47lyqXxcq1fdvEcP6 rA8PBSAQaUAO9WtyiCVcv0PB/7BK0bKoIKyiYRcO8zEVIcLiNpE7HzFTM/OXioI= =7b8l -----END PGP SIGNATURE----- --AHDOqJPeOUEuhUEBc02bHADLrMU4DkvBj-- From MAILER-DAEMON Tue Sep 01 13:23:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWpHY-0006lq-9T for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 13:23:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWpHS-0006k8-7s for qemu-block@nongnu.org; Tue, 01 Sep 2015 13:23:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWpHM-0002LN-6p for qemu-block@nongnu.org; Tue, 01 Sep 2015 13:23:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52426) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWpHM-0002Ji-2W; Tue, 01 Sep 2015 13:23:28 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 7C41D8EA29; Tue, 1 Sep 2015 17:23:27 +0000 (UTC) Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81HNPxZ022704 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Tue, 1 Sep 2015 13:23:26 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Tue, 1 Sep 2015 13:23:23 -0400 Message-Id: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berrange@redhat.com, qemu-block@nongnu.org, armbru@redhat.com, programmingkidx@gmail.com Subject: [Qemu-block] [RFC PATCH 0/2] Auto-generated IDs X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 17:23:38 -0000 Born from the conversation on qemu-devel, this generation scheme uses the format ultimately proposed by Kevin, after list discussion. It attempts to keep the ID strings as small as possible, while fulfilling: 1.) Guarantee no collisions with a user-specified ID 2.) Identify the sub-system the ID belongs to 3.) Guarantee of uniqueness 4.) Spoiling predictibility, to avoid creating an assumption of object ordering and parsing (i.e., we don't want users to think they can guess the next ID based on prior behavior). See patch 1 for the generation scheme details. Jeff Cody (2): util - add automated ID generation utility block: auto-generated node-names block.c | 25 ++++++++++++++++--------- include/qemu-common.h | 8 ++++++++ util/id.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 9 deletions(-) -- 1.9.3 From MAILER-DAEMON Tue Sep 01 13:23:41 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWpHZ-0006me-EQ for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 13:23:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWpHW-0006kg-Jx for qemu-block@nongnu.org; Tue, 01 Sep 2015 13:23:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWpHR-0002Pa-0m for qemu-block@nongnu.org; Tue, 01 Sep 2015 13:23:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52459) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWpHQ-0002PO-S5; Tue, 01 Sep 2015 13:23:32 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 7FE95FA9C2; Tue, 1 Sep 2015 17:23:32 +0000 (UTC) Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81HNUqn026907 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Tue, 1 Sep 2015 13:23:31 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Tue, 1 Sep 2015 13:23:25 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berrange@redhat.com, qemu-block@nongnu.org, armbru@redhat.com, programmingkidx@gmail.com Subject: [Qemu-block] [RFC PATCH 2/2] block: auto-generated node-names X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 17:23:39 -0000 If a node-name is not specified, automatically generate the node-name. Generated node-names will use the "block" sub-system identifier. Signed-off-by: Jeff Cody --- block.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/block.c b/block.c index d088ee0..892e127 100644 --- a/block.c +++ b/block.c @@ -771,32 +771,39 @@ static void bdrv_assign_node_name(BlockDriverState *bs, const char *node_name, Error **errp) { + char *gen_node_name = NULL; + if (!node_name) { - return; - } - - /* Check for empty string or invalid characters */ - if (!id_wellformed(node_name)) { - error_setg(errp, "Invalid node name"); - return; + gen_node_name = id_generate(ID_BLOCK); + node_name = gen_node_name; + } else { + /* Check for empty string or invalid characters, but not if it is + * generated (generated names use characters not available to the user) + * */ + if (!id_wellformed(node_name)) { + error_setg(errp, "Invalid node name"); + return; + } } /* takes care of avoiding namespaces collisions */ if (blk_by_name(node_name)) { error_setg(errp, "node-name=%s is conflicting with a device id", node_name); - return; + goto out; } /* takes care of avoiding duplicates node names */ if (bdrv_find_node(node_name)) { error_setg(errp, "Duplicate node name"); - return; + goto out; } /* copy node name into the bs and insert it into the graph list */ pstrcpy(bs->node_name, sizeof(bs->node_name), node_name); QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list); +out: + g_free(gen_node_name); } static QemuOptsList bdrv_runtime_opts = { -- 1.9.3 From MAILER-DAEMON Tue Sep 01 13:23:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWpHY-0006m3-BH for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 13:23:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWpHU-0006kV-OM for qemu-block@nongnu.org; Tue, 01 Sep 2015 13:23:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWpHO-0002OD-Mg for qemu-block@nongnu.org; Tue, 01 Sep 2015 13:23:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39865) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWpHO-0002Nv-Fd; Tue, 01 Sep 2015 13:23:30 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 1B4F1C1CC1F4; Tue, 1 Sep 2015 17:23:30 +0000 (UTC) Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81HNShc015407 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Tue, 1 Sep 2015 13:23:29 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Tue, 1 Sep 2015 13:23:24 -0400 Message-Id: <17356f309b182f0df47567aeed40ab0e3cfc99d3.1441127976.git.jcody@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berrange@redhat.com, qemu-block@nongnu.org, armbru@redhat.com, programmingkidx@gmail.com Subject: [Qemu-block] [RFC PATCH 1/2] util - add automated ID generation utility X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 17:23:38 -0000 Multiple sub-systems in QEMU may find it useful to generated IDs for objects that a user may reference via QMP or HMP. This patch presents a standardized way to do it, so that automatic ID generation follows the same rules. This patch enforces the following rules when generating an ID: 1.) Guarantee no collisions with a user-specified ID 2.) Identify the sub-system the ID belongs to 3.) Guarantee of uniqueness 4.) Spoiling predictibility, to avoid creating an assumption of object ordering and parsing (i.e., we don't want users to think they can guess the next ID based on prior behavior). The scheme for this is as follows (no spaces): # subsys D RR Reserved char --| | | | Subsytem String -----| | | Unique number (64-bit) --| | Two-digit random number ---| For example, a generated node-name for the block sub-system may take the look like this: #block076 The caller of id_generate() is responsible for freeing the generated node name string with g_free(). Signed-off-by: Jeff Cody --- include/qemu-common.h | 8 ++++++++ util/id.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/include/qemu-common.h b/include/qemu-common.h index bbaffd1..f6b0105 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -237,6 +237,14 @@ int64_t strtosz_suffix_unit(const char *nptr, char **end, #define STR_OR_NULL(str) ((str) ? (str) : "null") /* id.c */ + +typedef enum IdSubSystems { + ID_QDEV, + ID_BLOCK, + ID_MAX /* last element, used as array size */ +} IdSubSystems; + +char *id_generate(IdSubSystems); bool id_wellformed(const char *id); /* path.c */ diff --git a/util/id.c b/util/id.c index 09b22fb..48e2935 100644 --- a/util/id.c +++ b/util/id.c @@ -26,3 +26,38 @@ bool id_wellformed(const char *id) } return true; } + +#define ID_SPECIAL_CHAR '#' + +/* Generates an ID of the form: + * + * "#block146", + * + * where: + * - "#" is always the reserved character '#' + * - "block" refers to the subsystem identifed via IdSubSystems + * and id_subsys_str[] + * - "1" is a unique number (up to a uint64_t) for the subsystem, + * - "46" is a pseudo-random numer to create uniqueness + * + * The caller is responsible for freeing the returned string with g_free() + */ +char *id_generate(IdSubSystems id) +{ + const char *id_subsys_str[] = { + [ID_QDEV] = "qdev", + [ID_BLOCK] = "block", + }; + + static uint64_t id_counters[ID_MAX]; + uint32_t rnd; + + assert(id < ID_MAX); + + rnd = g_random_int_range(0, 99); + + return g_strdup_printf("%c%s%" PRIu64 "%" PRId32, ID_SPECIAL_CHAR, + id_subsys_str[id], + id_counters[id]++, + rnd); +} -- 1.9.3 From MAILER-DAEMON Tue Sep 01 14:55:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWqiO-0001Ih-Mk for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 14:55:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWqiL-0001BI-GQ for qemu-block@nongnu.org; Tue, 01 Sep 2015 14:55:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWqiI-0006Po-6r for qemu-block@nongnu.org; Tue, 01 Sep 2015 14:55:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWqiH-0006Od-VQ; Tue, 01 Sep 2015 14:55:22 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 73D16C0A15E0; Tue, 1 Sep 2015 18:55:21 +0000 (UTC) Received: from [10.3.113.115] (ovpn-113-115.phx2.redhat.com [10.3.113.115]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81ItKkh001267; Tue, 1 Sep 2015 14:55:20 -0400 To: Jeff Cody , qemu-devel@nongnu.org References: <17356f309b182f0df47567aeed40ab0e3cfc99d3.1441127976.git.jcody@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E5F493.9060402@redhat.com> Date: Tue, 1 Sep 2015 12:55:15 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <17356f309b182f0df47567aeed40ab0e3cfc99d3.1441127976.git.jcody@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Le0EG7hvEKrp8390Qf1nL9AjvBWqJqgAK" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berrange@redhat.com, qemu-block@nongnu.org, armbru@redhat.com, programmingkidx@gmail.com Subject: Re: [Qemu-block] [RFC PATCH 1/2] util - add automated ID generation utility X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 18:55:26 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Le0EG7hvEKrp8390Qf1nL9AjvBWqJqgAK Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/01/2015 11:23 AM, Jeff Cody wrote: > Multiple sub-systems in QEMU may find it useful to generated IDs > for objects that a user may reference via QMP or HMP. This patch > presents a standardized way to do it, so that automatic ID generation > follows the same rules. >=20 > This patch enforces the following rules when generating an ID: >=20 > 1.) Guarantee no collisions with a user-specified ID > 2.) Identify the sub-system the ID belongs to > 3.) Guarantee of uniqueness > 4.) Spoiling predictibility, to avoid creating an assumption > of object ordering and parsing (i.e., we don't want users to think > they can guess the next ID based on prior behavior). >=20 > The scheme for this is as follows (no spaces): >=20 > # subsys D RR > Reserved char --| | | | > Subsytem String -----| | | s/Subsytem/Subsystem/ > Unique number (64-bit) --| | > Two-digit random number ---| >=20 > For example, a generated node-name for the block sub-system may take th= e > look like this: s/take the// >=20 > #block076 >=20 > The caller of id_generate() is responsible for freeing the generated > node name string with g_free(). >=20 > Signed-off-by: Jeff Cody > --- > include/qemu-common.h | 8 ++++++++ > util/id.c | 35 +++++++++++++++++++++++++++++++++++ > 2 files changed, 43 insertions(+) >=20 > +char *id_generate(IdSubSystems id) > +{ > + const char *id_subsys_str[] =3D { s/id_/const id_/ > + [ID_QDEV] =3D "qdev", > + [ID_BLOCK] =3D "block", > + }; Do we want some sort of compile-time assertion that we have entries for all id values?... > + > + static uint64_t id_counters[ID_MAX]; > + uint32_t rnd; > + > + assert(id < ID_MAX); =2E..maybe in the form of assert(id_subsys_str[id]) > + > + rnd =3D g_random_int_range(0, 99); > + > + return g_strdup_printf("%c%s%" PRIu64 "%" PRId32, ID_SPECIAL_CHAR,= > + id_subsys_str[id= ], > + id_counters[id]+= +, > + rnd); > +} >=20 Looks reasonable to me. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Le0EG7hvEKrp8390Qf1nL9AjvBWqJqgAK Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5fSYAAoJEKeha0olJ0NqaxcH/1c0a3PtbEUWRGcc1i7KeeqI t17EzoduBfNHR9grfeXE98I/K36l5scrO9EomIRt4ik+W1I3+UsDahTlDAaqSJ58 Nw6Mh7v+aVA0O+mZmHyypTKCYikbTvD5HL0DcmHa+MqpJZz7EF1sMb9i6hch+XC+ xSTw9X8B4ZIDOltXpgbTqPEBGRnUgT/Q9AGCAcjBf5NtpddEa0IGy+KFViIDYaux W0VNMH+xLYXDEkeTzTjsDCi7VBVaRN/vb8z/cebiYbEtSTbUiIMupENIMH4hTC0S CSDD2+STDzoKBKoopPgIhu2AKWx3BoWmnR0+BZBB/vk91fs4g3aVMImfbytVIJo= =LIrv -----END PGP SIGNATURE----- --Le0EG7hvEKrp8390Qf1nL9AjvBWqJqgAK-- From MAILER-DAEMON Tue Sep 01 14:57:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWqkW-0004lr-PJ for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 14:57:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWqkU-0004fA-K3 for qemu-block@nongnu.org; Tue, 01 Sep 2015 14:57:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWqkQ-0008Px-Jc for qemu-block@nongnu.org; Tue, 01 Sep 2015 14:57:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWqkQ-0008Ph-EY; Tue, 01 Sep 2015 14:57:34 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id E467CC0AF3DB; Tue, 1 Sep 2015 18:57:33 +0000 (UTC) Received: from [10.3.113.115] (ovpn-113-115.phx2.redhat.com [10.3.113.115]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81IvWqe002549; Tue, 1 Sep 2015 14:57:33 -0400 To: Jeff Cody , qemu-devel@nongnu.org References: From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E5F517.4060306@redhat.com> Date: Tue, 1 Sep 2015 12:57:27 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="22A9O9RrH9egTh23wLbgugOiTLOaXTTQ9" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berrange@redhat.com, qemu-block@nongnu.org, armbru@redhat.com, programmingkidx@gmail.com Subject: Re: [Qemu-block] [RFC PATCH 2/2] block: auto-generated node-names X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 18:57:39 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --22A9O9RrH9egTh23wLbgugOiTLOaXTTQ9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/01/2015 11:23 AM, Jeff Cody wrote: > If a node-name is not specified, automatically generate the node-name. >=20 > Generated node-names will use the "block" sub-system identifier. >=20 > Signed-off-by: Jeff Cody > --- > block.c | 25 ++++++++++++++++--------- > 1 file changed, 16 insertions(+), 9 deletions(-) Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --22A9O9RrH9egTh23wLbgugOiTLOaXTTQ9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5fUXAAoJEKeha0olJ0Nq+joIAKoE80a/mxz6bR8YI0t62o/L XWkk0KXxkqUXVDvAptUdE4SkGNba7wjko5D5INygKs96GjAb/u5VnHpU9wdgpmwO 9sW+ByHBiOmEg4JS4PzfhZqmtn2y1gSmhNAYuc/BNCwZoawLDcxNYI5wpfUoQWP9 EKgBJOyS8h7ATSV2FRUx/qdnfqhb5uK3TsljxCAIYimRMfHSr//gT88Ay94jxuht 0r2KKN0tuIWaChofQWMBB0ek+rS9wEgeX9iDeNC5r6Z+awAdJdRGeipzWsEo5DKY YiyJCokVI5t0CZ1Ggigf5I3mrGnQ5mvnH89Jxt+GBsNJBx5fCPEpE9U7BhK4jCc= =w+jI -----END PGP SIGNATURE----- --22A9O9RrH9egTh23wLbgugOiTLOaXTTQ9-- From MAILER-DAEMON Tue Sep 01 15:14:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWr0M-000150-JH for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 15:14:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWr0J-00011H-SM for qemu-block@nongnu.org; Tue, 01 Sep 2015 15:14:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWr0E-000451-PM for qemu-block@nongnu.org; Tue, 01 Sep 2015 15:13:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWr0E-00044n-Ib; Tue, 01 Sep 2015 15:13:54 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id B49318E910; Tue, 1 Sep 2015 19:13:53 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81JDqbB021186; Tue, 1 Sep 2015 15:13:52 -0400 To: Jeff Cody , qemu-devel@nongnu.org References: <17356f309b182f0df47567aeed40ab0e3cfc99d3.1441127976.git.jcody@redhat.com> From: John Snow X-Enigmail-Draft-Status: N1110 Message-ID: <55E5F8F0.8040405@redhat.com> Date: Tue, 1 Sep 2015 15:13:52 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <17356f309b182f0df47567aeed40ab0e3cfc99d3.1441127976.git.jcody@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, programmingkidx@gmail.com, armbru@redhat.com, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [RFC PATCH 1/2] util - add automated ID generation utility X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 19:14:00 -0000 On 09/01/2015 01:23 PM, Jeff Cody wrote: > Multiple sub-systems in QEMU may find it useful to generated IDs generate > for objects that a user may reference via QMP or HMP. This patch > presents a standardized way to do it, so that automatic ID generation > follows the same rules. > > This patch enforces the following rules when generating an ID: > > 1.) Guarantee no collisions with a user-specified ID > 2.) Identify the sub-system the ID belongs to > 3.) Guarantee of uniqueness > 4.) Spoiling predictibility, to avoid creating an assumption predictability > of object ordering and parsing (i.e., we don't want users to think > they can guess the next ID based on prior behavior). > > The scheme for this is as follows (no spaces): > > # subsys D RR > Reserved char --| | | | > Subsytem String -----| | | Subsystem > Unique number (64-bit) --| | > Two-digit random number ---| > > For example, a generated node-name for the block sub-system may take the > look like this: > "take this form" or "look like this" > #block076 > > The caller of id_generate() is responsible for freeing the generated > node name string with g_free(). > > Signed-off-by: Jeff Cody > --- > include/qemu-common.h | 8 ++++++++ > util/id.c | 35 +++++++++++++++++++++++++++++++++++ > 2 files changed, 43 insertions(+) > > diff --git a/include/qemu-common.h b/include/qemu-common.h > index bbaffd1..f6b0105 100644 > --- a/include/qemu-common.h > +++ b/include/qemu-common.h > @@ -237,6 +237,14 @@ int64_t strtosz_suffix_unit(const char *nptr, char **end, > #define STR_OR_NULL(str) ((str) ? (str) : "null") > > /* id.c */ > + > +typedef enum IdSubSystems { > + ID_QDEV, > + ID_BLOCK, > + ID_MAX /* last element, used as array size */ > +} IdSubSystems; > + > +char *id_generate(IdSubSystems); > bool id_wellformed(const char *id); > > /* path.c */ > diff --git a/util/id.c b/util/id.c > index 09b22fb..48e2935 100644 > --- a/util/id.c > +++ b/util/id.c > @@ -26,3 +26,38 @@ bool id_wellformed(const char *id) > } > return true; > } > + > +#define ID_SPECIAL_CHAR '#' > + > +/* Generates an ID of the form: > + * > + * "#block146", > + * > + * where: > + * - "#" is always the reserved character '#' > + * - "block" refers to the subsystem identifed via IdSubSystems > + * and id_subsys_str[] > + * - "1" is a unique number (up to a uint64_t) for the subsystem, > + * - "46" is a pseudo-random numer to create uniqueness > + * > + * The caller is responsible for freeing the returned string with g_free() > + */ > +char *id_generate(IdSubSystems id) > +{ > + const char *id_subsys_str[] = { > + [ID_QDEV] = "qdev", > + [ID_BLOCK] = "block", > + }; > + Do we want this local to this function? A lookup table may be useful for utilities at some point. > + static uint64_t id_counters[ID_MAX]; > + uint32_t rnd; > + > + assert(id < ID_MAX); > + > + rnd = g_random_int_range(0, 99); > + > + return g_strdup_printf("%c%s%" PRIu64 "%" PRId32, ID_SPECIAL_CHAR, > + id_subsys_str[id], > + id_counters[id]++, > + rnd); > +} > So basically, it's # So we could see: |block|1|32| For the block subsystem, 1st device, salt is 3. But we could also see: |block|13|2| Block subsys, 13th device, salt is 2. Forcing a zero-pad on the salt should be enough to disambiguate in all cases: block132 block1302 This way, the last two digits are *always* salt, making the ID unambiguous and, I think, impossible to collide against regardless of that the rng returns in the future for new IDs. From MAILER-DAEMON Tue Sep 01 15:15:46 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWr22-00033y-C5 for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 15:15:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWr20-00033X-3z for qemu-block@nongnu.org; Tue, 01 Sep 2015 15:15:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWr1v-0005PK-0b for qemu-block@nongnu.org; Tue, 01 Sep 2015 15:15:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38817) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWr1u-0005PG-Rs; Tue, 01 Sep 2015 15:15:38 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 589F2C196504; Tue, 1 Sep 2015 19:15:38 +0000 (UTC) Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81JFaQM020117 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Tue, 1 Sep 2015 15:15:37 -0400 Date: Tue, 1 Sep 2015 15:15:35 -0400 From: Jeff Cody To: Eric Blake Message-ID: <20150901191535.GF2669@localhost.localdomain> References: <17356f309b182f0df47567aeed40ab0e3cfc99d3.1441127976.git.jcody@redhat.com> <55E5F493.9060402@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55E5F493.9060402@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berrange@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, armbru@redhat.com, programmingkidx@gmail.com Subject: Re: [Qemu-block] [RFC PATCH 1/2] util - add automated ID generation utility X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 19:15:45 -0000 On Tue, Sep 01, 2015 at 12:55:15PM -0600, Eric Blake wrote: > On 09/01/2015 11:23 AM, Jeff Cody wrote: > > Multiple sub-systems in QEMU may find it useful to generated IDs > > for objects that a user may reference via QMP or HMP. This patch > > presents a standardized way to do it, so that automatic ID generation > > follows the same rules. > > > > This patch enforces the following rules when generating an ID: > > > > 1.) Guarantee no collisions with a user-specified ID > > 2.) Identify the sub-system the ID belongs to > > 3.) Guarantee of uniqueness > > 4.) Spoiling predictibility, to avoid creating an assumption > > of object ordering and parsing (i.e., we don't want users to think > > they can guess the next ID based on prior behavior). > > > > The scheme for this is as follows (no spaces): > > > > # subsys D RR > > Reserved char --| | | | > > Subsytem String -----| | | > > s/Subsytem/Subsystem/ > > > Unique number (64-bit) --| | > > Two-digit random number ---| > > > > For example, a generated node-name for the block sub-system may take the > > look like this: > > s/take the// > > > > > #block076 > > > > The caller of id_generate() is responsible for freeing the generated > > node name string with g_free(). > > > > Signed-off-by: Jeff Cody > > --- > > include/qemu-common.h | 8 ++++++++ > > util/id.c | 35 +++++++++++++++++++++++++++++++++++ > > 2 files changed, 43 insertions(+) > > > > > +char *id_generate(IdSubSystems id) > > +{ > > + const char *id_subsys_str[] = { > > s/id_/const id_/ > Good point. > > + [ID_QDEV] = "qdev", > > + [ID_BLOCK] = "block", > > + }; > > Do we want some sort of compile-time assertion that we have entries for > all id values?... > > > + > > + static uint64_t id_counters[ID_MAX]; > > + uint32_t rnd; > > + > > + assert(id < ID_MAX); > > ...maybe in the form of assert(id_subsys_str[id]) > Yes, I think we do. If one is missing, that is certainly a mistake, and we run the risk of collisions as well. > > > + > > + rnd = g_random_int_range(0, 99); > > + > > + return g_strdup_printf("%c%s%" PRIu64 "%" PRId32, ID_SPECIAL_CHAR, > > + id_subsys_str[id], > > + id_counters[id]++, > > + rnd); > > +} > > > > Looks reasonable to me. > Thanks -Jeff From MAILER-DAEMON Tue Sep 01 15:25:17 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWrBF-0006Yf-6G for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 15:25:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWrBD-0006YY-Or for qemu-block@nongnu.org; Tue, 01 Sep 2015 15:25:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWrB9-0007Tc-O1 for qemu-block@nongnu.org; Tue, 01 Sep 2015 15:25:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWrB9-0007TM-JJ; Tue, 01 Sep 2015 15:25:11 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 23F29157757; Tue, 1 Sep 2015 19:25:11 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81JPApc017240; Tue, 1 Sep 2015 15:25:10 -0400 To: Jeff Cody , qemu-devel@nongnu.org References: From: John Snow X-Enigmail-Draft-Status: N1110 Message-ID: <55E5FB96.4020401@redhat.com> Date: Tue, 1 Sep 2015 15:25:10 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, programmingkidx@gmail.com, armbru@redhat.com, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [RFC PATCH 2/2] block: auto-generated node-names X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 19:25:16 -0000 On 09/01/2015 01:23 PM, Jeff Cody wrote: > If a node-name is not specified, automatically generate the node-name. > > Generated node-names will use the "block" sub-system identifier. > > Signed-off-by: Jeff Cody > --- > block.c | 25 ++++++++++++++++--------- > 1 file changed, 16 insertions(+), 9 deletions(-) > > diff --git a/block.c b/block.c > index d088ee0..892e127 100644 > --- a/block.c > +++ b/block.c > @@ -771,32 +771,39 @@ static void bdrv_assign_node_name(BlockDriverState *bs, > const char *node_name, > Error **errp) > { > + char *gen_node_name = NULL; > + > if (!node_name) { > - return; > - } > - > - /* Check for empty string or invalid characters */ > - if (!id_wellformed(node_name)) { > - error_setg(errp, "Invalid node name"); > - return; > + gen_node_name = id_generate(ID_BLOCK); > + node_name = gen_node_name; > + } else { > + /* Check for empty string or invalid characters, but not if it is > + * generated (generated names use characters not available to the user) > + * */ > + if (!id_wellformed(node_name)) { > + error_setg(errp, "Invalid node name"); > + return; > + } > } > > /* takes care of avoiding namespaces collisions */ > if (blk_by_name(node_name)) { > error_setg(errp, "node-name=%s is conflicting with a device id", > node_name); > - return; > + goto out; > } > > /* takes care of avoiding duplicates node names */ > if (bdrv_find_node(node_name)) { > error_setg(errp, "Duplicate node name"); > - return; > + goto out; > } > > /* copy node name into the bs and insert it into the graph list */ > pstrcpy(bs->node_name, sizeof(bs->node_name), node_name); > QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list); > +out: > + g_free(gen_node_name); > } > > static QemuOptsList bdrv_runtime_opts = { > Reviewed-by: John Snow From MAILER-DAEMON Tue Sep 01 15:28:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWrEF-0008GH-CY for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 15:28:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWrEC-0008Fa-RF for qemu-block@nongnu.org; Tue, 01 Sep 2015 15:28:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWrE8-0001rE-NK for qemu-block@nongnu.org; Tue, 01 Sep 2015 15:28:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36825) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWrE8-0001qo-Gt; Tue, 01 Sep 2015 15:28:16 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 6B80678; Tue, 1 Sep 2015 19:21:40 +0000 (UTC) Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81JLcS4015606 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Tue, 1 Sep 2015 15:21:39 -0400 Date: Tue, 1 Sep 2015 15:21:37 -0400 From: Jeff Cody To: John Snow Message-ID: <20150901192137.GG2669@localhost.localdomain> References: <17356f309b182f0df47567aeed40ab0e3cfc99d3.1441127976.git.jcody@redhat.com> <55E5F8F0.8040405@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55E5F8F0.8040405@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, programmingkidx@gmail.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, armbru@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [RFC PATCH 1/2] util - add automated ID generation utility X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 19:28:22 -0000 On Tue, Sep 01, 2015 at 03:13:52PM -0400, John Snow wrote: > > > On 09/01/2015 01:23 PM, Jeff Cody wrote: > > Multiple sub-systems in QEMU may find it useful to generated IDs > > generate > > > for objects that a user may reference via QMP or HMP. This patch > > presents a standardized way to do it, so that automatic ID generation > > follows the same rules. > > > > This patch enforces the following rules when generating an ID: > > > > 1.) Guarantee no collisions with a user-specified ID > > 2.) Identify the sub-system the ID belongs to > > 3.) Guarantee of uniqueness > > 4.) Spoiling predictibility, to avoid creating an assumption > > predictability > > > of object ordering and parsing (i.e., we don't want users to think > > they can guess the next ID based on prior behavior). > > > > The scheme for this is as follows (no spaces): > > > > # subsys D RR > > Reserved char --| | | | > > Subsytem String -----| | | > > Subsystem > > > Unique number (64-bit) --| | > > Two-digit random number ---| > > > > For example, a generated node-name for the block sub-system may take the > > look like this: > > > > "take this form" or "look like this" > All I can say is, sometimes my fingers don't obey my brain. > > #block076 > > > > The caller of id_generate() is responsible for freeing the generated > > node name string with g_free(). > > > > Signed-off-by: Jeff Cody > > --- > > include/qemu-common.h | 8 ++++++++ > > util/id.c | 35 +++++++++++++++++++++++++++++++++++ > > 2 files changed, 43 insertions(+) > > > > diff --git a/include/qemu-common.h b/include/qemu-common.h > > index bbaffd1..f6b0105 100644 > > --- a/include/qemu-common.h > > +++ b/include/qemu-common.h > > @@ -237,6 +237,14 @@ int64_t strtosz_suffix_unit(const char *nptr, char **end, > > #define STR_OR_NULL(str) ((str) ? (str) : "null") > > > > /* id.c */ > > + > > +typedef enum IdSubSystems { > > + ID_QDEV, > > + ID_BLOCK, > > + ID_MAX /* last element, used as array size */ > > +} IdSubSystems; > > + > > +char *id_generate(IdSubSystems); > > bool id_wellformed(const char *id); > > > > /* path.c */ > > diff --git a/util/id.c b/util/id.c > > index 09b22fb..48e2935 100644 > > --- a/util/id.c > > +++ b/util/id.c > > @@ -26,3 +26,38 @@ bool id_wellformed(const char *id) > > } > > return true; > > } > > + > > +#define ID_SPECIAL_CHAR '#' > > + > > +/* Generates an ID of the form: > > + * > > + * "#block146", > > + * > > + * where: > > + * - "#" is always the reserved character '#' > > + * - "block" refers to the subsystem identifed via IdSubSystems > > + * and id_subsys_str[] > > + * - "1" is a unique number (up to a uint64_t) for the subsystem, > > + * - "46" is a pseudo-random numer to create uniqueness > > + * > > + * The caller is responsible for freeing the returned string with g_free() > > + */ > > +char *id_generate(IdSubSystems id) > > +{ > > + const char *id_subsys_str[] = { > > + [ID_QDEV] = "qdev", > > + [ID_BLOCK] = "block", > > + }; > > + > > Do we want this local to this function? A lookup table may be useful for > utilities at some point. > Possibly. I'm neutral, we can move it out of the function and make it static. > > + static uint64_t id_counters[ID_MAX]; > > + uint32_t rnd; > > + > > + assert(id < ID_MAX); > > + > > + rnd = g_random_int_range(0, 99); > > + > > + return g_strdup_printf("%c%s%" PRIu64 "%" PRId32, ID_SPECIAL_CHAR, > > + id_subsys_str[id], > > + id_counters[id]++, > > + rnd); > > +} > > > > So basically, it's # > > So we could see: > > |block|1|32| > > For the block subsystem, 1st device, salt is 3. > But we could also see: > > |block|13|2| > > Block subsys, 13th device, salt is 2. > > Forcing a zero-pad on the salt should be enough to disambiguate in all > cases: > > block132 > block1302 > > This way, the last two digits are *always* salt, making the ID > unambiguous and, I think, impossible to collide against regardless of > that the rng returns in the future for new IDs. Yes - that is actually what I meant to do. We definitely want to enforce two digits for the random element. Thanks, Jeff From MAILER-DAEMON Tue Sep 01 16:50:51 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWsW3-00043W-3Z for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 16:50:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWsW0-00041q-Dc for qemu-block@nongnu.org; Tue, 01 Sep 2015 16:50:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWsVx-0004ZH-5m for qemu-block@nongnu.org; Tue, 01 Sep 2015 16:50:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54774) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWsVx-0004Z7-0m; Tue, 01 Sep 2015 16:50:45 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 72395A49F4; Tue, 1 Sep 2015 20:50:44 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81Kog4N007617; Tue, 1 Sep 2015 16:50:43 -0400 From: John Snow To: qemu-block@nongnu.org Date: Tue, 1 Sep 2015 16:50:37 -0400 Message-Id: <1441140641-17631-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com Subject: [Qemu-block] [PATCH 0/4] ahci: clean up signature generation X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 20:50:49 -0000 Ultimately, clean up the signature generation and as a result, tidy up the port_reset and init_d2h functions. ________________________________________________________________________________ For convenience, this branch is available at: https://github.com/jnsnow/qemu.git branch ahci-sigfix https://github.com/jnsnow/qemu/tree/ahci-sigfix This version is tagged ahci-sigfix-v1: https://github.com/jnsnow/qemu/releases/tag/ahci-sigfix-v1 John Snow (4): ahci: remove dead reset code ahci: fix signature generation ahci: remove cmd_fis argument from write_fis_d2h ahci: clean up initial d2h semantics hw/ide/ahci.c | 53 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-) -- 2.4.3 From MAILER-DAEMON Tue Sep 01 16:50:53 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWsW5-00047e-Bp for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 16:50:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWsW1-000423-FC for qemu-block@nongnu.org; Tue, 01 Sep 2015 16:50:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWsW0-0004ao-E3 for qemu-block@nongnu.org; Tue, 01 Sep 2015 16:50:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41943) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWsW0-0004aV-6B; Tue, 01 Sep 2015 16:50:48 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id D2A2E461D3; Tue, 1 Sep 2015 20:50:47 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81Kog4R007617; Tue, 1 Sep 2015 16:50:47 -0400 From: John Snow To: qemu-block@nongnu.org Date: Tue, 1 Sep 2015 16:50:41 -0400 Message-Id: <1441140641-17631-5-git-send-email-jsnow@redhat.com> In-Reply-To: <1441140641-17631-1-git-send-email-jsnow@redhat.com> References: <1441140641-17631-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com Subject: [Qemu-block] [PATCH 4/4] ahci: clean up initial d2h semantics X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 20:50:50 -0000 with write_fis_d2h and signature generation tidied up, let's adjust the initial d2h semantics to make more sense. The initial d2h is considered delivered if there is guest memory to save it to. Signed-off-by: John Snow --- hw/ide/ahci.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index aa605ec..2186801 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -47,7 +47,7 @@ do { \ static void check_cmd(AHCIState *s, int port); static int handle_cmd(AHCIState *s, int port, uint8_t slot); static void ahci_reset_port(AHCIState *s, int port); -static void ahci_write_fis_d2h(AHCIDevice *ad); +static bool ahci_write_fis_d2h(AHCIDevice *ad); static void ahci_init_d2h(AHCIDevice *ad); static int ahci_dma_prepare_buf(IDEDMA *dma, int32_t limit); static void ahci_commit_buf(IDEDMA *dma, uint32_t tx_bytes); @@ -297,7 +297,6 @@ static void ahci_port_write(AHCIState *s, int port, int offset, uint32_t val) if ((pr->cmd & PORT_CMD_FIS_ON) && !s->dev[port].init_d2h_sent) { ahci_init_d2h(&s->dev[port]); - s->dev[port].init_d2h_sent = true; } check_cmd(s, port); @@ -543,14 +542,19 @@ static void ahci_init_d2h(AHCIDevice *ad) IDEState *ide_state = &ad->port.ifs[0]; AHCIPortRegs *pr = &ad->port_regs; - /* We're emulating receiving the first Reg H2D Fis from the device; - * Update the SIG register, but otherwise procede as normal. */ - pr->sig = (ide_state->hcyl << 24) | - (ide_state->lcyl << 16) | - (ide_state->sector << 8) | - (ide_state->nsector & 0xFF); + if (ad->init_d2h_sent) { + return; + } - ahci_write_fis_d2h(ad); + if (ahci_write_fis_d2h(ad)) { + ad->init_d2h_sent = true; + /* We're emulating receiving the first Reg H2D Fis from the device; + * Update the SIG register, but otherwise procede as normal. */ + pr->sig = (ide_state->hcyl << 24) | + (ide_state->lcyl << 16) | + (ide_state->sector << 8) | + (ide_state->nsector & 0xFF); + } } static void ahci_set_signature(AHCIDevice *ad, uint32_t sig) @@ -752,7 +756,7 @@ static void ahci_write_fis_pio(AHCIDevice *ad, uint16_t len) ahci_trigger_irq(ad->hba, ad, PORT_IRQ_PIOS_FIS); } -static void ahci_write_fis_d2h(AHCIDevice *ad) +static bool ahci_write_fis_d2h(AHCIDevice *ad) { AHCIPortRegs *pr = &ad->port_regs; uint8_t *d2h_fis; @@ -760,7 +764,7 @@ static void ahci_write_fis_d2h(AHCIDevice *ad) IDEState *s = &ad->port.ifs[0]; if (!ad->res_fis || !(pr->cmd & PORT_CMD_FIS_RX)) { - return; + return false; } d2h_fis = &ad->res_fis[RES_FIS_RFIS]; @@ -793,6 +797,7 @@ static void ahci_write_fis_d2h(AHCIDevice *ad) } ahci_trigger_irq(ad->hba, ad, PORT_IRQ_D2H_REG_FIS); + return true; } static int prdt_tbl_entry_size(const AHCI_SG *tbl) -- 2.4.3 From MAILER-DAEMON Tue Sep 01 16:50:51 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWsW3-00043t-76 for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 16:50:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWsW0-00041s-ED for qemu-block@nongnu.org; Tue, 01 Sep 2015 16:50:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWsVy-0004Zo-LG for qemu-block@nongnu.org; Tue, 01 Sep 2015 16:50:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63032) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWsVy-0004Zg-Gq; Tue, 01 Sep 2015 16:50:46 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 305AAA49EF; Tue, 1 Sep 2015 20:50:46 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81Kog4P007617; Tue, 1 Sep 2015 16:50:45 -0400 From: John Snow To: qemu-block@nongnu.org Date: Tue, 1 Sep 2015 16:50:39 -0400 Message-Id: <1441140641-17631-3-git-send-email-jsnow@redhat.com> In-Reply-To: <1441140641-17631-1-git-send-email-jsnow@redhat.com> References: <1441140641-17631-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com Subject: [Qemu-block] [PATCH 2/4] ahci: fix signature generation X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 20:50:49 -0000 The initial register device-to-host FIS no longer needs to specially set certain fields, as these can be handled generically by setting those fields explicitly with the signatures we want at port reset time. (1) Signatures are decomposed into their four component registers and set upon (AHCI) port reset. (2) the signature cache register is no longer set manually per-each device type, but instead just once during ahci_init_d2h. Signed-off-by: John Snow --- hw/ide/ahci.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index d04a161..3c50ccb 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -542,20 +542,31 @@ static void ahci_init_d2h(AHCIDevice *ad) { uint8_t init_fis[20]; IDEState *ide_state = &ad->port.ifs[0]; + AHCIPortRegs *pr = &ad->port_regs; memset(init_fis, 0, sizeof(init_fis)); - init_fis[4] = 1; - init_fis[12] = 1; - - if (ide_state->drive_kind == IDE_CD) { - init_fis[5] = ide_state->lcyl; - init_fis[6] = ide_state->hcyl; - } + /* We're emulating receiving the first Reg H2D Fis from the device; + * Update the SIG register, but otherwise procede as normal. */ + pr->sig = (ide_state->hcyl << 24) | + (ide_state->lcyl << 16) | + (ide_state->sector << 8) | + (ide_state->nsector & 0xFF); ahci_write_fis_d2h(ad, init_fis); } +static void ahci_set_signature(AHCIDevice *ad, uint32_t sig) +{ + IDEState *s = &ad->port.ifs[0]; + s->hcyl = sig >> 24 & 0xFF; + s->lcyl = sig >> 16 & 0xFF; + s->sector = sig >> 8 & 0xFF; + s->nsector = sig & 0xFF; + + DPRINTF(ad->port_no, "set hcyl:lcyl:sect:nsect = 0x%08x\n", sig); +} + static void ahci_reset_port(AHCIState *s, int port) { AHCIDevice *d = &s->dev[port]; @@ -605,13 +616,10 @@ static void ahci_reset_port(AHCIState *s, int port) s->dev[port].port_state = STATE_RUN; if (ide_state->drive_kind == IDE_CD) { - pr->sig = SATA_SIGNATURE_CDROM; - ide_state->lcyl = 0x14; - ide_state->hcyl = 0xeb; - DPRINTF(port, "set lcyl = %d\n", ide_state->lcyl); + ahci_set_signature(d, SATA_SIGNATURE_CDROM);\ ide_state->status = SEEK_STAT | WRERR_STAT | READY_STAT; } else { - pr->sig = SATA_SIGNATURE_DISK; + ahci_set_signature(d, SATA_SIGNATURE_DISK); ide_state->status = SEEK_STAT | WRERR_STAT; } -- 2.4.3 From MAILER-DAEMON Tue Sep 01 16:50:51 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWsW2-000439-W6 for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 16:50:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWsW0-00041r-E1 for qemu-block@nongnu.org; Tue, 01 Sep 2015 16:50:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWsVy-0004Za-0Y for qemu-block@nongnu.org; Tue, 01 Sep 2015 16:50:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55213) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWsVx-0004ZP-Rg; Tue, 01 Sep 2015 16:50:45 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 6DD79C0EE053; Tue, 1 Sep 2015 20:50:45 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81Kog4O007617; Tue, 1 Sep 2015 16:50:44 -0400 From: John Snow To: qemu-block@nongnu.org Date: Tue, 1 Sep 2015 16:50:38 -0400 Message-Id: <1441140641-17631-2-git-send-email-jsnow@redhat.com> In-Reply-To: <1441140641-17631-1-git-send-email-jsnow@redhat.com> References: <1441140641-17631-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com Subject: [Qemu-block] [PATCH 1/4] ahci: remove dead reset code X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 20:50:49 -0000 This check is dead due to an earlier conditional. AHCI does not currently support hotplugging, so checks to see if devices are present or not are useless. Remove it. Reported-by: Stefan Hajnoczi Signed-off-by: John Snow --- hw/ide/ahci.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 48749c1..d04a161 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -604,10 +604,7 @@ static void ahci_reset_port(AHCIState *s, int port) } s->dev[port].port_state = STATE_RUN; - if (!ide_state->blk) { - pr->sig = 0; - ide_state->status = SEEK_STAT | WRERR_STAT; - } else if (ide_state->drive_kind == IDE_CD) { + if (ide_state->drive_kind == IDE_CD) { pr->sig = SATA_SIGNATURE_CDROM; ide_state->lcyl = 0x14; ide_state->hcyl = 0xeb; -- 2.4.3 From MAILER-DAEMON Tue Sep 01 16:50:51 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWsW3-00044D-AP for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 16:50:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWsW0-00041t-Jm for qemu-block@nongnu.org; Tue, 01 Sep 2015 16:50:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWsVz-0004aF-JI for qemu-block@nongnu.org; Tue, 01 Sep 2015 16:50:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54782) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWsVz-0004a5-DP; Tue, 01 Sep 2015 16:50:47 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 0D1EBA49EF; Tue, 1 Sep 2015 20:50:47 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81Kog4Q007617; Tue, 1 Sep 2015 16:50:46 -0400 From: John Snow To: qemu-block@nongnu.org Date: Tue, 1 Sep 2015 16:50:40 -0400 Message-Id: <1441140641-17631-4-git-send-email-jsnow@redhat.com> In-Reply-To: <1441140641-17631-1-git-send-email-jsnow@redhat.com> References: <1441140641-17631-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com Subject: [Qemu-block] [PATCH 3/4] ahci: remove cmd_fis argument from write_fis_d2h X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 20:50:49 -0000 It's no longer used. We used to generate a D2H FIS based upon the command FIS that prompted the update, but in reality, the D2H FIS is generated purely from register state. cmd_fis is vestigial, so get rid of it. Signed-off-by: John Snow --- hw/ide/ahci.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 3c50ccb..aa605ec 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -47,7 +47,7 @@ do { \ static void check_cmd(AHCIState *s, int port); static int handle_cmd(AHCIState *s, int port, uint8_t slot); static void ahci_reset_port(AHCIState *s, int port); -static void ahci_write_fis_d2h(AHCIDevice *ad, uint8_t *cmd_fis); +static void ahci_write_fis_d2h(AHCIDevice *ad); static void ahci_init_d2h(AHCIDevice *ad); static int ahci_dma_prepare_buf(IDEDMA *dma, int32_t limit); static void ahci_commit_buf(IDEDMA *dma, uint32_t tx_bytes); @@ -540,12 +540,9 @@ static void ahci_check_cmd_bh(void *opaque) static void ahci_init_d2h(AHCIDevice *ad) { - uint8_t init_fis[20]; IDEState *ide_state = &ad->port.ifs[0]; AHCIPortRegs *pr = &ad->port_regs; - memset(init_fis, 0, sizeof(init_fis)); - /* We're emulating receiving the first Reg H2D Fis from the device; * Update the SIG register, but otherwise procede as normal. */ pr->sig = (ide_state->hcyl << 24) | @@ -553,7 +550,7 @@ static void ahci_init_d2h(AHCIDevice *ad) (ide_state->sector << 8) | (ide_state->nsector & 0xFF); - ahci_write_fis_d2h(ad, init_fis); + ahci_write_fis_d2h(ad); } static void ahci_set_signature(AHCIDevice *ad, uint32_t sig) @@ -755,7 +752,7 @@ static void ahci_write_fis_pio(AHCIDevice *ad, uint16_t len) ahci_trigger_irq(ad->hba, ad, PORT_IRQ_PIOS_FIS); } -static void ahci_write_fis_d2h(AHCIDevice *ad, uint8_t *cmd_fis) +static void ahci_write_fis_d2h(AHCIDevice *ad) { AHCIPortRegs *pr = &ad->port_regs; uint8_t *d2h_fis; @@ -1410,7 +1407,7 @@ static void ahci_cmd_done(IDEDMA *dma) DPRINTF(ad->port_no, "cmd done\n"); /* update d2h status */ - ahci_write_fis_d2h(ad, NULL); + ahci_write_fis_d2h(ad); if (!ad->check_bh) { /* maybe we still have something to process, check later */ -- 2.4.3 From MAILER-DAEMON Tue Sep 01 18:30:25 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWu4P-0003nU-Pw for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 18:30:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWu4N-0003lk-6s for qemu-block@nongnu.org; Tue, 01 Sep 2015 18:30:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWu4L-00033w-Jy for qemu-block@nongnu.org; Tue, 01 Sep 2015 18:30:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51539) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWu4L-00033q-Cq; Tue, 01 Sep 2015 18:30:21 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 21CA2A3039; Tue, 1 Sep 2015 22:30:21 +0000 (UTC) Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81MUJY2014629 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Tue, 1 Sep 2015 18:30:20 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Tue, 1 Sep 2015 18:30:15 -0400 Message-Id: <45295c490f1d7c2c2209a19fba8c656967d03d5b.1441140367.git.jcody@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berrange@redhat.com, qemu-block@nongnu.org, armbru@redhat.com, programmingkidx@gmail.com Subject: [Qemu-block] [PATCH v2 1/2] util - add automated ID generation utility X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 22:30:24 -0000 Multiple sub-systems in QEMU may find it useful to generate IDs for objects that a user may reference via QMP or HMP. This patch presents a standardized way to do it, so that automatic ID generation follows the same rules. This patch enforces the following rules when generating an ID: 1.) Guarantee no collisions with a user-specified ID 2.) Identify the sub-system the ID belongs to 3.) Guarantee of uniqueness 4.) Spoiling predictability, to avoid creating an assumption of object ordering and parsing (i.e., we don't want users to think they can guess the next ID based on prior behavior). The scheme for this is as follows (no spaces): # subsys D RR Reserved char --| | | | Subsystem String ----| | | Unique number (64-bit) --| | Two-digit random number ---| For example, a generated node-name for the block sub-system may look like this: #block076 The caller of id_generate() is responsible for freeing the generated node name string with g_free(). Signed-off-by: Jeff Cody --- include/qemu-common.h | 8 ++++++++ util/id.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/qemu-common.h b/include/qemu-common.h index bbaffd1..f6b0105 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -237,6 +237,14 @@ int64_t strtosz_suffix_unit(const char *nptr, char **end, #define STR_OR_NULL(str) ((str) ? (str) : "null") /* id.c */ + +typedef enum IdSubSystems { + ID_QDEV, + ID_BLOCK, + ID_MAX /* last element, used as array size */ +} IdSubSystems; + +char *id_generate(IdSubSystems); bool id_wellformed(const char *id); /* path.c */ diff --git a/util/id.c b/util/id.c index 09b22fb..9457f2d 100644 --- a/util/id.c +++ b/util/id.c @@ -26,3 +26,39 @@ bool id_wellformed(const char *id) } return true; } + +#define ID_SPECIAL_CHAR '#' + +static const char * const id_subsys_str[] = { + [ID_QDEV] = "qdev", + [ID_BLOCK] = "block", +}; + +/* Generates an ID of the form: + * + * "#block146", + * + * where: + * - "#" is always the reserved character '#' + * - "block" refers to the subsystem identifed via IdSubSystems + * and id_subsys_str[] + * - "1" is a unique number (up to a uint64_t) for the subsystem + * - "46" is a zero-padded two digit pseudo-random number + * + * The caller is responsible for freeing the returned string with g_free() + */ +char *id_generate(IdSubSystems id) +{ + static uint64_t id_counters[ID_MAX]; + uint32_t rnd; + + assert(id < ID_MAX); + assert(id_subsys_str[id]); + + rnd = g_random_int_range(0, 99); + + return g_strdup_printf("%c%s%" PRIu64 "%02" PRId32, ID_SPECIAL_CHAR, + id_subsys_str[id], + id_counters[id]++, + rnd); +} -- 1.9.3 From MAILER-DAEMON Tue Sep 01 18:30:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWu4Q-0003oj-S4 for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 18:30:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWu4P-0003mY-00 for qemu-block@nongnu.org; Tue, 01 Sep 2015 18:30:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWu4O-00034K-5W for qemu-block@nongnu.org; Tue, 01 Sep 2015 18:30:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWu4N-00034D-Vz; Tue, 01 Sep 2015 18:30:24 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id B223AC0EE043; Tue, 1 Sep 2015 22:30:23 +0000 (UTC) Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81MULWx032288 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Tue, 1 Sep 2015 18:30:23 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Tue, 1 Sep 2015 18:30:16 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berrange@redhat.com, qemu-block@nongnu.org, armbru@redhat.com, programmingkidx@gmail.com Subject: [Qemu-block] [PATCH v2 2/2] block: auto-generated node-names X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 22:30:25 -0000 If a node-name is not specified, automatically generate the node-name. Generated node-names will use the "block" sub-system identifier. Reviewed-by: Eric Blake Reviewed-by: John Snow Signed-off-by: Jeff Cody --- block.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/block.c b/block.c index d088ee0..892e127 100644 --- a/block.c +++ b/block.c @@ -771,32 +771,39 @@ static void bdrv_assign_node_name(BlockDriverState *bs, const char *node_name, Error **errp) { + char *gen_node_name = NULL; + if (!node_name) { - return; - } - - /* Check for empty string or invalid characters */ - if (!id_wellformed(node_name)) { - error_setg(errp, "Invalid node name"); - return; + gen_node_name = id_generate(ID_BLOCK); + node_name = gen_node_name; + } else { + /* Check for empty string or invalid characters, but not if it is + * generated (generated names use characters not available to the user) + * */ + if (!id_wellformed(node_name)) { + error_setg(errp, "Invalid node name"); + return; + } } /* takes care of avoiding namespaces collisions */ if (blk_by_name(node_name)) { error_setg(errp, "node-name=%s is conflicting with a device id", node_name); - return; + goto out; } /* takes care of avoiding duplicates node names */ if (bdrv_find_node(node_name)) { error_setg(errp, "Duplicate node name"); - return; + goto out; } /* copy node name into the bs and insert it into the graph list */ pstrcpy(bs->node_name, sizeof(bs->node_name), node_name); QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list); +out: + g_free(gen_node_name); } static QemuOptsList bdrv_runtime_opts = { -- 1.9.3 From MAILER-DAEMON Tue Sep 01 18:30:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWu4S-0003pk-Pt for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 18:30:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWu4N-0003li-6A for qemu-block@nongnu.org; Tue, 01 Sep 2015 18:30:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWu4K-00033l-0e for qemu-block@nongnu.org; Tue, 01 Sep 2015 18:30:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWu4J-00033f-Pm; Tue, 01 Sep 2015 18:30:19 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id BB1758EA26; Tue, 1 Sep 2015 22:30:18 +0000 (UTC) Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81MUGZs015929 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Tue, 1 Sep 2015 18:30:18 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Tue, 1 Sep 2015 18:30:14 -0400 Message-Id: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berrange@redhat.com, qemu-block@nongnu.org, armbru@redhat.com, programmingkidx@gmail.com Subject: [Qemu-block] [PATCH v2 0/2] Auto-generated IDs X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 22:30:27 -0000 Changes from RFC v1: Patch 1: Several typos / grammatical errors (thanks Eric, John) Make id_subsys_str[] const pointer to const strings (thanks Eric) Moved id_subsys_str[] out from id_generate() (thanks John) Assert on null string for given id (thanks Eric) Zero-pad the 2-digit random # (thanks John) Patch 2: None Born from the conversation on qemu-devel, this generation scheme uses the format ultimately proposed by Kevin, after list discussion. It attempts to keep the ID strings as small as possible, while fulfilling: 1.) Guarantee no collisions with a user-specified ID 2.) Identify the sub-system the ID belongs to 3.) Guarantee of uniqueness 4.) Spoiling predictibility, to avoid creating an assumption of object ordering and parsing (i.e., we don't want users to think they can guess the next ID based on prior behavior). See patch 1 for the generation scheme details. Jeff Cody (2): util - add automated ID generation utility block: auto-generated node-names block.c | 25 ++++++++++++++++--------- include/qemu-common.h | 8 ++++++++ util/id.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 9 deletions(-) -- 1.9.3 From MAILER-DAEMON Tue Sep 01 18:55:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWuSe-0004Wr-8m for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 18:55:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWuSb-0004We-Rs for qemu-block@nongnu.org; Tue, 01 Sep 2015 18:55:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWuSY-0006mP-Lq for qemu-block@nongnu.org; Tue, 01 Sep 2015 18:55:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36433) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWuSY-0006mB-Eu; Tue, 01 Sep 2015 18:55:22 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 03C863DD42; Tue, 1 Sep 2015 22:55:22 +0000 (UTC) Received: from [10.3.113.115] (ovpn-113-115.phx2.redhat.com [10.3.113.115]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81MtLQq022653; Tue, 1 Sep 2015 18:55:21 -0400 To: Jeff Cody , qemu-devel@nongnu.org References: <45295c490f1d7c2c2209a19fba8c656967d03d5b.1441140367.git.jcody@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55E62CD4.9060309@redhat.com> Date: Tue, 1 Sep 2015 16:55:16 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <45295c490f1d7c2c2209a19fba8c656967d03d5b.1441140367.git.jcody@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="10HoVKPGStCi0xAiLQ9Cqekruo1278nfl" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berrange@redhat.com, qemu-block@nongnu.org, armbru@redhat.com, programmingkidx@gmail.com Subject: Re: [Qemu-block] [PATCH v2 1/2] util - add automated ID generation utility X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 22:55:27 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --10HoVKPGStCi0xAiLQ9Cqekruo1278nfl Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/01/2015 04:30 PM, Jeff Cody wrote: > Multiple sub-systems in QEMU may find it useful to generate IDs > for objects that a user may reference via QMP or HMP. This patch > presents a standardized way to do it, so that automatic ID generation > follows the same rules. >=20 > This patch enforces the following rules when generating an ID: >=20 > 1.) Guarantee no collisions with a user-specified ID > 2.) Identify the sub-system the ID belongs to > 3.) Guarantee of uniqueness > 4.) Spoiling predictability, to avoid creating an assumption > of object ordering and parsing (i.e., we don't want users to think > they can guess the next ID based on prior behavior). >=20 > The scheme for this is as follows (no spaces): >=20 > # subsys D RR > Reserved char --| | | | > Subsystem String ----| | | > Unique number (64-bit) --| | > Two-digit random number ---| >=20 > For example, a generated node-name for the block sub-system may look > like this: >=20 > #block076 >=20 > The caller of id_generate() is responsible for freeing the generated > node name string with g_free(). >=20 > Signed-off-by: Jeff Cody > --- > include/qemu-common.h | 8 ++++++++ > util/id.c | 36 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 44 insertions(+) Reviewed-by: Eric Blake > + > +static const char * const id_subsys_str[] =3D { > + [ID_QDEV] =3D "qdev", > + [ID_BLOCK] =3D "block", > +}; We're inconsistent on whether there should be a space in '*const' (compare commit a91e211 with b86f461, for example). But since qemu.git has both spellings in various contexts, it's probably not worth changing here. > + > + rnd =3D g_random_int_range(0, 99); Thankfully, g_random_* is a PRNG that is not consuming system entropy (auto-generated names should not be starving /dev/random). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --10HoVKPGStCi0xAiLQ9Cqekruo1278nfl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5izUAAoJEKeha0olJ0NqBJUIAJTFXflBethHpGVh2WbrU7LM gWMk0FMOfhhA4f5V4hvVSB8ArC39UfnhyNLAFd7z/ul6UxtRzXgDrXZPWiyXQjms 9RE3FTubFvVNuPHnRWatCCJlU1B3vtDSQ14jyboVfhlqujAL5EBAlHs5d/jesI5y VSgDyn3geGHrIF4qB3Mx90k2+nO6KAHmujn4dnPYGZgdD+U+9pdpnlDlIrN4dWVo 8hf6YVK14iRhD1i6I6mgpHv3TV1PmY+YXJcPP8OTptArSGElWIXXAgbuhPW/30HA qNemQCSBbn1tFAreW5cKOKOVqFcMAeuJ23CXuQLA679UAgor5QD2cJfCCjeYCYg= =4QDV -----END PGP SIGNATURE----- --10HoVKPGStCi0xAiLQ9Cqekruo1278nfl-- From MAILER-DAEMON Tue Sep 01 20:08:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWvbJ-0006zo-My for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 20:08:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWvbI-0006yo-22 for qemu-block@nongnu.org; Tue, 01 Sep 2015 20:08:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWvbE-0002Dr-Rm for qemu-block@nongnu.org; Tue, 01 Sep 2015 20:08:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59027) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWvbE-0002Dn-MX; Tue, 01 Sep 2015 20:08:24 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 0C635A9F; Wed, 2 Sep 2015 00:08:24 +0000 (UTC) Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8208LQC001138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Tue, 1 Sep 2015 20:08:23 -0400 Date: Tue, 1 Sep 2015 20:08:21 -0400 From: Jeff Cody To: Eric Blake Message-ID: <20150902000821.GH2669@localhost.localdomain> References: <45295c490f1d7c2c2209a19fba8c656967d03d5b.1441140367.git.jcody@redhat.com> <55E62CD4.9060309@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55E62CD4.9060309@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berrange@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, armbru@redhat.com, programmingkidx@gmail.com Subject: Re: [Qemu-block] [PATCH v2 1/2] util - add automated ID generation utility X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 00:08:29 -0000 On Tue, Sep 01, 2015 at 04:55:16PM -0600, Eric Blake wrote: > On 09/01/2015 04:30 PM, Jeff Cody wrote: > > Multiple sub-systems in QEMU may find it useful to generate IDs > > for objects that a user may reference via QMP or HMP. This patch > > presents a standardized way to do it, so that automatic ID generation > > follows the same rules. > > > > This patch enforces the following rules when generating an ID: > > > > 1.) Guarantee no collisions with a user-specified ID > > 2.) Identify the sub-system the ID belongs to > > 3.) Guarantee of uniqueness > > 4.) Spoiling predictability, to avoid creating an assumption > > of object ordering and parsing (i.e., we don't want users to think > > they can guess the next ID based on prior behavior). > > > > The scheme for this is as follows (no spaces): > > > > # subsys D RR > > Reserved char --| | | | > > Subsystem String ----| | | > > Unique number (64-bit) --| | > > Two-digit random number ---| > > > > For example, a generated node-name for the block sub-system may look > > like this: > > > > #block076 > > > > The caller of id_generate() is responsible for freeing the generated > > node name string with g_free(). > > > > Signed-off-by: Jeff Cody > > --- > > include/qemu-common.h | 8 ++++++++ > > util/id.c | 36 ++++++++++++++++++++++++++++++++++++ > > 2 files changed, 44 insertions(+) > > Reviewed-by: Eric Blake > > > + > > +static const char * const id_subsys_str[] = { > > + [ID_QDEV] = "qdev", > > + [ID_BLOCK] = "block", > > +}; > > We're inconsistent on whether there should be a space in '*const' > (compare commit a91e211 with b86f461, for example). But since qemu.git > has both spellings in various contexts, it's probably not worth changing > here. > If this ends up needing another rev, I'll change it for you :) > > + > > + rnd = g_random_int_range(0, 99); > > Thankfully, g_random_* is a PRNG that is not consuming system entropy > (auto-generated names should not be starving /dev/random). > Yup. Thanks, Jeff From MAILER-DAEMON Tue Sep 01 20:13:45 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWvgP-00019x-GP for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 20:13:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWvgN-00019i-15 for qemu-block@nongnu.org; Tue, 01 Sep 2015 20:13:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWvgJ-0003u1-Py for qemu-block@nongnu.org; Tue, 01 Sep 2015 20:13:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47723) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWvgJ-0003tx-I8; Tue, 01 Sep 2015 20:13:39 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id F309E461D3; Wed, 2 Sep 2015 00:13:38 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t820Db1n020503; Tue, 1 Sep 2015 20:13:38 -0400 To: Jeff Cody , qemu-devel@nongnu.org References: <45295c490f1d7c2c2209a19fba8c656967d03d5b.1441140367.git.jcody@redhat.com> From: John Snow Message-ID: <55E63F31.90001@redhat.com> Date: Tue, 1 Sep 2015 20:13:37 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <45295c490f1d7c2c2209a19fba8c656967d03d5b.1441140367.git.jcody@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, programmingkidx@gmail.com, armbru@redhat.com, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 1/2] util - add automated ID generation utility X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 00:13:44 -0000 On 09/01/2015 06:30 PM, Jeff Cody wrote: > Multiple sub-systems in QEMU may find it useful to generate IDs > for objects that a user may reference via QMP or HMP. This patch > presents a standardized way to do it, so that automatic ID generation > follows the same rules. > > This patch enforces the following rules when generating an ID: > > 1.) Guarantee no collisions with a user-specified ID > 2.) Identify the sub-system the ID belongs to > 3.) Guarantee of uniqueness > 4.) Spoiling predictability, to avoid creating an assumption > of object ordering and parsing (i.e., we don't want users to think > they can guess the next ID based on prior behavior). > > The scheme for this is as follows (no spaces): > > # subsys D RR > Reserved char --| | | | > Subsystem String ----| | | > Unique number (64-bit) --| | > Two-digit random number ---| > > For example, a generated node-name for the block sub-system may look > like this: > > #block076 > > The caller of id_generate() is responsible for freeing the generated > node name string with g_free(). > > Signed-off-by: Jeff Cody > --- > include/qemu-common.h | 8 ++++++++ > util/id.c | 36 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 44 insertions(+) > > diff --git a/include/qemu-common.h b/include/qemu-common.h > index bbaffd1..f6b0105 100644 > --- a/include/qemu-common.h > +++ b/include/qemu-common.h > @@ -237,6 +237,14 @@ int64_t strtosz_suffix_unit(const char *nptr, char **end, > #define STR_OR_NULL(str) ((str) ? (str) : "null") > > /* id.c */ > + > +typedef enum IdSubSystems { > + ID_QDEV, > + ID_BLOCK, > + ID_MAX /* last element, used as array size */ > +} IdSubSystems; > + > +char *id_generate(IdSubSystems); > bool id_wellformed(const char *id); > > /* path.c */ > diff --git a/util/id.c b/util/id.c > index 09b22fb..9457f2d 100644 > --- a/util/id.c > +++ b/util/id.c > @@ -26,3 +26,39 @@ bool id_wellformed(const char *id) > } > return true; > } > + > +#define ID_SPECIAL_CHAR '#' > + > +static const char * const id_subsys_str[] = { > + [ID_QDEV] = "qdev", > + [ID_BLOCK] = "block", > +}; > + > +/* Generates an ID of the form: > + * > + * "#block146", > + * > + * where: > + * - "#" is always the reserved character '#' > + * - "block" refers to the subsystem identifed via IdSubSystems > + * and id_subsys_str[] > + * - "1" is a unique number (up to a uint64_t) for the subsystem > + * - "46" is a zero-padded two digit pseudo-random number > + * > + * The caller is responsible for freeing the returned string with g_free() > + */ > +char *id_generate(IdSubSystems id) > +{ > + static uint64_t id_counters[ID_MAX]; > + uint32_t rnd; > + > + assert(id < ID_MAX); > + assert(id_subsys_str[id]); > + > + rnd = g_random_int_range(0, 99); > + > + return g_strdup_printf("%c%s%" PRIu64 "%02" PRId32, ID_SPECIAL_CHAR, > + id_subsys_str[id], > + id_counters[id]++, > + rnd); > +} > Seems good to me. Reviewed-by: John Snow From MAILER-DAEMON Tue Sep 01 21:26:34 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZWwos-0003c5-0h for mharc-qemu-block@gnu.org; Tue, 01 Sep 2015 21:26:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWwop-0003aa-Ab for qemu-block@nongnu.org; Tue, 01 Sep 2015 21:26:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWwol-0008SF-Ad for qemu-block@nongnu.org; Tue, 01 Sep 2015 21:26:31 -0400 Received: from [59.151.112.132] (port=21910 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWwok-0008Re-UC; Tue, 01 Sep 2015 21:26:27 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100259422" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 09:29:27 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t821QDAJ023547; Wed, 2 Sep 2015 09:26:14 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 2 Sep 2015 09:26:22 +0800 To: Eric Blake , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi References: <1439279489-13338-1-git-send-email-wency@cn.fujitsu.com> <1439279489-13338-6-git-send-email-wency@cn.fujitsu.com> <55E4A536.6040905@redhat.com> <55E4F767.1070602@cn.fujitsu.com> <55E5C572.7000606@redhat.com> From: Wen Congyang Message-ID: <55E65026.2050902@cn.fujitsu.com> Date: Wed, 2 Sep 2015 09:25:58 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55E5C572.7000606@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Patch for-2.5 v2 5/6] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 01:26:32 -0000 On 09/01/2015 11:34 PM, Eric Blake wrote: > On 08/31/2015 06:55 PM, Wen Congyang wrote: > >>>> +This command is still a work in progress. It doesn't support all >>>> +block drivers. Stay away from it unless you want it to help with >>>> +its development. >>> >>> Maybe we should name it 'x-child-add' for now, so that we aren't baking >>> ourselves into a corner. >> >> Do you mean the command name should be x-child-add? It is OK. > > Use of the 'x-' prefix means a command is experimental and may change or > be withdrawn. It gives us a way to test if an interface is useful > without committing to that interface long term. We've still got time > before 2.5 to get blockdev-add working everywhere, in which case I think > we are better off using blockdev-add to create a new unattached BDS and > then have this command pass the node name to be made the new child, > rather than all the options for opening the child from scratch. > Good idea. The unattached BDS created by the command blockdev-add always have BB. So it may be used by the device created by the command device_add later. So I think we should have an API to check it. What about the following patches? http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg01591.html http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg01590.html Thanks Wen Congyang From MAILER-DAEMON Wed Sep 02 02:35:59 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX1eJ-0005Kx-6d for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 02:35:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX1eG-0005HD-Cq for qemu-block@nongnu.org; Wed, 02 Sep 2015 02:35:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX1eF-0002gM-J6 for qemu-block@nongnu.org; Wed, 02 Sep 2015 02:35:56 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:16530 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX1eB-0002e0-6V; Wed, 02 Sep 2015 02:35:51 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BzBQBfmOZV/5tjdVtdGQEBAYJ/gT2qLQEBAQEBAQUBgQuaaQKBQTwQAQEBAQEBAYEKhCQBAQMBOj8FCwsOEyUPASwbBgESiCYMAclXAQEBAQEBAQMBAQEBAR2GLIVChQsHhCwBBIxwiFOnYSaEATwzgk0BAQE X-IPAS-Result: A2BzBQBfmOZV/5tjdVtdGQEBAYJ/gT2qLQEBAQEBAQUBgQuaaQKBQTwQAQEBAQEBAYEKhCQBAQMBOj8FCwsOEyUPASwbBgESiCYMAclXAQEBAQEBAQMBAQEBAR2GLIVChQsHhCwBBIxwiFOnYSaEATwzgk0BAQE X-IronPort-AV: E=Sophos;i="5.17,451,1437429600"; d="scan'208";a="14825973" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 02 Sep 2015 08:35:38 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZX1dy-0001OU-01; Wed, 02 Sep 2015 08:35:38 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZX1dx-00086k-Pj; Wed, 02 Sep 2015 08:35:37 +0200 From: Alberto Garcia To: Jeff Cody , qemu-devel@nongnu.org In-Reply-To: <45295c490f1d7c2c2209a19fba8c656967d03d5b.1441140367.git.jcody@redhat.com> References: <45295c490f1d7c2c2209a19fba8c656967d03d5b.1441140367.git.jcody@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Wed, 02 Sep 2015 08:35:37 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, programmingkidx@gmail.com, berrange@redhat.com, armbru@redhat.com, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 1/2] util - add automated ID generation utility X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 06:35:57 -0000 On Wed 02 Sep 2015 12:30:15 AM CEST, Jeff Cody wrote: > Multiple sub-systems in QEMU may find it useful to generate IDs > for objects that a user may reference via QMP or HMP. This patch > presents a standardized way to do it, so that automatic ID generation > follows the same rules. > + > +typedef enum IdSubSystems { > + ID_QDEV, > + ID_BLOCK, > + ID_MAX /* last element, used as array size */ > +} IdSubSystems; > + > +char *id_generate(IdSubSystems); Not that it matters much, but it seems that everywhere else in the QEMU source code the rule is to name the parameters in function prototypes. Otherwise, the patch looks good! Reviewed-by: Alberto Garcia Berto From MAILER-DAEMON Wed Sep 02 03:04:59 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX26N-0003D6-6y for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 03:04:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX26K-0003BN-1n for qemu-block@nongnu.org; Wed, 02 Sep 2015 03:04:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX26G-0003nT-Rh for qemu-block@nongnu.org; Wed, 02 Sep 2015 03:04:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55227) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX26G-0003nN-NK; Wed, 02 Sep 2015 03:04:52 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 1C54AAA0A1; Wed, 2 Sep 2015 07:04:52 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8274och003754 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 2 Sep 2015 03:04:51 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 93373303F90E; Wed, 2 Sep 2015 09:04:49 +0200 (CEST) From: Markus Armbruster To: Kevin Wolf References: <457103c2204e849aea3b83ffd78fad049d8d923d.1441014844.git.berto@igalia.com> <55E4B0CC.6070906@redhat.com> <55E4B374.70800@redhat.com> <20150901113111.GB4304@noname.redhat.com> <20150901144002.GF4304@noname.redhat.com> Date: Wed, 02 Sep 2015 09:04:49 +0200 In-Reply-To: <20150901144002.GF4304@noname.redhat.com> (Kevin Wolf's message of "Tue, 1 Sep 2015 16:40:02 +0200") Message-ID: <87r3mh5mjy.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 1/1] block: Allow passing BlockdevOptions to blockdev-snapshot-sync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 07:04:57 -0000 Kevin Wolf writes: > Am 01.09.2015 um 16:22 hat Alberto Garcia geschrieben: [...] >> Would you then prefer me to create a new command instead of extending >> the existing one? What would be the benefit (other than a better name)? > > A clean interface. There is really little overlap with what we have: > > { 'struct': 'BlockdevSnapshot', > 'data': { '*device': 'str', '*node-name': 'str', > 'snapshot-file': 'str', '*snapshot-node-name': 'str', > '*format': 'str', '*mode': 'NewImageMode' } } > > When you add an existing node which has been created with blockdev-add > as a snapshot, you won't use snapshot-file, snapshot-node-name, format > and mode. We would either have to make all of them optional and actually > forbid them when a reference is given, or to ensure that they are > consistent with the already existing node. That we have both device and > node-name (and both marked as optional, while one of them is required) is > also not in line with our current practise. > > If we went further that way, the schema wouldn't really be expressive > any more because there would be too many hidden rules of which > combinations are allowed and which aren't. Yes, and let me elaborate a bit. QMP permits evolving stuff compatibly. We use this capability to keep things simple and short when we add functionality: we extend existing stuff instead of duplicating and modifying it. Say, add detail to a query result, or add an optional command parameter that modifies behavior. The question to ask is whether the single, extended interface is still simpler than a new interface plus the unchanged old one. I expect introspection to influence our understanding of "simple interface" going forward. Stuff visible in introspection is usually simple. Rules of use introspection can't show are often problematic. [...] From MAILER-DAEMON Wed Sep 02 04:52:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3m9-0007cg-GW for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m5-0007Vf-5A for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3m4-0004TL-2V for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:08 -0400 Received: from [59.151.112.132] (port=26837 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3lz-0004Bl-9q; Wed, 02 Sep 2015 04:52:03 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276461" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:54:57 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828picK020264; Wed, 2 Sep 2015 16:51:44 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:51:52 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:05 +0800 Message-ID: <1441183880-26993-2-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Yang Hongyang Subject: [Qemu-block] [PATCH 01/16] introduce a new API to enable/disable attach device model X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:10 -0000 Signed-off-by: Wen Congyang --- block/block-backend.c | 24 ++++++++++++++++++++++++ include/sysemu/block-backend.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index aee8a12..72d8b2c 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -344,6 +344,30 @@ void *blk_get_attached_dev(BlockBackend *blk) } /* + * Disable to attach a device mode to @blk. + * Return 0 on success, -EBUSY when a device model is attached already. + */ +int blk_disable_attach_dev(BlockBackend *blk) +{ + if (blk->dev) { + return blk->dev == (void *)-1 ? 0 : -EBUSY; + } + + blk->dev = (void *)-1; + return 0; +} + +/* + * Enable to attach a device mode to @blk. + */ +void blk_enable_attach_dev(BlockBackend *blk) +{ + if (blk->dev == (void *)-1) { + blk->dev = NULL; + } +} + +/* * Set @blk's device model callbacks to @ops. * @opaque is the opaque argument to pass to the callbacks. * This is for use by device models. diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 8fc960f..7619a9f 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -80,6 +80,8 @@ int blk_attach_dev(BlockBackend *blk, void *dev); void blk_attach_dev_nofail(BlockBackend *blk, void *dev); void blk_detach_dev(BlockBackend *blk, void *dev); void *blk_get_attached_dev(BlockBackend *blk); +int blk_disable_attach_dev(BlockBackend *blk); +void blk_enable_attach_dev(BlockBackend *blk); void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void *opaque); int blk_read(BlockBackend *blk, int64_t sector_num, uint8_t *buf, int nb_sectors); -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:16 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3mB-0007hY-Se for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m5-0007WB-U6 for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3m4-0004To-Lp for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:09 -0400 Received: from [59.151.112.132] (port=26837 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m1-0004Bl-9R; Wed, 02 Sep 2015 04:52:06 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276467" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:54:59 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828pk29020274; Wed, 2 Sep 2015 16:51:46 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:51:55 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:07 +0800 Message-ID: <1441183880-26993-4-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH 03/16] allow writing to the backing file X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:11 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block.c | 41 ++++++++++++++++++++++++++++++++++++++++- qapi/block-core.json | 7 ++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index aeb365b..d02d9e9 100644 --- a/block.c +++ b/block.c @@ -747,6 +747,15 @@ static const BdrvChildRole child_backing = { .inherit_flags = bdrv_backing_flags, }; +static int bdrv_backing_rw_flags(int flags) +{ + return bdrv_backing_flags(flags) | BDRV_O_RDWR; +} + +static const BdrvChildRole child_backing_rw = { + .inherit_flags = bdrv_backing_rw_flags, +}; + static int bdrv_open_flags(BlockDriverState *bs, int flags) { int open_flags = flags | BDRV_O_CACHE_WB; @@ -1169,6 +1178,20 @@ out: bdrv_refresh_limits(bs, NULL); } +#define ALLOW_WRITE_BACKING_FILE "allow-write-backing-file" +static QemuOptsList backing_file_opts = { + .name = "backing_file", + .head = QTAILQ_HEAD_INITIALIZER(backing_file_opts.head), + .desc = { + { + .name = ALLOW_WRITE_BACKING_FILE, + .type = QEMU_OPT_BOOL, + .help = "allow write to backing file", + }, + { /* end of list */ } + }, +}; + /* * Opens the backing file for a BlockDriverState if not yet open * @@ -1183,6 +1206,9 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) int ret = 0; BlockDriverState *backing_hd; Error *local_err = NULL; + QemuOpts *opts = NULL; + bool child_rw = false; + const BdrvChildRole *child_role = NULL; if (bs->backing_hd != NULL) { QDECREF(options); @@ -1195,6 +1221,18 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) } bs->open_flags &= ~BDRV_O_NO_BACKING; + + opts = qemu_opts_create(&backing_file_opts, NULL, 0, &error_abort); + qemu_opts_absorb_qdict(opts, options, &local_err); + if (local_err) { + ret = -EINVAL; + error_propagate(errp, local_err); + QDECREF(options); + goto free_exit; + } + child_rw = qemu_opt_get_bool(opts, ALLOW_WRITE_BACKING_FILE, false); + child_role = child_rw ? &child_backing_rw : &child_backing; + if (qdict_haskey(options, "file.filename")) { backing_filename[0] = '\0'; } else if (bs->backing_file[0] == '\0' && qdict_size(options) == 0) { @@ -1227,7 +1265,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) assert(bs->backing_hd == NULL); ret = bdrv_open_inherit(&backing_hd, *backing_filename ? backing_filename : NULL, - NULL, options, 0, bs, &child_backing, + NULL, options, 0, bs, child_role, NULL, &local_err); if (ret < 0) { bdrv_unref(backing_hd); @@ -1242,6 +1280,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) bdrv_set_backing_hd(bs, backing_hd); free_exit: + qemu_opts_del(opts); g_free(backing_filename); return ret; } diff --git a/qapi/block-core.json b/qapi/block-core.json index 50292b9..bf141a2 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1408,6 +1408,10 @@ # @detect-zeroes: #optional detect and optimize zero writes (Since 2.1) # (default: off) # +# @allow-write-backing-file: #optional whether the backing file is opened in +# read-write mode. It is only for backing file +# (Since 2.5 default: false) +# # Since: 1.7 ## { 'struct': 'BlockdevOptionsBase', @@ -1420,7 +1424,8 @@ '*rerror': 'BlockdevOnError', '*werror': 'BlockdevOnError', '*read-only': 'bool', - '*detect-zeroes': 'BlockdevDetectZeroesOptions' } } + '*detect-zeroes': 'BlockdevDetectZeroesOptions', + '*allow-write-backing-file': 'bool' } } ## # @BlockdevOptionsFile -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:20 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3mG-0007oE-1y for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m6-0007Xm-SN for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3m5-0004U3-Gx for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:10 -0400 Received: from [59.151.112.132] (port=2317 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m2-0004EK-AH; Wed, 02 Sep 2015 04:52:06 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276469" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:55:01 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828pldA020278; Wed, 2 Sep 2015 16:51:48 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:51:56 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:08 +0800 Message-ID: <1441183880-26993-5-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH 04/16] block: Allow references for backing files X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:12 -0000 Usage: -drive file=xxx,id=Y, \ -drive file=xxxx,id=X,backing.backing_reference=Y It will create such backing chain: {virtio-blk dev 'Y'} {virtio-blk dev 'X'} | | | | v v [base] <- [mid] <- ( Y ) <----------------- ( X ) Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block.c | 39 +++++++++++++++++++++++++++++++++++---- include/block/block.h | 1 + 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index d02d9e9..f93c50d 100644 --- a/block.c +++ b/block.c @@ -1179,6 +1179,7 @@ out: } #define ALLOW_WRITE_BACKING_FILE "allow-write-backing-file" +#define BACKING_REFERENCE "backing_reference" static QemuOptsList backing_file_opts = { .name = "backing_file", .head = QTAILQ_HEAD_INITIALIZER(backing_file_opts.head), @@ -1188,6 +1189,11 @@ static QemuOptsList backing_file_opts = { .type = QEMU_OPT_BOOL, .help = "allow write to backing file", }, + { + .name = BACKING_REFERENCE, + .type = QEMU_OPT_STRING, + .help = "reference to the exsiting BDS", + }, { /* end of list */ } }, }; @@ -1204,11 +1210,12 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) { char *backing_filename = g_malloc0(PATH_MAX); int ret = 0; - BlockDriverState *backing_hd; + BlockDriverState *backing_hd = NULL; Error *local_err = NULL; QemuOpts *opts = NULL; bool child_rw = false; const BdrvChildRole *child_role = NULL; + const char *reference = NULL; if (bs->backing_hd != NULL) { QDECREF(options); @@ -1231,9 +1238,10 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) goto free_exit; } child_rw = qemu_opt_get_bool(opts, ALLOW_WRITE_BACKING_FILE, false); + reference = qemu_opt_get(opts, BACKING_REFERENCE); child_role = child_rw ? &child_backing_rw : &child_backing; - if (qdict_haskey(options, "file.filename")) { + if (qdict_haskey(options, "file.filename") || reference) { backing_filename[0] = '\0'; } else if (bs->backing_file[0] == '\0' && qdict_size(options) == 0) { QDECREF(options); @@ -1256,7 +1264,9 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) goto free_exit; } - backing_hd = bdrv_new(); + if (!reference) { + backing_hd = bdrv_new(); + } if (bs->backing_format[0] != '\0' && !qdict_haskey(options, "driver")) { qdict_put(options, "driver", qstring_from_str(bs->backing_format)); @@ -1265,7 +1275,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) assert(bs->backing_hd == NULL); ret = bdrv_open_inherit(&backing_hd, *backing_filename ? backing_filename : NULL, - NULL, options, 0, bs, child_role, + reference, options, 0, bs, child_role, NULL, &local_err); if (ret < 0) { bdrv_unref(backing_hd); @@ -1276,6 +1286,19 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) error_free(local_err); goto free_exit; } + if (reference) { + if (bdrv_op_is_blocked(backing_hd, BLOCK_OP_TYPE_BACKING_REFERENCE, + errp)) { + ret = -EBUSY; + goto free_reference_exit; + } + if (backing_hd->blk && blk_disable_attach_dev(backing_hd->blk)) { + error_setg(errp, "backing_hd %s is used by the other device model", + reference); + ret = -EBUSY; + goto free_reference_exit; + } + } bdrv_set_backing_hd(bs, backing_hd); @@ -1283,6 +1306,11 @@ free_exit: qemu_opts_del(opts); g_free(backing_filename); return ret; + +free_reference_exit: + bdrv_unref(backing_hd); + bs->open_flags |= BDRV_O_NO_BACKING; + goto free_exit; } /* @@ -1947,6 +1975,9 @@ void bdrv_close(BlockDriverState *bs) if (bs->backing_hd) { BlockDriverState *backing_hd = bs->backing_hd; bdrv_set_backing_hd(bs, NULL); + if (backing_hd->blk) { + blk_enable_attach_dev(backing_hd->blk); + } bdrv_unref(backing_hd); } diff --git a/include/block/block.h b/include/block/block.h index 612dcad..5812716 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -170,6 +170,7 @@ typedef enum BlockOpType { BLOCK_OP_TYPE_RESIZE, BLOCK_OP_TYPE_STREAM, BLOCK_OP_TYPE_REPLACE, + BLOCK_OP_TYPE_BACKING_REFERENCE, BLOCK_OP_TYPE_MAX, } BlockOpType; -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:24 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3mK-0007vv-8X for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m5-0007WF-VZ for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3m4-0004Tc-Fg for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:09 -0400 Received: from [59.151.112.132] (port=8817 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m0-00047B-Bb; Wed, 02 Sep 2015 04:52:05 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276459" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:54:56 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828pghQ020260; Wed, 2 Sep 2015 16:51:42 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:51:51 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:04 +0800 Message-ID: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Yang Hongyang Subject: [Qemu-block] [PATCH 00/16] Block replication for continuous checkpoints X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:14 -0000 Block replication is a very important feature which is used for continuous checkpoints(for example: COLO). You can the detailed information about block replication from here: http://wiki.qemu.org/Features/BlockReplication Usage: Please refer to docs/block-replication.txt You can get the patch here: https://github.com/coloft/qemu/tree/wency/block-replication-v9 You can get the patch with framework here: https://github.com/coloft/qemu/commits/colo-v2.0-periodic-mode TODO: 1. Continuous block replication. It will be started after basic functions are accepted. Changs Log: V9: 1. Update the error messages 2. Rebase to the newest qemu 3. Split child add/delete support. These patches are sent in another patchset. V8: 1. Address Alberto Garcia's comments V7: 1. Implement adding/removing quorum child. Remove the option non-connect. 2. Simplify the backing refrence option according to Stefan Hajnoczi's suggestion V6: 1. Rebase to the newest qemu. V5: 1. Address the comments from Gong Lei 2. Speed the failover up. The secondary vm can take over very quickly even if there are too many I/O requests. V4: 1. Introduce a new driver replication to avoid touch nbd and qcow2. V3: 1: use error_setg() instead of error_set() 2. Add a new block job API 3. Active disk, hidden disk and nbd target uses the same AioContext 4. Add a testcase to test new hbitmap API V2: 1. Redesign the secondary qemu(use image-fleecing) 2. Use Error objects to return error message 3. Address the comments from Max Reitz and Eric Blake Wen Congyang (16): introduce a new API to enable/disable attach device model introduce a new API to check if blk is attached allow writing to the backing file block: Allow references for backing files introduce a new API qemu_opts_absorb_qdict_by_index() quorum: allow ignoring child errors Backup: clear all bitmap when doing block checkpoint block: make bdrv_put_ref_bh_schedule() as a public API Allow creating backup jobs when opening BDS docs: block replication's description Add new block driver interfaces to control block replication skip nbd_target when starting block replication quorum: implement block driver interfaces for block replication Implement new driver for block replication support replication driver in blockdev-add Add a new API to start/stop replication, do checkpoint to all BDSes block.c | 230 +++++++++++++++++++- block/Makefile.objs | 3 +- block/backup.c | 14 ++ block/block-backend.c | 33 +++ block/quorum.c | 171 ++++++++++++++- block/replication.c | 471 +++++++++++++++++++++++++++++++++++++++++ blockdev.c | 37 +--- blockjob.c | 11 + docs/block-replication.txt | 183 ++++++++++++++++ include/block/block.h | 11 + include/block/block_int.h | 14 ++ include/block/blockjob.h | 12 ++ include/qemu/option.h | 2 + include/sysemu/block-backend.h | 3 + qapi/block-core.json | 43 +++- util/qemu-option.c | 44 ++++ 16 files changed, 1234 insertions(+), 48 deletions(-) create mode 100644 block/replication.c create mode 100644 docs/block-replication.txt -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3mO-00084j-Vj for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m8-0007bL-DB for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3m7-0004Vr-8x for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:12 -0400 Received: from [59.151.112.132] (port=2317 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m0-0004EK-K0; Wed, 02 Sep 2015 04:52:05 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276463" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:54:58 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828pjdU020268; Wed, 2 Sep 2015 16:51:45 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:51:54 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:06 +0800 Message-ID: <1441183880-26993-3-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Yang Hongyang Subject: [Qemu-block] [PATCH 02/16] introduce a new API to check if blk is attached X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:16 -0000 Signed-off-by: Wen Congyang --- block.c | 4 ++-- block/block-backend.c | 9 +++++++++ include/sysemu/block-backend.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index 0f9029b..aeb365b 100644 --- a/block.c +++ b/block.c @@ -2089,7 +2089,7 @@ void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old) } /* bs_new must be unattached and shouldn't have anything fancy enabled */ - assert(!bs_new->blk); + assert(!blk_is_attached(bs_new->blk)); assert(QLIST_EMPTY(&bs_new->dirty_bitmaps)); assert(bs_new->job == NULL); assert(bs_new->io_limits_enabled == false); @@ -2106,7 +2106,7 @@ void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old) bdrv_move_feature_fields(bs_new, &tmp); /* bs_new must remain unattached */ - assert(!bs_new->blk); + assert(!blk_is_attached(bs_new->blk)); /* Check a few fields that should remain attached to the device */ assert(bs_new->job == NULL); diff --git a/block/block-backend.c b/block/block-backend.c index 72d8b2c..1463c37 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -368,6 +368,15 @@ void blk_enable_attach_dev(BlockBackend *blk) } /* + * Return true if a device model is attached to @blk already, + * otherwise, return false. + */ +bool blk_is_attached(BlockBackend *blk) +{ + return blk != NULL && blk->dev != NULL && blk->dev != (void *)-1; +} + +/* * Set @blk's device model callbacks to @ops. * @opaque is the opaque argument to pass to the callbacks. * This is for use by device models. diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 7619a9f..a8c6fd2 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -82,6 +82,7 @@ void blk_detach_dev(BlockBackend *blk, void *dev); void *blk_get_attached_dev(BlockBackend *blk); int blk_disable_attach_dev(BlockBackend *blk); void blk_enable_attach_dev(BlockBackend *blk); +bool blk_is_attached(BlockBackend *blk); void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void *opaque); int blk_read(BlockBackend *blk, int64_t sector_num, uint8_t *buf, int nb_sectors); -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3mP-00085p-Ib for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m9-0007cB-8R for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3m7-0004WH-U2 for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:13 -0400 Received: from [59.151.112.132] (port=8817 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m4-00047B-CS; Wed, 02 Sep 2015 04:52:09 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276470" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:55:02 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828pnar020281; Wed, 2 Sep 2015 16:51:49 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:51:58 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:09 +0800 Message-ID: <1441183880-26993-6-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH 05/16] introduce a new API qemu_opts_absorb_qdict_by_index() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:16 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- include/qemu/option.h | 2 ++ util/qemu-option.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/include/qemu/option.h b/include/qemu/option.h index 57e51c9..725a781 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -129,6 +129,8 @@ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict, Error **errp); QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict); void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp); +void qemu_opts_absorb_qdict_by_index(QemuOpts *opts, QDict *qdict, + const char *index, Error **errp); typedef int (*qemu_opts_loopfunc)(void *opaque, QemuOpts *opts, Error **errp); int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, diff --git a/util/qemu-option.c b/util/qemu-option.c index efe9d27..a93a269 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -1021,6 +1021,50 @@ void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp) } /* + * Adds all QDict entries to the QemuOpts that can be added and removes them + * from the QDict. The key starts with "%index." in the %qdict. When this + * function returns, the QDict contains only those entries that couldn't be + * added to the QemuOpts. + */ +void qemu_opts_absorb_qdict_by_index(QemuOpts *opts, QDict *qdict, + const char *index, Error **errp) +{ + const QDictEntry *entry, *next; + const char *key; + int len = strlen(index); + + entry = qdict_first(qdict); + + while (entry != NULL) { + Error *local_err = NULL; + OptsFromQDictState state = { + .errp = &local_err, + .opts = opts, + }; + + next = qdict_next(qdict, entry); + if (strncmp(entry->key, index, len) || *(entry->key + len) != '.') { + entry = next; + continue; + } + + key = entry->key + len + 1; + + if (find_desc_by_name(opts->list->desc, key)) { + qemu_opts_from_qdict_1(key, entry->value, &state); + if (local_err) { + error_propagate(errp, local_err); + return; + } else { + qdict_del(qdict, entry->key); + } + } + + entry = next; + } +} + +/* * Convert from QemuOpts to QDict. * The QDict values are of type QString. * TODO We'll want to use types appropriate for opt->desc->type, but -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3mQ-00087l-OI for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3mB-0007gp-JZ for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3m8-0004WS-AK for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:15 -0400 Received: from [59.151.112.132] (port=26837 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m5-0004Bl-7a; Wed, 02 Sep 2015 04:52:09 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276475" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:55:06 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828pr2P020290; Wed, 2 Sep 2015 16:51:53 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:52:01 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:12 +0800 Message-ID: <1441183880-26993-9-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Yang Hongyang Subject: [Qemu-block] [PATCH 08/16] block: make bdrv_put_ref_bh_schedule() as a public API X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:17 -0000 Signed-off-by: Wen Congyang --- block.c | 25 +++++++++++++++++++++++++ blockdev.c | 37 ++++++------------------------------- include/block/block.h | 1 + 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/block.c b/block.c index f93c50d..5119e1e 100644 --- a/block.c +++ b/block.c @@ -3688,6 +3688,31 @@ void bdrv_unref(BlockDriverState *bs) } } +typedef struct { + QEMUBH *bh; + BlockDriverState *bs; +} BDRVPutRefBH; + +static void bdrv_put_ref_bh(void *opaque) +{ + BDRVPutRefBH *s = opaque; + + bdrv_unref(s->bs); + qemu_bh_delete(s->bh); + g_free(s); +} + +/* Release a BDS reference in a BH */ +void bdrv_put_ref_bh_schedule(BlockDriverState *bs) +{ + BDRVPutRefBH *s; + + s = g_new(BDRVPutRefBH, 1); + s->bh = qemu_bh_new(bdrv_put_ref_bh, s); + s->bs = bs; + qemu_bh_schedule(s->bh); +} + struct BdrvOpBlocker { Error *reason; QLIST_ENTRY(BdrvOpBlocker) list; diff --git a/blockdev.c b/blockdev.c index 09e9639..bb9ffae 100644 --- a/blockdev.c +++ b/blockdev.c @@ -276,37 +276,6 @@ static void bdrv_format_print(void *opaque, const char *name) error_printf(" %s", name); } -typedef struct { - QEMUBH *bh; - BlockDriverState *bs; -} BDRVPutRefBH; - -static void bdrv_put_ref_bh(void *opaque) -{ - BDRVPutRefBH *s = opaque; - - bdrv_unref(s->bs); - qemu_bh_delete(s->bh); - g_free(s); -} - -/* - * Release a BDS reference in a BH - * - * It is not safe to use bdrv_unref() from a callback function when the callers - * still need the BlockDriverState. In such cases we schedule a BH to release - * the reference. - */ -static void bdrv_put_ref_bh_schedule(BlockDriverState *bs) -{ - BDRVPutRefBH *s; - - s = g_new(BDRVPutRefBH, 1); - s->bh = qemu_bh_new(bdrv_put_ref_bh, s); - s->bs = bs; - qemu_bh_schedule(s->bh); -} - static int parse_block_error_action(const char *buf, bool is_read, Error **errp) { if (!strcmp(buf, "ignore")) { @@ -2329,6 +2298,12 @@ static void block_job_cb(void *opaque, int ret) block_job_event_completed(bs->job, msg); } + + /* + * It is not safe to use bdrv_unref() from a callback function when the + * callers still need the BlockDriverState. In such cases we schedule + * a BH to release the reference. + */ bdrv_put_ref_bh_schedule(bs); } diff --git a/include/block/block.h b/include/block/block.h index 5812716..98c8509 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -519,6 +519,7 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs); void bdrv_ref(BlockDriverState *bs); void bdrv_unref(BlockDriverState *bs); void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child); +void bdrv_put_ref_bh_schedule(BlockDriverState *bs); bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp); void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason); -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:32 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3mR-0008AO-Qh for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3mD-0007if-0Y for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3mB-0004Xl-Lf for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:16 -0400 Received: from [59.151.112.132] (port=2317 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m7-0004EK-0e; Wed, 02 Sep 2015 04:52:11 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276484" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:55:11 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828pw1j020305; Wed, 2 Sep 2015 16:51:58 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:52:07 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:16 +0800 Message-ID: <1441183880-26993-13-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH 12/16] skip nbd_target when starting block replication X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:18 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/block.c b/block.c index c7670d2..50f3532 100644 --- a/block.c +++ b/block.c @@ -4396,6 +4396,10 @@ void bdrv_start_replication(BlockDriverState *bs, ReplicationMode mode, { BlockDriver *drv = bs->drv; + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKING_REFERENCE, NULL)) { + return; + } + if (drv && drv->bdrv_start_replication) { drv->bdrv_start_replication(bs, mode, errp); } else if (bs->file) { @@ -4410,6 +4414,10 @@ void bdrv_do_checkpoint(BlockDriverState *bs, Error **errp) { BlockDriver *drv = bs->drv; + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKING_REFERENCE, NULL)) { + return; + } + if (drv && drv->bdrv_do_checkpoint) { drv->bdrv_do_checkpoint(bs, errp); } else if (bs->file) { @@ -4424,6 +4432,10 @@ void bdrv_stop_replication(BlockDriverState *bs, bool failover, Error **errp) { BlockDriver *drv = bs->drv; + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKING_REFERENCE, NULL)) { + return; + } + if (drv && drv->bdrv_stop_replication) { drv->bdrv_stop_replication(bs, failover, errp); } else if (bs->file) { -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:24 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3mK-0007wN-H4 for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50628) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m9-0007cF-91 for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3m7-0004W2-H7 for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:13 -0400 Received: from [59.151.112.132] (port=26837 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m3-0004Bl-HW; Wed, 02 Sep 2015 04:52:08 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276472" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:55:03 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828poR3020284; Wed, 2 Sep 2015 16:51:50 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:51:59 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:10 +0800 Message-ID: <1441183880-26993-7-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH 06/16] quorum: allow ignoring child errors X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:16 -0000 If the child is not ready, read/write/getlength/flush will return -errno. It is not critical error, and can be ignored: 1. read/write: Just not report the error event. 2. getlength: just ignore it. If all children's getlength return -errno, and be ignored, return -EIO. 3. flush: Just ignore it. If all children's getlength return -errno, and be ignored, return 0. Usage: children.x.ignore-errors=true Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Cc: Alberto Garcia --- block/quorum.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++---- qapi/block-core.json | 5 ++- 2 files changed, 91 insertions(+), 8 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index 8059861..f23dbb7 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -30,6 +30,7 @@ #define QUORUM_OPT_BLKVERIFY "blkverify" #define QUORUM_OPT_REWRITE "rewrite-corrupted" #define QUORUM_OPT_READ_PATTERN "read-pattern" +#define QUORUM_CHILDREN_OPT_IGNORE_ERRORS "ignore-errors" /* This union holds a vote hash value */ typedef union QuorumVoteValue { @@ -65,6 +66,7 @@ typedef struct QuorumVotes { /* the following structure holds the state of one quorum instance */ typedef struct BDRVQuorumState { BlockDriverState **bs; /* children BlockDriverStates */ + bool *ignore_errors; /* ignore children's error? */ int num_children; /* children count */ int max_children; /* The maximum children count, we need to reallocate * bs if num_children will larger than maximum. @@ -100,6 +102,7 @@ typedef struct QuorumChildRequest { uint8_t *buf; int ret; QuorumAIOCB *parent; + int index; } QuorumChildRequest; /* Quorum will use the following structure to track progress of each read/write @@ -212,6 +215,7 @@ static QuorumAIOCB *quorum_aio_get(BDRVQuorumState *s, acb->qcrs[i].buf = NULL; acb->qcrs[i].ret = 0; acb->qcrs[i].parent = acb; + acb->qcrs[i].index = i; } return acb; @@ -305,7 +309,7 @@ static void quorum_aio_cb(void *opaque, int ret) acb->count++; if (ret == 0) { acb->success_count++; - } else { + } else if (!s->ignore_errors[sacb->index]) { quorum_report_bad(acb, sacb->aiocb->bs->node_name, ret); } assert(acb->count <= s->num_children); @@ -716,19 +720,31 @@ static BlockAIOCB *quorum_aio_writev(BlockDriverState *bs, static int64_t quorum_getlength(BlockDriverState *bs) { BDRVQuorumState *s = bs->opaque; - int64_t result; + int64_t result = -EIO; int i; /* check that all file have the same length */ - result = bdrv_getlength(s->bs[0]); - if (result < 0) { - return result; - } - for (i = 1; i < s->num_children; i++) { + for (i = 0; i < s->num_children; i++) { int64_t value = bdrv_getlength(s->bs[i]); + if (value < 0) { return value; } + + if (value == 0 && s->ignore_errors[i]) { + /* + * If the child is not ready, it cannot return -errno, + * otherwise refresh_total_sectors() will fail when + * we open the child. + */ + continue; + } + + if (result == -EIO) { + result = value; + continue; + } + if (value != result) { return -EIO; } @@ -766,6 +782,9 @@ static coroutine_fn int quorum_co_flush(BlockDriverState *bs) for (i = 0; i < s->num_children; i++) { result = bdrv_co_flush(s->bs[i]); + if (result < 0 && s->ignore_errors[i]) { + result = 0; + } result_value.l = result; quorum_count_vote(&error_votes, &result_value, i); } @@ -840,6 +859,19 @@ static QemuOptsList quorum_runtime_opts = { }, }; +static QemuOptsList quorum_children_common_opts = { + .name = "quorum children", + .head = QTAILQ_HEAD_INITIALIZER(quorum_children_common_opts.head), + .desc = { + { + .name = QUORUM_CHILDREN_OPT_IGNORE_ERRORS, + .type = QEMU_OPT_BOOL, + .help = "ignore child I/O error", + }, + { /* end of list */ } + }, +}; + static int parse_read_pattern(const char *opt) { int i; @@ -858,6 +890,37 @@ static int parse_read_pattern(const char *opt) return -EINVAL; } +static int parse_children_options(BDRVQuorumState *s, QDict *options, + const char *indexstr, int index, + Error **errp) +{ + QemuOpts *children_opts = NULL; + Error *local_err = NULL; + int ret = 0; + bool value; + + children_opts = qemu_opts_create(&quorum_children_common_opts, NULL, 0, + &error_abort); + qemu_opts_absorb_qdict_by_index(children_opts, options, indexstr, + &local_err); + if (local_err) { + ret = -EINVAL; + goto out; + } + + value = qemu_opt_get_bool(children_opts, QUORUM_CHILDREN_OPT_IGNORE_ERRORS, + false); + s->ignore_errors[index] = value; + +out: + qemu_opts_del(children_opts); + /* propagate error */ + if (local_err) { + error_propagate(errp, local_err); + } + return ret; +} + static int quorum_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { @@ -929,12 +992,18 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, s->bs = g_new0(BlockDriverState *, s->num_children); opened = g_new0(bool, s->num_children); s->max_children = s->num_children; + s->ignore_errors = g_new0(bool, s->num_children); for (i = 0; i < s->num_children; i++) { char indexstr[32]; ret = snprintf(indexstr, 32, "children.%d", i); assert(ret < 32); + ret = parse_children_options(s, options, indexstr, i, &local_err); + if (ret < 0) { + goto close_exit; + } + ret = bdrv_open_image(&s->bs[i], NULL, options, indexstr, bs, &child_format, false, &local_err); if (ret < 0) { @@ -976,6 +1045,7 @@ static void quorum_close(BlockDriverState *bs) } g_free(s->bs); + g_free(s->ignore_errors); } static void quorum_detach_aio_context(BlockDriverState *bs) @@ -1014,10 +1084,18 @@ static void quorum_add_child(BlockDriverState *bs, QDict *options, Error **errp) } s->bs = g_renew(BlockDriverState *, s->bs, s->max_children + 1); + s->ignore_errors = g_renew(bool, s->ignore_errors, s->max_children + 1); s->bs[s->num_children] = NULL; s->max_children += 1; } + ret = parse_children_options(s, options, "child", s->num_children, + &local_err); + if (ret < 0) { + error_propagate(errp, local_err); + return; + } + ret = bdrv_open_image(&s->bs[s->num_children], NULL, options, "child", bs, &child_format, false, &local_err); if (ret < 0) { @@ -1058,6 +1136,8 @@ static void quorum_del_child(BlockDriverState *bs, BlockDriverState *child_bs, bdrv_drain(bs); /* We can safely remove this child now */ memmove(&s->bs[i], &s->bs[i+1], (s->num_children - i - 1) * sizeof(void *)); + memmove(&s->ignore_errors[i], &s->ignore_errors[i+1], + (s->num_children - i - 1) * sizeof(bool)); s->num_children--; s->bs[s->num_children] = NULL; bdrv_unref(child_bs); diff --git a/qapi/block-core.json b/qapi/block-core.json index bf141a2..24099ef 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1411,6 +1411,8 @@ # @allow-write-backing-file: #optional whether the backing file is opened in # read-write mode. It is only for backing file # (Since 2.5 default: false) +# @ignore-errors: #options whether the child's I/O error should be ignored. +# it is only for quorum's child.(Since 2.5 default: false) # # Since: 1.7 ## @@ -1425,7 +1427,8 @@ '*werror': 'BlockdevOnError', '*read-only': 'bool', '*detect-zeroes': 'BlockdevDetectZeroesOptions', - '*allow-write-backing-file': 'bool' } } + '*allow-write-backing-file': 'bool', + '*ignore-errors': 'bool' } } ## # @BlockdevOptionsFile -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:32 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3mS-0008Cj-L8 for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3mE-0007ko-C5 for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3mC-0004YP-Vu for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:18 -0400 Received: from [59.151.112.132] (port=2317 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m8-0004EK-Co; Wed, 02 Sep 2015 04:52:13 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276486" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:55:13 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828q0Jq020309; Wed, 2 Sep 2015 16:52:00 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:52:08 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:17 +0800 Message-ID: <1441183880-26993-14-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH 13/16] quorum: implement block driver interfaces for block replication X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:19 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Reviewed-by: Alberto Garcia --- block/quorum.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index f23dbb7..5c00f0c 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -87,6 +87,8 @@ typedef struct BDRVQuorumState { */ QuorumReadPattern read_pattern; + + int replication_index; /* store which child supports block replication */ } BDRVQuorumState; typedef struct QuorumAIOCB QuorumAIOCB; @@ -1014,6 +1016,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, } g_free(opened); + s->replication_index = -1; goto exit; close_exit: @@ -1176,6 +1179,76 @@ static void quorum_refresh_filename(BlockDriverState *bs) bs->full_open_options = opts; } +static void quorum_start_replication(BlockDriverState *bs, ReplicationMode mode, + Error **errp) +{ + BDRVQuorumState *s = bs->opaque; + int count = 0, i, index; + Error *local_err = NULL; + + /* + * TODO: support REPLICATION_MODE_SECONDARY if we allow secondary + * QEMU becoming primary QEMU. + */ + if (mode != REPLICATION_MODE_PRIMARY) { + error_setg(errp, "The replication mode for quorum should be 'primary'"); + return; + } + + if (s->read_pattern != QUORUM_READ_PATTERN_FIFO) { + error_setg(errp, "Block replication needs read pattern 'fifo'"); + return; + } + + for (i = 0; i < s->num_children; i++) { + bdrv_start_replication(s->bs[i], mode, &local_err); + if (local_err) { + error_free(local_err); + local_err = NULL; + } else { + count++; + index = i; + } + } + + if (count == 0) { + error_setg(errp, "No child supports block replication"); + } else if (count > 1) { + for (i = 0; i < s->num_children; i++) { + bdrv_stop_replication(s->bs[i], false, NULL); + } + error_setg(errp, "Too many children support block replication"); + } else { + s->replication_index = index; + } +} + +static void quorum_do_checkpoint(BlockDriverState *bs, Error **errp) +{ + BDRVQuorumState *s = bs->opaque; + + if (s->replication_index < 0) { + error_setg(errp, "Block replication is not running"); + return; + } + + bdrv_do_checkpoint(s->bs[s->replication_index], errp); +} + +static void quorum_stop_replication(BlockDriverState *bs, bool failover, + Error **errp) +{ + BDRVQuorumState *s = bs->opaque; + + if (s->replication_index < 0) { + error_setg(errp, "Block replication is not running"); + return; + } + + bdrv_stop_replication(s->bs[s->replication_index], failover, errp); + s->replication_index = -1; +} + static BlockDriver bdrv_quorum = { .format_name = "quorum", .protocol_name = "quorum", @@ -1202,6 +1275,10 @@ static BlockDriver bdrv_quorum = { .is_filter = true, .bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter, + + .bdrv_start_replication = quorum_start_replication, + .bdrv_do_checkpoint = quorum_do_checkpoint, + .bdrv_stop_replication = quorum_stop_replication, }; static void bdrv_quorum_init(void) -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:36 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3mV-0008Ib-L7 for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3mG-0007pA-W3 for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3mB-0004Xz-U5 for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:20 -0400 Received: from [59.151.112.132] (port=26837 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m6-0004Bl-KU; Wed, 02 Sep 2015 04:52:10 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276480" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:55:10 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828pvoA020302; Wed, 2 Sep 2015 16:51:57 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:52:06 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:15 +0800 Message-ID: <1441183880-26993-12-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Luiz Capitulino , Gonglei , Yang Hongyang , Michael Roth , zhanghailiang Subject: [Qemu-block] [PATCH 11/16] Add new block driver interfaces to control block replication X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:22 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Cc: Luiz Capitulino Cc: Michael Roth Reviewed-by: Paolo Bonzini --- block.c | 43 +++++++++++++++++++++++++++++++++++++++++++ include/block/block.h | 5 +++++ include/block/block_int.h | 14 ++++++++++++++ qapi/block-core.json | 15 +++++++++++++++ 4 files changed, 77 insertions(+) diff --git a/block.c b/block.c index 5119e1e..c7670d2 100644 --- a/block.c +++ b/block.c @@ -4390,3 +4390,46 @@ void bdrv_del_child(BlockDriverState *bs, BlockDriverState *child_bs, bs->drv->bdrv_del_child(bs, child_bs, errp); } + +void bdrv_start_replication(BlockDriverState *bs, ReplicationMode mode, + Error **errp) +{ + BlockDriver *drv = bs->drv; + + if (drv && drv->bdrv_start_replication) { + drv->bdrv_start_replication(bs, mode, errp); + } else if (bs->file) { + bdrv_start_replication(bs->file, mode, errp); + } else { + error_setg(errp, "The BDS %s doesn't support starting block" + " replication", bs->filename); + } +} + +void bdrv_do_checkpoint(BlockDriverState *bs, Error **errp) +{ + BlockDriver *drv = bs->drv; + + if (drv && drv->bdrv_do_checkpoint) { + drv->bdrv_do_checkpoint(bs, errp); + } else if (bs->file) { + bdrv_do_checkpoint(bs->file, errp); + } else { + error_setg(errp, "The BDS %s doesn't support block checkpoint", + bs->filename); + } +} + +void bdrv_stop_replication(BlockDriverState *bs, bool failover, Error **errp) +{ + BlockDriver *drv = bs->drv; + + if (drv && drv->bdrv_stop_replication) { + drv->bdrv_stop_replication(bs, failover, errp); + } else if (bs->file) { + bdrv_stop_replication(bs->file, failover, errp); + } else { + error_setg(errp, "The BDS %s doesn't support stopping block" + " replication", bs->filename); + } +} diff --git a/include/block/block.h b/include/block/block.h index 98c8509..192a066 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -626,4 +626,9 @@ void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp); void bdrv_del_child(BlockDriverState *bs, BlockDriverState *child, Error **errp); +void bdrv_start_replication(BlockDriverState *bs, ReplicationMode mode, + Error **errp); +void bdrv_do_checkpoint(BlockDriverState *bs, Error **errp); +void bdrv_stop_replication(BlockDriverState *bs, bool failover, Error **errp); + #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index b6f2905..1c2d310 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -293,6 +293,20 @@ struct BlockDriver { void (*bdrv_del_child)(BlockDriverState *bs, BlockDriverState *child, Error **errp); + void (*bdrv_start_replication)(BlockDriverState *bs, ReplicationMode mode, + Error **errp); + /* Drop Disk buffer when doing checkpoint. */ + void (*bdrv_do_checkpoint)(BlockDriverState *bs, Error **errp); + /* + * After failover, we should flush Disk buffer into secondary disk + * and stop block replication. + * + * If the guest is shutdown, we should drop Disk buffer and stop + * block representation. + */ + void (*bdrv_stop_replication)(BlockDriverState *bs, bool failover, + Error **errp); + QLIST_ENTRY(BlockDriver) list; }; diff --git a/qapi/block-core.json b/qapi/block-core.json index 24099ef..96f0530 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1810,6 +1810,21 @@ 'data': { '*export': 'str' } } ## +# @ReplicationMode +# +# An enumeration of replication modes. +# +# @unprotected: Replication is not started or after failover. +# +# @primary: Primary mode, the vm's state will be sent to secondary QEMU. +# +# @secondary: Secondary mode, receive the vm's state from primary QEMU. +# +# Since: 2.4 +## +{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] } + +## # @BlockdevOptions # # Options for creating a block device. -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3mO-00084I-Pf for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m8-0007bP-Du for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3m7-0004Vi-4t for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:12 -0400 Received: from [59.151.112.132] (port=2317 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m4-0004EK-4y; Wed, 02 Sep 2015 04:52:08 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276473" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:55:05 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828pppA020287; Wed, 2 Sep 2015 16:51:51 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:52:00 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:11 +0800 Message-ID: <1441183880-26993-8-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH 07/16] Backup: clear all bitmap when doing block checkpoint X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:16 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Cc: Jeff Cody --- block/backup.c | 14 ++++++++++++++ blockjob.c | 11 +++++++++++ include/block/blockjob.h | 12 ++++++++++++ 3 files changed, 37 insertions(+) diff --git a/block/backup.c b/block/backup.c index b729c4b..59bdb79 100644 --- a/block/backup.c +++ b/block/backup.c @@ -217,11 +217,25 @@ static void backup_iostatus_reset(BlockJob *job) bdrv_iostatus_reset(s->target); } +static void backup_do_checkpoint(BlockJob *job, Error **errp) +{ + BackupBlockJob *backup_job = container_of(job, BackupBlockJob, common); + + if (backup_job->sync_mode != MIRROR_SYNC_MODE_NONE) { + error_setg(errp, "The backup job only supports block checkpoint in" + " sync=none mode"); + return; + } + + hbitmap_reset_all(backup_job->bitmap); +} + static const BlockJobDriver backup_job_driver = { .instance_size = sizeof(BackupBlockJob), .job_type = BLOCK_JOB_TYPE_BACKUP, .set_speed = backup_set_speed, .iostatus_reset = backup_iostatus_reset, + .do_checkpoint = backup_do_checkpoint, }; static BlockErrorAction backup_error_action(BackupBlockJob *job, diff --git a/blockjob.c b/blockjob.c index 62bb906..5528d92 100644 --- a/blockjob.c +++ b/blockjob.c @@ -404,3 +404,14 @@ void block_job_defer_to_main_loop(BlockJob *job, qemu_bh_schedule(data->bh); } + +void block_job_do_checkpoint(BlockJob *job, Error **errp) +{ + if (!job->driver->do_checkpoint) { + error_setg(errp, "The job %s doesn't support block checkpoint", + BlockJobType_lookup[job->driver->job_type]); + return; + } + + job->driver->do_checkpoint(job, errp); +} diff --git a/include/block/blockjob.h b/include/block/blockjob.h index dd9d5e6..0b4f386 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -50,6 +50,9 @@ typedef struct BlockJobDriver { * manually. */ void (*complete)(BlockJob *job, Error **errp); + + /** Optional callback for job types that support checkpoint. */ + void (*do_checkpoint)(BlockJob *job, Error **errp); } BlockJobDriver; /** @@ -356,4 +359,13 @@ void block_job_defer_to_main_loop(BlockJob *job, BlockJobDeferToMainLoopFn *fn, void *opaque); +/** + * block_job_do_checkpoint: + * @job: The job. + * @errp: Error object. + * + * Do block checkpoint on the specified job. + */ +void block_job_do_checkpoint(BlockJob *job, Error **errp); + #endif -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3ma-0008Ob-5g for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3mL-0007xr-6T for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3mH-0004Zp-VY for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:25 -0400 Received: from [59.151.112.132] (port=26837 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3mF-0004Bl-Kg; Wed, 02 Sep 2015 04:52:19 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276492" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:55:18 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828q442020327; Wed, 2 Sep 2015 16:52:04 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:52:13 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:20 +0800 Message-ID: <1441183880-26993-17-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH 16/16] Add a new API to start/stop replication, do checkpoint to all BDSes X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:26 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/block/block.h | 4 +++ 2 files changed, 72 insertions(+) diff --git a/block.c b/block.c index 50f3532..1e019bf 100644 --- a/block.c +++ b/block.c @@ -4445,3 +4445,71 @@ void bdrv_stop_replication(BlockDriverState *bs, bool failover, Error **errp) " replication", bs->filename); } } + +void bdrv_start_replication_all(ReplicationMode mode, Error **errp) +{ + BlockDriverState *bs = NULL, *temp = NULL; + Error *local_err = NULL; + + while ((bs = bdrv_next(bs))) { + if (bdrv_is_read_only(bs) || !bdrv_is_inserted(bs)) { + continue; + } + + bdrv_start_replication(bs, mode, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto fail; + } + } + + return; + +fail: + while ((temp = bdrv_next(temp)) && bs != temp) { + bdrv_stop_replication(temp, false, NULL); + } +} + +void bdrv_do_checkpoint_all(Error **errp) +{ + BlockDriverState *bs = NULL; + Error *local_err = NULL; + + while ((bs = bdrv_next(bs))) { + if (bdrv_is_read_only(bs) || !bdrv_is_inserted(bs)) { + continue; + } + + bdrv_do_checkpoint(bs, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + } +} + +void bdrv_stop_replication_all(bool failover, Error **errp) +{ + BlockDriverState *bs = NULL; + Error *local_err = NULL; + + while ((bs = bdrv_next(bs))) { + if (bdrv_is_read_only(bs) || !bdrv_is_inserted(bs)) { + continue; + } + + bdrv_stop_replication(bs, failover, &local_err); + if (!errp) { + /* + * The caller doesn't care the result, they just + * want to stop all block's replication. + */ + continue; + } + if (local_err) { + error_propagate(errp, local_err); + return; + } + } +} diff --git a/include/block/block.h b/include/block/block.h index 192a066..2aa4376 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -631,4 +631,8 @@ void bdrv_start_replication(BlockDriverState *bs, ReplicationMode mode, void bdrv_do_checkpoint(BlockDriverState *bs, Error **errp); void bdrv_stop_replication(BlockDriverState *bs, bool failover, Error **errp); +void bdrv_start_replication_all(ReplicationMode mode, Error **errp); +void bdrv_do_checkpoint_all(Error **errp); +void bdrv_stop_replication_all(bool failover, Error **errp); + #endif -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:33 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3mS-0008DE-TU for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3mF-0007n1-9h for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3mE-0004Yq-CD for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:19 -0400 Received: from [59.151.112.132] (port=2317 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3mB-0004EK-Kz; Wed, 02 Sep 2015 04:52:15 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276491" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:55:16 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828q29A020320; Wed, 2 Sep 2015 16:52:02 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:52:11 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:19 +0800 Message-ID: <1441183880-26993-16-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Yang Hongyang Subject: [Qemu-block] [PATCH 15/16] support replication driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:20 -0000 Signed-off-by: Wen Congyang --- qapi/block-core.json | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 96f0530..86275e3 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1383,7 +1383,7 @@ 'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device', 'host_floppy', 'http', 'https', 'null-aio', 'null-co', 'parallels', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx', - 'vmdk', 'vpc', 'vvfat', 'nbd' ] } + 'vmdk', 'vpc', 'vvfat', 'nbd', 'replication' ] } ## # @BlockdevOptionsBase @@ -1825,6 +1825,19 @@ { 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] } ## +# @BlockdevOptionsReplication +# +# Driver specific block device options for replication +# +# @mode: the replication mode +# +# Since: 2.5 +## +{ 'struct': 'BlockdevOptionsReplication', + 'base': 'BlockdevOptionsGenericFormat', + 'data': { 'mode': 'ReplicationMode' } } + +## # @BlockdevOptions # # Options for creating a block device. @@ -1869,7 +1882,8 @@ 'vhdx': 'BlockdevOptionsGenericFormat', 'vmdk': 'BlockdevOptionsGenericCOWFormat', 'vpc': 'BlockdevOptionsGenericFormat', - 'vvfat': 'BlockdevOptionsVVFAT' + 'vvfat': 'BlockdevOptionsVVFAT', + 'replication':'BlockdevOptionsReplication' } } ## -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3mP-000858-9x for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m9-0007cA-8U for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3m7-0004WC-Sh for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:12 -0400 Received: from [59.151.112.132] (port=2317 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m5-0004EK-IP; Wed, 02 Sep 2015 04:52:09 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276478" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:55:07 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828psYc020295; Wed, 2 Sep 2015 16:51:54 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:52:03 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:13 +0800 Message-ID: <1441183880-26993-10-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH 09/16] Allow creating backup jobs when opening BDS X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:16 -0000 When opening BDS, we need to create backup jobs for image-fleecing. Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Cc: Jeff Cody Reviewed-by: Stefan Hajnoczi --- block/Makefile.objs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/Makefile.objs b/block/Makefile.objs index 58ef2ef..fa05f37 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -22,10 +22,10 @@ block-obj-$(CONFIG_ARCHIPELAGO) += archipelago.o block-obj-$(CONFIG_LIBSSH2) += ssh.o block-obj-y += accounting.o block-obj-y += write-threshold.o +block-obj-y += backup.o common-obj-y += stream.o common-obj-y += commit.o -common-obj-y += backup.o iscsi.o-cflags := $(LIBISCSI_CFLAGS) iscsi.o-libs := $(LIBISCSI_LIBS) -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3ma-0008P5-Bz for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3mL-0007xp-6A for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3mI-0004Zv-6g for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:25 -0400 Received: from [59.151.112.132] (port=26837 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3mA-0004Bl-0t; Wed, 02 Sep 2015 04:52:18 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276489" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:55:14 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828q1MU020313; Wed, 2 Sep 2015 16:52:01 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:52:10 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:18 +0800 Message-ID: <1441183880-26993-15-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH 14/16] Implement new driver for block replication X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:27 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block/Makefile.objs | 1 + block/replication.c | 471 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 472 insertions(+) create mode 100644 block/replication.c diff --git a/block/Makefile.objs b/block/Makefile.objs index fa05f37..94c1d03 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -23,6 +23,7 @@ block-obj-$(CONFIG_LIBSSH2) += ssh.o block-obj-y += accounting.o block-obj-y += write-threshold.o block-obj-y += backup.o +block-obj-y += replication.o common-obj-y += stream.o common-obj-y += commit.o diff --git a/block/replication.c b/block/replication.c new file mode 100644 index 0000000..813f610 --- /dev/null +++ b/block/replication.c @@ -0,0 +1,471 @@ +/* + * Replication Block filter + * + * Copyright (c) 2015 HUAWEI TECHNOLOGIES CO., LTD. + * Copyright (c) 2015 Intel Corporation + * Copyright (c) 2015 FUJITSU LIMITED + * + * Author: + * Wen Congyang + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu-common.h" +#include "block/block_int.h" +#include "block/blockjob.h" +#include "block/nbd.h" + +typedef struct BDRVReplicationState { + ReplicationMode mode; + int replication_state; + BlockDriverState *active_disk; + BlockDriverState *hidden_disk; + BlockDriverState *secondary_disk; + int error; +} BDRVReplicationState; + +enum { + BLOCK_REPLICATION_NONE, /* block replication is not started */ + BLOCK_REPLICATION_RUNNING, /* block replication is running */ + BLOCK_REPLICATION_DONE, /* block replication is done(failover) */ +}; + +#define COMMIT_CLUSTER_BITS 16 +#define COMMIT_CLUSTER_SIZE (1 << COMMIT_CLUSTER_BITS) +#define COMMIT_SECTORS_PER_CLUSTER (COMMIT_CLUSTER_SIZE / BDRV_SECTOR_SIZE) + +static void replication_stop(BlockDriverState *bs, bool failover, Error **errp); + +#define REPLICATION_MODE "mode" +static QemuOptsList replication_runtime_opts = { + .name = "replication", + .head = QTAILQ_HEAD_INITIALIZER(replication_runtime_opts.head), + .desc = { + { + .name = REPLICATION_MODE, + .type = QEMU_OPT_STRING, + }, + { /* end of list */ } + }, +}; + +static int replication_open(BlockDriverState *bs, QDict *options, + int flags, Error **errp) +{ + int ret; + BDRVReplicationState *s = bs->opaque;; + Error *local_err = NULL; + QemuOpts *opts = NULL; + const char *mode; + + ret = -EINVAL; + opts = qemu_opts_create(&replication_runtime_opts, NULL, 0, &error_abort); + qemu_opts_absorb_qdict(opts, options, &local_err); + if (local_err) { + goto fail; + } + + mode = qemu_opt_get(opts, REPLICATION_MODE); + if (!mode) { + error_setg(&local_err, "Missing the option mode"); + goto fail; + } + + if (!strcmp(mode, "primary")) { + s->mode = REPLICATION_MODE_PRIMARY; + } else if (!strcmp(mode, "secondary")) { + s->mode = REPLICATION_MODE_SECONDARY; + } else { + error_setg(&local_err, + "The option mode's value should be primary or secondary"); + goto fail; + } + + ret = 0; + +fail: + qemu_opts_del(opts); + /* propagate error */ + if (local_err) { + error_propagate(errp, local_err); + } + return ret; +} + +static void replication_close(BlockDriverState *bs) +{ + BDRVReplicationState *s = bs->opaque; + + if (s->replication_state == BLOCK_REPLICATION_RUNNING) { + replication_stop(bs, false, NULL); + } +} + +static int64_t replication_getlength(BlockDriverState *bs) +{ + return bdrv_getlength(bs->file); +} + +static int replication_get_io_status(BDRVReplicationState *s) +{ + switch (s->replication_state) { + case BLOCK_REPLICATION_NONE: + return -EIO; + case BLOCK_REPLICATION_RUNNING: + return 0; + case BLOCK_REPLICATION_DONE: + return s->mode == REPLICATION_MODE_PRIMARY ? -EIO : 1; + default: + abort(); + } +} + +static int replication_return_value(BDRVReplicationState *s, int ret) +{ + if (s->mode == REPLICATION_MODE_SECONDARY) { + return ret; + } + + if (ret < 0) { + s->error = ret; + ret = 0; + } + + return ret; +} + +static coroutine_fn int replication_co_readv(BlockDriverState *bs, + int64_t sector_num, + int remaining_sectors, + QEMUIOVector *qiov) +{ + BDRVReplicationState *s = bs->opaque; + int ret; + + if (s->mode == REPLICATION_MODE_PRIMARY) { + /* We only use it to forward primary write requests */ + return -EIO; + } + + ret = replication_get_io_status(s); + if (ret < 0) { + return ret; + } + + /* + * After failover, because we don't commit active disk/hidden disk + * to secondary disk, so we should read from active disk directly. + */ + ret = bdrv_co_readv(bs->file, sector_num, remaining_sectors, qiov); + return replication_return_value(s, ret); +} + +static coroutine_fn int replication_co_writev(BlockDriverState *bs, + int64_t sector_num, + int remaining_sectors, + QEMUIOVector *qiov) +{ + BDRVReplicationState *s = bs->opaque; + QEMUIOVector hd_qiov; + uint64_t bytes_done = 0; + BlockDriverState *top = bs->file; + BlockDriverState *base = s->secondary_disk; + BlockDriverState *target; + int ret, n; + + ret = replication_get_io_status(s); + if (ret < 0) { + return ret; + } + + if (ret == 0) { + ret = bdrv_co_writev(bs->file, sector_num, remaining_sectors, qiov); + return replication_return_value(s, ret); + } + + /* + * Only write to active disk if the sectors have + * already been allocated in active disk/hidden disk. + */ + qemu_iovec_init(&hd_qiov, qiov->niov); + while (remaining_sectors > 0) { + ret = bdrv_is_allocated_above(top, base, sector_num, + remaining_sectors, &n); + if (ret < 0) { + return ret; + } + + qemu_iovec_reset(&hd_qiov); + qemu_iovec_concat(&hd_qiov, qiov, bytes_done, n * 512); + + target = ret ? top: base; + ret = bdrv_co_writev(target, sector_num, n, &hd_qiov); + if (ret < 0) { + return ret; + } + + remaining_sectors -= n; + sector_num += n; + bytes_done += n * BDRV_SECTOR_SIZE; + } + + return 0; +} + +static coroutine_fn int replication_co_discard(BlockDriverState *bs, + int64_t sector_num, + int nb_sectors) +{ + BDRVReplicationState *s = bs->opaque; + int ret; + + ret = replication_get_io_status(s); + if (ret < 0) { + return ret; + } + + if (ret == 1) { + /* It is secondary qemu and we are after failover */ + ret = bdrv_co_discard(s->secondary_disk, sector_num, nb_sectors); + if (ret) { + return ret; + } + } + + ret = bdrv_co_discard(bs->file, sector_num, nb_sectors); + return replication_return_value(s, ret); +} + +static bool replication_recurse_is_first_non_filter(BlockDriverState *bs, + BlockDriverState *candidate) +{ + return bdrv_recurse_is_first_non_filter(bs->file, candidate); +} + +static void secondary_do_checkpoint(BDRVReplicationState *s, Error **errp) +{ + Error *local_err = NULL; + int ret; + + if (!s->secondary_disk->job) { + error_setg(errp, "Backup job is cancelled unexpectedly"); + return; + } + + block_job_do_checkpoint(s->secondary_disk->job, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + ret = s->active_disk->drv->bdrv_make_empty(s->active_disk); + if (ret < 0) { + error_setg(errp, "Cannot make active disk empty"); + return; + } + + ret = s->hidden_disk->drv->bdrv_make_empty(s->hidden_disk); + if (ret < 0) { + error_setg(errp, "Cannot make hidden disk empty"); + return; + } +} + +static void backup_job_completed(void *opaque, int ret) +{ + BDRVReplicationState *s = opaque; + + if (s->replication_state != BLOCK_REPLICATION_DONE) { + /* The backup job is cancelled unexpectedly */ + s->error = -EIO; + } + + bdrv_op_block(s->hidden_disk, BLOCK_OP_TYPE_BACKUP_TARGET, + s->active_disk->backing_blocker); + bdrv_op_block(s->secondary_disk, BLOCK_OP_TYPE_BACKUP_SOURCE, + s->hidden_disk->backing_blocker); + + bdrv_put_ref_bh_schedule(s->secondary_disk); +} + +static void replication_start(BlockDriverState *bs, ReplicationMode mode, + Error **errp) +{ + BDRVReplicationState *s = bs->opaque; + int64_t active_length, hidden_length, disk_length; + AioContext *aio_context; + Error *local_err = NULL; + + if (s->replication_state != BLOCK_REPLICATION_NONE) { + error_setg(errp, "Block replication is running or done"); + return; + } + + if (s->mode != mode) { + error_setg(errp, "The parameter mode's value is invalid, needs %d," + " but receives %d", s->mode, mode); + return; + } + + switch (s->mode) { + case REPLICATION_MODE_PRIMARY: + break; + case REPLICATION_MODE_SECONDARY: + s->active_disk = bs->file; + if (!bs->file->backing_hd) { + error_setg(errp, "Active disk doesn't have backing file"); + return; + } + + s->hidden_disk = s->active_disk->backing_hd; + if (!s->hidden_disk->backing_hd) { + error_setg(errp, "Hidden disk doesn't have backing file"); + return; + } + + s->secondary_disk = s->hidden_disk->backing_hd; + if (!s->secondary_disk->blk) { + error_setg(errp, "The secondary disk doesn't have block backend"); + return; + } + + /* verify the length */ + active_length = bdrv_getlength(s->active_disk); + hidden_length = bdrv_getlength(s->hidden_disk); + disk_length = bdrv_getlength(s->secondary_disk); + if (active_length < 0 || hidden_length < 0 || disk_length < 0 || + active_length != hidden_length || hidden_length != disk_length) { + error_setg(errp, "active disk, hidden disk, secondary disk's length" + " are not the same"); + return; + } + + if (!s->active_disk->drv->bdrv_make_empty || + !s->hidden_disk->drv->bdrv_make_empty) { + error_setg(errp, + "active disk or hidden disk doesn't support make_empty"); + return; + } + + /* start backup job now */ + bdrv_op_unblock(s->hidden_disk, BLOCK_OP_TYPE_BACKUP_TARGET, + s->active_disk->backing_blocker); + bdrv_op_unblock(s->secondary_disk, BLOCK_OP_TYPE_BACKUP_SOURCE, + s->hidden_disk->backing_blocker); + bdrv_ref(s->hidden_disk); + + aio_context = bdrv_get_aio_context(bs); + aio_context_acquire(aio_context); + bdrv_set_aio_context(s->secondary_disk, aio_context); + backup_start(s->secondary_disk, s->hidden_disk, 0, + MIRROR_SYNC_MODE_NONE, NULL, BLOCKDEV_ON_ERROR_REPORT, + BLOCKDEV_ON_ERROR_REPORT, backup_job_completed, + s, &local_err); + aio_context_release(aio_context); + if (local_err) { + error_propagate(errp, local_err); + bdrv_op_block(s->hidden_disk, BLOCK_OP_TYPE_BACKUP_TARGET, + s->active_disk->backing_blocker); + bdrv_op_block(s->secondary_disk, BLOCK_OP_TYPE_BACKUP_SOURCE, + s->hidden_disk->backing_blocker); + bdrv_unref(s->hidden_disk); + return; + } + break; + default: + abort(); + } + + s->replication_state = BLOCK_REPLICATION_RUNNING; + + if (s->mode == REPLICATION_MODE_SECONDARY) { + secondary_do_checkpoint(s, errp); + } + + s->error = 0; +} + +static void replication_do_checkpoint(BlockDriverState *bs, Error **errp) +{ + BDRVReplicationState *s = bs->opaque; + + if (s->replication_state != BLOCK_REPLICATION_RUNNING) { + error_setg(errp, "Block replication is not running"); + return; + } + + if (s->error) { + error_setg(errp, "I/O error occurs"); + return; + } + + if (s->mode == REPLICATION_MODE_SECONDARY) { + secondary_do_checkpoint(s, errp); + } +} + +static void replication_stop(BlockDriverState *bs, bool failover, Error **errp) +{ + BDRVReplicationState *s = bs->opaque; + + if (s->replication_state != BLOCK_REPLICATION_RUNNING) { + error_setg(errp, "Block replication is not running"); + return; + } + + s->replication_state = BLOCK_REPLICATION_DONE; + + switch (s->mode) { + case REPLICATION_MODE_PRIMARY: + break; + case REPLICATION_MODE_SECONDARY: + if (!failover) { + /* + * The guest will be shutdown, and secondary disk is the + * same as the primary disk. Just make active disk and + * hidden disk empty. + */ + secondary_do_checkpoint(s, errp); + return; + } + + if (s->secondary_disk->job) { + block_job_cancel(s->secondary_disk->job); + } + break; + default: + abort(); + } +} + +BlockDriver bdrv_replication = { + .format_name = "replication", + .protocol_name = "replication", + .instance_size = sizeof(BDRVReplicationState), + + .bdrv_open = replication_open, + .bdrv_close = replication_close, + + .bdrv_getlength = replication_getlength, + .bdrv_co_readv = replication_co_readv, + .bdrv_co_writev = replication_co_writev, + .bdrv_co_discard = replication_co_discard, + + .is_filter = true, + .bdrv_recurse_is_first_non_filter = replication_recurse_is_first_non_filter, + + .bdrv_start_replication = replication_start, + .bdrv_do_checkpoint = replication_do_checkpoint, + .bdrv_stop_replication = replication_stop, + + .has_variable_length = true, +}; + +static void bdrv_replication_init(void) +{ + bdrv_register(&bdrv_replication); +} + +block_init(bdrv_replication_init); -- 2.4.3 From MAILER-DAEMON Wed Sep 02 04:52:33 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX3mT-0008E7-A6 for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 04:52:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3mF-0007nx-TQ for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX3mE-0004Yj-6D for qemu-block@nongnu.org; Wed, 02 Sep 2015 04:52:19 -0400 Received: from [59.151.112.132] (port=8817 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX3m7-00047B-NM; Wed, 02 Sep 2015 04:52:14 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100276479" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 02 Sep 2015 16:55:08 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t828pt7a020299; Wed, 2 Sep 2015 16:51:55 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 2 Sep 2015 16:52:04 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Wed, 2 Sep 2015 16:51:14 +0800 Message-ID: <1441183880-26993-11-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH 10/16] docs: block replication's description X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 08:52:21 -0000 Signed-off-by: Wen Congyang Signed-off-by: Yang Hongyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- docs/block-replication.txt | 183 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 docs/block-replication.txt diff --git a/docs/block-replication.txt b/docs/block-replication.txt new file mode 100644 index 0000000..b3cee8f --- /dev/null +++ b/docs/block-replication.txt @@ -0,0 +1,183 @@ +Block replication +---------------------------------------- +Copyright Fujitsu, Corp. 2015 +Copyright (c) 2015 Intel Corporation +Copyright (c) 2015 HUAWEI TECHNOLOGIES CO., LTD. + +This work is licensed under the terms of the GNU GPL, version 2 or later. +See the COPYING file in the top-level directory. + +Block replication is used for continuous checkpoints. It is designed +for COLO (COurse-grain LOck-stepping) where the Secondary VM is running. +It can also be applied for FT/HA (Fault-tolerance/High Assurance) scenario, +where the Secondary VM is not running. + +This document gives an overview of block replication's design. + +== Background == +High availability solutions such as micro checkpoint and COLO will do +consecutive checkpoints. The VM state of Primary VM and Secondary VM is +identical right after a VM checkpoint, but becomes different as the VM +executes till the next checkpoint. To support disk contents checkpoint, +the modified disk contents in the Secondary VM must be buffered, and are +only dropped at next checkpoint time. To reduce the network transportation +effort at the time of checkpoint, the disk modification operations of +Primary disk are asynchronously forwarded to the Secondary node. + +== Workflow == +The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V | + +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content(it could be from either "Secondary Write Requests" or + previous COW of "Primary Write Requests") in the Disk buffer. + 3) Primary write requests will be written to Secondary disk. + 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer. + +== Architecture == +We are going to implement block replication from many basic +blocks that are already in QEMU. + + virtio-blk || + ^ || .---------- + | || | Secondary + 1 Quorum || '---------- + / \ || + / \ || + Primary 2 filter + disk ^ virtio-blk + | ^ + 3 NBD -------> 3 NBD | + client || server 2 filter + || ^ ^ +--------. || | | +Primary | || Secondary disk <--------- hidden-disk 5 <--------- active-disk 4 +--------' || | backing ^ backing + || | | + || | | + || '-------------------------' + || drive-backup sync=none + +1) The disk on the primary is represented by a block device with two +children, providing replication between a primary disk and the host that +runs the secondary VM. The read pattern for quorum can be extended to +make the primary always read from the local disk instead of going through +NBD. + +2) The new block filter(the name is replication) will control the block +replication. + +3) The secondary disk receives writes from the primary VM through QEMU's +embedded NBD server (speculative write-through). + +4) The disk on the secondary is represented by a custom block device +(called active-disk). It should be an empty disk, and the format should +support bdrv_make_empty() and backing file. + +5) The hidden-disk is created automatically. It buffers the original content +that is modified by the primary VM. It should also be an empty disk, and +the driver supports bdrv_make_empty() and backing file. + +== Failure Handling == +There are 6 internal errors when block replication is running: +1. I/O error on primary disk +2. Forwarding primary write requests failed +3. Backup failed +4. I/O error on secondary disk +5. I/O error on active disk +6. Making active disk or hidden disk empty failed +In case 1 and 5, we just report the error to the disk layer. In case 2, 3, +4 and 6, we just report block replication's error to FT/HA manager(which +decides when to do a new checkpoint, when to do failover). +There is one internal error when doing failover: +1. Commiting the data in active disk/hidden disk to secondary disk failed +We just to report this error to FT/HA manager. + +== New block driver interface == +We add three block driver interfaces to control block replication: +a. bdrv_start_replication() + Start block replication, called in migration/checkpoint thread. + We must call bdrv_start_replication() in secondary QEMU before + calling bdrv_start_replication() in primary QEMU. The caller + must hold the I/O mutex lock if it is in migration/checkpoint + thread. +b. bdrv_do_checkpoint() + This interface is called after all VM state is transferred to + Secondary QEMU. The Disk buffer will be dropped in this interface. + The caller must hold the I/O mutex lock if it is in migration/checkpoint + thread. +c. bdrv_stop_replication() + It is called on failover. We will flush the Disk buffer into + Secondary Disk and stop block replication. The vm should be stopped + before calling it if you use this API to shutdown the guest, or other + things except failover. The caller must hold the I/O mutex lock if it is + in migration/checkpoint thread. + +== Usage == +Primary: + -drive if=xxx,driver=quorum,read-pattern=fifo,id=colo1,vote-threshold=1\ + children.0.file.filename=1.raw,\ + children.0.driver=raw,\ + + Run qmp command in primary qemu: + child_add disk1 child.driver=replication,child.mode=primary,\ + child.file.host=xxx,child.file.port=xxx,\ + child.file.driver=nbd,child.ignore-errors=on + Note: + 1. There should be only one NBD Client for each primary disk. + 2. host is the secondary physical machine's hostname or IP + 3. Each disk must have its own export name. + 4. It is all a single argument to -drive and child_add, and you should + ignore the leading whitespace. + 5. The qmp command line must be run after running qmp command line in + secondary qemu. + +Secondary: + -drive if=none,driver=raw,file=1.raw,id=colo1 \ + -drive if=xxx,driver=replication,mode=secondary,\ + file.file.filename=active_disk.qcow2,\ + file.driver=qcow2,\ + file.backing.file.filename=hidden_disk.qcow2,\ + file.backing.driver=qcow2,\ + file.backing.allow-write-backing-file=on,\ + file.backing.backing.backing_reference=colo1\ + + Then run qmp command in secondary qemu: + nbd-server-start host:port + nbd-server-add -w colo1 + + Note: + 1. The export name in secondary QEMU command line is the secondary + disk's id. + 2. The export name for the same disk must be the same + 3. The qmp command nbd-server-start and nbd-server-add must be run + before running the qmp command migrate on primary QEMU + 4. Don't use nbd-server-start's other options + 5. Active disk, hidden disk and nbd target's length should be the + same. + 6. It is better to put active disk and hidden disk in ramdisk. + 7. It is all a single argument to -drive, and you should ignore + the leading whitespace. -- 2.4.3 From MAILER-DAEMON Wed Sep 02 10:11:04 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX8ki-0004C6-FC for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 10:11:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX8kb-000452-A8 for qemu-block@nongnu.org; Wed, 02 Sep 2015 10:11:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX8kX-0000KH-4N for qemu-block@nongnu.org; Wed, 02 Sep 2015 10:10:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56807) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX8kW-0000K8-TQ; Wed, 02 Sep 2015 10:10:53 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 3D434C0F05C2; Wed, 2 Sep 2015 14:10:51 +0000 (UTC) Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82EAnou000623 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Wed, 2 Sep 2015 10:10:51 -0400 Date: Wed, 2 Sep 2015 10:10:49 -0400 From: Jeff Cody To: Wen Congyang Message-ID: <20150902141049.GA1170@localhost.localdomain> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-8-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441183880-26993-8-git-send-email-wency@cn.fujitsu.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Michael R. Hines" , Max Reitz , Gonglei , Stefan Hajnoczi , Paolo Bonzini , Yang Hongyang , "Dr. David Alan Gilbert" Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 07/16] Backup: clear all bitmap when doing block checkpoint X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 14:11:02 -0000 On Wed, Sep 02, 2015 at 04:51:11PM +0800, Wen Congyang wrote: > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei > Cc: Jeff Cody > --- > block/backup.c | 14 ++++++++++++++ > blockjob.c | 11 +++++++++++ > include/block/blockjob.h | 12 ++++++++++++ > 3 files changed, 37 insertions(+) > > diff --git a/block/backup.c b/block/backup.c > index b729c4b..59bdb79 100644 > --- a/block/backup.c > +++ b/block/backup.c > @@ -217,11 +217,25 @@ static void backup_iostatus_reset(BlockJob *job) > bdrv_iostatus_reset(s->target); > } > > +static void backup_do_checkpoint(BlockJob *job, Error **errp) > +{ > + BackupBlockJob *backup_job = container_of(job, BackupBlockJob, common); > + > + if (backup_job->sync_mode != MIRROR_SYNC_MODE_NONE) { > + error_setg(errp, "The backup job only supports block checkpoint in" > + " sync=none mode"); > + return; > + } > + > + hbitmap_reset_all(backup_job->bitmap); > +} > + > static const BlockJobDriver backup_job_driver = { > .instance_size = sizeof(BackupBlockJob), > .job_type = BLOCK_JOB_TYPE_BACKUP, > .set_speed = backup_set_speed, > .iostatus_reset = backup_iostatus_reset, > + .do_checkpoint = backup_do_checkpoint, > }; > > static BlockErrorAction backup_error_action(BackupBlockJob *job, > diff --git a/blockjob.c b/blockjob.c > index 62bb906..5528d92 100644 > --- a/blockjob.c > +++ b/blockjob.c > @@ -404,3 +404,14 @@ void block_job_defer_to_main_loop(BlockJob *job, > > qemu_bh_schedule(data->bh); > } > + > +void block_job_do_checkpoint(BlockJob *job, Error **errp) > +{ > + if (!job->driver->do_checkpoint) { > + error_setg(errp, "The job %s doesn't support block checkpoint", > + BlockJobType_lookup[job->driver->job_type]); > + return; > + } > + > + job->driver->do_checkpoint(job, errp); > +} > diff --git a/include/block/blockjob.h b/include/block/blockjob.h > index dd9d5e6..0b4f386 100644 > --- a/include/block/blockjob.h > +++ b/include/block/blockjob.h > @@ -50,6 +50,9 @@ typedef struct BlockJobDriver { > * manually. > */ > void (*complete)(BlockJob *job, Error **errp); > + > + /** Optional callback for job types that support checkpoint. */ > + void (*do_checkpoint)(BlockJob *job, Error **errp); > } BlockJobDriver; > > /** > @@ -356,4 +359,13 @@ void block_job_defer_to_main_loop(BlockJob *job, > BlockJobDeferToMainLoopFn *fn, > void *opaque); > > +/** > + * block_job_do_checkpoint: > + * @job: The job. > + * @errp: Error object. > + * > + * Do block checkpoint on the specified job. > + */ > +void block_job_do_checkpoint(BlockJob *job, Error **errp); > + > #endif > -- > 2.4.3 > > Reviewed-by: Jeff Cody From MAILER-DAEMON Wed Sep 02 10:12:36 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX8mC-0005IS-5R for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 10:12:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX8m8-0005GZ-Vt for qemu-block@nongnu.org; Wed, 02 Sep 2015 10:12:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX8m6-0001D3-2h for qemu-block@nongnu.org; Wed, 02 Sep 2015 10:12:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57288) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX8m5-0001Cr-Tq; Wed, 02 Sep 2015 10:12:30 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 685ABC0F05D7; Wed, 2 Sep 2015 14:12:29 +0000 (UTC) Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82ECR2m007402 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Wed, 2 Sep 2015 10:12:28 -0400 Date: Wed, 2 Sep 2015 10:12:27 -0400 From: Jeff Cody To: Wen Congyang Message-ID: <20150902141227.GB1170@localhost.localdomain> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-10-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441183880-26993-10-git-send-email-wency@cn.fujitsu.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Michael R. Hines" , Max Reitz , Gonglei , Stefan Hajnoczi , Paolo Bonzini , Yang Hongyang , "Dr. David Alan Gilbert" Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 09/16] Allow creating backup jobs when opening BDS X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 14:12:33 -0000 On Wed, Sep 02, 2015 at 04:51:13PM +0800, Wen Congyang wrote: > When opening BDS, we need to create backup jobs for > image-fleecing. > > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei > Cc: Jeff Cody > Reviewed-by: Stefan Hajnoczi > --- > block/Makefile.objs | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/block/Makefile.objs b/block/Makefile.objs > index 58ef2ef..fa05f37 100644 > --- a/block/Makefile.objs > +++ b/block/Makefile.objs > @@ -22,10 +22,10 @@ block-obj-$(CONFIG_ARCHIPELAGO) += archipelago.o > block-obj-$(CONFIG_LIBSSH2) += ssh.o > block-obj-y += accounting.o > block-obj-y += write-threshold.o > +block-obj-y += backup.o > > common-obj-y += stream.o > common-obj-y += commit.o > -common-obj-y += backup.o > > iscsi.o-cflags := $(LIBISCSI_CFLAGS) > iscsi.o-libs := $(LIBISCSI_LIBS) > -- > 2.4.3 > > Reviewed-by: Jeff Cody From MAILER-DAEMON Wed Sep 02 10:19:04 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX8sS-0007ZT-FI for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 10:19:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX8sP-0007W2-Tb for qemu-block@nongnu.org; Wed, 02 Sep 2015 10:19:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX8sN-0004Fl-2A for qemu-block@nongnu.org; Wed, 02 Sep 2015 10:19:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59460) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX8sM-0004Fh-Qu; Wed, 02 Sep 2015 10:18:58 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 52A258E3E5; Wed, 2 Sep 2015 14:18:58 +0000 (UTC) Received: from localhost (ovpn-112-71.ams2.redhat.com [10.36.112.71]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82EItht011975; Wed, 2 Sep 2015 10:18:56 -0400 Date: Wed, 2 Sep 2015 15:18:54 +0100 From: Stefan Hajnoczi To: Wen Congyang Message-ID: <20150902141854.GH1924@stefanha-thinkpad.redhat.com> References: <55D3EFF4.7030004@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55D3EFF4.7030004@cn.fujitsu.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devl , qemu block Subject: Re: [Qemu-block] [PATCH] Block: don't do copy-on-read in before_write_notifier X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 14:19:03 -0000 On Wed, Aug 19, 2015 at 10:54:44AM +0800, Wen Congyang wrote: > We will copy data in before_write_notifier to do backup. > It is a nested I/O request, so we cannot do copy-on-read. > > Signed-off-by: Wen Congyang > --- > block/backup.c | 19 +++++++++++++------ > block/io.c | 11 ++++++++++- > include/block/block.h | 3 +++ > trace-events | 1 + > 4 files changed, 27 insertions(+), 7 deletions(-) > > diff --git a/block/backup.c b/block/backup.c > index 965654d..b729c4b 100644 > --- a/block/backup.c > +++ b/block/backup.c > @@ -89,7 +89,8 @@ static void cow_request_end(CowRequest *req) > > static int coroutine_fn backup_do_cow(BlockDriverState *bs, > int64_t sector_num, int nb_sectors, > - bool *error_is_read) > + bool *error_is_read, > + bool is_write_notifier) > { > BackupBlockJob *job = (BackupBlockJob *)bs->job; > CowRequest cow_request; > @@ -129,8 +130,13 @@ static int coroutine_fn backup_do_cow(BlockDriverState *bs, > iov.iov_len = n * BDRV_SECTOR_SIZE; > qemu_iovec_init_external(&bounce_qiov, &iov, 1); > > - ret = bdrv_co_readv(bs, start * BACKUP_SECTORS_PER_CLUSTER, n, > - &bounce_qiov); > + if (is_write_notifier) { > + ret = bdrv_co_nested_readv(bs, start * BACKUP_SECTORS_PER_CLUSTER, > + n, &bounce_qiov); > + } else { > + ret = bdrv_co_readv(bs, start * BACKUP_SECTORS_PER_CLUSTER, n, > + &bounce_qiov); > + } > if (ret < 0) { > trace_backup_do_cow_read_fail(job, start, ret); > if (error_is_read) { > @@ -190,7 +196,7 @@ static int coroutine_fn backup_before_write_notify( > assert((req->offset & (BDRV_SECTOR_SIZE - 1)) == 0); > assert((req->bytes & (BDRV_SECTOR_SIZE - 1)) == 0); > > - return backup_do_cow(req->bs, sector_num, nb_sectors, NULL); > + return backup_do_cow(req->bs, sector_num, nb_sectors, NULL, true); > } > > static void backup_set_speed(BlockJob *job, int64_t speed, Error **errp) > @@ -303,7 +309,8 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job) > return ret; > } > ret = backup_do_cow(bs, cluster * BACKUP_SECTORS_PER_CLUSTER, > - BACKUP_SECTORS_PER_CLUSTER, &error_is_read); > + BACKUP_SECTORS_PER_CLUSTER, &error_is_read, > + false); > if ((ret < 0) && > backup_error_action(job, error_is_read, -ret) == > BLOCK_ERROR_ACTION_REPORT) { > @@ -408,7 +415,7 @@ static void coroutine_fn backup_run(void *opaque) > } > /* FULL sync mode we copy the whole drive. */ > ret = backup_do_cow(bs, start * BACKUP_SECTORS_PER_CLUSTER, > - BACKUP_SECTORS_PER_CLUSTER, &error_is_read); > + BACKUP_SECTORS_PER_CLUSTER, &error_is_read, false); > if (ret < 0) { > /* Depending on error action, fail now or retry cluster */ > BlockErrorAction action = > diff --git a/block/io.c b/block/io.c > index d4bc83b..04325f9 100644 > --- a/block/io.c > +++ b/block/io.c > @@ -932,7 +932,8 @@ static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs, > return ret; > } > > - if (bs->copy_on_read) { > + /* Don't do copy-on-read if we read data before write operation */ > + if (bs->copy_on_read && !(flags & BDRV_REQ_NESTED)) { > flags |= BDRV_REQ_COPY_ON_READ; > } > > @@ -1001,6 +1002,14 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, > return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, 0); > } > > +int coroutine_fn bdrv_co_nested_readv(BlockDriverState *bs, > + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) > +{ > + trace_bdrv_co_nested_readv(bs, sector_num, nb_sectors); > + > + return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, BDRV_REQ_NESTED); > +} > + > int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs, > int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) > { > diff --git a/include/block/block.h b/include/block/block.h > index 608cd4e..f5578b2 100644 > --- a/include/block/block.h > +++ b/include/block/block.h > @@ -60,6 +60,7 @@ typedef enum { > * opened with BDRV_O_UNMAP. > */ > BDRV_REQ_MAY_UNMAP = 0x4, > + BDRV_REQ_NESTED = 0x8, > } BdrvRequestFlags; > > typedef struct BlockSizes { > @@ -253,6 +254,8 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, > int nb_sectors, QEMUIOVector *qiov); > int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs, > int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); > +int coroutine_fn bdrv_co_nested_readv(BlockDriverState *bs, > + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); > int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num, > int nb_sectors, QEMUIOVector *qiov); > /* > diff --git a/trace-events b/trace-events > index 8f9614a..e29e1cf 100644 > --- a/trace-events > +++ b/trace-events > @@ -69,6 +69,7 @@ bdrv_aio_write_zeroes(void *bs, int64_t sector_num, int nb_sectors, int flags, v > bdrv_lock_medium(void *bs, bool locked) "bs %p locked %d" > bdrv_co_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" > bdrv_co_copy_on_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" > +bdrv_co_nested_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" > bdrv_co_writev(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" > bdrv_co_write_zeroes(void *bs, int64_t sector_num, int nb_sector, int flags) "bs %p sector_num %"PRId64" nb_sectors %d flags %#x" > bdrv_co_io_em(void *bs, int64_t sector_num, int nb_sectors, int is_write, void *acb) "bs %p sector_num %"PRId64" nb_sectors %d is_write %d acb %p" This solution looks good to me. I think the BDRV_REQ_NESTED and bdrv_co_nested_readv() name is too vague, especially since there is no documentation about what "nested" means here. I'm afraid the flag will be (ab)used for other stuff in the future and we'll end up with confusing/broken semantics. Please call it BDRV_REQ_NO_COPY_ON_READ so it's clear what this flag does. From MAILER-DAEMON Wed Sep 02 10:23:17 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX8wX-0002gU-1N for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 10:23:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX8wT-0002a8-1X for qemu-block@nongnu.org; Wed, 02 Sep 2015 10:23:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX8wN-0006Jp-C7 for qemu-block@nongnu.org; Wed, 02 Sep 2015 10:23:12 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:32380 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX8wJ-0006HU-F9; Wed, 02 Sep 2015 10:23:03 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2C8BQDUBedV/5tjdVtdGQEBAYJ/qwUFAYELAZgSglgCgTU7EQEBAQEBAQGBCoQkAQEDATo/EAsOEyUPASwbBog5DAHLQwEBAQEBAQQBAQEBHoYshUKFCweELAWMc4hWp2UmgkGBQDyDAAEBAQ X-IPAS-Result: A2C8BQDUBedV/5tjdVtdGQEBAYJ/qwUFAYELAZgSglgCgTU7EQEBAQEBAQGBCoQkAQEDATo/EAsOEyUPASwbBog5DAHLQwEBAQEBAQQBAQEBHoYshUKFCweELAWMc4hWp2UmgkGBQDyDAAEBAQ X-IronPort-AV: E=Sophos;i="5.17,453,1437429600"; d="scan'208";a="15114347" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 02 Sep 2015 16:23:00 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZX8wG-0001H7-Dp; Wed, 02 Sep 2015 16:23:00 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZX8wG-0002aK-7v; Wed, 02 Sep 2015 16:23:00 +0200 From: Alberto Garcia To: Kevin Wolf In-Reply-To: <20150901144002.GF4304@noname.redhat.com> References: <457103c2204e849aea3b83ffd78fad049d8d923d.1441014844.git.berto@igalia.com> <55E4B0CC.6070906@redhat.com> <55E4B374.70800@redhat.com> <20150901113111.GB4304@noname.redhat.com> <20150901144002.GF4304@noname.redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Wed, 02 Sep 2015 16:23:00 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 1/1] block: Allow passing BlockdevOptions to blockdev-snapshot-sync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 14:23:16 -0000 On Tue 01 Sep 2015 04:40:02 PM CEST, Kevin Wolf wrote: >> > Let's avoid such magic and instead add a new, clean blockdev-* >> > style command. Maybe call it simply blockdev-snapshot; the -sync >> > part was added because we knew it wouldn't be the final version of >> > the command. Now we don't have any bdrv_open() in it any more that >> > could by synchronous or asynchronous. Ok, I have a first working prototype of the new command using references as suggested. > { 'struct': 'BlockdevSnapshot', > 'data': { '*device': 'str', '*node-name': 'str', > 'snapshot-file': 'str', '*snapshot-node-name': 'str', > '*format': 'str', '*mode': 'NewImageMode' } } [...] > > What you really need for the version with a reference is just: > > { 'struct': 'BlockdevSnapshot', > 'data': { 'device': 'str', 'snapshot': 'str' } } And what do I do with the old BlockdevSnapshot? I guess it can just be renamed to BlockdevSnapshotSync or something like that? Berto From MAILER-DAEMON Wed Sep 02 10:23:24 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX8we-0002rK-7x for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 10:23:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX8wb-0002lz-G2 for qemu-block@nongnu.org; Wed, 02 Sep 2015 10:23:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX8wY-0006Ls-LI for qemu-block@nongnu.org; Wed, 02 Sep 2015 10:23:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37990) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX8wY-0006LV-B0; Wed, 02 Sep 2015 10:23:18 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 5B0BE8CF62; Wed, 2 Sep 2015 14:23:16 +0000 (UTC) Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82ENEJe015116 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Wed, 2 Sep 2015 10:23:15 -0400 Date: Wed, 2 Sep 2015 10:23:13 -0400 From: Jeff Cody To: Stefan Hajnoczi Message-ID: <20150902142313.GC1170@localhost.localdomain> References: <55D3EFF4.7030004@cn.fujitsu.com> <20150902141854.GH1924@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150902141854.GH1924@stefanha-thinkpad.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu block , qemu-devl , Wen Congyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] Block: don't do copy-on-read in before_write_notifier X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 14:23:22 -0000 On Wed, Sep 02, 2015 at 03:18:54PM +0100, Stefan Hajnoczi wrote: > On Wed, Aug 19, 2015 at 10:54:44AM +0800, Wen Congyang wrote: > > We will copy data in before_write_notifier to do backup. > > It is a nested I/O request, so we cannot do copy-on-read. > > > > Signed-off-by: Wen Congyang > > --- > > block/backup.c | 19 +++++++++++++------ > > block/io.c | 11 ++++++++++- > > include/block/block.h | 3 +++ > > trace-events | 1 + > > 4 files changed, 27 insertions(+), 7 deletions(-) > > > > diff --git a/block/backup.c b/block/backup.c > > index 965654d..b729c4b 100644 > > --- a/block/backup.c > > +++ b/block/backup.c > > @@ -89,7 +89,8 @@ static void cow_request_end(CowRequest *req) > > > > static int coroutine_fn backup_do_cow(BlockDriverState *bs, > > int64_t sector_num, int nb_sectors, > > - bool *error_is_read) > > + bool *error_is_read, > > + bool is_write_notifier) > > { > > BackupBlockJob *job = (BackupBlockJob *)bs->job; > > CowRequest cow_request; > > @@ -129,8 +130,13 @@ static int coroutine_fn backup_do_cow(BlockDriverState *bs, > > iov.iov_len = n * BDRV_SECTOR_SIZE; > > qemu_iovec_init_external(&bounce_qiov, &iov, 1); > > > > - ret = bdrv_co_readv(bs, start * BACKUP_SECTORS_PER_CLUSTER, n, > > - &bounce_qiov); > > + if (is_write_notifier) { > > + ret = bdrv_co_nested_readv(bs, start * BACKUP_SECTORS_PER_CLUSTER, > > + n, &bounce_qiov); > > + } else { > > + ret = bdrv_co_readv(bs, start * BACKUP_SECTORS_PER_CLUSTER, n, > > + &bounce_qiov); > > + } > > if (ret < 0) { > > trace_backup_do_cow_read_fail(job, start, ret); > > if (error_is_read) { > > @@ -190,7 +196,7 @@ static int coroutine_fn backup_before_write_notify( > > assert((req->offset & (BDRV_SECTOR_SIZE - 1)) == 0); > > assert((req->bytes & (BDRV_SECTOR_SIZE - 1)) == 0); > > > > - return backup_do_cow(req->bs, sector_num, nb_sectors, NULL); > > + return backup_do_cow(req->bs, sector_num, nb_sectors, NULL, true); > > } > > > > static void backup_set_speed(BlockJob *job, int64_t speed, Error **errp) > > @@ -303,7 +309,8 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job) > > return ret; > > } > > ret = backup_do_cow(bs, cluster * BACKUP_SECTORS_PER_CLUSTER, > > - BACKUP_SECTORS_PER_CLUSTER, &error_is_read); > > + BACKUP_SECTORS_PER_CLUSTER, &error_is_read, > > + false); > > if ((ret < 0) && > > backup_error_action(job, error_is_read, -ret) == > > BLOCK_ERROR_ACTION_REPORT) { > > @@ -408,7 +415,7 @@ static void coroutine_fn backup_run(void *opaque) > > } > > /* FULL sync mode we copy the whole drive. */ > > ret = backup_do_cow(bs, start * BACKUP_SECTORS_PER_CLUSTER, > > - BACKUP_SECTORS_PER_CLUSTER, &error_is_read); > > + BACKUP_SECTORS_PER_CLUSTER, &error_is_read, false); > > if (ret < 0) { > > /* Depending on error action, fail now or retry cluster */ > > BlockErrorAction action = > > diff --git a/block/io.c b/block/io.c > > index d4bc83b..04325f9 100644 > > --- a/block/io.c > > +++ b/block/io.c > > @@ -932,7 +932,8 @@ static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs, > > return ret; > > } > > > > - if (bs->copy_on_read) { > > + /* Don't do copy-on-read if we read data before write operation */ > > + if (bs->copy_on_read && !(flags & BDRV_REQ_NESTED)) { > > flags |= BDRV_REQ_COPY_ON_READ; > > } > > > > @@ -1001,6 +1002,14 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, > > return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, 0); > > } > > > > +int coroutine_fn bdrv_co_nested_readv(BlockDriverState *bs, > > + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) > > +{ > > + trace_bdrv_co_nested_readv(bs, sector_num, nb_sectors); > > + > > + return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, BDRV_REQ_NESTED); > > +} > > + > > int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs, > > int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) > > { > > diff --git a/include/block/block.h b/include/block/block.h > > index 608cd4e..f5578b2 100644 > > --- a/include/block/block.h > > +++ b/include/block/block.h > > @@ -60,6 +60,7 @@ typedef enum { > > * opened with BDRV_O_UNMAP. > > */ > > BDRV_REQ_MAY_UNMAP = 0x4, > > + BDRV_REQ_NESTED = 0x8, > > } BdrvRequestFlags; > > > > typedef struct BlockSizes { > > @@ -253,6 +254,8 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, > > int nb_sectors, QEMUIOVector *qiov); > > int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs, > > int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); > > +int coroutine_fn bdrv_co_nested_readv(BlockDriverState *bs, > > + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); > > int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num, > > int nb_sectors, QEMUIOVector *qiov); > > /* > > diff --git a/trace-events b/trace-events > > index 8f9614a..e29e1cf 100644 > > --- a/trace-events > > +++ b/trace-events > > @@ -69,6 +69,7 @@ bdrv_aio_write_zeroes(void *bs, int64_t sector_num, int nb_sectors, int flags, v > > bdrv_lock_medium(void *bs, bool locked) "bs %p locked %d" > > bdrv_co_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" > > bdrv_co_copy_on_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" > > +bdrv_co_nested_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" > > bdrv_co_writev(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" > > bdrv_co_write_zeroes(void *bs, int64_t sector_num, int nb_sector, int flags) "bs %p sector_num %"PRId64" nb_sectors %d flags %#x" > > bdrv_co_io_em(void *bs, int64_t sector_num, int nb_sectors, int is_write, void *acb) "bs %p sector_num %"PRId64" nb_sectors %d is_write %d acb %p" > > This solution looks good to me. > > I think the BDRV_REQ_NESTED and bdrv_co_nested_readv() name is too > vague, especially since there is no documentation about what "nested" > means here. I'm afraid the flag will be (ab)used for other stuff in the > future and we'll end up with confusing/broken semantics. > > Please call it BDRV_REQ_NO_COPY_ON_READ so it's clear what this flag > does. > I was able to test his solution, and can verify it fixed it, so I can give: Tested-by: Jeff Cody If you are re-spinning this patch, could you also split the patch in two? One for the core block io changes, and the second patch for using the new nested readv function in backup.c Thanks, Jeff From MAILER-DAEMON Wed Sep 02 10:53:22 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX9Pe-0003Q8-SY for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 10:53:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX9Pc-0003Of-HU for qemu-block@nongnu.org; Wed, 02 Sep 2015 10:53:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX9PZ-000447-BU for qemu-block@nongnu.org; Wed, 02 Sep 2015 10:53:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56671) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX9PZ-000443-4X; Wed, 02 Sep 2015 10:53:17 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 8D7F63DD42; Wed, 2 Sep 2015 14:53:16 +0000 (UTC) Received: from [10.36.116.52] (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82ErDoc004785 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 2 Sep 2015 10:53:15 -0400 To: Eric Blake , qemu-block@nongnu.org References: <1439939415-18180-1-git-send-email-mreitz@redhat.com> <1439939415-18180-2-git-send-email-mreitz@redhat.com> <55E4BDFF.70002@redhat.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <55E70D58.4050406@redhat.com> Date: Wed, 2 Sep 2015 16:53:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55E4BDFF.70002@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Gx1XFtnVCQSV40o85bmfNsxkAIbV7e86b" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 1/6] block: Change bdrv_get_encrypted_filename() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 14:53:21 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Gx1XFtnVCQSV40o85bmfNsxkAIbV7e86b Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 31.08.2015 22:50, Eric Blake wrote: > On 08/18/2015 05:10 PM, Max Reitz wrote: >> Instead of returning a pointer to the filename, copy it into a buffer >> specified by the caller. >> >> Signed-off-by: Max Reitz >> --- >> block.c | 25 ++++++++++++++++++------- >> include/block/block.h | 2 +- >> monitor.c | 6 +++++- >> 3 files changed, 24 insertions(+), 9 deletions(-) >=20 > Would it be better to just have bdrv_get_encrypted_filename() return a > g_malloc'd buffer, instead of making the caller do it? Then the buffer= > can be g_strdup'd to the correct size, instead of over-allocating > PATH_MAX bytes when a smaller size will usually do. Probably, yes. I wanted the interface to be similar to the new bdrv_filename(), but since all the callers of bdrv_get_encrypted_filename() would have to allocate the buffer anyway, I probably should pass through bdrv_filename_alloc() (and more on that in my reply to your review of patch 3). >> >> diff --git a/block.c b/block.c >> index d088ee0..41b0f85 100644 >> --- a/block.c >> +++ b/block.c >> @@ -2760,10 +2760,13 @@ void bdrv_add_key(BlockDriverState *bs, const = char *key, Error **errp) >> } >> } else { >> if (bdrv_key_required(bs)) { >> + char *enc_filename =3D g_malloc(PATH_MAX); >> + bdrv_get_encrypted_filename(bs, enc_filename, PATH_MAX); >> error_set(errp, ERROR_CLASS_DEVICE_ENCRYPTED, >> "'%s' (%s) is encrypted", >> bdrv_get_device_or_node_name(bs), >> - bdrv_get_encrypted_filename(bs)); >> + enc_filename); >=20 > Should you assert(enc_filename) to prove we know we aren't calling > error_set("%s", NULL)? After all, bdrv_get_encrypted_filename() can > return NULL, but only if no encrypted name is available; while > bdrv_key_required() implies that an encrypted name is available. Well, in this version, enc_filename will never be NULL because it has been returned by g_malloc(). But it may become necessary with the interface change you suggested (bdrv_get_encrypted_filename() allocating the buffer and returning it), so I'll keep it in mind. Thanks for your review and your suggestions! :-) Max >> -const char *bdrv_get_encrypted_filename(BlockDriverState *bs) >> +char *bdrv_get_encrypted_filename(BlockDriverState *bs, char *dest, s= ize_t sz) >> { >> - if (bs->backing_hd && bs->backing_hd->encrypted) >> - return bs->backing_file; >> - else if (bs->encrypted) >> - return bs->filename; >> - else >> + if (sz > INT_MAX) { >> + sz =3D INT_MAX; >> + } >> + >> + if (bs->backing_hd && bs->backing_hd->encrypted) { >> + pstrcpy(dest, sz, bs->backing_file); >> + return dest; >=20 > Again, using g_strdup() here instead of making the caller pass in a > buffer might be nicer semantics (certainly fewer places that have to > pre-allocate g_malloc0(PATH_MAX) bytes). >=20 >=20 >> +++ b/monitor.c >> @@ -5292,10 +5292,14 @@ int monitor_read_bdrv_key_start(Monitor *mon, = BlockDriverState *bs, >> BlockCompletionFunc *completion_cb, >> void *opaque) >> { >> + char *enc_filename; >> int err; >> =20 >> + enc_filename =3D g_malloc(PATH_MAX); >> + bdrv_get_encrypted_filename(bs, enc_filename, PATH_MAX); >> monitor_printf(mon, "%s (%s) is encrypted.\n", bdrv_get_device_na= me(bs), >> - bdrv_get_encrypted_filename(bs)); >> + enc_filename); >> + g_free(enc_filename); >=20 > And once again, an assert(enc_filename) might be nice to be sure we > aren't dealing with a NULL return. >=20 --Gx1XFtnVCQSV40o85bmfNsxkAIbV7e86b Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV5w1YAAoJEDuxQgLoOKytKEgH/i/l5lCFzOdkGXRmzmFcyp+F ewr3SNz3GP2QXQrPs9UxOOWndepxdDpmBYUo4ZxFKcehguXJxbvcBI8v8NTV9RS3 I/siX9ZZus0FTiAmoJneesbvmOE9zFT1AC6C/wNI5bi1gx+qxQ5sVCYJFJQRZc/Q 1k5zLO5IvLIgXJxPFA1IwUJprCOo0OPOnrBOMTsxAQHbGL98Td7pnBh327HKBVuH t7XOWIlH3Kitm9aiR6Mz82g3ZoYjOMHzRmmkMejLXcfheyf9+AHn5zPpRZPD40LL 6pB4QWYZOtpML1vNmcp+jXVRj3CbHWDLcKz+U/kWO4aWIhBAVPAo5d8TGvQrmwI= =0epe -----END PGP SIGNATURE----- --Gx1XFtnVCQSV40o85bmfNsxkAIbV7e86b-- From MAILER-DAEMON Wed Sep 02 10:59:22 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX9VR-0006dA-Vy for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 10:59:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX9VP-0006ch-EI for qemu-block@nongnu.org; Wed, 02 Sep 2015 10:59:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX9VM-0006JX-7q for qemu-block@nongnu.org; Wed, 02 Sep 2015 10:59:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57979) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX9VL-0006JC-Vw; Wed, 02 Sep 2015 10:59:16 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 5BA73341ACA; Wed, 2 Sep 2015 14:59:15 +0000 (UTC) Received: from [10.36.116.52] (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82ExCN4003303 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 2 Sep 2015 10:59:13 -0400 To: Eric Blake , qemu-block@nongnu.org References: <1439939415-18180-1-git-send-email-mreitz@redhat.com> <1439939415-18180-4-git-send-email-mreitz@redhat.com> <55E4C062.4010008@redhat.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <55E70EBF.3020808@redhat.com> Date: Wed, 2 Sep 2015 16:59:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55E4C062.4010008@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BIC39l1HBvXTFfDVKeQe5N8rp62jimpHS" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 3/6] block: Add bdrv_filename() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 14:59:20 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --BIC39l1HBvXTFfDVKeQe5N8rp62jimpHS Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 31.08.2015 23:00, Eric Blake wrote: > On 08/18/2015 05:10 PM, Max Reitz wrote: >> Split the part which actually refreshes the BlockDriverState.filename >> field off of bdrv_refresh_filename() into a more generic function >> bdrv_filename(), which first calls bdrv_refresh_filename() and then >> stores a qemu-usable filename into the given buffer instead of >> BlockDriverState.filename. >> >> Since bdrv_refresh_filename() therefore no longer refreshes that field= , >> some calls to that function have to be replaced by calls to >> bdrv_filename() "manually" refreshing the BDS filename field (this is >> only temporary). >> >> Additionally, a wrapper function bdrv_filename_alloc() is added which >> allocates a buffer of size PATH_MAX, call bdrv_filename() on that buff= er >> and returns it, since needing a temporary buffer for the filename is a= >> rather common pattern. >> >> Signed-off-by: Max Reitz >> --- >> block.c | 39 ++++++++++++++++++++++++++++++++------- >> block/blkverify.c | 3 ++- >> block/quorum.c | 2 +- >> include/block/block.h | 2 ++ >> 4 files changed, 37 insertions(+), 9 deletions(-) >> >=20 >> +/* First refreshes exact_filename and full_open_options by calling >> + * bdrv_refresh_filename(). Then, if exact_filename is set, it is cop= ied into >> + * the target buffer. Otherwise, full_open_options is converted to a = JSON >> + * object, prefixed with "json:" (for use through the JSON pseudo pro= tocol) and >> + * put there. >> + * >> + * If sz > 0, the string put into the buffer will always be null-term= inated. >> + * >> + * Returns @dest. >> + */ >> +char *bdrv_filename(BlockDriverState *bs, char *dest, size_t sz) >> +{ >=20 > How does one tell if 'sz' was large enough, vs. too short and therefore= > the snprintf() truncated the resulting string? Would the code be any > simpler if this always returned a freshly g_malloc'd string of the righ= t > length, rather than making the caller have to pre-allocate and guess > whether the allocation was big enough? >=20 >> + bdrv_refresh_filename(bs); >> + >> + if (sz > INT_MAX) { >> + sz =3D INT_MAX; >> + } >> =20 >> if (bs->exact_filename[0]) { >> - pstrcpy(bs->filename, sizeof(bs->filename), bs->exact_filenam= e); >> + pstrcpy(dest, sz, bs->exact_filename); >> } else if (bs->full_open_options) { >> QString *json =3D qobject_to_json(QOBJECT(bs->full_open_optio= ns)); >> - snprintf(bs->filename, sizeof(bs->filename), "json:%s", >> - qstring_get_str(json)); >> + snprintf(dest, sz, "json:%s", qstring_get_str(json)); >> QDECREF(json); >> } >> + >> + return dest; >=20 > In other words, I think it's very dangerous to use snprintf() without > checking whether the result fit. There are a couple of places in qemu which copy BDS.filename into a pre-existing buffer, so I'd rather not just drop bdrv_filename() as it is= =2E I guess I'll just make it so that calling bdrv_filename() with a NULL dest will result in the buffer being allocated. Note however that there are a couple of places in qemu which rely on filenames not exceeding PATH_MAX (by using PATH_MAX sized buffers for holding them). Maybe we'll eventually get around to fix them, but right now it's a limitation not introduced by this series. Max --BIC39l1HBvXTFfDVKeQe5N8rp62jimpHS Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV5w6/AAoJEDuxQgLoOKytnWMIAIGxn4UvCWeGOVzl5xqL5sly tV2zQb2czo94FsBbHwN4Q2Peax722utUM5ThQaVOfYTLNv/8EbOMW18Stf9YQsU/ nXIOHyTWICL0H7wIYEHCSxlIT45lsKOr9U0x+SvxFNpweuM7F+pD3+44SAu7NrRN guf1n7hlCnaYcZWP8eKGxR11V3DV5sMWb3fJ6KIxeK9L1umJ9NiC4C/bXLxDXHlJ S430z2YSsvGW2LO5AMdbs700ve3WibE/jqdUy8doA/GdKlpyPms3DqJU22bnsfEe TGTIQxtyXneBuHOV2vFERXr8z3pbVBtwMvdJSzweyrRM9Pm8Q14dbXU9acq/zKw= =s732 -----END PGP SIGNATURE----- --BIC39l1HBvXTFfDVKeQe5N8rp62jimpHS-- From MAILER-DAEMON Wed Sep 02 11:01:10 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX9XC-0008Ah-PM for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 11:01:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX9X6-000857-CO for qemu-block@nongnu.org; Wed, 02 Sep 2015 11:01:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX9X3-0007Y1-5M for qemu-block@nongnu.org; Wed, 02 Sep 2015 11:01:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41880) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX9X2-0007Xt-Tn; Wed, 02 Sep 2015 11:01:01 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 66883A2C09; Wed, 2 Sep 2015 15:01:00 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82F0wbj004926; Wed, 2 Sep 2015 11:00:58 -0400 To: Wen Congyang , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi References: <1439279489-13338-1-git-send-email-wency@cn.fujitsu.com> <1439279489-13338-6-git-send-email-wency@cn.fujitsu.com> <55E4A536.6040905@redhat.com> <55E4F767.1070602@cn.fujitsu.com> <55E5C572.7000606@redhat.com> <55E65026.2050902@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55E70F26.8020506@redhat.com> Date: Wed, 2 Sep 2015 09:00:54 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55E65026.2050902@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="LFixEbfQFAct6nvdfE40k68MvhD5KwWAg" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Max Reitz , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Patch for-2.5 v2 5/6] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 15:01:10 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --LFixEbfQFAct6nvdfE40k68MvhD5KwWAg Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/01/2015 07:25 PM, Wen Congyang wrote: > On 09/01/2015 11:34 PM, Eric Blake wrote: >> On 08/31/2015 06:55 PM, Wen Congyang wrote: >> >>>>> +This command is still a work in progress. It doesn't support all >>>>> +block drivers. Stay away from it unless you want it to help with >>>>> +its development. >>>> >>>> Maybe we should name it 'x-child-add' for now, so that we aren't bak= ing >>>> ourselves into a corner. >>> >>> Do you mean the command name should be x-child-add? It is OK. >> >> Use of the 'x-' prefix means a command is experimental and may change = or >> be withdrawn. It gives us a way to test if an interface is useful >> without committing to that interface long term. We've still got time >> before 2.5 to get blockdev-add working everywhere, in which case I thi= nk >> we are better off using blockdev-add to create a new unattached BDS an= d >> then have this command pass the node name to be made the new child, >> rather than all the options for opening the child from scratch. >> >=20 > Good idea. The unattached BDS created by the command blockdev-add alway= s > have BB. So it may be used by the device created by the command device_= add > later. We recently discussed (although the current documentation of BlockdevOptionsBase sounds like it hasn't been merged yet) the idea of enhancing blockdev-add to control whether a BB is created alongside a BDS= =2E Remember, blockdev-add can be used to create a chain. When originally implemented, we documented that 'id' must be present on the top of the chain, and absent everywhere else, and that 'node-name' was optional everywhere. The 'id' became associated with the BB at the top level, and the optional node-names allow you to then manipulate other BDS. But the proposal at hand is that we would allow 'id' to be optional at the top level (at which point 'node-name' is required, because we have to have SOME way to refer to the BDS); and when that happens, we end up creating a BDS that is not associated with any BB yet. Similarly, it is possible to create a BB that does not yet have a BDS yet (think an empty cdrom drive); so it then becomes possible to associate a BDS to a BB as a separate step. [/me goes searching] Ah - we are waiting for Max's patches to land: https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg04201.html in particular patch 02/38: https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg04204.html Once we have that, then we can indeed create a BDS without a BB, and it is then that you can plug your unconnected BDS into a quorum. So I'd recommend helping review Max's series, and base your actions on top of his (I really do think it is a better approach to separate BDS creation from chain manipulation, and your add/remove a child is about chain manipulation and does not need to be creating BDS). > So I think we should have an API to check it. What about the following > patches? > http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg01591.html > http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg01590.html I haven't looked at them yet, but really like Max's approach for separating BDS from BB by treating BB without BDS as an empty media case, and BDS without a BB as something that can then be manipulated to be associated with another BDS or BB. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --LFixEbfQFAct6nvdfE40k68MvhD5KwWAg Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5w8mAAoJEKeha0olJ0NqRjYH/0nNOcAXszZ5XqGWBzyyS/JQ /psrFjNpOaRbsdvUyCnCLEWTYv4NZ6ZZvIZR0A1ZAfuzVC1IdtjUKlCPCzwCnS32 xP79N1uCQltMebIeOMtTr7c16X/VnXdpeKXDPy17Yi4yvS5Oa0P2J+Dcr17932rP 3P3NkfU9dsuDDZJdKm+52WT2tVPo24jEZsttEGJCwJnr3Kl8ZT2rxJquOjRzQolb FA3jfMhj2RnJtS5HhPcSAXZak4xztG92Z5Tfl729QPNTQYceRteiGOakpTFu+Cc9 tzuwcosFCcJ3/pXGVDZ+HQf2NSGdsDMaz7iVqTVZ5PzKwDdfBDZV8dAbIDfkpPo= =DfqH -----END PGP SIGNATURE----- --LFixEbfQFAct6nvdfE40k68MvhD5KwWAg-- From MAILER-DAEMON Wed Sep 02 11:03:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX9Z0-0001UB-EE for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 11:03:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX9Yv-0001T8-4o for qemu-block@nongnu.org; Wed, 02 Sep 2015 11:03:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX9Yr-0008Np-3p for qemu-block@nongnu.org; Wed, 02 Sep 2015 11:02:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42538) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX9Yq-0008NZ-Uu; Wed, 02 Sep 2015 11:02:53 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 8F04CA9F; Wed, 2 Sep 2015 15:02:52 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82F2pOH007890; Wed, 2 Sep 2015 11:02:51 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E70F9B.20309@redhat.com> Date: Wed, 2 Sep 2015 09:02:51 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1437414365-11881-1-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="EC9ugFonP1KbWAHAaKOcM88FJJATX2qJE" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v4 00/38] blockdev: BlockBackend and media X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 15:03:01 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --EC9ugFonP1KbWAHAaKOcM88FJJATX2qJE Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/20/2015 11:45 AM, Max Reitz wrote: > First of all: Thank you, Eric and Berto, for reviewing v3! And thank > you, Fam, for at least having a peek at it and being confident enough t= o > base a series of your own on it. :-) >=20 > This series reworks a lot regarding BlockBackend and media. Basically, > it allows empty BlockBackends, that is BBs without a BDS tree. >=20 > Before this series, empty drives are represented by a BlockBackend with= > an empty BDS attached to it (a BDS with a NULL driver). However, now we= > have BlockBackends, thus an empty drive should be represented by a > BlockBackend without any BDS tree attached to it. This is what this > series does. We've obviously missed 2.4; but now that 2.5 is open, are there plans to get this series in sooner rather than later? Wen's work on dynamically adding/deleting children from a quorum would benefit from the ability to create a BDS without an associated BB, which in turn would help the COLO work. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --EC9ugFonP1KbWAHAaKOcM88FJJATX2qJE Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5w+bAAoJEKeha0olJ0NqqCsH/jk/lWiV+2nhBTvwTrdo8ieD rIohbAXWWJEtGN6FkRewx2IIzQCmVsQW1MkAInAdYkVezYmU6nYSxcplX/DdPSZO GUQm0D7M6QEZO11mZQx6Ap4H3XjG9OxSspfdR3LEjgOzVHai5U3Xm6LaplBlmrH7 jupZUgK67HYmIJAhUrJCEPAucP7NYqLIyFlHD8IV/I0PgmrbvF/od1JC3XpbYneb Ymlt/rsZOUMFbIIyhzQo81NUzCC2EWCgCkTBqC2/XhUYSrzpWOl1rmibiYnax9EU fdyk2y5/vaoMWD2gqQCrQo20yfj0NaUNuWqdsw+k71id6XFBCLrdmcOlZwOMGLA= =OJ58 -----END PGP SIGNATURE----- --EC9ugFonP1KbWAHAaKOcM88FJJATX2qJE-- From MAILER-DAEMON Wed Sep 02 11:09:53 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX9fd-0004Ag-Nv for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 11:09:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX9fa-0004A6-0W for qemu-block@nongnu.org; Wed, 02 Sep 2015 11:09:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX9fW-0003f4-Nd for qemu-block@nongnu.org; Wed, 02 Sep 2015 11:09:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60938) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX9fW-0003dF-CS; Wed, 02 Sep 2015 11:09:46 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 2D2DF341AC3; Wed, 2 Sep 2015 15:09:45 +0000 (UTC) Received: from [10.36.116.52] (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82F9foL012831 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 2 Sep 2015 11:09:43 -0400 To: Jeff Cody References: <1441047913-30596-1-git-send-email-mreitz@redhat.com> <1441047913-30596-2-git-send-email-mreitz@redhat.com> <20150831225519.GG31272@localhost.localdomain> From: Max Reitz Message-ID: <55E71135.1060403@redhat.com> Date: Wed, 2 Sep 2015 17:09:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150831225519.GG31272@localhost.localdomain> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PgWDf6D4eD9H5LFCrMTqEKiuF7r3PhFem" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 1/2] iotests: Do not suppress segfaults in bash tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 15:09:52 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --PgWDf6D4eD9H5LFCrMTqEKiuF7r3PhFem Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 01.09.2015 00:55, Jeff Cody wrote: > On Mon, Aug 31, 2015 at 09:05:12PM +0200, Max Reitz wrote: >> Currently, if a qemu/qemu-io/qemu-img/qemu-nbd invocation receives a >> segmentation fault, that message is invisible in most cases since the >> output is generally filtered and bash suppresses the segmentation faul= t >> notice for any but the last element of a pipe. >> >> Most of the time, the test will then fail anyway because of missing >> output, but not necessarily (as happened with test 82 recently). >> >> Fix this by making the corresponding environment variables point to >> wrapper functions which execute the respective command in a subshell. >> >> Signed-off-by: Max Reitz >> --- >> tests/qemu-iotests/039 | 19 ++++++------------- >> tests/qemu-iotests/039.out | 6 +++--- >> tests/qemu-iotests/061 | 6 ++++-- >> tests/qemu-iotests/061.out | 2 ++ >> tests/qemu-iotests/check | 8 ++++---- >> tests/qemu-iotests/common.config | 34 ++++++++++++++++++++++++++++++-= --- >> tests/qemu-iotests/common.rc | 12 +++++++++++- >> tests/qemu-iotests/iotests.py | 6 +++--- >> 8 files changed, 63 insertions(+), 30 deletions(-) >> >=20 > Test 082 fails now: >=20 > Testing: amend -f qcow2 -o backing_file=3DTEST_DIR/t.qcow2, -o help T= EST_DIR/t.qcow2 > qemu-img: Invalid option list: backing_file=3DTEST_DIR/t.qcow2, > +./common.config: line 117: 737 Segmentation fault (core dumped= ) ( exec $QEMU_IMG_CMD "$@" ) > =20 > Testing: amend -f qcow2 -o backing_file=3DTEST_DIR/t.qcow2 -o ,help T= EST_DIR/t.qcow2 > qemu-img: Invalid option list: ,help > +./common.config: line 117: 746 Segmentation fault (core dumped= ) ( exec $QEMU_IMG_CMD "$@" ) > =20 > Testing: amend -f qcow2 -o backing_file=3DTEST_DIR/t.qcow2 -o ,, -o h= elp TEST_DIR/t.qcow2 > qemu-img: Invalid option list: ,, > +./common.config: line 117: 756 Segmentation fault (core dumped= ) ( exec $QEMU_IMG_CMD "$@" ) > =20 > Testing: amend -f qcow2 -o help > Supported options >=20 >=20 > That shows me your patches are working well :) Yes, as intended. :-) fyi, the patch fixing this is http://lists.nongnu.org/archive/html/qemu-block/2015-08/msg00156.html. >> diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 >> index 859705f..617f397 100755 >> --- a/tests/qemu-iotests/039 >> +++ b/tests/qemu-iotests/039 >> @@ -47,13 +47,6 @@ _supported_os Linux >> _default_cache_mode "writethrough" >> _supported_cache_modes "writethrough" >> =20 >> -_subshell_exec() >> -{ >> - # Executing crashing commands in a subshell prevents information = like the >> - # "Killed" line from being lost >> - (exec "$@") >> -} >> - >> size=3D128M >> =20 >> echo >> @@ -74,8 +67,8 @@ echo "=3D=3D Creating a dirty image file =3D=3D" >> IMGOPTS=3D"compat=3D1.1,lazy_refcounts=3Don" >> _make_test_img $size >> =20 >> -_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \ >> - -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&= 1 \ >> +$QEMU_IO -c "write -P 0x5a 0 512" \ >> + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ >> | _filter_qemu_io >> =20 >> # The dirty bit must be set >> @@ -109,8 +102,8 @@ echo "=3D=3D Opening a dirty image read/write shou= ld repair it =3D=3D" >> IMGOPTS=3D"compat=3D1.1,lazy_refcounts=3Don" >> _make_test_img $size >> =20 >> -_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \ >> - -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&= 1 \ >> +$QEMU_IO -c "write -P 0x5a 0 512" \ >> + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ >> | _filter_qemu_io >> =20 >> # The dirty bit must be set >> @@ -127,8 +120,8 @@ echo "=3D=3D Creating an image file with lazy_refc= ounts=3Doff =3D=3D" >> IMGOPTS=3D"compat=3D1.1,lazy_refcounts=3Doff" >> _make_test_img $size >> =20 >> -_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \ >> - -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&= 1 \ >> +$QEMU_IO -c "write -P 0x5a 0 512" \ >> + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ >> | _filter_qemu_io >> =20 >> # The dirty bit must not be set since lazy_refcounts=3Doff >> diff --git a/tests/qemu-iotests/039.out b/tests/qemu-iotests/039.out >> index d09751f..613ef1b 100644 >> --- a/tests/qemu-iotests/039.out >> +++ b/tests/qemu-iotests/039.out >> @@ -11,7 +11,7 @@ No errors were found on the image. >> Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 >> wrote 512/512 bytes at offset 0 >> 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) >> -./039: Killed ( exec "$@" ) >> +./common.config: Killed ( exec $QEMU_IO_CMD "$@" ) >> incompatible_features 0x1 >> ERROR cluster 5 refcount=3D0 reference=3D1 >> ERROR OFLAG_COPIED data cluster: l2_entry=3D8000000000050000 refcount= =3D0 >> @@ -46,7 +46,7 @@ read 512/512 bytes at offset 0 >> Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 >> wrote 512/512 bytes at offset 0 >> 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) >> -./039: Killed ( exec "$@" ) >> +./common.config: Killed ( exec $QEMU_IO_CMD "$@" ) >> incompatible_features 0x1 >> ERROR cluster 5 refcount=3D0 reference=3D1 >> Rebuilding refcount structure >> @@ -60,7 +60,7 @@ incompatible_features 0x0 >> Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 >> wrote 512/512 bytes at offset 0 >> 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) >> -./039: Killed ( exec "$@" ) >> +./common.config: Killed ( exec $QEMU_IO_CMD "$@" ) >> incompatible_features 0x0 >> No errors were found on the image. >> =20 >> diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 >> index 8d37f8a..1df887a 100755 >> --- a/tests/qemu-iotests/061 >> +++ b/tests/qemu-iotests/061 >> @@ -58,7 +58,8 @@ echo >> echo "=3D=3D=3D Testing dirty version downgrade =3D=3D=3D" >> echo >> IMGOPTS=3D"compat=3D1.1,lazy_refcounts=3Don" _make_test_img 64M >> -$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" | _f= ilter_qemu_io >> +$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" 2>&1= \ >> + | _filter_qemu_io >> $PYTHON qcow2.py "$TEST_IMG" dump-header >> $QEMU_IMG amend -o "compat=3D0.10" "$TEST_IMG" >> $PYTHON qcow2.py "$TEST_IMG" dump-header >> @@ -91,7 +92,8 @@ echo >> echo "=3D=3D=3D Testing dirty lazy_refcounts=3Doff =3D=3D=3D" >> echo >> IMGOPTS=3D"compat=3D1.1,lazy_refcounts=3Don" _make_test_img 64M >> -$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" | _f= ilter_qemu_io >> +$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" 2>&1= \ >> + | _filter_qemu_io >> $PYTHON qcow2.py "$TEST_IMG" dump-header >> $QEMU_IMG amend -o "lazy_refcounts=3Doff" "$TEST_IMG" >> $PYTHON qcow2.py "$TEST_IMG" dump-header >> diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out >> index 5ec248f..c9e3917 100644 >> --- a/tests/qemu-iotests/061.out >> +++ b/tests/qemu-iotests/061.out >> @@ -57,6 +57,7 @@ No errors were found on the image. >> Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 >> wrote 131072/131072 bytes at offset 0 >> 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) >> +./common.config: Aborted (core dumped) ( exec $QEMU_I= O_CMD "$@" ) >> magic 0x514649fb >> version 3 >> backing_file_offset 0x0 >> @@ -214,6 +215,7 @@ No errors were found on the image. >> Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 >> wrote 131072/131072 bytes at offset 0 >> 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) >> +./common.config: Aborted (core dumped) ( exec $QEMU_I= O_CMD "$@" ) >> magic 0x514649fb >> version 3 >> backing_file_offset 0x0 >> diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check >> index 6d58203..b5a535e 100755 >> --- a/tests/qemu-iotests/check >> +++ b/tests/qemu-iotests/check >> @@ -231,10 +231,10 @@ FULL_HOST_DETAILS=3D`_full_platform_details` >> #FULL_MOUNT_OPTIONS=3D`_scratch_mount_options` >> =20 >> cat <> -QEMU -- $QEMU >> -QEMU_IMG -- $QEMU_IMG >> -QEMU_IO -- $QEMU_IO >> -QEMU_NBD -- $QEMU_NBD >> +QEMU -- $QEMU_CMD >> +QEMU_IMG -- $QEMU_IMG_CMD >> +QEMU_IO -- $QEMU_IO_CMD >> +QEMU_NBD -- $QEMU_NBD_CMD >> IMGFMT -- $FULL_IMGFMT_DETAILS >> IMGPROTO -- $FULL_IMGPROTO_DETAILS >> PLATFORM -- $FULL_HOST_DETAILS >> diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/com= mon.config >> index e0bf896..480efe6 100644 >> --- a/tests/qemu-iotests/common.config >> +++ b/tests/qemu-iotests/common.config >> @@ -103,10 +103,36 @@ if [ -z "$QEMU_NBD_PROG" ]; then >> export QEMU_NBD_PROG=3D"`set_prog_path qemu-nbd`" >> fi >> =20 >> -export QEMU=3D"$QEMU_PROG $QEMU_OPTIONS" >> -export QEMU_IMG=3D$QEMU_IMG_PROG >> -export QEMU_IO=3D"$QEMU_IO_PROG $QEMU_IO_OPTIONS" >> -export QEMU_NBD=3D$QEMU_NBD_PROG >> +export QEMU_CMD=3D"$QEMU_PROG $QEMU_OPTIONS" >> +export QEMU_IMG_CMD=3D$QEMU_IMG_PROG >> +export QEMU_IO_CMD=3D"$QEMU_IO_PROG $QEMU_IO_OPTIONS" >> +export QEMU_NBD_CMD=3D$QEMU_NBD_PROG >> + >=20 > Unfortunately, these exports (old and new) make it so that pathnames > with spaces won't work (in case someone hasn't had it beaten into them > that spaced pathnames is begging for trouble...). But luckily, I > think your patch make it easier to fix this, since you have the > wrapper! >=20 > I think we want to drop the _OPTIONS in each of the exports, e.g.: >=20 > -export QEMU=3D"$QEMU_PROG $QEMU_OPTIONS" > +export QEMU_CMD=3D"$QEMU_PROG" >=20 > And then instead of this: >=20 >> +_qemu_wrapper() >> +{ >> + (exec $QEMU_CMD "$@") >> +} >> + >=20 > Use this form, instead: >=20 > +_qemu_wrapper() > +{ > + (exec "$QEMU_CMD" "$QEMU_OPTIONS" "$@") > +} > + Yes, I tried not to break anything in that regard that wasn't already broken, but if we have the chance to fix something, then we (I) should go for it. QEMU_CMD is used for the Python tests as the command line to be used for qemu invocation, so it cannot be modified like that. But what I can do is to drop QEMU.*_CMD and replace it by "$QEMU.*_PROG" "$QEMU.*_OPTIONS" everywhere, I guess. I'll have a look. Thanks for reviewing! Max >> +_qemu_img_wrapper() >> +{ >> + (exec $QEMU_IMG_CMD "$@") >> +} >> + >> +_qemu_io_wrapper() >> +{ >> + (exec $QEMU_IO_CMD "$@") >> +} >> + >> +_qemu_nbd_wrapper() >> +{ >> + (exec $QEMU_NBD_CMD "$@") >> +} >> + >=20 > Repeat as appropriate, above. >=20 >> +export QEMU=3D_qemu_wrapper >> +export QEMU_IMG=3D_qemu_img_wrapper >> +export QEMU_IO=3D_qemu_io_wrapper >> +export QEMU_NBD=3D_qemu_nbd_wrapper >> + >> default_machine=3D$($QEMU -machine \? | awk '/(default)/{print $1}') >> default_alias_machine=3D$($QEMU -machine \? |\ >> awk -v var_default_machine=3D"$default_machine"\)\ >> diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.= rc >> index 22d3514..28e4bea 100644 >> --- a/tests/qemu-iotests/common.rc >> +++ b/tests/qemu-iotests/common.rc >> @@ -439,7 +439,17 @@ _unsupported_imgopts() >> # >> _require_command() >> { >> - eval c=3D\$$1 >> + if [ "$1" =3D "QEMU" ]; then >> + c=3D$QEMU_PROG >> + elif [ "$1" =3D "QEMU_IMG" ]; then >> + c=3D$QEMU_IMG_PROG >> + elif [ "$1" =3D "QEMU_IO" ]; then >> + c=3D$QEMU_IO_PROG >> + elif [ "$1" =3D "QEMU_NBD" ]; then >> + c=3D$QEMU_NBD_PROG >> + else >> + eval c=3D\$$1 >> + fi >> [ -x "$c" ] || _notrun "$1 utility required, skipped this test" >> } >> =20 >> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotest= s.py >> index 5579253..927c74a 100644 >> --- a/tests/qemu-iotests/iotests.py >> +++ b/tests/qemu-iotests/iotests.py >> @@ -33,9 +33,9 @@ __all__ =3D ['imgfmt', 'imgproto', 'test_dir' 'qemu_= img', 'qemu_io', >> =20 >> # This will not work if arguments or path contain spaces but is neces= sary if we >> # want to support the override options that ./check supports. >> -qemu_img_args =3D os.environ.get('QEMU_IMG', 'qemu-img').strip().spli= t(' ') >> -qemu_io_args =3D os.environ.get('QEMU_IO', 'qemu-io').strip().split('= ') >> -qemu_args =3D os.environ.get('QEMU', 'qemu').strip().split(' ') >> +qemu_img_args =3D os.environ.get('QEMU_IMG_CMD', 'qemu-img').strip().= split(' ') >> +qemu_io_args =3D os.environ.get('QEMU_IO_CMD', 'qemu-io').strip().spl= it(' ') >> +qemu_args =3D os.environ.get('QEMU_CMD', 'qemu').strip().split(' ') >> =20 >> imgfmt =3D os.environ.get('IMGFMT', 'raw') >> imgproto =3D os.environ.get('IMGPROTO', 'file') >> --=20 >> 2.5.0 >> >> --PgWDf6D4eD9H5LFCrMTqEKiuF7r3PhFem Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV5xE1AAoJEDuxQgLoOKytQfkIAKkx3e3oS5KuXHQMWZLvELNY J/eCfiKPH1oi758/oMYq4Jz/EAT2H/OL+ibhFMR/4ua+OISVpci8H4IMiE6+Vdtq oCkkzGV8EKQc79UVVxdzKupTTLUW6imau6rSV3Wa67hqVzJMoft1SsdZq8g2EkWn xCUobxnYQyJC/mzk89gKLWCyKt/Xj68VQ67iUh8TnTYVIPSgQLxhbwCD9xYO9wTI 6pSdWLLhxMJarBwWzKN1Hv7v57/x1TyJbHdDjf64daT9dVcPjmdPJ0u8k2/4KA9p IFp12gP4IARN0NSL4tiq9cNMciDHX7SRba6//I6X7qINuCB9ILsPSG7RBvwdn1w= =Rh1Y -----END PGP SIGNATURE----- --PgWDf6D4eD9H5LFCrMTqEKiuF7r3PhFem-- From MAILER-DAEMON Wed Sep 02 11:30:42 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZX9zm-0002rr-9S for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 11:30:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX9zj-0002rg-UU for qemu-block@nongnu.org; Wed, 02 Sep 2015 11:30:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZX9zg-0003SE-FV for qemu-block@nongnu.org; Wed, 02 Sep 2015 11:30:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50252) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZX9zg-0003S0-2J; Wed, 02 Sep 2015 11:30:36 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 9136F5F; Wed, 2 Sep 2015 15:30:35 +0000 (UTC) Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82FUXj9021213 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Wed, 2 Sep 2015 11:30:34 -0400 Date: Wed, 2 Sep 2015 11:30:32 -0400 From: Jeff Cody To: Max Reitz Message-ID: <20150902153032.GP11016@localhost.localdomain> References: <1441047913-30596-1-git-send-email-mreitz@redhat.com> <1441047913-30596-2-git-send-email-mreitz@redhat.com> <20150831225519.GG31272@localhost.localdomain> <55E71135.1060403@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55E71135.1060403@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 1/2] iotests: Do not suppress segfaults in bash tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 15:30:41 -0000 On Wed, Sep 02, 2015 at 05:09:41PM +0200, Max Reitz wrote: > On 01.09.2015 00:55, Jeff Cody wrote: > > On Mon, Aug 31, 2015 at 09:05:12PM +0200, Max Reitz wrote: > >> Currently, if a qemu/qemu-io/qemu-img/qemu-nbd invocation receives a > >> segmentation fault, that message is invisible in most cases since the > >> output is generally filtered and bash suppresses the segmentation fault > >> notice for any but the last element of a pipe. > >> > >> Most of the time, the test will then fail anyway because of missing > >> output, but not necessarily (as happened with test 82 recently). > >> > >> Fix this by making the corresponding environment variables point to > >> wrapper functions which execute the respective command in a subshell. > >> > >> Signed-off-by: Max Reitz > >> --- > >> tests/qemu-iotests/039 | 19 ++++++------------- > >> tests/qemu-iotests/039.out | 6 +++--- > >> tests/qemu-iotests/061 | 6 ++++-- > >> tests/qemu-iotests/061.out | 2 ++ > >> tests/qemu-iotests/check | 8 ++++---- > >> tests/qemu-iotests/common.config | 34 ++++++++++++++++++++++++++++++---- > >> tests/qemu-iotests/common.rc | 12 +++++++++++- > >> tests/qemu-iotests/iotests.py | 6 +++--- > >> 8 files changed, 63 insertions(+), 30 deletions(-) > >> [snip] > >> > >> -export QEMU="$QEMU_PROG $QEMU_OPTIONS" > >> -export QEMU_IMG=$QEMU_IMG_PROG > >> -export QEMU_IO="$QEMU_IO_PROG $QEMU_IO_OPTIONS" > >> -export QEMU_NBD=$QEMU_NBD_PROG > >> +export QEMU_CMD="$QEMU_PROG $QEMU_OPTIONS" > >> +export QEMU_IMG_CMD=$QEMU_IMG_PROG > >> +export QEMU_IO_CMD="$QEMU_IO_PROG $QEMU_IO_OPTIONS" > >> +export QEMU_NBD_CMD=$QEMU_NBD_PROG > >> + > > > > Unfortunately, these exports (old and new) make it so that pathnames > > with spaces won't work (in case someone hasn't had it beaten into them > > that spaced pathnames is begging for trouble...). But luckily, I > > think your patch make it easier to fix this, since you have the > > wrapper! > > > > I think we want to drop the _OPTIONS in each of the exports, e.g.: > > > > -export QEMU="$QEMU_PROG $QEMU_OPTIONS" > > +export QEMU_CMD="$QEMU_PROG" > > > > And then instead of this: > > > >> +_qemu_wrapper() > >> +{ > >> + (exec $QEMU_CMD "$@") > >> +} > >> + > > > > Use this form, instead: > > > > +_qemu_wrapper() > > +{ > > + (exec "$QEMU_CMD" "$QEMU_OPTIONS" "$@") > > +} > > + > > Yes, I tried not to break anything in that regard that wasn't already > broken, but if we have the chance to fix something, then we (I) should > go for it. > > QEMU_CMD is used for the Python tests as the command line to be used for > qemu invocation, so it cannot be modified like that. But what I can do > is to drop QEMU.*_CMD and replace it by "$QEMU.*_PROG" "$QEMU.*_OPTIONS" > everywhere, I guess. I'll have a look. > Good point. I don't think it needs to be done in this patch series, as your patches don't change this behavior. It could be done in a follow-up series, by you or someone else. I'm happy to give my r-b as-is, and we can change it later.: Reviewed-by: Jeff Cody > Thanks for reviewing! > > Max You're welcome :) > > >> +_qemu_img_wrapper() > >> +{ > >> + (exec $QEMU_IMG_CMD "$@") > >> +} > >> + > >> +_qemu_io_wrapper() > >> +{ > >> + (exec $QEMU_IO_CMD "$@") > >> +} > >> + > >> +_qemu_nbd_wrapper() > >> +{ > >> + (exec $QEMU_NBD_CMD "$@") > >> +} > >> + > > > > Repeat as appropriate, above. > > > >> +export QEMU=_qemu_wrapper > >> +export QEMU_IMG=_qemu_img_wrapper > >> +export QEMU_IO=_qemu_io_wrapper > >> +export QEMU_NBD=_qemu_nbd_wrapper > >> + > >> default_machine=$($QEMU -machine \? | awk '/(default)/{print $1}') > >> default_alias_machine=$($QEMU -machine \? |\ > >> awk -v var_default_machine="$default_machine"\)\ > >> diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc > >> index 22d3514..28e4bea 100644 > >> --- a/tests/qemu-iotests/common.rc > >> +++ b/tests/qemu-iotests/common.rc > >> @@ -439,7 +439,17 @@ _unsupported_imgopts() > >> # > >> _require_command() > >> { > >> - eval c=\$$1 > >> + if [ "$1" = "QEMU" ]; then > >> + c=$QEMU_PROG > >> + elif [ "$1" = "QEMU_IMG" ]; then > >> + c=$QEMU_IMG_PROG > >> + elif [ "$1" = "QEMU_IO" ]; then > >> + c=$QEMU_IO_PROG > >> + elif [ "$1" = "QEMU_NBD" ]; then > >> + c=$QEMU_NBD_PROG > >> + else > >> + eval c=\$$1 > >> + fi > >> [ -x "$c" ] || _notrun "$1 utility required, skipped this test" > >> } > >> > >> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py > >> index 5579253..927c74a 100644 > >> --- a/tests/qemu-iotests/iotests.py > >> +++ b/tests/qemu-iotests/iotests.py > >> @@ -33,9 +33,9 @@ __all__ = ['imgfmt', 'imgproto', 'test_dir' 'qemu_img', 'qemu_io', > >> > >> # This will not work if arguments or path contain spaces but is necessary if we > >> # want to support the override options that ./check supports. > >> -qemu_img_args = os.environ.get('QEMU_IMG', 'qemu-img').strip().split(' ') > >> -qemu_io_args = os.environ.get('QEMU_IO', 'qemu-io').strip().split(' ') > >> -qemu_args = os.environ.get('QEMU', 'qemu').strip().split(' ') > >> +qemu_img_args = os.environ.get('QEMU_IMG_CMD', 'qemu-img').strip().split(' ') > >> +qemu_io_args = os.environ.get('QEMU_IO_CMD', 'qemu-io').strip().split(' ') > >> +qemu_args = os.environ.get('QEMU_CMD', 'qemu').strip().split(' ') > >> > >> imgfmt = os.environ.get('IMGFMT', 'raw') > >> imgproto = os.environ.get('IMGPROTO', 'file') > >> -- > >> 2.5.0 > >> > >> > > From MAILER-DAEMON Wed Sep 02 11:37:55 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXA6l-0007BC-TG for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 11:37:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXA6j-0007Ag-SX for qemu-block@nongnu.org; Wed, 02 Sep 2015 11:37:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXA6g-0008AV-MO for qemu-block@nongnu.org; Wed, 02 Sep 2015 11:37:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXA6g-0008AE-Ex; Wed, 02 Sep 2015 11:37:50 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 6693AC0E9161; Wed, 2 Sep 2015 15:37:49 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82FblgG002300; Wed, 2 Sep 2015 11:37:48 -0400 To: Wen Congyang , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-2-git-send-email-wency@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E717C7.5050303@redhat.com> Date: Wed, 2 Sep 2015 09:37:43 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1441183880-26993-2-git-send-email-wency@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PbvqhKbmJaT3gldSnJbxkI1h0433nxsmM" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 01/16] introduce a new API to enable/disable attach device model X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 15:37:55 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --PbvqhKbmJaT3gldSnJbxkI1h0433nxsmM Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/02/2015 02:51 AM, Wen Congyang wrote: > Signed-off-by: Wen Congyang > --- > block/block-backend.c | 24 ++++++++++++++++++++++++ > include/sysemu/block-backend.h | 2 ++ > 2 files changed, 26 insertions(+) >=20 > diff --git a/block/block-backend.c b/block/block-backend.c > index aee8a12..72d8b2c 100644 > --- a/block/block-backend.c > +++ b/block/block-backend.c > @@ -344,6 +344,30 @@ void *blk_get_attached_dev(BlockBackend *blk) > } > =20 > /* > + * Disable to attach a device mode to @blk. s/to attach/attaching/ s/mode/model/ But I'm not even sure this patch makes sense. I'd rather see Max's work go in that allows for a BB without a BDS as representing a drive without media, because then it is clear - either a BB has an associated BDS (and cannot attach another one), or it does not (and attaching is fine). > + * Return 0 on success, -EBUSY when a device model is attached already= =2E > + */ > +int blk_disable_attach_dev(BlockBackend *blk) > +{ > + if (blk->dev) { > + return blk->dev =3D=3D (void *)-1 ? 0 : -EBUSY; > + } > + > + blk->dev =3D (void *)-1; > + return 0; > +} > + > +/* > + * Enable to attach a device mode to @blk. > + */ > +void blk_enable_attach_dev(BlockBackend *blk) > +{ > + if (blk->dev =3D=3D (void *)-1) { At the very least, if we allow a special sentinel to represent a BB without a BDS (other than NULL, the way Max's series does it), it should at least be wrapped by a macro, rather than using '(void *)-1' at multiple call sites. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --PbvqhKbmJaT3gldSnJbxkI1h0433nxsmM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5xfHAAoJEKeha0olJ0NqvvoIAI4iAOWL4JBkd7JkdULQhvkj Od2Vn5HAvc2I/33PwxeZCP3qKtFhapJpmvoqLASuwkedY2aj+OLBEpwaFCRezWIE Y9F1cPCK4IuWfD1W+UhNrLqVAZiiPcxQLHau4c5DITAHHtiWeaeH0pKwuv5dYZnm gVaa5LDAnvKIFgyhalqvRLnWvB0Sd6ymwSnxcRNYgns6+Wv4P17cl+a25QFn2pbo 5HqCIzvqYrd4Bjc4gzLLBxtZB3zraZW+Cx8+nEtcsM7hzznublyTgnsudg4BQo4I tKT+8OO8Et2EAe4jiOLSN0i2ttxSN9D61qZJDY2AmAzisr7dAjpclh0yDQn5VFY= =FEd2 -----END PGP SIGNATURE----- --PbvqhKbmJaT3gldSnJbxkI1h0433nxsmM-- From MAILER-DAEMON Wed Sep 02 11:40:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXA9H-0001Qw-2w for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 11:40:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXA9E-0001NU-PY for qemu-block@nongnu.org; Wed, 02 Sep 2015 11:40:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXA9B-0000wx-Iw for qemu-block@nongnu.org; Wed, 02 Sep 2015 11:40:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58850) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXA9B-0000wk-Cn; Wed, 02 Sep 2015 11:40:25 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 83B1FAB997; Wed, 2 Sep 2015 15:40:24 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82FeMf4030420; Wed, 2 Sep 2015 11:40:23 -0400 To: Wen Congyang , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-3-git-send-email-wency@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E71866.5050502@redhat.com> Date: Wed, 2 Sep 2015 09:40:22 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1441183880-26993-3-git-send-email-wency@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ioPik2IaLVNwkLaeiQdRvJwUBPddrHJW6" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 02/16] introduce a new API to check if blk is attached X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 15:40:29 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ioPik2IaLVNwkLaeiQdRvJwUBPddrHJW6 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/02/2015 02:51 AM, Wen Congyang wrote: > Signed-off-by: Wen Congyang > --- > block.c | 4 ++-- > block/block-backend.c | 9 +++++++++ > include/sysemu/block-backend.h | 1 + > 3 files changed, 12 insertions(+), 2 deletions(-) >=20 > /* > + * Return true if a device model is attached to @blk already, > + * otherwise, return false. > + */ > +bool blk_is_attached(BlockBackend *blk) > +{ > + return blk !=3D NULL && blk->dev !=3D NULL && blk->dev !=3D (void = *)-1; Again, I don't like the raw magic constant, even if we go with this patch. And it is shorter to write: return blk && blk->dev && blk->dev !=3D MAGIC; But I think it is better to just allow for a NULL BDS to represent an unattached media (in which case Max's patches may already cover what you are trying to do here), rather than trying to overload a special value different from NULL. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ioPik2IaLVNwkLaeiQdRvJwUBPddrHJW6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5xhmAAoJEKeha0olJ0Nq0K0H/3P3A4dVgJKkUEoviSHicEck OvDla/2LbDeBL7jsaKvcNuc48nho20FrNiX7JtHUzc90kUOdSgHfUxZDv9Zb1SIR rnWGrWU6hzYC3i2cThpb8O6j3lB/UVsFjOgLOFn19qf1UWad/g4ukYP8CtivYPFY hQmgDwk834wYocnwr6k65Qqz30o7iQj3bKg3Z71DfE8m24O/B45tCk0QkEp4K3fT f6uUOEOub3WT9+PtDlldQPK3MqZJIuBvHxhPO1gefJmntPdP97k88m2lqnTLTceg pnwa8SuvXk7FcnmOCmAvJYqTwedgp1Bd13zLiP1s6zEU4yZ/pjHramaYNaJKkcw= =ukYN -----END PGP SIGNATURE----- --ioPik2IaLVNwkLaeiQdRvJwUBPddrHJW6-- From MAILER-DAEMON Wed Sep 02 11:43:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXACA-0005h0-3p for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 11:43:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXAC7-0005ed-En for qemu-block@nongnu.org; Wed, 02 Sep 2015 11:43:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXAC2-00031d-Fj for qemu-block@nongnu.org; Wed, 02 Sep 2015 11:43:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54125) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXAC2-00031G-7W; Wed, 02 Sep 2015 11:43:22 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id CE1478E3D1; Wed, 2 Sep 2015 15:43:21 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82FhLKW004735; Wed, 2 Sep 2015 11:43:21 -0400 To: Alberto Garcia , Kevin Wolf References: <457103c2204e849aea3b83ffd78fad049d8d923d.1441014844.git.berto@igalia.com> <55E4B0CC.6070906@redhat.com> <55E4B374.70800@redhat.com> <20150901113111.GB4304@noname.redhat.com> <20150901144002.GF4304@noname.redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E71918.4000300@redhat.com> Date: Wed, 2 Sep 2015 09:43:20 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Q0nL6iwuQmHvKRt4f65rmlg6sDfaWlhgx" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 1/1] block: Allow passing BlockdevOptions to blockdev-snapshot-sync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 15:43:28 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Q0nL6iwuQmHvKRt4f65rmlg6sDfaWlhgx Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/02/2015 08:23 AM, Alberto Garcia wrote: > On Tue 01 Sep 2015 04:40:02 PM CEST, Kevin Wolf wrote: >=20 >>>> Let's avoid such magic and instead add a new, clean blockdev-* >>>> style command. Maybe call it simply blockdev-snapshot; the -sync >>>> part was added because we knew it wouldn't be the final version of >>>> the command. Now we don't have any bdrv_open() in it any more that >>>> could by synchronous or asynchronous. >=20 > Ok, I have a first working prototype of the new command using > references as suggested. >=20 >> { 'struct': 'BlockdevSnapshot', >> 'data': { '*device': 'str', '*node-name': 'str', >> 'snapshot-file': 'str', '*snapshot-node-name': 'str', >> '*format': 'str', '*mode': 'NewImageMode' } } > [...] >> >> What you really need for the version with a reference is just: >> >> { 'struct': 'BlockdevSnapshot', >> 'data': { 'device': 'str', 'snapshot': 'str' } } >=20 > And what do I do with the old BlockdevSnapshot? I guess it can just be > renamed to BlockdevSnapshotSync or something like that? Sure. And one of the nice things with the ongoing introspection work is that qapi type names are NOT exposed as ABI (changing the name of a type affects the generated C code, but does not affect what a QMP client sends over the wire), so it is safe to do. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Q0nL6iwuQmHvKRt4f65rmlg6sDfaWlhgx Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5xkYAAoJEKeha0olJ0NqAusH/2eBuIetQSay0ejwIglKF7On AH+TnOIX+C6wn7QQLMiA5rKdttkOwsC8z1ul1YXvU5Qzr1XT0f/4dAutO/m1Mjdk CdhUaJZggm+MYW0Pgmehmcu3l+8hwPWv1DdsEqDfkT7oAjVCY1sCXjh+8WvuPrPV k1agKU+77CHMxPGASI9+QHFZzUYQQnw6l84ZMOeznSiq+oqzXoZz+wHHSIhd6w7U 0qvgxIF4MpvFcNIE8owhwEKANJvNrtZG9V6Yyn5PhrS9WvMDZ2kOXPCYRDdop6dM y75ToRc6/8CbZUC96H92irWCij6XlrV1MK1QrLKfbiyCHQMFykbw1Dfai0tLw00= =TGN2 -----END PGP SIGNATURE----- --Q0nL6iwuQmHvKRt4f65rmlg6sDfaWlhgx-- From MAILER-DAEMON Wed Sep 02 12:06:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXAYA-0006Qo-VP for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 12:06:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXAY5-0006Js-JN for qemu-block@nongnu.org; Wed, 02 Sep 2015 12:06:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXAY1-000578-EO for qemu-block@nongnu.org; Wed, 02 Sep 2015 12:06:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50014) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXAY1-00056j-71; Wed, 02 Sep 2015 12:06:05 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 681108EA45; Wed, 2 Sep 2015 16:06:04 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82G62PK024262; Wed, 2 Sep 2015 12:06:02 -0400 To: Wen Congyang , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-4-git-send-email-wency@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E71E6A.1000001@redhat.com> Date: Wed, 2 Sep 2015 10:06:02 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1441183880-26993-4-git-send-email-wency@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="fhkWd6MMHPAq1WaKcEaBPtEvqBuLpkcoh" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 03/16] allow writing to the backing file X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 16:06:13 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --fhkWd6MMHPAq1WaKcEaBPtEvqBuLpkcoh Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/02/2015 02:51 AM, Wen Congyang wrote: > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei Not much description in the commit message. I really want an explanation of why this patch is necessary. After all, with 'block-commit', we were able to turn on read-write mode of backing files on an as-needed basis, without having to expose that to the end user. Giving the end user a knob that they must tune feels a bit awkward, and probably means we don't have the design right. > --- > block.c | 41 ++++++++++++++++++++++++++++++++++++++++- > qapi/block-core.json | 7 ++++++- > 2 files changed, 46 insertions(+), 2 deletions(-) >=20 > +#define ALLOW_WRITE_BACKING_FILE "allow-write-backing-file" > +static QemuOptsList backing_file_opts =3D { > + .name =3D "backing_file", > + .head =3D QTAILQ_HEAD_INITIALIZER(backing_file_opts.head), > + .desc =3D { > + { > + .name =3D ALLOW_WRITE_BACKING_FILE, > + .type =3D QEMU_OPT_BOOL, > + .help =3D "allow write to backing file", If you do add more justification for why this patch is necessary, then, s/write/writes/ > +++ b/qapi/block-core.json > @@ -1408,6 +1408,10 @@ > # @detect-zeroes: #optional detect and optimize zero writes (Since 2.1= ) > # (default: off) > # > +# @allow-write-backing-file: #optional whether the backing file is ope= ned in > +# read-write mode. It is only for backing f= ile > +# (Since 2.5 default: false) > +# The name feels a bit long. It sounds like it is an error to pass allow-write-backing-file for a top-level BDS (that is, the BDS associated with a BB). Meanwhile, the default for any backing chain BDS is to open it read-only, regardless of the 'read-only' setting of the parent. But can we just allow 'read-only':false on a backing BDS to mean that the BDS starts life as read-write, without having to add a new parameter? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --fhkWd6MMHPAq1WaKcEaBPtEvqBuLpkcoh Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5x5qAAoJEKeha0olJ0NqLFYH/1ndM8sVrCCYsM9BMeXEgqcS JjVSnUtA9y7j0f5wdDV3u6VQX94U8AGqZRcHE9EVHmtuB1ok0BJ2pApZFXL3VmCy QUdwjMCsGTHaGwwYiz/21qK3n6PLVMyiLXnr9H/ASuLwVtSsS9nS+rW6fYlI+tGz MX1k8TguE4T0MyBoOoxuzGlDUlasgySZX3NpUU/TaMY2gjoeeIuWwpQXWUPHXzS1 rLf9qYaMkqF3dl4baGUgmNErj3VQ6xnuBdMQVxqTmXegaW/z+/5XI5TcsmSda49I JBc16Ft3pTg+kb9RfwDelSeLcI9+ZeIvObhW0jr25W4GEVb544m6RNCZp4nCIq8= =G9Bc -----END PGP SIGNATURE----- --fhkWd6MMHPAq1WaKcEaBPtEvqBuLpkcoh-- From MAILER-DAEMON Wed Sep 02 12:30:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXAvq-0000pw-WF for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 12:30:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXAvn-0000p6-QR for qemu-block@nongnu.org; Wed, 02 Sep 2015 12:30:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXAvi-0007NM-GJ for qemu-block@nongnu.org; Wed, 02 Sep 2015 12:30:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXAvi-0007N3-7n; Wed, 02 Sep 2015 12:30:34 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 8BCCBC15CA88; Wed, 2 Sep 2015 16:30:33 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82GUUqg014703; Wed, 2 Sep 2015 12:30:31 -0400 To: Wen Congyang , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-7-git-send-email-wency@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55E72422.30301@redhat.com> Date: Wed, 2 Sep 2015 10:30:26 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1441183880-26993-7-git-send-email-wency@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="IeHDGbjBTpln4BirIBgLn9FjqJCM6QpBD" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 06/16] quorum: allow ignoring child errors X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 16:30:42 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --IeHDGbjBTpln4BirIBgLn9FjqJCM6QpBD Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/02/2015 02:51 AM, Wen Congyang wrote: > If the child is not ready, read/write/getlength/flush will > return -errno. It is not critical error, and can be ignored: > 1. read/write: > Just not report the error event. What happens if all the children report an error? Or is the threshold at play here? For example, if you have a threshold of 3/5, then I'm assuming that if up to two children return an errno, then it is okay to ignore; but if three or more return an errno, you haven't met threshold, so the I/O must fail. Are you ignoring ALL errors (including things like EACCES), or just EIO errors? > 2. getlength: > just ignore it. If all children's getlength return -errno, > and be ignored, return -EIO. > 3. flush: > Just ignore it. If all children's getlength return -errno, s/getlength/flush/ > and be ignored, return 0. Yuck - claiming success when all of the children fail feels dangerous. >=20 > Usage: children.x.ignore-errors=3Dtrue >=20 > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei > Cc: Alberto Garcia > --- > block/quorum.c | 94 ++++++++++++++++++++++++++++++++++++++++++++= ++++---- Interface review only: > +++ b/qapi/block-core.json > @@ -1411,6 +1411,8 @@ > # @allow-write-backing-file: #optional whether the backing file is ope= ned in > # read-write mode. It is only for backing f= ile > # (Since 2.5 default: false) > +# @ignore-errors: #options whether the child's I/O error should be ign= ored. s/options/optional/ s/error/errors/ > +# it is only for quorum's child.(Since 2.5 default: fa= lse) Space after '.' in English sentences. The fact that you are documenting that this option can only be specified for quorum children makes me wonder if it belongs better as an option in BlockdevOptionsQuorum rather than BlockdevOptionsBase. Semantically, it sounds like you are trying to allow for a per-child decision of whether this particular child's errors matter to the overall quorum. So, if we have a 3/5 quorum, we can decide that for children A, B, C, and D, errors cannot be ignored, but for child E, errors are not a problem. As written, you are tying the semantics to each child BDS, and requiring special code to double-check that the property is only ever set if the BDS is used as the child of a quorum. Furthermore, if the property is set, you are then changing what the child does in response to various operations. What if you instead create a list property in the quorum parent? Maybe along the lines of: # @child-errors-okay: #optional an array of named-node children where errors will be ignored (Since 2.5, default empty) { 'struct': 'BlockdevOptionsQuorum', 'data': { '*blkverify': 'bool', 'children': [ 'BlockdevRef' ], 'vote-threshold': 'int', '*rewrite-corrupted': 'bool', '*read-pattern': 'QuorumReadPattern', '*child-errors-okay': ['str'] } } The above example of a 3/5 quorum, where only child E can ignore errors, would then be represented as: { "children": [ "A", "B", "C", "D", "E" ], 'vote-threshold':3, 'child-errors-okay': [ "E" ] } The code to ignore the errors is then done in the quorum itself (the BDS for E does not have to care about a special ignore-errors property, but just always returns the error as usual; and then the quorum is deciding how to handle the error), and you are not polluting the BDS state for something that is quorum-specific, because it is now the quorum itself that tracks the special casing. Finally, why can't hot-plug/unplug of quorum members work? If you are going to always ignore errors from a particular child, then why is that child even part of the quorum? Isn't a better design to just not add the child to the quorum until it is ready and won't be reporting errors? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --IeHDGbjBTpln4BirIBgLn9FjqJCM6QpBD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5yQiAAoJEKeha0olJ0Nq5l4H+QGfz2TJyzQENuB9nS11ozu4 7pYv27rxgLGTVFY9iP3vIdXP4RwnT7qea7Lr5XhLFSjSUK0Uo7mJ9J41qnctM7su dgLz2q7eU+pzFRr8xGMBK9sooKlsih8XrHQslFTNnTCLuMabMaS1gib1zd58cJ5I 41sMt5VuMZGj1Y/7mUvVwedZfA5L9zi20ZtE0jv5rWFrElZ7f7aFJi6Nj4nm3S8v k6GRNBrHJCqguYPu0mTmQ4s8SKifJITyN/4uTH8IyqSAeC0FAh6I9dHbGowN4l4R MihmaVSncYd0RAsUqRn29fxPmf1KIMErXw5spnWtfgfbbIHt8XmYodrgfPElnpM= =OtCu -----END PGP SIGNATURE----- --IeHDGbjBTpln4BirIBgLn9FjqJCM6QpBD-- From MAILER-DAEMON Wed Sep 02 12:33:38 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXAyg-00039z-3X for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 12:33:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXAyZ-00031B-IY for qemu-block@nongnu.org; Wed, 02 Sep 2015 12:33:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXAyV-00006l-AR for qemu-block@nongnu.org; Wed, 02 Sep 2015 12:33:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57743) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXAyV-00006W-3l; Wed, 02 Sep 2015 12:33:27 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id B69B58EA2B; Wed, 2 Sep 2015 16:33:26 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82GXPeX011528; Wed, 2 Sep 2015 12:33:25 -0400 To: Wen Congyang , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-12-git-send-email-wency@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E724D4.4000202@redhat.com> Date: Wed, 2 Sep 2015 10:33:24 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1441183880-26993-12-git-send-email-wency@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="M0pppTO7U6Cdw0GMq7GCTUghonxTOrir5" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Michael Roth , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Luiz Capitulino , Gonglei , Yang Hongyang , zhanghailiang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 11/16] Add new block driver interfaces to control block replication X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 16:33:37 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --M0pppTO7U6Cdw0GMq7GCTUghonxTOrir5 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/02/2015 02:51 AM, Wen Congyang wrote: > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei > Cc: Luiz Capitulino > Cc: Michael Roth > Reviewed-by: Paolo Bonzini > --- > block.c | 43 +++++++++++++++++++++++++++++++++++++++= ++++ > include/block/block.h | 5 +++++ > include/block/block_int.h | 14 ++++++++++++++ > qapi/block-core.json | 15 +++++++++++++++ > 4 files changed, 77 insertions(+) >=20 Just an interface review for now: > +++ b/qapi/block-core.json > @@ -1810,6 +1810,21 @@ > 'data': { '*export': 'str' } } > =20 > ## > +# @ReplicationMode > +# > +# An enumeration of replication modes. > +# > +# @unprotected: Replication is not started or after failover. Maybe: Replication is either not started, or has experienced failover. > +# > +# @primary: Primary mode, the vm's state will be sent to secondary QEM= U. > +# > +# @secondary: Secondary mode, receive the vm's state from primary QEMU= =2E > +# > +# Since: 2.4 You've missed 2.4; this should be 2.5. > +## > +{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] } Where is 'unprotected' in this list? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --M0pppTO7U6Cdw0GMq7GCTUghonxTOrir5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5yTUAAoJEKeha0olJ0NqetEH/0YanyoRj9Ml1/47M7T3z4fA H4+Yq/XhxJnIL+1oxThx+epNyTDlaBk6IWos7J1unQ8gq46SSmv8UZIzNZ+nUWEs g0Lb4Bq5uDWK2DcFLHGSJLOc91yYKZz23dPcw5W42pCxc6t03tfGIuk7Om6L+iA3 Cc3svUKCfopyP3F+KaJdWUACyy6WAjMHLFhAzYAh0PCLGcnISXKyvvGVSMeRnT9E qk/krS0keL6OUYPA9tI0fI5OT68VSNjiQB/oN0n5aKvgJkKJ3ZpheffudS4WSg5Z VYNBBfSz7FHzn4g9lCc55m83VVeHAnF7u0C0sOzJKhh8eQ7VhIL3mzS7gx4aCTE= =+j15 -----END PGP SIGNATURE----- --M0pppTO7U6Cdw0GMq7GCTUghonxTOrir5-- From MAILER-DAEMON Wed Sep 02 12:36:50 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXB1m-0005k0-NR for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 12:36:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXB1k-0005jc-6F for qemu-block@nongnu.org; Wed, 02 Sep 2015 12:36:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXB1f-0001l8-Ts for qemu-block@nongnu.org; Wed, 02 Sep 2015 12:36:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47160) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXB1f-0001kw-La; Wed, 02 Sep 2015 12:36:43 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 219DAA145C; Wed, 2 Sep 2015 16:36:43 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82GafuX018258; Wed, 2 Sep 2015 12:36:41 -0400 To: Wen Congyang , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-16-git-send-email-wency@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E72599.6080107@redhat.com> Date: Wed, 2 Sep 2015 10:36:41 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1441183880-26993-16-git-send-email-wency@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="l4xoGdTEtM5jJTqGnGVKR7VB25UCHPkLQ" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 15/16] support replication driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 16:36:49 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --l4xoGdTEtM5jJTqGnGVKR7VB25UCHPkLQ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/02/2015 02:51 AM, Wen Congyang wrote: > Signed-off-by: Wen Congyang > --- > qapi/block-core.json | 18 ++++++++++++++++-- > 1 file changed, 16 insertions(+), 2 deletions(-) >=20 > diff --git a/qapi/block-core.json b/qapi/block-core.json > index 96f0530..86275e3 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -1383,7 +1383,7 @@ > 'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',= > 'host_floppy', 'http', 'https', 'null-aio', 'null-co', 'pa= rallels', > 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'v= hdx', > - 'vmdk', 'vpc', 'vvfat', 'nbd' ] } > + 'vmdk', 'vpc', 'vvfat', 'nbd', 'replication' ] } 'nbd' is not in the current qemu.git; which means your patch series depends on a prerequisite series. Please mention that sort of information in your cover letter. Please keep this enum in alphabetical order. Missing documentation under @drv of BlockDeviceInfo that this was introduced in 2.5. > =20 > ## > # @BlockdevOptionsBase > @@ -1825,6 +1825,19 @@ > { 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] } > =20 > ## > +# @BlockdevOptionsReplication > +# > +# Driver specific block device options for replication > +# > +# @mode: the replication mode Can the mode be 'unprotected', or must it be 'primary' or 'secondary' when first creating a replication BDS? > +# > +# Since: 2.5 > +## > +{ 'struct': 'BlockdevOptionsReplication', > + 'base': 'BlockdevOptionsGenericFormat', > + 'data': { 'mode': 'ReplicationMode' } } > + > +## > # @BlockdevOptions > # > # Options for creating a block device. > @@ -1869,7 +1882,8 @@ > 'vhdx': 'BlockdevOptionsGenericFormat', > 'vmdk': 'BlockdevOptionsGenericCOWFormat', > 'vpc': 'BlockdevOptionsGenericFormat', > - 'vvfat': 'BlockdevOptionsVVFAT' > + 'vvfat': 'BlockdevOptionsVVFAT', > + 'replication':'BlockdevOptionsReplication' > } } It helps to keep this alphabetical. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --l4xoGdTEtM5jJTqGnGVKR7VB25UCHPkLQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5yWZAAoJEKeha0olJ0NqpasH/1n/v2EP0/+OWMgR0+9Ih57N 20LiJBAWZ9cCNs+QQtSTtgpkvJHYobzeVI33WuDjXyXtDbJCBNlOVNgUIrjtZ3a1 wecux2ZBEUHfG1Be7ATuHlalR0Oh+FG8dNskEQvvw7HXyKFEK9brZzJQRhfct4we 3Evs+h55FoNjTByHnPEetl37ceXcHMsxDSo2TikolemjCsOJtc0BQvVtXDpdxasp E6UZ+sNo54BFRXlG70yLon44woL43NJRf7GlenIsyf7A1ikic85Huf33u7nY3e2J 9igmRNmB8gVbvXQoZUlXNeBcuDQGaaHHT/fx5S+v2QTMD2TGsXU0KcopCqNlizI= =dz4a -----END PGP SIGNATURE----- --l4xoGdTEtM5jJTqGnGVKR7VB25UCHPkLQ-- From MAILER-DAEMON Wed Sep 02 14:50:42 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXD7K-0005Gk-2V for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 14:50:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXD7F-0005E8-Uc for qemu-block@nongnu.org; Wed, 02 Sep 2015 14:50:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXD70-0005ah-Ou for qemu-block@nongnu.org; Wed, 02 Sep 2015 14:50:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXD70-0005Zl-Di; Wed, 02 Sep 2015 14:50:22 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 3F0E2C0F05E3; Wed, 2 Sep 2015 18:50:21 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82IoJbx028294; Wed, 2 Sep 2015 14:50:19 -0400 To: Wen Congyang , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-5-git-send-email-wency@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55E744E6.5040502@redhat.com> Date: Wed, 2 Sep 2015 12:50:14 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1441183880-26993-5-git-send-email-wency@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pL0aoTIlSaxu0ocNGJC2ngMQBWXt2VfMg" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 04/16] block: Allow references for backing files X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 18:50:39 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --pL0aoTIlSaxu0ocNGJC2ngMQBWXt2VfMg Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/02/2015 02:51 AM, Wen Congyang wrote: > Usage: > -drive file=3Dxxx,id=3DY, \ > -drive file=3Dxxxx,id=3DX,backing.backing_reference=3DY >=20 > It will create such backing chain: > {virtio-blk dev 'Y'} {virtio-blk dev 'X'} > | | > | | > v v >=20 > [base] <- [mid] <- ( Y ) <----------------- ( X ) This makes any changes to 'Y' have unspecified effects on 'X'. While we may have a valid reason to use a backing BDS in more than one chain, I seriously doubt anyone will ever want to have two guest-visible -drive's that are both read-write where one can corrupt the other. I can totally see the point of having BDS 'Y' exist for checkpoints or some other non-guest-visible action, so I'm not saying this patch is wrong, just that the commit message is picking a poor example of how it would be used= =2E >=20 > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei > --- > block.c | 39 +++++++++++++++++++++++++++++++++++---- > include/block/block.h | 1 + > 2 files changed, 36 insertions(+), 4 deletions(-) >=20 > diff --git a/block.c b/block.c > index d02d9e9..f93c50d 100644 > --- a/block.c > +++ b/block.c > @@ -1179,6 +1179,7 @@ out: > } > =20 > #define ALLOW_WRITE_BACKING_FILE "allow-write-backing-file" > +#define BACKING_REFERENCE "backing_reference" Why the inconsistency in '-' vs. '_'? I'd stick with dash here. > static QemuOptsList backing_file_opts =3D { > .name =3D "backing_file", > .head =3D QTAILQ_HEAD_INITIALIZER(backing_file_opts.head), > @@ -1188,6 +1189,11 @@ static QemuOptsList backing_file_opts =3D { > .type =3D QEMU_OPT_BOOL, > .help =3D "allow write to backing file", > }, > + { > + .name =3D BACKING_REFERENCE, > + .type =3D QEMU_OPT_STRING, > + .help =3D "reference to the exsiting BDS", s/exsiting/existing/ But why do we need this? In qapi, BlockdevOptionsGenericCOWFormat already has '*backing':'BlockdevRef', and BlockdevRef already has a choice between 'definition' (object) and 'reference' (string). Or is this just a matter of teaching the command line to do what QMP can already do? In which case, wouldn't: -drive file=3Dxxx,id=3DY, -drive file=3Dxxxx,id=3DX,backing=3DY be the natural mapping of 'backing' being a string rather than a dictiona= ry? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --pL0aoTIlSaxu0ocNGJC2ngMQBWXt2VfMg Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV50TmAAoJEKeha0olJ0Nqfe4H/1nQQIH4UH5ZqPTxC1ElE+Je mVsOb3s1gppTeuEbDdVwxpuGPHUHhtpB3H6RLyr2vUyGczBEpM904qDE6A+ksc0g cxnroexrDLg7H/CDFQwQB5TtuoUZWrRgqTn2pQtdUZXuhWndPvnNBR5Wg3IEPKGc m/fzLTXu8mMACBWPA+eg057r5kNmaZos6u4upCZdBAsCOYESLWimIPog/khF762a 0Xhl1a+BIPgW+DSy0yxNOxH41pWi+buIa9k8DfOLmqrWtTkPJqIqQdd1qn8hadNY cfQ4I36LEDCAU2G96FTJouHO8q9EhBRbGM2iOI5oKDwPUbEdN7V+CNMozKhQb7Y= =DCkR -----END PGP SIGNATURE----- --pL0aoTIlSaxu0ocNGJC2ngMQBWXt2VfMg-- From MAILER-DAEMON Wed Sep 02 14:52:41 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXD9F-0006lW-P7 for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 14:52:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXD9D-0006kO-7v for qemu-block@nongnu.org; Wed, 02 Sep 2015 14:52:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXD98-0006lh-7o for qemu-block@nongnu.org; Wed, 02 Sep 2015 14:52:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50294) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXD98-0006lZ-2S; Wed, 02 Sep 2015 14:52:34 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 8CEEFC0E915D; Wed, 2 Sep 2015 18:52:33 +0000 (UTC) Received: from localhost (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82IqTBb028095 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 2 Sep 2015 14:52:32 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 2 Sep 2015 20:52:24 +0200 Message-Id: <1441219948-13242-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH v2 0/4] iotests: Emit signal-kill messages X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 18:52:40 -0000 Currently, if a qemu-related command (qemu, qemu-io, qemu-img, qemu-nbd) is invoked in an iotest, receives a signal and is subsequently killed (e.g. a segmentation fault), this is not logged in the test output. The first patch in this series makes the bash tests no longer suppress that line, and the second patch adds a similar notification for the python tests. Patch 3 tries to fix some handling of spaces in command filenames, and apparently actually succeeds in doing so (all Python tests work, most bash tests work; if they fail, it's the test's fault). However, it does not fix handling of spaces in arguments: This is because we probably don't have to worry about that anyway, and because it would be pretty difficult to fix. v2: - Patch 1: Added, pulled in from v4 of my "blockdev: BlockBackend and media" series (needed in patch 2) - Patch 2: Added, required because patch 3 now fixes argument handling for the Python iotests - Patch 3: - Fix handling of spaces in command filenames [Jeff] - Fix argument handling for Python iotests (accidental fallout from the above) git-backport-diff against v1: Key: [----] : patches are identical [####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively 001/4:[down] 'iotests: More options for VM.add_drive()' 002/4:[down] 'iotests: Respect -nodefaults in tests 41 and 55' 003/4:[0047] [FC] 'iotests: Do not suppress segfaults in bash tests' 004/4:[----] [--] 'iotests: Warn if python subprocess is killed' Max Reitz (4): iotests: More options for VM.add_drive() iotests: Respect -nodefaults in tests 41 and 55 iotests: Do not suppress segfaults in bash tests iotests: Warn if python subprocess is killed tests/qemu-iotests/039 | 19 +++++---------- tests/qemu-iotests/039.out | 6 ++--- tests/qemu-iotests/041 | 12 +++++++--- tests/qemu-iotests/055 | 10 +++++--- tests/qemu-iotests/061 | 6 +++-- tests/qemu-iotests/061.out | 2 ++ tests/qemu-iotests/check | 8 +++---- tests/qemu-iotests/common.config | 29 +++++++++++++++++++---- tests/qemu-iotests/common.rc | 12 +++++++++- tests/qemu-iotests/iotests.py | 51 ++++++++++++++++++++++++++++++---------- 10 files changed, 110 insertions(+), 45 deletions(-) -- 2.5.1 From MAILER-DAEMON Wed Sep 02 14:52:44 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXD9H-0006mY-TR for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 14:52:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXD9E-0006kd-5O for qemu-block@nongnu.org; Wed, 02 Sep 2015 14:52:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXD9D-0006mN-Bd for qemu-block@nongnu.org; Wed, 02 Sep 2015 14:52:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33184) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXD9D-0006mF-6i; Wed, 02 Sep 2015 14:52:39 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id D545D550D1; Wed, 2 Sep 2015 18:52:38 +0000 (UTC) Received: from localhost (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82IqZ3n032528 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 2 Sep 2015 14:52:38 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 2 Sep 2015 20:52:25 +0200 Message-Id: <1441219948-13242-2-git-send-email-mreitz@redhat.com> In-Reply-To: <1441219948-13242-1-git-send-email-mreitz@redhat.com> References: <1441219948-13242-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH v2 1/4] iotests: More options for VM.add_drive() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 18:52:41 -0000 This patch allows specifying the interface to be used for the drive, and makes specifying a path optional (if the path is None, the "file" option will be omitted, thus creating an empty drive). Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- tests/qemu-iotests/iotests.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 5579253..1f913a1 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -118,13 +118,16 @@ class VM(object): self._args.append('-monitor') self._args.append(args) - def add_drive(self, path, opts=''): + def add_drive(self, path, opts='', interface='virtio'): '''Add a virtio-blk drive to the VM''' - options = ['if=virtio', + options = ['if=%s' % interface, 'format=%s' % imgfmt, 'cache=%s' % cachemode, - 'file=%s' % path, 'id=drive%d' % self._num_drives] + + if path is not None: + options.append('file=%s' % path) + if opts: options.append(opts) -- 2.5.1 From MAILER-DAEMON Wed Sep 02 14:52:52 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXD9Q-00072c-ES for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 14:52:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXD9K-0006s6-4J for qemu-block@nongnu.org; Wed, 02 Sep 2015 14:52:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXD9I-0006pH-Vo for qemu-block@nongnu.org; Wed, 02 Sep 2015 14:52:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49300) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXD9I-0006p9-PR; Wed, 02 Sep 2015 14:52:44 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 6E93C91C02; Wed, 2 Sep 2015 18:52:44 +0000 (UTC) Received: from localhost (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82IqeTO029743 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 2 Sep 2015 14:52:43 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 2 Sep 2015 20:52:26 +0200 Message-Id: <1441219948-13242-3-git-send-email-mreitz@redhat.com> In-Reply-To: <1441219948-13242-1-git-send-email-mreitz@redhat.com> References: <1441219948-13242-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH v2 2/4] iotests: Respect -nodefaults in tests 41 and 55 X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 18:52:51 -0000 While -nodefaults is set in $QEMU_OPTIONS, this is currently (wrongly) ignored for Python iotests. In order to be prepared for when this is fixed, we should explicitly add an IDE CD-ROM drive instead of relying on it being created automatically. Signed-off-by: Max Reitz --- tests/qemu-iotests/041 | 12 +++++++++--- tests/qemu-iotests/055 | 10 +++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index de8ea15..38ca5f1 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -42,6 +42,8 @@ class TestSingleDrive(iotests.QMPTestCase): iotests.create_image(backing_img, self.image_len) qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img) self.vm = iotests.VM().add_drive(test_img) + if iotests.qemu_default_machine == 'pc': + self.vm.add_drive(None, 'media=cdrom', 'ide') self.vm.launch() def tearDown(self): @@ -170,8 +172,8 @@ class TestSingleDrive(iotests.QMPTestCase): if iotests.qemu_default_machine != 'pc': return - result = self.vm.qmp('drive-mirror', device='ide1-cd0', sync='full', - target=target_img) + result = self.vm.qmp('drive-mirror', device='drive1', # CD-ROM + sync='full', target=target_img) self.assert_qmp(result, 'error/class', 'GenericError') def test_image_not_found(self): @@ -710,6 +712,9 @@ class TestRepairQuorum(iotests.QMPTestCase): def setUp(self): self.vm = iotests.VM() + if iotests.qemu_default_machine == 'pc': + self.vm.add_drive(None, 'media=cdrom', 'ide') + # Add each individual quorum images for i in self.IMAGES: qemu_img('create', '-f', iotests.imgfmt, i, @@ -837,7 +842,8 @@ class TestRepairQuorum(iotests.QMPTestCase): if iotests.qemu_default_machine != 'pc': return - result = self.vm.qmp('drive-mirror', device='ide1-cd0', sync='full', + result = self.vm.qmp('drive-mirror', device='drive0', # CD-ROM + sync='full', node_name='repair0', replaces='img1', target=quorum_repair_img, format=iotests.imgfmt) diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055 index e6e0ac4..c8e3578 100755 --- a/tests/qemu-iotests/055 +++ b/tests/qemu-iotests/055 @@ -42,6 +42,8 @@ class TestSingleDrive(iotests.QMPTestCase): qemu_img('create', '-f', iotests.imgfmt, blockdev_target_img, str(TestSingleDrive.image_len)) self.vm = iotests.VM().add_drive(test_img).add_drive(blockdev_target_img) + if iotests.qemu_default_machine == 'pc': + self.vm.add_drive(None, 'media=cdrom', 'ide') self.vm.launch() def tearDown(self): @@ -107,7 +109,7 @@ class TestSingleDrive(iotests.QMPTestCase): if iotests.qemu_default_machine != 'pc': return - result = self.vm.qmp('drive-backup', device='ide1-cd0', + result = self.vm.qmp('drive-backup', device='drive2', # CD-ROM target=target_img, sync='full') self.assert_qmp(result, 'error/class', 'GenericError') @@ -115,7 +117,7 @@ class TestSingleDrive(iotests.QMPTestCase): if iotests.qemu_default_machine != 'pc': return - result = self.vm.qmp('blockdev-backup', device='ide1-cd0', + result = self.vm.qmp('blockdev-backup', device='drive2', # CD-ROM target='drive1', sync='full') self.assert_qmp(result, 'error/class', 'GenericError') @@ -255,6 +257,8 @@ class TestSingleTransaction(iotests.QMPTestCase): qemu_img('create', '-f', iotests.imgfmt, blockdev_target_img, str(TestSingleDrive.image_len)) self.vm = iotests.VM().add_drive(test_img).add_drive(blockdev_target_img) + if iotests.qemu_default_machine == 'pc': + self.vm.add_drive(None, 'media=cdrom', 'ide') self.vm.launch() def tearDown(self): @@ -334,7 +338,7 @@ class TestSingleTransaction(iotests.QMPTestCase): result = self.vm.qmp('transaction', actions=[{ 'type': cmd, - 'data': { 'device': 'ide1-cd0', + 'data': { 'device': 'drive2', # CD-ROM 'target': target, 'sync': 'full' }, } -- 2.5.1 From MAILER-DAEMON Wed Sep 02 14:52:56 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXD9U-000797-7I for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 14:52:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXD9Q-00073L-Pu for qemu-block@nongnu.org; Wed, 02 Sep 2015 14:52:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXD9P-0006r6-2f for qemu-block@nongnu.org; Wed, 02 Sep 2015 14:52:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43309) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXD9O-0006r2-LO; Wed, 02 Sep 2015 14:52:50 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 4DBC7A8E; Wed, 2 Sep 2015 18:52:50 +0000 (UTC) Received: from localhost (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82IqjcH032378 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 2 Sep 2015 14:52:48 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 2 Sep 2015 20:52:27 +0200 Message-Id: <1441219948-13242-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1441219948-13242-1-git-send-email-mreitz@redhat.com> References: <1441219948-13242-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH v2 3/4] iotests: Do not suppress segfaults in bash tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 18:52:54 -0000 Currently, if a qemu/qemu-io/qemu-img/qemu-nbd invocation receives a segmentation fault, that message is invisible in most cases since the output is generally filtered and bash suppresses the segmentation fault notice for any but the last element of a pipe. Most of the time, the test will then fail anyway because of missing output, but not necessarily (as happened with test 82 recently). Fix this by making the corresponding environment variables point to wrapper functions which execute the respective command in a subshell. Giving options to qemu/qemu-io/qemu-img and path names with spaces were broken for the Python tests; this patch "accidentally" fixes that. Signed-off-by: Max Reitz --- tests/qemu-iotests/039 | 19 ++++++------------- tests/qemu-iotests/039.out | 6 +++--- tests/qemu-iotests/061 | 6 ++++-- tests/qemu-iotests/061.out | 2 ++ tests/qemu-iotests/check | 8 ++++---- tests/qemu-iotests/common.config | 29 +++++++++++++++++++++++++---- tests/qemu-iotests/common.rc | 12 +++++++++++- tests/qemu-iotests/iotests.py | 16 ++++++++++++---- 8 files changed, 67 insertions(+), 31 deletions(-) diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 index 859705f..617f397 100755 --- a/tests/qemu-iotests/039 +++ b/tests/qemu-iotests/039 @@ -47,13 +47,6 @@ _supported_os Linux _default_cache_mode "writethrough" _supported_cache_modes "writethrough" -_subshell_exec() -{ - # Executing crashing commands in a subshell prevents information like the - # "Killed" line from being lost - (exec "$@") -} - size=128M echo @@ -74,8 +67,8 @@ echo "== Creating a dirty image file ==" IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img $size -_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \ - -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ +$QEMU_IO -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ | _filter_qemu_io # The dirty bit must be set @@ -109,8 +102,8 @@ echo "== Opening a dirty image read/write should repair it ==" IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img $size -_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \ - -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ +$QEMU_IO -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ | _filter_qemu_io # The dirty bit must be set @@ -127,8 +120,8 @@ echo "== Creating an image file with lazy_refcounts=off ==" IMGOPTS="compat=1.1,lazy_refcounts=off" _make_test_img $size -_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \ - -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ +$QEMU_IO -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ | _filter_qemu_io # The dirty bit must not be set since lazy_refcounts=off diff --git a/tests/qemu-iotests/039.out b/tests/qemu-iotests/039.out index d09751f..b055670 100644 --- a/tests/qemu-iotests/039.out +++ b/tests/qemu-iotests/039.out @@ -11,7 +11,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./039: Killed ( exec "$@" ) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) incompatible_features 0x1 ERROR cluster 5 refcount=0 reference=1 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0 @@ -46,7 +46,7 @@ read 512/512 bytes at offset 0 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./039: Killed ( exec "$@" ) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) incompatible_features 0x1 ERROR cluster 5 refcount=0 reference=1 Rebuilding refcount structure @@ -60,7 +60,7 @@ incompatible_features 0x0 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./039: Killed ( exec "$@" ) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) incompatible_features 0x0 No errors were found on the image. diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 index 8d37f8a..1df887a 100755 --- a/tests/qemu-iotests/061 +++ b/tests/qemu-iotests/061 @@ -58,7 +58,8 @@ echo echo "=== Testing dirty version downgrade ===" echo IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M -$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" 2>&1 \ + | _filter_qemu_io $PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" $PYTHON qcow2.py "$TEST_IMG" dump-header @@ -91,7 +92,8 @@ echo echo "=== Testing dirty lazy_refcounts=off ===" echo IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M -$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" 2>&1 \ + | _filter_qemu_io $PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IMG amend -o "lazy_refcounts=off" "$TEST_IMG" $PYTHON qcow2.py "$TEST_IMG" dump-header diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out index 5ec248f..4505376 100644 --- a/tests/qemu-iotests/061.out +++ b/tests/qemu-iotests/061.out @@ -57,6 +57,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 wrote 131072/131072 bytes at offset 0 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +./common.config: Aborted (core dumped) ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) magic 0x514649fb version 3 backing_file_offset 0x0 @@ -214,6 +215,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 wrote 131072/131072 bytes at offset 0 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +./common.config: Aborted (core dumped) ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) magic 0x514649fb version 3 backing_file_offset 0x0 diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index 6d58203..c350f16 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -231,10 +231,10 @@ FULL_HOST_DETAILS=`_full_platform_details` #FULL_MOUNT_OPTIONS=`_scratch_mount_options` cat <) id 1ZXD9Z-0007II-7W for qemu-block@nongnu.org; Wed, 02 Sep 2015 14:53:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXD9V-0006t2-Os for qemu-block@nongnu.org; Wed, 02 Sep 2015 14:53:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33281) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXD9V-0006sP-IQ; Wed, 02 Sep 2015 14:52:57 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 3CF04461C4; Wed, 2 Sep 2015 18:52:57 +0000 (UTC) Received: from localhost (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82IqpT5032657 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 2 Sep 2015 14:52:56 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 2 Sep 2015 20:52:28 +0200 Message-Id: <1441219948-13242-5-git-send-email-mreitz@redhat.com> In-Reply-To: <1441219948-13242-1-git-send-email-mreitz@redhat.com> References: <1441219948-13242-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH v2 4/4] iotests: Warn if python subprocess is killed X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 18:53:02 -0000 Currently, if a subprocess of a python test (i.e. qemu-io, qemu-img, or qemu) receives a signal and is subsequently aborted, this is not logged. This patch makes python tests always check the exit code of these subprocesses, and emit a message if they have been killed. Signed-off-by: Max Reitz --- tests/qemu-iotests/iotests.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 8e3419f..ff5905f 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -57,20 +57,34 @@ socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper') def qemu_img(*args): '''Run qemu-img and return the exit code''' devnull = open('/dev/null', 'r+') - return subprocess.call(qemu_img_args + list(args), stdin=devnull, stdout=devnull) + exitcode = subprocess.call(qemu_img_args + list(args), stdin=devnull, stdout=devnull) + if exitcode < 0: + sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) + return exitcode def qemu_img_verbose(*args): '''Run qemu-img without suppressing its output and return the exit code''' - return subprocess.call(qemu_img_args + list(args)) + exitcode = subprocess.call(qemu_img_args + list(args)) + if exitcode < 0: + sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) + return exitcode def qemu_img_pipe(*args): '''Run qemu-img and return its output''' - return subprocess.Popen(qemu_img_args + list(args), stdout=subprocess.PIPE).communicate()[0] + subp = subprocess.Popen(qemu_img_args + list(args), stdout=subprocess.PIPE) + exitcode = subp.wait() + if exitcode < 0: + sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) + return subp.communicate()[0] def qemu_io(*args): '''Run qemu-io and return the stdout data''' args = qemu_io_args + list(args) - return subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0] + subp = subprocess.Popen(args, stdout=subprocess.PIPE) + exitcode = subp.wait() + if exitcode < 0: + sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' '.join(args))) + return subp.communicate()[0] def compare_images(img1, img2): '''Return True if two image files are identical''' @@ -208,7 +222,9 @@ class VM(object): '''Terminate the VM and clean up''' if not self._popen is None: self._qmp.cmd('quit') - self._popen.wait() + exitcode = self._popen.wait() + if exitcode < 0: + sys.stderr.write('qemu received signal %i: %s\n' % (-exitcode, ' '.join(self._args))) os.remove(self._monitor_path) os.remove(self._qtest_path) os.remove(self._qemu_log_path) -- 2.5.1 From MAILER-DAEMON Wed Sep 02 15:01:34 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXDHq-0005XQ-NZ for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 15:01:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXDHo-0005We-IT for qemu-block@nongnu.org; Wed, 02 Sep 2015 15:01:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXDHk-0001ry-I2 for qemu-block@nongnu.org; Wed, 02 Sep 2015 15:01:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45386) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXDHk-0001po-B0; Wed, 02 Sep 2015 15:01:28 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 71A6CA83; Wed, 2 Sep 2015 19:01:27 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82J1OoL001607; Wed, 2 Sep 2015 15:01:25 -0400 To: Wen Congyang , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-6-git-send-email-wency@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55E74780.4040804@redhat.com> Date: Wed, 2 Sep 2015 13:01:20 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1441183880-26993-6-git-send-email-wency@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rVD6r7lFhPR0gIejS81b5mq5P8nnEEpvX" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 05/16] introduce a new API qemu_opts_absorb_qdict_by_index() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 19:01:33 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rVD6r7lFhPR0gIejS81b5mq5P8nnEEpvX Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/02/2015 02:51 AM, Wen Congyang wrote: > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei Commit message is a bit sparse. > --- > include/qemu/option.h | 2 ++ > util/qemu-option.c | 44 +++++++++++++++++++++++++++++++++++++++++++= + > 2 files changed, 46 insertions(+) >=20 Missing testsuite exposure of the new function. > /* > + * Adds all QDict entries to the QemuOpts that can be added and remove= s them > + * from the QDict. The key starts with "%index." in the %qdict. When t= his "%index." reads awkwardly (I thought it was a printf-style format). But I'm not sure if "starts with %index followed by '.'" is any better. > + * function returns, the QDict contains only those entries that couldn= 't be > + * added to the QemuOpts. > + */ > +void qemu_opts_absorb_qdict_by_index(QemuOpts *opts, QDict *qdict, > + const char *index, Error **errp) > +{ I didn't review the algorithm closely, but here's a superficial comment: > + const QDictEntry *entry, *next; > + const char *key; > + int len =3D strlen(index); size_t --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --rVD6r7lFhPR0gIejS81b5mq5P8nnEEpvX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV50eAAAoJEKeha0olJ0NqBH4H/RO4RWD7tFwI5mwXWZaKhDD8 tePhRXpYL6Sl9RQftVqpoPrfwOCjG9IvVbFbF7RPDq2K+y3uthBsKo0Ff9H0cRio sRN7A8Ru5t6BRRyrvhO61lrCboiaFzZlxSpxdnvl+efiTVLEjUyAOpYUN7Fyb/uH GzKrT/miJLhHsXGfzaPXo2HaohHpBGO8W4EYtGN6yXq42lGL2uRBVvspu15qh8SM 9UhQHTI/GP+SZtVpD5KnQ6Em+75XWDi7ag1aj0IRKVDZhNXUYtqvJoV98lhT/cQX LBj8FP0KT16PjmB6ASdCXOUlreiE9ET/dH2LYAoXf0q2T/hBXPSgoZm52a9yQzc= =oNr8 -----END PGP SIGNATURE----- --rVD6r7lFhPR0gIejS81b5mq5P8nnEEpvX-- From MAILER-DAEMON Wed Sep 02 15:56:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXE8Y-00036y-HJ for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 15:56:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXE8V-00036K-Ih for qemu-block@nongnu.org; Wed, 02 Sep 2015 15:56:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXE8S-00079a-EE for qemu-block@nongnu.org; Wed, 02 Sep 2015 15:55:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56082) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXE8S-00079L-9G; Wed, 02 Sep 2015 15:55:56 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id B47ADA2025; Wed, 2 Sep 2015 19:55:55 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82Jtsx1027959; Wed, 2 Sep 2015 15:55:55 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1441219948-13242-1-git-send-email-mreitz@redhat.com> <1441219948-13242-3-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E75446.4070807@redhat.com> Date: Wed, 2 Sep 2015 13:55:50 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1441219948-13242-3-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="eTNqdlXbg4xCogNvM4e5P0A9r15SRVSRx" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 2/4] iotests: Respect -nodefaults in tests 41 and 55 X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 19:56:00 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --eTNqdlXbg4xCogNvM4e5P0A9r15SRVSRx Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/02/2015 12:52 PM, Max Reitz wrote: > While -nodefaults is set in $QEMU_OPTIONS, this is currently (wrongly) > ignored for Python iotests. In order to be prepared for when this is > fixed, we should explicitly add an IDE CD-ROM drive instead of relying > on it being created automatically. >=20 > Signed-off-by: Max Reitz > --- > tests/qemu-iotests/041 | 12 +++++++++--- > tests/qemu-iotests/055 | 10 +++++++--- > 2 files changed, 16 insertions(+), 6 deletions(-) Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --eTNqdlXbg4xCogNvM4e5P0A9r15SRVSRx Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV51RGAAoJEKeha0olJ0NqZ50H/1j94QkXAacqCLecXrihq+M6 Mof7njM7zSzOijVJ9EVSX52kGs+2lXo7JBiG87yxtoJvMzuHNqqlKwa4VE3DfoGm w7Hj4Kwl0r43sFTchT/cfkFqCdaqOcftcLM14yN4lK+DZ/mFUpDtekjU7OxYHZQO Kqy3KwnU9pFRS4g5eFDZ2P2qk4buvXyLEoliX/Xt5X+0V2i6UroFC1oiGu6agqPv mobgBrEYu0bbjA8ewfIQrerISCVC4v+8BZQNK9IbOgsGwsWt+KFR/uQPAH2p03ut iDQSENmM+pYc8R/3U3JwsY5lalS+oTGVg6ssqOzA3suF2t6p5QGXtflNuKKaYys= =6As9 -----END PGP SIGNATURE----- --eTNqdlXbg4xCogNvM4e5P0A9r15SRVSRx-- From MAILER-DAEMON Wed Sep 02 16:02:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXEF5-0002AM-Mz for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 16:02:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXEF2-000292-UA for qemu-block@nongnu.org; Wed, 02 Sep 2015 16:02:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXEEz-0002ep-PN for qemu-block@nongnu.org; Wed, 02 Sep 2015 16:02:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59095) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXEEz-0002ei-JH; Wed, 02 Sep 2015 16:02:41 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 047F4A2C34; Wed, 2 Sep 2015 20:02:40 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82K2edi003656; Wed, 2 Sep 2015 16:02:40 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1441219948-13242-1-git-send-email-mreitz@redhat.com> <1441219948-13242-4-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55E755DF.3070506@redhat.com> Date: Wed, 2 Sep 2015 14:02:39 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1441219948-13242-4-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Qs1LH0aBmaPp22Qe8mmSm2jwMNsU6Kfdu" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 3/4] iotests: Do not suppress segfaults in bash tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 20:02:45 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Qs1LH0aBmaPp22Qe8mmSm2jwMNsU6Kfdu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/02/2015 12:52 PM, Max Reitz wrote: > Currently, if a qemu/qemu-io/qemu-img/qemu-nbd invocation receives a > segmentation fault, that message is invisible in most cases since the > output is generally filtered and bash suppresses the segmentation fault= > notice for any but the last element of a pipe. >=20 > Most of the time, the test will then fail anyway because of missing > output, but not necessarily (as happened with test 82 recently). >=20 > Fix this by making the corresponding environment variables point to > wrapper functions which execute the respective command in a subshell. >=20 > Giving options to qemu/qemu-io/qemu-img and path names with spaces were= > broken for the Python tests; this patch "accidentally" fixes that. >=20 > Signed-off-by: Max Reitz > --- Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Qs1LH0aBmaPp22Qe8mmSm2jwMNsU6Kfdu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV51XfAAoJEKeha0olJ0NqfVIH/3hSbgw8f55y8zqQQvEapc6j CQ/3xwCkZC/LgH7B2xDEOKp0fSLWESewBnY5KD9///5yM3K/1De/WQI0L4tOsL1g NwT+9/bZpS6jsX4gpUVz4e5HcGt4HmfJTaT9A1fKkavse4hXGMRIFA1FuL91fq5q +TZnQ/0mL3IhLQrcxX0IlB8KJujocmXpGI4IXMg4Jhn3mO0zZw6D5prm67l9Q591 5HDLlgmlPsga8rTjamZOufa2SQDc7ZVKkOs888hDbOzQ80sLKQNyWkTlhuUGvsZg PffWgIIuaOu7lhGNkvkwsTahDljLFX0cdWDmT0GJLX01m+ObGPfAULY0x3DJzNY= =YS8Y -----END PGP SIGNATURE----- --Qs1LH0aBmaPp22Qe8mmSm2jwMNsU6Kfdu-- From MAILER-DAEMON Wed Sep 02 16:17:11 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXET1-0007RO-OJ for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 16:17:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXET0-0007QR-0W for qemu-block@nongnu.org; Wed, 02 Sep 2015 16:17:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXESw-0008M2-RH for qemu-block@nongnu.org; Wed, 02 Sep 2015 16:17:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39812) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXESw-0008Le-La; Wed, 02 Sep 2015 16:17:06 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 09ABA91C27; Wed, 2 Sep 2015 20:17:05 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82KH5lA006852; Wed, 2 Sep 2015 16:17:05 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1441219948-13242-1-git-send-email-mreitz@redhat.com> <1441219948-13242-5-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E7593C.5090905@redhat.com> Date: Wed, 2 Sep 2015 14:17:00 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1441219948-13242-5-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xQ5Qe3W64Q1XFCgQCqgKOCacOsqd5n4XJ" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 4/4] iotests: Warn if python subprocess is killed X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 20:17:10 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --xQ5Qe3W64Q1XFCgQCqgKOCacOsqd5n4XJ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/02/2015 12:52 PM, Max Reitz wrote: > Currently, if a subprocess of a python test (i.e. qemu-io, qemu-img, or= > qemu) receives a signal and is subsequently aborted, this is not logged= =2E >=20 > This patch makes python tests always check the exit code of these > subprocesses, and emit a message if they have been killed. >=20 > Signed-off-by: Max Reitz > --- > tests/qemu-iotests/iotests.py | 26 +++++++++++++++++++++----- > 1 file changed, 21 insertions(+), 5 deletions(-) >=20 Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --xQ5Qe3W64Q1XFCgQCqgKOCacOsqd5n4XJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV51k8AAoJEKeha0olJ0NqAp0H/0qxQ4mrzvzYh3wrZKboqmIo bwJPcOIY1fv1vMyRV41Y7BNH7Lhho2y1ZqH3bj7tLu2scmSvL180WcLS0xApOOhQ SzySmkqMLCxFK5/UvnLjzn/PT3OhteenQK57nN6vMOhGVeZybh60f5pg1xORKlZg WPi+PoNFEZ6YZ1C+X3+O/cdRgZZsMn1cNA4A4Wt/1A2aqy92mLg6G+CjG/mWyASR ZadijHc9fyxld/nGaIuuI/3i9YaSu7sIO/u5snjZA/66pePETQHDB2GBhllJB6o9 lLGUwKdCWebTblEv961ImqFPXXZzyPWQMo5I7MTsRQBQM7Qt3oA0Q4gZaLWzSQc= =IQTA -----END PGP SIGNATURE----- --xQ5Qe3W64Q1XFCgQCqgKOCacOsqd5n4XJ-- From MAILER-DAEMON Wed Sep 02 16:41:45 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXEqn-0005Pi-LT for mharc-qemu-block@gnu.org; Wed, 02 Sep 2015 16:41:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXEqk-0005PL-PK for qemu-block@nongnu.org; Wed, 02 Sep 2015 16:41:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXEqg-0001pQ-OG for qemu-block@nongnu.org; Wed, 02 Sep 2015 16:41:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57480) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXEqg-0001oi-Ec; Wed, 02 Sep 2015 16:41:38 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id E75B0341AC3; Wed, 2 Sep 2015 20:41:37 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82KfYK4026666; Wed, 2 Sep 2015 16:41:35 -0400 To: Wen Congyang , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-11-git-send-email-wency@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55E75EF9.304@redhat.com> Date: Wed, 2 Sep 2015 14:41:29 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1441183880-26993-11-git-send-email-wency@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ruJCqqaVh8JFgRvH1LWK0Ga6WWnP9xrQO" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 10/16] docs: block replication's description X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 20:41:44 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ruJCqqaVh8JFgRvH1LWK0Ga6WWnP9xrQO Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/02/2015 02:51 AM, Wen Congyang wrote: > Signed-off-by: Wen Congyang > Signed-off-by: Yang Hongyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei > --- > docs/block-replication.txt | 183 +++++++++++++++++++++++++++++++++++++= ++++++++ > 1 file changed, 183 insertions(+) > create mode 100644 docs/block-replication.txt >=20 > + > + 1) Primary write requests will be copied and forwarded to Secondar= y > + QEMU. > + 2) Before Primary write requests are written to Secondary disk, th= e > + original sector content will be read from Secondary disk and > + buffered in the Disk buffer, but it will not overwrite the exis= ting > + sector content(it could be from either "Secondary Write Request= s" or space before '(' in English sentences. > + previous COW of "Primary Write Requests") in the Disk buffer. > + 3) Primary write requests will be written to Secondary disk. > + 4) Secondary write requests will be buffered in the Disk buffer an= d it > + will overwrite the existing sector content in the buffer. > + > +=3D=3D Architecture =3D=3D > + 3 NBD -------> 3 NBD = | > + client || server = 2 filter > + || ^ = ^ > +--------. || | = | > +Primary | || Secondary disk <--------- hidden-disk 5 = <--------- active-disk 4 > +--------' || | backing ^ = backing > + || | | > + || | | > + || '-------------------------' > + || drive-backup sync=3Dnone > + > + > +4) The disk on the secondary is represented by a custom block device > +(called active-disk). It should be an empty disk, and the format shoul= d > +support bdrv_make_empty() and backing file. s/be an empty disk/start as an empty disk/ > + > +5) The hidden-disk is created automatically. It buffers the original c= ontent > +that is modified by the primary VM. It should also be an empty disk, a= nd s/be/start as/ > +the driver supports bdrv_make_empty() and backing file. Missing mention that a drive-backup job is run to allow hidden-disk to buffer any state that would otherwise be lost by the speculative write-through of the NBD server into the secondary disk. > + > +=3D=3D Failure Handling =3D=3D > +There are 6 internal errors when block replication is running: > +1. I/O error on primary disk > +2. Forwarding primary write requests failed > +3. Backup failed > +4. I/O error on secondary disk > +5. I/O error on active disk > +6. Making active disk or hidden disk empty failed > +In case 1 and 5, we just report the error to the disk layer. In case 2= , 3, > +4 and 6, we just report block replication's error to FT/HA manager(whi= ch space before '(' > +decides when to do a new checkpoint, when to do failover). > +There is one internal error when doing failover: > +1. Commiting the data in active disk/hidden disk to secondary disk fai= led s/Commiting/Committing/ > +We just to report this error to FT/HA manager. > + > +=3D=3D New block driver interface =3D=3D > + > +=3D=3D Usage =3D=3D > +Primary: > + -drive if=3Dxxx,driver=3Dquorum,read-pattern=3Dfifo,id=3Dcolo1,vote-= threshold=3D1\ > + children.0.file.filename=3D1.raw,\ > + children.0.driver=3Draw,\ > + > + Run qmp command in primary qemu: > + child_add disk1 child.driver=3Dreplication,child.mode=3Dprimary,\ > + child.file.host=3Dxxx,child.file.port=3Dxxx,\ > + child.file.driver=3Dnbd,child.ignore-errors=3Don My comments earlier in this series mean this step should be two QMP commands: the first is blockdev-add to create an unassociated BDS, the second to then add that BDS into the quorum. > + Note: > + 1. There should be only one NBD Client for each primary disk. > + 2. host is the secondary physical machine's hostname or IP > + 3. Each disk must have its own export name. > + 4. It is all a single argument to -drive and child_add, and you shou= ld > + ignore the leading whitespace. > + 5. The qmp command line must be run after running qmp command line i= n > + secondary qemu. > + > +Secondary: > + -drive if=3Dnone,driver=3Draw,file=3D1.raw,id=3Dcolo1 \ > + -drive if=3Dxxx,driver=3Dreplication,mode=3Dsecondary,\ > + file.file.filename=3Dactive_disk.qcow2,\ > + file.driver=3Dqcow2,\ > + file.backing.file.filename=3Dhidden_disk.qcow2,\ > + file.backing.driver=3Dqcow2,\ > + file.backing.allow-write-backing-file=3Don,\ > + file.backing.backing.backing_reference=3Dcolo1\ > + > + Then run qmp command in secondary qemu: > + nbd-server-start host:port > + nbd-server-add -w colo1 > + > + Note: > + 1. The export name in secondary QEMU command line is the secondary > + disk's id. > + 2. The export name for the same disk must be the same > + 3. The qmp command nbd-server-start and nbd-server-add must be run > + before running the qmp command migrate on primary QEMU > + 4. Don't use nbd-server-start's other options > + 5. Active disk, hidden disk and nbd target's length should be the > + same. > + 6. It is better to put active disk and hidden disk in ramdisk. > + 7. It is all a single argument to -drive, and you should ignore > + the leading whitespace. Missing: document the steps taken during failover (that is, how do I promote a Secondary into a new Primary, and then attach a new Secondary to that point). In particular, I suspect there may be differences between whether you want to roll back to the state of the last checkpoint (in hidden_disk) or just go with the current state of the Secondary (in Active); either way, it probably involves doing an active commit of the state you want into Secondary, then the formation of a new quorum to start handing replication data off through a new NBD client connection. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ruJCqqaVh8JFgRvH1LWK0Ga6WWnP9xrQO Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5175AAoJEKeha0olJ0NqTHIH/RbJ4qdzVnOTAY2XizlQ2Z0i +N4S/USKUQWLS5GX9oqCkXpwJUcP16QDxZTbSLw4Am0E8fDg2bx9mLGHRork8C7a 9QFdPtdeup7HUSvM3EUAXjw4raBlG/IE2rpbvPyU9bN4GItmbMJZGpedsbrwEqVc jF7O7m5t0ESOSULypLvQng116QB11UEZblPi4gbHZSnZaY6AEnsVMIWVF58Nppbu MQ298MXkL0dK+PNlsNxI2INTI4fvU953PWs936DXpxXBXzMvmV/Xu84V9S7ot1Mn RaD6LfxNZsKiKD8jFuMm2WnlxsR3nowQ6azDET9+B3aSNDXD1NrY86L0EviLy3Y= =M+zl -----END PGP SIGNATURE----- --ruJCqqaVh8JFgRvH1LWK0Ga6WWnP9xrQO-- From MAILER-DAEMON Thu Sep 03 10:47:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXVnu-0006jU-4j for mharc-qemu-block@gnu.org; Thu, 03 Sep 2015 10:47:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXVnp-0006cj-U6 for qemu-block@nongnu.org; Thu, 03 Sep 2015 10:47:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXVnl-00058Y-US for qemu-block@nongnu.org; Thu, 03 Sep 2015 10:47:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51336) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXVnl-00058H-P9; Thu, 03 Sep 2015 10:47:45 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 51D64C0AAB18; Thu, 3 Sep 2015 14:47:45 +0000 (UTC) Received: from localhost (ovpn-112-61.phx2.redhat.com [10.3.112.61]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t83ElhQN015698 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Thu, 3 Sep 2015 10:47:44 -0400 Date: Thu, 3 Sep 2015 10:47:42 -0400 From: Jeff Cody To: Alberto Garcia Message-ID: <20150903144742.GC19447@localhost.localdomain> References: <45295c490f1d7c2c2209a19fba8c656967d03d5b.1441140367.git.jcody@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, berrange@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, armbru@redhat.com, programmingkidx@gmail.com Subject: Re: [Qemu-block] [PATCH v2 1/2] util - add automated ID generation utility X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2015 14:47:51 -0000 On Wed, Sep 02, 2015 at 08:35:37AM +0200, Alberto Garcia wrote: > On Wed 02 Sep 2015 12:30:15 AM CEST, Jeff Cody wrote: > > > Multiple sub-systems in QEMU may find it useful to generate IDs > > for objects that a user may reference via QMP or HMP. This patch > > presents a standardized way to do it, so that automatic ID generation > > follows the same rules. > > > + > > +typedef enum IdSubSystems { > > + ID_QDEV, > > + ID_BLOCK, > > + ID_MAX /* last element, used as array size */ > > +} IdSubSystems; > > + > > +char *id_generate(IdSubSystems); > > Not that it matters much, but it seems that everywhere else in the QEMU > source code the rule is to name the parameters in function prototypes. > Indeed... another syntactic tweak to make if a v3 is needed (or a maintainer insists!) > Otherwise, the patch looks good! > > Reviewed-by: Alberto Garcia > > Berto Thanks! -Jeff From MAILER-DAEMON Thu Sep 03 11:02:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXW2C-0000QJ-JE for mharc-qemu-block@gnu.org; Thu, 03 Sep 2015 11:02:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47771) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXW29-0000Ks-6I for qemu-block@nongnu.org; Thu, 03 Sep 2015 11:02:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXW23-0006Co-VR for qemu-block@nongnu.org; Thu, 03 Sep 2015 11:02:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34188) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXW23-0006CC-Qz; Thu, 03 Sep 2015 11:02:31 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 4B73BC0B2B41; Thu, 3 Sep 2015 15:02:31 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-87.ams2.redhat.com [10.36.116.87]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t83F2Scf027735; Thu, 3 Sep 2015 11:02:29 -0400 Date: Thu, 3 Sep 2015 17:02:28 +0200 From: Kevin Wolf To: Jeff Cody Message-ID: <20150903150228.GB8138@noname.redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: berrange@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, armbru@redhat.com, programmingkidx@gmail.com Subject: Re: [Qemu-block] [PATCH v2 0/2] Auto-generated IDs X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2015 15:02:38 -0000 Am 02.09.2015 um 00:30 hat Jeff Cody geschrieben: > Changes from RFC v1: > > Patch 1: Several typos / grammatical errors (thanks Eric, John) > Make id_subsys_str[] const pointer to const strings (thanks Eric) > Moved id_subsys_str[] out from id_generate() (thanks John) > Assert on null string for given id (thanks Eric) > Zero-pad the 2-digit random # (thanks John) > > Patch 2: None > > Born from the conversation on qemu-devel, this generation scheme uses the > format ultimately proposed by Kevin, after list discussion. > > It attempts to keep the ID strings as small as possible, while fulfilling: > > 1.) Guarantee no collisions with a user-specified ID > 2.) Identify the sub-system the ID belongs to > 3.) Guarantee of uniqueness > 4.) Spoiling predictibility, to avoid creating an assumption > of object ordering and parsing (i.e., we don't want users to think > they can guess the next ID based on prior behavior). > > See patch 1 for the generation scheme details. Thanks, applied to the block branch. While applying, I fixed up the id_generate() declaration in the header file to include an identifier for the parameter. Kevin From MAILER-DAEMON Thu Sep 03 11:13:55 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXWD5-0004CD-Bv for mharc-qemu-block@gnu.org; Thu, 03 Sep 2015 11:13:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXWD2-0004BL-Qf for qemu-block@nongnu.org; Thu, 03 Sep 2015 11:13:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXWCx-0002Pe-SB for qemu-block@nongnu.org; Thu, 03 Sep 2015 11:13:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35603) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXWCx-0002PM-Mx; Thu, 03 Sep 2015 11:13:47 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 48D4340C59; Thu, 3 Sep 2015 15:13:47 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-87.ams2.redhat.com [10.36.116.87]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t83FDjSY005939; Thu, 3 Sep 2015 11:13:45 -0400 Date: Thu, 3 Sep 2015 17:13:44 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150903151344.GC8138@noname.redhat.com> References: <1440111638-30188-1-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1440111638-30188-1-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-stable@nongnu.org Subject: Re: [Qemu-block] [PATCH v2] qemu-img: Fix crash in amend invocation X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2015 15:13:53 -0000 Am 21.08.2015 um 01:00 hat Max Reitz geschrieben: > Example: > $ ./qemu-img create -f qcow2 /tmp/t.qcow2 64M > $ ./qemu-img amend -f qcow2 -o backing_file=/tmp/t.qcow2, -o help \ > /tmp/t.qcow2 > > This should not crash. This actually is tested by iotest 082, but not > caught due to the segmentation fault being silent (which is something > that needs to be fixed, too). > > Reported-by: Dr. David Alan Gilbert > Cc: qemu-stable > Signed-off-by: Max Reitz > --- > v2: > - Fix leak introduced by trying to be clever [Eric] > (thank you for catching this!) Thanks, applied to the block branch. Kevin From MAILER-DAEMON Thu Sep 03 11:25:35 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXWON-0001Of-U4 for mharc-qemu-block@gnu.org; Thu, 03 Sep 2015 11:25:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXWOI-0001Mw-EJ for qemu-block@nongnu.org; Thu, 03 Sep 2015 11:25:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXWOH-0007zo-Nc for qemu-block@nongnu.org; Thu, 03 Sep 2015 11:25:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32960) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXWOH-0007zb-Im; Thu, 03 Sep 2015 11:25:29 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 2BBF9AED57; Thu, 3 Sep 2015 15:25:29 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-87.ams2.redhat.com [10.36.116.87]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t83FPRZw014575; Thu, 3 Sep 2015 11:25:27 -0400 Date: Thu, 3 Sep 2015 17:25:26 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150903152526.GD8138@noname.redhat.com> References: <1441219948-13242-1-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441219948-13242-1-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 0/4] iotests: Emit signal-kill messages X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2015 15:25:34 -0000 Am 02.09.2015 um 20:52 hat Max Reitz geschrieben: > Currently, if a qemu-related command (qemu, qemu-io, qemu-img, qemu-nbd) > is invoked in an iotest, receives a signal and is subsequently killed > (e.g. a segmentation fault), this is not logged in the test output. The > first patch in this series makes the bash tests no longer suppress that > line, and the second patch adds a similar notification for the python > tests. > > Patch 3 tries to fix some handling of spaces in command filenames, and > apparently actually succeeds in doing so (all Python tests work, most > bash tests work; if they fail, it's the test's fault). However, it does > not fix handling of spaces in arguments: This is because we probably > don't have to worry about that anyway, and because it would be pretty > difficult to fix. Thanks, applied to the block branch. Kevin From MAILER-DAEMON Thu Sep 03 11:44:45 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXWgv-0004KX-PG for mharc-qemu-block@gnu.org; Thu, 03 Sep 2015 11:44:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXWgs-0004En-W0 for qemu-block@nongnu.org; Thu, 03 Sep 2015 11:44:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXWgp-00015g-Lv for qemu-block@nongnu.org; Thu, 03 Sep 2015 11:44:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47042) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXWgp-00015c-F9; Thu, 03 Sep 2015 11:44:39 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 18A688CF65; Thu, 3 Sep 2015 15:44:39 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-87.ams2.redhat.com [10.36.116.87]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t83FiaDH000895; Thu, 3 Sep 2015 11:44:37 -0400 Date: Thu, 3 Sep 2015 17:44:36 +0200 From: Kevin Wolf To: Stefan Hajnoczi Message-ID: <20150903154436.GE8138@noname.redhat.com> References: <55D3EFF4.7030004@cn.fujitsu.com> <20150902141854.GH1924@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150902141854.GH1924@stefanha-thinkpad.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu block , qemu-devl , Wen Congyang Subject: Re: [Qemu-block] [PATCH] Block: don't do copy-on-read in before_write_notifier X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2015 15:44:44 -0000 Am 02.09.2015 um 16:18 hat Stefan Hajnoczi geschrieben: > On Wed, Aug 19, 2015 at 10:54:44AM +0800, Wen Congyang wrote: > > We will copy data in before_write_notifier to do backup. > > It is a nested I/O request, so we cannot do copy-on-read. > > > > Signed-off-by: Wen Congyang > > --- > > block/backup.c | 19 +++++++++++++------ > > block/io.c | 11 ++++++++++- > > include/block/block.h | 3 +++ > > trace-events | 1 + > > 4 files changed, 27 insertions(+), 7 deletions(-) > > > > diff --git a/block/backup.c b/block/backup.c > > index 965654d..b729c4b 100644 > > --- a/block/backup.c > > +++ b/block/backup.c > > @@ -89,7 +89,8 @@ static void cow_request_end(CowRequest *req) > > > > static int coroutine_fn backup_do_cow(BlockDriverState *bs, > > int64_t sector_num, int nb_sectors, > > - bool *error_is_read) > > + bool *error_is_read, > > + bool is_write_notifier) > > { > > BackupBlockJob *job = (BackupBlockJob *)bs->job; > > CowRequest cow_request; > > @@ -129,8 +130,13 @@ static int coroutine_fn backup_do_cow(BlockDriverState *bs, > > iov.iov_len = n * BDRV_SECTOR_SIZE; > > qemu_iovec_init_external(&bounce_qiov, &iov, 1); > > > > - ret = bdrv_co_readv(bs, start * BACKUP_SECTORS_PER_CLUSTER, n, > > - &bounce_qiov); > > + if (is_write_notifier) { > > + ret = bdrv_co_nested_readv(bs, start * BACKUP_SECTORS_PER_CLUSTER, > > + n, &bounce_qiov); > > + } else { > > + ret = bdrv_co_readv(bs, start * BACKUP_SECTORS_PER_CLUSTER, n, > > + &bounce_qiov); > > + } > > if (ret < 0) { > > trace_backup_do_cow_read_fail(job, start, ret); > > if (error_is_read) { > > @@ -190,7 +196,7 @@ static int coroutine_fn backup_before_write_notify( > > assert((req->offset & (BDRV_SECTOR_SIZE - 1)) == 0); > > assert((req->bytes & (BDRV_SECTOR_SIZE - 1)) == 0); > > > > - return backup_do_cow(req->bs, sector_num, nb_sectors, NULL); > > + return backup_do_cow(req->bs, sector_num, nb_sectors, NULL, true); > > } > > > > static void backup_set_speed(BlockJob *job, int64_t speed, Error **errp) > > @@ -303,7 +309,8 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job) > > return ret; > > } > > ret = backup_do_cow(bs, cluster * BACKUP_SECTORS_PER_CLUSTER, > > - BACKUP_SECTORS_PER_CLUSTER, &error_is_read); > > + BACKUP_SECTORS_PER_CLUSTER, &error_is_read, > > + false); > > if ((ret < 0) && > > backup_error_action(job, error_is_read, -ret) == > > BLOCK_ERROR_ACTION_REPORT) { > > @@ -408,7 +415,7 @@ static void coroutine_fn backup_run(void *opaque) > > } > > /* FULL sync mode we copy the whole drive. */ > > ret = backup_do_cow(bs, start * BACKUP_SECTORS_PER_CLUSTER, > > - BACKUP_SECTORS_PER_CLUSTER, &error_is_read); > > + BACKUP_SECTORS_PER_CLUSTER, &error_is_read, false); > > if (ret < 0) { > > /* Depending on error action, fail now or retry cluster */ > > BlockErrorAction action = > > diff --git a/block/io.c b/block/io.c > > index d4bc83b..04325f9 100644 > > --- a/block/io.c > > +++ b/block/io.c > > @@ -932,7 +932,8 @@ static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs, > > return ret; > > } > > > > - if (bs->copy_on_read) { > > + /* Don't do copy-on-read if we read data before write operation */ > > + if (bs->copy_on_read && !(flags & BDRV_REQ_NESTED)) { > > flags |= BDRV_REQ_COPY_ON_READ; > > } > > > > @@ -1001,6 +1002,14 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, > > return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, 0); > > } > > > > +int coroutine_fn bdrv_co_nested_readv(BlockDriverState *bs, > > + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) > > +{ > > + trace_bdrv_co_nested_readv(bs, sector_num, nb_sectors); > > + > > + return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, BDRV_REQ_NESTED); > > +} > > + > > int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs, > > int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) > > { > > diff --git a/include/block/block.h b/include/block/block.h > > index 608cd4e..f5578b2 100644 > > --- a/include/block/block.h > > +++ b/include/block/block.h > > @@ -60,6 +60,7 @@ typedef enum { > > * opened with BDRV_O_UNMAP. > > */ > > BDRV_REQ_MAY_UNMAP = 0x4, > > + BDRV_REQ_NESTED = 0x8, > > } BdrvRequestFlags; > > > > typedef struct BlockSizes { > > @@ -253,6 +254,8 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, > > int nb_sectors, QEMUIOVector *qiov); > > int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs, > > int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); > > +int coroutine_fn bdrv_co_nested_readv(BlockDriverState *bs, > > + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); > > int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num, > > int nb_sectors, QEMUIOVector *qiov); > > /* > > diff --git a/trace-events b/trace-events > > index 8f9614a..e29e1cf 100644 > > --- a/trace-events > > +++ b/trace-events > > @@ -69,6 +69,7 @@ bdrv_aio_write_zeroes(void *bs, int64_t sector_num, int nb_sectors, int flags, v > > bdrv_lock_medium(void *bs, bool locked) "bs %p locked %d" > > bdrv_co_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" > > bdrv_co_copy_on_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" > > +bdrv_co_nested_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" > > bdrv_co_writev(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" > > bdrv_co_write_zeroes(void *bs, int64_t sector_num, int nb_sector, int flags) "bs %p sector_num %"PRId64" nb_sectors %d flags %#x" > > bdrv_co_io_em(void *bs, int64_t sector_num, int nb_sectors, int is_write, void *acb) "bs %p sector_num %"PRId64" nb_sectors %d is_write %d acb %p" > > This solution looks good to me. > > I think the BDRV_REQ_NESTED and bdrv_co_nested_readv() name is too > vague, especially since there is no documentation about what "nested" > means here. I'm afraid the flag will be (ab)used for other stuff in the > future and we'll end up with confusing/broken semantics. > > Please call it BDRV_REQ_NO_COPY_ON_READ so it's clear what this flag > does. It also makes clear that it's an ugly hack. :-) The scenario that is fixed here is one of the reasons why I disliked these notifiers from the beginning. I still hope that we can move to filter BDSes at some point and get rid of the hacks that were required in the generic block layer to make things work without filters. Kevin From MAILER-DAEMON Thu Sep 03 11:54:37 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXWqT-0005tA-QF for mharc-qemu-block@gnu.org; Thu, 03 Sep 2015 11:54:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXWqR-0005oK-HP for qemu-block@nongnu.org; Thu, 03 Sep 2015 11:54:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXWqQ-0005dO-Ls for qemu-block@nongnu.org; Thu, 03 Sep 2015 11:54:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44669) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXWqQ-0005dG-H5; Thu, 03 Sep 2015 11:54:34 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 2D69EA2025; Thu, 3 Sep 2015 15:54:34 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-87.ams2.redhat.com [10.36.116.87]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t83FsVqh010450; Thu, 3 Sep 2015 11:54:32 -0400 Date: Thu, 3 Sep 2015 17:54:31 +0200 From: Kevin Wolf To: Jeff Cody Message-ID: <20150903155431.GF8138@noname.redhat.com> References: <20150903150228.GB8138@noname.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150903150228.GB8138@noname.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: programmingkidx@gmail.com, berrange@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, armbru@redhat.com Subject: Re: [Qemu-block] [PATCH v2 0/2] Auto-generated IDs X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2015 15:54:36 -0000 Am 03.09.2015 um 17:02 hat Kevin Wolf geschrieben: > Am 02.09.2015 um 00:30 hat Jeff Cody geschrieben: > > Changes from RFC v1: > > > > Patch 1: Several typos / grammatical errors (thanks Eric, John) > > Make id_subsys_str[] const pointer to const strings (thanks Eric) > > Moved id_subsys_str[] out from id_generate() (thanks John) > > Assert on null string for given id (thanks Eric) > > Zero-pad the 2-digit random # (thanks John) > > > > Patch 2: None > > > > Born from the conversation on qemu-devel, this generation scheme uses the > > format ultimately proposed by Kevin, after list discussion. > > > > It attempts to keep the ID strings as small as possible, while fulfilling: > > > > 1.) Guarantee no collisions with a user-specified ID > > 2.) Identify the sub-system the ID belongs to > > 3.) Guarantee of uniqueness > > 4.) Spoiling predictibility, to avoid creating an assumption > > of object ordering and parsing (i.e., we don't want users to think > > they can guess the next ID based on prior behavior). > > > > See patch 1 for the generation scheme details. > > Thanks, applied to the block branch. > > While applying, I fixed up the id_generate() declaration in the header > file to include an identifier for the parameter. I'm afraid we'll need a v3 that fixes the qemu-iotests output for 051 and 067. It will also require a new filter function because of the random part in the ID. Kevin From MAILER-DAEMON Thu Sep 03 12:59:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXXrT-0001lR-ES for mharc-qemu-block@gnu.org; Thu, 03 Sep 2015 12:59:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXXrN-0001Z8-RL for qemu-block@nongnu.org; Thu, 03 Sep 2015 12:59:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXXrM-0004Pr-GF for qemu-block@nongnu.org; Thu, 03 Sep 2015 12:59:37 -0400 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]:35474) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXXrH-0004Nv-Uc; Thu, 03 Sep 2015 12:59:32 -0400 Received: by wicge5 with SMTP id ge5so80687867wic.0; Thu, 03 Sep 2015 09:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=u5gP2OODfXH/k/qinbF8McrTOsJpMGkqu1P0cwB9+UE=; b=FSuuxRIwQoE7tgYbdIIW0DnGjbIdFG4ja5n3GnWe39V2EeVfS4+Wm5Y29pWtZ2XSCK 0kmW7umFj3+ipL0MpAIrpflHtuwtcNYnhwGDek7R39VH5o6GW3LtMn4oy3n+yXaxD9qT 7keWnuFqn70WU2JhqXGLVYaS6dSonwWG0ZrYKRYCyHV+vfZOix4d4H+NY6xAGxVafeFd pY74u8WljAGqPbZnDy+NtuTBNiHpxRRx6SMczRQ5ewS6FGW8xJGUAsr/f8Nk2GJ65EJB M1kXNDW0FksVl8GcFoa0NYb0EyGMS6UFw36fENPPY/2eZl3vxR1+Hv7s5jWAB4DcZKDa Dreg== X-Received: by 10.180.108.103 with SMTP id hj7mr16292300wib.11.1441299571193; Thu, 03 Sep 2015 09:59:31 -0700 (PDT) Received: from localhost (host86-153-218-221.range86-153.btcentralplus.com. [86.153.218.221]) by smtp.gmail.com with ESMTPSA id kb1sm38689135wjc.24.2015.09.03.09.59.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Sep 2015 09:59:30 -0700 (PDT) Date: Thu, 3 Sep 2015 17:59:28 +0100 From: Stefan Hajnoczi To: Peter Lieven Message-ID: <20150903165928.GF18405@stefanha-thinkpad.redhat.com> References: <1440058448-27847-1-git-send-email-pl@kamp.de> <1440058448-27847-3-git-send-email-pl@kamp.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1440058448-27847-3-git-send-email-pl@kamp.de> User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::230 Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 2/2] ide/atapi: partially avoid deadlock if the storage backend is dead X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2015 16:59:42 -0000 On Thu, Aug 20, 2015 at 10:14:08AM +0200, Peter Lieven wrote: > the blk_drain_all() that is executed if the guest issues a DMA cancel > leads to a stuck main loop if the storage backend (e.g. a NFS share) > is unresponsive. > > This scenario is a common case for CDROM images mounted from an > NFS share. In this case a broken NFS server can take down the > whole VM even if the mounted CDROM is not used and was just not > unmounted after usage. > > This approach avoids the blk_drain_all for read-only media and > cancelles the AIO locally and makes the callback a NOP if the > original request is completed after the NFS share is responsive > again. > > Signed-off-by: Peter Lieven > --- > hw/ide/pci.c | 32 ++++++++++++++++++-------------- > 1 file changed, 18 insertions(+), 14 deletions(-) > > diff --git a/hw/ide/pci.c b/hw/ide/pci.c > index d31ff88..a8b4175 100644 > --- a/hw/ide/pci.c > +++ b/hw/ide/pci.c > @@ -240,21 +240,25 @@ void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val) > /* Ignore writes to SSBM if it keeps the old value */ > if ((val & BM_CMD_START) != (bm->cmd & BM_CMD_START)) { > if (!(val & BM_CMD_START)) { > - /* > - * We can't cancel Scatter Gather DMA in the middle of the > - * operation or a partial (not full) DMA transfer would reach > - * the storage so we wait for completion instead (we beahve > - * like if the DMA was completed by the time the guest trying > - * to cancel dma with bmdma_cmd_writeb with BM_CMD_START not > - * set). > - * > - * In the future we'll be able to safely cancel the I/O if the > - * whole DMA operation will be submitted to disk with a single > - * aio operation with preadv/pwritev. > - */ > if (bm->bus->dma->aiocb) { > - blk_drain_all(); > - assert(bm->bus->dma->aiocb == NULL); > + if (!bdrv_is_read_only(bm->bus->dma->aiocb->bs)) { > + /* We can't cancel Scatter Gather DMA in the middle of the > + * operation or a partial (not full) DMA transfer would > + * reach the storage so we wait for completion instead > + * (we beahve like if the DMA was completed by the time the > + * guest trying to cancel dma with bmdma_cmd_writeb with > + * BM_CMD_START not set). */ > + blk_drain_all(); > + assert(bm->bus->dma->aiocb == NULL); > + } else { > + /* On a read-only device (e.g. CDROM) we can't cause incon- > + * sistencies and thus cancel the AIOCB locally and avoid > + * to be called back later if the original request is > + * completed. */ > + BlockAIOCB *aiocb = bm->bus->dma->aiocb; > + aiocb->cb(aiocb->opaque, -ECANCELED); > + aiocb->cb = NULL; I'm concerned that this isn't safe. What happens if the request does complete (e.g. will guest RAM be modified by the read operation)? What happens if a new request is started and then old NOPed request completes? Taking a step back, what are the semantics of writing !(val & BM_CMD_START)? Is the device guaranteed to cancel/complete requests during the register write? From MAILER-DAEMON Thu Sep 03 13:06:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXXxn-0006Rm-OZ for mharc-qemu-block@gnu.org; Thu, 03 Sep 2015 13:06:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXXxg-0006Ie-AI for qemu-block@nongnu.org; Thu, 03 Sep 2015 13:06:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXXxb-0007be-Qb for qemu-block@nongnu.org; Thu, 03 Sep 2015 13:06:08 -0400 Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]:32774) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXXxX-0007Yt-9F; Thu, 03 Sep 2015 13:05:59 -0400 Received: by wiclk2 with SMTP id lk2so5759727wic.0; Thu, 03 Sep 2015 10:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=OBrJFlJuQW3ieqzwqkEde0HTb4hj7BaFGGkKS/5lJmo=; b=R6kXYCXGksqhtFx3mWq55zEGcyZoYmeTi0pn8bqxTV6YHYbOOfjsuyivmn/CBIqPxS 2y9fusIf7Ks5ZBiKK+gSSteaJ2phjWaTCsbrZC83kQ2rKNiJliZ4E5UEZRgRIUTdhgyS i0/9nuqpcOauS1uoRCQU1YeFz9Snef4G1/0V6P+ZI1dhzqVVcufO3HPJ0AeGWVZ26GPR 4DgQyHn6R5cMXKkJNlQzx60sQEAspTK+07nJbcgRv52ILc/uLdDx23ypwNh680uzEfK8 kYpD2P3KQ0uTU2sUpAc2n6Zt0+uaDPvbWh6aGU//O5QAXbiV2eXsRut64B4S5Wf0eqNx HNxQ== X-Received: by 10.194.78.164 with SMTP id c4mr50419208wjx.65.1441299958576; Thu, 03 Sep 2015 10:05:58 -0700 (PDT) Received: from localhost (host86-153-218-221.range86-153.btcentralplus.com. [86.153.218.221]) by smtp.gmail.com with ESMTPSA id f7sm30884wij.17.2015.09.03.10.05.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Sep 2015 10:05:57 -0700 (PDT) Date: Thu, 3 Sep 2015 18:05:54 +0100 From: Stefan Hajnoczi To: Jeff Cody Message-ID: <20150903170554.GG18405@stefanha-thinkpad.redhat.com> References: <1440403565-27432-1-git-send-email-pl@kamp.de> <55DB64CC.2040207@redhat.com> <55DB71BD.3080402@kamp.de> <55DB7ADC.1010109@redhat.com> <20150826153117.GH11016@localhost.localdomain> <55DE0A22.1020302@kamp.de> <20150826191441.GB31272@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150826191441.GB31272@localhost.localdomain> User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::233 Cc: kwolf@redhat.com, Peter Lieven , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCHv2] block/nfs: cache allocated filesize for read-only files X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2015 17:06:14 -0000 On Wed, Aug 26, 2015 at 03:14:41PM -0400, Jeff Cody wrote: > On Wed, Aug 26, 2015 at 08:49:06PM +0200, Peter Lieven wrote: > > Am 26.08.2015 um 17:31 schrieb Jeff Cody: > > > On Mon, Aug 24, 2015 at 10:13:16PM +0200, Max Reitz wrote: > > >> On 24.08.2015 21:34, Peter Lieven wrote: > > >>> Am 24.08.2015 um 20:39 schrieb Max Reitz: > > >>>> On 24.08.2015 10:06, Peter Lieven wrote: > > >>>>> If the file is readonly its not expected to grow so > > >>>>> save the blocking call to nfs_fstat_async and use > > >>>>> the value saved at connection time. Also important > > >>>>> the monitor (and thus the main loop) will not hang > > >>>>> if block device info is queried and the NFS share > > >>>>> is unresponsive. > > >>>>> > > >>>>> Signed-off-by: Peter Lieven > > >>>>> --- > > >>>>> v1->v2: update cache on reopen_prepare [Max] > > >>>>> > > >>>>> block/nfs.c | 35 +++++++++++++++++++++++++++++++++++ > > >>>>> 1 file changed, 35 insertions(+) > > >>>> Reviewed-by: Max Reitz > > >>>> > > >>>> I hope you're ready for the "Stale actual-size value with > > >>>> cache=direct,read-only=on,format=raw files on NFS" reports. :-) > > >>> actually a good point, maybe the cache should only be used if > > >>> > > >>> !(bs->open_flags & BDRV_O_NOCACHE) > > >> Good enough a point to fix it? ;-) > > >> > > >> Max > > >> > > > It seems more inline with expected behavior, to add the cache checking > > > in before using the size cache. Would you be opposed to a v3 with > > > this check added in? > > > > Of course, will send it tomorrow. > > > > > > > > One other concern I have is similar to a concern Max raised earlier - > > > about an external program modifying the raw image, while QEMU has it > > > opened r/o. In particular, I wonder about an NFS server making an > > > image either sparse / non-sparse. If it was exported read-only, it > > > may be a valid assumption that this could be done safely, as it would > > > not change the reported file size or contents, just the allocated size > > > on disk. > > > > This might be a use case. But if I allow caching the allocated filesize > > might not always be correct. This is even the case on a NFS share mounted > > through the kernel where some attributes a cached for some time. > > > > Anyway, would it hurt here if the actual filesize was too small? > > In fact it was incorrect since libnfs support was added :-) > > > > Yeah, I'm not sure what harm it would cause in practice. It is a > fairly edge use case to begin with, and a relatively benign side > affect (especially since you added reopen() support). > > With the cache flag checking, I am comfortable adding my r-b. I don't remember QEMU's behavior on an LVM volume (which can be resized underneath QEMU but isn't expected to grow or shrink under normal operation). The same semantics should probably be used here. Stefan From MAILER-DAEMON Thu Sep 03 14:12:52 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXZ0G-0000cT-Ly for mharc-qemu-block@gnu.org; Thu, 03 Sep 2015 14:12:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXZ0F-0000bw-0M for qemu-block@nongnu.org; Thu, 03 Sep 2015 14:12:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXZ0B-00051p-P8 for qemu-block@nongnu.org; Thu, 03 Sep 2015 14:12:50 -0400 Received: from mail-vk0-f48.google.com ([209.85.213.48]:33035) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXZ0B-00051d-Lv for qemu-block@nongnu.org; Thu, 03 Sep 2015 14:12:47 -0400 Received: by vkbf67 with SMTP id f67so29283998vkb.0 for ; Thu, 03 Sep 2015 11:12:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc :content-type; bh=/Aq0PTHGB/t89jKtoKkjnC6kvKB9swgIhs5Xetme4LI=; b=AgVE4wPw5IPXIHUTNQ1E2s1SenzGeITICCMbjnSBzP1Mg0RzrxneEFaQ4VPi03raTg 9TA3D5VPRDphgDBP9/mpuDvYec3CnZZ5qtBtQxXPtS/v321+Rxsbx4K/1rOXKwow/hIL SXgdjs3p7u7oHeY/KVddgIHoNQ1xa4dbG/NLa9CETZisixvDSlNYDXh7OZJSP2DKwu00 GZVWbkj1Zk6YAqRhSJfsu/PInPPjpg1RKmk2bnfMCkH49lFuuWb2NGhYpFPCJncFjDgT 4qPDcyzHCnkfZaxjmo4b4L7hO92wpddrGXq3U0Hbvp5q0Lihz1STi2T+Ip9qMfFz8KF/ Liow== X-Gm-Message-State: ALoCoQk2vLcSniOflPd6GoiqBNI+qb9wWI61FnfVcfvhESNTnlt2WY59iLkPDvmRs4lDNn/5AUM5 X-Received: by 10.52.176.195 with SMTP id ck3mr33508281vdc.78.1441303967123; Thu, 03 Sep 2015 11:12:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.153.135 with HTTP; Thu, 3 Sep 2015 11:12:27 -0700 (PDT) From: Peter Maydell Date: Thu, 3 Sep 2015 19:12:27 +0100 Message-ID: To: QEMU Developers Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.213.48 Cc: Qemu-block Subject: [Qemu-block] please fix block device FIXMEs in 2.4's changelog X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2015 18:12:51 -0000 There are two lines in 2.4's changelog (http://wiki.qemu.org/ChangeLog/2.4) in the "Block devices in system emulation" section which read: * FIXME: Throttle groups and * FIXME: incremental backup? Could somebody fill these in with real content before we all forget what was and wasn't in 2.4? thanks -- PMM From MAILER-DAEMON Thu Sep 03 14:29:19 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXZGB-00074G-35 for mharc-qemu-block@gnu.org; Thu, 03 Sep 2015 14:29:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXZG9-00072D-99 for qemu-block@nongnu.org; Thu, 03 Sep 2015 14:29:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXZG6-0003mS-4D for qemu-block@nongnu.org; Thu, 03 Sep 2015 14:29:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58412) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXZG5-0003mL-VC; Thu, 03 Sep 2015 14:29:14 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id B9B16A86; Thu, 3 Sep 2015 18:29:12 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t83ITBEj006489; Thu, 3 Sep 2015 14:29:12 -0400 To: Peter Maydell , QEMU Developers References: From: John Snow Message-ID: <55E89177.6040706@redhat.com> Date: Thu, 3 Sep 2015 14:29:11 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Qemu-block Subject: Re: [Qemu-block] [Qemu-devel] please fix block device FIXMEs in 2.4's changelog X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2015 18:29:18 -0000 On 09/03/2015 02:12 PM, Peter Maydell wrote: > There are two lines in 2.4's changelog (http://wiki.qemu.org/ChangeLog/2.4) > in the "Block devices in system emulation" section which read: > > * FIXME: Throttle groups > > and > > * FIXME: incremental backup? > ^ Done. > Could somebody fill these in with real content before we all forget > what was and wasn't in 2.4? > > thanks > -- PMM > From MAILER-DAEMON Thu Sep 03 14:50:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXZaP-0003Gc-IW for mharc-qemu-block@gnu.org; Thu, 03 Sep 2015 14:50:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXZaM-0003EV-Uz for qemu-block@nongnu.org; Thu, 03 Sep 2015 14:50:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXZaM-0000iR-3l for qemu-block@nongnu.org; Thu, 03 Sep 2015 14:50:10 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:43724 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXZaH-00007s-3J; Thu, 03 Sep 2015 14:50:05 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2DoFgC1lehV/5tjdVtdGQEBAYJ/VGmpSgEFAYELlGyFfwKBOTsRAQEBAQEBAYEKQQECAoNeAQEDATo/BQsLISUPASwbBgESiCYMAQjLXwEBAQEBAQEDAQEBAQEdhiyFQoJ2ghUHhCwFjHiIWYUHiTpGg2yDH5FUJoQCPDMBgiSBXIJYgnMBAQE X-IPAS-Result: A2DoFgC1lehV/5tjdVtdGQEBAYJ/VGmpSgEFAYELlGyFfwKBOTsRAQEBAQEBAYEKQQECAoNeAQEDATo/BQsLISUPASwbBgESiCYMAQjLXwEBAQEBAQEDAQEBAQEdhiyFQoJ2ghUHhCwFjHiIWYUHiTpGg2yDH5FUJoQCPDMBgiSBXIJYgnMBAQE X-IronPort-AV: E=Sophos;i="5.17,463,1437429600"; d="scan'208";a="16191076" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 03 Sep 2015 20:49:26 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZXZZe-0003pZ-TN; Thu, 03 Sep 2015 20:49:26 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZXZZe-0005oD-Ma; Thu, 03 Sep 2015 20:49:26 +0200 From: Alberto Garcia To: Peter Maydell , QEMU Developers In-Reply-To: References: User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Thu, 03 Sep 2015 20:49:26 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Qemu-block Subject: Re: [Qemu-block] please fix block device FIXMEs in 2.4's changelog X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2015 18:50:12 -0000 On Thu 03 Sep 2015 08:12:27 PM CEST, Peter Maydell wrote: > There are two lines in 2.4's changelog (http://wiki.qemu.org/ChangeLog/2.4) > in the "Block devices in system emulation" section which read: > > * FIXME: Throttle groups Hmm, why is that twice? There was a line about that already earlier in the document: " I/O throttling now supports groups, so I/O limits can be shared among multiple drives (use -drive throttling.group=). " Berto From MAILER-DAEMON Thu Sep 03 19:32:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXdzb-0006xC-Qq for mharc-qemu-block@gnu.org; Thu, 03 Sep 2015 19:32:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51771) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXdza-0006wW-4C for qemu-block@nongnu.org; Thu, 03 Sep 2015 19:32:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXdzV-0004WW-4c for qemu-block@nongnu.org; Thu, 03 Sep 2015 19:32:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52146) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXdzU-0004WN-TA; Thu, 03 Sep 2015 19:32:25 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 6F522341AD6; Thu, 3 Sep 2015 23:32:24 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t83NWNDi026346; Thu, 3 Sep 2015 19:32:23 -0400 From: John Snow To: qemu-block@nongnu.org Date: Thu, 3 Sep 2015 19:32:22 -0400 Message-Id: <1441323142-22671-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PATCH] atapi: abort transfers with 0 byte limits X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2015 23:32:31 -0000 We're supposed to abort on transfers like this, unless we fill Word 125 of our IDENTIFY data with a default transfer size, which we don't currently do. This is an ATA error, not a SCSI/ATAPI one. See ATA8-ACS3 sections 7.17.6.49 or 7.21.5. If we don't do this, QEMU will loop forever trying to transfer zero bytes, which isn't particularly useful. Signed-off-by: John Snow --- hw/ide/atapi.c | 32 +++++++++++++++++++++++++++----- hw/ide/core.c | 2 +- hw/ide/internal.h | 1 + 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 79dd167..7a4908f 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -1169,20 +1169,28 @@ enum { * 4.1.8) */ CHECK_READY = 0x02, + + /* + * Commands flagged with NONDATA do not in any circumstances return + * any data via ide_atapi_cmd_reply. These commands are exempt from + * the normal byte_count_limit constraints. + * See ATA8-ACS3 "7.21.5 Byte Count Limit" + */ + NONDATA = 0x04, }; static const struct { void (*handler)(IDEState *s, uint8_t *buf); int flags; } atapi_cmd_table[0x100] = { - [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY }, + [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY | NONDATA }, [ 0x03 ] = { cmd_request_sense, ALLOW_UA }, [ 0x12 ] = { cmd_inquiry, ALLOW_UA }, - [ 0x1b ] = { cmd_start_stop_unit, 0 }, /* [1] */ - [ 0x1e ] = { cmd_prevent_allow_medium_removal, 0 }, + [ 0x1b ] = { cmd_start_stop_unit, NONDATA }, /* [1] */ + [ 0x1e ] = { cmd_prevent_allow_medium_removal, NONDATA }, [ 0x25 ] = { cmd_read_cdvd_capacity, CHECK_READY }, [ 0x28 ] = { cmd_read, /* (10) */ CHECK_READY }, - [ 0x2b ] = { cmd_seek, CHECK_READY }, + [ 0x2b ] = { cmd_seek, CHECK_READY | NONDATA }, [ 0x43 ] = { cmd_read_toc_pma_atip, CHECK_READY }, [ 0x46 ] = { cmd_get_configuration, ALLOW_UA }, [ 0x4a ] = { cmd_get_event_status_notification, ALLOW_UA }, @@ -1190,7 +1198,7 @@ static const struct { [ 0x5a ] = { cmd_mode_sense, /* (10) */ 0 }, [ 0xa8 ] = { cmd_read, /* (12) */ CHECK_READY }, [ 0xad ] = { cmd_read_dvd_structure, CHECK_READY }, - [ 0xbb ] = { cmd_set_speed, 0 }, + [ 0xbb ] = { cmd_set_speed, NONDATA }, [ 0xbd ] = { cmd_mechanism_status, 0 }, [ 0xbe ] = { cmd_read_cd, CHECK_READY }, /* [1] handler detects and reports not ready condition itself */ @@ -1251,6 +1259,20 @@ void ide_atapi_cmd(IDEState *s) return; } + /* Nondata commands permit the byte_count_limit to be 0. + * If this is a data-transferring command and BCL is 0, + * we abort at the /ATA/ level, not the ATAPI level. + * See ATA8 ACS3 section 7.17.6.49 and 7.21.5 */ + if (!(atapi_cmd_table[s->io_buffer[0]].flags & NONDATA)) { + /* TODO: Check IDENTIFY data word 125 for default BCL (currently 0) */ + uint16_t byte_count_limit = s->lcyl | (s->hcyl << 8); + if (!byte_count_limit) { + /* TODO: Move abort back into core.c and make static inline again */ + ide_abort_command(s); + return; + } + } + /* Execute the command */ if (atapi_cmd_table[s->io_buffer[0]].handler) { atapi_cmd_table[s->io_buffer[0]].handler(s, buf); diff --git a/hw/ide/core.c b/hw/ide/core.c index 50449ca..28cf535 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -457,7 +457,7 @@ BlockAIOCB *ide_issue_trim(BlockBackend *blk, return &iocb->common; } -static inline void ide_abort_command(IDEState *s) +void ide_abort_command(IDEState *s) { ide_transfer_stop(s); s->status = READY_STAT | ERR_STAT; diff --git a/hw/ide/internal.h b/hw/ide/internal.h index 30fdcbc..40e1aa4 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -537,6 +537,7 @@ void ide_set_sector(IDEState *s, int64_t sector_num); void ide_start_dma(IDEState *s, BlockCompletionFunc *cb); void ide_dma_error(IDEState *s); +void ide_abort_command(IDEState *s); void ide_atapi_cmd_ok(IDEState *s); void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc); -- 2.4.3 From MAILER-DAEMON Fri Sep 04 08:38:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXqGE-00087V-P0 for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 08:38:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXqGA-0007xu-1A for qemu-block@nongnu.org; Fri, 04 Sep 2015 08:38:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXqG8-0007Td-8j for qemu-block@nongnu.org; Fri, 04 Sep 2015 08:38:25 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:50720 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXqG4-0007Sa-4x; Fri, 04 Sep 2015 08:38:20 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CfBgBskOlV/5tjdVtdGQEBAYMFgT2BRqgQAQEBAQEBBQGBC5JvAQmHcgKBNjgUAQEBAQEBAYEKhCQBAQQnUhA/EjwbGRuIFwHKciyGLIlhbAeELAWHMYVGcYdpjHeacCaBSkYcgVduiUsBAQE X-IPAS-Result: A2CfBgBskOlV/5tjdVtdGQEBAYMFgT2BRqgQAQEBAQEBBQGBC5JvAQmHcgKBNjgUAQEBAQEBAYEKhCQBAQQnUhA/EjwbGRuIFwHKciyGLIlhbAeELAWHMYVGcYdpjHeacCaBSkYcgVduiUsBAQE X-IronPort-AV: E=Sophos;i="5.17,469,1437429600"; d="scan'208";a="16908116" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 04 Sep 2015 14:38:17 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZXqG0-0007Z2-8K; Fri, 04 Sep 2015 14:38:16 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZXqFm-0004um-Ae; Fri, 04 Sep 2015 15:38:02 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 4 Sep 2015 15:37:53 +0300 Message-Id: X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v2 2/2] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 12:38:27 -0000 One of the limitations of the 'blockdev-snapshot-sync' command is that it does not allow passing BlockdevOptions to the newly created snapshots, so they are always opened using the default values. Extending the command to allow passing options is not a practical solution because there is overlap between those options and some of the existing parameters of the command. This patch introduces a new 'blockdev-snapshot' command with a simpler interface: it just takes two references to existing block devices that will be used as the source and target for the snapshot. Since the main difference between the two commands is that one of them creates and opens the target image, while the other uses an already opened one, the bulk of the implementation is shared. Signed-off-by: Alberto Garcia --- blockdev.c | 154 ++++++++++++++++++++++++++++++++------------------- qapi-schema.json | 1 + qapi/block-core.json | 26 +++++++++ qmp-commands.hx | 28 ++++++++++ 4 files changed, 153 insertions(+), 56 deletions(-) diff --git a/blockdev.c b/blockdev.c index 6b787c1..db6e3bf 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1183,6 +1183,18 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, &snapshot, errp); } +void qmp_blockdev_snapshot(const char *device, const char *snapshot, + Error **errp) +{ + BlockdevSnapshot snapshot_data = { + .device = (char *) device, + .snapshot = (char *) snapshot + }; + + blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT, + &snapshot_data, errp); +} + void qmp_blockdev_snapshot_internal_sync(const char *device, const char *name, Error **errp) @@ -1521,60 +1533,52 @@ typedef struct ExternalSnapshotState { static void external_snapshot_prepare(BlkTransactionState *common, Error **errp) { - int flags, ret; - QDict *options; + int flags = 0, ret; + QDict *options = NULL; Error *local_err = NULL; - bool has_device = false; + /* Device and node name of the image to generate the snapshot from */ const char *device; - bool has_node_name = false; const char *node_name; - bool has_snapshot_node_name = false; - const char *snapshot_node_name; + /* Reference to the new image (for 'blockdev-snapshot') */ + const char *snapshot_ref; + /* File name of the new image (for 'blockdev-snapshot-sync') */ const char *new_image_file; - const char *format = "qcow2"; - enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; ExternalSnapshotState *state = DO_UPCAST(ExternalSnapshotState, common, common); TransactionAction *action = common->action; - /* get parameters */ - g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC); - - has_device = action->blockdev_snapshot_sync->has_device; - device = action->blockdev_snapshot_sync->device; - has_node_name = action->blockdev_snapshot_sync->has_node_name; - node_name = action->blockdev_snapshot_sync->node_name; - has_snapshot_node_name = - action->blockdev_snapshot_sync->has_snapshot_node_name; - snapshot_node_name = action->blockdev_snapshot_sync->snapshot_node_name; - - new_image_file = action->blockdev_snapshot_sync->snapshot_file; - if (action->blockdev_snapshot_sync->has_format) { - format = action->blockdev_snapshot_sync->format; - } - if (action->blockdev_snapshot_sync->has_mode) { - mode = action->blockdev_snapshot_sync->mode; + /* 'blockdev-snapshot' and 'blockdev-snapshot-sync' have similar + * purpose but a different set of parameters */ + switch (action->kind) { + case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT: + { + BlockdevSnapshot *s = action->blockdev_snapshot; + device = s->device; + node_name = s->device; + new_image_file = NULL; + snapshot_ref = s->snapshot; + } + break; + case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC: + { + BlockdevSnapshotSync *s = action->blockdev_snapshot_sync; + device = s->has_device ? s->device : NULL; + node_name = s->has_node_name ? s->node_name : NULL; + new_image_file = s->snapshot_file; + snapshot_ref = NULL; + } + break; + default: + g_assert_not_reached(); } /* start processing */ - state->old_bs = bdrv_lookup_bs(has_device ? device : NULL, - has_node_name ? node_name : NULL, - &local_err); + state->old_bs = bdrv_lookup_bs(device, node_name, &local_err); if (local_err) { error_propagate(errp, local_err); return; } - if (has_node_name && !has_snapshot_node_name) { - error_setg(errp, "New snapshot node name missing"); - return; - } - - if (has_snapshot_node_name && bdrv_find_node(snapshot_node_name)) { - error_setg(errp, "New snapshot node name already existing"); - return; - } - /* Acquire AioContext now so any threads operating on old_bs stop */ state->aio_context = bdrv_get_aio_context(state->old_bs); aio_context_acquire(state->aio_context); @@ -1601,35 +1605,67 @@ static void external_snapshot_prepare(BlkTransactionState *common, return; } - flags = state->old_bs->open_flags; - - /* create new image w/backing file */ - if (mode != NEW_IMAGE_MODE_EXISTING) { - bdrv_img_create(new_image_file, format, - state->old_bs->filename, - state->old_bs->drv->format_name, - NULL, -1, flags, &local_err, false); - if (local_err) { + if (snapshot_ref) { + if (!bdrv_lookup_bs(snapshot_ref, snapshot_ref, &local_err)) { error_propagate(errp, local_err); return; } } - options = qdict_new(); - if (has_snapshot_node_name) { - qdict_put(options, "node-name", - qstring_from_str(snapshot_node_name)); + if (action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC) { + BlockdevSnapshotSync *s = action->blockdev_snapshot_sync; + const char *format = s->has_format ? s->format : "qcow2"; + enum NewImageMode mode; + const char *snapshot_node_name = + s->has_snapshot_node_name ? s->snapshot_node_name : NULL; + + if (node_name && !snapshot_node_name) { + error_setg(errp, "New snapshot node name missing"); + return; + } + + if (snapshot_node_name && bdrv_find_node(snapshot_node_name)) { + error_setg(errp, "New snapshot node name already existing"); + return; + } + + flags = state->old_bs->open_flags; + + /* create new image w/backing file */ + mode = s->has_mode ? s->mode : NEW_IMAGE_MODE_ABSOLUTE_PATHS; + if (mode != NEW_IMAGE_MODE_EXISTING) { + bdrv_img_create(new_image_file, format, + state->old_bs->filename, + state->old_bs->drv->format_name, + NULL, -1, flags, &local_err, false); + if (local_err) { + error_propagate(errp, local_err); + return; + } + } + + options = qdict_new(); + if (s->has_snapshot_node_name) { + qdict_put(options, "node-name", + qstring_from_str(snapshot_node_name)); + } + qdict_put(options, "driver", qstring_from_str(format)); + + flags |= BDRV_O_NO_BACKING; } - qdict_put(options, "driver", qstring_from_str(format)); - /* TODO Inherit bs->options or only take explicit options with an - * extended QMP command? */ assert(state->new_bs == NULL); - ret = bdrv_open(&state->new_bs, new_image_file, NULL, options, - flags | BDRV_O_NO_BACKING, &local_err); + ret = bdrv_open(&state->new_bs, new_image_file, snapshot_ref, options, + flags, &local_err); /* We will manually add the backing_hd field to the bs later */ if (ret != 0) { error_propagate(errp, local_err); + return; + } + + if (state->new_bs->blk != NULL) { + error_setg(errp, "The snapshot is already in use by %s", + blk_name(state->new_bs->blk)); } } @@ -1818,6 +1854,12 @@ static void abort_commit(BlkTransactionState *common) } static const BdrvActionOps actions[] = { + [TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT] = { + .instance_size = sizeof(ExternalSnapshotState), + .prepare = external_snapshot_prepare, + .commit = external_snapshot_commit, + .abort = external_snapshot_abort, + }, [TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC] = { .instance_size = sizeof(ExternalSnapshotState), .prepare = external_snapshot_prepare, diff --git a/qapi-schema.json b/qapi-schema.json index c32dc20..7dfaea9 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1496,6 +1496,7 @@ ## { 'union': 'TransactionAction', 'data': { + 'blockdev-snapshot': 'BlockdevSnapshot', 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', 'drive-backup': 'DriveBackup', 'blockdev-backup': 'BlockdevBackup', diff --git a/qapi/block-core.json b/qapi/block-core.json index ec50f06..adfae23 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -705,6 +705,19 @@ '*format': 'str', '*mode': 'NewImageMode' } } ## +# @BlockdevSnapshot +# +# @device: device or node name to generate the snapshot from. +# +# @snapshot: reference to the existing block device that will be used +# for the snapshot. +# +# Since 2.5 +## +{ 'struct': 'BlockdevSnapshot', + 'data': { 'device': 'str', 'snapshot': 'str' } } + +## # @DriveBackup # # @device: the name of the device which should be copied. @@ -800,6 +813,19 @@ { 'command': 'blockdev-snapshot-sync', 'data': 'BlockdevSnapshotSync' } + +## +# @blockdev-snapshot +# +# Generates a snapshot of a block device. +# +# For the arguments, see the documentation of BlockdevSnapshot. +# +# Since 2.5 +## +{ 'command': 'blockdev-snapshot', + 'data': 'BlockdevSnapshot' } + ## # @change-backing-file # diff --git a/qmp-commands.hx b/qmp-commands.hx index 495670b..5bc2991 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1454,6 +1454,34 @@ Example: EQMP { + .name = "blockdev-snapshot", + .args_type = "device:s,snapshot:s", + .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot, + }, + +SQMP +blockdev-snapshot +----------------- +Since 2.5 + +Create a snapshot of a block device. 'device' and 'snapshot' both +refer to existing block devices. The former is the one to generate the +snapshot from, and the latter is the target of the snapshot. + +Arguments: + +- "device": snapshot source (json-string) +- "snapshot": snapshot target (json-string) + +Example: + +-> { "execute": "blockdev-snapshot", "arguments": { "device": "ide-hd0", + "snapshot": "node1534" } } +<- { "return": {} } + +EQMP + + { .name = "blockdev-snapshot-internal-sync", .args_type = "device:B,name:s", .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot_internal_sync, -- 2.5.1 From MAILER-DAEMON Fri Sep 04 08:38:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXqGE-00087o-SR for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 08:38:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXqGB-00080E-9u for qemu-block@nongnu.org; Fri, 04 Sep 2015 08:38:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXqGA-0007UE-E1 for qemu-block@nongnu.org; Fri, 04 Sep 2015 08:38:27 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:50708 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXqG3-0007SO-PB; Fri, 04 Sep 2015 08:38:19 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2A7DQBskOlV/5tjdVtdGQEBAYMFgT2BRqgQAQEBAQEBBQGBC5J5h3ICgTY6EgEBAQEBAQGBCoQkAQEEeRA/EjwbGYgyAcpyASuCT4NdiWFsBxeEFQWMd3GHaYd0hQOacCaBSkYcgVduiUsBAQE X-IPAS-Result: A2A7DQBskOlV/5tjdVtdGQEBAYMFgT2BRqgQAQEBAQEBBQGBC5J5h3ICgTY6EgEBAQEBAQGBCoQkAQEEeRA/EjwbGYgyAcpyASuCT4NdiWFsBxeEFQWMd3GHaYd0hQOacCaBSkYcgVduiUsBAQE X-IronPort-AV: E=Sophos;i="5.17,469,1437429600"; d="scan'208";a="16908114" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 04 Sep 2015 14:38:17 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZXqG0-0007Z1-A8; Fri, 04 Sep 2015 14:38:16 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZXqFm-0004uh-9C; Fri, 04 Sep 2015 15:38:02 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 4 Sep 2015 15:37:52 +0300 Message-Id: <85145eb8ea318202b0209aabaed5690cbbf3c688.1441369227.git.berto@igalia.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v2 1/2] block: rename BlockdevSnapshot to BlockdevSnapshotSync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 12:38:28 -0000 We will introduce the 'blockdev-snapshot' command that will require its own struct for the parameters, so we need to rename this one in order to avoid name clashes. Signed-off-by: Alberto Garcia --- blockdev.c | 2 +- qapi-schema.json | 2 +- qapi/block-core.json | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/blockdev.c b/blockdev.c index 3f42863..6b787c1 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1166,7 +1166,7 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, bool has_format, const char *format, bool has_mode, NewImageMode mode, Error **errp) { - BlockdevSnapshot snapshot = { + BlockdevSnapshotSync snapshot = { .has_device = has_device, .device = (char *) device, .has_node_name = has_node_name, diff --git a/qapi-schema.json b/qapi-schema.json index 1521eb7..c32dc20 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1496,7 +1496,7 @@ ## { 'union': 'TransactionAction', 'data': { - 'blockdev-snapshot-sync': 'BlockdevSnapshot', + 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', 'drive-backup': 'DriveBackup', 'blockdev-backup': 'BlockdevBackup', 'abort': 'Abort', diff --git a/qapi/block-core.json b/qapi/block-core.json index cb99cad..ec50f06 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -682,7 +682,7 @@ 'data': [ 'existing', 'absolute-paths' ] } ## -# @BlockdevSnapshot +# @BlockdevSnapshotSync # # Either @device or @node-name must be set but not both. # @@ -699,7 +699,7 @@ # @mode: #optional whether and how QEMU should create a new image, default is # 'absolute-paths'. ## -{ 'struct': 'BlockdevSnapshot', +{ 'struct': 'BlockdevSnapshotSync', 'data': { '*device': 'str', '*node-name': 'str', 'snapshot-file': 'str', '*snapshot-node-name': 'str', '*format': 'str', '*mode': 'NewImageMode' } } @@ -790,7 +790,7 @@ # # Generates a synchronous snapshot of a block device. # -# For the arguments, see the documentation of BlockdevSnapshot. +# For the arguments, see the documentation of BlockdevSnapshotSync. # # Returns: nothing on success # If @device is not a valid block device, DeviceNotFound @@ -798,7 +798,7 @@ # Since 0.14.0 ## { 'command': 'blockdev-snapshot-sync', - 'data': 'BlockdevSnapshot' } + 'data': 'BlockdevSnapshotSync' } ## # @change-backing-file -- 2.5.1 From MAILER-DAEMON Fri Sep 04 08:38:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXqGF-00088J-04 for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 08:38:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXqGB-00080Q-Bn for qemu-block@nongnu.org; Fri, 04 Sep 2015 08:38:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXqGA-0007UK-GT for qemu-block@nongnu.org; Fri, 04 Sep 2015 08:38:27 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:50708 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXqG3-0007SO-5m; Fri, 04 Sep 2015 08:38:19 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BaBQBskOlV/5tjdVtdGQEBAYMFVGmpUQUBAQEBAQEFAYELlEQiCoV7gTg7EQEBAQEBAQGBCoQmAQQCdk86FIhmAQjLEgSGLIpNHoQVBYcxhjeESYMghQeFDoJimnAmgUoBgjhuAYlKAQEB X-IPAS-Result: A2BaBQBskOlV/5tjdVtdGQEBAYMFVGmpUQUBAQEBAQEFAYELlEQiCoV7gTg7EQEBAQEBAQGBCoQmAQQCdk86FIhmAQjLEgSGLIpNHoQVBYcxhjeESYMghQeFDoJimnAmgUoBgjhuAYlKAQEB X-IronPort-AV: E=Sophos;i="5.17,469,1437429600"; d="scan'208";a="16908113" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 04 Sep 2015 14:38:17 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZXqG0-0007Z0-6K; Fri, 04 Sep 2015 14:38:16 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZXqFm-0004ue-6K; Fri, 04 Sep 2015 15:38:02 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 4 Sep 2015 15:37:51 +0300 Message-Id: X-Mailer: git-send-email 2.5.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v2 0/2] Add 'blockdev-snapshot' command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 12:38:28 -0000 Previous attempt to extend blockdev-snapshot-sync: https://lists.gnu.org/archive/html/qemu-block/2015-08/msg00236.html As discussed in the previous thread, this adds a new command called 'blockdev-snapshot', that simply takes references to two existing block devices. I decided to share most of the implementation with the previous 'blockdev-snapshot-sync' since the only differences are in the 'prepare' step. The tests are missing, but I wanted to know first if you are otherwise OK with this approach. If the patches look good I'll write the tests next week. These patches apply on top of two series from Max: - This one allows creating BDS that are not attached to a BlockBackend https://lists.gnu.org/archive/html/qemu-block/2015-07/msg00382.html - This one drops the drv parameter from bdrv_open(), which was preventing us from creating snapshots of images opened with custom runtime options: https://lists.gnu.org/archive/html/qemu-block/2015-08/msg00189.html You cannot apply these two series cleanly on top of each other, so if you want to try my patches without having to merge everything manually, you can get the whole thing here: https://github.com/bertogg/qemu/commits/blockdev-snapshot Comments are welcome! Berto Alberto Garcia (2): block: rename BlockdevSnapshot to BlockdevSnapshotSync block: add a 'blockdev-snapshot' QMP command blockdev.c | 156 ++++++++++++++++++++++++++++++++------------------- qapi-schema.json | 3 +- qapi/block-core.json | 32 ++++++++++- qmp-commands.hx | 28 +++++++++ 4 files changed, 158 insertions(+), 61 deletions(-) -- 2.5.1 From MAILER-DAEMON Fri Sep 04 10:25:34 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXrvq-0002Bb-MJ for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 10:25:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXrvo-00026f-A8 for qemu-block@nongnu.org; Fri, 04 Sep 2015 10:25:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXrvn-0003Ye-B5 for qemu-block@nongnu.org; Fri, 04 Sep 2015 10:25:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56305) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXrvn-0003YX-6G; Fri, 04 Sep 2015 10:25:31 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id D3927A145C; Fri, 4 Sep 2015 14:25:30 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84EPS65014211; Fri, 4 Sep 2015 10:25:29 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <85145eb8ea318202b0209aabaed5690cbbf3c688.1441369227.git.berto@igalia.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E9A9D8.3050601@redhat.com> Date: Fri, 4 Sep 2015 08:25:28 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <85145eb8ea318202b0209aabaed5690cbbf3c688.1441369227.git.berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="HGTsBR4VhU4d5kgdSP4aXikLHno4EVI8S" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v2 1/2] block: rename BlockdevSnapshot to BlockdevSnapshotSync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 14:25:33 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --HGTsBR4VhU4d5kgdSP4aXikLHno4EVI8S Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/04/2015 06:37 AM, Alberto Garcia wrote: > We will introduce the 'blockdev-snapshot' command that will require > its own struct for the parameters, so we need to rename this one in > order to avoid name clashes. >=20 > Signed-off-by: Alberto Garcia > --- > blockdev.c | 2 +- > qapi-schema.json | 2 +- > qapi/block-core.json | 8 ++++---- > 3 files changed, 6 insertions(+), 6 deletions(-) Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --HGTsBR4VhU4d5kgdSP4aXikLHno4EVI8S Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV6anYAAoJEKeha0olJ0NqvPAH/1guxEW5aZ15TRBvFMOsyWJr h5rpZLFZVi8sN9lk2PJ66tgL5XAG+TrS9b6HRP2/hWOcZvaLkXPyLOiD094BW9Ds 39z1Tnnu56gBNsHguLrkrsd/rPSMIMN7OfxtiVxlqY61NwiGHiE2hivEdSZn1Z+x YH9EkNrW8tCnG4Tigd1wHDjgSj2mn2It13B68nUSLC65bLI/DcpmLzwO/lyn8UBS EvHrQ2ALhOjZ52tatd6JOH670jJ1SGy9uzq/TMVIeNczURolQeJ5YasazI1RzDgo yvWzg9YntVlwNN75TISQ1Qgm37gOcEXrR1ZfAytuJjHOSN8Gv74E9TPPGjTlz0M= =qTKP -----END PGP SIGNATURE----- --HGTsBR4VhU4d5kgdSP4aXikLHno4EVI8S-- From MAILER-DAEMON Fri Sep 04 10:42:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXsCC-00060A-8F for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 10:42:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXsC8-0005uE-RX for qemu-block@nongnu.org; Fri, 04 Sep 2015 10:42:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXsC7-0005Ut-BW for qemu-block@nongnu.org; Fri, 04 Sep 2015 10:42:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXsC7-0005Up-2w; Fri, 04 Sep 2015 10:42:23 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id BD3B4C0B2B59; Fri, 4 Sep 2015 14:42:22 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84EgLta025138; Fri, 4 Sep 2015 10:42:21 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55E9ADC9.3000404@redhat.com> Date: Fri, 4 Sep 2015 08:42:17 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="cTL9UISFtmx7CouIcOL0VP1XiLi8U5t3D" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v2 2/2] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 14:42:26 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --cTL9UISFtmx7CouIcOL0VP1XiLi8U5t3D Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/04/2015 06:37 AM, Alberto Garcia wrote: > One of the limitations of the 'blockdev-snapshot-sync' command is that > it does not allow passing BlockdevOptions to the newly created > snapshots, so they are always opened using the default values. >=20 > Extending the command to allow passing options is not a practical > solution because there is overlap between those options and some of > the existing parameters of the command. >=20 > This patch introduces a new 'blockdev-snapshot' command with a simpler > interface: it just takes two references to existing block devices that > will be used as the source and target for the snapshot. >=20 > Since the main difference between the two commands is that one of them > creates and opens the target image, while the other uses an already > opened one, the bulk of the implementation is shared. I like it. Obviously, we have to get the pre-requisites in first, to allow opening a BDS without a BB, but it is nicer overall. >=20 > Signed-off-by: Alberto Garcia > --- > blockdev.c | 154 ++++++++++++++++++++++++++++++++-----------= -------- > qapi-schema.json | 1 + > qapi/block-core.json | 26 +++++++++ > qmp-commands.hx | 28 ++++++++++ > 4 files changed, 153 insertions(+), 56 deletions(-) >=20 > diff --git a/blockdev.c b/blockdev.c > index 6b787c1..db6e3bf 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1183,6 +1183,18 @@ void qmp_blockdev_snapshot_sync(bool has_device,= const char *device, > &snapshot, errp); > } > =20 > +void qmp_blockdev_snapshot(const char *device, const char *snapshot, Is 'node' a better name than 'device' here? > Error **errp) > @@ -1521,60 +1533,52 @@ typedef struct ExternalSnapshotState { > static void external_snapshot_prepare(BlkTransactionState *common, > Error **errp) > { > + /* 'blockdev-snapshot' and 'blockdev-snapshot-sync' have similar > + * purpose but a different set of parameters */ > + switch (action->kind) { > + case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT: > + { > + BlockdevSnapshot *s =3D action->blockdev_snapshot; > + device =3D s->device; > + node_name =3D s->device; Again, I think this should be setting s->node_name, not s->device. > + new_image_file =3D NULL; > + snapshot_ref =3D s->snapshot; > + } > + break; > + case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC: > + { > + BlockdevSnapshotSync *s =3D action->blockdev_snapshot_sync= ; > + device =3D s->has_device ? s->device : NULL; > + node_name =3D s->has_node_name ? s->node_name : NULL; > + new_image_file =3D s->snapshot_file; > + snapshot_ref =3D NULL; > + } > + break; > + default: > + g_assert_not_reached(); > } > =20 > /* start processing */ > - state->old_bs =3D bdrv_lookup_bs(has_device ? device : NULL, > - has_node_name ? node_name : NULL, > - &local_err); > + state->old_bs =3D bdrv_lookup_bs(device, node_name, &local_err); > if (local_err) { > error_propagate(errp, local_err); > return; > } > =20 > - if (has_node_name && !has_snapshot_node_name) { > - error_setg(errp, "New snapshot node name missing"); > - return; > - } > - > - if (has_snapshot_node_name && bdrv_find_node(snapshot_node_name)) = { > - error_setg(errp, "New snapshot node name already existing"); > - return; > - } > - > /* Acquire AioContext now so any threads operating on old_bs stop = */ > state->aio_context =3D bdrv_get_aio_context(state->old_bs); > aio_context_acquire(state->aio_context); > @@ -1601,35 +1605,67 @@ static void external_snapshot_prepare(BlkTransa= ctionState *common, > return; > } > =20 > - flags =3D state->old_bs->open_flags; > - > - /* create new image w/backing file */ > - if (mode !=3D NEW_IMAGE_MODE_EXISTING) { > - bdrv_img_create(new_image_file, format, > - state->old_bs->filename, > - state->old_bs->drv->format_name, > - NULL, -1, flags, &local_err, false); > - if (local_err) { > + if (snapshot_ref) { > + if (!bdrv_lookup_bs(snapshot_ref, snapshot_ref, &local_err)) {= > error_propagate(errp, local_err); > return; > } > } Shouldn't you also check that snapshot_ref does not currently have a backing BDS (as it is the act of creating the snapshot that sets the current device as the backing of the snapshot_ref BDS before altering the BB to point to snapshot_ref as its new BDS)? > +++ b/qapi-schema.json > @@ -1496,6 +1496,7 @@ > ## > { 'union': 'TransactionAction', > 'data': { > + 'blockdev-snapshot': 'BlockdevSnapshot', Missing 'since 2.5' documentation. > 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', > 'drive-backup': 'DriveBackup', > 'blockdev-backup': 'BlockdevBackup', > diff --git a/qapi/block-core.json b/qapi/block-core.json > index ec50f06..adfae23 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -705,6 +705,19 @@ > '*format': 'str', '*mode': 'NewImageMode' } } > =20 > ## > +# @BlockdevSnapshot > +# > +# @device: device or node name to generate the snapshot from. Would naming this 'node' make more sense? > +# > +# @snapshot: reference to the existing block device that will be used > +# for the snapshot. > +# > +# Since 2.5 > +## > +{ 'struct': 'BlockdevSnapshot', > + 'data': { 'device': 'str', 'snapshot': 'str' } } > + > +## > # @DriveBackup > # > # @device: the name of the device which should be copied. > @@ -800,6 +813,19 @@ > { 'command': 'blockdev-snapshot-sync', > 'data': 'BlockdevSnapshotSync' } > =20 > + > +## > +# @blockdev-snapshot > +# > +# Generates a snapshot of a block device. > +# > +# For the arguments, see the documentation of BlockdevSnapshot. > +# > +# Since 2.5 > +## > +{ 'command': 'blockdev-snapshot', > + 'data': 'BlockdevSnapshot' } > + Overall, I like the syntax. > +SQMP > +blockdev-snapshot > +----------------- > +Since 2.5 > + > +Create a snapshot of a block device. 'device' and 'snapshot' both > +refer to existing block devices. The former is the one to generate the= > +snapshot from, and the latter is the target of the snapshot. Is there any better terminology? Maybe: The act of creating a snapshot installs 'device' as the backing image of 'snapshot'; additionally, if 'device' is associated with a block device, the block device changes to using 'snapshot' as its new active image. Hmm - I wonder if that means we should have an optional boolean parameter that allows us to avoid the automatic pivot. After all, with 'blockdev-snapshot-sync', you can specify 'device' and omit 'node-name' to update the device's active layer, or you can omit 'device' and specify 'node-name' to create another qcow2 file but NOT install it as the active layer, regardless of which 'node-name' that serves as the starting point. So when 'node-name' is the BDS node that 'device' is currently visiting, you have control over whether 'device' auto-updates to the new BDS. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --cTL9UISFtmx7CouIcOL0VP1XiLi8U5t3D Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV6a3JAAoJEKeha0olJ0NqMkUH/iMx4C00xKlv9vxo/o8IYKMO Dz96Ad8aOXVq8eaQZyLX4iP/Q0vB4k64xximnoK/5cTchFIgPhTZrShSdst52iEx 1ZNz/ZxgtAT1h533DISac9mTxpL8X2b41ivGiw0nuBBaIbju+OsaU3I/0gt1MWrw 1xrGh+9slkBtJKVTcNB00jmBPvY9BfgJXChM5lEoK4wwOEm2NjHw3zYN7rpe0JSQ TTmAv85x5oGRCxSz0CrsX60h8za7X4+HeHa1DE4bybLYX3OFTGmu8NAR2Jrlxf/N iVkWDnP3f25Z66yHN08hS3sv+CllAFNQb03fv31sWIL2XpC5WBuuU0Rj6WE246Y= =LSbt -----END PGP SIGNATURE----- --cTL9UISFtmx7CouIcOL0VP1XiLi8U5t3D-- From MAILER-DAEMON Fri Sep 04 13:18:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXuda-0000qc-H5 for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 13:18:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudW-0000fG-1r for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXudV-0003cb-BJ for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:18:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60068) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudV-0003cK-2g; Fri, 04 Sep 2015 13:18:49 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 8F4C2461E2; Fri, 4 Sep 2015 17:18:48 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84HIh6f032478; Fri, 4 Sep 2015 13:18:47 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 19:18:26 +0200 Message-Id: <1441387117-27072-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1441387117-27072-1-git-send-email-kwolf@redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v2 02/13] qemu-io: Remove duplicate 'open' error message X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 17:18:51 -0000 qemu_opts_parse_noisily() already prints an error message with the exact reason why the parsing failed. No need to add another less specific one. Signed-off-by: Kevin Wolf --- qemu-io.c | 1 - 1 file changed, 1 deletion(-) diff --git a/qemu-io.c b/qemu-io.c index f1e3a67..269f17c 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -156,7 +156,6 @@ static int open_f(BlockBackend *blk, int argc, char **argv) break; case 'o': if (!qemu_opts_parse_noisily(&empty_opts, optarg, false)) { - printf("could not parse option list -- %s\n", optarg); qemu_opts_reset(&empty_opts); return 0; } -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 13:18:56 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXudb-0000tH-OO for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 13:18:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudY-0000lV-79 for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:18:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXudX-0003eA-7n for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:18:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41841) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudW-0003db-N0; Fri, 04 Sep 2015 13:18:51 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 490BD2BDB57; Fri, 4 Sep 2015 17:18:50 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84HIh6g032478; Fri, 4 Sep 2015 13:18:48 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 19:18:27 +0200 Message-Id: <1441387117-27072-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1441387117-27072-1-git-send-email-kwolf@redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v2 03/13] qemu-io: Add command 'reopen' X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 17:18:53 -0000 Signed-off-by: Kevin Wolf --- qemu-io-cmds.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 53477e1..d6572a8 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1979,6 +1979,95 @@ static const cmdinfo_t map_cmd = { .oneline = "prints the allocated areas of a file", }; +static void reopen_help(void) +{ + printf( +"\n" +" Changes the open options of an already opened image\n" +"\n" +" Example:\n" +" 'reopen -o lazy-refcounts=on' - activates lazy refcount writeback on a qcow2 image\n" +"\n" +" -r, -- Reopen the image read-only\n" +" -c, -- Change the cache mode to the given value\n" +" -o, -- Changes block driver options (cf. 'open' command)\n" +"\n"); +} + +static int reopen_f(BlockBackend *blk, int argc, char **argv); + +static QemuOptsList reopen_opts = { + .name = "reopen", + .merge_lists = true, + .head = QTAILQ_HEAD_INITIALIZER(reopen_opts.head), + .desc = { + /* no elements => accept any params */ + { /* end of list */ } + }, +}; + +static const cmdinfo_t reopen_cmd = { + .name = "reopen", + .argmin = 0, + .argmax = -1, + .cfunc = reopen_f, + .args = "[-r] [-c cache] [-o options]", + .oneline = "reopens an image with new options", + .help = reopen_help, +}; + +static int reopen_f(BlockBackend *blk, int argc, char **argv) +{ + BlockDriverState *bs = blk_bs(blk); + QemuOpts *qopts; + QDict *opts; + int c; + int flags = bs->open_flags; + + BlockReopenQueue *brq; + Error *local_err = NULL; + + while ((c = getopt(argc, argv, "c:o:r")) != -1) { + switch (c) { + case 'c': + if (bdrv_parse_cache_flags(optarg, &flags) < 0) { + error_report("Invalid cache option: %s", optarg); + return 0; + } + break; + case 'o': + if (!qemu_opts_parse_noisily(&reopen_opts, optarg, 0)) { + qemu_opts_reset(&reopen_opts); + return 0; + } + break; + case 'r': + flags &= ~BDRV_O_RDWR; + break; + default: + qemu_opts_reset(&reopen_opts); + return qemuio_command_usage(&reopen_cmd); + } + } + + if (optind != argc) { + qemu_opts_reset(&reopen_opts); + return qemuio_command_usage(&reopen_cmd); + } + + qopts = qemu_opts_find(&reopen_opts, NULL); + opts = qopts ? qemu_opts_to_qdict(qopts, NULL) : NULL; + qemu_opts_reset(&reopen_opts); + + brq = bdrv_reopen_queue(NULL, bs, opts, flags); + bdrv_reopen_multiple(brq, &local_err); + if (local_err) { + error_report_err(local_err); + } + + return 0; +} + static int break_f(BlockBackend *blk, int argc, char **argv) { int ret; @@ -2266,6 +2355,7 @@ static void __attribute((constructor)) init_qemuio_commands(void) qemuio_add_command(&discard_cmd); qemuio_add_command(&alloc_cmd); qemuio_add_command(&map_cmd); + qemuio_add_command(&reopen_cmd); qemuio_add_command(&break_cmd); qemuio_add_command(&remove_break_cmd); qemuio_add_command(&resume_cmd); -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 13:18:57 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXudd-0000wn-KD for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 13:18:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXuda-0000rF-NL for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:18:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXuda-0003gB-15 for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:18:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60703) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudZ-0003g4-Sk; Fri, 04 Sep 2015 13:18:53 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 714B48F2FE; Fri, 4 Sep 2015 17:18:53 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84HIh6h032478; Fri, 4 Sep 2015 13:18:52 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 19:18:28 +0200 Message-Id: <1441387117-27072-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1441387117-27072-1-git-send-email-kwolf@redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v2 04/13] qcow2: Improve error message X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 17:18:55 -0000 Eric says that "any" sounds better than "either", and my non-native feeling says the same, so let's change it. Suggested-by: Eric Blake Signed-off-by: Kevin Wolf --- block/qcow2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index 76c331b..e120ed3 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -971,7 +971,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, overlap_check_template = QCOW2_OL_ALL; } else { error_setg(errp, "Unsupported value '%s' for qcow2 option " - "'overlap-check'. Allowed are either of the following: " + "'overlap-check'. Allowed are any of the following: " "none, constant, cached, all", opt_overlap_check); ret = -EINVAL; goto fail; -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 13:19:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXudh-00014u-3M for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 13:19:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXude-0000z6-MP for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:18:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXudd-0003hP-HW for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:18:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47642) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudd-0003hJ-Bb; Fri, 04 Sep 2015 13:18:57 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id E1E8591DAC; Fri, 4 Sep 2015 17:18:56 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84HIh6j032478; Fri, 4 Sep 2015 13:18:55 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 19:18:30 +0200 Message-Id: <1441387117-27072-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1441387117-27072-1-git-send-email-kwolf@redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v2 06/13] qcow2: Move qcow2_update_options() call up X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 17:18:59 -0000 qcow2_update_options() only updates some variables in BDRVQcowState and doesn't really depend on other parts of it being initialised yet, so it can be moved so that it immediately follows the other half of option handling code in qcow2_open(). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index dc07d35..2903481 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -920,6 +920,15 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, goto fail; } + /* Enable lazy_refcounts according to image and command line options */ + ret = qcow2_update_options(bs, opts, flags, errp); + if (ret < 0) { + goto fail; + } + + qemu_opts_del(opts); + opts = NULL; + s->cluster_cache = g_malloc(s->cluster_size); /* one more sector for decompressed data alignment */ s->cluster_data = qemu_try_blockalign(bs->file, QCOW_MAX_CRYPT_CLUSTERS @@ -1004,15 +1013,6 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, } } - /* Enable lazy_refcounts according to image and command line options */ - ret = qcow2_update_options(bs, opts, flags, errp); - if (ret < 0) { - goto fail; - } - - qemu_opts_del(opts); - opts = NULL; - #ifdef DEBUG_ALLOC { BdrvCheckResult result = {0}; -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 13:18:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXuda-0000qz-LU for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 13:18:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudV-0000eC-NA for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXudT-0003bj-KP for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:18:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47603) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudT-0003b9-DP; Fri, 04 Sep 2015 13:18:47 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id EB57D91DAC; Fri, 4 Sep 2015 17:18:46 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84HIh6e032478; Fri, 4 Sep 2015 13:18:45 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 19:18:25 +0200 Message-Id: <1441387117-27072-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1441387117-27072-1-git-send-email-kwolf@redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v2 01/13] block: Allow specifying driver-specific options to reopen X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 17:18:51 -0000 Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block.c | 42 +++++++++++++++++++++++++++++++++++++++--- block/commit.c | 4 ++-- include/block/block.h | 4 +++- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index 090923c..a2cd9b8 100644 --- a/block.c +++ b/block.c @@ -1660,6 +1660,9 @@ typedef struct BlockReopenQueueEntry { * * bs is the BlockDriverState to add to the reopen queue. * + * options contains the changed options for the associated bs + * (the BlockReopenQueue takes ownership) + * * flags contains the open flags for the associated bs * * returns a pointer to bs_queue, which is either the newly allocated @@ -1667,18 +1670,28 @@ typedef struct BlockReopenQueueEntry { * */ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, - BlockDriverState *bs, int flags) + BlockDriverState *bs, + QDict *options, int flags) { assert(bs != NULL); BlockReopenQueueEntry *bs_entry; BdrvChild *child; + QDict *old_options; if (bs_queue == NULL) { bs_queue = g_new0(BlockReopenQueue, 1); QSIMPLEQ_INIT(bs_queue); } + if (!options) { + options = qdict_new(); + } + + old_options = qdict_clone_shallow(bs->options); + qdict_join(options, old_options, false); + QDECREF(old_options); + /* bdrv_open() masks this flag out */ flags &= ~BDRV_O_PROTOCOL; @@ -1690,13 +1703,15 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, } child_flags = child->role->inherit_flags(flags); - bdrv_reopen_queue(bs_queue, child->bs, child_flags); + /* TODO Pass down child flags (backing.*, extents.*, ...) */ + bdrv_reopen_queue(bs_queue, child->bs, NULL, child_flags); } bs_entry = g_new0(BlockReopenQueueEntry, 1); QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry); bs_entry->state.bs = bs; + bs_entry->state.options = options; bs_entry->state.flags = flags; return bs_queue; @@ -1749,6 +1764,7 @@ cleanup: if (ret && bs_entry->prepared) { bdrv_reopen_abort(&bs_entry->state); } + QDECREF(bs_entry->state.options); g_free(bs_entry); } g_free(bs_queue); @@ -1761,7 +1777,7 @@ int bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp) { int ret = -1; Error *local_err = NULL; - BlockReopenQueue *queue = bdrv_reopen_queue(NULL, bs, bdrv_flags); + BlockReopenQueue *queue = bdrv_reopen_queue(NULL, bs, NULL, bdrv_flags); ret = bdrv_reopen_multiple(queue, &local_err); if (local_err != NULL) { @@ -1837,6 +1853,26 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, goto error; } + /* Options that are not handled are only okay if they are unchanged + * compared to the old state. It is expected that some options are only + * used for the initial open, but not reopen (e.g. filename) */ + if (qdict_size(reopen_state->options)) { + const QDictEntry *entry = qdict_first(reopen_state->options); + + do { + QString *new_obj = qobject_to_qstring(entry->value); + const char *new = qstring_get_str(new_obj); + const char *old = qdict_get_try_str(reopen_state->bs->options, + entry->key); + + if (!old || strcmp(new, old)) { + error_setg(errp, "Cannot change the option '%s'", entry->key); + ret = -EINVAL; + goto error; + } + } while ((entry = qdict_next(reopen_state->options, entry))); + } + ret = 0; error: diff --git a/block/commit.c b/block/commit.c index 7312a5b..d12e26f 100644 --- a/block/commit.c +++ b/block/commit.c @@ -236,11 +236,11 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base, /* convert base & overlay_bs to r/w, if necessary */ if (!(orig_base_flags & BDRV_O_RDWR)) { - reopen_queue = bdrv_reopen_queue(reopen_queue, base, + reopen_queue = bdrv_reopen_queue(reopen_queue, base, NULL, orig_base_flags | BDRV_O_RDWR); } if (!(orig_overlay_flags & BDRV_O_RDWR)) { - reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs, + reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs, NULL, orig_overlay_flags | BDRV_O_RDWR); } if (reopen_queue) { diff --git a/include/block/block.h b/include/block/block.h index 608cd4e..555a2ce 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -147,6 +147,7 @@ typedef QSIMPLEQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue; typedef struct BDRVReopenState { BlockDriverState *bs; int flags; + QDict *options; void *opaque; } BDRVReopenState; @@ -221,7 +222,8 @@ int bdrv_open(BlockDriverState **pbs, const char *filename, const char *reference, QDict *options, int flags, BlockDriver *drv, Error **errp); BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, - BlockDriverState *bs, int flags); + BlockDriverState *bs, + QDict *options, int flags); int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp); int bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp); int bdrv_reopen_prepare(BDRVReopenState *reopen_state, -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 13:19:04 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXudk-0001Ao-6r for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 13:19:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudg-00012s-H1 for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:19:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXudf-0003iB-6n for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:19:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60101) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudf-0003i4-0Y; Fri, 04 Sep 2015 13:18:59 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 912CD4B; Fri, 4 Sep 2015 17:18:58 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84HIh6k032478; Fri, 4 Sep 2015 13:18:57 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 19:18:31 +0200 Message-Id: <1441387117-27072-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1441387117-27072-1-git-send-email-kwolf@redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v2 07/13] qcow2: Move rest of option handling to qcow2_update_options() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 17:19:02 -0000 With this commit, the handling of driver-specific options in qcow2_open() is completely separated out into qcow2_update_options(). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2.c | 111 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 56 insertions(+), 55 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 2903481..bad377d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -541,15 +541,65 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, } } -static int qcow2_update_options(BlockDriverState *bs, QemuOpts *opts, +static int qcow2_update_options(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVQcowState *s = bs->opaque; + QemuOpts *opts = NULL; const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; + uint64_t l2_cache_size, refcount_cache_size; int i; + Error *local_err = NULL; int ret; + opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); + qemu_opts_absorb_qdict(opts, options, &local_err); + if (local_err) { + error_propagate(errp, local_err); + ret = -EINVAL; + goto fail; + } + + /* get L2 table/refcount block cache size from command line options */ + read_cache_sizes(bs, opts, &l2_cache_size, &refcount_cache_size, + &local_err); + if (local_err) { + error_propagate(errp, local_err); + ret = -EINVAL; + goto fail; + } + + l2_cache_size /= s->cluster_size; + if (l2_cache_size < MIN_L2_CACHE_SIZE) { + l2_cache_size = MIN_L2_CACHE_SIZE; + } + if (l2_cache_size > INT_MAX) { + error_setg(errp, "L2 cache size too big"); + ret = -EINVAL; + goto fail; + } + + refcount_cache_size /= s->cluster_size; + if (refcount_cache_size < MIN_REFCOUNT_CACHE_SIZE) { + refcount_cache_size = MIN_REFCOUNT_CACHE_SIZE; + } + if (refcount_cache_size > INT_MAX) { + error_setg(errp, "Refcount cache size too big"); + ret = -EINVAL; + goto fail; + } + + /* alloc L2 table/refcount block cache */ + s->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); + s->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); + if (s->l2_table_cache == NULL || s->refcount_block_cache == NULL) { + error_setg(errp, "Could not allocate metadata caches"); + ret = -ENOMEM; + goto fail; + } + + /* Enable lazy_refcounts according to image and command line options */ s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); @@ -612,6 +662,9 @@ static int qcow2_update_options(BlockDriverState *bs, QemuOpts *opts, ret = 0; fail: + qemu_opts_del(opts); + opts = NULL; + return ret; } @@ -622,11 +675,9 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, unsigned int len, i; int ret = 0; QCowHeader header; - QemuOpts *opts = NULL; Error *local_err = NULL; uint64_t ext_end; uint64_t l1_vm_state_index; - uint64_t l2_cache_size, refcount_cache_size; ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); if (ret < 0) { @@ -874,61 +925,12 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, } } - /* get L2 table/refcount block cache size from command line options */ - opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); - ret = -EINVAL; - goto fail; - } - - read_cache_sizes(bs, opts, &l2_cache_size, &refcount_cache_size, - &local_err); - if (local_err) { - error_propagate(errp, local_err); - ret = -EINVAL; - goto fail; - } - - l2_cache_size /= s->cluster_size; - if (l2_cache_size < MIN_L2_CACHE_SIZE) { - l2_cache_size = MIN_L2_CACHE_SIZE; - } - if (l2_cache_size > INT_MAX) { - error_setg(errp, "L2 cache size too big"); - ret = -EINVAL; - goto fail; - } - - refcount_cache_size /= s->cluster_size; - if (refcount_cache_size < MIN_REFCOUNT_CACHE_SIZE) { - refcount_cache_size = MIN_REFCOUNT_CACHE_SIZE; - } - if (refcount_cache_size > INT_MAX) { - error_setg(errp, "Refcount cache size too big"); - ret = -EINVAL; - goto fail; - } - - /* alloc L2 table/refcount block cache */ - s->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); - s->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); - if (s->l2_table_cache == NULL || s->refcount_block_cache == NULL) { - error_setg(errp, "Could not allocate metadata caches"); - ret = -ENOMEM; - goto fail; - } - - /* Enable lazy_refcounts according to image and command line options */ - ret = qcow2_update_options(bs, opts, flags, errp); + /* Parse driver-specific options */ + ret = qcow2_update_options(bs, options, flags, errp); if (ret < 0) { goto fail; } - qemu_opts_del(opts); - opts = NULL; - s->cluster_cache = g_malloc(s->cluster_size); /* one more sector for decompressed data alignment */ s->cluster_data = qemu_try_blockalign(bs->file, QCOW_MAX_CRYPT_CLUSTERS @@ -1022,7 +1024,6 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, return ret; fail: - qemu_opts_del(opts); g_free(s->unknown_header_fields); cleanup_unknown_header_ext(bs); qcow2_free_snapshots(bs); -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 13:19:05 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXudl-0001Dh-Hd for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 13:19:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudh-00016t-RI for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:19:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXudg-0003iw-TK for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:19:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49695) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudg-0003ij-Mi; Fri, 04 Sep 2015 13:19:00 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 4599FC0B2B4E; Fri, 4 Sep 2015 17:19:00 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84HIh6l032478; Fri, 4 Sep 2015 13:18:58 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 19:18:32 +0200 Message-Id: <1441387117-27072-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1441387117-27072-1-git-send-email-kwolf@redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v2 08/13] qcow2: Leave s unchanged on qcow2_update_options() failure X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 17:19:03 -0000 On return, either all new options should be applied to BDRVQcowState (on success), or all of the old settings should be preserved (on failure). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2.c | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index bad377d..9b67334 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -549,6 +549,9 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; + Qcow2Cache *l2_table_cache; + Qcow2Cache *refcount_block_cache; + bool use_lazy_refcounts; int i; Error *local_err = NULL; int ret; @@ -591,28 +594,25 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, } /* alloc L2 table/refcount block cache */ - s->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); - s->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); - if (s->l2_table_cache == NULL || s->refcount_block_cache == NULL) { + l2_table_cache = qcow2_cache_create(bs, l2_cache_size); + refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); + if (l2_table_cache == NULL || refcount_block_cache == NULL) { error_setg(errp, "Could not allocate metadata caches"); ret = -ENOMEM; goto fail; } /* Enable lazy_refcounts according to image and command line options */ - s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, + use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); + if (use_lazy_refcounts && s->qcow_version < 3) { + error_setg(errp, "Lazy refcounts require a qcow2 image with at least " + "qemu 1.1 compatibility level"); + ret = -EINVAL; + goto fail; + } - s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; - s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; - s->discard_passthrough[QCOW2_DISCARD_REQUEST] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, - flags & BDRV_O_UNMAP); - s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); - s->discard_passthrough[QCOW2_DISCARD_OTHER] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); - + /* Overlap check options */ opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); if (opt_overlap_check_template && opt_overlap_check && @@ -644,6 +644,10 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, goto fail; } + /* + * Start updating fields in BDRVQcowState. + * After this point no failure is allowed any more. + */ s->overlap_check = 0; for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { /* overlap-check defines a template bitmask, but every flag may be @@ -653,12 +657,20 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, overlap_check_template & (1 << i)) << i; } - if (s->use_lazy_refcounts && s->qcow_version < 3) { - error_setg(errp, "Lazy refcounts require a qcow2 image with at least " - "qemu 1.1 compatibility level"); - ret = -EINVAL; - goto fail; - } + s->l2_table_cache = l2_table_cache; + s->refcount_block_cache = refcount_block_cache; + + s->use_lazy_refcounts = use_lazy_refcounts; + + s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; + s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; + s->discard_passthrough[QCOW2_DISCARD_REQUEST] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, + flags & BDRV_O_UNMAP); + s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); + s->discard_passthrough[QCOW2_DISCARD_OTHER] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); ret = 0; fail: -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 13:19:08 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXudn-0001ID-NC for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 13:19:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudj-00019V-LB for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:19:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXudi-0003kg-U9 for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:19:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42860) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudi-0003kU-II; Fri, 04 Sep 2015 13:19:02 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 20ED6C0ADB40; Fri, 4 Sep 2015 17:19:02 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84HIh6m032478; Fri, 4 Sep 2015 13:19:00 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 19:18:33 +0200 Message-Id: <1441387117-27072-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1441387117-27072-1-git-send-email-kwolf@redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v2 09/13] qcow2: Fix memory leak in qcow2_update_options() error path X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 17:19:06 -0000 Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 9b67334..24acefd 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -549,8 +549,8 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; - Qcow2Cache *l2_table_cache; - Qcow2Cache *refcount_block_cache; + Qcow2Cache *l2_table_cache = NULL; + Qcow2Cache *refcount_block_cache = NULL; bool use_lazy_refcounts; int i; Error *local_err = NULL; @@ -674,6 +674,14 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, ret = 0; fail: + if (ret < 0) { + if (l2_table_cache) { + qcow2_cache_destroy(bs, l2_table_cache); + } + if (refcount_block_cache) { + qcow2_cache_destroy(bs, refcount_block_cache); + } + } qemu_opts_del(opts); opts = NULL; -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 13:19:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXudh-00015O-8R for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 13:19:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXude-0000zA-MW for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:18:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXudb-0003h0-V0 for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:18:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17852) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudb-0003gm-Lk; Fri, 04 Sep 2015 13:18:55 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 377DE8E3FB; Fri, 4 Sep 2015 17:18:55 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84HIh6i032478; Fri, 4 Sep 2015 13:18:53 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 19:18:29 +0200 Message-Id: <1441387117-27072-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1441387117-27072-1-git-send-email-kwolf@redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v2 05/13] qcow2: Factor out qcow2_update_options() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 17:19:00 -0000 Eventually we want to be able to change options at runtime. As a first step towards that goal, separate some option handling code from the general initialisation code in qcow2_open(). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2.c | 135 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 76 insertions(+), 59 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index e120ed3..dc07d35 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -541,6 +541,80 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, } } +static int qcow2_update_options(BlockDriverState *bs, QemuOpts *opts, + int flags, Error **errp) +{ + BDRVQcowState *s = bs->opaque; + const char *opt_overlap_check, *opt_overlap_check_template; + int overlap_check_template = 0; + int i; + int ret; + + s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, + (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); + + s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; + s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; + s->discard_passthrough[QCOW2_DISCARD_REQUEST] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, + flags & BDRV_O_UNMAP); + s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); + s->discard_passthrough[QCOW2_DISCARD_OTHER] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); + + opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); + opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); + if (opt_overlap_check_template && opt_overlap_check && + strcmp(opt_overlap_check_template, opt_overlap_check)) + { + error_setg(errp, "Conflicting values for qcow2 options '" + QCOW2_OPT_OVERLAP "' ('%s') and '" QCOW2_OPT_OVERLAP_TEMPLATE + "' ('%s')", opt_overlap_check, opt_overlap_check_template); + ret = -EINVAL; + goto fail; + } + if (!opt_overlap_check) { + opt_overlap_check = opt_overlap_check_template ?: "cached"; + } + + if (!strcmp(opt_overlap_check, "none")) { + overlap_check_template = 0; + } else if (!strcmp(opt_overlap_check, "constant")) { + overlap_check_template = QCOW2_OL_CONSTANT; + } else if (!strcmp(opt_overlap_check, "cached")) { + overlap_check_template = QCOW2_OL_CACHED; + } else if (!strcmp(opt_overlap_check, "all")) { + overlap_check_template = QCOW2_OL_ALL; + } else { + error_setg(errp, "Unsupported value '%s' for qcow2 option " + "'overlap-check'. Allowed are any of the following: " + "none, constant, cached, all", opt_overlap_check); + ret = -EINVAL; + goto fail; + } + + s->overlap_check = 0; + for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { + /* overlap-check defines a template bitmask, but every flag may be + * overwritten through the associated boolean option */ + s->overlap_check |= + qemu_opt_get_bool(opts, overlap_bool_option_names[i], + overlap_check_template & (1 << i)) << i; + } + + if (s->use_lazy_refcounts && s->qcow_version < 3) { + error_setg(errp, "Lazy refcounts require a qcow2 image with at least " + "qemu 1.1 compatibility level"); + ret = -EINVAL; + goto fail; + } + + ret = 0; +fail: + return ret; +} + static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { @@ -552,8 +626,6 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, Error *local_err = NULL; uint64_t ext_end; uint64_t l1_vm_state_index; - const char *opt_overlap_check, *opt_overlap_check_template; - int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); @@ -933,69 +1005,14 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, } /* Enable lazy_refcounts according to image and command line options */ - s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, - (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); - - s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; - s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; - s->discard_passthrough[QCOW2_DISCARD_REQUEST] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, - flags & BDRV_O_UNMAP); - s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); - s->discard_passthrough[QCOW2_DISCARD_OTHER] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); - - opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); - opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); - if (opt_overlap_check_template && opt_overlap_check && - strcmp(opt_overlap_check_template, opt_overlap_check)) - { - error_setg(errp, "Conflicting values for qcow2 options '" - QCOW2_OPT_OVERLAP "' ('%s') and '" QCOW2_OPT_OVERLAP_TEMPLATE - "' ('%s')", opt_overlap_check, opt_overlap_check_template); - ret = -EINVAL; - goto fail; - } - if (!opt_overlap_check) { - opt_overlap_check = opt_overlap_check_template ?: "cached"; - } - - if (!strcmp(opt_overlap_check, "none")) { - overlap_check_template = 0; - } else if (!strcmp(opt_overlap_check, "constant")) { - overlap_check_template = QCOW2_OL_CONSTANT; - } else if (!strcmp(opt_overlap_check, "cached")) { - overlap_check_template = QCOW2_OL_CACHED; - } else if (!strcmp(opt_overlap_check, "all")) { - overlap_check_template = QCOW2_OL_ALL; - } else { - error_setg(errp, "Unsupported value '%s' for qcow2 option " - "'overlap-check'. Allowed are any of the following: " - "none, constant, cached, all", opt_overlap_check); - ret = -EINVAL; + ret = qcow2_update_options(bs, opts, flags, errp); + if (ret < 0) { goto fail; } - s->overlap_check = 0; - for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { - /* overlap-check defines a template bitmask, but every flag may be - * overwritten through the associated boolean option */ - s->overlap_check |= - qemu_opt_get_bool(opts, overlap_bool_option_names[i], - overlap_check_template & (1 << i)) << i; - } - qemu_opts_del(opts); opts = NULL; - if (s->use_lazy_refcounts && s->qcow_version < 3) { - error_setg(errp, "Lazy refcounts require a qcow2 image with at least " - "qemu 1.1 compatibility level"); - ret = -EINVAL; - goto fail; - } - #ifdef DEBUG_ALLOC { BdrvCheckResult result = {0}; -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 13:18:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXuda-0000qK-Ba for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 13:18:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudV-0000eA-N4 for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXudS-0003aZ-Fx for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:18:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudS-0003Zo-Bd; Fri, 04 Sep 2015 13:18:46 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 405AF91C1C; Fri, 4 Sep 2015 17:18:45 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84HIh6d032478; Fri, 4 Sep 2015 13:18:43 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 19:18:24 +0200 Message-Id: <1441387117-27072-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v2 00/13] qcow2: reopen: Change driver-specific runtime options X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 17:18:51 -0000 This is part two of what I had sent earlier as "[PATCH 00/34] block: Cache mode for children, reopen overhaul and more". Most of the patches were actually already reviewed in v1. Apart from a few addressed review comments, there are no functional changes compared to v1. Some rebasing was necessary; also the qemu-iotests cases are new. Kevin Wolf (13): block: Allow specifying driver-specific options to reopen qemu-io: Remove duplicate 'open' error message qemu-io: Add command 'reopen' qcow2: Improve error message qcow2: Factor out qcow2_update_options() qcow2: Move qcow2_update_options() call up qcow2: Move rest of option handling to qcow2_update_options() qcow2: Leave s unchanged on qcow2_update_options() failure qcow2: Fix memory leak in qcow2_update_options() error path qcow2: Make qcow2_update_options() suitable for transactions qcow2: Support updating driver-specific options in reopen qemu-iotests: Reopen qcow2 with lazy-refcounts change qemu-iotests: More qcow2 reopen tests block.c | 42 +++++- block/commit.c | 4 +- block/qcow2.c | 362 ++++++++++++++++++++++++++++++--------------- include/block/block.h | 4 +- qemu-io-cmds.c | 90 +++++++++++ qemu-io.c | 1 - tests/qemu-iotests/039 | 27 ++++ tests/qemu-iotests/039.out | 18 +++ tests/qemu-iotests/137 | 143 ++++++++++++++++++ tests/qemu-iotests/137.out | 43 ++++++ tests/qemu-iotests/group | 1 + 11 files changed, 612 insertions(+), 123 deletions(-) create mode 100755 tests/qemu-iotests/137 create mode 100644 tests/qemu-iotests/137.out -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 13:19:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXuds-0001Ru-RE for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 13:19:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudn-0001Hk-AF for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:19:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXudl-0003mM-Sj for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:19:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudl-0003lz-MS; Fri, 04 Sep 2015 13:19:05 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 394FD14AA4; Fri, 4 Sep 2015 17:19:05 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84HIh6n032478; Fri, 4 Sep 2015 13:19:02 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 19:18:34 +0200 Message-Id: <1441387117-27072-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1441387117-27072-1-git-send-email-kwolf@redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v2 10/13] qcow2: Make qcow2_update_options() suitable for transactions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 17:19:08 -0000 Before we can allow updating options at runtime with bdrv_reopen(), we need to split the function into prepare/commit/abort parts. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2.c | 101 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 34 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 24acefd..b498cf1 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -541,17 +541,24 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, } } -static int qcow2_update_options(BlockDriverState *bs, QDict *options, - int flags, Error **errp) +typedef struct Qcow2ReopenState { + Qcow2Cache *l2_table_cache; + Qcow2Cache *refcount_block_cache; + bool use_lazy_refcounts; + int overlap_check; + bool discard_passthrough[QCOW2_DISCARD_MAX]; +} Qcow2ReopenState; + +static int qcow2_update_options_prepare(BlockDriverState *bs, + Qcow2ReopenState *r, + QDict *options, int flags, + Error **errp) { BDRVQcowState *s = bs->opaque; QemuOpts *opts = NULL; const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; - Qcow2Cache *l2_table_cache = NULL; - Qcow2Cache *refcount_block_cache = NULL; - bool use_lazy_refcounts; int i; Error *local_err = NULL; int ret; @@ -594,18 +601,18 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, } /* alloc L2 table/refcount block cache */ - l2_table_cache = qcow2_cache_create(bs, l2_cache_size); - refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); - if (l2_table_cache == NULL || refcount_block_cache == NULL) { + r->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); + r->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); + if (r->l2_table_cache == NULL || r->refcount_block_cache == NULL) { error_setg(errp, "Could not allocate metadata caches"); ret = -ENOMEM; goto fail; } /* Enable lazy_refcounts according to image and command line options */ - use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, + r->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); - if (use_lazy_refcounts && s->qcow_version < 3) { + if (r->use_lazy_refcounts && s->qcow_version < 3) { error_setg(errp, "Lazy refcounts require a qcow2 image with at least " "qemu 1.1 compatibility level"); ret = -EINVAL; @@ -644,46 +651,72 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, goto fail; } - /* - * Start updating fields in BDRVQcowState. - * After this point no failure is allowed any more. - */ - s->overlap_check = 0; + r->overlap_check = 0; for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { /* overlap-check defines a template bitmask, but every flag may be * overwritten through the associated boolean option */ - s->overlap_check |= + r->overlap_check |= qemu_opt_get_bool(opts, overlap_bool_option_names[i], overlap_check_template & (1 << i)) << i; } - s->l2_table_cache = l2_table_cache; - s->refcount_block_cache = refcount_block_cache; - - s->use_lazy_refcounts = use_lazy_refcounts; - - s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; - s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; - s->discard_passthrough[QCOW2_DISCARD_REQUEST] = + r->discard_passthrough[QCOW2_DISCARD_NEVER] = false; + r->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; + r->discard_passthrough[QCOW2_DISCARD_REQUEST] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, flags & BDRV_O_UNMAP); - s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = + r->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); - s->discard_passthrough[QCOW2_DISCARD_OTHER] = + r->discard_passthrough[QCOW2_DISCARD_OTHER] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); ret = 0; fail: - if (ret < 0) { - if (l2_table_cache) { - qcow2_cache_destroy(bs, l2_table_cache); - } - if (refcount_block_cache) { - qcow2_cache_destroy(bs, refcount_block_cache); - } - } qemu_opts_del(opts); opts = NULL; + return ret; +} + +static void qcow2_update_options_commit(BlockDriverState *bs, + Qcow2ReopenState *r) +{ + BDRVQcowState *s = bs->opaque; + int i; + + s->l2_table_cache = r->l2_table_cache; + s->refcount_block_cache = r->refcount_block_cache; + + s->overlap_check = r->overlap_check; + s->use_lazy_refcounts = r->use_lazy_refcounts; + + for (i = 0; i < QCOW2_DISCARD_MAX; i++) { + s->discard_passthrough[i] = r->discard_passthrough[i]; + } +} + +static void qcow2_update_options_abort(BlockDriverState *bs, + Qcow2ReopenState *r) +{ + if (r->l2_table_cache) { + qcow2_cache_destroy(bs, r->l2_table_cache); + } + if (r->refcount_block_cache) { + qcow2_cache_destroy(bs, r->refcount_block_cache); + } +} + +static int qcow2_update_options(BlockDriverState *bs, QDict *options, + int flags, Error **errp) +{ + Qcow2ReopenState r = {}; + int ret; + + ret = qcow2_update_options_prepare(bs, &r, options, flags, errp); + if (ret >= 0) { + qcow2_update_options_commit(bs, &r); + } else { + qcow2_update_options_abort(bs, &r); + } return ret; } -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 13:19:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXudt-0001TL-H7 for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 13:19:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudq-0001Nr-Cl for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:19:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXudp-0003nf-CU for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:19:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42883) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudp-0003nQ-8H; Fri, 04 Sep 2015 13:19:09 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id CDDE7C0ADB42; Fri, 4 Sep 2015 17:19:08 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84HIh6p032478; Fri, 4 Sep 2015 13:19:07 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 19:18:36 +0200 Message-Id: <1441387117-27072-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1441387117-27072-1-git-send-email-kwolf@redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v2 12/13] qemu-iotests: Reopen qcow2 with lazy-refcounts change X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 17:19:11 -0000 Signed-off-by: Kevin Wolf --- tests/qemu-iotests/039 | 27 +++++++++++++++++++++++++++ tests/qemu-iotests/039.out | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 index 617f397..9e9b379 100755 --- a/tests/qemu-iotests/039 +++ b/tests/qemu-iotests/039 @@ -147,6 +147,33 @@ $PYTHON qcow2.py "$TEST_IMG".base dump-header | grep incompatible_features _check_test_img TEST_IMG="$TEST_IMG".base _check_test_img +echo +echo "== Changing lazy_refcounts setting at runtime ==" + +IMGOPTS="compat=1.1,lazy_refcounts=off" +_make_test_img $size + +$QEMU_IO -c "reopen -o lazy-refcounts=on" \ + -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ + | _filter_qemu_io + +# The dirty bit must be set +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +_check_test_img + +IMGOPTS="compat=1.1,lazy_refcounts=on" +_make_test_img $size + +$QEMU_IO -c "reopen -o lazy-refcounts=off" \ + -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ + | _filter_qemu_io + +# The dirty bit must not be set +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +_check_test_img + # success, all done echo "*** done" diff --git a/tests/qemu-iotests/039.out b/tests/qemu-iotests/039.out index b055670..39859b2 100644 --- a/tests/qemu-iotests/039.out +++ b/tests/qemu-iotests/039.out @@ -74,4 +74,22 @@ incompatible_features 0x0 incompatible_features 0x0 No errors were found on the image. No errors were found on the image. + +== Changing lazy_refcounts setting at runtime == +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) +incompatible_features 0x1 +ERROR cluster 5 refcount=0 reference=1 +ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0 + +2 errors were found on the image. +Data may be corrupted, or further writes to the image may corrupt it. +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) +incompatible_features 0x0 +No errors were found on the image. *** done -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 13:19:21 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXue1-0001hW-2Y for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 13:19:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudt-0001SX-4u for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:19:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXudr-0003oe-G0 for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:19:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudr-0003oR-9K; Fri, 04 Sep 2015 13:19:11 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id D1887A2C3B; Fri, 4 Sep 2015 17:19:10 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84HIh6q032478; Fri, 4 Sep 2015 13:19:09 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 19:18:37 +0200 Message-Id: <1441387117-27072-14-git-send-email-kwolf@redhat.com> In-Reply-To: <1441387117-27072-1-git-send-email-kwolf@redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v2 13/13] qemu-iotests: More qcow2 reopen tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 17:19:17 -0000 Signed-off-by: Kevin Wolf --- tests/qemu-iotests/137 | 143 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/137.out | 43 ++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 187 insertions(+) create mode 100755 tests/qemu-iotests/137 create mode 100644 tests/qemu-iotests/137.out diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 new file mode 100755 index 0000000..ad52f71 --- /dev/null +++ b/tests/qemu-iotests/137 @@ -0,0 +1,143 @@ +#!/bin/bash +# +# Test qcow2 reopen +# +# Copyright (C) 2015 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=kwolf@redhat.com + +seq="$(basename $0)" +echo "QA output created by $seq" + +here="$PWD" +tmp=/tmp/$$ +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +_supported_fmt qcow2 +_supported_proto generic +_supported_os Linux + + +_make_test_img 64M + +echo === Try setting valid values for all options === +echo + +# Try all options and then check that all of the basic I/O operations still +# work on this image. +$QEMU_IO \ + -c "reopen -o lazy-refcounts=on,pass-discard-request=on" \ + -c "reopen -o lazy-refcounts=off,pass-discard-request=off" \ + -c "reopen -o pass-discard-snapshot=on,pass-discard-other=on" \ + -c "reopen -o pass-discard-snapshot=off,pass-discard-other=off" \ + -c "reopen -o overlap-check=all" \ + -c "reopen -o overlap-check=none" \ + -c "reopen -o overlap-check=cached" \ + -c "reopen -o overlap-check=constant" \ + -c "reopen -o overlap-check.template=all" \ + -c "reopen -o overlap-check.template=none" \ + -c "reopen -o overlap-check.template=cached" \ + -c "reopen -o overlap-check.template=constant" \ + -c "reopen -o overlap-check.main-header=on" \ + -c "reopen -o overlap-check.main-header=off" \ + -c "reopen -o overlap-check.active-l1=on" \ + -c "reopen -o overlap-check.active-l1=off" \ + -c "reopen -o overlap-check.active-l2=on" \ + -c "reopen -o overlap-check.active-l2=off" \ + -c "reopen -o overlap-check.refcount-table=on" \ + -c "reopen -o overlap-check.refcount-table=off" \ + -c "reopen -o overlap-check.refcount-block=on" \ + -c "reopen -o overlap-check.refcount-block=off" \ + -c "reopen -o overlap-check.snapshot-table=on" \ + -c "reopen -o overlap-check.snapshot-table=off" \ + -c "reopen -o overlap-check.inactive-l1=on" \ + -c "reopen -o overlap-check.inactive-l1=off" \ + -c "reopen -o overlap-check.inactive-l2=on" \ + -c "reopen -o overlap-check.inactive-l2=off" \ + -c "reopen -o cache-size=1M" \ + -c "reopen -o l2-cache-size=512k" \ + -c "reopen -o refcount-cache-size=128k" \ + \ + -c "write -P 55 0 32M" \ + -c "read -P 55 0 32M" \ + -c "discard 0 32M" \ + -c "write -z 0 32M" \ + -c "read -P 0 0 32M" \ + \ + "$TEST_IMG" | _filter_qemu_io + + +echo +echo === Try setting some invalid values === +echo + +$QEMU_IO \ + -c "reopen -o lazy-refcounts=42" \ + -c "reopen -o cache-size=1M,l2-cache-size=64k,refcount-cache-size=64k" \ + -c "reopen -o cache-size=1M,l2-cache-size=2M" \ + -c "reopen -o cache-size=1M,refcount-cache-size=2M" \ + -c "reopen -o l2-cache-size=256T" \ + -c "reopen -o l2-cache-size=64G" \ + -c "reopen -o refcount-cache-size=256T" \ + -c "reopen -o refcount-cache-size=64G" \ + -c "reopen -o overlap-check=constant,overlap-check.template=all" \ + -c "reopen -o overlap-check=blubb" \ + -c "reopen -o overlap-check.template=blubb" \ + "$TEST_IMG" | _filter_qemu_io + +echo +echo === Test transaction semantics === +echo + +# Whether lazy-refcounts was actually enabled can easily be tested: Check if +# the dirty bit is set after a crash +$QEMU_IO \ + -c "reopen -o lazy-refcounts=on,overlap-check=blubb" \ + -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" \ + "$TEST_IMG" 2>&1 | _filter_qemu_io + +# The dirty bit must not be set +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features + +# Similarly we can test whether corruption detection has been enabled: +# Create L1/L2, overwrite first entry in refcount block, allocate something. +# Disabling the checks should fail, so the corruption must be detected. +_make_test_img 64M +$QEMU_IO -c "write 0 64k" "$TEST_IMG" | _filter_qemu_io +poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00" +$QEMU_IO \ + -c "reopen -o overlap-check=none,lazy-refcounts=42" \ + -c "write 64k 64k" \ + "$TEST_IMG" 2>&1 | _filter_qemu_io + +# success, all done +echo '*** done' +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/137.out b/tests/qemu-iotests/137.out new file mode 100644 index 0000000..b1a1565 --- /dev/null +++ b/tests/qemu-iotests/137.out @@ -0,0 +1,43 @@ +QA output created by 137 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 +=== Try setting valid values for all options === + +wrote 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +discard 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=== Try setting some invalid values === + +Parameter 'lazy-refcounts' expects 'on' or 'off' +cache-size, l2-cache-size and refcount-cache-size may not be set the same time +l2-cache-size may not exceed cache-size +refcount-cache-size may not exceed cache-size +L2 cache size too big +Could not allocate metadata caches +L2 cache size too big +Could not allocate metadata caches +Conflicting values for qcow2 options 'overlap-check' ('constant') and 'overlap-check.template' ('all') +Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all +Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all + +=== Test transaction semantics === + +Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) +incompatible_features 0x0 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Parameter 'lazy-refcounts' expects 'on' or 'off' +qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with qcow2_header); further corruption events will be suppressed +write failed: Input/output error +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index c430b6c..3a6a8f0 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -134,3 +134,4 @@ 132 rw auto quick 134 rw auto quick 135 rw auto +137 rw auto -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 13:19:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXudt-0001Sj-7G for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 13:19:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudp-0001Li-BS for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:19:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXudo-0003n2-4T for qemu-block@nongnu.org; Fri, 04 Sep 2015 13:19:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42878) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXudn-0003mr-MG; Fri, 04 Sep 2015 13:19:07 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 17420C0ADB42; Fri, 4 Sep 2015 17:19:07 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-105.ams2.redhat.com [10.36.116.105]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84HIh6o032478; Fri, 4 Sep 2015 13:19:05 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 19:18:35 +0200 Message-Id: <1441387117-27072-12-git-send-email-kwolf@redhat.com> In-Reply-To: <1441387117-27072-1-git-send-email-kwolf@redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v2 11/13] qcow2: Support updating driver-specific options in reopen X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 17:19:10 -0000 For updating the cache sizes or disabling lazy refcounts there is a bit more to do than just changing the variables, but otherwise we're all set for changing options during bdrv_reopen(). Just implement the missing pieces and hook the functions up in bdrv_reopen(). Signed-off-by: Kevin Wolf --- block/qcow2.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 6 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index b498cf1..8d52766 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -600,7 +600,24 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, goto fail; } - /* alloc L2 table/refcount block cache */ + /* alloc new L2 table/refcount block cache, flush old one */ + if (s->l2_table_cache) { + ret = qcow2_cache_flush(bs, s->l2_table_cache); + if (ret) { + error_setg_errno(errp, -ret, "Failed to flush the L2 table cache"); + goto fail; + } + } + + if (s->refcount_block_cache) { + ret = qcow2_cache_flush(bs, s->refcount_block_cache); + if (ret) { + error_setg_errno(errp, -ret, + "Failed to flush the refcount block cache"); + goto fail; + } + } + r->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); r->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); if (r->l2_table_cache == NULL || r->refcount_block_cache == NULL) { @@ -609,7 +626,7 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, goto fail; } - /* Enable lazy_refcounts according to image and command line options */ + /* lazy-refcounts; flush if going from enabled to disabled */ r->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); if (r->use_lazy_refcounts && s->qcow_version < 3) { @@ -619,6 +636,14 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, goto fail; } + if (s->use_lazy_refcounts && !r->use_lazy_refcounts) { + ret = qcow2_mark_clean(bs); + if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to disable lazy refcounts"); + goto fail; + } + } + /* Overlap check options */ opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); @@ -683,6 +708,12 @@ static void qcow2_update_options_commit(BlockDriverState *bs, BDRVQcowState *s = bs->opaque; int i; + if (s->l2_table_cache) { + qcow2_cache_destroy(bs, s->l2_table_cache); + } + if (s->refcount_block_cache) { + qcow2_cache_destroy(bs, s->refcount_block_cache); + } s->l2_table_cache = r->l2_table_cache; s->refcount_block_cache = r->refcount_block_cache; @@ -1137,26 +1168,52 @@ static int qcow2_set_key(BlockDriverState *bs, const char *key) return 0; } -/* We have no actual commit/abort logic for qcow2, but we need to write out any - * unwritten data if we reopen read-only. */ static int qcow2_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { + Qcow2ReopenState *r; int ret; + r = g_new0(Qcow2ReopenState, 1); + state->opaque = r; + + ret = qcow2_update_options_prepare(state->bs, r, state->options, + state->flags, errp); + if (ret < 0) { + goto fail; + } + + /* We need to write out any unwritten data if we reopen read-only. */ if ((state->flags & BDRV_O_RDWR) == 0) { ret = bdrv_flush(state->bs); if (ret < 0) { - return ret; + goto fail; } ret = qcow2_mark_clean(state->bs); if (ret < 0) { - return ret; + goto fail; } } return 0; + +fail: + qcow2_update_options_abort(state->bs, r); + g_free(r); + return ret; +} + +static void qcow2_reopen_commit(BDRVReopenState *state) +{ + qcow2_update_options_commit(state->bs, state->opaque); + g_free(state->opaque); +} + +static void qcow2_reopen_abort(BDRVReopenState *state) +{ + qcow2_update_options_abort(state->bs, state->opaque); + g_free(state->opaque); } static int64_t coroutine_fn qcow2_co_get_block_status(BlockDriverState *bs, @@ -3013,6 +3070,8 @@ BlockDriver bdrv_qcow2 = { .bdrv_open = qcow2_open, .bdrv_close = qcow2_close, .bdrv_reopen_prepare = qcow2_reopen_prepare, + .bdrv_reopen_commit = qcow2_reopen_commit, + .bdrv_reopen_abort = qcow2_reopen_abort, .bdrv_create = qcow2_create, .bdrv_has_zero_init = bdrv_has_zero_init_1, .bdrv_co_get_block_status = qcow2_co_get_block_status, -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 14:11:00 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXvS0-0007Xn-TN for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 14:11:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXvRy-0007U9-PR for qemu-block@nongnu.org; Fri, 04 Sep 2015 14:10:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXvRt-0002S2-MX for qemu-block@nongnu.org; Fri, 04 Sep 2015 14:10:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43772) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXvRt-0002Rt-GL; Fri, 04 Sep 2015 14:10:53 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id D53DA341AF5; Fri, 4 Sep 2015 18:10:50 +0000 (UTC) Received: from [10.36.116.49] (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84IAmhV021896 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 4 Sep 2015 14:10:49 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> <1441387117-27072-3-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <55E9DEA7.8030903@redhat.com> Date: Fri, 4 Sep 2015 20:10:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441387117-27072-3-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jBLs0FoITFE6mWDghBK2Dti4RDAAnP8AF" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 02/13] qemu-io: Remove duplicate 'open' error message X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 18:10:59 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jBLs0FoITFE6mWDghBK2Dti4RDAAnP8AF Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 04.09.2015 19:18, Kevin Wolf wrote: > qemu_opts_parse_noisily() already prints an error message with the exac= t > reason why the parsing failed. No need to add another less specific one= =2E >=20 > Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --jBLs0FoITFE6mWDghBK2Dti4RDAAnP8AF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV6d6nAAoJEDuxQgLoOKyth7MIAI0irCncbY3A5Fn3vUIOlXcL IXJy+8DHVntIXUDSJDMD1dAXwXSLZZg3HC71THZI6q8wZX/Vi8Kc730brGFn7/s+ T0FFxbKe8FMsmqeQC6wPu6jT58yyKa/7lEJ9NOTCkcIICSbVEAwZ6bren9Bcmsq2 NsW4UzkITqZjaKZe3AZR9CyHxaQ/R9S0aUyoWhITGfjG0trRJW1mBk47ti9kCPJx Q5Ph35weswZHtXOztWxx+UZx+tx3Hv4dlP1cuYkMyEhdrSTYZNJvcFshRH4OXp+l FRQdnLcGiO1g7IN0Sdm/yW1hybLzYRAR2XSbkQRGUINVa53U38pi/mfWyHvPO7w= =h3Fw -----END PGP SIGNATURE----- --jBLs0FoITFE6mWDghBK2Dti4RDAAnP8AF-- From MAILER-DAEMON Fri Sep 04 14:33:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXvoA-0003v2-Qf for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 14:33:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXvo8-0003rS-J3 for qemu-block@nongnu.org; Fri, 04 Sep 2015 14:33:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXvo4-00047G-Gr for qemu-block@nongnu.org; Fri, 04 Sep 2015 14:33:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60046) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXvo4-00046p-CS; Fri, 04 Sep 2015 14:33:48 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 0B6B08E3F3; Fri, 4 Sep 2015 18:33:48 +0000 (UTC) Received: from [10.36.116.49] (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84IXjEY010465 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 4 Sep 2015 14:33:46 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> <1441387117-27072-4-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <55E9E408.1010903@redhat.com> Date: Fri, 4 Sep 2015 20:33:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441387117-27072-4-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="cGr1XVde1lSexxx5uMMFoL3S7OM7ppSUl" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 03/13] qemu-io: Add command 'reopen' X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 18:33:53 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --cGr1XVde1lSexxx5uMMFoL3S7OM7ppSUl Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 04.09.2015 19:18, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > qemu-io-cmds.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++ > 1 file changed, 90 insertions(+) Reviewed-by: Max Reitz --cGr1XVde1lSexxx5uMMFoL3S7OM7ppSUl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV6eQIAAoJEDuxQgLoOKytUHEIAJojY5P2519KgXJNyBXnW9aB Ui3W556qYQw663XEelAg6fRjYHwI6xfyEUCF5AiptqQRUlutJHxRheguObC5OqwK pDQMEmTqeTsReOt+4EDcGrqBR9T5B7duCQ4CaXpRDpMzzU82kN31qPD7CYzfNWN1 VJKXmolUGNZj9xT4c46MBSDbdvVQpGbx1Mb7sB9SwLjoe4/KLh77tg08/qKFaPq+ 9NHkeKzQiXgZ8Avz7ONHXKNPAW9TjsZ5Jx4v9N7cerfbG9VSZsK4xUGgsRMPXoO9 YbifbLWBD1TFxh7ItnMhYCGqw8o7xIucguBH2Y2dq5qYeBbaQNaAZsZnYphZiL8= =CoK1 -----END PGP SIGNATURE----- --cGr1XVde1lSexxx5uMMFoL3S7OM7ppSUl-- From MAILER-DAEMON Fri Sep 04 14:34:25 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXvof-0004p6-Pt for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 14:34:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXvoe-0004lT-2W for qemu-block@nongnu.org; Fri, 04 Sep 2015 14:34:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXvoa-0004U9-0e for qemu-block@nongnu.org; Fri, 04 Sep 2015 14:34:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48543) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXvoZ-0004U1-Rs; Fri, 04 Sep 2015 14:34:19 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 95522461D4; Fri, 4 Sep 2015 18:34:19 +0000 (UTC) Received: from [10.36.116.49] (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84IYH4U003173 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 4 Sep 2015 14:34:18 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> <1441387117-27072-5-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <55E9E428.30402@redhat.com> Date: Fri, 4 Sep 2015 20:34:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441387117-27072-5-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="9184O5dlvAFWEPAdIqgpum7lxbj4xxU5L" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 04/13] qcow2: Improve error message X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 18:34:25 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --9184O5dlvAFWEPAdIqgpum7lxbj4xxU5L Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 04.09.2015 19:18, Kevin Wolf wrote: > Eric says that "any" sounds better than "either", and my non-native > feeling says the same, so let's change it. >=20 > Suggested-by: Eric Blake > Signed-off-by: Kevin Wolf > --- > block/qcow2.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Max Reitz --9184O5dlvAFWEPAdIqgpum7lxbj4xxU5L Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV6eQoAAoJEDuxQgLoOKyt/P4IAIwCez/JHiCGODsWiF/NzogU /cXQmwQGBF4D/Hf2tQr7WfCsvXXNjSrkteoA7mZsSrvZjZAEIbt2MkTgXinwRo7w DL48ewwoi/D+pKn+lP+WavfXE0s42qysGtyXAR+FJm05IiZi6HL3UWr6MgUhOKrN aO/OoNVVNHkbT0L12UY/Cn8iM/z8GH2/aTBmRahYsWCaJBPglGpE9QBZqkB9KMhg mrGvX2IVRdT7iuEPbTcfrbBDFVxYgC97gYuuoRLJp/hbCQ+iZuplfWjsYjW7MBHn oxVgFGmScU+5C62ndIYz00QodCa6NgQrk0IHBxDZ3x2qV/U35LrMJM/HMiYgHGo= =MdKv -----END PGP SIGNATURE----- --9184O5dlvAFWEPAdIqgpum7lxbj4xxU5L-- From MAILER-DAEMON Fri Sep 04 15:16:48 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXwTg-0006SB-5J for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 15:16:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXwTd-0006RR-Mg for qemu-block@nongnu.org; Fri, 04 Sep 2015 15:16:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXwTY-0000pl-O1 for qemu-block@nongnu.org; Fri, 04 Sep 2015 15:16:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXwTY-0000pU-JL; Fri, 04 Sep 2015 15:16:40 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 441DD8F2E4; Fri, 4 Sep 2015 19:16:39 +0000 (UTC) Received: from [10.36.116.49] (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84JGaJB023092 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 4 Sep 2015 15:16:38 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> <1441387117-27072-12-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <55E9EE14.9090300@redhat.com> Date: Fri, 4 Sep 2015 21:16:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441387117-27072-12-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jAgwJMH6uPOAVfDeDvhmguBsvg00c5wPr" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 11/13] qcow2: Support updating driver-specific options in reopen X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 19:16:46 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jAgwJMH6uPOAVfDeDvhmguBsvg00c5wPr Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 04.09.2015 19:18, Kevin Wolf wrote: > For updating the cache sizes or disabling lazy refcounts there is a bit= > more to do than just changing the variables, but otherwise we're all se= t > for changing options during bdrv_reopen(). >=20 > Just implement the missing pieces and hook the functions up in > bdrv_reopen(). >=20 > Signed-off-by: Kevin Wolf > --- > block/qcow2.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++= +++----- > 1 file changed, 65 insertions(+), 6 deletions(-) Reviewed-by: Max Reitz --jAgwJMH6uPOAVfDeDvhmguBsvg00c5wPr Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV6e4UAAoJEDuxQgLoOKytRGIH/jeE9a8VBzAVHhO4ygrbijhW ZxwDiFdMFKxd1OWqguLkn+JU0/gPatq1UZDBZYX7YN+/YH/dc0XBJe8fJI+kSurj Y7qG7jbV4YQW0TIiIWXCajgE0Z0c4IVx6ygqoVpZCEylIpzznvGM8LgBv2LI+Gp2 PqBcW+g4Zyzm3aqCL59HwRl93qmW1lYI0boPyMVu1uV0nTG78926elhsSqysAIGF s3OocPjBk8TA/LQrC2xcazgESKM0uVks9Jon5JUP/Qdxr+7e0W2p8tyv/JVKr3Fb SqsMDbYXtUJ5YkN2O3ahJqiYxOE191m8z00SNtsS+XcKoa7x94DxInKBKyzWoas= =d0YY -----END PGP SIGNATURE----- --jAgwJMH6uPOAVfDeDvhmguBsvg00c5wPr-- From MAILER-DAEMON Fri Sep 04 15:22:22 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXwZ4-000121-6l for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 15:22:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXwZ1-00010m-N8 for qemu-block@nongnu.org; Fri, 04 Sep 2015 15:22:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXwYx-0006c4-Nw for qemu-block@nongnu.org; Fri, 04 Sep 2015 15:22:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47730) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXwYx-0006bU-H7; Fri, 04 Sep 2015 15:22:15 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id E0866C0B2B44; Fri, 4 Sep 2015 19:22:14 +0000 (UTC) Received: from [10.36.116.49] (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84JMBTg031546 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 4 Sep 2015 15:22:13 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> <1441387117-27072-13-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <55E9EF63.7080204@redhat.com> Date: Fri, 4 Sep 2015 21:22:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441387117-27072-13-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="IdEr9FwdoopPQP1MeSb6XweoDU2aU69nk" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 12/13] qemu-iotests: Reopen qcow2 with lazy-refcounts change X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 19:22:20 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --IdEr9FwdoopPQP1MeSb6XweoDU2aU69nk Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 04.09.2015 19:18, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > tests/qemu-iotests/039 | 27 +++++++++++++++++++++++++++ > tests/qemu-iotests/039.out | 18 ++++++++++++++++++ > 2 files changed, 45 insertions(+) >=20 > diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 > index 617f397..9e9b379 100755 > --- a/tests/qemu-iotests/039 > +++ b/tests/qemu-iotests/039 > @@ -147,6 +147,33 @@ $PYTHON qcow2.py "$TEST_IMG".base dump-header | gr= ep incompatible_features > _check_test_img > TEST_IMG=3D"$TEST_IMG".base _check_test_img > =20 > +echo > +echo "=3D=3D Changing lazy_refcounts setting at runtime =3D=3D" > + > +IMGOPTS=3D"compat=3D1.1,lazy_refcounts=3Doff" > +_make_test_img $size > + > +$QEMU_IO -c "reopen -o lazy-refcounts=3Don" \ > + -c "write -P 0x5a 0 512" \ > + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ > + | _filter_qemu_io > + > +# The dirty bit must be set > +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features > +_check_test_img > + > +IMGOPTS=3D"compat=3D1.1,lazy_refcounts=3Don" > +_make_test_img $size > + > +$QEMU_IO -c "reopen -o lazy-refcounts=3Doff" \ > + -c "write -P 0x5a 0 512" \ Maybe it would be nicer to test this the other way around, write first and then disable lazy refcounts in order to test whether the refcounts are actually flushed during the reopen. Either way: Reviewed-by: Max Reitz > + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ > + | _filter_qemu_io > + > +# The dirty bit must not be set > +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features > +_check_test_img > + > =20 > # success, all done > echo "*** done" > diff --git a/tests/qemu-iotests/039.out b/tests/qemu-iotests/039.out > index b055670..39859b2 100644 > --- a/tests/qemu-iotests/039.out > +++ b/tests/qemu-iotests/039.out > @@ -74,4 +74,22 @@ incompatible_features 0x0 > incompatible_features 0x0 > No errors were found on the image. > No errors were found on the image. > + > +=3D=3D Changing lazy_refcounts setting at runtime =3D=3D > +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 > +wrote 512/512 bytes at offset 0 > +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_= IO_OPTIONS "$@" ) > +incompatible_features 0x1 > +ERROR cluster 5 refcount=3D0 reference=3D1 > +ERROR OFLAG_COPIED data cluster: l2_entry=3D8000000000050000 refcount=3D= 0 > + > +2 errors were found on the image. > +Data may be corrupted, or further writes to the image may corrupt it. > +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 > +wrote 512/512 bytes at offset 0 > +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_= IO_OPTIONS "$@" ) > +incompatible_features 0x0 > +No errors were found on the image. > *** done >=20 --IdEr9FwdoopPQP1MeSb6XweoDU2aU69nk Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV6e9jAAoJEDuxQgLoOKytHWcH/javAzPbNyK+Zz9Jc4+WXKcr UBJ/KDqvtjBc82uoQcS9ieWjZ/Nr/5bFu8Tts4JSnxFvw1IAIxbSkpXj+5Fo8AXZ hcIQEB2aaDShdXGLTtb6i4zFkJIY+xm6nHIB5vDZu9pKp2ZSeRiXzxJxKQVainYh 4Gec//gwwjHtecXcnq0eUd1tXuiS50kkb49ThrGhr8cmZnJLLK0swpuSHszguJmq n2IoB6FlVpzBrlN8atTaNwcLlhri7WaHnickZO64x5uxwRhepYsIblvxtmAfVcR7 ve+Y99w43rcnXxDhwGAdi8J/8EKXTliVJNhpVdRC2/aJXMCWluoOjx4qj6Z8xcc= =rUp6 -----END PGP SIGNATURE----- --IdEr9FwdoopPQP1MeSb6XweoDU2aU69nk-- From MAILER-DAEMON Fri Sep 04 15:52:42 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXx2Q-0005nE-Ti for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 15:52:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXx2O-0005mJ-NJ for qemu-block@nongnu.org; Fri, 04 Sep 2015 15:52:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXx2L-0005AT-Fm for qemu-block@nongnu.org; Fri, 04 Sep 2015 15:52:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35549) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXx2L-0005AN-90; Fri, 04 Sep 2015 15:52:37 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id BCAA0461D4; Fri, 4 Sep 2015 19:52:36 +0000 (UTC) Received: from [10.36.116.49] (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84JqU7P027457 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 4 Sep 2015 15:52:35 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> <1441387117-27072-14-git-send-email-kwolf@redhat.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <55E9F67D.9010909@redhat.com> Date: Fri, 4 Sep 2015 21:52:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441387117-27072-14-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="CNWxh8B6GD2ohEA2s7Rxb72B5s4CGxDgV" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 13/13] qemu-iotests: More qcow2 reopen tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 19:52:41 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --CNWxh8B6GD2ohEA2s7Rxb72B5s4CGxDgV Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 04.09.2015 19:18, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > tests/qemu-iotests/137 | 143 +++++++++++++++++++++++++++++++++++++= ++++++++ > tests/qemu-iotests/137.out | 43 ++++++++++++++ > tests/qemu-iotests/group | 1 + > 3 files changed, 187 insertions(+) > create mode 100755 tests/qemu-iotests/137 > create mode 100644 tests/qemu-iotests/137.out >=20 > diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 > new file mode 100755 > index 0000000..ad52f71 > --- /dev/null > +++ b/tests/qemu-iotests/137 [snip] > +echo > +echo =3D=3D=3D Try setting some invalid values =3D=3D=3D > +echo > + > +$QEMU_IO \ > + -c "reopen -o lazy-refcounts=3D42" \ > + -c "reopen -o cache-size=3D1M,l2-cache-size=3D64k,refcount-cache-s= ize=3D64k" \ > + -c "reopen -o cache-size=3D1M,l2-cache-size=3D2M" \ > + -c "reopen -o cache-size=3D1M,refcount-cache-size=3D2M" \ > + -c "reopen -o l2-cache-size=3D256T" \ > + -c "reopen -o l2-cache-size=3D64G" \ Testing this seems risky. The rest looks fine, but I'm not sure whether this is really needed so much that we should risk the test failing on some machines, especially in the future. Or actually even on my machine: $ touch ~/tmp/swap $ truncate ~/tmp/swap --size 128G $ fallocate -l 128G ~/tmp/swap # mkswap ~maxx/tmp/swap # swapon ~max/tmp/swap $ cd /to/qemu/build $ ./qemu-io -c 'reopen -o l2-cache-size=3D64G' test.qcow2 $ (Running the test itself is apparently a bad idea, because then for some reason Linux thinks I actually want to use the swap and everything slows down to a crawl) Max > + -c "reopen -o refcount-cache-size=3D256T" \ > + -c "reopen -o refcount-cache-size=3D64G" \ > + -c "reopen -o overlap-check=3Dconstant,overlap-check.template=3Dal= l" \ > + -c "reopen -o overlap-check=3Dblubb" \ > + -c "reopen -o overlap-check.template=3Dblubb" \ > + "$TEST_IMG" | _filter_qemu_io > + [snip] --CNWxh8B6GD2ohEA2s7Rxb72B5s4CGxDgV Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV6fZ+AAoJEDuxQgLoOKytd6YIAKumkgPbioqeqE3To4PwQryI AUe5DUOkps5EzRrVVbSKfNYYAFDlQTA7WO0GHF5eIPHSgkLTzB8pmf2Fl/Dxkz6I 1PQT6yPJMbpj2OZFDox5coKPVZmsoLAAGX7axm0NBHxIpstZbuuePcPSRQ/ZKWrP TmJgaolgBLNxC8UNaXF5fg6AYbDNIFM2Z8eySIpaukcYAW2o0P1n2v9KoeRd+Kl8 nam4hMJ6vMxN9T8LvjB2+5zv6WlwjhzB42DGwBtJASq+Zt6dDgz+iC7FkD/8Ki8i hbdVIhmTmN9rAoIPrN4WcvzVlkVCf8GoC4goX7KaAHQxNNMRhr5doOdhW+lLShc= =3k9H -----END PGP SIGNATURE----- --CNWxh8B6GD2ohEA2s7Rxb72B5s4CGxDgV-- From MAILER-DAEMON Fri Sep 04 16:10:59 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxK7-0001O8-7r for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:10:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxK5-0001N8-3P for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:10:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxK0-000575-A1 for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:10:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxK0-00056r-5N; Fri, 04 Sep 2015 16:10:52 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 37CF18F314; Fri, 4 Sep 2015 20:10:51 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlK021891; Fri, 4 Sep 2015 16:10:49 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:31 +0200 Message-Id: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 00/16] Block patches X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:10:58 -0000 The following changes since commit b597aa037dbd98014c8dec3d69a5e2240f432533: Merge remote-tracking branch 'remotes/armbru/tags/pull-monitor-2015-09-04' into staging (2015-09-04 17:37:50 +0100) are available in the git repository at: git://repo.or.cz/qemu/kevin.git tags/for-upstream for you to fetch changes up to c804b5791d51608c0e12e4cc2b40b3d763ce796c: Merge remote-tracking branch 'mreitz/tags/pull-block-for-kevin-2015-09-04' into queue-block (2015-09-04 21:43:55 +0200) ---------------------------------------------------------------- Block layer patches ---------------------------------------------------------------- Alberto Garcia (4): qcow2: mark the memory as no longer needed after qcow2_cache_empty() qcow2: add option to clean unused cache entries after some time docs: document how to configure the qcow2 L2/refcount caches qcow2: reorder fields in Qcow2CachedTable to reduce padding Bo Tu (5): qemu-iotests: qemu machine type support qemu-iotests: disable default qemu devices for cross-platform compatibility qemu-iotests: s390x: fix test 041 and 055 qemu-iotests: s390x: fix test 049, reject negative sizes in QemuOpts qemu-iotests: s390x: fix test 130 Kevin Wolf (1): Merge remote-tracking branch 'mreitz/tags/pull-block-for-kevin-2015-09-04' into queue-block Max Reitz (6): block/raw-posix: Use raw_normalize_devicepath() qemu-img: Fix crash in amend invocation iotests: More options for VM.add_drive() iotests: Respect -nodefaults in tests 41 and 55 iotests: Do not suppress segfaults in bash tests iotests: Warn if python subprocess is killed Wen Congyang (1): quorum: validate vote threshold against num_children even if read-pattern is fifo block/qcow2-cache.c | 63 +++++++++- block/qcow2.c | 64 ++++++++++ block/qcow2.h | 4 + block/quorum.c | 12 +- block/raw-posix.c | 22 +++- docs/qcow2-cache.txt | 164 ++++++++++++++++++++++++ qapi/block-core.json | 7 +- qemu-img.c | 3 +- tests/qemu-iotests/039 | 19 +-- tests/qemu-iotests/039.out | 6 +- tests/qemu-iotests/041 | 18 ++- tests/qemu-iotests/049.out | 10 +- tests/qemu-iotests/055 | 19 ++- tests/qemu-iotests/061 | 6 +- tests/qemu-iotests/061.out | 2 + tests/qemu-iotests/067 | 8 +- tests/qemu-iotests/067.out | 266 +-------------------------------------- tests/qemu-iotests/071.out | 4 - tests/qemu-iotests/081.out | 2 - tests/qemu-iotests/087.out | 12 -- tests/qemu-iotests/130 | 8 +- tests/qemu-iotests/130.out | 4 +- tests/qemu-iotests/check | 13 +- tests/qemu-iotests/common | 1 + tests/qemu-iotests/common.config | 38 +++++- tests/qemu-iotests/common.qemu | 2 +- tests/qemu-iotests/common.rc | 12 +- tests/qemu-iotests/iotests.py | 52 ++++++-- util/qemu-option.c | 5 + 29 files changed, 487 insertions(+), 359 deletions(-) create mode 100644 docs/qcow2-cache.txt From MAILER-DAEMON Fri Sep 04 16:11:00 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxK8-0001Qr-Bu for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxK5-0001NB-AB for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:10:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxK1-000589-IK for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:10:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxK1-000584-Cj; Fri, 04 Sep 2015 16:10:53 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id CC88E341AF6; Fri, 4 Sep 2015 20:10:52 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlL021891; Fri, 4 Sep 2015 16:10:51 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:32 +0200 Message-Id: <1441397447-6516-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 01/16] qemu-iotests: qemu machine type support X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:10:58 -0000 From: Bo Tu This patch adds qemu machine type support to the io test suite. Based on the qemu default machine type and alias of the default machine type the reference output file can now vary from the default to a machine specific output file if necessary. When using a machine specific reference file if the default machine has an alias then use the alias as the output file name otherwise use the default machine name as the output file name. Reviewed-by: Max Reitz Reviewed-by: Michael Mueller Reviewed-by: Sascha Silbe Signed-off-by: Xiao Guang Chen Signed-off-by: Kevin Wolf --- tests/qemu-iotests/check | 5 +++++ tests/qemu-iotests/common.config | 11 ++++++++++- tests/qemu-iotests/iotests.py | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index 1fa6319..6d58203 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -330,6 +330,11 @@ do fi reference="$source_iotests/$seq.out" + reference_machine="$source_iotests/$seq.$QEMU_DEFAULT_MACHINE.out" + if [ -f "$reference_machine" ]; then + reference="$reference_machine" + fi + if [ "$CACHEMODE" = "none" ]; then [ -f "$source_iotests/$seq.out.nocache" ] && reference="$source_iotests/$seq.out.nocache" fi diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config index a1973ad..e0bf896 100644 --- a/tests/qemu-iotests/common.config +++ b/tests/qemu-iotests/common.config @@ -103,10 +103,19 @@ if [ -z "$QEMU_NBD_PROG" ]; then export QEMU_NBD_PROG="`set_prog_path qemu-nbd`" fi -export QEMU=$QEMU_PROG +export QEMU="$QEMU_PROG $QEMU_OPTIONS" export QEMU_IMG=$QEMU_IMG_PROG export QEMU_IO="$QEMU_IO_PROG $QEMU_IO_OPTIONS" export QEMU_NBD=$QEMU_NBD_PROG +default_machine=$($QEMU -machine \? | awk '/(default)/{print $1}') +default_alias_machine=$($QEMU -machine \? |\ + awk -v var_default_machine="$default_machine"\)\ + '{if ($(NF-2)=="(alias"&&$(NF-1)=="of"&&$(NF)==var_default_machine){print $1}}') +if [ ! -z "$default_alias_machine" ]; then + default_machine="$default_alias_machine" +fi + +export QEMU_DEFAULT_MACHINE="$default_machine" [ -f /etc/qemu-iotest.config ] && . /etc/qemu-iotest.config diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 8615b10..5579253 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -42,6 +42,7 @@ imgproto = os.environ.get('IMGPROTO', 'file') test_dir = os.environ.get('TEST_DIR', '/var/tmp') output_dir = os.environ.get('OUTPUT_DIR', '.') cachemode = os.environ.get('CACHEMODE') +qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE') socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper') -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxK9-0001Ta-Jn for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxK5-0001NC-AV for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxK3-00059G-8X for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:10:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38703) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxK2-000593-UK; Fri, 04 Sep 2015 16:10:55 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 81F58461D6; Fri, 4 Sep 2015 20:10:54 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlM021891; Fri, 4 Sep 2015 16:10:53 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:33 +0200 Message-Id: <1441397447-6516-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 02/16] qemu-iotests: disable default qemu devices for cross-platform compatibility X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:11:00 -0000 From: Bo Tu This patch fixes an io test suite issue that was introduced with the commit c88930a6866e74953e931ae749781e98e486e5c8 'qemu-char: Permit only a single "stdio" character device'. The option supresses the creation of default devices such as the floopy and cdrom. Output files for test case 067, 071, 081 and 087 need to be updated to accommodate this change. Use virtio-blk instead of virtio-blk-pci as the device driver for test case 067. For virtio-blk-pci is the same with virtio-blk as device driver but other platform such as s390 may not recognize the virtio-blk-pci. The default devices differ across machines. As the qemu output often contains these devices (or events for them, like opening a CD tray on reset), the reference output currently is rather machine-specific. All existing qemu tests explicitly configure the devices they're working with, so just pass -nodefaults to qemu by default to disable the default devices. Update the reference outputs accordingly. Reviewed-by: Max Reitz Reviewed-by: Michael Mueller Reviewed-by: Sascha Silbe Signed-off-by: Xiao Guang Chen Signed-off-by: Kevin Wolf --- tests/qemu-iotests/067 | 8 +- tests/qemu-iotests/067.out | 266 +---------------------------------------- tests/qemu-iotests/071.out | 4 - tests/qemu-iotests/081.out | 2 - tests/qemu-iotests/087.out | 12 -- tests/qemu-iotests/common | 1 + tests/qemu-iotests/common.qemu | 2 +- 7 files changed, 7 insertions(+), 288 deletions(-) diff --git a/tests/qemu-iotests/067 b/tests/qemu-iotests/067 index 83eefa3..3e9a053 100755 --- a/tests/qemu-iotests/067 +++ b/tests/qemu-iotests/067 @@ -59,7 +59,7 @@ echo echo === -drive/-device and device_del === echo -run_qemu -drive file=$TEST_IMG,format=$IMGFMT,if=none,id=disk -device virtio-blk-pci,drive=disk,id=virtio0 <"${fifo_out}" \ 2>&1 \ <"${fifo_in}" & -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxKA-0001Vp-DC for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxK7-0001Oj-Fy for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxK6-0005CF-D2 for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:10:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxK6-0005Bl-5Y; Fri, 04 Sep 2015 16:10:58 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id BB5684C099; Fri, 4 Sep 2015 20:10:57 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlO021891; Fri, 4 Sep 2015 16:10:56 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:35 +0200 Message-Id: <1441397447-6516-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 04/16] qemu-iotests: s390x: fix test 049, reject negative sizes in QemuOpts X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:11:00 -0000 From: Bo Tu when creating an image qemu-img enable us specifying the size of the image using -o size=xx options. But when we specify an invalid size such as a negtive size then different platform gives different result. parse_option_size() function in util/qemu-option.c will be called to parse the size, a cast was called in the function to cast the input (saved as a double in the function) size to an unsigned int64 value, when the input is a negtive value or exceeds the maximum of uint64, then the result is undefined. According to C99 6.3.1.4, the result of converting a floating point number to an integer that cannot represent the (integer part of) number is undefined. And sure enough the results are different on x86 and s390. C99 Language spec 6.3.1.4 Real floating and integers: the result of this assignment/cast is undefined if the float is not in the open interval (-1, U_MAX+1). Reviewed-by: Max Reitz Reviewed-by: Sascha Silbe Signed-off-by: Bo Tu Signed-off-by: Kevin Wolf --- tests/qemu-iotests/049.out | 10 ++++------ util/qemu-option.c | 5 +++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out index 9f93666..8884543 100644 --- a/tests/qemu-iotests/049.out +++ b/tests/qemu-iotests/049.out @@ -95,17 +95,15 @@ qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- -1024 qemu-img: Image size must be less than 8 EiB! qemu-img create -f qcow2 -o size=-1024 TEST_DIR/t.qcow2 -qemu-img: qcow2 doesn't support shrinking images yet -qemu-img: TEST_DIR/t.qcow2: Could not resize image: Operation not supported -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=-1024 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 +qemu-img: Parameter 'size' expects a non-negative number below 2^64 +qemu-img: TEST_DIR/t.qcow2: Invalid options for file format 'qcow2' qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- -1k qemu-img: Image size must be less than 8 EiB! qemu-img create -f qcow2 -o size=-1k TEST_DIR/t.qcow2 -qemu-img: qcow2 doesn't support shrinking images yet -qemu-img: TEST_DIR/t.qcow2: Could not resize image: Operation not supported -Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=-1024 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 +qemu-img: Parameter 'size' expects a non-negative number below 2^64 +qemu-img: TEST_DIR/t.qcow2: Invalid options for file format 'qcow2' qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- 1kilobyte qemu-img: Invalid image size specified! You may use k, M, G, T, P or E suffixes for diff --git a/util/qemu-option.c b/util/qemu-option.c index efe9d27..efd6f02 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -180,6 +180,11 @@ void parse_option_size(const char *name, const char *value, if (value != NULL) { sizef = strtod(value, &postfix); + if (sizef < 0 || sizef > UINT64_MAX) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, + "a non-negative number below 2^64"); + return; + } switch (*postfix) { case 'T': sizef *= 1024; -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:00 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxK8-0001RP-GK for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxK5-0001NF-PB for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:10:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxK4-0005AK-Qc for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:10:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54758) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxK4-00059p-Lm; Fri, 04 Sep 2015 16:10:56 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 3A4B5A444A; Fri, 4 Sep 2015 20:10:56 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlN021891; Fri, 4 Sep 2015 16:10:54 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:34 +0200 Message-Id: <1441397447-6516-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 03/16] qemu-iotests: s390x: fix test 041 and 055 X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:10:58 -0000 From: Bo Tu There is no 'ide-cd' device defined on non-pc platform, so test_medium_not_found() test should be skipped. Reviewed-by: Max Reitz Reviewed-by: Michael Mueller Reviewed-by: Sascha Silbe Signed-off-by: Xiao Guang Chen Signed-off-by: Kevin Wolf --- tests/qemu-iotests/041 | 6 ++++++ tests/qemu-iotests/055 | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index 3d46ed7..de8ea15 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -167,6 +167,9 @@ class TestSingleDrive(iotests.QMPTestCase): 'target image does not match source after mirroring') def test_medium_not_found(self): + if iotests.qemu_default_machine != 'pc': + return + result = self.vm.qmp('drive-mirror', device='ide1-cd0', sync='full', target=target_img) self.assert_qmp(result, 'error/class', 'GenericError') @@ -831,6 +834,9 @@ class TestRepairQuorum(iotests.QMPTestCase): if not self.has_quorum(): return + if iotests.qemu_default_machine != 'pc': + return + result = self.vm.qmp('drive-mirror', device='ide1-cd0', sync='full', node_name='repair0', replaces='img1', diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055 index 017a609..e6e0ac4 100755 --- a/tests/qemu-iotests/055 +++ b/tests/qemu-iotests/055 @@ -104,11 +104,17 @@ class TestSingleDrive(iotests.QMPTestCase): self.do_test_pause('blockdev-backup', 'drive1', blockdev_target_img) def test_medium_not_found(self): + if iotests.qemu_default_machine != 'pc': + return + result = self.vm.qmp('drive-backup', device='ide1-cd0', target=target_img, sync='full') self.assert_qmp(result, 'error/class', 'GenericError') def test_medium_not_found_blockdev_backup(self): + if iotests.qemu_default_machine != 'pc': + return + result = self.vm.qmp('blockdev-backup', device='ide1-cd0', target='drive1', sync='full') self.assert_qmp(result, 'error/class', 'GenericError') @@ -323,6 +329,9 @@ class TestSingleTransaction(iotests.QMPTestCase): self.do_test_pause('blockdev-backup', 'drive1', blockdev_target_img) def do_test_medium_not_found(self, cmd, target): + if iotests.qemu_default_machine != 'pc': + return + result = self.vm.qmp('transaction', actions=[{ 'type': cmd, 'data': { 'device': 'ide1-cd0', -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:10 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxKH-0001iw-OU for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKB-0001X7-0r for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxKA-0005FI-5N for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52662) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKA-0005ED-14; Fri, 04 Sep 2015 16:11:02 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 9A313A2C18; Fri, 4 Sep 2015 20:11:01 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlQ021891; Fri, 4 Sep 2015 16:11:00 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:37 +0200 Message-Id: <1441397447-6516-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 06/16] block/raw-posix: Use raw_normalize_devicepath() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:11:08 -0000 From: Max Reitz The filename given to qemu_open() in block/raw-posix.c should generally have been processed by raw_normalize_devicepath(); unless we are only probing (in which case the caller often checks whether the file is a block device or not, and this property will be changed by raw_normalize_devicepath() on NetBSD) or it is about a deprecated device (i.e. floppy). Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/raw-posix.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 855febe..30df8ad 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -670,11 +670,17 @@ static int raw_reopen_prepare(BDRVReopenState *state, /* If we cannot use fcntl, or fcntl failed, fall back to qemu_open() */ if (raw_s->fd == -1) { - assert(!(raw_s->open_flags & O_CREAT)); - raw_s->fd = qemu_open(state->bs->filename, raw_s->open_flags); - if (raw_s->fd == -1) { - error_setg_errno(errp, errno, "Could not reopen file"); - ret = -1; + const char *normalized_filename = state->bs->filename; + ret = raw_normalize_devicepath(&normalized_filename); + if (ret < 0) { + error_setg_errno(errp, -ret, "Could not normalize device path"); + } else { + assert(!(raw_s->open_flags & O_CREAT)); + raw_s->fd = qemu_open(normalized_filename, raw_s->open_flags); + if (raw_s->fd == -1) { + error_setg_errno(errp, errno, "Could not reopen file"); + ret = -1; + } } } @@ -2314,6 +2320,12 @@ static int hdev_create(const char *filename, QemuOpts *opts, (void)has_prefix; + ret = raw_normalize_devicepath(&filename); + if (ret < 0) { + error_setg_errno(errp, -ret, "Could not normalize device path"); + return ret; + } + /* Read out options */ total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:12 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxKK-0001ms-3U for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKG-0001f4-1F for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxKD-0005Gu-H7 for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKD-0005Gi-Bf; Fri, 04 Sep 2015 16:11:05 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id E9F31C0AD281; Fri, 4 Sep 2015 20:11:04 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlS021891; Fri, 4 Sep 2015 16:11:03 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:39 +0200 Message-Id: <1441397447-6516-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 08/16] iotests: More options for VM.add_drive() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:11:09 -0000 From: Max Reitz This patch allows specifying the interface to be used for the drive, and makes specifying a path optional (if the path is None, the "file" option will be omitted, thus creating an empty drive). Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- tests/qemu-iotests/iotests.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 5579253..1f913a1 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -118,13 +118,16 @@ class VM(object): self._args.append('-monitor') self._args.append(args) - def add_drive(self, path, opts=''): + def add_drive(self, path, opts='', interface='virtio'): '''Add a virtio-blk drive to the VM''' - options = ['if=virtio', + options = ['if=%s' % interface, 'format=%s' % imgfmt, 'cache=%s' % cachemode, - 'file=%s' % path, 'id=drive%d' % self._num_drives] + + if path is not None: + options.append('file=%s' % path) + if opts: options.append(opts) -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxKL-0001p8-19 for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKG-0001fc-FB for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxKF-0005HQ-AE for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54814) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKF-0005HJ-1s; Fri, 04 Sep 2015 16:11:07 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id A3B0791DAC; Fri, 4 Sep 2015 20:11:06 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlT021891; Fri, 4 Sep 2015 16:11:05 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:40 +0200 Message-Id: <1441397447-6516-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 09/16] iotests: Respect -nodefaults in tests 41 and 55 X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:11:10 -0000 From: Max Reitz While -nodefaults is set in $QEMU_OPTIONS, this is currently (wrongly) ignored for Python iotests. In order to be prepared for when this is fixed, we should explicitly add an IDE CD-ROM drive instead of relying on it being created automatically. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- tests/qemu-iotests/041 | 12 +++++++++--- tests/qemu-iotests/055 | 10 +++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index de8ea15..38ca5f1 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -42,6 +42,8 @@ class TestSingleDrive(iotests.QMPTestCase): iotests.create_image(backing_img, self.image_len) qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img) self.vm = iotests.VM().add_drive(test_img) + if iotests.qemu_default_machine == 'pc': + self.vm.add_drive(None, 'media=cdrom', 'ide') self.vm.launch() def tearDown(self): @@ -170,8 +172,8 @@ class TestSingleDrive(iotests.QMPTestCase): if iotests.qemu_default_machine != 'pc': return - result = self.vm.qmp('drive-mirror', device='ide1-cd0', sync='full', - target=target_img) + result = self.vm.qmp('drive-mirror', device='drive1', # CD-ROM + sync='full', target=target_img) self.assert_qmp(result, 'error/class', 'GenericError') def test_image_not_found(self): @@ -710,6 +712,9 @@ class TestRepairQuorum(iotests.QMPTestCase): def setUp(self): self.vm = iotests.VM() + if iotests.qemu_default_machine == 'pc': + self.vm.add_drive(None, 'media=cdrom', 'ide') + # Add each individual quorum images for i in self.IMAGES: qemu_img('create', '-f', iotests.imgfmt, i, @@ -837,7 +842,8 @@ class TestRepairQuorum(iotests.QMPTestCase): if iotests.qemu_default_machine != 'pc': return - result = self.vm.qmp('drive-mirror', device='ide1-cd0', sync='full', + result = self.vm.qmp('drive-mirror', device='drive0', # CD-ROM + sync='full', node_name='repair0', replaces='img1', target=quorum_repair_img, format=iotests.imgfmt) diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055 index e6e0ac4..c8e3578 100755 --- a/tests/qemu-iotests/055 +++ b/tests/qemu-iotests/055 @@ -42,6 +42,8 @@ class TestSingleDrive(iotests.QMPTestCase): qemu_img('create', '-f', iotests.imgfmt, blockdev_target_img, str(TestSingleDrive.image_len)) self.vm = iotests.VM().add_drive(test_img).add_drive(blockdev_target_img) + if iotests.qemu_default_machine == 'pc': + self.vm.add_drive(None, 'media=cdrom', 'ide') self.vm.launch() def tearDown(self): @@ -107,7 +109,7 @@ class TestSingleDrive(iotests.QMPTestCase): if iotests.qemu_default_machine != 'pc': return - result = self.vm.qmp('drive-backup', device='ide1-cd0', + result = self.vm.qmp('drive-backup', device='drive2', # CD-ROM target=target_img, sync='full') self.assert_qmp(result, 'error/class', 'GenericError') @@ -115,7 +117,7 @@ class TestSingleDrive(iotests.QMPTestCase): if iotests.qemu_default_machine != 'pc': return - result = self.vm.qmp('blockdev-backup', device='ide1-cd0', + result = self.vm.qmp('blockdev-backup', device='drive2', # CD-ROM target='drive1', sync='full') self.assert_qmp(result, 'error/class', 'GenericError') @@ -255,6 +257,8 @@ class TestSingleTransaction(iotests.QMPTestCase): qemu_img('create', '-f', iotests.imgfmt, blockdev_target_img, str(TestSingleDrive.image_len)) self.vm = iotests.VM().add_drive(test_img).add_drive(blockdev_target_img) + if iotests.qemu_default_machine == 'pc': + self.vm.add_drive(None, 'media=cdrom', 'ide') self.vm.launch() def tearDown(self): @@ -334,7 +338,7 @@ class TestSingleTransaction(iotests.QMPTestCase): result = self.vm.qmp('transaction', actions=[{ 'type': cmd, - 'data': { 'device': 'ide1-cd0', + 'data': { 'device': 'drive2', # CD-ROM 'target': target, 'sync': 'full' }, } -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxKM-0001rx-Vp for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKJ-0001le-KU for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxKI-0005Jc-NU for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKI-0005JP-GH; Fri, 04 Sep 2015 16:11:10 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 1BA9CA2C1F; Fri, 4 Sep 2015 20:11:10 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlV021891; Fri, 4 Sep 2015 16:11:08 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:42 +0200 Message-Id: <1441397447-6516-12-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 11/16] iotests: Warn if python subprocess is killed X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:11:12 -0000 From: Max Reitz Currently, if a subprocess of a python test (i.e. qemu-io, qemu-img, or qemu) receives a signal and is subsequently aborted, this is not logged. This patch makes python tests always check the exit code of these subprocesses, and emit a message if they have been killed. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- tests/qemu-iotests/iotests.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 8e3419f..ff5905f 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -57,20 +57,34 @@ socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper') def qemu_img(*args): '''Run qemu-img and return the exit code''' devnull = open('/dev/null', 'r+') - return subprocess.call(qemu_img_args + list(args), stdin=devnull, stdout=devnull) + exitcode = subprocess.call(qemu_img_args + list(args), stdin=devnull, stdout=devnull) + if exitcode < 0: + sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) + return exitcode def qemu_img_verbose(*args): '''Run qemu-img without suppressing its output and return the exit code''' - return subprocess.call(qemu_img_args + list(args)) + exitcode = subprocess.call(qemu_img_args + list(args)) + if exitcode < 0: + sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) + return exitcode def qemu_img_pipe(*args): '''Run qemu-img and return its output''' - return subprocess.Popen(qemu_img_args + list(args), stdout=subprocess.PIPE).communicate()[0] + subp = subprocess.Popen(qemu_img_args + list(args), stdout=subprocess.PIPE) + exitcode = subp.wait() + if exitcode < 0: + sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) + return subp.communicate()[0] def qemu_io(*args): '''Run qemu-io and return the stdout data''' args = qemu_io_args + list(args) - return subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0] + subp = subprocess.Popen(args, stdout=subprocess.PIPE) + exitcode = subp.wait() + if exitcode < 0: + sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' '.join(args))) + return subp.communicate()[0] def compare_images(img1, img2): '''Return True if two image files are identical''' @@ -208,7 +222,9 @@ class VM(object): '''Terminate the VM and clean up''' if not self._popen is None: self._qmp.cmd('quit') - self._popen.wait() + exitcode = self._popen.wait() + if exitcode < 0: + sys.stderr.write('qemu received signal %i: %s\n' % (-exitcode, ' '.join(self._args))) os.remove(self._monitor_path) os.remove(self._qtest_path) os.remove(self._qemu_log_path) -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:09 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxKG-0001gm-Sh for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxK9-0001UG-SJ for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxK8-0005DG-KR for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57017) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxK8-0005D2-D3; Fri, 04 Sep 2015 16:11:00 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 02507C0B2E1A; Fri, 4 Sep 2015 20:10:59 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlP021891; Fri, 4 Sep 2015 16:10:58 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:36 +0200 Message-Id: <1441397447-6516-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 05/16] qemu-iotests: s390x: fix test 130 X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:11:03 -0000 From: Bo Tu The default device id of hard disk on the s390 platform is "virtio0" which differs to the "ide0-hd0" for the x86 platform. Setting id in the drive definition, ie:"qemu -drive id=testdisk", will be the same on all platforms. Reviewed-by: Max Reitz Signed-off-by: Bo Tu Signed-off-by: Kevin Wolf --- tests/qemu-iotests/130 | 8 ++++---- tests/qemu-iotests/130.out | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/130 b/tests/qemu-iotests/130 index bc26247..9209992 100755 --- a/tests/qemu-iotests/130 +++ b/tests/qemu-iotests/130 @@ -59,8 +59,8 @@ echo # bdrv_make_empty() involves a header update for qcow2 # Test that a backing file isn't written -_launch_qemu -drive file="$TEST_IMG",backing.file.filename="$TEST_IMG.base" -_send_qemu_cmd $QEMU_HANDLE "commit ide0-hd0" "(qemu)" +_launch_qemu -drive id=testdisk,file="$TEST_IMG",backing.file.filename="$TEST_IMG.base" +_send_qemu_cmd $QEMU_HANDLE "commit testdisk" "(qemu)" _send_qemu_cmd $QEMU_HANDLE '' '(qemu)' _cleanup_qemu _img_info | _filter_img_info @@ -68,8 +68,8 @@ _img_info | _filter_img_info # Make sure that if there was a backing file that was just overridden on the # command line, that backing file is retained, with the right format _make_test_img -F raw -b "$TEST_IMG.orig" 64M -_launch_qemu -drive file="$TEST_IMG",backing.file.filename="$TEST_IMG.base",backing.driver=$IMGFMT -_send_qemu_cmd $QEMU_HANDLE "commit ide0-hd0" "(qemu)" +_launch_qemu -drive id=testdisk,file="$TEST_IMG",backing.file.filename="$TEST_IMG.base",backing.driver=$IMGFMT +_send_qemu_cmd $QEMU_HANDLE "commit testdisk" "(qemu)" _send_qemu_cmd $QEMU_HANDLE '' '(qemu)' _cleanup_qemu _img_info | _filter_img_info diff --git a/tests/qemu-iotests/130.out b/tests/qemu-iotests/130.out index ea68b5d..9ec9d2a 100644 --- a/tests/qemu-iotests/130.out +++ b/tests/qemu-iotests/130.out @@ -9,14 +9,14 @@ virtual size: 64M (67108864 bytes) === HMP commit === QEMU X.Y.Z monitor - type 'help' for more information -(qemu) ccocomcommcommicommitcommit commit icommit idcommit idecommit ide0commit ide0-commit ide0-hcommit ide0-hdcommit ide0-hd0 +(qemu) ccocomcommcommicommitcommit commit tcommit tecommit tescommit testcommit testdcommit testdicommit testdiscommit testdisk (qemu) image: TEST_DIR/t.IMGFMT file format: IMGFMT virtual size: 64M (67108864 bytes) Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file='TEST_DIR/t.IMGFMT.orig' backing_fmt='raw' QEMU X.Y.Z monitor - type 'help' for more information -(qemu) ccocomcommcommicommitcommit commit icommit idcommit idecommit ide0commit ide0-commit ide0-hcommit ide0-hdcommit ide0-hd0 +(qemu) ccocomcommcommicommitcommit commit tcommit tecommit tescommit testcommit testdcommit testdicommit testdiscommit testdisk (qemu) image: TEST_DIR/t.IMGFMT file format: IMGFMT -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:12 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxKK-0001nk-CX for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKG-0001f0-0h for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxKC-0005GZ-6R for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49130) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKB-0005GO-Q2; Fri, 04 Sep 2015 16:11:03 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 4FB9A2BB3A5; Fri, 4 Sep 2015 20:11:03 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlR021891; Fri, 4 Sep 2015 16:11:01 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:38 +0200 Message-Id: <1441397447-6516-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 07/16] qemu-img: Fix crash in amend invocation X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:11:09 -0000 From: Max Reitz Example: $ ./qemu-img create -f qcow2 /tmp/t.qcow2 64M $ ./qemu-img amend -f qcow2 -o backing_file=/tmp/t.qcow2, -o help \ /tmp/t.qcow2 This should not crash. This actually is tested by iotest 082, but not caught due to the segmentation fault being silent (which is something that needs to be fixed, too). Reported-by: Dr. David Alan Gilbert Cc: qemu-stable Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- qemu-img.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qemu-img.c b/qemu-img.c index 75f4ee4..6ff4e85 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2931,7 +2931,7 @@ static int img_amend(int argc, char **argv) if (!is_valid_option_list(optarg)) { error_report("Invalid option list: %s", optarg); ret = -1; - goto out; + goto out_no_progress; } if (!options) { options = g_strdup(optarg); @@ -3031,6 +3031,7 @@ static int img_amend(int argc, char **argv) out: qemu_progress_end(); +out_no_progress: blk_unref(blk); qemu_opts_del(opts); qemu_opts_free(create_opts); -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:22 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxKU-000268-Ix for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKL-0001pX-Cz for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxKK-0005LT-D3 for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54828) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKK-0005LG-8q; Fri, 04 Sep 2015 16:11:12 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id C786632C40F; Fri, 4 Sep 2015 20:11:11 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlW021891; Fri, 4 Sep 2015 16:11:10 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:43 +0200 Message-Id: <1441397447-6516-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 12/16] qcow2: mark the memory as no longer needed after qcow2_cache_empty() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:11:18 -0000 From: Alberto Garcia After having emptied the cache, the data in the cache tables is no longer useful, so we can tell the kernel that we are done with it. In Linux this frees the resources associated with it. The effect of this can be seen in the HMP commit operation: it moves data from the top to the base image (and fills both caches), then it empties the top image. At this point the data in that cache is no longer needed so it's just wasting memory. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz Message-id: 08538b098e1faf6c92496477cf9b47a20e5aacea.1438690126.git.berto@igalia.com Signed-off-by: Max Reitz --- block/qcow2-cache.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 53b8afc..f63e7d8 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -22,8 +22,16 @@ * THE SOFTWARE. */ +/* Needed for CONFIG_MADVISE */ +#include "config-host.h" + +#if defined(CONFIG_MADVISE) || defined(CONFIG_POSIX_MADVISE) +#include +#endif + #include "block/block_int.h" #include "qemu-common.h" +#include "qemu/osdep.h" #include "qcow2.h" #include "trace.h" @@ -60,6 +68,22 @@ static inline int qcow2_cache_get_table_idx(BlockDriverState *bs, return idx; } +static void qcow2_cache_table_release(BlockDriverState *bs, Qcow2Cache *c, + int i, int num_tables) +{ +#if QEMU_MADV_DONTNEED != QEMU_MADV_INVALID + BDRVQcowState *s = bs->opaque; + void *t = qcow2_cache_get_table_addr(bs, c, i); + int align = getpagesize(); + size_t mem_size = (size_t) s->cluster_size * num_tables; + size_t offset = QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t; + size_t length = QEMU_ALIGN_DOWN(mem_size - offset, align); + if (length > 0) { + qemu_madvise((uint8_t *) t + offset, length, QEMU_MADV_DONTNEED); + } +#endif +} + Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables) { BDRVQcowState *s = bs->opaque; @@ -237,6 +261,8 @@ int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c) c->entries[i].lru_counter = 0; } + qcow2_cache_table_release(bs, c, 0, c->size); + c->lru_counter = 0; return 0; -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:24 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxKV-00028L-UA for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKQ-0001yN-F6 for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxKM-0005MG-7c for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKL-0005M1-TR; Fri, 04 Sep 2015 16:11:14 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 7CE8CC0AA36F; Fri, 4 Sep 2015 20:11:13 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlX021891; Fri, 4 Sep 2015 16:11:12 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:44 +0200 Message-Id: <1441397447-6516-14-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 13/16] qcow2: add option to clean unused cache entries after some time X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:11:20 -0000 From: Alberto Garcia This adds a new 'cache-clean-interval' option that cleans all qcow2 cache entries that haven't been used in a certain interval, given in seconds. This allows setting a large L2 cache size so it can handle scenarios with lots of I/O and at the same time use little memory during periods of inactivity. This feature currently relies on MADV_DONTNEED to free that memory, so it is not useful in systems that don't follow that behavior. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz Message-id: a70d12da60433df9360ada648b3f34b8f6f354ce.1438690126.git.berto@igalia.com Signed-off-by: Max Reitz --- block/qcow2-cache.c | 35 ++++++++++++++++++++++++++++ block/qcow2.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ block/qcow2.h | 4 ++++ qapi/block-core.json | 7 +++++- 4 files changed, 109 insertions(+), 1 deletion(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index f63e7d8..8457458 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -49,6 +49,7 @@ struct Qcow2Cache { bool depends_on_flush; void *table_array; uint64_t lru_counter; + uint64_t cache_clean_lru_counter; }; static inline void *qcow2_cache_get_table_addr(BlockDriverState *bs, @@ -84,6 +85,40 @@ static void qcow2_cache_table_release(BlockDriverState *bs, Qcow2Cache *c, #endif } +static inline bool can_clean_entry(Qcow2Cache *c, int i) +{ + Qcow2CachedTable *t = &c->entries[i]; + return t->ref == 0 && !t->dirty && t->offset != 0 && + t->lru_counter <= c->cache_clean_lru_counter; +} + +void qcow2_cache_clean_unused(BlockDriverState *bs, Qcow2Cache *c) +{ + int i = 0; + while (i < c->size) { + int to_clean = 0; + + /* Skip the entries that we don't need to clean */ + while (i < c->size && !can_clean_entry(c, i)) { + i++; + } + + /* And count how many we can clean in a row */ + while (i < c->size && can_clean_entry(c, i)) { + c->entries[i].offset = 0; + c->entries[i].lru_counter = 0; + i++; + to_clean++; + } + + if (to_clean > 0) { + qcow2_cache_table_release(bs, c, i - to_clean, to_clean); + } + } + + c->cache_clean_lru_counter = c->lru_counter; +} + Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables) { BDRVQcowState *s = bs->opaque; diff --git a/block/qcow2.c b/block/qcow2.c index 76c331b..ea34ae2 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -467,6 +467,11 @@ static QemuOptsList qcow2_runtime_opts = { .type = QEMU_OPT_SIZE, .help = "Maximum refcount block cache size", }, + { + .name = QCOW2_OPT_CACHE_CLEAN_INTERVAL, + .type = QEMU_OPT_NUMBER, + .help = "Clean unused cache entries after this time (in seconds)", + }, { /* end of list */ } }, }; @@ -482,6 +487,49 @@ static const char *overlap_bool_option_names[QCOW2_OL_MAX_BITNR] = { [QCOW2_OL_INACTIVE_L2_BITNR] = QCOW2_OPT_OVERLAP_INACTIVE_L2, }; +static void cache_clean_timer_cb(void *opaque) +{ + BlockDriverState *bs = opaque; + BDRVQcowState *s = bs->opaque; + qcow2_cache_clean_unused(bs, s->l2_table_cache); + qcow2_cache_clean_unused(bs, s->refcount_block_cache); + timer_mod(s->cache_clean_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + + (int64_t) s->cache_clean_interval * 1000); +} + +static void cache_clean_timer_init(BlockDriverState *bs, AioContext *context) +{ + BDRVQcowState *s = bs->opaque; + if (s->cache_clean_interval > 0) { + s->cache_clean_timer = aio_timer_new(context, QEMU_CLOCK_VIRTUAL, + SCALE_MS, cache_clean_timer_cb, + bs); + timer_mod(s->cache_clean_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + + (int64_t) s->cache_clean_interval * 1000); + } +} + +static void cache_clean_timer_del(BlockDriverState *bs) +{ + BDRVQcowState *s = bs->opaque; + if (s->cache_clean_timer) { + timer_del(s->cache_clean_timer); + timer_free(s->cache_clean_timer); + s->cache_clean_timer = NULL; + } +} + +static void qcow2_detach_aio_context(BlockDriverState *bs) +{ + cache_clean_timer_del(bs); +} + +static void qcow2_attach_aio_context(BlockDriverState *bs, + AioContext *new_context) +{ + cache_clean_timer_init(bs, new_context); +} + static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, uint64_t *l2_cache_size, uint64_t *refcount_cache_size, Error **errp) @@ -555,6 +603,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; + uint64_t cache_clean_interval; ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); if (ret < 0) { @@ -848,6 +897,16 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, goto fail; } + cache_clean_interval = + qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0); + if (cache_clean_interval > UINT_MAX) { + error_setg(errp, "Cache clean interval too big"); + ret = -EINVAL; + goto fail; + } + s->cache_clean_interval = cache_clean_interval; + cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); + s->cluster_cache = g_malloc(s->cluster_size); /* one more sector for decompressed data alignment */ s->cluster_data = qemu_try_blockalign(bs->file, QCOW_MAX_CRYPT_CLUSTERS @@ -1013,6 +1072,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, qemu_vfree(s->l1_table); /* else pre-write overlap checks in cache_destroy may crash */ s->l1_table = NULL; + cache_clean_timer_del(bs); if (s->l2_table_cache) { qcow2_cache_destroy(bs, s->l2_table_cache); } @@ -1471,6 +1531,7 @@ static void qcow2_close(BlockDriverState *bs) } } + cache_clean_timer_del(bs); qcow2_cache_destroy(bs, s->l2_table_cache); qcow2_cache_destroy(bs, s->refcount_block_cache); @@ -2977,6 +3038,9 @@ BlockDriver bdrv_qcow2 = { .create_opts = &qcow2_create_opts, .bdrv_check = qcow2_check, .bdrv_amend_options = qcow2_amend_options, + + .bdrv_detach_aio_context = qcow2_detach_aio_context, + .bdrv_attach_aio_context = qcow2_attach_aio_context, }; static void bdrv_qcow2_init(void) diff --git a/block/qcow2.h b/block/qcow2.h index 72e1328..71dafd6 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -96,6 +96,7 @@ #define QCOW2_OPT_CACHE_SIZE "cache-size" #define QCOW2_OPT_L2_CACHE_SIZE "l2-cache-size" #define QCOW2_OPT_REFCOUNT_CACHE_SIZE "refcount-cache-size" +#define QCOW2_OPT_CACHE_CLEAN_INTERVAL "cache-clean-interval" typedef struct QCowHeader { uint32_t magic; @@ -239,6 +240,8 @@ typedef struct BDRVQcowState { Qcow2Cache* l2_table_cache; Qcow2Cache* refcount_block_cache; + QEMUTimer *cache_clean_timer; + unsigned cache_clean_interval; uint8_t *cluster_cache; uint8_t *cluster_data; @@ -581,6 +584,7 @@ int qcow2_cache_set_dependency(BlockDriverState *bs, Qcow2Cache *c, Qcow2Cache *dependency); void qcow2_cache_depends_on_flush(Qcow2Cache *c); +void qcow2_cache_clean_unused(BlockDriverState *bs, Qcow2Cache *c); int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c); int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset, diff --git a/qapi/block-core.json b/qapi/block-core.json index 7b2efb8..bb2189e 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1592,6 +1592,10 @@ # @refcount-cache-size: #optional the maximum size of the refcount block cache # in bytes (since 2.2) # +# @cache-clean-interval: #optional clean unused entries in the L2 and refcount +# caches. The interval is in seconds. The default value +# is 0 and it disables this feature (since 2.5) +# # Since: 1.7 ## { 'struct': 'BlockdevOptionsQcow2', @@ -1603,7 +1607,8 @@ '*overlap-check': 'Qcow2OverlapChecks', '*cache-size': 'int', '*l2-cache-size': 'int', - '*refcount-cache-size': 'int' } } + '*refcount-cache-size': 'int', + '*cache-clean-interval': 'int' } } ## -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxKa-0002FL-Ar for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKS-00021z-0N for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxKR-0005Q7-0a for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54860) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKQ-0005Pr-ST; Fri, 04 Sep 2015 16:11:18 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 644FD32C413; Fri, 4 Sep 2015 20:11:18 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnla021891; Fri, 4 Sep 2015 16:11:17 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:47 +0200 Message-Id: <1441397447-6516-17-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 16/16] quorum: validate vote threshold against num_children even if read-pattern is fifo X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:11:21 -0000 From: Wen Congyang We need to use threshold to check if too many write operation fails. If threshold is larger than num children, we always get write error event even if all write operations success. Signed-off-by: Wen Congyang Message-id: 55962F72.3060003@cn.fujitsu.com Reviewed-by: Alberto Garcia Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- block/quorum.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index 2f6c45f..8fe53b4 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -889,6 +889,12 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, } s->threshold = qemu_opt_get_number(opts, QUORUM_OPT_VOTE_THRESHOLD, 0); + /* and validate it against s->num_children */ + ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err); + if (ret < 0) { + goto exit; + } + ret = parse_read_pattern(qemu_opt_get(opts, QUORUM_OPT_READ_PATTERN)); if (ret < 0) { error_setg(&local_err, "Please set read-pattern as fifo or quorum"); @@ -897,12 +903,6 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, s->read_pattern = ret; if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) { - /* and validate it against s->num_children */ - ret = quorum_valid_threshold(s->threshold, s->num_children, &local_err); - if (ret < 0) { - goto exit; - } - /* is the driver in blkverify mode */ if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) && s->num_children == 2 && s->threshold == 2) { -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxKU-00026q-Pl for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKQ-0001yP-Ew for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxKP-0005Or-BA for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52742) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKP-0005OX-4h; Fri, 04 Sep 2015 16:11:17 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id B6783A2C22; Fri, 4 Sep 2015 20:11:16 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlZ021891; Fri, 4 Sep 2015 16:11:15 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:46 +0200 Message-Id: <1441397447-6516-16-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 15/16] qcow2: reorder fields in Qcow2CachedTable to reduce padding X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:11:19 -0000 From: Alberto Garcia Changing the current ordering saves 8 bytes per cache entry in x86_64. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Message-id: 0bd55291211df3dfb514d0e7d2031dd5c4f9f807.1438690126.git.berto@igalia.com Signed-off-by: Max Reitz --- block/qcow2-cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 8457458..046f5b8 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -37,9 +37,9 @@ typedef struct Qcow2CachedTable { int64_t offset; - bool dirty; uint64_t lru_counter; int ref; + bool dirty; } Qcow2CachedTable; struct Qcow2Cache { -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxKV-00027L-9z for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKQ-0001yW-GN for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxKN-0005NW-Ut for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39087) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKN-0005NR-Nl; Fri, 04 Sep 2015 16:11:15 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 2C90891E8B; Fri, 4 Sep 2015 20:11:15 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlY021891; Fri, 4 Sep 2015 16:11:13 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:45 +0200 Message-Id: <1441397447-6516-15-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 14/16] docs: document how to configure the qcow2 L2/refcount caches X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:11:20 -0000 From: Alberto Garcia QEMU has options to configure the size of the L2 and refcount caches for the qcow2 format. However, choosing the right sizes for a particular disk image is not a straightforward operation since the ratio between the cache size and the allocated disk space is not obvious and depends on the size of the cluster and the refcount entries. This document attempts to give an overview of both caches and how to configure their sizes. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz Message-id: 55de928e139b1ba3f3d40fe9c6c88f30b1f36410.1438690126.git.berto@igalia.com Signed-off-by: Max Reitz --- docs/qcow2-cache.txt | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 docs/qcow2-cache.txt diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt new file mode 100644 index 0000000..5bb0607 --- /dev/null +++ b/docs/qcow2-cache.txt @@ -0,0 +1,164 @@ +qcow2 L2/refcount cache configuration +===================================== +Copyright (C) 2015 Igalia, S.L. +Author: Alberto Garcia + +This work is licensed under the terms of the GNU GPL, version 2 or +later. See the COPYING file in the top-level directory. + +Introduction +------------ +The QEMU qcow2 driver has two caches that can improve the I/O +performance significantly. However, setting the right cache sizes is +not a straightforward operation. + +This document attempts to give an overview of the L2 and refcount +caches, and how to configure them. + +Please refer to the docs/specs/qcow2.txt file for an in-depth +technical description of the qcow2 file format. + + +Clusters +-------- +A qcow2 file is organized in units of constant size called clusters. + +The cluster size is configurable, but it must be a power of two and +its value 512 bytes or higher. QEMU currently defaults to 64 KB +clusters, and it does not support sizes larger than 2MB. + +The 'qemu-img create' command supports specifying the size using the +cluster_size option: + + qemu-img create -f qcow2 -o cluster_size=128K hd.qcow2 4G + + +The L2 tables +------------- +The qcow2 format uses a two-level structure to map the virtual disk as +seen by the guest to the disk image in the host. These structures are +called the L1 and L2 tables. + +There is one single L1 table per disk image. The table is small and is +always kept in memory. + +There can be many L2 tables, depending on how much space has been +allocated in the image. Each table is one cluster in size. In order to +read or write data from the virtual disk, QEMU needs to read its +corresponding L2 table to find out where that data is located. Since +reading the table for each I/O operation can be expensive, QEMU keeps +an L2 cache in memory to speed up disk access. + +The size of the L2 cache can be configured, and setting the right +value can improve the I/O performance significantly. + + +The refcount blocks +------------------- +The qcow2 format also mantains a reference count for each cluster. +Reference counts are used for cluster allocation and internal +snapshots. The data is stored in a two-level structure similar to the +L1/L2 tables described above. + +The second level structures are called refcount blocks, are also one +cluster in size and the number is also variable and dependent on the +amount of allocated space. + +Each block contains a number of refcount entries. Their size (in bits) +is a power of two and must not be higher than 64. It defaults to 16 +bits, but a different value can be set using the refcount_bits option: + + qemu-img create -f qcow2 -o refcount_bits=8 hd.qcow2 4G + +QEMU keeps a refcount cache to speed up I/O much like the +aforementioned L2 cache, and its size can also be configured. + + +Choosing the right cache sizes +------------------------------ +In order to choose the cache sizes we need to know how they relate to +the amount of allocated space. + +The amount of virtual disk that can be mapped by the L2 and refcount +caches (in bytes) is: + + disk_size = l2_cache_size * cluster_size / 8 + disk_size = refcount_cache_size * cluster_size * 8 / refcount_bits + +With the default values for cluster_size (64KB) and refcount_bits +(16), that is + + disk_size = l2_cache_size * 8192 + disk_size = refcount_cache_size * 32768 + +So in order to cover n GB of disk space with the default values we +need: + + l2_cache_size = disk_size_GB * 131072 + refcount_cache_size = disk_size_GB * 32768 + +QEMU has a default L2 cache of 1MB (1048576 bytes) and a refcount +cache of 256KB (262144 bytes), so using the formulas we've just seen +we have + + 1048576 / 131072 = 8 GB of virtual disk covered by that cache + 262144 / 32768 = 8 GB + + +How to configure the cache sizes +-------------------------------- +Cache sizes can be configured using the -drive option in the +command-line, or the 'blockdev-add' QMP command. + +There are three options available, and all of them take bytes: + +"l2-cache-size": maximum size of the L2 table cache +"refcount-cache-size": maximum size of the refcount block cache +"cache-size": maximum size of both caches combined + +There are two things that need to be taken into account: + + - Both caches must have a size that is a multiple of the cluster + size. + + - If you only set one of the options above, QEMU will automatically + adjust the others so that the L2 cache is 4 times bigger than the + refcount cache. + +This means that these options are equivalent: + + -drive file=hd.qcow2,l2-cache-size=2097152 + -drive file=hd.qcow2,refcount-cache-size=524288 + -drive file=hd.qcow2,cache-size=2621440 + +The reason for this 1/4 ratio is to ensure that both caches cover the +same amount of disk space. Note however that this is only valid with +the default value of refcount_bits (16). If you are using a different +value you might want to calculate both cache sizes yourself since QEMU +will always use the same 1/4 ratio. + +It's also worth mentioning that there's no strict need for both caches +to cover the same amount of disk space. The refcount cache is used +much less often than the L2 cache, so it's perfectly reasonable to +keep it small. + + +Reducing the memory usage +------------------------- +It is possible to clean unused cache entries in order to reduce the +memory usage during periods of low I/O activity. + +The parameter "cache-clean-interval" defines an interval (in seconds). +All cache entries that haven't been accessed during that interval are +removed from memory. + +This example removes all unused cache entries every 15 minutes: + + -drive file=hd.qcow2,cache-clean-interval=900 + +If unset, the default value for this parameter is 0 and it disables +this feature. + +Note that this functionality currently relies on the MADV_DONTNEED +argument for madvise() to actually free the memory, so it is not +useful in systems that don't follow that behavior. -- 1.8.3.1 From MAILER-DAEMON Fri Sep 04 16:11:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXxKN-0001sV-45 for mharc-qemu-block@gnu.org; Fri, 04 Sep 2015 16:11:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKJ-0001l1-8m for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxKH-0005Ir-6g for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:11:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxKG-0005IJ-TK; Fri, 04 Sep 2015 16:11:09 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 7DFE4C0AA36C; Fri, 4 Sep 2015 20:11:08 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KAnlU021891; Fri, 4 Sep 2015 16:11:06 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Sep 2015 22:10:41 +0200 Message-Id: <1441397447-6516-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PULL 10/16] iotests: Do not suppress segfaults in bash tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:11:13 -0000 From: Max Reitz Currently, if a qemu/qemu-io/qemu-img/qemu-nbd invocation receives a segmentation fault, that message is invisible in most cases since the output is generally filtered and bash suppresses the segmentation fault notice for any but the last element of a pipe. Most of the time, the test will then fail anyway because of missing output, but not necessarily (as happened with test 82 recently). Fix this by making the corresponding environment variables point to wrapper functions which execute the respective command in a subshell. Giving options to qemu/qemu-io/qemu-img and path names with spaces were broken for the Python tests; this patch "accidentally" fixes that. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- tests/qemu-iotests/039 | 19 ++++++------------- tests/qemu-iotests/039.out | 6 +++--- tests/qemu-iotests/061 | 6 ++++-- tests/qemu-iotests/061.out | 2 ++ tests/qemu-iotests/check | 8 ++++---- tests/qemu-iotests/common.config | 29 +++++++++++++++++++++++++---- tests/qemu-iotests/common.rc | 12 +++++++++++- tests/qemu-iotests/iotests.py | 16 ++++++++++++---- 8 files changed, 67 insertions(+), 31 deletions(-) diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 index 859705f..617f397 100755 --- a/tests/qemu-iotests/039 +++ b/tests/qemu-iotests/039 @@ -47,13 +47,6 @@ _supported_os Linux _default_cache_mode "writethrough" _supported_cache_modes "writethrough" -_subshell_exec() -{ - # Executing crashing commands in a subshell prevents information like the - # "Killed" line from being lost - (exec "$@") -} - size=128M echo @@ -74,8 +67,8 @@ echo "== Creating a dirty image file ==" IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img $size -_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \ - -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ +$QEMU_IO -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ | _filter_qemu_io # The dirty bit must be set @@ -109,8 +102,8 @@ echo "== Opening a dirty image read/write should repair it ==" IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img $size -_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \ - -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ +$QEMU_IO -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ | _filter_qemu_io # The dirty bit must be set @@ -127,8 +120,8 @@ echo "== Creating an image file with lazy_refcounts=off ==" IMGOPTS="compat=1.1,lazy_refcounts=off" _make_test_img $size -_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \ - -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ +$QEMU_IO -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ | _filter_qemu_io # The dirty bit must not be set since lazy_refcounts=off diff --git a/tests/qemu-iotests/039.out b/tests/qemu-iotests/039.out index d09751f..b055670 100644 --- a/tests/qemu-iotests/039.out +++ b/tests/qemu-iotests/039.out @@ -11,7 +11,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./039: Killed ( exec "$@" ) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) incompatible_features 0x1 ERROR cluster 5 refcount=0 reference=1 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0 @@ -46,7 +46,7 @@ read 512/512 bytes at offset 0 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./039: Killed ( exec "$@" ) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) incompatible_features 0x1 ERROR cluster 5 refcount=0 reference=1 Rebuilding refcount structure @@ -60,7 +60,7 @@ incompatible_features 0x0 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./039: Killed ( exec "$@" ) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) incompatible_features 0x0 No errors were found on the image. diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 index 8d37f8a..1df887a 100755 --- a/tests/qemu-iotests/061 +++ b/tests/qemu-iotests/061 @@ -58,7 +58,8 @@ echo echo "=== Testing dirty version downgrade ===" echo IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M -$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" 2>&1 \ + | _filter_qemu_io $PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" $PYTHON qcow2.py "$TEST_IMG" dump-header @@ -91,7 +92,8 @@ echo echo "=== Testing dirty lazy_refcounts=off ===" echo IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M -$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" 2>&1 \ + | _filter_qemu_io $PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IMG amend -o "lazy_refcounts=off" "$TEST_IMG" $PYTHON qcow2.py "$TEST_IMG" dump-header diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out index 5ec248f..4505376 100644 --- a/tests/qemu-iotests/061.out +++ b/tests/qemu-iotests/061.out @@ -57,6 +57,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 wrote 131072/131072 bytes at offset 0 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +./common.config: Aborted (core dumped) ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) magic 0x514649fb version 3 backing_file_offset 0x0 @@ -214,6 +215,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 wrote 131072/131072 bytes at offset 0 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +./common.config: Aborted (core dumped) ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) magic 0x514649fb version 3 backing_file_offset 0x0 diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index 6d58203..c350f16 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -231,10 +231,10 @@ FULL_HOST_DETAILS=`_full_platform_details` #FULL_MOUNT_OPTIONS=`_scratch_mount_options` cat <) id 1ZXxTo-0000g6-Mo for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:21:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXxTk-0001q7-Ej for qemu-block@nongnu.org; Fri, 04 Sep 2015 16:21:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59750) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXxTj-0001pk-W7; Fri, 04 Sep 2015 16:20:56 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 60757C0AD281; Fri, 4 Sep 2015 20:20:55 +0000 (UTC) Received: from [10.3.113.113] (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t84KKsKO021548; Fri, 4 Sep 2015 16:20:54 -0400 To: =?UTF-8?B?S8WRdsOhZ8OzLCBab2x0w6Fu?= , qemu-devel@nongnu.org References: <5527b250be7e2ce3359680b31f8c431924299a95.1440171025.git.DirtY.iCE.hu@gmail.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55E9FD26.4060208@redhat.com> Date: Fri, 4 Sep 2015 14:20:54 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <5527b250be7e2ce3359680b31f8c431924299a95.1440171025.git.DirtY.iCE.hu@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="RrVAQte3xI5JMFAa9sJEDte4gpWuMB0h9" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Gerd Hoffmann , "open list:Block layer core" Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 01/49] opts: produce valid command line in qemu_opts_print X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2015 20:21:02 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --RrVAQte3xI5JMFAa9sJEDte4gpWuMB0h9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/21/2015 09:36 AM, K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n wrote: > This will let us print options in a format that the user would actually= > write it on the command line (foo=3Dbar,baz=3Dasd,etc=3Ddef), without > prepending a spurious comma at the beginning of the list, or quoting > values unnecessarily. This patch provides the following changes: > * write id=3D, if the option has an id > * do not print separator before the first element > * do not quote string arguments > * properly escape commas (,) for QEMU >=20 > Reviewed-by: Markus Armbruster > Reviewed-by: Stefan Hajnoczi > Reviewed-by: Marc-Andr=C3=A9 Lureau > Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n > --- > +++ b/util/qemu-option.c > @@ -730,14 +730,35 @@ void qemu_opts_del(QemuOpts *opts) > g_free(opts); > } > =20 > -void qemu_opts_print(QemuOpts *opts, const char *sep) > +/* print value, escaping any commas in value */ > +static void escaped_print(const char *value) > +{ > + const char *ptr; > + > + for (ptr =3D value; *ptr; ++ptr) { > + if (*ptr =3D=3D ',') { > + putchar(','); > + } > + putchar(*ptr); > + } I guess this not in a hot path. (If it were, I might suggest using strchr() to skip to the next command, and fwrite() to output blocks of data between commas, rather than putchar() at a time; but unless it shows up in a benchmark that might be premature optimization) --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --RrVAQte3xI5JMFAa9sJEDte4gpWuMB0h9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV6f0mAAoJEKeha0olJ0NqIYgH/2iF08jL+K26cs+JeKCe4C7h NGcE+G+NyHMcquLnhyLgLL9ijA5tURhABb+Ibao0dDAP3RGZZmUg3TjOwZ1W+DTL YBb6TDUFFZjprJnEmOS909uUOhKU5pMrTMoOcxPT/mn+2IuzULukp/B4ORaoNE7L 9sCNUjisRLOSoK+c1mCbM+qj3ACUJiUo7YTcWvRaBjfnGkNLHzn+gE8TePqMvRDj JMPVzcXKSwt1m6LRn8axGXBTCxpzuZdKMUFmFTys5sPVA+NtgbntWlRzEUxLpa7G b+W8ha/t2p7t1hWGxNGoM26T4V1skCuAugVEkbkW1EVYA96tE5RuSExtsPME63M= =pnXw -----END PGP SIGNATURE----- --RrVAQte3xI5JMFAa9sJEDte4gpWuMB0h9-- From MAILER-DAEMON Sun Sep 06 05:24:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYWBT-0006aM-Ox for mharc-qemu-block@gnu.org; Sun, 06 Sep 2015 05:24:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYWBQ-0006Yy-TT for qemu-block@nongnu.org; Sun, 06 Sep 2015 05:24:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYWBN-0006ZJ-PO for qemu-block@nongnu.org; Sun, 06 Sep 2015 05:24:20 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:38021 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYWBN-0006Yi-Eh for qemu-block@nongnu.org; Sun, 06 Sep 2015 05:24:17 -0400 Received: (qmail 8380 invoked by uid 89); 6 Sep 2015 09:24:14 -0000 Received: from [195.62.97.28] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.7/20881. hbedv: 8.3.34.10/7.12.6.206. spamassassin: 3.4.0. Clear:RC:1(195.62.97.28):SA:0(-2.0/5.0):. Processed in 2.498399 secs); 06 Sep 2015 09:24:14 -0000 Received: from smtp.kamp.de (HELO submission.kamp.de) ([195.62.97.28]) by mx01.kamp.de with ESMTPS (DHE-RSA-AES256-SHA encrypted); 6 Sep 2015 09:24:11 -0000 X-GL_Whitelist: yes Received: (qmail 8803 invoked from network); 6 Sep 2015 09:12:36 -0000 Received: from ac66.vpn.kamp-intra.net (HELO ?172.20.250.66?) (pl@kamp.de@172.20.250.66) by submission.kamp.de with ESMTPS (DHE-RSA-AES128-SHA encrypted) ESMTPA; 6 Sep 2015 09:12:36 -0000 Message-ID: <55EC063A.6080501@kamp.de> Date: Sun, 06 Sep 2015 11:24:10 +0200 From: Peter Lieven User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Stefan Hajnoczi References: <1440058448-27847-1-git-send-email-pl@kamp.de> <1440058448-27847-3-git-send-email-pl@kamp.de> <20150903165928.GF18405@stefanha-thinkpad.redhat.com> In-Reply-To: <20150903165928.GF18405@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 2/2] ide/atapi: partially avoid deadlock if the storage backend is dead X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Sep 2015 09:24:22 -0000 Am 03.09.2015 um 18:59 schrieb Stefan Hajnoczi: > On Thu, Aug 20, 2015 at 10:14:08AM +0200, Peter Lieven wrote: >> the blk_drain_all() that is executed if the guest issues a DMA cancel >> leads to a stuck main loop if the storage backend (e.g. a NFS share) >> is unresponsive. >> >> This scenario is a common case for CDROM images mounted from an >> NFS share. In this case a broken NFS server can take down the >> whole VM even if the mounted CDROM is not used and was just not >> unmounted after usage. >> >> This approach avoids the blk_drain_all for read-only media and >> cancelles the AIO locally and makes the callback a NOP if the >> original request is completed after the NFS share is responsive >> again. >> >> Signed-off-by: Peter Lieven >> --- >> hw/ide/pci.c | 32 ++++++++++++++++++-------------- >> 1 file changed, 18 insertions(+), 14 deletions(-) >> >> diff --git a/hw/ide/pci.c b/hw/ide/pci.c >> index d31ff88..a8b4175 100644 >> --- a/hw/ide/pci.c >> +++ b/hw/ide/pci.c >> @@ -240,21 +240,25 @@ void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val) >> /* Ignore writes to SSBM if it keeps the old value */ >> if ((val & BM_CMD_START) != (bm->cmd & BM_CMD_START)) { >> if (!(val & BM_CMD_START)) { >> - /* >> - * We can't cancel Scatter Gather DMA in the middle of the >> - * operation or a partial (not full) DMA transfer would reach >> - * the storage so we wait for completion instead (we beahve >> - * like if the DMA was completed by the time the guest trying >> - * to cancel dma with bmdma_cmd_writeb with BM_CMD_START not >> - * set). >> - * >> - * In the future we'll be able to safely cancel the I/O if the >> - * whole DMA operation will be submitted to disk with a single >> - * aio operation with preadv/pwritev. >> - */ >> if (bm->bus->dma->aiocb) { >> - blk_drain_all(); >> - assert(bm->bus->dma->aiocb == NULL); >> + if (!bdrv_is_read_only(bm->bus->dma->aiocb->bs)) { >> + /* We can't cancel Scatter Gather DMA in the middle of the >> + * operation or a partial (not full) DMA transfer would >> + * reach the storage so we wait for completion instead >> + * (we beahve like if the DMA was completed by the time the >> + * guest trying to cancel dma with bmdma_cmd_writeb with >> + * BM_CMD_START not set). */ >> + blk_drain_all(); >> + assert(bm->bus->dma->aiocb == NULL); >> + } else { >> + /* On a read-only device (e.g. CDROM) we can't cause incon- >> + * sistencies and thus cancel the AIOCB locally and avoid >> + * to be called back later if the original request is >> + * completed. */ >> + BlockAIOCB *aiocb = bm->bus->dma->aiocb; >> + aiocb->cb(aiocb->opaque, -ECANCELED); >> + aiocb->cb = NULL; > I'm concerned that this isn't safe. > > What happens if the request does complete (e.g. will guest RAM be > modified by the read operation)? I am afraid you are right. The callback of the storage driver will likely overwrite the memory. This could be solved for storage drivers which don't do zero copy if it would be possible to notifiy them about the cancellation. > > What happens if a new request is started and then old NOPed request > completes? That should work because the callback of the NOPed request is never fired. > > Taking a step back, what are the semantics of writing !(val & > BM_CMD_START)? Is the device guaranteed to cancel/complete requests > during the register write? I have to check that. John, do you have an idea? Stefan, or do you have a better approach for getting rid of the bdrv_drain_all in this piece of code? Peter From MAILER-DAEMON Sun Sep 06 07:01:35 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYXhX-0004DH-Na for mharc-qemu-block@gnu.org; Sun, 06 Sep 2015 07:01:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYXhV-0004Cl-3A for qemu-block@nongnu.org; Sun, 06 Sep 2015 07:01:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYXhR-0001Ko-0X for qemu-block@nongnu.org; Sun, 06 Sep 2015 07:01:33 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:40923) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYXhQ-0001Kh-QD; Sun, 06 Sep 2015 07:01:28 -0400 Received: from tsrv.tls.msk.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 258CA409B9; Sun, 6 Sep 2015 14:01:28 +0300 (MSK) Received: from [192.168.88.2] (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.tls.msk.ru (Postfix) with ESMTP id 0EB54A76; Sun, 6 Sep 2015 14:01:28 +0300 (MSK) Message-ID: <55EC1D08.3090502@msgid.tls.msk.ru> Date: Sun, 06 Sep 2015 14:01:28 +0300 From: Michael Tokarev Organization: Telecom Service, JSC User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: =?UTF-8?B?IkvFkXbDoWfDsywgWm9sdMOhbiI=?= , qemu-devel@nongnu.org References: In-Reply-To: OpenPGP: id=804465C5 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 86.62.121.231 Cc: qemu-trivial@nongnu.org, Kevin Wolf , Markus Armbruster , Qemu Block layer core Subject: Re: [Qemu-block] [PATCH v3] opts: produce valid command line in qemu_opts_print X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Sep 2015 11:01:34 -0000 07.07.2015 17:42, K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n wrote: > This will let us print options in a format that the user would actually > write it on the command line (foo=3Dbar,baz=3Dasd,etc=3Ddef), without > prepending a spurious comma at the beginning of the list, or quoting > values unnecessarily. This patch provides the following changes: > * write and id=3D, if the option has an id > * do not print separator before the first element > * do not quote string arguments > * properly escape commas (,) for QEMU Applied to -trivial, thank you! /mjt From MAILER-DAEMON Sun Sep 06 21:27:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYlDu-0006Rm-Lo for mharc-qemu-block@gnu.org; Sun, 06 Sep 2015 21:27:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYlDr-0006RL-Vm for qemu-block@nongnu.org; Sun, 06 Sep 2015 21:27:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYlDn-0007v0-Sk for qemu-block@nongnu.org; Sun, 06 Sep 2015 21:27:51 -0400 Received: from [59.151.112.132] (port=50215 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYlDn-0007re-I6; Sun, 06 Sep 2015 21:27:47 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100409817" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 07 Sep 2015 09:30:37 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t871RQNE021577; Mon, 7 Sep 2015 09:27:26 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Mon, 7 Sep 2015 09:27:37 +0800 To: Eric Blake , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-2-git-send-email-wency@cn.fujitsu.com> <55E717C7.5050303@redhat.com> From: Wen Congyang Message-ID: <55ECE7F1.9010007@cn.fujitsu.com> Date: Mon, 7 Sep 2015 09:27:13 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55E717C7.5050303@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 01/16] introduce a new API to enable/disable attach device model X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 01:27:53 -0000 On 09/02/2015 11:37 PM, Eric Blake wrote: > On 09/02/2015 02:51 AM, Wen Congyang wrote: >> Signed-off-by: Wen Congyang >> --- >> block/block-backend.c | 24 ++++++++++++++++++++++++ >> include/sysemu/block-backend.h | 2 ++ >> 2 files changed, 26 insertions(+) >> >> diff --git a/block/block-backend.c b/block/block-backend.c >> index aee8a12..72d8b2c 100644 >> --- a/block/block-backend.c >> +++ b/block/block-backend.c >> @@ -344,6 +344,30 @@ void *blk_get_attached_dev(BlockBackend *blk) >> } >> >> /* >> + * Disable to attach a device mode to @blk. > > s/to attach/attaching/ > s/mode/model/ > > But I'm not even sure this patch makes sense. I'd rather see Max's work > go in that allows for a BB without a BDS as representing a drive without > media, because then it is clear - either a BB has an associated BDS (and > cannot attach another one), or it does not (and attaching is fine). Hmm, I think the API's name cause a misunderstanding. These APIs are used to check if the BB is used by some block device. It is very useful if we allow references for backing files. If the backing file referes an existing BDS that with BB, the block device can't use this BB at the same time. Thanks Wen Congyang > >> + * Return 0 on success, -EBUSY when a device model is attached already. >> + */ >> +int blk_disable_attach_dev(BlockBackend *blk) >> +{ >> + if (blk->dev) { >> + return blk->dev == (void *)-1 ? 0 : -EBUSY; >> + } >> + >> + blk->dev = (void *)-1; >> + return 0; >> +} >> + >> +/* >> + * Enable to attach a device mode to @blk. >> + */ >> +void blk_enable_attach_dev(BlockBackend *blk) >> +{ >> + if (blk->dev == (void *)-1) { > > At the very least, if we allow a special sentinel to represent a BB > without a BDS (other than NULL, the way Max's series does it), it should > at least be wrapped by a macro, rather than using '(void *)-1' at > multiple call sites. > From MAILER-DAEMON Sun Sep 06 22:18:51 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYm1D-000377-MD for mharc-qemu-block@gnu.org; Sun, 06 Sep 2015 22:18:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYm1B-00035H-5O for qemu-block@nongnu.org; Sun, 06 Sep 2015 22:18:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYm18-0007f7-0c for qemu-block@nongnu.org; Sun, 06 Sep 2015 22:18:49 -0400 Received: from [59.151.112.132] (port=64859 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYm16-0007eX-SG; Sun, 06 Sep 2015 22:18:45 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100411753" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 07 Sep 2015 10:21:39 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t872IRax025105; Mon, 7 Sep 2015 10:18:28 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Mon, 7 Sep 2015 10:18:38 +0800 To: Eric Blake , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-6-git-send-email-wency@cn.fujitsu.com> <55E74780.4040804@redhat.com> From: Wen Congyang Message-ID: <55ECF3E7.7090001@cn.fujitsu.com> Date: Mon, 7 Sep 2015 10:18:15 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55E74780.4040804@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 05/16] introduce a new API qemu_opts_absorb_qdict_by_index() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 02:18:50 -0000 On 09/03/2015 03:01 AM, Eric Blake wrote: > On 09/02/2015 02:51 AM, Wen Congyang wrote: >> Signed-off-by: Wen Congyang >> Signed-off-by: zhanghailiang >> Signed-off-by: Gonglei > > Commit message is a bit sparse. > >> --- >> include/qemu/option.h | 2 ++ >> util/qemu-option.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 46 insertions(+) >> > > Missing testsuite exposure of the new function. Do you mean: update tests/test-qemu-opts.c? > >> /* >> + * Adds all QDict entries to the QemuOpts that can be added and removes them >> + * from the QDict. The key starts with "%index." in the %qdict. When this > > "%index." reads awkwardly (I thought it was a printf-style format). But > I'm not sure if "starts with %index followed by '.'" is any better. The other comments use '@'. I will update it in the next version. > >> + * function returns, the QDict contains only those entries that couldn't be >> + * added to the QemuOpts. >> + */ >> +void qemu_opts_absorb_qdict_by_index(QemuOpts *opts, QDict *qdict, >> + const char *index, Error **errp) >> +{ > > I didn't review the algorithm closely, but here's a superficial comment: > >> + const QDictEntry *entry, *next; >> + const char *key; >> + int len = strlen(index); > > size_t OK, will fix it in the next version. Thanks Wen Congyang > From MAILER-DAEMON Sun Sep 06 23:41:19 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYnJ1-000379-E3 for mharc-qemu-block@gnu.org; Sun, 06 Sep 2015 23:41:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYnIz-00036w-0z for qemu-block@nongnu.org; Sun, 06 Sep 2015 23:41:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYnIv-00072t-Oc for qemu-block@nongnu.org; Sun, 06 Sep 2015 23:41:16 -0400 Received: from [59.151.112.132] (port=29249 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYnIu-00071I-Ry; Sun, 06 Sep 2015 23:41:13 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100414773" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 07 Sep 2015 11:44:02 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t873eoEL031214; Mon, 7 Sep 2015 11:40:50 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Mon, 7 Sep 2015 11:41:01 +0800 From: Wen Congyang To: Eric Blake , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-7-git-send-email-wency@cn.fujitsu.com> <55E72422.30301@redhat.com> Message-ID: <55ED073B.2070403@cn.fujitsu.com> Date: Mon, 7 Sep 2015 11:40:43 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55E72422.30301@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 06/16] quorum: allow ignoring child errors X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 03:41:18 -0000 On 09/03/2015 12:30 AM, Eric Blake wrote: > On 09/02/2015 02:51 AM, Wen Congyang wrote: >> If the child is not ready, read/write/getlength/flush will >> return -errno. It is not critical error, and can be ignored: >> 1. read/write: >> Just not report the error event. > > What happens if all the children report an error? Or is the threshold > at play here? Good question. What about this: if we have 5 children, only 4 children can ignore errors. > > For example, if you have a threshold of 3/5, then I'm assuming that if > up to two children return an errno, then it is okay to ignore; but if > three or more return an errno, you haven't met threshold, so the I/O > must fail. Do more check here, at least one child sucesses. > > Are you ignoring ALL errors (including things like EACCES), or just EIO > errors? Does bdrv_xxx() always return -errno on error? > > >> 2. getlength: >> just ignore it. If all children's getlength return -errno, >> and be ignored, return -EIO. >> 3. flush: >> Just ignore it. If all children's getlength return -errno, > > s/getlength/flush/ > >> and be ignored, return 0. > > Yuck - claiming success when all of the children fail feels dangerous. Yes. > >> >> Usage: children.x.ignore-errors=true >> >> Signed-off-by: Wen Congyang >> Signed-off-by: zhanghailiang >> Signed-off-by: Gonglei >> Cc: Alberto Garcia >> --- >> block/quorum.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++---- > > Interface review only: > >> +++ b/qapi/block-core.json >> @@ -1411,6 +1411,8 @@ >> # @allow-write-backing-file: #optional whether the backing file is opened in >> # read-write mode. It is only for backing file >> # (Since 2.5 default: false) >> +# @ignore-errors: #options whether the child's I/O error should be ignored. > > s/options/optional/ > s/error/errors/ > >> +# it is only for quorum's child.(Since 2.5 default: false) > > Space after '.' in English sentences. > > The fact that you are documenting that this option can only be specified > for quorum children makes me wonder if it belongs better as an option in > BlockdevOptionsQuorum rather than BlockdevOptionsBase. Hmm, how to define it? It is quorum's child's option, not quorum's option. > > Semantically, it sounds like you are trying to allow for a per-child > decision of whether this particular child's errors matter to the overall > quorum. So, if we have a 3/5 quorum, we can decide that for children A, > B, C, and D, errors cannot be ignored, but for child E, errors are not a > problem. > > As written, you are tying the semantics to each child BDS, and requiring > special code to double-check that the property is only ever set if the > BDS is used as the child of a quorum. Furthermore, if the property is > set, you are then changing what the child does in response to various > operations. > > What if you instead create a list property in the quorum parent? Maybe > along the lines of: > > # @child-errors-okay: #optional an array of named-node children where > errors will be ignored (Since 2.5, default empty) > > { 'struct': 'BlockdevOptionsQuorum', > 'data': { '*blkverify': 'bool', > 'children': [ 'BlockdevRef' ], > 'vote-threshold': 'int', > '*rewrite-corrupted': 'bool', > '*read-pattern': 'QuorumReadPattern', > '*child-errors-okay': ['str'] } } > > The above example of a 3/5 quorum, where only child E can ignore errors, > would then be represented as: > > { "children": [ "A", "B", "C", "D", "E" ], 'vote-threshold':3, > 'child-errors-okay': [ "E" ] } OK, I will try it. > > The code to ignore the errors is then done in the quorum itself (the BDS > for E does not have to care about a special ignore-errors property, but > just always returns the error as usual; and then the quorum is deciding > how to handle the error), and you are not polluting the BDS state for > something that is quorum-specific, because it is now the quorum itself > that tracks the special casing. > > Finally, why can't hot-plug/unplug of quorum members work? If you are > going to always ignore errors from a particular child, then why is that > child even part of the quorum? Isn't a better design to just not add > the child to the quorum until it is ready and won't be reporting errors? > Yes. In the early version, I don't use hot-plug/unplug of quorum members, so the quorum member may be not ready. Now I use hot-plug/unplug of quorum members, so the quorum's member is ready when it is hot added. In such case, the quorum member is not ready after failover. This error is expected, but I want this error can be ignored, otherwise, there may be too error events... Thanks Wen Congyang From MAILER-DAEMON Sun Sep 06 23:56:14 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYnXS-0005tz-P1 for mharc-qemu-block@gnu.org; Sun, 06 Sep 2015 23:56:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYnXQ-0005tp-Hv for qemu-block@nongnu.org; Sun, 06 Sep 2015 23:56:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYnXL-0004OF-UQ for qemu-block@nongnu.org; Sun, 06 Sep 2015 23:56:12 -0400 Received: from [59.151.112.132] (port=38277 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYnXK-0004MN-Fl; Sun, 06 Sep 2015 23:56:07 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100415268" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 07 Sep 2015 11:59:00 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t873tnMV032201; Mon, 7 Sep 2015 11:55:49 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Mon, 7 Sep 2015 11:56:00 +0800 To: Eric Blake , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi References: <1439279489-13338-1-git-send-email-wency@cn.fujitsu.com> <1439279489-13338-6-git-send-email-wency@cn.fujitsu.com> <55E4A536.6040905@redhat.com> <55E4F767.1070602@cn.fujitsu.com> <55E5C572.7000606@redhat.com> <55E65026.2050902@cn.fujitsu.com> <55E70F26.8020506@redhat.com> From: Wen Congyang Message-ID: <55ED0ABD.2030204@cn.fujitsu.com> Date: Mon, 7 Sep 2015 11:55:41 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55E70F26.8020506@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Max Reitz , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Patch for-2.5 v2 5/6] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 03:56:13 -0000 On 09/02/2015 11:00 PM, Eric Blake wrote: > On 09/01/2015 07:25 PM, Wen Congyang wrote: >> On 09/01/2015 11:34 PM, Eric Blake wrote: >>> On 08/31/2015 06:55 PM, Wen Congyang wrote: >>> >>>>>> +This command is still a work in progress. It doesn't support all >>>>>> +block drivers. Stay away from it unless you want it to help with >>>>>> +its development. >>>>> >>>>> Maybe we should name it 'x-child-add' for now, so that we aren't baking >>>>> ourselves into a corner. >>>> >>>> Do you mean the command name should be x-child-add? It is OK. >>> >>> Use of the 'x-' prefix means a command is experimental and may change or >>> be withdrawn. It gives us a way to test if an interface is useful >>> without committing to that interface long term. We've still got time >>> before 2.5 to get blockdev-add working everywhere, in which case I think >>> we are better off using blockdev-add to create a new unattached BDS and >>> then have this command pass the node name to be made the new child, >>> rather than all the options for opening the child from scratch. >>> >> >> Good idea. The unattached BDS created by the command blockdev-add always >> have BB. So it may be used by the device created by the command device_add >> later. > > We recently discussed (although the current documentation of > BlockdevOptionsBase sounds like it hasn't been merged yet) the idea of > enhancing blockdev-add to control whether a BB is created alongside a BDS. > > Remember, blockdev-add can be used to create a chain. When originally > implemented, we documented that 'id' must be present on the top of the > chain, and absent everywhere else, and that 'node-name' was optional > everywhere. The 'id' became associated with the BB at the top level, > and the optional node-names allow you to then manipulate other BDS. But > the proposal at hand is that we would allow 'id' to be optional at the > top level (at which point 'node-name' is required, because we have to > have SOME way to refer to the BDS); and when that happens, we end up > creating a BDS that is not associated with any BB yet. Similarly, it is > possible to create a BB that does not yet have a BDS yet (think an empty > cdrom drive); so it then becomes possible to associate a BDS to a BB as > a separate step. > > [/me goes searching] > Ah - we are waiting for Max's patches to land: > https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg04201.html > in particular patch 02/38: > https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg04204.html > > Once we have that, then we can indeed create a BDS without a BB, and it > is then that you can plug your unconnected BDS into a quorum. So I'd > recommend helping review Max's series, and base your actions on top of > his (I really do think it is a better approach to separate BDS creation > from chain manipulation, and your add/remove a child is about chain > manipulation and does not need to be creating BDS). > >> So I think we should have an API to check it. What about the following >> patches? >> http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg01591.html >> http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg01590.html > > I haven't looked at them yet, but really like Max's approach for > separating BDS from BB by treating BB without BDS as an empty media > case, and BDS without a BB as something that can then be manipulated to > be associated with another BDS or BB. Do you mean we can create a top BDS without BB by the command line -drive in the future? Thanks Wen Congyang From MAILER-DAEMON Mon Sep 07 00:43:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYoHP-0006Id-96 for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 00:43:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYoHM-0006GE-MV for qemu-block@nongnu.org; Mon, 07 Sep 2015 00:43:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYoHH-0002Bf-NA for qemu-block@nongnu.org; Mon, 07 Sep 2015 00:43:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41252) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYoHH-0002Aa-IM; Mon, 07 Sep 2015 00:43:35 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id D51EB461D6; Mon, 7 Sep 2015 04:43:34 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t874hXN2028566; Mon, 7 Sep 2015 00:43:34 -0400 Date: Mon, 7 Sep 2015 12:43:32 +0800 From: Fam Zheng To: Stefan Hajnoczi Message-ID: <20150907044332.GA3958@ad.nay.redhat.com> References: <1438144934-23619-1-git-send-email-famz@redhat.com> <1438144934-23619-4-git-send-email-famz@redhat.com> <20150827135352.GC4917@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150827135352.GC4917@stefanha-thinkpad.redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH v2 03/11] block: Mark fd handlers as "protocol" X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 04:43:41 -0000 On Thu, 08/27 14:53, Stefan Hajnoczi wrote: > On Wed, Jul 29, 2015 at 12:42:06PM +0800, Fam Zheng wrote: > > diff --git a/include/block/aio.h b/include/block/aio.h > > index bd1d44b..d02ddfa 100644 > > --- a/include/block/aio.h > > +++ b/include/block/aio.h > > @@ -273,6 +273,7 @@ bool aio_pending(AioContext *ctx); > > bool aio_dispatch(AioContext *ctx); > > > > #define AIO_CLIENT_UNSPECIFIED (1 << 0) > > +#define AIO_CLIENT_PROTOCOL (1 << 1) > > The semantics need to be documented here, not just in the commit > description. > > AIO_CLIENT_BLOCK_DRIVER or AIO_CLIENT_BLOCK_PROTOCOL seems like a > clearer name to me since "protocol" just by itself could mean many > things. OK, renaming to AIO_CLIENT_BLOCK_DRIVER. Thanks, Fam From MAILER-DAEMON Mon Sep 07 01:26:38 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYoww-0007zZ-Sl for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 01:26:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYowv-0007zM-1c for qemu-block@nongnu.org; Mon, 07 Sep 2015 01:26:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYowr-0004Qd-Sw for qemu-block@nongnu.org; Mon, 07 Sep 2015 01:26:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60017) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYowr-0004QD-Or; Mon, 07 Sep 2015 01:26:33 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 542D78CF56; Mon, 7 Sep 2015 05:26:33 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t875QUBG025546; Mon, 7 Sep 2015 01:26:32 -0400 Date: Mon, 7 Sep 2015 13:26:29 +0800 From: Fam Zheng To: Stefan Hajnoczi Message-ID: <20150907052629.GB3958@ad.nay.redhat.com> References: <1438144934-23619-1-git-send-email-famz@redhat.com> <1438144934-23619-8-git-send-email-famz@redhat.com> <20150827172338.GG4917@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150827172338.GG4917@stefanha-thinkpad.redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 07/11] aio-posix: introduce aio_{disable, enable}_clients X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 05:26:37 -0000 On Thu, 08/27 18:23, Stefan Hajnoczi wrote: > On Wed, Jul 29, 2015 at 12:42:10PM +0800, Fam Zheng wrote: > > +void aio_disable_enable_clients(AioContext *ctx, int clients_mask, > > + bool is_disable) > > +{ > > + AioHandler *node; > > + aio_context_acquire(ctx); > > + > > + QLIST_FOREACH(node, &ctx->aio_handlers, node) { > > + if (!node->deleted && node->type & clients_mask) { > > + node->disable_cnt += is_disable ? 1 : -1; > > + } > > + } > > + aio_context_release(ctx); > > +} > > If someone adds an fd of a disabled type *after* the call to > aio_disable_clients() then it won't be disabled. > > Another approach is to keep an array of counters per AioContext and > check the counters during aio_poll() when deciding which fds to monitor. Good idea, I'll change that way. > > Also, this function acquires/releases AioContext so it's worth > mentioning in the doc comments that this function is thread-safe. > OK. Fam From MAILER-DAEMON Mon Sep 07 01:54:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYpNR-0003mp-Pb for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 01:54:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYpNQ-0003kh-C9 for qemu-block@nongnu.org; Mon, 07 Sep 2015 01:54:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYpNP-00089X-9v for qemu-block@nongnu.org; Mon, 07 Sep 2015 01:54:00 -0400 Received: from [59.151.112.132] (port=16020 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYpNK-00088N-0n; Mon, 07 Sep 2015 01:53:54 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100418493" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 07 Sep 2015 13:56:43 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t875rW38005164; Mon, 7 Sep 2015 13:53:32 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Mon, 7 Sep 2015 13:53:43 +0800 To: Eric Blake , Max Reitz , References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <55E70F9B.20309@redhat.com> From: Wen Congyang Message-ID: <55ED2655.1040405@cn.fujitsu.com> Date: Mon, 7 Sep 2015 13:53:25 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55E70F9B.20309@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 00/38] blockdev: BlockBackend and media X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 05:54:01 -0000 On 09/02/2015 11:02 PM, Eric Blake wrote: > On 07/20/2015 11:45 AM, Max Reitz wrote: >> First of all: Thank you, Eric and Berto, for reviewing v3! And thank >> you, Fam, for at least having a peek at it and being confident enough to >> base a series of your own on it. :-) >> >> This series reworks a lot regarding BlockBackend and media. Basically, >> it allows empty BlockBackends, that is BBs without a BDS tree. >> >> Before this series, empty drives are represented by a BlockBackend with >> an empty BDS attached to it (a BDS with a NULL driver). However, now we >> have BlockBackends, thus an empty drive should be represented by a >> BlockBackend without any BDS tree attached to it. This is what this >> series does. > > We've obviously missed 2.4; but now that 2.5 is open, are there plans to > get this series in sooner rather than later? Wen's work on dynamically > adding/deleting children from a quorum would benefit from the ability to > create a BDS without an associated BB, which in turn would help the COLO > work. > This feature is very useful for COLO. COLO needs the following: 1. adding/deleting children from a quorum dynamically 2. allow references for backing files The BDS without BB only can be created by the monitor command blockdev-add. How to create it in the command line? Thanks Wen Congyang From MAILER-DAEMON Mon Sep 07 02:28:38 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYpuw-0001ry-9l for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 02:28:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYput-0001q7-27 for qemu-block@nongnu.org; Mon, 07 Sep 2015 02:28:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYpup-00061I-PM for qemu-block@nongnu.org; Mon, 07 Sep 2015 02:28:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYpup-000617-HZ; Mon, 07 Sep 2015 02:28:31 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id F38628C1A1; Mon, 7 Sep 2015 06:28:30 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t876SS0o025138; Mon, 7 Sep 2015 02:28:29 -0400 Date: Mon, 7 Sep 2015 14:28:26 +0800 From: Fam Zheng To: Stefan Hajnoczi Message-ID: <20150907062826.GC3958@ad.nay.redhat.com> References: <1438144934-23619-1-git-send-email-famz@redhat.com> <20150828115320.GK4917@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150828115320.GK4917@stefanha-thinkpad.redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH v2 00/11] aio: Introduce handler type to fix nested aio_poll for dataplane X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 06:28:36 -0000 On Fri, 08/28 12:53, Stefan Hajnoczi wrote: > On Wed, Jul 29, 2015 at 12:42:03PM +0800, Fam Zheng wrote: > > v2: Switch to disable/enable model. [Paolo] > > > > Most existing nested aio_poll()'s in block layer are inconsiderate of > > dispatching potential new r/w requests from ioeventfds and nbd exports, which > > might result in responsiveness issues (e.g. bdrv_drain_all will not return when > > new requests keep coming), or even wrong semantics (e.g. qmp_transaction cannot > > enforce atomicity due to aio_poll in bdrv_drain_all). > > > > Previous attampts to address this issue include new op blocker[1], bdrv_lock[2] > > and nested AioContext (patches not posted to qemu-devel). > > > > This approach is based on the idea proposed by Paolo Bonzini. The original idea > > is introducing "aio_context_disable_client / aio_context_enable_client to > > filter AioContext handlers according to the "client", e.g. > > AIO_CLIENT_DATAPLANE (ioeventfd), AIO_CLIENT_PROTOCOL, AIO_CLIENT_NBD_SERVER, > > AIO_CLIENT_CONTEXT, ... Extend aio_set_{event_notifier,fd}_handler to pass a > > client (type)." > > > > After this series, block layer aio_poll() will only process those "protocol" > > fds that are used in block I/O, plus the ctx->notifier for aio_notify(); other > > aio_poll()'s keep unchanged. > > > > The biggest advantage over approaches [1] and [2] is, no change is needed in > > virtio-{blk,scsi}-dataplane code, also this doesn't depend on converting QMP to > > coroutines. > > > > The windows implementation is not tested except for compiling. > > > > [1]: https://lists.gnu.org/archive/html/qemu-block/2015-05/msg00800.html > > [2]: http://lists.nongnu.org/archive/html/qemu-block/2015-06/msg00027.html > > > > > > Fam Zheng (11): > > aio: Introduce "type" in aio_set_fd_handler and aio_set_event_notifier > > aio: Save type to AioHandler > > block: Mark fd handlers as "protocol" > > nbd: Mark fd handlers client type as "nbd server" > > aio: Mark ctx->notifier's client type as "context" > > dataplane: Mark host notifiers' client type as "dataplane" > > aio-posix: introduce aio_{disable,enable}_clients > > aio-win32: Implement aio_{disable,enable}_clients > > block: Introduce bdrv_aio_poll > > block: Replace nested aio_poll with bdrv_aio_poll > > block: Only poll block layer fds in bdrv_aio_poll > > > > aio-posix.c | 23 ++++++++++++++-- > > aio-win32.c | 22 +++++++++++++++- > > async.c | 3 ++- > > block.c | 2 +- > > block/curl.c | 16 +++++++----- > > block/io.c | 28 +++++++++++++------- > > block/iscsi.c | 9 +++---- > > block/linux-aio.c | 5 ++-- > > block/nbd-client.c | 10 ++++--- > > block/nfs.c | 19 ++++++-------- > > block/qed-table.c | 8 +++--- > > block/sheepdog.c | 32 +++++++++++++++-------- > > block/ssh.c | 5 ++-- > > block/win32-aio.c | 5 ++-- > > blockjob.c | 2 +- > > hw/block/dataplane/virtio-blk.c | 6 +++-- > > hw/scsi/virtio-scsi-dataplane.c | 24 +++++++++++------ > > include/block/aio.h | 33 +++++++++++++++++++++++ > > include/block/block.h | 2 ++ > > nbd.c | 4 ++- > > qemu-img.c | 2 +- > > qemu-io-cmds.c | 4 +-- > > tests/test-aio.c | 58 +++++++++++++++++++++++------------------ > > 23 files changed, 219 insertions(+), 103 deletions(-) > > What is the status of this series? > > Paolo's points about Patch 11 & 12 stand. It seems the fd type concept > is good but the bdrv_aio_poll() mechanism requires changes to fully > solve the problem. Let's drop bdrv_aio_poll(), introduce bdrv_quiesce() and bdrv_unquiesce() to protect nested aio_poll(). For example in QMP, add them between prepare and commit. That needs more changes, like splitting drive_backup_prepare() and put the starting of coroutine and installing of "before_write" notifier to BdrvActionOps.commit. Fam From MAILER-DAEMON Mon Sep 07 04:00:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYrM2-0006kh-3G for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 04:00:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYrLs-0006fl-6j for qemu-block@nongnu.org; Mon, 07 Sep 2015 04:00:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYrLn-0007CS-Rh for qemu-block@nongnu.org; Mon, 07 Sep 2015 04:00:31 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:48166 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYrLh-0006Xf-JU; Mon, 07 Sep 2015 04:00:21 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CQBQC1Qu1V/5tjdVteGQEBAYMHgT2pTAEBAQEBAQUBgQsBmnMCgSY7EQEBAQEBAQGBCoQjAQEBAQIBOj8FCwsOCgklDwEsGwYBEogmDAHIOAEBAQEBAQEDAQEBAQEdhiyFQoUMB4QsBYcxhUaFO4MjjkaQdog1JoIQHIFWPDOISQEBAQ X-IPAS-Result: A2CQBQC1Qu1V/5tjdVteGQEBAYMHgT2pTAEBAQEBAQUBgQsBmnMCgSY7EQEBAQEBAQGBCoQjAQEBAQIBOj8FCwsOCgklDwEsGwYBEogmDAHIOAEBAQEBAQEDAQEBAQEdhiyFQoUMB4QsBYcxhUaFO4MjjkaQdog1JoIQHIFWPDOISQEBAQ X-IronPort-AV: E=Sophos;i="5.17,484,1437429600"; d="scan'208";a="18115963" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 07 Sep 2015 09:59:41 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZYrL3-0003V4-OM; Mon, 07 Sep 2015 09:59:41 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZYrL3-00016F-9B; Mon, 07 Sep 2015 09:59:41 +0200 From: Alberto Garcia To: Eric Blake , qemu-devel@nongnu.org In-Reply-To: <55E9ADC9.3000404@redhat.com> References: <55E9ADC9.3000404@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Mon, 07 Sep 2015 09:59:41 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v2 2/2] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 08:00:37 -0000 On Fri 04 Sep 2015 04:42:17 PM CEST, Eric Blake wrote: >> @@ -1183,6 +1183,18 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, >> &snapshot, errp); >> } >> >> +void qmp_blockdev_snapshot(const char *device, const char *snapshot, > > Is 'node' a better name than 'device' here? I don't have a strong preference (I was just following Kevin's suggestion), but 'device' seems to be the most common name for this parameter. This one can take a node name as well, but it will only accept an active layer anyway... I can change the name if you prefer. >> + if (snapshot_ref) { >> + if (!bdrv_lookup_bs(snapshot_ref, snapshot_ref, &local_err)) { >> error_propagate(errp, local_err); >> return; >> } >> } > > Shouldn't you also check that snapshot_ref does not currently have a > backing BDS (as it is the act of creating the snapshot that sets the > current device as the backing of the snapshot_ref BDS before altering > the BB to point to snapshot_ref as its new BDS)? I think you're right, thanks! >> +SQMP >> +blockdev-snapshot >> +----------------- >> +Since 2.5 >> + >> +Create a snapshot of a block device. 'device' and 'snapshot' both >> +refer to existing block devices. The former is the one to generate >> +the snapshot from, and the latter is the target of the snapshot. > > Is there any better terminology? Maybe: > > The act of creating a snapshot installs 'device' as the backing image > of 'snapshot'; additionally, if 'device' is associated with a block > device, the block device changes to using 'snapshot' as its new active > image. Sounds good. > Hmm - I wonder if that means we should have an optional boolean > parameter that allows us to avoid the automatic pivot. After all, > with 'blockdev-snapshot-sync', you can specify 'device' and omit > 'node-name' to update the device's active layer, or you can omit > 'device' and specify 'node-name' to create another qcow2 file but NOT > install it as the active layer, regardless of which 'node-name' that > serves as the starting point. So when 'node-name' is the BDS node that > 'device' is currently visiting, you have control over whether 'device' > auto-updates to the new BDS. What's the use case for that? Berto From MAILER-DAEMON Mon Sep 07 06:25:39 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYtcJ-0003tt-EF for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 06:25:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYtcD-0003iT-OC for qemu-block@nongnu.org; Mon, 07 Sep 2015 06:25:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYtcB-0003oX-Mi for qemu-block@nongnu.org; Mon, 07 Sep 2015 06:25:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44256) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYtcB-0003ns-II; Mon, 07 Sep 2015 06:25:31 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 9D7D38F265; Mon, 7 Sep 2015 10:25:30 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t87APSl0009871; Mon, 7 Sep 2015 06:25:29 -0400 Date: Mon, 7 Sep 2015 12:25:28 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150907102528.GA5529@noname.redhat.com> References: <1440611272-4571-1-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1440611272-4571-1-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 0/5] block: Drop drv parameter from bdrv_open() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 10:25:35 -0000 Am 26.08.2015 um 19:47 hat Max Reitz geschrieben: > We don't really need that parameter, so let's drop it. Doing so may even > fix some bugs, see > http://lists.nongnu.org/archive/html/qemu-block/2015-08/msg00171.html. > > In the course of writing this series, I had to decide whether the make > sure all callers of bdrv_find_whitelisted_format() would still only > accept whitelisted formats, which you'd think would be a good idea; but > the only caller left was qmp_change_blockdev(), so I guess noone really > cared about it anymore, instead relying on use_bdrv_whitelist alone. > > So I decided dropped bdrv_find_whitelisted_format() completely. If you > feel this is a bad decision, feel free to argue but then I guess we'll > have to reevaluate all bdrv_find_format() calls whether they should > actually be bdrv_find_whitelisted_format() calls. Thanks, applied to the block branch. Kevin From MAILER-DAEMON Mon Sep 07 06:40:06 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYtqI-00060f-U2 for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 06:40:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYtqE-0005wI-L2 for qemu-block@nongnu.org; Mon, 07 Sep 2015 06:40:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYtqB-0001Nm-8h for qemu-block@nongnu.org; Mon, 07 Sep 2015 06:40:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYtqA-0001Ne-VB; Mon, 07 Sep 2015 06:39:59 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 7024280B5A; Mon, 7 Sep 2015 10:39:58 +0000 (UTC) Received: from [10.36.112.56] (ovpn-112-56.ams2.redhat.com [10.36.112.56]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87AdoYO012737 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 06:39:53 -0400 To: Peter Lieven , qemu-devel@nongnu.org, qemu-block@nongnu.org References: <1439552016-8557-1-git-send-email-pl@kamp.de> <55E41297.5000303@kamp.de> From: Paolo Bonzini Message-ID: <55ED6976.2010000@redhat.com> Date: Mon, 7 Sep 2015 12:39:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55E41297.5000303@kamp.de> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: andrey@xdel.ru, qemu-stable@nongnu.org, ronniesahlberg@gmail.com Subject: Re: [Qemu-block] [PATCH] block/iscsi: validate block size returned from target X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 10:40:03 -0000 On 31/08/2015 10:38, Peter Lieven wrote: >> >> diff --git a/block/iscsi.c b/block/iscsi.c >> index 5002916..fac3a7a 100644 >> --- a/block/iscsi.c >> +++ b/block/iscsi.c >> @@ -1214,6 +1214,10 @@ static void iscsi_readcapacity_sync(IscsiLun >> *iscsilun, Error **errp) >> if (task == NULL || task->status != SCSI_STATUS_GOOD) { >> error_setg(errp, "iSCSI: failed to send readcapacity10 >> command."); >> + } else if (!iscsilun->block_size || >> + iscsilun->block_size % BDRV_SECTOR_SIZE) { >> + error_setg(errp, "iSCSI: the target returned an invalid " >> + "block size of %d.", iscsilun->block_size); >> } >> if (task) { >> scsi_free_scsi_task(task); > > Ping Queued but not sent due to KVM Forum and vacation. Paolo From MAILER-DAEMON Mon Sep 07 07:05:16 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYuEd-0002Np-Vm for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 07:05:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48979) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYuEX-0002IZ-Ct for qemu-block@nongnu.org; Mon, 07 Sep 2015 07:05:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYuET-0007ks-5V for qemu-block@nongnu.org; Mon, 07 Sep 2015 07:05:09 -0400 Received: from mail-vk0-f46.google.com ([209.85.213.46]:33844) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYuET-0007jX-0w for qemu-block@nongnu.org; Mon, 07 Sep 2015 07:05:05 -0400 Received: by vkhf67 with SMTP id f67so41484573vkh.1 for ; Mon, 07 Sep 2015 04:05:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=L3g86ZaweYAA3jZ77JQv1Hp95ZLKOnJ1MAzAuedi9fY=; b=kLgnXyevxTPSGIVPl3JzhDAkyT1EXAqoKht9xUkHC86mlq8rv15CpCSA4MbcLdnIgf PG/huqJj1fY2TG65Su40WF7UAFx3+sY1743v9AOLGYGWrNZyN7XWxUBC8TjVpVSZ9ryb o2xVor0qlju6BPYG0vSk0mBJ1cNPu9CAdLVkrHUKPdwdGYMiCAiO2s09sf7DxgSB8qgp 9gCQ3NVkmfWtbJdODqPDyT+iB/yYi3lR1ERC2GZBYH5wS/9TLoo/weDBY4ldIS9/Si80 WMl8OOdYJrj4O7QhZtJN/Cpx7/sbk2TuwwSMv+ScrQ+bGv/1NvFcYZOWBQP0zxSoMIi/ QwVg== X-Gm-Message-State: ALoCoQmB3YJXIb+f8lsSEYvU0y/a5mUDHyNfkhXaTz++FRK16u4bWfWaB4QHnjbyu1qgekY4oasc X-Received: by 10.52.176.195 with SMTP id ck3mr25253633vdc.78.1441623904357; Mon, 07 Sep 2015 04:05:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.153.135 with HTTP; Mon, 7 Sep 2015 04:04:45 -0700 (PDT) In-Reply-To: <1437741192-20955-1-git-send-email-peter.maydell@linaro.org> References: <1437741192-20955-1-git-send-email-peter.maydell@linaro.org> From: Peter Maydell Date: Mon, 7 Sep 2015 12:04:45 +0100 Message-ID: To: QEMU Developers Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.213.46 Cc: Kevin Wolf , Qemu-block , Patch Tracking , "Michael S. Tsirkin" , Keith Busch , Paolo Bonzini Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 0/6] replace qemu_fls() with pow2ceil()/pow2floor() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 11:05:15 -0000 Ping? Paolo, do you want to take these, should I just apply them to master, or what? thanks -- PMM On 24 July 2015 at 13:33, Peter Maydell wrote: > We have a qemu_fls() function which is just a silly wrapper > around clz32() and which is used in only a handful of places > in the codebase. It turns out that all of those are really > trying to round up or down to a power of 2, which is something > we have utility functions for. This series replaces all > the qemu_fls() calls with pow2ceil() or pow2floor(), and then > removes the now-unused function. > > For the case where you really want to do bit counting rather > than just power-of-2 rounding, you should use the clz/clo > functions directly. > > No changes from v1 to v2 except for a new patch 6 which moves > the pow2ceil and pow2floor functions to inline. > > Peter Maydell (6): > hw/pci: Use pow2ceil() rather than hand-calculation > hw/virtio/virtio-pci: Use pow2ceil() rather than hand-calculation > hw/block/nvme.c: Use pow2ceil() rather than hand-calculation > exec.c: Use pow2floor() rather than hand-calculation > Remove unused qemu_fls function > Make pow2ceil() and pow2floor() inline > > exec.c | 4 +--- > hw/block/nvme.c | 2 +- > hw/pci/msix.c | 4 +--- > hw/pci/pci.c | 4 +--- > hw/virtio/virtio-pci.c | 4 +--- > include/qemu-common.h | 17 +---------------- > include/qemu/host-utils.h | 33 +++++++++++++++++++++++++++++++++ > util/cutils.c | 28 ---------------------------- > 8 files changed, 39 insertions(+), 57 deletions(-) From MAILER-DAEMON Mon Sep 07 07:31:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYueC-0007iL-00 for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 07:31:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYue8-0007cf-Rd for qemu-block@nongnu.org; Mon, 07 Sep 2015 07:31:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYue8-0003hS-2j for qemu-block@nongnu.org; Mon, 07 Sep 2015 07:31:36 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:31659 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYue3-0003gt-Nf; Mon, 07 Sep 2015 07:31:31 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2C6BQBCde1V/5tjdVteGQEBAYMHgT2pTwEBAQEBBQGBCwGacwKBLjsRAQEBAQEBAYEKhCQBAQQ6PxALDgoJJQ8BLBsGARKIMgHIcQEBAQEBAQEDAQEBAQEdhiyFQoUMB4QsAQSVVadxJoQCPDOISQEBAQ X-IPAS-Result: A2C6BQBCde1V/5tjdVteGQEBAYMHgT2pTwEBAQEBBQGBCwGacwKBLjsRAQEBAQEBAYEKhCQBAQQ6PxALDgoJJQ8BLBsGARKIMgHIcQEBAQEBAQEDAQEBAQEdhiyFQoUMB4QsAQSVVadxJoQCPDOISQEBAQ X-IronPort-AV: E=Sophos;i="5.17,484,1437429600"; d="scan'208";a="18245195" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 07 Sep 2015 13:31:14 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZYudm-0005jW-2O; Mon, 07 Sep 2015 13:31:14 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZYudl-000887-TB; Mon, 07 Sep 2015 13:31:13 +0200 From: Alberto Garcia To: Eric Blake , qemu-devel@nongnu.org In-Reply-To: <55E9ADC9.3000404@redhat.com> References: <55E9ADC9.3000404@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Mon, 07 Sep 2015 13:31:13 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v2 2/2] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 11:31:38 -0000 On Fri 04 Sep 2015 04:42:17 PM CEST, Eric Blake wrote: >> + if (snapshot_ref) { >> + if (!bdrv_lookup_bs(snapshot_ref, snapshot_ref, &local_err)) { >> error_propagate(errp, local_err); >> return; >> } >> } > > Shouldn't you also check that snapshot_ref does not currently have a > backing BDS (as it is the act of creating the snapshot that sets the > current device as the backing of the snapshot_ref BDS before altering > the BB to point to snapshot_ref as its new BDS)? Wait, I actually think that it should have a backing BDS. This new command is roughly equivalent to the 'existing' mode of the 'blockdev-snapshot-sync' command, so the new image must be created externally in both cases having the current image as its backing file. The difference is that 'blockdev-snapshot-sync' will open the new image and not its backing chain (using the BDRV_O_NO_BACKING flag), but in 'blockdev-snapshot' the image must be opened previously with 'blockdev-add', which will open the whole chain. So I think that we should expect a backing image and we have to unref it during the 'commit' part of the transaction (before bdrv_append()). Berto From MAILER-DAEMON Mon Sep 07 08:08:48 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYvE8-0002pR-Oz for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 08:08:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYvE5-0002jJ-Ih for qemu-block@nongnu.org; Mon, 07 Sep 2015 08:08:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYvE2-0003yD-Cy for qemu-block@nongnu.org; Mon, 07 Sep 2015 08:08:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42549) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYvE2-0003y9-5G; Mon, 07 Sep 2015 08:08:42 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id AEEE9C0B9869; Mon, 7 Sep 2015 12:08:41 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t87C8d7Y014369; Mon, 7 Sep 2015 08:08:40 -0400 Date: Mon, 7 Sep 2015 14:08:39 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150907120839.GB5529@noname.redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> <1441387117-27072-14-git-send-email-kwolf@redhat.com> <55E9F67D.9010909@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="TB36FDmn/VVEgNH/" Content-Disposition: inline In-Reply-To: <55E9F67D.9010909@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 13/13] qemu-iotests: More qcow2 reopen tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 12:08:47 -0000 --TB36FDmn/VVEgNH/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 04.09.2015 um 21:52 hat Max Reitz geschrieben: > On 04.09.2015 19:18, Kevin Wolf wrote: > > Signed-off-by: Kevin Wolf > > --- > > tests/qemu-iotests/137 | 143 +++++++++++++++++++++++++++++++++++++= ++++++++ > > tests/qemu-iotests/137.out | 43 ++++++++++++++ > > tests/qemu-iotests/group | 1 + > > 3 files changed, 187 insertions(+) > > create mode 100755 tests/qemu-iotests/137 > > create mode 100644 tests/qemu-iotests/137.out > >=20 > > diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 > > new file mode 100755 > > index 0000000..ad52f71 > > --- /dev/null > > +++ b/tests/qemu-iotests/137 >=20 >=20 > [snip] >=20 > > +echo > > +echo =3D=3D=3D Try setting some invalid values =3D=3D=3D > > +echo > > + > > +$QEMU_IO \ > > + -c "reopen -o lazy-refcounts=3D42" \ > > + -c "reopen -o cache-size=3D1M,l2-cache-size=3D64k,refcount-cache-s= ize=3D64k" \ > > + -c "reopen -o cache-size=3D1M,l2-cache-size=3D2M" \ > > + -c "reopen -o cache-size=3D1M,refcount-cache-size=3D2M" \ > > + -c "reopen -o l2-cache-size=3D256T" \ > > + -c "reopen -o l2-cache-size=3D64G" \ >=20 > Testing this seems risky. The rest looks fine, but I'm not sure whether > this is really needed so much that we should risk the test failing on > some machines, especially in the future. I think we should be testing the "too large, but not much too large" case. A risk of false positives is better than a risk to break things without noticing. I could make it something like 64T, though, that should last a bit longer. The "much too large" case starts at 128T (INT_MAX * s->cluster_size =3D=3D 2G * 64k). > Or actually even on my machine: >=20 > $ touch ~/tmp/swap > $ truncate ~/tmp/swap --size 128G > $ fallocate -l 128G ~/tmp/swap > # mkswap ~maxx/tmp/swap > # swapon ~max/tmp/swap This looks faked. :-P > $ cd /to/qemu/build > $ ./qemu-io -c 'reopen -o l2-cache-size=3D64G' test.qcow2 > $ >=20 > (Running the test itself is apparently a bad idea, because then for some > reason Linux thinks I actually want to use the swap and everything slows > down to a crawl) Well, if you do that intentionally, I guess you deserve it... Kevin --TB36FDmn/VVEgNH/ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJV7X5HAAoJEH8JsnLIjy/W63AP/AmnpzQiYeNtNkWzU8vFWwPd vlzO2a5ixcvPyFYKRPGAWUefH+NX+vDRwBPRV0Q0151uHpXCfJ+fPN8EMSUaw/91 ENdSQlKXoyhADR6R9kSL50vnaoHRXu2ItBbjDHqiNIA89nKH7JQuingvy57LFuLe iZmTs5CTt5ZnlAOS7prtwWckDksHuzVvqQMIFeXWlZAubUE8w6op/EqXp2UCD37M Sa8skFvmzWRW3/CVhHJTnAsBB4fxflGa4obooC0xNX3ud9s2wwAdrM4Ewdxekksd 6/ErJQhyTCicWPFwO6KkVHAOK00HWubajGiD1pgZWMA0Pnx0+94iHGGZFdwshM0k YKUo2ddh+zIovt66ifnTZ2zOTUD+Zkz/t904Yo1WXamWmbn/8gcovPZx6BfRi5wo O77BbmK/LK9jrRwkWLcPKom8Uz1hovQ0+PRI22TwDfFT2Ok1aul2lbVd5w57KoB+ oJT5XmkwTPT9GkR7q222AZf8oWWQb+dBhyxS2IcfcJ5wm9ORFftwlZ20smnWvOf/ fZL2ZIU1Z+lzARAbLbYxhVdLOl6c7YblFvZ/6TlwYtOl7Yb7FJnMCBPESzGsK3ue phfn0oLJSKdN8rWF1aIHwtYomwTYRmINiP3uSV1J430mQDLuyxY3jCKv8Pdgq5+C x0aUgqugwo7ipDzDUoGj =vbua -----END PGP SIGNATURE----- --TB36FDmn/VVEgNH/-- From MAILER-DAEMON Mon Sep 07 08:19:08 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYvO8-0006Fl-Hp for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 08:19:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYvO4-0006Bd-H1 for qemu-block@nongnu.org; Mon, 07 Sep 2015 08:19:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYvNz-0008UW-JU for qemu-block@nongnu.org; Mon, 07 Sep 2015 08:19:04 -0400 Received: from mail-vk0-f41.google.com ([209.85.213.41]:33999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYvNz-0008UE-GN for qemu-block@nongnu.org; Mon, 07 Sep 2015 08:18:59 -0400 Received: by vkhf67 with SMTP id f67so42330180vkh.1 for ; Mon, 07 Sep 2015 05:18:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=DqFFcLUJZV1BG8B42R+vdVFxUj8PRa7S2rr2I5qEmLs=; b=SWHZtL4gYSyKKRFIxLUeuKUHKzeDQQMaoKo9o1oPAbiTUgZLMBs5xuKRGdGf72R9Hk A3hpW8hJC/AISjicMrNnsSyppQD7c6P7Y9WzwZGtZufyur4UvawEtYRYnchdOLC3Sb63 6NJUh/oOLdWzxAVlMu2yA2pMAhC122LVYaXPejclssg8Mqt1/WHtToGKeMHiRq9o64/m UENbFEc11pQ3RQfEV1eA91lIoRn/QzmXfsDO9/4yWUFwiQqobSLxWyGrSWqyr453zfcp q2yzJr+XjRlaXrBnpiXqRGF60cxYTY5/kx97/7sFJqHcAAgOGVpoTbCre8e15h1vOI8G zFEQ== X-Gm-Message-State: ALoCoQnHZVCTbz/WrFz0Kzos50ihijHNEUooWxnMujaw8ehTEIgmFSjks0gbiW09G+gSGgwEkDwf X-Received: by 10.52.74.1 with SMTP id p1mr24908162vdv.1.1441628338877; Mon, 07 Sep 2015 05:18:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.153.135 with HTTP; Mon, 7 Sep 2015 05:18:39 -0700 (PDT) In-Reply-To: <1441397447-6516-1-git-send-email-kwolf@redhat.com> References: <1441397447-6516-1-git-send-email-kwolf@redhat.com> From: Peter Maydell Date: Mon, 7 Sep 2015 13:18:39 +0100 Message-ID: To: Kevin Wolf Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.213.41 Cc: QEMU Developers , Qemu-block , Max Reitz Subject: Re: [Qemu-block] [Qemu-devel] [PULL 00/16] Block patches X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 12:19:05 -0000 On 4 September 2015 at 21:10, Kevin Wolf wrote: > The following changes since commit b597aa037dbd98014c8dec3d69a5e2240f432533: > > Merge remote-tracking branch 'remotes/armbru/tags/pull-monitor-2015-09-04' into staging (2015-09-04 17:37:50 +0100) > > are available in the git repository at: > > > git://repo.or.cz/qemu/kevin.git tags/for-upstream > > for you to fetch changes up to c804b5791d51608c0e12e4cc2b40b3d763ce796c: > > Merge remote-tracking branch 'mreitz/tags/pull-block-for-kevin-2015-09-04' into queue-block (2015-09-04 21:43:55 +0200) > > ---------------------------------------------------------------- > > Block layer patches Applied, thanks. -- PMM From MAILER-DAEMON Mon Sep 07 08:23:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYvS7-0000sf-MM for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 08:23:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYvS1-0000qe-Uk for qemu-block@nongnu.org; Mon, 07 Sep 2015 08:23:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYvRx-0001Rx-00 for qemu-block@nongnu.org; Mon, 07 Sep 2015 08:23:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36849) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYvRw-0001Rt-OX; Mon, 07 Sep 2015 08:23:04 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 40A64C0AE66A; Mon, 7 Sep 2015 12:23:04 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t87CN2kX004744; Mon, 7 Sep 2015 08:23:03 -0400 Date: Mon, 7 Sep 2015 14:23:02 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150907122302.GC5529@noname.redhat.com> References: <1441387117-27072-1-git-send-email-kwolf@redhat.com> <1441387117-27072-14-git-send-email-kwolf@redhat.com> <55E9F67D.9010909@redhat.com> <20150907120839.GB5529@noname.redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="oC1+HKm2/end4ao3" Content-Disposition: inline In-Reply-To: <20150907120839.GB5529@noname.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 13/13] qemu-iotests: More qcow2 reopen tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 12:23:14 -0000 --oC1+HKm2/end4ao3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 07.09.2015 um 14:08 hat Kevin Wolf geschrieben: > Am 04.09.2015 um 21:52 hat Max Reitz geschrieben: > > On 04.09.2015 19:18, Kevin Wolf wrote: > > > Signed-off-by: Kevin Wolf > > > --- > > > tests/qemu-iotests/137 | 143 +++++++++++++++++++++++++++++++++++= ++++++++++ > > > tests/qemu-iotests/137.out | 43 ++++++++++++++ > > > tests/qemu-iotests/group | 1 + > > > 3 files changed, 187 insertions(+) > > > create mode 100755 tests/qemu-iotests/137 > > > create mode 100644 tests/qemu-iotests/137.out > > >=20 > > > diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 > > > new file mode 100755 > > > index 0000000..ad52f71 > > > --- /dev/null > > > +++ b/tests/qemu-iotests/137 > >=20 > >=20 > > [snip] > >=20 > > > +echo > > > +echo =3D=3D=3D Try setting some invalid values =3D=3D=3D > > > +echo > > > + > > > +$QEMU_IO \ > > > + -c "reopen -o lazy-refcounts=3D42" \ > > > + -c "reopen -o cache-size=3D1M,l2-cache-size=3D64k,refcount-cache= -size=3D64k" \ > > > + -c "reopen -o cache-size=3D1M,l2-cache-size=3D2M" \ > > > + -c "reopen -o cache-size=3D1M,refcount-cache-size=3D2M" \ > > > + -c "reopen -o l2-cache-size=3D256T" \ > > > + -c "reopen -o l2-cache-size=3D64G" \ > >=20 > > Testing this seems risky. The rest looks fine, but I'm not sure whether > > this is really needed so much that we should risk the test failing on > > some machines, especially in the future. >=20 > I think we should be testing the "too large, but not much too large" > case. A risk of false positives is better than a risk to break things > without noticing. I could make it something like 64T, though, that > should last a bit longer. The "much too large" case starts at 128T > (INT_MAX * s->cluster_size =3D=3D 2G * 64k). =2E..except that qcow2_cache_create() also allocates a Qcow2CachedTable array and that one is small enough in comparison that we'd end up again in the same range as before, where allocations might not fail right away, but fill up the swap. Fair enough, I'll remove the lines. Do you want a v3 on the list or can I fix it while merging? Kevin --oC1+HKm2/end4ao3 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJV7YGmAAoJEH8JsnLIjy/WLs0QALPnu57i5fg05wU8rAS7t+fc Egg/0d7/m8s1Z6E3H0mV3qtQrN1UEVq67AWhhti9eyVc2gEMPJ/dZ9bLIAStmPaA 8UhvG5EK0X8MxTSqYOXs9tOdObO+MYCV8aEs/X0JzJ+ZcLU0Ziq1hQGk90QzZVKP XNgct7nFynF1hh05pawvmohK+3w67QtRLIDi7fir1AX+ykWW5/gqOwRMqmYGyTAB aSiG3HtGb66g9iPqiGVnPRUTMSkNf8pDkrHNmO08y/+KywJL/jwTvCgDbNJtQZWc 0GeoQlaHt5jrjLIuRRT6y2r2NU5/SqM0qsNkXO8KKSV+CKiUH8ZfcMH3d+mDXPX3 SheWumlt1nxo1lrYmYb2bR1FXZot+QU3etJZVDZveeOeM2dxa0FYt8LpWu+Mvc6G dRlDxFO5MWL1vW02SGUlALpOHDnlMR/+W0bvpcsdIPWXw542w2/msiL4mzi9Hl7o CrV682AlfLPc1YSpaXaL0h0BHNmQEVKlnXEDxtj5Mn2S0KB2XWzJJXhAkSqBkzpq tb9toGurFB3NmhVhsiaIv9jbykNtjEOVS+V/BEfbtfRkAVpi1Gb19ZqX0hlZGoYp Mp5A6GvfVFyoS9d8CpNKGg0fCHI5Ey8Q76HOcogwyKZLGfDxor2m4Gs8nngsz/DF UgQskRSLRwQLkpAWdfwy =naZ3 -----END PGP SIGNATURE----- --oC1+HKm2/end4ao3-- From MAILER-DAEMON Mon Sep 07 08:35:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYvdW-0006u5-5C for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 08:35:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYvdP-0006mt-4D for qemu-block@nongnu.org; Mon, 07 Sep 2015 08:35:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYvdO-0006VP-Bt for qemu-block@nongnu.org; Mon, 07 Sep 2015 08:34:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37875) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYvdO-0006VI-6i; Mon, 07 Sep 2015 08:34:54 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id AC26F2D8B7C; Mon, 7 Sep 2015 12:34:53 +0000 (UTC) Received: from [10.36.112.56] (ovpn-112-56.ams2.redhat.com [10.36.112.56]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87CYnbv023427 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 08:34:51 -0400 To: Peter Maydell , QEMU Developers References: <1437741192-20955-1-git-send-email-peter.maydell@linaro.org> From: Paolo Bonzini Message-ID: <55ED8469.1010508@redhat.com> Date: Mon, 7 Sep 2015 14:34:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Keith Busch , Patch Tracking , Qemu-block , "Michael S. Tsirkin" Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 0/6] replace qemu_fls() with pow2ceil()/pow2floor() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 12:35:00 -0000 On 07/09/2015 13:04, Peter Maydell wrote: > Ping? > > Paolo, do you want to take these, should I just apply them > to master, or what? Sorry, I thought you were applying these or pulling them through your trees. Let me know if you still want me to take them. Paolo From MAILER-DAEMON Mon Sep 07 09:26:39 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwRS-00046e-Nu for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:26:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRN-00043K-Av for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwRI-0004wD-CV for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50732) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRI-0004w3-6u; Mon, 07 Sep 2015 09:26:28 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B84228535C; Mon, 7 Sep 2015 13:26:27 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87DQN4t001488; Mon, 7 Sep 2015 09:26:24 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 15:26:08 +0200 Message-Id: <1441632381-26638-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v3 00/13] qcow2: reopen: Change driver-specific runtime options X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:26:34 -0000 This is part two of what I had sent earlier as "[PATCH 00/34] block: Cache mode for children, reopen overhaul and more". Most of the patches were actually already reviewed in v1. v3: - Removed tests that depend on memory size of test machine [Max] - Rebased, resolved conflicts with Berto's cache cleaning timer series v2: Apart from a few addressed review comments, there are no functional changes compared to v1. Some rebasing was necessary; also the qemu-iotests cases are new. Kevin Wolf (13): block: Allow specifying driver-specific options to reopen qemu-io: Remove duplicate 'open' error message qemu-io: Add command 'reopen' qcow2: Improve error message qcow2: Factor out qcow2_update_options() qcow2: Move qcow2_update_options() call up qcow2: Move rest of option handling to qcow2_update_options() qcow2: Leave s unchanged on qcow2_update_options() failure qcow2: Fix memory leak in qcow2_update_options() error path qcow2: Make qcow2_update_options() suitable for transactions qcow2: Support updating driver-specific options in reopen qemu-iotests: Reopen qcow2 with lazy-refcounts change qemu-iotests: More qcow2 reopen tests block.c | 42 ++++- block/commit.c | 4 +- block/qcow2.c | 390 ++++++++++++++++++++++++++++++--------------- include/block/block.h | 4 +- qemu-io-cmds.c | 90 +++++++++++ qemu-io.c | 1 - tests/qemu-iotests/039 | 27 ++++ tests/qemu-iotests/039.out | 18 +++ tests/qemu-iotests/137 | 145 +++++++++++++++++ tests/qemu-iotests/137.out | 42 +++++ tests/qemu-iotests/group | 1 + 11 files changed, 630 insertions(+), 134 deletions(-) create mode 100755 tests/qemu-iotests/137 create mode 100644 tests/qemu-iotests/137.out -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 09:26:46 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwRa-0004JV-1x for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:26:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRU-00049T-Ct for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwRQ-00050F-Cn for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRQ-0004zx-61; Mon, 07 Sep 2015 09:26:36 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id DEA7680091; Mon, 7 Sep 2015 13:26:35 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87DQN4w001488; Mon, 7 Sep 2015 09:26:33 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 15:26:11 +0200 Message-Id: <1441632381-26638-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1441632381-26638-1-git-send-email-kwolf@redhat.com> References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v3 03/13] qemu-io: Add command 'reopen' X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:26:44 -0000 Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- qemu-io-cmds.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 53477e1..d6572a8 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1979,6 +1979,95 @@ static const cmdinfo_t map_cmd = { .oneline = "prints the allocated areas of a file", }; +static void reopen_help(void) +{ + printf( +"\n" +" Changes the open options of an already opened image\n" +"\n" +" Example:\n" +" 'reopen -o lazy-refcounts=on' - activates lazy refcount writeback on a qcow2 image\n" +"\n" +" -r, -- Reopen the image read-only\n" +" -c, -- Change the cache mode to the given value\n" +" -o, -- Changes block driver options (cf. 'open' command)\n" +"\n"); +} + +static int reopen_f(BlockBackend *blk, int argc, char **argv); + +static QemuOptsList reopen_opts = { + .name = "reopen", + .merge_lists = true, + .head = QTAILQ_HEAD_INITIALIZER(reopen_opts.head), + .desc = { + /* no elements => accept any params */ + { /* end of list */ } + }, +}; + +static const cmdinfo_t reopen_cmd = { + .name = "reopen", + .argmin = 0, + .argmax = -1, + .cfunc = reopen_f, + .args = "[-r] [-c cache] [-o options]", + .oneline = "reopens an image with new options", + .help = reopen_help, +}; + +static int reopen_f(BlockBackend *blk, int argc, char **argv) +{ + BlockDriverState *bs = blk_bs(blk); + QemuOpts *qopts; + QDict *opts; + int c; + int flags = bs->open_flags; + + BlockReopenQueue *brq; + Error *local_err = NULL; + + while ((c = getopt(argc, argv, "c:o:r")) != -1) { + switch (c) { + case 'c': + if (bdrv_parse_cache_flags(optarg, &flags) < 0) { + error_report("Invalid cache option: %s", optarg); + return 0; + } + break; + case 'o': + if (!qemu_opts_parse_noisily(&reopen_opts, optarg, 0)) { + qemu_opts_reset(&reopen_opts); + return 0; + } + break; + case 'r': + flags &= ~BDRV_O_RDWR; + break; + default: + qemu_opts_reset(&reopen_opts); + return qemuio_command_usage(&reopen_cmd); + } + } + + if (optind != argc) { + qemu_opts_reset(&reopen_opts); + return qemuio_command_usage(&reopen_cmd); + } + + qopts = qemu_opts_find(&reopen_opts, NULL); + opts = qopts ? qemu_opts_to_qdict(qopts, NULL) : NULL; + qemu_opts_reset(&reopen_opts); + + brq = bdrv_reopen_queue(NULL, bs, opts, flags); + bdrv_reopen_multiple(brq, &local_err); + if (local_err) { + error_report_err(local_err); + } + + return 0; +} + static int break_f(BlockBackend *blk, int argc, char **argv) { int ret; @@ -2266,6 +2355,7 @@ static void __attribute((constructor)) init_qemuio_commands(void) qemuio_add_command(&discard_cmd); qemuio_add_command(&alloc_cmd); qemuio_add_command(&map_cmd); + qemuio_add_command(&reopen_cmd); qemuio_add_command(&break_cmd); qemuio_add_command(&remove_break_cmd); qemuio_add_command(&resume_cmd); -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 09:26:48 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwRc-0004NP-BP for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:26:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRY-0004FC-3G for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwRV-00051x-HC for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRV-00051q-89; Mon, 07 Sep 2015 09:26:41 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id EB6C149; Mon, 7 Sep 2015 13:26:40 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87DQN50001488; Mon, 7 Sep 2015 09:26:38 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 15:26:13 +0200 Message-Id: <1441632381-26638-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1441632381-26638-1-git-send-email-kwolf@redhat.com> References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v3 05/13] qcow2: Factor out qcow2_update_options() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:26:45 -0000 Eventually we want to be able to change options at runtime. As a first step towards that goal, separate some option handling code from the general initialisation code in qcow2_open(). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2.c | 135 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 76 insertions(+), 59 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index b681977..e98982d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -589,6 +589,80 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, } } +static int qcow2_update_options(BlockDriverState *bs, QemuOpts *opts, + int flags, Error **errp) +{ + BDRVQcowState *s = bs->opaque; + const char *opt_overlap_check, *opt_overlap_check_template; + int overlap_check_template = 0; + int i; + int ret; + + s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, + (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); + + s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; + s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; + s->discard_passthrough[QCOW2_DISCARD_REQUEST] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, + flags & BDRV_O_UNMAP); + s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); + s->discard_passthrough[QCOW2_DISCARD_OTHER] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); + + opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); + opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); + if (opt_overlap_check_template && opt_overlap_check && + strcmp(opt_overlap_check_template, opt_overlap_check)) + { + error_setg(errp, "Conflicting values for qcow2 options '" + QCOW2_OPT_OVERLAP "' ('%s') and '" QCOW2_OPT_OVERLAP_TEMPLATE + "' ('%s')", opt_overlap_check, opt_overlap_check_template); + ret = -EINVAL; + goto fail; + } + if (!opt_overlap_check) { + opt_overlap_check = opt_overlap_check_template ?: "cached"; + } + + if (!strcmp(opt_overlap_check, "none")) { + overlap_check_template = 0; + } else if (!strcmp(opt_overlap_check, "constant")) { + overlap_check_template = QCOW2_OL_CONSTANT; + } else if (!strcmp(opt_overlap_check, "cached")) { + overlap_check_template = QCOW2_OL_CACHED; + } else if (!strcmp(opt_overlap_check, "all")) { + overlap_check_template = QCOW2_OL_ALL; + } else { + error_setg(errp, "Unsupported value '%s' for qcow2 option " + "'overlap-check'. Allowed are any of the following: " + "none, constant, cached, all", opt_overlap_check); + ret = -EINVAL; + goto fail; + } + + s->overlap_check = 0; + for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { + /* overlap-check defines a template bitmask, but every flag may be + * overwritten through the associated boolean option */ + s->overlap_check |= + qemu_opt_get_bool(opts, overlap_bool_option_names[i], + overlap_check_template & (1 << i)) << i; + } + + if (s->use_lazy_refcounts && s->qcow_version < 3) { + error_setg(errp, "Lazy refcounts require a qcow2 image with at least " + "qemu 1.1 compatibility level"); + ret = -EINVAL; + goto fail; + } + + ret = 0; +fail: + return ret; +} + static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { @@ -600,8 +674,6 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, Error *local_err = NULL; uint64_t ext_end; uint64_t l1_vm_state_index; - const char *opt_overlap_check, *opt_overlap_check_template; - int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; uint64_t cache_clean_interval; @@ -992,69 +1064,14 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, } /* Enable lazy_refcounts according to image and command line options */ - s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, - (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); - - s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; - s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; - s->discard_passthrough[QCOW2_DISCARD_REQUEST] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, - flags & BDRV_O_UNMAP); - s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); - s->discard_passthrough[QCOW2_DISCARD_OTHER] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); - - opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); - opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); - if (opt_overlap_check_template && opt_overlap_check && - strcmp(opt_overlap_check_template, opt_overlap_check)) - { - error_setg(errp, "Conflicting values for qcow2 options '" - QCOW2_OPT_OVERLAP "' ('%s') and '" QCOW2_OPT_OVERLAP_TEMPLATE - "' ('%s')", opt_overlap_check, opt_overlap_check_template); - ret = -EINVAL; - goto fail; - } - if (!opt_overlap_check) { - opt_overlap_check = opt_overlap_check_template ?: "cached"; - } - - if (!strcmp(opt_overlap_check, "none")) { - overlap_check_template = 0; - } else if (!strcmp(opt_overlap_check, "constant")) { - overlap_check_template = QCOW2_OL_CONSTANT; - } else if (!strcmp(opt_overlap_check, "cached")) { - overlap_check_template = QCOW2_OL_CACHED; - } else if (!strcmp(opt_overlap_check, "all")) { - overlap_check_template = QCOW2_OL_ALL; - } else { - error_setg(errp, "Unsupported value '%s' for qcow2 option " - "'overlap-check'. Allowed are any of the following: " - "none, constant, cached, all", opt_overlap_check); - ret = -EINVAL; + ret = qcow2_update_options(bs, opts, flags, errp); + if (ret < 0) { goto fail; } - s->overlap_check = 0; - for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { - /* overlap-check defines a template bitmask, but every flag may be - * overwritten through the associated boolean option */ - s->overlap_check |= - qemu_opt_get_bool(opts, overlap_bool_option_names[i], - overlap_check_template & (1 << i)) << i; - } - qemu_opts_del(opts); opts = NULL; - if (s->use_lazy_refcounts && s->qcow_version < 3) { - error_setg(errp, "Lazy refcounts require a qcow2 image with at least " - "qemu 1.1 compatibility level"); - ret = -EINVAL; - goto fail; - } - #ifdef DEBUG_ALLOC { BdrvCheckResult result = {0}; -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 09:26:51 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwRf-0004Tg-JI for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:26:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRc-0004Na-7X for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwRb-0005GN-2Z for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53844) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRa-0005Fv-Rl; Mon, 07 Sep 2015 09:26:47 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 902B88C1D3; Mon, 7 Sep 2015 13:26:46 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87DQN52001488; Mon, 7 Sep 2015 09:26:44 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 15:26:15 +0200 Message-Id: <1441632381-26638-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1441632381-26638-1-git-send-email-kwolf@redhat.com> References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v3 07/13] qcow2: Move rest of option handling to qcow2_update_options() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:26:49 -0000 With this commit, the handling of driver-specific options in qcow2_open() is completely separated out into qcow2_update_options(). Signed-off-by: Kevin Wolf --- block/qcow2.c | 134 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 68 insertions(+), 66 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index f7b5cbf..382d314 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -589,15 +589,77 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, } } -static int qcow2_update_options(BlockDriverState *bs, QemuOpts *opts, +static int qcow2_update_options(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVQcowState *s = bs->opaque; + QemuOpts *opts = NULL; const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; + uint64_t l2_cache_size, refcount_cache_size; + uint64_t cache_clean_interval; int i; + Error *local_err = NULL; int ret; + opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); + qemu_opts_absorb_qdict(opts, options, &local_err); + if (local_err) { + error_propagate(errp, local_err); + ret = -EINVAL; + goto fail; + } + + /* get L2 table/refcount block cache size from command line options */ + read_cache_sizes(bs, opts, &l2_cache_size, &refcount_cache_size, + &local_err); + if (local_err) { + error_propagate(errp, local_err); + ret = -EINVAL; + goto fail; + } + + l2_cache_size /= s->cluster_size; + if (l2_cache_size < MIN_L2_CACHE_SIZE) { + l2_cache_size = MIN_L2_CACHE_SIZE; + } + if (l2_cache_size > INT_MAX) { + error_setg(errp, "L2 cache size too big"); + ret = -EINVAL; + goto fail; + } + + refcount_cache_size /= s->cluster_size; + if (refcount_cache_size < MIN_REFCOUNT_CACHE_SIZE) { + refcount_cache_size = MIN_REFCOUNT_CACHE_SIZE; + } + if (refcount_cache_size > INT_MAX) { + error_setg(errp, "Refcount cache size too big"); + ret = -EINVAL; + goto fail; + } + + /* alloc L2 table/refcount block cache */ + s->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); + s->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); + if (s->l2_table_cache == NULL || s->refcount_block_cache == NULL) { + error_setg(errp, "Could not allocate metadata caches"); + ret = -ENOMEM; + goto fail; + } + + /* New interval for cache cleanup timer */ + cache_clean_interval = + qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0); + if (cache_clean_interval > UINT_MAX) { + error_setg(errp, "Cache clean interval too big"); + ret = -EINVAL; + goto fail; + } + s->cache_clean_interval = cache_clean_interval; + cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); + + /* Enable lazy_refcounts according to image and command line options */ s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); @@ -660,6 +722,9 @@ static int qcow2_update_options(BlockDriverState *bs, QemuOpts *opts, ret = 0; fail: + qemu_opts_del(opts); + opts = NULL; + return ret; } @@ -670,12 +735,9 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, unsigned int len, i; int ret = 0; QCowHeader header; - QemuOpts *opts = NULL; Error *local_err = NULL; uint64_t ext_end; uint64_t l1_vm_state_index; - uint64_t l2_cache_size, refcount_cache_size; - uint64_t cache_clean_interval; ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); if (ret < 0) { @@ -923,71 +985,12 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, } } - /* get L2 table/refcount block cache size from command line options */ - opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); - ret = -EINVAL; - goto fail; - } - - read_cache_sizes(bs, opts, &l2_cache_size, &refcount_cache_size, - &local_err); - if (local_err) { - error_propagate(errp, local_err); - ret = -EINVAL; - goto fail; - } - - l2_cache_size /= s->cluster_size; - if (l2_cache_size < MIN_L2_CACHE_SIZE) { - l2_cache_size = MIN_L2_CACHE_SIZE; - } - if (l2_cache_size > INT_MAX) { - error_setg(errp, "L2 cache size too big"); - ret = -EINVAL; - goto fail; - } - - refcount_cache_size /= s->cluster_size; - if (refcount_cache_size < MIN_REFCOUNT_CACHE_SIZE) { - refcount_cache_size = MIN_REFCOUNT_CACHE_SIZE; - } - if (refcount_cache_size > INT_MAX) { - error_setg(errp, "Refcount cache size too big"); - ret = -EINVAL; - goto fail; - } - - /* alloc L2 table/refcount block cache */ - s->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); - s->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); - if (s->l2_table_cache == NULL || s->refcount_block_cache == NULL) { - error_setg(errp, "Could not allocate metadata caches"); - ret = -ENOMEM; - goto fail; - } - - cache_clean_interval = - qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0); - if (cache_clean_interval > UINT_MAX) { - error_setg(errp, "Cache clean interval too big"); - ret = -EINVAL; - goto fail; - } - s->cache_clean_interval = cache_clean_interval; - cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); - - /* Enable lazy_refcounts according to image and command line options */ - ret = qcow2_update_options(bs, opts, flags, errp); + /* Parse driver-specific options */ + ret = qcow2_update_options(bs, options, flags, errp); if (ret < 0) { goto fail; } - qemu_opts_del(opts); - opts = NULL; - s->cluster_cache = g_malloc(s->cluster_size); /* one more sector for decompressed data alignment */ s->cluster_data = qemu_try_blockalign(bs->file, QCOW_MAX_CRYPT_CLUSTERS @@ -1081,7 +1084,6 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, return ret; fail: - qemu_opts_del(opts); g_free(s->unknown_header_fields); cleanup_unknown_header_ext(bs); qcow2_free_snapshots(bs); -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 09:26:46 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwRa-0004Jy-9y for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:26:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRY-0004F5-34 for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwRT-000517-4I for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRS-00050x-Nt; Mon, 07 Sep 2015 09:26:39 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 74B928E3D3; Mon, 7 Sep 2015 13:26:38 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87DQN4x001488; Mon, 7 Sep 2015 09:26:36 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 15:26:12 +0200 Message-Id: <1441632381-26638-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1441632381-26638-1-git-send-email-kwolf@redhat.com> References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v3 04/13] qcow2: Improve error message X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:26:45 -0000 Eric says that "any" sounds better than "either", and my non-native feeling says the same, so let's change it. Suggested-by: Eric Blake Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block/qcow2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index a707d8d..b681977 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1030,7 +1030,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, overlap_check_template = QCOW2_OL_ALL; } else { error_setg(errp, "Unsupported value '%s' for qcow2 option " - "'overlap-check'. Allowed are either of the following: " + "'overlap-check'. Allowed are any of the following: " "none, constant, cached, all", opt_overlap_check); ret = -EINVAL; goto fail; -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 09:26:48 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwRc-0004O8-HH for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:26:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRY-0004H7-SQ for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwRY-00058B-3i for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRX-00057e-Uo; Mon, 07 Sep 2015 09:26:44 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id A9354461C0; Mon, 7 Sep 2015 13:26:43 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87DQN51001488; Mon, 7 Sep 2015 09:26:41 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 15:26:14 +0200 Message-Id: <1441632381-26638-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1441632381-26638-1-git-send-email-kwolf@redhat.com> References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v3 06/13] qcow2: Move qcow2_update_options() call up X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:26:45 -0000 qcow2_update_options() only updates some variables in BDRVQcowState and doesn't really depend on other parts of it being initialised yet, so it can be moved so that it immediately follows the other half of option handling code in qcow2_open(). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index e98982d..f7b5cbf 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -979,6 +979,15 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, s->cache_clean_interval = cache_clean_interval; cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); + /* Enable lazy_refcounts according to image and command line options */ + ret = qcow2_update_options(bs, opts, flags, errp); + if (ret < 0) { + goto fail; + } + + qemu_opts_del(opts); + opts = NULL; + s->cluster_cache = g_malloc(s->cluster_size); /* one more sector for decompressed data alignment */ s->cluster_data = qemu_try_blockalign(bs->file, QCOW_MAX_CRYPT_CLUSTERS @@ -1063,15 +1072,6 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, } } - /* Enable lazy_refcounts according to image and command line options */ - ret = qcow2_update_options(bs, opts, flags, errp); - if (ret < 0) { - goto fail; - } - - qemu_opts_del(opts); - opts = NULL; - #ifdef DEBUG_ALLOC { BdrvCheckResult result = {0}; -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 09:26:58 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwRm-0004g0-2n for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:26:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRi-0004ae-Qr for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwRd-0005On-RG for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38644) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRd-0005ON-Kl; Mon, 07 Sep 2015 09:26:49 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 5F46680B27; Mon, 7 Sep 2015 13:26:49 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87DQN53001488; Mon, 7 Sep 2015 09:26:47 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 15:26:16 +0200 Message-Id: <1441632381-26638-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1441632381-26638-1-git-send-email-kwolf@redhat.com> References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v3 08/13] qcow2: Leave s unchanged on qcow2_update_options() failure X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:26:56 -0000 On return, either all new options should be applied to BDRVQcowState (on success), or all of the old settings should be preserved (on failure). Signed-off-by: Kevin Wolf --- block/qcow2.c | 57 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 382d314..923b9dd 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -597,7 +597,10 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; + Qcow2Cache *l2_table_cache; + Qcow2Cache *refcount_block_cache; uint64_t cache_clean_interval; + bool use_lazy_refcounts; int i; Error *local_err = NULL; int ret; @@ -640,9 +643,9 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, } /* alloc L2 table/refcount block cache */ - s->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); - s->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); - if (s->l2_table_cache == NULL || s->refcount_block_cache == NULL) { + l2_table_cache = qcow2_cache_create(bs, l2_cache_size); + refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); + if (l2_table_cache == NULL || refcount_block_cache == NULL) { error_setg(errp, "Could not allocate metadata caches"); ret = -ENOMEM; goto fail; @@ -656,23 +659,18 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, ret = -EINVAL; goto fail; } - s->cache_clean_interval = cache_clean_interval; - cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); /* Enable lazy_refcounts according to image and command line options */ - s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, + use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); + if (use_lazy_refcounts && s->qcow_version < 3) { + error_setg(errp, "Lazy refcounts require a qcow2 image with at least " + "qemu 1.1 compatibility level"); + ret = -EINVAL; + goto fail; + } - s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; - s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; - s->discard_passthrough[QCOW2_DISCARD_REQUEST] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, - flags & BDRV_O_UNMAP); - s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); - s->discard_passthrough[QCOW2_DISCARD_OTHER] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); - + /* Overlap check options */ opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); if (opt_overlap_check_template && opt_overlap_check && @@ -704,6 +702,10 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, goto fail; } + /* + * Start updating fields in BDRVQcowState. + * After this point no failure is allowed any more. + */ s->overlap_check = 0; for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { /* overlap-check defines a template bitmask, but every flag may be @@ -713,12 +715,23 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, overlap_check_template & (1 << i)) << i; } - if (s->use_lazy_refcounts && s->qcow_version < 3) { - error_setg(errp, "Lazy refcounts require a qcow2 image with at least " - "qemu 1.1 compatibility level"); - ret = -EINVAL; - goto fail; - } + s->l2_table_cache = l2_table_cache; + s->refcount_block_cache = refcount_block_cache; + + s->use_lazy_refcounts = use_lazy_refcounts; + + s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; + s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; + s->discard_passthrough[QCOW2_DISCARD_REQUEST] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, + flags & BDRV_O_UNMAP); + s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); + s->discard_passthrough[QCOW2_DISCARD_OTHER] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); + + s->cache_clean_interval = cache_clean_interval; + cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); ret = 0; fail: -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 09:27:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwRp-0004nG-MF for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:27:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRl-0004f7-I3 for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwRk-0005VE-EW for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53886) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRk-0005Uw-0V; Mon, 07 Sep 2015 09:26:56 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id AF5EBA8D; Mon, 7 Sep 2015 13:26:55 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87DQN55001488; Mon, 7 Sep 2015 09:26:53 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 15:26:18 +0200 Message-Id: <1441632381-26638-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1441632381-26638-1-git-send-email-kwolf@redhat.com> References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v3 10/13] qcow2: Make qcow2_update_options() suitable for transactions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:26:59 -0000 Before we can allow updating options at runtime with bdrv_reopen(), we need to split the function into prepare/commit/abort parts. Signed-off-by: Kevin Wolf --- block/qcow2.c | 113 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 73 insertions(+), 40 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 226b1b1..eb379c1 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -589,18 +589,25 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, } } -static int qcow2_update_options(BlockDriverState *bs, QDict *options, - int flags, Error **errp) +typedef struct Qcow2ReopenState { + Qcow2Cache *l2_table_cache; + Qcow2Cache *refcount_block_cache; + bool use_lazy_refcounts; + int overlap_check; + bool discard_passthrough[QCOW2_DISCARD_MAX]; + uint64_t cache_clean_interval; +} Qcow2ReopenState; + +static int qcow2_update_options_prepare(BlockDriverState *bs, + Qcow2ReopenState *r, + QDict *options, int flags, + Error **errp) { BDRVQcowState *s = bs->opaque; QemuOpts *opts = NULL; const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; - Qcow2Cache *l2_table_cache = NULL; - Qcow2Cache *refcount_block_cache = NULL; - uint64_t cache_clean_interval; - bool use_lazy_refcounts; int i; Error *local_err = NULL; int ret; @@ -643,27 +650,27 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, } /* alloc L2 table/refcount block cache */ - l2_table_cache = qcow2_cache_create(bs, l2_cache_size); - refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); - if (l2_table_cache == NULL || refcount_block_cache == NULL) { + r->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); + r->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); + if (r->l2_table_cache == NULL || r->refcount_block_cache == NULL) { error_setg(errp, "Could not allocate metadata caches"); ret = -ENOMEM; goto fail; } /* New interval for cache cleanup timer */ - cache_clean_interval = + r->cache_clean_interval = qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0); - if (cache_clean_interval > UINT_MAX) { + if (r->cache_clean_interval > UINT_MAX) { error_setg(errp, "Cache clean interval too big"); ret = -EINVAL; goto fail; } /* Enable lazy_refcounts according to image and command line options */ - use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, + r->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); - if (use_lazy_refcounts && s->qcow_version < 3) { + if (r->use_lazy_refcounts && s->qcow_version < 3) { error_setg(errp, "Lazy refcounts require a qcow2 image with at least " "qemu 1.1 compatibility level"); ret = -EINVAL; @@ -702,49 +709,75 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, goto fail; } - /* - * Start updating fields in BDRVQcowState. - * After this point no failure is allowed any more. - */ - s->overlap_check = 0; + r->overlap_check = 0; for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { /* overlap-check defines a template bitmask, but every flag may be * overwritten through the associated boolean option */ - s->overlap_check |= + r->overlap_check |= qemu_opt_get_bool(opts, overlap_bool_option_names[i], overlap_check_template & (1 << i)) << i; } - s->l2_table_cache = l2_table_cache; - s->refcount_block_cache = refcount_block_cache; - - s->use_lazy_refcounts = use_lazy_refcounts; - - s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; - s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; - s->discard_passthrough[QCOW2_DISCARD_REQUEST] = + r->discard_passthrough[QCOW2_DISCARD_NEVER] = false; + r->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; + r->discard_passthrough[QCOW2_DISCARD_REQUEST] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, flags & BDRV_O_UNMAP); - s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = + r->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); - s->discard_passthrough[QCOW2_DISCARD_OTHER] = + r->discard_passthrough[QCOW2_DISCARD_OTHER] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); - s->cache_clean_interval = cache_clean_interval; - cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); - ret = 0; fail: - if (ret < 0) { - if (l2_table_cache) { - qcow2_cache_destroy(bs, l2_table_cache); - } - if (refcount_block_cache) { - qcow2_cache_destroy(bs, refcount_block_cache); - } - } qemu_opts_del(opts); opts = NULL; + return ret; +} + +static void qcow2_update_options_commit(BlockDriverState *bs, + Qcow2ReopenState *r) +{ + BDRVQcowState *s = bs->opaque; + int i; + + s->l2_table_cache = r->l2_table_cache; + s->refcount_block_cache = r->refcount_block_cache; + + s->overlap_check = r->overlap_check; + s->use_lazy_refcounts = r->use_lazy_refcounts; + + for (i = 0; i < QCOW2_DISCARD_MAX; i++) { + s->discard_passthrough[i] = r->discard_passthrough[i]; + } + + s->cache_clean_interval = r->cache_clean_interval; + cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); +} + +static void qcow2_update_options_abort(BlockDriverState *bs, + Qcow2ReopenState *r) +{ + if (r->l2_table_cache) { + qcow2_cache_destroy(bs, r->l2_table_cache); + } + if (r->refcount_block_cache) { + qcow2_cache_destroy(bs, r->refcount_block_cache); + } +} + +static int qcow2_update_options(BlockDriverState *bs, QDict *options, + int flags, Error **errp) +{ + Qcow2ReopenState r = {}; + int ret; + + ret = qcow2_update_options_prepare(bs, &r, options, flags, errp); + if (ret >= 0) { + qcow2_update_options_commit(bs, &r); + } else { + qcow2_update_options_abort(bs, &r); + } return ret; } -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 09:26:56 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwRk-0004cX-Eh for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:26:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRi-0004ad-QS for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwRh-0005SF-N5 for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58187) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRh-0005SB-J8; Mon, 07 Sep 2015 09:26:53 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 4FC4EC0B9892; Mon, 7 Sep 2015 13:26:53 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87DQN54001488; Mon, 7 Sep 2015 09:26:49 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 15:26:17 +0200 Message-Id: <1441632381-26638-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1441632381-26638-1-git-send-email-kwolf@redhat.com> References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v3 09/13] qcow2: Fix memory leak in qcow2_update_options() error path X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:26:55 -0000 Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 923b9dd..226b1b1 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -597,8 +597,8 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; - Qcow2Cache *l2_table_cache; - Qcow2Cache *refcount_block_cache; + Qcow2Cache *l2_table_cache = NULL; + Qcow2Cache *refcount_block_cache = NULL; uint64_t cache_clean_interval; bool use_lazy_refcounts; int i; @@ -735,6 +735,14 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, ret = 0; fail: + if (ret < 0) { + if (l2_table_cache) { + qcow2_cache_destroy(bs, l2_table_cache); + } + if (refcount_block_cache) { + qcow2_cache_destroy(bs, refcount_block_cache); + } + } qemu_opts_del(opts); opts = NULL; -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 09:27:07 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwRv-0004xR-D6 for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:27:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55631) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRs-0004t0-U8 for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:27:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwRp-0005ZO-LG for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:27:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52023) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRp-0005ZI-Gy; Mon, 07 Sep 2015 09:27:01 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 11C5432B39D; Mon, 7 Sep 2015 13:27:01 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87DQN57001488; Mon, 7 Sep 2015 09:26:58 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 15:26:20 +0200 Message-Id: <1441632381-26638-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1441632381-26638-1-git-send-email-kwolf@redhat.com> References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v3 12/13] qemu-iotests: Reopen qcow2 with lazy-refcounts change X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:27:06 -0000 Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- tests/qemu-iotests/039 | 27 +++++++++++++++++++++++++++ tests/qemu-iotests/039.out | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 index 617f397..9e9b379 100755 --- a/tests/qemu-iotests/039 +++ b/tests/qemu-iotests/039 @@ -147,6 +147,33 @@ $PYTHON qcow2.py "$TEST_IMG".base dump-header | grep incompatible_features _check_test_img TEST_IMG="$TEST_IMG".base _check_test_img +echo +echo "== Changing lazy_refcounts setting at runtime ==" + +IMGOPTS="compat=1.1,lazy_refcounts=off" +_make_test_img $size + +$QEMU_IO -c "reopen -o lazy-refcounts=on" \ + -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ + | _filter_qemu_io + +# The dirty bit must be set +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +_check_test_img + +IMGOPTS="compat=1.1,lazy_refcounts=on" +_make_test_img $size + +$QEMU_IO -c "reopen -o lazy-refcounts=off" \ + -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ + | _filter_qemu_io + +# The dirty bit must not be set +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +_check_test_img + # success, all done echo "*** done" diff --git a/tests/qemu-iotests/039.out b/tests/qemu-iotests/039.out index b055670..39859b2 100644 --- a/tests/qemu-iotests/039.out +++ b/tests/qemu-iotests/039.out @@ -74,4 +74,22 @@ incompatible_features 0x0 incompatible_features 0x0 No errors were found on the image. No errors were found on the image. + +== Changing lazy_refcounts setting at runtime == +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) +incompatible_features 0x1 +ERROR cluster 5 refcount=0 reference=1 +ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0 + +2 errors were found on the image. +Data may be corrupted, or further writes to the image may corrupt it. +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) +incompatible_features 0x0 +No errors were found on the image. *** done -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 09:27:10 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwRy-00052b-ML for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:27:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRt-0004uZ-T6 for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:27:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwRs-0005d9-DM for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:27:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38695) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRs-0005cT-3M; Mon, 07 Sep 2015 09:27:04 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id CF6BC80091; Mon, 7 Sep 2015 13:27:03 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87DQN58001488; Mon, 7 Sep 2015 09:27:01 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 15:26:21 +0200 Message-Id: <1441632381-26638-14-git-send-email-kwolf@redhat.com> In-Reply-To: <1441632381-26638-1-git-send-email-kwolf@redhat.com> References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v3 13/13] qemu-iotests: More qcow2 reopen tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:27:07 -0000 Signed-off-by: Kevin Wolf --- tests/qemu-iotests/137 | 145 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/137.out | 42 +++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 188 insertions(+) create mode 100755 tests/qemu-iotests/137 create mode 100644 tests/qemu-iotests/137.out diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 new file mode 100755 index 0000000..9a6597c --- /dev/null +++ b/tests/qemu-iotests/137 @@ -0,0 +1,145 @@ +#!/bin/bash +# +# Test qcow2 reopen +# +# Copyright (C) 2015 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=kwolf@redhat.com + +seq="$(basename $0)" +echo "QA output created by $seq" + +here="$PWD" +tmp=/tmp/$$ +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +_supported_fmt qcow2 +_supported_proto generic +_supported_os Linux + + +_make_test_img 64M + +echo === Try setting valid values for all options === +echo + +# Try all options and then check that all of the basic I/O operations still +# work on this image. +$QEMU_IO \ + -c "reopen -o lazy-refcounts=on,pass-discard-request=on" \ + -c "reopen -o lazy-refcounts=off,pass-discard-request=off" \ + -c "reopen -o pass-discard-snapshot=on,pass-discard-other=on" \ + -c "reopen -o pass-discard-snapshot=off,pass-discard-other=off" \ + -c "reopen -o overlap-check=all" \ + -c "reopen -o overlap-check=none" \ + -c "reopen -o overlap-check=cached" \ + -c "reopen -o overlap-check=constant" \ + -c "reopen -o overlap-check.template=all" \ + -c "reopen -o overlap-check.template=none" \ + -c "reopen -o overlap-check.template=cached" \ + -c "reopen -o overlap-check.template=constant" \ + -c "reopen -o overlap-check.main-header=on" \ + -c "reopen -o overlap-check.main-header=off" \ + -c "reopen -o overlap-check.active-l1=on" \ + -c "reopen -o overlap-check.active-l1=off" \ + -c "reopen -o overlap-check.active-l2=on" \ + -c "reopen -o overlap-check.active-l2=off" \ + -c "reopen -o overlap-check.refcount-table=on" \ + -c "reopen -o overlap-check.refcount-table=off" \ + -c "reopen -o overlap-check.refcount-block=on" \ + -c "reopen -o overlap-check.refcount-block=off" \ + -c "reopen -o overlap-check.snapshot-table=on" \ + -c "reopen -o overlap-check.snapshot-table=off" \ + -c "reopen -o overlap-check.inactive-l1=on" \ + -c "reopen -o overlap-check.inactive-l1=off" \ + -c "reopen -o overlap-check.inactive-l2=on" \ + -c "reopen -o overlap-check.inactive-l2=off" \ + -c "reopen -o cache-size=1M" \ + -c "reopen -o l2-cache-size=512k" \ + -c "reopen -o refcount-cache-size=128k" \ + -c "reopen -o cache-clean-interval=5" \ + -c "reopen -o cache-clean-interval=0" \ + -c "reopen -o cache-clean-interval=10" \ + \ + -c "write -P 55 0 32M" \ + -c "read -P 55 0 32M" \ + -c "discard 0 32M" \ + -c "write -z 0 32M" \ + -c "read -P 0 0 32M" \ + \ + "$TEST_IMG" | _filter_qemu_io + + +echo +echo === Try setting some invalid values === +echo + +$QEMU_IO \ + -c "reopen -o lazy-refcounts=42" \ + -c "reopen -o cache-size=1M,l2-cache-size=64k,refcount-cache-size=64k" \ + -c "reopen -o cache-size=1M,l2-cache-size=2M" \ + -c "reopen -o cache-size=1M,refcount-cache-size=2M" \ + -c "reopen -o l2-cache-size=256T" \ + -c "reopen -o refcount-cache-size=256T" \ + -c "reopen -o overlap-check=constant,overlap-check.template=all" \ + -c "reopen -o overlap-check=blubb" \ + -c "reopen -o overlap-check.template=blubb" \ + -c "reopen -o cache-clean-interval=-1" \ + "$TEST_IMG" | _filter_qemu_io + +echo +echo === Test transaction semantics === +echo + +# Whether lazy-refcounts was actually enabled can easily be tested: Check if +# the dirty bit is set after a crash +$QEMU_IO \ + -c "reopen -o lazy-refcounts=on,overlap-check=blubb" \ + -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" \ + "$TEST_IMG" 2>&1 | _filter_qemu_io + +# The dirty bit must not be set +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features + +# Similarly we can test whether corruption detection has been enabled: +# Create L1/L2, overwrite first entry in refcount block, allocate something. +# Disabling the checks should fail, so the corruption must be detected. +_make_test_img 64M +$QEMU_IO -c "write 0 64k" "$TEST_IMG" | _filter_qemu_io +poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00" +$QEMU_IO \ + -c "reopen -o overlap-check=none,lazy-refcounts=42" \ + -c "write 64k 64k" \ + "$TEST_IMG" 2>&1 | _filter_qemu_io + +# success, all done +echo '*** done' +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/137.out b/tests/qemu-iotests/137.out new file mode 100644 index 0000000..cf55a41 --- /dev/null +++ b/tests/qemu-iotests/137.out @@ -0,0 +1,42 @@ +QA output created by 137 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 +=== Try setting valid values for all options === + +wrote 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +discard 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=== Try setting some invalid values === + +Parameter 'lazy-refcounts' expects 'on' or 'off' +cache-size, l2-cache-size and refcount-cache-size may not be set the same time +l2-cache-size may not exceed cache-size +refcount-cache-size may not exceed cache-size +L2 cache size too big +L2 cache size too big +Conflicting values for qcow2 options 'overlap-check' ('constant') and 'overlap-check.template' ('all') +Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all +Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all +Cache clean interval too big + +=== Test transaction semantics === + +Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) +incompatible_features 0x0 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Parameter 'lazy-refcounts' expects 'on' or 'off' +qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with qcow2_header); further corruption events will be suppressed +write failed: Input/output error +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index c430b6c..3a6a8f0 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -134,3 +134,4 @@ 132 rw auto quick 134 rw auto quick 135 rw auto +137 rw auto -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 09:26:39 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwRT-00047B-9h for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:26:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRO-00043U-7k for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwRN-0004y3-Hm for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58117) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRN-0004xl-Dm; Mon, 07 Sep 2015 09:26:33 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 27097C0B9862; Mon, 7 Sep 2015 13:26:33 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87DQN4v001488; Mon, 7 Sep 2015 09:26:30 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 15:26:10 +0200 Message-Id: <1441632381-26638-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1441632381-26638-1-git-send-email-kwolf@redhat.com> References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v3 02/13] qemu-io: Remove duplicate 'open' error message X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:26:35 -0000 qemu_opts_parse_noisily() already prints an error message with the exact reason why the parsing failed. No need to add another less specific one. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- qemu-io.c | 1 - 1 file changed, 1 deletion(-) diff --git a/qemu-io.c b/qemu-io.c index f1e3a67..269f17c 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -156,7 +156,6 @@ static int open_f(BlockBackend *blk, int argc, char **argv) break; case 'o': if (!qemu_opts_parse_noisily(&empty_opts, optarg, false)) { - printf("could not parse option list -- %s\n", optarg); qemu_opts_reset(&empty_opts); return 0; } -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 09:26:39 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwRT-00046z-6X for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:26:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRN-00043L-Aw for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwRL-0004wx-1B for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50733) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRK-0004wr-QY; Mon, 07 Sep 2015 09:26:30 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 771BE49; Mon, 7 Sep 2015 13:26:30 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87DQN4u001488; Mon, 7 Sep 2015 09:26:28 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 15:26:09 +0200 Message-Id: <1441632381-26638-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1441632381-26638-1-git-send-email-kwolf@redhat.com> References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v3 01/13] block: Allow specifying driver-specific options to reopen X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:26:34 -0000 Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block.c | 42 +++++++++++++++++++++++++++++++++++++++--- block/commit.c | 4 ++-- include/block/block.h | 4 +++- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index 910e004..e859fd0 100644 --- a/block.c +++ b/block.c @@ -1636,6 +1636,9 @@ typedef struct BlockReopenQueueEntry { * * bs is the BlockDriverState to add to the reopen queue. * + * options contains the changed options for the associated bs + * (the BlockReopenQueue takes ownership) + * * flags contains the open flags for the associated bs * * returns a pointer to bs_queue, which is either the newly allocated @@ -1643,18 +1646,28 @@ typedef struct BlockReopenQueueEntry { * */ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, - BlockDriverState *bs, int flags) + BlockDriverState *bs, + QDict *options, int flags) { assert(bs != NULL); BlockReopenQueueEntry *bs_entry; BdrvChild *child; + QDict *old_options; if (bs_queue == NULL) { bs_queue = g_new0(BlockReopenQueue, 1); QSIMPLEQ_INIT(bs_queue); } + if (!options) { + options = qdict_new(); + } + + old_options = qdict_clone_shallow(bs->options); + qdict_join(options, old_options, false); + QDECREF(old_options); + /* bdrv_open() masks this flag out */ flags &= ~BDRV_O_PROTOCOL; @@ -1666,13 +1679,15 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, } child_flags = child->role->inherit_flags(flags); - bdrv_reopen_queue(bs_queue, child->bs, child_flags); + /* TODO Pass down child flags (backing.*, extents.*, ...) */ + bdrv_reopen_queue(bs_queue, child->bs, NULL, child_flags); } bs_entry = g_new0(BlockReopenQueueEntry, 1); QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry); bs_entry->state.bs = bs; + bs_entry->state.options = options; bs_entry->state.flags = flags; return bs_queue; @@ -1725,6 +1740,7 @@ cleanup: if (ret && bs_entry->prepared) { bdrv_reopen_abort(&bs_entry->state); } + QDECREF(bs_entry->state.options); g_free(bs_entry); } g_free(bs_queue); @@ -1737,7 +1753,7 @@ int bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp) { int ret = -1; Error *local_err = NULL; - BlockReopenQueue *queue = bdrv_reopen_queue(NULL, bs, bdrv_flags); + BlockReopenQueue *queue = bdrv_reopen_queue(NULL, bs, NULL, bdrv_flags); ret = bdrv_reopen_multiple(queue, &local_err); if (local_err != NULL) { @@ -1813,6 +1829,26 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, goto error; } + /* Options that are not handled are only okay if they are unchanged + * compared to the old state. It is expected that some options are only + * used for the initial open, but not reopen (e.g. filename) */ + if (qdict_size(reopen_state->options)) { + const QDictEntry *entry = qdict_first(reopen_state->options); + + do { + QString *new_obj = qobject_to_qstring(entry->value); + const char *new = qstring_get_str(new_obj); + const char *old = qdict_get_try_str(reopen_state->bs->options, + entry->key); + + if (!old || strcmp(new, old)) { + error_setg(errp, "Cannot change the option '%s'", entry->key); + ret = -EINVAL; + goto error; + } + } while ((entry = qdict_next(reopen_state->options, entry))); + } + ret = 0; error: diff --git a/block/commit.c b/block/commit.c index 7312a5b..d12e26f 100644 --- a/block/commit.c +++ b/block/commit.c @@ -236,11 +236,11 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base, /* convert base & overlay_bs to r/w, if necessary */ if (!(orig_base_flags & BDRV_O_RDWR)) { - reopen_queue = bdrv_reopen_queue(reopen_queue, base, + reopen_queue = bdrv_reopen_queue(reopen_queue, base, NULL, orig_base_flags | BDRV_O_RDWR); } if (!(orig_overlay_flags & BDRV_O_RDWR)) { - reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs, + reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs, NULL, orig_overlay_flags | BDRV_O_RDWR); } if (reopen_queue) { diff --git a/include/block/block.h b/include/block/block.h index c7fdbaa..4ceceed 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -147,6 +147,7 @@ typedef QSIMPLEQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue; typedef struct BDRVReopenState { BlockDriverState *bs; int flags; + QDict *options; void *opaque; } BDRVReopenState; @@ -218,7 +219,8 @@ int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp); int bdrv_open(BlockDriverState **pbs, const char *filename, const char *reference, QDict *options, int flags, Error **errp); BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, - BlockDriverState *bs, int flags); + BlockDriverState *bs, + QDict *options, int flags); int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp); int bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp); int bdrv_reopen_prepare(BDRVReopenState *reopen_state, -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 09:27:05 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwRt-0004uM-Rd for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:27:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRn-0004j9-TM for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:27:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwRm-0005Xs-OP for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:26:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwRm-0005Wi-Ht; Mon, 07 Sep 2015 09:26:58 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 4BAE48EA23; Mon, 7 Sep 2015 13:26:58 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87DQN56001488; Mon, 7 Sep 2015 09:26:56 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 15:26:19 +0200 Message-Id: <1441632381-26638-12-git-send-email-kwolf@redhat.com> In-Reply-To: <1441632381-26638-1-git-send-email-kwolf@redhat.com> References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-block] [PATCH v3 11/13] qcow2: Support updating driver-specific options in reopen X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:27:05 -0000 For updating the cache sizes or disabling lazy refcounts there is a bit more to do than just changing the variables, but otherwise we're all set for changing options during bdrv_reopen(). Just implement the missing pieces and hook the functions up in bdrv_reopen(). Signed-off-by: Kevin Wolf --- block/qcow2.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index eb379c1..23493d4 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -649,7 +649,24 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, goto fail; } - /* alloc L2 table/refcount block cache */ + /* alloc new L2 table/refcount block cache, flush old one */ + if (s->l2_table_cache) { + ret = qcow2_cache_flush(bs, s->l2_table_cache); + if (ret) { + error_setg_errno(errp, -ret, "Failed to flush the L2 table cache"); + goto fail; + } + } + + if (s->refcount_block_cache) { + ret = qcow2_cache_flush(bs, s->refcount_block_cache); + if (ret) { + error_setg_errno(errp, -ret, + "Failed to flush the refcount block cache"); + goto fail; + } + } + r->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); r->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); if (r->l2_table_cache == NULL || r->refcount_block_cache == NULL) { @@ -660,14 +677,15 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, /* New interval for cache cleanup timer */ r->cache_clean_interval = - qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0); + qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, + s->cache_clean_interval); if (r->cache_clean_interval > UINT_MAX) { error_setg(errp, "Cache clean interval too big"); ret = -EINVAL; goto fail; } - /* Enable lazy_refcounts according to image and command line options */ + /* lazy-refcounts; flush if going from enabled to disabled */ r->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); if (r->use_lazy_refcounts && s->qcow_version < 3) { @@ -677,6 +695,14 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, goto fail; } + if (s->use_lazy_refcounts && !r->use_lazy_refcounts) { + ret = qcow2_mark_clean(bs); + if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to disable lazy refcounts"); + goto fail; + } + } + /* Overlap check options */ opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); @@ -741,6 +767,12 @@ static void qcow2_update_options_commit(BlockDriverState *bs, BDRVQcowState *s = bs->opaque; int i; + if (s->l2_table_cache) { + qcow2_cache_destroy(bs, s->l2_table_cache); + } + if (s->refcount_block_cache) { + qcow2_cache_destroy(bs, s->refcount_block_cache); + } s->l2_table_cache = r->l2_table_cache; s->refcount_block_cache = r->refcount_block_cache; @@ -751,8 +783,11 @@ static void qcow2_update_options_commit(BlockDriverState *bs, s->discard_passthrough[i] = r->discard_passthrough[i]; } - s->cache_clean_interval = r->cache_clean_interval; - cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); + if (s->cache_clean_interval != r->cache_clean_interval) { + cache_clean_timer_del(bs); + s->cache_clean_interval = r->cache_clean_interval; + cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); + } } static void qcow2_update_options_abort(BlockDriverState *bs, @@ -1199,26 +1234,52 @@ static int qcow2_set_key(BlockDriverState *bs, const char *key) return 0; } -/* We have no actual commit/abort logic for qcow2, but we need to write out any - * unwritten data if we reopen read-only. */ static int qcow2_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { + Qcow2ReopenState *r; int ret; + r = g_new0(Qcow2ReopenState, 1); + state->opaque = r; + + ret = qcow2_update_options_prepare(state->bs, r, state->options, + state->flags, errp); + if (ret < 0) { + goto fail; + } + + /* We need to write out any unwritten data if we reopen read-only. */ if ((state->flags & BDRV_O_RDWR) == 0) { ret = bdrv_flush(state->bs); if (ret < 0) { - return ret; + goto fail; } ret = qcow2_mark_clean(state->bs); if (ret < 0) { - return ret; + goto fail; } } return 0; + +fail: + qcow2_update_options_abort(state->bs, r); + g_free(r); + return ret; +} + +static void qcow2_reopen_commit(BDRVReopenState *state) +{ + qcow2_update_options_commit(state->bs, state->opaque); + g_free(state->opaque); +} + +static void qcow2_reopen_abort(BDRVReopenState *state) +{ + qcow2_update_options_abort(state->bs, state->opaque); + g_free(state->opaque); } static int64_t coroutine_fn qcow2_co_get_block_status(BlockDriverState *bs, @@ -3082,6 +3143,8 @@ BlockDriver bdrv_qcow2 = { .bdrv_open = qcow2_open, .bdrv_close = qcow2_close, .bdrv_reopen_prepare = qcow2_reopen_prepare, + .bdrv_reopen_commit = qcow2_reopen_commit, + .bdrv_reopen_abort = qcow2_reopen_abort, .bdrv_create = qcow2_create, .bdrv_has_zero_init = bdrv_has_zero_init_1, .bdrv_co_get_block_status = qcow2_co_get_block_status, -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 09:43:39 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYwhv-0000qe-Bi for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 09:43:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwhs-0000lm-Gm for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:43:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYwhr-0005Hq-HN for qemu-block@nongnu.org; Mon, 07 Sep 2015 09:43:36 -0400 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:32778) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYwhm-0005El-Bm; Mon, 07 Sep 2015 09:43:30 -0400 Received: by wiclk2 with SMTP id lk2so89387414wic.0; Mon, 07 Sep 2015 06:43:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=ZUPRvGu9bl8mOjg3c3VoKCFwUMGxZJ+Nf3CiEn7klzg=; b=V/oT9cwV4u4hL8w5c3NcY+zmXUMngALnrgm9NQlcfCiMzOYn+9fZGQaoQim3YfQmkP kzpQwog69X821VRUb8sCwrNeWITL5aL7QKgaOQMOil6yxOi5+lkH9xfxGCcIjQm3y2st xhDqcwgZo6o9VDBETwbVnokGadniZHYXz3oKHy6Znb2uAZ00yZrhVdwfbP3dvdrp7IhW BHRa0htyM4DRi6O4gc3ZJv7TA3uRUT5JD2+Wow9onfbDHqSvSWEg5m59UF7KVMvFUQ5S zyoZR4jDBtSzAOeCV/EXTbW+1jL51pUsGhUBCsAjYAL3tunRtgbv9GKVBDwDMHABUFxH qkag== X-Received: by 10.180.106.3 with SMTP id gq3mr34738252wib.50.1441633409797; Mon, 07 Sep 2015 06:43:29 -0700 (PDT) Received: from localhost (host86-153-218-221.range86-153.btcentralplus.com. [86.153.218.221]) by smtp.gmail.com with ESMTPSA id xs1sm20186781wjc.7.2015.09.07.06.43.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2015 06:43:28 -0700 (PDT) Date: Mon, 7 Sep 2015 14:43:26 +0100 From: Stefan Hajnoczi To: Peter Lieven Message-ID: <20150907134326.GI9593@stefanha-thinkpad.redhat.com> References: <1440058448-27847-1-git-send-email-pl@kamp.de> <1440058448-27847-3-git-send-email-pl@kamp.de> <20150903165928.GF18405@stefanha-thinkpad.redhat.com> <55EC063A.6080501@kamp.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55EC063A.6080501@kamp.de> User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22b Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 2/2] ide/atapi: partially avoid deadlock if the storage backend is dead X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 13:43:37 -0000 On Sun, Sep 06, 2015 at 11:24:10AM +0200, Peter Lieven wrote: > > Taking a step back, what are the semantics of writing !(val & > > BM_CMD_START)? Is the device guaranteed to cancel/complete requests > > during the register write? > > I have to check that. John, do you have an idea? > > Stefan, or do you have a better approach for getting rid of the bdrv_drain_all > in this piece of code? What's needed is an asynchronous approach that honors the semantics of the Start/Stop bit. >From "Programming Interface for Bus Master IDE Controller", Revision 1.0: "Start/Stop Bus Master: Writing a '1' to this bit enables bus master operation of the controller. Bus master operation begins when this bit is detected changing from a zero to a one. The controller will transfer data between the IDE device and memory only when this bit is set. Master operation can be halted by writing a '0' to this bit. All state information is lost when a '0' is written; Master mode operation cannot be stopped and then resumed. If this bit is reset while bus master operation is still active (i.e., the Bus Master IDE Active bit of the Bus Master IDE Status register for that IDE channel is set) and the drive has not yet finished its data transfer (The Interupt bit in the Bus Master IDE Status register for that IDE channel is not set), the bus master command is said to be aborted and data transfered from the drive may be discarded before being written to system memory. This bit is intended to be reset after the data transfer is completed, as indicated by either the Bus Master IDE Active bit or the Interrupt bit of the Bus Master IDE Status register for that IDE channel being set, or both." bdrv_aio_cancel() can be used to nudge the request to cancel. The completion function is still called at some later point - and it could take an arbitrary amount of time before the request finishes. >From the IDE emulation perspective, there are two requirements: 1. After the Start bit has been cleared, no IDE state changes should occur due to the pending request. No interrupts should be raised and no registers should change when the request completes (success/error/cancelled). Also, the guest should be able to set the bit again and submit a new request. 2. No guest memory should be touched by a running request after the bit is cleared. QEMU needs to go through bounce buffers in all cases instead of doing zero copy (mapping the PRDT). Using bounce buffers should be doable but you need to check the IDE code paths (PIO, DMA, and ATAPI) reachable from hw/ide/pci.c. There's also a denial-of-service scenario where the guest repeatedly submits an I/O requests and then clears the Start/Stop bit. That would cause QEMU to build up many pending I/O requests and bounce buffers. That needs to be handled, for example by punishing the guest by failing news I/O if there are more than 16 cancelled requests pending. I'm interested in other ideas, but I think the solution space for synchronous approaches that implement the semantics correctly is small. I can think of a few other approaches that are easier to implement, perform better, etc but they aren't correct. Stefan From MAILER-DAEMON Mon Sep 07 10:06:12 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYx3k-0003ed-6w for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 10:06:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYx3h-0003bO-HL for qemu-block@nongnu.org; Mon, 07 Sep 2015 10:06:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYx3f-00075G-OT for qemu-block@nongnu.org; Mon, 07 Sep 2015 10:06:09 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:37366 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYx3f-00074x-Dv for qemu-block@nongnu.org; Mon, 07 Sep 2015 10:06:07 -0400 Received: (qmail 24101 invoked by uid 89); 7 Sep 2015 14:06:06 -0000 Received: from [195.62.97.28] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.7/20886. hbedv: 8.3.34.18/7.12.7.52. spamassassin: 3.4.0. Clear:RC:1(195.62.97.28):SA:0(-2.0/5.0):. Processed in 6.013244 secs); 07 Sep 2015 14:06:06 -0000 Received: from smtp.kamp.de (HELO submission.kamp.de) ([195.62.97.28]) by mx01.kamp.de with ESMTPS (DHE-RSA-AES256-SHA encrypted); 7 Sep 2015 14:05:59 -0000 X-GL_Whitelist: yes Received: (qmail 13275 invoked from network); 7 Sep 2015 13:54:21 -0000 Received: from ac68.vpn.kamp-intra.net (HELO ?172.20.250.68?) (pl@kamp.de@172.20.250.68) by submission.kamp.de with ESMTPS (DHE-RSA-AES128-SHA encrypted) ESMTPA; 7 Sep 2015 13:54:21 -0000 Message-ID: <55ED99C7.1070402@kamp.de> Date: Mon, 07 Sep 2015 16:05:59 +0200 From: Peter Lieven User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Stefan Hajnoczi References: <1440058448-27847-1-git-send-email-pl@kamp.de> <1440058448-27847-3-git-send-email-pl@kamp.de> <20150903165928.GF18405@stefanha-thinkpad.redhat.com> <55EC063A.6080501@kamp.de> <20150907134326.GI9593@stefanha-thinkpad.redhat.com> In-Reply-To: <20150907134326.GI9593@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 2/2] ide/atapi: partially avoid deadlock if the storage backend is dead X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 14:06:10 -0000 Am 07.09.2015 um 15:43 schrieb Stefan Hajnoczi: > On Sun, Sep 06, 2015 at 11:24:10AM +0200, Peter Lieven wrote: >>> Taking a step back, what are the semantics of writing !(val & >>> BM_CMD_START)? Is the device guaranteed to cancel/complete requests >>> during the register write? >> I have to check that. John, do you have an idea? >> >> Stefan, or do you have a better approach for getting rid of the bdrv_drain_all >> in this piece of code? > What's needed is an asynchronous approach that honors the semantics of > the Start/Stop bit. > > From "Programming Interface for Bus Master IDE Controller", Revision 1.0: > > "Start/Stop Bus Master: Writing a '1' to this bit enables bus master > operation of the controller. Bus master operation begins when this bit > is detected changing from a zero to a one. The controller will transfer > data between the IDE device and memory only when this bit is set. > Master operation can be halted by writing a '0' to this bit. All state > information is lost when a '0' is written; Master mode operation cannot > be stopped and then resumed. If this bit is reset while bus master > operation is still active (i.e., the Bus Master IDE Active bit of the > Bus Master IDE Status register for that IDE channel is set) and the > drive has not yet finished its data transfer (The Interupt bit in the > Bus Master IDE Status register for that IDE channel is not set), the bus > master command is said to be aborted and data transfered from the drive > may be discarded before being written to system memory. This bit is > intended to be reset after the data transfer is completed, as indicated > by either the Bus Master IDE Active bit or the Interrupt bit of the Bus > Master IDE Status register for that IDE channel being set, or both." > > bdrv_aio_cancel() can be used to nudge the request to cancel. The > completion function is still called at some later point - and it could > take an arbitrary amount of time before the request finishes. > > From the IDE emulation perspective, there are two requirements: > > 1. After the Start bit has been cleared, no IDE state changes should > occur due to the pending request. No interrupts should be raised and > no registers should change when the request completes > (success/error/cancelled). Also, the guest should be able to set the > bit again and submit a new request. I think my approach should fullfil this requirement already The callback into the IDE layer is set to NULL. > > 2. No guest memory should be touched by a running request after the bit > is cleared. QEMU needs to go through bounce buffers in all cases > instead of doing zero copy (mapping the PRDT). > > Using bounce buffers should be doable but you need to check the IDE > code paths (PIO, DMA, and ATAPI) reachable from hw/ide/pci.c. > There's also a denial-of-service scenario where the guest repeatedly > submits an I/O requests and then clears the Start/Stop bit. That > would cause QEMU to build up many pending I/O requests and bounce > buffers. That needs to be handled, for example by punishing the > guest by failing news I/O if there are more than 16 cancelled > requests pending. This sounds doable. I will look into this. Peter From MAILER-DAEMON Mon Sep 07 10:56:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYxpx-0006DV-Cz for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 10:56:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYxpo-0006A2-AO for qemu-block@nongnu.org; Mon, 07 Sep 2015 10:55:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYxpm-00051z-VN for qemu-block@nongnu.org; Mon, 07 Sep 2015 10:55:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYxpm-00051v-KC; Mon, 07 Sep 2015 10:55:50 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 080BA80092; Mon, 7 Sep 2015 14:55:50 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t87EtlUL021982; Mon, 7 Sep 2015 10:55:48 -0400 Date: Mon, 7 Sep 2015 16:55:47 +0200 From: Kevin Wolf To: Alberto Garcia Message-ID: <20150907145547.GD5529@noname.redhat.com> References: <55E9ADC9.3000404@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v2 2/2] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 14:55:56 -0000 Am 07.09.2015 um 13:31 hat Alberto Garcia geschrieben: > On Fri 04 Sep 2015 04:42:17 PM CEST, Eric Blake wrote: > >> + if (snapshot_ref) { > >> + if (!bdrv_lookup_bs(snapshot_ref, snapshot_ref, &local_err)) { > >> error_propagate(errp, local_err); > >> return; > >> } > >> } > > > > Shouldn't you also check that snapshot_ref does not currently have a > > backing BDS (as it is the act of creating the snapshot that sets the > > current device as the backing of the snapshot_ref BDS before altering > > the BB to point to snapshot_ref as its new BDS)? > > Wait, I actually think that it should have a backing BDS. This new > command is roughly equivalent to the 'existing' mode of the > 'blockdev-snapshot-sync' command, so the new image must be created > externally in both cases having the current image as its backing file. > > The difference is that 'blockdev-snapshot-sync' will open the new image > and not its backing chain (using the BDRV_O_NO_BACKING flag), but in > 'blockdev-snapshot' the image must be opened previously with > 'blockdev-add', which will open the whole chain. > > So I think that we should expect a backing image and we have to unref it > during the 'commit' part of the transaction (before bdrv_append()). This means that the images in the backing chain are opened twice before doing the bdrv_append(). This definitely includes the active layer as one example of an illegal setup, and with block jobs running on the backing files it might involve even more writable image files. I think Eric's approach is better, where we check the required conditions instead of adding magic to somehow transfer a questionable state into what we want. Of course, this means that we need to provide a way to actually fulfill the right conditions, and you might be right that it doesn't exist yet. Could the same effect as BDRV_O_NO_BACKING possibly be achieved with blockdev-add with something like '"backing": {}'? We might actually have the same problem in more places: In optional fields, we need to distinguish "use the default" from "I don't want any". Especially if we want to support reopen in QMP at some point, we need to figure this out (default is leaving options unchanged, but unsetting must be possible). Kevin From MAILER-DAEMON Mon Sep 07 11:06:25 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYy01-0004L0-Oa for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 11:06:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYxzw-0004C9-9X for qemu-block@nongnu.org; Mon, 07 Sep 2015 11:06:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYxzv-0003JU-Gt for qemu-block@nongnu.org; Mon, 07 Sep 2015 11:06:20 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:8208 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYxzp-0002xx-Az; Mon, 07 Sep 2015 11:06:13 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2C5BQD4pu1V/5tjdVtdGQEBAYMHqw8BAQEBAQUBgQsBmB2CVgKBMDsRAQEBAQEBAYEKhCQBAQMBOj8FCwsOEyUPASwbBog5DAHJDAEBAQEBBQIBH4YshUKFDAeELAEElVWncSaEAjyIfAEBAQ X-IPAS-Result: A2C5BQD4pu1V/5tjdVtdGQEBAYMHqw8BAQEBAQUBgQsBmB2CVgKBMDsRAQEBAQEBAYEKhCQBAQMBOj8FCwsOEyUPASwbBog5DAHJDAEBAQEBBQIBH4YshUKFDAeELAEElVWncSaEAjyIfAEBAQ X-IronPort-AV: E=Sophos;i="5.17,485,1437429600"; d="scan'208";a="17647976" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 07 Sep 2015 17:06:06 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZYxzi-0007th-76; Mon, 07 Sep 2015 17:06:06 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZYxzi-0006j2-0N; Mon, 07 Sep 2015 17:06:06 +0200 From: Alberto Garcia To: Kevin Wolf In-Reply-To: <20150907145547.GD5529@noname.redhat.com> References: <55E9ADC9.3000404@redhat.com> <20150907145547.GD5529@noname.redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Mon, 07 Sep 2015 17:06:05 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v2 2/2] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 15:06:21 -0000 On Mon 07 Sep 2015 04:55:47 PM CEST, Kevin Wolf wrote: > Of course, this means that we need to provide a way to actually > fulfill the right conditions, and you might be right that it doesn't > exist yet. Could the same effect as BDRV_O_NO_BACKING possibly be > achieved with blockdev-add with something like '"backing": {}'? I'm not sure it that would be the best API, but the overall idea looks good to me. Berto From MAILER-DAEMON Mon Sep 07 11:15:03 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYy8N-0000ip-2C for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 11:15:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYy8I-0000dA-OV for qemu-block@nongnu.org; Mon, 07 Sep 2015 11:14:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYy8D-0007XA-Mn for qemu-block@nongnu.org; Mon, 07 Sep 2015 11:14:58 -0400 Received: from mail-yk0-f172.google.com ([209.85.160.172]:33725) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYy8D-0007X6-G6 for qemu-block@nongnu.org; Mon, 07 Sep 2015 11:14:53 -0400 Received: by ykei199 with SMTP id i199so82678157yke.0 for ; Mon, 07 Sep 2015 08:14:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=892Thh+JEKSXS0Ri/hkLcfvWQYnRDj2Fv7wQpVkJ+3Y=; b=dgkHZViVDbjTbCSWuAmhye89YeI+iFYxwzexo4srsODkdc6v2ypiCbVKCqubZFa6Rd hyFtoWSe8N4JrmeKoCWvci+PODRGauNmgp9dKAKEHanPeln/A1tfMMS4M1YV5C4MfXbL Ec/RRD9GH7+QqHPjllk+GjLfYHzcMWyGphucfpYuLywmp0IzmPeVo0crlzEX7ejkm1wK Tb99wjHTKfbLqThGvtUTM+bAeHVnYt0ul9b6MUbK9WnJwmFkwwz2d/RU/G++SYSR/Wcr beBNRSdNzxKz6ozLT6CDRphFf/XCk/HBX1mLt6UOUGeTOq5OufCFwQCg+nnRKfF5hFTG +RZw== X-Gm-Message-State: ALoCoQnqQNkuzmgX9xVD/9CGpLbuyPbYMSeKftNgO9fMfxVIHkHEPzsWbZ62U+RMSGyFEAiWfgOu X-Received: by 10.129.50.73 with SMTP id y70mr19486772ywy.3.1441638457979; Mon, 07 Sep 2015 08:07:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.153.135 with HTTP; Mon, 7 Sep 2015 08:07:18 -0700 (PDT) In-Reply-To: <55ED8469.1010508@redhat.com> References: <1437741192-20955-1-git-send-email-peter.maydell@linaro.org> <55ED8469.1010508@redhat.com> From: Peter Maydell Date: Mon, 7 Sep 2015 16:07:18 +0100 Message-ID: To: Paolo Bonzini Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.160.172 Cc: Kevin Wolf , Qemu-block , Patch Tracking , "Michael S. Tsirkin" , QEMU Developers , Keith Busch Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 0/6] replace qemu_fls() with pow2ceil()/pow2floor() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 15:14:59 -0000 On 7 September 2015 at 13:34, Paolo Bonzini wrote: > > > On 07/09/2015 13:04, Peter Maydell wrote: >> Ping? >> >> Paolo, do you want to take these, should I just apply them >> to master, or what? > > Sorry, I thought you were applying these or pulling them through your > trees. Let me know if you still want me to take them. OK, I've applied this to master. thanks -- PMM From MAILER-DAEMON Mon Sep 07 11:15:12 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYy8W-0000vD-AY for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 11:15:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYy8R-0000pd-Py for qemu-block@nongnu.org; Mon, 07 Sep 2015 11:15:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYy8K-0007aW-28 for qemu-block@nongnu.org; Mon, 07 Sep 2015 11:15:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46100) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYy8J-0007aS-NG; Mon, 07 Sep 2015 11:15:00 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 3EAD28C1A1; Mon, 7 Sep 2015 15:14:59 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87FEuci023927; Mon, 7 Sep 2015 11:14:57 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Sep 2015 17:14:55 +0200 Message-Id: <1441638895-1445-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PATCH] qcow2: Rename BDRVQcowState to BDRVQcow2State X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 15:15:11 -0000 BDRVQcowState is already used by qcow1, and gdb is always confused which one to use. Rename the qcow2 one so they can be distinguished. Signed-off-by: Kevin Wolf --- block/qcow2-cache.c | 14 ++++----- block/qcow2-cluster.c | 48 +++++++++++++++---------------- block/qcow2-refcount.c | 58 ++++++++++++++++++------------------- block/qcow2-snapshot.c | 20 ++++++------- block/qcow2.c | 78 +++++++++++++++++++++++++------------------------- block/qcow2.h | 22 +++++++------- 6 files changed, 120 insertions(+), 120 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 046f5b8..7b14c5c 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -55,14 +55,14 @@ struct Qcow2Cache { static inline void *qcow2_cache_get_table_addr(BlockDriverState *bs, Qcow2Cache *c, int table) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; return (uint8_t *) c->table_array + (size_t) table * s->cluster_size; } static inline int qcow2_cache_get_table_idx(BlockDriverState *bs, Qcow2Cache *c, void *table) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; ptrdiff_t table_offset = (uint8_t *) table - (uint8_t *) c->table_array; int idx = table_offset / s->cluster_size; assert(idx >= 0 && idx < c->size && table_offset % s->cluster_size == 0); @@ -73,7 +73,7 @@ static void qcow2_cache_table_release(BlockDriverState *bs, Qcow2Cache *c, int i, int num_tables) { #if QEMU_MADV_DONTNEED != QEMU_MADV_INVALID - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; void *t = qcow2_cache_get_table_addr(bs, c, i); int align = getpagesize(); size_t mem_size = (size_t) s->cluster_size * num_tables; @@ -121,7 +121,7 @@ void qcow2_cache_clean_unused(BlockDriverState *bs, Qcow2Cache *c) Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; Qcow2Cache *c; c = g_new0(Qcow2Cache, 1); @@ -172,7 +172,7 @@ static int qcow2_cache_flush_dependency(BlockDriverState *bs, Qcow2Cache *c) static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret = 0; if (!c->entries[i].dirty || !c->entries[i].offset) { @@ -229,7 +229,7 @@ static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i) int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int result = 0; int ret; int i; @@ -306,7 +306,7 @@ int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c) static int qcow2_cache_do_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset, void **table, bool read_from_disk) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int i; int ret; int lookup_index; diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index b43f186..2975b83 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -32,7 +32,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, bool exact_size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int new_l1_size2, ret, i; uint64_t *new_l1_table; int64_t old_l1_table_offset, old_l1_size; @@ -148,7 +148,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, static int l2_load(BlockDriverState *bs, uint64_t l2_offset, uint64_t **l2_table) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret; ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void**) l2_table); @@ -163,7 +163,7 @@ static int l2_load(BlockDriverState *bs, uint64_t l2_offset, #define L1_ENTRIES_PER_SECTOR (512 / 8) int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t buf[L1_ENTRIES_PER_SECTOR] = { 0 }; int l1_start_index; int i, ret; @@ -203,7 +203,7 @@ int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index) static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t old_l2_offset; uint64_t *l2_table = NULL; int64_t l2_offset; @@ -339,7 +339,7 @@ static int count_contiguous_free_clusters(uint64_t nb_clusters, uint64_t *l2_tab /* The crypt function is compatible with the linux cryptoloop algorithm for < 4 GB images. NOTE: out_buf == in_buf is supported */ -int qcow2_encrypt_sectors(BDRVQcowState *s, int64_t sector_num, +int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t sector_num, uint8_t *out_buf, const uint8_t *in_buf, int nb_sectors, bool enc, Error **errp) @@ -387,7 +387,7 @@ static int coroutine_fn copy_sectors(BlockDriverState *bs, uint64_t cluster_offset, int n_start, int n_end) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QEMUIOVector qiov; struct iovec iov; int n, ret; @@ -469,7 +469,7 @@ out: int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, int *num, uint64_t *cluster_offset) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; unsigned int l2_index; uint64_t l1_index, l2_offset, *l2_table; int l1_bits, c; @@ -606,7 +606,7 @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset, uint64_t **new_l2_table, int *new_l2_index) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; unsigned int l2_index; uint64_t l1_index, l2_offset; uint64_t *l2_table = NULL; @@ -680,7 +680,7 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, uint64_t offset, int compressed_size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int l2_index, ret; uint64_t *l2_table; int64_t cluster_offset; @@ -725,7 +725,7 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, static int perform_cow(BlockDriverState *bs, QCowL2Meta *m, Qcow2COWRegion *r) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret; if (r->nb_sectors == 0) { @@ -754,7 +754,7 @@ static int perform_cow(BlockDriverState *bs, QCowL2Meta *m, Qcow2COWRegion *r) int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int i, j = 0, l2_index, ret; uint64_t *old_cluster, *l2_table; uint64_t cluster_offset = m->alloc_offset; @@ -837,7 +837,7 @@ err: * write, but require COW to be performed (this includes yet unallocated space, * which must copy from the backing file) */ -static int count_cow_clusters(BDRVQcowState *s, int nb_clusters, +static int count_cow_clusters(BDRVQcow2State *s, int nb_clusters, uint64_t *l2_table, int l2_index) { int i; @@ -883,7 +883,7 @@ out: static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset, uint64_t *cur_bytes, QCowL2Meta **m) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowL2Meta *old_alloc; uint64_t bytes = *cur_bytes; @@ -956,7 +956,7 @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset, static int handle_copied(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int l2_index; uint64_t cluster_offset; uint64_t *l2_table; @@ -1063,7 +1063,7 @@ out: static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, unsigned int *nb_clusters) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; trace_qcow2_do_alloc_clusters_offset(qemu_coroutine_self(), guest_offset, *host_offset, *nb_clusters); @@ -1111,7 +1111,7 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int l2_index; uint64_t *l2_table; uint64_t entry; @@ -1263,7 +1263,7 @@ fail: int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, int *num, uint64_t *host_offset, QCowL2Meta **m) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t start, remaining; uint64_t cluster_offset; uint64_t cur_bytes; @@ -1397,7 +1397,7 @@ static int decompress_buffer(uint8_t *out_buf, int out_buf_size, int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret, csize, nb_csectors, sector_offset; uint64_t coffset; @@ -1428,7 +1428,7 @@ int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) static int discard_single_l2(BlockDriverState *bs, uint64_t offset, unsigned int nb_clusters, enum qcow2_discard_type type, bool full_discard) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; int l2_index; int ret; @@ -1501,7 +1501,7 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors, enum qcow2_discard_type type, bool full_discard) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t end_offset; unsigned int nb_clusters; int ret; @@ -1547,7 +1547,7 @@ fail: static int zero_single_l2(BlockDriverState *bs, uint64_t offset, unsigned int nb_clusters) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; int l2_index; int ret; @@ -1583,7 +1583,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; unsigned int nb_clusters; int ret; @@ -1628,7 +1628,7 @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table, int64_t l1_entries, BlockDriverAmendStatusCB *status_cb) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; bool is_active_l1 = (l1_table == s->l1_table); uint64_t *l2_table = NULL; int ret; @@ -1815,7 +1815,7 @@ fail: int qcow2_expand_zero_clusters(BlockDriverState *bs, BlockDriverAmendStatusCB *status_cb) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t *l1_table = NULL; int64_t l1_entries = 0, visited_l1_entries = 0; int ret; diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index b0ee42d..53e3e9f 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -82,7 +82,7 @@ static Qcow2SetRefcountFunc *const set_refcount_funcs[] = { int qcow2_refcount_init(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; unsigned int refcount_table_size2, i; int ret; @@ -116,7 +116,7 @@ int qcow2_refcount_init(BlockDriverState *bs) void qcow2_refcount_close(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; g_free(s->refcount_table); } @@ -214,7 +214,7 @@ static int load_refcount_block(BlockDriverState *bs, int64_t refcount_block_offset, void **refcount_block) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret; BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_LOAD); @@ -231,7 +231,7 @@ static int load_refcount_block(BlockDriverState *bs, int qcow2_get_refcount(BlockDriverState *bs, int64_t cluster_index, uint64_t *refcount) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t refcount_table_index, block_index; int64_t refcount_block_offset; int ret; @@ -274,7 +274,7 @@ int qcow2_get_refcount(BlockDriverState *bs, int64_t cluster_index, * Rounds the refcount table size up to avoid growing the table for each single * refcount block that is allocated. */ -static unsigned int next_refcount_table_size(BDRVQcowState *s, +static unsigned int next_refcount_table_size(BDRVQcow2State *s, unsigned int min_size) { unsigned int min_clusters = (min_size >> (s->cluster_bits - 3)) + 1; @@ -290,7 +290,7 @@ static unsigned int next_refcount_table_size(BDRVQcowState *s, /* Checks if two offsets are described by the same refcount block */ -static int in_same_refcount_block(BDRVQcowState *s, uint64_t offset_a, +static int in_same_refcount_block(BDRVQcow2State *s, uint64_t offset_a, uint64_t offset_b) { uint64_t block_a = offset_a >> (s->cluster_bits + s->refcount_block_bits); @@ -308,7 +308,7 @@ static int in_same_refcount_block(BDRVQcowState *s, uint64_t offset_a, static int alloc_refcount_block(BlockDriverState *bs, int64_t cluster_index, void **refcount_block) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; unsigned int refcount_table_index; int ret; @@ -605,7 +605,7 @@ fail_block: void qcow2_process_discards(BlockDriverState *bs, int ret) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; Qcow2DiscardRegion *d, *next; QTAILQ_FOREACH_SAFE(d, &s->discards, next, next) { @@ -625,7 +625,7 @@ void qcow2_process_discards(BlockDriverState *bs, int ret) static void update_refcount_discard(BlockDriverState *bs, uint64_t offset, uint64_t length) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; Qcow2DiscardRegion *d, *p, *next; QTAILQ_FOREACH(d, &s->discards, next) { @@ -682,7 +682,7 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs, bool decrease, enum qcow2_discard_type type) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t start, last, cluster_offset; void *refcount_block = NULL; int64_t old_table_index = -1; @@ -793,7 +793,7 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs, uint64_t addend, bool decrease, enum qcow2_discard_type type) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret; ret = update_refcount(bs, cluster_index << s->cluster_bits, 1, addend, @@ -815,7 +815,7 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs, /* return < 0 if error */ static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t i, nb_clusters, refcount; int ret; @@ -878,7 +878,7 @@ int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size) int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, int nb_clusters) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t cluster_index, refcount; uint64_t i; int ret; @@ -916,7 +916,7 @@ int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, contiguous sectors. size must be <= cluster_size */ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t offset; size_t free_in_cluster; int ret; @@ -992,7 +992,7 @@ void qcow2_free_clusters(BlockDriverState *bs, void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry, int nb_clusters, enum qcow2_discard_type type) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; switch (qcow2_get_cluster_type(l2_entry)) { case QCOW2_CLUSTER_COMPRESSED: @@ -1036,7 +1036,7 @@ void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry, int qcow2_update_snapshot_refcount(BlockDriverState *bs, int64_t l1_table_offset, int l1_size, int addend) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2, refcount; bool l1_allocated = false; int64_t old_offset, old_l2_offset; @@ -1233,7 +1233,7 @@ fail: /* refcount checking functions */ -static size_t refcount_array_byte_size(BDRVQcowState *s, uint64_t entries) +static size_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries) { /* This assertion holds because there is no way we can address more than * 2^(64 - 9) clusters at once (with cluster size 512 = 2^9, and because @@ -1256,7 +1256,7 @@ static size_t refcount_array_byte_size(BDRVQcowState *s, uint64_t entries) * refcount array buffer will be aligned to a cluster boundary, and the newly * allocated area will be zeroed. */ -static int realloc_refcount_array(BDRVQcowState *s, void **array, +static int realloc_refcount_array(BDRVQcow2State *s, void **array, int64_t *size, int64_t new_size) { size_t old_byte_size, new_byte_size; @@ -1304,7 +1304,7 @@ static int inc_refcounts(BlockDriverState *bs, int64_t *refcount_table_size, int64_t offset, int64_t size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t start, last, cluster_offset, k, refcount; int ret; @@ -1357,7 +1357,7 @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, int64_t *refcount_table_size, int64_t l2_offset, int flags) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t *l2_table, l2_entry; uint64_t next_contiguous_offset = 0; int i, l2_size, nb_csectors, ret; @@ -1477,7 +1477,7 @@ static int check_refcounts_l1(BlockDriverState *bs, int64_t l1_table_offset, int l1_size, int flags) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t *l1_table = NULL, l2_offset, l1_size2; int i, ret; @@ -1554,7 +1554,7 @@ fail: static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t *l2_table = qemu_blockalign(bs, s->cluster_size); int ret; uint64_t refcount; @@ -1673,7 +1673,7 @@ static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix, bool *rebuild, void **refcount_table, int64_t *nb_clusters) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t i, size; int ret; @@ -1776,7 +1776,7 @@ static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix, bool *rebuild, void **refcount_table, int64_t *nb_clusters) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t i; QCowSnapshot *sn; int ret; @@ -1840,7 +1840,7 @@ static void compare_refcounts(BlockDriverState *bs, BdrvCheckResult *res, int64_t *highest_cluster, void *refcount_table, int64_t nb_clusters) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t i; uint64_t refcount1, refcount2; int ret; @@ -1917,7 +1917,7 @@ static int64_t alloc_clusters_imrt(BlockDriverState *bs, int64_t *imrt_nb_clusters, int64_t *first_free_cluster) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t cluster = *first_free_cluster, i; bool first_gap = true; int contiguous_free_clusters; @@ -1987,7 +1987,7 @@ static int rebuild_refcount_structure(BlockDriverState *bs, void **refcount_table, int64_t *nb_clusters) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t first_free_cluster = 0, reftable_offset = -1, cluster = 0; int64_t refblock_offset, refblock_start, refblock_index; uint32_t reftable_size = 0; @@ -2174,7 +2174,7 @@ fail: int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; BdrvCheckResult pre_compare_res; int64_t size, highest_cluster, nb_clusters; void *refcount_table = NULL; @@ -2311,7 +2311,7 @@ fail: int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset, int64_t size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int chk = s->overlap_check & ~ign; int i, j; diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index b6f58c1..92f4dfc 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -29,7 +29,7 @@ void qcow2_free_snapshots(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int i; for(i = 0; i < s->nb_snapshots; i++) { @@ -43,7 +43,7 @@ void qcow2_free_snapshots(BlockDriverState *bs) int qcow2_read_snapshots(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowSnapshotHeader h; QCowSnapshotExtraData extra; QCowSnapshot *sn; @@ -136,7 +136,7 @@ fail: /* add at the end of the file a new list of snapshots */ static int qcow2_write_snapshots(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowSnapshot *sn; QCowSnapshotHeader h; QCowSnapshotExtraData extra; @@ -278,7 +278,7 @@ fail: static void find_new_snapshot_id(BlockDriverState *bs, char *id_str, int id_str_size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowSnapshot *sn; int i; unsigned long id, id_max = 0; @@ -296,7 +296,7 @@ static int find_snapshot_by_id_and_name(BlockDriverState *bs, const char *id, const char *name) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int i; if (id && name) { @@ -338,7 +338,7 @@ static int find_snapshot_by_id_or_name(BlockDriverState *bs, /* if no id is provided, a new one is constructed */ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowSnapshot *new_snapshot_list = NULL; QCowSnapshot *old_snapshot_list = NULL; QCowSnapshot sn1, *sn = &sn1; @@ -461,7 +461,7 @@ fail: /* copy the snapshot 'snapshot_name' into the current disk image */ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowSnapshot *sn; int i, snapshot_index; int cur_l1_bytes, sn_l1_bytes; @@ -587,7 +587,7 @@ int qcow2_snapshot_delete(BlockDriverState *bs, const char *name, Error **errp) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowSnapshot sn; int snapshot_index, ret; @@ -650,7 +650,7 @@ int qcow2_snapshot_delete(BlockDriverState *bs, int qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QEMUSnapshotInfo *sn_tab, *sn_info; QCowSnapshot *sn; int i; @@ -683,7 +683,7 @@ int qcow2_snapshot_load_tmp(BlockDriverState *bs, Error **errp) { int i, snapshot_index; - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowSnapshot *sn; uint64_t *new_l1_table; int new_l1_bytes; diff --git a/block/qcow2.c b/block/qcow2.c index a707d8d..9b09e01 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -85,7 +85,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, uint64_t end_offset, void **p_feature_table, Error **errp) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowExtension ext; uint64_t offset; int ret; @@ -187,7 +187,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, static void cleanup_unknown_header_ext(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; Qcow2UnknownHeaderExtension *uext, *next; QLIST_FOREACH_SAFE(uext, &s->unknown_header_ext, next, next) { @@ -249,7 +249,7 @@ static void report_unsupported_feature(BlockDriverState *bs, */ int qcow2_mark_dirty(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t val; int ret; @@ -282,7 +282,7 @@ int qcow2_mark_dirty(BlockDriverState *bs) */ static int qcow2_mark_clean(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; if (s->incompatible_features & QCOW2_INCOMPAT_DIRTY) { int ret; @@ -304,7 +304,7 @@ static int qcow2_mark_clean(BlockDriverState *bs) */ int qcow2_mark_corrupt(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; s->incompatible_features |= QCOW2_INCOMPAT_CORRUPT; return qcow2_update_header(bs); @@ -316,7 +316,7 @@ int qcow2_mark_corrupt(BlockDriverState *bs) */ int qcow2_mark_consistent(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) { int ret = bdrv_flush(bs); @@ -351,7 +351,7 @@ static int qcow2_check(BlockDriverState *bs, BdrvCheckResult *result, static int validate_table_offset(BlockDriverState *bs, uint64_t offset, uint64_t entries, size_t entry_len) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t size; /* Use signed INT64_MAX as the maximum even for uint64_t header fields, @@ -490,7 +490,7 @@ static const char *overlap_bool_option_names[QCOW2_OL_MAX_BITNR] = { static void cache_clean_timer_cb(void *opaque) { BlockDriverState *bs = opaque; - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; qcow2_cache_clean_unused(bs, s->l2_table_cache); qcow2_cache_clean_unused(bs, s->refcount_block_cache); timer_mod(s->cache_clean_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + @@ -499,7 +499,7 @@ static void cache_clean_timer_cb(void *opaque) static void cache_clean_timer_init(BlockDriverState *bs, AioContext *context) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; if (s->cache_clean_interval > 0) { s->cache_clean_timer = aio_timer_new(context, QEMU_CLOCK_VIRTUAL, SCALE_MS, cache_clean_timer_cb, @@ -511,7 +511,7 @@ static void cache_clean_timer_init(BlockDriverState *bs, AioContext *context) static void cache_clean_timer_del(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; if (s->cache_clean_timer) { timer_del(s->cache_clean_timer); timer_free(s->cache_clean_timer); @@ -534,7 +534,7 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, uint64_t *l2_cache_size, uint64_t *refcount_cache_size, Error **errp) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t combined_cache_size; bool l2_cache_size_set, refcount_cache_size_set, combined_cache_size_set; @@ -592,7 +592,7 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; unsigned int len, i; int ret = 0; QCowHeader header; @@ -1086,14 +1086,14 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, static void qcow2_refresh_limits(BlockDriverState *bs, Error **errp) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; bs->bl.write_zeroes_alignment = s->cluster_sectors; } static int qcow2_set_key(BlockDriverState *bs, const char *key) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint8_t keybuf[16]; int len, i; Error *err = NULL; @@ -1151,7 +1151,7 @@ static int qcow2_reopen_prepare(BDRVReopenState *state, static int64_t coroutine_fn qcow2_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t cluster_offset; int index_in_cluster, ret; int64_t status = 0; @@ -1198,7 +1198,7 @@ int qcow2_backing_read1(BlockDriverState *bs, QEMUIOVector *qiov, static coroutine_fn int qcow2_co_readv(BlockDriverState *bs, int64_t sector_num, int remaining_sectors, QEMUIOVector *qiov) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int index_in_cluster, n1; int ret; int cur_nr_sectors; /* number of sectors in current iteration */ @@ -1360,7 +1360,7 @@ static coroutine_fn int qcow2_co_writev(BlockDriverState *bs, int remaining_sectors, QEMUIOVector *qiov) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int index_in_cluster; int ret; int cur_nr_sectors; /* number of sectors in current iteration */ @@ -1506,7 +1506,7 @@ fail: static void qcow2_close(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; qemu_vfree(s->l1_table); /* else pre-write overlap checks in cache_destroy may crash */ s->l1_table = NULL; @@ -1552,7 +1552,7 @@ static void qcow2_close(BlockDriverState *bs) static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int flags = s->flags; QCryptoCipher *cipher = NULL; QDict *options; @@ -1575,7 +1575,7 @@ static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp) return; } - memset(s, 0, sizeof(BDRVQcowState)); + memset(s, 0, sizeof(BDRVQcow2State)); options = qdict_clone_shallow(bs->options); ret = qcow2_open(bs, options, flags, &local_err); @@ -1622,7 +1622,7 @@ static size_t header_ext_add(char *buf, uint32_t magic, const void *s, */ int qcow2_update_header(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowHeader *header; char *buf; size_t buflen = s->cluster_size; @@ -1791,7 +1791,7 @@ fail: static int qcow2_change_backing_file(BlockDriverState *bs, const char *backing_file, const char *backing_fmt) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: ""); pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_fmt ?: ""); @@ -2074,7 +2074,7 @@ static int qcow2_create2(const char *filename, int64_t total_size, /* And if we're supposed to preallocate metadata, do that now */ if (prealloc != PREALLOC_MODE_OFF) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; qemu_co_mutex_lock(&s->lock); ret = preallocate(bs); qemu_co_mutex_unlock(&s->lock); @@ -2209,7 +2209,7 @@ static coroutine_fn int qcow2_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors, BdrvRequestFlags flags) { int ret; - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; /* Emulate misaligned zero writes */ if (sector_num % s->cluster_sectors || nb_sectors % s->cluster_sectors) { @@ -2229,7 +2229,7 @@ static coroutine_fn int qcow2_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { int ret; - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; qemu_co_mutex_lock(&s->lock); ret = qcow2_discard_clusters(bs, sector_num << BDRV_SECTOR_BITS, @@ -2240,7 +2240,7 @@ static coroutine_fn int qcow2_co_discard(BlockDriverState *bs, static int qcow2_truncate(BlockDriverState *bs, int64_t offset) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t new_l1_size; int ret; @@ -2284,7 +2284,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset) static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; z_stream strm; int ret, out_len; uint8_t *out_buf; @@ -2375,7 +2375,7 @@ fail: static int make_completely_empty(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret, l1_clusters; int64_t offset; uint64_t *new_reftable = NULL; @@ -2523,7 +2523,7 @@ fail: static int qcow2_make_empty(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t start_sector; int sector_step = INT_MAX / BDRV_SECTOR_SIZE; int l1_clusters, ret = 0; @@ -2564,7 +2564,7 @@ static int qcow2_make_empty(BlockDriverState *bs) static coroutine_fn int qcow2_co_flush_to_os(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret; qemu_co_mutex_lock(&s->lock); @@ -2588,7 +2588,7 @@ static coroutine_fn int qcow2_co_flush_to_os(BlockDriverState *bs) static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; bdi->unallocated_blocks_are_zero = true; bdi->can_write_zeroes_with_unmap = (s->qcow_version >= 3); bdi->cluster_size = s->cluster_size; @@ -2598,7 +2598,7 @@ static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1); *spec_info = (ImageInfoSpecific){ @@ -2631,7 +2631,7 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs) #if 0 static void dump_refcounts(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t nb_clusters, k, k1, size; int refcount; @@ -2652,7 +2652,7 @@ static void dump_refcounts(BlockDriverState *bs) static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t total_sectors = bs->total_sectors; bool zero_beyond_eof = bs->zero_beyond_eof; int ret; @@ -2673,7 +2673,7 @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, static int qcow2_load_vmstate(BlockDriverState *bs, uint8_t *buf, int64_t pos, int size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; bool zero_beyond_eof = bs->zero_beyond_eof; int ret; @@ -2692,7 +2692,7 @@ static int qcow2_load_vmstate(BlockDriverState *bs, uint8_t *buf, static int qcow2_downgrade(BlockDriverState *bs, int target_version, BlockDriverAmendStatusCB *status_cb) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int current_version = s->qcow_version; int ret; @@ -2756,7 +2756,7 @@ static int qcow2_downgrade(BlockDriverState *bs, int target_version, static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, BlockDriverAmendStatusCB *status_cb) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int old_version = s->qcow_version, new_version = old_version; uint64_t new_size = 0; const char *backing_file = NULL, *backing_format = NULL; @@ -2903,7 +2903,7 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset, int64_t size, const char *message_format, ...) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; const char *node_name; char *message; va_list ap; @@ -3004,7 +3004,7 @@ static QemuOptsList qcow2_create_opts = { BlockDriver bdrv_qcow2 = { .format_name = "qcow2", - .instance_size = sizeof(BDRVQcowState), + .instance_size = sizeof(BDRVQcow2State), .bdrv_probe = qcow2_probe, .bdrv_open = qcow2_open, .bdrv_close = qcow2_close, diff --git a/block/qcow2.h b/block/qcow2.h index 71dafd6..61f1b57 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -222,7 +222,7 @@ typedef uint64_t Qcow2GetRefcountFunc(const void *refcount_array, typedef void Qcow2SetRefcountFunc(void *refcount_array, uint64_t index, uint64_t value); -typedef struct BDRVQcowState { +typedef struct BDRVQcow2State { int cluster_bits; int cluster_size; int cluster_sectors; @@ -293,7 +293,7 @@ typedef struct BDRVQcowState { * override) */ char *image_backing_file; char *image_backing_format; -} BDRVQcowState; +} BDRVQcow2State; struct QCowAIOCB; @@ -405,28 +405,28 @@ typedef enum QCow2MetadataOverlap { #define REFT_OFFSET_MASK 0xfffffffffffffe00ULL -static inline int64_t start_of_cluster(BDRVQcowState *s, int64_t offset) +static inline int64_t start_of_cluster(BDRVQcow2State *s, int64_t offset) { return offset & ~(s->cluster_size - 1); } -static inline int64_t offset_into_cluster(BDRVQcowState *s, int64_t offset) +static inline int64_t offset_into_cluster(BDRVQcow2State *s, int64_t offset) { return offset & (s->cluster_size - 1); } -static inline int size_to_clusters(BDRVQcowState *s, int64_t size) +static inline int size_to_clusters(BDRVQcow2State *s, int64_t size) { return (size + (s->cluster_size - 1)) >> s->cluster_bits; } -static inline int64_t size_to_l1(BDRVQcowState *s, int64_t size) +static inline int64_t size_to_l1(BDRVQcow2State *s, int64_t size) { int shift = s->cluster_bits + s->l2_bits; return (size + (1ULL << shift) - 1) >> shift; } -static inline int offset_to_l2_index(BDRVQcowState *s, int64_t offset) +static inline int offset_to_l2_index(BDRVQcow2State *s, int64_t offset) { return (offset >> s->cluster_bits) & (s->l2_size - 1); } @@ -437,12 +437,12 @@ static inline int64_t align_offset(int64_t offset, int n) return offset; } -static inline int64_t qcow2_vm_state_offset(BDRVQcowState *s) +static inline int64_t qcow2_vm_state_offset(BDRVQcow2State *s) { return (int64_t)s->l1_vm_state_index << (s->cluster_bits + s->l2_bits); } -static inline uint64_t qcow2_max_refcount_clusters(BDRVQcowState *s) +static inline uint64_t qcow2_max_refcount_clusters(BDRVQcow2State *s) { return QCOW_MAX_REFTABLE_SIZE >> s->cluster_bits; } @@ -461,7 +461,7 @@ static inline int qcow2_get_cluster_type(uint64_t l2_entry) } /* Check whether refcounts are eager or lazy */ -static inline bool qcow2_need_accurate_refcounts(BDRVQcowState *s) +static inline bool qcow2_need_accurate_refcounts(BDRVQcow2State *s) { return !(s->incompatible_features & QCOW2_INCOMPAT_DIRTY); } @@ -537,7 +537,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index); void qcow2_l2_cache_reset(BlockDriverState *bs); int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset); -int qcow2_encrypt_sectors(BDRVQcowState *s, int64_t sector_num, +int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t sector_num, uint8_t *out_buf, const uint8_t *in_buf, int nb_sectors, bool enc, Error **errp); -- 1.8.3.1 From MAILER-DAEMON Mon Sep 07 11:59:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYypM-0002Gb-Ku for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 11:59:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYypI-0002FF-0U for qemu-block@nongnu.org; Mon, 07 Sep 2015 11:59:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYypF-0005tF-BH for qemu-block@nongnu.org; Mon, 07 Sep 2015 11:59:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49896) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYypF-0005t7-5G; Mon, 07 Sep 2015 11:59:21 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id A0A598535C; Mon, 7 Sep 2015 15:59:20 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t87FxHQg013979; Mon, 7 Sep 2015 11:59:18 -0400 Date: Mon, 7 Sep 2015 17:59:17 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150907155917.GE5529@noname.redhat.com> References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-2-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437414365-11881-2-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v4 01/38] block: Remove host floppy support X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 15:59:25 -0000 Am 20.07.2015 um 19:45 hat Max Reitz geschrieben: > It has been deprecated as of 2.3, so we can now remove it. > > Signed-off-by: Max Reitz > @@ -2241,8 +2188,9 @@ static BlockAIOCB *hdev_aio_ioctl(BlockDriverState *bs, > pool = aio_get_thread_pool(bdrv_get_aio_context(bs)); > return thread_pool_submit_aio(pool, aio_worker, acb, cb, opaque); > } > +#endif /* linux */ > > -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) > +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) > static int fd_open(BlockDriverState *bs) > { > BDRVRawState *s = bs->opaque; > @@ -2252,7 +2200,7 @@ static int fd_open(BlockDriverState *bs) > return 0; > return -EIO; > } > -#else /* !linux && !FreeBSD */ > +#else /* !FreeBSD */ > > static int fd_open(BlockDriverState *bs) > { Full context: #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) static int fd_open(BlockDriverState *bs) { BDRVRawState *s = bs->opaque; /* this is just to ensure s->fd is sane (its called by io ops) */ if (s->fd >= 0) return 0; return -EIO; } #else /* !FreeBSD */ static int fd_open(BlockDriverState *bs) { return 0; } #endif /* !linux && !FreeBSD */ First of all, the final comment isn't accurate any more, this branch is now for Linux, too. But really the whole #ifdef looks dubious now. It's not clear to me why we're checking fd >= 0 for FreeBSD at all, using an invalid file descriptor (most likely -1, which is set explicitly in some places) should automatically lead to failure. And conversely, I can't see why doing the same check for non-FreeBSD platforms should hurt. Ideally, I'd try to get rid of all the fd_open() calls, but failing that let's use the FreeBSD version universally and get rid of the #ifdef at least. Or perhaps get rid of the #ifdef in this patch and add another one that removes fd_open() completely. > diff --git a/qapi/block-core.json b/qapi/block-core.json > index 7b2efb8..133fa38 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -215,10 +215,11 @@ > # @drv: the name of the block format used to open the backing device. As of > # 0.14.0 this can be: 'blkdebug', 'bochs', 'cloop', 'cow', 'dmg', > # 'file', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device', > -# 'host_floppy', 'http', 'https', 'nbd', 'parallels', 'qcow', > +# 'http', 'https', 'nbd', 'parallels', 'qcow', > # 'qcow2', 'raw', 'tftp', 'vdi', 'vmdk', 'vpc', 'vvfat' > # 2.2: 'archipelago' added, 'cow' dropped > # 2.3: 'host_floppy' deprecated > +# 2.4: 'host_floppy' dropped 2.5 Kevin From MAILER-DAEMON Mon Sep 07 12:12:16 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYz1k-0000v7-IL for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 12:12:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYz1e-0000mk-SG for qemu-block@nongnu.org; Mon, 07 Sep 2015 12:12:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYz1a-0003Ja-Af for qemu-block@nongnu.org; Mon, 07 Sep 2015 12:12:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYz1a-0003JC-6W; Mon, 07 Sep 2015 12:12:06 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id BE2AC341ADF; Mon, 7 Sep 2015 16:12:05 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t87GC3PI023832; Mon, 7 Sep 2015 12:12:03 -0400 Date: Mon, 7 Sep 2015 18:12:02 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150907161202.GF5529@noname.redhat.com> References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-3-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437414365-11881-3-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v4 02/38] blockdev: Allow creation of BDS trees without BB X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 16:12:11 -0000 Am 20.07.2015 um 19:45 hat Max Reitz geschrieben: > If the "id" field is missing from the options given to blockdev-add, > just omit the BlockBackend and create the BlockDriverState tree alone. > > However, if "id" is missing, "node-name" must be specified; otherwise, > the BDS tree would no longer be accessible. We can probably lift this restriction once Jeff's auto-generated ID patches are in. However, allowing additional things is easy, so no objection here. > Many BDS options which are not parsed by bdrv_open() (like caching) > cannot be specified for these BB-less BDS trees yet. A future patch will > remove this limitation. This makes the command mostly useless, but that's okay. We'll be working on converting flags to QDict options one by one and then it will start working. There is, however, one flag that doesn't correspond to an option or enable an additional feature that is simply missing until then. That one worries me a bit: BDRV_O_INCOMING. We should probably include it in this patch; or maybe better add another patch before this one which moves the setting of BDRV_O_INCOMING from blockdev_init() to bdrv_open_common(). > Signed-off-by: Max Reitz > Reviewed-by: Eric Blake > Reviewed-by: Alberto Garcia > --- > blockdev.c | 44 +++++++++++++++++++++++++++++++------------- > qapi/block-core.json | 13 +++++++++---- > tests/qemu-iotests/087 | 2 +- > tests/qemu-iotests/087.out | 4 ++-- > 4 files changed, 43 insertions(+), 20 deletions(-) Kevin From MAILER-DAEMON Mon Sep 07 12:20:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYzA6-0008H5-T2 for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 12:20:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYzA4-0008Gi-80 for qemu-block@nongnu.org; Mon, 07 Sep 2015 12:20:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYz9v-0008AN-J6 for qemu-block@nongnu.org; Mon, 07 Sep 2015 12:20:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55274) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYz9v-00089S-4d; Mon, 07 Sep 2015 12:20:43 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 751728CF5D; Mon, 7 Sep 2015 16:20:42 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t87GKd30020142; Mon, 7 Sep 2015 12:20:40 -0400 Date: Mon, 7 Sep 2015 18:20:39 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150907162039.GG5529@noname.redhat.com> References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-4-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437414365-11881-4-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v4 03/38] iotests: Only create BB if necessary X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 16:20:53 -0000 Am 20.07.2015 um 19:45 hat Max Reitz geschrieben: > Tests 071 and 081 test giving references in blockdev-add. It is not > necessary to create a BlockBackend here, so omit it. > > Signed-off-by: Max Reitz > Reviewed-by: Eric Blake > Reviewed-by: Alberto Garcia > --- > tests/qemu-iotests/071 | 50 ++++++++++++++++++++++++++++++++++++++++++---- > tests/qemu-iotests/071.out | 12 +++++++---- > tests/qemu-iotests/081 | 14 ++++++++++++- > tests/qemu-iotests/081.out | 5 +++-- > 4 files changed, 70 insertions(+), 11 deletions(-) > > diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071 > index 9eaa49b..68bedd4 100755 > --- a/tests/qemu-iotests/071 > +++ b/tests/qemu-iotests/071 > @@ -104,11 +104,20 @@ echo > echo "=== Testing blkdebug on existing block device ===" > echo > > -run_qemu -drive "file=$TEST_IMG,format=raw,if=none,id=drive0" < +run_qemu < { "execute": "qmp_capabilities" } > { "execute": "blockdev-add", > "arguments": { > "options": { > + "node-name": "drive0", > + "driver": "file", > + "filename": "$TEST_IMG" > + } > + } > +} Any specific reason why format=raw is translated into driver=file here... > +{ "execute": "blockdev-add", > + "arguments": { > + "options": { > "driver": "$IMGFMT", > "id": "drive0-debug", > "file": { > @@ -133,11 +142,23 @@ echo > echo "=== Testing blkverify on existing block device ===" > echo > > -run_qemu -drive "file=$TEST_IMG,format=$IMGFMT,if=none,id=drive0" < +run_qemu < { "execute": "qmp_capabilities" } > { "execute": "blockdev-add", > "arguments": { > "options": { > + "node-name": "drive0", > + "driver": "$IMGFMT", > + "file": { > + "driver": "file", > + "filename": "$TEST_IMG" > + } > + } > + } > +} > +{ "execute": "blockdev-add", > + "arguments": { > + "options": { > "driver": "blkverify", > "id": "drive0-verify", > "test": "drive0", > @@ -163,11 +184,23 @@ echo > echo "=== Testing blkverify on existing raw block device ===" > echo > > -run_qemu -drive "file=$TEST_IMG.base,format=raw,if=none,id=drive0" < +run_qemu < { "execute": "qmp_capabilities" } > { "execute": "blockdev-add", > "arguments": { > "options": { > + "node-name": "drive0", > + "driver": "raw", > + "file": { > + "driver": "file", > + "filename": "$TEST_IMG.base" > + } > + } > + } > +} ...but into driver=raw,file.driver=file here? > +{ "execute": "blockdev-add", > + "arguments": { > + "options": { > "driver": "blkverify", > "id": "drive0-verify", > "test": { > diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 > index d9b042c..5c8a8fa 100755 > --- a/tests/qemu-iotests/081 > +++ b/tests/qemu-iotests/081 > @@ -101,11 +101,23 @@ $QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io > echo > echo "== checking mixed reference/option specification ==" > > -run_qemu -drive "file=$TEST_DIR/2.raw,format=$IMGFMT,if=none,id=drive2" < +run_qemu < { "execute": "qmp_capabilities" } > { "execute": "blockdev-add", > "arguments": { > "options": { > + "node-name": "drive2", > + "driver": "raw", > + "file": { > + "driver": "file", > + "filename": "$TEST_DIR/2.raw" > + } > + } > + } > +} And here $IMGFMT becomes raw (which is equivalent, but...) > +{ "execute": "blockdev-add", > + "arguments": { > + "options": { > "driver": "quorum", > "id": "drive0-quorum", > "vote-threshold": 2, Kevin From MAILER-DAEMON Mon Sep 07 12:26:55 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYzFv-00031Q-9s for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 12:26:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYzFs-00031G-TX for qemu-block@nongnu.org; Mon, 07 Sep 2015 12:26:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYzFn-0003on-Uw for qemu-block@nongnu.org; Mon, 07 Sep 2015 12:26:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42886) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYzFn-0003n2-Ob; Mon, 07 Sep 2015 12:26:47 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id EFD308EA30; Mon, 7 Sep 2015 16:26:46 +0000 (UTC) Received: from [10.36.116.102] (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87GQhGf016241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 12:26:44 -0400 To: Kevin Wolf References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-2-git-send-email-mreitz@redhat.com> <20150907155917.GE5529@noname.redhat.com> From: Max Reitz Message-ID: <55EDBAC2.4070107@redhat.com> Date: Mon, 7 Sep 2015 18:26:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150907155917.GE5529@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="91WeHJS7ASEQcj6AUWA81bjFQaXXfH2hE" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v4 01/38] block: Remove host floppy support X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 16:26:54 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --91WeHJS7ASEQcj6AUWA81bjFQaXXfH2hE Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 07.09.2015 17:59, Kevin Wolf wrote: > Am 20.07.2015 um 19:45 hat Max Reitz geschrieben: >> It has been deprecated as of 2.3, so we can now remove it. >> >> Signed-off-by: Max Reitz >=20 >> @@ -2241,8 +2188,9 @@ static BlockAIOCB *hdev_aio_ioctl(BlockDriverSta= te *bs, >> pool =3D aio_get_thread_pool(bdrv_get_aio_context(bs)); >> return thread_pool_submit_aio(pool, aio_worker, acb, cb, opaque);= >> } >> +#endif /* linux */ >> =20 >> -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) >> +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) >> static int fd_open(BlockDriverState *bs) >> { >> BDRVRawState *s =3D bs->opaque; >> @@ -2252,7 +2200,7 @@ static int fd_open(BlockDriverState *bs) >> return 0; >> return -EIO; >> } >> -#else /* !linux && !FreeBSD */ >> +#else /* !FreeBSD */ >> =20 >> static int fd_open(BlockDriverState *bs) >> { >=20 > Full context: >=20 > #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) > static int fd_open(BlockDriverState *bs) > { > BDRVRawState *s =3D bs->opaque; >=20 > /* this is just to ensure s->fd is sane (its called by io ops) = */ > if (s->fd >=3D 0) > return 0; > return -EIO; > } > #else /* !FreeBSD */ >=20 > static int fd_open(BlockDriverState *bs) > { > return 0; > } >=20 > #endif /* !linux && !FreeBSD */ >=20 > First of all, the final comment isn't accurate any more, this branch is= > now for Linux, too. >=20 > But really the whole #ifdef looks dubious now. It's not clear to me why= > we're checking fd >=3D 0 for FreeBSD at all, Me neither, so I just decided to keep it the way it was. > using an invalid file > descriptor (most likely -1, which is set explicitly in some places) > should automatically lead to failure. And conversely, I can't see why > doing the same check for non-FreeBSD platforms should hurt. >=20 > Ideally, I'd try to get rid of all the fd_open() calls, but failing tha= t > let's use the FreeBSD version universally and get rid of the #ifdef at > least. Or perhaps get rid of the #ifdef in this patch and add another > one that removes fd_open() completely. Seems reasonable, will do. >> diff --git a/qapi/block-core.json b/qapi/block-core.json >> index 7b2efb8..133fa38 100644 >> --- a/qapi/block-core.json >> +++ b/qapi/block-core.json >> @@ -215,10 +215,11 @@ >> # @drv: the name of the block format used to open the backing device.= As of >> # 0.14.0 this can be: 'blkdebug', 'bochs', 'cloop', 'cow', 'dmg= ', >> # 'file', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device', >> -# 'host_floppy', 'http', 'https', 'nbd', 'parallels', 'qcow', >> +# 'http', 'https', 'nbd', 'parallels', 'qcow', >> # 'qcow2', 'raw', 'tftp', 'vdi', 'vmdk', 'vpc', 'vvfat' >> # 2.2: 'archipelago' added, 'cow' dropped >> # 2.3: 'host_floppy' deprecated >> +# 2.4: 'host_floppy' dropped >=20 > 2.5 I should have grep'ed through it. :-) Thanks for reviewing! Max --91WeHJS7ASEQcj6AUWA81bjFQaXXfH2hE Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV7brCAAoJEDuxQgLoOKytNJAIAKXTXGn12aDpG1dafyCvbIZ5 OovGWgNYBJLM/nT4Ytu5VtsnVGUJ3cH3BS8VaZ3x4XiAKapQlCw7IpznEBjvkwHk jVwBSRupsQvkCwEvpKkIUbInu941ubUgwvQ8elixtu6KRbZD5REvOD8GTvLhiDmC XeoD1/QCTyu1HWmpeYKeEu14qhY7pzH/iq9G2Lb/bPOrVctBVDpLWsYS31qe39xS 3V8MiJsKCDCTjXFLVExWYLN05SiD/AB8KONdhlY9RCdMgWEHd10XP1J4B7YL/c8x 5sOWGOCSfzQ6mtytI1Z87Q5iuuMkrC7awz2rg+2yeM9asN5OyzxVmEtT3FHOBQk= =mUPN -----END PGP SIGNATURE----- --91WeHJS7ASEQcj6AUWA81bjFQaXXfH2hE-- From MAILER-DAEMON Mon Sep 07 12:37:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYzQR-0001ZD-PC for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 12:37:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYzQP-0001WF-BS for qemu-block@nongnu.org; Mon, 07 Sep 2015 12:37:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYzQL-00085x-Bp for qemu-block@nongnu.org; Mon, 07 Sep 2015 12:37:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35752) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYzQL-00085q-7A; Mon, 07 Sep 2015 12:37:41 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 1DE2CC0B9875; Mon, 7 Sep 2015 16:37:40 +0000 (UTC) Received: from [10.36.112.56] (ovpn-112-56.ams2.redhat.com [10.36.112.56]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87Gba9c029966 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 12:37:38 -0400 To: John Snow , qemu-block@nongnu.org References: <1440546331-29087-1-git-send-email-jsnow@redhat.com> <1440546331-29087-2-git-send-email-jsnow@redhat.com> From: Paolo Bonzini Message-ID: <55EDBD4F.7070204@redhat.com> Date: Mon, 7 Sep 2015 18:37:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1440546331-29087-2-git-send-email-jsnow@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: hare@suse.de, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 1/1] ide: unify io_buffer_offset increments X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 16:37:46 -0000 On 26/08/2015 01:45, John Snow wrote: > IDEState's io_buffer_offset was originally added to keep track of offsets > in AHCI rather exclusively, but it was added to IDEState instead of an > AHCI-specific structure. Interesting to see something weird turn into feature. :) Reviewed-by: Paolo Bonzini > AHCI fakes all PIO transfers using DMA and a scatter-gather list. When > the core or atapi layers invoke HBA-specific mechanisms for transfers, > they do not always know that it is being backed by DMA or a sglist, so > this offset is not always updated by the HBA code everywhere. > > If we modify it in dma_buf_commit, however, any HBA that needs to use > this offset to manage operating on only part of a sglist will have > access to it. > > This will fix ATAPI PIO transfers performed through the AHCI HBA, > which were previously not modifying this value appropriately. > > This will fix ATAPI PIO transfers larger than one sector. From MAILER-DAEMON Mon Sep 07 12:38:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYzR1-0002Jc-4o for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 12:38:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYzQy-0002Gk-KB for qemu-block@nongnu.org; Mon, 07 Sep 2015 12:38:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYzQu-0008DS-JJ for qemu-block@nongnu.org; Mon, 07 Sep 2015 12:38:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60616) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYzQu-0008DM-C9; Mon, 07 Sep 2015 12:38:16 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 090084AD5F; Mon, 7 Sep 2015 16:38:16 +0000 (UTC) Received: from [10.36.116.102] (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87GcCiw013157 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 12:38:13 -0400 To: Kevin Wolf References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-3-git-send-email-mreitz@redhat.com> <20150907161202.GF5529@noname.redhat.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <55EDBD74.6070409@redhat.com> Date: Mon, 7 Sep 2015 18:38:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150907161202.GF5529@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="HtCMPT7Ch0m5kW7QhAxeXQq8KTI8F0hku" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v4 02/38] blockdev: Allow creation of BDS trees without BB X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 16:38:21 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --HtCMPT7Ch0m5kW7QhAxeXQq8KTI8F0hku Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 07.09.2015 18:12, Kevin Wolf wrote: > Am 20.07.2015 um 19:45 hat Max Reitz geschrieben: >> If the "id" field is missing from the options given to blockdev-add, >> just omit the BlockBackend and create the BlockDriverState tree alone.= >> >> However, if "id" is missing, "node-name" must be specified; otherwise,= >> the BDS tree would no longer be accessible. >=20 > We can probably lift this restriction once Jeff's auto-generated ID > patches are in. However, allowing additional things is easy, so no > objection here. Maybe we can lift it, but I don't know. In order to know the node-name, you'd have to do a query-named-block-nodes before blockdev-add and another one afterwards, diff it, and thus obtain the ID. But maybe that doesn't even work, since one blockdev-add operation usually adds multiple BDSs at ones. >> Many BDS options which are not parsed by bdrv_open() (like caching) >> cannot be specified for these BB-less BDS trees yet. A future patch wi= ll >> remove this limitation. >=20 > This makes the command mostly useless, but that's okay. Well, the future patch is part of this series, so yes, it is okay. > We'll be working > on converting flags to QDict options one by one and then it will start > working. >=20 > There is, however, one flag that doesn't correspond to an option or > enable an additional feature that is simply missing until then. That on= e > worries me a bit: BDRV_O_INCOMING. We should probably include it in thi= s > patch; or maybe better add another patch before this one which moves th= e > setting of BDRV_O_INCOMING from blockdev_init() to bdrv_open_common(). Hm, probably so, yes. It's still missing at the end of this series, too. However, as far as I can see, O_INCOMING is set only for the root BDS, so moving it to bdrv_open_common() would probably change behavior, though maybe that'd be a bug fix, actually. Max >> Signed-off-by: Max Reitz >> Reviewed-by: Eric Blake >> Reviewed-by: Alberto Garcia >> --- >> blockdev.c | 44 +++++++++++++++++++++++++++++++------= ------- >> qapi/block-core.json | 13 +++++++++---- >> tests/qemu-iotests/087 | 2 +- >> tests/qemu-iotests/087.out | 4 ++-- >> 4 files changed, 43 insertions(+), 20 deletions(-) >=20 > Kevin >=20 --HtCMPT7Ch0m5kW7QhAxeXQq8KTI8F0hku Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV7b10AAoJEDuxQgLoOKytRPwH/i8V7fcmN+vqyUNxQhogSs9j /AqBjz0H3NebdHTLA4Jfw1mwCdMy4MCsflj9dHUviNeCLbEWXUDe/AR0nmI3h7kz 5Y9BHmRpxaUr6Ax+MLRTmwJYojPm+tEDvOL5h+eCwJpq0LeyrpeqQtmZeWMWfgHh E8dJGcv8hrg88BZJXTzG3yYQ67CS+H5XdPvLfjlsERbSjdxjwcp1O1xnuw3Dbr0Z 1n8Sk7N5orhlVzD1+eabrMnI5A+dsUNys38SfpjqL6JHHBYO8xh3vxy7Lf/xIeT2 zz8Kj9CnJyfH9ab8nDPvu5tD3jVEd/Bd53RflDXhgdceBg96KiMQT8MEDJVwouM= =A+nn -----END PGP SIGNATURE----- --HtCMPT7Ch0m5kW7QhAxeXQq8KTI8F0hku-- From MAILER-DAEMON Mon Sep 07 12:54:41 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYzgn-0008VI-Ri for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 12:54:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYzgl-0008Uz-NR for qemu-block@nongnu.org; Mon, 07 Sep 2015 12:54:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYzgi-00082h-Dd for qemu-block@nongnu.org; Mon, 07 Sep 2015 12:54:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYzgi-00082d-6m; Mon, 07 Sep 2015 12:54:36 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 8EF1D2D1272; Mon, 7 Sep 2015 16:54:35 +0000 (UTC) Received: from [10.36.116.102] (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87GsVt3008243 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 12:54:33 -0400 To: Kevin Wolf References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-4-git-send-email-mreitz@redhat.com> <20150907162039.GG5529@noname.redhat.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <55EDC147.1080002@redhat.com> Date: Mon, 7 Sep 2015 18:54:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150907162039.GG5529@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pmxlB6nPxFUdUomF4J8rtN9h2OIaUbtGL" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v4 03/38] iotests: Only create BB if necessary X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 16:54:40 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --pmxlB6nPxFUdUomF4J8rtN9h2OIaUbtGL Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 07.09.2015 18:20, Kevin Wolf wrote: > Am 20.07.2015 um 19:45 hat Max Reitz geschrieben: >> Tests 071 and 081 test giving references in blockdev-add. It is not >> necessary to create a BlockBackend here, so omit it. >> >> Signed-off-by: Max Reitz >> Reviewed-by: Eric Blake >> Reviewed-by: Alberto Garcia >> --- >> tests/qemu-iotests/071 | 50 +++++++++++++++++++++++++++++++++++++= +++++---- >> tests/qemu-iotests/071.out | 12 +++++++---- >> tests/qemu-iotests/081 | 14 ++++++++++++- >> tests/qemu-iotests/081.out | 5 +++-- >> 4 files changed, 70 insertions(+), 11 deletions(-) >> >> diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071 >> index 9eaa49b..68bedd4 100755 >> --- a/tests/qemu-iotests/071 >> +++ b/tests/qemu-iotests/071 >> @@ -104,11 +104,20 @@ echo >> echo "=3D=3D=3D Testing blkdebug on existing block device =3D=3D=3D" >> echo >> =20 >> -run_qemu -drive "file=3D$TEST_IMG,format=3Draw,if=3Dnone,id=3Ddrive0"= <> +run_qemu <> { "execute": "qmp_capabilities" } >> { "execute": "blockdev-add", >> "arguments": { >> "options": { >> + "node-name": "drive0", >> + "driver": "file", >> + "filename": "$TEST_IMG" >> + } >> + } >> +} >=20 > Any specific reason why format=3Draw is translated into driver=3Dfile h= ere... This is for the BDS used under blockdev-add, which is supposed to be a protocol BDS. "raw" was actually wrong, but apparently I felt bad about specifying a protocol driver on the command line. >> +{ "execute": "blockdev-add", >> + "arguments": { >> + "options": { >> "driver": "$IMGFMT", >> "id": "drive0-debug", >> "file": { >> @@ -133,11 +142,23 @@ echo >> echo "=3D=3D=3D Testing blkverify on existing block device =3D=3D=3D"= >> echo >> =20 >> -run_qemu -drive "file=3D$TEST_IMG,format=3D$IMGFMT,if=3Dnone,id=3Ddri= ve0" <> +run_qemu <> { "execute": "qmp_capabilities" } >> { "execute": "blockdev-add", >> "arguments": { >> "options": { >> + "node-name": "drive0", >> + "driver": "$IMGFMT", >> + "file": { >> + "driver": "file", >> + "filename": "$TEST_IMG" >> + } >> + } >> + } >> +} >> +{ "execute": "blockdev-add", >> + "arguments": { >> + "options": { >> "driver": "blkverify", >> "id": "drive0-verify", >> "test": "drive0", >> @@ -163,11 +184,23 @@ echo >> echo "=3D=3D=3D Testing blkverify on existing raw block device =3D=3D= =3D" >> echo >> =20 >> -run_qemu -drive "file=3D$TEST_IMG.base,format=3Draw,if=3Dnone,id=3Ddr= ive0" <> +run_qemu <> { "execute": "qmp_capabilities" } >> { "execute": "blockdev-add", >> "arguments": { >> "options": { >> + "node-name": "drive0", >> + "driver": "raw", >> + "file": { >> + "driver": "file", >> + "filename": "$TEST_IMG.base" >> + } >> + } >> + } >> +} >=20 > ...but into driver=3Draw,file.driver=3Dfile here? Probably because I assumed based on the test above this one that the "raw" BDS for blkverify would be a format BDS. Apparently it's not and both this and the test above this one should be fixed. >> +{ "execute": "blockdev-add", >> + "arguments": { >> + "options": { >> "driver": "blkverify", >> "id": "drive0-verify", >> "test": { >=20 >> diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 >> index d9b042c..5c8a8fa 100755 >> --- a/tests/qemu-iotests/081 >> +++ b/tests/qemu-iotests/081 >> @@ -101,11 +101,23 @@ $QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0= $size" | _filter_qemu_io >> echo >> echo "=3D=3D checking mixed reference/option specification =3D=3D" >> =20 >> -run_qemu -drive "file=3D$TEST_DIR/2.raw,format=3D$IMGFMT,if=3Dnone,id= =3Ddrive2" <> +run_qemu <> { "execute": "qmp_capabilities" } >> { "execute": "blockdev-add", >> "arguments": { >> "options": { >> + "node-name": "drive2", >> + "driver": "raw", >> + "file": { >> + "driver": "file", >> + "filename": "$TEST_DIR/2.raw" >> + } >> + } >> + } >> +} >=20 > And here $IMGFMT becomes raw (which is equivalent, but...) The other blockdev-add in this example uses hard-coded "raw", too. And then there's the hard-coded ".raw" extension everywhere in this test... I'll fix it, but that means fixing the pre-existing blockdev-add, too, and for such matters the most difficult thing always tends to be explaining it in the commit message. :-) Max >> +{ "execute": "blockdev-add", >> + "arguments": { >> + "options": { >> "driver": "quorum", >> "id": "drive0-quorum", >> "vote-threshold": 2, >=20 > Kevin >=20 --pmxlB6nPxFUdUomF4J8rtN9h2OIaUbtGL Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV7cFHAAoJEDuxQgLoOKytIhUH/2aLCIgGSMYhE3hrZggKEtEI QEnOrhMLH2IPt0HxyvrUrGsjyliEJTNmnIA/kVIl0QylCa1iZS/k7Rp3juaJoet9 VMOSNGWjWA3sY2itVUVZonixudRmi/BZ9ish2wJHG7AlmoHsGkuOaHx0DMfzgUQW N0cAvQxFUuIirqzM8ADnsfaYI323GSUqxDCXwxz7du0a8sjiAGQ7pk5mD+x9v4MD lTSRrOmxHEMKTHYqYeEIKQvmZeG3eJInOVD9jfkCTe5U28TKQe1WvgBrJNU5Llra tiM+0xSZ2zFz8vBjA2bwxgAC7FImPp7YN3+QLuWaoLvxFsGOORas12Rhrp1b4do= =elzV -----END PGP SIGNATURE----- --pmxlB6nPxFUdUomF4J8rtN9h2OIaUbtGL-- From MAILER-DAEMON Mon Sep 07 13:06:12 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZYzrw-0006g0-86 for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 13:06:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYzrt-0006ce-RK for qemu-block@nongnu.org; Mon, 07 Sep 2015 13:06:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYzrp-0005cO-UI for qemu-block@nongnu.org; Mon, 07 Sep 2015 13:06:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39945) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYzrp-0005cC-Mv; Mon, 07 Sep 2015 13:06:05 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 59B12C0B9882; Mon, 7 Sep 2015 16:56:45 +0000 (UTC) Received: from work-vm (ovpn-116-61.ams2.redhat.com [10.36.116.61]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87Gud4u027614 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 7 Sep 2015 12:56:41 -0400 Date: Mon, 7 Sep 2015 17:56:39 +0100 From: "Dr. David Alan Gilbert" To: Eric Blake Message-ID: <20150907165638.GJ2337@work-vm> References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-7-git-send-email-wency@cn.fujitsu.com> <55E72422.30301@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55E72422.30301@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , qemu devel , "Michael R. Hines" , Max Reitz , Gonglei , Stefan Hajnoczi , Paolo Bonzini , Yang Hongyang , zhanghailiang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 06/16] quorum: allow ignoring child errors X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 17:06:11 -0000 * Eric Blake (eblake@redhat.com) wrote: > On 09/02/2015 02:51 AM, Wen Congyang wrote: > > If the child is not ready, read/write/getlength/flush will > > return -errno. It is not critical error, and can be ignored: > > 1. read/write: > > Just not report the error event. > > What happens if all the children report an error? Or is the threshold > at play here? I think it's interesting because in the COLO case the intention isn't really about a threshold (in the way you might use for RAID or mirroring), it's that one of the stores is local (and not expected to error) and one is somewhere over a network, so if it fails you don't want to stop the local VM working. However, if it fails we do need to know about it; if any write to the secondary stops then the fault-tolerance has failed (at least for that drive); so we should do *something* - I'm not sure what though. Dave > For example, if you have a threshold of 3/5, then I'm assuming that if > up to two children return an errno, then it is okay to ignore; but if > three or more return an errno, you haven't met threshold, so the I/O > must fail. > > Are you ignoring ALL errors (including things like EACCES), or just EIO > errors? > > > > 2. getlength: > > just ignore it. If all children's getlength return -errno, > > and be ignored, return -EIO. > > 3. flush: > > Just ignore it. If all children's getlength return -errno, > > s/getlength/flush/ > > > and be ignored, return 0. > > Yuck - claiming success when all of the children fail feels dangerous. > > > > > Usage: children.x.ignore-errors=true > > > > Signed-off-by: Wen Congyang > > Signed-off-by: zhanghailiang > > Signed-off-by: Gonglei > > Cc: Alberto Garcia > > --- > > block/quorum.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++---- > > Interface review only: > > > +++ b/qapi/block-core.json > > @@ -1411,6 +1411,8 @@ > > # @allow-write-backing-file: #optional whether the backing file is opened in > > # read-write mode. It is only for backing file > > # (Since 2.5 default: false) > > +# @ignore-errors: #options whether the child's I/O error should be ignored. > > s/options/optional/ > s/error/errors/ > > > +# it is only for quorum's child.(Since 2.5 default: false) > > Space after '.' in English sentences. > > The fact that you are documenting that this option can only be specified > for quorum children makes me wonder if it belongs better as an option in > BlockdevOptionsQuorum rather than BlockdevOptionsBase. > > Semantically, it sounds like you are trying to allow for a per-child > decision of whether this particular child's errors matter to the overall > quorum. So, if we have a 3/5 quorum, we can decide that for children A, > B, C, and D, errors cannot be ignored, but for child E, errors are not a > problem. > > As written, you are tying the semantics to each child BDS, and requiring > special code to double-check that the property is only ever set if the > BDS is used as the child of a quorum. Furthermore, if the property is > set, you are then changing what the child does in response to various > operations. > > What if you instead create a list property in the quorum parent? Maybe > along the lines of: > > # @child-errors-okay: #optional an array of named-node children where > errors will be ignored (Since 2.5, default empty) > > { 'struct': 'BlockdevOptionsQuorum', > 'data': { '*blkverify': 'bool', > 'children': [ 'BlockdevRef' ], > 'vote-threshold': 'int', > '*rewrite-corrupted': 'bool', > '*read-pattern': 'QuorumReadPattern', > '*child-errors-okay': ['str'] } } > > The above example of a 3/5 quorum, where only child E can ignore errors, > would then be represented as: > > { "children": [ "A", "B", "C", "D", "E" ], 'vote-threshold':3, > 'child-errors-okay': [ "E" ] } > > The code to ignore the errors is then done in the quorum itself (the BDS > for E does not have to care about a special ignore-errors property, but > just always returns the error as usual; and then the quorum is deciding > how to handle the error), and you are not polluting the BDS state for > something that is quorum-specific, because it is now the quorum itself > that tracks the special casing. > > Finally, why can't hot-plug/unplug of quorum members work? If you are > going to always ignore errors from a particular child, then why is that > child even part of the quorum? Isn't a better design to just not add > the child to the quorum until it is ready and won't be reporting errors? > > -- > Eric Blake eblake redhat com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK From MAILER-DAEMON Mon Sep 07 13:43:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ0Rl-0006GQ-3Q for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 13:43:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ0Ri-0006Cu-SW for qemu-block@nongnu.org; Mon, 07 Sep 2015 13:43:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ0Rf-0007QO-Ia for qemu-block@nongnu.org; Mon, 07 Sep 2015 13:43:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33389) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ0Rf-0007Ph-Da; Mon, 07 Sep 2015 13:43:07 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 416A32DD31A; Mon, 7 Sep 2015 17:43:06 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t87Hh386003403; Mon, 7 Sep 2015 13:43:04 -0400 Date: Mon, 7 Sep 2015 19:43:03 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150907174303.GH5529@noname.redhat.com> References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-7-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437414365-11881-7-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v4 06/38] block: Make bdrv_is_inserted() recursive X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 17:43:12 -0000 Am 20.07.2015 um 19:45 hat Max Reitz geschrieben: > If bdrv_is_inserted() is called on the top level BDS, it should make > sure all nodes in the BDS tree are actually inserted. > > Signed-off-by: Max Reitz > Reviewed-by: Eric Blake > Reviewed-by: Alberto Garcia > --- > block.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/block.c b/block.c > index 494e08e..1d27b6a 100644 > --- a/block.c > +++ b/block.c > @@ -3235,10 +3235,9 @@ bool bdrv_is_inserted(BlockDriverState *bs) > if (!drv) { > return false; > } > - if (!drv->bdrv_is_inserted) { > - return true; > - } > - return drv->bdrv_is_inserted(bs); > + return (!drv->bdrv_is_inserted || drv->bdrv_is_inserted(bs)) && > + (!bs->file || bdrv_is_inserted(bs->file)) && > + (!bs->backing_hd || bdrv_is_inserted(bs->backing_hd)); > } Hm... Recursion often makes the right semantics unclear. I think though what you're after here is good as a default behaviour, i.e. a non-leaf node is inserted iff all of its children are inserted. We can do things in various ways without breaking stuff because raw-posix is the only driver actually implementing .bdrv_is_inserted, but I think it would make most sense like this: * If a driver implements .bdrv_is_inserted, we use this (and only this) for determining whether a medium is inserted. * The default behaviour for drivers which don't have .bdrv_is_inserted is checking all children (in bs->children, not restricted to file and backing_hd, so that quorum etc. work) * Consequently, a driver that doesn't want all of its children considered (which may be a very valid desire), can implement its own handler and doesn't get the default handling then. This seems to be the most consistent with other recursive operations. Also, after this patch, raw_bsd.c should be able drop its implementation. Kevin From MAILER-DAEMON Mon Sep 07 14:03:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ0lf-0006EK-St for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 14:03:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ0ld-0006Ao-PQ for qemu-block@nongnu.org; Mon, 07 Sep 2015 14:03:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ0la-0000Uq-IF for qemu-block@nongnu.org; Mon, 07 Sep 2015 14:03:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56101) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ0la-0000UT-Bs; Mon, 07 Sep 2015 14:03:42 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 92C8780091; Mon, 7 Sep 2015 18:03:41 +0000 (UTC) Received: from [10.36.116.102] (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87I3a23009459 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 14:03:38 -0400 To: Kevin Wolf References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-7-git-send-email-mreitz@redhat.com> <20150907174303.GH5529@noname.redhat.com> From: Max Reitz Message-ID: <55EDD177.6030300@redhat.com> Date: Mon, 7 Sep 2015 20:03:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150907174303.GH5529@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BH7xpenl0AENO9ihoT5XtAgQge91XAcpG" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v4 06/38] block: Make bdrv_is_inserted() recursive X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 18:03:46 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --BH7xpenl0AENO9ihoT5XtAgQge91XAcpG Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 07.09.2015 19:43, Kevin Wolf wrote: > Am 20.07.2015 um 19:45 hat Max Reitz geschrieben: >> If bdrv_is_inserted() is called on the top level BDS, it should make >> sure all nodes in the BDS tree are actually inserted. >> >> Signed-off-by: Max Reitz >> Reviewed-by: Eric Blake >> Reviewed-by: Alberto Garcia >> --- >> block.c | 7 +++---- >> 1 file changed, 3 insertions(+), 4 deletions(-) >> >> diff --git a/block.c b/block.c >> index 494e08e..1d27b6a 100644 >> --- a/block.c >> +++ b/block.c >> @@ -3235,10 +3235,9 @@ bool bdrv_is_inserted(BlockDriverState *bs) >> if (!drv) { >> return false; >> } >> - if (!drv->bdrv_is_inserted) { >> - return true; >> - } >> - return drv->bdrv_is_inserted(bs); >> + return (!drv->bdrv_is_inserted || drv->bdrv_is_inserted(bs)) && >> + (!bs->file || bdrv_is_inserted(bs->file)) && >> + (!bs->backing_hd || bdrv_is_inserted(bs->backing_hd= )); >> } >=20 > Hm... Recursion often makes the right semantics unclear. I think though= > what you're after here is good as a default behaviour, i.e. a non-leaf > node is inserted iff all of its children are inserted. We can do things= > in various ways without breaking stuff because raw-posix is the only > driver actually implementing .bdrv_is_inserted, but I think it would > make most sense like this: >=20 > * If a driver implements .bdrv_is_inserted, we use this (and only this)= > for determining whether a medium is inserted. >=20 > * The default behaviour for drivers which don't have .bdrv_is_inserted > is checking all children (in bs->children, not restricted to file and= > backing_hd, so that quorum etc. work) >=20 > * Consequently, a driver that doesn't want all of its children > considered (which may be a very valid desire), can implement its own > handler and doesn't get the default handling then. >=20 > This seems to be the most consistent with other recursive operations. You're right, I'll change this patch accordingly. > Also, after this patch, raw_bsd.c should be able drop its > implementation. Indeed. Max --BH7xpenl0AENO9ihoT5XtAgQge91XAcpG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV7dF3AAoJEDuxQgLoOKyt4AYIAIfSHbyPbSSyzBx0FU7O1YMB 1b3IXu4OjMGJZ1hn+E+Ho5SHIWR9pGorGa8yPkrvnH10yls1r9dzWDOQCtNMiMBC Mdcl0KOKwGHAjnKtWUgHwQwMHksF9NOZ1TXIQfsA8RaEoGy04xS8BOAOL165lanM baoG5XnTFmtFGx6SQkdpRiWJl5GwUmMWnQRhAh1Fh+P8HDpAlCgSt5lIEAy2UG6H VhI7TRbYsuVkhezeS6/mf33v6VytOvXh/UxxsCgDYAv1rrOd736d/FGX86wTCwqH V6cJxd/RGrBMZ/rlzODyikA5L7DJqStD1tb2ZfPnhRZ3GR3lE8u3iwtzH90hEMg= =zeCT -----END PGP SIGNATURE----- --BH7xpenl0AENO9ihoT5XtAgQge91XAcpG-- From MAILER-DAEMON Mon Sep 07 14:04:04 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ0lw-0006b8-Ge for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 14:04:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ0lu-0006Ye-FR for qemu-block@nongnu.org; Mon, 07 Sep 2015 14:04:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ0ls-0000ky-M1 for qemu-block@nongnu.org; Mon, 07 Sep 2015 14:04:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46970) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ0ls-0000kr-HK; Mon, 07 Sep 2015 14:04:00 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 1993DC0B986F; Mon, 7 Sep 2015 18:04:00 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t87I3vas009550; Mon, 7 Sep 2015 14:03:58 -0400 Date: Mon, 7 Sep 2015 20:03:57 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150907180357.GI5529@noname.redhat.com> References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-8-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437414365-11881-8-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v4 07/38] block/quorum: Implement bdrv_is_inserted() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 18:04:03 -0000 Am 20.07.2015 um 19:45 hat Max Reitz geschrieben: > bdrv_is_inserted() should be invoked recursively on the children of > quorum. > > Signed-off-by: Max Reitz > Reviewed-by: Eric Blake > Reviewed-by: Alberto Garcia If you implement patch 6 like I suggested, this one could be dropped. Kevin From MAILER-DAEMON Mon Sep 07 14:04:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ0mk-0007uf-3J for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 14:04:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ0mh-0007pT-0w for qemu-block@nongnu.org; Mon, 07 Sep 2015 14:04:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ0mf-0001ZV-TG for qemu-block@nongnu.org; Mon, 07 Sep 2015 14:04:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41906) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ0mf-0001Yo-LL; Mon, 07 Sep 2015 14:04:49 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 38E458AE6C; Mon, 7 Sep 2015 18:04:49 +0000 (UTC) Received: from [10.36.116.102] (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87I4jYK017459 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 14:04:47 -0400 To: Kevin Wolf References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-8-git-send-email-mreitz@redhat.com> <20150907180357.GI5529@noname.redhat.com> From: Max Reitz Message-ID: <55EDD1BD.9000002@redhat.com> Date: Mon, 7 Sep 2015 20:04:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150907180357.GI5529@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="GjJX6v5QG6lI4GkrHhNNpACifGqHUS2QM" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v4 07/38] block/quorum: Implement bdrv_is_inserted() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 18:04:51 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --GjJX6v5QG6lI4GkrHhNNpACifGqHUS2QM Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 07.09.2015 20:03, Kevin Wolf wrote: > Am 20.07.2015 um 19:45 hat Max Reitz geschrieben: >> bdrv_is_inserted() should be invoked recursively on the children of >> quorum. >> >> Signed-off-by: Max Reitz >> Reviewed-by: Eric Blake >> Reviewed-by: Alberto Garcia >=20 > If you implement patch 6 like I suggested, this one could be dropped. Now that we have this infrastructure, yes. :-) Max --GjJX6v5QG6lI4GkrHhNNpACifGqHUS2QM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV7dG9AAoJEDuxQgLoOKytBRkH/Roscj2OEMO/KIqJyR/6c6Tz Y+t1XRGHxAhZo43nmshHojHYDUcZ3PP0t6UxZ32GNfgcm81V1tblObTeqEEIrtin //hvECi68J/zQzoLS+hUwrfyTky4RmMk7sH3qnGeJsTY8/9JBV8+PZ0G90ubDyjM MYNUUZDF2VRrqctfitBiw3pZmBJH3d5aDluumx3v/4PzSNh0/MPtq7ZxSWTiQ8zg XwUtF1ZYfM5sG1o5upJGmZMJaLGkP6XnHMvhW2ZrxrWWLeMfdpgZQHT7M0xJ/hAi jviR4PqZNbFC7cu6x8Wa68zvsFGyn+xT+DSISBWU59LY2k7nhXcRtk2eToJTc2g= =yLmK -----END PGP SIGNATURE----- --GjJX6v5QG6lI4GkrHhNNpACifGqHUS2QM-- From MAILER-DAEMON Mon Sep 07 14:13:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ0v2-0008ED-IU for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 14:13:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ0v1-0008Dy-0P for qemu-block@nongnu.org; Mon, 07 Sep 2015 14:13:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ0uw-0005DK-1c for qemu-block@nongnu.org; Mon, 07 Sep 2015 14:13:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44933) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ0uv-0005Cz-T5; Mon, 07 Sep 2015 14:13:21 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 688F48C1BE; Mon, 7 Sep 2015 18:13:21 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t87IDIgQ030382; Mon, 7 Sep 2015 14:13:19 -0400 Date: Mon, 7 Sep 2015 20:13:18 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150907181318.GJ5529@noname.redhat.com> References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-10-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437414365-11881-10-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v4 09/38] hw/block/fdc: Implement tray status X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 18:13:27 -0000 Am 20.07.2015 um 19:45 hat Max Reitz geschrieben: > The tray of an FDD is open iff there is no medium inserted (there are > only two states for an FDD: "medium inserted" or "no medium inserted"). > > This results in the tray being reported as open if qemu has been started > with the default floppy drive, which breaks some tests. Fix them. > > Signed-off-by: Max Reitz > Reviewed-by: Eric Blake > --- > hw/block/fdc.c | 20 ++++++++++++---- > tests/fdc-test.c | 4 +--- > tests/qemu-iotests/067.out | 60 +++++++--------------------------------------- > tests/qemu-iotests/071.out | 2 -- > tests/qemu-iotests/081.out | 1 - > tests/qemu-iotests/087.out | 6 ----- > 6 files changed, 25 insertions(+), 68 deletions(-) The test cases seem to need some rebasing. Kevin From MAILER-DAEMON Mon Sep 07 14:16:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ0xv-00029P-Jv for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 14:16:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ0xt-000299-2z for qemu-block@nongnu.org; Mon, 07 Sep 2015 14:16:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ0xo-0006tA-4g for qemu-block@nongnu.org; Mon, 07 Sep 2015 14:16:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57891) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ0xo-0006st-0C; Mon, 07 Sep 2015 14:16:20 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 5D59C80B5A; Mon, 7 Sep 2015 18:16:19 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t87IGGiU013733; Mon, 7 Sep 2015 14:16:17 -0400 Date: Mon, 7 Sep 2015 20:16:16 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150907181616.GK5529@noname.redhat.com> References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-8-git-send-email-mreitz@redhat.com> <20150907180357.GI5529@noname.redhat.com> <55EDD1BD.9000002@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ghzN8eJ9Qlbqn3iT" Content-Disposition: inline In-Reply-To: <55EDD1BD.9000002@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v4 07/38] block/quorum: Implement bdrv_is_inserted() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 18:16:26 -0000 --ghzN8eJ9Qlbqn3iT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 07.09.2015 um 20:04 hat Max Reitz geschrieben: > On 07.09.2015 20:03, Kevin Wolf wrote: > > Am 20.07.2015 um 19:45 hat Max Reitz geschrieben: > >> bdrv_is_inserted() should be invoked recursively on the children of > >> quorum. > >> > >> Signed-off-by: Max Reitz > >> Reviewed-by: Eric Blake > >> Reviewed-by: Alberto Garcia > >=20 > > If you implement patch 6 like I suggested, this one could be dropped. >=20 > Now that we have this infrastructure, yes. :-) It hardly ever feels like it, but sometimes we do make progress. :-) Kevin --ghzN8eJ9Qlbqn3iT Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJV7dRwAAoJEH8JsnLIjy/WV6QP/2YMFkI4n76Rxa0v7mljo+kc 55tUITkfBHEaNO3VIOQj7gBKr+iD19I0pg2zc6NHlGjzXWPSChAuI4xYXXJ3LLKQ 8XXb6UV/ur7OnrmZbLZ5nCln+gxuWfo2dd4zqAJaNMxr+/wSuzILJXPjCZ5eZeS/ HP3hUEoQziVnGtpc0PwxstaDy3rC/RPEN/XcWKJbo1NJ4isCrjOKImu/XKPwPJTq b61lP0YWMUgjaYd1hh1w6jtL9DQTnh/PSSBh1ZNUJnQFYr0U9hXjhTSC/vcLfkkN M900Jt4pw0ZYaOpE9os7hsl8NVeXI/0NxBV5fKS+WoMyNzt7ER6X1O2u3+VIt8U4 ZDX35bjMmxCVDDihP546TZurjeV/4lJ3vO5bluttPx3f4nJ8L0jD+qq6WBx4jlog 2wKo5d1d7LaXtiERwfiz3F2SaF0EbaVAmKjfbxP8ThdCOydi1qn93uWf5f1xqY8g 6MOeuicuYuNYKvs640kmH3GYftQaeHpawK9m86EFGPAhiTWh7eppUNmvmYzaFvj4 2ugNTm+kMMZnYZUoHGHHAyTNuK/xAzYPH7tyt0hKBRidAB+1hMcpqb0IBoQClVnp pajF+9TgMAoPjaTIOF7x8y2OUWRF/122pNS22lDzZyqKal5/jMtD/wOuGzujOSom 18xNaOO5q4O2pLhhjFx9 =q7Bm -----END PGP SIGNATURE----- --ghzN8eJ9Qlbqn3iT-- From MAILER-DAEMON Mon Sep 07 14:42:32 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ1NA-00019t-Kw for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 14:42:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ1N8-00017F-OZ for qemu-block@nongnu.org; Mon, 07 Sep 2015 14:42:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ1N5-0002CA-Gu for qemu-block@nongnu.org; Mon, 07 Sep 2015 14:42:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ1N5-0002Bx-AV; Mon, 07 Sep 2015 14:42:27 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id D416DC0B9869; Mon, 7 Sep 2015 18:42:26 +0000 (UTC) Received: from [10.36.116.102] (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87IgMYU021238 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 14:42:24 -0400 To: Wen Congyang , Eric Blake , qemu-block@nongnu.org References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <55E70F9B.20309@redhat.com> <55ED2655.1040405@cn.fujitsu.com> From: Max Reitz Message-ID: <55EDDA8E.6060900@redhat.com> Date: Mon, 7 Sep 2015 20:42:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55ED2655.1040405@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="AirLWD3Ec7BKC6DVww9FJI8xOt8lPHIIS" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 00/38] blockdev: BlockBackend and media X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 18:42:31 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --AirLWD3Ec7BKC6DVww9FJI8xOt8lPHIIS Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07.09.2015 07:53, Wen Congyang wrote: > On 09/02/2015 11:02 PM, Eric Blake wrote: >> On 07/20/2015 11:45 AM, Max Reitz wrote: >>> First of all: Thank you, Eric and Berto, for reviewing v3! And thank >>> you, Fam, for at least having a peek at it and being confident enough= to >>> base a series of your own on it. :-) >>> >>> This series reworks a lot regarding BlockBackend and media. Basically= , >>> it allows empty BlockBackends, that is BBs without a BDS tree. >>> >>> Before this series, empty drives are represented by a BlockBackend wi= th >>> an empty BDS attached to it (a BDS with a NULL driver). However, now = we >>> have BlockBackends, thus an empty drive should be represented by a >>> BlockBackend without any BDS tree attached to it. This is what this >>> series does. >> >> We've obviously missed 2.4; but now that 2.5 is open, are there plans = to >> get this series in sooner rather than later? Wen's work on dynamicall= y >> adding/deleting children from a quorum would benefit from the ability = to >> create a BDS without an associated BB, which in turn would help the CO= LO >> work. >> >=20 > This feature is very useful for COLO. COLO needs the following: > 1. adding/deleting children from a quorum dynamically > 2. allow references for backing files >=20 > The BDS without BB only can be created by the monitor command blockdev-= add. > How to create it in the command line? Right now: Not at all. Of course it would be possible to add a new command line parameter ("-blockdev"? "-bds"?) or option to drive ("backend=3Doff" or whatever), but right now I didn't see a need for that= =2E This series uses this so you can add a new medium for e.g. a CD drive at runtime. The backends remains attached to the drive, and you swap out the BDS tree. Thus, there was no need to add a medium via the command lin= e. Furthermore, often runtime configuration is a subset of command line configuration, i.e. you can always start the VM paused, invoke some QMP commands, and then continue the VM. Therefore I don't know whether we really need the ability to add BB-less BDS trees via the command line. Max --AirLWD3Ec7BKC6DVww9FJI8xOt8lPHIIS Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV7dqOAAoJEDuxQgLoOKytKZ4H/j4HXtccgq5HR/Inw4CJGW/F 2mcyJJlbPPV4tjFy0QObRC7ta8wWG0EHpmKkGgZEP99PbWNqNwGzg162C/EXhxvd z3LaoRWuuRBbii8UjCT5osOyTAhi0x7hjijTyEzGKMVKnBW5cSpvM/7xXkvxwbKj KAjbD//ZXLzMP144HEkI3MIC7vyrk5Nwp7odHvYy9JaRiugt4trVrliuPBc8nmlR CRcQrCDJHg/iY6iLI/GMDw7kVtu5ZFj7cpTe/whKry1D6W5O2P3mRz3pOnOqrI81 ZAGN1GxiNcP+sHvgkMVjTXhvqaRE8pypOzhaUM5uPMbunWtSmWCTsnyMIApx1K8= =1riy -----END PGP SIGNATURE----- --AirLWD3Ec7BKC6DVww9FJI8xOt8lPHIIS-- From MAILER-DAEMON Mon Sep 07 14:57:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ1bd-0006DM-CI for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 14:57:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ1bb-0006Aa-G3 for qemu-block@nongnu.org; Mon, 07 Sep 2015 14:57:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ1bX-0000G9-VC for qemu-block@nongnu.org; Mon, 07 Sep 2015 14:57:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45227) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ1bX-0000G2-Qe; Mon, 07 Sep 2015 14:57:23 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 396D7157757; Mon, 7 Sep 2015 18:57:23 +0000 (UTC) Received: from [10.36.116.102] (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87IvK4a024857 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 14:57:22 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1441638895-1445-1-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <55EDDE0F.50801@redhat.com> Date: Mon, 7 Sep 2015 20:57:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441638895-1445-1-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="thrX7D9tJT7Tnu6hKi8oqpqWaG6eSBwwG" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH] qcow2: Rename BDRVQcowState to BDRVQcow2State X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 18:57:28 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --thrX7D9tJT7Tnu6hKi8oqpqWaG6eSBwwG Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 07.09.2015 17:14, Kevin Wolf wrote: > BDRVQcowState is already used by qcow1, and gdb is always confused whic= h > one to use. Rename the qcow2 one so they can be distinguished. >=20 > Signed-off-by: Kevin Wolf > --- > block/qcow2-cache.c | 14 ++++----- > block/qcow2-cluster.c | 48 +++++++++++++++---------------- > block/qcow2-refcount.c | 58 ++++++++++++++++++------------------- > block/qcow2-snapshot.c | 20 ++++++------- > block/qcow2.c | 78 +++++++++++++++++++++++++-----------------= -------- > block/qcow2.h | 22 +++++++------- > 6 files changed, 120 insertions(+), 120 deletions(-) Reviewed-by: Max Reitz --thrX7D9tJT7Tnu6hKi8oqpqWaG6eSBwwG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV7d4QAAoJEDuxQgLoOKyt7MoH/RRT2Bj0JHIBMYCieV3SaYPE QWwx9qeXORdjdf4jkqJnJE2jf0XpZH6MyvB2Fyd1MUpX4AJwTriklZeTvUUPY0+L Tjx9U8M/n9LHbPNs+IIoeGIYxP1Fqb5bSx/AR9Ruka7uFBWRrN3vdbT0dU/+IOZz nGk8nHRqLpu1IzYq29+A0loJGE2TwnDcTYKr/edzgJ+2zHxAfMt0bz/MhonIGrbl rb9NUgPXVt/17z4lIoN5TR5ao2V+vRH8eXsmhZoAa9zqCljLxuUFUlxHyXWZXKuA 7tM7GXoLKXKMuAhiVY//nUlDk1AJsND56BifCEJsyEu1ilY/hHIu0U4AQNZK2VQ= =+Kum -----END PGP SIGNATURE----- --thrX7D9tJT7Tnu6hKi8oqpqWaG6eSBwwG-- From MAILER-DAEMON Mon Sep 07 15:38:34 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ2FO-0004PI-81 for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 15:38:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ2FL-0004La-KE for qemu-block@nongnu.org; Mon, 07 Sep 2015 15:38:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ2FI-0000sy-FL for qemu-block@nongnu.org; Mon, 07 Sep 2015 15:38:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36541) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ2FI-0000q3-Ax; Mon, 07 Sep 2015 15:38:28 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 20D2C461D2; Mon, 7 Sep 2015 19:38:27 +0000 (UTC) Received: from [10.36.116.102] (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87JcNnB019184 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 15:38:25 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> <1441632381-26638-9-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <55EDE7AE.6090303@redhat.com> Date: Mon, 7 Sep 2015 21:38:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441632381-26638-9-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="i8x0XHqB0tdTUI94CCbnP7AM5wtvkBJjw" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH v3 08/13] qcow2: Leave s unchanged on qcow2_update_options() failure X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 19:38:32 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --i8x0XHqB0tdTUI94CCbnP7AM5wtvkBJjw Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 07.09.2015 15:26, Kevin Wolf wrote: > On return, either all new options should be applied to BDRVQcowState (o= n > success), or all of the old settings should be preserved (on failure). >=20 > Signed-off-by: Kevin Wolf > --- > block/qcow2.c | 57 +++++++++++++++++++++++++++++++++++----------------= ------ > 1 file changed, 35 insertions(+), 22 deletions(-) Reviewed-by: Max Reitz --i8x0XHqB0tdTUI94CCbnP7AM5wtvkBJjw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV7eeuAAoJEDuxQgLoOKytMmsH/jxJHFv+kzubtiTE+M6FUCxs Zv3xm6fYSUJ0FQQ48z4090JNLe7/2h27oDdIrF1xpp3DoKpL9Afc4EyRqeMg+oTy BZZSkmXKvliyUrfPavFcCt65K64b3y9Ln3Row+we7FsLuScXZDGdm1m5S+BV50pu fX27SyGKTrn9SEOc+yHBo9yKq+zGf2t8IiMQzSUuk/yNT+cONfcqc3xTWYp9qKwc P/ppfXru2t/Hk79n17UrLuQ+tCnxfOO4TOqnMDo44PqcUanleIrp6bNMu9gVBH2e DSAjcHa8dCSU4bAcZn3O6pd7BrSofkrF3NNqrcYv7QMN5XUWk5OS1xhUI3kFlBQ= =3Lst -----END PGP SIGNATURE----- --i8x0XHqB0tdTUI94CCbnP7AM5wtvkBJjw-- From MAILER-DAEMON Mon Sep 07 15:41:11 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ2Hv-0005sF-RL for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 15:41:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57882) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ2Ht-0005rK-1r for qemu-block@nongnu.org; Mon, 07 Sep 2015 15:41:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ2Hp-0002Zz-SQ for qemu-block@nongnu.org; Mon, 07 Sep 2015 15:41:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57658) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ2Hp-0002Zt-NJ; Mon, 07 Sep 2015 15:41:05 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 38FEAC0B9863; Mon, 7 Sep 2015 19:35:13 +0000 (UTC) Received: from [10.36.116.102] (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87JZ9rh019523 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 15:35:11 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> <1441632381-26638-8-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <55EDE6ED.1070007@redhat.com> Date: Mon, 7 Sep 2015 21:35:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441632381-26638-8-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="P6199Xpmub1aWEu1lRIPNdxfqDl9ugCGQ" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH v3 07/13] qcow2: Move rest of option handling to qcow2_update_options() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 19:41:09 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --P6199Xpmub1aWEu1lRIPNdxfqDl9ugCGQ Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 07.09.2015 15:26, Kevin Wolf wrote: > With this commit, the handling of driver-specific options in > qcow2_open() is completely separated out into qcow2_update_options(). >=20 > Signed-off-by: Kevin Wolf > --- > block/qcow2.c | 134 +++++++++++++++++++++++++++++---------------------= -------- > 1 file changed, 68 insertions(+), 66 deletions(-) Reviewed-by: Max Reitz --P6199Xpmub1aWEu1lRIPNdxfqDl9ugCGQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV7ebtAAoJEDuxQgLoOKyt898IAKkGejTmx3RvwoJFkT7MeiA1 TjuVt/LcIPVjVhGkWIrrBS1CZOU+mh0iwyzVMtIhgIKWb2SY23wybzCIlAq5goI5 LlP+juBd8zvnxjsa7YISlQA4KKnL2jkO2i65j3h+rxMR1Yf2v1h/Gf2D5WGgxYiO xTyQGQYuSRJTQWoDGJs9uKChNKaFlHq6GrUSMp970IuUAqUhypLZmSDXNdRk2c4f Imub+h6aEsC5arrn9sr3my78S3VBReKLIKuoFj4fRgIGByHK5cmc2DJOhsCqHW48 odubufs8GI7No9iQ+1t4nWuAoD+h5SnqIJ9KzXcOtbSaizsP2jsQetZON50WzFA= =HnB7 -----END PGP SIGNATURE----- --P6199Xpmub1aWEu1lRIPNdxfqDl9ugCGQ-- From MAILER-DAEMON Mon Sep 07 15:41:51 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ2IZ-0006kJ-5c for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 15:41:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ2IW-0006fY-00 for qemu-block@nongnu.org; Mon, 07 Sep 2015 15:41:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ2IV-0002xR-5e for qemu-block@nongnu.org; Mon, 07 Sep 2015 15:41:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54254) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ2IU-0002vl-O5; Mon, 07 Sep 2015 15:41:47 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 720684AD5F; Mon, 7 Sep 2015 19:41:46 +0000 (UTC) Received: from [10.36.116.102] (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87JfhqT026514 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 15:41:44 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> <1441632381-26638-11-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <55EDE876.1090106@redhat.com> Date: Mon, 7 Sep 2015 21:41:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441632381-26638-11-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lo4xlKwdOdgn4vnIinOwkhFXC4N4rnrH2" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH v3 10/13] qcow2: Make qcow2_update_options() suitable for transactions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 19:41:49 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --lo4xlKwdOdgn4vnIinOwkhFXC4N4rnrH2 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 07.09.2015 15:26, Kevin Wolf wrote: > Before we can allow updating options at runtime with bdrv_reopen(), we > need to split the function into prepare/commit/abort parts. >=20 > Signed-off-by: Kevin Wolf > --- > block/qcow2.c | 113 +++++++++++++++++++++++++++++++++++++-------------= -------- > 1 file changed, 73 insertions(+), 40 deletions(-) Reviewed-by: Max Reitz --lo4xlKwdOdgn4vnIinOwkhFXC4N4rnrH2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV7eh2AAoJEDuxQgLoOKytPosH/RmvlvJVPz1xgi7eKJE8Vw82 bHPNgZKtS5i0bb28tW9v+aVA2HKpzo1LB5V5cgUUOVyGLg5a2hCvZTrx97/MCSOI Z/4frB1itLpghcwWVFRlg+LLJhJZbXVJVhLTuWUNSyKecMnoTwHPtgOUr585jWCl VFXa1H8XfkFFjk4dD3r0azLOGfQbsuCWHFVvbW9aW3kCsQuwoJIEb/Grv+eYQTdR jcBip/KCAeySpV8c5zoZ1sL/lt3f2XFriRnJs4tDSVwDAck8kj/di0eeI1AMUqKz XqOz16Oi9QjvVRgRijwOo6lvgowB9j+q6LkYl/hhGeEzkZqd26CtdgETGE/tylw= =eU7e -----END PGP SIGNATURE----- --lo4xlKwdOdgn4vnIinOwkhFXC4N4rnrH2-- From MAILER-DAEMON Mon Sep 07 15:45:05 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ2Lh-0000QQ-Mj for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 15:45:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ2Lf-0000P7-O5 for qemu-block@nongnu.org; Mon, 07 Sep 2015 15:45:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ2Lc-0003i7-Hv for qemu-block@nongnu.org; Mon, 07 Sep 2015 15:45:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46961) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ2Lc-0003i2-C8; Mon, 07 Sep 2015 15:45:00 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id F0C198EB30; Mon, 7 Sep 2015 19:44:59 +0000 (UTC) Received: from [10.36.116.102] (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87Jivnc005207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 15:44:58 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> <1441632381-26638-12-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <55EDE938.5070608@redhat.com> Date: Mon, 7 Sep 2015 21:44:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441632381-26638-12-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rX09RAUi1Rk4HBu4TClLrnfwTp5tO9E95" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH v3 11/13] qcow2: Support updating driver-specific options in reopen X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 19:45:04 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rX09RAUi1Rk4HBu4TClLrnfwTp5tO9E95 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 07.09.2015 15:26, Kevin Wolf wrote: > For updating the cache sizes or disabling lazy refcounts And updating the cache clean timer, too. > there is a bit= > more to do than just changing the variables, but otherwise we're all se= t > for changing options during bdrv_reopen(). >=20 > Just implement the missing pieces and hook the functions up in > bdrv_reopen(). >=20 > Signed-off-by: Kevin Wolf > --- > block/qcow2.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++= +------- > 1 file changed, 72 insertions(+), 9 deletions(-) Whether you mention it or not (can be fixed up when applying the patch, too): Reviewed-by: Max Reitz --rX09RAUi1Rk4HBu4TClLrnfwTp5tO9E95 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV7ek4AAoJEDuxQgLoOKytIDkH/jWxKRgybas3FLrmAaVINcdy 5B5EfDn2wwSggz776I1fpHc065JridxJ5oeDEvK9ljsVUddVfzad9h3IWMsgmvqX 2TbAxrbTVx7gw6IPk/m1qf63U5pYvcN3U11GYBfp0QyqikqggAATqu2g6Tlg0oCh YXNICJXYPWGriifDOLVioHF7OxZOVNR3zJtwPaCy3yuO82ojGzOTXY0QBSbbr1xW niUh6L2y+UCOdV7XOxCf3hm5UhlpU2LA49n4jwzBbCGxK23gfcg9Na/dHpBZMo8h G/pG+iBhfgFp556G+L4OdyYCjur8HUrA0YdKJmbvbK0VF9kiTyHMVF3lmGYYt70= =EMzc -----END PGP SIGNATURE----- --rX09RAUi1Rk4HBu4TClLrnfwTp5tO9E95-- From MAILER-DAEMON Mon Sep 07 15:46:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ2Mb-0001Eh-5U for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 15:46:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ2MY-0001BU-KX for qemu-block@nongnu.org; Mon, 07 Sep 2015 15:45:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ2MV-0004F8-FA for qemu-block@nongnu.org; Mon, 07 Sep 2015 15:45:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ2MV-0004F3-2t; Mon, 07 Sep 2015 15:45:55 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id C24C1C0B9863; Mon, 7 Sep 2015 19:45:54 +0000 (UTC) Received: from [10.36.116.102] (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t87Jjpoc027694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Sep 2015 15:45:53 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1441632381-26638-1-git-send-email-kwolf@redhat.com> <1441632381-26638-14-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <55EDE96F.2060009@redhat.com> Date: Mon, 7 Sep 2015 21:45:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441632381-26638-14-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="LrlvStCPlHClF12IBet5GirrvAXd5Wd14" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH v3 13/13] qemu-iotests: More qcow2 reopen tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2015 19:45:59 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --LrlvStCPlHClF12IBet5GirrvAXd5Wd14 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 07.09.2015 15:26, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > tests/qemu-iotests/137 | 145 +++++++++++++++++++++++++++++++++++++= ++++++++ > tests/qemu-iotests/137.out | 42 +++++++++++++ > tests/qemu-iotests/group | 1 + > 3 files changed, 188 insertions(+) > create mode 100755 tests/qemu-iotests/137 > create mode 100644 tests/qemu-iotests/137.out Reviewed-by: Max Reitz --LrlvStCPlHClF12IBet5GirrvAXd5Wd14 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV7elvAAoJEDuxQgLoOKytkAUH/3icNjva1Ye5SHwesDEkI6LQ bWsw1W2z45rPde6TTZ7MuGZavxjSibLi9a/340/Rvxoe72HoA3FZVBCH6O2yUMJi SPHj1QRrmdvNLD5xvsoJcUrqbRKUhDv9wGK01t3000+gdjmY9VS/WKoLSEBe8lc2 gCr01Pk+GeaOYt7scJ65lOsmv/9J8FjMDVZz/JtwSQkNnsU+JzXskwMVjpvl6cJP 7u4MhpIE0HKjlw/JejJQK9WX2J4eXhxLmxlQB7TcDAjBzwiHRqz68FawkZpm+qib Ovz9xGaR+s6izJM6jB3QlfDtkZUWFK+IOsv3AI51mq6/WBZb4+U4h337+FhAHKE= =JAnU -----END PGP SIGNATURE----- --LrlvStCPlHClF12IBet5GirrvAXd5Wd14-- From MAILER-DAEMON Mon Sep 07 20:47:07 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ73z-0001ml-H0 for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 20:47:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ73w-0001m2-Je for qemu-block@nongnu.org; Mon, 07 Sep 2015 20:47:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ73s-0003CZ-L9 for qemu-block@nongnu.org; Mon, 07 Sep 2015 20:47:04 -0400 Received: from [59.151.112.132] (port=18184 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ73r-0003CF-Sx; Mon, 07 Sep 2015 20:47:00 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100448511" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 Sep 2015 08:49:55 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t880kgTi011025; Tue, 8 Sep 2015 08:46:42 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 8 Sep 2015 08:46:53 +0800 To: "Dr. David Alan Gilbert" , Eric Blake References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-7-git-send-email-wency@cn.fujitsu.com> <55E72422.30301@redhat.com> <20150907165638.GJ2337@work-vm> From: Wen Congyang Message-ID: <55EE2FEC.8080408@cn.fujitsu.com> Date: Tue, 8 Sep 2015 08:46:36 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150907165638.GJ2337@work-vm> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , Fam Zheng , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Michael R. Hines" , Max Reitz , Gonglei , Stefan Hajnoczi , Paolo Bonzini , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 06/16] quorum: allow ignoring child errors X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 00:47:06 -0000 On 09/08/2015 12:56 AM, Dr. David Alan Gilbert wrote: > * Eric Blake (eblake@redhat.com) wrote: >> On 09/02/2015 02:51 AM, Wen Congyang wrote: >>> If the child is not ready, read/write/getlength/flush will >>> return -errno. It is not critical error, and can be ignored: >>> 1. read/write: >>> Just not report the error event. >> >> What happens if all the children report an error? Or is the threshold >> at play here? > > I think it's interesting because in the COLO case the intention isn't > really about a threshold (in the way you might use for RAID or mirroring), > it's that one of the stores is local (and not expected to error) and one > is somewhere over a network, so if it fails you don't want to stop > the local VM working. > > However, if it fails we do need to know about it; if any write to > the secondary stops then the fault-tolerance has failed (at least for > that drive); so we should do *something* - I'm not sure what though. The filter driver replication catches this error, and the COLO framework will get this error when doing checkpoint. Thanks Wen Congyang > > Dave > > >> For example, if you have a threshold of 3/5, then I'm assuming that if >> up to two children return an errno, then it is okay to ignore; but if >> three or more return an errno, you haven't met threshold, so the I/O >> must fail. >> >> Are you ignoring ALL errors (including things like EACCES), or just EIO >> errors? >> >> >>> 2. getlength: >>> just ignore it. If all children's getlength return -errno, >>> and be ignored, return -EIO. >>> 3. flush: >>> Just ignore it. If all children's getlength return -errno, >> >> s/getlength/flush/ >> >>> and be ignored, return 0. >> >> Yuck - claiming success when all of the children fail feels dangerous. >> >>> >>> Usage: children.x.ignore-errors=true >>> >>> Signed-off-by: Wen Congyang >>> Signed-off-by: zhanghailiang >>> Signed-off-by: Gonglei >>> Cc: Alberto Garcia >>> --- >>> block/quorum.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++---- >> >> Interface review only: >> >>> +++ b/qapi/block-core.json >>> @@ -1411,6 +1411,8 @@ >>> # @allow-write-backing-file: #optional whether the backing file is opened in >>> # read-write mode. It is only for backing file >>> # (Since 2.5 default: false) >>> +# @ignore-errors: #options whether the child's I/O error should be ignored. >> >> s/options/optional/ >> s/error/errors/ >> >>> +# it is only for quorum's child.(Since 2.5 default: false) >> >> Space after '.' in English sentences. >> >> The fact that you are documenting that this option can only be specified >> for quorum children makes me wonder if it belongs better as an option in >> BlockdevOptionsQuorum rather than BlockdevOptionsBase. >> >> Semantically, it sounds like you are trying to allow for a per-child >> decision of whether this particular child's errors matter to the overall >> quorum. So, if we have a 3/5 quorum, we can decide that for children A, >> B, C, and D, errors cannot be ignored, but for child E, errors are not a >> problem. >> >> As written, you are tying the semantics to each child BDS, and requiring >> special code to double-check that the property is only ever set if the >> BDS is used as the child of a quorum. Furthermore, if the property is >> set, you are then changing what the child does in response to various >> operations. >> >> What if you instead create a list property in the quorum parent? Maybe >> along the lines of: >> >> # @child-errors-okay: #optional an array of named-node children where >> errors will be ignored (Since 2.5, default empty) >> >> { 'struct': 'BlockdevOptionsQuorum', >> 'data': { '*blkverify': 'bool', >> 'children': [ 'BlockdevRef' ], >> 'vote-threshold': 'int', >> '*rewrite-corrupted': 'bool', >> '*read-pattern': 'QuorumReadPattern', >> '*child-errors-okay': ['str'] } } >> >> The above example of a 3/5 quorum, where only child E can ignore errors, >> would then be represented as: >> >> { "children": [ "A", "B", "C", "D", "E" ], 'vote-threshold':3, >> 'child-errors-okay': [ "E" ] } >> >> The code to ignore the errors is then done in the quorum itself (the BDS >> for E does not have to care about a special ignore-errors property, but >> just always returns the error as usual; and then the quorum is deciding >> how to handle the error), and you are not polluting the BDS state for >> something that is quorum-specific, because it is now the quorum itself >> that tracks the special casing. >> >> Finally, why can't hot-plug/unplug of quorum members work? If you are >> going to always ignore errors from a particular child, then why is that >> child even part of the quorum? Isn't a better design to just not add >> the child to the quorum until it is ready and won't be reporting errors? >> >> -- >> Eric Blake eblake redhat com +1-919-301-3266 >> Libvirt virtualization library http://libvirt.org >> > > > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK > . > From MAILER-DAEMON Mon Sep 07 23:29:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ9ar-00051Z-A7 for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 23:29:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ9ao-0004vC-Ch for qemu-block@nongnu.org; Mon, 07 Sep 2015 23:29:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ9an-00026i-GF for qemu-block@nongnu.org; Mon, 07 Sep 2015 23:29:10 -0400 Received: from [59.151.112.132] (port=13270 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ9ak-00024k-CU; Mon, 07 Sep 2015 23:29:06 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100454547" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 Sep 2015 11:31:56 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t883SjT7021881; Tue, 8 Sep 2015 11:28:45 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 8 Sep 2015 11:28:57 +0800 From: Wen Congyang To: qemu devel , Paolo Bonzini , Kevin Wolf , Stefan Hajnoczi , qemu block , Jeff Cody Date: Tue, 8 Sep 2015 11:28:33 +0800 Message-ID: <1441682913-14320-3-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441682913-14320-1-git-send-email-wency@cn.fujitsu.com> References: <1441682913-14320-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Wen Congyang Subject: [Qemu-block] [PATCH v2 2/2] Backup: don't do copy-on-read in before_write_notifier X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 03:29:11 -0000 We will copy data in before_write_notifier to do backup. It is a nested I/O request, so we cannot do copy-on-read. The steps to reproduce it: 1. -drive copy-on-read=on,... // qemu option 2. drive_backup -f disk0 /path_to_backup.img // monitor command Signed-off-by: Wen Congyang Tested-by: Jeff Cody --- block/backup.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/block/backup.c b/block/backup.c index 965654d..5696431 100644 --- a/block/backup.c +++ b/block/backup.c @@ -89,7 +89,8 @@ static void cow_request_end(CowRequest *req) static int coroutine_fn backup_do_cow(BlockDriverState *bs, int64_t sector_num, int nb_sectors, - bool *error_is_read) + bool *error_is_read, + bool is_write_notifier) { BackupBlockJob *job = (BackupBlockJob *)bs->job; CowRequest cow_request; @@ -129,8 +130,14 @@ static int coroutine_fn backup_do_cow(BlockDriverState *bs, iov.iov_len = n * BDRV_SECTOR_SIZE; qemu_iovec_init_external(&bounce_qiov, &iov, 1); - ret = bdrv_co_readv(bs, start * BACKUP_SECTORS_PER_CLUSTER, n, - &bounce_qiov); + if (is_write_notifier) { + ret = bdrv_co_no_copy_on_readv(bs, + start * BACKUP_SECTORS_PER_CLUSTER, + n, &bounce_qiov); + } else { + ret = bdrv_co_readv(bs, start * BACKUP_SECTORS_PER_CLUSTER, n, + &bounce_qiov); + } if (ret < 0) { trace_backup_do_cow_read_fail(job, start, ret); if (error_is_read) { @@ -190,7 +197,7 @@ static int coroutine_fn backup_before_write_notify( assert((req->offset & (BDRV_SECTOR_SIZE - 1)) == 0); assert((req->bytes & (BDRV_SECTOR_SIZE - 1)) == 0); - return backup_do_cow(req->bs, sector_num, nb_sectors, NULL); + return backup_do_cow(req->bs, sector_num, nb_sectors, NULL, true); } static void backup_set_speed(BlockJob *job, int64_t speed, Error **errp) @@ -303,7 +310,8 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job) return ret; } ret = backup_do_cow(bs, cluster * BACKUP_SECTORS_PER_CLUSTER, - BACKUP_SECTORS_PER_CLUSTER, &error_is_read); + BACKUP_SECTORS_PER_CLUSTER, &error_is_read, + false); if ((ret < 0) && backup_error_action(job, error_is_read, -ret) == BLOCK_ERROR_ACTION_REPORT) { @@ -408,7 +416,7 @@ static void coroutine_fn backup_run(void *opaque) } /* FULL sync mode we copy the whole drive. */ ret = backup_do_cow(bs, start * BACKUP_SECTORS_PER_CLUSTER, - BACKUP_SECTORS_PER_CLUSTER, &error_is_read); + BACKUP_SECTORS_PER_CLUSTER, &error_is_read, false); if (ret < 0) { /* Depending on error action, fail now or retry cluster */ BlockErrorAction action = -- 2.4.3 From MAILER-DAEMON Mon Sep 07 23:29:14 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ9as-00054F-Ic for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 23:29:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ9ao-0004vf-No for qemu-block@nongnu.org; Mon, 07 Sep 2015 23:29:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ9an-00026s-MT for qemu-block@nongnu.org; Mon, 07 Sep 2015 23:29:10 -0400 Received: from [59.151.112.132] (port=13270 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ9ai-00024k-Pl; Mon, 07 Sep 2015 23:29:05 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100454546" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 Sep 2015 11:31:55 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t883Sil2021877; Tue, 8 Sep 2015 11:28:45 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 8 Sep 2015 11:28:56 +0800 From: Wen Congyang To: qemu devel , Paolo Bonzini , Kevin Wolf , Stefan Hajnoczi , qemu block , Jeff Cody Date: Tue, 8 Sep 2015 11:28:32 +0800 Message-ID: <1441682913-14320-2-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441682913-14320-1-git-send-email-wency@cn.fujitsu.com> References: <1441682913-14320-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Wen Congyang Subject: [Qemu-block] [PATCH v2 1/2] block: Introduce a new API bdrv_co_no_copy_on_readv() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 03:29:11 -0000 In some cases, we need to disable copy-on-read, and just read the data. Signed-off-by: Wen Congyang --- block/io.c | 12 +++++++++++- include/block/block.h | 9 ++++++--- trace-events | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/block/io.c b/block/io.c index d4bc83b..94e18e6 100644 --- a/block/io.c +++ b/block/io.c @@ -932,7 +932,8 @@ static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs, return ret; } - if (bs->copy_on_read) { + /* Don't do copy-on-read if we read data before write operation */ + if (bs->copy_on_read && !(flags & BDRV_REQ_NO_COPY_ON_READ)) { flags |= BDRV_REQ_COPY_ON_READ; } @@ -1001,6 +1002,15 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, 0); } +int coroutine_fn bdrv_co_no_copy_on_readv(BlockDriverState *bs, + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) +{ + trace_bdrv_co_no_copy_on_readv(bs, sector_num, nb_sectors); + + return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, + BDRV_REQ_NO_COPY_ON_READ); +} + int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { diff --git a/include/block/block.h b/include/block/block.h index 608cd4e..c80d95d 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -51,15 +51,16 @@ typedef struct BlockFragInfo { } BlockFragInfo; typedef enum { - BDRV_REQ_COPY_ON_READ = 0x1, - BDRV_REQ_ZERO_WRITE = 0x2, + BDRV_REQ_COPY_ON_READ = 0x1, + BDRV_REQ_ZERO_WRITE = 0x2, /* The BDRV_REQ_MAY_UNMAP flag is used to indicate that the block driver * is allowed to optimize a write zeroes request by unmapping (discarding) * blocks if it is guaranteed that the result will read back as * zeroes. The flag is only passed to the driver if the block device is * opened with BDRV_O_UNMAP. */ - BDRV_REQ_MAY_UNMAP = 0x4, + BDRV_REQ_MAY_UNMAP = 0x4, + BDRV_REQ_NO_COPY_ON_READ = 0x8, } BdrvRequestFlags; typedef struct BlockSizes { @@ -253,6 +254,8 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); +int coroutine_fn bdrv_co_no_copy_on_readv(BlockDriverState *bs, + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); /* diff --git a/trace-events b/trace-events index 0a82f0c..3a7d163 100644 --- a/trace-events +++ b/trace-events @@ -69,6 +69,7 @@ bdrv_aio_write_zeroes(void *bs, int64_t sector_num, int nb_sectors, int flags, v bdrv_lock_medium(void *bs, bool locked) "bs %p locked %d" bdrv_co_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" bdrv_co_copy_on_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" +bdrv_co_no_copy_on_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" bdrv_co_writev(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" bdrv_co_write_zeroes(void *bs, int64_t sector_num, int nb_sector, int flags) "bs %p sector_num %"PRId64" nb_sectors %d flags %#x" bdrv_co_io_em(void *bs, int64_t sector_num, int nb_sectors, int is_write, void *acb) "bs %p sector_num %"PRId64" nb_sectors %d is_write %d acb %p" -- 2.4.3 From MAILER-DAEMON Mon Sep 07 23:29:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZ9ar-000528-Et for mharc-qemu-block@gnu.org; Mon, 07 Sep 2015 23:29:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ9ao-0004vD-DM for qemu-block@nongnu.org; Mon, 07 Sep 2015 23:29:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ9an-00026n-GV for qemu-block@nongnu.org; Mon, 07 Sep 2015 23:29:10 -0400 Received: from [59.151.112.132] (port=56149 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ9aj-00024i-4t; Mon, 07 Sep 2015 23:29:05 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100454544" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 Sep 2015 11:31:54 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t883Shpb021874; Tue, 8 Sep 2015 11:28:44 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 8 Sep 2015 11:28:55 +0800 From: Wen Congyang To: qemu devel , Paolo Bonzini , Kevin Wolf , Stefan Hajnoczi , qemu block , Jeff Cody Date: Tue, 8 Sep 2015 11:28:31 +0800 Message-ID: <1441682913-14320-1-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Wen Congyang Subject: [Qemu-block] [PATCH v2 0/2] Block: don't do copy-on-read in before_write_notifier X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 03:29:11 -0000 If we do copy-on-read in before_write_notifier, qemu will be crashed. The backtrace is: Program terminated with signal 6, Aborted. #0 0x00007f5d69207b55 in raise () from /lib64/libc.so.6 (gdb) bt #0 0x00007f5d69207b55 in raise () from /lib64/libc.so.6 #1 0x00007f5d69209131 in abort () from /lib64/libc.so.6 #2 0x00007f5d69200a10 in __assert_fail () from /lib64/libc.so.6 #3 0x00007f5d6cb3a0d5 in wait_serialising_requests (self=0x7f5d36feeae0) at block/io.c:452 #4 0x00007f5d6cb3ae79 in bdrv_aligned_preadv (bs=0x7f5d6d570170, req=0x7f5d36feeae0, offset=93585408, bytes=65536, align=512, qiov=0x7f5d36feec90, flags=1) at block/io.c:847 #5 0x00007f5d6cb3b3cc in bdrv_co_do_preadv (bs=0x7f5d6d570170, offset=93585408, bytes=65536, qiov=0x7f5d36feec90, flags=BDRV_REQ_COPY_ON_READ) at block/io.c:971 #6 0x00007f5d6cb3b497 in bdrv_co_do_readv (bs=0x7f5d6d570170, sector_num=182784, nb_sectors=128, qiov=0x7f5d36feec90, flags=0) at block/io.c:993 #7 0x00007f5d6cb3b504 in bdrv_co_readv (bs=0x7f5d6d570170, sector_num=182784, nb_sectors=128, qiov=0x7f5d36feec90) at block/io.c:1002 #8 0x00007f5d6c8eaf42 in backup_do_cow (bs=0x7f5d6d570170, sector_num=182784, nb_sectors=8, error_is_read=0x0) at block/backup.c:132 #9 0x00007f5d6c8eb6cf in backup_before_write_notify (notifier=0x7f5d435fcf30, opaque=0x7f5d36feee40) at block/backup.c:193 #10 0x00007f5d6cb9ec33 in notifier_with_return_list_notify (list=0x7f5d6d5731f8, data=0x7f5d36feee40) at util/notify.c:65 #11 0x00007f5d6cb3bcc8 in bdrv_aligned_pwritev (bs=0x7f5d6d570170, req=0x7f5d36feee40, offset=93585408, bytes=4096, qiov=0x7f5d6eef4cf8, flags=0) at block/io.c:1126 #12 0x00007f5d6cb3c79e in bdrv_co_do_pwritev (bs=0x7f5d6d570170, offset=93585408, bytes=4096, qiov=0x7f5d6eef4cf8, flags=0) at block/io.c:1364 #13 0x00007f5d6cb3c867 in bdrv_co_do_writev (bs=0x7f5d6d570170, sector_num=182784, nb_sectors=8, qiov=0x7f5d6eef4cf8, flags=0) at block/io.c:1388 #14 0x00007f5d6cb3ea09 in bdrv_co_do_rw (opaque=0x7f5d38465ee0) at block/io.c:2123 #15 0x00007f5d6caeb03d in coroutine_trampoline (i0=944146112, i1=32605) at coroutine-ucontext.c:80 #16 0x00007f5d69218be0 in __correctly_grouped_prefixwc () from /lib64/libc.so.6 #17 0x0000000000000000 in ?? () Wen Congyang (2): block: Introduce a new API bdrv_co_no_copy_on_readv() Backup: don't do copy-on-read in before_write_notifier block/backup.c | 20 ++++++++++++++------ block/io.c | 12 +++++++++++- include/block/block.h | 9 ++++++--- trace-events | 1 + 4 files changed, 32 insertions(+), 10 deletions(-) -- 2.4.3 From MAILER-DAEMON Tue Sep 08 01:54:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZBrN-00050A-W5 for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 01:54:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZBrL-0004wN-Ba for qemu-block@nongnu.org; Tue, 08 Sep 2015 01:54:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZBrK-0004jc-6i for qemu-block@nongnu.org; Tue, 08 Sep 2015 01:54:23 -0400 Received: from [59.151.112.132] (port=8307 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZBrE-0004hi-Ux; Tue, 08 Sep 2015 01:54:17 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100458737" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 Sep 2015 13:57:09 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t885rxQ9029006; Tue, 8 Sep 2015 13:53:59 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 8 Sep 2015 13:54:10 +0800 To: Max Reitz , References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-30-git-send-email-mreitz@redhat.com> From: Wen Congyang Message-ID: <55EE77F1.8080007@cn.fujitsu.com> Date: Tue, 8 Sep 2015 13:53:53 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1437414365-11881-30-git-send-email-mreitz@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 29/38] blockdev: Add blockdev-insert-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 05:54:24 -0000 On 07/21/2015 01:45 AM, 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). Is it OK to insert a medium to more than one BB? Thanks Wen Congyang > > Signed-off-by: Max Reitz > --- > blockdev.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ > qapi/block-core.json | 17 +++++++++++++++++ > qmp-commands.hx | 37 +++++++++++++++++++++++++++++++++++++ > 3 files changed, 102 insertions(+) > > diff --git a/blockdev.c b/blockdev.c > index 481760a..a80d0e2 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -2164,6 +2164,54 @@ void qmp_blockdev_remove_medium(const char *device, Error **errp) > } > } > > +static void qmp_blockdev_insert_anon_medium(const char *device, > + BlockDriverState *bs, Error **errp) > +{ > + BlockBackend *blk; > + bool has_device; > + > + blk = blk_by_name(device); > + if (!blk) { > + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, > + "Device '%s' not found", device); > + return; > + } > + > + /* For BBs without a device, we can exchange the BDS tree at will */ > + has_device = blk_get_attached_dev(blk); > + > + if (has_device && !blk_dev_has_removable_media(blk)) { > + error_setg(errp, "Device '%s' is not removable", device); > + return; > + } > + > + if (has_device && !blk_dev_is_tray_open(blk)) { > + error_setg(errp, "Tray of device '%s' is not open", device); > + return; > + } > + > + if (blk_bs(blk)) { > + error_setg(errp, "There already is a medium in device '%s'", device); > + return; > + } > + > + blk_insert_bs(blk, bs); > +} > + > +void qmp_blockdev_insert_medium(const char *device, const char *node_name, > + Error **errp) > +{ > + BlockDriverState *bs; > + > + bs = bdrv_find_node(node_name); > + if (!bs) { > + error_setg(errp, "Node '%s' not found", node_name); > + return; > + } > + > + qmp_blockdev_insert_anon_medium(device, bs, errp); > +} > + > /* throttling disk I/O limits */ > void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, > int64_t bps_wr, > diff --git a/qapi/block-core.json b/qapi/block-core.json > index 63a83e4..84c9b23 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -1925,6 +1925,23 @@ > { 'command': 'blockdev-remove-medium', > 'data': { 'device': 'str' } } > > +## > +# @blockdev-insert-medium: > +# > +# Inserts a medium (a block driver state tree) into a block device. That block > +# device's tray must currently be open and there must be no medium inserted > +# already. > +# > +# @device: block device name > +# > +# @node-name: name of a node in the block driver state graph > +# > +# Since: 2.5 > +## > +{ 'command': 'blockdev-insert-medium', > + 'data': { 'device': 'str', > + 'node-name': 'str'} } > + > > ## > # @BlockErrorAction > diff --git a/qmp-commands.hx b/qmp-commands.hx > index ff6c572..b4c34fe 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -3991,6 +3991,43 @@ Example: > EQMP > > { > + .name = "blockdev-insert-medium", > + .args_type = "device:s,node-name:s", > + .mhandler.cmd_new = qmp_marshal_input_blockdev_insert_medium, > + }, > + > +SQMP > +blockdev-insert-medium > +---------------------- > + > +Inserts a medium (a block driver state tree) into a block device. That block > +device's tray must currently be open and there must be no medium inserted > +already. > + > +Arguments: > + > +- "device": block device name (json-string) > +- "node-name": root node of the BDS tree to insert into the block device > + > +Example: > + > +-> { "execute": "blockdev-add", > + "arguments": { "options": { "node-name": "node0", > + "driver": "raw", > + "file": { "driver": "file", > + "filename": "fedora.iso" } } } } > + > +<- { "return": {} } > + > +-> { "execute": "blockdev-insert-medium", > + "arguments": { "device": "ide1-cd0", > + "node-name": "node0" } } > + > +<- { "return": {} } > + > +EQMP > + > + { > .name = "query-named-block-nodes", > .args_type = "", > .mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes, > From MAILER-DAEMON Tue Sep 08 05:10:53 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZEvV-00027N-HQ for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 05:10:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZEvS-00026G-Bz for qemu-block@nongnu.org; Tue, 08 Sep 2015 05:10:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZEvR-0001GA-1t for qemu-block@nongnu.org; Tue, 08 Sep 2015 05:10:50 -0400 Received: from [59.151.112.132] (port=52228 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZEvP-0001B6-NG; Tue, 08 Sep 2015 05:10:48 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100466819" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 Sep 2015 17:13:38 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t889ARjl009913; Tue, 8 Sep 2015 17:10:28 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 8 Sep 2015 17:10:39 +0800 To: Eric Blake , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi References: <1439279489-13338-1-git-send-email-wency@cn.fujitsu.com> <1439279489-13338-4-git-send-email-wency@cn.fujitsu.com> <55E4917A.9010703@redhat.com> <55E4F4FF.1000504@cn.fujitsu.com> <55E5C4B0.1080301@redhat.com> From: Wen Congyang Message-ID: <55EEA5FE.2000507@cn.fujitsu.com> Date: Tue, 8 Sep 2015 17:10:22 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55E5C4B0.1080301@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Patch for-2.5 v2 3/6] Add new block driver interface to add/delete a BDS's child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 09:10:51 -0000 On 09/01/2015 11:30 PM, Eric Blake wrote: > On 08/31/2015 06:44 PM, Wen Congyang wrote: > >>> >>>> + * Hot add/remove a BDS's child. So the user can take a child offline when >>>> + * it is broken and take a new child online >>>> + */ >>>> +void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp) >>>> +{ >>>> + >>>> + if (!bs->drv || !bs->drv->bdrv_add_child) { >>>> + error_setg(errp, "The BDS %s doesn't support adding a child", >>>> + bdrv_get_device_or_node_name(bs)); >>>> + return; >>>> + } >>>> + >>>> + bs->drv->bdrv_add_child(bs, options, errp); >>> >>> Should this also check that bs is not already a child of something? Or >>> a bit looser, we may want to allow a BDS to be a child of multiple trees >>> (a common shared backing file), but we still definitely don't want to >>> allow nonsensical loops such as trying to make a BDS be hot-added as its >>> own child. >>> >> >> hot-added BDS is a new BDS, but it is OK to check it here. I will update it >> in the next version. > > Design-wise, I think we really want to have the add-child operation be > handed a pre-opened BDS, rather than the options dictionary to open the > BDS itself. That is, we should use the existing blockdev-add (and > enhance it to support everything) to open the BDS, and then this command > should just attach that BDS as the new child (which is why it IS > important that we validate that the new BDS being added doesn't create > an invalid loop). > How to check it? The parent BDS can get all children. But the child doesn't know if it is some BDS's child. Thanks Wen Congyang From MAILER-DAEMON Tue Sep 08 05:13:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZEyC-0003P0-Ib for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 05:13:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZEy8-0003ML-UH for qemu-block@nongnu.org; Tue, 08 Sep 2015 05:13:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZEy7-0002ey-S0 for qemu-block@nongnu.org; Tue, 08 Sep 2015 05:13:36 -0400 Received: from [59.151.112.132] (port=2629 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZExx-0002c5-BT; Tue, 08 Sep 2015 05:13:31 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100466944" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 Sep 2015 17:16:18 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t889D7N6010108; Tue, 8 Sep 2015 17:13:08 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 8 Sep 2015 17:13:19 +0800 To: Max Reitz , References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-30-git-send-email-mreitz@redhat.com> From: Wen Congyang Message-ID: <55EEA69E.4010706@cn.fujitsu.com> Date: Tue, 8 Sep 2015 17:13:02 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1437414365-11881-30-git-send-email-mreitz@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 29/38] blockdev: Add blockdev-insert-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 09:13:38 -0000 On 07/21/2015 01:45 AM, 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). > > Signed-off-by: Max Reitz > --- > blockdev.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ > qapi/block-core.json | 17 +++++++++++++++++ > qmp-commands.hx | 37 +++++++++++++++++++++++++++++++++++++ > 3 files changed, 102 insertions(+) > > diff --git a/blockdev.c b/blockdev.c > index 481760a..a80d0e2 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -2164,6 +2164,54 @@ void qmp_blockdev_remove_medium(const char *device, Error **errp) > } > } > > +static void qmp_blockdev_insert_anon_medium(const char *device, > + BlockDriverState *bs, Error **errp) > +{ > + BlockBackend *blk; > + bool has_device; > + > + blk = blk_by_name(device); > + if (!blk) { > + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, > + "Device '%s' not found", device); > + return; > + } > + > + /* For BBs without a device, we can exchange the BDS tree at will */ > + has_device = blk_get_attached_dev(blk); > + > + if (has_device && !blk_dev_has_removable_media(blk)) { > + error_setg(errp, "Device '%s' is not removable", device); > + return; > + } > + > + if (has_device && !blk_dev_is_tray_open(blk)) { > + error_setg(errp, "Tray of device '%s' is not open", device); > + return; > + } > + > + if (blk_bs(blk)) { > + error_setg(errp, "There already is a medium in device '%s'", device); > + return; > + } > + > + blk_insert_bs(blk, bs); > +} > + > +void qmp_blockdev_insert_medium(const char *device, const char *node_name, > + Error **errp) > +{ > + BlockDriverState *bs; > + > + bs = bdrv_find_node(node_name); > + if (!bs) { > + error_setg(errp, "Node '%s' not found", node_name); > + return; > + } Hmm, it is OK if the bs is not top BDS? Thanks Wen Congyang > + > + qmp_blockdev_insert_anon_medium(device, bs, errp); > +} > + > /* throttling disk I/O limits */ > void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, > int64_t bps_wr, > diff --git a/qapi/block-core.json b/qapi/block-core.json > index 63a83e4..84c9b23 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -1925,6 +1925,23 @@ > { 'command': 'blockdev-remove-medium', > 'data': { 'device': 'str' } } > > +## > +# @blockdev-insert-medium: > +# > +# Inserts a medium (a block driver state tree) into a block device. That block > +# device's tray must currently be open and there must be no medium inserted > +# already. > +# > +# @device: block device name > +# > +# @node-name: name of a node in the block driver state graph > +# > +# Since: 2.5 > +## > +{ 'command': 'blockdev-insert-medium', > + 'data': { 'device': 'str', > + 'node-name': 'str'} } > + > > ## > # @BlockErrorAction > diff --git a/qmp-commands.hx b/qmp-commands.hx > index ff6c572..b4c34fe 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -3991,6 +3991,43 @@ Example: > EQMP > > { > + .name = "blockdev-insert-medium", > + .args_type = "device:s,node-name:s", > + .mhandler.cmd_new = qmp_marshal_input_blockdev_insert_medium, > + }, > + > +SQMP > +blockdev-insert-medium > +---------------------- > + > +Inserts a medium (a block driver state tree) into a block device. That block > +device's tray must currently be open and there must be no medium inserted > +already. > + > +Arguments: > + > +- "device": block device name (json-string) > +- "node-name": root node of the BDS tree to insert into the block device > + > +Example: > + > +-> { "execute": "blockdev-add", > + "arguments": { "options": { "node-name": "node0", > + "driver": "raw", > + "file": { "driver": "file", > + "filename": "fedora.iso" } } } } > + > +<- { "return": {} } > + > +-> { "execute": "blockdev-insert-medium", > + "arguments": { "device": "ide1-cd0", > + "node-name": "node0" } } > + > +<- { "return": {} } > + > +EQMP > + > + { > .name = "query-named-block-nodes", > .args_type = "", > .mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes, > From MAILER-DAEMON Tue Sep 08 05:35:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZFJD-0003BQ-QK for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 05:35:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZFJA-00039o-Oo for qemu-block@nongnu.org; Tue, 08 Sep 2015 05:35:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZFJ5-0003lC-9c for qemu-block@nongnu.org; Tue, 08 Sep 2015 05:35:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54814) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZFJ5-0003kt-5U; Tue, 08 Sep 2015 05:35:15 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id BC267C0AE66B; Tue, 8 Sep 2015 09:35:14 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t889ZDrx013976; Tue, 8 Sep 2015 05:35:14 -0400 Date: Tue, 8 Sep 2015 17:35:11 +0800 From: Fam Zheng To: "Denis V. Lunev" Message-ID: <20150908093511.GH24489@ad.nay.redhat.com> References: <1441699228-25767-1-git-send-email-den@openvz.org> <1441699228-25767-5-git-send-email-den@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441699228-25767-5-git-send-email-den@openvz.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-block@nongnu.org, qemu-devel@nongnu.org, Stefan Hajnoczi , Raushaniya Maksudova Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 4/5] disk_deadlines: add control of requests time expiration X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 09:35:21 -0000 On Tue, 09/08 11:00, Denis V. Lunev wrote: > typedef struct DiskDeadlines { > bool enabled; > + bool expired_tree; > + pthread_mutex_t mtx_tree; This won't compile on win32, probably use QemuMutex instead? In file included from /tmp/qemu-build/include/block/accounting.h:30:0, from /tmp/qemu-build/include/block/block.h:8, from /tmp/qemu-build/include/monitor/monitor.h:6, from /tmp/qemu-build/util/osdep.c:51: /tmp/qemu-build/include/block/disk-deadlines.h:38:5: error: unknown type name 'pthread_mutex_t' pthread_mutex_t mtx_tree; ^ /tmp/qemu-build/rules.mak:57: recipe for target 'util/osdep.o' failed From MAILER-DAEMON Tue Sep 08 05:42:50 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZFQQ-00075A-E8 for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 05:42:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZFQO-000747-QA for qemu-block@nongnu.org; Tue, 08 Sep 2015 05:42:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZFQO-0007lQ-11 for qemu-block@nongnu.org; Tue, 08 Sep 2015 05:42:48 -0400 Received: from relay.parallels.com ([195.214.232.42]:48055) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZFQI-0007hn-Gg; Tue, 08 Sep 2015 05:42:42 -0400 Received: from [10.67.48.55] (helo=mail.parallels.net) by relay.parallels.com with esmtps (TLSv1.2:AES256-SHA:256) (Exim 4.85) (envelope-from ) id 1ZZFQH-00057v-Hg; Tue, 08 Sep 2015 12:42:41 +0300 Received: from [10.30.2.139] (10.30.2.139) by MSK-EXCH1.sw.swsoft.com (10.67.48.55) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Tue, 8 Sep 2015 11:42:35 +0200 To: Fam Zheng References: <1441699228-25767-1-git-send-email-den@openvz.org> <1441699228-25767-5-git-send-email-den@openvz.org> <20150908093511.GH24489@ad.nay.redhat.com> From: "Denis V. Lunev" Message-ID: <55EEAD85.4080809@openvz.org> Date: Tue, 8 Sep 2015 12:42:29 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150908093511.GH24489@ad.nay.redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: US-EXCH.sw.swsoft.com (10.255.249.47) To MSK-EXCH1.sw.swsoft.com (10.67.48.55) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.214.232.42 Cc: Kevin Wolf , qemu-block@nongnu.org, qemu-devel@nongnu.org, Stefan Hajnoczi , Raushaniya Maksudova Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 4/5] disk_deadlines: add control of requests time expiration X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 09:42:49 -0000 On 09/08/2015 12:35 PM, Fam Zheng wrote: > On Tue, 09/08 11:00, Denis V. Lunev wrote: >> typedef struct DiskDeadlines { >> bool enabled; >> + bool expired_tree; >> + pthread_mutex_t mtx_tree; > This won't compile on win32, probably use QemuMutex instead? > > In file included from /tmp/qemu-build/include/block/accounting.h:30:0, > from /tmp/qemu-build/include/block/block.h:8, > from /tmp/qemu-build/include/monitor/monitor.h:6, > from /tmp/qemu-build/util/osdep.c:51: > /tmp/qemu-build/include/block/disk-deadlines.h:38:5: error: unknown type name 'pthread_mutex_t' > pthread_mutex_t mtx_tree; > ^ > /tmp/qemu-build/rules.mak:57: recipe for target 'util/osdep.o' failed > got this. Thank you From MAILER-DAEMON Tue Sep 08 09:48:37 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZJGH-0001gK-FH for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 09:48:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZJGD-0001bf-Ot for qemu-block@nongnu.org; Tue, 08 Sep 2015 09:48:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZJGC-00039D-N6 for qemu-block@nongnu.org; Tue, 08 Sep 2015 09:48:33 -0400 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:33579) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZJG8-00036I-2F; Tue, 08 Sep 2015 09:48:28 -0400 Received: by wiclk2 with SMTP id lk2so121221845wic.0; Tue, 08 Sep 2015 06:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=c/Ygo8Cq/Q5jENpmDJT0vTEBNGL4CBnh2lTZFZ430kw=; b=cIcbdNP8set4PmwoLtUuW4KYDDGVZsyIy4TitQmEDvf4YGOQCivSTQESpUZ/J899FO fb9eoywKYX4v5WkcsVrtV2t7GPJtj0+1vaJH3DmeFdGm3mD7JXzDZLLG+TIRgu5xQV75 +SH3HJlrLoAzVNL7pt+wkEF6JUl0/JIcOnQA03GlhqrTny5zvplu+fx4y4szFcaBFY1R WzAtJSdpf5FqeuQX6DXoryv2s8LToUAB/aFsgJE4kQSTOADX+jB43IjzcOMTRGf+u+gV 9HZDDxaUZTmZO52xj1BBK2VIFtpP112lBbY02PktWo3jjXsurPktMNgU31WC+thpikJP cgIg== X-Received: by 10.180.91.194 with SMTP id cg2mr23537549wib.72.1441720107101; Tue, 08 Sep 2015 06:48:27 -0700 (PDT) Received: from localhost (host86-153-218-221.range86-153.btcentralplus.com. [86.153.218.221]) by smtp.gmail.com with ESMTPSA id d1sm5939826wiz.0.2015.09.08.06.48.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Sep 2015 06:48:26 -0700 (PDT) Date: Tue, 8 Sep 2015 14:48:25 +0100 From: Stefan Hajnoczi To: Stefan Hajnoczi Message-ID: <20150908134825.GA19999@stefanha-thinkpad.redhat.com> References: <1437407656-26726-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437407656-26726-1-git-send-email-stefanha@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::231 Cc: atheurer@redhat.com, Kevin Wolf , qemu-block@nongnu.org, psuriset@redhat.com, qemu-devel@nongnu.org, Ming Lei , Paolo Bonzini Subject: Re: [Qemu-block] [PATCH] virtio-blk: use blk_io_plug/unplug for Linux AIO batching X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 13:48:35 -0000 On Mon, Jul 20, 2015 at 04:54:16PM +0100, Stefan Hajnoczi wrote: > The raw-posix block driver implements Linux AIO batching so multiple > requests can be submitted with a single io_submit(2) system call. > Batching is currently only used by virtio-scsi and > virtio-blk-data-plane. > > Enable batching for regular virtio-blk so the number of io_submit(2) > system calls is reduced for workloads with queue depth > 1. > > In 4KB random read performance tests with queue depth 32, the CPU > utilization on the host is reduced by 9.4%. The fio job is as follows: > > [global] > bs=4k > ioengine=libaio > iodepth=32 > direct=1 > sync=0 > time_based=1 > runtime=30 > clocksource=gettimeofday > ramp_time=5 > > [job1] > rw=randread > filename=/dev/vdb > size=4096M > write_bw_log=fio > write_iops_log=fio > write_lat_log=fio > log_avg_msec=1000 > > This benchmark was run on an raw image on LVM. The disk was an SSD > drive and -drive cache=none,aio=native was used. > > Tested-by: Pradeep Surisetty > Signed-off-by: Stefan Hajnoczi > --- > hw/block/virtio-blk.c | 4 ++++ > 1 file changed, 4 insertions(+) Thanks, applied to my master tree: https://github.com/stefanha/qemu/commits/master Stefan From MAILER-DAEMON Tue Sep 08 11:52:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZLC3-000642-GQ for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 11:52:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZLBx-00062k-4b for qemu-block@nongnu.org; Tue, 08 Sep 2015 11:52:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZLBt-0003DC-Vx for qemu-block@nongnu.org; Tue, 08 Sep 2015 11:52:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49690) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZLBt-0003D8-Qw; Tue, 08 Sep 2015 11:52:13 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 5E31080092; Tue, 8 Sep 2015 15:52:13 +0000 (UTC) Received: from [10.3.113.73] (ovpn-113-73.phx2.redhat.com [10.3.113.73]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88FqCbQ021803; Tue, 8 Sep 2015 11:52:12 -0400 To: Wen Congyang , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi References: <1439279489-13338-1-git-send-email-wency@cn.fujitsu.com> <1439279489-13338-4-git-send-email-wency@cn.fujitsu.com> <55E4917A.9010703@redhat.com> <55E4F4FF.1000504@cn.fujitsu.com> <55E5C4B0.1080301@redhat.com> <55EEA5FE.2000507@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55EF0427.3020301@redhat.com> Date: Tue, 8 Sep 2015 09:52:07 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55EEA5FE.2000507@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="e5bOW8V2sVp2srANBfJW49wuHUcj1ow6g" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Patch for-2.5 v2 3/6] Add new block driver interface to add/delete a BDS's child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 15:52:18 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --e5bOW8V2sVp2srANBfJW49wuHUcj1ow6g Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/08/2015 03:10 AM, Wen Congyang wrote: >> Design-wise, I think we really want to have the add-child operation be= >> handed a pre-opened BDS, rather than the options dictionary to open th= e >> BDS itself. That is, we should use the existing blockdev-add (and >> enhance it to support everything) to open the BDS, and then this comma= nd >> should just attach that BDS as the new child (which is why it IS >> important that we validate that the new BDS being added doesn't create= >> an invalid loop). >> >=20 > How to check it? The parent BDS can get all children. But the child doe= sn't > know if it is some BDS's child. If I'm not mistaken, a child DOES know what its parent(s) are, once we have Max's series for NULL BDS representing a BB without media. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --e5bOW8V2sVp2srANBfJW49wuHUcj1ow6g Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV7wQnAAoJEKeha0olJ0Nqf5QH/3GdP9dPJ8MhL10NPkEhoWm2 +SMQI7Y9gnHy8txWo92xT+t1YNH8sfd2z8Os0JjF2KPC3xvTG5SalJDc1mRiPk7x pTihwcZMGHzfpzDr2PG59hl/0Pfnzv65RqKHixVZ8ybUHbZ7k24nQmHqFpqbVK3M FxD8kTyaeLU4FKKPYkGZ0A9TBfWNsrKznhxHijtseqebCOCxSdm0pQgGQz8hRtrz +E873e4C+yOXmKBfUQN+seEBoMwGFrqdzqEcF1zOJn0BqcoA59Q+pI19wpu3eVN5 46W1KSOHduNYjYUaPwlm2tI4PA8OOD19Abp+rwPfIjxglnruV1iuHEY4va9L2q4= =hhql -----END PGP SIGNATURE----- --e5bOW8V2sVp2srANBfJW49wuHUcj1ow6g-- From MAILER-DAEMON Tue Sep 08 11:53:44 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZLDM-0007Pm-Qq for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 11:53:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZLDI-0007KI-9b for qemu-block@nongnu.org; Tue, 08 Sep 2015 11:53:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZLDD-0003k7-NC for qemu-block@nongnu.org; Tue, 08 Sep 2015 11:53:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZLDD-0003ju-IU; Tue, 08 Sep 2015 11:53:35 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 214C78C1D7; Tue, 8 Sep 2015 15:53:35 +0000 (UTC) Received: from [10.3.113.73] (ovpn-113-73.phx2.redhat.com [10.3.113.73]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88FrXKA015105; Tue, 8 Sep 2015 11:53:33 -0400 To: Wen Congyang , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi References: <1439279489-13338-1-git-send-email-wency@cn.fujitsu.com> <1439279489-13338-6-git-send-email-wency@cn.fujitsu.com> <55E4A536.6040905@redhat.com> <55E4F767.1070602@cn.fujitsu.com> <55E5C572.7000606@redhat.com> <55E65026.2050902@cn.fujitsu.com> <55E70F26.8020506@redhat.com> <55ED0ABD.2030204@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55EF047D.8060504@redhat.com> Date: Tue, 8 Sep 2015 09:53:33 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55ED0ABD.2030204@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="dEJBpkKHGHN02MM2fmaAqBHAKM0cIC1XQ" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Max Reitz , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Patch for-2.5 v2 5/6] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 15:53:42 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --dEJBpkKHGHN02MM2fmaAqBHAKM0cIC1XQ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/06/2015 09:55 PM, Wen Congyang wrote: >> I haven't looked at them yet, but really like Max's approach for >> separating BDS from BB by treating BB without BDS as an empty media >> case, and BDS without a BB as something that can then be manipulated t= o >> be associated with another BDS or BB. >=20 > Do you mean we can create a top BDS without BB by the command line -dri= ve > in the future? Not quite. -drive means create a BB. But it should be possible to create a BDS without a BB from the command line, to match what blockdev-add can do in QMP. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --dEJBpkKHGHN02MM2fmaAqBHAKM0cIC1XQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV7wR9AAoJEKeha0olJ0NqcWoIAIscAonyqiwhfE9vLPh5rfNz 7QC+0if8Yna9IZCrHdotAIOv5sxdsA0KaNxMlo47Qur3NP2/qUPU1bxkFx1M4nn8 mLcXIj/D6sY1NRELPgEbVevZbq2+wHL0w9YyqfTA9PnqP07Jm3SZpBOaVpFHqE+j c7KHX9tnPrGqEnfG/jDKmamA4PzD0PP183Cq7JlZYtIcKoKFlDxZHOD8VV7NMlIn Khf+3L6BKLf96e60wigQXoIFYIc2QNzM/Cn6FfmnMHz1e7dLPA7ukXsoEWp6FZKL txWe94sXiuMyXoekAbfoY9B/k4pPcysM/LlPv0UrQU/8ha7gJmOJw+kmyXEmiaY= =odj1 -----END PGP SIGNATURE----- --dEJBpkKHGHN02MM2fmaAqBHAKM0cIC1XQ-- From MAILER-DAEMON Tue Sep 08 11:57:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZLGy-0000ee-Re for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 11:57:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZLGv-0000eH-W7 for qemu-block@nongnu.org; Tue, 08 Sep 2015 11:57:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZLGs-0006N0-QQ for qemu-block@nongnu.org; Tue, 08 Sep 2015 11:57:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38319) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZLGs-0006Mq-L8; Tue, 08 Sep 2015 11:57:22 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 31597AB4; Tue, 8 Sep 2015 15:57:22 +0000 (UTC) Received: from [10.3.113.73] (ovpn-113-73.phx2.redhat.com [10.3.113.73]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88FvL8I010421; Tue, 8 Sep 2015 11:57:21 -0400 To: Wen Congyang , Max Reitz , qemu-block@nongnu.org References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-30-git-send-email-mreitz@redhat.com> <55EE77F1.8080007@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55EF0560.7090109@redhat.com> Date: Tue, 8 Sep 2015 09:57:20 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55EE77F1.8080007@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="nP53BPO5efqgBj3HNVNOMA2n9TsqBLlTV" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 29/38] blockdev: Add blockdev-insert-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 15:57:26 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --nP53BPO5efqgBj3HNVNOMA2n9TsqBLlTV Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/07/2015 11:53 PM, Wen Congyang wrote: > On 07/21/2015 01:45 AM, 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). >=20 > Is it OK to insert a medium to more than one BB? A read-only medium - sure :) A read-write medium - probably a recipe for data corruption. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --nP53BPO5efqgBj3HNVNOMA2n9TsqBLlTV Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV7wVgAAoJEKeha0olJ0NqFlUH/jh2JDgdNmC7sxVcQRd0YpW4 rnDhoZcP56DYSxi+6HnvWKgNrr9p4gjhG4wqeInpR00ppBhScvnNnJK/NAy2E3ig abtxXSm8WzCz9jxnCwcMu5py+iHAQiVDHiTc2lmy/AANMCwWLs/8wD8WYT62BpHt mPh+1HqKccloCKans6HHulQN40byU0k11nxr6VRQJ/T3MPKuJINb3omXLWxbOrOA WkBoZNUPabxKfxudFzaTq8EymhRAYK2YoaKc01RSkqs/F5WFQ7UlvNbUI2Ppshlb e18P8KSKSu5theJNo40s+cnzOM//trZ9SZzZ6J840WuCQvC86t2Xg9kqqIibMm8= =vq5w -----END PGP SIGNATURE----- --nP53BPO5efqgBj3HNVNOMA2n9TsqBLlTV-- From MAILER-DAEMON Tue Sep 08 12:08:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZLRd-0005tN-Nd for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 12:08:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZLRZ-0005oM-Uo for qemu-block@nongnu.org; Tue, 08 Sep 2015 12:08:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZLRW-00027y-P6 for qemu-block@nongnu.org; Tue, 08 Sep 2015 12:08:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54572) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZLRW-00027u-KL; Tue, 08 Sep 2015 12:08:22 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 9589E80091; Tue, 8 Sep 2015 16:01:39 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88G1cdL020364; Tue, 8 Sep 2015 12:01:38 -0400 To: Paolo Bonzini , qemu-block@nongnu.org References: <1440546331-29087-1-git-send-email-jsnow@redhat.com> <1440546331-29087-2-git-send-email-jsnow@redhat.com> <55EDBD4F.7070204@redhat.com> From: John Snow X-Enigmail-Draft-Status: N1110 Message-ID: <55EF0662.60703@redhat.com> Date: Tue, 8 Sep 2015 12:01:38 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55EDBD4F.7070204@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: hare@suse.de, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 1/1] ide: unify io_buffer_offset increments X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 16:08:26 -0000 On 09/07/2015 12:37 PM, Paolo Bonzini wrote: > > > On 26/08/2015 01:45, John Snow wrote: >> IDEState's io_buffer_offset was originally added to keep track of offsets >> in AHCI rather exclusively, but it was added to IDEState instead of an >> AHCI-specific structure. > > Interesting to see something weird turn into feature. :) > There's lots of stuff in places where it doesn't really belong in the IDE universe, so it takes a while to sift through all the usages and start to straighten it all out. > Reviewed-by: Paolo Bonzini > Grazie. >> AHCI fakes all PIO transfers using DMA and a scatter-gather list. When >> the core or atapi layers invoke HBA-specific mechanisms for transfers, >> they do not always know that it is being backed by DMA or a sglist, so >> this offset is not always updated by the HBA code everywhere. >> >> If we modify it in dma_buf_commit, however, any HBA that needs to use >> this offset to manage operating on only part of a sglist will have >> access to it. >> >> This will fix ATAPI PIO transfers performed through the AHCI HBA, >> which were previously not modifying this value appropriately. >> >> This will fix ATAPI PIO transfers larger than one sector. > Thanks, applied to my IDE tree: https://github.com/jnsnow/qemu/commits/ide https://github.com/jnsnow/qemu.git --js From MAILER-DAEMON Tue Sep 08 16:10:12 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZPDY-0002vV-6o for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 16:10:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZPDP-0002mS-5v for qemu-block@nongnu.org; Tue, 08 Sep 2015 16:10:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZPDN-0008M7-Hl for qemu-block@nongnu.org; Tue, 08 Sep 2015 16:10:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34694) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZPDN-0008Lm-An; Tue, 08 Sep 2015 16:10:01 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id E40B51BD093; Tue, 8 Sep 2015 20:10:00 +0000 (UTC) Received: from localhost (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88K9w1S014765 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 8 Sep 2015 16:10:00 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 8 Sep 2015 22:09:54 +0200 Message-Id: <1441742995-11794-2-git-send-email-mreitz@redhat.com> In-Reply-To: <1441742995-11794-1-git-send-email-mreitz@redhat.com> References: <1441742995-11794-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH 1/2] qcow2: Make size_to_clusters() return int64_t X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 20:10:08 -0000 Sadly, some images may have more clusters than what can be represented using a plain int. We should be prepared for that case (in qcow2_check_refcounts() we actually were trying to catch that case, but since size_to_clusters() truncated the returned value, that check never did anything useful). Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 20 +++++++++++--------- block/qcow2.h | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 2975b83..a34f0b1 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -473,8 +473,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, unsigned int l2_index; uint64_t l1_index, l2_offset, *l2_table; int l1_bits, c; - unsigned int index_in_cluster, nb_clusters; - uint64_t nb_available, nb_needed; + unsigned int index_in_cluster; + uint64_t nb_available, nb_needed, nb_clusters; int ret; index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1); @@ -837,10 +837,10 @@ err: * write, but require COW to be performed (this includes yet unallocated space, * which must copy from the backing file) */ -static int count_cow_clusters(BDRVQcow2State *s, int nb_clusters, +static int count_cow_clusters(BDRVQcow2State *s, uint64_t nb_clusters, uint64_t *l2_table, int l2_index) { - int i; + uint64_t i; for (i = 0; i < nb_clusters; i++) { uint64_t l2_entry = be64_to_cpu(l2_table[l2_index + i]); @@ -960,7 +960,7 @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset, int l2_index; uint64_t cluster_offset; uint64_t *l2_table; - unsigned int nb_clusters; + uint64_t nb_clusters; unsigned int keep_clusters; int ret; @@ -1426,7 +1426,7 @@ int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) * clusters. */ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, - unsigned int nb_clusters, enum qcow2_discard_type type, bool full_discard) + uint64_t nb_clusters, enum qcow2_discard_type type, bool full_discard) { BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; @@ -1441,6 +1441,7 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, /* Limit nb_clusters to one L2 table */ nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); for (i = 0; i < nb_clusters; i++) { uint64_t old_l2_entry; @@ -1503,7 +1504,7 @@ int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, { BDRVQcow2State *s = bs->opaque; uint64_t end_offset; - unsigned int nb_clusters; + uint64_t nb_clusters; int ret; end_offset = offset + (nb_sectors << BDRV_SECTOR_BITS); @@ -1545,7 +1546,7 @@ fail: * clusters. */ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, - unsigned int nb_clusters) + uint64_t nb_clusters) { BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; @@ -1560,6 +1561,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, /* Limit nb_clusters to one L2 table */ nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); for (i = 0; i < nb_clusters; i++) { uint64_t old_offset; @@ -1584,7 +1586,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors) { BDRVQcow2State *s = bs->opaque; - unsigned int nb_clusters; + uint64_t nb_clusters; int ret; /* The zero flag is only supported by version 3 and newer */ diff --git a/block/qcow2.h b/block/qcow2.h index 61f1b57..ce292a0 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -415,7 +415,7 @@ static inline int64_t offset_into_cluster(BDRVQcow2State *s, int64_t offset) return offset & (s->cluster_size - 1); } -static inline int size_to_clusters(BDRVQcow2State *s, int64_t size) +static inline int64_t size_to_clusters(BDRVQcow2State *s, int64_t size) { return (size + (s->cluster_size - 1)) >> s->cluster_bits; } -- 2.5.1 From MAILER-DAEMON Tue Sep 08 16:10:12 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZPDY-0002vn-9n for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 16:10:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZPDP-0002mT-5o for qemu-block@nongnu.org; Tue, 08 Sep 2015 16:10:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZPDL-0008LK-3w for qemu-block@nongnu.org; Tue, 08 Sep 2015 16:10:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45335) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZPDK-0008LB-VN; Tue, 08 Sep 2015 16:09:59 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 176B1157773; Tue, 8 Sep 2015 20:09:58 +0000 (UTC) Received: from localhost (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88K9uX9014613 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 8 Sep 2015 16:09:57 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 8 Sep 2015 22:09:53 +0200 Message-Id: <1441742995-11794-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH 0/2] qcow2: Make size_to_clusters() return int64_t X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 20:10:08 -0000 Some callers actually expected that function to return int64_t. As it turns out, it doesn't. Fix that. Max Reitz (2): qcow2: Make size_to_clusters() return int64_t iotests: Add test for checking large image files block/qcow2-cluster.c | 20 +++++++------ block/qcow2.h | 2 +- tests/qemu-iotests/138 | 73 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/138.out | 9 ++++++ tests/qemu-iotests/group | 1 + 5 files changed, 95 insertions(+), 10 deletions(-) create mode 100755 tests/qemu-iotests/138 create mode 100644 tests/qemu-iotests/138.out -- 2.5.1 From MAILER-DAEMON Tue Sep 08 16:10:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZPDZ-0002y5-Ct for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 16:10:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZPDS-0002p8-6g for qemu-block@nongnu.org; Tue, 08 Sep 2015 16:10:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZPDQ-0008SW-KZ for qemu-block@nongnu.org; Tue, 08 Sep 2015 16:10:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZPDQ-0008Rj-Bn; Tue, 08 Sep 2015 16:10:04 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id ED1FC461C3; Tue, 8 Sep 2015 20:10:03 +0000 (UTC) Received: from localhost (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88KA1Qm022955 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 8 Sep 2015 16:10:03 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 8 Sep 2015 22:09:55 +0200 Message-Id: <1441742995-11794-3-git-send-email-mreitz@redhat.com> In-Reply-To: <1441742995-11794-1-git-send-email-mreitz@redhat.com> References: <1441742995-11794-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH 2/2] iotests: Add test for checking large image files X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 20:10:11 -0000 Add a test for checking a qcow2 file with a multiple of 2^32 clusters. Signed-off-by: Max Reitz --- tests/qemu-iotests/138 | 73 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/138.out | 9 ++++++ tests/qemu-iotests/group | 1 + 3 files changed, 83 insertions(+) create mode 100755 tests/qemu-iotests/138 create mode 100644 tests/qemu-iotests/138.out diff --git a/tests/qemu-iotests/138 b/tests/qemu-iotests/138 new file mode 100755 index 0000000..0507ccc --- /dev/null +++ b/tests/qemu-iotests/138 @@ -0,0 +1,73 @@ +#!/bin/bash +# +# General test case for qcow2's image check +# +# Copyright (C) 2015 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=mreitz@redhat.com + +seq="$(basename $0)" +echo "QA output created by $seq" + +here="$PWD" +tmp=/tmp/$$ +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +# This tests qocw2-specific low-level functionality +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +echo +echo '=== Check on an image with a multiple of 2^32 clusters ===' +echo + +IMGOPTS=$(_optstr_add "$IMGOPTS" "cluster_size=512") \ + _make_test_img 512 + +# Allocate L2 table +$QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io + +# Put the data cluster at a multiple of 2 TB, resulting in the image apparently +# having a multiple of 2^32 clusters +# (To be more specific: It is at 32 PB) +poke_file "$TEST_IMG" 2048 "\x80\x80\x00\x00\x00\x00\x00\x00" + +# An offset of 32 PB results in qemu-img check having to allocate an in-memory +# refcount table of 128 TB (16 bit refcounts, 512 byte clusters). +# This should be generally too much for any system and thus fail. +# What this test is checking is that the qcow2 driver actually tries to allocate +# such a large amount of memory (and is consequently aborting) instead of having +# truncated the cluster count somewhere (which would result in much less memory +# being allocated and then a segfault occuring). +_check_test_img + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/138.out b/tests/qemu-iotests/138.out new file mode 100644 index 0000000..3fe911f --- /dev/null +++ b/tests/qemu-iotests/138.out @@ -0,0 +1,9 @@ +QA output created by 138 + +=== Check on an image with a multiple of 2^32 clusters === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=512 +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +qemu-img: Check failed: Cannot allocate memory +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 3a6a8f0..439b1d2 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -135,3 +135,4 @@ 134 rw auto quick 135 rw auto 137 rw auto +138 rw auto quick -- 2.5.1 From MAILER-DAEMON Tue Sep 08 16:17:14 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZPKM-0007x1-Jx for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 16:17:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZPKJ-0007w6-II for qemu-block@nongnu.org; Tue, 08 Sep 2015 16:17:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZPKF-0004t9-Ed for qemu-block@nongnu.org; Tue, 08 Sep 2015 16:17:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36452) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZPKF-0004t4-9x; Tue, 08 Sep 2015 16:17:07 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id AC0EC8F2E3; Tue, 8 Sep 2015 20:17:06 +0000 (UTC) Received: from [10.36.116.53] (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88KH3dS019209 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 8 Sep 2015 16:17:05 -0400 To: qemu-block@nongnu.org References: <1441742995-11794-1-git-send-email-mreitz@redhat.com> <1441742995-11794-2-git-send-email-mreitz@redhat.com> From: Max Reitz Message-ID: <55EF423C.4010501@redhat.com> Date: Tue, 8 Sep 2015 22:17:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441742995-11794-2-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5Pt0gKRAh7jVq4RXoBiUPufBViRPU7WNX" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, qemu-stable@nongnu.org Subject: Re: [Qemu-block] [PATCH 1/2] qcow2: Make size_to_clusters() return int64_t X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 20:17:12 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --5Pt0gKRAh7jVq4RXoBiUPufBViRPU7WNX Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 08.09.2015 22:09, Max Reitz wrote: > Sadly, some images may have more clusters than what can be represented > using a plain int. We should be prepared for that case (in > qcow2_check_refcounts() we actually were trying to catch that case, but= > since size_to_clusters() truncated the returned value, that check never= > did anything useful). >=20 Cc: qemu-stable > Signed-off-by: Max Reitz > --- > block/qcow2-cluster.c | 20 +++++++++++--------- > block/qcow2.h | 2 +- > 2 files changed, 12 insertions(+), 10 deletions(-) --5Pt0gKRAh7jVq4RXoBiUPufBViRPU7WNX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV70I8AAoJEDuxQgLoOKyt5qwH/iY59MFSGt6i7DSaPZjGs/kU g/m6ZrM8N0ED4Yukw9W+ybu8M/SkxMBg8SHbNss0pppr0c5G7tCc4IlzzB88CZSu QqYYBcy6oH2IF4nHn98x+J1LF+lKR6gv0w41b5JT9z3j4+yCYjQsBAU87sxCOGyY s7EVqccyW170PavViJBi9EvgPrUzSkffJOu/3pI6WZBTLpHxk1m7CC1G07qxt+FZ Gu7y71gmUFYe0NJMVivP2l5hx5zjZhLpQY4W+ytjRDQDbQ3GOrbmMZo9NDLESan3 cKuPBjZ6Cm9WP9NEyJpSXk3QsZRSDNMwpLtZ4zgdL3Eeb/Lmccr8zgoI/gld52g= =hzHM -----END PGP SIGNATURE----- --5Pt0gKRAh7jVq4RXoBiUPufBViRPU7WNX-- From MAILER-DAEMON Tue Sep 08 16:21:22 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZPOM-00012u-Hc for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 16:21:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZPOH-00012R-Lv for qemu-block@nongnu.org; Tue, 08 Sep 2015 16:21:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZPOD-0006z7-Mu for qemu-block@nongnu.org; Tue, 08 Sep 2015 16:21:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47879) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZPOD-0006yz-IY; Tue, 08 Sep 2015 16:21:13 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 15E128E688; Tue, 8 Sep 2015 20:21:13 +0000 (UTC) Received: from [10.3.113.73] (ovpn-113-73.phx2.redhat.com [10.3.113.73]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88KLCjP021090; Tue, 8 Sep 2015 16:21:12 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1441742995-11794-1-git-send-email-mreitz@redhat.com> <1441742995-11794-3-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55EF4333.3080703@redhat.com> Date: Tue, 8 Sep 2015 14:21:07 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441742995-11794-3-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="JfRpE63KCsnmAb1nJVjNr0i0TBahdDWHg" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 2/2] iotests: Add test for checking large image files X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 20:21:21 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --JfRpE63KCsnmAb1nJVjNr0i0TBahdDWHg Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/08/2015 02:09 PM, Max Reitz wrote: > Add a test for checking a qcow2 file with a multiple of 2^32 clusters. >=20 > Signed-off-by: Max Reitz > --- > tests/qemu-iotests/138 | 73 ++++++++++++++++++++++++++++++++++++++= ++++++++ > tests/qemu-iotests/138.out | 9 ++++++ > tests/qemu-iotests/group | 1 + > 3 files changed, 83 insertions(+) > create mode 100755 tests/qemu-iotests/138 > create mode 100644 tests/qemu-iotests/138.out >=20 > +# Put the data cluster at a multiple of 2 TB, resulting in the image a= pparently > +# having a multiple of 2^32 clusters > +# (To be more specific: It is at 32 PB) > +poke_file "$TEST_IMG" 2048 "\x80\x80\x00\x00\x00\x00\x00\x00" > + > +# An offset of 32 PB results in qemu-img check having to allocate an i= n-memory > +# refcount table of 128 TB (16 bit refcounts, 512 byte clusters). > +# This should be generally too much for any system and thus fail. > +# What this test is checking is that the qcow2 driver actually tries t= o allocate > +# such a large amount of memory (and is consequently aborting) instead= of having > +# truncated the cluster count somewhere (which would result in much le= ss memory > +# being allocated and then a segfault occuring). s/occuring/occurring/ With the typo fixed, Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --JfRpE63KCsnmAb1nJVjNr0i0TBahdDWHg Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV70MzAAoJEKeha0olJ0NqE3EH/134uskmoSyNmMpHWmhLKDUL X2ZM0H3hn+8QfTXkyNskpnpPf8/4/6OZ5y7TuAy06FucQ8aZNejp3ED90qWo79g4 VcxV+2jy2pOBxl/ERgt2FWmwq4z3LPMsC6F2543eMCD41EId8Qpk237MoY4syYCw mbBskzj7z9NfRhk6Tt83F8BT4Jm6oZrJmYPSoUlfjKTeHo4rhBB380IPlbp24Uv1 MWIac6ARNmfME7AJY85rxBfHUEa5UBRSz2gggJCRIg3mbGg4Fcx3uTj35VtwbD3L nfPlLvc/Ke0HKuzgbmwX2hmB/bOPqgKnZ4V5ef06LlRhHI1iiB2kB5FGam1CRno= =fRII -----END PGP SIGNATURE----- --JfRpE63KCsnmAb1nJVjNr0i0TBahdDWHg-- From MAILER-DAEMON Tue Sep 08 16:22:46 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZPPi-00022Z-08 for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 16:22:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZPPZ-00021Z-FS for qemu-block@nongnu.org; Tue, 08 Sep 2015 16:22:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZPPV-0007o5-Eq for qemu-block@nongnu.org; Tue, 08 Sep 2015 16:22:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZPPV-0007ns-2W; Tue, 08 Sep 2015 16:22:33 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id AB8738C1A3; Tue, 8 Sep 2015 20:22:32 +0000 (UTC) Received: from [10.3.113.73] (ovpn-113-73.phx2.redhat.com [10.3.113.73]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88KMWha030045; Tue, 8 Sep 2015 16:22:32 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1441742995-11794-1-git-send-email-mreitz@redhat.com> <1441742995-11794-2-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55EF4387.9060503@redhat.com> Date: Tue, 8 Sep 2015 14:22:31 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441742995-11794-2-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="O9Aa5Ta3VGiE0exnGvhMU29pQ7oVArpx0" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 1/2] qcow2: Make size_to_clusters() return int64_t X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 20:22:42 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --O9Aa5Ta3VGiE0exnGvhMU29pQ7oVArpx0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/08/2015 02:09 PM, Max Reitz wrote: > Sadly, some images may have more clusters than what can be represented > using a plain int. We should be prepared for that case (in > qcow2_check_refcounts() we actually were trying to catch that case, but= > since size_to_clusters() truncated the returned value, that check never= > did anything useful). >=20 > Signed-off-by: Max Reitz > --- > block/qcow2-cluster.c | 20 +++++++++++--------- > block/qcow2.h | 2 +- > 2 files changed, 12 insertions(+), 10 deletions(-) >=20 > diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c > index 2975b83..a34f0b1 100644 > --- a/block/qcow2-cluster.c > +++ b/block/qcow2-cluster.c > @@ -473,8 +473,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, = uint64_t offset, > unsigned int l2_index; > uint64_t l1_index, l2_offset, *l2_table; > int l1_bits, c; > - unsigned int index_in_cluster, nb_clusters; > - uint64_t nb_available, nb_needed; > + unsigned int index_in_cluster; > + uint64_t nb_available, nb_needed, nb_clusters; Most uses are storing the results unsigned... > =20 > -static inline int size_to_clusters(BDRVQcow2State *s, int64_t size) > +static inline int64_t size_to_clusters(BDRVQcow2State *s, int64_t size= ) > { > return (size + (s->cluster_size - 1)) >> s->cluster_bits; > } =2E..and the function itself doesn't appear to intentionally return negative (unless size was passed in as negative, but then that may be accidental). Should it just return uint64_t instead? At any rate, I agree that 'int' is too small, so: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --O9Aa5Ta3VGiE0exnGvhMU29pQ7oVArpx0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV70OHAAoJEKeha0olJ0NqIAwH/jiEB/qdZy/euZWGmP9YZoJY 7Rb4k9wM6oBpGRPa1H3Uxe/osObwKa9yENkHDaEItKBfDb7aQuHnvVxnY9LJ+UUH +PlG3iTbNgTplGk0LXjVX2HaK32oZz3uh3y1aNrFW+MX9E/Mfx1cL2MrEe8p9Lu7 3GgABz0kx9Sld4ee9hHZdEUeyFBl2J7gJfOWKlCZ6vfMVmQIIUhBHt9aZ0uwkJPO /G99R6kEfxS0iAq+QrPsZZDq+2kKzACruePHFBOwXNupeQGK7SyV6hM9wbdPpPxS HfYHn9VTeoVrntIzfpI9cgz+62X0zucc17gmXxxsu0iT29GYzzVOupnPRa/jh/k= =oK/h -----END PGP SIGNATURE----- --O9Aa5Ta3VGiE0exnGvhMU29pQ7oVArpx0-- From MAILER-DAEMON Tue Sep 08 16:26:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZPT2-000454-Vv for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 16:26:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZPT0-00040s-EX for qemu-block@nongnu.org; Tue, 08 Sep 2015 16:26:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZPSx-0000dI-6F for qemu-block@nongnu.org; Tue, 08 Sep 2015 16:26:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52147) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZPSx-0000cz-02; Tue, 08 Sep 2015 16:26:07 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id AC09E8C1DA; Tue, 8 Sep 2015 20:26:06 +0000 (UTC) Received: from [10.36.116.53] (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88KQ3B7023326 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 8 Sep 2015 16:26:05 -0400 To: Eric Blake , qemu-block@nongnu.org References: <1441742995-11794-1-git-send-email-mreitz@redhat.com> <1441742995-11794-2-git-send-email-mreitz@redhat.com> <55EF4387.9060503@redhat.com> From: Max Reitz Message-ID: <55EF445B.50108@redhat.com> Date: Tue, 8 Sep 2015 22:26:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55EF4387.9060503@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="JghKJDpFEf6OKdETSauFnhgaMUNsScCqQ" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 1/2] qcow2: Make size_to_clusters() return int64_t X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 20:26:11 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --JghKJDpFEf6OKdETSauFnhgaMUNsScCqQ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08.09.2015 22:22, Eric Blake wrote: > On 09/08/2015 02:09 PM, Max Reitz wrote: >> Sadly, some images may have more clusters than what can be represented= >> using a plain int. We should be prepared for that case (in >> qcow2_check_refcounts() we actually were trying to catch that case, bu= t >> since size_to_clusters() truncated the returned value, that check neve= r >> did anything useful). >> >> Signed-off-by: Max Reitz >> --- >> block/qcow2-cluster.c | 20 +++++++++++--------- >> block/qcow2.h | 2 +- >> 2 files changed, 12 insertions(+), 10 deletions(-) >> >> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c >> index 2975b83..a34f0b1 100644 >> --- a/block/qcow2-cluster.c >> +++ b/block/qcow2-cluster.c >> @@ -473,8 +473,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs,= uint64_t offset, >> unsigned int l2_index; >> uint64_t l1_index, l2_offset, *l2_table; >> int l1_bits, c; >> - unsigned int index_in_cluster, nb_clusters; >> - uint64_t nb_available, nb_needed; >> + unsigned int index_in_cluster; >> + uint64_t nb_available, nb_needed, nb_clusters; >=20 > Most uses are storing the results unsigned... >=20 >> =20 >> -static inline int size_to_clusters(BDRVQcow2State *s, int64_t size) >> +static inline int64_t size_to_clusters(BDRVQcow2State *s, int64_t siz= e) >> { >> return (size + (s->cluster_size - 1)) >> s->cluster_bits; >> } >=20 > ...and the function itself doesn't appear to intentionally return > negative (unless size was passed in as negative, but then that may be > accidental). Should it just return uint64_t instead? It won't matter in practice because we generally don't support any offsets bigger than INT64_MAX anyway; the @size parameter has been an int64_t all along, too. If I have to respin for some reason (i.e. maintainer not willing to fix up the comment in patch 2), I'll probably change the type, though. > At any rate, I agree that 'int' is too small, so: > Reviewed-by: Eric Blake Thanks! Max --JghKJDpFEf6OKdETSauFnhgaMUNsScCqQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV70RbAAoJEDuxQgLoOKytNZMIAJm3GCqGWy+qtIFhh2IdH1CN 21buHiXq7PDHFJL+P6v2iAzOoewmbJ9TlFznL68CZkhX7XybQP/im1TWVH1aRweY MXBBf+nwxv2e5Jfis/EJgYhcEC/4uRKzlhvAR11O8HPLpy74jFOJwGpjJ/tabYL5 uuD5O/bM1glZNu+u2iJzglu9Jmb5A8YOTUpxdFzKs+NhscARLRq0BYXXvYtw5on/ ylj1e9j8lu0cYbBp9wq8n875py+u35zGbQlHRsJyd9POubq2X8zwnhOZlTnfEQTp OVbXfLt9O5q66Tg/CMns93zZuv4ryQSyDzkG77OmG9Tk1IrdV+VXyM4khK5DfXs= =aYAP -----END PGP SIGNATURE----- --JghKJDpFEf6OKdETSauFnhgaMUNsScCqQ-- From MAILER-DAEMON Tue Sep 08 17:21:04 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZQK8-0003WA-GN for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 17:21:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZQK5-0003DD-3p for qemu-block@nongnu.org; Tue, 08 Sep 2015 17:21:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZQK1-0002q3-5y for qemu-block@nongnu.org; Tue, 08 Sep 2015 17:21:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZQK0-0002pt-TS; Tue, 08 Sep 2015 17:20:57 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id B2C548E699; Tue, 8 Sep 2015 21:20:55 +0000 (UTC) Received: from [10.36.116.53] (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88LKpMx013854 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 8 Sep 2015 17:20:53 -0400 To: Wen Congyang , qemu-block@nongnu.org References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-30-git-send-email-mreitz@redhat.com> <55EEA69E.4010706@cn.fujitsu.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <55EF5133.2040807@redhat.com> Date: Tue, 8 Sep 2015 23:20:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55EEA69E.4010706@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Kn6oKhicGs3a9HHN7Bkbrb76K8KmnKqDb" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 29/38] blockdev: Add blockdev-insert-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 21:21:02 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Kn6oKhicGs3a9HHN7Bkbrb76K8KmnKqDb Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 08.09.2015 11:13, Wen Congyang wrote: > On 07/21/2015 01:45 AM, 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). >> >> Signed-off-by: Max Reitz >> --- >> blockdev.c | 48 +++++++++++++++++++++++++++++++++++++++++++= +++++ >> qapi/block-core.json | 17 +++++++++++++++++ >> qmp-commands.hx | 37 +++++++++++++++++++++++++++++++++++++ >> 3 files changed, 102 insertions(+) >> >> diff --git a/blockdev.c b/blockdev.c >> index 481760a..a80d0e2 100644 >> --- a/blockdev.c >> +++ b/blockdev.c >> @@ -2164,6 +2164,54 @@ void qmp_blockdev_remove_medium(const char *dev= ice, Error **errp) >> } >> } >> =20 >> +static void qmp_blockdev_insert_anon_medium(const char *device, >> + BlockDriverState *bs, Err= or **errp) >> +{ >> + BlockBackend *blk; >> + bool has_device; >> + >> + blk =3D blk_by_name(device); >> + if (!blk) { >> + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, >> + "Device '%s' not found", device); >> + return; >> + } >> + >> + /* For BBs without a device, we can exchange the BDS tree at will= */ >> + has_device =3D blk_get_attached_dev(blk); >> + >> + if (has_device && !blk_dev_has_removable_media(blk)) { >> + error_setg(errp, "Device '%s' is not removable", device); >> + return; >> + } >> + >> + if (has_device && !blk_dev_is_tray_open(blk)) { >> + error_setg(errp, "Tray of device '%s' is not open", device); >> + return; >> + } >> + >> + if (blk_bs(blk)) { >> + error_setg(errp, "There already is a medium in device '%s'", = device); >> + return; >> + } >> + >> + blk_insert_bs(blk, bs); >> +} >> + >> +void qmp_blockdev_insert_medium(const char *device, const char *node_= name, >> + Error **errp) >> +{ >> + BlockDriverState *bs; >> + >> + bs =3D bdrv_find_node(node_name); >> + if (!bs) { >> + error_setg(errp, "Node '%s' not found", node_name); >> + return; >> + } >=20 > Hmm, it is OK if the bs is not top BDS? I think so, yes. Generally, there's probably no reason to do that, but I don't know why we should not allow that case. For instance, you might want to make a backing file available read-only somewhere. It should be impossible to make it available writable, and it should not be allowed to start a block-commit operation while the backing file can be accessed by the guest, but this should be achieved using op blockers. What we need for this to work are fine-grained op blockers, I think. But working around that for now by only allowing to insert top BDS won't work, since you can still start block jobs which target top BDS, too (e.g. blockdev-backup can write to a BDS/BB that is visible to the guest)= =2E All in all, I think it's fine to insert non-top BDS, but we should definitely worry about which exact BDS one can insert once we have fine-grained op blockers. Max > Thanks > Wen Congyang >=20 >> + >> + qmp_blockdev_insert_anon_medium(device, bs, errp); >> +} >> + >> /* throttling disk I/O limits */ >> void qmp_block_set_io_throttle(const char *device, int64_t bps, int64= _t bps_rd, >> int64_t bps_wr, >> diff --git a/qapi/block-core.json b/qapi/block-core.json >> index 63a83e4..84c9b23 100644 >> --- a/qapi/block-core.json >> +++ b/qapi/block-core.json >> @@ -1925,6 +1925,23 @@ >> { 'command': 'blockdev-remove-medium', >> 'data': { 'device': 'str' } } >> =20 >> +## >> +# @blockdev-insert-medium: >> +# >> +# Inserts a medium (a block driver state tree) into a block device. T= hat block >> +# device's tray must currently be open and there must be no medium in= serted >> +# already. >> +# >> +# @device: block device name >> +# >> +# @node-name: name of a node in the block driver state graph >> +# >> +# Since: 2.5 >> +## >> +{ 'command': 'blockdev-insert-medium', >> + 'data': { 'device': 'str', >> + 'node-name': 'str'} } >> + >> =20 >> ## >> # @BlockErrorAction >> diff --git a/qmp-commands.hx b/qmp-commands.hx >> index ff6c572..b4c34fe 100644 >> --- a/qmp-commands.hx >> +++ b/qmp-commands.hx >> @@ -3991,6 +3991,43 @@ Example: >> EQMP >> =20 >> { >> + .name =3D "blockdev-insert-medium", >> + .args_type =3D "device:s,node-name:s", >> + .mhandler.cmd_new =3D qmp_marshal_input_blockdev_insert_mediu= m, >> + }, >> + >> +SQMP >> +blockdev-insert-medium >> +---------------------- >> + >> +Inserts a medium (a block driver state tree) into a block device. Tha= t block >> +device's tray must currently be open and there must be no medium inse= rted >> +already. >> + >> +Arguments: >> + >> +- "device": block device name (json-string) >> +- "node-name": root node of the BDS tree to insert into the block dev= ice >> + >> +Example: >> + >> +-> { "execute": "blockdev-add", >> + "arguments": { "options": { "node-name": "node0", >> + "driver": "raw", >> + "file": { "driver": "file", >> + "filename": "fedora.iso" }= } } } >> + >> +<- { "return": {} } >> + >> +-> { "execute": "blockdev-insert-medium", >> + "arguments": { "device": "ide1-cd0", >> + "node-name": "node0" } } >> + >> +<- { "return": {} } >> + >> +EQMP >> + >> + { >> .name =3D "query-named-block-nodes", >> .args_type =3D "", >> .mhandler.cmd_new =3D qmp_marshal_input_query_named_block_nod= es, >> >=20 --Kn6oKhicGs3a9HHN7Bkbrb76K8KmnKqDb Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV71EzAAoJEDuxQgLoOKytvMIH/2xVQxMU3drZ21BDvjrKsaN+ MyEhHQcKJ88pQSh356gfsk8MEwEeKRypfmaXmoq96Tsy2sVroRtCZzA7ORel2T1P VWdYQHnpp5U5SRjscguFunL5uEX+febCKh0UlxPVhv7d7L6y/osKS4dArhQ7xlFE 7ZqjPnBQmQQWVxln87nvwyOVmrO8W+wlb8XGsGnVlcwZVNDFCFkeEGJeVsKVKYsA AVF1KgPO4V1iUYpMtoXKt1KI0NOcR9R679aO0tNVL1IviQ+zvHea1r5swNJxWUCz QjijrggjwbGiPpfwjTTlkD8JHVCI3eN51Q3yZ/PQLEZrSZrLq2g1LtMrWhpWbqg= =HMUN -----END PGP SIGNATURE----- --Kn6oKhicGs3a9HHN7Bkbrb76K8KmnKqDb-- From MAILER-DAEMON Tue Sep 08 17:25:46 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZQOg-0000vZ-LB for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 17:25:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZQOd-0000vO-8C for qemu-block@nongnu.org; Tue, 08 Sep 2015 17:25:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZQOY-0005CI-W3 for qemu-block@nongnu.org; Tue, 08 Sep 2015 17:25:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZQOY-0005C7-P1; Tue, 08 Sep 2015 17:25:38 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 74DDD3FE7B; Tue, 8 Sep 2015 21:25:38 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88LPbNj022033; Tue, 8 Sep 2015 17:25:37 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1441047913-30596-1-git-send-email-mreitz@redhat.com> <1441047913-30596-3-git-send-email-mreitz@redhat.com> From: John Snow Message-ID: <55EF5251.90906@redhat.com> Date: Tue, 8 Sep 2015 17:25:37 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441047913-30596-3-git-send-email-mreitz@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 2/2] iotests: Warn if python subprocess is killed X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 21:25:44 -0000 On 08/31/2015 03:05 PM, Max Reitz wrote: > Currently, if a subprocess of a python test (i.e. qemu-io, qemu-img, or > qemu) receives a signal and is subsequently aborted, this is not logged. > > This patch makes python tests always check the exit code of these > subprocesses, and emit a message if they have been killed. > > Signed-off-by: Max Reitz > --- > tests/qemu-iotests/iotests.py | 26 +++++++++++++++++++++----- > 1 file changed, 21 insertions(+), 5 deletions(-) > > diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py > index 927c74a..d082597 100644 > --- a/tests/qemu-iotests/iotests.py > +++ b/tests/qemu-iotests/iotests.py > @@ -49,20 +49,34 @@ socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper') > def qemu_img(*args): > '''Run qemu-img and return the exit code''' > devnull = open('/dev/null', 'r+') > - return subprocess.call(qemu_img_args + list(args), stdin=devnull, stdout=devnull) > + exitcode = subprocess.call(qemu_img_args + list(args), stdin=devnull, stdout=devnull) > + if exitcode < 0: > + sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) > + return exitcode > Why tack on the arguments after the retcode for the print? The format makes it look like it should be a description for the signal received. > def qemu_img_verbose(*args): > '''Run qemu-img without suppressing its output and return the exit code''' > - return subprocess.call(qemu_img_args + list(args)) > + exitcode = subprocess.call(qemu_img_args + list(args)) > + if exitcode < 0: > + sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) > + return exitcode > > def qemu_img_pipe(*args): > '''Run qemu-img and return its output''' > - return subprocess.Popen(qemu_img_args + list(args), stdout=subprocess.PIPE).communicate()[0] > + subp = subprocess.Popen(qemu_img_args + list(args), stdout=subprocess.PIPE) > + exitcode = subp.wait() > + if exitcode < 0: > + sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) > + return subp.communicate()[0] > > def qemu_io(*args): > '''Run qemu-io and return the stdout data''' > args = qemu_io_args + list(args) > - return subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0] > + subp = subprocess.Popen(args, stdout=subprocess.PIPE) > + exitcode = subp.wait() > + if exitcode < 0: > + sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' '.join(args))) > + return subp.communicate()[0] > > def compare_images(img1, img2): > '''Return True if two image files are identical''' > @@ -197,7 +211,9 @@ class VM(object): > '''Terminate the VM and clean up''' > if not self._popen is None: > self._qmp.cmd('quit') > - self._popen.wait() > + exitcode = self._popen.wait() > + if exitcode < 0: > + sys.stderr.write('qemu received signal %i: %s\n' % (-exitcode, ' '.join(self._args))) > os.remove(self._monitor_path) > os.remove(self._qtest_path) > os.remove(self._qemu_log_path) > From MAILER-DAEMON Tue Sep 08 17:29:53 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZQSf-0004Af-Lt for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 17:29:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZQSd-0004AI-Pp for qemu-block@nongnu.org; Tue, 08 Sep 2015 17:29:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZQSa-0007Zd-HC for qemu-block@nongnu.org; Tue, 08 Sep 2015 17:29:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37137) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZQSa-0007ZX-9L; Tue, 08 Sep 2015 17:29:48 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id A9B49373BD7; Tue, 8 Sep 2015 21:29:47 +0000 (UTC) Received: from [10.36.116.53] (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88LTiTI017803 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 8 Sep 2015 17:29:45 -0400 To: John Snow , qemu-block@nongnu.org References: <1441047913-30596-1-git-send-email-mreitz@redhat.com> <1441047913-30596-3-git-send-email-mreitz@redhat.com> <55EF5251.90906@redhat.com> From: Max Reitz Message-ID: <55EF5347.8020503@redhat.com> Date: Tue, 8 Sep 2015 23:29:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55EF5251.90906@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="NCGPxWOhnDStRtD4U8B8HcoQMIdfiqahT" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 2/2] iotests: Warn if python subprocess is killed X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 21:29:52 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --NCGPxWOhnDStRtD4U8B8HcoQMIdfiqahT Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 08.09.2015 23:25, John Snow wrote: >=20 >=20 > On 08/31/2015 03:05 PM, Max Reitz wrote: >> Currently, if a subprocess of a python test (i.e. qemu-io, qemu-img, o= r >> qemu) receives a signal and is subsequently aborted, this is not logge= d. >> >> This patch makes python tests always check the exit code of these >> subprocesses, and emit a message if they have been killed. >> >> Signed-off-by: Max Reitz >> --- >> tests/qemu-iotests/iotests.py | 26 +++++++++++++++++++++----- >> 1 file changed, 21 insertions(+), 5 deletions(-) >> >> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotest= s.py >> index 927c74a..d082597 100644 >> --- a/tests/qemu-iotests/iotests.py >> +++ b/tests/qemu-iotests/iotests.py >> @@ -49,20 +49,34 @@ socket_scm_helper =3D os.environ.get('SOCKET_SCM_H= ELPER', 'socket_scm_helper') >> def qemu_img(*args): >> '''Run qemu-img and return the exit code''' >> devnull =3D open('/dev/null', 'r+') >> - return subprocess.call(qemu_img_args + list(args), stdin=3Ddevnul= l, stdout=3Ddevnull) >> + exitcode =3D subprocess.call(qemu_img_args + list(args), stdin=3D= devnull, stdout=3Ddevnull) >> + if exitcode < 0: >> + sys.stderr.write('qemu-img received signal %i: %s\n' % (-exit= code, ' '.join(qemu_img_args + list(args)))) >> + return exitcode >> =20 >=20 > Why tack on the arguments after the retcode for the print? The format > makes it look like it should be a description for the signal received. qemu_img_args contains the qemu-img filename as well, so it should be obvious that that is the command line. For the "why": I hope it will make debugging easier by providing the exact command line so you can reproduce the problem outside of the test. Max >=20 >> def qemu_img_verbose(*args): >> '''Run qemu-img without suppressing its output and return the exi= t code''' >> - return subprocess.call(qemu_img_args + list(args)) >> + exitcode =3D subprocess.call(qemu_img_args + list(args)) >> + if exitcode < 0: >> + sys.stderr.write('qemu-img received signal %i: %s\n' % (-exit= code, ' '.join(qemu_img_args + list(args)))) >> + return exitcode >> =20 >> def qemu_img_pipe(*args): >> '''Run qemu-img and return its output''' >> - return subprocess.Popen(qemu_img_args + list(args), stdout=3Dsubp= rocess.PIPE).communicate()[0] >> + subp =3D subprocess.Popen(qemu_img_args + list(args), stdout=3Dsu= bprocess.PIPE) >> + exitcode =3D subp.wait() >> + if exitcode < 0: >> + sys.stderr.write('qemu-img received signal %i: %s\n' % (-exit= code, ' '.join(qemu_img_args + list(args)))) >> + return subp.communicate()[0] >> =20 >> def qemu_io(*args): >> '''Run qemu-io and return the stdout data''' >> args =3D qemu_io_args + list(args) >> - return subprocess.Popen(args, stdout=3Dsubprocess.PIPE).communica= te()[0] >> + subp =3D subprocess.Popen(args, stdout=3Dsubprocess.PIPE) >> + exitcode =3D subp.wait() >> + if exitcode < 0: >> + sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitc= ode, ' '.join(args))) >> + return subp.communicate()[0] >> =20 >> def compare_images(img1, img2): >> '''Return True if two image files are identical''' >> @@ -197,7 +211,9 @@ class VM(object): >> '''Terminate the VM and clean up''' >> if not self._popen is None: >> self._qmp.cmd('quit') >> - self._popen.wait() >> + exitcode =3D self._popen.wait() >> + if exitcode < 0: >> + sys.stderr.write('qemu received signal %i: %s\n' % (-= exitcode, ' '.join(self._args))) >> os.remove(self._monitor_path) >> os.remove(self._qtest_path) >> os.remove(self._qemu_log_path) >> --NCGPxWOhnDStRtD4U8B8HcoQMIdfiqahT Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV71NHAAoJEDuxQgLoOKyterEH/18GrkBGucAS4w5swEMJGACG C9PErAX/ZFoZFpXETsPSeB0Q3N5jmDaNcSCTqIUaPQF59G4WsvzR54l0vTRsjejS yi4I5tYDehtzYrgedSj+CLzDkgpdUm3PE//XKMWGoFBVPEsbvPOlrzeifbwO5QAh SOK0s+7Sc26+y2KaBlwJeZON+zk7w38++7m3qIZbeQN0fX439d00VbEcw4bZHyfv 9LrG6oPKn0fxQnoj2bw0XKv+uaZRpCBgyMgLhyi7v2a0LfXAal9dYvb3kW2CkOoW +g9YlR9zAONm52KD1yxJkFnSIQuRnYft8YxE4SjFSdD/AYe6cXc2Hz8Ljw2sd74= =hxrd -----END PGP SIGNATURE----- --NCGPxWOhnDStRtD4U8B8HcoQMIdfiqahT-- From MAILER-DAEMON Tue Sep 08 17:37:11 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZQZj-0007oz-Ap for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 17:37:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZQZh-0007oK-39 for qemu-block@nongnu.org; Tue, 08 Sep 2015 17:37:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZQZd-0003Oe-QJ for qemu-block@nongnu.org; Tue, 08 Sep 2015 17:37:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZQZd-0003OW-JI; Tue, 08 Sep 2015 17:37:05 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 23D8A8E3E8; Tue, 8 Sep 2015 21:37:05 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88Lb4kw018870; Tue, 8 Sep 2015 17:37:04 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1441047913-30596-1-git-send-email-mreitz@redhat.com> <1441047913-30596-3-git-send-email-mreitz@redhat.com> <55EF5251.90906@redhat.com> <55EF5347.8020503@redhat.com> From: John Snow Message-ID: <55EF5500.4080904@redhat.com> Date: Tue, 8 Sep 2015 17:37:04 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55EF5347.8020503@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 2/2] iotests: Warn if python subprocess is killed X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 21:37:10 -0000 On 09/08/2015 05:29 PM, Max Reitz wrote: > On 08.09.2015 23:25, John Snow wrote: >> >> >> On 08/31/2015 03:05 PM, Max Reitz wrote: >>> Currently, if a subprocess of a python test (i.e. qemu-io, >>> qemu-img, or qemu) receives a signal and is subsequently >>> aborted, this is not logged. >>> >>> This patch makes python tests always check the exit code of >>> these subprocesses, and emit a message if they have been >>> killed. >>> >>> Signed-off-by: Max Reitz --- >>> tests/qemu-iotests/iotests.py | 26 +++++++++++++++++++++----- 1 >>> file changed, 21 insertions(+), 5 deletions(-) >>> >>> diff --git a/tests/qemu-iotests/iotests.py >>> b/tests/qemu-iotests/iotests.py index 927c74a..d082597 100644 >>> --- a/tests/qemu-iotests/iotests.py +++ >>> b/tests/qemu-iotests/iotests.py @@ -49,20 +49,34 @@ >>> socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', >>> 'socket_scm_helper') def qemu_img(*args): '''Run qemu-img and >>> return the exit code''' devnull = open('/dev/null', 'r+') - >>> return subprocess.call(qemu_img_args + list(args), >>> stdin=devnull, stdout=devnull) + exitcode = >>> subprocess.call(qemu_img_args + list(args), stdin=devnull, >>> stdout=devnull) + if exitcode < 0: + >>> sys.stderr.write('qemu-img received signal %i: %s\n' % >>> (-exitcode, ' '.join(qemu_img_args + list(args)))) + return >>> exitcode >>> >> >> Why tack on the arguments after the retcode for the print? The >> format makes it look like it should be a description for the >> signal received. > > qemu_img_args contains the qemu-img filename as well, so it should > be obvious that that is the command line. > > For the "why": I hope it will make debugging easier by providing > the exact command line so you can reproduce the problem outside of > the test. > > Max > Sorry for being captain bikeshed: can this be something like: "%s received signal %i; args: %s" to avoid the string looking like it was meant to answer the question of what the signal was? I won't insist on it, though: Reviewed-by: John Snow >> >>> def qemu_img_verbose(*args): '''Run qemu-img without >>> suppressing its output and return the exit code''' - return >>> subprocess.call(qemu_img_args + list(args)) + exitcode = >>> subprocess.call(qemu_img_args + list(args)) + if exitcode < >>> 0: + sys.stderr.write('qemu-img received signal %i: >>> %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) + >>> return exitcode >>> >>> def qemu_img_pipe(*args): '''Run qemu-img and return its >>> output''' - return subprocess.Popen(qemu_img_args + >>> list(args), stdout=subprocess.PIPE).communicate()[0] + subp >>> = subprocess.Popen(qemu_img_args + list(args), >>> stdout=subprocess.PIPE) + exitcode = subp.wait() + if >>> exitcode < 0: + sys.stderr.write('qemu-img received >>> signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + >>> list(args)))) + return subp.communicate()[0] >>> >>> def qemu_io(*args): '''Run qemu-io and return the stdout >>> data''' args = qemu_io_args + list(args) - return >>> subprocess.Popen(args, >>> stdout=subprocess.PIPE).communicate()[0] + subp = >>> subprocess.Popen(args, stdout=subprocess.PIPE) + exitcode = >>> subp.wait() + if exitcode < 0: + >>> sys.stderr.write('qemu-io received signal %i: %s\n' % >>> (-exitcode, ' '.join(args))) + return subp.communicate()[0] >>> >>> def compare_images(img1, img2): '''Return True if two image >>> files are identical''' @@ -197,7 +211,9 @@ class VM(object): >>> '''Terminate the VM and clean up''' if not self._popen is >>> None: self._qmp.cmd('quit') - self._popen.wait() + >>> exitcode = self._popen.wait() + if exitcode < 0: + >>> sys.stderr.write('qemu received signal %i: %s\n' % (-exitcode, >>> ' '.join(self._args))) os.remove(self._monitor_path) >>> os.remove(self._qtest_path) os.remove(self._qemu_log_path) >>> > > From MAILER-DAEMON Tue Sep 08 17:38:56 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZQbQ-0000Y8-F9 for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 17:38:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZQbO-0000Y1-KI for qemu-block@nongnu.org; Tue, 08 Sep 2015 17:38:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZQbL-0003xw-CG for qemu-block@nongnu.org; Tue, 08 Sep 2015 17:38:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53453) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZQbL-0003xm-5n; Tue, 08 Sep 2015 17:38:51 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id DBC1D8EA23; Tue, 8 Sep 2015 21:38:50 +0000 (UTC) Received: from [10.36.116.53] (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88LcmkH029098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 8 Sep 2015 17:38:49 -0400 To: John Snow , qemu-block@nongnu.org References: <1441047913-30596-1-git-send-email-mreitz@redhat.com> <1441047913-30596-3-git-send-email-mreitz@redhat.com> <55EF5251.90906@redhat.com> <55EF5347.8020503@redhat.com> <55EF5500.4080904@redhat.com> From: Max Reitz Message-ID: <55EF5567.7040809@redhat.com> Date: Tue, 8 Sep 2015 23:38:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55EF5500.4080904@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="61xbd2gAl1eRRkTgQmTXiPlVRwoFjfgcX" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 2/2] iotests: Warn if python subprocess is killed X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 21:38:55 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --61xbd2gAl1eRRkTgQmTXiPlVRwoFjfgcX Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 08.09.2015 23:37, John Snow wrote: >=20 >=20 > On 09/08/2015 05:29 PM, Max Reitz wrote: >> On 08.09.2015 23:25, John Snow wrote: >>> >>> >>> On 08/31/2015 03:05 PM, Max Reitz wrote: >>>> Currently, if a subprocess of a python test (i.e. qemu-io, >>>> qemu-img, or qemu) receives a signal and is subsequently >>>> aborted, this is not logged. >>>> >>>> This patch makes python tests always check the exit code of >>>> these subprocesses, and emit a message if they have been >>>> killed. >>>> >>>> Signed-off-by: Max Reitz ---=20 >>>> tests/qemu-iotests/iotests.py | 26 +++++++++++++++++++++----- 1 >>>> file changed, 21 insertions(+), 5 deletions(-) >>>> >>>> diff --git a/tests/qemu-iotests/iotests.py >>>> b/tests/qemu-iotests/iotests.py index 927c74a..d082597 100644=20 >>>> --- a/tests/qemu-iotests/iotests.py +++ >>>> b/tests/qemu-iotests/iotests.py @@ -49,20 +49,34 @@ >>>> socket_scm_helper =3D os.environ.get('SOCKET_SCM_HELPER', >>>> 'socket_scm_helper') def qemu_img(*args): '''Run qemu-img and >>>> return the exit code''' devnull =3D open('/dev/null', 'r+') - >>>> return subprocess.call(qemu_img_args + list(args), >>>> stdin=3Ddevnull, stdout=3Ddevnull) + exitcode =3D >>>> subprocess.call(qemu_img_args + list(args), stdin=3Ddevnull, >>>> stdout=3Ddevnull) + if exitcode < 0: + >>>> sys.stderr.write('qemu-img received signal %i: %s\n' % >>>> (-exitcode, ' '.join(qemu_img_args + list(args)))) + return >>>> exitcode >>>> >>> >>> Why tack on the arguments after the retcode for the print? The >>> format makes it look like it should be a description for the >>> signal received. >> >> qemu_img_args contains the qemu-img filename as well, so it should >> be obvious that that is the command line. >> >> For the "why": I hope it will make debugging easier by providing >> the exact command line so you can reproduce the problem outside of >> the test. >> >> Max >> >=20 > Sorry for being captain bikeshed: can this be something like: >=20 > "%s received signal %i; args: %s" >=20 > to avoid the string looking like it was meant to answer the question > of what the signal was? > I won't insist on it, though: >=20 > Reviewed-by: John Snow Well, feel free to fix it since it's already in master. :-) (also, compare how bash does it: > $FILE: line $LINE: $PID $SIGNAL_NAME (core dumped) ($ARGS) ) Max --61xbd2gAl1eRRkTgQmTXiPlVRwoFjfgcX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV71VnAAoJEDuxQgLoOKytibUH/Rz24Xhrk5vdtS+MXI0iTAJP aDmJhujTcsALA+FYQqmP0jkbzmwJxm8GwkosOUEbxRMHi+vv4rh/BrhGZ5Q0LAyn CmZJUY40cmgQ8MLp+iAxAJsoQ2TA4qbIFIZOWnbbS7mN0K5WJO/rkZZ7cvjsBzsq q99bKkQ5m3KDKt5RX5a+T305vVaKwq0i2uEjPVaBSez+byNVHM6ygFxKepeTkTpA 0h61D+nXHbiqB0La2wsu5CM9TapMzA+hjvP8RazudEwslpeCCUPEI97XRV9E2lJV /CU0YEz/3tqcujQvF9EaefXFz97bzXYKDdlNfEknPON1zuie3wY6QPVWnZAk4G4= =h1Cq -----END PGP SIGNATURE----- --61xbd2gAl1eRRkTgQmTXiPlVRwoFjfgcX-- From MAILER-DAEMON Tue Sep 08 17:42:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZQet-000282-BF for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 17:42:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZQeq-00027c-L8 for qemu-block@nongnu.org; Tue, 08 Sep 2015 17:42:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZQel-0005hd-Hc for qemu-block@nongnu.org; Tue, 08 Sep 2015 17:42:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZQel-0005hX-DH; Tue, 08 Sep 2015 17:42:23 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id DD77C461DA; Tue, 8 Sep 2015 21:42:22 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t88LgLD1024894; Tue, 8 Sep 2015 17:42:22 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1441047913-30596-1-git-send-email-mreitz@redhat.com> <1441047913-30596-3-git-send-email-mreitz@redhat.com> <55EF5251.90906@redhat.com> <55EF5347.8020503@redhat.com> <55EF5500.4080904@redhat.com> <55EF5567.7040809@redhat.com> From: John Snow Message-ID: <55EF563D.4070304@redhat.com> Date: Tue, 8 Sep 2015 17:42:21 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55EF5567.7040809@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 2/2] iotests: Warn if python subprocess is killed X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2015 21:42:29 -0000 On 09/08/2015 05:38 PM, Max Reitz wrote: > On 08.09.2015 23:37, John Snow wrote: >> >> >> On 09/08/2015 05:29 PM, Max Reitz wrote: >>> On 08.09.2015 23:25, John Snow wrote: >>>> >>>> >>>> On 08/31/2015 03:05 PM, Max Reitz wrote: >>>>> Currently, if a subprocess of a python test (i.e. qemu-io, >>>>> qemu-img, or qemu) receives a signal and is subsequently >>>>> aborted, this is not logged. >>>>> >>>>> This patch makes python tests always check the exit code >>>>> of these subprocesses, and emit a message if they have >>>>> been killed. >>>>> >>>>> Signed-off-by: Max Reitz --- >>>>> tests/qemu-iotests/iotests.py | 26 >>>>> +++++++++++++++++++++----- 1 file changed, 21 >>>>> insertions(+), 5 deletions(-) >>>>> >>>>> diff --git a/tests/qemu-iotests/iotests.py >>>>> b/tests/qemu-iotests/iotests.py index 927c74a..d082597 >>>>> 100644 --- a/tests/qemu-iotests/iotests.py +++ >>>>> b/tests/qemu-iotests/iotests.py @@ -49,20 +49,34 @@ >>>>> socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', >>>>> 'socket_scm_helper') def qemu_img(*args): '''Run qemu-img >>>>> and return the exit code''' devnull = open('/dev/null', >>>>> 'r+') - return subprocess.call(qemu_img_args + list(args), >>>>> stdin=devnull, stdout=devnull) + exitcode = >>>>> subprocess.call(qemu_img_args + list(args), stdin=devnull, >>>>> stdout=devnull) + if exitcode < 0: + >>>>> sys.stderr.write('qemu-img received signal %i: %s\n' % >>>>> (-exitcode, ' '.join(qemu_img_args + list(args)))) + >>>>> return exitcode >>>>> >>>> >>>> Why tack on the arguments after the retcode for the print? >>>> The format makes it look like it should be a description for >>>> the signal received. >>> >>> qemu_img_args contains the qemu-img filename as well, so it >>> should be obvious that that is the command line. >>> >>> For the "why": I hope it will make debugging easier by >>> providing the exact command line so you can reproduce the >>> problem outside of the test. >>> >>> Max >>> >> >> Sorry for being captain bikeshed: can this be something like: >> >> "%s received signal %i; args: %s" >> >> to avoid the string looking like it was meant to answer the >> question of what the signal was? I won't insist on it, though: >> >> Reviewed-by: John Snow > > Well, feel free to fix it since it's already in master. :-) > > (also, compare how bash does it: >> $FILE: line $LINE: $PID $SIGNAL_NAME (core dumped) ($ARGS) > ) > > Max > ugh! pfeh! didn't see the v2, sorry. ignore this garbage. --js From MAILER-DAEMON Tue Sep 08 23:22:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZVxf-0002LT-AM for mharc-qemu-block@gnu.org; Tue, 08 Sep 2015 23:22:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZVxc-0002LB-TY for qemu-block@nongnu.org; Tue, 08 Sep 2015 23:22:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZVxY-0005G6-TB for qemu-block@nongnu.org; Tue, 08 Sep 2015 23:22:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51387) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZVxY-0005Fu-Nj; Tue, 08 Sep 2015 23:22:08 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 2E8A4C0A1608; Wed, 9 Sep 2015 03:22:08 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t893M65E019587; Tue, 8 Sep 2015 23:22:07 -0400 Date: Wed, 9 Sep 2015 11:22:05 +0800 From: Fam Zheng To: Paolo Bonzini Message-ID: <20150909032205.GA10922@ad.nay.redhat.com> References: <1438144934-23619-1-git-send-email-famz@redhat.com> <1438144934-23619-12-git-send-email-famz@redhat.com> <55B882C1.8070500@redhat.com> <20150729105725.GA10376@ad.nay.redhat.com> <55B8B2C3.9050307@redhat.com> <20150729115333.GA15022@ad.nay.redhat.com> <55B8C12D.2070105@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55B8C12D.2070105@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 11/11] block: Only poll block layer fds in bdrv_aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 03:22:14 -0000 On Wed, 07/29 14:03, Paolo Bonzini wrote: > > > On 29/07/2015 13:53, Fam Zheng wrote: > >> > Yes, though I think you'd end up reverting patches 10 and 11 in the end. > > We will add outer disable/enable pairs to prevent another threads's aio_poll > > from sneaking in between bdrv_aio_poll calls, but we needn't obsolete > > bdrv_aio_poll() because of that - it can be useful by itself. For example > > bdrv_aio_cancel shouldn't look at ioeventfd, otherwise it could spin for too > > long on high load. Does that make sense? > > Did you mean bdrv_drain() (when it is not already surrounded by > disable/enable pairs in the caller)? But yes, that makes sense. > > I'm not sure that it makes sense to disable/enable in places such as > bdrv_pread. The caller's block, if any, should suffice. In this sense > you'd end up reverting large parts of patch 10. > > Then you would have to see how many calls to bdrv_aio_poll are still > there, and how many can be converted with no semantic change to aio_poll > (e.g. there's no difference in qemu-img.c), and you'd end up reverting > patches 9 and 11 too. But we can look at that later. Another advantage for bdrv_aio_poll() is, in main loop we will not need a separate AioContext in changes like: http://patchwork.ozlabs.org/patch/514968/ Because nested aio_poll will automatically be limited to only process block layer events. My idea is to eventually let main loop use aio_poll, which means we would also move chardev onto it. It would be neat to put all fds of the main thread into a single AioContext. Fam From MAILER-DAEMON Wed Sep 09 02:06:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZYWc-0000hj-Ga for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 02:06:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZYWZ-0000hY-I2 for qemu-block@nongnu.org; Wed, 09 Sep 2015 02:06:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZYWV-0000YI-Gy for qemu-block@nongnu.org; Wed, 09 Sep 2015 02:06:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZYWV-0000Y9-6R; Wed, 09 Sep 2015 02:06:23 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 9F06991C1C; Wed, 9 Sep 2015 06:06:22 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8966K7I021128; Wed, 9 Sep 2015 02:06:21 -0400 Date: Wed, 9 Sep 2015 14:06:19 +0800 From: Fam Zheng To: Paolo Bonzini Message-ID: <20150909060619.GB21413@ad.nay.redhat.com> References: <1438868176-20364-1-git-send-email-pbonzini@redhat.com> <1438868176-20364-2-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438868176-20364-2-git-send-email-pbonzini@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 01/18] iothread: release iothread around aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 06:06:29 -0000 On Thu, 08/06 15:35, Paolo Bonzini wrote: > This is the first step towards having fine-grained critical sections in > dataplane threads, which resolves lock ordering problems between > address_space_* functions (which need the BQL when doing MMIO, even > after we complete RCU-based dispatch) and the AioContext. > > Because AioContext does not use contention callbacks anymore, the > unit test has to be changed. > > Previously applied as a0710f7995f914e3044e5899bd8ff6c43c62f916 and > then reverted. > > Reviewed-by: Stefan Hajnoczi > Signed-off-by: Paolo Bonzini > --- > async.c | 22 +++------------------- > docs/multiple-iothreads.txt | 25 +++++++++++++++---------- > include/block/aio.h | 3 --- > iothread.c | 11 ++--------- > tests/test-aio.c | 19 +++++++++++-------- > 5 files changed, 31 insertions(+), 49 deletions(-) > > diff --git a/async.c b/async.c > index efce14b..f992914 100644 > --- a/async.c > +++ b/async.c > @@ -79,8 +79,8 @@ int aio_bh_poll(AioContext *ctx) > * aio_notify again if necessary. > */ > if (!bh->deleted && atomic_xchg(&bh->scheduled, 0)) { > - /* Idle BHs and the notify BH don't count as progress */ > - if (!bh->idle && bh != ctx->notify_dummy_bh) { > + /* Idle BHs don't count as progress */ > + if (!bh->idle) { > ret = 1; > } > bh->idle = 0; > @@ -232,7 +232,6 @@ aio_ctx_finalize(GSource *source) > { > AioContext *ctx = (AioContext *) source; > > - qemu_bh_delete(ctx->notify_dummy_bh); > thread_pool_free(ctx->thread_pool); > > qemu_mutex_lock(&ctx->bh_lock); > @@ -299,19 +298,6 @@ static void aio_timerlist_notify(void *opaque) > aio_notify(opaque); > } > > -static void aio_rfifolock_cb(void *opaque) > -{ > - AioContext *ctx = opaque; > - > - /* Kick owner thread in case they are blocked in aio_poll() */ > - qemu_bh_schedule(ctx->notify_dummy_bh); > -} > - > -static void notify_dummy_bh(void *opaque) > -{ > - /* Do nothing, we were invoked just to force the event loop to iterate */ > -} > - > static void event_notifier_dummy_cb(EventNotifier *e) > { > } > @@ -333,11 +319,9 @@ AioContext *aio_context_new(Error **errp) > event_notifier_dummy_cb); > ctx->thread_pool = NULL; > qemu_mutex_init(&ctx->bh_lock); > - rfifolock_init(&ctx->lock, aio_rfifolock_cb, ctx); > + rfifolock_init(&ctx->lock, NULL, NULL); > timerlistgroup_init(&ctx->tlg, aio_timerlist_notify, ctx); > > - ctx->notify_dummy_bh = aio_bh_new(ctx, notify_dummy_bh, NULL); > - > return ctx; > } > > diff --git a/docs/multiple-iothreads.txt b/docs/multiple-iothreads.txt > index 40b8419..723cc7e 100644 > --- a/docs/multiple-iothreads.txt > +++ b/docs/multiple-iothreads.txt > @@ -105,13 +105,10 @@ a BH in the target AioContext beforehand and then call qemu_bh_schedule(). No > acquire/release or locking is needed for the qemu_bh_schedule() call. But be > sure to acquire the AioContext for aio_bh_new() if necessary. > > -The relationship between AioContext and the block layer > -------------------------------------------------------- > -The AioContext originates from the QEMU block layer because it provides a > -scoped way of running event loop iterations until all work is done. This > -feature is used to complete all in-flight block I/O requests (see > -bdrv_drain_all()). Nowadays AioContext is a generic event loop that can be > -used by any QEMU subsystem. > +AioContext and the block layer > +------------------------------ > +The AioContext originates from the QEMU block layer, even though nowadays > +AioContext is a generic event loop that can be used by any QEMU subsystem. > > The block layer has support for AioContext integrated. Each BlockDriverState > is associated with an AioContext using bdrv_set_aio_context() and > @@ -122,9 +119,17 @@ Block layer code must therefore expect to run in an IOThread and avoid using > old APIs that implicitly use the main loop. See the "How to program for > IOThreads" above for information on how to do that. > > -If main loop code such as a QMP function wishes to access a BlockDriverState it > -must first call aio_context_acquire(bdrv_get_aio_context(bs)) to ensure the > -IOThread does not run in parallel. > +If main loop code such as a QMP function wishes to access a BlockDriverState > +it must first call aio_context_acquire(bdrv_get_aio_context(bs)) to ensure > +that callbacks in the IOThread do not run in parallel. > + > +Code running in the monitor typically uses bdrv_drain() to ensure that > +past requests from the guest are completed. When a block device is > +running in an IOThread, the IOThread can also process requests from > +the guest (via ioeventfd). These requests have to be blocked with > +aio_disable_clients() before calling bdrv_drain(). You can then reenable > +guest requests with aio_enable_clients() before finally releasing the > +AioContext and completing the monitor command. This patch will probably go in before aio_disable_clients, if any, but I'm not quite confident about the interface yet: listing a precise set of clients from monitor is an ugly coupling between modules: aio_disable_clients(bdrv_get_aio_context(bs), AIO_CLIENT_NBD | AIO_CLIENT_IOEVENTFD | AIO_CLIENT_FOO); ... aio_enble_clients(bdrv_get_aio_context(bs), AIO_CLIENT_NBD | AIO_CLIENT_IOEVENTFD | AIO_CLIENT_FOO); I prefer at least an abstraction: bdrv_quiesce_begin(bs); ... bdrv_quiesce_end(bs); My point is maybe we should leave documenting this to whichever series that introduces it? Fam > > Long-running jobs (usually in the form of coroutines) are best scheduled in the > BlockDriverState's AioContext to avoid the need to acquire/release around each > diff --git a/include/block/aio.h b/include/block/aio.h > index 400b1b0..9dd32e0 100644 > --- a/include/block/aio.h > +++ b/include/block/aio.h > @@ -114,9 +114,6 @@ struct AioContext { > bool notified; > EventNotifier notifier; > > - /* Scheduling this BH forces the event loop it iterate */ > - QEMUBH *notify_dummy_bh; > - > /* Thread pool for performing work and receiving completion callbacks */ > struct ThreadPool *thread_pool; > > diff --git a/iothread.c b/iothread.c > index da6ce7b..8f6d2e4 100644 > --- a/iothread.c > +++ b/iothread.c > @@ -30,7 +30,6 @@ typedef ObjectClass IOThreadClass; > static void *iothread_run(void *opaque) > { > IOThread *iothread = opaque; > - bool blocking; > > rcu_register_thread(); > > @@ -39,14 +38,8 @@ static void *iothread_run(void *opaque) > qemu_cond_signal(&iothread->init_done_cond); > qemu_mutex_unlock(&iothread->init_done_lock); > > - while (!iothread->stopping) { > - aio_context_acquire(iothread->ctx); > - blocking = true; > - while (!iothread->stopping && aio_poll(iothread->ctx, blocking)) { > - /* Progress was made, keep going */ > - blocking = false; > - } > - aio_context_release(iothread->ctx); > + while (!atomic_read(&iothread->stopping)) { > + aio_poll(iothread->ctx, true); > } > > rcu_unregister_thread(); > diff --git a/tests/test-aio.c b/tests/test-aio.c > index 217e337..b4bd3f1 100644 > --- a/tests/test-aio.c > +++ b/tests/test-aio.c > @@ -99,6 +99,7 @@ static void event_ready_cb(EventNotifier *e) > > typedef struct { > QemuMutex start_lock; > + EventNotifier notifier; > bool thread_acquired; > } AcquireTestData; > > @@ -110,6 +111,8 @@ static void *test_acquire_thread(void *opaque) > qemu_mutex_lock(&data->start_lock); > qemu_mutex_unlock(&data->start_lock); > > + g_usleep(500000); > + event_notifier_set(&data->notifier); > aio_context_acquire(ctx); > aio_context_release(ctx); > > @@ -118,20 +121,19 @@ static void *test_acquire_thread(void *opaque) > return NULL; > } > > -static void dummy_notifier_read(EventNotifier *unused) > +static void dummy_notifier_read(EventNotifier *n) > { > - g_assert(false); /* should never be invoked */ > + event_notifier_test_and_clear(n); > } > > static void test_acquire(void) > { > QemuThread thread; > - EventNotifier notifier; > AcquireTestData data; > > /* Dummy event notifier ensures aio_poll() will block */ > - event_notifier_init(¬ifier, false); > - aio_set_event_notifier(ctx, ¬ifier, dummy_notifier_read); > + event_notifier_init(&data.notifier, false); > + aio_set_event_notifier(ctx, &data.notifier, dummy_notifier_read); > g_assert(!aio_poll(ctx, false)); /* consume aio_notify() */ > > qemu_mutex_init(&data.start_lock); > @@ -145,12 +147,13 @@ static void test_acquire(void) > /* Block in aio_poll(), let other thread kick us and acquire context */ > aio_context_acquire(ctx); > qemu_mutex_unlock(&data.start_lock); /* let the thread run */ > - g_assert(!aio_poll(ctx, true)); > + g_assert(aio_poll(ctx, true)); > + g_assert(!data.thread_acquired); > aio_context_release(ctx); > > qemu_thread_join(&thread); > - aio_set_event_notifier(ctx, ¬ifier, NULL); > - event_notifier_cleanup(¬ifier); > + aio_set_event_notifier(ctx, &data.notifier, NULL); > + event_notifier_cleanup(&data.notifier); > > g_assert(data.thread_acquired); > } > -- > 2.4.3 > > From MAILER-DAEMON Wed Sep 09 02:08:46 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZYYo-0001sQ-3P for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 02:08:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZYYk-0001rc-88 for qemu-block@nongnu.org; Wed, 09 Sep 2015 02:08:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZYYg-0001St-6c for qemu-block@nongnu.org; Wed, 09 Sep 2015 02:08:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42402) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZYYg-0001Sn-0H; Wed, 09 Sep 2015 02:08:38 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 50BDF2BA10C; Wed, 9 Sep 2015 06:08:37 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8968Zka021141; Wed, 9 Sep 2015 02:08:36 -0400 Date: Wed, 9 Sep 2015 14:08:35 +0800 From: Fam Zheng To: Paolo Bonzini Message-ID: <20150909060835.GC21413@ad.nay.redhat.com> References: <1438868176-20364-1-git-send-email-pbonzini@redhat.com> <1438868176-20364-3-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438868176-20364-3-git-send-email-pbonzini@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 02/18] aio: rename bh_lock to list_lock X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 06:08:43 -0000 On Thu, 08/06 15:36, Paolo Bonzini wrote: > This will be used for AioHandlers too. There is going to be little > or no contention, so it is better to reuse the same lock. > > Signed-off-by: Paolo Bonzini Reviewed-by: Fam Zheng > --- > async.c | 16 ++++++++-------- > include/block/aio.h | 2 +- > 2 files changed, 9 insertions(+), 9 deletions(-) > > diff --git a/async.c b/async.c > index f992914..7e97614 100644 > --- a/async.c > +++ b/async.c > @@ -50,12 +50,12 @@ QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque) > .cb = cb, > .opaque = opaque, > }; > - qemu_mutex_lock(&ctx->bh_lock); > + qemu_mutex_lock(&ctx->list_lock); > bh->next = ctx->first_bh; > /* Make sure that the members are ready before putting bh into list */ > smp_wmb(); > ctx->first_bh = bh; > - qemu_mutex_unlock(&ctx->bh_lock); > + qemu_mutex_unlock(&ctx->list_lock); > return bh; > } > > @@ -92,7 +92,7 @@ int aio_bh_poll(AioContext *ctx) > > /* remove deleted bhs */ > if (!ctx->walking_bh) { > - qemu_mutex_lock(&ctx->bh_lock); > + qemu_mutex_lock(&ctx->list_lock); > bhp = &ctx->first_bh; > while (*bhp) { > bh = *bhp; > @@ -103,7 +103,7 @@ int aio_bh_poll(AioContext *ctx) > bhp = &bh->next; > } > } > - qemu_mutex_unlock(&ctx->bh_lock); > + qemu_mutex_unlock(&ctx->list_lock); > } > > return ret; > @@ -234,7 +234,7 @@ aio_ctx_finalize(GSource *source) > > thread_pool_free(ctx->thread_pool); > > - qemu_mutex_lock(&ctx->bh_lock); > + qemu_mutex_lock(&ctx->list_lock); > while (ctx->first_bh) { > QEMUBH *next = ctx->first_bh->next; > > @@ -244,12 +244,12 @@ aio_ctx_finalize(GSource *source) > g_free(ctx->first_bh); > ctx->first_bh = next; > } > - qemu_mutex_unlock(&ctx->bh_lock); > + qemu_mutex_unlock(&ctx->list_lock); > > aio_set_event_notifier(ctx, &ctx->notifier, NULL); > event_notifier_cleanup(&ctx->notifier); > rfifolock_destroy(&ctx->lock); > - qemu_mutex_destroy(&ctx->bh_lock); > + qemu_mutex_destroy(&ctx->list_lock); > timerlistgroup_deinit(&ctx->tlg); > } > > @@ -318,7 +318,7 @@ AioContext *aio_context_new(Error **errp) > (EventNotifierHandler *) > event_notifier_dummy_cb); > ctx->thread_pool = NULL; > - qemu_mutex_init(&ctx->bh_lock); > + qemu_mutex_init(&ctx->list_lock); > rfifolock_init(&ctx->lock, NULL, NULL); > timerlistgroup_init(&ctx->tlg, aio_timerlist_notify, ctx); > > diff --git a/include/block/aio.h b/include/block/aio.h > index 9dd32e0..026f6c1 100644 > --- a/include/block/aio.h > +++ b/include/block/aio.h > @@ -89,7 +89,7 @@ struct AioContext { > uint32_t notify_me; > > /* lock to protect between bh's adders and deleter */ > - QemuMutex bh_lock; > + QemuMutex list_lock; > > /* Anchor of the list of Bottom Halves belonging to the context */ > struct QEMUBH *first_bh; > -- > 2.4.3 > > > From MAILER-DAEMON Wed Sep 09 02:15:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZYfL-0004Nw-F7 for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 02:15:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43650) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZYfI-0004Nj-To for qemu-block@nongnu.org; Wed, 09 Sep 2015 02:15:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZYfF-0003yO-1Q for qemu-block@nongnu.org; Wed, 09 Sep 2015 02:15:28 -0400 Received: from [59.151.112.132] (port=23059 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZYfD-0003x5-IW; Wed, 09 Sep 2015 02:15:24 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100505877" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Sep 2015 14:18:06 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t896EuBl027722; Wed, 9 Sep 2015 14:14:56 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 9 Sep 2015 14:15:08 +0800 To: Eric Blake , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi References: <1439279489-13338-1-git-send-email-wency@cn.fujitsu.com> <1439279489-13338-4-git-send-email-wency@cn.fujitsu.com> <55E4917A.9010703@redhat.com> <55E4F4FF.1000504@cn.fujitsu.com> <55E5C4B0.1080301@redhat.com> <55EEA5FE.2000507@cn.fujitsu.com> <55EF0427.3020301@redhat.com> From: Wen Congyang Message-ID: <55EFCE5B.50102@cn.fujitsu.com> Date: Wed, 9 Sep 2015 14:14:51 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55EF0427.3020301@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Patch for-2.5 v2 3/6] Add new block driver interface to add/delete a BDS's child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 06:15:30 -0000 On 09/08/2015 11:52 PM, Eric Blake wrote: > On 09/08/2015 03:10 AM, Wen Congyang wrote: > >>> Design-wise, I think we really want to have the add-child operation be >>> handed a pre-opened BDS, rather than the options dictionary to open the >>> BDS itself. That is, we should use the existing blockdev-add (and >>> enhance it to support everything) to open the BDS, and then this command >>> should just attach that BDS as the new child (which is why it IS >>> important that we validate that the new BDS being added doesn't create >>> an invalid loop). >>> >> >> How to check it? The parent BDS can get all children. But the child doesn't >> know if it is some BDS's child. > > If I'm not mistaken, a child DOES know what its parent(s) are, once we > have Max's series for NULL BDS representing a BB without media. > Which patch? I don't find it. Thanks Wen Congyang From MAILER-DAEMON Wed Sep 09 03:31:22 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZZqk-0002Ti-1Z for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 03:31:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZZqh-0002Of-6A for qemu-block@nongnu.org; Wed, 09 Sep 2015 03:31:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZZqb-0000XI-QE for qemu-block@nongnu.org; Wed, 09 Sep 2015 03:31:19 -0400 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]:36395) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZZqb-0000XD-Kd; Wed, 09 Sep 2015 03:31:13 -0400 Received: by wicgb1 with SMTP id gb1so104703842wic.1; Wed, 09 Sep 2015 00:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=HQTtgfcDMnPD0zaxCXGQ4izu7DMoVDg1xp6eQFF/ndM=; b=vokBxmYgzTMe9NLyHMG6TI9dsUNsxOrFKVQb5HdynsRTYJnN/hHK5HNz/FsIcIC2Ep i4hzf38Laz7CnLtAt2aCTDMRDbyJZQw9kmLh34ul1Y8hr7rW0tZ+RDVQOIg5GDQPGfgx NFJ3u5d1dJImL3PVKU3nu0ZKxSreeVxDuP4eEnEze9ZPhABo8cZLG5Y+IEoPwStptG1I XmmYYrgS7IHEF1mHk08VxwuhgTVCv0NsvlDRc3T+sl9LbAJIAlDnK5CVjGKkSrp4+z+I nLd2/7O/8bwxcdrP4hggB3UJ8cyTa/IAR3ZEkdcquOHTy4B2oHdZMkOF4s+9O5YSJuAq YgFQ== X-Received: by 10.180.105.135 with SMTP id gm7mr9756118wib.18.1441783872981; Wed, 09 Sep 2015 00:31:12 -0700 (PDT) Received: from [192.168.10.165] ([94.39.138.45]) by smtp.googlemail.com with ESMTPSA id xs1sm8734531wjc.7.2015.09.09.00.31.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 00:31:11 -0700 (PDT) Sender: Paolo Bonzini To: Fam Zheng References: <1438868176-20364-1-git-send-email-pbonzini@redhat.com> <1438868176-20364-2-git-send-email-pbonzini@redhat.com> <20150909060619.GB21413@ad.nay.redhat.com> From: Paolo Bonzini Message-ID: <55EFE03E.10804@redhat.com> Date: Wed, 9 Sep 2015 09:31:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150909060619.GB21413@ad.nay.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::230 Cc: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 01/18] iothread: release iothread around aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 07:31:20 -0000 On 09/09/2015 08:06, Fam Zheng wrote: > This patch will probably go in before aio_disable_clients, Actually I think it's blocked by aio_disable_clients. > if any, but I'm not > quite confident about the interface yet: listing a precise set of clients from > monitor is an ugly coupling between modules: > > aio_disable_clients(bdrv_get_aio_context(bs), > AIO_CLIENT_NBD | AIO_CLIENT_IOEVENTFD | AIO_CLIENT_FOO); > > ... > > aio_enble_clients(bdrv_get_aio_context(bs), > AIO_CLIENT_NBD | AIO_CLIENT_IOEVENTFD | AIO_CLIENT_FOO); > > I prefer at least an abstraction: > > bdrv_quiesce_begin(bs); > > ... > > bdrv_quiesce_end(bs); That's fine. Paolo > My point is maybe we should leave documenting this to whichever series that > introduces it? From MAILER-DAEMON Wed Sep 09 04:22:39 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZaeN-0004MU-Gu for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 04:22:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZaeH-0004Lk-0G for qemu-block@nongnu.org; Wed, 09 Sep 2015 04:22:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZaeD-00014W-Mf for qemu-block@nongnu.org; Wed, 09 Sep 2015 04:22:32 -0400 Received: from [59.151.112.132] (port=45142 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZaeC-00012Q-Vl; Wed, 09 Sep 2015 04:22:29 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100511876" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Sep 2015 16:25:21 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t898MBQO004445; Wed, 9 Sep 2015 16:22:11 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 9 Sep 2015 16:22:23 +0800 To: Eric Blake , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-11-git-send-email-wency@cn.fujitsu.com> <55E75EF9.304@redhat.com> From: Wen Congyang Message-ID: <55EFEC2E.50608@cn.fujitsu.com> Date: Wed, 9 Sep 2015 16:22:06 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55E75EF9.304@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 10/16] docs: block replication's description X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 08:22:37 -0000 On 09/03/2015 04:41 AM, Eric Blake wrote: > On 09/02/2015 02:51 AM, Wen Congyang wrote: >> Signed-off-by: Wen Congyang >> Signed-off-by: Yang Hongyang >> Signed-off-by: zhanghailiang >> Signed-off-by: Gonglei >> --- >> docs/block-replication.txt | 183 +++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 183 insertions(+) >> create mode 100644 docs/block-replication.txt >> > > >> + >> + 1) Primary write requests will be copied and forwarded to Secondary >> + QEMU. >> + 2) Before Primary write requests are written to Secondary disk, the >> + original sector content will be read from Secondary disk and >> + buffered in the Disk buffer, but it will not overwrite the existing >> + sector content(it could be from either "Secondary Write Requests" or > > space before '(' in English sentences. > >> + previous COW of "Primary Write Requests") in the Disk buffer. >> + 3) Primary write requests will be written to Secondary disk. >> + 4) Secondary write requests will be buffered in the Disk buffer and it >> + will overwrite the existing sector content in the buffer. >> + >> +== Architecture == > >> + 3 NBD -------> 3 NBD | >> + client || server 2 filter >> + || ^ ^ >> +--------. || | | >> +Primary | || Secondary disk <--------- hidden-disk 5 <--------- active-disk 4 >> +--------' || | backing ^ backing >> + || | | >> + || | | >> + || '-------------------------' >> + || drive-backup sync=none >> + > >> + >> +4) The disk on the secondary is represented by a custom block device >> +(called active-disk). It should be an empty disk, and the format should >> +support bdrv_make_empty() and backing file. > > s/be an empty disk/start as an empty disk/ > >> + >> +5) The hidden-disk is created automatically. It buffers the original content >> +that is modified by the primary VM. It should also be an empty disk, and > > s/be/start as/ > >> +the driver supports bdrv_make_empty() and backing file. > > Missing mention that a drive-backup job is run to allow hidden-disk to > buffer any state that would otherwise be lost by the speculative > write-through of the NBD server into the secondary disk. > >> + >> +== Failure Handling == >> +There are 6 internal errors when block replication is running: >> +1. I/O error on primary disk >> +2. Forwarding primary write requests failed >> +3. Backup failed >> +4. I/O error on secondary disk >> +5. I/O error on active disk >> +6. Making active disk or hidden disk empty failed >> +In case 1 and 5, we just report the error to the disk layer. In case 2, 3, >> +4 and 6, we just report block replication's error to FT/HA manager(which > > space before '(' > >> +decides when to do a new checkpoint, when to do failover). >> +There is one internal error when doing failover: >> +1. Commiting the data in active disk/hidden disk to secondary disk failed > > s/Commiting/Committing/ > >> +We just to report this error to FT/HA manager. >> + >> +== New block driver interface == > >> + >> +== Usage == >> +Primary: >> + -drive if=xxx,driver=quorum,read-pattern=fifo,id=colo1,vote-threshold=1\ >> + children.0.file.filename=1.raw,\ >> + children.0.driver=raw,\ >> + >> + Run qmp command in primary qemu: >> + child_add disk1 child.driver=replication,child.mode=primary,\ >> + child.file.host=xxx,child.file.port=xxx,\ >> + child.file.driver=nbd,child.ignore-errors=on > > My comments earlier in this series mean this step should be two QMP > commands: the first is blockdev-add to create an unassociated BDS, the > second to then add that BDS into the quorum. > >> + Note: >> + 1. There should be only one NBD Client for each primary disk. >> + 2. host is the secondary physical machine's hostname or IP >> + 3. Each disk must have its own export name. >> + 4. It is all a single argument to -drive and child_add, and you should >> + ignore the leading whitespace. >> + 5. The qmp command line must be run after running qmp command line in >> + secondary qemu. >> + >> +Secondary: >> + -drive if=none,driver=raw,file=1.raw,id=colo1 \ >> + -drive if=xxx,driver=replication,mode=secondary,\ >> + file.file.filename=active_disk.qcow2,\ >> + file.driver=qcow2,\ >> + file.backing.file.filename=hidden_disk.qcow2,\ >> + file.backing.driver=qcow2,\ >> + file.backing.allow-write-backing-file=on,\ >> + file.backing.backing.backing_reference=colo1\ >> + >> + Then run qmp command in secondary qemu: >> + nbd-server-start host:port >> + nbd-server-add -w colo1 >> + >> + Note: >> + 1. The export name in secondary QEMU command line is the secondary >> + disk's id. >> + 2. The export name for the same disk must be the same >> + 3. The qmp command nbd-server-start and nbd-server-add must be run >> + before running the qmp command migrate on primary QEMU >> + 4. Don't use nbd-server-start's other options >> + 5. Active disk, hidden disk and nbd target's length should be the >> + same. >> + 6. It is better to put active disk and hidden disk in ramdisk. >> + 7. It is all a single argument to -drive, and you should ignore >> + the leading whitespace. > > Missing: document the steps taken during failover (that is, how do I > promote a Secondary into a new Primary, and then attach a new Secondary > to that point). In particular, I suspect there may be differences Continuous block replication is in the TODO list. But I think it is very easy to implement it if the quorum's child can be hot-added/removed. > between whether you want to roll back to the state of the last > checkpoint (in hidden_disk) or just go with the current state of the For periodic checkpoint, the secondary vm is not running, so just commit hidden_disk to secondary disk. For COLO, the secondary vm is running, and we need this state, so just commit active disk to secondary disk(hidden_disk is also committed). In which case, do we need to drop secondary disk and commit hidden disk? Thanks Wen Congyang > Secondary (in Active); either way, it probably involves doing an active > commit of the state you want into Secondary, then the formation of a new > quorum to start handing replication data off through a new NBD client > connection. > From MAILER-DAEMON Wed Sep 09 04:27:45 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZajI-0007Ba-VK for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 04:27:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZajE-00079d-2C for qemu-block@nongnu.org; Wed, 09 Sep 2015 04:27:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZaj9-0003N9-EX for qemu-block@nongnu.org; Wed, 09 Sep 2015 04:27:40 -0400 Received: from [59.151.112.132] (port=56712 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZaj7-0003L8-Ue; Wed, 09 Sep 2015 04:27:35 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100512103" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Sep 2015 16:30:27 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t898RH6a004853; Wed, 9 Sep 2015 16:27:17 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 9 Sep 2015 16:27:29 +0800 To: Eric Blake , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-16-git-send-email-wency@cn.fujitsu.com> <55E72599.6080107@redhat.com> From: Wen Congyang Message-ID: <55EFED60.9090000@cn.fujitsu.com> Date: Wed, 9 Sep 2015 16:27:12 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55E72599.6080107@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 15/16] support replication driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 08:27:43 -0000 On 09/03/2015 12:36 AM, Eric Blake wrote: > On 09/02/2015 02:51 AM, Wen Congyang wrote: >> Signed-off-by: Wen Congyang >> --- >> qapi/block-core.json | 18 ++++++++++++++++-- >> 1 file changed, 16 insertions(+), 2 deletions(-) >> >> diff --git a/qapi/block-core.json b/qapi/block-core.json >> index 96f0530..86275e3 100644 >> --- a/qapi/block-core.json >> +++ b/qapi/block-core.json >> @@ -1383,7 +1383,7 @@ >> 'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device', >> 'host_floppy', 'http', 'https', 'null-aio', 'null-co', 'parallels', >> 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx', >> - 'vmdk', 'vpc', 'vvfat', 'nbd' ] } >> + 'vmdk', 'vpc', 'vvfat', 'nbd', 'replication' ] } > > 'nbd' is not in the current qemu.git; which means your patch series > depends on a prerequisite series. Please mention that sort of > information in your cover letter. > > Please keep this enum in alphabetical order. > > Missing documentation under @drv of BlockDeviceInfo that this was > introduced in 2.5. OK > >> >> ## >> # @BlockdevOptionsBase >> @@ -1825,6 +1825,19 @@ >> { 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] } >> >> ## >> +# @BlockdevOptionsReplication >> +# >> +# Driver specific block device options for replication >> +# >> +# @mode: the replication mode > > Can the mode be 'unprotected', or must it be 'primary' or 'secondary' > when first creating a replication BDS? I will check it, and fix it in the next version. > >> +# >> +# Since: 2.5 >> +## >> +{ 'struct': 'BlockdevOptionsReplication', >> + 'base': 'BlockdevOptionsGenericFormat', >> + 'data': { 'mode': 'ReplicationMode' } } >> + >> +## >> # @BlockdevOptions >> # >> # Options for creating a block device. >> @@ -1869,7 +1882,8 @@ >> 'vhdx': 'BlockdevOptionsGenericFormat', >> 'vmdk': 'BlockdevOptionsGenericCOWFormat', >> 'vpc': 'BlockdevOptionsGenericFormat', >> - 'vvfat': 'BlockdevOptionsVVFAT' >> + 'vvfat': 'BlockdevOptionsVVFAT', >> + 'replication':'BlockdevOptionsReplication' >> } } > > It helps to keep this alphabetical. > OK Thanks Wen Congyang From MAILER-DAEMON Wed Sep 09 04:45:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZb0R-0005V3-SH for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 04:45:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZb0P-0005Us-2q for qemu-block@nongnu.org; Wed, 09 Sep 2015 04:45:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZb0L-0003my-KJ for qemu-block@nongnu.org; Wed, 09 Sep 2015 04:45:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34396) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZb0L-0003mW-DX; Wed, 09 Sep 2015 04:45:21 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 0E17796CA; Wed, 9 Sep 2015 08:45:21 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-112.ams2.redhat.com [10.36.116.112]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t898jJQZ013267; Wed, 9 Sep 2015 04:45:19 -0400 Date: Wed, 9 Sep 2015 10:45:19 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150909084519.GB4860@noname.redhat.com> References: <1441742995-11794-1-git-send-email-mreitz@redhat.com> <1441742995-11794-2-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441742995-11794-2-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 1/2] qcow2: Make size_to_clusters() return int64_t X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 08:45:26 -0000 Am 08.09.2015 um 22:09 hat Max Reitz geschrieben: > Sadly, some images may have more clusters than what can be represented > using a plain int. We should be prepared for that case (in > qcow2_check_refcounts() we actually were trying to catch that case, but > since size_to_clusters() truncated the returned value, that check never > did anything useful). > > Signed-off-by: Max Reitz You seem to fix a few of the callers as well, which is a good thing. However, what about realloc_refcount_array()? It uses size_t, which can be 32 bits, whereas the comment in refcount_array_byte_size() suggests that we could get as much as 2^55. > diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c > index 2975b83..a34f0b1 100644 > --- a/block/qcow2-cluster.c > +++ b/block/qcow2-cluster.c > @@ -473,8 +473,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, > unsigned int l2_index; > uint64_t l1_index, l2_offset, *l2_table; > int l1_bits, c; > - unsigned int index_in_cluster, nb_clusters; > - uint64_t nb_available, nb_needed; > + unsigned int index_in_cluster; > + uint64_t nb_available, nb_needed, nb_clusters; > int ret; > > index_in_cluster = (offset >> 9) & (s->cluster_sectors - 1); We're probably better off adding an assertion here. The type change is useless because nb_clusters is only used as a parameter for calling count_contiguous_(free_)clusters, which is a function that takes int64_t and returns int (which totally makes sense). In the overflow case it seems to have an endless loop. Of course, all of that doesn't really matter because nb_needed never exceeds a single L2 table. > @@ -837,10 +837,10 @@ err: > * write, but require COW to be performed (this includes yet unallocated space, > * which must copy from the backing file) > */ > -static int count_cow_clusters(BDRVQcow2State *s, int nb_clusters, > +static int count_cow_clusters(BDRVQcow2State *s, uint64_t nb_clusters, > uint64_t *l2_table, int l2_index) > { > - int i; > + uint64_t i; > > for (i = 0; i < nb_clusters; i++) { > uint64_t l2_entry = be64_to_cpu(l2_table[l2_index + i]); The return value is still int, so this changes the behaviour from an endless loop (same thing as mentioned above) to a truncated return value. Questionable whether that is an improvement (I'd say no). > @@ -960,7 +960,7 @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset, > int l2_index; > uint64_t cluster_offset; > uint64_t *l2_table; > - unsigned int nb_clusters; > + uint64_t nb_clusters; > unsigned int keep_clusters; > int ret; It looks like size isn't limited to a single L2 table there yet, so this is an important fix. However, handle_alloc() needs the same. > @@ -1426,7 +1426,7 @@ int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) > * clusters. > */ > static int discard_single_l2(BlockDriverState *bs, uint64_t offset, > - unsigned int nb_clusters, enum qcow2_discard_type type, bool full_discard) > + uint64_t nb_clusters, enum qcow2_discard_type type, bool full_discard) > { > BDRVQcow2State *s = bs->opaque; > uint64_t *l2_table; > @@ -1441,6 +1441,7 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, > > /* Limit nb_clusters to one L2 table */ > nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); > + assert(nb_clusters <= INT_MAX); > > for (i = 0; i < nb_clusters; i++) { > uint64_t old_l2_entry; > @@ -1503,7 +1504,7 @@ int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, > { > BDRVQcow2State *s = bs->opaque; > uint64_t end_offset; > - unsigned int nb_clusters; > + uint64_t nb_clusters; > int ret; > > end_offset = offset + (nb_sectors << BDRV_SECTOR_BITS); We can actually assert nb_clusters <= INT_MAX directly after assigning it and before limiting it to a single L2 table. nb_sectors is already int, so nb_clusters can never be larger. I'm not objecting to uint64_t and an assertion, though, being explicit is always nice. > @@ -1545,7 +1546,7 @@ fail: > * clusters. > */ > static int zero_single_l2(BlockDriverState *bs, uint64_t offset, > - unsigned int nb_clusters) > + uint64_t nb_clusters) > { > BDRVQcow2State *s = bs->opaque; > uint64_t *l2_table; > @@ -1560,6 +1561,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, > > /* Limit nb_clusters to one L2 table */ > nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); > + assert(nb_clusters <= INT_MAX); > > for (i = 0; i < nb_clusters; i++) { > uint64_t old_offset; > @@ -1584,7 +1586,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, > int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors) > { > BDRVQcow2State *s = bs->opaque; > - unsigned int nb_clusters; > + uint64_t nb_clusters; > int ret; > > /* The zero flag is only supported by version 3 and newer */ Same thing really. > diff --git a/block/qcow2.h b/block/qcow2.h > index 61f1b57..ce292a0 100644 > --- a/block/qcow2.h > +++ b/block/qcow2.h > @@ -415,7 +415,7 @@ static inline int64_t offset_into_cluster(BDRVQcow2State *s, int64_t offset) > return offset & (s->cluster_size - 1); > } > > -static inline int size_to_clusters(BDRVQcow2State *s, int64_t size) > +static inline int64_t size_to_clusters(BDRVQcow2State *s, int64_t size) > { > return (size + (s->cluster_size - 1)) >> s->cluster_bits; > } Kevin From MAILER-DAEMON Wed Sep 09 04:49:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZb4k-0007ZA-Ul for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 04:49:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37296) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZb4j-0007Z2-7G for qemu-block@nongnu.org; Wed, 09 Sep 2015 04:49:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZb4g-0005xq-0S for qemu-block@nongnu.org; Wed, 09 Sep 2015 04:49:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZb4f-0005xh-RY; Wed, 09 Sep 2015 04:49:49 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 8277B2EB662; Wed, 9 Sep 2015 08:49:49 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t898nlsU015506; Wed, 9 Sep 2015 04:49:48 -0400 Date: Wed, 9 Sep 2015 16:49:47 +0800 From: Fam Zheng To: Paolo Bonzini Message-ID: <20150909084947.GD21413@ad.nay.redhat.com> References: <1438868176-20364-1-git-send-email-pbonzini@redhat.com> <1438868176-20364-4-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438868176-20364-4-git-send-email-pbonzini@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 03/18] qemu-thread: introduce QemuLockCnt X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 08:49:54 -0000 On Thu, 08/06 15:36, Paolo Bonzini wrote: > +QemuLockCnt usage > +----------------- > + > +The typical pattern for QemuLockCnt functions is as follows. > + > + qemu_lockcnt_inc(&xyz_lockcnt); > + if (xyz) { > + ... access xyz ... > + } > + > + if (qemu_lockcnt_dec_and_lock(&xyz_lockcnt)) { > + g_free(xyz); > + xyz = NULL; > + qemu_lockcnt_unlock(&xyz_lockcnt); > + } > + > +Modifications are done using qemu_lockcnt_lock and qemu_lockcnt_unlock: > + > + qemu_lockcnt_lock(&xyz_lockcnt); > + xyz = g_malloc(xyz); > + qemu_lockcnt_unlock(&xyz_lockcnt); > + > +If an object has to be freed outside a visit, you can use the following > +scheme: > + > + qemu_lockcnt_lock(&xyz_lockcnt); > + if (!qemu_lockcnt_count(&xyz_lockcnt)) { > + g_free(xyz); > + xyz = NULL; > + } > + qemu_lockcnt_unlock(&xyz_lockcnt); > + > +In both the first and the third code snippets, g_free is only executed > +if count is zero. qemu_lockcnt_inc prevents the count from becoming > +non-zero while the object is being freed. > + > + > +QemuLockCnt can also be used to access a list as follows: > + > + qemu_lockcnt_inc(&io_handlers_lockcnt); > + QLIST_FOREACH_RCU(ioh, &io_handlers, pioh) { > + if (ioh->revents & G_IO_OUT) { > + ioh->fd_write(ioh->opaque); > + } > + } I'm confused, the comment of QLIST_FOREACH_RCU says "list traversal must occur within an RCU critical section.", but there is not rcu_read_lock here. Why? Fam > + > + if (qemu_lockcnt_dec_and_lock(&io_handlers_lockcnt)) { > + QLIST_FOREACH_SAFE(ioh, &io_handlers, next, pioh) { > + if (ioh->deleted) { > + QLIST_REMOVE(ioh, next); > + g_free(ioh); > + } > + } > + qemu_lockcnt_unlock(&io_handlers_lockcnt); > + } > + > +An alternative pattern uses qemu_lockcnt_dec_if_lock: > + > + qemu_lockcnt_inc(&io_handlers_lockcnt); > + QLIST_FOREACH_SAFE_RCU(ioh, &io_handlers, next, pioh) { > + if (ioh->deleted && qemu_lockcnt_dec_if_lock(&io_handlers_lockcnt)) { > + QLIST_REMOVE(ioh, next); > + g_free(ioh); > + qemu_lockcnt_inc_and_unlock(&io_handlers_lockcnt); > + continue; > + } > + > + if (ioh->revents & G_IO_OUT) { > + ioh->fd_write(ioh->opaque); > + } > + } > + qemu_lockcnt_dec(&io_handlers_lockcnt); > + > +Here you can use qemu_lockcnt_dec because there is no special task > +to do if the count goes from 1 to 0. From MAILER-DAEMON Wed Sep 09 04:52:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZb7D-0000Qi-Ur for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 04:52:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZb7B-0000Qa-TX for qemu-block@nongnu.org; Wed, 09 Sep 2015 04:52:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZb78-0007iJ-L7 for qemu-block@nongnu.org; Wed, 09 Sep 2015 04:52:25 -0400 Received: from [59.151.112.132] (port=39070 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZb77-0007hO-VI; Wed, 09 Sep 2015 04:52:22 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100513231" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Sep 2015 16:55:12 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t898q0SC006659; Wed, 9 Sep 2015 16:52:00 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 9 Sep 2015 16:52:12 +0800 To: Eric Blake , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-5-git-send-email-wency@cn.fujitsu.com> <55E744E6.5040502@redhat.com> From: Wen Congyang Message-ID: <55EFF32C.1000604@cn.fujitsu.com> Date: Wed, 9 Sep 2015 16:51:56 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55E744E6.5040502@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 04/16] block: Allow references for backing files X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 08:52:26 -0000 On 09/03/2015 02:50 AM, Eric Blake wrote: > On 09/02/2015 02:51 AM, Wen Congyang wrote: >> Usage: >> -drive file=xxx,id=Y, \ >> -drive file=xxxx,id=X,backing.backing_reference=Y >> >> It will create such backing chain: >> {virtio-blk dev 'Y'} {virtio-blk dev 'X'} >> | | >> | | >> v v >> >> [base] <- [mid] <- ( Y ) <----------------- ( X ) > > This makes any changes to 'Y' have unspecified effects on 'X'. While we > may have a valid reason to use a backing BDS in more than one chain, I > seriously doubt anyone will ever want to have two guest-visible -drive's > that are both read-write where one can corrupt the other. I can totally > see the point of having BDS 'Y' exist for checkpoints or some other > non-guest-visible action, so I'm not saying this patch is wrong, just > that the commit message is picking a poor example of how it would be used. Sorry, this graph is wrong. virtio-blk dev 'Y' can not use the BDS Y if it is referenced by X. That is why I need patch 1 and 2. Thanks Wen Congyang > >> >> Signed-off-by: Wen Congyang >> Signed-off-by: zhanghailiang >> Signed-off-by: Gonglei >> --- >> block.c | 39 +++++++++++++++++++++++++++++++++++---- >> include/block/block.h | 1 + >> 2 files changed, 36 insertions(+), 4 deletions(-) >> >> diff --git a/block.c b/block.c >> index d02d9e9..f93c50d 100644 >> --- a/block.c >> +++ b/block.c >> @@ -1179,6 +1179,7 @@ out: >> } >> >> #define ALLOW_WRITE_BACKING_FILE "allow-write-backing-file" >> +#define BACKING_REFERENCE "backing_reference" > > Why the inconsistency in '-' vs. '_'? I'd stick with dash here. > >> static QemuOptsList backing_file_opts = { >> .name = "backing_file", >> .head = QTAILQ_HEAD_INITIALIZER(backing_file_opts.head), >> @@ -1188,6 +1189,11 @@ static QemuOptsList backing_file_opts = { >> .type = QEMU_OPT_BOOL, >> .help = "allow write to backing file", >> }, >> + { >> + .name = BACKING_REFERENCE, >> + .type = QEMU_OPT_STRING, >> + .help = "reference to the exsiting BDS", > > s/exsiting/existing/ > > But why do we need this? In qapi, BlockdevOptionsGenericCOWFormat > already has '*backing':'BlockdevRef', and BlockdevRef already has a > choice between 'definition' (object) and 'reference' (string). Or is > this just a matter of teaching the command line to do what QMP can > already do? In which case, wouldn't: > > -drive file=xxx,id=Y, -drive file=xxxx,id=X,backing=Y > > be the natural mapping of 'backing' being a string rather than a dictionary? > From MAILER-DAEMON Wed Sep 09 05:15:07 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZbT9-0001RL-Gr for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 05:15:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZbT6-0001Pq-QH for qemu-block@nongnu.org; Wed, 09 Sep 2015 05:15:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZbT1-0001Q3-Ox for qemu-block@nongnu.org; Wed, 09 Sep 2015 05:15:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47494) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZbT1-0001Pu-KA; Wed, 09 Sep 2015 05:14:59 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 2AE54C0AA271; Wed, 9 Sep 2015 09:14:58 +0000 (UTC) Received: from [10.36.112.46] (ovpn-112-46.ams2.redhat.com [10.36.112.46]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t899EsK0013814 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 9 Sep 2015 05:14:56 -0400 To: Fam Zheng References: <1438868176-20364-1-git-send-email-pbonzini@redhat.com> <1438868176-20364-4-git-send-email-pbonzini@redhat.com> <20150909084947.GD21413@ad.nay.redhat.com> From: Paolo Bonzini Message-ID: <55EFF88E.4000301@redhat.com> Date: Wed, 9 Sep 2015 11:14:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150909084947.GD21413@ad.nay.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 03/18] qemu-thread: introduce QemuLockCnt X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 09:15:05 -0000 On 09/09/2015 10:49, Fam Zheng wrote: >> > + qemu_lockcnt_inc(&io_handlers_lockcnt); >> > + QLIST_FOREACH_RCU(ioh, &io_handlers, pioh) { >> > + if (ioh->revents & G_IO_OUT) { >> > + ioh->fd_write(ioh->opaque); >> > + } >> > + } > I'm confused, the comment of QLIST_FOREACH_RCU says "list traversal > must occur within an RCU critical section.", but there is not rcu_read_lock > here. Why? Right, the comment should be updated. RCU can be seen as a "global reference count" that prevents freeing an object between rcu_read_lock and rcu_read_unlock. Here the reference count is provided by the LockCnt. The difference between QLIST_FOREACH and QLIST_FOREACH_RCU is just that the latter has an extra smp_read_barrier_depends. The barrier is needed for all lockless visits. I think QLIST_FOREACH_RCU is more expressive than QLIST_FOREACH_LOCKLESS or something like that. Paolo From MAILER-DAEMON Wed Sep 09 05:19:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZbXm-0004pt-Ge for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 05:19:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZbXi-0004pU-36 for qemu-block@nongnu.org; Wed, 09 Sep 2015 05:19:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZbXe-0006Fw-3Q for qemu-block@nongnu.org; Wed, 09 Sep 2015 05:19:50 -0400 Received: from [59.151.112.132] (port=9854 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZbXd-0006B3-Ew; Wed, 09 Sep 2015 05:19:46 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100514372" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Sep 2015 17:22:33 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t899JMYY008311; Wed, 9 Sep 2015 17:19:22 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 9 Sep 2015 17:19:34 +0800 To: Eric Blake , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-4-git-send-email-wency@cn.fujitsu.com> <55E71E6A.1000001@redhat.com> From: Wen Congyang Message-ID: <55EFF996.5070202@cn.fujitsu.com> Date: Wed, 9 Sep 2015 17:19:18 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55E71E6A.1000001@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 03/16] allow writing to the backing file X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 09:19:52 -0000 On 09/03/2015 12:06 AM, Eric Blake wrote: > On 09/02/2015 02:51 AM, Wen Congyang wrote: >> Signed-off-by: Wen Congyang >> Signed-off-by: zhanghailiang >> Signed-off-by: Gonglei > > Not much description in the commit message. I really want an > explanation of why this patch is necessary. After all, with For COLO, we have such backing chain: secondary disk <-- hidden disk <-- active disk secondary disk is top BDS(use bacing reference), so it can be opened in read-write mode. But hidden disk is read only, and we need to write to hidden disk(backup job will write data to it). > 'block-commit', we were able to turn on read-write mode of backing files > on an as-needed basis, without having to expose that to the end user. > Giving the end user a knob that they must tune feels a bit awkward, and > probably means we don't have the design right. > >> --- >> block.c | 41 ++++++++++++++++++++++++++++++++++++++++- >> qapi/block-core.json | 7 ++++++- >> 2 files changed, 46 insertions(+), 2 deletions(-) >> > >> +#define ALLOW_WRITE_BACKING_FILE "allow-write-backing-file" >> +static QemuOptsList backing_file_opts = { >> + .name = "backing_file", >> + .head = QTAILQ_HEAD_INITIALIZER(backing_file_opts.head), >> + .desc = { >> + { >> + .name = ALLOW_WRITE_BACKING_FILE, >> + .type = QEMU_OPT_BOOL, >> + .help = "allow write to backing file", > > If you do add more justification for why this patch is necessary, then, > > s/write/writes/ > >> +++ b/qapi/block-core.json >> @@ -1408,6 +1408,10 @@ >> # @detect-zeroes: #optional detect and optimize zero writes (Since 2.1) >> # (default: off) >> # >> +# @allow-write-backing-file: #optional whether the backing file is opened in >> +# read-write mode. It is only for backing file >> +# (Since 2.5 default: false) >> +# > > The name feels a bit long. > > It sounds like it is an error to pass allow-write-backing-file for a > top-level BDS (that is, the BDS associated with a BB). Meanwhile, the > default for any backing chain BDS is to open it read-only, regardless of > the 'read-only' setting of the parent. But can we just allow > 'read-only':false on a backing BDS to mean that the BDS starts life as > read-write, without having to add a new parameter? > We have discussed it before: http://lists.nongnu.org/archive/html/qemu-devel/2015-02/msg04468.html Thanks Wen Congyang From MAILER-DAEMON Wed Sep 09 05:24:52 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZbca-0006z3-Py for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 05:24:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZbcY-0006vq-Ho for qemu-block@nongnu.org; Wed, 09 Sep 2015 05:24:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZbcX-0003pz-L9 for qemu-block@nongnu.org; Wed, 09 Sep 2015 05:24:50 -0400 Received: from [59.151.112.132] (port=47790 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZbcR-0003nu-Uj; Wed, 09 Sep 2015 05:24:44 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100514554" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Sep 2015 17:27:33 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t899OM6h008784; Wed, 9 Sep 2015 17:24:22 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 9 Sep 2015 17:24:34 +0800 To: Eric Blake , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-12-git-send-email-wency@cn.fujitsu.com> <55E724D4.4000202@redhat.com> From: Wen Congyang Message-ID: <55EFFAC2.4030201@cn.fujitsu.com> Date: Wed, 9 Sep 2015 17:24:18 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55E724D4.4000202@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , Michael Roth , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Luiz Capitulino , Gonglei , Yang Hongyang , zhanghailiang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 11/16] Add new block driver interfaces to control block replication X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 09:24:51 -0000 On 09/03/2015 12:33 AM, Eric Blake wrote: > On 09/02/2015 02:51 AM, Wen Congyang wrote: >> Signed-off-by: Wen Congyang >> Signed-off-by: zhanghailiang >> Signed-off-by: Gonglei >> Cc: Luiz Capitulino >> Cc: Michael Roth >> Reviewed-by: Paolo Bonzini >> --- >> block.c | 43 +++++++++++++++++++++++++++++++++++++++++++ >> include/block/block.h | 5 +++++ >> include/block/block_int.h | 14 ++++++++++++++ >> qapi/block-core.json | 15 +++++++++++++++ >> 4 files changed, 77 insertions(+) >> > > Just an interface review for now: > >> +++ b/qapi/block-core.json >> @@ -1810,6 +1810,21 @@ >> 'data': { '*export': 'str' } } >> >> ## >> +# @ReplicationMode >> +# >> +# An enumeration of replication modes. >> +# >> +# @unprotected: Replication is not started or after failover. > > Maybe: > > Replication is either not started, or has experienced failover. OK > >> +# >> +# @primary: Primary mode, the vm's state will be sent to secondary QEMU. >> +# >> +# @secondary: Secondary mode, receive the vm's state from primary QEMU. >> +# >> +# Since: 2.4 > > You've missed 2.4; this should be 2.5. Yes, I forgot to update it. I will check all patches. > >> +## >> +{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] } > > Where is 'unprotected' in this list? > I don't know when it is removed. I will check it and fix it in the next version. Thanks Wen Congyang From MAILER-DAEMON Wed Sep 09 05:39:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZbqV-0001FM-3V for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 05:39:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZbqR-0001EM-P9 for qemu-block@nongnu.org; Wed, 09 Sep 2015 05:39:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZbqN-0002OA-QD for qemu-block@nongnu.org; Wed, 09 Sep 2015 05:39:11 -0400 Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:35711) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZbqN-0002Nw-Jo; Wed, 09 Sep 2015 05:39:07 -0400 Received: by wicge5 with SMTP id ge5so147493499wic.0; Wed, 09 Sep 2015 02:39:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=ZduZBQpLZ+K8LfPDqGg6Gwt26v0Qj07xhelmwujdoQg=; b=q0CZya2DWO5QoQo85qWyhn2fdJ8QC8LPMtnj7jv6Zg8upjvyY503Tvf1y/sCQgoxjE bI4VmTNgTU8VNPG+2gu+YmEkLW2LgvFJcfhPfHi07Yb+SvJno4EVXlFvxYZH5dxI+7Tz 3Kurh6YuZK+3lGm5UO2koys00nS0dFRN53SjZMgMdF3KJUyJeyhNn0WpNyd7dcKsasX1 DPdye/oyyS1Pg/Wlt4SOM3hR3xt8PUz6l2mpQ7wYKiHwYTYtI2a48uW4Zwt2ggjZEsch uvO1R9biEYq1oO/7O2ZzS935gxgN7ekOkJHqvgXD0QCYRCxiF9M5jgIVsHo7uDiIVtzA DMtQ== X-Received: by 10.194.78.230 with SMTP id e6mr56486776wjx.43.1441791547073; Wed, 09 Sep 2015 02:39:07 -0700 (PDT) Received: from localhost (host86-182-204-196.range86-182.btcentralplus.com. [86.182.204.196]) by smtp.gmail.com with ESMTPSA id v6sm9278604wjf.13.2015.09.09.02.39.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 02:39:06 -0700 (PDT) Date: Wed, 9 Sep 2015 10:39:05 +0100 From: Stefan Hajnoczi To: Kevin Wolf Message-ID: <20150909093905.GJ9777@stefanha-thinkpad.redhat.com> References: <1441638895-1445-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441638895-1445-1-git-send-email-kwolf@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22d Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH] qcow2: Rename BDRVQcowState to BDRVQcow2State X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 09:39:12 -0000 On Mon, Sep 07, 2015 at 05:14:55PM +0200, Kevin Wolf wrote: > BDRVQcowState is already used by qcow1, and gdb is always confused which > one to use. Rename the qcow2 one so they can be distinguished. > > Signed-off-by: Kevin Wolf > --- > block/qcow2-cache.c | 14 ++++----- > block/qcow2-cluster.c | 48 +++++++++++++++---------------- > block/qcow2-refcount.c | 58 ++++++++++++++++++------------------- > block/qcow2-snapshot.c | 20 ++++++------- > block/qcow2.c | 78 +++++++++++++++++++++++++------------------------- > block/qcow2.h | 22 +++++++------- > 6 files changed, 120 insertions(+), 120 deletions(-) I never thought I'd see the day! Reviewed-by: Stefan Hajnoczi From MAILER-DAEMON Wed Sep 09 06:01:49 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZcCL-0006Vd-B2 for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 06:01:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZcCI-0006Sd-Ln for qemu-block@nongnu.org; Wed, 09 Sep 2015 06:01:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZcCE-0000bx-En for qemu-block@nongnu.org; Wed, 09 Sep 2015 06:01:46 -0400 Received: from [59.151.112.132] (port=6423 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZcC7-0000MO-A2; Wed, 09 Sep 2015 06:01:36 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100516184" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Sep 2015 18:04:22 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t89A1BlT010991; Wed, 9 Sep 2015 18:01:11 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 9 Sep 2015 18:01:23 +0800 To: Max Reitz , References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-30-git-send-email-mreitz@redhat.com> <55EEA69E.4010706@cn.fujitsu.com> <55EF5133.2040807@redhat.com> From: Wen Congyang Message-ID: <55F00363.5080709@cn.fujitsu.com> Date: Wed, 9 Sep 2015 18:01:07 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55EF5133.2040807@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 29/38] blockdev: Add blockdev-insert-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 10:01:47 -0000 On 09/09/2015 05:20 AM, Max Reitz wrote: > On 08.09.2015 11:13, Wen Congyang wrote: >> On 07/21/2015 01:45 AM, 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). >>> >>> Signed-off-by: Max Reitz >>> --- >>> blockdev.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ >>> qapi/block-core.json | 17 +++++++++++++++++ >>> qmp-commands.hx | 37 +++++++++++++++++++++++++++++++++++++ >>> 3 files changed, 102 insertions(+) >>> >>> diff --git a/blockdev.c b/blockdev.c >>> index 481760a..a80d0e2 100644 >>> --- a/blockdev.c >>> +++ b/blockdev.c >>> @@ -2164,6 +2164,54 @@ void qmp_blockdev_remove_medium(const char *device, Error **errp) >>> } >>> } >>> >>> +static void qmp_blockdev_insert_anon_medium(const char *device, >>> + BlockDriverState *bs, Error **errp) >>> +{ >>> + BlockBackend *blk; >>> + bool has_device; >>> + >>> + blk = blk_by_name(device); >>> + if (!blk) { >>> + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, >>> + "Device '%s' not found", device); >>> + return; >>> + } >>> + >>> + /* For BBs without a device, we can exchange the BDS tree at will */ >>> + has_device = blk_get_attached_dev(blk); >>> + >>> + if (has_device && !blk_dev_has_removable_media(blk)) { >>> + error_setg(errp, "Device '%s' is not removable", device); >>> + return; >>> + } >>> + >>> + if (has_device && !blk_dev_is_tray_open(blk)) { >>> + error_setg(errp, "Tray of device '%s' is not open", device); >>> + return; >>> + } >>> + >>> + if (blk_bs(blk)) { >>> + error_setg(errp, "There already is a medium in device '%s'", device); >>> + return; >>> + } >>> + >>> + blk_insert_bs(blk, bs); >>> +} >>> + >>> +void qmp_blockdev_insert_medium(const char *device, const char *node_name, >>> + Error **errp) >>> +{ >>> + BlockDriverState *bs; >>> + >>> + bs = bdrv_find_node(node_name); >>> + if (!bs) { >>> + error_setg(errp, "Node '%s' not found", node_name); >>> + return; >>> + } >> >> Hmm, it is OK if the bs is not top BDS? > > I think so, yes. Generally, there's probably no reason to do that, but I > don't know why we should not allow that case. For instance, you might > want to make a backing file available read-only somewhere. > > It should be impossible to make it available writable, and it should not > be allowed to start a block-commit operation while the backing file can > be accessed by the guest, but this should be achieved using op blockers. > > What we need for this to work are fine-grained op blockers, I think. But > working around that for now by only allowing to insert top BDS won't > work, since you can still start block jobs which target top BDS, too > (e.g. blockdev-backup can write to a BDS/BB that is visible to the guest). > > All in all, I think it's fine to insert non-top BDS, but we should > definitely worry about which exact BDS one can insert once we have > fine-grained op blockers. A BDS can be written by its parent, its block backend, a block job.. So I think we should have some way to avoid more than two sources writing to it, otherwise the data may be corrupted. Thanks Wen Congyang > > Max > >> Thanks >> Wen Congyang >> >>> + >>> + qmp_blockdev_insert_anon_medium(device, bs, errp); >>> +} >>> + >>> /* throttling disk I/O limits */ >>> void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, >>> int64_t bps_wr, >>> diff --git a/qapi/block-core.json b/qapi/block-core.json >>> index 63a83e4..84c9b23 100644 >>> --- a/qapi/block-core.json >>> +++ b/qapi/block-core.json >>> @@ -1925,6 +1925,23 @@ >>> { 'command': 'blockdev-remove-medium', >>> 'data': { 'device': 'str' } } >>> >>> +## >>> +# @blockdev-insert-medium: >>> +# >>> +# Inserts a medium (a block driver state tree) into a block device. That block >>> +# device's tray must currently be open and there must be no medium inserted >>> +# already. >>> +# >>> +# @device: block device name >>> +# >>> +# @node-name: name of a node in the block driver state graph >>> +# >>> +# Since: 2.5 >>> +## >>> +{ 'command': 'blockdev-insert-medium', >>> + 'data': { 'device': 'str', >>> + 'node-name': 'str'} } >>> + >>> >>> ## >>> # @BlockErrorAction >>> diff --git a/qmp-commands.hx b/qmp-commands.hx >>> index ff6c572..b4c34fe 100644 >>> --- a/qmp-commands.hx >>> +++ b/qmp-commands.hx >>> @@ -3991,6 +3991,43 @@ Example: >>> EQMP >>> >>> { >>> + .name = "blockdev-insert-medium", >>> + .args_type = "device:s,node-name:s", >>> + .mhandler.cmd_new = qmp_marshal_input_blockdev_insert_medium, >>> + }, >>> + >>> +SQMP >>> +blockdev-insert-medium >>> +---------------------- >>> + >>> +Inserts a medium (a block driver state tree) into a block device. That block >>> +device's tray must currently be open and there must be no medium inserted >>> +already. >>> + >>> +Arguments: >>> + >>> +- "device": block device name (json-string) >>> +- "node-name": root node of the BDS tree to insert into the block device >>> + >>> +Example: >>> + >>> +-> { "execute": "blockdev-add", >>> + "arguments": { "options": { "node-name": "node0", >>> + "driver": "raw", >>> + "file": { "driver": "file", >>> + "filename": "fedora.iso" } } } } >>> + >>> +<- { "return": {} } >>> + >>> +-> { "execute": "blockdev-insert-medium", >>> + "arguments": { "device": "ide1-cd0", >>> + "node-name": "node0" } } >>> + >>> +<- { "return": {} } >>> + >>> +EQMP >>> + >>> + { >>> .name = "query-named-block-nodes", >>> .args_type = "", >>> .mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes, >>> >> > > From MAILER-DAEMON Wed Sep 09 08:11:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZeE0-0001FO-0L for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 08:11:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZeDw-0000yi-AU for qemu-block@nongnu.org; Wed, 09 Sep 2015 08:11:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZeDt-0001Jm-4o for qemu-block@nongnu.org; Wed, 09 Sep 2015 08:11:36 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:8490 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZeDs-0001B6-VU; Wed, 09 Sep 2015 08:11:33 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AFAgCxIPBV/5tjdVtdGQEBAYMHgT2pFwUBgQuSfAEJh3ACgTY4FAEBAQEBAQGBCoQkAQEDATo/BQsLDhMlDwEsGwYBEogmDAHKFwEBAQEBAQEDAQEBAQEdhiyFQoUMB4QsAQSVVqdyJoQCPDOISQEBAQ X-IPAS-Result: A2AFAgCxIPBV/5tjdVtdGQEBAYMHgT2pFwUBgQuSfAEJh3ACgTY4FAEBAQEBAQGBCoQkAQEDATo/BQsLDhMlDwEsGwYBEogmDAHKFwEBAQEBAQEDAQEBAQEdhiyFQoUMB4QsAQSVVqdyJoQCPDOISQEBAQ X-IronPort-AV: E=Sophos;i="5.17,496,1437429600"; d="scan'208";a="20514014" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 09 Sep 2015 14:10:52 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZZeDD-0000Vx-W8; Wed, 09 Sep 2015 14:10:52 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZZeDD-0001uY-PZ; Wed, 09 Sep 2015 14:10:51 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1441638895-1445-1-git-send-email-kwolf@redhat.com> References: <1441638895-1445-1-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Wed, 09 Sep 2015 14:10:51 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH] qcow2: Rename BDRVQcowState to BDRVQcow2State X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 12:11:37 -0000 On Mon 07 Sep 2015 05:14:55 PM CEST, Kevin Wolf wrote: > BDRVQcowState is already used by qcow1, and gdb is always confused > which one to use. Rename the qcow2 one so they can be distinguished. > > Signed-off-by: Kevin Wolf Reviewed-by: Alberto Garcia Berto From MAILER-DAEMON Wed Sep 09 08:59:59 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZeyl-0002Zn-SX for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 08:59:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZeyi-0002Yu-GP for qemu-block@nongnu.org; Wed, 09 Sep 2015 08:59:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZeyc-00005r-9g for qemu-block@nongnu.org; Wed, 09 Sep 2015 08:59:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42489) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZeyc-0008F0-2F; Wed, 09 Sep 2015 08:59:50 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 6F13EA062E; Wed, 9 Sep 2015 12:59:46 +0000 (UTC) Received: from [10.36.116.125] (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t89CxguP024162 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 9 Sep 2015 08:59:43 -0400 To: Wen Congyang , qemu-block@nongnu.org References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-30-git-send-email-mreitz@redhat.com> <55EEA69E.4010706@cn.fujitsu.com> <55EF5133.2040807@redhat.com> <55F00363.5080709@cn.fujitsu.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <55F02D3D.6020102@redhat.com> Date: Wed, 9 Sep 2015 14:59:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F00363.5080709@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Xh7xlaPfWo3m1633K3HfklO2Vp3fuo35F" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 29/38] blockdev: Add blockdev-insert-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 12:59:58 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Xh7xlaPfWo3m1633K3HfklO2Vp3fuo35F Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 09.09.2015 12:01, Wen Congyang wrote: > On 09/09/2015 05:20 AM, Max Reitz wrote: >> On 08.09.2015 11:13, Wen Congyang wrote: >>> On 07/21/2015 01:45 AM, Max Reitz wrote: >>>> And a helper function for that, which directly takes a pointer to th= e >>>> BDS to be inserted instead of its node-name (which will be used for >>>> implementing 'change' using blockdev-insert-medium). >>>> >>>> Signed-off-by: Max Reitz >>>> --- >>>> blockdev.c | 48 +++++++++++++++++++++++++++++++++++++++++= +++++++ >>>> qapi/block-core.json | 17 +++++++++++++++++ >>>> qmp-commands.hx | 37 +++++++++++++++++++++++++++++++++++++ >>>> 3 files changed, 102 insertions(+) >>>> >>>> diff --git a/blockdev.c b/blockdev.c >>>> index 481760a..a80d0e2 100644 >>>> --- a/blockdev.c >>>> +++ b/blockdev.c >>>> @@ -2164,6 +2164,54 @@ void qmp_blockdev_remove_medium(const char *d= evice, Error **errp) >>>> } >>>> } >>>> =20 >>>> +static void qmp_blockdev_insert_anon_medium(const char *device, >>>> + BlockDriverState *bs, E= rror **errp) >>>> +{ >>>> + BlockBackend *blk; >>>> + bool has_device; >>>> + >>>> + blk =3D blk_by_name(device); >>>> + if (!blk) { >>>> + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, >>>> + "Device '%s' not found", device); >>>> + return; >>>> + } >>>> + >>>> + /* For BBs without a device, we can exchange the BDS tree at wi= ll */ >>>> + has_device =3D blk_get_attached_dev(blk); >>>> + >>>> + if (has_device && !blk_dev_has_removable_media(blk)) { >>>> + error_setg(errp, "Device '%s' is not removable", device); >>>> + return; >>>> + } >>>> + >>>> + if (has_device && !blk_dev_is_tray_open(blk)) { >>>> + error_setg(errp, "Tray of device '%s' is not open", device)= ; >>>> + return; >>>> + } >>>> + >>>> + if (blk_bs(blk)) { >>>> + error_setg(errp, "There already is a medium in device '%s'"= , device); >>>> + return; >>>> + } >>>> + >>>> + blk_insert_bs(blk, bs); >>>> +} >>>> + >>>> +void qmp_blockdev_insert_medium(const char *device, const char *nod= e_name, >>>> + Error **errp) >>>> +{ >>>> + BlockDriverState *bs; >>>> + >>>> + bs =3D bdrv_find_node(node_name); >>>> + if (!bs) { >>>> + error_setg(errp, "Node '%s' not found", node_name); >>>> + return; >>>> + } >>> >>> Hmm, it is OK if the bs is not top BDS? >> >> I think so, yes. Generally, there's probably no reason to do that, but= I >> don't know why we should not allow that case. For instance, you might >> want to make a backing file available read-only somewhere. >> >> It should be impossible to make it available writable, and it should n= ot >> be allowed to start a block-commit operation while the backing file ca= n >> be accessed by the guest, but this should be achieved using op blocker= s. >> >> What we need for this to work are fine-grained op blockers, I think. B= ut >> working around that for now by only allowing to insert top BDS won't >> work, since you can still start block jobs which target top BDS, too >> (e.g. blockdev-backup can write to a BDS/BB that is visible to the gue= st). >> >> All in all, I think it's fine to insert non-top BDS, but we should >> definitely worry about which exact BDS one can insert once we have >> fine-grained op blockers. >=20 > A BDS can be written by its parent, its block backend, a block job.. > So I think we should have some way to avoid more than two sources writi= ng > to it, otherwise the data may be corrupted. Yes, and that would be op blockers. As I said, using blockdev-backup you can write to a BB that can be written to by the guest as well. I think this is a bug, but it is a bug that needs to be fixed by having better op blockers in place, which Jeff Cody is working on. Regarding this series, I don't consider this to be too big of an issue. Yes, if you are working with floppy disks, you can have the case of a block job and the guest writing to the BDS at the same time. But I can't really imagine who would use floppy disks and block jobs at the same time (people who still use floppy disks for their VMs don't strike me as the kind of people who use the management features of qemu, especially not for those floppy disks). Other than that, this function (blockdev-insert-medium) can only be used for optical ROM devices (I don't think we have CD/DVD-RW support, do we?), so it's much less of an issue there. So all in all I don't consider this too big of an issue here. If others think different, then I would delay this part of the series (which overhauls the "change" command) until we have fine-grained op blockers. Max --Xh7xlaPfWo3m1633K3HfklO2Vp3fuo35F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEbBAEBCAAGBQJV8C09AAoJEDuxQgLoOKyt8A8H+NH7WLcR/igrNO2PBwoELZh6 eVnYKzIAPnLLeNl9iVrP6/MGE/afiD2r44kzfNtUGexm8sIO/8zmwQ5BWykMhDik xK6PZxpEMnM+EeRYGzGqwlknToH9C0sz9HSH7sffz2fMr/qPR7H0jlmxsqBtvF6l 1oVsnsPOSVMtsgQFli/Wo7jBUmbjW3gj9dQF6q7tC3ZZ4MN4RfIlSdNo1Uu38H9D XWufXbdjwfVQyVlhVOmUMgN1kLK9nJ/7ASplKzfqSnUkuZXNSgsfEA0bX+9rRr3z rVdADMqhrcbb9pbN+f2jrPAxYDy+xOrKb05UTTosbzAvseAgC5IGvimL0Oz8oA== =0VBD -----END PGP SIGNATURE----- --Xh7xlaPfWo3m1633K3HfklO2Vp3fuo35F-- From MAILER-DAEMON Wed Sep 09 09:42:11 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZfdb-0001wx-UA for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 09:42:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZfdT-0001uu-9E for qemu-block@nongnu.org; Wed, 09 Sep 2015 09:42:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZfdO-0007Ss-M5 for qemu-block@nongnu.org; Wed, 09 Sep 2015 09:42:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46683) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZfdO-0007So-E2; Wed, 09 Sep 2015 09:41:58 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 0171D2E6CC6; Wed, 9 Sep 2015 13:41:57 +0000 (UTC) Received: from [10.36.116.125] (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t89Dft3r024685 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 9 Sep 2015 09:41:56 -0400 To: Kevin Wolf References: <1441742995-11794-1-git-send-email-mreitz@redhat.com> <1441742995-11794-2-git-send-email-mreitz@redhat.com> <20150909084519.GB4860@noname.redhat.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <55F03722.2000301@redhat.com> Date: Wed, 9 Sep 2015 15:41:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150909084519.GB4860@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="AX3esCRjNPejWHTQtI50XFCp5j1GlOsGb" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 1/2] qcow2: Make size_to_clusters() return int64_t X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 13:42:09 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --AX3esCRjNPejWHTQtI50XFCp5j1GlOsGb Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 09.09.2015 10:45, Kevin Wolf wrote: > Am 08.09.2015 um 22:09 hat Max Reitz geschrieben: >> Sadly, some images may have more clusters than what can be represented= >> using a plain int. We should be prepared for that case (in >> qcow2_check_refcounts() we actually were trying to catch that case, bu= t >> since size_to_clusters() truncated the returned value, that check neve= r >> did anything useful). >> >> Signed-off-by: Max Reitz >=20 > You seem to fix a few of the callers as well, which is a good thing. >=20 > However, what about realloc_refcount_array()? It uses size_t, which can= > be 32 bits, whereas the comment in refcount_array_byte_size() suggests > that we could get as much as 2^55. You're right. It was probably just too late when I wrote this patch. I looked at that code and assumed that in the past I was intelligent enough to make sure somewhere that it won't overflow there. Obviously I wasn't. >> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c >> index 2975b83..a34f0b1 100644 >> --- a/block/qcow2-cluster.c >> +++ b/block/qcow2-cluster.c >> @@ -473,8 +473,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs,= uint64_t offset, >> unsigned int l2_index; >> uint64_t l1_index, l2_offset, *l2_table; >> int l1_bits, c; >> - unsigned int index_in_cluster, nb_clusters; >> - uint64_t nb_available, nb_needed; >> + unsigned int index_in_cluster; >> + uint64_t nb_available, nb_needed, nb_clusters; >> int ret; >> =20 >> index_in_cluster =3D (offset >> 9) & (s->cluster_sectors - 1); >=20 > We're probably better off adding an assertion here. The type change is > useless because nb_clusters is only used as a parameter for calling > count_contiguous_(free_)clusters, which is a function that takes int64_= t > and returns int (which totally makes sense). In the overflow case it > seems to have an endless loop. >=20 > Of course, all of that doesn't really matter because nb_needed never > exceeds a single L2 table. Hm, yes. I just looked at count_contiguous_{free_,}clusters() and they took int64_t as a parameter, so I assumed they were prepared to handle it. Again, what a fool I was. Yes, I'll add an assertion. Or maybe I don't, because I feel like the best place to do so is actually in count_contiguous_{free_,}clusters(). And there isn't even a need for an assertion there, because we can just limit nb_clusters to the number of L2 table entries in those functions. So there it's a question of "We could actually easily work with large @nb_clusters by limiting it to the obvious maximum, but you are not supposed to call this function with such large values, so by having a too large value you are violating the function contract". I'll probably just add an assertion. >> @@ -837,10 +837,10 @@ err: >> * write, but require COW to be performed (this includes yet unalloca= ted space, >> * which must copy from the backing file) >> */ >> -static int count_cow_clusters(BDRVQcow2State *s, int nb_clusters, >> +static int count_cow_clusters(BDRVQcow2State *s, uint64_t nb_clusters= , >> uint64_t *l2_table, int l2_index) >> { >> - int i; >> + uint64_t i; >> =20 >> for (i =3D 0; i < nb_clusters; i++) { >> uint64_t l2_entry =3D be64_to_cpu(l2_table[l2_index + i]); >=20 > The return value is still int, so this changes the behaviour from an > endless loop (same thing as mentioned above) to a truncated return > value. Questionable whether that is an improvement (I'd say no). OK. Argh. OK then. I'll keep this function taking an int, and make count_contiguous_{free_,}clusters() take an int, too, and handle the assert()s in the functions calling those. >> @@ -960,7 +960,7 @@ static int handle_copied(BlockDriverState *bs, uin= t64_t guest_offset, >> int l2_index; >> uint64_t cluster_offset; >> uint64_t *l2_table; >> - unsigned int nb_clusters; >> + uint64_t nb_clusters; >> unsigned int keep_clusters; >> int ret; >=20 > It looks like size isn't limited to a single L2 table there yet, so thi= s > is an important fix. However, handle_alloc() needs the same. Oops, I simply missed that size_to_clusters() call. >> @@ -1426,7 +1426,7 @@ int qcow2_decompress_cluster(BlockDriverState *b= s, uint64_t cluster_offset) >> * clusters. >> */ >> static int discard_single_l2(BlockDriverState *bs, uint64_t offset, >> - unsigned int nb_clusters, enum qcow2_discard_type type, bool full= _discard) >> + uint64_t nb_clusters, enum qcow2_discard_type type, bool full_dis= card) >> { >> BDRVQcow2State *s =3D bs->opaque; >> uint64_t *l2_table; >> @@ -1441,6 +1441,7 @@ static int discard_single_l2(BlockDriverState *b= s, uint64_t offset, >> =20 >> /* Limit nb_clusters to one L2 table */ >> nb_clusters =3D MIN(nb_clusters, s->l2_size - l2_index); >> + assert(nb_clusters <=3D INT_MAX); >> =20 >> for (i =3D 0; i < nb_clusters; i++) { >> uint64_t old_l2_entry; >> @@ -1503,7 +1504,7 @@ int qcow2_discard_clusters(BlockDriverState *bs,= uint64_t offset, >> { >> BDRVQcow2State *s =3D bs->opaque; >> uint64_t end_offset; >> - unsigned int nb_clusters; >> + uint64_t nb_clusters; >> int ret; >> =20 >> end_offset =3D offset + (nb_sectors << BDRV_SECTOR_BITS); >=20 > We can actually assert nb_clusters <=3D INT_MAX directly after assignin= g > it and before limiting it to a single L2 table. nb_sectors is already > int, so nb_clusters can never be larger. Hm, I think I like asserting such a range limitation after the last assignment, and the fact that that assignment is limiting is obvious, too, since s->l2_size is an int. So I think I'll keep it as it is (and do the same elsewhere). > I'm not objecting to uint64_t and an assertion, though, being explicit > is always nice. >=20 >> @@ -1545,7 +1546,7 @@ fail: >> * clusters. >> */ >> static int zero_single_l2(BlockDriverState *bs, uint64_t offset, >> - unsigned int nb_clusters) >> + uint64_t nb_clusters) >> { >> BDRVQcow2State *s =3D bs->opaque; >> uint64_t *l2_table; >> @@ -1560,6 +1561,7 @@ static int zero_single_l2(BlockDriverState *bs, = uint64_t offset, >> =20 >> /* Limit nb_clusters to one L2 table */ >> nb_clusters =3D MIN(nb_clusters, s->l2_size - l2_index); >> + assert(nb_clusters <=3D INT_MAX); >> =20 >> for (i =3D 0; i < nb_clusters; i++) { >> uint64_t old_offset; >> @@ -1584,7 +1586,7 @@ static int zero_single_l2(BlockDriverState *bs, = uint64_t offset, >> int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb= _sectors) >> { >> BDRVQcow2State *s =3D bs->opaque; >> - unsigned int nb_clusters; >> + uint64_t nb_clusters; >> int ret; >> =20 >> /* The zero flag is only supported by version 3 and newer */ >=20 > Same thing really. Not really. The value returned by this function is not related to nb_clusters (it's 0 in case of success), and zero_single_l2() takes a uint64_t and makes good use of it. So this should actually be fine. >> diff --git a/block/qcow2.h b/block/qcow2.h >> index 61f1b57..ce292a0 100644 >> --- a/block/qcow2.h >> +++ b/block/qcow2.h >> @@ -415,7 +415,7 @@ static inline int64_t offset_into_cluster(BDRVQcow= 2State *s, int64_t offset) >> return offset & (s->cluster_size - 1); >> } >> =20 >> -static inline int size_to_clusters(BDRVQcow2State *s, int64_t size) >> +static inline int64_t size_to_clusters(BDRVQcow2State *s, int64_t siz= e) >> { >> return (size + (s->cluster_size - 1)) >> s->cluster_bits; >> } >=20 > Kevin >=20 Thanks for reviewing! Max --AX3esCRjNPejWHTQtI50XFCp5j1GlOsGb Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV8DciAAoJEDuxQgLoOKytFfEH/0nghH1CwasXtdfmPwkRxKfm XN+o1euqi8DITOpedxwCSqH7qEXWYHT1ISzNpp2aGBxiW0Kt1lO+rePIJ8O1D+XQ nwVQk3/mFh5b+M53/cHHwLq9bAjtjVhjmansNRe2R7yxO+vK+IHburSajwB99CWV 0gXx0fY6MqC/gB74+QH8IMuRFsHLElzKv5IKf29y0seuOwDH310BCBLUaEui39Eb 7t4bpkj97lre8SjZaTR75Z4+6kgLscA8l4kk5tfgVrJNQalaBr4G1HVp1qrE6qCN xify5u1nQcklP99WszQ5ongdA/GneCcMCqWwf0etCOxub4IWMNhlUPPPA0cMvZg= =ziao -----END PGP SIGNATURE----- --AX3esCRjNPejWHTQtI50XFCp5j1GlOsGb-- From MAILER-DAEMON Wed Sep 09 12:10:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZhwf-0006rp-SS for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 12:10:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZhwZ-0006pI-1m for qemu-block@nongnu.org; Wed, 09 Sep 2015 12:09:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZhwU-0005qg-OM for qemu-block@nongnu.org; Wed, 09 Sep 2015 12:09:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41620) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZhwU-0005qZ-K5; Wed, 09 Sep 2015 12:09:50 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 06C63A2C12; Wed, 9 Sep 2015 16:09:50 +0000 (UTC) Received: from localhost (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t89G9lOt005788 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 9 Sep 2015 12:09:49 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 9 Sep 2015 18:09:45 +0200 Message-Id: <1441814987-27121-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH v2 0/2] qcow2: Make size_to_clusters() return uint64_t X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 16:10:00 -0000 Some callers actually expected that function to return uint64_t. As it turns out, it doesn't. Fix that. v2: - Patch 1: - int64_t -> uint64_t [Eric] - Several fixes in places calling size_to_clusters() (and transitively, too) [Kevin] - Patch 2: - s/occuring/occurring/ [Eric] Max Reitz (2): qcow2: Make size_to_clusters() return uint64_t iotests: Add test for checking large image files block/qcow2-cluster.c | 30 ++++++++++++------- block/qcow2-refcount.c | 10 +++++-- block/qcow2.h | 6 ++-- tests/qemu-iotests/138 | 73 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/138.out | 9 ++++++ tests/qemu-iotests/group | 1 + 6 files changed, 112 insertions(+), 17 deletions(-) create mode 100755 tests/qemu-iotests/138 create mode 100644 tests/qemu-iotests/138.out -- 2.5.1 From MAILER-DAEMON Wed Sep 09 12:10:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZhwg-0006s4-2h for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 12:10:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZhwZ-0006pJ-ED for qemu-block@nongnu.org; Wed, 09 Sep 2015 12:10:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZhwY-0005rN-3X for qemu-block@nongnu.org; Wed, 09 Sep 2015 12:09:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32812) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZhwX-0005rI-QB; Wed, 09 Sep 2015 12:09:54 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 565A82EB662; Wed, 9 Sep 2015 16:09:53 +0000 (UTC) Received: from localhost (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t89G9ofS032335 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 9 Sep 2015 12:09:52 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 9 Sep 2015 18:09:46 +0200 Message-Id: <1441814987-27121-2-git-send-email-mreitz@redhat.com> In-Reply-To: <1441814987-27121-1-git-send-email-mreitz@redhat.com> References: <1441814987-27121-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH v2 1/2] qcow2: Make size_to_clusters() return uint64_t X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 16:10:00 -0000 Sadly, some images may have more clusters than what can be represented using a plain int. We should be prepared for that case (in qcow2_check_refcounts() we actually were trying to catch that case, but since size_to_clusters() truncated the returned value, that check never did anything useful). Cc: qemu-stable Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 30 +++++++++++++++++++----------- block/qcow2-refcount.c | 10 +++++++--- block/qcow2.h | 6 +++--- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 2975b83..dc217e7 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -298,7 +298,7 @@ fail: * as contiguous. (This allows it, for example, to stop at the first compressed * cluster which may require a different handling) */ -static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size, +static int count_contiguous_clusters(int nb_clusters, int cluster_size, uint64_t *l2_table, uint64_t stop_flags) { int i; @@ -321,7 +321,7 @@ static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size, return i; } -static int count_contiguous_free_clusters(uint64_t nb_clusters, uint64_t *l2_table) +static int count_contiguous_free_clusters(int nb_clusters, uint64_t *l2_table) { int i; @@ -495,6 +495,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, if (nb_needed > nb_available) { nb_needed = nb_available; } + assert(nb_needed <= INT_MAX); *cluster_offset = 0; @@ -530,6 +531,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); *cluster_offset = be64_to_cpu(l2_table[l2_index]); + + /* nb_needed <= INT_MAX, thus nb_clusters <= INT_MAX, too */ nb_clusters = size_to_clusters(s, nb_needed << 9); ret = qcow2_get_cluster_type(*cluster_offset); @@ -840,7 +843,7 @@ err: static int count_cow_clusters(BDRVQcow2State *s, int nb_clusters, uint64_t *l2_table, int l2_index) { - int i; + uint64_t i; for (i = 0; i < nb_clusters; i++) { uint64_t l2_entry = be64_to_cpu(l2_table[l2_index + i]); @@ -960,7 +963,7 @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset, int l2_index; uint64_t cluster_offset; uint64_t *l2_table; - unsigned int nb_clusters; + uint64_t nb_clusters; unsigned int keep_clusters; int ret; @@ -979,6 +982,7 @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset, l2_index = offset_to_l2_index(s, guest_offset); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); /* Find L2 entry for the first involved cluster */ ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index); @@ -1061,7 +1065,7 @@ out: * restarted, but the whole request should not be failed. */ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, - uint64_t *host_offset, unsigned int *nb_clusters) + uint64_t *host_offset, uint64_t *nb_clusters) { BDRVQcow2State *s = bs->opaque; @@ -1079,7 +1083,7 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, *host_offset = cluster_offset; return 0; } else { - int ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters); + int64_t ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters); if (ret < 0) { return ret; } @@ -1115,7 +1119,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, int l2_index; uint64_t *l2_table; uint64_t entry; - unsigned int nb_clusters; + uint64_t nb_clusters; int ret; uint64_t alloc_cluster_offset; @@ -1133,6 +1137,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, l2_index = offset_to_l2_index(s, guest_offset); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); /* Find L2 entry for the first involved cluster */ ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index); @@ -1426,7 +1431,8 @@ int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) * clusters. */ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, - unsigned int nb_clusters, enum qcow2_discard_type type, bool full_discard) + uint64_t nb_clusters, enum qcow2_discard_type type, + bool full_discard) { BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; @@ -1441,6 +1447,7 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, /* Limit nb_clusters to one L2 table */ nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); for (i = 0; i < nb_clusters; i++) { uint64_t old_l2_entry; @@ -1503,7 +1510,7 @@ int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, { BDRVQcow2State *s = bs->opaque; uint64_t end_offset; - unsigned int nb_clusters; + uint64_t nb_clusters; int ret; end_offset = offset + (nb_sectors << BDRV_SECTOR_BITS); @@ -1545,7 +1552,7 @@ fail: * clusters. */ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, - unsigned int nb_clusters) + uint64_t nb_clusters) { BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; @@ -1560,6 +1567,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, /* Limit nb_clusters to one L2 table */ nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); for (i = 0; i < nb_clusters; i++) { uint64_t old_offset; @@ -1584,7 +1592,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors) { BDRVQcow2State *s = bs->opaque; - unsigned int nb_clusters; + uint64_t nb_clusters; int ret; /* The zero flag is only supported by version 3 and newer */ diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 53e3e9f..e8430ec 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -875,8 +875,8 @@ int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size) return offset; } -int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, - int nb_clusters) +int64_t qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, + int64_t nb_clusters) { BDRVQcow2State *s = bs->opaque; uint64_t cluster_index, refcount; @@ -1259,7 +1259,7 @@ static size_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries) static int realloc_refcount_array(BDRVQcow2State *s, void **array, int64_t *size, int64_t new_size) { - size_t old_byte_size, new_byte_size; + int64_t old_byte_size, new_byte_size; void *new_ptr; /* Round to clusters so the array can be directly written to disk */ @@ -1275,6 +1275,10 @@ static int realloc_refcount_array(BDRVQcow2State *s, void **array, assert(new_byte_size > 0); + if (new_byte_size > SIZE_MAX) { + return -ENOMEM; + } + new_ptr = g_try_realloc(*array, new_byte_size); if (!new_ptr) { return -ENOMEM; diff --git a/block/qcow2.h b/block/qcow2.h index 61f1b57..d700bf1 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -415,7 +415,7 @@ static inline int64_t offset_into_cluster(BDRVQcow2State *s, int64_t offset) return offset & (s->cluster_size - 1); } -static inline int size_to_clusters(BDRVQcow2State *s, int64_t size) +static inline uint64_t size_to_clusters(BDRVQcow2State *s, uint64_t size) { return (size + (s->cluster_size - 1)) >> s->cluster_bits; } @@ -509,8 +509,8 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs, int64_t cluster_index, enum qcow2_discard_type type); int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size); -int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, - int nb_clusters); +int64_t qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, + int64_t nb_clusters); int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size); void qcow2_free_clusters(BlockDriverState *bs, int64_t offset, int64_t size, -- 2.5.1 From MAILER-DAEMON Wed Sep 09 12:10:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZhwf-0006rw-Vg for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 12:10:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZhwc-0006pX-Hc for qemu-block@nongnu.org; Wed, 09 Sep 2015 12:09:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZhwb-0005sB-0m for qemu-block@nongnu.org; Wed, 09 Sep 2015 12:09:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38636) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZhwa-0005s7-QB; Wed, 09 Sep 2015 12:09:56 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 664618E690; Wed, 9 Sep 2015 16:09:56 +0000 (UTC) Received: from localhost (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t89G9rO9032365 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 9 Sep 2015 12:09:55 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 9 Sep 2015 18:09:47 +0200 Message-Id: <1441814987-27121-3-git-send-email-mreitz@redhat.com> In-Reply-To: <1441814987-27121-1-git-send-email-mreitz@redhat.com> References: <1441814987-27121-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH v2 2/2] iotests: Add test for checking large image files X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 16:10:00 -0000 Add a test for checking a qcow2 file with a multiple of 2^32 clusters. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- tests/qemu-iotests/138 | 73 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/138.out | 9 ++++++ tests/qemu-iotests/group | 1 + 3 files changed, 83 insertions(+) create mode 100755 tests/qemu-iotests/138 create mode 100644 tests/qemu-iotests/138.out diff --git a/tests/qemu-iotests/138 b/tests/qemu-iotests/138 new file mode 100755 index 0000000..a5c3464 --- /dev/null +++ b/tests/qemu-iotests/138 @@ -0,0 +1,73 @@ +#!/bin/bash +# +# General test case for qcow2's image check +# +# Copyright (C) 2015 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=mreitz@redhat.com + +seq="$(basename $0)" +echo "QA output created by $seq" + +here="$PWD" +tmp=/tmp/$$ +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +# This tests qocw2-specific low-level functionality +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +echo +echo '=== Check on an image with a multiple of 2^32 clusters ===' +echo + +IMGOPTS=$(_optstr_add "$IMGOPTS" "cluster_size=512") \ + _make_test_img 512 + +# Allocate L2 table +$QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io + +# Put the data cluster at a multiple of 2 TB, resulting in the image apparently +# having a multiple of 2^32 clusters +# (To be more specific: It is at 32 PB) +poke_file "$TEST_IMG" 2048 "\x80\x80\x00\x00\x00\x00\x00\x00" + +# An offset of 32 PB results in qemu-img check having to allocate an in-memory +# refcount table of 128 TB (16 bit refcounts, 512 byte clusters). +# This should be generally too much for any system and thus fail. +# What this test is checking is that the qcow2 driver actually tries to allocate +# such a large amount of memory (and is consequently aborting) instead of having +# truncated the cluster count somewhere (which would result in much less memory +# being allocated and then a segfault occurring). +_check_test_img + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/138.out b/tests/qemu-iotests/138.out new file mode 100644 index 0000000..3fe911f --- /dev/null +++ b/tests/qemu-iotests/138.out @@ -0,0 +1,9 @@ +QA output created by 138 + +=== Check on an image with a multiple of 2^32 clusters === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=512 +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +qemu-img: Check failed: Cannot allocate memory +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 3a6a8f0..439b1d2 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -135,3 +135,4 @@ 134 rw auto quick 135 rw auto 137 rw auto +138 rw auto quick -- 2.5.1 From MAILER-DAEMON Wed Sep 09 12:28:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZiEH-0006hn-QL for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 12:28:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZiED-0006gw-0D for qemu-block@nongnu.org; Wed, 09 Sep 2015 12:28:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZiEB-0001jS-1o for qemu-block@nongnu.org; Wed, 09 Sep 2015 12:28:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60354) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZiEA-0001jM-MO; Wed, 09 Sep 2015 12:28:06 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 67E6B8EA3A; Wed, 9 Sep 2015 16:28:06 +0000 (UTC) Received: from scv.usersys.redhat.com (vpn-63-148.rdu2.redhat.com [10.10.63.148]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t89GS3GO019231; Wed, 9 Sep 2015 12:28:04 -0400 From: John Snow To: qemu-block@nongnu.org Date: Wed, 9 Sep 2015 12:28:02 -0400 Message-Id: <1441816082-21031-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefano.stabellini@eu.citrix.com, armbru@redhat.com, qemu-devel@nongnu.org, ppandit@redhat.com, luodalongde@gmail.com, liuling-it@360.cn Subject: [Qemu-block] [PATCH] ide: fix ATAPI command permissions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 16:28:10 -0000 We're a little too lenient with what we'll let an ATAPI drive handle. Clamp down on the IDE command execution table to remove CD_OK permissions from commands that are not and have never been ATAPI commands. For ATAPI command validity, please see: - ATA4 Section 6.5 ("PACKET Command feature set") - ATA8/ACS Section 4.3 ("The PACKET feature set") - ACS3 Section 4.3 ("The PACKET feature set") ACS3 has a historical command validity table in Table B.4 ("Historical Command Assignments") that can be referenced to find when a command was introduced, deprecated, obsoleted, etc. The only reference for ATAPI command validity is by checking that version's PACKET feature set section. ATAPI was introduced by T13 into ATA4, all commands retired prior to ATA4 therefore are assumed to have never been ATAPI commands. Mandatory commands, as listed in ATA8-ACS3, are: - DEVICE RESET - EXECUTE DEVICE DIAGNOSTIC - IDENTIFY DEVICE - IDENTIFY PACKET DEVICE - NOP - PACKET - READ SECTOR(S) - SET FEATURES Optional commands as listed in ATA8-ACS3, are: - FLUSH CACHE - READ LOG DMA EXT - READ LOG EXT - WRITE LOG DMA EXT - WRITE LOG EXT All other commands are illegal to send to an ATAPI device and should be rejected by the device. CD_OK removal justifications: 0x06 WIN_DSM Defined in ACS2. Not valid for ATAPI. 0x21 WIN_READ_ONCE Retired in ATA5. Not ATAPI in ATA4. 0x94 WIN_STANDBYNOW2 Retired in ATA4. Did not coexist with ATAPI. 0x95 WIN_IDLEIMMEDIATE2 Retired in ATA4. Did not coexist with ATAPI. 0x96 WIN_STANDBY2 Retired in ATA4. Did not coexist with ATAPI. 0x97 WIN_SETIDLE2 Retired in ATA4. Did not coexist with ATAPI. 0x98 WIN_CHECKPOWERMODE2 Retired in ATA4. Did not coexist with ATAPI. 0x99 WIN_SLEEPNOW2 Retired in ATA4. Did not coexist with ATAPI. 0xE0 WIN_STANDBYNOW1 Not part of ATAPI in ATA4, ACS or ACS3. 0xE1 WIN_IDLEIMMDIATE Not part of ATAPI in ATA4, ACS or ACS3. 0xE2 WIN_STANDBY Not part of ATAPI in ATA4, ACS or ACS3. 0xE3 WIN_SETIDLE1 Not part of ATAPI in ATA4, ACS or ACS3. 0xE4 WIN_CHECKPOWERMODE1 Not part of ATAPI in ATA4, ACS or ACS3. 0xE5 WIN_SLEEPNOW1 Not part of ATAPI in ATA4, ACS or ACS3. 0xF8 WIN_READ_NATIVE_MAX Obsoleted in ACS3. Not ATAPI in ATA4 or ACS. This patch fixes a divide by zero fault that can be caused by sending the WIN_READ_NATIVE_MAX command to an empty ATAPI drive, which causes it to attempt to use zeroed CHS values to perform sector arithmetic. Reported-by: Qinghao Tang Signed-off-by: John Snow --- hw/ide/core.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 50449ca..71caea9 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -1747,11 +1747,11 @@ static const struct { } ide_cmd_table[0x100] = { /* NOP not implemented, mandatory for CD */ [CFA_REQ_EXT_ERROR_CODE] = { cmd_cfa_req_ext_error_code, CFA_OK }, - [WIN_DSM] = { cmd_data_set_management, ALL_OK }, + [WIN_DSM] = { cmd_data_set_management, HD_CFA_OK }, [WIN_DEVICE_RESET] = { cmd_device_reset, CD_OK }, [WIN_RECAL] = { cmd_nop, HD_CFA_OK | SET_DSC}, [WIN_READ] = { cmd_read_pio, ALL_OK }, - [WIN_READ_ONCE] = { cmd_read_pio, ALL_OK }, + [WIN_READ_ONCE] = { cmd_read_pio, HD_CFA_OK }, [WIN_READ_EXT] = { cmd_read_pio, HD_CFA_OK }, [WIN_READDMA_EXT] = { cmd_read_dma, HD_CFA_OK }, [WIN_READ_NATIVE_MAX_EXT] = { cmd_read_native_max, HD_CFA_OK | SET_DSC }, @@ -1770,12 +1770,12 @@ static const struct { [CFA_TRANSLATE_SECTOR] = { cmd_cfa_translate_sector, CFA_OK }, [WIN_DIAGNOSE] = { cmd_exec_dev_diagnostic, ALL_OK }, [WIN_SPECIFY] = { cmd_nop, HD_CFA_OK | SET_DSC }, - [WIN_STANDBYNOW2] = { cmd_nop, ALL_OK }, - [WIN_IDLEIMMEDIATE2] = { cmd_nop, ALL_OK }, - [WIN_STANDBY2] = { cmd_nop, ALL_OK }, - [WIN_SETIDLE2] = { cmd_nop, ALL_OK }, - [WIN_CHECKPOWERMODE2] = { cmd_check_power_mode, ALL_OK | SET_DSC }, - [WIN_SLEEPNOW2] = { cmd_nop, ALL_OK }, + [WIN_STANDBYNOW2] = { cmd_nop, HD_CFA_OK }, + [WIN_IDLEIMMEDIATE2] = { cmd_nop, HD_CFA_OK }, + [WIN_STANDBY2] = { cmd_nop, HD_CFA_OK }, + [WIN_SETIDLE2] = { cmd_nop, HD_CFA_OK }, + [WIN_CHECKPOWERMODE2] = { cmd_check_power_mode, HD_CFA_OK | SET_DSC }, + [WIN_SLEEPNOW2] = { cmd_nop, HD_CFA_OK }, [WIN_PACKETCMD] = { cmd_packet, CD_OK }, [WIN_PIDENTIFY] = { cmd_identify_packet, CD_OK }, [WIN_SMART] = { cmd_smart, HD_CFA_OK | SET_DSC }, @@ -1789,19 +1789,19 @@ static const struct { [WIN_WRITEDMA] = { cmd_write_dma, HD_CFA_OK }, [WIN_WRITEDMA_ONCE] = { cmd_write_dma, HD_CFA_OK }, [CFA_WRITE_MULTI_WO_ERASE] = { cmd_write_multiple, CFA_OK }, - [WIN_STANDBYNOW1] = { cmd_nop, ALL_OK }, - [WIN_IDLEIMMEDIATE] = { cmd_nop, ALL_OK }, - [WIN_STANDBY] = { cmd_nop, ALL_OK }, - [WIN_SETIDLE1] = { cmd_nop, ALL_OK }, - [WIN_CHECKPOWERMODE1] = { cmd_check_power_mode, ALL_OK | SET_DSC }, - [WIN_SLEEPNOW1] = { cmd_nop, ALL_OK }, + [WIN_STANDBYNOW1] = { cmd_nop, HD_CFA_OK }, + [WIN_IDLEIMMEDIATE] = { cmd_nop, HD_CFA_OK }, + [WIN_STANDBY] = { cmd_nop, HD_CFA_OK }, + [WIN_SETIDLE1] = { cmd_nop, HD_CFA_OK }, + [WIN_CHECKPOWERMODE1] = { cmd_check_power_mode, HD_CFA_OK | SET_DSC }, + [WIN_SLEEPNOW1] = { cmd_nop, HD_CFA_OK }, [WIN_FLUSH_CACHE] = { cmd_flush_cache, ALL_OK }, [WIN_FLUSH_CACHE_EXT] = { cmd_flush_cache, HD_CFA_OK }, [WIN_IDENTIFY] = { cmd_identify, ALL_OK }, [WIN_SETFEATURES] = { cmd_set_features, ALL_OK | SET_DSC }, [IBM_SENSE_CONDITION] = { cmd_ibm_sense_condition, CFA_OK | SET_DSC }, [CFA_WEAR_LEVEL] = { cmd_cfa_erase_sectors, HD_CFA_OK | SET_DSC }, - [WIN_READ_NATIVE_MAX] = { cmd_read_native_max, ALL_OK | SET_DSC }, + [WIN_READ_NATIVE_MAX] = { cmd_read_native_max, HD_CFA_OK | SET_DSC }, }; static bool ide_cmd_permitted(IDEState *s, uint32_t cmd) -- 2.4.3 From MAILER-DAEMON Wed Sep 09 12:37:09 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZiMv-0003ay-FW for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 12:37:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZiMs-0003XT-IS for qemu-block@nongnu.org; Wed, 09 Sep 2015 12:37:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZiMn-0006cH-OA for qemu-block@nongnu.org; Wed, 09 Sep 2015 12:37:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48646) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZiMn-0006c3-Jm; Wed, 09 Sep 2015 12:37:01 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 3BCDA8C1BE; Wed, 9 Sep 2015 16:37:01 +0000 (UTC) Received: from scv.usersys.redhat.com (vpn-63-148.rdu2.redhat.com [10.10.63.148]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t89Gb0IB030422; Wed, 9 Sep 2015 12:37:00 -0400 To: qemu-block@nongnu.org References: <1440623592-13999-1-git-send-email-jsnow@redhat.com> From: John Snow Message-ID: <55F0602C.20207@redhat.com> Date: Wed, 9 Sep 2015 12:37:00 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1440623592-13999-1-git-send-email-jsnow@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, zuban32s@gmail.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 0/4] ide: simple ATAPI tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 16:37:08 -0000 Ping -- apologies. :) I'll take a simple ACK before I merge it into my tree. On 08/26/2015 05:13 PM, John Snow wrote: > We don't have any CDROM tests yet. > So, add some for the PCI/BMDMA HBA. > > ________________________________________________________________________________ > > For convenience, this branch is available at: > https://github.com/jnsnow/qemu.git branch ide-atapi-test > https://github.com/jnsnow/qemu/tree/ide-atapi-test > > This version is tagged ide-atapi-test-v1: > https://github.com/jnsnow/qemu/releases/tag/ide-atapi-test-v1 > > John Snow (4): > qtest/ahci: use generate_pattern everywhere > qtest/ahci: export generate_pattern > ide-test: add cdrom pio test > ide-test: add cdrom dma test > > tests/ahci-test.c | 43 +--------- > tests/ide-test.c | 232 ++++++++++++++++++++++++++++++++++++++++++++++---- > tests/libqos/libqos.c | 26 ++++++ > tests/libqos/libqos.h | 1 + > 4 files changed, 245 insertions(+), 57 deletions(-) > From MAILER-DAEMON Wed Sep 09 13:00:46 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZijm-0006pY-6V for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 13:00:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZijj-0006p6-KI for qemu-block@nongnu.org; Wed, 09 Sep 2015 13:00:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZijf-0001Iu-Ct for qemu-block@nongnu.org; Wed, 09 Sep 2015 13:00:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48411) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZijf-0001IR-8H; Wed, 09 Sep 2015 13:00:39 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id C93CCC0AA276; Wed, 9 Sep 2015 17:00:38 +0000 (UTC) Received: from [10.36.112.83] (ovpn-112-83.ams2.redhat.com [10.36.112.83]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t89H0YeQ004712 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 9 Sep 2015 13:00:36 -0400 To: John Snow , qemu-block@nongnu.org References: <1440623592-13999-1-git-send-email-jsnow@redhat.com> <55F0602C.20207@redhat.com> From: Paolo Bonzini Message-ID: <55F065B2.30509@redhat.com> Date: Wed, 9 Sep 2015 19:00:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55F0602C.20207@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, zuban32s@gmail.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 0/4] ide: simple ATAPI tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 17:00:44 -0000 On 09/09/2015 18:37, John Snow wrote: > Ping -- apologies. :) > > I'll take a simple ACK before I merge it into my tree. I don't think you need one. :) Paolo > On 08/26/2015 05:13 PM, John Snow wrote: >> We don't have any CDROM tests yet. >> So, add some for the PCI/BMDMA HBA. >> >> ________________________________________________________________________________ >> >> For convenience, this branch is available at: >> https://github.com/jnsnow/qemu.git branch ide-atapi-test >> https://github.com/jnsnow/qemu/tree/ide-atapi-test >> >> This version is tagged ide-atapi-test-v1: >> https://github.com/jnsnow/qemu/releases/tag/ide-atapi-test-v1 >> >> John Snow (4): >> qtest/ahci: use generate_pattern everywhere >> qtest/ahci: export generate_pattern >> ide-test: add cdrom pio test >> ide-test: add cdrom dma test >> >> tests/ahci-test.c | 43 +--------- >> tests/ide-test.c | 232 ++++++++++++++++++++++++++++++++++++++++++++++---- >> tests/libqos/libqos.c | 26 ++++++ >> tests/libqos/libqos.h | 1 + >> 4 files changed, 245 insertions(+), 57 deletions(-) >> From MAILER-DAEMON Wed Sep 09 13:05:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZint-0000iF-AQ for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 13:05:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54428) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZinn-0000gm-7B for qemu-block@nongnu.org; Wed, 09 Sep 2015 13:04:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZink-00035J-1R for qemu-block@nongnu.org; Wed, 09 Sep 2015 13:04:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59907) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZinj-000351-So; Wed, 09 Sep 2015 13:04:51 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 677A9C0B986C; Wed, 9 Sep 2015 17:04:51 +0000 (UTC) Received: from scv.usersys.redhat.com (vpn-63-148.rdu2.redhat.com [10.10.63.148]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t89H4o1T015371; Wed, 9 Sep 2015 13:04:50 -0400 To: Paolo Bonzini , qemu-block@nongnu.org References: <1440623592-13999-1-git-send-email-jsnow@redhat.com> <55F0602C.20207@redhat.com> <55F065B2.30509@redhat.com> From: John Snow Message-ID: <55F066B2.50907@redhat.com> Date: Wed, 9 Sep 2015 13:04:50 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F065B2.30509@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, zuban32s@gmail.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 0/4] ide: simple ATAPI tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 17:04:59 -0000 On 09/09/2015 01:00 PM, Paolo Bonzini wrote: > > > On 09/09/2015 18:37, John Snow wrote: >> Ping -- apologies. :) >> >> I'll take a simple ACK before I merge it into my tree. > > I don't think you need one. :) > > Paolo > I guess technically not, but I like when somebody at least takes a peek before I just brazenly send pullreqs. I haven't achieved the level of ATA COWBOY yet. --js >> On 08/26/2015 05:13 PM, John Snow wrote: >>> We don't have any CDROM tests yet. >>> So, add some for the PCI/BMDMA HBA. >>> >>> ________________________________________________________________________________ >>> >>> For convenience, this branch is available at: >>> https://github.com/jnsnow/qemu.git branch ide-atapi-test >>> https://github.com/jnsnow/qemu/tree/ide-atapi-test >>> >>> This version is tagged ide-atapi-test-v1: >>> https://github.com/jnsnow/qemu/releases/tag/ide-atapi-test-v1 >>> >>> John Snow (4): >>> qtest/ahci: use generate_pattern everywhere >>> qtest/ahci: export generate_pattern >>> ide-test: add cdrom pio test >>> ide-test: add cdrom dma test >>> >>> tests/ahci-test.c | 43 +--------- >>> tests/ide-test.c | 232 ++++++++++++++++++++++++++++++++++++++++++++++---- >>> tests/libqos/libqos.c | 26 ++++++ >>> tests/libqos/libqos.h | 1 + >>> 4 files changed, 245 insertions(+), 57 deletions(-) >>> From MAILER-DAEMON Wed Sep 09 13:12:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZiv7-0002wr-Hu for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 13:12:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZiv5-0002vz-8G for qemu-block@nongnu.org; Wed, 09 Sep 2015 13:12:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZiv2-0000FU-2R for qemu-block@nongnu.org; Wed, 09 Sep 2015 13:12:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43621) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZiv1-0000FG-Tb; Wed, 09 Sep 2015 13:12:24 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id ED1F75BA17; Wed, 9 Sep 2015 17:12:22 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-87.ams2.redhat.com [10.36.116.87]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t89HCLW5019705; Wed, 9 Sep 2015 13:12:21 -0400 Date: Wed, 9 Sep 2015 19:12:20 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150909171220.GG4860@noname.redhat.com> References: <1441814987-27121-1-git-send-email-mreitz@redhat.com> <1441814987-27121-2-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441814987-27121-2-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 1/2] qcow2: Make size_to_clusters() return uint64_t X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 17:12:28 -0000 Am 09.09.2015 um 18:09 hat Max Reitz geschrieben: > Sadly, some images may have more clusters than what can be represented > using a plain int. We should be prepared for that case (in > qcow2_check_refcounts() we actually were trying to catch that case, but > since size_to_clusters() truncated the returned value, that check never > did anything useful). > > Cc: qemu-stable > Signed-off-by: Max Reitz > @@ -840,7 +843,7 @@ err: > static int count_cow_clusters(BDRVQcow2State *s, int nb_clusters, > uint64_t *l2_table, int l2_index) > { > - int i; > + uint64_t i; > > for (i = 0; i < nb_clusters; i++) { > uint64_t l2_entry = be64_to_cpu(l2_table[l2_index + i]); As discussed on IRC, I removed this hunk, which isn't needed in v2. Thanks, applied all to the block branch. Kevin From MAILER-DAEMON Wed Sep 09 21:13:03 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZqQA-0000IM-RG for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 21:13:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZqQ7-0000Ak-ON for qemu-block@nongnu.org; Wed, 09 Sep 2015 21:13:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZqQ6-0005K0-Ka for qemu-block@nongnu.org; Wed, 09 Sep 2015 21:12:59 -0400 Received: from [59.151.112.132] (port=4852 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZqPz-0005IL-Is; Wed, 09 Sep 2015 21:12:53 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100540817" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 10 Sep 2015 09:15:46 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8A1CaDd001152; Thu, 10 Sep 2015 09:12:36 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Thu, 10 Sep 2015 09:12:48 +0800 To: Max Reitz , References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-30-git-send-email-mreitz@redhat.com> <55EEA69E.4010706@cn.fujitsu.com> <55EF5133.2040807@redhat.com> <55F00363.5080709@cn.fujitsu.com> <55F02D3D.6020102@redhat.com> From: Wen Congyang Message-ID: <55F0D901.1010607@cn.fujitsu.com> Date: Thu, 10 Sep 2015 09:12:33 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F02D3D.6020102@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 29/38] blockdev: Add blockdev-insert-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 01:13:01 -0000 On 09/09/2015 08:59 PM, Max Reitz wrote: > On 09.09.2015 12:01, Wen Congyang wrote: >> On 09/09/2015 05:20 AM, Max Reitz wrote: >>> On 08.09.2015 11:13, Wen Congyang wrote: >>>> On 07/21/2015 01:45 AM, 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). >>>>> >>>>> Signed-off-by: Max Reitz >>>>> --- >>>>> blockdev.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ >>>>> qapi/block-core.json | 17 +++++++++++++++++ >>>>> qmp-commands.hx | 37 +++++++++++++++++++++++++++++++++++++ >>>>> 3 files changed, 102 insertions(+) >>>>> >>>>> diff --git a/blockdev.c b/blockdev.c >>>>> index 481760a..a80d0e2 100644 >>>>> --- a/blockdev.c >>>>> +++ b/blockdev.c >>>>> @@ -2164,6 +2164,54 @@ void qmp_blockdev_remove_medium(const char *device, Error **errp) >>>>> } >>>>> } >>>>> >>>>> +static void qmp_blockdev_insert_anon_medium(const char *device, >>>>> + BlockDriverState *bs, Error **errp) >>>>> +{ >>>>> + BlockBackend *blk; >>>>> + bool has_device; >>>>> + >>>>> + blk = blk_by_name(device); >>>>> + if (!blk) { >>>>> + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, >>>>> + "Device '%s' not found", device); >>>>> + return; >>>>> + } >>>>> + >>>>> + /* For BBs without a device, we can exchange the BDS tree at will */ >>>>> + has_device = blk_get_attached_dev(blk); >>>>> + >>>>> + if (has_device && !blk_dev_has_removable_media(blk)) { >>>>> + error_setg(errp, "Device '%s' is not removable", device); >>>>> + return; >>>>> + } >>>>> + >>>>> + if (has_device && !blk_dev_is_tray_open(blk)) { >>>>> + error_setg(errp, "Tray of device '%s' is not open", device); >>>>> + return; >>>>> + } >>>>> + >>>>> + if (blk_bs(blk)) { >>>>> + error_setg(errp, "There already is a medium in device '%s'", device); >>>>> + return; >>>>> + } >>>>> + >>>>> + blk_insert_bs(blk, bs); >>>>> +} >>>>> + >>>>> +void qmp_blockdev_insert_medium(const char *device, const char *node_name, >>>>> + Error **errp) >>>>> +{ >>>>> + BlockDriverState *bs; >>>>> + >>>>> + bs = bdrv_find_node(node_name); >>>>> + if (!bs) { >>>>> + error_setg(errp, "Node '%s' not found", node_name); >>>>> + return; >>>>> + } >>>> >>>> Hmm, it is OK if the bs is not top BDS? >>> >>> I think so, yes. Generally, there's probably no reason to do that, but I >>> don't know why we should not allow that case. For instance, you might >>> want to make a backing file available read-only somewhere. >>> >>> It should be impossible to make it available writable, and it should not >>> be allowed to start a block-commit operation while the backing file can >>> be accessed by the guest, but this should be achieved using op blockers. >>> >>> What we need for this to work are fine-grained op blockers, I think. But >>> working around that for now by only allowing to insert top BDS won't >>> work, since you can still start block jobs which target top BDS, too >>> (e.g. blockdev-backup can write to a BDS/BB that is visible to the guest). >>> >>> All in all, I think it's fine to insert non-top BDS, but we should >>> definitely worry about which exact BDS one can insert once we have >>> fine-grained op blockers. >> >> A BDS can be written by its parent, its block backend, a block job.. >> So I think we should have some way to avoid more than two sources writing >> to it, otherwise the data may be corrupted. > > Yes, and that would be op blockers. > > As I said, using blockdev-backup you can write to a BB that can be > written to by the guest as well. I think this is a bug, but it is a bug > that needs to be fixed by having better op blockers in place, which Jeff > Cody is working on. > > Regarding this series, I don't consider this to be too big of an issue. > Yes, if you are working with floppy disks, you can have the case of a > block job and the guest writing to the BDS at the same time. But I can't > really imagine who would use floppy disks and block jobs at the same > time (people who still use floppy disks for their VMs don't strike me as > the kind of people who use the management features of qemu, especially > not for those floppy disks). > > Other than that, this function (blockdev-insert-medium) can only be used > for optical ROM devices (I don't think we have CD/DVD-RW support, do > we?), so it's much less of an issue there. > > So all in all I don't consider this too big of an issue here. If others > think different, then I would delay this part of the series (which > overhauls the "change" command) until we have fine-grained op blockers. In most cases, the user uses this command to change CD/DVD media, so it is OK. But IIRC scsi disk can also be changed. So we can mark this command as experimental (the command name can be x-blockdev-insert-medium). Thanks Wen Congyang > > Max > From MAILER-DAEMON Wed Sep 09 23:23:16 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZsSC-0003fe-DV for mharc-qemu-block@gnu.org; Wed, 09 Sep 2015 23:23:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50016) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZsSA-0003aj-5f for qemu-block@nongnu.org; Wed, 09 Sep 2015 23:23:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZsS9-0005xB-7k for qemu-block@nongnu.org; Wed, 09 Sep 2015 23:23:14 -0400 Received: from [59.151.112.132] (port=48905 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZsS2-0005n7-Td; Wed, 09 Sep 2015 23:23:07 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100546391" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 10 Sep 2015 11:25:56 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8A3Mknk010446; Thu, 10 Sep 2015 11:22:46 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Thu, 10 Sep 2015 11:22:58 +0800 To: Max Reitz , References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-30-git-send-email-mreitz@redhat.com> <55EEA69E.4010706@cn.fujitsu.com> <55EF5133.2040807@redhat.com> <55F00363.5080709@cn.fujitsu.com> <55F02D3D.6020102@redhat.com> From: Wen Congyang Message-ID: <55F0F783.6020408@cn.fujitsu.com> Date: Thu, 10 Sep 2015 11:22:43 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F02D3D.6020102@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 29/38] blockdev: Add blockdev-insert-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 03:23:15 -0000 On 09/09/2015 08:59 PM, Max Reitz wrote: > On 09.09.2015 12:01, Wen Congyang wrote: >> On 09/09/2015 05:20 AM, Max Reitz wrote: >>> On 08.09.2015 11:13, Wen Congyang wrote: >>>> On 07/21/2015 01:45 AM, 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). >>>>> >>>>> Signed-off-by: Max Reitz >>>>> --- >>>>> blockdev.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ >>>>> qapi/block-core.json | 17 +++++++++++++++++ >>>>> qmp-commands.hx | 37 +++++++++++++++++++++++++++++++++++++ >>>>> 3 files changed, 102 insertions(+) >>>>> >>>>> diff --git a/blockdev.c b/blockdev.c >>>>> index 481760a..a80d0e2 100644 >>>>> --- a/blockdev.c >>>>> +++ b/blockdev.c >>>>> @@ -2164,6 +2164,54 @@ void qmp_blockdev_remove_medium(const char *device, Error **errp) >>>>> } >>>>> } >>>>> >>>>> +static void qmp_blockdev_insert_anon_medium(const char *device, >>>>> + BlockDriverState *bs, Error **errp) >>>>> +{ >>>>> + BlockBackend *blk; >>>>> + bool has_device; >>>>> + >>>>> + blk = blk_by_name(device); >>>>> + if (!blk) { >>>>> + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, >>>>> + "Device '%s' not found", device); >>>>> + return; >>>>> + } >>>>> + >>>>> + /* For BBs without a device, we can exchange the BDS tree at will */ >>>>> + has_device = blk_get_attached_dev(blk); >>>>> + >>>>> + if (has_device && !blk_dev_has_removable_media(blk)) { >>>>> + error_setg(errp, "Device '%s' is not removable", device); >>>>> + return; >>>>> + } >>>>> + >>>>> + if (has_device && !blk_dev_is_tray_open(blk)) { >>>>> + error_setg(errp, "Tray of device '%s' is not open", device); >>>>> + return; >>>>> + } >>>>> + >>>>> + if (blk_bs(blk)) { >>>>> + error_setg(errp, "There already is a medium in device '%s'", device); >>>>> + return; >>>>> + } >>>>> + >>>>> + blk_insert_bs(blk, bs); >>>>> +} >>>>> + >>>>> +void qmp_blockdev_insert_medium(const char *device, const char *node_name, >>>>> + Error **errp) >>>>> +{ >>>>> + BlockDriverState *bs; >>>>> + >>>>> + bs = bdrv_find_node(node_name); >>>>> + if (!bs) { >>>>> + error_setg(errp, "Node '%s' not found", node_name); >>>>> + return; >>>>> + } >>>> >>>> Hmm, it is OK if the bs is not top BDS? >>> >>> I think so, yes. Generally, there's probably no reason to do that, but I >>> don't know why we should not allow that case. For instance, you might >>> want to make a backing file available read-only somewhere. >>> >>> It should be impossible to make it available writable, and it should not >>> be allowed to start a block-commit operation while the backing file can >>> be accessed by the guest, but this should be achieved using op blockers. >>> >>> What we need for this to work are fine-grained op blockers, I think. But >>> working around that for now by only allowing to insert top BDS won't >>> work, since you can still start block jobs which target top BDS, too >>> (e.g. blockdev-backup can write to a BDS/BB that is visible to the guest). >>> >>> All in all, I think it's fine to insert non-top BDS, but we should >>> definitely worry about which exact BDS one can insert once we have >>> fine-grained op blockers. >> >> A BDS can be written by its parent, its block backend, a block job.. >> So I think we should have some way to avoid more than two sources writing >> to it, otherwise the data may be corrupted. > > Yes, and that would be op blockers. > > As I said, using blockdev-backup you can write to a BB that can be > written to by the guest as well. I think this is a bug, but it is a bug > that needs to be fixed by having better op blockers in place, which Jeff > Cody is working on. I don't find such patches in the maillist. Thanks Wen Congyang > > Regarding this series, I don't consider this to be too big of an issue. > Yes, if you are working with floppy disks, you can have the case of a > block job and the guest writing to the BDS at the same time. But I can't > really imagine who would use floppy disks and block jobs at the same > time (people who still use floppy disks for their VMs don't strike me as > the kind of people who use the management features of qemu, especially > not for those floppy disks). > > Other than that, this function (blockdev-insert-medium) can only be used > for optical ROM devices (I don't think we have CD/DVD-RW support, do > we?), so it's much less of an issue there. > > So all in all I don't consider this too big of an issue here. If others > think different, then I would delay this part of the series (which > overhauls the "change" command) until we have fine-grained op blockers. > > Max > From MAILER-DAEMON Thu Sep 10 00:07:00 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZt8W-0003Iq-Q9 for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 00:07:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZt8P-00034k-8E for qemu-block@nongnu.org; Thu, 10 Sep 2015 00:06:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZt8N-000524-5J for qemu-block@nongnu.org; Thu, 10 Sep 2015 00:06:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43516) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZt8N-00051q-0r; Thu, 10 Sep 2015 00:06:51 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 978778EA35; Thu, 10 Sep 2015 04:06:50 +0000 (UTC) Received: from red.redhat.com ([10.3.113.15]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8A46Zhc031165; Thu, 10 Sep 2015 00:06:49 -0400 From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 9 Sep 2015 22:06:17 -0600 Message-Id: <1441857991-7309-16-git-send-email-eblake@redhat.com> In-Reply-To: <1441857991-7309-1-git-send-email-eblake@redhat.com> References: <1441857991-7309-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , "open list:Block layer core" , armbru@redhat.com, Gerd Hoffmann , DirtY.iCE.hu@gmail.com, marcandre.lureau@redhat.com Subject: [Qemu-block] [PATCH RFC v4 15/29] qapi: Avoid use of 'data' member of qapi unions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 04:06:54 -0000 qapi code generators currently create a 'void *data' member as part of the anonymous union embedded in the C struct corresponding to a qapi union. However, directly assigning to this member of the union feels a bit fishy, when we can directly use the rest of the struct instead. Signed-off-by: Eric Blake --- blockdev.c | 22 ++++++++++++---------- ui/input.c | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/blockdev.c b/blockdev.c index e4cec0e..0808312 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1052,14 +1052,11 @@ void hmp_commit(Monitor *mon, const QDict *qdict) } } -static void blockdev_do_action(int type, void *data, Error **errp) +static void blockdev_do_action(TransactionAction *action, Error **errp) { - TransactionAction action; TransactionActionList list; - action.type = type; - action.data = data; - list.value = &action; + list.value = action; list.next = NULL; qmp_transaction(&list, errp); } @@ -1085,8 +1082,11 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, .has_mode = has_mode, .mode = mode, }; - blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC, - &snapshot, errp); + TransactionAction action = { + .type = TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC, + .blockdev_snapshot_sync = &snapshot, + }; + blockdev_do_action(&action, errp); } void qmp_blockdev_snapshot_internal_sync(const char *device, @@ -1097,9 +1097,11 @@ void qmp_blockdev_snapshot_internal_sync(const char *device, .device = (char *) device, .name = (char *) name }; - - blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_INTERNAL_SYNC, - &snapshot, errp); + TransactionAction action = { + .type = TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_INTERNAL_SYNC, + .blockdev_snapshot_internal_sync = &snapshot, + }; + blockdev_do_action(&action, errp); } SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device, diff --git a/ui/input.c b/ui/input.c index fd86571..edd237d 100644 --- a/ui/input.c +++ b/ui/input.c @@ -452,7 +452,7 @@ InputEvent *qemu_input_event_new_move(InputEventKind kind, InputMoveEvent *move = g_new0(InputMoveEvent, 1); evt->type = kind; - evt->data = move; + evt->rel = move; /* also would work as evt->abs */ move->axis = axis; move->value = value; return evt; -- 2.4.3 From MAILER-DAEMON Thu Sep 10 00:07:17 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZt8n-0003nG-4h for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 00:07:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZt8M-0002zD-J7 for qemu-block@nongnu.org; Thu, 10 Sep 2015 00:06:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZt8E-0004y0-Od for qemu-block@nongnu.org; Thu, 10 Sep 2015 00:06:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZt8E-0004wg-9g; Thu, 10 Sep 2015 00:06:42 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id D27CB5369; Thu, 10 Sep 2015 04:06:41 +0000 (UTC) Received: from red.redhat.com ([10.3.113.15]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8A46ZhQ031165; Thu, 10 Sep 2015 00:06:40 -0400 From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 9 Sep 2015 22:06:05 -0600 Message-Id: <1441857991-7309-4-git-send-email-eblake@redhat.com> In-Reply-To: <1441857991-7309-1-git-send-email-eblake@redhat.com> References: <1441857991-7309-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , Eduardo Habkost , "open list:qcow2" , "Michael S. Tsirkin" , Jason Wang , armbru@redhat.com, Luiz Capitulino , Igor Mammedov , Paolo Bonzini , Gerd Hoffmann , Stefan Hajnoczi , DirtY.iCE.hu@gmail.com, marcandre.lureau@redhat.com, Michael Roth Subject: [Qemu-block] [PATCH RFC v4 03/29] qapi: use 'type' in generated C code to match QMP union wire form X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 04:06:55 -0000 When dealing with simple qapi unions, the code was generating a discriminator field of 'kind' even though the discriminator is sent as 'type' over QMP. Renaming things to match gets us one step closer to reusing common generator code for both simple and flat unions, without having to special case the naming choice for simple unions. It also gets rid of some TODO markers in using the raw QAPISchemaObjectTypeVariants.tag_name field, although we can't yet convert that field to private until later fixes to alternate types also quit using it. However, this patch does not rename the generated enum, which is still 'unionnameKind'; if we wanted, a further patch could generate implicit enums as 'unionnameType', with even more churn to C code to react, and probably update the qapi generator to reserve the 'fooType' namespace instead of 'fooKind', or better yet ensure that generated names do not conflict with user names. But that is a lot harder, as we already have existing qapi usage of types that end in 'Type'. Signed-off-by: Eric Blake --- block/qcow2.c | 2 +- block/vmdk.c | 2 +- blockdev.c | 16 ++++++++-------- hmp.c | 12 ++++++------ hw/input/hid.c | 2 +- hw/input/ps2.c | 2 +- hw/input/virtio-input-hid.c | 2 +- hw/mem/pc-dimm.c | 2 +- net/dump.c | 2 +- net/hub.c | 2 +- net/l2tpv3.c | 2 +- net/net.c | 20 ++++++++++---------- net/slirp.c | 2 +- net/socket.c | 2 +- net/tap.c | 4 ++-- net/vhost-user.c | 2 +- numa.c | 4 ++-- qemu-char.c | 24 ++++++++++++------------ scripts/qapi-types.py | 7 ++----- scripts/qapi-visit.py | 13 +++---------- tests/test-qmp-commands.c | 2 +- tests/test-qmp-input-visitor.c | 10 +++++----- tests/test-qmp-output-visitor.c | 8 ++++---- tpm.c | 2 +- ui/input-keymap.c | 10 +++++----- ui/input-legacy.c | 2 +- ui/input.c | 22 +++++++++++----------- util/qemu-sockets.c | 12 ++++++------ 28 files changed, 91 insertions(+), 101 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index ea34ae2..dc3a73f 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2596,7 +2596,7 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs) ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1); *spec_info = (ImageInfoSpecific){ - .kind = IMAGE_INFO_SPECIFIC_KIND_QCOW2, + .type = IMAGE_INFO_SPECIFIC_KIND_QCOW2, { .qcow2 = g_new(ImageInfoSpecificQCow2, 1), }, diff --git a/block/vmdk.c b/block/vmdk.c index fbaab67..180f416 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2153,7 +2153,7 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs) ImageInfoList **next; *spec_info = (ImageInfoSpecific){ - .kind = IMAGE_INFO_SPECIFIC_KIND_VMDK, + .type = IMAGE_INFO_SPECIFIC_KIND_VMDK, { .vmdk = g_new0(ImageInfoSpecificVmdk, 1), }, diff --git a/blockdev.c b/blockdev.c index 6b48be6..e4cec0e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1052,12 +1052,12 @@ void hmp_commit(Monitor *mon, const QDict *qdict) } } -static void blockdev_do_action(int kind, void *data, Error **errp) +static void blockdev_do_action(int type, void *data, Error **errp) { TransactionAction action; TransactionActionList list; - action.kind = kind; + action.type = type; action.data = data; list.value = &action; list.next = NULL; @@ -1297,7 +1297,7 @@ static void internal_snapshot_prepare(BlkTransactionState *common, InternalSnapshotState *state; int ret1; - g_assert(common->action->kind == + g_assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_INTERNAL_SYNC); internal = common->action->blockdev_snapshot_internal_sync; state = DO_UPCAST(InternalSnapshotState, common, common); @@ -1440,7 +1440,7 @@ static void external_snapshot_prepare(BlkTransactionState *common, TransactionAction *action = common->action; /* get parameters */ - g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC); + g_assert(action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC); has_device = action->blockdev_snapshot_sync->has_device; device = action->blockdev_snapshot_sync->device; @@ -1585,7 +1585,7 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp) DriveBackup *backup; Error *local_err = NULL; - assert(common->action->kind == TRANSACTION_ACTION_KIND_DRIVE_BACKUP); + assert(common->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP); backup = common->action->drive_backup; blk = blk_by_name(backup->device); @@ -1653,7 +1653,7 @@ static void blockdev_backup_prepare(BlkTransactionState *common, Error **errp) BlockBackend *blk; Error *local_err = NULL; - assert(common->action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); + assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); backup = common->action->blockdev_backup; blk = blk_by_name(backup->device); @@ -1780,9 +1780,9 @@ void qmp_transaction(TransactionActionList *dev_list, Error **errp) dev_info = dev_entry->value; dev_entry = dev_entry->next; - assert(dev_info->kind < ARRAY_SIZE(actions)); + assert(dev_info->type < ARRAY_SIZE(actions)); - ops = &actions[dev_info->kind]; + ops = &actions[dev_info->type]; assert(ops->instance_size > 0); state = g_malloc0(ops->instance_size); diff --git a/hmp.c b/hmp.c index 3f807b7..849b292 100644 --- a/hmp.c +++ b/hmp.c @@ -830,9 +830,9 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) c, TpmModel_lookup[ti->model]); monitor_printf(mon, " \\ %s: type=%s", - ti->id, TpmTypeOptionsKind_lookup[ti->options->kind]); + ti->id, TpmTypeOptionsKind_lookup[ti->options->type]); - switch (ti->options->kind) { + switch (ti->options->type) { case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH: tpo = ti->options->passthrough; monitor_printf(mon, "%s%s%s%s", @@ -1714,14 +1714,14 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) if (*endp != '\0') { goto err_out; } - keylist->value->kind = KEY_VALUE_KIND_NUMBER; + keylist->value->type = KEY_VALUE_KIND_NUMBER; keylist->value->number = value; } else { int idx = index_from_key(keyname_buf); if (idx == Q_KEY_CODE_MAX) { goto err_out; } - keylist->value->kind = KEY_VALUE_KIND_QCODE; + keylist->value->type = KEY_VALUE_KIND_QCODE; keylist->value->qcode = idx; } @@ -1937,12 +1937,12 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict) value = info->value; if (value) { - switch (value->kind) { + switch (value->type) { case MEMORY_DEVICE_INFO_KIND_DIMM: di = value->dimm; monitor_printf(mon, "Memory device [%s]: \"%s\"\n", - MemoryDeviceInfoKind_lookup[value->kind], + MemoryDeviceInfoKind_lookup[value->type], di->id ? di->id : ""); monitor_printf(mon, " addr: 0x%" PRIx64 "\n", di->addr); monitor_printf(mon, " slot: %" PRId64 "\n", di->slot); diff --git a/hw/input/hid.c b/hw/input/hid.c index 21ebd9e..ac02f88 100644 --- a/hw/input/hid.c +++ b/hw/input/hid.c @@ -119,7 +119,7 @@ static void hid_pointer_event(DeviceState *dev, QemuConsole *src, assert(hs->n < QUEUE_LENGTH); e = &hs->ptr.queue[(hs->head + hs->n) & QUEUE_MASK]; - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_REL: if (evt->rel->axis == INPUT_AXIS_X) { e->xdx += evt->rel->value; diff --git a/hw/input/ps2.c b/hw/input/ps2.c index fdbe565..58decf2 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -393,7 +393,7 @@ static void ps2_mouse_event(DeviceState *dev, QemuConsole *src, if (!(s->mouse_status & MOUSE_STATUS_ENABLED)) return; - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_REL: if (evt->rel->axis == INPUT_AXIS_X) { s->mouse_dx += evt->rel->value; diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index 4d85dad..362dad3 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -191,7 +191,7 @@ static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src, virtio_input_event event; int qcode; - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_KEY: qcode = qemu_input_key_value_to_qcode(evt->key->key); if (qcode && keymap_qcode[qcode]) { diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index bb04862..a444195 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -196,7 +196,7 @@ ram_addr_t get_current_ram_size(void) MemoryDeviceInfo *value = info->value; if (value) { - switch (value->kind) { + switch (value->type) { case MEMORY_DEVICE_INFO_KIND_DIMM: size += value->dimm->size; break; diff --git a/net/dump.c b/net/dump.c index d80fa94..a1f99c3 100644 --- a/net/dump.c +++ b/net/dump.c @@ -154,7 +154,7 @@ int net_init_dump(const Netdev *netdev, const char *name, char def_file[128]; const NetdevDumpOptions *dump; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_DUMP); dump = netdev->opts->dump; assert(peer); diff --git a/net/hub.c b/net/hub.c index 29f65b2..047d861 100644 --- a/net/hub.c +++ b/net/hub.c @@ -285,7 +285,7 @@ int net_init_hubport(const Netdev *netdev, const char *name, { const NetdevHubPortOptions *hubport; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_HUBPORT); assert(!peer); hubport = netdev->opts->hubport; diff --git a/net/l2tpv3.c b/net/l2tpv3.c index d2f8431..bdb13fa 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -545,7 +545,7 @@ int net_init_l2tpv3(const Netdev *netdev, s->queue_tail = 0; s->header_mismatch = false; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_L2TPV3); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_L2TPV3); l2tpv3 = netdev->opts->l2tpv3; if (l2tpv3->has_ipv6 && l2tpv3->ipv6) { diff --git a/net/net.c b/net/net.c index 4d99b48..94a3d18 100644 --- a/net/net.c +++ b/net/net.c @@ -820,7 +820,7 @@ static int net_init_nic(const Netdev *netdev, const char *name, NICInfo *nd; const NetLegacyNicOptions *nic; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_NIC); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_NIC); nic = netdev->opts->nic; idx = nic_get_free_idx(); @@ -924,9 +924,9 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) opts = netdev->opts; name = netdev->id; - if (opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP || - opts->kind == NET_CLIENT_OPTIONS_KIND_NIC || - !net_client_init_fun[opts->kind]) { + if (opts->type == NET_CLIENT_OPTIONS_KIND_DUMP || + opts->type == NET_CLIENT_OPTIONS_KIND_NIC || + !net_client_init_fun[opts->type]) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a netdev backend type"); return -1; @@ -939,16 +939,16 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) /* missing optional values have been initialized to "all bits zero" */ name = net->has_id ? net->id : net->name; - if (opts->kind == NET_CLIENT_OPTIONS_KIND_NONE) { + if (opts->type == NET_CLIENT_OPTIONS_KIND_NONE) { return 0; /* nothing to do */ } - if (opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT) { + if (opts->type == NET_CLIENT_OPTIONS_KIND_HUBPORT) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a net type"); return -1; } - if (!net_client_init_fun[opts->kind]) { + if (!net_client_init_fun[opts->type]) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a net backend type (maybe it is not compiled " "into this binary)"); @@ -956,17 +956,17 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) } /* Do not add to a vlan if it's a nic with a netdev= parameter. */ - if (opts->kind != NET_CLIENT_OPTIONS_KIND_NIC || + if (opts->type != NET_CLIENT_OPTIONS_KIND_NIC || !opts->nic->has_netdev) { peer = net_hub_add_port(net->has_vlan ? net->vlan : 0, NULL); } } - if (net_client_init_fun[opts->kind](netdev, name, peer, errp) < 0) { + if (net_client_init_fun[opts->type](netdev, name, peer, errp) < 0) { /* FIXME drop when all init functions store an Error */ if (errp && !*errp) { error_setg(errp, QERR_DEVICE_INIT_FAILED, - NetClientOptionsKind_lookup[opts->kind]); + NetClientOptionsKind_lookup[opts->type]); } return -1; } diff --git a/net/slirp.c b/net/slirp.c index 0fc2c52..e160b9c 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -746,7 +746,7 @@ int net_init_slirp(const Netdev *netdev, const char *name, const NetdevUserOptions *user; const char **dnssearch; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_USER); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_USER); user = netdev->opts->user; vnet = user->has_net ? g_strdup(user->net) : diff --git a/net/socket.c b/net/socket.c index 75f693c..7f949e2 100644 --- a/net/socket.c +++ b/net/socket.c @@ -706,7 +706,7 @@ int net_init_socket(const Netdev *netdev, const char *name, Error *err = NULL; const NetdevSocketOptions *sock; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_SOCKET); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_SOCKET); sock = netdev->opts->socket; if (sock->has_fd + sock->has_listen + sock->has_connect + sock->has_mcast + diff --git a/net/tap.c b/net/tap.c index 263f807..aecc759 100644 --- a/net/tap.c +++ b/net/tap.c @@ -565,7 +565,7 @@ int net_init_bridge(const Netdev *netdev, const char *name, TAPState *s; int fd, vnet_hdr; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_BRIDGE); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_BRIDGE); bridge = netdev->opts->bridge; helper = bridge->has_helper ? bridge->helper : DEFAULT_BRIDGE_HELPER; @@ -728,7 +728,7 @@ int net_init_tap(const Netdev *netdev, const char *name, const char *vhostfdname; char ifname[128]; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_TAP); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_TAP); tap = netdev->opts->tap; queues = tap->has_queues ? tap->queues : 1; vhostfdname = tap->has_vhostfd ? tap->vhostfd : NULL; diff --git a/net/vhost-user.c b/net/vhost-user.c index 20981a9..8597ec4 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -229,7 +229,7 @@ int net_init_vhost_user(const Netdev *netdev, const char *name, const NetdevVhostUserOptions *vhost_user_opts; CharDriverState *chr; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_VHOST_USER); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER); vhost_user_opts = netdev->opts->vhost_user; chr = net_vhost_parse_chardev(vhost_user_opts, errp); diff --git a/numa.c b/numa.c index 402804b..aa9e0f7 100644 --- a/numa.c +++ b/numa.c @@ -226,7 +226,7 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp) goto error; } - switch (object->kind) { + switch (object->type) { case NUMA_OPTIONS_KIND_NODE: numa_node_parse(object->node, opts, &err); if (err) { @@ -487,7 +487,7 @@ static void numa_stat_memory_devices(uint64_t node_mem[]) MemoryDeviceInfo *value = info->value; if (value) { - switch (value->kind) { + switch (value->type) { case MEMORY_DEVICE_INFO_KIND_DIMM: node_mem[value->dimm->node] += value->dimm->size; break; diff --git a/qemu-char.c b/qemu-char.c index d956f8d..20fc51f 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -123,7 +123,7 @@ static int SocketAddress_to_str(char *dest, int max_len, const char *prefix, SocketAddress *addr, bool is_listen, bool is_telnet) { - switch (addr->kind) { + switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: return snprintf(dest, max_len, "%s%s:%s:%s%s", prefix, is_telnet ? "telnet" : "tcp", addr->inet->host, @@ -3570,11 +3570,11 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend, addr = g_new0(SocketAddress, 1); if (path) { - addr->kind = SOCKET_ADDRESS_KIND_UNIX; + addr->type = SOCKET_ADDRESS_KIND_UNIX; addr->q_unix = g_new0(UnixSocketAddress, 1); addr->q_unix->path = g_strdup(path); } else { - addr->kind = SOCKET_ADDRESS_KIND_INET; + addr->type = SOCKET_ADDRESS_KIND_INET; addr->inet = g_new0(InetSocketAddress, 1); addr->inet->host = g_strdup(host); addr->inet->port = g_strdup(port); @@ -3619,7 +3619,7 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend, backend->udp = g_new0(ChardevUdp, 1); addr = g_new0(SocketAddress, 1); - addr->kind = SOCKET_ADDRESS_KIND_INET; + addr->type = SOCKET_ADDRESS_KIND_INET; addr->inet = g_new0(InetSocketAddress, 1); addr->inet->host = g_strdup(host); addr->inet->port = g_strdup(port); @@ -3632,7 +3632,7 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend, if (has_local) { backend->udp->has_local = true; addr = g_new0(SocketAddress, 1); - addr->kind = SOCKET_ADDRESS_KIND_INET; + addr->type = SOCKET_ADDRESS_KIND_INET; addr->inet = g_new0(InetSocketAddress, 1); addr->inet->host = g_strdup(localaddr); addr->inet->port = g_strdup(localport); @@ -3704,7 +3704,7 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, } chr = NULL; - backend->kind = cd->kind; + backend->type = cd->kind; if (cd->parse) { cd->parse(opts, backend, &local_err); if (local_err) { @@ -3722,7 +3722,7 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, qapi_free_ChardevReturn(ret); backend = g_new0(ChardevBackend, 1); backend->mux = g_new0(ChardevMux, 1); - backend->kind = CHARDEV_BACKEND_KIND_MUX; + backend->type = CHARDEV_BACKEND_KIND_MUX; backend->mux->chardev = g_strdup(bid); ret = qmp_chardev_add(id, backend, errp); if (!ret) { @@ -4151,7 +4151,7 @@ static CharDriverState *qmp_chardev_open_socket(ChardevSocket *sock, s->fd = -1; s->listen_fd = -1; - s->is_unix = addr->kind == SOCKET_ADDRESS_KIND_UNIX; + s->is_unix = addr->type == SOCKET_ADDRESS_KIND_UNIX; s->is_listen = is_listen; s->is_telnet = is_telnet; s->do_nodelay = do_nodelay; @@ -4225,7 +4225,7 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, return NULL; } - switch (backend->kind) { + switch (backend->type) { case CHARDEV_BACKEND_KIND_FILE: chr = qmp_chardev_open_file(backend->file, errp); break; @@ -4296,7 +4296,7 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, chr = qemu_chr_open_ringbuf(backend->ringbuf, errp); break; default: - error_setg(errp, "unknown chardev backend (%d)", backend->kind); + error_setg(errp, "unknown chardev backend (%d)", backend->type); break; } @@ -4312,9 +4312,9 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, if (chr) { chr->label = g_strdup(id); chr->avail_connections = - (backend->kind == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1; + (backend->type == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1; if (!chr->filename) { - chr->filename = g_strdup(ChardevBackendKind_lookup[backend->kind]); + chr->filename = g_strdup(ChardevBackendKind_lookup[backend->type]); } if (!chr->explicit_be_open) { qemu_chr_be_event(chr, CHR_EVENT_OPENED); diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 6c9fecd..99bf00a 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -136,7 +136,7 @@ struct %(c_name)s { ''') else: ret += mcgen(''' - %(c_type)s kind; + %(c_type)s type; ''', c_type=c_name(variants.tag_member.type.name)) @@ -152,10 +152,7 @@ struct %(c_name)s { union { /* union tag is @%(c_name)s */ void *data; ''', - # TODO ugly special case for simple union - # Use same tag name in C as on the wire to get rid of - # it, then: c_name=c_name(variants.tag_member.name) - c_name=c_name(variants.tag_name or 'kind')) + c_name=c_name(variants.tag_member.name)) for var in variants.variants: # Ugly special case for simple union TODO get rid of it diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index d776948..59b46e9 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -207,11 +207,11 @@ void visit_type_%(c_name)s(Visitor *m, %(c_name)s **obj, const char *name, Error if (err) { goto out; } - visit_get_next_type(m, (int*) &(*obj)->kind, %(c_name)s_qtypes, name, &err); + visit_get_next_type(m, (int*) &(*obj)->type, %(c_name)s_qtypes, name, &err); if (err) { goto out_end; } - switch ((*obj)->kind) { + switch ((*obj)->type) { ''', c_name=c_name(name)) @@ -278,9 +278,6 @@ void visit_type_%(c_name)s(Visitor *m, %(c_name)s **obj, const char *name, Error c_name=c_name(name)) tag_key = variants.tag_member.name - if not variants.tag_name: - # we pointlessly use a different key for simple unions - tag_key = 'type' ret += mcgen(''' visit_type_%(c_type)s(m, &(*obj)->%(c_name)s, "%(name)s", &err); if (err) { @@ -292,11 +289,7 @@ void visit_type_%(c_name)s(Visitor *m, %(c_name)s **obj, const char *name, Error switch ((*obj)->%(c_name)s) { ''', c_type=variants.tag_member.type.c_name(), - # TODO ugly special case for simple union - # Use same tag name in C as on the wire to get rid of - # it, then: c_name=c_name(variants.tag_member.name) - c_name=c_name(variants.tag_name or 'kind'), - name=tag_key) + c_name=c_name(tag_key), name=tag_key) for var in variants.variants: # TODO ugly special case for simple union diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index 8d5249e..6a67e73 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -64,7 +64,7 @@ __org_qemu_x_Union1 *qmp___org_qemu_x_command(__org_qemu_x_EnumList *a, { __org_qemu_x_Union1 *ret = g_new0(__org_qemu_x_Union1, 1); - ret->kind = ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; + ret->type = ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; ret->__org_qemu_x_branch = strdup("blah1"); return ret; diff --git a/tests/test-qmp-input-visitor.c b/tests/test-qmp-input-visitor.c index 61715b3..da84993 100644 --- a/tests/test-qmp-input-visitor.c +++ b/tests/test-qmp-input-visitor.c @@ -374,7 +374,7 @@ static void test_visitor_in_alternate(TestInputVisitorData *data, visit_type_UserDefAlternate(v, &tmp, NULL, &err); g_assert(err == NULL); - g_assert_cmpint(tmp->kind, ==, USER_DEF_ALTERNATE_KIND_I); + g_assert_cmpint(tmp->type, ==, USER_DEF_ALTERNATE_KIND_I); g_assert_cmpint(tmp->i, ==, 42); qapi_free_UserDefAlternate(tmp); } @@ -404,7 +404,7 @@ static void test_native_list_integer_helper(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &err); g_assert(err == NULL); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->kind, ==, kind); + g_assert_cmpint(cvalue->type, ==, kind); switch (kind) { case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: { @@ -567,7 +567,7 @@ static void test_visitor_in_native_list_bool(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &err); g_assert(err == NULL); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->kind, ==, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN); + g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN); for (i = 0, elem = cvalue->boolean; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, (i % 3 == 0) ? 1 : 0); @@ -602,7 +602,7 @@ static void test_visitor_in_native_list_string(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &err); g_assert(err == NULL); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->kind, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING); + g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING); for (i = 0, elem = cvalue->string; elem; elem = elem->next, i++) { gchar str[8]; @@ -641,7 +641,7 @@ static void test_visitor_in_native_list_number(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &err); g_assert(err == NULL); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->kind, ==, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER); + g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER); for (i = 0, elem = cvalue->number; elem; elem = elem->next, i++) { GString *double_expected = g_string_new(""); diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c index 1a28dc2..2162a4a 100644 --- a/tests/test-qmp-output-visitor.c +++ b/tests/test-qmp-output-visitor.c @@ -517,7 +517,7 @@ static void test_visitor_out_alternate(TestOutputVisitorData *data, Error *err = NULL; UserDefAlternate *tmp = g_malloc0(sizeof(UserDefAlternate)); - tmp->kind = USER_DEF_ALTERNATE_KIND_I; + tmp->type = USER_DEF_ALTERNATE_KIND_I; tmp->i = 42; visit_type_UserDefAlternate(data->ov, &tmp, NULL, &err); @@ -542,7 +542,7 @@ static void test_visitor_out_empty(TestOutputVisitorData *data, static void init_native_list(UserDefNativeListUnion *cvalue) { int i; - switch (cvalue->kind) { + switch (cvalue->type) { case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: { intList **list = &cvalue->integer; for (i = 0; i < 32; i++) { @@ -763,14 +763,14 @@ static void test_native_list(TestOutputVisitorData *data, Error *err = NULL; QObject *obj; - cvalue->kind = kind; + cvalue->type = kind; init_native_list(cvalue); visit_type_UserDefNativeListUnion(data->ov, &cvalue, NULL, &err); g_assert(err == NULL); obj = qmp_output_get_qobject(data->qov); - check_native_list(obj, cvalue->kind); + check_native_list(obj, cvalue->type); qapi_free_UserDefNativeListUnion(cvalue); qobject_decref(obj); } diff --git a/tpm.c b/tpm.c index 4e9b109..fcab81c 100644 --- a/tpm.c +++ b/tpm.c @@ -260,7 +260,7 @@ static TPMInfo *qmp_query_tpm_inst(TPMBackend *drv) switch (drv->ops->type) { case TPM_TYPE_PASSTHROUGH: - res->options->kind = TPM_TYPE_OPTIONS_KIND_PASSTHROUGH; + res->options->type = TPM_TYPE_OPTIONS_KIND_PASSTHROUGH; tpo = g_new0(TPMPassthroughOptions, 1); res->options->passthrough = tpo; if (drv->path) { diff --git a/ui/input-keymap.c b/ui/input-keymap.c index 7635cb0..088523d 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -139,10 +139,10 @@ static int number_to_qcode[0x100]; int qemu_input_key_value_to_number(const KeyValue *value) { - if (value->kind == KEY_VALUE_KIND_QCODE) { + if (value->type == KEY_VALUE_KIND_QCODE) { return qcode_to_number[value->qcode]; } else { - assert(value->kind == KEY_VALUE_KIND_NUMBER); + assert(value->type == KEY_VALUE_KIND_NUMBER); return value->number; } } @@ -166,10 +166,10 @@ int qemu_input_key_number_to_qcode(uint8_t nr) int qemu_input_key_value_to_qcode(const KeyValue *value) { - if (value->kind == KEY_VALUE_KIND_QCODE) { + if (value->type == KEY_VALUE_KIND_QCODE) { return value->qcode; } else { - assert(value->kind == KEY_VALUE_KIND_NUMBER); + assert(value->type == KEY_VALUE_KIND_NUMBER); return qemu_input_key_number_to_qcode(value->number); } } @@ -180,7 +180,7 @@ int qemu_input_key_value_to_scancode(const KeyValue *value, bool down, int keycode = qemu_input_key_value_to_number(value); int count = 0; - if (value->kind == KEY_VALUE_KIND_QCODE && + if (value->type == KEY_VALUE_KIND_QCODE && value->qcode == Q_KEY_CODE_PAUSE) { /* specific case */ int v = down ? 0 : 0x80; diff --git a/ui/input-legacy.c b/ui/input-legacy.c index e50f296..6149648 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -150,7 +150,7 @@ static void legacy_mouse_event(DeviceState *dev, QemuConsole *src, }; QEMUPutMouseEntry *s = (QEMUPutMouseEntry *)dev; - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_BTN: if (evt->btn->down) { s->buttons |= bmap[evt->btn->button]; diff --git a/ui/input.c b/ui/input.c index 1a552d1..fd86571 100644 --- a/ui/input.c +++ b/ui/input.c @@ -147,10 +147,10 @@ void qmp_x_input_send_event(bool has_console, int64_t console, for (e = events; e != NULL; e = e->next) { InputEvent *event = e->value; - if (!qemu_input_find_handler(1 << event->kind, con)) { + if (!qemu_input_find_handler(1 << event->type, con)) { error_setg(errp, "Input handler not found for " "event type %s", - InputEventKind_lookup[event->kind]); + InputEventKind_lookup[event->type]); return; } } @@ -197,9 +197,9 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt) if (src) { idx = qemu_console_get_index(src); } - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_KEY: - switch (evt->key->key->kind) { + switch (evt->key->key->type) { case KEY_VALUE_KIND_NUMBER: qcode = qemu_input_key_number_to_qcode(evt->key->key->number); name = QKeyCode_lookup[qcode]; @@ -311,12 +311,12 @@ void qemu_input_event_send(QemuConsole *src, InputEvent *evt) qemu_input_event_trace(src, evt); /* pre processing */ - if (graphic_rotate && (evt->kind == INPUT_EVENT_KIND_ABS)) { + if (graphic_rotate && (evt->type == INPUT_EVENT_KIND_ABS)) { qemu_input_transform_abs_rotate(evt); } /* send event */ - s = qemu_input_find_handler(1 << evt->kind, src); + s = qemu_input_find_handler(1 << evt->type, src); if (!s) { return; } @@ -349,7 +349,7 @@ InputEvent *qemu_input_event_new_key(KeyValue *key, bool down) { InputEvent *evt = g_new0(InputEvent, 1); evt->key = g_new0(InputKeyEvent, 1); - evt->kind = INPUT_EVENT_KIND_KEY; + evt->type = INPUT_EVENT_KIND_KEY; evt->key->key = key; evt->key->down = down; return evt; @@ -372,7 +372,7 @@ void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down) void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down) { KeyValue *key = g_new0(KeyValue, 1); - key->kind = KEY_VALUE_KIND_NUMBER; + key->type = KEY_VALUE_KIND_NUMBER; key->number = num; qemu_input_event_send_key(src, key, down); } @@ -380,7 +380,7 @@ void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down) void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down) { KeyValue *key = g_new0(KeyValue, 1); - key->kind = KEY_VALUE_KIND_QCODE; + key->type = KEY_VALUE_KIND_QCODE; key->qcode = q; qemu_input_event_send_key(src, key, down); } @@ -399,7 +399,7 @@ InputEvent *qemu_input_event_new_btn(InputButton btn, bool down) { InputEvent *evt = g_new0(InputEvent, 1); evt->btn = g_new0(InputBtnEvent, 1); - evt->kind = INPUT_EVENT_KIND_BTN; + evt->type = INPUT_EVENT_KIND_BTN; evt->btn->button = btn; evt->btn->down = down; return evt; @@ -451,7 +451,7 @@ InputEvent *qemu_input_event_new_move(InputEventKind kind, InputEvent *evt = g_new0(InputEvent, 1); InputMoveEvent *move = g_new0(InputMoveEvent, 1); - evt->kind = kind; + evt->type = kind; evt->data = move; move->axis = axis; move->value = value; diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 2add83a..277b139 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -904,7 +904,7 @@ SocketAddress *socket_parse(const char *str, Error **errp) error_setg(errp, "invalid Unix socket address"); goto fail; } else { - addr->kind = SOCKET_ADDRESS_KIND_UNIX; + addr->type = SOCKET_ADDRESS_KIND_UNIX; addr->q_unix = g_new(UnixSocketAddress, 1); addr->q_unix->path = g_strdup(str + 5); } @@ -913,12 +913,12 @@ SocketAddress *socket_parse(const char *str, Error **errp) error_setg(errp, "invalid file descriptor address"); goto fail; } else { - addr->kind = SOCKET_ADDRESS_KIND_FD; + addr->type = SOCKET_ADDRESS_KIND_FD; addr->fd = g_new(String, 1); addr->fd->str = g_strdup(str + 3); } } else { - addr->kind = SOCKET_ADDRESS_KIND_INET; + addr->type = SOCKET_ADDRESS_KIND_INET; addr->inet = inet_parse(str, errp); if (addr->inet == NULL) { goto fail; @@ -938,7 +938,7 @@ int socket_connect(SocketAddress *addr, Error **errp, int fd; opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); - switch (addr->kind) { + switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: inet_addr_to_opts(opts, addr->inet); fd = inet_connect_opts(opts, errp, callback, opaque); @@ -970,7 +970,7 @@ int socket_listen(SocketAddress *addr, Error **errp) int fd; opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); - switch (addr->kind) { + switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: inet_addr_to_opts(opts, addr->inet); fd = inet_listen_opts(opts, 0, errp); @@ -998,7 +998,7 @@ int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp) int fd; opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); - switch (remote->kind) { + switch (remote->type) { case SOCKET_ADDRESS_KIND_INET: inet_addr_to_opts(opts, remote->inet); if (local) { -- 2.4.3 From MAILER-DAEMON Thu Sep 10 03:55:33 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZwhh-00057Q-OK for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 03:55:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZwhf-000571-Qn for qemu-block@nongnu.org; Thu, 10 Sep 2015 03:55:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZwhc-0005nc-JJ for qemu-block@nongnu.org; Thu, 10 Sep 2015 03:55:31 -0400 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]:45645) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZwhc-0005lH-Dn for qemu-block@nongnu.org; Thu, 10 Sep 2015 03:55:28 -0400 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id DF74F28939; Thu, 10 Sep 2015 00:57:56 -0700 (PDT) Received: from EX13-CAS-008.vmware.com (ex13-cas-008.vmware.com [10.113.191.58]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 3550BB06DC; Thu, 10 Sep 2015 00:55:26 -0700 (PDT) Received: from rgerganov-dev.eng.vmware.com (10.113.160.246) by EX13-MBX-024.vmware.com (10.113.191.44) with Microsoft SMTP Server (TLS) id 15.0.1076.9; Thu, 10 Sep 2015 00:55:24 -0700 From: Radoslav Gerganov To: Date: Thu, 10 Sep 2015 10:53:14 +0300 Message-ID: <1441871594-21252-1-git-send-email-rgerganov@vmware.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.113.160.246] X-ClientProxiedBy: EX13-CAS-013.vmware.com (10.113.191.65) To EX13-MBX-024.vmware.com (10.113.191.44) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.91.2.12 Cc: kwolf@redhat.com, famz@redhat.com Subject: [Qemu-block] [PATCH] vmdk: Fix next_cluster_sector for compressed write X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 07:55:32 -0000 When the VMDK is streamOptimized (or compressed), the next_cluster_sector must not be incremented by a fixed number of sectors. Instead of this, it must be rounded up to the next consecutive sector. Fixing this results in much smaller compressed images. Signed-off-by: Radoslav Gerganov --- block/vmdk.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index fbaab67..3bd5ccd 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1324,8 +1324,12 @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, write_end_sector = DIV_ROUND_UP(write_offset + write_len, BDRV_SECTOR_SIZE); - extent->next_cluster_sector = MAX(extent->next_cluster_sector, - write_end_sector); + if (extent->compressed) { + extent->next_cluster_sector = write_end_sector; + } else { + extent->next_cluster_sector = MAX(extent->next_cluster_sector, + write_end_sector); + } if (ret != write_len) { ret = ret < 0 ? ret : -EIO; -- 1.9.1 From MAILER-DAEMON Thu Sep 10 04:16:08 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZx1c-0003rZ-78 for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 04:16:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZx1Z-0003oB-WF for qemu-block@nongnu.org; Thu, 10 Sep 2015 04:16:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZx1V-0007Na-Sl for qemu-block@nongnu.org; Thu, 10 Sep 2015 04:16:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZx1V-0007NS-OQ for qemu-block@nongnu.org; Thu, 10 Sep 2015 04:16:01 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id D7062C1C655E; Thu, 10 Sep 2015 08:16:00 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8A8FwDu023117; Thu, 10 Sep 2015 04:15:59 -0400 Date: Thu, 10 Sep 2015 16:15:57 +0800 From: Fam Zheng To: Radoslav Gerganov Message-ID: <20150910081557.GA27306@ad.nay.redhat.com> References: <1441871594-21252-1-git-send-email-rgerganov@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441871594-21252-1-git-send-email-rgerganov@vmware.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH] vmdk: Fix next_cluster_sector for compressed write X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 08:16:07 -0000 On Thu, 09/10 10:53, Radoslav Gerganov wrote: > When the VMDK is streamOptimized (or compressed), the > next_cluster_sector must not be incremented by a fixed number of > sectors. Instead of this, it must be rounded up to the next consecutive > sector. Fixing this results in much smaller compressed images. > > Signed-off-by: Radoslav Gerganov Is this patch enough to produce a valid streamOptimized image? Because I remember there were reports on some other issues with footer or grain markers. Fam > --- > block/vmdk.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/block/vmdk.c b/block/vmdk.c > index fbaab67..3bd5ccd 100644 > --- a/block/vmdk.c > +++ b/block/vmdk.c > @@ -1324,8 +1324,12 @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, > > write_end_sector = DIV_ROUND_UP(write_offset + write_len, BDRV_SECTOR_SIZE); > > - extent->next_cluster_sector = MAX(extent->next_cluster_sector, > - write_end_sector); > + if (extent->compressed) { > + extent->next_cluster_sector = write_end_sector; > + } else { > + extent->next_cluster_sector = MAX(extent->next_cluster_sector, > + write_end_sector); > + } > > if (ret != write_len) { > ret = ret < 0 ? ret : -EIO; > -- > 1.9.1 > From MAILER-DAEMON Thu Sep 10 04:48:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZxXK-0000ys-Jq for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 04:48:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZxX2-0000uc-HU for qemu-block@nongnu.org; Thu, 10 Sep 2015 04:48:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZxWq-0006Hp-5v for qemu-block@nongnu.org; Thu, 10 Sep 2015 04:48:35 -0400 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]:46041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZxWp-00069j-Ny for qemu-block@nongnu.org; Thu, 10 Sep 2015 04:48:23 -0400 Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 98DF9288E2; Thu, 10 Sep 2015 01:48:25 -0700 (PDT) Received: from EX13-CAS-003.vmware.com (ex13-cas-003.vmware.com [10.113.191.53]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id AD2FA4089C; Thu, 10 Sep 2015 01:48:20 -0700 (PDT) Received: from [10.23.13.216] (10.113.160.246) by EX13-MBX-024.vmware.com (10.113.191.44) with Microsoft SMTP Server (TLS) id 15.0.1076.9; Thu, 10 Sep 2015 01:48:19 -0700 Message-ID: <55F143C6.5020401@vmware.com> Date: Thu, 10 Sep 2015 11:48:06 +0300 From: Radoslav Gerganov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Fam Zheng References: <1441871594-21252-1-git-send-email-rgerganov@vmware.com> <20150910081557.GA27306@ad.nay.redhat.com> In-Reply-To: <20150910081557.GA27306@ad.nay.redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.113.160.246] X-ClientProxiedBy: EX13-CAS-013.vmware.com (10.113.191.65) To EX13-MBX-024.vmware.com (10.113.191.44) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.91.2.13 Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH] vmdk: Fix next_cluster_sector for compressed write X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 08:48:53 -0000 On 10.09.2015 11:15, Fam Zheng wrote: > On Thu, 09/10 10:53, Radoslav Gerganov wrote: >> When the VMDK is streamOptimized (or compressed), the >> next_cluster_sector must not be incremented by a fixed number of >> sectors. Instead of this, it must be rounded up to the next consecutive >> sector. Fixing this results in much smaller compressed images. >> >> Signed-off-by: Radoslav Gerganov > > Is this patch enough to produce a valid streamOptimized image? Because I > remember there were reports on some other issues with footer or grain markers. > > Fam The VMDK spec says that each marker and its associated block must begin on sector boundary which is true before and after my patch. However, with my patch we don't put empty sectors when we achieve good compression for the current cluster but start the next cluster on the next consecutive sector. I have also verified that images produced with my patch can be booted in VMware Workstation. -Rado >> --- >> block/vmdk.c | 8 ++++++-- >> 1 file changed, 6 insertions(+), 2 deletions(-) >> >> diff --git a/block/vmdk.c b/block/vmdk.c >> index fbaab67..3bd5ccd 100644 >> --- a/block/vmdk.c >> +++ b/block/vmdk.c >> @@ -1324,8 +1324,12 @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, >> >> write_end_sector = DIV_ROUND_UP(write_offset + write_len, BDRV_SECTOR_SIZE); >> >> - extent->next_cluster_sector = MAX(extent->next_cluster_sector, >> - write_end_sector); >> + if (extent->compressed) { >> + extent->next_cluster_sector = write_end_sector; >> + } else { >> + extent->next_cluster_sector = MAX(extent->next_cluster_sector, >> + write_end_sector); >> + } >> >> if (ret != write_len) { >> ret = ret < 0 ? ret : -EIO; >> -- >> 1.9.1 >> From MAILER-DAEMON Thu Sep 10 04:58:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZxgL-0004Y8-6w for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 04:58:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZxgJ-0004VS-3c for qemu-block@nongnu.org; Thu, 10 Sep 2015 04:58:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZxgG-0002Vp-Dk for qemu-block@nongnu.org; Thu, 10 Sep 2015 04:58:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39269) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZxgG-0002Vh-8e for qemu-block@nongnu.org; Thu, 10 Sep 2015 04:58:08 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 2180C91C23; Thu, 10 Sep 2015 08:58:07 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8A8w4Fa009383; Thu, 10 Sep 2015 04:58:05 -0400 Date: Thu, 10 Sep 2015 16:58:03 +0800 From: Fam Zheng To: Radoslav Gerganov Message-ID: <20150910085803.GB27306@ad.nay.redhat.com> References: <1441871594-21252-1-git-send-email-rgerganov@vmware.com> <20150910081557.GA27306@ad.nay.redhat.com> <55F143C6.5020401@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55F143C6.5020401@vmware.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH] vmdk: Fix next_cluster_sector for compressed write X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 08:58:12 -0000 On Thu, 09/10 11:48, Radoslav Gerganov wrote: > On 10.09.2015 11:15, Fam Zheng wrote: > > On Thu, 09/10 10:53, Radoslav Gerganov wrote: > >> When the VMDK is streamOptimized (or compressed), the > >> next_cluster_sector must not be incremented by a fixed number of > >> sectors. Instead of this, it must be rounded up to the next consecutive > >> sector. Fixing this results in much smaller compressed images. > >> > >> Signed-off-by: Radoslav Gerganov > > > > Is this patch enough to produce a valid streamOptimized image? Because I > > remember there were reports on some other issues with footer or grain markers. > > > > Fam > > The VMDK spec says that each marker and its associated block must begin on > sector boundary which is true before and after my patch. However, with my > patch we don't put empty sectors when we achieve good compression for the > current cluster but start the next cluster on the next consecutive sector. > > I have also verified that images produced with my patch can be booted in > VMware Workstation. Thanks, the change looks good to me. Reviewed-by: Fam Zheng From MAILER-DAEMON Thu Sep 10 05:18:03 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZxzW-0000RE-SP for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 05:18:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZxzS-0000Io-Ni for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:18:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZxzP-0004WG-GC for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:17:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZxzP-0004W8-6x; Thu, 10 Sep 2015 05:17:55 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id B6CED8E6E0; Thu, 10 Sep 2015 09:17:54 +0000 (UTC) Received: from redhat.com (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8A9HplG019702; Thu, 10 Sep 2015 05:17:52 -0400 Date: Thu, 10 Sep 2015 12:17:51 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1441876643-7467-4-git-send-email-mst@redhat.com> References: <1441876643-7467-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441876643-7467-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Amit Shah , Stefan Hajnoczi , Cornelia Huck , Paolo Bonzini Subject: [Qemu-block] [PULL 3/7] virtio: avoid leading underscores for helpers X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 09:18:01 -0000 From: Cornelia Huck Commit ef546f1275f6563e8934dd5e338d29d9f9909ca6 ("virtio: add feature checking helpers") introduced a helper __virtio_has_feature. We don't want to use reserved identifiers, though, so let's rename __virtio_has_feature to virtio_has_feature and virtio_has_feature to virtio_vdev_has_feature. Signed-off-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-access.h | 2 +- include/hw/virtio/virtio.h | 11 ++++++----- hw/block/virtio-blk.c | 7 ++++--- hw/char/virtio-serial-bus.c | 2 +- hw/net/vhost_net.c | 2 +- hw/net/virtio-net.c | 31 ++++++++++++++++--------------- hw/scsi/virtio-scsi.c | 8 ++++---- hw/virtio/dataplane/vring.c | 10 +++++----- hw/virtio/vhost.c | 4 ++-- hw/virtio/virtio-balloon.c | 2 +- hw/virtio/virtio.c | 14 +++++++------- 11 files changed, 48 insertions(+), 45 deletions(-) diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h index 1ec1dfd..8aec843 100644 --- a/include/hw/virtio/virtio-access.h +++ b/include/hw/virtio/virtio-access.h @@ -19,7 +19,7 @@ static inline bool virtio_access_is_big_endian(VirtIODevice *vdev) { - if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { /* Devices conforming to VIRTIO 1.0 or later are always LE. */ return false; } diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index cccae89..6201ee8 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -261,26 +261,27 @@ static inline void virtio_clear_feature(uint64_t *features, unsigned int fbit) *features &= ~(1ULL << fbit); } -static inline bool __virtio_has_feature(uint64_t features, unsigned int fbit) +static inline bool virtio_has_feature(uint64_t features, unsigned int fbit) { assert(fbit < 64); return !!(features & (1ULL << fbit)); } -static inline bool virtio_has_feature(VirtIODevice *vdev, unsigned int fbit) +static inline bool virtio_vdev_has_feature(VirtIODevice *vdev, + unsigned int fbit) { - return __virtio_has_feature(vdev->guest_features, fbit); + return virtio_has_feature(vdev->guest_features, fbit); } static inline bool virtio_host_has_feature(VirtIODevice *vdev, unsigned int fbit) { - return __virtio_has_feature(vdev->host_features, fbit); + return virtio_has_feature(vdev->host_features, fbit); } static inline bool virtio_is_big_endian(VirtIODevice *vdev) { - if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN); return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_BIG; } diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 1556c9c..f9301ae 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -731,7 +731,7 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features, virtio_add_feature(&features, VIRTIO_BLK_F_GEOMETRY); virtio_add_feature(&features, VIRTIO_BLK_F_TOPOLOGY); virtio_add_feature(&features, VIRTIO_BLK_F_BLK_SIZE); - if (__virtio_has_feature(features, VIRTIO_F_VERSION_1)) { + if (virtio_has_feature(features, VIRTIO_F_VERSION_1)) { if (s->conf.scsi) { error_setg(errp, "Please set scsi=off for virtio-blk devices in order to use virtio 1.0"); return 0; @@ -782,10 +782,11 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status) * * s->blk would erroneously be placed in writethrough mode. */ - if (!virtio_has_feature(vdev, VIRTIO_BLK_F_CONFIG_WCE)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_BLK_F_CONFIG_WCE)) { aio_context_acquire(blk_get_aio_context(s->blk)); blk_set_enable_write_cache(s->blk, - virtio_has_feature(vdev, VIRTIO_BLK_F_WCE)); + virtio_vdev_has_feature(vdev, + VIRTIO_BLK_F_WCE)); aio_context_release(blk_get_aio_context(s->blk)); } } diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index bc56f5d..be97058 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -76,7 +76,7 @@ static VirtIOSerialPort *find_port_by_name(char *name) static bool use_multiport(VirtIOSerial *vser) { VirtIODevice *vdev = VIRTIO_DEVICE(vser); - return virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT); + return virtio_vdev_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT); } static size_t write_to_port(VirtIOSerialPort *port, diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 5c1d11f..1d76b94 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -197,7 +197,7 @@ static int vhost_net_set_vnet_endian(VirtIODevice *dev, NetClientState *peer, { int r = 0; - if (virtio_has_feature(dev, VIRTIO_F_VERSION_1) || + if (virtio_vdev_has_feature(dev, VIRTIO_F_VERSION_1) || (virtio_legacy_is_cross_endian(dev) && !virtio_is_big_endian(dev))) { r = qemu_set_vnet_le(peer, set); if (r) { diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 8d28e45..f72eebf 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -86,8 +86,8 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config) memcpy(&netcfg, config, n->config_size); - if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR) && - !virtio_has_feature(vdev, VIRTIO_F_VERSION_1) && + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR) && + !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) && memcmp(netcfg.mac, n->mac, ETH_ALEN)) { memcpy(n->mac, netcfg.mac, ETH_ALEN); qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac); @@ -304,7 +304,7 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc) info->multicast_table = str_list; info->vlan_table = get_vlan_table(n); - if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VLAN)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VLAN)) { info->vlan = RX_STATE_ALL; } else if (!info->vlan_table) { info->vlan = RX_STATE_NONE; @@ -529,13 +529,13 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features) int i; virtio_net_set_multiqueue(n, - __virtio_has_feature(features, VIRTIO_NET_F_MQ)); + virtio_has_feature(features, VIRTIO_NET_F_MQ)); virtio_net_set_mrg_rx_bufs(n, - __virtio_has_feature(features, - VIRTIO_NET_F_MRG_RXBUF), - __virtio_has_feature(features, - VIRTIO_F_VERSION_1)); + virtio_has_feature(features, + VIRTIO_NET_F_MRG_RXBUF), + virtio_has_feature(features, + VIRTIO_F_VERSION_1)); if (n->has_vnet_hdr) { n->curr_guest_offloads = @@ -552,7 +552,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features) vhost_net_ack_features(get_vhost_net(nc->peer), features); } - if (__virtio_has_feature(features, VIRTIO_NET_F_CTRL_VLAN)) { + if (virtio_has_feature(features, VIRTIO_NET_F_CTRL_VLAN)) { memset(n->vlans, 0, MAX_VLAN >> 3); } else { memset(n->vlans, 0xff, MAX_VLAN >> 3); @@ -599,7 +599,7 @@ static int virtio_net_handle_offloads(VirtIONet *n, uint8_t cmd, uint64_t offloads; size_t s; - if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { return VIRTIO_NET_ERR; } @@ -1449,7 +1449,7 @@ static void virtio_net_save_device(VirtIODevice *vdev, QEMUFile *f) } } - if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { qemu_put_be64(f, n->curr_guest_offloads); } } @@ -1475,7 +1475,8 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, n->vqs[0].tx_waiting = qemu_get_be32(f); virtio_net_set_mrg_rx_bufs(n, qemu_get_be32(f), - virtio_has_feature(vdev, VIRTIO_F_VERSION_1)); + virtio_vdev_has_feature(vdev, + VIRTIO_F_VERSION_1)); if (version_id >= 3) n->status = qemu_get_be16(f); @@ -1558,7 +1559,7 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, } } - if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { n->curr_guest_offloads = qemu_get_be64(f); } else { n->curr_guest_offloads = virtio_net_supported_guest_offloads(n); @@ -1585,8 +1586,8 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, qemu_get_subqueue(n->nic, i)->link_down = link_down; } - if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) && - virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) && + virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) { n->announce_counter = SELF_ANNOUNCE_ROUNDS; timer_mod(n->announce_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL)); } diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index a8bb1c6..1c33f14 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -145,7 +145,7 @@ static int virtio_scsi_parse_req(VirtIOSCSIReq *req, * * TODO: always disable this workaround for virtio 1.0 devices. */ - if (!virtio_has_feature(vdev, VIRTIO_F_ANY_LAYOUT)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_F_ANY_LAYOUT)) { if (req->elem.out_num) { req_size = req->elem.out_sg[0].iov_len; } @@ -759,7 +759,7 @@ static void virtio_scsi_change(SCSIBus *bus, SCSIDevice *dev, SCSISense sense) VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus); VirtIODevice *vdev = VIRTIO_DEVICE(s); - if (virtio_has_feature(vdev, VIRTIO_SCSI_F_CHANGE) && + if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_CHANGE) && dev->type != TYPE_ROM) { virtio_scsi_push_event(s, dev, VIRTIO_SCSI_T_PARAM_CHANGE, sense.asc | (sense.ascq << 8)); @@ -783,7 +783,7 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev, aio_context_release(s->ctx); } - if (virtio_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) { virtio_scsi_push_event(s, sd, VIRTIO_SCSI_T_TRANSPORT_RESET, VIRTIO_SCSI_EVT_RESET_RESCAN); @@ -797,7 +797,7 @@ static void virtio_scsi_hotunplug(HotplugHandler *hotplug_dev, DeviceState *dev, VirtIOSCSI *s = VIRTIO_SCSI(vdev); SCSIDevice *sd = SCSI_DEVICE(dev); - if (virtio_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) { virtio_scsi_push_event(s, sd, VIRTIO_SCSI_T_TRANSPORT_RESET, VIRTIO_SCSI_EVT_RESET_REMOVED); diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c index 07fd69c..fece83a 100644 --- a/hw/virtio/dataplane/vring.c +++ b/hw/virtio/dataplane/vring.c @@ -105,7 +105,7 @@ void vring_teardown(Vring *vring, VirtIODevice *vdev, int n) /* Disable guest->host notifies */ void vring_disable_notification(VirtIODevice *vdev, Vring *vring) { - if (!virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_set_used_flags(vdev, vring, VRING_USED_F_NO_NOTIFY); } } @@ -116,7 +116,7 @@ void vring_disable_notification(VirtIODevice *vdev, Vring *vring) */ bool vring_enable_notification(VirtIODevice *vdev, Vring *vring) { - if (virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_avail_event(&vring->vr) = vring->vr.avail->idx; } else { vring_clear_used_flags(vdev, vring, VRING_USED_F_NO_NOTIFY); @@ -135,12 +135,12 @@ bool vring_should_notify(VirtIODevice *vdev, Vring *vring) * interrupts. */ smp_mb(); - if (virtio_has_feature(vdev, VIRTIO_F_NOTIFY_ON_EMPTY) && + if (virtio_vdev_has_feature(vdev, VIRTIO_F_NOTIFY_ON_EMPTY) && unlikely(!vring_more_avail(vdev, vring))) { return true; } - if (!virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { return !(vring_get_avail_flags(vdev, vring) & VRING_AVAIL_F_NO_INTERRUPT); } @@ -402,7 +402,7 @@ int vring_pop(VirtIODevice *vdev, Vring *vring, /* On success, increment avail index. */ vring->last_avail_idx++; - if (virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_avail_event(&vring->vr) = virtio_tswap16(vdev, vring->last_avail_idx); } diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 2712c6f..a08c36b 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -742,7 +742,7 @@ static int vhost_virtqueue_start(struct vhost_dev *dev, return -errno; } - if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1) && + if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) && virtio_legacy_is_cross_endian(vdev)) { r = vhost_virtqueue_set_vring_endian_legacy(dev, virtio_is_big_endian(vdev), @@ -839,7 +839,7 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev, /* In the cross-endian case, we need to reset the vring endianness to * native as legacy devices expect so by default. */ - if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1) && + if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) && virtio_legacy_is_cross_endian(vdev)) { r = vhost_virtqueue_set_vring_endian_legacy(dev, !virtio_is_big_endian(vdev), diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 3577b7a..c419b17 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -70,7 +70,7 @@ static inline void reset_stats(VirtIOBalloon *dev) static bool balloon_stats_supported(const VirtIOBalloon *s) { VirtIODevice *vdev = VIRTIO_DEVICE(s); - return virtio_has_feature(vdev, VIRTIO_BALLOON_F_STATS_VQ); + return virtio_vdev_has_feature(vdev, VIRTIO_BALLOON_F_STATS_VQ); } static bool balloon_stats_enabled(const VirtIOBalloon *s) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 788b556..0832db9 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -220,7 +220,7 @@ static inline void vring_set_avail_event(VirtQueue *vq, uint16_t val) void virtio_queue_set_notification(VirtQueue *vq, int enable) { vq->notification = enable; - if (virtio_has_feature(vq->vdev, VIRTIO_RING_F_EVENT_IDX)) { + if (virtio_vdev_has_feature(vq->vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_set_avail_event(vq, vring_avail_idx(vq)); } else if (enable) { vring_used_flags_unset_bit(vq, VRING_USED_F_NO_NOTIFY); @@ -471,7 +471,7 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem) max = vq->vring.num; i = head = virtqueue_get_head(vq, vq->last_avail_idx++); - if (virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_set_avail_event(vq, vq->last_avail_idx); } @@ -560,7 +560,7 @@ int virtio_set_status(VirtIODevice *vdev, uint8_t val) VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); trace_virtio_set_status(vdev, val); - if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { if (!(vdev->status & VIRTIO_CONFIG_S_FEATURES_OK) && val & VIRTIO_CONFIG_S_FEATURES_OK) { int ret = virtio_validate_features(vdev); @@ -898,7 +898,7 @@ void virtio_queue_set_align(VirtIODevice *vdev, int n, int align) VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); /* virtio-1 compliant devices cannot change the alignment */ - if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { error_report("tried to modify queue alignment for virtio-1 device"); return; } @@ -993,12 +993,12 @@ static bool vring_notify(VirtIODevice *vdev, VirtQueue *vq) /* We need to expose used array entries before checking used event. */ smp_mb(); /* Always notify when queue is empty (when feature acknowledge) */ - if (virtio_has_feature(vdev, VIRTIO_F_NOTIFY_ON_EMPTY) && + if (virtio_vdev_has_feature(vdev, VIRTIO_F_NOTIFY_ON_EMPTY) && !vq->inuse && vring_avail_idx(vq) == vq->last_avail_idx) { return true; } - if (!virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { return !(vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT); } @@ -1035,7 +1035,7 @@ static bool virtio_device_endian_needed(void *opaque) VirtIODevice *vdev = opaque; assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN); - if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { return vdev->device_endian != virtio_default_endian(); } /* Devices conforming to VIRTIO 1.0 or later are always LE. */ -- MST From MAILER-DAEMON Thu Sep 10 05:19:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZy0U-00029x-5T for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 05:19:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZy0R-00024u-Nx for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:19:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZy0O-0004m3-K7 for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:18:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45234) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZy0O-0004lx-Ch; Thu, 10 Sep 2015 05:18:56 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id EA85BA8D; Thu, 10 Sep 2015 09:18:55 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-61.ams2.redhat.com [10.36.116.61]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8A9IsEu017200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 10 Sep 2015 05:18:55 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AB7E63001102; Thu, 10 Sep 2015 11:18:53 +0200 (CEST) From: Markus Armbruster To: John Snow References: <1440623592-13999-1-git-send-email-jsnow@redhat.com> <1440623592-13999-3-git-send-email-jsnow@redhat.com> Date: Thu, 10 Sep 2015 11:18:53 +0200 In-Reply-To: <1440623592-13999-3-git-send-email-jsnow@redhat.com> (John Snow's message of "Wed, 26 Aug 2015 17:13:10 -0400") Message-ID: <87pp1q7htu.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, zuban32s@gmail.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 2/4] qtest/ahci: export generate_pattern X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 09:19:01 -0000 John Snow writes: > Share the pattern function for ide and ahci test. > > Signed-off-by: John Snow > --- > tests/ahci-test.c | 26 -------------------------- > tests/libqos/libqos.c | 26 ++++++++++++++++++++++++++ > tests/libqos/libqos.h | 1 + > 3 files changed, 27 insertions(+), 26 deletions(-) > > diff --git a/tests/ahci-test.c b/tests/ahci-test.c > index b1a785c..59d387c 100644 > --- a/tests/ahci-test.c > +++ b/tests/ahci-test.c > @@ -71,32 +71,6 @@ static void string_bswap16(uint16_t *s, size_t bytes) > } > } > > -static void generate_pattern(void *buffer, size_t len, size_t cycle_len) > -{ > - int i, j; > - unsigned char *tx = (unsigned char *)buffer; > - unsigned char p; > - size_t *sx; > - > - /* Write an indicative pattern that varies and is unique per-cycle */ > - p = rand() % 256; > - for (i = 0; i < len; i++) { > - tx[i] = p++ % 256; > - if (i % cycle_len == 0) { > - p = rand() % 256; > - } > - } > - > - /* force uniqueness by writing an id per-cycle */ > - for (i = 0; i < len / cycle_len; i++) { > - j = i * cycle_len; > - if (j + sizeof(*sx) <= len) { > - sx = (size_t *)&tx[j]; > - *sx = i; > - } > - } > -} > - > /** > * Verify that the transfer did not corrupt our state at all. > */ > diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c > index fce625b..8d7c5a9 100644 > --- a/tests/libqos/libqos.c > +++ b/tests/libqos/libqos.c > @@ -212,3 +212,29 @@ void prepare_blkdebug_script(const char *debug_fn, const char *event) > ret = fclose(debug_file); > g_assert(ret == 0); > } > + > +void generate_pattern(void *buffer, size_t len, size_t cycle_len) > +{ > + int i, j; > + unsigned char *tx = (unsigned char *)buffer; > + unsigned char p; > + size_t *sx; > + > + /* Write an indicative pattern that varies and is unique per-cycle */ > + p = rand() % 256; > + for (i = 0; i < len; i++) { > + tx[i] = p++ % 256; > + if (i % cycle_len == 0) { > + p = rand() % 256; > + } > + } > + > + /* force uniqueness by writing an id per-cycle */ > + for (i = 0; i < len / cycle_len; i++) { > + j = i * cycle_len; > + if (j + sizeof(*sx) <= len) { > + sx = (size_t *)&tx[j]; Relies on cycle_len being a multiple of size_t's alignment. So far, it's always AHCI_SECTOR_SIZE, which should do. > + *sx = i; > + } > + } > +} Looks like overkill to me, but since it's working code... :) > diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h > index e1f14ea..492a651 100644 > --- a/tests/libqos/libqos.h > +++ b/tests/libqos/libqos.h > @@ -24,6 +24,7 @@ void mkqcow2(const char *file, unsigned size_mb); > void set_context(QOSState *s); > void migrate(QOSState *from, QOSState *to, const char *uri); > void prepare_blkdebug_script(const char *debug_fn, const char *event); > +void generate_pattern(void *buffer, size_t len, size_t cycle_len); > > static inline uint64_t qmalloc(QOSState *q, size_t bytes) > { From MAILER-DAEMON Thu Sep 10 05:27:10 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZy8M-0005xq-R5 for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 05:27:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZy8H-0005pc-Ux for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:27:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZy8F-0001q9-QC for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:27:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZy8F-0001q2-I7; Thu, 10 Sep 2015 05:27:03 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 47DB18EA2E; Thu, 10 Sep 2015 09:27:03 +0000 (UTC) Received: from redhat.com (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8A9QxYU024832; Thu, 10 Sep 2015 05:27:00 -0400 Date: Thu, 10 Sep 2015 12:26:59 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1441876643-7467-4-git-send-email-mst@redhat.com> References: <1441876643-7467-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441876643-7467-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Amit Shah , Stefan Hajnoczi , Cornelia Huck , Paolo Bonzini Subject: [Qemu-block] [PULL 3/7] virtio: avoid leading underscores for helpers X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 09:27:08 -0000 From: Cornelia Huck Commit ef546f1275f6563e8934dd5e338d29d9f9909ca6 ("virtio: add feature checking helpers") introduced a helper __virtio_has_feature. We don't want to use reserved identifiers, though, so let's rename __virtio_has_feature to virtio_has_feature and virtio_has_feature to virtio_vdev_has_feature. Signed-off-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-access.h | 2 +- include/hw/virtio/virtio.h | 11 ++++++----- hw/block/virtio-blk.c | 7 ++++--- hw/char/virtio-serial-bus.c | 2 +- hw/net/vhost_net.c | 2 +- hw/net/virtio-net.c | 31 ++++++++++++++++--------------- hw/scsi/virtio-scsi.c | 8 ++++---- hw/virtio/dataplane/vring.c | 10 +++++----- hw/virtio/vhost.c | 4 ++-- hw/virtio/virtio-balloon.c | 2 +- hw/virtio/virtio.c | 14 +++++++------- 11 files changed, 48 insertions(+), 45 deletions(-) diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h index 1ec1dfd..8aec843 100644 --- a/include/hw/virtio/virtio-access.h +++ b/include/hw/virtio/virtio-access.h @@ -19,7 +19,7 @@ static inline bool virtio_access_is_big_endian(VirtIODevice *vdev) { - if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { /* Devices conforming to VIRTIO 1.0 or later are always LE. */ return false; } diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index cccae89..6201ee8 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -261,26 +261,27 @@ static inline void virtio_clear_feature(uint64_t *features, unsigned int fbit) *features &= ~(1ULL << fbit); } -static inline bool __virtio_has_feature(uint64_t features, unsigned int fbit) +static inline bool virtio_has_feature(uint64_t features, unsigned int fbit) { assert(fbit < 64); return !!(features & (1ULL << fbit)); } -static inline bool virtio_has_feature(VirtIODevice *vdev, unsigned int fbit) +static inline bool virtio_vdev_has_feature(VirtIODevice *vdev, + unsigned int fbit) { - return __virtio_has_feature(vdev->guest_features, fbit); + return virtio_has_feature(vdev->guest_features, fbit); } static inline bool virtio_host_has_feature(VirtIODevice *vdev, unsigned int fbit) { - return __virtio_has_feature(vdev->host_features, fbit); + return virtio_has_feature(vdev->host_features, fbit); } static inline bool virtio_is_big_endian(VirtIODevice *vdev) { - if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN); return vdev->device_endian == VIRTIO_DEVICE_ENDIAN_BIG; } diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 1556c9c..f9301ae 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -731,7 +731,7 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features, virtio_add_feature(&features, VIRTIO_BLK_F_GEOMETRY); virtio_add_feature(&features, VIRTIO_BLK_F_TOPOLOGY); virtio_add_feature(&features, VIRTIO_BLK_F_BLK_SIZE); - if (__virtio_has_feature(features, VIRTIO_F_VERSION_1)) { + if (virtio_has_feature(features, VIRTIO_F_VERSION_1)) { if (s->conf.scsi) { error_setg(errp, "Please set scsi=off for virtio-blk devices in order to use virtio 1.0"); return 0; @@ -782,10 +782,11 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status) * * s->blk would erroneously be placed in writethrough mode. */ - if (!virtio_has_feature(vdev, VIRTIO_BLK_F_CONFIG_WCE)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_BLK_F_CONFIG_WCE)) { aio_context_acquire(blk_get_aio_context(s->blk)); blk_set_enable_write_cache(s->blk, - virtio_has_feature(vdev, VIRTIO_BLK_F_WCE)); + virtio_vdev_has_feature(vdev, + VIRTIO_BLK_F_WCE)); aio_context_release(blk_get_aio_context(s->blk)); } } diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index bc56f5d..be97058 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -76,7 +76,7 @@ static VirtIOSerialPort *find_port_by_name(char *name) static bool use_multiport(VirtIOSerial *vser) { VirtIODevice *vdev = VIRTIO_DEVICE(vser); - return virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT); + return virtio_vdev_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT); } static size_t write_to_port(VirtIOSerialPort *port, diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 5c1d11f..1d76b94 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -197,7 +197,7 @@ static int vhost_net_set_vnet_endian(VirtIODevice *dev, NetClientState *peer, { int r = 0; - if (virtio_has_feature(dev, VIRTIO_F_VERSION_1) || + if (virtio_vdev_has_feature(dev, VIRTIO_F_VERSION_1) || (virtio_legacy_is_cross_endian(dev) && !virtio_is_big_endian(dev))) { r = qemu_set_vnet_le(peer, set); if (r) { diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 8d28e45..f72eebf 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -86,8 +86,8 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config) memcpy(&netcfg, config, n->config_size); - if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR) && - !virtio_has_feature(vdev, VIRTIO_F_VERSION_1) && + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR) && + !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) && memcmp(netcfg.mac, n->mac, ETH_ALEN)) { memcpy(n->mac, netcfg.mac, ETH_ALEN); qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac); @@ -304,7 +304,7 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc) info->multicast_table = str_list; info->vlan_table = get_vlan_table(n); - if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VLAN)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VLAN)) { info->vlan = RX_STATE_ALL; } else if (!info->vlan_table) { info->vlan = RX_STATE_NONE; @@ -529,13 +529,13 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features) int i; virtio_net_set_multiqueue(n, - __virtio_has_feature(features, VIRTIO_NET_F_MQ)); + virtio_has_feature(features, VIRTIO_NET_F_MQ)); virtio_net_set_mrg_rx_bufs(n, - __virtio_has_feature(features, - VIRTIO_NET_F_MRG_RXBUF), - __virtio_has_feature(features, - VIRTIO_F_VERSION_1)); + virtio_has_feature(features, + VIRTIO_NET_F_MRG_RXBUF), + virtio_has_feature(features, + VIRTIO_F_VERSION_1)); if (n->has_vnet_hdr) { n->curr_guest_offloads = @@ -552,7 +552,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features) vhost_net_ack_features(get_vhost_net(nc->peer), features); } - if (__virtio_has_feature(features, VIRTIO_NET_F_CTRL_VLAN)) { + if (virtio_has_feature(features, VIRTIO_NET_F_CTRL_VLAN)) { memset(n->vlans, 0, MAX_VLAN >> 3); } else { memset(n->vlans, 0xff, MAX_VLAN >> 3); @@ -599,7 +599,7 @@ static int virtio_net_handle_offloads(VirtIONet *n, uint8_t cmd, uint64_t offloads; size_t s; - if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { return VIRTIO_NET_ERR; } @@ -1449,7 +1449,7 @@ static void virtio_net_save_device(VirtIODevice *vdev, QEMUFile *f) } } - if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { qemu_put_be64(f, n->curr_guest_offloads); } } @@ -1475,7 +1475,8 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, n->vqs[0].tx_waiting = qemu_get_be32(f); virtio_net_set_mrg_rx_bufs(n, qemu_get_be32(f), - virtio_has_feature(vdev, VIRTIO_F_VERSION_1)); + virtio_vdev_has_feature(vdev, + VIRTIO_F_VERSION_1)); if (version_id >= 3) n->status = qemu_get_be16(f); @@ -1558,7 +1559,7 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, } } - if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { n->curr_guest_offloads = qemu_get_be64(f); } else { n->curr_guest_offloads = virtio_net_supported_guest_offloads(n); @@ -1585,8 +1586,8 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, qemu_get_subqueue(n->nic, i)->link_down = link_down; } - if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) && - virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) && + virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) { n->announce_counter = SELF_ANNOUNCE_ROUNDS; timer_mod(n->announce_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL)); } diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index a8bb1c6..1c33f14 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -145,7 +145,7 @@ static int virtio_scsi_parse_req(VirtIOSCSIReq *req, * * TODO: always disable this workaround for virtio 1.0 devices. */ - if (!virtio_has_feature(vdev, VIRTIO_F_ANY_LAYOUT)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_F_ANY_LAYOUT)) { if (req->elem.out_num) { req_size = req->elem.out_sg[0].iov_len; } @@ -759,7 +759,7 @@ static void virtio_scsi_change(SCSIBus *bus, SCSIDevice *dev, SCSISense sense) VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus); VirtIODevice *vdev = VIRTIO_DEVICE(s); - if (virtio_has_feature(vdev, VIRTIO_SCSI_F_CHANGE) && + if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_CHANGE) && dev->type != TYPE_ROM) { virtio_scsi_push_event(s, dev, VIRTIO_SCSI_T_PARAM_CHANGE, sense.asc | (sense.ascq << 8)); @@ -783,7 +783,7 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev, aio_context_release(s->ctx); } - if (virtio_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) { virtio_scsi_push_event(s, sd, VIRTIO_SCSI_T_TRANSPORT_RESET, VIRTIO_SCSI_EVT_RESET_RESCAN); @@ -797,7 +797,7 @@ static void virtio_scsi_hotunplug(HotplugHandler *hotplug_dev, DeviceState *dev, VirtIOSCSI *s = VIRTIO_SCSI(vdev); SCSIDevice *sd = SCSI_DEVICE(dev); - if (virtio_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) { virtio_scsi_push_event(s, sd, VIRTIO_SCSI_T_TRANSPORT_RESET, VIRTIO_SCSI_EVT_RESET_REMOVED); diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c index 07fd69c..fece83a 100644 --- a/hw/virtio/dataplane/vring.c +++ b/hw/virtio/dataplane/vring.c @@ -105,7 +105,7 @@ void vring_teardown(Vring *vring, VirtIODevice *vdev, int n) /* Disable guest->host notifies */ void vring_disable_notification(VirtIODevice *vdev, Vring *vring) { - if (!virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_set_used_flags(vdev, vring, VRING_USED_F_NO_NOTIFY); } } @@ -116,7 +116,7 @@ void vring_disable_notification(VirtIODevice *vdev, Vring *vring) */ bool vring_enable_notification(VirtIODevice *vdev, Vring *vring) { - if (virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_avail_event(&vring->vr) = vring->vr.avail->idx; } else { vring_clear_used_flags(vdev, vring, VRING_USED_F_NO_NOTIFY); @@ -135,12 +135,12 @@ bool vring_should_notify(VirtIODevice *vdev, Vring *vring) * interrupts. */ smp_mb(); - if (virtio_has_feature(vdev, VIRTIO_F_NOTIFY_ON_EMPTY) && + if (virtio_vdev_has_feature(vdev, VIRTIO_F_NOTIFY_ON_EMPTY) && unlikely(!vring_more_avail(vdev, vring))) { return true; } - if (!virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { return !(vring_get_avail_flags(vdev, vring) & VRING_AVAIL_F_NO_INTERRUPT); } @@ -402,7 +402,7 @@ int vring_pop(VirtIODevice *vdev, Vring *vring, /* On success, increment avail index. */ vring->last_avail_idx++; - if (virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_avail_event(&vring->vr) = virtio_tswap16(vdev, vring->last_avail_idx); } diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 2712c6f..a08c36b 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -742,7 +742,7 @@ static int vhost_virtqueue_start(struct vhost_dev *dev, return -errno; } - if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1) && + if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) && virtio_legacy_is_cross_endian(vdev)) { r = vhost_virtqueue_set_vring_endian_legacy(dev, virtio_is_big_endian(vdev), @@ -839,7 +839,7 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev, /* In the cross-endian case, we need to reset the vring endianness to * native as legacy devices expect so by default. */ - if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1) && + if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) && virtio_legacy_is_cross_endian(vdev)) { r = vhost_virtqueue_set_vring_endian_legacy(dev, !virtio_is_big_endian(vdev), diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 3577b7a..c419b17 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -70,7 +70,7 @@ static inline void reset_stats(VirtIOBalloon *dev) static bool balloon_stats_supported(const VirtIOBalloon *s) { VirtIODevice *vdev = VIRTIO_DEVICE(s); - return virtio_has_feature(vdev, VIRTIO_BALLOON_F_STATS_VQ); + return virtio_vdev_has_feature(vdev, VIRTIO_BALLOON_F_STATS_VQ); } static bool balloon_stats_enabled(const VirtIOBalloon *s) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 788b556..0832db9 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -220,7 +220,7 @@ static inline void vring_set_avail_event(VirtQueue *vq, uint16_t val) void virtio_queue_set_notification(VirtQueue *vq, int enable) { vq->notification = enable; - if (virtio_has_feature(vq->vdev, VIRTIO_RING_F_EVENT_IDX)) { + if (virtio_vdev_has_feature(vq->vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_set_avail_event(vq, vring_avail_idx(vq)); } else if (enable) { vring_used_flags_unset_bit(vq, VRING_USED_F_NO_NOTIFY); @@ -471,7 +471,7 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem) max = vq->vring.num; i = head = virtqueue_get_head(vq, vq->last_avail_idx++); - if (virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_set_avail_event(vq, vq->last_avail_idx); } @@ -560,7 +560,7 @@ int virtio_set_status(VirtIODevice *vdev, uint8_t val) VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); trace_virtio_set_status(vdev, val); - if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { if (!(vdev->status & VIRTIO_CONFIG_S_FEATURES_OK) && val & VIRTIO_CONFIG_S_FEATURES_OK) { int ret = virtio_validate_features(vdev); @@ -898,7 +898,7 @@ void virtio_queue_set_align(VirtIODevice *vdev, int n, int align) VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); /* virtio-1 compliant devices cannot change the alignment */ - if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { error_report("tried to modify queue alignment for virtio-1 device"); return; } @@ -993,12 +993,12 @@ static bool vring_notify(VirtIODevice *vdev, VirtQueue *vq) /* We need to expose used array entries before checking used event. */ smp_mb(); /* Always notify when queue is empty (when feature acknowledge) */ - if (virtio_has_feature(vdev, VIRTIO_F_NOTIFY_ON_EMPTY) && + if (virtio_vdev_has_feature(vdev, VIRTIO_F_NOTIFY_ON_EMPTY) && !vq->inuse && vring_avail_idx(vq) == vq->last_avail_idx) { return true; } - if (!virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { return !(vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT); } @@ -1035,7 +1035,7 @@ static bool virtio_device_endian_needed(void *opaque) VirtIODevice *vdev = opaque; assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN); - if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { return vdev->device_endian != virtio_default_endian(); } /* Devices conforming to VIRTIO 1.0 or later are always LE. */ -- MST From MAILER-DAEMON Thu Sep 10 05:42:55 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZyNb-0002kx-EF for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 05:42:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyNY-0002fS-Ip for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:42:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZyNV-0001U6-5k for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:42:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyNU-0001TW-VT; Thu, 10 Sep 2015 05:42:49 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id A5A538E698; Thu, 10 Sep 2015 09:42:48 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-61.ams2.redhat.com [10.36.116.61]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8A9gkVg000470 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 10 Sep 2015 05:42:48 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 28E033001102; Thu, 10 Sep 2015 11:42:46 +0200 (CEST) From: Markus Armbruster To: John Snow References: <1440623592-13999-1-git-send-email-jsnow@redhat.com> <1440623592-13999-4-git-send-email-jsnow@redhat.com> Date: Thu, 10 Sep 2015 11:42:46 +0200 In-Reply-To: <1440623592-13999-4-git-send-email-jsnow@redhat.com> (John Snow's message of "Wed, 26 Aug 2015 17:13:11 -0400") Message-ID: <87d1xq7gq1.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, zuban32s@gmail.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 3/4] ide-test: add cdrom pio test X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 09:42:54 -0000 John Snow writes: > Add a simple read test for ATAPI devices, > using the PIO mechanism. > > Signed-off-by: John Snow > --- > tests/ide-test.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 144 insertions(+) > > diff --git a/tests/ide-test.c b/tests/ide-test.c > index 4a07e3a..90524e3 100644 > --- a/tests/ide-test.c > +++ b/tests/ide-test.c > @@ -45,6 +45,12 @@ > #define IDE_BASE 0x1f0 > #define IDE_PRIMARY_IRQ 14 > > +#define ATAPI_BLOCK_SIZE 2048 > + > +/* How many bytes to receive via ATAPI PIO at one time. > + * Must be less than 0xFFFF. */ > +#define BYTE_COUNT_LIMIT 5120 > + > enum { > reg_data = 0x0, > reg_nsectors = 0x2, > @@ -80,6 +86,7 @@ enum { > CMD_WRITE_DMA = 0xca, > CMD_FLUSH_CACHE = 0xe7, > CMD_IDENTIFY = 0xec, > + CMD_PACKET = 0xa0, > > CMDF_ABORT = 0x100, > CMDF_NO_BM = 0x200, > @@ -585,6 +592,140 @@ static void test_isa_retry_flush(const char *machine) > test_retry_flush("isapc"); > } > > +typedef struct Read10CDB { > + uint8_t opcode; > + uint8_t flags; > + uint32_t lba; > + uint8_t reserved; > + uint16_t nblocks; > + uint8_t control; > + uint16_t padding; > +} __attribute__((__packed__)) Read10CDB; > + > +static void send_scsi_cdb_read10(uint32_t lba, uint16_t nblocks) > +{ > + Read10CDB pkt = { .padding = 0 }; > + int i; > + > + /* Construct SCSI CDB packet */ > + pkt.opcode = 0x28; > + pkt.lba = cpu_to_be32(lba); > + pkt.nblocks = cpu_to_be16(nblocks); > + > + /* Send Packet */ > + for (i = 0; i < sizeof(Read10CDB)/2; i++) { > + outw(IDE_BASE + reg_data, ((uint16_t *)&pkt)[i]); Requires pkt to be suitable aligned. It is. > + } > +} > + > +static void nsleep(int64_t nsecs) > +{ > + const struct timespec val = { .tv_nsec = nsecs }; > + nanosleep(&val, NULL); > + clock_set(nsecs); > +} > + > +static uint8_t ide_wait_clear(uint8_t flag) > +{ > + int i; > + uint8_t data; > + > + /* Wait with a 5 second timeout */ > + for (i = 0; i <= 12500000; i++) { > + data = inb(IDE_BASE + reg_status); > + if (!(data & flag)) { > + return data; > + } > + nsleep(400); > + } > + g_assert_not_reached(); > + return 0xff; Unreachable code, not needed as long as g_assert_not_reached() is properly annotated noreturn. > +} > + > +static void cdrom_pio_impl(int nblocks) > +{ > + FILE *fh; > + size_t patt_len = ATAPI_BLOCK_SIZE * MAX(16, nblocks); > + char *pattern = g_malloc(patt_len); > + size_t rxsize = ATAPI_BLOCK_SIZE * nblocks; > + char *rx = g_malloc0(rxsize); > + int i, j; > + uint8_t data; > + uint16_t limit; > + > + /* Prepopulate the CDROM with an interesting pattern */ > + generate_pattern(pattern, patt_len, ATAPI_BLOCK_SIZE); > + fh = fopen(tmp_path, "w+"); > + fwrite(pattern, ATAPI_BLOCK_SIZE, MAX(16, nblocks), fh); I guess I would've avoided repeating MAX(16, nblocks), but it'll do. > + fclose(fh); > + > + ide_test_start( > + "-drive file=%s,if=ide,media=cdrom,cache=writeback,format=raw", tmp_path); Legacy syntax. Okay. > + qtest_irq_intercept_in(global_qtest, "ioapic"); > + > + /* PACKET command on device 0 */ > + outb(IDE_BASE + reg_device, 0); > + outb(IDE_BASE + reg_lba_middle, BYTE_COUNT_LIMIT & 0xFF); > + outb(IDE_BASE + reg_lba_high, (BYTE_COUNT_LIMIT >> 8 & 0xFF)); > + outb(IDE_BASE + reg_command, CMD_PACKET); Ignorant question: why no reg_lba_low? > + /* HPD0: Check_Status_A State */ > + nsleep(400); > + data = ide_wait_clear(BSY); Ignorant question: why do you need to wait 400ns before you wait? > + /* HPD1: Send_Packet State */ > + assert_bit_set(data, DRQ | DRDY); > + assert_bit_clear(data, ERR | DF | BSY); > + > + /* SCSI CDB (READ10) -- read n*2048 bytes from block 0 */ > + send_scsi_cdb_read10(0, nblocks); > + > + /* HPD3: INTRQ_Wait */ > + i = 0; > + do { > + data = get_irq(IDE_PRIMARY_IRQ); > + nsleep(400); > + i++; > + g_assert_cmpint(i, <=, 12500000); > + } while (!data); Similar to ide_wait_clear(). Why do you need to nsleep() after get_irq() returned non-zero? > + > + /* HPD2: Check_Status_B */ > + data = ide_wait_clear(BSY); > + assert_bit_set(data, DRQ | DRDY); > + assert_bit_clear(data, ERR | DF | BSY); > + > + /* Read data back: occurs in bursts of 'BYTE_COUNT_LIMIT' bytes. > + * If BYTE_COUNT_LIMIT is odd, we transfer BYTE_COUNT_LIMIT - 1 bytes. > + * We allow an odd limit only when the remaining transfer size is > + * less than BYTE_COUNT_LIMIT. > + * For our purposes, we can only request even multiples, so do not > + * attempt to read remainders. */ > + limit = BYTE_COUNT_LIMIT & ~1; Does nothing, BYTE_COUNT_LIMIT is 5120. Build-time assertion !(BYTE_COUNT_LIMIT & 1) would do. > + for (i = 0; i < DIV_ROUND_UP(rxsize, limit); i++) { > + size_t r = (rxsize - (limit * i)) / 2; > + for (j = 0; j < MIN((limit / 2), r); j++) { > + ((uint16_t *)rx)[(i * (limit/2)) + j] = inw(IDE_BASE + reg_data); Would be more readable with uint16_t *rx. Only if it doesn't require casts elsewhere. I guess I would've tried a single loop instead of nesting two. But since this works, keep it. > + } > + } > + data = ide_wait_clear(DRQ); > + assert_bit_set(data, DRDY); > + assert_bit_clear(data, DRQ | ERR | DF | BSY); > + > + g_assert_cmpint(memcmp(pattern, rx, rxsize), ==, 0); > + g_free(pattern); > + g_free(rx); > + test_bmdma_teardown(); > +} > + > +static void test_cdrom_pio(void) > +{ > + cdrom_pio_impl(1); > +} > + > +static void test_cdrom_pio_large(void) > +{ > + /* Test a few loops of the PIO DRQ mechanism. */ > + cdrom_pio_impl(BYTE_COUNT_LIMIT * 4 / ATAPI_BLOCK_SIZE); > +} > + > int main(int argc, char **argv) > { > const char *arch = qtest_get_arch(); > @@ -628,6 +769,9 @@ int main(int argc, char **argv) > qtest_add_func("/ide/flush/retry_pci", test_pci_retry_flush); > qtest_add_func("/ide/flush/retry_isa", test_isa_retry_flush); > > + qtest_add_func("/ide/cdrom/pio", test_cdrom_pio); > + qtest_add_func("/ide/cdrom/pio_large", test_cdrom_pio_large); > + > ret = g_test_run(); > > /* Cleanup */ From MAILER-DAEMON Thu Sep 10 05:56:10 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZyaQ-00087Z-01 for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 05:56:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyaJ-0007tl-Mr for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:56:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZyaI-0008J9-QA for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:56:03 -0400 Received: from [59.151.112.132] (port=28716 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyaC-0008GC-SE; Thu, 10 Sep 2015 05:55:57 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100563394" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 10 Sep 2015 17:58:50 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8A9teJS001055; Thu, 10 Sep 2015 17:55:40 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 10 Sep 2015 17:55:53 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Thu, 10 Sep 2015 17:55:01 +0800 Message-ID: <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 09:56:05 -0000 The NBD driver needs: filename, path or (host, port, exportname). It checks which key exists and decides use unix or inet socket. It doesn't recognize the key type, so we can't use union, and can't reuse InetSocketAddress. Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 11134a8..e68a59f 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1376,12 +1376,14 @@ # # @host_device, @host_cdrom: Since 2.1 # +# @nbd: Since 2.5 +# # Since: 2.0 ## { 'enum': 'BlockdevDriver', 'data': [ 'archipelago', 'blkdebug', 'blkverify', 'bochs', 'cloop', 'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device', - 'http', 'https', 'null-aio', 'null-co', 'parallels', + 'http', 'https', 'nbd', 'null-aio', 'null-co', 'parallels', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] } @@ -1797,6 +1799,42 @@ '*read-pattern': 'QuorumReadPattern' } } ## +# @BlockdevOptionsNBD +# +# Driver specific block device options for NBD +# +# @filename: #optional unix or inet path. The format is: +# unix: nbd+unix:///export?socket=path or +# nbd:unix:path:exportname=export +# inet: nbd[+tcp]://host[:port]/export or +# nbd:host[:port]:exportname=export +# +# @path: #optional filesystem path to use +# +# @host: #optional host part of the address +# +# @port: #optional port part of the address +# +# @ipv4: #optional whether to accept IPv4 addresses, default try both IPv4 +# and IPv6 +# +# @ipv6: #optional whether to accept IPv6 addresses, default try both IPv4 +# and IPv6 +# +# @export: #optional the NBD export name +# +# Since: 2.5 +## +{ 'struct': 'BlockdevOptionsNBD', + 'data': { '*filename': 'str', + '*path': 'str', + '*host': 'str', + '*port': 'str', + '*ipv4': 'bool', + '*ipv6': 'bool', + '*export': 'str' } } + +## # @BlockdevOptions # # Options for creating a block device. @@ -1822,7 +1860,7 @@ 'http': 'BlockdevOptionsFile', 'https': 'BlockdevOptionsFile', # TODO iscsi: Wait for structured options -# TODO nbd: Should take InetSocketAddress for 'host'? + 'nbd': 'BlockdevOptionsNBD', # TODO nfs: Wait for structured options 'null-aio': 'BlockdevOptionsNull', 'null-co': 'BlockdevOptionsNull', -- 2.4.3 From MAILER-DAEMON Thu Sep 10 05:56:12 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZyaS-0008D1-GX for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 05:56:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyaN-00081i-Co for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:56:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZyaJ-0008JU-9C for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:56:07 -0400 Received: from [59.151.112.132] (port=30822 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyaF-0008HI-Kz; Thu, 10 Sep 2015 05:56:00 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100563403" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 10 Sep 2015 17:58:53 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8A9tiBF001069; Thu, 10 Sep 2015 17:55:44 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 10 Sep 2015 17:55:56 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Thu, 10 Sep 2015 17:55:04 +0800 Message-ID: <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 09:56:11 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- blockdev.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ qapi/block-core.json | 34 +++++++++++++++++++++++++++++++++ qmp-commands.hx | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+) diff --git a/blockdev.c b/blockdev.c index bd47756..0a40607 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3413,6 +3413,53 @@ fail: qmp_output_visitor_cleanup(ov); } +void qmp_x_child_add(const char *parent, const char *child, + Error **errp) +{ + BlockDriverState *parent_bs, *child_bs; + Error *local_err = NULL; + + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); + if (!parent_bs) { + error_propagate(errp, local_err); + return; + } + + child_bs = bdrv_find_node(child); + if (!child_bs) { + error_setg(errp, "Node '%s' not found", child); + return; + } + + bdrv_add_child(parent_bs, child_bs, &local_err); + if (local_err) { + error_propagate(errp, local_err); + } +} + +void qmp_child_del(const char *parent, const char *child, Error **errp) +{ + BlockDriverState *parent_bs, *child_bs; + Error *local_err = NULL; + + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); + if (!parent_bs) { + error_propagate(errp, local_err); + return; + } + + child_bs = bdrv_find_node(child); + if (!child_bs) { + error_setg(errp, "Node '%s' not found", child); + return; + } + + bdrv_del_child(parent_bs, child_bs, &local_err); + if (local_err) { + error_propagate(errp, local_err); + } +} + BlockJobInfoList *qmp_query_block_jobs(Error **errp) { BlockJobInfoList *head = NULL, **p_next = &head; diff --git a/qapi/block-core.json b/qapi/block-core.json index e68a59f..b959577 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2272,3 +2272,37 @@ ## { 'command': 'block-set-write-threshold', 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } + +## +# @x-child-add +# +# Add a new child to the parent BDS. Currently only the Quorum driver +# implements this feature. This is useful to fix a broken quorum child. +# +# @parent: graph node name or id which the child will be added to. +# +# @child: graph node name that will be added. +# +# Note: this command is experimental, and not a stable API. +# +# Since: 2.5 +## +{ 'command': 'x-child-add', + 'data' : { 'parent': 'str', 'child': 'str' } } + +## +# @child-del +# +# Remove a child from the parent BDS. Currently only the Quorum driver +# implements this feature. This is useful to fix a broken quorum child. +# Note, you can't remove a child if it would bring the quorum below its +# threshold. +# +# @parent: graph node name or id from which the child will removed. +# +# @child: graph node name that will be removed. +# +# Since: 2.5 +## +{ 'command': 'child-del', + 'data' : { 'parent': 'str', 'child': 'str' } } diff --git a/qmp-commands.hx b/qmp-commands.hx index 495670b..139a23b 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -4053,6 +4053,59 @@ Example: EQMP { + .name = "x-child-add", + .args_type = "parent:B,child:B", + .mhandler.cmd_new = qmp_marshal_input_x_child_add, + }, + +SQMP +x-child-add +------------ + +Add a child to a quorum node. + +Arguments: + +- "parent": the quorum's id or node name +- "child": the child node-name which will be added + +Note: this command is experimental, and not a stable API. + +Example: + +-> { "execute": "x-child-add", + "arguments": { "parent": "disk1", "child": "new_node" } } +<- { "return": {} } + +EQMP + + { + .name = "child-del", + .args_type = "parent:B,child:B", + .mhandler.cmd_new = qmp_marshal_input_child_del, + }, + +SQMP +child-del +------------ + +Delete a child from a quorum node. It can be used to remove a broken +quorum child. + +Arguments: + +- "parent": the quorum's id or node name +- "child": the child node-name which will be removed + +Example: + +-> { "execute": "child-del", + "arguments": { "parent": "disk1", "child": "new_node" } } +<- { "return": {} } + +EQMP + + { .name = "query-named-block-nodes", .args_type = "", .mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes, -- 2.4.3 From MAILER-DAEMON Thu Sep 10 05:56:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZyaT-0008Fe-LK for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 05:56:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyaN-00082F-Ic for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:56:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZyaM-0008Kj-Ey for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:56:07 -0400 Received: from [59.151.112.132] (port=57034 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyaF-0008G7-0i; Thu, 10 Sep 2015 05:56:00 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100563400" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 10 Sep 2015 17:58:52 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8A9tgMt001065; Thu, 10 Sep 2015 17:55:43 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 10 Sep 2015 17:55:55 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Thu, 10 Sep 2015 17:55:03 +0800 Message-ID: <1441878905-5272-4-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v3 3/5] quorum: implement bdrv_add_child() and bdrv_del_child() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 09:56:12 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block.c | 6 ++--- block/quorum.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++-- include/block/block.h | 3 +++ 3 files changed, 76 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 682d2ec..6ffd27b 100644 --- a/block.c +++ b/block.c @@ -1100,9 +1100,9 @@ static int bdrv_fill_options(QDict **options, const char **pfilename, return 0; } -static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, - BlockDriverState *child_bs, - const BdrvChildRole *child_role) +BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, + BlockDriverState *child_bs, + const BdrvChildRole *child_role) { BdrvChild *child = g_new(BdrvChild, 1); *child = (BdrvChild) { diff --git a/block/quorum.c b/block/quorum.c index 72183d6..13e33ad 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -66,6 +66,9 @@ typedef struct QuorumVotes { typedef struct BDRVQuorumState { BlockDriverState **bs; /* children BlockDriverStates */ int num_children; /* children count */ + int max_children; /* The maximum children count, we need to reallocate + * bs if num_children grows larger than maximum. + */ int threshold; /* if less than threshold children reads gave the * same result a quorum error occurs. */ @@ -874,9 +877,9 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, ret = -EINVAL; goto exit; } - if (s->num_children < 2) { + if (s->num_children < 1) { error_setg(&local_err, - "Number of provided children must be greater than 1"); + "Number of provided children must be 1 or more"); ret = -EINVAL; goto exit; } @@ -925,6 +928,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, /* allocate the children BlockDriverState array */ s->bs = g_new0(BlockDriverState *, s->num_children); opened = g_new0(bool, s->num_children); + s->max_children = s->num_children; for (i = 0; i < s->num_children; i++) { char indexstr[32]; @@ -995,6 +999,67 @@ static void quorum_attach_aio_context(BlockDriverState *bs, } } +static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs, + Error **errp) +{ + BDRVQuorumState *s = bs->opaque; + + bdrv_drain(bs); + + if (s->num_children == s->max_children) { + if (s->max_children >= INT_MAX) { + error_setg(errp, "Too many children"); + return; + } + + s->bs = g_renew(BlockDriverState *, s->bs, s->max_children + 1); + s->bs[s->num_children] = NULL; + s->max_children++; + } + + bdrv_ref(child_bs); + bdrv_attach_child(bs, child_bs, &child_format); + s->bs[s->num_children++] = child_bs; +} + +static void quorum_del_child(BlockDriverState *bs, BlockDriverState *child_bs, + Error **errp) +{ + BDRVQuorumState *s = bs->opaque; + BdrvChild *child; + int i; + + for (i = 0; i < s->num_children; i++) { + if (s->bs[i] == child_bs) { + break; + } + } + + QLIST_FOREACH(child, &bs->children, next) { + if (child->bs == child_bs) { + break; + } + } + + /* we have checked it in bdrv_del_child() */ + assert(i < s->num_children && child); + + if (s->num_children <= s->threshold) { + error_setg(errp, + "The number of children cannot be lower than the vote threshold %d", + s->threshold); + return; + } + + bdrv_drain(bs); + /* We can safely remove this child now */ + memmove(&s->bs[i], &s->bs[i + 1], + (s->num_children - i - 1) * sizeof(void *)); + s->num_children--; + s->bs[s->num_children] = NULL; + bdrv_unref_child(bs, child); +} + static void quorum_refresh_filename(BlockDriverState *bs) { BDRVQuorumState *s = bs->opaque; @@ -1063,6 +1128,9 @@ static BlockDriver bdrv_quorum = { .bdrv_detach_aio_context = quorum_detach_aio_context, .bdrv_attach_aio_context = quorum_attach_aio_context, + .bdrv_add_child = quorum_add_child, + .bdrv_del_child = quorum_del_child, + .is_filter = true, .bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter, diff --git a/include/block/block.h b/include/block/block.h index 8480af7..97188b1 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -503,6 +503,9 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs); void bdrv_ref(BlockDriverState *bs); void bdrv_unref(BlockDriverState *bs); void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child); +BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, + BlockDriverState *child_bs, + const BdrvChildRole *child_role); bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp); void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason); -- 2.4.3 From MAILER-DAEMON Thu Sep 10 05:56:10 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZyaQ-00088i-I4 for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 05:56:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyaJ-0007uT-Vu for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:56:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZyaJ-0008JN-51 for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:56:03 -0400 Received: from [59.151.112.132] (port=57219 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyaF-0008HK-QR; Thu, 10 Sep 2015 05:56:00 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100563406" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 10 Sep 2015 17:58:54 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8A9tj6K001074; Thu, 10 Sep 2015 17:55:45 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 10 Sep 2015 17:55:58 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Thu, 10 Sep 2015 17:55:05 +0800 Message-ID: <1441878905-5272-6-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Luiz Capitulino , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v3 5/5] hmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 09:56:05 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Cc: Luiz Capitulino --- hmp-commands.hx | 28 ++++++++++++++++++++++++++++ hmp.c | 20 ++++++++++++++++++++ hmp.h | 2 ++ 3 files changed, 50 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index fece64f..bd365bb 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -193,6 +193,34 @@ actions (drive options rerror, werror). ETEXI { + .name = "child_add", + .args_type = "id:B,child:B", + .params = "parent child", + .help = "add a child to a BDS", + .mhandler.cmd = hmp_child_add, + }, + +STEXI +@item child_add @var{parent device} @var{child device} +@findex child_add +Add a child to the block device. +ETEXI + + { + .name = "child_del", + .args_type = "id:B,child:B", + .params = "parent child", + .help = "remove a child from a BDS", + .mhandler.cmd = hmp_child_del, + }, + +STEXI +@item child_del @var{parent device} @var{child device} +@findex child_del +Remove a child from the parent device. +ETEXI + + { .name = "change", .args_type = "device:B,target:F,arg:s?,read-only-mode:s?", .params = "device filename [format [read-only-mode]]", diff --git a/hmp.c b/hmp.c index 6e2bbc8..0d6f6c9 100644 --- a/hmp.c +++ b/hmp.c @@ -2348,3 +2348,23 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict) qapi_free_RockerOfDpaGroupList(list); } + +void hmp_child_add(Monitor *mon, const QDict *qdict) +{ + const char *id = qdict_get_str(qdict, "id"); + const char *child_id = qdict_get_str(qdict, "child"); + Error *local_err = NULL; + + qmp_x_child_add(id, child_id, &local_err); + hmp_handle_error(mon, &local_err); +} + +void hmp_child_del(Monitor *mon, const QDict *qdict) +{ + const char *id = qdict_get_str(qdict, "id"); + const char *child_id = qdict_get_str(qdict, "child"); + Error *local_err = NULL; + + qmp_child_del(id, child_id, &local_err); + hmp_handle_error(mon, &local_err); +} diff --git a/hmp.h b/hmp.h index 81656c3..5bd780c 100644 --- a/hmp.h +++ b/hmp.h @@ -130,5 +130,7 @@ void hmp_rocker(Monitor *mon, const QDict *qdict); void hmp_rocker_ports(Monitor *mon, const QDict *qdict); void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict); void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict); +void hmp_child_add(Monitor *mon, const QDict *qdict); +void hmp_child_del(Monitor *mon, const QDict *qdict); #endif -- 2.4.3 From MAILER-DAEMON Thu Sep 10 05:56:10 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZyaQ-00089J-QJ for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 05:56:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyaJ-0007tn-Mv for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:56:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZyaI-0008J4-Pd for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:56:03 -0400 Received: from [59.151.112.132] (port=2286 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyaC-0008GN-N1; Thu, 10 Sep 2015 05:55:57 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100563395" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 10 Sep 2015 17:58:51 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8A9tfVY001060; Thu, 10 Sep 2015 17:55:41 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 10 Sep 2015 17:55:54 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Thu, 10 Sep 2015 17:55:02 +0800 Message-ID: <1441878905-5272-3-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v3 2/5] Add new block driver interface to add/delete a BDS's child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 09:56:06 -0000 In some cases, we want to take a quorum child offline, and take another child online. Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++ include/block/block.h | 5 +++++ include/block/block_int.h | 5 +++++ 3 files changed, 62 insertions(+) diff --git a/block.c b/block.c index d004bd0..682d2ec 100644 --- a/block.c +++ b/block.c @@ -4115,3 +4115,55 @@ void bdrv_refresh_filename(BlockDriverState *bs) QDECREF(json); } } + +/* + * Hot add/remove a BDS's child. So the user can take a child offline when + * it is broken and take a new child online + */ +void bdrv_add_child(BlockDriverState *parent_bs, BlockDriverState *child_bs, + Error **errp) +{ + + if (!parent_bs->drv || !parent_bs->drv->bdrv_add_child) { + error_setg(errp, "The BDS %s doesn't support adding a child", + bdrv_get_device_or_node_name(parent_bs)); + return; + } + + if (child_bs->blk) { + error_setg(errp, "The BDS %s is used by the block device %s", + child_bs->node_name, blk_name(child_bs->blk)); + return; + } + + /* TODO: check if the child bs has parent */ + + parent_bs->drv->bdrv_add_child(parent_bs, child_bs, errp); +} + +void bdrv_del_child(BlockDriverState *parent_bs, BlockDriverState *child_bs, + Error **errp) +{ + BdrvChild *child; + + if (!parent_bs->drv || !parent_bs->drv->bdrv_del_child) { + error_setg(errp, "The BDS %s doesn't support removing a child", + bdrv_get_device_or_node_name(parent_bs)); + return; + } + + QLIST_FOREACH(child, &parent_bs->children, next) { + if (child->bs == child_bs) { + break; + } + } + + if (!child) { + error_setg(errp, "The BDS %s is not the BDS %s's child", + bdrv_get_device_or_node_name(child_bs), + bdrv_get_device_or_node_name(parent_bs)); + return; + } + + parent_bs->drv->bdrv_del_child(parent_bs, child_bs, errp); +} diff --git a/include/block/block.h b/include/block/block.h index a4e31af..8480af7 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -603,4 +603,9 @@ void bdrv_io_plug(BlockDriverState *bs); void bdrv_io_unplug(BlockDriverState *bs); void bdrv_flush_io_queue(BlockDriverState *bs); +void bdrv_add_child(BlockDriverState *parent, BlockDriverState *child, + Error **errp); +void bdrv_del_child(BlockDriverState *parent, BlockDriverState *child, + Error **errp); + #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index ca1eefa..b4d5250 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -288,6 +288,11 @@ struct BlockDriver { */ int (*bdrv_probe_geometry)(BlockDriverState *bs, HDGeometry *geo); + void (*bdrv_add_child)(BlockDriverState *parent, BlockDriverState *child, + Error **errp); + void (*bdrv_del_child)(BlockDriverState *parent, BlockDriverState *child, + Error **errp); + QLIST_ENTRY(BlockDriver) list; }; -- 2.4.3 From MAILER-DAEMON Thu Sep 10 05:56:10 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZyaQ-000885-DC for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 05:56:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyaK-0007uj-2L for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:56:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZyaJ-0008JH-2I for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:56:04 -0400 Received: from [59.151.112.132] (port=57034 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyaC-0008G7-JN; Thu, 10 Sep 2015 05:55:56 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100563390" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 10 Sep 2015 17:58:48 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8A9tdbQ001052; Thu, 10 Sep 2015 17:55:39 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 10 Sep 2015 17:55:51 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Thu, 10 Sep 2015 17:55:00 +0800 Message-ID: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Yang Hongyang Subject: [Qemu-block] [PATCH v3 0/5] qapi: child add/delete support X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 09:56:05 -0000 If quorum's child is broken, we can use mirror job to replace it. But sometimes, the user only need to remove the broken child, and add it later when the problem is fixed. ChangLog: v3: 1. Don't open BDS in bdrv_add_child(). Use the existing BDS which is created by the QMP command blockdev-add. 2. The driver NBD can support filename, path, host:port now. v2: 1. Use bdrv_get_device_or_node_name() instead of new function bdrv_get_id_or_node_name() 2. Update the error message 3. Update the documents in block-core.json Wen Congyang (5): support nbd driver in blockdev-add Add new block driver interface to add/delete a BDS's child quorum: implement bdrv_add_child() and bdrv_del_child() qmp: add monitor command to add/remove a child hmp: add monitor command to add/remove a child block.c | 58 ++++++++++++++++++++++++++++++++++-- block/quorum.c | 72 ++++++++++++++++++++++++++++++++++++++++++-- blockdev.c | 47 +++++++++++++++++++++++++++++ hmp-commands.hx | 28 +++++++++++++++++ hmp.c | 20 +++++++++++++ hmp.h | 2 ++ include/block/block.h | 8 +++++ include/block/block_int.h | 5 ++++ qapi/block-core.json | 76 +++++++++++++++++++++++++++++++++++++++++++++-- qmp-commands.hx | 53 +++++++++++++++++++++++++++++++++ 10 files changed, 362 insertions(+), 7 deletions(-) -- 2.4.3 From MAILER-DAEMON Thu Sep 10 05:59:49 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZydx-0005g4-Qf for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 05:59:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZydv-0005bg-Dm for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:59:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZydr-0002Ht-An for qemu-block@nongnu.org; Thu, 10 Sep 2015 05:59:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51839) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZydr-0002Hl-6W; Thu, 10 Sep 2015 05:59:43 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id CA21491C24; Thu, 10 Sep 2015 09:59:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-61.ams2.redhat.com [10.36.116.61]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8A9xfD4003128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 10 Sep 2015 05:59:42 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 704BC3001102; Thu, 10 Sep 2015 11:59:40 +0200 (CEST) From: Markus Armbruster To: John Snow References: <1440623592-13999-1-git-send-email-jsnow@redhat.com> <55F0602C.20207@redhat.com> <55F065B2.30509@redhat.com> <55F066B2.50907@redhat.com> Date: Thu, 10 Sep 2015 11:59:40 +0200 In-Reply-To: <55F066B2.50907@redhat.com> (John Snow's message of "Wed, 9 Sep 2015 13:04:50 -0400") Message-ID: <87bnda7fxv.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, zuban32s@gmail.com, qemu-devel@nongnu.org, stefanha@redhat.com, Paolo Bonzini Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 0/4] ide: simple ATAPI tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 09:59:48 -0000 John Snow writes: > On 09/09/2015 01:00 PM, Paolo Bonzini wrote: >> >> >> On 09/09/2015 18:37, John Snow wrote: >>> Ping -- apologies. :) >>> >>> I'll take a simple ACK before I merge it into my tree. >> >> I don't think you need one. :) >> >> Paolo >> > > I guess technically not, but I like when somebody at least takes a peek > before I just brazenly send pullreqs. > > I haven't achieved the level of ATA COWBOY yet. I like the prudent attitude. For tests, however, you can lower the bar a bit. Anyway, it looks sane to me. From MAILER-DAEMON Thu Sep 10 06:05:16 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZyjE-0001qZ-N5 for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 06:05:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyj7-0001mP-1U for qemu-block@nongnu.org; Thu, 10 Sep 2015 06:05:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZyj3-0005XS-Cy for qemu-block@nongnu.org; Thu, 10 Sep 2015 06:05:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41674) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZyj3-0005WA-5r; Thu, 10 Sep 2015 06:05:05 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 410742B786B; Thu, 10 Sep 2015 10:05:04 +0000 (UTC) Received: from redhat.com (vpn1-5-225.ams2.redhat.com [10.36.5.225]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8AA4xD4010633 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 10 Sep 2015 06:05:01 -0400 Date: Thu, 10 Sep 2015 11:04:58 +0100 From: "Daniel P. Berrange" To: Wen Congyang Message-ID: <20150910100458.GJ11366@redhat.com> References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , Markus Armbruster , Gonglei , Stefan Hajnoczi , Yang Hongyang , "Dr. David Alan Gilbert" Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 10:05:15 -0000 On Thu, Sep 10, 2015 at 05:55:04PM +0800, Wen Congyang wrote: > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei > --- > blockdev.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ > qapi/block-core.json | 34 +++++++++++++++++++++++++++++++++ > qmp-commands.hx | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 134 insertions(+) > > diff --git a/qapi/block-core.json b/qapi/block-core.json > index e68a59f..b959577 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -2272,3 +2272,37 @@ > ## > { 'command': 'block-set-write-threshold', > 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } > + > +## > +# @x-child-add > +# > +# Add a new child to the parent BDS. Currently only the Quorum driver > +# implements this feature. This is useful to fix a broken quorum child. > +# > +# @parent: graph node name or id which the child will be added to. > +# > +# @child: graph node name that will be added. > +# > +# Note: this command is experimental, and not a stable API. > +# > +# Since: 2.5 > +## > +{ 'command': 'x-child-add', > + 'data' : { 'parent': 'str', 'child': 'str' } } > + > +## > +# @child-del > +# > +# Remove a child from the parent BDS. Currently only the Quorum driver > +# implements this feature. This is useful to fix a broken quorum child. > +# Note, you can't remove a child if it would bring the quorum below its > +# threshold. > +# > +# @parent: graph node name or id from which the child will removed. > +# > +# @child: graph node name that will be removed. > +# > +# Since: 2.5 > +## > +{ 'command': 'child-del', > + 'data' : { 'parent': 'str', 'child': 'str' } } These command names are faaaar too generic. If this only applies to block devices, then I'd expect something like 'block' as a prefix for the command names. Likewise with your next hmp patch Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From MAILER-DAEMON Thu Sep 10 06:35:16 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZZzCG-0002ZN-LW for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 06:35:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZzCE-0002Ug-OH for qemu-block@nongnu.org; Thu, 10 Sep 2015 06:35:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZzCB-0004lK-IY for qemu-block@nongnu.org; Thu, 10 Sep 2015 06:35:14 -0400 Received: from [59.151.112.132] (port=6029 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZzCB-0004kk-6s; Thu, 10 Sep 2015 06:35:11 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100564812" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 10 Sep 2015 18:38:02 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8AAYqBT002895; Thu, 10 Sep 2015 18:34:53 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Thu, 10 Sep 2015 18:35:05 +0800 To: "Daniel P. Berrange" References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> <20150910100458.GJ11366@redhat.com> From: Wen Congyang Message-ID: <55F15CA0.9060306@cn.fujitsu.com> Date: Thu, 10 Sep 2015 18:34:08 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150910100458.GJ11366@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , Markus Armbruster , Gonglei , Stefan Hajnoczi , Yang Hongyang , "Dr. David Alan Gilbert" Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 10:35:15 -0000 On 09/10/2015 06:04 PM, Daniel P. Berrange wrote: > On Thu, Sep 10, 2015 at 05:55:04PM +0800, Wen Congyang wrote: >> Signed-off-by: Wen Congyang >> Signed-off-by: zhanghailiang >> Signed-off-by: Gonglei >> --- >> blockdev.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ >> qapi/block-core.json | 34 +++++++++++++++++++++++++++++++++ >> qmp-commands.hx | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 3 files changed, 134 insertions(+) >> >> diff --git a/qapi/block-core.json b/qapi/block-core.json >> index e68a59f..b959577 100644 >> --- a/qapi/block-core.json >> +++ b/qapi/block-core.json >> @@ -2272,3 +2272,37 @@ >> ## >> { 'command': 'block-set-write-threshold', >> 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } >> + >> +## >> +# @x-child-add >> +# >> +# Add a new child to the parent BDS. Currently only the Quorum driver >> +# implements this feature. This is useful to fix a broken quorum child. >> +# >> +# @parent: graph node name or id which the child will be added to. >> +# >> +# @child: graph node name that will be added. >> +# >> +# Note: this command is experimental, and not a stable API. >> +# >> +# Since: 2.5 >> +## >> +{ 'command': 'x-child-add', >> + 'data' : { 'parent': 'str', 'child': 'str' } } >> + >> +## >> +# @child-del >> +# >> +# Remove a child from the parent BDS. Currently only the Quorum driver >> +# implements this feature. This is useful to fix a broken quorum child. >> +# Note, you can't remove a child if it would bring the quorum below its >> +# threshold. >> +# >> +# @parent: graph node name or id from which the child will removed. >> +# >> +# @child: graph node name that will be removed. >> +# >> +# Since: 2.5 >> +## >> +{ 'command': 'child-del', >> + 'data' : { 'parent': 'str', 'child': 'str' } } > > These command names are faaaar too generic. If this only applies to > block devices, then I'd expect something like 'block' as a prefix for > the command names. Likewise with your next hmp patch OK, I will fix it in the next version. I guess blockdev may be better. Thanks Wen Congyang > > Regards, > Daniel > From MAILER-DAEMON Thu Sep 10 08:02:36 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Za0Ym-0007lW-MP for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 08:02:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za0Yi-0007gZ-Bu for qemu-block@nongnu.org; Thu, 10 Sep 2015 08:02:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Za0Ya-00008K-It for qemu-block@nongnu.org; Thu, 10 Sep 2015 08:02:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za0Ya-00008B-EP; Thu, 10 Sep 2015 08:02:24 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 02E9AFA9DF; Thu, 10 Sep 2015 12:02:23 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-109.ams2.redhat.com [10.36.116.109]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8AC2MJo012498; Thu, 10 Sep 2015 08:02:22 -0400 Date: Thu, 10 Sep 2015 14:02:21 +0200 From: Kevin Wolf To: Fam Zheng Message-ID: <20150910120221.GC4460@noname.redhat.com> References: <1441871594-21252-1-git-send-email-rgerganov@vmware.com> <20150910081557.GA27306@ad.nay.redhat.com> <55F143C6.5020401@vmware.com> <20150910085803.GB27306@ad.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150910085803.GB27306@ad.nay.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH] vmdk: Fix next_cluster_sector for compressed write X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 12:02:35 -0000 Am 10.09.2015 um 10:58 hat Fam Zheng geschrieben: > On Thu, 09/10 11:48, Radoslav Gerganov wrote: > > On 10.09.2015 11:15, Fam Zheng wrote: > > > On Thu, 09/10 10:53, Radoslav Gerganov wrote: > > >> When the VMDK is streamOptimized (or compressed), the > > >> next_cluster_sector must not be incremented by a fixed number of > > >> sectors. Instead of this, it must be rounded up to the next consecutive > > >> sector. Fixing this results in much smaller compressed images. > > >> > > >> Signed-off-by: Radoslav Gerganov > > > > > > Is this patch enough to produce a valid streamOptimized image? Because I > > > remember there were reports on some other issues with footer or grain markers. > > > > > > Fam > > > > The VMDK spec says that each marker and its associated block must begin on > > sector boundary which is true before and after my patch. However, with my > > patch we don't put empty sectors when we achieve good compression for the > > current cluster but start the next cluster on the next consecutive sector. > > > > I have also verified that images produced with my patch can be booted in > > VMware Workstation. > > Thanks, the change looks good to me. > > Reviewed-by: Fam Zheng Thanks, applied to the block branch. Radoslav, for your next patch please remember to always keep qemu-devel CCed, even if you're sending the patch to a more specific mailing list. I'm adding it to this mail so that people who aren't subscribed to qemu-block have a chance to notice the patch. Kevin From MAILER-DAEMON Thu Sep 10 09:40:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Za25W-0001fh-In for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 09:40:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za25Q-0001Vj-T6 for qemu-block@nongnu.org; Thu, 10 Sep 2015 09:40:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Za25J-0002as-Vi for qemu-block@nongnu.org; Thu, 10 Sep 2015 09:40:24 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:35253 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za25J-0001t7-A1 for qemu-block@nongnu.org; Thu, 10 Sep 2015 09:40:17 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BHBgAUh/FV/5tjdVtdGQEBAYMHgT2pGAEBAQEBAQUBgQqTCYQ6gzYCgUA5EwEBAQEBAQGBCoQkAQEEeRA/EjwbGYgyActvLIYsik4HhCwFjHdxh26Mepp4IgFAgUqCOW6ISQEBAQ X-IPAS-Result: A2BHBgAUh/FV/5tjdVtdGQEBAYMHgT2pGAEBAQEBAQUBgQqTCYQ6gzYCgUA5EwEBAQEBAQGBCoQkAQEEeRA/EjwbGYgyActvLIYsik4HhCwFjHdxh26Mepp4IgFAgUqCOW6ISQEBAQ X-IronPort-AV: E=Sophos;i="5.17,504,1437429600"; d="scan'208";a="19976277" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 10 Sep 2015 15:39:34 +0200 Received: from 85-76-23-60-nat.elisa-mobile.fi ([85.76.23.60] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1Za24c-00014p-05; Thu, 10 Sep 2015 15:39:34 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1Za24N-00088f-KV; Thu, 10 Sep 2015 16:39:19 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 10 Sep 2015 16:39:12 +0300 Message-Id: <791796d6176b5439491a46496de216ec453ecf93.1441890725.git.berto@igalia.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v3 4/4] block: add tests for the 'blockdev-snapshot' command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 13:40:28 -0000 Signed-off-by: Alberto Garcia --- tests/qemu-iotests/085 | 97 +++++++++++++++++++++++++++++++++++++++++++--- tests/qemu-iotests/085.out | 34 +++++++++++++++- 2 files changed, 123 insertions(+), 8 deletions(-) diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085 index 56cd6f8..2b0f85a 100755 --- a/tests/qemu-iotests/085 +++ b/tests/qemu-iotests/085 @@ -7,6 +7,7 @@ # snapshots are performed. # # Copyright (C) 2014 Red Hat, Inc. +# Copyright (C) 2015 Igalia, S.L. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,17 +35,17 @@ status=1 # failure is the default! snapshot_virt0="snapshot-v0.qcow2" snapshot_virt1="snapshot-v1.qcow2" -MAX_SNAPSHOTS=10 +SNAPSHOTS=10 _cleanup() { _cleanup_qemu - for i in $(seq 1 ${MAX_SNAPSHOTS}) + for i in $(seq 1 ${SNAPSHOTS}) do rm -f "${TEST_DIR}/${i}-${snapshot_virt0}" rm -f "${TEST_DIR}/${i}-${snapshot_virt1}" done - _cleanup_test_img + rm -f "${TEST_IMG}.1" "${TEST_IMG}.2" } trap "_cleanup; exit \$status" 0 1 2 3 15 @@ -85,18 +86,45 @@ function create_group_snapshot() _send_qemu_cmd $h "${cmd}" "return" } +# ${1}: unique identifier for the snapshot filename +# ${2}: true: ignore backing images (default); false: don't ignore them +function add_snapshot_image() +{ + base_image="${TEST_DIR}/$((${1}-1))-${snapshot_virt0}" + snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}" + _make_test_img -b "${base_image}" "$size" + mv "${TEST_IMG}" "${snapshot_file}" + cmd="{ 'execute': 'blockdev-add', 'arguments': + { 'options': + { 'driver': 'qcow2', 'node-name': 'snap_"${1}"', + 'ignore-backing': "${2:-true}", 'file': + { 'driver': 'file', 'filename': '"${snapshot_file}"' } } } }" + _send_qemu_cmd $h "${cmd}" "return" +} + +# ${1}: unique identifier for the snapshot filename +# ${2}: expected response, defaults to 'return' +function blockdev_snapshot() +{ + cmd="{ 'execute': 'blockdev-snapshot', + 'arguments': { 'device': 'virtio0', + 'snapshot':'snap_"${1}"' } }" + _send_qemu_cmd $h "${cmd}" "${2:-return}" +} + size=128M _make_test_img $size -mv "${TEST_IMG}" "${TEST_IMG}.orig" +mv "${TEST_IMG}" "${TEST_IMG}.1" _make_test_img $size +mv "${TEST_IMG}" "${TEST_IMG}.2" echo echo === Running QEMU === echo qemu_comm_method="qmp" -_launch_qemu -drive file="${TEST_IMG}.orig",if=virtio -drive file="${TEST_IMG}",if=virtio +_launch_qemu -drive file="${TEST_IMG}.1",if=virtio -drive file="${TEST_IMG}.2",if=virtio h=$QEMU_HANDLE echo @@ -105,6 +133,8 @@ echo _send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return" +# Tests for the blockdev-snapshot-sync command + echo echo === Create a single snapshot on virtio0 === echo @@ -132,11 +162,66 @@ echo echo === Create several transactional group snapshots === echo -for i in $(seq 2 ${MAX_SNAPSHOTS}) +for i in $(seq 2 ${SNAPSHOTS}) do create_group_snapshot ${i} done +# Tests for the blockdev-snapshot command + +echo +echo === Create a couple of snapshots using blockdev-snapshot === +echo + +SNAPSHOTS=$((${SNAPSHOTS}+1)) +add_snapshot_image ${SNAPSHOTS} +blockdev_snapshot ${SNAPSHOTS} + +SNAPSHOTS=$((${SNAPSHOTS}+1)) +add_snapshot_image ${SNAPSHOTS} +blockdev_snapshot ${SNAPSHOTS} + +echo +echo === Invalid command - snapshot node used as active layer === +echo + +blockdev_snapshot ${SNAPSHOTS} error + +_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot', + 'arguments': { 'device':'virtio0', + 'snapshot':'virtio0' } + }" "error" + +_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot', + 'arguments': { 'device':'virtio0', + 'snapshot':'virtio1' } + }" "error" + +echo +echo === Invalid command - snapshot node used as backing hd === +echo + +blockdev_snapshot $((${SNAPSHOTS}-1)) error + +echo +echo === Invalid command - snapshot node has a backing image === +echo + +SNAPSHOTS=$((${SNAPSHOTS}+1)) +add_snapshot_image ${SNAPSHOTS} false +blockdev_snapshot ${SNAPSHOTS} error + +echo +echo === Invalid command - The node does not exist === +echo + +blockdev_snapshot $((${SNAPSHOTS}+1)) error + +_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot', + 'arguments': { 'device':'nodevice', + 'snapshot':'snap_"${SNAPSHOTS}"' } + }" "error" + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out index 5eb8b94..2238f6d 100644 --- a/tests/qemu-iotests/085.out +++ b/tests/qemu-iotests/085.out @@ -11,7 +11,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 === Create a single snapshot on virtio0 === -Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/t.qcow2.orig' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 +Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/t.qcow2.1' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 {"return": {}} === Invalid command - missing device and nodename === @@ -26,7 +26,7 @@ Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file === Create several transactional group snapshots === Formatting 'TEST_DIR/2-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/1-snapshot-v0.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 -Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/t.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 +Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/t.qcow2.2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 {"return": {}} Formatting 'TEST_DIR/3-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/2-snapshot-v0.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/3-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/2-snapshot-v1.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 @@ -52,4 +52,34 @@ Formatting 'TEST_DIR/9-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file Formatting 'TEST_DIR/10-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/9-snapshot-v0.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/9-snapshot-v1.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 {"return": {}} + +=== Create a couple of snapshots using blockdev-snapshot === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file='TEST_DIR/10-snapshot-v0.IMGFMT' +{"return": {}} +{"return": {}} +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file='TEST_DIR/11-snapshot-v0.IMGFMT' +{"return": {}} +{"return": {}} + +=== Invalid command - snapshot node used as active layer === + +{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio0"}} +{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio0"}} +{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio1"}} + +=== Invalid command - snapshot node used as backing hd === + +{"error": {"class": "GenericError", "desc": "Node 'snap_11' is busy: node is used as backing hd of 'virtio0'"}} + +=== Invalid command - snapshot node has a backing image === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file='TEST_DIR/12-snapshot-v0.IMGFMT' +{"return": {}} +{"error": {"class": "GenericError", "desc": "The snapshot already has a backing image"}} + +=== Invalid command - The node does not exist === + +{"error": {"class": "GenericError", "desc": "Cannot find device=snap_14 nor node_name=snap_14"}} +{"error": {"class": "GenericError", "desc": "Cannot find device=nodevice nor node_name=nodevice"}} *** done -- 2.5.1 From MAILER-DAEMON Thu Sep 10 09:40:33 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Za25Z-0001jT-0s for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 09:40:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za25T-0001aj-Sq for qemu-block@nongnu.org; Thu, 10 Sep 2015 09:40:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Za25Q-0002fQ-9K for qemu-block@nongnu.org; Thu, 10 Sep 2015 09:40:27 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:35253 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za25K-0001t7-Bk; Thu, 10 Sep 2015 09:40:18 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BNCgAUh/FV/5tjdVtdGQEBAYMHgT2BSKdQAQEBAQEBBQGBCpMJh3ACgUA5EwEBAQEBAQGBCoQkAQEEJ1IQPxI8GxkbiBcBy28shiyJYmwHhCwFhzGFRnGHbox6mngjAj6BSkYcgVduiEkBAQE X-IPAS-Result: A2BNCgAUh/FV/5tjdVtdGQEBAYMHgT2BSKdQAQEBAQEBBQGBCpMJh3ACgUA5EwEBAQEBAQGBCoQkAQEEJ1IQPxI8GxkbiBcBy28shiyJYmwHhCwFhzGFRnGHbox6mngjAj6BSkYcgVduiEkBAQE X-IronPort-AV: E=Sophos;i="5.17,504,1437429600"; d="scan'208";a="19976340" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 10 Sep 2015 15:39:45 +0200 Received: from 85-76-23-60-nat.elisa-mobile.fi ([85.76.23.60] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1Za24m-00014o-Me; Thu, 10 Sep 2015 15:39:45 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1Za24N-00088b-Js; Thu, 10 Sep 2015 16:39:19 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 10 Sep 2015 16:39:11 +0300 Message-Id: <40f3f51fb44da70929f7055e95582351d1aa3f34.1441890725.git.berto@igalia.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v3 3/4] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 13:40:32 -0000 One of the limitations of the 'blockdev-snapshot-sync' command is that it does not allow passing BlockdevOptions to the newly created snapshots, so they are always opened using the default values. Extending the command to allow passing options is not a practical solution because there is overlap between those options and some of the existing parameters of the command. This patch introduces a new 'blockdev-snapshot' command with a simpler interface: it just takes two references to existing block devices that will be used as the source and target for the snapshot. Since the main difference between the two commands is that one of them creates and opens the target image, while the other uses an already opened one, the bulk of the implementation is shared. Signed-off-by: Alberto Garcia --- blockdev.c | 163 ++++++++++++++++++++++++++++++++------------------- qapi-schema.json | 2 + qapi/block-core.json | 26 ++++++++ qmp-commands.hx | 29 +++++++++ 4 files changed, 160 insertions(+), 60 deletions(-) diff --git a/blockdev.c b/blockdev.c index 6b787c1..78cfb79 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1183,6 +1183,18 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, &snapshot, errp); } +void qmp_blockdev_snapshot(const char *device, const char *snapshot, + Error **errp) +{ + BlockdevSnapshot snapshot_data = { + .device = (char *) device, + .snapshot = (char *) snapshot + }; + + blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT, + &snapshot_data, errp); +} + void qmp_blockdev_snapshot_internal_sync(const char *device, const char *name, Error **errp) @@ -1521,57 +1533,48 @@ typedef struct ExternalSnapshotState { static void external_snapshot_prepare(BlkTransactionState *common, Error **errp) { - int flags, ret; - QDict *options; + int flags = 0, ret; + QDict *options = NULL; Error *local_err = NULL; - bool has_device = false; + /* Device and node name of the image to generate the snapshot from */ const char *device; - bool has_node_name = false; const char *node_name; - bool has_snapshot_node_name = false; - const char *snapshot_node_name; + /* Reference to the new image (for 'blockdev-snapshot') */ + const char *snapshot_ref; + /* File name of the new image (for 'blockdev-snapshot-sync') */ const char *new_image_file; - const char *format = "qcow2"; - enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; ExternalSnapshotState *state = DO_UPCAST(ExternalSnapshotState, common, common); TransactionAction *action = common->action; - /* get parameters */ - g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC); - - has_device = action->blockdev_snapshot_sync->has_device; - device = action->blockdev_snapshot_sync->device; - has_node_name = action->blockdev_snapshot_sync->has_node_name; - node_name = action->blockdev_snapshot_sync->node_name; - has_snapshot_node_name = - action->blockdev_snapshot_sync->has_snapshot_node_name; - snapshot_node_name = action->blockdev_snapshot_sync->snapshot_node_name; - - new_image_file = action->blockdev_snapshot_sync->snapshot_file; - if (action->blockdev_snapshot_sync->has_format) { - format = action->blockdev_snapshot_sync->format; - } - if (action->blockdev_snapshot_sync->has_mode) { - mode = action->blockdev_snapshot_sync->mode; + /* 'blockdev-snapshot' and 'blockdev-snapshot-sync' have similar + * purpose but a different set of parameters */ + switch (action->kind) { + case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT: + { + BlockdevSnapshot *s = action->blockdev_snapshot; + device = s->device; + node_name = s->device; + new_image_file = NULL; + snapshot_ref = s->snapshot; + } + break; + case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC: + { + BlockdevSnapshotSync *s = action->blockdev_snapshot_sync; + device = s->has_device ? s->device : NULL; + node_name = s->has_node_name ? s->node_name : NULL; + new_image_file = s->snapshot_file; + snapshot_ref = NULL; + } + break; + default: + g_assert_not_reached(); } /* start processing */ - state->old_bs = bdrv_lookup_bs(has_device ? device : NULL, - has_node_name ? node_name : NULL, - &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - - if (has_node_name && !has_snapshot_node_name) { - error_setg(errp, "New snapshot node name missing"); - return; - } - - if (has_snapshot_node_name && bdrv_find_node(snapshot_node_name)) { - error_setg(errp, "New snapshot node name already existing"); + state->old_bs = bdrv_lookup_bs(device, node_name, errp); + if (!state->old_bs) { return; } @@ -1601,35 +1604,69 @@ static void external_snapshot_prepare(BlkTransactionState *common, return; } - flags = state->old_bs->open_flags; + if (action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC) { + BlockdevSnapshotSync *s = action->blockdev_snapshot_sync; + const char *format = s->has_format ? s->format : "qcow2"; + enum NewImageMode mode; + const char *snapshot_node_name = + s->has_snapshot_node_name ? s->snapshot_node_name : NULL; - /* create new image w/backing file */ - if (mode != NEW_IMAGE_MODE_EXISTING) { - bdrv_img_create(new_image_file, format, - state->old_bs->filename, - state->old_bs->drv->format_name, - NULL, -1, flags, &local_err, false); - if (local_err) { - error_propagate(errp, local_err); + if (node_name && !snapshot_node_name) { + error_setg(errp, "New snapshot node name missing"); return; } - } - options = qdict_new(); - if (has_snapshot_node_name) { - qdict_put(options, "node-name", - qstring_from_str(snapshot_node_name)); + if (snapshot_node_name && bdrv_find_node(snapshot_node_name)) { + error_setg(errp, "New snapshot node name already existing"); + return; + } + + flags = state->old_bs->open_flags; + + /* create new image w/backing file */ + mode = s->has_mode ? s->mode : NEW_IMAGE_MODE_ABSOLUTE_PATHS; + if (mode != NEW_IMAGE_MODE_EXISTING) { + bdrv_img_create(new_image_file, format, + state->old_bs->filename, + state->old_bs->drv->format_name, + NULL, -1, flags, &local_err, false); + if (local_err) { + error_propagate(errp, local_err); + return; + } + } + + options = qdict_new(); + if (s->has_snapshot_node_name) { + qdict_put(options, "node-name", + qstring_from_str(snapshot_node_name)); + } + qdict_put(options, "driver", qstring_from_str(format)); + + flags |= BDRV_O_NO_BACKING; } - qdict_put(options, "driver", qstring_from_str(format)); - /* TODO Inherit bs->options or only take explicit options with an - * extended QMP command? */ assert(state->new_bs == NULL); - ret = bdrv_open(&state->new_bs, new_image_file, NULL, options, - flags | BDRV_O_NO_BACKING, &local_err); + ret = bdrv_open(&state->new_bs, new_image_file, snapshot_ref, options, + flags, errp); /* We will manually add the backing_hd field to the bs later */ if (ret != 0) { - error_propagate(errp, local_err); + return; + } + + if (state->new_bs->blk != NULL) { + error_setg(errp, "The snapshot is already in use by %s", + blk_name(state->new_bs->blk)); + return; + } + + if (bdrv_op_is_blocked(state->new_bs, BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT, + errp)) { + return; + } + + if (state->new_bs->backing_hd != NULL) { + error_setg(errp, "The snapshot already has a backing image"); } } @@ -1818,6 +1855,12 @@ static void abort_commit(BlkTransactionState *common) } static const BdrvActionOps actions[] = { + [TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT] = { + .instance_size = sizeof(ExternalSnapshotState), + .prepare = external_snapshot_prepare, + .commit = external_snapshot_commit, + .abort = external_snapshot_abort, + }, [TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC] = { .instance_size = sizeof(ExternalSnapshotState), .prepare = external_snapshot_prepare, diff --git a/qapi-schema.json b/qapi-schema.json index c32dc20..71dacea 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1493,9 +1493,11 @@ # abort since 1.6 # blockdev-snapshot-internal-sync since 1.7 # blockdev-backup since 2.3 +# blockdev-snapshot since 2.5 ## { 'union': 'TransactionAction', 'data': { + 'blockdev-snapshot': 'BlockdevSnapshot', 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', 'drive-backup': 'DriveBackup', 'blockdev-backup': 'BlockdevBackup', diff --git a/qapi/block-core.json b/qapi/block-core.json index 0f797d7..7d05166 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -705,6 +705,19 @@ '*format': 'str', '*mode': 'NewImageMode' } } ## +# @BlockdevSnapshot +# +# @device: device or node name to generate the snapshot from. +# +# @snapshot: reference to the existing block device that will be used +# for the snapshot. +# +# Since 2.5 +## +{ 'struct': 'BlockdevSnapshot', + 'data': { 'device': 'str', 'snapshot': 'str' } } + +## # @DriveBackup # # @device: the name of the device which should be copied. @@ -800,6 +813,19 @@ { 'command': 'blockdev-snapshot-sync', 'data': 'BlockdevSnapshotSync' } + +## +# @blockdev-snapshot +# +# Generates a snapshot of a block device. +# +# For the arguments, see the documentation of BlockdevSnapshot. +# +# Since 2.5 +## +{ 'command': 'blockdev-snapshot', + 'data': 'BlockdevSnapshot' } + ## # @change-backing-file # diff --git a/qmp-commands.hx b/qmp-commands.hx index 495670b..05a5675 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1454,6 +1454,35 @@ Example: EQMP { + .name = "blockdev-snapshot", + .args_type = "device:s,snapshot:s", + .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot, + }, + +SQMP +blockdev-snapshot +----------------- +Since 2.5 + +Create a snapshot, by installing 'device' as the backing image of +'snapshot'. Additionally, if 'device' is associated with a block +device, the block device changes to using 'snapshot' as its new active +image. + +Arguments: + +- "device": snapshot source (json-string) +- "snapshot": snapshot target (json-string) + +Example: + +-> { "execute": "blockdev-snapshot", "arguments": { "device": "ide-hd0", + "snapshot": "node1534" } } +<- { "return": {} } + +EQMP + + { .name = "blockdev-snapshot-internal-sync", .args_type = "device:B,name:s", .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot_internal_sync, -- 2.5.1 From MAILER-DAEMON Thu Sep 10 09:40:33 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Za25Z-0001jx-7b for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 09:40:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za25T-0001ag-Ss for qemu-block@nongnu.org; Thu, 10 Sep 2015 09:40:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Za25P-0002f8-S6 for qemu-block@nongnu.org; Thu, 10 Sep 2015 09:40:27 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:58765 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za25N-00020H-JB; Thu, 10 Sep 2015 09:40:21 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AMBAAUh/FV/5tjdVtdGQEBAYMHgT2BSKdQAQEBAQEBBQGBCpJ7AQ2HcAKBQDgUAQEBAQEBAYEKhCQBAQR5ED8SPBsZiDIBy28BK4JPg12JYmwHF4QVBYx3cYduh3eFA5p4HwEBQoFKRhyBV26ISQEBAQ X-IPAS-Result: A2AMBAAUh/FV/5tjdVtdGQEBAYMHgT2BSKdQAQEBAQEBBQGBCpJ7AQ2HcAKBQDgUAQEBAQEBAYEKhCQBAQR5ED8SPBsZiDIBy28BK4JPg12JYmwHF4QVBYx3cYduh3eFA5p4HwEBQoFKRhyBV26ISQEBAQ X-IronPort-AV: E=Sophos;i="5.17,504,1437429600"; d="scan'208";a="19976341" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 10 Sep 2015 15:39:45 +0200 Received: from 85-76-23-60-nat.elisa-mobile.fi ([85.76.23.60] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1Za24n-00014q-0P; Thu, 10 Sep 2015 15:39:45 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1Za24N-00088T-IB; Thu, 10 Sep 2015 16:39:19 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 10 Sep 2015 16:39:09 +0300 Message-Id: X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v3 1/4] block: rename BlockdevSnapshot to BlockdevSnapshotSync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 13:40:32 -0000 We will introduce the 'blockdev-snapshot' command that will require its own struct for the parameters, so we need to rename this one in order to avoid name clashes. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake --- blockdev.c | 2 +- qapi-schema.json | 2 +- qapi/block-core.json | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/blockdev.c b/blockdev.c index 3f42863..6b787c1 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1166,7 +1166,7 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, bool has_format, const char *format, bool has_mode, NewImageMode mode, Error **errp) { - BlockdevSnapshot snapshot = { + BlockdevSnapshotSync snapshot = { .has_device = has_device, .device = (char *) device, .has_node_name = has_node_name, diff --git a/qapi-schema.json b/qapi-schema.json index 1521eb7..c32dc20 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1496,7 +1496,7 @@ ## { 'union': 'TransactionAction', 'data': { - 'blockdev-snapshot-sync': 'BlockdevSnapshot', + 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', 'drive-backup': 'DriveBackup', 'blockdev-backup': 'BlockdevBackup', 'abort': 'Abort', diff --git a/qapi/block-core.json b/qapi/block-core.json index cb99cad..ec50f06 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -682,7 +682,7 @@ 'data': [ 'existing', 'absolute-paths' ] } ## -# @BlockdevSnapshot +# @BlockdevSnapshotSync # # Either @device or @node-name must be set but not both. # @@ -699,7 +699,7 @@ # @mode: #optional whether and how QEMU should create a new image, default is # 'absolute-paths'. ## -{ 'struct': 'BlockdevSnapshot', +{ 'struct': 'BlockdevSnapshotSync', 'data': { '*device': 'str', '*node-name': 'str', 'snapshot-file': 'str', '*snapshot-node-name': 'str', '*format': 'str', '*mode': 'NewImageMode' } } @@ -790,7 +790,7 @@ # # Generates a synchronous snapshot of a block device. # -# For the arguments, see the documentation of BlockdevSnapshot. +# For the arguments, see the documentation of BlockdevSnapshotSync. # # Returns: nothing on success # If @device is not a valid block device, DeviceNotFound @@ -798,7 +798,7 @@ # Since 0.14.0 ## { 'command': 'blockdev-snapshot-sync', - 'data': 'BlockdevSnapshot' } + 'data': 'BlockdevSnapshotSync' } ## # @change-backing-file -- 2.5.1 From MAILER-DAEMON Thu Sep 10 09:41:00 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Za25z-0002BJ-ML for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 09:40:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za25u-000227-8d for qemu-block@nongnu.org; Thu, 10 Sep 2015 09:40:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Za25q-0002rW-8c for qemu-block@nongnu.org; Thu, 10 Sep 2015 09:40:54 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:57440 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za25g-0002o9-KY; Thu, 10 Sep 2015 09:40:41 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2B4BQAUh/FV/5tjdVtdGQEBAYMHVGmpEwUBAQEBAQEFAYEKlFcfCoV5gUI7EQEBAQEBAQGBCoQmAQQCdk86FE+IFwEIzA8EhiyKTh6EFQWHMYY3h26FCoUOgmKBTJB3iDU3LIFKAYI4bgGISAEBAQ X-IPAS-Result: A2B4BQAUh/FV/5tjdVtdGQEBAYMHVGmpEwUBAQEBAQEFAYEKlFcfCoV5gUI7EQEBAQEBAQGBCoQmAQQCdk86FE+IFwEIzA8EhiyKTh6EFQWHMYY3h26FCoUOgmKBTJB3iDU3LIFKAYI4bgGISAEBAQ X-IronPort-AV: E=Sophos;i="5.17,504,1437429600"; d="scan'208";a="19976274" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 10 Sep 2015 15:39:34 +0200 Received: from 85-76-23-60-nat.elisa-mobile.fi ([85.76.23.60] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1Za24b-00014o-U4; Thu, 10 Sep 2015 15:39:34 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1Za24N-00088P-H0; Thu, 10 Sep 2015 16:39:19 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 10 Sep 2015 16:39:08 +0300 Message-Id: X-Mailer: git-send-email 2.5.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v3 0/4] Add 'blockdev-snapshot' command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 13:40:58 -0000 Hi, here's version 3 of the patchset that adds the 'blockdev-snapshot' QMP command. This one has a couple of important fixes plus some of the corrections suggested by Eric. The most controversial change, I believe, is the addition of the 'ignore-backing' field to BlockdevOptionsGenericCOWFormat. This allows opening an image using 'blockdev-add' but not its backing chain. I expect that this will generate some debate so decided to go for a simple solution that would allow me to finish the rest of the series, but I'm of course open to go for an alternative API/solution. Regards, Berto v3: - Add 'ignore-backing' field to BlockdevOptionsGenericCOWFormat. This allows opening images but not their backing images. - Check for op blockers in the snapshot node and make sure that it doesn't have any backing image. - Remove extra check for the existence of the snapshot node: bdrv_open() already does that. - Extend iotest 085 to add tests for 'blockdev-snapshot'. - Replace local_err with errp in some places where the former is unnecessary. - Update command description. - Add 'since' tag to the 'blockdev-snapshot' field in TransactionAction. v2: https://lists.gnu.org/archive/html/qemu-block/2015-09/msg00094.html - Add 'blockdev-snapshot' command instead of allowing passing options to 'blockdev-snapshot-sync'. - Rename BlockdevSnapshot to BlockdevSnapshotSync v1: https://lists.gnu.org/archive/html/qemu-block/2015-08/msg00236.html Alberto Garcia (4): block: rename BlockdevSnapshot to BlockdevSnapshotSync block: Add 'ignore-backing' field to BlockdevOptionsGenericCOWFormat block: add a 'blockdev-snapshot' QMP command block: add tests for the 'blockdev-snapshot' command block.c | 5 ++ blockdev.c | 165 ++++++++++++++++++++++++++++----------------- qapi-schema.json | 4 +- qapi/block-core.json | 38 +++++++++-- qmp-commands.hx | 29 ++++++++ tests/qemu-iotests/085 | 97 ++++++++++++++++++++++++-- tests/qemu-iotests/085.out | 34 +++++++++- 7 files changed, 298 insertions(+), 74 deletions(-) -- 2.5.1 From MAILER-DAEMON Thu Sep 10 09:41:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Za261-0002D3-1S for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 09:41:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za25x-00028X-UK for qemu-block@nongnu.org; Thu, 10 Sep 2015 09:40:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Za25t-0002sB-Tb for qemu-block@nongnu.org; Thu, 10 Sep 2015 09:40:57 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:57440 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za25j-0002o9-9J; Thu, 10 Sep 2015 09:40:43 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AQAgAUh/FV/5tjdVtdGQEBAYMHgT2pGAEBAQEBAQUBgQqSewENh3ACgUA4FAEBAQEBAQGBCoQkAQEEJ1IQPxI8GxmIMgHLbwEBCCKCT4NdiWllBxeEFQWNaIduh3eFA5p4HwEBQoFKeIFBbocBgUgBAQE X-IPAS-Result: A2AQAgAUh/FV/5tjdVtdGQEBAYMHgT2pGAEBAQEBAQUBgQqSewENh3ACgUA4FAEBAQEBAQGBCoQkAQEEJ1IQPxI8GxmIMgHLbwEBCCKCT4NdiWllBxeEFQWNaIduh3eFA5p4HwEBQoFKeIFBbocBgUgBAQE X-IronPort-AV: E=Sophos;i="5.17,504,1437429600"; d="scan'208";a="19976276" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 10 Sep 2015 15:39:34 +0200 Received: from 85-76-23-60-nat.elisa-mobile.fi ([85.76.23.60] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1Za24c-00014q-2K; Thu, 10 Sep 2015 15:39:34 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1Za24N-00088X-J0; Thu, 10 Sep 2015 16:39:19 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 10 Sep 2015 16:39:10 +0300 Message-Id: <1be64a26c9a89ff0af4c2b1299d6c8b58361644a.1441890725.git.berto@igalia.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v3 2/4] block: Add 'ignore-backing' field to BlockdevOptionsGenericCOWFormat X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 13:40:59 -0000 If set to true, the image will be opened with the BDRV_O_NO_BACKING flag. This is useful for creating snapshots using images opened with blockdev-add, since they are not supposed to have a backing image before the operation. Signed-off-by: Alberto Garcia --- block.c | 5 +++++ qapi/block-core.json | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 22d3b0e..4be32fb 100644 --- a/block.c +++ b/block.c @@ -1469,6 +1469,11 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, assert(drvname || !(flags & BDRV_O_PROTOCOL)); + if (qdict_get_try_bool(options, "ignore-backing", false)) { + flags |= BDRV_O_NO_BACKING; + } + qdict_del(options, "ignore-backing"); + bs->open_flags = flags; bs->options = options; options = qdict_clone_shallow(options); diff --git a/qapi/block-core.json b/qapi/block-core.json index ec50f06..0f797d7 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1498,11 +1498,15 @@ # allowed to pass an empty string here in order to disable the # default backing file. # +# @ignore-backing: #optional if true, no backing file will be +# opened. Defaults to false (Since 2.5) +# # Since: 1.7 ## { 'struct': 'BlockdevOptionsGenericCOWFormat', 'base': 'BlockdevOptionsGenericFormat', - 'data': { '*backing': 'BlockdevRef' } } + 'data': { '*backing': 'BlockdevRef', + '*ignore-backing': 'bool' } } ## # @Qcow2OverlapCheckMode -- 2.5.1 From MAILER-DAEMON Thu Sep 10 15:09:53 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Za7EH-0000K8-QQ for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 15:09:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za7EE-0000Jn-I0 for qemu-block@nongnu.org; Thu, 10 Sep 2015 15:09:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Za7EB-0003RS-13 for qemu-block@nongnu.org; Thu, 10 Sep 2015 15:09:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42064) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za7EA-0003RN-NR; Thu, 10 Sep 2015 15:09:46 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 908E02F02CA; Thu, 10 Sep 2015 19:09:45 +0000 (UTC) Received: from [10.36.116.27] (ovpn-116-27.ams2.redhat.com [10.36.116.27]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8AJ9f9W025599 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 10 Sep 2015 15:09:42 -0400 To: Wen Congyang , qemu-block@nongnu.org References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-30-git-send-email-mreitz@redhat.com> <55EEA69E.4010706@cn.fujitsu.com> <55EF5133.2040807@redhat.com> <55F00363.5080709@cn.fujitsu.com> <55F02D3D.6020102@redhat.com> <55F0D901.1010607@cn.fujitsu.com> From: Max Reitz Message-ID: <55F1D575.9020909@redhat.com> Date: Thu, 10 Sep 2015 21:09:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F0D901.1010607@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PiEP1lJUWrNstaOKw83kpaT9s3kbIG7uX" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 29/38] blockdev: Add blockdev-insert-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 19:09:51 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --PiEP1lJUWrNstaOKw83kpaT9s3kbIG7uX Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 10.09.2015 03:12, Wen Congyang wrote: > On 09/09/2015 08:59 PM, Max Reitz wrote: >> On 09.09.2015 12:01, Wen Congyang wrote: >>> On 09/09/2015 05:20 AM, Max Reitz wrote: >>>> On 08.09.2015 11:13, Wen Congyang wrote: >>>>> On 07/21/2015 01:45 AM, 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 fo= r >>>>>> implementing 'change' using blockdev-insert-medium). >>>>>> >>>>>> Signed-off-by: Max Reitz >>>>>> --- >>>>>> blockdev.c | 48 +++++++++++++++++++++++++++++++++++++++= +++++++++ >>>>>> qapi/block-core.json | 17 +++++++++++++++++ >>>>>> qmp-commands.hx | 37 +++++++++++++++++++++++++++++++++++++ >>>>>> 3 files changed, 102 insertions(+) >>>>>> >>>>>> diff --git a/blockdev.c b/blockdev.c >>>>>> index 481760a..a80d0e2 100644 >>>>>> --- a/blockdev.c >>>>>> +++ b/blockdev.c >>>>>> @@ -2164,6 +2164,54 @@ void qmp_blockdev_remove_medium(const char = *device, Error **errp) >>>>>> } >>>>>> } >>>>>> =20 >>>>>> +static void qmp_blockdev_insert_anon_medium(const char *device, >>>>>> + BlockDriverState *bs,= Error **errp) >>>>>> +{ >>>>>> + BlockBackend *blk; >>>>>> + bool has_device; >>>>>> + >>>>>> + blk =3D blk_by_name(device); >>>>>> + if (!blk) { >>>>>> + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, >>>>>> + "Device '%s' not found", device); >>>>>> + return; >>>>>> + } >>>>>> + >>>>>> + /* For BBs without a device, we can exchange the BDS tree at = will */ >>>>>> + has_device =3D blk_get_attached_dev(blk); >>>>>> + >>>>>> + if (has_device && !blk_dev_has_removable_media(blk)) { >>>>>> + error_setg(errp, "Device '%s' is not removable", device);= >>>>>> + return; >>>>>> + } >>>>>> + >>>>>> + if (has_device && !blk_dev_is_tray_open(blk)) { >>>>>> + error_setg(errp, "Tray of device '%s' is not open", devic= e); >>>>>> + return; >>>>>> + } >>>>>> + >>>>>> + if (blk_bs(blk)) { >>>>>> + error_setg(errp, "There already is a medium in device '%s= '", device); >>>>>> + return; >>>>>> + } >>>>>> + >>>>>> + blk_insert_bs(blk, bs); >>>>>> +} >>>>>> + >>>>>> +void qmp_blockdev_insert_medium(const char *device, const char *n= ode_name, >>>>>> + Error **errp) >>>>>> +{ >>>>>> + BlockDriverState *bs; >>>>>> + >>>>>> + bs =3D bdrv_find_node(node_name); >>>>>> + if (!bs) { >>>>>> + error_setg(errp, "Node '%s' not found", node_name); >>>>>> + return; >>>>>> + } >>>>> >>>>> Hmm, it is OK if the bs is not top BDS? >>>> >>>> I think so, yes. Generally, there's probably no reason to do that, b= ut I >>>> don't know why we should not allow that case. For instance, you migh= t >>>> want to make a backing file available read-only somewhere. >>>> >>>> It should be impossible to make it available writable, and it should= not >>>> be allowed to start a block-commit operation while the backing file = can >>>> be accessed by the guest, but this should be achieved using op block= ers. >>>> >>>> What we need for this to work are fine-grained op blockers, I think.= But >>>> working around that for now by only allowing to insert top BDS won't= >>>> work, since you can still start block jobs which target top BDS, too= >>>> (e.g. blockdev-backup can write to a BDS/BB that is visible to the g= uest). >>>> >>>> All in all, I think it's fine to insert non-top BDS, but we should >>>> definitely worry about which exact BDS one can insert once we have >>>> fine-grained op blockers. >>> >>> A BDS can be written by its parent, its block backend, a block job.. >>> So I think we should have some way to avoid more than two sources wri= ting >>> to it, otherwise the data may be corrupted. >> >> Yes, and that would be op blockers. >> >> As I said, using blockdev-backup you can write to a BB that can be >> written to by the guest as well. I think this is a bug, but it is a bu= g >> that needs to be fixed by having better op blockers in place, which Je= ff >> Cody is working on. >> >> Regarding this series, I don't consider this to be too big of an issue= =2E >> Yes, if you are working with floppy disks, you can have the case of a >> block job and the guest writing to the BDS at the same time. But I can= 't >> really imagine who would use floppy disks and block jobs at the same >> time (people who still use floppy disks for their VMs don't strike me = as >> the kind of people who use the management features of qemu, especially= >> not for those floppy disks). >> >> Other than that, this function (blockdev-insert-medium) can only be us= ed >> for optical ROM devices (I don't think we have CD/DVD-RW support, do >> we?), so it's much less of an issue there. >> >> So all in all I don't consider this too big of an issue here. If other= s >> think different, then I would delay this part of the series (which >> overhauls the "change" command) until we have fine-grained op blockers= =2E >=20 > In most cases, the user uses this command to change CD/DVD media, so it= is OK. > But IIRC scsi disk can also be changed. So we can mark this command as = experimental > (the command name can be x-blockdev-insert-medium). I'd rather delay this part than mark it experimental. But then again, seeing that we have cases like this already (i.e. blockdev-backup) and nobody seems to be complaining, I still think it should be fine. Max --PiEP1lJUWrNstaOKw83kpaT9s3kbIG7uX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV8dV1AAoJEDuxQgLoOKytF+EIAI7iub0e/UVaBc1x9heB3vBz dwwmnW0RDGkgNwZvG3yxOIAOB9oQe1nQ2PmlgD2fPfWEO4WmuKCgplym1XuxrQQz lh0u5ZvDyR/vNCx0xlGzB+9B44GzLAaEXM9H/9TkuUSHuH/jqJWvZXWTwO52hI6n P/8f7GDRVqfU9BGE+RmQHJzMLT0Qt5VNAbS/tdkLOX9JlTn3nYUwS7eqJ4i07Q3w BKU+nwnz8PN/pMGxN+KV21sA5NmoyUyDyEhZkBufjqUkLOdO5Mkvk356ruE+POwf VsqWi3TU8RIreULZKcaNP9CH8NqrK4rs/lFmCuc9AuRnu188p0vOcR2ml9Riz+k= =Wuqk -----END PGP SIGNATURE----- --PiEP1lJUWrNstaOKw83kpaT9s3kbIG7uX-- From MAILER-DAEMON Thu Sep 10 15:10:18 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Za7Eg-0000st-Eg for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 15:10:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za7Ee-0000pp-9H for qemu-block@nongnu.org; Thu, 10 Sep 2015 15:10:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Za7Ed-0003pZ-5r for qemu-block@nongnu.org; Thu, 10 Sep 2015 15:10:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za7Ec-0003pR-Vi; Thu, 10 Sep 2015 15:10:15 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 89452AA6; Thu, 10 Sep 2015 19:10:14 +0000 (UTC) Received: from [10.36.116.27] (ovpn-116-27.ams2.redhat.com [10.36.116.27]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8AJAAGg028550 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 10 Sep 2015 15:10:12 -0400 To: Wen Congyang , qemu-block@nongnu.org References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-30-git-send-email-mreitz@redhat.com> <55EEA69E.4010706@cn.fujitsu.com> <55EF5133.2040807@redhat.com> <55F00363.5080709@cn.fujitsu.com> <55F02D3D.6020102@redhat.com> <55F0F783.6020408@cn.fujitsu.com> From: Max Reitz Message-ID: <55F1D592.2000406@redhat.com> Date: Thu, 10 Sep 2015 21:10:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F0F783.6020408@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pwd8e292uWKS3uiGk3cb3v7TeITDoF1BF" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 29/38] blockdev: Add blockdev-insert-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 19:10:17 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --pwd8e292uWKS3uiGk3cb3v7TeITDoF1BF Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 10.09.2015 05:22, Wen Congyang wrote: > On 09/09/2015 08:59 PM, Max Reitz wrote: >> On 09.09.2015 12:01, Wen Congyang wrote: >>> On 09/09/2015 05:20 AM, Max Reitz wrote: >>>> On 08.09.2015 11:13, Wen Congyang wrote: >>>>> On 07/21/2015 01:45 AM, 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 fo= r >>>>>> implementing 'change' using blockdev-insert-medium). >>>>>> >>>>>> Signed-off-by: Max Reitz >>>>>> --- >>>>>> blockdev.c | 48 +++++++++++++++++++++++++++++++++++++++= +++++++++ >>>>>> qapi/block-core.json | 17 +++++++++++++++++ >>>>>> qmp-commands.hx | 37 +++++++++++++++++++++++++++++++++++++ >>>>>> 3 files changed, 102 insertions(+) >>>>>> >>>>>> diff --git a/blockdev.c b/blockdev.c >>>>>> index 481760a..a80d0e2 100644 >>>>>> --- a/blockdev.c >>>>>> +++ b/blockdev.c >>>>>> @@ -2164,6 +2164,54 @@ void qmp_blockdev_remove_medium(const char = *device, Error **errp) >>>>>> } >>>>>> } >>>>>> =20 >>>>>> +static void qmp_blockdev_insert_anon_medium(const char *device, >>>>>> + BlockDriverState *bs,= Error **errp) >>>>>> +{ >>>>>> + BlockBackend *blk; >>>>>> + bool has_device; >>>>>> + >>>>>> + blk =3D blk_by_name(device); >>>>>> + if (!blk) { >>>>>> + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, >>>>>> + "Device '%s' not found", device); >>>>>> + return; >>>>>> + } >>>>>> + >>>>>> + /* For BBs without a device, we can exchange the BDS tree at = will */ >>>>>> + has_device =3D blk_get_attached_dev(blk); >>>>>> + >>>>>> + if (has_device && !blk_dev_has_removable_media(blk)) { >>>>>> + error_setg(errp, "Device '%s' is not removable", device);= >>>>>> + return; >>>>>> + } >>>>>> + >>>>>> + if (has_device && !blk_dev_is_tray_open(blk)) { >>>>>> + error_setg(errp, "Tray of device '%s' is not open", devic= e); >>>>>> + return; >>>>>> + } >>>>>> + >>>>>> + if (blk_bs(blk)) { >>>>>> + error_setg(errp, "There already is a medium in device '%s= '", device); >>>>>> + return; >>>>>> + } >>>>>> + >>>>>> + blk_insert_bs(blk, bs); >>>>>> +} >>>>>> + >>>>>> +void qmp_blockdev_insert_medium(const char *device, const char *n= ode_name, >>>>>> + Error **errp) >>>>>> +{ >>>>>> + BlockDriverState *bs; >>>>>> + >>>>>> + bs =3D bdrv_find_node(node_name); >>>>>> + if (!bs) { >>>>>> + error_setg(errp, "Node '%s' not found", node_name); >>>>>> + return; >>>>>> + } >>>>> >>>>> Hmm, it is OK if the bs is not top BDS? >>>> >>>> I think so, yes. Generally, there's probably no reason to do that, b= ut I >>>> don't know why we should not allow that case. For instance, you migh= t >>>> want to make a backing file available read-only somewhere. >>>> >>>> It should be impossible to make it available writable, and it should= not >>>> be allowed to start a block-commit operation while the backing file = can >>>> be accessed by the guest, but this should be achieved using op block= ers. >>>> >>>> What we need for this to work are fine-grained op blockers, I think.= But >>>> working around that for now by only allowing to insert top BDS won't= >>>> work, since you can still start block jobs which target top BDS, too= >>>> (e.g. blockdev-backup can write to a BDS/BB that is visible to the g= uest). >>>> >>>> All in all, I think it's fine to insert non-top BDS, but we should >>>> definitely worry about which exact BDS one can insert once we have >>>> fine-grained op blockers. >>> >>> A BDS can be written by its parent, its block backend, a block job.. >>> So I think we should have some way to avoid more than two sources wri= ting >>> to it, otherwise the data may be corrupted. >> >> Yes, and that would be op blockers. >> >> As I said, using blockdev-backup you can write to a BB that can be >> written to by the guest as well. I think this is a bug, but it is a bu= g >> that needs to be fixed by having better op blockers in place, which Je= ff >> Cody is working on. >=20 > I don't find such patches in the maillist. That's because Jeff is still working on designing and writing them. Max --pwd8e292uWKS3uiGk3cb3v7TeITDoF1BF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV8dWSAAoJEDuxQgLoOKytlq4H/0RpQLPL+fECbwtfm+fqBlNn 3TlCQ5NihpTt/TKbfVha9BmbKaqbe3BlYQS8KE3QAo2z8rBrQWorJQvlzdoBHYlf W2H+lPdPL7dXJUCIXlscWOpPqN2/2DEc3qiLg4SxvJD5Dmmuk3qqY/lJE6TJtgSy wzYSQ8iot3sl/TJDCRR9p/ONDFTsgwvfRMJRsCubNuIUsCNqcsaY1XLrhIGiIk4/ 3l0sgwYgKRr4lb9SG5wLpzp37ROISDIG8b5xT8MXfFELzsm0YGU4Xyj2s5L14UXL 6aqrCJIa4+bX5sBG26mPjEPJ12E01DynyE1liLVNzdsv3KswCRXcVBUiQibrOZk= =vEAY -----END PGP SIGNATURE----- --pwd8e292uWKS3uiGk3cb3v7TeITDoF1BF-- From MAILER-DAEMON Thu Sep 10 17:22:41 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Za9In-0005EU-Gm for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 17:22:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za9Ik-0005EE-7Y for qemu-block@nongnu.org; Thu, 10 Sep 2015 17:22:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Za9Ih-0003Kw-0a for qemu-block@nongnu.org; Thu, 10 Sep 2015 17:22:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46235) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za9Ig-0003K3-OG; Thu, 10 Sep 2015 17:22:34 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id E71C3A0B6C; Thu, 10 Sep 2015 21:22:32 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8ALMV8K008415; Thu, 10 Sep 2015 17:22:31 -0400 To: Markus Armbruster References: <1440623592-13999-1-git-send-email-jsnow@redhat.com> <1440623592-13999-4-git-send-email-jsnow@redhat.com> <87d1xq7gq1.fsf@blackfin.pond.sub.org> From: John Snow X-Enigmail-Draft-Status: N1110 Message-ID: <55F1F497.300@redhat.com> Date: Thu, 10 Sep 2015 17:22:31 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87d1xq7gq1.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, zuban32s@gmail.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 3/4] ide-test: add cdrom pio test X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 21:22:39 -0000 On 09/10/2015 05:42 AM, Markus Armbruster wrote: > John Snow writes: > >> Add a simple read test for ATAPI devices, >> using the PIO mechanism. >> >> Signed-off-by: John Snow >> --- >> tests/ide-test.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 144 insertions(+) >> >> diff --git a/tests/ide-test.c b/tests/ide-test.c >> index 4a07e3a..90524e3 100644 >> --- a/tests/ide-test.c >> +++ b/tests/ide-test.c >> @@ -45,6 +45,12 @@ >> #define IDE_BASE 0x1f0 >> #define IDE_PRIMARY_IRQ 14 >> >> +#define ATAPI_BLOCK_SIZE 2048 >> + >> +/* How many bytes to receive via ATAPI PIO at one time. >> + * Must be less than 0xFFFF. */ >> +#define BYTE_COUNT_LIMIT 5120 >> + >> enum { >> reg_data = 0x0, >> reg_nsectors = 0x2, >> @@ -80,6 +86,7 @@ enum { >> CMD_WRITE_DMA = 0xca, >> CMD_FLUSH_CACHE = 0xe7, >> CMD_IDENTIFY = 0xec, >> + CMD_PACKET = 0xa0, >> >> CMDF_ABORT = 0x100, >> CMDF_NO_BM = 0x200, >> @@ -585,6 +592,140 @@ static void test_isa_retry_flush(const char *machine) >> test_retry_flush("isapc"); >> } >> >> +typedef struct Read10CDB { >> + uint8_t opcode; >> + uint8_t flags; >> + uint32_t lba; >> + uint8_t reserved; >> + uint16_t nblocks; >> + uint8_t control; >> + uint16_t padding; >> +} __attribute__((__packed__)) Read10CDB; >> + >> +static void send_scsi_cdb_read10(uint32_t lba, uint16_t nblocks) >> +{ >> + Read10CDB pkt = { .padding = 0 }; >> + int i; >> + >> + /* Construct SCSI CDB packet */ >> + pkt.opcode = 0x28; >> + pkt.lba = cpu_to_be32(lba); >> + pkt.nblocks = cpu_to_be16(nblocks); >> + >> + /* Send Packet */ >> + for (i = 0; i < sizeof(Read10CDB)/2; i++) { >> + outw(IDE_BASE + reg_data, ((uint16_t *)&pkt)[i]); > > Requires pkt to be suitable aligned. It is. > >> + } >> +} >> + >> +static void nsleep(int64_t nsecs) >> +{ >> + const struct timespec val = { .tv_nsec = nsecs }; >> + nanosleep(&val, NULL); >> + clock_set(nsecs); >> +} >> + >> +static uint8_t ide_wait_clear(uint8_t flag) >> +{ >> + int i; >> + uint8_t data; >> + >> + /* Wait with a 5 second timeout */ >> + for (i = 0; i <= 12500000; i++) { >> + data = inb(IDE_BASE + reg_status); >> + if (!(data & flag)) { >> + return data; >> + } >> + nsleep(400); >> + } >> + g_assert_not_reached(); >> + return 0xff; > > Unreachable code, not needed as long as g_assert_not_reached() is > properly annotated noreturn. > Good point, bad habit. >> +} >> + >> +static void cdrom_pio_impl(int nblocks) >> +{ >> + FILE *fh; >> + size_t patt_len = ATAPI_BLOCK_SIZE * MAX(16, nblocks); >> + char *pattern = g_malloc(patt_len); >> + size_t rxsize = ATAPI_BLOCK_SIZE * nblocks; >> + char *rx = g_malloc0(rxsize); >> + int i, j; >> + uint8_t data; >> + uint16_t limit; >> + >> + /* Prepopulate the CDROM with an interesting pattern */ >> + generate_pattern(pattern, patt_len, ATAPI_BLOCK_SIZE); >> + fh = fopen(tmp_path, "w+"); >> + fwrite(pattern, ATAPI_BLOCK_SIZE, MAX(16, nblocks), fh); > > I guess I would've avoided repeating MAX(16, nblocks), but it'll do. > >> + fclose(fh); >> + >> + ide_test_start( >> + "-drive file=%s,if=ide,media=cdrom,cache=writeback,format=raw", tmp_path); > > Legacy syntax. Okay. > "I expected better from you, John." >> + qtest_irq_intercept_in(global_qtest, "ioapic"); >> + >> + /* PACKET command on device 0 */ >> + outb(IDE_BASE + reg_device, 0); >> + outb(IDE_BASE + reg_lba_middle, BYTE_COUNT_LIMIT & 0xFF); >> + outb(IDE_BASE + reg_lba_high, (BYTE_COUNT_LIMIT >> 8 & 0xFF)); >> + outb(IDE_BASE + reg_command, CMD_PACKET); > > Ignorant question: why no reg_lba_low? > It's not used by the PACKET command. Most fields aren't, but lba_middle/lba_high (lcyl and hcyl) are re-purposed to represent a 16 bit "byte count limit" field. >> + /* HPD0: Check_Status_A State */ >> + nsleep(400); >> + data = ide_wait_clear(BSY); > > Ignorant question: why do you need to wait 400ns before you wait? > Blindly following spec to a fault -- the purpose on real hardware is to allow the drive a chance to set the BSY flag before we witness it being reset back to zero. QEMU of course will set and clear BSY synchronously before we ever make it back, but I try to write these tests in a manner where they are ignorant of QEMU's internals as much as I can, so you see some weird timing stuff here and there. Secretly I want to leave these tests generic enough to try and test them with pass-through devices and real hardware someday to see how my assertions match up against decidedly real hardware. >> + /* HPD1: Send_Packet State */ >> + assert_bit_set(data, DRQ | DRDY); >> + assert_bit_clear(data, ERR | DF | BSY); >> + >> + /* SCSI CDB (READ10) -- read n*2048 bytes from block 0 */ >> + send_scsi_cdb_read10(0, nblocks); >> + >> + /* HPD3: INTRQ_Wait */ >> + i = 0; >> + do { >> + data = get_irq(IDE_PRIMARY_IRQ); >> + nsleep(400); >> + i++; >> + g_assert_cmpint(i, <=, 12500000); >> + } while (!data); > > Similar to ide_wait_clear(). Why do you need to nsleep() after > get_irq() returned non-zero? > Ran out of thinking fluid. Ugly loop. >> + >> + /* HPD2: Check_Status_B */ >> + data = ide_wait_clear(BSY); >> + assert_bit_set(data, DRQ | DRDY); >> + assert_bit_clear(data, ERR | DF | BSY); >> + >> + /* Read data back: occurs in bursts of 'BYTE_COUNT_LIMIT' bytes. >> + * If BYTE_COUNT_LIMIT is odd, we transfer BYTE_COUNT_LIMIT - 1 bytes. >> + * We allow an odd limit only when the remaining transfer size is >> + * less than BYTE_COUNT_LIMIT. >> + * For our purposes, we can only request even multiples, so do not >> + * attempt to read remainders. */ >> + limit = BYTE_COUNT_LIMIT & ~1; > > Does nothing, BYTE_COUNT_LIMIT is 5120. Build-time assertion > !(BYTE_COUNT_LIMIT & 1) would do. > Allowing for the possibility of tests to exercise this bizarre property of the BCL in the future, though I think there'd be more work to do in the loop below. I intend to expand these tests bit-by-bit over time, so this is just some evidence of where I'm thinking on that. >> + for (i = 0; i < DIV_ROUND_UP(rxsize, limit); i++) { >> + size_t r = (rxsize - (limit * i)) / 2; >> + for (j = 0; j < MIN((limit / 2), r); j++) { >> + ((uint16_t *)rx)[(i * (limit/2)) + j] = inw(IDE_BASE + reg_data); > > Would be more readable with uint16_t *rx. Only if it doesn't require > casts elsewhere. > > I guess I would've tried a single loop instead of nesting two. But > since this works, keep it. > It's to accommodate the DRQ blocks, and to allow myself the chance to query the device between the distinct DRQ segments. It could just be a flat loop and it'd work okay... >> + } >> + } >> + data = ide_wait_clear(DRQ); >> + assert_bit_set(data, DRDY); >> + assert_bit_clear(data, DRQ | ERR | DF | BSY); >> + >> + g_assert_cmpint(memcmp(pattern, rx, rxsize), ==, 0); >> + g_free(pattern); >> + g_free(rx); >> + test_bmdma_teardown(); >> +} >> + >> +static void test_cdrom_pio(void) >> +{ >> + cdrom_pio_impl(1); >> +} >> + >> +static void test_cdrom_pio_large(void) >> +{ >> + /* Test a few loops of the PIO DRQ mechanism. */ >> + cdrom_pio_impl(BYTE_COUNT_LIMIT * 4 / ATAPI_BLOCK_SIZE); >> +} >> + >> int main(int argc, char **argv) >> { >> const char *arch = qtest_get_arch(); >> @@ -628,6 +769,9 @@ int main(int argc, char **argv) >> qtest_add_func("/ide/flush/retry_pci", test_pci_retry_flush); >> qtest_add_func("/ide/flush/retry_isa", test_isa_retry_flush); >> >> + qtest_add_func("/ide/cdrom/pio", test_cdrom_pio); >> + qtest_add_func("/ide/cdrom/pio_large", test_cdrom_pio_large); >> + >> ret = g_test_run(); >> >> /* Cleanup */ I'll polish just a pinch more. Thanks for the sanity check. --js From MAILER-DAEMON Thu Sep 10 17:40:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Za9a0-0005jA-E2 for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 17:40:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za9Zx-0005fW-Oi for qemu-block@nongnu.org; Thu, 10 Sep 2015 17:40:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Za9Zs-0004A1-P6 for qemu-block@nongnu.org; Thu, 10 Sep 2015 17:40:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42071) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Za9Zs-00049w-HY; Thu, 10 Sep 2015 17:40:20 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 184AF461EF; Thu, 10 Sep 2015 21:40:20 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8ALeIfH011217; Thu, 10 Sep 2015 17:40:18 -0400 To: Markus Armbruster References: <1440623592-13999-1-git-send-email-jsnow@redhat.com> <1440623592-13999-3-git-send-email-jsnow@redhat.com> <87pp1q7htu.fsf@blackfin.pond.sub.org> From: John Snow Message-ID: <55F1F8C2.1050807@redhat.com> Date: Thu, 10 Sep 2015 17:40:18 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87pp1q7htu.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, zuban32s@gmail.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 2/4] qtest/ahci: export generate_pattern X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 21:40:26 -0000 On 09/10/2015 05:18 AM, Markus Armbruster wrote: > John Snow writes: >=20 >> Share the pattern function for ide and ahci test. >> >> Signed-off-by: John Snow >> --- >> tests/ahci-test.c | 26 -------------------------- >> tests/libqos/libqos.c | 26 ++++++++++++++++++++++++++ >> tests/libqos/libqos.h | 1 + >> 3 files changed, 27 insertions(+), 26 deletions(-) >> >> diff --git a/tests/ahci-test.c b/tests/ahci-test.c >> index b1a785c..59d387c 100644 >> --- a/tests/ahci-test.c >> +++ b/tests/ahci-test.c >> @@ -71,32 +71,6 @@ static void string_bswap16(uint16_t *s, size_t byte= s) >> } >> } >> =20 >> -static void generate_pattern(void *buffer, size_t len, size_t cycle_l= en) >> -{ >> - int i, j; >> - unsigned char *tx =3D (unsigned char *)buffer; >> - unsigned char p; >> - size_t *sx; >> - >> - /* Write an indicative pattern that varies and is unique per-cycl= e */ >> - p =3D rand() % 256; >> - for (i =3D 0; i < len; i++) { >> - tx[i] =3D p++ % 256; >> - if (i % cycle_len =3D=3D 0) { >> - p =3D rand() % 256; >> - } >> - } >> - >> - /* force uniqueness by writing an id per-cycle */ >> - for (i =3D 0; i < len / cycle_len; i++) { >> - j =3D i * cycle_len; >> - if (j + sizeof(*sx) <=3D len) { >> - sx =3D (size_t *)&tx[j]; >> - *sx =3D i; >> - } >> - } >> -} >> - >> /** >> * Verify that the transfer did not corrupt our state at all. >> */ >> diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c >> index fce625b..8d7c5a9 100644 >> --- a/tests/libqos/libqos.c >> +++ b/tests/libqos/libqos.c >> @@ -212,3 +212,29 @@ void prepare_blkdebug_script(const char *debug_fn= , const char *event) >> ret =3D fclose(debug_file); >> g_assert(ret =3D=3D 0); >> } >> + >> +void generate_pattern(void *buffer, size_t len, size_t cycle_len) >> +{ >> + int i, j; >> + unsigned char *tx =3D (unsigned char *)buffer; >> + unsigned char p; >> + size_t *sx; >> + >> + /* Write an indicative pattern that varies and is unique per-cycl= e */ >> + p =3D rand() % 256; >> + for (i =3D 0; i < len; i++) { >> + tx[i] =3D p++ % 256; >> + if (i % cycle_len =3D=3D 0) { >> + p =3D rand() % 256; >> + } >> + } >> + >> + /* force uniqueness by writing an id per-cycle */ >> + for (i =3D 0; i < len / cycle_len; i++) { >> + j =3D i * cycle_len; >> + if (j + sizeof(*sx) <=3D len) { >> + sx =3D (size_t *)&tx[j]; >=20 > Relies on cycle_len being a multiple of size_t's alignment. So far, > it's always AHCI_SECTOR_SIZE, which should do. >=20 >> + *sx =3D i; >> + } >> + } >> +} >=20 > Looks like overkill to me, but since it's working code... :) >=20 I'll spare you the details, but I found it to be genuinely helpful to have a pattern like this while debugging. Makes it very easy to see which pattern came from where and so on. The per-sector uniqueness was critical, too ... >> diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h >> index e1f14ea..492a651 100644 >> --- a/tests/libqos/libqos.h >> +++ b/tests/libqos/libqos.h >> @@ -24,6 +24,7 @@ void mkqcow2(const char *file, unsigned size_mb); >> void set_context(QOSState *s); >> void migrate(QOSState *from, QOSState *to, const char *uri); >> void prepare_blkdebug_script(const char *debug_fn, const char *event)= ; >> +void generate_pattern(void *buffer, size_t len, size_t cycle_len); >> =20 >> static inline uint64_t qmalloc(QOSState *q, size_t bytes) >> { --=20 =97js From MAILER-DAEMON Thu Sep 10 19:21:07 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaB9P-00058R-4U for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 19:21:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaB9L-00050p-97 for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:21:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaB9H-0007PI-Vo for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:21:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaB9H-0007Ol-Qn; Thu, 10 Sep 2015 19:20:59 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 01AA9C0A5381; Thu, 10 Sep 2015 23:20:58 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8ANKvBW008977; Thu, 10 Sep 2015 19:20:58 -0400 From: John Snow To: qemu-block@nongnu.org Date: Thu, 10 Sep 2015 19:20:55 -0400 Message-Id: <1441927256-24625-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PATCH v2 0/1] atapi: abort transfers with 0 byte limits X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 23:21:04 -0000 v2: Make sure we only abort PIO commands if BCL is zero, not DMA. ________________________________________________________________________________ For convenience, this branch is available at: https://github.com/jnsnow/qemu.git branch atapi-bclimit https://github.com/jnsnow/qemu/tree/atapi-bclimit This version is tagged atapi-bclimit-v2: https://github.com/jnsnow/qemu/releases/tag/atapi-bclimit-v2 John Snow (1): atapi: abort transfers with 0 byte limits hw/ide/atapi.c | 32 +++++++++++++++++++++++++++----- hw/ide/core.c | 2 +- hw/ide/internal.h | 1 + 3 files changed, 29 insertions(+), 6 deletions(-) -- 2.4.3 From MAILER-DAEMON Thu Sep 10 19:21:07 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaB9P-000595-8l for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 19:21:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaB9L-00050o-96 for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:21:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaB9I-0007PY-8Q for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:21:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45468) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaB9I-0007PC-1P; Thu, 10 Sep 2015 19:21:00 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 91EDBAACCD; Thu, 10 Sep 2015 23:20:59 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8ANKvBX008977; Thu, 10 Sep 2015 19:20:59 -0400 From: John Snow To: qemu-block@nongnu.org Date: Thu, 10 Sep 2015 19:20:56 -0400 Message-Id: <1441927256-24625-2-git-send-email-jsnow@redhat.com> In-Reply-To: <1441927256-24625-1-git-send-email-jsnow@redhat.com> References: <1441927256-24625-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PATCH v2 1/1] atapi: abort transfers with 0 byte limits X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 23:21:04 -0000 We're supposed to abort on transfers like this, unless we fill Word 125 of our IDENTIFY data with a default transfer size, which we don't currently do. This is an ATA error, not a SCSI/ATAPI one. See ATA8-ACS3 sections 7.17.6.49 or 7.21.5. If we don't do this, QEMU will loop forever trying to transfer zero bytes, which isn't particularly useful. Signed-off-by: John Snow --- hw/ide/atapi.c | 32 +++++++++++++++++++++++++++----- hw/ide/core.c | 2 +- hw/ide/internal.h | 1 + 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 79dd167..a832746 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -1169,20 +1169,28 @@ enum { * 4.1.8) */ CHECK_READY = 0x02, + + /* + * Commands flagged with NONDATA do not in any circumstances return + * any data via ide_atapi_cmd_reply. These commands are exempt from + * the normal byte_count_limit constraints. + * See ATA8-ACS3 "7.21.5 Byte Count Limit" + */ + NONDATA = 0x04, }; static const struct { void (*handler)(IDEState *s, uint8_t *buf); int flags; } atapi_cmd_table[0x100] = { - [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY }, + [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY | NONDATA }, [ 0x03 ] = { cmd_request_sense, ALLOW_UA }, [ 0x12 ] = { cmd_inquiry, ALLOW_UA }, - [ 0x1b ] = { cmd_start_stop_unit, 0 }, /* [1] */ - [ 0x1e ] = { cmd_prevent_allow_medium_removal, 0 }, + [ 0x1b ] = { cmd_start_stop_unit, NONDATA }, /* [1] */ + [ 0x1e ] = { cmd_prevent_allow_medium_removal, NONDATA }, [ 0x25 ] = { cmd_read_cdvd_capacity, CHECK_READY }, [ 0x28 ] = { cmd_read, /* (10) */ CHECK_READY }, - [ 0x2b ] = { cmd_seek, CHECK_READY }, + [ 0x2b ] = { cmd_seek, CHECK_READY | NONDATA }, [ 0x43 ] = { cmd_read_toc_pma_atip, CHECK_READY }, [ 0x46 ] = { cmd_get_configuration, ALLOW_UA }, [ 0x4a ] = { cmd_get_event_status_notification, ALLOW_UA }, @@ -1190,7 +1198,7 @@ static const struct { [ 0x5a ] = { cmd_mode_sense, /* (10) */ 0 }, [ 0xa8 ] = { cmd_read, /* (12) */ CHECK_READY }, [ 0xad ] = { cmd_read_dvd_structure, CHECK_READY }, - [ 0xbb ] = { cmd_set_speed, 0 }, + [ 0xbb ] = { cmd_set_speed, NONDATA }, [ 0xbd ] = { cmd_mechanism_status, 0 }, [ 0xbe ] = { cmd_read_cd, CHECK_READY }, /* [1] handler detects and reports not ready condition itself */ @@ -1251,6 +1259,20 @@ void ide_atapi_cmd(IDEState *s) return; } + /* Nondata commands permit the byte_count_limit to be 0. + * If this is a data-transferring PIO command and BCL is 0, + * we abort at the /ATA/ level, not the ATAPI level. + * See ATA8 ACS3 section 7.17.6.49 and 7.21.5 */ + if (!(atapi_cmd_table[s->io_buffer[0]].flags & NONDATA)) { + /* TODO: Check IDENTIFY data word 125 for default BCL (currently 0) */ + uint16_t byte_count_limit = s->lcyl | (s->hcyl << 8); + if !(byte_count_limit || s->atapi_dma) { + /* TODO: Move abort back into core.c and make static inline again */ + ide_abort_command(s); + return; + } + } + /* Execute the command */ if (atapi_cmd_table[s->io_buffer[0]].handler) { atapi_cmd_table[s->io_buffer[0]].handler(s, buf); diff --git a/hw/ide/core.c b/hw/ide/core.c index 50449ca..28cf535 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -457,7 +457,7 @@ BlockAIOCB *ide_issue_trim(BlockBackend *blk, return &iocb->common; } -static inline void ide_abort_command(IDEState *s) +void ide_abort_command(IDEState *s) { ide_transfer_stop(s); s->status = READY_STAT | ERR_STAT; diff --git a/hw/ide/internal.h b/hw/ide/internal.h index 30fdcbc..40e1aa4 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -537,6 +537,7 @@ void ide_set_sector(IDEState *s, int64_t sector_num); void ide_start_dma(IDEState *s, BlockCompletionFunc *cb); void ide_dma_error(IDEState *s); +void ide_abort_command(IDEState *s); void ide_atapi_cmd_ok(IDEState *s); void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc); -- 2.4.3 From MAILER-DAEMON Thu Sep 10 19:22:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaBAl-00078F-1x for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 19:22:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaBAi-00075m-Cb for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:22:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaBAf-0000KN-8l for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:22:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53541) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaBAe-0000K6-SV; Thu, 10 Sep 2015 19:22:25 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 7C712C0AD281; Thu, 10 Sep 2015 23:22:24 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8ANMNs6014430; Thu, 10 Sep 2015 19:22:23 -0400 To: qemu-block@nongnu.org References: <1441323142-22671-1-git-send-email-jsnow@redhat.com> From: John Snow Message-ID: <55F210AF.7000306@redhat.com> Date: Thu, 10 Sep 2015 19:22:23 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441323142-22671-1-git-send-email-jsnow@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] atapi: abort transfers with 0 byte limits X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 23:22:29 -0000 On 09/03/2015 07:32 PM, John Snow wrote: > We're supposed to abort on transfers like this, unless we fill > Word 125 of our IDENTIFY data with a default transfer size, which > we don't currently do. > > This is an ATA error, not a SCSI/ATAPI one. > See ATA8-ACS3 sections 7.17.6.49 or 7.21.5. > > If we don't do this, QEMU will loop forever trying to transfer > zero bytes, which isn't particularly useful. > > Signed-off-by: John Snow > --- > hw/ide/atapi.c | 32 +++++++++++++++++++++++++++----- > hw/ide/core.c | 2 +- > hw/ide/internal.h | 1 + > 3 files changed, 29 insertions(+), 6 deletions(-) > > diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c > index 79dd167..7a4908f 100644 > --- a/hw/ide/atapi.c > +++ b/hw/ide/atapi.c > @@ -1169,20 +1169,28 @@ enum { > * 4.1.8) > */ > CHECK_READY = 0x02, > + > + /* > + * Commands flagged with NONDATA do not in any circumstances return > + * any data via ide_atapi_cmd_reply. These commands are exempt from > + * the normal byte_count_limit constraints. > + * See ATA8-ACS3 "7.21.5 Byte Count Limit" > + */ > + NONDATA = 0x04, > }; > > static const struct { > void (*handler)(IDEState *s, uint8_t *buf); > int flags; > } atapi_cmd_table[0x100] = { > - [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY }, > + [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY | NONDATA }, > [ 0x03 ] = { cmd_request_sense, ALLOW_UA }, > [ 0x12 ] = { cmd_inquiry, ALLOW_UA }, > - [ 0x1b ] = { cmd_start_stop_unit, 0 }, /* [1] */ > - [ 0x1e ] = { cmd_prevent_allow_medium_removal, 0 }, > + [ 0x1b ] = { cmd_start_stop_unit, NONDATA }, /* [1] */ > + [ 0x1e ] = { cmd_prevent_allow_medium_removal, NONDATA }, > [ 0x25 ] = { cmd_read_cdvd_capacity, CHECK_READY }, > [ 0x28 ] = { cmd_read, /* (10) */ CHECK_READY }, > - [ 0x2b ] = { cmd_seek, CHECK_READY }, > + [ 0x2b ] = { cmd_seek, CHECK_READY | NONDATA }, > [ 0x43 ] = { cmd_read_toc_pma_atip, CHECK_READY }, > [ 0x46 ] = { cmd_get_configuration, ALLOW_UA }, > [ 0x4a ] = { cmd_get_event_status_notification, ALLOW_UA }, > @@ -1190,7 +1198,7 @@ static const struct { > [ 0x5a ] = { cmd_mode_sense, /* (10) */ 0 }, > [ 0xa8 ] = { cmd_read, /* (12) */ CHECK_READY }, > [ 0xad ] = { cmd_read_dvd_structure, CHECK_READY }, > - [ 0xbb ] = { cmd_set_speed, 0 }, > + [ 0xbb ] = { cmd_set_speed, NONDATA }, > [ 0xbd ] = { cmd_mechanism_status, 0 }, > [ 0xbe ] = { cmd_read_cd, CHECK_READY }, > /* [1] handler detects and reports not ready condition itself */ > @@ -1251,6 +1259,20 @@ void ide_atapi_cmd(IDEState *s) > return; > } > > + /* Nondata commands permit the byte_count_limit to be 0. > + * If this is a data-transferring command and BCL is 0, > + * we abort at the /ATA/ level, not the ATAPI level. > + * See ATA8 ACS3 section 7.17.6.49 and 7.21.5 */ > + if (!(atapi_cmd_table[s->io_buffer[0]].flags & NONDATA)) { > + /* TODO: Check IDENTIFY data word 125 for default BCL (currently 0) */ > + uint16_t byte_count_limit = s->lcyl | (s->hcyl << 8); > + if (!byte_count_limit) { NACK, this will catch DMA commands too which is not what we want. Spec does allow for BCL to be zero if the transfer mechanism is not PIO. See V2. > + /* TODO: Move abort back into core.c and make static inline again */ > + ide_abort_command(s); > + return; > + } > + } > + > /* Execute the command */ > if (atapi_cmd_table[s->io_buffer[0]].handler) { > atapi_cmd_table[s->io_buffer[0]].handler(s, buf); > diff --git a/hw/ide/core.c b/hw/ide/core.c > index 50449ca..28cf535 100644 > --- a/hw/ide/core.c > +++ b/hw/ide/core.c > @@ -457,7 +457,7 @@ BlockAIOCB *ide_issue_trim(BlockBackend *blk, > return &iocb->common; > } > > -static inline void ide_abort_command(IDEState *s) > +void ide_abort_command(IDEState *s) > { > ide_transfer_stop(s); > s->status = READY_STAT | ERR_STAT; > diff --git a/hw/ide/internal.h b/hw/ide/internal.h > index 30fdcbc..40e1aa4 100644 > --- a/hw/ide/internal.h > +++ b/hw/ide/internal.h > @@ -537,6 +537,7 @@ void ide_set_sector(IDEState *s, int64_t sector_num); > > void ide_start_dma(IDEState *s, BlockCompletionFunc *cb); > void ide_dma_error(IDEState *s); > +void ide_abort_command(IDEState *s); > > void ide_atapi_cmd_ok(IDEState *s); > void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc); > From MAILER-DAEMON Thu Sep 10 19:34:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaBM7-0002ti-2y for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 19:34:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41453) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaBM4-0002tV-NL for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:34:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaBLz-0001Hl-92 for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:34:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46289) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaAy1-0000nx-AT; Thu, 10 Sep 2015 19:09:21 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id D0B2FA9A; Thu, 10 Sep 2015 23:09:20 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8AN9Gar010910; Thu, 10 Sep 2015 19:09:20 -0400 From: John Snow To: qemu-block@nongnu.org Date: Thu, 10 Sep 2015 19:09:14 -0400 Message-Id: <1441926555-19471-4-git-send-email-jsnow@redhat.com> In-Reply-To: <1441926555-19471-1-git-send-email-jsnow@redhat.com> References: <1441926555-19471-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, zuban32s@gmail.com, stefanha@redhat.com, pbonzini@redhat.com Subject: [Qemu-block] [PATCH v2 3/4] ide-test: add cdrom pio test X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 23:34:14 -0000 Add a simple read test for ATAPI devices, using the PIO mechanism. Signed-off-by: John Snow --- tests/ide-test.c | 157 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) diff --git a/tests/ide-test.c b/tests/ide-test.c index 4a07e3a..b3ddcf4 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -45,6 +45,12 @@ #define IDE_BASE 0x1f0 #define IDE_PRIMARY_IRQ 14 +#define ATAPI_BLOCK_SIZE 2048 + +/* How many bytes to receive via ATAPI PIO at one time. + * Must be less than 0xFFFF. */ +#define BYTE_COUNT_LIMIT 5120 + enum { reg_data = 0x0, reg_nsectors = 0x2, @@ -80,6 +86,7 @@ enum { CMD_WRITE_DMA = 0xca, CMD_FLUSH_CACHE = 0xe7, CMD_IDENTIFY = 0xec, + CMD_PACKET = 0xa0, CMDF_ABORT = 0x100, CMDF_NO_BM = 0x200, @@ -585,6 +592,153 @@ static void test_isa_retry_flush(const char *machine) test_retry_flush("isapc"); } +typedef struct Read10CDB { + uint8_t opcode; + uint8_t flags; + uint32_t lba; + uint8_t reserved; + uint16_t nblocks; + uint8_t control; + uint16_t padding; +} __attribute__((__packed__)) Read10CDB; + +static void send_scsi_cdb_read10(uint32_t lba, uint16_t nblocks) +{ + Read10CDB pkt = { .padding = 0 }; + int i; + + /* Construct SCSI CDB packet */ + pkt.opcode = 0x28; + pkt.lba = cpu_to_be32(lba); + pkt.nblocks = cpu_to_be16(nblocks); + + /* Send Packet */ + for (i = 0; i < sizeof(Read10CDB)/2; i++) { + outw(IDE_BASE + reg_data, ((uint16_t *)&pkt)[i]); + } +} + +static void nsleep(int64_t nsecs) +{ + const struct timespec val = { .tv_nsec = nsecs }; + nanosleep(&val, NULL); + clock_set(nsecs); +} + +static uint8_t ide_wait_clear(uint8_t flag) +{ + int i; + uint8_t data; + + /* Wait with a 5 second timeout */ + for (i = 0; i <= 12500000; i++) { + data = inb(IDE_BASE + reg_status); + if (!(data & flag)) { + return data; + } + nsleep(400); + } + g_assert_not_reached(); +} + +static void ide_wait_intr(int irq) +{ + int i; + bool intr; + + for (i = 0; i <= 12500000; i++) { + intr = get_irq(irq); + if (intr) { + return; + } + nsleep(400); + } + + g_assert_not_reached(); +} + +static void cdrom_pio_impl(int nblocks) +{ + FILE *fh; + int patt_blocks = MAX(16, nblocks); + size_t patt_len = ATAPI_BLOCK_SIZE * patt_blocks; + char *pattern = g_malloc(patt_len); + size_t rxsize = ATAPI_BLOCK_SIZE * nblocks; + uint16_t *rx = g_malloc0(rxsize); + int i, j; + uint8_t data; + uint16_t limit; + + /* Prepopulate the CDROM with an interesting pattern */ + generate_pattern(pattern, patt_len, ATAPI_BLOCK_SIZE); + fh = fopen(tmp_path, "w+"); + fwrite(pattern, ATAPI_BLOCK_SIZE, patt_blocks, fh); + fclose(fh); + + ide_test_start("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 " + "-device ide-cd,drive=sr0,bus=ide.0", tmp_path); + qtest_irq_intercept_in(global_qtest, "ioapic"); + + /* PACKET command on device 0 */ + outb(IDE_BASE + reg_device, 0); + outb(IDE_BASE + reg_lba_middle, BYTE_COUNT_LIMIT & 0xFF); + outb(IDE_BASE + reg_lba_high, (BYTE_COUNT_LIMIT >> 8 & 0xFF)); + outb(IDE_BASE + reg_command, CMD_PACKET); + /* HPD0: Check_Status_A State */ + nsleep(400); + data = ide_wait_clear(BSY); + /* HPD1: Send_Packet State */ + assert_bit_set(data, DRQ | DRDY); + assert_bit_clear(data, ERR | DF | BSY); + + /* SCSI CDB (READ10) -- read n*2048 bytes from block 0 */ + send_scsi_cdb_read10(0, nblocks); + + /* HPD3: INTRQ_Wait */ + ide_wait_intr(IDE_PRIMARY_IRQ); + + /* HPD2: Check_Status_B */ + data = ide_wait_clear(BSY); + assert_bit_set(data, DRQ | DRDY); + assert_bit_clear(data, ERR | DF | BSY); + + /* Read data back: occurs in bursts of 'BYTE_COUNT_LIMIT' bytes. + * If BYTE_COUNT_LIMIT is odd, we transfer BYTE_COUNT_LIMIT - 1 bytes. + * We allow an odd limit only when the remaining transfer size is + * less than BYTE_COUNT_LIMIT. However, SCSI's read10 command can only + * request n blocks, so our request size is always even. + * For this reason, we assume there is never a hanging byte to fetch. */ + g_assert(!(rxsize & 1)); + limit = BYTE_COUNT_LIMIT & ~1; + for (i = 0; i < DIV_ROUND_UP(rxsize, limit); i++) { + size_t offset = i * (limit / 2); + size_t rem = (rxsize / 2) - offset; + for (j = 0; j < MIN((limit / 2), rem); j++) { + rx[offset + j] = inw(IDE_BASE + reg_data); + } + ide_wait_intr(IDE_PRIMARY_IRQ); + } + data = ide_wait_clear(DRQ); + assert_bit_set(data, DRDY); + assert_bit_clear(data, DRQ | ERR | DF | BSY); + + g_assert_cmpint(memcmp(pattern, rx, rxsize), ==, 0); + g_free(pattern); + g_free(rx); + test_bmdma_teardown(); +} + +static void test_cdrom_pio(void) +{ + cdrom_pio_impl(1); +} + +static void test_cdrom_pio_large(void) +{ + /* Test a few loops of the PIO DRQ mechanism. */ + cdrom_pio_impl(BYTE_COUNT_LIMIT * 4 / ATAPI_BLOCK_SIZE); +} + int main(int argc, char **argv) { const char *arch = qtest_get_arch(); @@ -628,6 +782,9 @@ int main(int argc, char **argv) qtest_add_func("/ide/flush/retry_pci", test_pci_retry_flush); qtest_add_func("/ide/flush/retry_isa", test_isa_retry_flush); + qtest_add_func("/ide/cdrom/pio", test_cdrom_pio); + qtest_add_func("/ide/cdrom/pio_large", test_cdrom_pio_large); + ret = g_test_run(); /* Cleanup */ -- 2.4.3 From MAILER-DAEMON Thu Sep 10 19:41:08 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaBSm-00060M-LG for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 19:41:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaBSk-0005wi-5c for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:41:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaBRh-0003uK-EF for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:40:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34398) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaAy2-0000o1-7g; Thu, 10 Sep 2015 19:09:22 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id BEE488EA2E; Thu, 10 Sep 2015 23:09:21 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8AN9Gas010910; Thu, 10 Sep 2015 19:09:20 -0400 From: John Snow To: qemu-block@nongnu.org Date: Thu, 10 Sep 2015 19:09:15 -0400 Message-Id: <1441926555-19471-5-git-send-email-jsnow@redhat.com> In-Reply-To: <1441926555-19471-1-git-send-email-jsnow@redhat.com> References: <1441926555-19471-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, zuban32s@gmail.com, stefanha@redhat.com, pbonzini@redhat.com Subject: [Qemu-block] [PATCH v2 4/4] ide-test: add cdrom dma test X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 23:41:07 -0000 Now, test the DMA functionality of the ATAPI drive. Signed-off-by: John Snow --- tests/ide-test.c | 90 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 72 insertions(+), 18 deletions(-) diff --git a/tests/ide-test.c b/tests/ide-test.c index b3ddcf4..5594738 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -53,6 +53,7 @@ enum { reg_data = 0x0, + reg_feature = 0x1, reg_nsectors = 0x2, reg_lba_low = 0x3, reg_lba_middle = 0x4, @@ -179,7 +180,8 @@ typedef struct PrdtEntry { #define assert_bit_clear(data, mask) g_assert_cmphex((data) & (mask), ==, 0) static int send_dma_request(int cmd, uint64_t sector, int nb_sectors, - PrdtEntry *prdt, int prdt_entries) + PrdtEntry *prdt, int prdt_entries, + void(*post_exec)(uint64_t sector, int nb_sectors)) { QPCIDevice *dev; uint16_t bmdma_base; @@ -196,6 +198,9 @@ static int send_dma_request(int cmd, uint64_t sector, int nb_sectors, switch (cmd) { case CMD_READ_DMA: + case CMD_PACKET: + /* Assuming we only test data reads w/ ATAPI, otherwise we need to know + * the SCSI command being sent in the packet, too. */ from_dev = true; break; case CMD_WRITE_DMA: @@ -224,14 +229,22 @@ static int send_dma_request(int cmd, uint64_t sector, int nb_sectors, outl(bmdma_base + bmreg_prdt, guest_prdt); /* ATA DMA command */ - outb(IDE_BASE + reg_nsectors, nb_sectors); - - outb(IDE_BASE + reg_lba_low, sector & 0xff); - outb(IDE_BASE + reg_lba_middle, (sector >> 8) & 0xff); - outb(IDE_BASE + reg_lba_high, (sector >> 16) & 0xff); + if (cmd == CMD_PACKET) { + /* Enables ATAPI DMA; otherwise PIO is attempted */ + outb(IDE_BASE + reg_feature, 0x01); + } else { + outb(IDE_BASE + reg_nsectors, nb_sectors); + outb(IDE_BASE + reg_lba_low, sector & 0xff); + outb(IDE_BASE + reg_lba_middle, (sector >> 8) & 0xff); + outb(IDE_BASE + reg_lba_high, (sector >> 16) & 0xff); + } outb(IDE_BASE + reg_command, cmd); + if (post_exec) { + post_exec(sector, nb_sectors); + } + /* Start DMA transfer */ outb(bmdma_base + bmreg_cmd, BM_CMD_START | (from_dev ? BM_CMD_WRITE : 0)); @@ -285,7 +298,8 @@ static void test_bmdma_simple_rw(void) memset(buf, 0x55, len); memwrite(guest_buf, buf, len); - status = send_dma_request(CMD_WRITE_DMA, 0, 1, prdt, ARRAY_SIZE(prdt)); + status = send_dma_request(CMD_WRITE_DMA, 0, 1, prdt, + ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, BM_STS_INTR); assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR); @@ -293,14 +307,15 @@ static void test_bmdma_simple_rw(void) memset(buf, 0xaa, len); memwrite(guest_buf, buf, len); - status = send_dma_request(CMD_WRITE_DMA, 1, 1, prdt, ARRAY_SIZE(prdt)); + status = send_dma_request(CMD_WRITE_DMA, 1, 1, prdt, + ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, BM_STS_INTR); assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR); /* Read and verify 0x55 pattern in sector 0 */ memset(cmpbuf, 0x55, len); - status = send_dma_request(CMD_READ_DMA, 0, 1, prdt, ARRAY_SIZE(prdt)); + status = send_dma_request(CMD_READ_DMA, 0, 1, prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, BM_STS_INTR); assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR); @@ -310,7 +325,7 @@ static void test_bmdma_simple_rw(void) /* Read and verify 0xaa pattern in sector 1 */ memset(cmpbuf, 0xaa, len); - status = send_dma_request(CMD_READ_DMA, 1, 1, prdt, ARRAY_SIZE(prdt)); + status = send_dma_request(CMD_READ_DMA, 1, 1, prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, BM_STS_INTR); assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR); @@ -335,13 +350,13 @@ static void test_bmdma_short_prdt(void) /* Normal request */ status = send_dma_request(CMD_READ_DMA, 0, 1, - prdt, ARRAY_SIZE(prdt)); + prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, 0); assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR); /* Abort the request before it completes */ status = send_dma_request(CMD_READ_DMA | CMDF_ABORT, 0, 1, - prdt, ARRAY_SIZE(prdt)); + prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, 0); assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR); } @@ -360,13 +375,13 @@ static void test_bmdma_one_sector_short_prdt(void) /* Normal request */ status = send_dma_request(CMD_READ_DMA, 0, 2, - prdt, ARRAY_SIZE(prdt)); + prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, 0); assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR); /* Abort the request before it completes */ status = send_dma_request(CMD_READ_DMA | CMDF_ABORT, 0, 2, - prdt, ARRAY_SIZE(prdt)); + prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, 0); assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR); } @@ -384,13 +399,13 @@ static void test_bmdma_long_prdt(void) /* Normal request */ status = send_dma_request(CMD_READ_DMA, 0, 1, - prdt, ARRAY_SIZE(prdt)); + prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, BM_STS_ACTIVE | BM_STS_INTR); assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR); /* Abort the request before it completes */ status = send_dma_request(CMD_READ_DMA | CMDF_ABORT, 0, 1, - prdt, ARRAY_SIZE(prdt)); + prdt, ARRAY_SIZE(prdt), NULL); g_assert_cmphex(status, ==, BM_STS_INTR); assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR); } @@ -406,7 +421,7 @@ static void test_bmdma_no_busmaster(void) PrdtEntry prdt[4096] = { }; status = send_dma_request(CMD_READ_DMA | CMDF_NO_BM, 0, 512, - prdt, ARRAY_SIZE(prdt)); + prdt, ARRAY_SIZE(prdt), NULL); /* Not entirely clear what the expected result is, but this is what we get * in practice. At least we want to be aware of any changes. */ @@ -602,11 +617,15 @@ typedef struct Read10CDB { uint16_t padding; } __attribute__((__packed__)) Read10CDB; -static void send_scsi_cdb_read10(uint32_t lba, uint16_t nblocks) +static void send_scsi_cdb_read10(uint64_t lba, int nblocks) { Read10CDB pkt = { .padding = 0 }; int i; + g_assert_cmpint(lba, <=, UINT32_MAX); + g_assert_cmpint(nblocks, <=, UINT16_MAX); + g_assert_cmpint(nblocks, >=, 0); + /* Construct SCSI CDB packet */ pkt.opcode = 0x28; pkt.lba = cpu_to_be32(lba); @@ -739,6 +758,40 @@ static void test_cdrom_pio_large(void) cdrom_pio_impl(BYTE_COUNT_LIMIT * 4 / ATAPI_BLOCK_SIZE); } + +static void test_cdrom_dma(void) +{ + static const size_t len = ATAPI_BLOCK_SIZE; + char *pattern = g_malloc(ATAPI_BLOCK_SIZE * 16); + char *rx = g_malloc0(len); + uintptr_t guest_buf; + PrdtEntry prdt[1]; + FILE *fh; + + ide_test_start("-drive if=none,file=%s,media=cdrom,format=raw,id=sr0,index=0 " + "-device ide-cd,drive=sr0,bus=ide.0", tmp_path); + qtest_irq_intercept_in(global_qtest, "ioapic"); + + guest_buf = guest_alloc(guest_malloc, len); + prdt[0].addr = cpu_to_le32(guest_buf); + prdt[0].size = cpu_to_le32(len | PRDT_EOT); + + generate_pattern(pattern, ATAPI_BLOCK_SIZE * 16, ATAPI_BLOCK_SIZE); + fh = fopen(tmp_path, "w+"); + fwrite(pattern, ATAPI_BLOCK_SIZE, 16, fh); + fclose(fh); + + send_dma_request(CMD_PACKET, 0, 1, prdt, 1, send_scsi_cdb_read10); + + /* Read back data from guest memory into local qtest memory */ + memread(guest_buf, rx, len); + g_assert_cmpint(memcmp(pattern, rx, len), ==, 0); + + g_free(pattern); + g_free(rx); + test_bmdma_teardown(); +} + int main(int argc, char **argv) { const char *arch = qtest_get_arch(); @@ -784,6 +837,7 @@ int main(int argc, char **argv) qtest_add_func("/ide/cdrom/pio", test_cdrom_pio); qtest_add_func("/ide/cdrom/pio_large", test_cdrom_pio_large); + qtest_add_func("/ide/cdrom/dma", test_cdrom_dma); ret = g_test_run(); -- 2.4.3 From MAILER-DAEMON Thu Sep 10 19:42:46 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaBUM-0007LL-I3 for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 19:42:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaBUJ-0007KU-HR for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:42:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaBUG-0005uD-2s for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:42:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaAxy-0000nX-TW; Thu, 10 Sep 2015 19:09:18 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 366D7C0A5382; Thu, 10 Sep 2015 23:09:18 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8AN9Gao010910; Thu, 10 Sep 2015 19:09:17 -0400 From: John Snow To: qemu-block@nongnu.org Date: Thu, 10 Sep 2015 19:09:11 -0400 Message-Id: <1441926555-19471-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, zuban32s@gmail.com, stefanha@redhat.com, pbonzini@redhat.com Subject: [Qemu-block] [PATCH v2 0/4] ide: simple ATAPI tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 23:42:44 -0000 We don't have any CDROM tests yet. So, add some for the PCI/BMDMA HBA. === v2: === - Some readability feedback from Markus - Added an IRQ poll for the DRQ read loop ________________________________________________________________________________ For convenience, this branch is available at: https://github.com/jnsnow/qemu.git branch ide-atapi-test https://github.com/jnsnow/qemu/tree/ide-atapi-test This version is tagged ide-atapi-test-v2: https://github.com/jnsnow/qemu/releases/tag/ide-atapi-test-v2 John Snow (4): qtest/ahci: use generate_pattern everywhere qtest/ahci: export generate_pattern ide-test: add cdrom pio test ide-test: add cdrom dma test tests/ahci-test.c | 43 +-------- tests/ide-test.c | 245 ++++++++++++++++++++++++++++++++++++++++++++++---- tests/libqos/libqos.c | 26 ++++++ tests/libqos/libqos.h | 1 + 4 files changed, 258 insertions(+), 57 deletions(-) -- 2.4.3 From MAILER-DAEMON Thu Sep 10 19:43:16 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaBUq-0008Ay-0t for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 19:43:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaBUm-00086D-NB for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:43:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaBUl-0006AC-5Y for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:43:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56207) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaAy0-0000nr-CM; Thu, 10 Sep 2015 19:09:20 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id E92134DB01; Thu, 10 Sep 2015 23:09:19 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8AN9Gaq010910; Thu, 10 Sep 2015 19:09:19 -0400 From: John Snow To: qemu-block@nongnu.org Date: Thu, 10 Sep 2015 19:09:13 -0400 Message-Id: <1441926555-19471-3-git-send-email-jsnow@redhat.com> In-Reply-To: <1441926555-19471-1-git-send-email-jsnow@redhat.com> References: <1441926555-19471-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, zuban32s@gmail.com, stefanha@redhat.com, pbonzini@redhat.com Subject: [Qemu-block] [PATCH v2 2/4] qtest/ahci: export generate_pattern X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 23:43:14 -0000 Share the pattern function for ide and ahci test. Signed-off-by: John Snow --- tests/ahci-test.c | 26 -------------------------- tests/libqos/libqos.c | 26 ++++++++++++++++++++++++++ tests/libqos/libqos.h | 1 + 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/tests/ahci-test.c b/tests/ahci-test.c index b1a785c..59d387c 100644 --- a/tests/ahci-test.c +++ b/tests/ahci-test.c @@ -71,32 +71,6 @@ static void string_bswap16(uint16_t *s, size_t bytes) } } -static void generate_pattern(void *buffer, size_t len, size_t cycle_len) -{ - int i, j; - unsigned char *tx = (unsigned char *)buffer; - unsigned char p; - size_t *sx; - - /* Write an indicative pattern that varies and is unique per-cycle */ - p = rand() % 256; - for (i = 0; i < len; i++) { - tx[i] = p++ % 256; - if (i % cycle_len == 0) { - p = rand() % 256; - } - } - - /* force uniqueness by writing an id per-cycle */ - for (i = 0; i < len / cycle_len; i++) { - j = i * cycle_len; - if (j + sizeof(*sx) <= len) { - sx = (size_t *)&tx[j]; - *sx = i; - } - } -} - /** * Verify that the transfer did not corrupt our state at all. */ diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c index fce625b..8d7c5a9 100644 --- a/tests/libqos/libqos.c +++ b/tests/libqos/libqos.c @@ -212,3 +212,29 @@ void prepare_blkdebug_script(const char *debug_fn, const char *event) ret = fclose(debug_file); g_assert(ret == 0); } + +void generate_pattern(void *buffer, size_t len, size_t cycle_len) +{ + int i, j; + unsigned char *tx = (unsigned char *)buffer; + unsigned char p; + size_t *sx; + + /* Write an indicative pattern that varies and is unique per-cycle */ + p = rand() % 256; + for (i = 0; i < len; i++) { + tx[i] = p++ % 256; + if (i % cycle_len == 0) { + p = rand() % 256; + } + } + + /* force uniqueness by writing an id per-cycle */ + for (i = 0; i < len / cycle_len; i++) { + j = i * cycle_len; + if (j + sizeof(*sx) <= len) { + sx = (size_t *)&tx[j]; + *sx = i; + } + } +} diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h index e1f14ea..492a651 100644 --- a/tests/libqos/libqos.h +++ b/tests/libqos/libqos.h @@ -24,6 +24,7 @@ void mkqcow2(const char *file, unsigned size_mb); void set_context(QOSState *s); void migrate(QOSState *from, QOSState *to, const char *uri); void prepare_blkdebug_script(const char *debug_fn, const char *event); +void generate_pattern(void *buffer, size_t len, size_t cycle_len); static inline uint64_t qmalloc(QOSState *q, size_t bytes) { -- 2.4.3 From MAILER-DAEMON Thu Sep 10 19:43:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaBVL-0000dd-GI for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 19:43:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaBVI-0000a7-Ju for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:43:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaBVH-0006Ss-8G for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:43:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40042) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaAxz-0000nf-Ei; Thu, 10 Sep 2015 19:09:19 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 0B1E2C0A5381; Thu, 10 Sep 2015 23:09:19 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8AN9Gap010910; Thu, 10 Sep 2015 19:09:18 -0400 From: John Snow To: qemu-block@nongnu.org Date: Thu, 10 Sep 2015 19:09:12 -0400 Message-Id: <1441926555-19471-2-git-send-email-jsnow@redhat.com> In-Reply-To: <1441926555-19471-1-git-send-email-jsnow@redhat.com> References: <1441926555-19471-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, zuban32s@gmail.com, stefanha@redhat.com, pbonzini@redhat.com Subject: [Qemu-block] [PATCH v2 1/4] qtest/ahci: use generate_pattern everywhere X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 23:43:46 -0000 Fix the pattern generation to actually be interesting, and make sure all buffers in the ahci-test actually use it. Signed-off-by: John Snow --- tests/ahci-test.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/tests/ahci-test.c b/tests/ahci-test.c index 87d7691..b1a785c 100644 --- a/tests/ahci-test.c +++ b/tests/ahci-test.c @@ -80,9 +80,9 @@ static void generate_pattern(void *buffer, size_t len, size_t cycle_len) /* Write an indicative pattern that varies and is unique per-cycle */ p = rand() % 256; - for (i = j = 0; i < len; i++, j++) { - tx[i] = p; - if (j % cycle_len == 0) { + for (i = 0; i < len; i++) { + tx[i] = p++ % 256; + if (i % cycle_len == 0) { p = rand() % 256; } } @@ -1155,7 +1155,6 @@ static void ahci_migrate_simple(uint8_t cmd_read, uint8_t cmd_write) size_t bufsize = 4096; unsigned char *tx = g_malloc(bufsize); unsigned char *rx = g_malloc0(bufsize); - unsigned i; const char *uri = "tcp:127.0.0.1:1234"; src = ahci_boot_and_enable("-m 1024 -M q35 " @@ -1171,9 +1170,7 @@ static void ahci_migrate_simple(uint8_t cmd_read, uint8_t cmd_write) ahci_port_clear(src, px); /* create pattern */ - for (i = 0; i < bufsize; i++) { - tx[i] = (bufsize - i); - } + generate_pattern(tx, bufsize, AHCI_SECTOR_SIZE); /* Write, migrate, then read. */ ahci_io(src, px, cmd_write, tx, bufsize, 0); @@ -1213,7 +1210,6 @@ static void ahci_halted_io_test(uint8_t cmd_read, uint8_t cmd_write) size_t bufsize = 4096; unsigned char *tx = g_malloc(bufsize); unsigned char *rx = g_malloc0(bufsize); - unsigned i; uint64_t ptr; AHCICommand *cmd; @@ -1231,11 +1227,8 @@ static void ahci_halted_io_test(uint8_t cmd_read, uint8_t cmd_write) port = ahci_port_select(ahci); ahci_port_clear(ahci, port); - for (i = 0; i < bufsize; i++) { - tx[i] = (bufsize - i); - } - /* create DMA source buffer and write pattern */ + generate_pattern(tx, bufsize, AHCI_SECTOR_SIZE); ptr = ahci_alloc(ahci, bufsize); g_assert(ptr); memwrite(ptr, tx, bufsize); @@ -1282,7 +1275,6 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, uint8_t cmd_write) size_t bufsize = 4096; unsigned char *tx = g_malloc(bufsize); unsigned char *rx = g_malloc0(bufsize); - unsigned i; uint64_t ptr; AHCICommand *cmd; const char *uri = "tcp:127.0.0.1:1234"; @@ -1310,10 +1302,7 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, uint8_t cmd_write) /* Initialize and prepare */ port = ahci_port_select(src); ahci_port_clear(src, port); - - for (i = 0; i < bufsize; i++) { - tx[i] = (bufsize - i); - } + generate_pattern(tx, bufsize, AHCI_SECTOR_SIZE); /* create DMA source buffer and write pattern */ ptr = ahci_alloc(src, bufsize); -- 2.4.3 From MAILER-DAEMON Thu Sep 10 19:47:36 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaBZ2-0002cz-AL for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 19:47:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaBYz-0002cS-9W for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:47:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaBYu-0003Ks-9k for qemu-block@nongnu.org; Thu, 10 Sep 2015 19:47:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51807) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaBYu-0003KH-37; Thu, 10 Sep 2015 19:47:28 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 78ACCA86; Thu, 10 Sep 2015 23:47:27 +0000 (UTC) Received: from [10.3.113.15] ([10.3.113.15]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8ANlQ8R030202; Thu, 10 Sep 2015 19:47:26 -0400 To: John Snow , qemu-block@nongnu.org References: <1441926555-19471-1-git-send-email-jsnow@redhat.com> <1441926555-19471-2-git-send-email-jsnow@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55F21689.1080608@redhat.com> Date: Thu, 10 Sep 2015 17:47:21 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441926555-19471-2-git-send-email-jsnow@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="EGTTh1dV9G4uHdVBtxoX4WNQqJtMOKTDa" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, zuban32s@gmail.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com Subject: Re: [Qemu-block] [PATCH v2 1/4] qtest/ahci: use generate_pattern everywhere X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 23:47:34 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --EGTTh1dV9G4uHdVBtxoX4WNQqJtMOKTDa Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/10/2015 05:09 PM, John Snow wrote: > Fix the pattern generation to actually be interesting, > and make sure all buffers in the ahci-test actually use it. >=20 > Signed-off-by: John Snow > --- > tests/ahci-test.c | 23 ++++++----------------- > 1 file changed, 6 insertions(+), 17 deletions(-) >=20 > diff --git a/tests/ahci-test.c b/tests/ahci-test.c > index 87d7691..b1a785c 100644 > --- a/tests/ahci-test.c > +++ b/tests/ahci-test.c > @@ -80,9 +80,9 @@ static void generate_pattern(void *buffer, size_t len= , size_t cycle_len) > =20 > /* Write an indicative pattern that varies and is unique per-cycle= */ > p =3D rand() % 256; > - for (i =3D j =3D 0; i < len; i++, j++) { > - tx[i] =3D p; > - if (j % cycle_len =3D=3D 0) { > + for (i =3D 0; i < len; i++) { > + tx[i] =3D p++ % 256; > + if (i % cycle_len =3D=3D 0) { > p =3D rand() % 256; I'd drop the pointless %256, since the compiler already automatically truncates int to char when assigning to a char variable. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --EGTTh1dV9G4uHdVBtxoX4WNQqJtMOKTDa Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV8haJAAoJEKeha0olJ0Nq05oIAI+oLpJhPXtYmPr10hlsuvGI ku3RJeXdAjlQVLjBT+aukStCY8ytmv3u4JtD4f+M/rs+WhRq7Iy0EUDCF/NutIEf e04n6sdeTMERToltW+2vXWrSlxWpblRIehScDrTNIRyz/tfzemwBQlkxNZmLZz1p kNGI9OOMYJc27DvgyC/zCfIk5fekRzRFTleQgzun1esZi5yjH5Vb3k9EM+vA4j6C zJhCmg1zf7S+xWuHRay4zPG3rWmj1X25fbZ88Ooi9kiT3YUdJ+t7fO+hoUu+K+iR lMR1DeoT17uu7HTZjCl5cuQ0EIbL5S87Y82G/LQGcy36n/dTDqN8y0vPbkwA5yc= =t5X2 -----END PGP SIGNATURE----- --EGTTh1dV9G4uHdVBtxoX4WNQqJtMOKTDa-- From MAILER-DAEMON Thu Sep 10 23:11:51 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaEkh-0007c3-P5 for mharc-qemu-block@gnu.org; Thu, 10 Sep 2015 23:11:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaEkf-0007bp-BJ for qemu-block@nongnu.org; Thu, 10 Sep 2015 23:11:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaEka-00005d-Cj for qemu-block@nongnu.org; Thu, 10 Sep 2015 23:11:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42869) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaEka-00005T-8k; Thu, 10 Sep 2015 23:11:44 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 95EFD2F02C5; Fri, 11 Sep 2015 03:11:43 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8B3BfAl027932; Thu, 10 Sep 2015 23:11:42 -0400 Date: Fri, 11 Sep 2015 11:11:41 +0800 From: Fam Zheng To: John Snow Message-ID: <20150911031141.GA2592@ad.nay.redhat.com> References: <1441927256-24625-1-git-send-email-jsnow@redhat.com> <1441927256-24625-2-git-send-email-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441927256-24625-2-git-send-email-jsnow@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 1/1] atapi: abort transfers with 0 byte limits X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 03:11:50 -0000 On Thu, 09/10 19:20, John Snow wrote: > > + /* Nondata commands permit the byte_count_limit to be 0. > + * If this is a data-transferring PIO command and BCL is 0, > + * we abort at the /ATA/ level, not the ATAPI level. > + * See ATA8 ACS3 section 7.17.6.49 and 7.21.5 */ > + if (!(atapi_cmd_table[s->io_buffer[0]].flags & NONDATA)) { > + /* TODO: Check IDENTIFY data word 125 for default BCL (currently 0) */ > + uint16_t byte_count_limit = s->lcyl | (s->hcyl << 8); > + if !(byte_count_limit || s->atapi_dma) { !( ? Fam From MAILER-DAEMON Fri Sep 11 02:00:46 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaHOA-0003Vl-OC for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 02:00:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41433) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaHO7-0003NP-Ns for qemu-block@nongnu.org; Fri, 11 Sep 2015 02:00:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaHO3-0008D0-MD for qemu-block@nongnu.org; Fri, 11 Sep 2015 02:00:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45854) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaHO3-0008Cq-Fc; Fri, 11 Sep 2015 02:00:39 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id D23A68C1C3; Fri, 11 Sep 2015 06:00:38 +0000 (UTC) Received: from cpc-pc.redhat.com (vpn1-5-176.pek2.redhat.com [10.72.5.176]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8B60ZEB032020; Fri, 11 Sep 2015 02:00:36 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 11 Sep 2015 14:00:52 +0800 Message-Id: <1441951252-13439-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , Peter Lieven , qemu-block@nongnu.org, Ronnie Sahlberg Subject: [Qemu-block] [PATCH] iscsi: Add chap and "initiator-name" etc as per drive options X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 06:00:45 -0000 Previously we use "-iscsi id=target-iqn,user=foo,password=bar,..." to specify iscsi connection parameters, unfortunately it doesn't work with qemu-img. This patch adds per drive options to iscsi driver so that at least qemu-img can use the "json:{...}" filename magic. Signed-off-by: Fam Zheng --- block/iscsi.c | 83 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 19 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index 5002916..9efb9ec 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1011,7 +1011,9 @@ retry: return 0; } -static void parse_chap(struct iscsi_context *iscsi, const char *target, +static void parse_chap(struct iscsi_context *iscsi, + QemuOpts *img_opts, + const char *target, Error **errp) { QemuOptsList *list; @@ -1025,19 +1027,22 @@ static void parse_chap(struct iscsi_context *iscsi, const char *target, } opts = qemu_opts_find(list, target); - if (opts == NULL) { + if (!opts) { opts = QTAILQ_FIRST(&list->head); - if (!opts) { - return; - } } - user = qemu_opt_get(opts, "user"); + user = qemu_opt_get(img_opts, "user"); + if (!user && opts) { + user = qemu_opt_get(opts, "user"); + } if (!user) { return; } - password = qemu_opt_get(opts, "password"); + password = qemu_opt_get(img_opts, "password"); + if (!password && opts) { + password = qemu_opt_get(opts, "password"); + } if (!password) { error_setg(errp, "CHAP username specified but no password was given"); return; @@ -1048,13 +1053,20 @@ static void parse_chap(struct iscsi_context *iscsi, const char *target, } } -static void parse_header_digest(struct iscsi_context *iscsi, const char *target, +static void parse_header_digest(struct iscsi_context *iscsi, + QemuOpts *img_opts, + const char *target, Error **errp) { QemuOptsList *list; QemuOpts *opts; const char *digest = NULL; + digest = qemu_opt_get(img_opts, "header-digest"); + if (digest) { + goto found; + } + list = qemu_find_opts("iscsi"); if (!list) { return; @@ -1073,6 +1085,7 @@ static void parse_header_digest(struct iscsi_context *iscsi, const char *target, return; } +found: if (!strcmp(digest, "CRC32C")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C); } else if (!strcmp(digest, "NONE")) { @@ -1086,7 +1099,7 @@ static void parse_header_digest(struct iscsi_context *iscsi, const char *target, } } -static char *parse_initiator_name(const char *target) +static char *parse_initiator_name(QemuOpts *img_opts, const char *target) { QemuOptsList *list; QemuOpts *opts; @@ -1094,6 +1107,11 @@ static char *parse_initiator_name(const char *target) char *iscsi_name; UuidInfo *uuid_info; + name = qemu_opt_get(img_opts, "initiator-name"); + if (name) { + return g_strdup(name); + } + list = qemu_find_opts("iscsi"); if (list) { opts = qemu_opts_find(list, target); @@ -1120,12 +1138,17 @@ static char *parse_initiator_name(const char *target) return iscsi_name; } -static int parse_timeout(const char *target) +static int parse_timeout(QemuOpts *img_opts, const char *target) { QemuOptsList *list; QemuOpts *opts; const char *timeout; + timeout = qemu_opt_get(img_opts, "iscsi"); + if (timeout) { + goto out; + } + list = qemu_find_opts("iscsi"); if (list) { opts = qemu_opts_find(list, target); @@ -1134,13 +1157,14 @@ static int parse_timeout(const char *target) } if (opts) { timeout = qemu_opt_get(opts, "timeout"); - if (timeout) { - return atoi(timeout); - } } } - - return 0; +out: + if (timeout) { + return atoi(timeout); + } else { + return 0; + } } static void iscsi_nop_timed_event(void *opaque) @@ -1229,6 +1253,27 @@ static QemuOptsList runtime_opts = { .name = "filename", .type = QEMU_OPT_STRING, .help = "URL to the iscsi image", + },{ + .name = "user", + .type = QEMU_OPT_STRING, + .help = "username for CHAP authentication to target", + },{ + .name = "password", + .type = QEMU_OPT_STRING, + .help = "password for CHAP authentication to target", + },{ + .name = "header-digest", + .type = QEMU_OPT_STRING, + .help = "HeaderDigest setting. " + "{CRC32C|CRC32C-NONE|NONE-CRC32C|NONE}", + },{ + .name = "initiator-name", + .type = QEMU_OPT_STRING, + .help = "Initiator iqn name to use when connecting", + },{ + .name = "timeout", + .type = QEMU_OPT_NUMBER, + .help = "Request timeout in seconds (default 0 = no timeout)", }, { /* end of list */ } }, @@ -1390,7 +1435,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, memset(iscsilun, 0, sizeof(IscsiLun)); - initiator_name = parse_initiator_name(iscsi_url->target); + initiator_name = parse_initiator_name(opts, iscsi_url->target); iscsi = iscsi_create_context(initiator_name); if (iscsi == NULL) { @@ -1416,7 +1461,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, } /* check if we got CHAP username/password via the options */ - parse_chap(iscsi, iscsi_url->target, &local_err); + parse_chap(iscsi, opts, iscsi_url->target, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); ret = -EINVAL; @@ -1432,7 +1477,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); /* check if we got HEADER_DIGEST via the options */ - parse_header_digest(iscsi, iscsi_url->target, &local_err); + parse_header_digest(iscsi, opts, iscsi_url->target, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); ret = -EINVAL; @@ -1440,7 +1485,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, } /* timeout handling is broken in libiscsi before 1.15.0 */ - timeout = parse_timeout(iscsi_url->target); + timeout = parse_timeout(opts, iscsi_url->target); #if defined(LIBISCSI_API_VERSION) && LIBISCSI_API_VERSION >= 20150621 iscsi_set_timeout(iscsi, timeout); #else -- 2.5.0 From MAILER-DAEMON Fri Sep 11 02:56:45 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaIGL-0001ng-3c for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 02:56:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaIGI-0001mm-1q for qemu-block@nongnu.org; Fri, 11 Sep 2015 02:56:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaIGE-0004HT-T6 for qemu-block@nongnu.org; Fri, 11 Sep 2015 02:56:41 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:36201) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaIGE-0003yN-LE; Fri, 11 Sep 2015 02:56:38 -0400 Received: from tsrv.tls.msk.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id CFC2A413F3; Fri, 11 Sep 2015 09:56:29 +0300 (MSK) Received: from [192.168.88.2] (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.tls.msk.ru (Postfix) with ESMTP id A4EE2A52; Fri, 11 Sep 2015 09:56:29 +0300 (MSK) Message-ID: <55F27B1D.4030901@msgid.tls.msk.ru> Date: Fri, 11 Sep 2015 09:56:29 +0300 From: Michael Tokarev Organization: Telecom Service, JSC User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: John Snow , qemu-block@nongnu.org References: <1441816082-21031-1-git-send-email-jsnow@redhat.com> In-Reply-To: <1441816082-21031-1-git-send-email-jsnow@redhat.com> OpenPGP: id=804465C5 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 86.62.121.231 Cc: kwolf@redhat.com, stefano.stabellini@eu.citrix.com, armbru@redhat.com, qemu-devel@nongnu.org, ppandit@redhat.com, luodalongde@gmail.com, liuling-it@360.cn Subject: Re: [Qemu-block] [PATCH] ide: fix ATAPI command permissions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 06:56:43 -0000 09.09.2015 19:28, John Snow wrote: > We're a little too lenient with what we'll let an ATAPI drive handle. > Clamp down on the IDE command execution table to remove CD_OK permissions > from commands that are not and have never been ATAPI commands. FWIW, this issue has been assigned CVE-2015-6855 identifier, which can be reflected in the commit message when applying. Since this issue has security impact, it might be a good idea to add Cc: qemu-stable@nongnu.org Thanks, /mjt From MAILER-DAEMON Fri Sep 11 03:31:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaIni-0006vJ-Rv for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 03:31:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaInd-0006lO-6I for qemu-block@nongnu.org; Fri, 11 Sep 2015 03:31:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaInY-0004rs-Ti for qemu-block@nongnu.org; Fri, 11 Sep 2015 03:31:09 -0400 Received: from [59.151.112.132] (port=10764 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaInS-0004la-7B; Fri, 11 Sep 2015 03:30:59 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100602511" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 11 Sep 2015 15:33:51 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8B7Ug23011873; Fri, 11 Sep 2015 15:30:42 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Fri, 11 Sep 2015 15:30:54 +0800 To: Max Reitz , References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-30-git-send-email-mreitz@redhat.com> <55EEA69E.4010706@cn.fujitsu.com> <55EF5133.2040807@redhat.com> <55F00363.5080709@cn.fujitsu.com> <55F02D3D.6020102@redhat.com> <55F0D901.1010607@cn.fujitsu.com> <55F1D575.9020909@redhat.com> From: Wen Congyang Message-ID: <55F28308.5030303@cn.fujitsu.com> Date: Fri, 11 Sep 2015 15:30:16 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F1D575.9020909@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 29/38] blockdev: Add blockdev-insert-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 07:31:13 -0000 On 09/11/2015 03:09 AM, Max Reitz wrote: > On 10.09.2015 03:12, Wen Congyang wrote: >> On 09/09/2015 08:59 PM, Max Reitz wrote: >>> On 09.09.2015 12:01, Wen Congyang wrote: >>>> On 09/09/2015 05:20 AM, Max Reitz wrote: >>>>> On 08.09.2015 11:13, Wen Congyang wrote: >>>>>> On 07/21/2015 01:45 AM, 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). >>>>>>> >>>>>>> Signed-off-by: Max Reitz >>>>>>> --- >>>>>>> blockdev.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ >>>>>>> qapi/block-core.json | 17 +++++++++++++++++ >>>>>>> qmp-commands.hx | 37 +++++++++++++++++++++++++++++++++++++ >>>>>>> 3 files changed, 102 insertions(+) >>>>>>> >>>>>>> diff --git a/blockdev.c b/blockdev.c >>>>>>> index 481760a..a80d0e2 100644 >>>>>>> --- a/blockdev.c >>>>>>> +++ b/blockdev.c >>>>>>> @@ -2164,6 +2164,54 @@ void qmp_blockdev_remove_medium(const char *device, Error **errp) >>>>>>> } >>>>>>> } >>>>>>> >>>>>>> +static void qmp_blockdev_insert_anon_medium(const char *device, >>>>>>> + BlockDriverState *bs, Error **errp) >>>>>>> +{ >>>>>>> + BlockBackend *blk; >>>>>>> + bool has_device; >>>>>>> + >>>>>>> + blk = blk_by_name(device); >>>>>>> + if (!blk) { >>>>>>> + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, >>>>>>> + "Device '%s' not found", device); >>>>>>> + return; >>>>>>> + } >>>>>>> + >>>>>>> + /* For BBs without a device, we can exchange the BDS tree at will */ >>>>>>> + has_device = blk_get_attached_dev(blk); >>>>>>> + >>>>>>> + if (has_device && !blk_dev_has_removable_media(blk)) { >>>>>>> + error_setg(errp, "Device '%s' is not removable", device); >>>>>>> + return; >>>>>>> + } >>>>>>> + >>>>>>> + if (has_device && !blk_dev_is_tray_open(blk)) { >>>>>>> + error_setg(errp, "Tray of device '%s' is not open", device); >>>>>>> + return; >>>>>>> + } >>>>>>> + >>>>>>> + if (blk_bs(blk)) { >>>>>>> + error_setg(errp, "There already is a medium in device '%s'", device); >>>>>>> + return; >>>>>>> + } >>>>>>> + >>>>>>> + blk_insert_bs(blk, bs); >>>>>>> +} >>>>>>> + >>>>>>> +void qmp_blockdev_insert_medium(const char *device, const char *node_name, >>>>>>> + Error **errp) >>>>>>> +{ >>>>>>> + BlockDriverState *bs; >>>>>>> + >>>>>>> + bs = bdrv_find_node(node_name); >>>>>>> + if (!bs) { >>>>>>> + error_setg(errp, "Node '%s' not found", node_name); >>>>>>> + return; >>>>>>> + } >>>>>> >>>>>> Hmm, it is OK if the bs is not top BDS? >>>>> >>>>> I think so, yes. Generally, there's probably no reason to do that, but I >>>>> don't know why we should not allow that case. For instance, you might >>>>> want to make a backing file available read-only somewhere. >>>>> >>>>> It should be impossible to make it available writable, and it should not >>>>> be allowed to start a block-commit operation while the backing file can >>>>> be accessed by the guest, but this should be achieved using op blockers. >>>>> >>>>> What we need for this to work are fine-grained op blockers, I think. But >>>>> working around that for now by only allowing to insert top BDS won't >>>>> work, since you can still start block jobs which target top BDS, too >>>>> (e.g. blockdev-backup can write to a BDS/BB that is visible to the guest). >>>>> >>>>> All in all, I think it's fine to insert non-top BDS, but we should >>>>> definitely worry about which exact BDS one can insert once we have >>>>> fine-grained op blockers. >>>> >>>> A BDS can be written by its parent, its block backend, a block job.. >>>> So I think we should have some way to avoid more than two sources writing >>>> to it, otherwise the data may be corrupted. >>> >>> Yes, and that would be op blockers. >>> >>> As I said, using blockdev-backup you can write to a BB that can be >>> written to by the guest as well. I think this is a bug, but it is a bug >>> that needs to be fixed by having better op blockers in place, which Jeff >>> Cody is working on. >>> >>> Regarding this series, I don't consider this to be too big of an issue. >>> Yes, if you are working with floppy disks, you can have the case of a >>> block job and the guest writing to the BDS at the same time. But I can't >>> really imagine who would use floppy disks and block jobs at the same >>> time (people who still use floppy disks for their VMs don't strike me as >>> the kind of people who use the management features of qemu, especially >>> not for those floppy disks). >>> >>> Other than that, this function (blockdev-insert-medium) can only be used >>> for optical ROM devices (I don't think we have CD/DVD-RW support, do >>> we?), so it's much less of an issue there. >>> >>> So all in all I don't consider this too big of an issue here. If others >>> think different, then I would delay this part of the series (which >>> overhauls the "change" command) until we have fine-grained op blockers. >> >> In most cases, the user uses this command to change CD/DVD media, so it is OK. >> But IIRC scsi disk can also be changed. So we can mark this command as experimental >> (the command name can be x-blockdev-insert-medium). > > I'd rather delay this part than mark it experimental. But then again, > seeing that we have cases like this already (i.e. blockdev-backup) and > nobody seems to be complaining, I still think it should be fine. Hmm, another question, when will you post the newest patchset? Block replication is based on this patchset. Thanks Wen Congyang > > Max > From MAILER-DAEMON Fri Sep 11 04:15:35 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaJUd-0004dE-DA for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 04:15:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaJUY-0004d1-GM for qemu-block@nongnu.org; Fri, 11 Sep 2015 04:15:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaJUU-0007Ic-6a for qemu-block@nongnu.org; Fri, 11 Sep 2015 04:15:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaJUU-0007IQ-1H; Fri, 11 Sep 2015 04:15:26 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 747522F2F8F; Fri, 11 Sep 2015 08:15:25 +0000 (UTC) Received: from [10.36.112.66] (ovpn-112-66.ams2.redhat.com [10.36.112.66]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8B8FKTO021144 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 11 Sep 2015 04:15:22 -0400 To: Fam Zheng References: <1438144934-23619-1-git-send-email-famz@redhat.com> <1438144934-23619-12-git-send-email-famz@redhat.com> <55B882C1.8070500@redhat.com> <20150729105725.GA10376@ad.nay.redhat.com> <55B8B2C3.9050307@redhat.com> <20150729115333.GA15022@ad.nay.redhat.com> <55B8C12D.2070105@redhat.com> <20150909032205.GA10922@ad.nay.redhat.com> From: Paolo Bonzini Message-ID: <55F28D99.5060908@redhat.com> Date: Fri, 11 Sep 2015 10:15:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150909032205.GA10922@ad.nay.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 11/11] block: Only poll block layer fds in bdrv_aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 08:15:34 -0000 On 09/09/2015 05:22, Fam Zheng wrote: > Another advantage for bdrv_aio_poll() is, in main loop we will not need > a separate AioContext in changes like: > > http://patchwork.ozlabs.org/patch/514968/ > > Because nested aio_poll will automatically be limited to only process block > layer events. My idea is to eventually let main loop use aio_poll That would be a step back. Using GSource is useful because it lets you integrate libraries such as GTK+. Paolo > , which means > we would also move chardev onto it. It would be neat to put all fds of the main > thread into a single AioContext. From MAILER-DAEMON Fri Sep 11 05:14:42 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaKPq-0002Df-BO for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 05:14:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaKPo-0002AF-0O for qemu-block@nongnu.org; Fri, 11 Sep 2015 05:14:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaKPk-0005Uz-RO for qemu-block@nongnu.org; Fri, 11 Sep 2015 05:14:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaKPk-0005Ut-N0; Fri, 11 Sep 2015 05:14:36 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id CA3902F2F85; Fri, 11 Sep 2015 09:14:35 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8B9EYjp025225; Fri, 11 Sep 2015 05:14:35 -0400 Date: Fri, 11 Sep 2015 17:14:33 +0800 From: Fam Zheng To: Paolo Bonzini Message-ID: <20150911091433.GA6759@ad.nay.redhat.com> References: <1438144934-23619-1-git-send-email-famz@redhat.com> <1438144934-23619-12-git-send-email-famz@redhat.com> <55B882C1.8070500@redhat.com> <20150729105725.GA10376@ad.nay.redhat.com> <55B8B2C3.9050307@redhat.com> <20150729115333.GA15022@ad.nay.redhat.com> <55B8C12D.2070105@redhat.com> <20150909032205.GA10922@ad.nay.redhat.com> <55F28D99.5060908@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55F28D99.5060908@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 11/11] block: Only poll block layer fds in bdrv_aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 09:14:40 -0000 On Fri, 09/11 10:15, Paolo Bonzini wrote: > > > On 09/09/2015 05:22, Fam Zheng wrote: > > Another advantage for bdrv_aio_poll() is, in main loop we will not need > > a separate AioContext in changes like: > > > > http://patchwork.ozlabs.org/patch/514968/ > > > > Because nested aio_poll will automatically be limited to only process block > > layer events. My idea is to eventually let main loop use aio_poll > > That would be a step back. Using GSource is useful because it lets you > integrate libraries such as GTK+. Can we move GTK to a separate GSource thread? Fam From MAILER-DAEMON Fri Sep 11 05:36:50 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaKlF-0004b2-Tr for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 05:36:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaKlD-0004WA-54 for qemu-block@nongnu.org; Fri, 11 Sep 2015 05:36:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaKlB-0002Gg-RI for qemu-block@nongnu.org; Fri, 11 Sep 2015 05:36:47 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:13915 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaKl6-0002Dg-Qk; Fri, 11 Sep 2015 05:36:40 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2ApAgA/oPJV/5tjdVtdGQEBAYMHVGmpJgUBgQoBknsBDYF4hXkCgVA4FAEBAQEBAQGBCoQkAQEDATo/EAshJQ8BLBsGARKIJgwBCMtRAQEBAQEBAQMBAQEBAR2GLIVEhDRZB4QsBZVWhQqKAoxjjAQfAQFCgkKBQDwziFeBSAEBAQ X-IPAS-Result: A2ApAgA/oPJV/5tjdVtdGQEBAYMHVGmpJgUBgQoBknsBDYF4hXkCgVA4FAEBAQEBAQGBCoQkAQEDATo/EAshJQ8BLBsGARKIJgwBCMtRAQEBAQEBAQMBAQEBAR2GLIVEhDRZB4QsBZVWhQqKAoxjjAQfAQFCgkKBQDwziFeBSAEBAQ X-IronPort-AV: E=Sophos;i="5.17,511,1437429600"; d="scan'208";a="20468888" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 11 Sep 2015 11:36:10 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZaKkc-000424-9s; Fri, 11 Sep 2015 11:36:10 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZaKkc-0003nP-3j; Fri, 11 Sep 2015 11:36:10 +0200 From: Alberto Garcia To: Fam Zheng , Paolo Bonzini In-Reply-To: <20150911091433.GA6759@ad.nay.redhat.com> References: <1438144934-23619-1-git-send-email-famz@redhat.com> <1438144934-23619-12-git-send-email-famz@redhat.com> <55B882C1.8070500@redhat.com> <20150729105725.GA10376@ad.nay.redhat.com> <55B8B2C3.9050307@redhat.com> <20150729115333.GA15022@ad.nay.redhat.com> <55B8C12D.2070105@redhat.com> <20150909032205.GA10922@ad.nay.redhat.com> <55F28D99.5060908@redhat.com> <20150911091433.GA6759@ad.nay.redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Fri, 11 Sep 2015 11:36:10 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 11/11] block: Only poll block layer fds in bdrv_aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 09:36:48 -0000 On Fri 11 Sep 2015 11:14:33 AM CEST, Fam Zheng wrote: >> > Another advantage for bdrv_aio_poll() is, in main loop we will not >> > need a separate AioContext in changes like: >> > >> > http://patchwork.ozlabs.org/patch/514968/ >> > >> > Because nested aio_poll will automatically be limited to only >> > process block layer events. My idea is to eventually let main loop >> > use aio_poll >> >> That would be a step back. Using GSource is useful because it lets >> you integrate libraries such as GTK+. > > Can we move GTK to a separate GSource thread? I think that GTK should always run in the main thread, or at least the one running the default main loop / GMainContext. Berto From MAILER-DAEMON Fri Sep 11 05:43:56 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaKs8-00006Y-Nk for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 05:43:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60534) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaKs6-0008Vd-GE for qemu-block@nongnu.org; Fri, 11 Sep 2015 05:43:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaKs2-00062u-Rh for qemu-block@nongnu.org; Fri, 11 Sep 2015 05:43:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48835) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaKs2-00062o-NI; Fri, 11 Sep 2015 05:43:50 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 3FBC78E698; Fri, 11 Sep 2015 09:43:50 +0000 (UTC) Received: from redhat.com (vpn1-4-166.ams2.redhat.com [10.36.4.166]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8B9hjIP012345 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 11 Sep 2015 05:43:48 -0400 Date: Fri, 11 Sep 2015 10:43:45 +0100 From: "Daniel P. Berrange" To: Alberto Garcia Message-ID: <20150911094345.GC21525@redhat.com> References: <1438144934-23619-12-git-send-email-famz@redhat.com> <55B882C1.8070500@redhat.com> <20150729105725.GA10376@ad.nay.redhat.com> <55B8B2C3.9050307@redhat.com> <20150729115333.GA15022@ad.nay.redhat.com> <55B8C12D.2070105@redhat.com> <20150909032205.GA10922@ad.nay.redhat.com> <55F28D99.5060908@redhat.com> <20150911091433.GA6759@ad.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, Fam Zheng , qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com, Paolo Bonzini Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 11/11] block: Only poll block layer fds in bdrv_aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 09:43:55 -0000 On Fri, Sep 11, 2015 at 11:36:10AM +0200, Alberto Garcia wrote: > On Fri 11 Sep 2015 11:14:33 AM CEST, Fam Zheng wrote: > > >> > Another advantage for bdrv_aio_poll() is, in main loop we will not > >> > need a separate AioContext in changes like: > >> > > >> > http://patchwork.ozlabs.org/patch/514968/ > >> > > >> > Because nested aio_poll will automatically be limited to only > >> > process block layer events. My idea is to eventually let main loop > >> > use aio_poll > >> > >> That would be a step back. Using GSource is useful because it lets > >> you integrate libraries such as GTK+. > > > > Can we move GTK to a separate GSource thread? > > I think that GTK should always run in the main thread, or at least the > one running the default main loop / GMainContext. In theory GTK can run from a separate thread, but my experiance with GTK and threads is that you end up in a world of hurt if you try to anything except use the main thread, so I'd really recommend against it. Even if you do extensive testing locally, things still break across different GTK versions people have, so its just not worth the pain. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From MAILER-DAEMON Fri Sep 11 05:44:32 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaKsi-0000ym-EM for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 05:44:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaKsg-0000wO-Oq for qemu-block@nongnu.org; Fri, 11 Sep 2015 05:44:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaKsf-0006Db-OH for qemu-block@nongnu.org; Fri, 11 Sep 2015 05:44:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55662) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaKsf-0006DW-IO; Fri, 11 Sep 2015 05:44:29 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 27143C0B2B79; Fri, 11 Sep 2015 09:44:29 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8B9iQP9007998; Fri, 11 Sep 2015 05:44:28 -0400 Date: Fri, 11 Sep 2015 17:44:25 +0800 From: Fam Zheng To: Alberto Garcia Message-ID: <20150911094425.GA9241@ad.nay.redhat.com> References: <1438144934-23619-12-git-send-email-famz@redhat.com> <55B882C1.8070500@redhat.com> <20150729105725.GA10376@ad.nay.redhat.com> <55B8B2C3.9050307@redhat.com> <20150729115333.GA15022@ad.nay.redhat.com> <55B8C12D.2070105@redhat.com> <20150909032205.GA10922@ad.nay.redhat.com> <55F28D99.5060908@redhat.com> <20150911091433.GA6759@ad.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, Paolo Bonzini , stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 11/11] block: Only poll block layer fds in bdrv_aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 09:44:31 -0000 On Fri, 09/11 11:36, Alberto Garcia wrote: > On Fri 11 Sep 2015 11:14:33 AM CEST, Fam Zheng wrote: > > >> > Another advantage for bdrv_aio_poll() is, in main loop we will not > >> > need a separate AioContext in changes like: > >> > > >> > http://patchwork.ozlabs.org/patch/514968/ > >> > > >> > Because nested aio_poll will automatically be limited to only > >> > process block layer events. My idea is to eventually let main loop > >> > use aio_poll > >> > >> That would be a step back. Using GSource is useful because it lets > >> you integrate libraries such as GTK+. > > > > Can we move GTK to a separate GSource thread? > > I think that GTK should always run in the main thread, or at least the > one running the default main loop / GMainContext. Yeah it's basically GMainContext staying in the main thread and block/net/chardev I/O put in a new AioContext thread. Fam From MAILER-DAEMON Fri Sep 11 05:45:45 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaKtt-0002ZA-38 for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 05:45:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaKtr-0002Z0-DE for qemu-block@nongnu.org; Fri, 11 Sep 2015 05:45:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaKtm-00074f-OP for qemu-block@nongnu.org; Fri, 11 Sep 2015 05:45:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32925) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaKtm-00074N-Il; Fri, 11 Sep 2015 05:45:38 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id A47D9461EF; Fri, 11 Sep 2015 09:45:37 +0000 (UTC) Received: from [10.36.112.66] (ovpn-112-66.ams2.redhat.com [10.36.112.66]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8B9jXGP002380 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 11 Sep 2015 05:45:35 -0400 To: Alberto Garcia , Fam Zheng References: <1438144934-23619-1-git-send-email-famz@redhat.com> <1438144934-23619-12-git-send-email-famz@redhat.com> <55B882C1.8070500@redhat.com> <20150729105725.GA10376@ad.nay.redhat.com> <55B8B2C3.9050307@redhat.com> <20150729115333.GA15022@ad.nay.redhat.com> <55B8C12D.2070105@redhat.com> <20150909032205.GA10922@ad.nay.redhat.com> <55F28D99.5060908@redhat.com> <20150911091433.GA6759@ad.nay.redhat.com> From: Paolo Bonzini Message-ID: <55F2A2BD.2020805@redhat.com> Date: Fri, 11 Sep 2015 11:45:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 11/11] block: Only poll block layer fds in bdrv_aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 09:45:44 -0000 On 11/09/2015 11:36, Alberto Garcia wrote: > > > > Because nested aio_poll will automatically be limited to only > > > > process block layer events. My idea is to eventually let main loop > > > > use aio_poll > > > > > > That would be a step back. Using GSource is useful because it lets > > > you integrate libraries such as GTK+. > > > > Can we move GTK to a separate GSource thread? > > I think that GTK should always run in the main thread, or at least the > one running the default main loop / GMainContext. Agreed. The glib main loop is a positive thing, not a negative one. Paolo From MAILER-DAEMON Fri Sep 11 06:05:53 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaLDN-0003hh-3Z for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 06:05:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaLDI-0003hS-Jk for qemu-block@nongnu.org; Fri, 11 Sep 2015 06:05:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaL2R-0004zq-Bs for qemu-block@nongnu.org; Fri, 11 Sep 2015 05:54:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46976) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaL2R-0004y2-6O; Fri, 11 Sep 2015 05:54:35 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 833BDC0A1600; Fri, 11 Sep 2015 09:54:34 +0000 (UTC) Received: from [10.36.112.66] (ovpn-112-66.ams2.redhat.com [10.36.112.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8B9sU5d011788 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 11 Sep 2015 05:54:32 -0400 To: Fam Zheng , Alberto Garcia References: <1438144934-23619-12-git-send-email-famz@redhat.com> <55B882C1.8070500@redhat.com> <20150729105725.GA10376@ad.nay.redhat.com> <55B8B2C3.9050307@redhat.com> <20150729115333.GA15022@ad.nay.redhat.com> <55B8C12D.2070105@redhat.com> <20150909032205.GA10922@ad.nay.redhat.com> <55F28D99.5060908@redhat.com> <20150911091433.GA6759@ad.nay.redhat.com> <20150911094425.GA9241@ad.nay.redhat.com> From: Paolo Bonzini X-Enigmail-Draft-Status: N1110 Message-ID: <55F2A4D6.6050009@redhat.com> Date: Fri, 11 Sep 2015 11:54:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150911094425.GA9241@ad.nay.redhat.com> Content-Type: text/plain; charset=windows-1252 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 11/11] block: Only poll block layer fds in bdrv_aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 10:05:51 -0000 On 11/09/2015 11:44, Fam Zheng wrote: > > > > That would be a step back. Using GSource is useful because it le= ts > > > > you integrate libraries such as GTK+. > > > > > > Can we move GTK to a separate GSource thread? > >=20 > > I think that GTK should always run in the main thread, or at least th= e > > one running the default main loop / GMainContext. >=20 > Yeah it's basically GMainContext staying in the main thread and > block/net/chardev I/O put in a new AioContext thread. Why? The point of an event loop is that you can multiplex everything on the same thread. Unless we have specific needs (e.g. scalability) one thread is the way to go and keep things simple. The tool we have for scalability is AioContext + dataplane threads, and because we _can_ integrate it into the main thread (AioContext is a GSource) we can write code once for the main thread and for external dataplane threads. Using AioContext instead of duplicating the code is great. Moving SLIRP to Win32 would get rid of all the duplicated select() code between aio-win32.c and main-loop.c. A lot of main-loop.c code can go away (probably not all because unlike glib we support nanosecond timeouts with TimerListGroup, but who knows). However, there is no need to deviate the event loop from the well-known, standardized glib architecture. Paolo From MAILER-DAEMON Fri Sep 11 06:39:37 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaLk0-0006Rf-Ty for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 06:39:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaLjv-0006Qw-Vy for qemu-block@nongnu.org; Fri, 11 Sep 2015 06:39:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaLju-0001es-Le for qemu-block@nongnu.org; Fri, 11 Sep 2015 06:39:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50853) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaLju-0001eZ-E7; Fri, 11 Sep 2015 06:39:30 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 0EAAD2F02BA; Fri, 11 Sep 2015 10:39:28 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8BAdQAQ005002; Fri, 11 Sep 2015 06:39:27 -0400 Date: Fri, 11 Sep 2015 12:39:26 +0200 From: Kevin Wolf To: Fam Zheng Message-ID: <20150911103926.GA5164@noname.redhat.com> References: <1438144934-23619-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438144934-23619-1-git-send-email-famz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v2 00/11] aio: Introduce handler type to fix nested aio_poll for dataplane X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 10:39:35 -0000 Am 29.07.2015 um 06:42 hat Fam Zheng geschrieben: > v2: Switch to disable/enable model. [Paolo] > > Most existing nested aio_poll()'s in block layer are inconsiderate of > dispatching potential new r/w requests from ioeventfds and nbd exports, which > might result in responsiveness issues (e.g. bdrv_drain_all will not return when > new requests keep coming), or even wrong semantics (e.g. qmp_transaction cannot > enforce atomicity due to aio_poll in bdrv_drain_all). > > Previous attampts to address this issue include new op blocker[1], bdrv_lock[2] > and nested AioContext (patches not posted to qemu-devel). > > This approach is based on the idea proposed by Paolo Bonzini. The original idea > is introducing "aio_context_disable_client / aio_context_enable_client to > filter AioContext handlers according to the "client", e.g. > AIO_CLIENT_DATAPLANE (ioeventfd), AIO_CLIENT_PROTOCOL, AIO_CLIENT_NBD_SERVER, > AIO_CLIENT_CONTEXT, ... Extend aio_set_{event_notifier,fd}_handler to pass a > client (type)." > > After this series, block layer aio_poll() will only process those "protocol" > fds that are used in block I/O, plus the ctx->notifier for aio_notify(); other > aio_poll()'s keep unchanged. > > The biggest advantage over approaches [1] and [2] is, no change is needed in > virtio-{blk,scsi}-dataplane code, also this doesn't depend on converting QMP to > coroutines. It seems that I haven't replied on the mailing list yet, even though I think I already said this in person at KVM Forum: This series fixes only a special case of the real problem, which is that bdrv_drain/all at a single point doesn't make a lot of sense, but needs to be replaced by a whole section with exclusive access, like a bdrv_drained_begin/end pair. To be clear: Anything that works with types of users instead of individual users is bound to fall short of being a complete solution. I don't prefer partial solutions when we know there is a bigger problem. This series addresses your immediate need of protecting against new data plane requests, which it arguably achieves. The second case I always have in mind is Berto's case where he has multiple streaming block jobs in the same backing file chain [1]. This involves a bdrv_reopen() of the target BDS to make it writable, and bdrv_reopen() uses bdrv_drain_all() so drivers don't have to cope with running requests while reopening themselves. It can however involve nested event loops for synchronous operations like bdrv_flush(), and if those can process completions of block jobs, which can respond by doing anything to the respective node, things can go wrong. You don't solve this by adding client types (then problematic request would be PROTOCOL in your proposal and you can never exclude that), but you really need to have bdrv_drained_being/end pairs, where only requests issued in between are processed and everything else waits. Kevin [1] https://lists.gnu.org/archive/html/qemu-devel/2015-06/msg06273.html From MAILER-DAEMON Fri Sep 11 06:41:03 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaLlP-0007Vb-Or for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 06:41:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaLlN-0007Ut-MP for qemu-block@nongnu.org; Fri, 11 Sep 2015 06:41:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaLlK-0002Vv-FU for qemu-block@nongnu.org; Fri, 11 Sep 2015 06:41:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48230) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaLlK-0002VR-9s; Fri, 11 Sep 2015 06:40:58 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id F402C80091; Fri, 11 Sep 2015 10:40:57 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BAeuoI002092; Fri, 11 Sep 2015 06:40:57 -0400 Date: Fri, 11 Sep 2015 18:40:55 +0800 From: Fam Zheng To: Paolo Bonzini Message-ID: <20150911104055.GB9241@ad.nay.redhat.com> References: <20150729105725.GA10376@ad.nay.redhat.com> <55B8B2C3.9050307@redhat.com> <20150729115333.GA15022@ad.nay.redhat.com> <55B8C12D.2070105@redhat.com> <20150909032205.GA10922@ad.nay.redhat.com> <55F28D99.5060908@redhat.com> <20150911091433.GA6759@ad.nay.redhat.com> <20150911094425.GA9241@ad.nay.redhat.com> <55F2A4D6.6050009@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55F2A4D6.6050009@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 11/11] block: Only poll block layer fds in bdrv_aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 10:41:02 -0000 On Fri, 09/11 11:54, Paolo Bonzini wrote: > > > On 11/09/2015 11:44, Fam Zheng wrote: > > > > > That would be a step back. Using GSource is useful because it lets > > > > > you integrate libraries such as GTK+. > > > > > > > > Can we move GTK to a separate GSource thread? > > > > > > I think that GTK should always run in the main thread, or at least the > > > one running the default main loop / GMainContext. > > > > Yeah it's basically GMainContext staying in the main thread and > > block/net/chardev I/O put in a new AioContext thread. > > Why? The point of an event loop is that you can multiplex everything on > the same thread. Unless we have specific needs (e.g. scalability) one > thread is the way to go and keep things simple. The reason is scalability. :) > > The tool we have for scalability is AioContext + dataplane threads, and > because we _can_ integrate it into the main thread (AioContext is a > GSource) we can write code once for the main thread and for external > dataplane threads. I don't think integrating with main thread or not is a problem, we can still use the same code as before, because the event loop code change should be transparent (see below). > > Using AioContext instead of duplicating the code is great. Moving SLIRP > to Win32 would get rid of all the duplicated select() code between > aio-win32.c and main-loop.c. A lot of main-loop.c code can go away > (probably not all because unlike glib we support nanosecond timeouts > with TimerListGroup, but who knows). > > However, there is no need to deviate the event loop from the well-known, > standardized glib architecture. Moving things to AIO isn't deviation, it's more about enabling of dataplane and epoll. That's why block was moved to AioContext, and I think we can do similar for net and serial, the difference is that as a start, they don't need to be fully BQL-free like virtio-blk and scsi. But by running in an aio_poll() loop, they can better performance because of epoll. I'm thinking about something like this: Main thread (GTK): g_main_run() New io thread (one per process, includes block, net, serial): while (true) { qemu_mutex_lock_iothread(); aio_poll(qemu_aio_context); qemu_mutex_unlock_iothread(); } Dataplane thread (one per "-object iothread", includes dataplane enabled devices): while (true) { aio_poll(iothread->ctx); } Fam From MAILER-DAEMON Fri Sep 11 06:46:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaLqR-00012D-P4 for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 06:46:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaLqQ-00011K-1l for qemu-block@nongnu.org; Fri, 11 Sep 2015 06:46:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaLqM-0006Gq-Su for qemu-block@nongnu.org; Fri, 11 Sep 2015 06:46:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42696) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaLqM-0006GG-NH; Fri, 11 Sep 2015 06:46:10 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 55936341AC2; Fri, 11 Sep 2015 10:46:10 +0000 (UTC) Received: from [10.36.112.66] (ovpn-112-66.ams2.redhat.com [10.36.112.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BAk6sW003852 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 11 Sep 2015 06:46:08 -0400 To: Fam Zheng References: <20150729105725.GA10376@ad.nay.redhat.com> <55B8B2C3.9050307@redhat.com> <20150729115333.GA15022@ad.nay.redhat.com> <55B8C12D.2070105@redhat.com> <20150909032205.GA10922@ad.nay.redhat.com> <55F28D99.5060908@redhat.com> <20150911091433.GA6759@ad.nay.redhat.com> <20150911094425.GA9241@ad.nay.redhat.com> <55F2A4D6.6050009@redhat.com> <20150911104055.GB9241@ad.nay.redhat.com> From: Paolo Bonzini Message-ID: <55F2B0EE.7030407@redhat.com> Date: Fri, 11 Sep 2015 12:46:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150911104055.GB9241@ad.nay.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 11/11] block: Only poll block layer fds in bdrv_aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 10:46:14 -0000 On 11/09/2015 12:40, Fam Zheng wrote: > On Fri, 09/11 11:54, Paolo Bonzini wrote: >> >> >> On 11/09/2015 11:44, Fam Zheng wrote: >>>>>> That would be a step back. Using GSource is useful because it lets >>>>>> you integrate libraries such as GTK+. >>>>> >>>>> Can we move GTK to a separate GSource thread? >>>> >>>> I think that GTK should always run in the main thread, or at least the >>>> one running the default main loop / GMainContext. >>> >>> Yeah it's basically GMainContext staying in the main thread and >>> block/net/chardev I/O put in a new AioContext thread. >> >> Why? The point of an event loop is that you can multiplex everything on >> the same thread. Unless we have specific needs (e.g. scalability) one >> thread is the way to go and keep things simple. > > The reason is scalability. :) Scalability of what? If virtio-net or virtio-serial needs to be more scalable, putting all of them into a non-main-loop thread will not make things more scalable, because you have a single thread anyway. You'd need to go BQL-free and allow an arbitrary number. > Moving things to AIO isn't deviation, it's more about enabling of dataplane and > epoll. That's why block was moved to AioContext, and I think we can do similar > for net and serial, the difference is that as a start, they don't need to be > fully BQL-free like virtio-blk and scsi. But by running in an aio_poll() loop, > they can better performance because of epoll. Isn't that what your "iohandler.c with AioHandler" already does? True, it would be epoll-within-poll, not pure poll. But if you need epoll, you might as well go BQL-free. Paolo From MAILER-DAEMON Fri Sep 11 07:01:32 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaM5E-0002Ff-Cj for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 07:01:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaM5C-0002F8-LL for qemu-block@nongnu.org; Fri, 11 Sep 2015 07:01:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaM57-0005g3-Mg for qemu-block@nongnu.org; Fri, 11 Sep 2015 07:01:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaM57-0005fw-HU; Fri, 11 Sep 2015 07:01:25 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 1850E91C27; Fri, 11 Sep 2015 11:01:25 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BB1N4I010813; Fri, 11 Sep 2015 07:01:24 -0400 Date: Fri, 11 Sep 2015 19:01:22 +0800 From: Fam Zheng To: Paolo Bonzini Message-ID: <20150911110122.GC9241@ad.nay.redhat.com> References: <20150729115333.GA15022@ad.nay.redhat.com> <55B8C12D.2070105@redhat.com> <20150909032205.GA10922@ad.nay.redhat.com> <55F28D99.5060908@redhat.com> <20150911091433.GA6759@ad.nay.redhat.com> <20150911094425.GA9241@ad.nay.redhat.com> <55F2A4D6.6050009@redhat.com> <20150911104055.GB9241@ad.nay.redhat.com> <55F2B0EE.7030407@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55F2B0EE.7030407@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 11/11] block: Only poll block layer fds in bdrv_aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 11:01:31 -0000 On Fri, 09/11 12:46, Paolo Bonzini wrote: > > > On 11/09/2015 12:40, Fam Zheng wrote: > > On Fri, 09/11 11:54, Paolo Bonzini wrote: > >> > >> > >> On 11/09/2015 11:44, Fam Zheng wrote: > >>>>>> That would be a step back. Using GSource is useful because it lets > >>>>>> you integrate libraries such as GTK+. > >>>>> > >>>>> Can we move GTK to a separate GSource thread? > >>>> > >>>> I think that GTK should always run in the main thread, or at least the > >>>> one running the default main loop / GMainContext. > >>> > >>> Yeah it's basically GMainContext staying in the main thread and > >>> block/net/chardev I/O put in a new AioContext thread. > >> > >> Why? The point of an event loop is that you can multiplex everything on > >> the same thread. Unless we have specific needs (e.g. scalability) one > >> thread is the way to go and keep things simple. > > > > The reason is scalability. :) > > Scalability of what? If virtio-net or virtio-serial needs to be more > scalable, putting all of them into a non-main-loop thread will not make > things more scalable, because you have a single thread anyway. You'd > need to go BQL-free and allow an arbitrary number. > > > Moving things to AIO isn't deviation, it's more about enabling of dataplane and > > epoll. That's why block was moved to AioContext, and I think we can do similar > > for net and serial, the difference is that as a start, they don't need to be > > fully BQL-free like virtio-blk and scsi. But by running in an aio_poll() loop, > > they can better performance because of epoll. > > Isn't that what your "iohandler.c with AioHandler" already does? True, > it would be epoll-within-poll, not pure poll. But if you need epoll, > you might as well go BQL-free. epoll-within-poll? Do you mean change the main event loop from: qemu_poll_ns([..., ioeventfd1, ioeventfd2, ..., ioeventfd99], ...) to qemu_poll_ns([epollfd], ...) where epollfd watches all the fds, and let the handler of epollfd do epoll_wait()? Fam From MAILER-DAEMON Fri Sep 11 07:03:03 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaM6h-0003Te-DV for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 07:03:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaM6f-0003TU-Gu for qemu-block@nongnu.org; Fri, 11 Sep 2015 07:03:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaM6e-0006ZC-HW for qemu-block@nongnu.org; Fri, 11 Sep 2015 07:03:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58034) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaM6e-0006Z8-CN; Fri, 11 Sep 2015 07:03:00 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id E4805C18F6B2; Fri, 11 Sep 2015 11:02:59 +0000 (UTC) Received: from [10.36.112.66] (ovpn-112-66.ams2.redhat.com [10.36.112.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BB2lEp011402 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 11 Sep 2015 07:02:53 -0400 To: Fam Zheng References: <20150729115333.GA15022@ad.nay.redhat.com> <55B8C12D.2070105@redhat.com> <20150909032205.GA10922@ad.nay.redhat.com> <55F28D99.5060908@redhat.com> <20150911091433.GA6759@ad.nay.redhat.com> <20150911094425.GA9241@ad.nay.redhat.com> <55F2A4D6.6050009@redhat.com> <20150911104055.GB9241@ad.nay.redhat.com> <55F2B0EE.7030407@redhat.com> <20150911110122.GC9241@ad.nay.redhat.com> From: Paolo Bonzini Message-ID: <55F2B4D7.4060801@redhat.com> Date: Fri, 11 Sep 2015 13:02:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150911110122.GC9241@ad.nay.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 11/11] block: Only poll block layer fds in bdrv_aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 11:03:02 -0000 On 11/09/2015 13:01, Fam Zheng wrote: > On Fri, 09/11 12:46, Paolo Bonzini wrote: >> >> >> On 11/09/2015 12:40, Fam Zheng wrote: >>> On Fri, 09/11 11:54, Paolo Bonzini wrote: >>>> >>>> >>>> On 11/09/2015 11:44, Fam Zheng wrote: >>>>>>>> That would be a step back. Using GSource is useful because it lets >>>>>>>> you integrate libraries such as GTK+. >>>>>>> >>>>>>> Can we move GTK to a separate GSource thread? >>>>>> >>>>>> I think that GTK should always run in the main thread, or at least the >>>>>> one running the default main loop / GMainContext. >>>>> >>>>> Yeah it's basically GMainContext staying in the main thread and >>>>> block/net/chardev I/O put in a new AioContext thread. >>>> >>>> Why? The point of an event loop is that you can multiplex everything on >>>> the same thread. Unless we have specific needs (e.g. scalability) one >>>> thread is the way to go and keep things simple. >>> >>> The reason is scalability. :) >> >> Scalability of what? If virtio-net or virtio-serial needs to be more >> scalable, putting all of them into a non-main-loop thread will not make >> things more scalable, because you have a single thread anyway. You'd >> need to go BQL-free and allow an arbitrary number. >> >>> Moving things to AIO isn't deviation, it's more about enabling of dataplane and >>> epoll. That's why block was moved to AioContext, and I think we can do similar >>> for net and serial, the difference is that as a start, they don't need to be >>> fully BQL-free like virtio-blk and scsi. But by running in an aio_poll() loop, >>> they can better performance because of epoll. >> >> Isn't that what your "iohandler.c with AioHandler" already does? True, >> it would be epoll-within-poll, not pure poll. But if you need epoll, >> you might as well go BQL-free. > > epoll-within-poll? Do you mean change the main event loop from: > > qemu_poll_ns([..., ioeventfd1, ioeventfd2, ..., ioeventfd99], ...) > > to > > qemu_poll_ns([epollfd], ...) > > where epollfd watches all the fds, and let the handler of epollfd do > epoll_wait()? I mean that glib's main loop (or os_host_main_loop_wait in main-loop.c) uses poll, and then the AioContext GSource uses epoll. Still, you have a constant (and low) number of file descriptors in the outer poll. Paolo From MAILER-DAEMON Fri Sep 11 07:13:08 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaMGR-0006V2-JF for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 07:13:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaMGO-0006Nt-0c for qemu-block@nongnu.org; Fri, 11 Sep 2015 07:13:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaMGJ-0005dw-O7 for qemu-block@nongnu.org; Fri, 11 Sep 2015 07:13:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38531) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaMGJ-0005dp-JR; Fri, 11 Sep 2015 07:12:59 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 06E5CA8D; Fri, 11 Sep 2015 11:12:59 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BBCvYu017595; Fri, 11 Sep 2015 07:12:58 -0400 Date: Fri, 11 Sep 2015 19:12:55 +0800 From: Fam Zheng To: Paolo Bonzini Message-ID: <20150911111255.GD9241@ad.nay.redhat.com> References: <20150909032205.GA10922@ad.nay.redhat.com> <55F28D99.5060908@redhat.com> <20150911091433.GA6759@ad.nay.redhat.com> <20150911094425.GA9241@ad.nay.redhat.com> <55F2A4D6.6050009@redhat.com> <20150911104055.GB9241@ad.nay.redhat.com> <55F2B0EE.7030407@redhat.com> <20150911110122.GC9241@ad.nay.redhat.com> <55F2B4D7.4060801@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55F2B4D7.4060801@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 11/11] block: Only poll block layer fds in bdrv_aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 11:13:05 -0000 On Fri, 09/11 13:02, Paolo Bonzini wrote: > > > On 11/09/2015 13:01, Fam Zheng wrote: > > On Fri, 09/11 12:46, Paolo Bonzini wrote: > >> > >> > >> On 11/09/2015 12:40, Fam Zheng wrote: > >>> On Fri, 09/11 11:54, Paolo Bonzini wrote: > >>>> > >>>> > >>>> On 11/09/2015 11:44, Fam Zheng wrote: > >>>>>>>> That would be a step back. Using GSource is useful because it lets > >>>>>>>> you integrate libraries such as GTK+. > >>>>>>> > >>>>>>> Can we move GTK to a separate GSource thread? > >>>>>> > >>>>>> I think that GTK should always run in the main thread, or at least the > >>>>>> one running the default main loop / GMainContext. > >>>>> > >>>>> Yeah it's basically GMainContext staying in the main thread and > >>>>> block/net/chardev I/O put in a new AioContext thread. > >>>> > >>>> Why? The point of an event loop is that you can multiplex everything on > >>>> the same thread. Unless we have specific needs (e.g. scalability) one > >>>> thread is the way to go and keep things simple. > >>> > >>> The reason is scalability. :) > >> > >> Scalability of what? If virtio-net or virtio-serial needs to be more > >> scalable, putting all of them into a non-main-loop thread will not make > >> things more scalable, because you have a single thread anyway. You'd > >> need to go BQL-free and allow an arbitrary number. > >> > >>> Moving things to AIO isn't deviation, it's more about enabling of dataplane and > >>> epoll. That's why block was moved to AioContext, and I think we can do similar > >>> for net and serial, the difference is that as a start, they don't need to be > >>> fully BQL-free like virtio-blk and scsi. But by running in an aio_poll() loop, > >>> they can better performance because of epoll. > >> > >> Isn't that what your "iohandler.c with AioHandler" already does? True, > >> it would be epoll-within-poll, not pure poll. But if you need epoll, > >> you might as well go BQL-free. > > > > epoll-within-poll? Do you mean change the main event loop from: > > > > qemu_poll_ns([..., ioeventfd1, ioeventfd2, ..., ioeventfd99], ...) > > > > to > > > > qemu_poll_ns([epollfd], ...) > > > > where epollfd watches all the fds, and let the handler of epollfd do > > epoll_wait()? > > I mean that glib's main loop (or os_host_main_loop_wait in main-loop.c) > uses poll, and then the AioContext GSource uses epoll. Still, you have > a constant (and low) number of file descriptors in the outer poll. > OK, I think I get your idea, and it sounds good to me, thank you very much! ;-) Fam From MAILER-DAEMON Fri Sep 11 07:47:03 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaMnH-0007ve-Eg for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 07:47:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaMnE-0007um-Cl for qemu-block@nongnu.org; Fri, 11 Sep 2015 07:47:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaMnB-0008Kc-4D for qemu-block@nongnu.org; Fri, 11 Sep 2015 07:47:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37745) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaMnA-0008KG-Sn; Fri, 11 Sep 2015 07:46:57 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 7AC9EA0BAE; Fri, 11 Sep 2015 11:46:56 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BBks7H004950; Fri, 11 Sep 2015 07:46:55 -0400 Date: Fri, 11 Sep 2015 19:46:53 +0800 From: Fam Zheng To: Kevin Wolf Message-ID: <20150911114653.GA11386@ad.nay.redhat.com> References: <1438144934-23619-1-git-send-email-famz@redhat.com> <20150911103926.GA5164@noname.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150911103926.GA5164@noname.redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 00/11] aio: Introduce handler type to fix nested aio_poll for dataplane X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 11:47:01 -0000 On Fri, 09/11 12:39, Kevin Wolf wrote: > Am 29.07.2015 um 06:42 hat Fam Zheng geschrieben: > > v2: Switch to disable/enable model. [Paolo] > > > > Most existing nested aio_poll()'s in block layer are inconsiderate of > > dispatching potential new r/w requests from ioeventfds and nbd exports, which > > might result in responsiveness issues (e.g. bdrv_drain_all will not return when > > new requests keep coming), or even wrong semantics (e.g. qmp_transaction cannot > > enforce atomicity due to aio_poll in bdrv_drain_all). > > > > Previous attampts to address this issue include new op blocker[1], bdrv_lock[2] > > and nested AioContext (patches not posted to qemu-devel). > > > > This approach is based on the idea proposed by Paolo Bonzini. The original idea > > is introducing "aio_context_disable_client / aio_context_enable_client to > > filter AioContext handlers according to the "client", e.g. > > AIO_CLIENT_DATAPLANE (ioeventfd), AIO_CLIENT_PROTOCOL, AIO_CLIENT_NBD_SERVER, > > AIO_CLIENT_CONTEXT, ... Extend aio_set_{event_notifier,fd}_handler to pass a > > client (type)." > > > > After this series, block layer aio_poll() will only process those "protocol" > > fds that are used in block I/O, plus the ctx->notifier for aio_notify(); other > > aio_poll()'s keep unchanged. > > > > The biggest advantage over approaches [1] and [2] is, no change is needed in > > virtio-{blk,scsi}-dataplane code, also this doesn't depend on converting QMP to > > coroutines. > > It seems that I haven't replied on the mailing list yet, even though I > think I already said this in person at KVM Forum: This series fixes only > a special case of the real problem, which is that bdrv_drain/all at a > single point doesn't make a lot of sense, but needs to be replaced by a > whole section with exclusive access, like a bdrv_drained_begin/end pair. > > To be clear: Anything that works with types of users instead of > individual users is bound to fall short of being a complete solution. I > don't prefer partial solutions when we know there is a bigger problem. > > This series addresses your immediate need of protecting against new data > plane requests, which it arguably achieves. The second case I always > have in mind is Berto's case where he has multiple streaming block jobs > in the same backing file chain [1]. > > This involves a bdrv_reopen() of the target BDS to make it writable, and > bdrv_reopen() uses bdrv_drain_all() so drivers don't have to cope with > running requests while reopening themselves. It can however involve > nested event loops for synchronous operations like bdrv_flush(), and if > those can process completions of block jobs, which can respond by doing > anything to the respective node, things can go wrong. Just to get a better idea of bdrv_drained_begin/end, could you explain how to use the pair to fix the above problem? > > You don't solve this by adding client types (then problematic request > would be PROTOCOL in your proposal and you can never exclude that), but > you really need to have bdrv_drained_being/end pairs, where only > requests issued in between are processed and everything else waits. What do you mean by "only requests issued in between are processed"? Where are the requests from? Fam From MAILER-DAEMON Fri Sep 11 08:22:24 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaNLU-0007UB-4N for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 08:22:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaNLQ-0007OX-FB for qemu-block@nongnu.org; Fri, 11 Sep 2015 08:22:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaNLN-0000fL-8c for qemu-block@nongnu.org; Fri, 11 Sep 2015 08:22:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50190) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaNLN-0000fG-0c; Fri, 11 Sep 2015 08:22:17 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 6828A8E3FE; Fri, 11 Sep 2015 12:22:16 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8BCME18028530; Fri, 11 Sep 2015 08:22:14 -0400 Date: Fri, 11 Sep 2015 14:22:14 +0200 From: Kevin Wolf To: Fam Zheng Message-ID: <20150911122214.GB5164@noname.redhat.com> References: <1438144934-23619-1-git-send-email-famz@redhat.com> <20150911103926.GA5164@noname.redhat.com> <20150911114653.GA11386@ad.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150911114653.GA11386@ad.nay.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 00/11] aio: Introduce handler type to fix nested aio_poll for dataplane X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 12:22:21 -0000 Am 11.09.2015 um 13:46 hat Fam Zheng geschrieben: > On Fri, 09/11 12:39, Kevin Wolf wrote: > > Am 29.07.2015 um 06:42 hat Fam Zheng geschrieben: > > > v2: Switch to disable/enable model. [Paolo] > > > > > > Most existing nested aio_poll()'s in block layer are inconsiderate of > > > dispatching potential new r/w requests from ioeventfds and nbd exports, which > > > might result in responsiveness issues (e.g. bdrv_drain_all will not return when > > > new requests keep coming), or even wrong semantics (e.g. qmp_transaction cannot > > > enforce atomicity due to aio_poll in bdrv_drain_all). > > > > > > Previous attampts to address this issue include new op blocker[1], bdrv_lock[2] > > > and nested AioContext (patches not posted to qemu-devel). > > > > > > This approach is based on the idea proposed by Paolo Bonzini. The original idea > > > is introducing "aio_context_disable_client / aio_context_enable_client to > > > filter AioContext handlers according to the "client", e.g. > > > AIO_CLIENT_DATAPLANE (ioeventfd), AIO_CLIENT_PROTOCOL, AIO_CLIENT_NBD_SERVER, > > > AIO_CLIENT_CONTEXT, ... Extend aio_set_{event_notifier,fd}_handler to pass a > > > client (type)." > > > > > > After this series, block layer aio_poll() will only process those "protocol" > > > fds that are used in block I/O, plus the ctx->notifier for aio_notify(); other > > > aio_poll()'s keep unchanged. > > > > > > The biggest advantage over approaches [1] and [2] is, no change is needed in > > > virtio-{blk,scsi}-dataplane code, also this doesn't depend on converting QMP to > > > coroutines. > > > > It seems that I haven't replied on the mailing list yet, even though I > > think I already said this in person at KVM Forum: This series fixes only > > a special case of the real problem, which is that bdrv_drain/all at a > > single point doesn't make a lot of sense, but needs to be replaced by a > > whole section with exclusive access, like a bdrv_drained_begin/end pair. > > > > To be clear: Anything that works with types of users instead of > > individual users is bound to fall short of being a complete solution. I > > don't prefer partial solutions when we know there is a bigger problem. > > > > This series addresses your immediate need of protecting against new data > > plane requests, which it arguably achieves. The second case I always > > have in mind is Berto's case where he has multiple streaming block jobs > > in the same backing file chain [1]. > > > > This involves a bdrv_reopen() of the target BDS to make it writable, and > > bdrv_reopen() uses bdrv_drain_all() so drivers don't have to cope with > > running requests while reopening themselves. It can however involve > > nested event loops for synchronous operations like bdrv_flush(), and if > > those can process completions of block jobs, which can respond by doing > > anything to the respective node, things can go wrong. > > Just to get a better idea of bdrv_drained_begin/end, could you explain how to > use the pair to fix the above problem? How to use it is easy part: In bdrv_reopen_multiple(), you would replace the existing bdrv_drain_all() with begin and you would add the corresponding end right before the return statement. > > You don't solve this by adding client types (then problematic request > > would be PROTOCOL in your proposal and you can never exclude that), but > > you really need to have bdrv_drained_being/end pairs, where only > > requests issued in between are processed and everything else waits. > > What do you mean by "only requests issued in between are processed"? Where are > the requests from? Generally speaking, you would have code that looks like this: bdrv_drain_begin() ... bdrv_something_synchronous() ... bdrv_drain_end() You want to process everything that is necessary for completing bdrv_something_synchronous(), but nothing else. The trickier question is how to implement this. I know that it's much easier to say that your series doesn't work than actually proposing something else that works... One relatively obvious answer we found when we discussed this a while back was some kind of a recursive CoRwLock (reader = in-flight request; writer = drained section), but that requires obviously that you're running in a coroutine if you want to do something with a drained request queue. I'm also not totally happy with the requirement of taking a reader lock more or less everywhere. But I'm not sure yet if there is a good alternative that can achieve the same. This needs some more thought, I guess. Kevin From MAILER-DAEMON Fri Sep 11 11:20:44 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaQ84-0003lN-0b for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 11:20:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaQ81-0003lC-JG for qemu-block@nongnu.org; Fri, 11 Sep 2015 11:20:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaQ7x-0003Pi-DJ for qemu-block@nongnu.org; Fri, 11 Sep 2015 11:20:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49079) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaQ7w-0003OJ-SD; Fri, 11 Sep 2015 11:20:37 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 0E974341AD9; Fri, 11 Sep 2015 15:20:35 +0000 (UTC) Received: from [10.3.113.15] ([10.3.113.15]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BFKYSN019927; Fri, 11 Sep 2015 11:20:34 -0400 To: Fam Zheng , qemu-devel@nongnu.org References: <1441951252-13439-1-git-send-email-famz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55F2F141.3000809@redhat.com> Date: Fri, 11 Sep 2015 09:20:33 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441951252-13439-1-git-send-email-famz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="R3LsB4RC74E03t0pM1Q8HGtta6ALBTFuq" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , Peter Lieven , Ronnie Sahlberg , qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] iscsi: Add chap and "initiator-name" etc as per drive options X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 15:20:42 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --R3LsB4RC74E03t0pM1Q8HGtta6ALBTFuq Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/11/2015 12:00 AM, Fam Zheng wrote: > Previously we use "-iscsi id=3Dtarget-iqn,user=3Dfoo,password=3Dbar,...= " to > specify iscsi connection parameters, unfortunately it doesn't work with= > qemu-img. >=20 > This patch adds per drive options to iscsi driver so that at least > qemu-img can use the "json:{...}" filename magic. >=20 > Signed-off-by: Fam Zheng > --- > block/iscsi.c | 83 +++++++++++++++++++++++++++++++++++++++++++++------= -------- > 1 file changed, 64 insertions(+), 19 deletions(-) It would be nice to also add a matching BlockdevOptionsIscsi to qapi/block-core.json, to allow setting these structured options from QMP. Separate patch is fine, but we need to do the work for ALL of the remaining block devices eventually, and now that you are structuring the command line is a good time to think about it. > static void iscsi_nop_timed_event(void *opaque) > @@ -1229,6 +1253,27 @@ static QemuOptsList runtime_opts =3D { > .name =3D "filename", > .type =3D QEMU_OPT_STRING, > .help =3D "URL to the iscsi image", > + },{ > + .name =3D "user", > + .type =3D QEMU_OPT_STRING, > + .help =3D "username for CHAP authentication to target", > + },{ > + .name =3D "password", > + .type =3D QEMU_OPT_STRING, > + .help =3D "password for CHAP authentication to target", > + },{ Also, this requires passing the password in the command line. We _really_ need to solve the problem of allowing the password to be passed via a fd or other QMP command, rather than on the command line. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --R3LsB4RC74E03t0pM1Q8HGtta6ALBTFuq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEbBAEBCAAGBQJV8vFBAAoJEKeha0olJ0Nq2Y0H+Oot/A6xXq4x0naOo3WHp2oM xFH/2vWFGcvW+aTcXy+zdf+Uk1C7q254sVrOK8FOwdpvljlGopJlP62t1NTlWDVG deLn7qIP85DDV8Gp3MyT3X25DoIi6MppVqckoGN+mvDWC6vkmY25g9uKhT57vGgw yKFVj3t1dFdXgzlFT9H0BUgfIDfrmemISiPsjpJNvHqLnpEtRAs1GX1aTTv/iamH JBEe0GidnFXQbGyz0U47WBbHzWiBH/3OXljGn8A2ElVpYygSpsJKAm6fUq1lql7B C0ciVXZRGp8OGhsDvrQDo/WCEppuGNr16z0EHzTli/twjs0akLqn1SDZCtJBrQ== =CUYw -----END PGP SIGNATURE----- --R3LsB4RC74E03t0pM1Q8HGtta6ALBTFuq-- From MAILER-DAEMON Fri Sep 11 11:27:59 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaQF5-0006Rr-S2 for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 11:27:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaQF3-0006PR-Fe for qemu-block@nongnu.org; Fri, 11 Sep 2015 11:27:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaQF2-0007So-EO for qemu-block@nongnu.org; Fri, 11 Sep 2015 11:27:57 -0400 Received: from mail-io0-x231.google.com ([2607:f8b0:4001:c06::231]:34443) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaQEw-0007Rt-4d; Fri, 11 Sep 2015 11:27:50 -0400 Received: by iofb144 with SMTP id b144so102296881iof.1; Fri, 11 Sep 2015 08:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=4F8lhwlBp/sGzzbIc8Bbzi/9h0S+lyiRRuZWiPismOI=; b=pV7DqELM35WI6FEzZyEeIN3Ydrh7WXXrDp2rAuwBYkLHb2efSD+M8bQY0tCXhW1gd6 WPDHGEtBvYa2+p+LdTNkGfhtpPQFs0HjvYVN8SedZMD/pnLfoV95iM9pNwKHIi6TYzgw cvF/eKTQtKG9H4oESMSqWiR7MC0ZmamLLKZox4mizZCpEXi1wGHB3LoCI6zgvtJe2EjC CScdCTm1PkjgaUJ+YM04OVHDrYqg+jzo8dZlB5jPzvP4Md4umSuD0J6drBhAYA/zyJer LxHfW89ZQLUPPimWh3Pd3xBcKwG2tV3zZdKr4AEiZE79c4/i55TAxgaORCOng0d7mkGI oHVA== MIME-Version: 1.0 X-Received: by 10.107.136.213 with SMTP id s82mr4797730ioi.111.1441985269187; Fri, 11 Sep 2015 08:27:49 -0700 (PDT) Received: by 10.79.78.208 with HTTP; Fri, 11 Sep 2015 08:27:49 -0700 (PDT) In-Reply-To: <55F2F141.3000809@redhat.com> References: <1441951252-13439-1-git-send-email-famz@redhat.com> <55F2F141.3000809@redhat.com> Date: Fri, 11 Sep 2015 08:27:49 -0700 Message-ID: From: ronnie sahlberg To: Eric Blake Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c06::231 Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Peter Lieven , qemu-devel , Paolo Bonzini Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] iscsi: Add chap and "initiator-name" etc as per drive options X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 15:27:58 -0000 On Fri, Sep 11, 2015 at 8:20 AM, Eric Blake wrote: > On 09/11/2015 12:00 AM, Fam Zheng wrote: >> Previously we use "-iscsi id=target-iqn,user=foo,password=bar,..." to >> specify iscsi connection parameters, unfortunately it doesn't work with >> qemu-img. >> >> This patch adds per drive options to iscsi driver so that at least >> qemu-img can use the "json:{...}" filename magic. >> >> Signed-off-by: Fam Zheng >> --- >> block/iscsi.c | 83 +++++++++++++++++++++++++++++++++++++++++++++-------------- >> 1 file changed, 64 insertions(+), 19 deletions(-) > > It would be nice to also add a matching BlockdevOptionsIscsi to > qapi/block-core.json, to allow setting these structured options from > QMP. Separate patch is fine, but we need to do the work for ALL of the > remaining block devices eventually, and now that you are structuring the > command line is a good time to think about it. > > >> static void iscsi_nop_timed_event(void *opaque) >> @@ -1229,6 +1253,27 @@ static QemuOptsList runtime_opts = { >> .name = "filename", >> .type = QEMU_OPT_STRING, >> .help = "URL to the iscsi image", >> + },{ >> + .name = "user", >> + .type = QEMU_OPT_STRING, >> + .help = "username for CHAP authentication to target", >> + },{ >> + .name = "password", >> + .type = QEMU_OPT_STRING, >> + .help = "password for CHAP authentication to target", >> + },{ > > Also, this requires passing the password in the command line. We > _really_ need to solve the problem of allowing the password to be passed > via a fd or other QMP command, rather than on the command line. Passing via command line is evil. It should still be possible to pass all this via a config file to qemu : """ ... Howto use a configuration file to set iSCSI configuration options: @example cat >iscsi.conf < > -- > Eric Blake eblake redhat com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org > From MAILER-DAEMON Fri Sep 11 12:48:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaRUX-000224-3m for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 12:48:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaRUU-00021P-Im for qemu-block@nongnu.org; Fri, 11 Sep 2015 12:47:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaRUR-0001y4-B2 for qemu-block@nongnu.org; Fri, 11 Sep 2015 12:47:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32867) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaRUR-0001xq-5g; Fri, 11 Sep 2015 12:47:55 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 8F4F2341AC2; Fri, 11 Sep 2015 16:47:54 +0000 (UTC) Received: from localhost (ovpn-116-61.ams2.redhat.com [10.36.116.61]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BGlqKr010863 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 11 Sep 2015 12:47:53 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 18:47:51 +0200 Message-Id: <1441990071-7205-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH] qcow2: Make qcow2_alloc_bytes() more explicit X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 16:47:59 -0000 In case of -EAGAIN returned by update_refcount(), we should discard the cluster offset we were trying to allocate and request a new one, because in theory that old offset might now be taken by a refcount block. In practice, this was not the case due to update_refcount() generally returning strictly monotonic increasing cluster offsets. However, this behavior is not set in stone, and it is also not obvious when looking at qcow2_alloc_bytes() alone, so we should not rely on it. Reported-by: Kevin Wolf Signed-off-by: Max Reitz --- block/qcow2-refcount.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index e8430ec..c30bb14 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -949,11 +949,17 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size) if (!offset || ROUND_UP(offset, s->cluster_size) != new_cluster) { offset = new_cluster; + free_in_cluster = s->cluster_size; + } else { + free_in_cluster += s->cluster_size; } } assert(offset); ret = update_refcount(bs, offset, size, 1, false, QCOW2_DISCARD_NEVER); + if (ret < 0) { + offset = 0; + } } while (ret == -EAGAIN); if (ret < 0) { return ret; -- 2.5.1 From MAILER-DAEMON Fri Sep 11 13:01:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaRhZ-0002K3-MT for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 13:01:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaRhT-0002Jd-El for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:01:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaRhM-0000WY-U8 for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:01:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59349) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaRhM-0000WP-Kr; Fri, 11 Sep 2015 13:01:16 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 1D447A0BA0; Fri, 11 Sep 2015 17:01:16 +0000 (UTC) Received: from [10.36.116.61] (ovpn-116-61.ams2.redhat.com [10.36.116.61]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BH1BGM018771 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 11 Sep 2015 13:01:13 -0400 To: Wen Congyang , qemu-block@nongnu.org References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-30-git-send-email-mreitz@redhat.com> <55EEA69E.4010706@cn.fujitsu.com> <55EF5133.2040807@redhat.com> <55F00363.5080709@cn.fujitsu.com> <55F02D3D.6020102@redhat.com> <55F0D901.1010607@cn.fujitsu.com> <55F1D575.9020909@redhat.com> <55F28308.5030303@cn.fujitsu.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <55F308D7.5010200@redhat.com> Date: Fri, 11 Sep 2015 19:01:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F28308.5030303@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jGbbKak4q6kiPLGnnmQjd3xubic4OIldd" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 29/38] blockdev: Add blockdev-insert-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 17:01:28 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jGbbKak4q6kiPLGnnmQjd3xubic4OIldd Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 11.09.2015 09:30, Wen Congyang wrote: > On 09/11/2015 03:09 AM, Max Reitz wrote: >> On 10.09.2015 03:12, Wen Congyang wrote: >>> On 09/09/2015 08:59 PM, Max Reitz wrote: >>>> On 09.09.2015 12:01, Wen Congyang wrote: >>>>> On 09/09/2015 05:20 AM, Max Reitz wrote: >>>>>> On 08.09.2015 11:13, Wen Congyang wrote: >>>>>>> On 07/21/2015 01:45 AM, Max Reitz wrote: >>>>>>>> And a helper function for that, which directly takes a pointer t= o the >>>>>>>> BDS to be inserted instead of its node-name (which will be used = for >>>>>>>> implementing 'change' using blockdev-insert-medium). >>>>>>>> >>>>>>>> Signed-off-by: Max Reitz >>>>>>>> --- >>>>>>>> blockdev.c | 48 +++++++++++++++++++++++++++++++++++++= +++++++++++ >>>>>>>> qapi/block-core.json | 17 +++++++++++++++++ >>>>>>>> qmp-commands.hx | 37 +++++++++++++++++++++++++++++++++++++= >>>>>>>> 3 files changed, 102 insertions(+) >>>>>>>> >>>>>>>> diff --git a/blockdev.c b/blockdev.c >>>>>>>> index 481760a..a80d0e2 100644 >>>>>>>> --- a/blockdev.c >>>>>>>> +++ b/blockdev.c >>>>>>>> @@ -2164,6 +2164,54 @@ void qmp_blockdev_remove_medium(const cha= r *device, Error **errp) >>>>>>>> } >>>>>>>> } >>>>>>>> =20 >>>>>>>> +static void qmp_blockdev_insert_anon_medium(const char *device,= >>>>>>>> + BlockDriverState *b= s, Error **errp) >>>>>>>> +{ >>>>>>>> + BlockBackend *blk; >>>>>>>> + bool has_device; >>>>>>>> + >>>>>>>> + blk =3D blk_by_name(device); >>>>>>>> + if (!blk) { >>>>>>>> + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, >>>>>>>> + "Device '%s' not found", device); >>>>>>>> + return; >>>>>>>> + } >>>>>>>> + >>>>>>>> + /* For BBs without a device, we can exchange the BDS tree a= t will */ >>>>>>>> + has_device =3D blk_get_attached_dev(blk); >>>>>>>> + >>>>>>>> + if (has_device && !blk_dev_has_removable_media(blk)) { >>>>>>>> + error_setg(errp, "Device '%s' is not removable", device= ); >>>>>>>> + return; >>>>>>>> + } >>>>>>>> + >>>>>>>> + if (has_device && !blk_dev_is_tray_open(blk)) { >>>>>>>> + error_setg(errp, "Tray of device '%s' is not open", dev= ice); >>>>>>>> + return; >>>>>>>> + } >>>>>>>> + >>>>>>>> + if (blk_bs(blk)) { >>>>>>>> + error_setg(errp, "There already is a medium in device '= %s'", device); >>>>>>>> + return; >>>>>>>> + } >>>>>>>> + >>>>>>>> + blk_insert_bs(blk, bs); >>>>>>>> +} >>>>>>>> + >>>>>>>> +void qmp_blockdev_insert_medium(const char *device, const char = *node_name, >>>>>>>> + Error **errp) >>>>>>>> +{ >>>>>>>> + BlockDriverState *bs; >>>>>>>> + >>>>>>>> + bs =3D bdrv_find_node(node_name); >>>>>>>> + if (!bs) { >>>>>>>> + error_setg(errp, "Node '%s' not found", node_name); >>>>>>>> + return; >>>>>>>> + } >>>>>>> >>>>>>> Hmm, it is OK if the bs is not top BDS? >>>>>> >>>>>> I think so, yes. Generally, there's probably no reason to do that,= but I >>>>>> don't know why we should not allow that case. For instance, you mi= ght >>>>>> want to make a backing file available read-only somewhere. >>>>>> >>>>>> It should be impossible to make it available writable, and it shou= ld not >>>>>> be allowed to start a block-commit operation while the backing fil= e can >>>>>> be accessed by the guest, but this should be achieved using op blo= ckers. >>>>>> >>>>>> What we need for this to work are fine-grained op blockers, I thin= k. But >>>>>> working around that for now by only allowing to insert top BDS won= 't >>>>>> work, since you can still start block jobs which target top BDS, t= oo >>>>>> (e.g. blockdev-backup can write to a BDS/BB that is visible to the= guest). >>>>>> >>>>>> All in all, I think it's fine to insert non-top BDS, but we should= >>>>>> definitely worry about which exact BDS one can insert once we have= >>>>>> fine-grained op blockers. >>>>> >>>>> A BDS can be written by its parent, its block backend, a block job.= =2E >>>>> So I think we should have some way to avoid more than two sources w= riting >>>>> to it, otherwise the data may be corrupted. >>>> >>>> Yes, and that would be op blockers. >>>> >>>> As I said, using blockdev-backup you can write to a BB that can be >>>> written to by the guest as well. I think this is a bug, but it is a = bug >>>> that needs to be fixed by having better op blockers in place, which = Jeff >>>> Cody is working on. >>>> >>>> Regarding this series, I don't consider this to be too big of an iss= ue. >>>> Yes, if you are working with floppy disks, you can have the case of = a >>>> block job and the guest writing to the BDS at the same time. But I c= an't >>>> really imagine who would use floppy disks and block jobs at the same= >>>> time (people who still use floppy disks for their VMs don't strike m= e as >>>> the kind of people who use the management features of qemu, especial= ly >>>> not for those floppy disks). >>>> >>>> Other than that, this function (blockdev-insert-medium) can only be = used >>>> for optical ROM devices (I don't think we have CD/DVD-RW support, do= >>>> we?), so it's much less of an issue there. >>>> >>>> So all in all I don't consider this too big of an issue here. If oth= ers >>>> think different, then I would delay this part of the series (which >>>> overhauls the "change" command) until we have fine-grained op blocke= rs. >>> >>> In most cases, the user uses this command to change CD/DVD media, so = it is OK. >>> But IIRC scsi disk can also be changed. So we can mark this command a= s experimental >>> (the command name can be x-blockdev-insert-medium). >> >> I'd rather delay this part than mark it experimental. But then again, >> seeing that we have cases like this already (i.e. blockdev-backup) and= >> nobody seems to be complaining, I still think it should be fine. >=20 > Hmm, another question, when will you post the newest patchset? Block re= plication is > based on this patchset. The best I can say is "once I have the time". There are a lot of things going on right now, not only regarding code I have to write, but also regarding patches I have to review. This series hasn't really been on other people's priority list for eight months now, so I had to take up other things in between which means that now I cannot just focus on this series alone and don't do anything else. Be assured that I took notice that you requested a new version, though, so I will work on it once I can. Max --jGbbKak4q6kiPLGnnmQjd3xubic4OIldd Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV8wjXAAoJEDuxQgLoOKytp40H/iqnnPrCecj8WLLrrdcXzek+ c2GXIFm2AdmRqrZfTyYJ4Z/Core1oQJIeMqrDNSCRhX/JSsPJDCK4XeN262YysAM cCDP7lvj4pVcHxnx8R85vpyN3aN8DivW5jo9UoKULx1Um5sVsIisMmzn3aRU1Vj+ snQKfTK0osxXJUwJEo+hGEaq6x6u1YFtlYFdzQXpxDVn6J4xc7s6aJo9e6/sgbBB l/yad+xBKOAoGURfNqcU2SxbR+dtS5qFY7jEAtGFkviAmn4If5OI1vfMX6X646ns L09jyR+62hafhyW05eJJp+QgrHjMKlotvrzsZPU6PgE3LatCrrTIaP0z1y9tvLo= =yxO3 -----END PGP SIGNATURE----- --jGbbKak4q6kiPLGnnmQjd3xubic4OIldd-- From MAILER-DAEMON Fri Sep 11 13:15:45 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaRvN-0000mT-0l for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 13:15:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaRvI-0000le-I3 for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:15:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaRvE-0006rV-7b for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:15:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49351) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaRvD-0006rK-VB; Fri, 11 Sep 2015 13:15:36 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 1B718341ADF; Fri, 11 Sep 2015 17:15:35 +0000 (UTC) Received: from [10.36.116.61] (ovpn-116-61.ams2.redhat.com [10.36.116.61]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BHFV2n030147 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 11 Sep 2015 13:15:33 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: From: Max Reitz Message-ID: <55F30C33.80008@redhat.com> Date: Fri, 11 Sep 2015 19:15:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="XPl0lkteUi8CuTT0i73sdHtaDnDebS1Sn" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v3 1/4] block: rename BlockdevSnapshot to BlockdevSnapshotSync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 17:15:41 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --XPl0lkteUi8CuTT0i73sdHtaDnDebS1Sn Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 10.09.2015 15:39, Alberto Garcia wrote: > We will introduce the 'blockdev-snapshot' command that will require > its own struct for the parameters, so we need to rename this one in > order to avoid name clashes. >=20 > Signed-off-by: Alberto Garcia > Reviewed-by: Eric Blake > --- > blockdev.c | 2 +- > qapi-schema.json | 2 +- > qapi/block-core.json | 8 ++++---- > 3 files changed, 6 insertions(+), 6 deletions(-) Reviewed-by: Max Reitz --XPl0lkteUi8CuTT0i73sdHtaDnDebS1Sn Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV8wwzAAoJEDuxQgLoOKytJc8H/j9qyZGeiYCHN6d6Y+O3zlh+ AVhgl6t0lSVnQs14BWV6Q351gpXpIxtESdmT3utrWZfbhi7eOtMybsd/nXca4pxJ NWTSiWy2xyZDErBrgE8R+5ns/PNl0b9/4ihwZ3XZ6JTLTVpQahf1B0tFQn/mxIVn M+WBlzfuOIXIbCYogUePzRMcyYVaOUDm5LvDFrRx/Izh7eLy+4H5TG4tYt+bA92V 2/Siz6PiCwi5VmfQcNZpohsNQ7GNsMPAG4ZVOq95V/PnD4AmyazPlJk1/xfHUz/A FBbwo/F0wFvKxXAkXcUFQDESch/AfdZX+JIzZrbSTqWYjtrUlifvZRIQGhWI3xg= =7XO0 -----END PGP SIGNATURE----- --XPl0lkteUi8CuTT0i73sdHtaDnDebS1Sn-- From MAILER-DAEMON Fri Sep 11 13:21:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaS1K-0002hZ-0r for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 13:21:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaS1I-0002hS-QD for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:21:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaS1F-0002Re-OE for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:21:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36603) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaS1F-0002RY-If; Fri, 11 Sep 2015 13:21:49 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id E7E44C0A514C; Fri, 11 Sep 2015 17:21:48 +0000 (UTC) Received: from [10.36.116.61] (ovpn-116-61.ams2.redhat.com [10.36.116.61]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BHLjUW002340 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 11 Sep 2015 13:21:46 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <1be64a26c9a89ff0af4c2b1299d6c8b58361644a.1441890725.git.berto@igalia.com> From: Max Reitz Message-ID: <55F30DA8.4070502@redhat.com> Date: Fri, 11 Sep 2015 19:21:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1be64a26c9a89ff0af4c2b1299d6c8b58361644a.1441890725.git.berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="LHHNLjCmR3O6h86K7NTKaeH22rQS6EEjk" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v3 2/4] block: Add 'ignore-backing' field to BlockdevOptionsGenericCOWFormat X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 17:21:53 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --LHHNLjCmR3O6h86K7NTKaeH22rQS6EEjk Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 10.09.2015 15:39, Alberto Garcia wrote: > If set to true, the image will be opened with the BDRV_O_NO_BACKING > flag. This is useful for creating snapshots using images opened with > blockdev-add, since they are not supposed to have a backing image > before the operation. >=20 > Signed-off-by: Alberto Garcia > --- > block.c | 5 +++++ > qapi/block-core.json | 6 +++++- > 2 files changed, 10 insertions(+), 1 deletion(-) Ignorant of any possible previous discussion that might have taken place: The documentation for @backing says it may be set to the empty string in order to achieve exactly that. So why do we need the new flag? Because "backing: ''" is ugly? Max --LHHNLjCmR3O6h86K7NTKaeH22rQS6EEjk Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV8w2oAAoJEDuxQgLoOKytXL0H/3m3waPKjMID2A1soJk1n1IK OYkFaYPNrWY9KFGh/H4V6TLy1ad6ucWSXo6QfasFQ2rH5wnP6/Mrk7OUNospb6e/ LVwMOPqaTlVFMC3YTn5FTAfwZn9JKKWVTra0axI1FEV2Z29UOeseXrkgCl9ynWb5 h+sncQMuiWld0M3tw04w1GdZTSmJI6ZjwkavzfqLcCBm3uL9XRsPieTNVJnIua9F rkzSeaHBzZinghu1eoYBiVY9C5aDE2iUjjebGqBpLL/d2r3A4QDzqItyise+sLOj 76uT3N6wh7qPGPGF+pxGFnxJm7UyBn8mqvxPD/iMiJyw6JMaQEH4/hgS/ILh4aU= =janG -----END PGP SIGNATURE----- --LHHNLjCmR3O6h86K7NTKaeH22rQS6EEjk-- From MAILER-DAEMON Fri Sep 11 13:28:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaS7i-0004qa-Ab for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 13:28:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaS7g-0004qI-LM for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:28:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaS7c-0005tz-7m for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:28:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38149) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaS7b-0005tp-Vi; Fri, 11 Sep 2015 13:28:24 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 7F0E2C0A5149; Fri, 11 Sep 2015 17:28:23 +0000 (UTC) Received: from [10.3.113.15] ([10.3.113.15]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BHSMf6009262; Fri, 11 Sep 2015 13:28:22 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <1be64a26c9a89ff0af4c2b1299d6c8b58361644a.1441890725.git.berto@igalia.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55F30F24.3000305@redhat.com> Date: Fri, 11 Sep 2015 11:28:04 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1be64a26c9a89ff0af4c2b1299d6c8b58361644a.1441890725.git.berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="G3XTopnvSAPfbT3mm0ANOhPQpW2i6mVaO" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v3 2/4] block: Add 'ignore-backing' field to BlockdevOptionsGenericCOWFormat X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 17:28:29 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --G3XTopnvSAPfbT3mm0ANOhPQpW2i6mVaO Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/10/2015 07:39 AM, Alberto Garcia wrote: > If set to true, the image will be opened with the BDRV_O_NO_BACKING > flag. This is useful for creating snapshots using images opened with > blockdev-add, since they are not supposed to have a backing image > before the operation. >=20 > Signed-off-by: Alberto Garcia > --- > block.c | 5 +++++ > qapi/block-core.json | 6 +++++- > 2 files changed, 10 insertions(+), 1 deletion(-) >=20 > diff --git a/block.c b/block.c > index 22d3b0e..4be32fb 100644 > --- a/block.c > +++ b/block.c > @@ -1469,6 +1469,11 @@ static int bdrv_open_inherit(BlockDriverState **= pbs, const char *filename, > =20 > assert(drvname || !(flags & BDRV_O_PROTOCOL)); > =20 > + if (qdict_get_try_bool(options, "ignore-backing", false)) { > + flags |=3D BDRV_O_NO_BACKING; > + } > + qdict_del(options, "ignore-backing"); What happens if the user specified "ignore-backing":true, "backing":...? Should that be a hard error? > { 'struct': 'BlockdevOptionsGenericCOWFormat', > 'base': 'BlockdevOptionsGenericFormat', > - 'data': { '*backing': 'BlockdevRef' } } > + 'data': { '*backing': 'BlockdevRef', > + '*ignore-backing': 'bool' } } Depending on whether the answer to my question is that we already behave sanely and don't leave a BlockdevRef dangling if the caller mixes the two approaches, then: Reviewed-by: Eric Blake But design-wise, would it make sense to support: "backing":null as an explicit request to not open a backing file? Right now, qapi does not have a way to express 'null' as part of an alternate type; but if it did, BlockdevRef would merely add 'null' as one of its allowed alternates. Then we wouldn't need ignore-backing from the QMP perspective. But I'm still not sure how it would map to the command line perspective. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --G3XTopnvSAPfbT3mm0ANOhPQpW2i6mVaO Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV8w8kAAoJEKeha0olJ0NqwCQIAJ4UV7NPEgMPAahmIvXgoqgq uhPTb3Y3Yv/bvK6mjmQaK1gUpc4aolez3jhorwzOuBb2/OBaKneHAG8xB6WcuydA jPvS2utX7VYRw4vbFB0O6tNN0YKcugw9HbtErpOdv4mt5aznB+L1R7ENF0l2VGPP ssYOu9DmLE1kAlX76F8OTDzklAQrqxFyRdNvLSXJzxo5zySD6zO4GCcFUEmSFoph YLdXsWEZbxZOWT5aY85r9zBEkPLE8vrsWIvEMsGhctlSKphQc7SoAOmX1bCSkvH2 BylRsFH/hJ0USlnV5g7Q0obKVtqdmhHVFIEPazYUKZGYqtu/bqfyE4KQd0Jr83s= =CnkQ -----END PGP SIGNATURE----- --G3XTopnvSAPfbT3mm0ANOhPQpW2i6mVaO-- From MAILER-DAEMON Fri Sep 11 13:29:00 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaS8C-0005Rg-Q1 for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 13:29:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaS8A-0005OW-A1 for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:28:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaS89-000640-E5 for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:28:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38290) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaS89-00063o-9c; Fri, 11 Sep 2015 13:28:57 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id CFE84C0A1614; Fri, 11 Sep 2015 17:28:56 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8BHSsOD029404; Fri, 11 Sep 2015 13:28:55 -0400 Date: Fri, 11 Sep 2015 19:28:54 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150911172854.GC5164@noname.redhat.com> References: <1be64a26c9a89ff0af4c2b1299d6c8b58361644a.1441890725.git.berto@igalia.com> <55F30DA8.4070502@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0OAP2g/MAC+5xKAE" Content-Disposition: inline In-Reply-To: <55F30DA8.4070502@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v3 2/4] block: Add 'ignore-backing' field to BlockdevOptionsGenericCOWFormat X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 17:28:59 -0000 --0OAP2g/MAC+5xKAE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 11.09.2015 um 19:21 hat Max Reitz geschrieben: > On 10.09.2015 15:39, Alberto Garcia wrote: > > If set to true, the image will be opened with the BDRV_O_NO_BACKING > > flag. This is useful for creating snapshots using images opened with > > blockdev-add, since they are not supposed to have a backing image > > before the operation. > >=20 > > Signed-off-by: Alberto Garcia > > --- > > block.c | 5 +++++ > > qapi/block-core.json | 6 +++++- > > 2 files changed, 10 insertions(+), 1 deletion(-) >=20 > Ignorant of any possible previous discussion that might have taken > place: The documentation for @backing says it may be set to the empty > string in order to achieve exactly that. >=20 > So why do we need the new flag? Because "backing: ''" is ugly? I guess it's just because you're the only one who actually reads the documentation. When discussing this, I didn't remember that we already had a way to express this (an additional bool wouldn't have been my favourite solution anyway). Thanks for catching this. Kevin --0OAP2g/MAC+5xKAE Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJV8w9WAAoJEH8JsnLIjy/W0FwQAKOPSsQ/42wTZ6LToenaOGJE SUi+tPYXkhqD+O4PpumRMTlF2CqiV0WVHuyQRxj0Xg9yMosQTW0A+0O6WN9cRY50 BLDgjFYQ+SEU//+yZmhRjYSU0ziS59jmJb4wUluJUViTvhz++xrBVqbLHYNgrq8t lXRQjPe2QcEKC0i/g4Qcwc3qNDa5eD3UJww9PEsyHuL0PsG6wg8Ch4ii+OBNStDR Jb+Wwqao3JfSRouO4vfyCowteIGnOXkQlORhlwOPZxtdvT35V1Myj/86pbAc6iQ6 THj1zaK21Z13alpta/bBID5htXLfQcKTKuJYsLcuxL4qarBz0KTDCOdhiwsifv3F CigKC7B3qSr/nn1svd6DICudNzWLv8e+yWgfDzJTkSQhA3m7E6kXOu5g9cfiuhJv Sg7m70xv8vJ7HdBd0kpm04F59jOpuFe5+LCbtb7UzAKdysSjB//0L1RgWDFhe3KW qBKb49ANEKNC8Qh4a2+XRCONAr7Tl/s744obns52qq0jVso05vKc0GGbtC3yjkfC bTDbcYu+ji/aNgqICYAAHhUPMmWg9pziC4etzgQf+V8nPmef39zYmMSSReh/QJy2 yn7z1FrRfD/n68m+oR4o+kKrFE8dn7ywbaTZg9CRsQIDjs4uWeBUqdokbNOKKG4L DnkiiX9lfBq2m2SJUrB6 =2lif -----END PGP SIGNATURE----- --0OAP2g/MAC+5xKAE-- From MAILER-DAEMON Fri Sep 11 13:30:53 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaSA1-00070z-3B for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 13:30:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaS9x-00070R-Ol for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:30:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaS9u-0007Me-GW for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:30:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34663) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaS9t-0007Kz-QB; Fri, 11 Sep 2015 13:30:46 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 66782A7569; Fri, 11 Sep 2015 17:30:45 +0000 (UTC) Received: from [10.3.113.15] ([10.3.113.15]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BHUioY030862; Fri, 11 Sep 2015 13:30:44 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <1be64a26c9a89ff0af4c2b1299d6c8b58361644a.1441890725.git.berto@igalia.com> <55F30F24.3000305@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55F30FC4.6030603@redhat.com> Date: Fri, 11 Sep 2015 11:30:44 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F30F24.3000305@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oPhvSVtMKRPXQkoJqfUHjjMlLx9JFmCU3" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz Subject: Re: [Qemu-block] [PATCH v3 2/4] block: Add 'ignore-backing' field to BlockdevOptionsGenericCOWFormat X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 17:30:51 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --oPhvSVtMKRPXQkoJqfUHjjMlLx9JFmCU3 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/11/2015 11:28 AM, Eric Blake wrote: > But design-wise, would it make sense to support: >=20 > "backing":null Just read Max's response; it sounds like we already have "backing":"" (and don't need "backing":null) for what we want. So maybe we don't need this patch after all. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --oPhvSVtMKRPXQkoJqfUHjjMlLx9JFmCU3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV8w/EAAoJEKeha0olJ0NqWNMH/1324P8QIF3y/Ci/LCdtpirr glX5arxqf119vX3tVrGbjTqgAqdxWdYemGtzQbt98k9qMfx1eJTQDksTQdO71vv7 xQH+cis0Is7QsWiOs8u0KPQ8YfADbjHeAljUQXhuKM2ALBFu9XsZuwaUkImkgTpn H5PZ7tiKeuULj0V2mG0tjdJA2pnhVVtk7W1sqgVk7OhplT8RJdrL/DDdZhuIaq5k Hh0/hy7lssIblwHz+NuvnKe2wQxbTD2NufzxIf4P27nwH0W2jynNHq1tYQ7e6eON /Lgt+yGujhvGUST0MLOGwWl474jr1zfVuOR4yUNIljnesP7SR6J+/DX+i2E5Aq4= =NK0y -----END PGP SIGNATURE----- --oPhvSVtMKRPXQkoJqfUHjjMlLx9JFmCU3-- From MAILER-DAEMON Fri Sep 11 13:33:55 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaSCx-0008Dk-Tu for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 13:33:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaSCw-0008Cb-2C for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:33:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaSCr-0000PV-3G for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:33:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaSCq-0000PO-UC; Fri, 11 Sep 2015 13:33:49 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 693818EA47; Fri, 11 Sep 2015 17:33:48 +0000 (UTC) Received: from [10.36.116.61] (ovpn-116-61.ams2.redhat.com [10.36.116.61]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BHXgQC032328 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 11 Sep 2015 13:33:45 -0400 To: Kevin Wolf References: <1be64a26c9a89ff0af4c2b1299d6c8b58361644a.1441890725.git.berto@igalia.com> <55F30DA8.4070502@redhat.com> <20150911172854.GC5164@noname.redhat.com> From: Max Reitz Message-ID: <55F31075.7090101@redhat.com> Date: Fri, 11 Sep 2015 19:33:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150911172854.GC5164@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oCJH0mqJS3KECIsAShXD19NNrDKKFo3FG" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v3 2/4] block: Add 'ignore-backing' field to BlockdevOptionsGenericCOWFormat X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 17:33:55 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --oCJH0mqJS3KECIsAShXD19NNrDKKFo3FG Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 11.09.2015 19:28, Kevin Wolf wrote: > Am 11.09.2015 um 19:21 hat Max Reitz geschrieben: >> On 10.09.2015 15:39, Alberto Garcia wrote: >>> If set to true, the image will be opened with the BDRV_O_NO_BACKING >>> flag. This is useful for creating snapshots using images opened with >>> blockdev-add, since they are not supposed to have a backing image >>> before the operation. >>> >>> Signed-off-by: Alberto Garcia >>> --- >>> block.c | 5 +++++ >>> qapi/block-core.json | 6 +++++- >>> 2 files changed, 10 insertions(+), 1 deletion(-) >> >> Ignorant of any possible previous discussion that might have taken >> place: The documentation for @backing says it may be set to the empty >> string in order to achieve exactly that. >> >> So why do we need the new flag? Because "backing: ''" is ugly? >=20 > I guess it's just because you're the only one who actually reads the > documentation. When discussing this, I didn't remember that we already > had a way to express this (an additional bool wouldn't have been my > favourite solution anyway). Thanks for catching this. I read the patch, it was part of the context. ;-) Max --oCJH0mqJS3KECIsAShXD19NNrDKKFo3FG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV8xB1AAoJEDuxQgLoOKytdaIH/30ADSMpIajTNS6uCSRv23Ov FEZCQmMnKRrFeUAyolT56uIlaQhQjQn+nTSDwT+saE6J70mYgNm1X9XnKWQURAf/ wEEsZVmzJNxDd9OCHxPchJJ1lnBVT1FujZ8AsHjPlJIVQCYW9wcHGI89qjg78eE6 CYn5til5vlVe3yc5U+vOxtkUc0ydnmkrTcHmWChHp+FycPlV2UYvRD2HPVfn2ukW iwqKb356priC4vWOx+JmQiECpyQrSCN3Wy2TLQer8dYb4f9geBXgVEduzvLcMEaq 0+6hmtdnKWya489K95M+/DOssyOml+zUQvVxEXCg045kpmXYCG0Ryj/HQAS3OTs= =zvcb -----END PGP SIGNATURE----- --oCJH0mqJS3KECIsAShXD19NNrDKKFo3FG-- From MAILER-DAEMON Fri Sep 11 13:53:18 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaSVi-0007tj-Hu for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 13:53:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaSVg-0007t6-Ou for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:53:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaSVc-0002GC-P3 for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:53:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaSVc-0002G0-J7; Fri, 11 Sep 2015 13:53:12 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 77EB8C0A161B; Fri, 11 Sep 2015 17:53:11 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8BHr9Sh017655; Fri, 11 Sep 2015 13:53:10 -0400 Date: Fri, 11 Sep 2015 19:53:09 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150911175309.GD5164@noname.redhat.com> References: <1441990071-7205-1-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441990071-7205-1-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH] qcow2: Make qcow2_alloc_bytes() more explicit X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 17:53:17 -0000 Am 11.09.2015 um 18:47 hat Max Reitz geschrieben: > In case of -EAGAIN returned by update_refcount(), we should discard the > cluster offset we were trying to allocate and request a new one, because > in theory that old offset might now be taken by a refcount block. > > In practice, this was not the case due to update_refcount() generally > returning strictly monotonic increasing cluster offsets. However, this > behavior is not set in stone, and it is also not obvious when looking at > qcow2_alloc_bytes() alone, so we should not rely on it. > > Reported-by: Kevin Wolf > Signed-off-by: Max Reitz > --- > block/qcow2-refcount.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c > index e8430ec..c30bb14 100644 > --- a/block/qcow2-refcount.c > +++ b/block/qcow2-refcount.c > @@ -949,11 +949,17 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size) > > if (!offset || ROUND_UP(offset, s->cluster_size) != new_cluster) { > offset = new_cluster; > + free_in_cluster = s->cluster_size; > + } else { > + free_in_cluster += s->cluster_size; > } > } This doesn't actually do anything except confuse the reader, but as the value of free_in_cluster doesn't matter in the second iteration because offset == 0, this is correct. > assert(offset); > ret = update_refcount(bs, offset, size, 1, false, QCOW2_DISCARD_NEVER); > + if (ret < 0) { > + offset = 0; > + } > } while (ret == -EAGAIN); > if (ret < 0) { > return ret; Thanks, applied to the block branch. Kevin From MAILER-DAEMON Fri Sep 11 13:58:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaSad-0001nT-QK for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 13:58:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaSab-0001nK-Pg for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:58:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaSaX-0004ng-Nx for qemu-block@nongnu.org; Fri, 11 Sep 2015 13:58:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40448) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaSaX-0004na-Gn; Fri, 11 Sep 2015 13:58:17 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id D99C6A0792; Fri, 11 Sep 2015 17:58:16 +0000 (UTC) Received: from [10.3.113.15] ([10.3.113.15]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BHwFGc012877; Fri, 11 Sep 2015 13:58:16 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <40f3f51fb44da70929f7055e95582351d1aa3f34.1441890725.git.berto@igalia.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55F31633.6010800@redhat.com> Date: Fri, 11 Sep 2015 11:58:11 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <40f3f51fb44da70929f7055e95582351d1aa3f34.1441890725.git.berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="D9tet23jeVcXkvIOn7gJCxdbrKb12ngK0" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v3 3/4] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 17:58:23 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --D9tet23jeVcXkvIOn7gJCxdbrKb12ngK0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/10/2015 07:39 AM, Alberto Garcia wrote: > One of the limitations of the 'blockdev-snapshot-sync' command is that > it does not allow passing BlockdevOptions to the newly created > snapshots, so they are always opened using the default values. >=20 > Extending the command to allow passing options is not a practical > solution because there is overlap between those options and some of > the existing parameters of the command. >=20 > This patch introduces a new 'blockdev-snapshot' command with a simpler > interface: it just takes two references to existing block devices that > will be used as the source and target for the snapshot. >=20 > Since the main difference between the two commands is that one of them > creates and opens the target image, while the other uses an already > opened one, the bulk of the implementation is shared. >=20 > Signed-off-by: Alberto Garcia > --- > blockdev.c | 163 ++++++++++++++++++++++++++++++++-----------= -------- > qapi-schema.json | 2 + > qapi/block-core.json | 26 ++++++++ > qmp-commands.hx | 29 +++++++++ > 4 files changed, 160 insertions(+), 60 deletions(-) >=20 > diff --git a/blockdev.c b/blockdev.c > index 6b787c1..78cfb79 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1183,6 +1183,18 @@ void qmp_blockdev_snapshot_sync(bool has_device,= const char *device, > &snapshot, errp); > } > =20 > +void qmp_blockdev_snapshot(const char *device, const char *snapshot, > + Error **errp) > +{ > + BlockdevSnapshot snapshot_data =3D { > + .device =3D (char *) device, > + .snapshot =3D (char *) snapshot > + }; Hmm. Sounds like you'd love to use my pending 'box':true qapi glue to make this function have the saner signature of void qmp_blockdev_snapshot(BlockdevSnapshot *arg, Error **errp); rather than having to rebuild the struct yourself (with an annoying cast to lose const) :) https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg02599.html But no need to hold this series up waiting for the qapi review queue to flush. We can simplify later. > =20 > - options =3D qdict_new(); > - if (has_snapshot_node_name) { > - qdict_put(options, "node-name", > - qstring_from_str(snapshot_node_name)); > + if (snapshot_node_name && bdrv_find_node(snapshot_node_name)) = { > + error_setg(errp, "New snapshot node name already existing"= ); Pre-existing, but s/existing/exists/ while you are reindenting this. > +++ b/qapi/block-core.json > @@ -705,6 +705,19 @@ > '*format': 'str', '*mode': 'NewImageMode' } } > =20 > ## > +# @BlockdevSnapshot > +# > +# @device: device or node name to generate the snapshot from. > +# > +# @snapshot: reference to the existing block device that will be used > +# for the snapshot. Maybe mention that it must NOT have a current backing file, and point to the "backing":"" trick to get it that way. > +Create a snapshot, by installing 'device' as the backing image of > +'snapshot'. Additionally, if 'device' is associated with a block > +device, the block device changes to using 'snapshot' as its new active= > +image. Still didn't answer the question from the earlier review of whether the blockdev-snapshot-sync behavior of specifying the node name of an active layer in order to not pivot the block device to the snapshot still makes sense to support in the blockdev-snapshot case. But we could always add an optional boolean flag later if someone comes up for a use case where they'd need to create a snapshot of the active layer without the block device pivoting, so I don't think it should hold up this patch. > + > +Arguments: > + > +- "device": snapshot source (json-string) > +- "snapshot": snapshot target (json-string) > + > +Example: > + > +-> { "execute": "blockdev-snapshot", "arguments": { "device": "ide-hd0= ", > + "snapshot": "node1= 534" } } > +<- { "return": {} } Maybe enhance the example to show the preliminary blockdev-add that created node1534? I've pointed out some potential wording improvements, but think they are minor enough that you can have: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --D9tet23jeVcXkvIOn7gJCxdbrKb12ngK0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV8xYzAAoJEKeha0olJ0NquNcIAI3fnYqVlWOnacDA1EeK5GjL sBguXnmH7VEXFMuea1uV9fWtvvOO/hT13tIJuoZWwLBV+lsulYeil5ZkiS3PR9ez JzJpvxkCHGqoys+V7viaufimpVQ97wnTjSqsISWYWHBq93G+JbB+XcDxXNvVDCh6 BK/qdX97S5FBeo2qfUCzKR15F3bOzN+mQGqKE41hTzAAlqMs0bbbQ7pfLts1/TaO 6SgM5yKxPsd0AS4AWNQNU2PiNznVvn87K485jim8fh4qezVc2+irBl73XNlQON0p YRH90Q/Mc7HA261O6FV1i5OdL+L1RimfZJKrC+aLhmpwosDPCsznO8xaqKTfvXQ= =Q5Dl -----END PGP SIGNATURE----- --D9tet23jeVcXkvIOn7gJCxdbrKb12ngK0-- From MAILER-DAEMON Fri Sep 11 14:02:36 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaSei-0004ac-4v for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 14:02:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaSeg-0004aS-1H for qemu-block@nongnu.org; Fri, 11 Sep 2015 14:02:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaSec-0006Mg-06 for qemu-block@nongnu.org; Fri, 11 Sep 2015 14:02:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49196) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaSeb-0006MK-RZ; Fri, 11 Sep 2015 14:02:29 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 0B4B68E3F2; Fri, 11 Sep 2015 18:02:29 +0000 (UTC) Received: from [10.3.113.15] ([10.3.113.15]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BI2SVc023075; Fri, 11 Sep 2015 14:02:28 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <791796d6176b5439491a46496de216ec453ecf93.1441890725.git.berto@igalia.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55F31733.4020105@redhat.com> Date: Fri, 11 Sep 2015 12:02:27 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <791796d6176b5439491a46496de216ec453ecf93.1441890725.git.berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xLfQ2vejQQsxo8VuGqUl4U6h12ORuip09" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v3 4/4] block: add tests for the 'blockdev-snapshot' command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 18:02:35 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --xLfQ2vejQQsxo8VuGqUl4U6h12ORuip09 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/10/2015 07:39 AM, Alberto Garcia wrote: > Signed-off-by: Alberto Garcia > --- > tests/qemu-iotests/085 | 97 ++++++++++++++++++++++++++++++++++++++= +++++--- > tests/qemu-iotests/085.out | 34 +++++++++++++++- > 2 files changed, 123 insertions(+), 8 deletions(-) >=20 > =20 > +# ${1}: unique identifier for the snapshot filename > +# ${2}: true: ignore backing images (default); false: don't ignore the= m > +function add_snapshot_image() > +{ > + base_image=3D"${TEST_DIR}/$((${1}-1))-${snapshot_virt0}" > + snapshot_file=3D"${TEST_DIR}/${1}-${snapshot_virt0}" > + _make_test_img -b "${base_image}" "$size" > + mv "${TEST_IMG}" "${snapshot_file}" > + cmd=3D"{ 'execute': 'blockdev-add', 'arguments': > + { 'options': > + { 'driver': 'qcow2', 'node-name': 'snap_"${1}"', > + 'ignore-backing': "${2:-true}", 'file': Needs to be reworked to use 'backing':'' instead of 'ignore-backing'. But overall looks like a sane set of tests to cover both positive and negative expected behavior. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --xLfQ2vejQQsxo8VuGqUl4U6h12ORuip09 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV8xczAAoJEKeha0olJ0NqkuAH/RNt0ZVRKHxr4+1Hz3Z+VkZp Jb9c7wJic4oWOqKJgLpFtH+P5ItwLR8fpH8YtP2SMfqKJTcs/4NX+/2cHdbyeG62 nKsOuUs/cW1F8cW68pCHnmMcyQXLjBsPAT9RSphx3kiBl3a50qt2JgzBxPJ8WADv LZUXTrUAKQdArz6MWe4970esguy5TcWal/52VvJyDk5LkgoeARzUIgv7RsGjQaXU dqGVZgSv+JCEjWf1jlgG8I/ykC+k9YAmLbK8yOK5t2j/QQch/dz7Th2hJvippzxO ceLt1MeqdaoaFOWm1XKPPhpCSASTfTr5QBzeC6Hoq74HTazuOCETTj1W1AZPRmk= =8GJn -----END PGP SIGNATURE----- --xLfQ2vejQQsxo8VuGqUl4U6h12ORuip09-- From MAILER-DAEMON Fri Sep 11 14:11:53 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaSnh-00080U-9C for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 14:11:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaSne-0007zm-0e for qemu-block@nongnu.org; Fri, 11 Sep 2015 14:11:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaSna-0002zh-P8 for qemu-block@nongnu.org; Fri, 11 Sep 2015 14:11:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40431) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaSna-0002zb-KH; Fri, 11 Sep 2015 14:11:46 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 23E638B136; Fri, 11 Sep 2015 18:11:46 +0000 (UTC) Received: from [10.36.116.61] (ovpn-116-61.ams2.redhat.com [10.36.116.61]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BIBg0C028663 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 11 Sep 2015 14:11:44 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <40f3f51fb44da70929f7055e95582351d1aa3f34.1441890725.git.berto@igalia.com> From: Max Reitz Message-ID: <55F3195D.9070604@redhat.com> Date: Fri, 11 Sep 2015 20:11:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <40f3f51fb44da70929f7055e95582351d1aa3f34.1441890725.git.berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QtvnEaotWG30EGOsWs9UCmLRNDR18FBWf" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v3 3/4] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 18:11:51 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --QtvnEaotWG30EGOsWs9UCmLRNDR18FBWf Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 10.09.2015 15:39, Alberto Garcia wrote: > One of the limitations of the 'blockdev-snapshot-sync' command is that > it does not allow passing BlockdevOptions to the newly created > snapshots, so they are always opened using the default values. >=20 > Extending the command to allow passing options is not a practical > solution because there is overlap between those options and some of > the existing parameters of the command. >=20 > This patch introduces a new 'blockdev-snapshot' command with a simpler > interface: it just takes two references to existing block devices that > will be used as the source and target for the snapshot. >=20 > Since the main difference between the two commands is that one of them > creates and opens the target image, while the other uses an already > opened one, the bulk of the implementation is shared. >=20 > Signed-off-by: Alberto Garcia > --- > blockdev.c | 163 ++++++++++++++++++++++++++++++++-----------= -------- > qapi-schema.json | 2 + > qapi/block-core.json | 26 ++++++++ > qmp-commands.hx | 29 +++++++++ > 4 files changed, 160 insertions(+), 60 deletions(-) Reviewed-by: Max Reitz --QtvnEaotWG30EGOsWs9UCmLRNDR18FBWf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV8xleAAoJEDuxQgLoOKytmFEH/RnIg0d1fczPmVuqN+3ywv5f X/SoQp9mO7t4KAhx4Equt9fg1b/R421/2hh0WigATyWMooi8DEeSBQRfPo/0dMLy q1MVU04DW7xRU3HrFAEGVTcxT0jJN2ENBVNfHX5bAfEYI7gyQU7Y4S+BoOemvUKC WoPl/8pMT3TXEA99wJ5uVCFfVpONaY53JFmRL3omfUi5RUB/xTmfvTL7jru+qblH 9MrWH33cl31qcaAc6VGIpPmQox6rvuIo/vLaee7ghVwN3cB2xt9bv/RrJlIZzcz3 FsXk+Q4pOZcKiTSX475u0bJmKG4nEhv3vUTq8UIW7qXO6OvroVw6nDQn22MXjsc= =N4ta -----END PGP SIGNATURE----- --QtvnEaotWG30EGOsWs9UCmLRNDR18FBWf-- From MAILER-DAEMON Fri Sep 11 15:41:17 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCD-0003aH-7O for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCA-0003WD-G8 for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUC6-00050X-9b for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39862) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUC5-0004xv-UB; Fri, 11 Sep 2015 15:41:10 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 428D291C0E; Fri, 11 Sep 2015 19:41:09 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7Q8017774; Fri, 11 Sep 2015 15:41:08 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:40 +0200 Message-Id: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 00/23] Block layer patches X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:15 -0000 The following changes since commit 30c38c90bd3f1bb105ebc069ac1821067c980b7c: scripts/qemu-gdb: Add brief comment describing usage (2015-09-11 17:14:50 +0100) are available in the git repository at: git://repo.or.cz/qemu/kevin.git tags/for-upstream for you to fetch changes up to 1fcbcc93872953d08cd35830d1169fed19196290: qcow2: Make qcow2_alloc_bytes() more explicit (2015-09-11 20:03:02 +0200) ---------------------------------------------------------------- Block layer patches ---------------------------------------------------------------- Kevin Wolf (14): qcow2: Rename BDRVQcowState to BDRVQcow2State block: Allow specifying driver-specific options to reopen qemu-io: Remove duplicate 'open' error message qemu-io: Add command 'reopen' qcow2: Improve error message qcow2: Factor out qcow2_update_options() qcow2: Move qcow2_update_options() call up qcow2: Move rest of option handling to qcow2_update_options() qcow2: Leave s unchanged on qcow2_update_options() failure qcow2: Fix memory leak in qcow2_update_options() error path qcow2: Make qcow2_update_options() suitable for transactions qcow2: Support updating driver-specific options in reopen qemu-iotests: Reopen qcow2 with lazy-refcounts change qemu-iotests: More qcow2 reopen tests Max Reitz (8): block: Always pass NULL as drv for bdrv_open() block: Drop drv parameter from bdrv_open() block: Drop drv parameter from bdrv_open_inherit() block: Drop drv parameter from bdrv_fill_options() block: Drop bdrv_find_whitelisted_format() qcow2: Make size_to_clusters() return uint64_t iotests: Add test for checking large image files qcow2: Make qcow2_alloc_bytes() more explicit Radoslav Gerganov (1): vmdk: Fix next_cluster_sector for compressed write block.c | 150 +++++++------- block/block-backend.c | 2 +- block/commit.c | 4 +- block/parallels.c | 2 +- block/qcow.c | 2 +- block/qcow2-cache.c | 14 +- block/qcow2-cluster.c | 76 +++---- block/qcow2-refcount.c | 74 ++++--- block/qcow2-snapshot.c | 20 +- block/qcow2.c | 486 +++++++++++++++++++++++++++++---------------- block/qcow2.h | 26 +-- block/qed.c | 2 +- block/sheepdog.c | 5 +- block/vdi.c | 2 +- block/vhdx.c | 2 +- block/vmdk.c | 15 +- block/vpc.c | 2 +- block/vvfat.c | 8 +- blockdev.c | 72 +++---- include/block/block.h | 9 +- qemu-io-cmds.c | 90 +++++++++ qemu-io.c | 1 - tests/qemu-iotests/039 | 27 +++ tests/qemu-iotests/039.out | 18 ++ tests/qemu-iotests/137 | 145 ++++++++++++++ tests/qemu-iotests/137.out | 42 ++++ tests/qemu-iotests/138 | 73 +++++++ tests/qemu-iotests/138.out | 9 + tests/qemu-iotests/group | 2 + 29 files changed, 972 insertions(+), 408 deletions(-) create mode 100755 tests/qemu-iotests/137 create mode 100644 tests/qemu-iotests/137.out create mode 100755 tests/qemu-iotests/138 create mode 100644 tests/qemu-iotests/138.out From MAILER-DAEMON Fri Sep 11 15:41:20 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCG-0003cR-1i for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCD-0003aY-DD for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCC-00058q-HB for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCC-00058g-Br; Fri, 11 Sep 2015 15:41:16 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 12EE6C0A1612; Fri, 11 Sep 2015 19:41:16 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QD017774; Fri, 11 Sep 2015 15:41:15 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:45 +0200 Message-Id: <1442000463-22777-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 05/23] block: Drop bdrv_find_whitelisted_format() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:18 -0000 From: Max Reitz It is unused by now, so we can drop it. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia Signed-off-by: Kevin Wolf --- block.c | 7 ------- include/block/block.h | 2 -- 2 files changed, 9 deletions(-) diff --git a/block.c b/block.c index 7c61555..3de83e6 100644 --- a/block.c +++ b/block.c @@ -313,13 +313,6 @@ static int bdrv_is_whitelisted(BlockDriver *drv, bool read_only) return 0; } -BlockDriver *bdrv_find_whitelisted_format(const char *format_name, - bool read_only) -{ - BlockDriver *drv = bdrv_find_format(format_name); - return drv && bdrv_is_whitelisted(drv, read_only) ? drv : NULL; -} - typedef struct CreateCo { BlockDriver *drv; char *filename; diff --git a/include/block/block.h b/include/block/block.h index ab4518c..e539194 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -193,8 +193,6 @@ BlockDriver *bdrv_find_protocol(const char *filename, bool allow_protocol_prefix, Error **errp); BlockDriver *bdrv_find_format(const char *format_name); -BlockDriver *bdrv_find_whitelisted_format(const char *format_name, - bool readonly); int bdrv_create(BlockDriver *drv, const char* filename, QemuOpts *opts, Error **errp); int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp); -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:22 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCI-0003g0-4g for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCB-0003YH-38 for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUC9-00056m-VM for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44037) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUC9-00056L-OE; Fri, 11 Sep 2015 15:41:13 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 6D92E8E3E8; Fri, 11 Sep 2015 19:41:13 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QB017774; Fri, 11 Sep 2015 15:41:12 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:43 +0200 Message-Id: <1442000463-22777-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 03/23] block: Drop drv parameter from bdrv_open_inherit() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:19 -0000 From: Max Reitz Now that this parameter is effectively unused, we can drop it and just pass NULL to bdrv_fill_options(). Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia Signed-off-by: Kevin Wolf --- block.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/block.c b/block.c index 0e1b4b4..52fa7f8 100644 --- a/block.c +++ b/block.c @@ -85,8 +85,7 @@ static QLIST_HEAD(, BlockDriver) bdrv_drivers = static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, const char *reference, QDict *options, int flags, BlockDriverState *parent, - const BdrvChildRole *child_role, - BlockDriver *drv, Error **errp); + const BdrvChildRole *child_role, Error **errp); static void bdrv_dirty_bitmap_truncate(BlockDriverState *bs); /* If non-zero, use only whitelisted block drivers */ @@ -1227,8 +1226,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) assert(bs->backing_hd == NULL); ret = bdrv_open_inherit(&backing_hd, *backing_filename ? backing_filename : NULL, - NULL, options, 0, bs, &child_backing, - NULL, &local_err); + NULL, options, 0, bs, &child_backing, &local_err); if (ret < 0) { bdrv_unref(backing_hd); backing_hd = NULL; @@ -1291,7 +1289,7 @@ BdrvChild *bdrv_open_child(const char *filename, bs = NULL; ret = bdrv_open_inherit(&bs, filename, reference, image_options, 0, - parent, child_role, NULL, errp); + parent, child_role, errp); if (ret < 0) { goto done; } @@ -1422,11 +1420,11 @@ out: static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, const char *reference, QDict *options, int flags, BlockDriverState *parent, - const BdrvChildRole *child_role, - BlockDriver *drv, Error **errp) + const BdrvChildRole *child_role, Error **errp) { int ret; BlockDriverState *file = NULL, *bs; + BlockDriver *drv = NULL; const char *drvname; Error *local_err = NULL; int snapshot_flags = 0; @@ -1476,13 +1474,12 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, flags = child_role->inherit_flags(parent->open_flags); } - ret = bdrv_fill_options(&options, &filename, &flags, drv, &local_err); + ret = bdrv_fill_options(&options, &filename, &flags, NULL, &local_err); if (local_err) { goto fail; } /* Find the right image format driver */ - drv = NULL; drvname = qdict_get_try_str(options, "driver"); if (drvname) { drv = bdrv_find_format(drvname); @@ -1640,7 +1637,7 @@ int bdrv_open(BlockDriverState **pbs, const char *filename, const char *reference, QDict *options, int flags, Error **errp) { return bdrv_open_inherit(pbs, filename, reference, options, flags, NULL, - NULL, NULL, errp); + NULL, errp); } typedef struct BlockReopenQueueEntry { -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:17 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCD-0003aS-Ah for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCA-0003WL-Gu for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUC8-00053x-Nn for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36185) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUC8-00053s-Db; Fri, 11 Sep 2015 15:41:12 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 1E383AC1A1; Fri, 11 Sep 2015 19:41:12 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QA017774; Fri, 11 Sep 2015 15:41:10 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:42 +0200 Message-Id: <1442000463-22777-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 02/23] block: Drop drv parameter from bdrv_open() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:16 -0000 From: Max Reitz Now that this parameter is effectively unused, we can drop it and just pass NULL on to bdrv_open_inherit(). Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia Signed-off-by: Kevin Wolf --- block.c | 9 ++++----- block/block-backend.c | 2 +- block/parallels.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 6 +++--- block/qed.c | 2 +- block/sheepdog.c | 5 ++--- block/vdi.c | 2 +- block/vhdx.c | 2 +- block/vmdk.c | 7 +++---- block/vpc.c | 2 +- block/vvfat.c | 2 +- blockdev.c | 8 ++++---- include/block/block.h | 3 +-- 14 files changed, 25 insertions(+), 29 deletions(-) diff --git a/block.c b/block.c index d0b9101..0e1b4b4 100644 --- a/block.c +++ b/block.c @@ -1391,7 +1391,7 @@ int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp) bs_snapshot = bdrv_new(); ret = bdrv_open(&bs_snapshot, NULL, NULL, snapshot_options, - flags, NULL, &local_err); + flags, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto out; @@ -1637,11 +1637,10 @@ close_and_fail: } int bdrv_open(BlockDriverState **pbs, const char *filename, - const char *reference, QDict *options, int flags, - BlockDriver *drv, Error **errp) + const char *reference, QDict *options, int flags, Error **errp) { return bdrv_open_inherit(pbs, filename, reference, options, flags, NULL, - NULL, drv, errp); + NULL, NULL, errp); } typedef struct BlockReopenQueueEntry { @@ -3846,7 +3845,7 @@ void bdrv_img_create(const char *filename, const char *fmt, bs = NULL; ret = bdrv_open(&bs, full_backing, NULL, backing_options, - back_flags, NULL, &local_err); + back_flags, &local_err); g_free(full_backing); if (ret < 0) { goto out; diff --git a/block/block-backend.c b/block/block-backend.c index aee8a12..c2e8732 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -126,7 +126,7 @@ BlockBackend *blk_new_open(const char *name, const char *filename, return NULL; } - ret = bdrv_open(&blk->bs, filename, reference, options, flags, NULL, errp); + ret = bdrv_open(&blk->bs, filename, reference, options, flags, errp); if (ret < 0) { blk_unref(blk); return NULL; diff --git a/block/parallels.c b/block/parallels.c index 046b568..5cd6ec3 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -476,7 +476,7 @@ static int parallels_create(const char *filename, QemuOpts *opts, Error **errp) file = NULL; ret = bdrv_open(&file, filename, NULL, NULL, - BDRV_O_RDWR | BDRV_O_PROTOCOL, NULL, &local_err); + BDRV_O_RDWR | BDRV_O_PROTOCOL, &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; diff --git a/block/qcow.c b/block/qcow.c index 01fba54..6e35db1 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -793,7 +793,7 @@ static int qcow_create(const char *filename, QemuOpts *opts, Error **errp) qcow_bs = NULL; ret = bdrv_open(&qcow_bs, filename, NULL, NULL, - BDRV_O_RDWR | BDRV_O_PROTOCOL, NULL, &local_err); + BDRV_O_RDWR | BDRV_O_PROTOCOL, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto cleanup; diff --git a/block/qcow2.c b/block/qcow2.c index 867b43b..a707d8d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1975,7 +1975,7 @@ static int qcow2_create2(const char *filename, int64_t total_size, bs = NULL; ret = bdrv_open(&bs, filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, - NULL, &local_err); + &local_err); if (ret < 0) { error_propagate(errp, local_err); return ret; @@ -2038,7 +2038,7 @@ static int qcow2_create2(const char *filename, int64_t total_size, qdict_put(options, "driver", qstring_from_str("qcow2")); ret = bdrv_open(&bs, filename, NULL, options, BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH, - NULL, &local_err); + &local_err); if (ret < 0) { error_propagate(errp, local_err); goto out; @@ -2092,7 +2092,7 @@ static int qcow2_create2(const char *filename, int64_t total_size, qdict_put(options, "driver", qstring_from_str("qcow2")); ret = bdrv_open(&bs, filename, NULL, options, BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_BACKING, - NULL, &local_err); + &local_err); if (local_err) { error_propagate(errp, local_err); goto out; diff --git a/block/qed.c b/block/qed.c index 954ed00..a7ff1d9 100644 --- a/block/qed.c +++ b/block/qed.c @@ -583,7 +583,7 @@ static int qed_create(const char *filename, uint32_t cluster_size, bs = NULL; ret = bdrv_open(&bs, filename, NULL, NULL, - BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_PROTOCOL, NULL, + BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_PROTOCOL, &local_err); if (ret < 0) { error_propagate(errp, local_err); diff --git a/block/sheepdog.c b/block/sheepdog.c index 9585beb..67ca788 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -1554,7 +1554,7 @@ static int sd_prealloc(const char *filename, Error **errp) int ret; ret = bdrv_open(&bs, filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, - NULL, errp); + errp); if (ret < 0) { goto out_with_err_set; } @@ -1746,8 +1746,7 @@ static int sd_create(const char *filename, QemuOpts *opts, } bs = NULL; - ret = bdrv_open(&bs, backing_file, NULL, NULL, BDRV_O_PROTOCOL, NULL, - errp); + ret = bdrv_open(&bs, backing_file, NULL, NULL, BDRV_O_PROTOCOL, errp); if (ret < 0) { goto out; } diff --git a/block/vdi.c b/block/vdi.c index 7642ef3..062a654 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -764,7 +764,7 @@ static int vdi_create(const char *filename, QemuOpts *opts, Error **errp) goto exit; } ret = bdrv_open(&bs, filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, - NULL, &local_err); + &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; diff --git a/block/vhdx.c b/block/vhdx.c index f05c7a9..d3bb1bd 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1842,7 +1842,7 @@ static int vhdx_create(const char *filename, QemuOpts *opts, Error **errp) bs = NULL; ret = bdrv_open(&bs, filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, - NULL, &local_err); + &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; diff --git a/block/vmdk.c b/block/vmdk.c index fbaab67..7bdc3d0 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1632,7 +1632,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize, assert(bs == NULL); ret = bdrv_open(&bs, filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, - NULL, &local_err); + &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; @@ -1905,8 +1905,7 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp) ret = -ENOENT; goto exit; } - ret = bdrv_open(&bs, full_backing, NULL, NULL, BDRV_O_NO_BACKING, NULL, - errp); + ret = bdrv_open(&bs, full_backing, NULL, NULL, BDRV_O_NO_BACKING, errp); g_free(full_backing); if (ret != 0) { goto exit; @@ -1977,7 +1976,7 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp) } assert(new_bs == NULL); ret = bdrv_open(&new_bs, filename, NULL, NULL, - BDRV_O_RDWR | BDRV_O_PROTOCOL, NULL, &local_err); + BDRV_O_RDWR | BDRV_O_PROTOCOL, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; diff --git a/block/vpc.c b/block/vpc.c index 3e385d9..2b3b518 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -794,7 +794,7 @@ static int vpc_create(const char *filename, QemuOpts *opts, Error **errp) goto out; } ret = bdrv_open(&bs, filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, - NULL, &local_err); + &local_err); if (ret < 0) { error_propagate(errp, local_err); goto out; diff --git a/block/vvfat.c b/block/vvfat.c index bffe8ad..7ddc962 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -2962,7 +2962,7 @@ static int enable_write_target(BDRVVVFATState *s, Error **errp) qdict_put(options, "driver", qstring_from_str("qcow")); ret = bdrv_open(&s->qcow, s->qcow_filename, NULL, options, BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH, - NULL, errp); + errp); if (ret < 0) { goto err; } diff --git a/blockdev.c b/blockdev.c index 577bf42..32b04b4 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1527,7 +1527,7 @@ static void external_snapshot_prepare(BlkTransactionState *common, * extended QMP command? */ assert(state->new_bs == NULL); ret = bdrv_open(&state->new_bs, new_image_file, NULL, options, - flags | BDRV_O_NO_BACKING, NULL, &local_err); + flags | BDRV_O_NO_BACKING, &local_err); /* We will manually add the backing_hd field to the bs later */ if (ret != 0) { error_propagate(errp, local_err); @@ -1901,7 +1901,7 @@ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename, qdict_put(options, "driver", qstring_from_str(format)); } - ret = bdrv_open(&bs, filename, NULL, options, bdrv_flags, NULL, &local_err); + ret = bdrv_open(&bs, filename, NULL, options, bdrv_flags, &local_err); if (ret < 0) { error_propagate(errp, local_err); return; @@ -2546,7 +2546,7 @@ void qmp_drive_backup(const char *device, const char *target, } target_bs = NULL; - ret = bdrv_open(&target_bs, target, NULL, options, flags, NULL, &local_err); + ret = bdrv_open(&target_bs, target, NULL, options, flags, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto out; @@ -2801,7 +2801,7 @@ void qmp_drive_mirror(const char *device, const char *target, */ target_bs = NULL; ret = bdrv_open(&target_bs, target, NULL, options, - flags | BDRV_O_NO_BACKING, NULL, &local_err); + flags | BDRV_O_NO_BACKING, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto out; diff --git a/include/block/block.h b/include/block/block.h index 0acd104..ab4518c 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -218,8 +218,7 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd); int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp); int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp); int bdrv_open(BlockDriverState **pbs, const char *filename, - const char *reference, QDict *options, int flags, - BlockDriver *drv, Error **errp); + const char *reference, QDict *options, int flags, Error **errp); BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, BlockDriverState *bs, int flags); int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp); -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCL-0003nf-Uk for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCG-0003ci-5R for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCB-00058E-AT for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33402) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCB-00057o-3H; Fri, 11 Sep 2015 15:41:15 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id C424491E97; Fri, 11 Sep 2015 19:41:14 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QC017774; Fri, 11 Sep 2015 15:41:13 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:44 +0200 Message-Id: <1442000463-22777-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 04/23] block: Drop drv parameter from bdrv_fill_options() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:24 -0000 From: Max Reitz Now that this parameter is effectively unused, we can drop it and change the function accordingly. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia Signed-off-by: Kevin Wolf --- block.c | 59 ++++++++++++++++++++++------------------------------------- 1 file changed, 22 insertions(+), 37 deletions(-) diff --git a/block.c b/block.c index 52fa7f8..7c61555 100644 --- a/block.c +++ b/block.c @@ -996,13 +996,13 @@ static QDict *parse_json_filename(const char *filename, Error **errp) * block driver has been specified explicitly. */ static int bdrv_fill_options(QDict **options, const char **pfilename, - int *flags, BlockDriver *drv, Error **errp) + int *flags, Error **errp) { const char *filename = *pfilename; const char *drvname; bool protocol = *flags & BDRV_O_PROTOCOL; bool parse_filename = false; - BlockDriver *tmp_drv; + BlockDriver *drv = NULL; Error *local_err = NULL; /* Parse json: pseudo-protocol */ @@ -1021,15 +1021,15 @@ static int bdrv_fill_options(QDict **options, const char **pfilename, } drvname = qdict_get_try_str(*options, "driver"); - - /* If the user has explicitly specified the driver, this choice should - * override the BDRV_O_PROTOCOL flag */ - tmp_drv = drv; - if (!tmp_drv && drvname) { - tmp_drv = bdrv_find_format(drvname); - } - if (tmp_drv) { - protocol = tmp_drv->bdrv_file_open; + if (drvname) { + drv = bdrv_find_format(drvname); + if (!drv) { + error_setg(errp, "Unknown driver '%s'", drvname); + return -ENOENT; + } + /* If the user has explicitly specified the driver, this choice should + * override the BDRV_O_PROTOCOL flag */ + protocol = drv->bdrv_file_open; } if (protocol) { @@ -1053,33 +1053,18 @@ static int bdrv_fill_options(QDict **options, const char **pfilename, /* Find the right block driver */ filename = qdict_get_try_str(*options, "filename"); - if (drv) { - if (drvname) { - error_setg(errp, "Driver specified twice"); - return -EINVAL; - } - drvname = drv->format_name; - qdict_put(*options, "driver", qstring_from_str(drvname)); - } else { - if (!drvname && protocol) { - if (filename) { - drv = bdrv_find_protocol(filename, parse_filename, errp); - if (!drv) { - return -EINVAL; - } - - drvname = drv->format_name; - qdict_put(*options, "driver", qstring_from_str(drvname)); - } else { - error_setg(errp, "Must specify either driver or file"); - return -EINVAL; - } - } else if (drvname) { - drv = bdrv_find_format(drvname); + if (!drvname && protocol) { + if (filename) { + drv = bdrv_find_protocol(filename, parse_filename, errp); if (!drv) { - error_setg(errp, "Unknown driver '%s'", drvname); - return -ENOENT; + return -EINVAL; } + + drvname = drv->format_name; + qdict_put(*options, "driver", qstring_from_str(drvname)); + } else { + error_setg(errp, "Must specify either driver or file"); + return -EINVAL; } } @@ -1474,7 +1459,7 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, flags = child_role->inherit_flags(parent->open_flags); } - ret = bdrv_fill_options(&options, &filename, &flags, NULL, &local_err); + ret = bdrv_fill_options(&options, &filename, &flags, &local_err); if (local_err) { goto fail; } -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCM-0003oW-DW for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCJ-0003jU-Vj for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCG-0005B3-VB for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44069) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCG-0005Au-R6; Fri, 11 Sep 2015 15:41:20 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 84B64AACD3; Fri, 11 Sep 2015 19:41:20 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QG017774; Fri, 11 Sep 2015 15:41:19 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:48 +0200 Message-Id: <1442000463-22777-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 08/23] qemu-io: Remove duplicate 'open' error message X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:25 -0000 qemu_opts_parse_noisily() already prints an error message with the exact reason why the parsing failed. No need to add another less specific one. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- qemu-io.c | 1 - 1 file changed, 1 deletion(-) diff --git a/qemu-io.c b/qemu-io.c index f1e3a67..269f17c 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -156,7 +156,6 @@ static int open_f(BlockBackend *blk, int argc, char **argv) break; case 'o': if (!qemu_opts_parse_noisily(&empty_opts, optarg, false)) { - printf("could not parse option list -- %s\n", optarg); qemu_opts_reset(&empty_opts); return 0; } -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:22 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCI-0003gF-AR for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCA-0003WA-Fv for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUC7-00053S-5M for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40256) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUC6-00052V-Uq; Fri, 11 Sep 2015 15:41:11 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 930F5C0A1608; Fri, 11 Sep 2015 19:41:10 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7Q9017774; Fri, 11 Sep 2015 15:41:09 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:41 +0200 Message-Id: <1442000463-22777-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 01/23] block: Always pass NULL as drv for bdrv_open() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:20 -0000 From: Max Reitz Change all callers of bdrv_open() to pass the driver name in the options QDict instead of passing its BlockDriver pointer. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia Signed-off-by: Kevin Wolf --- block.c | 24 ++++++++++---------- block/qcow2.c | 16 ++++++++----- block/vvfat.c | 8 +++++-- blockdev.c | 72 +++++++++++++++++++++++------------------------------------ 4 files changed, 57 insertions(+), 63 deletions(-) diff --git a/block.c b/block.c index cb5d7ae..d0b9101 100644 --- a/block.c +++ b/block.c @@ -1385,11 +1385,13 @@ int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp) qstring_from_str("file")); qdict_put(snapshot_options, "file.filename", qstring_from_str(tmp_filename)); + qdict_put(snapshot_options, "driver", + qstring_from_str("qcow2")); bs_snapshot = bdrv_new(); ret = bdrv_open(&bs_snapshot, NULL, NULL, snapshot_options, - flags, &bdrv_qcow2, &local_err); + flags, NULL, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto out; @@ -3739,7 +3741,6 @@ void bdrv_img_create(const char *filename, const char *fmt, const char *backing_fmt, *backing_file; int64_t size; BlockDriver *drv, *proto_drv; - BlockDriver *backing_drv = NULL; Error *local_err = NULL; int ret = 0; @@ -3813,14 +3814,6 @@ void bdrv_img_create(const char *filename, const char *fmt, } backing_fmt = qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT); - if (backing_fmt) { - backing_drv = bdrv_find_format(backing_fmt); - if (!backing_drv) { - error_setg(errp, "Unknown backing file format '%s'", - backing_fmt); - goto out; - } - } // The size for the image must always be specified, with one exception: // If we are using a backing file, we can obtain the size from there @@ -3831,6 +3824,7 @@ void bdrv_img_create(const char *filename, const char *fmt, char *full_backing = g_new0(char, PATH_MAX); int64_t size; int back_flags; + QDict *backing_options = NULL; bdrv_get_full_backing_filename_from_filename(filename, backing_file, full_backing, PATH_MAX, @@ -3844,9 +3838,15 @@ void bdrv_img_create(const char *filename, const char *fmt, back_flags = flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); + if (backing_fmt) { + backing_options = qdict_new(); + qdict_put(backing_options, "driver", + qstring_from_str(backing_fmt)); + } + bs = NULL; - ret = bdrv_open(&bs, full_backing, NULL, NULL, back_flags, - backing_drv, &local_err); + ret = bdrv_open(&bs, full_backing, NULL, backing_options, + back_flags, NULL, &local_err); g_free(full_backing); if (ret < 0) { goto out; diff --git a/block/qcow2.c b/block/qcow2.c index ea34ae2..867b43b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1873,8 +1873,10 @@ static int qcow2_create2(const char *filename, int64_t total_size, QemuOpts *opts, int version, int refcount_order, Error **errp) { - /* Calculate cluster_bits */ int cluster_bits; + QDict *options; + + /* Calculate cluster_bits */ cluster_bits = ctz32(cluster_size); if (cluster_bits < MIN_CLUSTER_BITS || cluster_bits > MAX_CLUSTER_BITS || (1 << cluster_bits) != cluster_size) @@ -2032,9 +2034,11 @@ static int qcow2_create2(const char *filename, int64_t total_size, * refcount of the cluster that is occupied by the header and the refcount * table) */ - ret = bdrv_open(&bs, filename, NULL, NULL, + options = qdict_new(); + qdict_put(options, "driver", qstring_from_str("qcow2")); + ret = bdrv_open(&bs, filename, NULL, options, BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH, - &bdrv_qcow2, &local_err); + NULL, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto out; @@ -2084,9 +2088,11 @@ static int qcow2_create2(const char *filename, int64_t total_size, bs = NULL; /* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */ - ret = bdrv_open(&bs, filename, NULL, NULL, + options = qdict_new(); + qdict_put(options, "driver", qstring_from_str("qcow2")); + ret = bdrv_open(&bs, filename, NULL, options, BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_BACKING, - &bdrv_qcow2, &local_err); + NULL, &local_err); if (local_err) { error_propagate(errp, local_err); goto out; diff --git a/block/vvfat.c b/block/vvfat.c index 2068697..bffe8ad 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -2926,6 +2926,8 @@ static int enable_write_target(BDRVVVFATState *s, Error **errp) QemuOpts *opts = NULL; int ret; int size = sector2cluster(s, s->sector_count); + QDict *options; + s->used_clusters = calloc(size, 1); array_init(&(s->commits), sizeof(commit_t)); @@ -2956,9 +2958,11 @@ static int enable_write_target(BDRVVVFATState *s, Error **errp) } s->qcow = NULL; - ret = bdrv_open(&s->qcow, s->qcow_filename, NULL, NULL, + options = qdict_new(); + qdict_put(options, "driver", qstring_from_str("qcow")); + ret = bdrv_open(&s->qcow, s->qcow_filename, NULL, options, BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH, - bdrv_qcow, errp); + NULL, errp); if (ret < 0) { goto err; } diff --git a/blockdev.c b/blockdev.c index 6b48be6..577bf42 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1422,9 +1422,8 @@ typedef struct ExternalSnapshotState { static void external_snapshot_prepare(BlkTransactionState *common, Error **errp) { - BlockDriver *drv; int flags, ret; - QDict *options = NULL; + QDict *options; Error *local_err = NULL; bool has_device = false; const char *device; @@ -1459,12 +1458,6 @@ static void external_snapshot_prepare(BlkTransactionState *common, } /* start processing */ - drv = bdrv_find_format(format); - if (!drv) { - error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format); - return; - } - state->old_bs = bdrv_lookup_bs(has_device ? device : NULL, has_node_name ? node_name : NULL, &local_err); @@ -1523,17 +1516,18 @@ static void external_snapshot_prepare(BlkTransactionState *common, } } + options = qdict_new(); if (has_snapshot_node_name) { - options = qdict_new(); qdict_put(options, "node-name", qstring_from_str(snapshot_node_name)); } + qdict_put(options, "driver", qstring_from_str(format)); /* TODO Inherit bs->options or only take explicit options with an * extended QMP command? */ assert(state->new_bs == NULL); ret = bdrv_open(&state->new_bs, new_image_file, NULL, options, - flags | BDRV_O_NO_BACKING, drv, &local_err); + flags | BDRV_O_NO_BACKING, NULL, &local_err); /* We will manually add the backing_hd field to the bs later */ if (ret != 0) { error_propagate(errp, local_err); @@ -1895,13 +1889,19 @@ void qmp_block_passwd(bool has_device, const char *device, /* Assumes AioContext is held */ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename, - int bdrv_flags, BlockDriver *drv, + int bdrv_flags, const char *format, const char *password, Error **errp) { Error *local_err = NULL; + QDict *options = NULL; int ret; - ret = bdrv_open(&bs, filename, NULL, NULL, bdrv_flags, drv, &local_err); + if (format) { + options = qdict_new(); + qdict_put(options, "driver", qstring_from_str(format)); + } + + ret = bdrv_open(&bs, filename, NULL, options, bdrv_flags, NULL, &local_err); if (ret < 0) { error_propagate(errp, local_err); return; @@ -1916,7 +1916,6 @@ void qmp_change_blockdev(const char *device, const char *filename, BlockBackend *blk; BlockDriverState *bs; AioContext *aio_context; - BlockDriver *drv = NULL; int bdrv_flags; Error *err = NULL; @@ -1931,14 +1930,6 @@ void qmp_change_blockdev(const char *device, const char *filename, aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); - if (format) { - drv = bdrv_find_whitelisted_format(format, bs->read_only); - if (!drv) { - error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format); - goto out; - } - } - eject_device(blk, 0, &err); if (err) { error_propagate(errp, err); @@ -1948,7 +1939,7 @@ void qmp_change_blockdev(const char *device, const char *filename, bdrv_flags = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR; bdrv_flags |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0; - qmp_bdrv_open_encrypted(bs, filename, bdrv_flags, drv, NULL, errp); + qmp_bdrv_open_encrypted(bs, filename, bdrv_flags, format, NULL, errp); out: aio_context_release(aio_context); @@ -2466,7 +2457,7 @@ void qmp_drive_backup(const char *device, const char *target, BlockDriverState *source = NULL; BdrvDirtyBitmap *bmap = NULL; AioContext *aio_context; - BlockDriver *drv = NULL; + QDict *options = NULL; Error *local_err = NULL; int flags; int64_t size; @@ -2506,13 +2497,6 @@ void qmp_drive_backup(const char *device, const char *target, if (!has_format) { format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name; } - if (format) { - drv = bdrv_find_format(format); - if (!drv) { - error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format); - goto out; - } - } /* Early check to avoid creating target */ if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKUP_SOURCE, errp)) { @@ -2540,7 +2524,7 @@ void qmp_drive_backup(const char *device, const char *target, } if (mode != NEW_IMAGE_MODE_EXISTING) { - assert(format && drv); + assert(format); if (source) { bdrv_img_create(target, format, source->filename, source->drv->format_name, NULL, @@ -2556,8 +2540,13 @@ void qmp_drive_backup(const char *device, const char *target, goto out; } + if (format) { + options = qdict_new(); + qdict_put(options, "driver", qstring_from_str(format)); + } + target_bs = NULL; - ret = bdrv_open(&target_bs, target, NULL, NULL, flags, drv, &local_err); + ret = bdrv_open(&target_bs, target, NULL, options, flags, NULL, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto out; @@ -2663,9 +2652,8 @@ void qmp_drive_mirror(const char *device, const char *target, BlockDriverState *bs; BlockDriverState *source, *target_bs; AioContext *aio_context; - BlockDriver *drv = NULL; Error *local_err = NULL; - QDict *options = NULL; + QDict *options; int flags; int64_t size; int ret; @@ -2722,13 +2710,6 @@ void qmp_drive_mirror(const char *device, const char *target, if (!has_format) { format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name; } - if (format) { - drv = bdrv_find_format(format); - if (!drv) { - error_setg(errp, QERR_INVALID_BLOCK_FORMAT, format); - goto out; - } - } if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR, errp)) { goto out; @@ -2783,7 +2764,7 @@ void qmp_drive_mirror(const char *device, const char *target, && mode != NEW_IMAGE_MODE_EXISTING) { /* create new image w/o backing file */ - assert(format && drv); + assert(format); bdrv_img_create(target, format, NULL, NULL, NULL, size, flags, &local_err, false); } else { @@ -2807,17 +2788,20 @@ void qmp_drive_mirror(const char *device, const char *target, goto out; } + options = qdict_new(); if (has_node_name) { - options = qdict_new(); qdict_put(options, "node-name", qstring_from_str(node_name)); } + if (format) { + qdict_put(options, "driver", qstring_from_str(format)); + } /* Mirroring takes care of copy-on-write using the source's backing * file. */ target_bs = NULL; ret = bdrv_open(&target_bs, target, NULL, options, - flags | BDRV_O_NO_BACKING, drv, &local_err); + flags | BDRV_O_NO_BACKING, NULL, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto out; -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:32 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCR-0003zM-Rv for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCK-0003ko-EF for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCJ-0005Cn-L3 for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54894) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCJ-0005Cj-GO; Fri, 11 Sep 2015 15:41:23 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 321B746264; Fri, 11 Sep 2015 19:41:23 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QI017774; Fri, 11 Sep 2015 15:41:22 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:50 +0200 Message-Id: <1442000463-22777-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 10/23] qcow2: Improve error message X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:25 -0000 Eric says that "any" sounds better than "either", and my non-native feeling says the same, so let's change it. Suggested-by: Eric Blake Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block/qcow2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index 9b09e01..7f06d37 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1030,7 +1030,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, overlap_check_template = QCOW2_OL_ALL; } else { error_setg(errp, "Unsupported value '%s' for qcow2 option " - "'overlap-check'. Allowed are either of the following: " + "'overlap-check'. Allowed are any of the following: " "none, constant, cached, all", opt_overlap_check); ret = -EINVAL; goto fail; -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCM-0003o6-3v for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCG-0003dr-RI for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCF-0005AE-OB for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47150) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCF-0005A4-Gs; Fri, 11 Sep 2015 15:41:19 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 3A4A8A2C16; Fri, 11 Sep 2015 19:41:19 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QF017774; Fri, 11 Sep 2015 15:41:18 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:47 +0200 Message-Id: <1442000463-22777-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 07/23] block: Allow specifying driver-specific options to reopen X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:24 -0000 Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block.c | 42 +++++++++++++++++++++++++++++++++++++++--- block/commit.c | 4 ++-- include/block/block.h | 4 +++- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index 3de83e6..6268e37 100644 --- a/block.c +++ b/block.c @@ -1636,6 +1636,9 @@ typedef struct BlockReopenQueueEntry { * * bs is the BlockDriverState to add to the reopen queue. * + * options contains the changed options for the associated bs + * (the BlockReopenQueue takes ownership) + * * flags contains the open flags for the associated bs * * returns a pointer to bs_queue, which is either the newly allocated @@ -1643,18 +1646,28 @@ typedef struct BlockReopenQueueEntry { * */ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, - BlockDriverState *bs, int flags) + BlockDriverState *bs, + QDict *options, int flags) { assert(bs != NULL); BlockReopenQueueEntry *bs_entry; BdrvChild *child; + QDict *old_options; if (bs_queue == NULL) { bs_queue = g_new0(BlockReopenQueue, 1); QSIMPLEQ_INIT(bs_queue); } + if (!options) { + options = qdict_new(); + } + + old_options = qdict_clone_shallow(bs->options); + qdict_join(options, old_options, false); + QDECREF(old_options); + /* bdrv_open() masks this flag out */ flags &= ~BDRV_O_PROTOCOL; @@ -1666,13 +1679,15 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, } child_flags = child->role->inherit_flags(flags); - bdrv_reopen_queue(bs_queue, child->bs, child_flags); + /* TODO Pass down child flags (backing.*, extents.*, ...) */ + bdrv_reopen_queue(bs_queue, child->bs, NULL, child_flags); } bs_entry = g_new0(BlockReopenQueueEntry, 1); QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry); bs_entry->state.bs = bs; + bs_entry->state.options = options; bs_entry->state.flags = flags; return bs_queue; @@ -1725,6 +1740,7 @@ cleanup: if (ret && bs_entry->prepared) { bdrv_reopen_abort(&bs_entry->state); } + QDECREF(bs_entry->state.options); g_free(bs_entry); } g_free(bs_queue); @@ -1737,7 +1753,7 @@ int bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp) { int ret = -1; Error *local_err = NULL; - BlockReopenQueue *queue = bdrv_reopen_queue(NULL, bs, bdrv_flags); + BlockReopenQueue *queue = bdrv_reopen_queue(NULL, bs, NULL, bdrv_flags); ret = bdrv_reopen_multiple(queue, &local_err); if (local_err != NULL) { @@ -1813,6 +1829,26 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, goto error; } + /* Options that are not handled are only okay if they are unchanged + * compared to the old state. It is expected that some options are only + * used for the initial open, but not reopen (e.g. filename) */ + if (qdict_size(reopen_state->options)) { + const QDictEntry *entry = qdict_first(reopen_state->options); + + do { + QString *new_obj = qobject_to_qstring(entry->value); + const char *new = qstring_get_str(new_obj); + const char *old = qdict_get_try_str(reopen_state->bs->options, + entry->key); + + if (!old || strcmp(new, old)) { + error_setg(errp, "Cannot change the option '%s'", entry->key); + ret = -EINVAL; + goto error; + } + } while ((entry = qdict_next(reopen_state->options, entry))); + } + ret = 0; error: diff --git a/block/commit.c b/block/commit.c index 7312a5b..d12e26f 100644 --- a/block/commit.c +++ b/block/commit.c @@ -236,11 +236,11 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base, /* convert base & overlay_bs to r/w, if necessary */ if (!(orig_base_flags & BDRV_O_RDWR)) { - reopen_queue = bdrv_reopen_queue(reopen_queue, base, + reopen_queue = bdrv_reopen_queue(reopen_queue, base, NULL, orig_base_flags | BDRV_O_RDWR); } if (!(orig_overlay_flags & BDRV_O_RDWR)) { - reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs, + reopen_queue = bdrv_reopen_queue(reopen_queue, overlay_bs, NULL, orig_overlay_flags | BDRV_O_RDWR); } if (reopen_queue) { diff --git a/include/block/block.h b/include/block/block.h index e539194..ef67353 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -147,6 +147,7 @@ typedef QSIMPLEQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue; typedef struct BDRVReopenState { BlockDriverState *bs; int flags; + QDict *options; void *opaque; } BDRVReopenState; @@ -218,7 +219,8 @@ int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp); int bdrv_open(BlockDriverState **pbs, const char *filename, const char *reference, QDict *options, int flags, Error **errp); BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, - BlockDriverState *bs, int flags); + BlockDriverState *bs, + QDict *options, int flags); int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp); int bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp); int bdrv_reopen_prepare(BDRVReopenState *reopen_state, -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCM-0003pb-Tj for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCJ-0003jW-Vz for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCI-0005CB-Ih for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36244) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCI-0005C2-Bz; Fri, 11 Sep 2015 15:41:22 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 049C3AC1A1; Fri, 11 Sep 2015 19:41:21 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QH017774; Fri, 11 Sep 2015 15:41:20 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:49 +0200 Message-Id: <1442000463-22777-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 09/23] qemu-io: Add command 'reopen' X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:25 -0000 Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- qemu-io-cmds.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 53477e1..d6572a8 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1979,6 +1979,95 @@ static const cmdinfo_t map_cmd = { .oneline = "prints the allocated areas of a file", }; +static void reopen_help(void) +{ + printf( +"\n" +" Changes the open options of an already opened image\n" +"\n" +" Example:\n" +" 'reopen -o lazy-refcounts=on' - activates lazy refcount writeback on a qcow2 image\n" +"\n" +" -r, -- Reopen the image read-only\n" +" -c, -- Change the cache mode to the given value\n" +" -o, -- Changes block driver options (cf. 'open' command)\n" +"\n"); +} + +static int reopen_f(BlockBackend *blk, int argc, char **argv); + +static QemuOptsList reopen_opts = { + .name = "reopen", + .merge_lists = true, + .head = QTAILQ_HEAD_INITIALIZER(reopen_opts.head), + .desc = { + /* no elements => accept any params */ + { /* end of list */ } + }, +}; + +static const cmdinfo_t reopen_cmd = { + .name = "reopen", + .argmin = 0, + .argmax = -1, + .cfunc = reopen_f, + .args = "[-r] [-c cache] [-o options]", + .oneline = "reopens an image with new options", + .help = reopen_help, +}; + +static int reopen_f(BlockBackend *blk, int argc, char **argv) +{ + BlockDriverState *bs = blk_bs(blk); + QemuOpts *qopts; + QDict *opts; + int c; + int flags = bs->open_flags; + + BlockReopenQueue *brq; + Error *local_err = NULL; + + while ((c = getopt(argc, argv, "c:o:r")) != -1) { + switch (c) { + case 'c': + if (bdrv_parse_cache_flags(optarg, &flags) < 0) { + error_report("Invalid cache option: %s", optarg); + return 0; + } + break; + case 'o': + if (!qemu_opts_parse_noisily(&reopen_opts, optarg, 0)) { + qemu_opts_reset(&reopen_opts); + return 0; + } + break; + case 'r': + flags &= ~BDRV_O_RDWR; + break; + default: + qemu_opts_reset(&reopen_opts); + return qemuio_command_usage(&reopen_cmd); + } + } + + if (optind != argc) { + qemu_opts_reset(&reopen_opts); + return qemuio_command_usage(&reopen_cmd); + } + + qopts = qemu_opts_find(&reopen_opts, NULL); + opts = qopts ? qemu_opts_to_qdict(qopts, NULL) : NULL; + qemu_opts_reset(&reopen_opts); + + brq = bdrv_reopen_queue(NULL, bs, opts, flags); + bdrv_reopen_multiple(brq, &local_err); + if (local_err) { + error_report_err(local_err); + } + + return 0; +} + static int break_f(BlockBackend *blk, int argc, char **argv) { int ret; @@ -2266,6 +2355,7 @@ static void __attribute((constructor)) init_qemuio_commands(void) qemuio_add_command(&discard_cmd); qemuio_add_command(&alloc_cmd); qemuio_add_command(&map_cmd); + qemuio_add_command(&reopen_cmd); qemuio_add_command(&break_cmd); qemuio_add_command(&remove_break_cmd); qemuio_add_command(&resume_cmd); -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCZ-0004Cb-E8 for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCI-0003hd-RK for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCE-00059m-IW for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49183) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCE-00059I-5S; Fri, 11 Sep 2015 15:41:18 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id D2B61C0B9194; Fri, 11 Sep 2015 19:41:17 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QE017774; Fri, 11 Sep 2015 15:41:16 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:46 +0200 Message-Id: <1442000463-22777-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 06/23] qcow2: Rename BDRVQcowState to BDRVQcow2State X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:27 -0000 BDRVQcowState is already used by qcow1, and gdb is always confused which one to use. Rename the qcow2 one so they can be distinguished. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz Reviewed-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia --- block/qcow2-cache.c | 14 ++++----- block/qcow2-cluster.c | 48 +++++++++++++++---------------- block/qcow2-refcount.c | 58 ++++++++++++++++++------------------- block/qcow2-snapshot.c | 20 ++++++------- block/qcow2.c | 78 +++++++++++++++++++++++++------------------------- block/qcow2.h | 22 +++++++------- 6 files changed, 120 insertions(+), 120 deletions(-) diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 046f5b8..7b14c5c 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -55,14 +55,14 @@ struct Qcow2Cache { static inline void *qcow2_cache_get_table_addr(BlockDriverState *bs, Qcow2Cache *c, int table) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; return (uint8_t *) c->table_array + (size_t) table * s->cluster_size; } static inline int qcow2_cache_get_table_idx(BlockDriverState *bs, Qcow2Cache *c, void *table) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; ptrdiff_t table_offset = (uint8_t *) table - (uint8_t *) c->table_array; int idx = table_offset / s->cluster_size; assert(idx >= 0 && idx < c->size && table_offset % s->cluster_size == 0); @@ -73,7 +73,7 @@ static void qcow2_cache_table_release(BlockDriverState *bs, Qcow2Cache *c, int i, int num_tables) { #if QEMU_MADV_DONTNEED != QEMU_MADV_INVALID - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; void *t = qcow2_cache_get_table_addr(bs, c, i); int align = getpagesize(); size_t mem_size = (size_t) s->cluster_size * num_tables; @@ -121,7 +121,7 @@ void qcow2_cache_clean_unused(BlockDriverState *bs, Qcow2Cache *c) Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; Qcow2Cache *c; c = g_new0(Qcow2Cache, 1); @@ -172,7 +172,7 @@ static int qcow2_cache_flush_dependency(BlockDriverState *bs, Qcow2Cache *c) static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret = 0; if (!c->entries[i].dirty || !c->entries[i].offset) { @@ -229,7 +229,7 @@ static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i) int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int result = 0; int ret; int i; @@ -306,7 +306,7 @@ int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c) static int qcow2_cache_do_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset, void **table, bool read_from_disk) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int i; int ret; int lookup_index; diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 61309ae..412ee27 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -32,7 +32,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, bool exact_size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int new_l1_size2, ret, i; uint64_t *new_l1_table; int64_t old_l1_table_offset, old_l1_size; @@ -148,7 +148,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, static int l2_load(BlockDriverState *bs, uint64_t l2_offset, uint64_t **l2_table) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret; ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void**) l2_table); @@ -163,7 +163,7 @@ static int l2_load(BlockDriverState *bs, uint64_t l2_offset, #define L1_ENTRIES_PER_SECTOR (512 / 8) int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t buf[L1_ENTRIES_PER_SECTOR] = { 0 }; int l1_start_index; int i, ret; @@ -203,7 +203,7 @@ int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index) static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t old_l2_offset; uint64_t *l2_table = NULL; int64_t l2_offset; @@ -339,7 +339,7 @@ static int count_contiguous_free_clusters(uint64_t nb_clusters, uint64_t *l2_tab /* The crypt function is compatible with the linux cryptoloop algorithm for < 4 GB images. NOTE: out_buf == in_buf is supported */ -int qcow2_encrypt_sectors(BDRVQcowState *s, int64_t sector_num, +int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t sector_num, uint8_t *out_buf, const uint8_t *in_buf, int nb_sectors, bool enc, Error **errp) @@ -387,7 +387,7 @@ static int coroutine_fn copy_sectors(BlockDriverState *bs, uint64_t cluster_offset, int n_start, int n_end) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QEMUIOVector qiov; struct iovec iov; int n, ret; @@ -469,7 +469,7 @@ out: int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, int *num, uint64_t *cluster_offset) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; unsigned int l2_index; uint64_t l1_index, l2_offset, *l2_table; int l1_bits, c; @@ -606,7 +606,7 @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset, uint64_t **new_l2_table, int *new_l2_index) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; unsigned int l2_index; uint64_t l1_index, l2_offset; uint64_t *l2_table = NULL; @@ -680,7 +680,7 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, uint64_t offset, int compressed_size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int l2_index, ret; uint64_t *l2_table; int64_t cluster_offset; @@ -725,7 +725,7 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, static int perform_cow(BlockDriverState *bs, QCowL2Meta *m, Qcow2COWRegion *r) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret; if (r->nb_sectors == 0) { @@ -754,7 +754,7 @@ static int perform_cow(BlockDriverState *bs, QCowL2Meta *m, Qcow2COWRegion *r) int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int i, j = 0, l2_index, ret; uint64_t *old_cluster, *l2_table; uint64_t cluster_offset = m->alloc_offset; @@ -837,7 +837,7 @@ err: * write, but require COW to be performed (this includes yet unallocated space, * which must copy from the backing file) */ -static int count_cow_clusters(BDRVQcowState *s, int nb_clusters, +static int count_cow_clusters(BDRVQcow2State *s, int nb_clusters, uint64_t *l2_table, int l2_index) { int i; @@ -883,7 +883,7 @@ out: static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset, uint64_t *cur_bytes, QCowL2Meta **m) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowL2Meta *old_alloc; uint64_t bytes = *cur_bytes; @@ -956,7 +956,7 @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset, static int handle_copied(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int l2_index; uint64_t cluster_offset; uint64_t *l2_table; @@ -1063,7 +1063,7 @@ out: static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, unsigned int *nb_clusters) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; trace_qcow2_do_alloc_clusters_offset(qemu_coroutine_self(), guest_offset, *host_offset, *nb_clusters); @@ -1111,7 +1111,7 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int l2_index; uint64_t *l2_table; uint64_t entry; @@ -1263,7 +1263,7 @@ fail: int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, int *num, uint64_t *host_offset, QCowL2Meta **m) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t start, remaining; uint64_t cluster_offset; uint64_t cur_bytes; @@ -1397,7 +1397,7 @@ static int decompress_buffer(uint8_t *out_buf, int out_buf_size, int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret, csize, nb_csectors, sector_offset; uint64_t coffset; @@ -1428,7 +1428,7 @@ int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) static int discard_single_l2(BlockDriverState *bs, uint64_t offset, unsigned int nb_clusters, enum qcow2_discard_type type, bool full_discard) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; int l2_index; int ret; @@ -1501,7 +1501,7 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors, enum qcow2_discard_type type, bool full_discard) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t end_offset; unsigned int nb_clusters; int ret; @@ -1547,7 +1547,7 @@ fail: static int zero_single_l2(BlockDriverState *bs, uint64_t offset, unsigned int nb_clusters) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; int l2_index; int ret; @@ -1583,7 +1583,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; unsigned int nb_clusters; int ret; @@ -1628,7 +1628,7 @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table, int64_t l1_entries, BlockDriverAmendStatusCB *status_cb) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; bool is_active_l1 = (l1_table == s->l1_table); uint64_t *l2_table = NULL; int ret; @@ -1815,7 +1815,7 @@ fail: int qcow2_expand_zero_clusters(BlockDriverState *bs, BlockDriverAmendStatusCB *status_cb) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t *l1_table = NULL; int64_t l1_entries = 0, visited_l1_entries = 0; int ret; diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index d8f0645..b780bb9 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -82,7 +82,7 @@ static Qcow2SetRefcountFunc *const set_refcount_funcs[] = { int qcow2_refcount_init(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; unsigned int refcount_table_size2, i; int ret; @@ -116,7 +116,7 @@ int qcow2_refcount_init(BlockDriverState *bs) void qcow2_refcount_close(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; g_free(s->refcount_table); } @@ -214,7 +214,7 @@ static int load_refcount_block(BlockDriverState *bs, int64_t refcount_block_offset, void **refcount_block) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret; BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_LOAD); @@ -231,7 +231,7 @@ static int load_refcount_block(BlockDriverState *bs, int qcow2_get_refcount(BlockDriverState *bs, int64_t cluster_index, uint64_t *refcount) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t refcount_table_index, block_index; int64_t refcount_block_offset; int ret; @@ -274,7 +274,7 @@ int qcow2_get_refcount(BlockDriverState *bs, int64_t cluster_index, * Rounds the refcount table size up to avoid growing the table for each single * refcount block that is allocated. */ -static unsigned int next_refcount_table_size(BDRVQcowState *s, +static unsigned int next_refcount_table_size(BDRVQcow2State *s, unsigned int min_size) { unsigned int min_clusters = (min_size >> (s->cluster_bits - 3)) + 1; @@ -290,7 +290,7 @@ static unsigned int next_refcount_table_size(BDRVQcowState *s, /* Checks if two offsets are described by the same refcount block */ -static int in_same_refcount_block(BDRVQcowState *s, uint64_t offset_a, +static int in_same_refcount_block(BDRVQcow2State *s, uint64_t offset_a, uint64_t offset_b) { uint64_t block_a = offset_a >> (s->cluster_bits + s->refcount_block_bits); @@ -308,7 +308,7 @@ static int in_same_refcount_block(BDRVQcowState *s, uint64_t offset_a, static int alloc_refcount_block(BlockDriverState *bs, int64_t cluster_index, void **refcount_block) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; unsigned int refcount_table_index; int ret; @@ -605,7 +605,7 @@ fail_block: void qcow2_process_discards(BlockDriverState *bs, int ret) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; Qcow2DiscardRegion *d, *next; QTAILQ_FOREACH_SAFE(d, &s->discards, next, next) { @@ -625,7 +625,7 @@ void qcow2_process_discards(BlockDriverState *bs, int ret) static void update_refcount_discard(BlockDriverState *bs, uint64_t offset, uint64_t length) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; Qcow2DiscardRegion *d, *p, *next; QTAILQ_FOREACH(d, &s->discards, next) { @@ -682,7 +682,7 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs, bool decrease, enum qcow2_discard_type type) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t start, last, cluster_offset; void *refcount_block = NULL; int64_t old_table_index = -1; @@ -793,7 +793,7 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs, uint64_t addend, bool decrease, enum qcow2_discard_type type) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret; ret = update_refcount(bs, cluster_index << s->cluster_bits, 1, addend, @@ -815,7 +815,7 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs, /* return < 0 if error */ static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t i, nb_clusters, refcount; int ret; @@ -878,7 +878,7 @@ int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size) int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, int nb_clusters) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t cluster_index, refcount; uint64_t i; int ret; @@ -916,7 +916,7 @@ int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, contiguous sectors. size must be <= cluster_size */ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t offset; size_t free_in_cluster; int ret; @@ -992,7 +992,7 @@ void qcow2_free_clusters(BlockDriverState *bs, void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry, int nb_clusters, enum qcow2_discard_type type) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; switch (qcow2_get_cluster_type(l2_entry)) { case QCOW2_CLUSTER_COMPRESSED: @@ -1036,7 +1036,7 @@ void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry, int qcow2_update_snapshot_refcount(BlockDriverState *bs, int64_t l1_table_offset, int l1_size, int addend) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2, refcount; bool l1_allocated = false; int64_t old_offset, old_l2_offset; @@ -1233,7 +1233,7 @@ fail: /* refcount checking functions */ -static size_t refcount_array_byte_size(BDRVQcowState *s, uint64_t entries) +static size_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries) { /* This assertion holds because there is no way we can address more than * 2^(64 - 9) clusters at once (with cluster size 512 = 2^9, and because @@ -1256,7 +1256,7 @@ static size_t refcount_array_byte_size(BDRVQcowState *s, uint64_t entries) * refcount array buffer will be aligned to a cluster boundary, and the newly * allocated area will be zeroed. */ -static int realloc_refcount_array(BDRVQcowState *s, void **array, +static int realloc_refcount_array(BDRVQcow2State *s, void **array, int64_t *size, int64_t new_size) { size_t old_byte_size, new_byte_size; @@ -1304,7 +1304,7 @@ static int inc_refcounts(BlockDriverState *bs, int64_t *refcount_table_size, int64_t offset, int64_t size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t start, last, cluster_offset, k, refcount; int ret; @@ -1357,7 +1357,7 @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, int64_t *refcount_table_size, int64_t l2_offset, int flags) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t *l2_table, l2_entry; uint64_t next_contiguous_offset = 0; int i, l2_size, nb_csectors, ret; @@ -1477,7 +1477,7 @@ static int check_refcounts_l1(BlockDriverState *bs, int64_t l1_table_offset, int l1_size, int flags) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t *l1_table = NULL, l2_offset, l1_size2; int i, ret; @@ -1554,7 +1554,7 @@ fail: static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t *l2_table = qemu_blockalign(bs, s->cluster_size); int ret; uint64_t refcount; @@ -1673,7 +1673,7 @@ static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix, bool *rebuild, void **refcount_table, int64_t *nb_clusters) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t i, size; int ret; @@ -1776,7 +1776,7 @@ static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix, bool *rebuild, void **refcount_table, int64_t *nb_clusters) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t i; QCowSnapshot *sn; int ret; @@ -1840,7 +1840,7 @@ static void compare_refcounts(BlockDriverState *bs, BdrvCheckResult *res, int64_t *highest_cluster, void *refcount_table, int64_t nb_clusters) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t i; uint64_t refcount1, refcount2; int ret; @@ -1917,7 +1917,7 @@ static int64_t alloc_clusters_imrt(BlockDriverState *bs, int64_t *imrt_nb_clusters, int64_t *first_free_cluster) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t cluster = *first_free_cluster, i; bool first_gap = true; int contiguous_free_clusters; @@ -1987,7 +1987,7 @@ static int rebuild_refcount_structure(BlockDriverState *bs, void **refcount_table, int64_t *nb_clusters) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t first_free_cluster = 0, reftable_offset = -1, cluster = 0; int64_t refblock_offset, refblock_start, refblock_index; uint32_t reftable_size = 0; @@ -2174,7 +2174,7 @@ fail: int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; BdrvCheckResult pre_compare_res; int64_t size, highest_cluster, nb_clusters; void *refcount_table = NULL; @@ -2311,7 +2311,7 @@ fail: int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset, int64_t size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int chk = s->overlap_check & ~ign; int i, j; diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index b6f58c1..92f4dfc 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -29,7 +29,7 @@ void qcow2_free_snapshots(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int i; for(i = 0; i < s->nb_snapshots; i++) { @@ -43,7 +43,7 @@ void qcow2_free_snapshots(BlockDriverState *bs) int qcow2_read_snapshots(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowSnapshotHeader h; QCowSnapshotExtraData extra; QCowSnapshot *sn; @@ -136,7 +136,7 @@ fail: /* add at the end of the file a new list of snapshots */ static int qcow2_write_snapshots(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowSnapshot *sn; QCowSnapshotHeader h; QCowSnapshotExtraData extra; @@ -278,7 +278,7 @@ fail: static void find_new_snapshot_id(BlockDriverState *bs, char *id_str, int id_str_size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowSnapshot *sn; int i; unsigned long id, id_max = 0; @@ -296,7 +296,7 @@ static int find_snapshot_by_id_and_name(BlockDriverState *bs, const char *id, const char *name) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int i; if (id && name) { @@ -338,7 +338,7 @@ static int find_snapshot_by_id_or_name(BlockDriverState *bs, /* if no id is provided, a new one is constructed */ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowSnapshot *new_snapshot_list = NULL; QCowSnapshot *old_snapshot_list = NULL; QCowSnapshot sn1, *sn = &sn1; @@ -461,7 +461,7 @@ fail: /* copy the snapshot 'snapshot_name' into the current disk image */ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowSnapshot *sn; int i, snapshot_index; int cur_l1_bytes, sn_l1_bytes; @@ -587,7 +587,7 @@ int qcow2_snapshot_delete(BlockDriverState *bs, const char *name, Error **errp) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowSnapshot sn; int snapshot_index, ret; @@ -650,7 +650,7 @@ int qcow2_snapshot_delete(BlockDriverState *bs, int qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QEMUSnapshotInfo *sn_tab, *sn_info; QCowSnapshot *sn; int i; @@ -683,7 +683,7 @@ int qcow2_snapshot_load_tmp(BlockDriverState *bs, Error **errp) { int i, snapshot_index; - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowSnapshot *sn; uint64_t *new_l1_table; int new_l1_bytes; diff --git a/block/qcow2.c b/block/qcow2.c index a707d8d..9b09e01 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -85,7 +85,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, uint64_t end_offset, void **p_feature_table, Error **errp) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowExtension ext; uint64_t offset; int ret; @@ -187,7 +187,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, static void cleanup_unknown_header_ext(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; Qcow2UnknownHeaderExtension *uext, *next; QLIST_FOREACH_SAFE(uext, &s->unknown_header_ext, next, next) { @@ -249,7 +249,7 @@ static void report_unsupported_feature(BlockDriverState *bs, */ int qcow2_mark_dirty(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t val; int ret; @@ -282,7 +282,7 @@ int qcow2_mark_dirty(BlockDriverState *bs) */ static int qcow2_mark_clean(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; if (s->incompatible_features & QCOW2_INCOMPAT_DIRTY) { int ret; @@ -304,7 +304,7 @@ static int qcow2_mark_clean(BlockDriverState *bs) */ int qcow2_mark_corrupt(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; s->incompatible_features |= QCOW2_INCOMPAT_CORRUPT; return qcow2_update_header(bs); @@ -316,7 +316,7 @@ int qcow2_mark_corrupt(BlockDriverState *bs) */ int qcow2_mark_consistent(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) { int ret = bdrv_flush(bs); @@ -351,7 +351,7 @@ static int qcow2_check(BlockDriverState *bs, BdrvCheckResult *result, static int validate_table_offset(BlockDriverState *bs, uint64_t offset, uint64_t entries, size_t entry_len) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t size; /* Use signed INT64_MAX as the maximum even for uint64_t header fields, @@ -490,7 +490,7 @@ static const char *overlap_bool_option_names[QCOW2_OL_MAX_BITNR] = { static void cache_clean_timer_cb(void *opaque) { BlockDriverState *bs = opaque; - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; qcow2_cache_clean_unused(bs, s->l2_table_cache); qcow2_cache_clean_unused(bs, s->refcount_block_cache); timer_mod(s->cache_clean_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + @@ -499,7 +499,7 @@ static void cache_clean_timer_cb(void *opaque) static void cache_clean_timer_init(BlockDriverState *bs, AioContext *context) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; if (s->cache_clean_interval > 0) { s->cache_clean_timer = aio_timer_new(context, QEMU_CLOCK_VIRTUAL, SCALE_MS, cache_clean_timer_cb, @@ -511,7 +511,7 @@ static void cache_clean_timer_init(BlockDriverState *bs, AioContext *context) static void cache_clean_timer_del(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; if (s->cache_clean_timer) { timer_del(s->cache_clean_timer); timer_free(s->cache_clean_timer); @@ -534,7 +534,7 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, uint64_t *l2_cache_size, uint64_t *refcount_cache_size, Error **errp) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t combined_cache_size; bool l2_cache_size_set, refcount_cache_size_set, combined_cache_size_set; @@ -592,7 +592,7 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; unsigned int len, i; int ret = 0; QCowHeader header; @@ -1086,14 +1086,14 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, static void qcow2_refresh_limits(BlockDriverState *bs, Error **errp) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; bs->bl.write_zeroes_alignment = s->cluster_sectors; } static int qcow2_set_key(BlockDriverState *bs, const char *key) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint8_t keybuf[16]; int len, i; Error *err = NULL; @@ -1151,7 +1151,7 @@ static int qcow2_reopen_prepare(BDRVReopenState *state, static int64_t coroutine_fn qcow2_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t cluster_offset; int index_in_cluster, ret; int64_t status = 0; @@ -1198,7 +1198,7 @@ int qcow2_backing_read1(BlockDriverState *bs, QEMUIOVector *qiov, static coroutine_fn int qcow2_co_readv(BlockDriverState *bs, int64_t sector_num, int remaining_sectors, QEMUIOVector *qiov) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int index_in_cluster, n1; int ret; int cur_nr_sectors; /* number of sectors in current iteration */ @@ -1360,7 +1360,7 @@ static coroutine_fn int qcow2_co_writev(BlockDriverState *bs, int remaining_sectors, QEMUIOVector *qiov) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int index_in_cluster; int ret; int cur_nr_sectors; /* number of sectors in current iteration */ @@ -1506,7 +1506,7 @@ fail: static void qcow2_close(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; qemu_vfree(s->l1_table); /* else pre-write overlap checks in cache_destroy may crash */ s->l1_table = NULL; @@ -1552,7 +1552,7 @@ static void qcow2_close(BlockDriverState *bs) static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int flags = s->flags; QCryptoCipher *cipher = NULL; QDict *options; @@ -1575,7 +1575,7 @@ static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp) return; } - memset(s, 0, sizeof(BDRVQcowState)); + memset(s, 0, sizeof(BDRVQcow2State)); options = qdict_clone_shallow(bs->options); ret = qcow2_open(bs, options, flags, &local_err); @@ -1622,7 +1622,7 @@ static size_t header_ext_add(char *buf, uint32_t magic, const void *s, */ int qcow2_update_header(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; QCowHeader *header; char *buf; size_t buflen = s->cluster_size; @@ -1791,7 +1791,7 @@ fail: static int qcow2_change_backing_file(BlockDriverState *bs, const char *backing_file, const char *backing_fmt) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: ""); pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_fmt ?: ""); @@ -2074,7 +2074,7 @@ static int qcow2_create2(const char *filename, int64_t total_size, /* And if we're supposed to preallocate metadata, do that now */ if (prealloc != PREALLOC_MODE_OFF) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; qemu_co_mutex_lock(&s->lock); ret = preallocate(bs); qemu_co_mutex_unlock(&s->lock); @@ -2209,7 +2209,7 @@ static coroutine_fn int qcow2_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors, BdrvRequestFlags flags) { int ret; - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; /* Emulate misaligned zero writes */ if (sector_num % s->cluster_sectors || nb_sectors % s->cluster_sectors) { @@ -2229,7 +2229,7 @@ static coroutine_fn int qcow2_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { int ret; - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; qemu_co_mutex_lock(&s->lock); ret = qcow2_discard_clusters(bs, sector_num << BDRV_SECTOR_BITS, @@ -2240,7 +2240,7 @@ static coroutine_fn int qcow2_co_discard(BlockDriverState *bs, static int qcow2_truncate(BlockDriverState *bs, int64_t offset) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t new_l1_size; int ret; @@ -2284,7 +2284,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset) static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; z_stream strm; int ret, out_len; uint8_t *out_buf; @@ -2375,7 +2375,7 @@ fail: static int make_completely_empty(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret, l1_clusters; int64_t offset; uint64_t *new_reftable = NULL; @@ -2523,7 +2523,7 @@ fail: static int qcow2_make_empty(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; uint64_t start_sector; int sector_step = INT_MAX / BDRV_SECTOR_SIZE; int l1_clusters, ret = 0; @@ -2564,7 +2564,7 @@ static int qcow2_make_empty(BlockDriverState *bs) static coroutine_fn int qcow2_co_flush_to_os(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int ret; qemu_co_mutex_lock(&s->lock); @@ -2588,7 +2588,7 @@ static coroutine_fn int qcow2_co_flush_to_os(BlockDriverState *bs) static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; bdi->unallocated_blocks_are_zero = true; bdi->can_write_zeroes_with_unmap = (s->qcow_version >= 3); bdi->cluster_size = s->cluster_size; @@ -2598,7 +2598,7 @@ static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1); *spec_info = (ImageInfoSpecific){ @@ -2631,7 +2631,7 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs) #if 0 static void dump_refcounts(BlockDriverState *bs) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t nb_clusters, k, k1, size; int refcount; @@ -2652,7 +2652,7 @@ static void dump_refcounts(BlockDriverState *bs) static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int64_t total_sectors = bs->total_sectors; bool zero_beyond_eof = bs->zero_beyond_eof; int ret; @@ -2673,7 +2673,7 @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, static int qcow2_load_vmstate(BlockDriverState *bs, uint8_t *buf, int64_t pos, int size) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; bool zero_beyond_eof = bs->zero_beyond_eof; int ret; @@ -2692,7 +2692,7 @@ static int qcow2_load_vmstate(BlockDriverState *bs, uint8_t *buf, static int qcow2_downgrade(BlockDriverState *bs, int target_version, BlockDriverAmendStatusCB *status_cb) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int current_version = s->qcow_version; int ret; @@ -2756,7 +2756,7 @@ static int qcow2_downgrade(BlockDriverState *bs, int target_version, static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, BlockDriverAmendStatusCB *status_cb) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; int old_version = s->qcow_version, new_version = old_version; uint64_t new_size = 0; const char *backing_file = NULL, *backing_format = NULL; @@ -2903,7 +2903,7 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset, int64_t size, const char *message_format, ...) { - BDRVQcowState *s = bs->opaque; + BDRVQcow2State *s = bs->opaque; const char *node_name; char *message; va_list ap; @@ -3004,7 +3004,7 @@ static QemuOptsList qcow2_create_opts = { BlockDriver bdrv_qcow2 = { .format_name = "qcow2", - .instance_size = sizeof(BDRVQcowState), + .instance_size = sizeof(BDRVQcow2State), .bdrv_probe = qcow2_probe, .bdrv_open = qcow2_open, .bdrv_close = qcow2_close, diff --git a/block/qcow2.h b/block/qcow2.h index 71dafd6..61f1b57 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -222,7 +222,7 @@ typedef uint64_t Qcow2GetRefcountFunc(const void *refcount_array, typedef void Qcow2SetRefcountFunc(void *refcount_array, uint64_t index, uint64_t value); -typedef struct BDRVQcowState { +typedef struct BDRVQcow2State { int cluster_bits; int cluster_size; int cluster_sectors; @@ -293,7 +293,7 @@ typedef struct BDRVQcowState { * override) */ char *image_backing_file; char *image_backing_format; -} BDRVQcowState; +} BDRVQcow2State; struct QCowAIOCB; @@ -405,28 +405,28 @@ typedef enum QCow2MetadataOverlap { #define REFT_OFFSET_MASK 0xfffffffffffffe00ULL -static inline int64_t start_of_cluster(BDRVQcowState *s, int64_t offset) +static inline int64_t start_of_cluster(BDRVQcow2State *s, int64_t offset) { return offset & ~(s->cluster_size - 1); } -static inline int64_t offset_into_cluster(BDRVQcowState *s, int64_t offset) +static inline int64_t offset_into_cluster(BDRVQcow2State *s, int64_t offset) { return offset & (s->cluster_size - 1); } -static inline int size_to_clusters(BDRVQcowState *s, int64_t size) +static inline int size_to_clusters(BDRVQcow2State *s, int64_t size) { return (size + (s->cluster_size - 1)) >> s->cluster_bits; } -static inline int64_t size_to_l1(BDRVQcowState *s, int64_t size) +static inline int64_t size_to_l1(BDRVQcow2State *s, int64_t size) { int shift = s->cluster_bits + s->l2_bits; return (size + (1ULL << shift) - 1) >> shift; } -static inline int offset_to_l2_index(BDRVQcowState *s, int64_t offset) +static inline int offset_to_l2_index(BDRVQcow2State *s, int64_t offset) { return (offset >> s->cluster_bits) & (s->l2_size - 1); } @@ -437,12 +437,12 @@ static inline int64_t align_offset(int64_t offset, int n) return offset; } -static inline int64_t qcow2_vm_state_offset(BDRVQcowState *s) +static inline int64_t qcow2_vm_state_offset(BDRVQcow2State *s) { return (int64_t)s->l1_vm_state_index << (s->cluster_bits + s->l2_bits); } -static inline uint64_t qcow2_max_refcount_clusters(BDRVQcowState *s) +static inline uint64_t qcow2_max_refcount_clusters(BDRVQcow2State *s) { return QCOW_MAX_REFTABLE_SIZE >> s->cluster_bits; } @@ -461,7 +461,7 @@ static inline int qcow2_get_cluster_type(uint64_t l2_entry) } /* Check whether refcounts are eager or lazy */ -static inline bool qcow2_need_accurate_refcounts(BDRVQcowState *s) +static inline bool qcow2_need_accurate_refcounts(BDRVQcow2State *s) { return !(s->incompatible_features & QCOW2_INCOMPAT_DIRTY); } @@ -537,7 +537,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index); void qcow2_l2_cache_reset(BlockDriverState *bs); int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset); -int qcow2_encrypt_sectors(BDRVQcowState *s, int64_t sector_num, +int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t sector_num, uint8_t *out_buf, const uint8_t *in_buf, int nb_sectors, bool enc, Error **errp); -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCa-0004Da-6i for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCN-0003pm-06 for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCL-0005EH-KI for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCL-0005Do-Ah; Fri, 11 Sep 2015 15:41:25 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id B1C492F517E; Fri, 11 Sep 2015 19:41:24 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QJ017774; Fri, 11 Sep 2015 15:41:23 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:51 +0200 Message-Id: <1442000463-22777-12-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 11/23] qcow2: Factor out qcow2_update_options() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:28 -0000 Eventually we want to be able to change options at runtime. As a first step towards that goal, separate some option handling code from the general initialisation code in qcow2_open(). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2.c | 135 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 76 insertions(+), 59 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 7f06d37..4dd0699 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -589,6 +589,80 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, } } +static int qcow2_update_options(BlockDriverState *bs, QemuOpts *opts, + int flags, Error **errp) +{ + BDRVQcow2State *s = bs->opaque; + const char *opt_overlap_check, *opt_overlap_check_template; + int overlap_check_template = 0; + int i; + int ret; + + s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, + (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); + + s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; + s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; + s->discard_passthrough[QCOW2_DISCARD_REQUEST] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, + flags & BDRV_O_UNMAP); + s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); + s->discard_passthrough[QCOW2_DISCARD_OTHER] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); + + opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); + opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); + if (opt_overlap_check_template && opt_overlap_check && + strcmp(opt_overlap_check_template, opt_overlap_check)) + { + error_setg(errp, "Conflicting values for qcow2 options '" + QCOW2_OPT_OVERLAP "' ('%s') and '" QCOW2_OPT_OVERLAP_TEMPLATE + "' ('%s')", opt_overlap_check, opt_overlap_check_template); + ret = -EINVAL; + goto fail; + } + if (!opt_overlap_check) { + opt_overlap_check = opt_overlap_check_template ?: "cached"; + } + + if (!strcmp(opt_overlap_check, "none")) { + overlap_check_template = 0; + } else if (!strcmp(opt_overlap_check, "constant")) { + overlap_check_template = QCOW2_OL_CONSTANT; + } else if (!strcmp(opt_overlap_check, "cached")) { + overlap_check_template = QCOW2_OL_CACHED; + } else if (!strcmp(opt_overlap_check, "all")) { + overlap_check_template = QCOW2_OL_ALL; + } else { + error_setg(errp, "Unsupported value '%s' for qcow2 option " + "'overlap-check'. Allowed are any of the following: " + "none, constant, cached, all", opt_overlap_check); + ret = -EINVAL; + goto fail; + } + + s->overlap_check = 0; + for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { + /* overlap-check defines a template bitmask, but every flag may be + * overwritten through the associated boolean option */ + s->overlap_check |= + qemu_opt_get_bool(opts, overlap_bool_option_names[i], + overlap_check_template & (1 << i)) << i; + } + + if (s->use_lazy_refcounts && s->qcow_version < 3) { + error_setg(errp, "Lazy refcounts require a qcow2 image with at least " + "qemu 1.1 compatibility level"); + ret = -EINVAL; + goto fail; + } + + ret = 0; +fail: + return ret; +} + static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { @@ -600,8 +674,6 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, Error *local_err = NULL; uint64_t ext_end; uint64_t l1_vm_state_index; - const char *opt_overlap_check, *opt_overlap_check_template; - int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; uint64_t cache_clean_interval; @@ -992,69 +1064,14 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, } /* Enable lazy_refcounts according to image and command line options */ - s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, - (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); - - s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; - s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; - s->discard_passthrough[QCOW2_DISCARD_REQUEST] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, - flags & BDRV_O_UNMAP); - s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); - s->discard_passthrough[QCOW2_DISCARD_OTHER] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); - - opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); - opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); - if (opt_overlap_check_template && opt_overlap_check && - strcmp(opt_overlap_check_template, opt_overlap_check)) - { - error_setg(errp, "Conflicting values for qcow2 options '" - QCOW2_OPT_OVERLAP "' ('%s') and '" QCOW2_OPT_OVERLAP_TEMPLATE - "' ('%s')", opt_overlap_check, opt_overlap_check_template); - ret = -EINVAL; - goto fail; - } - if (!opt_overlap_check) { - opt_overlap_check = opt_overlap_check_template ?: "cached"; - } - - if (!strcmp(opt_overlap_check, "none")) { - overlap_check_template = 0; - } else if (!strcmp(opt_overlap_check, "constant")) { - overlap_check_template = QCOW2_OL_CONSTANT; - } else if (!strcmp(opt_overlap_check, "cached")) { - overlap_check_template = QCOW2_OL_CACHED; - } else if (!strcmp(opt_overlap_check, "all")) { - overlap_check_template = QCOW2_OL_ALL; - } else { - error_setg(errp, "Unsupported value '%s' for qcow2 option " - "'overlap-check'. Allowed are any of the following: " - "none, constant, cached, all", opt_overlap_check); - ret = -EINVAL; + ret = qcow2_update_options(bs, opts, flags, errp); + if (ret < 0) { goto fail; } - s->overlap_check = 0; - for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { - /* overlap-check defines a template bitmask, but every flag may be - * overwritten through the associated boolean option */ - s->overlap_check |= - qemu_opt_get_bool(opts, overlap_bool_option_names[i], - overlap_check_template & (1 << i)) << i; - } - qemu_opts_del(opts); opts = NULL; - if (s->use_lazy_refcounts && s->qcow_version < 3) { - error_setg(errp, "Lazy refcounts require a qcow2 image with at least " - "qemu 1.1 compatibility level"); - ret = -EINVAL; - goto fail; - } - #ifdef DEBUG_ALLOC { BdrvCheckResult result = {0}; -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:41 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCb-0004Gq-O2 for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCP-0003th-3G for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCN-0005FM-Pj for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCN-0005FG-JL; Fri, 11 Sep 2015 15:41:27 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 4B0EBA0BA0; Fri, 11 Sep 2015 19:41:27 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QL017774; Fri, 11 Sep 2015 15:41:26 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:53 +0200 Message-Id: <1442000463-22777-14-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 13/23] qcow2: Move rest of option handling to qcow2_update_options() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:33 -0000 With this commit, the handling of driver-specific options in qcow2_open() is completely separated out into qcow2_update_options(). Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block/qcow2.c | 134 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 68 insertions(+), 66 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index be6b3c2..cf6992e 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -589,15 +589,77 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, } } -static int qcow2_update_options(BlockDriverState *bs, QemuOpts *opts, +static int qcow2_update_options(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVQcow2State *s = bs->opaque; + QemuOpts *opts = NULL; const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; + uint64_t l2_cache_size, refcount_cache_size; + uint64_t cache_clean_interval; int i; + Error *local_err = NULL; int ret; + opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); + qemu_opts_absorb_qdict(opts, options, &local_err); + if (local_err) { + error_propagate(errp, local_err); + ret = -EINVAL; + goto fail; + } + + /* get L2 table/refcount block cache size from command line options */ + read_cache_sizes(bs, opts, &l2_cache_size, &refcount_cache_size, + &local_err); + if (local_err) { + error_propagate(errp, local_err); + ret = -EINVAL; + goto fail; + } + + l2_cache_size /= s->cluster_size; + if (l2_cache_size < MIN_L2_CACHE_SIZE) { + l2_cache_size = MIN_L2_CACHE_SIZE; + } + if (l2_cache_size > INT_MAX) { + error_setg(errp, "L2 cache size too big"); + ret = -EINVAL; + goto fail; + } + + refcount_cache_size /= s->cluster_size; + if (refcount_cache_size < MIN_REFCOUNT_CACHE_SIZE) { + refcount_cache_size = MIN_REFCOUNT_CACHE_SIZE; + } + if (refcount_cache_size > INT_MAX) { + error_setg(errp, "Refcount cache size too big"); + ret = -EINVAL; + goto fail; + } + + /* alloc L2 table/refcount block cache */ + s->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); + s->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); + if (s->l2_table_cache == NULL || s->refcount_block_cache == NULL) { + error_setg(errp, "Could not allocate metadata caches"); + ret = -ENOMEM; + goto fail; + } + + /* New interval for cache cleanup timer */ + cache_clean_interval = + qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0); + if (cache_clean_interval > UINT_MAX) { + error_setg(errp, "Cache clean interval too big"); + ret = -EINVAL; + goto fail; + } + s->cache_clean_interval = cache_clean_interval; + cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); + + /* Enable lazy_refcounts according to image and command line options */ s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); @@ -660,6 +722,9 @@ static int qcow2_update_options(BlockDriverState *bs, QemuOpts *opts, ret = 0; fail: + qemu_opts_del(opts); + opts = NULL; + return ret; } @@ -670,12 +735,9 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, unsigned int len, i; int ret = 0; QCowHeader header; - QemuOpts *opts = NULL; Error *local_err = NULL; uint64_t ext_end; uint64_t l1_vm_state_index; - uint64_t l2_cache_size, refcount_cache_size; - uint64_t cache_clean_interval; ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); if (ret < 0) { @@ -923,71 +985,12 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, } } - /* get L2 table/refcount block cache size from command line options */ - opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); - ret = -EINVAL; - goto fail; - } - - read_cache_sizes(bs, opts, &l2_cache_size, &refcount_cache_size, - &local_err); - if (local_err) { - error_propagate(errp, local_err); - ret = -EINVAL; - goto fail; - } - - l2_cache_size /= s->cluster_size; - if (l2_cache_size < MIN_L2_CACHE_SIZE) { - l2_cache_size = MIN_L2_CACHE_SIZE; - } - if (l2_cache_size > INT_MAX) { - error_setg(errp, "L2 cache size too big"); - ret = -EINVAL; - goto fail; - } - - refcount_cache_size /= s->cluster_size; - if (refcount_cache_size < MIN_REFCOUNT_CACHE_SIZE) { - refcount_cache_size = MIN_REFCOUNT_CACHE_SIZE; - } - if (refcount_cache_size > INT_MAX) { - error_setg(errp, "Refcount cache size too big"); - ret = -EINVAL; - goto fail; - } - - /* alloc L2 table/refcount block cache */ - s->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); - s->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); - if (s->l2_table_cache == NULL || s->refcount_block_cache == NULL) { - error_setg(errp, "Could not allocate metadata caches"); - ret = -ENOMEM; - goto fail; - } - - cache_clean_interval = - qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0); - if (cache_clean_interval > UINT_MAX) { - error_setg(errp, "Cache clean interval too big"); - ret = -EINVAL; - goto fail; - } - s->cache_clean_interval = cache_clean_interval; - cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); - - /* Enable lazy_refcounts according to image and command line options */ - ret = qcow2_update_options(bs, opts, flags, errp); + /* Parse driver-specific options */ + ret = qcow2_update_options(bs, options, flags, errp); if (ret < 0) { goto fail; } - qemu_opts_del(opts); - opts = NULL; - s->cluster_cache = g_malloc(s->cluster_size); /* one more sector for decompressed data alignment */ s->cluster_data = qemu_try_blockalign(bs->file, QCOW_MAX_CRYPT_CLUSTERS @@ -1081,7 +1084,6 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, return ret; fail: - qemu_opts_del(opts); g_free(s->unknown_header_fields); cleanup_unknown_header_ext(bs); qcow2_free_snapshots(bs); -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:42 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCc-0004I2-7q for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCT-000416-34 for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCP-0005IF-5s for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49258) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCO-0005Fk-VU; Fri, 11 Sep 2015 15:41:29 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 9EB42C0B9199; Fri, 11 Sep 2015 19:41:28 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QM017774; Fri, 11 Sep 2015 15:41:27 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:54 +0200 Message-Id: <1442000463-22777-15-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 14/23] qcow2: Leave s unchanged on qcow2_update_options() failure X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:34 -0000 On return, either all new options should be applied to BDRVQcowState (on success), or all of the old settings should be preserved (on failure). Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block/qcow2.c | 57 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index cf6992e..c61d996 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -597,7 +597,10 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; + Qcow2Cache *l2_table_cache; + Qcow2Cache *refcount_block_cache; uint64_t cache_clean_interval; + bool use_lazy_refcounts; int i; Error *local_err = NULL; int ret; @@ -640,9 +643,9 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, } /* alloc L2 table/refcount block cache */ - s->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); - s->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); - if (s->l2_table_cache == NULL || s->refcount_block_cache == NULL) { + l2_table_cache = qcow2_cache_create(bs, l2_cache_size); + refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); + if (l2_table_cache == NULL || refcount_block_cache == NULL) { error_setg(errp, "Could not allocate metadata caches"); ret = -ENOMEM; goto fail; @@ -656,23 +659,18 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, ret = -EINVAL; goto fail; } - s->cache_clean_interval = cache_clean_interval; - cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); /* Enable lazy_refcounts according to image and command line options */ - s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, + use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); + if (use_lazy_refcounts && s->qcow_version < 3) { + error_setg(errp, "Lazy refcounts require a qcow2 image with at least " + "qemu 1.1 compatibility level"); + ret = -EINVAL; + goto fail; + } - s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; - s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; - s->discard_passthrough[QCOW2_DISCARD_REQUEST] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, - flags & BDRV_O_UNMAP); - s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); - s->discard_passthrough[QCOW2_DISCARD_OTHER] = - qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); - + /* Overlap check options */ opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); if (opt_overlap_check_template && opt_overlap_check && @@ -704,6 +702,10 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, goto fail; } + /* + * Start updating fields in BDRVQcow2State. + * After this point no failure is allowed any more. + */ s->overlap_check = 0; for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { /* overlap-check defines a template bitmask, but every flag may be @@ -713,12 +715,23 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, overlap_check_template & (1 << i)) << i; } - if (s->use_lazy_refcounts && s->qcow_version < 3) { - error_setg(errp, "Lazy refcounts require a qcow2 image with at least " - "qemu 1.1 compatibility level"); - ret = -EINVAL; - goto fail; - } + s->l2_table_cache = l2_table_cache; + s->refcount_block_cache = refcount_block_cache; + + s->use_lazy_refcounts = use_lazy_refcounts; + + s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; + s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; + s->discard_passthrough[QCOW2_DISCARD_REQUEST] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, + flags & BDRV_O_UNMAP); + s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); + s->discard_passthrough[QCOW2_DISCARD_OTHER] = + qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); + + s->cache_clean_interval = cache_clean_interval; + cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); ret = 0; fail: -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:46 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCg-0004Pc-Lq for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCc-0004IJ-PR for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCb-0005dH-CR for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCb-0005dC-6U; Fri, 11 Sep 2015 15:41:41 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id DD08C461EF; Fri, 11 Sep 2015 19:41:40 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QV017774; Fri, 11 Sep 2015 15:41:39 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:41:03 +0200 Message-Id: <1442000463-22777-24-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 23/23] qcow2: Make qcow2_alloc_bytes() more explicit X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:44 -0000 From: Max Reitz In case of -EAGAIN returned by update_refcount(), we should discard the cluster offset we were trying to allocate and request a new one, because in theory that old offset might now be taken by a refcount block. In practice, this was not the case due to update_refcount() generally returning strictly monotonic increasing cluster offsets. However, this behavior is not set in stone, and it is also not obvious when looking at qcow2_alloc_bytes() alone, so we should not rely on it. Reported-by: Kevin Wolf Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/qcow2-refcount.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 5f67798..3579c4d 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -949,11 +949,17 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size) if (!offset || ROUND_UP(offset, s->cluster_size) != new_cluster) { offset = new_cluster; + free_in_cluster = s->cluster_size; + } else { + free_in_cluster += s->cluster_size; } } assert(offset); ret = update_refcount(bs, offset, size, 1, false, QCOW2_DISCARD_NEVER); + if (ret < 0) { + offset = 0; + } } while (ret == -EAGAIN); if (ret < 0) { return ret; -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCg-0004QG-Rx for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58808) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCc-0004IB-Og for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCY-0005cZ-Mv for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54991) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCY-0005cC-GG; Fri, 11 Sep 2015 15:41:38 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 34D4D461C2; Fri, 11 Sep 2015 19:41:38 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QT017774; Fri, 11 Sep 2015 15:41:37 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:41:01 +0200 Message-Id: <1442000463-22777-22-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 21/23] iotests: Add test for checking large image files X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:44 -0000 From: Max Reitz Add a test for checking a qcow2 file with a multiple of 2^32 clusters. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- tests/qemu-iotests/138 | 73 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/138.out | 9 ++++++ tests/qemu-iotests/group | 1 + 3 files changed, 83 insertions(+) create mode 100755 tests/qemu-iotests/138 create mode 100644 tests/qemu-iotests/138.out diff --git a/tests/qemu-iotests/138 b/tests/qemu-iotests/138 new file mode 100755 index 0000000..a5c3464 --- /dev/null +++ b/tests/qemu-iotests/138 @@ -0,0 +1,73 @@ +#!/bin/bash +# +# General test case for qcow2's image check +# +# Copyright (C) 2015 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=mreitz@redhat.com + +seq="$(basename $0)" +echo "QA output created by $seq" + +here="$PWD" +tmp=/tmp/$$ +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +# This tests qocw2-specific low-level functionality +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +echo +echo '=== Check on an image with a multiple of 2^32 clusters ===' +echo + +IMGOPTS=$(_optstr_add "$IMGOPTS" "cluster_size=512") \ + _make_test_img 512 + +# Allocate L2 table +$QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io + +# Put the data cluster at a multiple of 2 TB, resulting in the image apparently +# having a multiple of 2^32 clusters +# (To be more specific: It is at 32 PB) +poke_file "$TEST_IMG" 2048 "\x80\x80\x00\x00\x00\x00\x00\x00" + +# An offset of 32 PB results in qemu-img check having to allocate an in-memory +# refcount table of 128 TB (16 bit refcounts, 512 byte clusters). +# This should be generally too much for any system and thus fail. +# What this test is checking is that the qcow2 driver actually tries to allocate +# such a large amount of memory (and is consequently aborting) instead of having +# truncated the cluster count somewhere (which would result in much less memory +# being allocated and then a segfault occurring). +_check_test_img + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/138.out b/tests/qemu-iotests/138.out new file mode 100644 index 0000000..3fe911f --- /dev/null +++ b/tests/qemu-iotests/138.out @@ -0,0 +1,9 @@ +QA output created by 138 + +=== Check on an image with a multiple of 2^32 clusters === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=512 +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +qemu-img: Check failed: Cannot allocate memory +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 3a6a8f0..439b1d2 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -135,3 +135,4 @@ 134 rw auto quick 135 rw auto 137 rw auto +138 rw auto quick -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCa-0004D6-1b for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCN-0003qE-65 for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCM-0005El-CJ for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54921) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCM-0005Eb-7x; Fri, 11 Sep 2015 15:41:26 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id E0154461C2; Fri, 11 Sep 2015 19:41:25 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QK017774; Fri, 11 Sep 2015 15:41:24 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:52 +0200 Message-Id: <1442000463-22777-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 12/23] qcow2: Move qcow2_update_options() call up X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:28 -0000 qcow2_update_options() only updates some variables in BDRVQcowState and doesn't really depend on other parts of it being initialised yet, so it can be moved so that it immediately follows the other half of option handling code in qcow2_open(). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 4dd0699..be6b3c2 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -979,6 +979,15 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, s->cache_clean_interval = cache_clean_interval; cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); + /* Enable lazy_refcounts according to image and command line options */ + ret = qcow2_update_options(bs, opts, flags, errp); + if (ret < 0) { + goto fail; + } + + qemu_opts_del(opts); + opts = NULL; + s->cluster_cache = g_malloc(s->cluster_size); /* one more sector for decompressed data alignment */ s->cluster_data = qemu_try_blockalign(bs->file, QCOW_MAX_CRYPT_CLUSTERS @@ -1063,15 +1072,6 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, } } - /* Enable lazy_refcounts according to image and command line options */ - ret = qcow2_update_options(bs, opts, flags, errp); - if (ret < 0) { - goto fail; - } - - qemu_opts_del(opts); - opts = NULL; - #ifdef DEBUG_ALLOC { BdrvCheckResult result = {0}; -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:42 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCb-0004HH-UK for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58725) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCT-000417-3D for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCQ-0005KM-E9 for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36327) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCQ-0005JE-7y; Fri, 11 Sep 2015 15:41:30 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id E9AB02E242D; Fri, 11 Sep 2015 19:41:29 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QN017774; Fri, 11 Sep 2015 15:41:28 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:55 +0200 Message-Id: <1442000463-22777-16-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 15/23] qcow2: Fix memory leak in qcow2_update_options() error path X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:34 -0000 Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index c61d996..374a56d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -597,8 +597,8 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; - Qcow2Cache *l2_table_cache; - Qcow2Cache *refcount_block_cache; + Qcow2Cache *l2_table_cache = NULL; + Qcow2Cache *refcount_block_cache = NULL; uint64_t cache_clean_interval; bool use_lazy_refcounts; int i; @@ -735,6 +735,14 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, ret = 0; fail: + if (ret < 0) { + if (l2_table_cache) { + qcow2_cache_destroy(bs, l2_table_cache); + } + if (refcount_block_cache) { + qcow2_cache_destroy(bs, refcount_block_cache); + } + } qemu_opts_del(opts); opts = NULL; -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:41:46 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUCg-0004PB-Gp for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:41:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCc-0004IH-PA for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUCZ-0005cw-W9 for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:41:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36402) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUCZ-0005cj-RE; Fri, 11 Sep 2015 15:41:39 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 843AE2E2424; Fri, 11 Sep 2015 19:41:39 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QU017774; Fri, 11 Sep 2015 15:41:38 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:41:02 +0200 Message-Id: <1442000463-22777-23-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 22/23] vmdk: Fix next_cluster_sector for compressed write X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:41:44 -0000 From: Radoslav Gerganov When the VMDK is streamOptimized (or compressed), the next_cluster_sector must not be incremented by a fixed number of sectors. Instead of this, it must be rounded up to the next consecutive sector. Fixing this results in much smaller compressed images. Signed-off-by: Radoslav Gerganov Reviewed-by: Fam Zheng Signed-off-by: Kevin Wolf --- block/vmdk.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 7bdc3d0..be0d640 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1324,8 +1324,12 @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, write_end_sector = DIV_ROUND_UP(write_offset + write_len, BDRV_SECTOR_SIZE); - extent->next_cluster_sector = MAX(extent->next_cluster_sector, - write_end_sector); + if (extent->compressed) { + extent->next_cluster_sector = write_end_sector; + } else { + extent->next_cluster_sector = MAX(extent->next_cluster_sector, + write_end_sector); + } if (ret != write_len) { ret = ret < 0 ? ret : -EIO; -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:48:21 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUJ3-0003PH-35 for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:48:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUJ0-0003Kd-1L for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:48:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUIy-0000Xe-RF for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:48:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45898) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUIy-0000Wx-KH; Fri, 11 Sep 2015 15:48:16 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 555E28E690; Fri, 11 Sep 2015 19:41:31 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QO017774; Fri, 11 Sep 2015 15:41:30 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:56 +0200 Message-Id: <1442000463-22777-17-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 16/23] qcow2: Make qcow2_update_options() suitable for transactions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:48:19 -0000 Before we can allow updating options at runtime with bdrv_reopen(), we need to split the function into prepare/commit/abort parts. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block/qcow2.c | 113 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 73 insertions(+), 40 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 374a56d..64ba3cb 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -589,18 +589,25 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, } } -static int qcow2_update_options(BlockDriverState *bs, QDict *options, - int flags, Error **errp) +typedef struct Qcow2ReopenState { + Qcow2Cache *l2_table_cache; + Qcow2Cache *refcount_block_cache; + bool use_lazy_refcounts; + int overlap_check; + bool discard_passthrough[QCOW2_DISCARD_MAX]; + uint64_t cache_clean_interval; +} Qcow2ReopenState; + +static int qcow2_update_options_prepare(BlockDriverState *bs, + Qcow2ReopenState *r, + QDict *options, int flags, + Error **errp) { BDRVQcow2State *s = bs->opaque; QemuOpts *opts = NULL; const char *opt_overlap_check, *opt_overlap_check_template; int overlap_check_template = 0; uint64_t l2_cache_size, refcount_cache_size; - Qcow2Cache *l2_table_cache = NULL; - Qcow2Cache *refcount_block_cache = NULL; - uint64_t cache_clean_interval; - bool use_lazy_refcounts; int i; Error *local_err = NULL; int ret; @@ -643,27 +650,27 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, } /* alloc L2 table/refcount block cache */ - l2_table_cache = qcow2_cache_create(bs, l2_cache_size); - refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); - if (l2_table_cache == NULL || refcount_block_cache == NULL) { + r->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); + r->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); + if (r->l2_table_cache == NULL || r->refcount_block_cache == NULL) { error_setg(errp, "Could not allocate metadata caches"); ret = -ENOMEM; goto fail; } /* New interval for cache cleanup timer */ - cache_clean_interval = + r->cache_clean_interval = qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0); - if (cache_clean_interval > UINT_MAX) { + if (r->cache_clean_interval > UINT_MAX) { error_setg(errp, "Cache clean interval too big"); ret = -EINVAL; goto fail; } /* Enable lazy_refcounts according to image and command line options */ - use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, + r->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); - if (use_lazy_refcounts && s->qcow_version < 3) { + if (r->use_lazy_refcounts && s->qcow_version < 3) { error_setg(errp, "Lazy refcounts require a qcow2 image with at least " "qemu 1.1 compatibility level"); ret = -EINVAL; @@ -702,49 +709,75 @@ static int qcow2_update_options(BlockDriverState *bs, QDict *options, goto fail; } - /* - * Start updating fields in BDRVQcow2State. - * After this point no failure is allowed any more. - */ - s->overlap_check = 0; + r->overlap_check = 0; for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { /* overlap-check defines a template bitmask, but every flag may be * overwritten through the associated boolean option */ - s->overlap_check |= + r->overlap_check |= qemu_opt_get_bool(opts, overlap_bool_option_names[i], overlap_check_template & (1 << i)) << i; } - s->l2_table_cache = l2_table_cache; - s->refcount_block_cache = refcount_block_cache; - - s->use_lazy_refcounts = use_lazy_refcounts; - - s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; - s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; - s->discard_passthrough[QCOW2_DISCARD_REQUEST] = + r->discard_passthrough[QCOW2_DISCARD_NEVER] = false; + r->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; + r->discard_passthrough[QCOW2_DISCARD_REQUEST] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, flags & BDRV_O_UNMAP); - s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = + r->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); - s->discard_passthrough[QCOW2_DISCARD_OTHER] = + r->discard_passthrough[QCOW2_DISCARD_OTHER] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); - s->cache_clean_interval = cache_clean_interval; - cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); - ret = 0; fail: - if (ret < 0) { - if (l2_table_cache) { - qcow2_cache_destroy(bs, l2_table_cache); - } - if (refcount_block_cache) { - qcow2_cache_destroy(bs, refcount_block_cache); - } - } qemu_opts_del(opts); opts = NULL; + return ret; +} + +static void qcow2_update_options_commit(BlockDriverState *bs, + Qcow2ReopenState *r) +{ + BDRVQcow2State *s = bs->opaque; + int i; + + s->l2_table_cache = r->l2_table_cache; + s->refcount_block_cache = r->refcount_block_cache; + + s->overlap_check = r->overlap_check; + s->use_lazy_refcounts = r->use_lazy_refcounts; + + for (i = 0; i < QCOW2_DISCARD_MAX; i++) { + s->discard_passthrough[i] = r->discard_passthrough[i]; + } + + s->cache_clean_interval = r->cache_clean_interval; + cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); +} + +static void qcow2_update_options_abort(BlockDriverState *bs, + Qcow2ReopenState *r) +{ + if (r->l2_table_cache) { + qcow2_cache_destroy(bs, r->l2_table_cache); + } + if (r->refcount_block_cache) { + qcow2_cache_destroy(bs, r->refcount_block_cache); + } +} + +static int qcow2_update_options(BlockDriverState *bs, QDict *options, + int flags, Error **errp) +{ + Qcow2ReopenState r = {}; + int ret; + + ret = qcow2_update_options_prepare(bs, &r, options, flags, errp); + if (ret >= 0) { + qcow2_update_options_commit(bs, &r); + } else { + qcow2_update_options_abort(bs, &r); + } return ret; } -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:48:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUJB-0003dw-Re for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:48:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUJ4-0003S9-Uv for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:48:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUIy-0000XX-Os for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:48:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45897) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUIy-0000Ww-KG; Fri, 11 Sep 2015 15:48:16 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 0B1848E3C0; Fri, 11 Sep 2015 19:41:34 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QQ017774; Fri, 11 Sep 2015 15:41:33 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:58 +0200 Message-Id: <1442000463-22777-19-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 18/23] qemu-iotests: Reopen qcow2 with lazy-refcounts change X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:48:27 -0000 Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- tests/qemu-iotests/039 | 27 +++++++++++++++++++++++++++ tests/qemu-iotests/039.out | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 index 617f397..9e9b379 100755 --- a/tests/qemu-iotests/039 +++ b/tests/qemu-iotests/039 @@ -147,6 +147,33 @@ $PYTHON qcow2.py "$TEST_IMG".base dump-header | grep incompatible_features _check_test_img TEST_IMG="$TEST_IMG".base _check_test_img +echo +echo "== Changing lazy_refcounts setting at runtime ==" + +IMGOPTS="compat=1.1,lazy_refcounts=off" +_make_test_img $size + +$QEMU_IO -c "reopen -o lazy-refcounts=on" \ + -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ + | _filter_qemu_io + +# The dirty bit must be set +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +_check_test_img + +IMGOPTS="compat=1.1,lazy_refcounts=on" +_make_test_img $size + +$QEMU_IO -c "reopen -o lazy-refcounts=off" \ + -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \ + | _filter_qemu_io + +# The dirty bit must not be set +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features +_check_test_img + # success, all done echo "*** done" diff --git a/tests/qemu-iotests/039.out b/tests/qemu-iotests/039.out index d8c5a44..03a31c5 100644 --- a/tests/qemu-iotests/039.out +++ b/tests/qemu-iotests/039.out @@ -74,4 +74,22 @@ incompatible_features 0x0 incompatible_features 0x0 No errors were found on the image. No errors were found on the image. + +== Changing lazy_refcounts setting at runtime == +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) +incompatible_features 0x1 +ERROR cluster 5 refcount=0 reference=1 +ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0 + +2 errors were found on the image. +Data may be corrupted, or further writes to the image may corrupt it. +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) +incompatible_features 0x0 +No errors were found on the image. *** done -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:48:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUJC-0003eO-1O for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:48:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUJ8-0003Yv-SE for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:48:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUJ4-0000ZA-Q6 for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:48:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35474) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUJ4-0000Z5-JE; Fri, 11 Sep 2015 15:48:22 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id AFF3980B27; Fri, 11 Sep 2015 19:41:32 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QP017774; Fri, 11 Sep 2015 15:41:31 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:57 +0200 Message-Id: <1442000463-22777-18-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 17/23] qcow2: Support updating driver-specific options in reopen X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:48:28 -0000 For updating the cache sizes, disabling lazy refcounts and updating the clean_cache_timer there is a bit more to do than just changing the variables, but otherwise we're all set for changing options during bdrv_reopen(). Just implement the missing pieces and hook the functions up in bdrv_reopen(). Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block/qcow2.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 64ba3cb..56ad808 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -649,7 +649,24 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, goto fail; } - /* alloc L2 table/refcount block cache */ + /* alloc new L2 table/refcount block cache, flush old one */ + if (s->l2_table_cache) { + ret = qcow2_cache_flush(bs, s->l2_table_cache); + if (ret) { + error_setg_errno(errp, -ret, "Failed to flush the L2 table cache"); + goto fail; + } + } + + if (s->refcount_block_cache) { + ret = qcow2_cache_flush(bs, s->refcount_block_cache); + if (ret) { + error_setg_errno(errp, -ret, + "Failed to flush the refcount block cache"); + goto fail; + } + } + r->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); r->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); if (r->l2_table_cache == NULL || r->refcount_block_cache == NULL) { @@ -660,14 +677,15 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, /* New interval for cache cleanup timer */ r->cache_clean_interval = - qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, 0); + qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL, + s->cache_clean_interval); if (r->cache_clean_interval > UINT_MAX) { error_setg(errp, "Cache clean interval too big"); ret = -EINVAL; goto fail; } - /* Enable lazy_refcounts according to image and command line options */ + /* lazy-refcounts; flush if going from enabled to disabled */ r->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); if (r->use_lazy_refcounts && s->qcow_version < 3) { @@ -677,6 +695,14 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, goto fail; } + if (s->use_lazy_refcounts && !r->use_lazy_refcounts) { + ret = qcow2_mark_clean(bs); + if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to disable lazy refcounts"); + goto fail; + } + } + /* Overlap check options */ opt_overlap_check = qemu_opt_get(opts, QCOW2_OPT_OVERLAP); opt_overlap_check_template = qemu_opt_get(opts, QCOW2_OPT_OVERLAP_TEMPLATE); @@ -741,6 +767,12 @@ static void qcow2_update_options_commit(BlockDriverState *bs, BDRVQcow2State *s = bs->opaque; int i; + if (s->l2_table_cache) { + qcow2_cache_destroy(bs, s->l2_table_cache); + } + if (s->refcount_block_cache) { + qcow2_cache_destroy(bs, s->refcount_block_cache); + } s->l2_table_cache = r->l2_table_cache; s->refcount_block_cache = r->refcount_block_cache; @@ -751,8 +783,11 @@ static void qcow2_update_options_commit(BlockDriverState *bs, s->discard_passthrough[i] = r->discard_passthrough[i]; } - s->cache_clean_interval = r->cache_clean_interval; - cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); + if (s->cache_clean_interval != r->cache_clean_interval) { + cache_clean_timer_del(bs); + s->cache_clean_interval = r->cache_clean_interval; + cache_clean_timer_init(bs, bdrv_get_aio_context(bs)); + } } static void qcow2_update_options_abort(BlockDriverState *bs, @@ -1199,26 +1234,52 @@ static int qcow2_set_key(BlockDriverState *bs, const char *key) return 0; } -/* We have no actual commit/abort logic for qcow2, but we need to write out any - * unwritten data if we reopen read-only. */ static int qcow2_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { + Qcow2ReopenState *r; int ret; + r = g_new0(Qcow2ReopenState, 1); + state->opaque = r; + + ret = qcow2_update_options_prepare(state->bs, r, state->options, + state->flags, errp); + if (ret < 0) { + goto fail; + } + + /* We need to write out any unwritten data if we reopen read-only. */ if ((state->flags & BDRV_O_RDWR) == 0) { ret = bdrv_flush(state->bs); if (ret < 0) { - return ret; + goto fail; } ret = qcow2_mark_clean(state->bs); if (ret < 0) { - return ret; + goto fail; } } return 0; + +fail: + qcow2_update_options_abort(state->bs, r); + g_free(r); + return ret; +} + +static void qcow2_reopen_commit(BDRVReopenState *state) +{ + qcow2_update_options_commit(state->bs, state->opaque); + g_free(state->opaque); +} + +static void qcow2_reopen_abort(BDRVReopenState *state) +{ + qcow2_update_options_abort(state->bs, state->opaque); + g_free(state->opaque); } static int64_t coroutine_fn qcow2_co_get_block_status(BlockDriverState *bs, @@ -3082,6 +3143,8 @@ BlockDriver bdrv_qcow2 = { .bdrv_open = qcow2_open, .bdrv_close = qcow2_close, .bdrv_reopen_prepare = qcow2_reopen_prepare, + .bdrv_reopen_commit = qcow2_reopen_commit, + .bdrv_reopen_abort = qcow2_reopen_abort, .bdrv_create = qcow2_create, .bdrv_has_zero_init = bdrv_has_zero_init_1, .bdrv_co_get_block_status = qcow2_co_get_block_status, -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:48:42 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaUJN-00041D-PG for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:48:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUJK-0003uX-3U for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:48:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaUJG-0000it-Qh for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:48:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41986) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaUJG-0000ib-AE; Fri, 11 Sep 2015 15:48:34 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id DEDBCAB10C; Fri, 11 Sep 2015 19:41:36 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QS017774; Fri, 11 Sep 2015 15:41:35 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:41:00 +0200 Message-Id: <1442000463-22777-21-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 20/23] qcow2: Make size_to_clusters() return uint64_t X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:48:40 -0000 From: Max Reitz Sadly, some images may have more clusters than what can be represented using a plain int. We should be prepared for that case (in qcow2_check_refcounts() we actually were trying to catch that case, but since size_to_clusters() truncated the returned value, that check never did anything useful). Cc: qemu-stable Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/qcow2-cluster.c | 28 ++++++++++++++++++---------- block/qcow2-refcount.c | 10 +++++++--- block/qcow2.h | 6 +++--- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 412ee27..6ede629 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -298,7 +298,7 @@ fail: * as contiguous. (This allows it, for example, to stop at the first compressed * cluster which may require a different handling) */ -static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size, +static int count_contiguous_clusters(int nb_clusters, int cluster_size, uint64_t *l2_table, uint64_t stop_flags) { int i; @@ -321,7 +321,7 @@ static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size, return i; } -static int count_contiguous_free_clusters(uint64_t nb_clusters, uint64_t *l2_table) +static int count_contiguous_free_clusters(int nb_clusters, uint64_t *l2_table) { int i; @@ -495,6 +495,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, if (nb_needed > nb_available) { nb_needed = nb_available; } + assert(nb_needed <= INT_MAX); *cluster_offset = 0; @@ -530,6 +531,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); *cluster_offset = be64_to_cpu(l2_table[l2_index]); + + /* nb_needed <= INT_MAX, thus nb_clusters <= INT_MAX, too */ nb_clusters = size_to_clusters(s, nb_needed << 9); ret = qcow2_get_cluster_type(*cluster_offset); @@ -960,7 +963,7 @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset, int l2_index; uint64_t cluster_offset; uint64_t *l2_table; - unsigned int nb_clusters; + uint64_t nb_clusters; unsigned int keep_clusters; int ret; @@ -979,6 +982,7 @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset, l2_index = offset_to_l2_index(s, guest_offset); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); /* Find L2 entry for the first involved cluster */ ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index); @@ -1061,7 +1065,7 @@ out: * restarted, but the whole request should not be failed. */ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, - uint64_t *host_offset, unsigned int *nb_clusters) + uint64_t *host_offset, uint64_t *nb_clusters) { BDRVQcow2State *s = bs->opaque; @@ -1079,7 +1083,7 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, *host_offset = cluster_offset; return 0; } else { - int ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters); + int64_t ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters); if (ret < 0) { return ret; } @@ -1115,7 +1119,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, int l2_index; uint64_t *l2_table; uint64_t entry; - unsigned int nb_clusters; + uint64_t nb_clusters; int ret; uint64_t alloc_cluster_offset; @@ -1133,6 +1137,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, l2_index = offset_to_l2_index(s, guest_offset); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); /* Find L2 entry for the first involved cluster */ ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index); @@ -1426,7 +1431,8 @@ int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) * clusters. */ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, - unsigned int nb_clusters, enum qcow2_discard_type type, bool full_discard) + uint64_t nb_clusters, enum qcow2_discard_type type, + bool full_discard) { BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; @@ -1441,6 +1447,7 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, /* Limit nb_clusters to one L2 table */ nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); for (i = 0; i < nb_clusters; i++) { uint64_t old_l2_entry; @@ -1503,7 +1510,7 @@ int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, { BDRVQcow2State *s = bs->opaque; uint64_t end_offset; - unsigned int nb_clusters; + uint64_t nb_clusters; int ret; end_offset = offset + (nb_sectors << BDRV_SECTOR_BITS); @@ -1545,7 +1552,7 @@ fail: * clusters. */ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, - unsigned int nb_clusters) + uint64_t nb_clusters) { BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; @@ -1560,6 +1567,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, /* Limit nb_clusters to one L2 table */ nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); for (i = 0; i < nb_clusters; i++) { uint64_t old_offset; @@ -1584,7 +1592,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors) { BDRVQcow2State *s = bs->opaque; - unsigned int nb_clusters; + uint64_t nb_clusters; int ret; /* The zero flag is only supported by version 3 and newer */ diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index b780bb9..5f67798 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -875,8 +875,8 @@ int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size) return offset; } -int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, - int nb_clusters) +int64_t qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, + int64_t nb_clusters) { BDRVQcow2State *s = bs->opaque; uint64_t cluster_index, refcount; @@ -1259,7 +1259,7 @@ static size_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries) static int realloc_refcount_array(BDRVQcow2State *s, void **array, int64_t *size, int64_t new_size) { - size_t old_byte_size, new_byte_size; + int64_t old_byte_size, new_byte_size; void *new_ptr; /* Round to clusters so the array can be directly written to disk */ @@ -1275,6 +1275,10 @@ static int realloc_refcount_array(BDRVQcow2State *s, void **array, assert(new_byte_size > 0); + if (new_byte_size > SIZE_MAX) { + return -ENOMEM; + } + new_ptr = g_try_realloc(*array, new_byte_size); if (!new_ptr) { return -ENOMEM; diff --git a/block/qcow2.h b/block/qcow2.h index 61f1b57..d700bf1 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -415,7 +415,7 @@ static inline int64_t offset_into_cluster(BDRVQcow2State *s, int64_t offset) return offset & (s->cluster_size - 1); } -static inline int size_to_clusters(BDRVQcow2State *s, int64_t size) +static inline uint64_t size_to_clusters(BDRVQcow2State *s, uint64_t size) { return (size + (s->cluster_size - 1)) >> s->cluster_bits; } @@ -509,8 +509,8 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs, int64_t cluster_index, enum qcow2_discard_type type); int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size); -int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, - int nb_clusters); +int64_t qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, + int64_t nb_clusters); int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size); void qcow2_free_clusters(BlockDriverState *bs, int64_t offset, int64_t size, -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 15:51:11 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaULm-0008Hk-S8 for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 15:51:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaULj-00089A-0C for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:51:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaULf-0002Mk-La for qemu-block@nongnu.org; Fri, 11 Sep 2015 15:51:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaULf-0002Md-AM; Fri, 11 Sep 2015 15:51:03 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 6E9B9C0A1613; Fri, 11 Sep 2015 19:41:35 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BJf7QR017774; Fri, 11 Sep 2015 15:41:34 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Sep 2015 21:40:59 +0200 Message-Id: <1442000463-22777-20-git-send-email-kwolf@redhat.com> In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 19/23] qemu-iotests: More qcow2 reopen tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 19:51:09 -0000 Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- tests/qemu-iotests/137 | 145 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/137.out | 42 +++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 188 insertions(+) create mode 100755 tests/qemu-iotests/137 create mode 100644 tests/qemu-iotests/137.out diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 new file mode 100755 index 0000000..9a6597c --- /dev/null +++ b/tests/qemu-iotests/137 @@ -0,0 +1,145 @@ +#!/bin/bash +# +# Test qcow2 reopen +# +# Copyright (C) 2015 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=kwolf@redhat.com + +seq="$(basename $0)" +echo "QA output created by $seq" + +here="$PWD" +tmp=/tmp/$$ +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +_supported_fmt qcow2 +_supported_proto generic +_supported_os Linux + + +_make_test_img 64M + +echo === Try setting valid values for all options === +echo + +# Try all options and then check that all of the basic I/O operations still +# work on this image. +$QEMU_IO \ + -c "reopen -o lazy-refcounts=on,pass-discard-request=on" \ + -c "reopen -o lazy-refcounts=off,pass-discard-request=off" \ + -c "reopen -o pass-discard-snapshot=on,pass-discard-other=on" \ + -c "reopen -o pass-discard-snapshot=off,pass-discard-other=off" \ + -c "reopen -o overlap-check=all" \ + -c "reopen -o overlap-check=none" \ + -c "reopen -o overlap-check=cached" \ + -c "reopen -o overlap-check=constant" \ + -c "reopen -o overlap-check.template=all" \ + -c "reopen -o overlap-check.template=none" \ + -c "reopen -o overlap-check.template=cached" \ + -c "reopen -o overlap-check.template=constant" \ + -c "reopen -o overlap-check.main-header=on" \ + -c "reopen -o overlap-check.main-header=off" \ + -c "reopen -o overlap-check.active-l1=on" \ + -c "reopen -o overlap-check.active-l1=off" \ + -c "reopen -o overlap-check.active-l2=on" \ + -c "reopen -o overlap-check.active-l2=off" \ + -c "reopen -o overlap-check.refcount-table=on" \ + -c "reopen -o overlap-check.refcount-table=off" \ + -c "reopen -o overlap-check.refcount-block=on" \ + -c "reopen -o overlap-check.refcount-block=off" \ + -c "reopen -o overlap-check.snapshot-table=on" \ + -c "reopen -o overlap-check.snapshot-table=off" \ + -c "reopen -o overlap-check.inactive-l1=on" \ + -c "reopen -o overlap-check.inactive-l1=off" \ + -c "reopen -o overlap-check.inactive-l2=on" \ + -c "reopen -o overlap-check.inactive-l2=off" \ + -c "reopen -o cache-size=1M" \ + -c "reopen -o l2-cache-size=512k" \ + -c "reopen -o refcount-cache-size=128k" \ + -c "reopen -o cache-clean-interval=5" \ + -c "reopen -o cache-clean-interval=0" \ + -c "reopen -o cache-clean-interval=10" \ + \ + -c "write -P 55 0 32M" \ + -c "read -P 55 0 32M" \ + -c "discard 0 32M" \ + -c "write -z 0 32M" \ + -c "read -P 0 0 32M" \ + \ + "$TEST_IMG" | _filter_qemu_io + + +echo +echo === Try setting some invalid values === +echo + +$QEMU_IO \ + -c "reopen -o lazy-refcounts=42" \ + -c "reopen -o cache-size=1M,l2-cache-size=64k,refcount-cache-size=64k" \ + -c "reopen -o cache-size=1M,l2-cache-size=2M" \ + -c "reopen -o cache-size=1M,refcount-cache-size=2M" \ + -c "reopen -o l2-cache-size=256T" \ + -c "reopen -o refcount-cache-size=256T" \ + -c "reopen -o overlap-check=constant,overlap-check.template=all" \ + -c "reopen -o overlap-check=blubb" \ + -c "reopen -o overlap-check.template=blubb" \ + -c "reopen -o cache-clean-interval=-1" \ + "$TEST_IMG" | _filter_qemu_io + +echo +echo === Test transaction semantics === +echo + +# Whether lazy-refcounts was actually enabled can easily be tested: Check if +# the dirty bit is set after a crash +$QEMU_IO \ + -c "reopen -o lazy-refcounts=on,overlap-check=blubb" \ + -c "write -P 0x5a 0 512" \ + -c "sigraise $(kill -l KILL)" \ + "$TEST_IMG" 2>&1 | _filter_qemu_io + +# The dirty bit must not be set +$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features + +# Similarly we can test whether corruption detection has been enabled: +# Create L1/L2, overwrite first entry in refcount block, allocate something. +# Disabling the checks should fail, so the corruption must be detected. +_make_test_img 64M +$QEMU_IO -c "write 0 64k" "$TEST_IMG" | _filter_qemu_io +poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00" +$QEMU_IO \ + -c "reopen -o overlap-check=none,lazy-refcounts=42" \ + -c "write 64k 64k" \ + "$TEST_IMG" 2>&1 | _filter_qemu_io + +# success, all done +echo '*** done' +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/137.out b/tests/qemu-iotests/137.out new file mode 100644 index 0000000..cf55a41 --- /dev/null +++ b/tests/qemu-iotests/137.out @@ -0,0 +1,42 @@ +QA output created by 137 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 +=== Try setting valid values for all options === + +wrote 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +discard 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 33554432/33554432 bytes at offset 0 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=== Try setting some invalid values === + +Parameter 'lazy-refcounts' expects 'on' or 'off' +cache-size, l2-cache-size and refcount-cache-size may not be set the same time +l2-cache-size may not exceed cache-size +refcount-cache-size may not exceed cache-size +L2 cache size too big +L2 cache size too big +Conflicting values for qcow2 options 'overlap-check' ('constant') and 'overlap-check.template' ('all') +Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all +Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all +Cache clean interval too big + +=== Test transaction semantics === + +Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) +incompatible_features 0x0 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Parameter 'lazy-refcounts' expects 'on' or 'off' +qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with qcow2_header); further corruption events will be suppressed +write failed: Input/output error +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index c430b6c..3a6a8f0 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -134,3 +134,4 @@ 132 rw auto quick 134 rw auto quick 135 rw auto +137 rw auto -- 1.8.3.1 From MAILER-DAEMON Fri Sep 11 19:21:00 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZaXcq-0007q2-IL for mharc-qemu-block@gnu.org; Fri, 11 Sep 2015 19:21:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaXcm-0007pI-W6 for qemu-block@nongnu.org; Fri, 11 Sep 2015 19:20:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaXci-0007gM-4g for qemu-block@nongnu.org; Fri, 11 Sep 2015 19:20:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36873) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaXch-0007gG-Vo; Fri, 11 Sep 2015 19:20:52 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id F3B36341AC2; Fri, 11 Sep 2015 23:20:50 +0000 (UTC) Received: from [10.3.113.15] ([10.3.113.15]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8BNKnjr013647; Fri, 11 Sep 2015 19:20:49 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-17-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55F361CC.6030306@redhat.com> Date: Fri, 11 Sep 2015 17:20:44 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1437414365-11881-17-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="mv2g7sMACinjq5oDaPJJJahfp60JrRAhj" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v4 16/38] block: Add BlockBackendRootState X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 23:20:58 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --mv2g7sMACinjq5oDaPJJJahfp60JrRAhj Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/20/2015 11:45 AM, Max Reitz wrote: > This structure will store some of the state of the root BDS if the BDS > tree is removed, so that state can be restored once a new BDS tree is > inserted. >=20 > Signed-off-by: Max Reitz > --- > block/block-backend.c | 37 ++++++++++++++++++++++++++++++++++= +++ > include/block/block_int.h | 10 ++++++++++ > include/qemu/typedefs.h | 1 + > include/sysemu/block-backend.h | 2 ++ > 4 files changed, 50 insertions(+) Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --mv2g7sMACinjq5oDaPJJJahfp60JrRAhj Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV82HMAAoJEKeha0olJ0NqLAMH/A/Xsez/0RK7Nh5IdrEL6xDg ZEvAH/ol3ST2Xo4iKpAIBX5JnLM6d1Xv027WZyZVn3eBopopd2tqpWNz5YsBpw/Z FSwjMYWMM4CVl8xEtmsWw6YAEkJryuIcqc2y7FvgrWspR3d5UMBWddSfesz6QZss isFl7c9lhWfBFL04I905jMARtmoA9l9EbrJzZWIP5D18v96msKeyi2h2xlTN8jxc p19fwkbmQiKjCdbwFVt3bB7CGPKB8cm5FL/oJxnrSixoUbQbuzzK5B5z9GdsEHhi zycClsrZZK3OibWSD8ShyvUVWWUJtRmho9cKlav3wzJNZIx9PZbnQMIzMej/MaI= =EP7Q -----END PGP SIGNATURE----- --mv2g7sMACinjq5oDaPJJJahfp60JrRAhj-- From MAILER-DAEMON Sat Sep 12 21:35:24 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZawCS-0004ln-2m for mharc-qemu-block@gnu.org; Sat, 12 Sep 2015 21:35:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZawCO-0004dm-S8 for qemu-block@nongnu.org; Sat, 12 Sep 2015 21:35:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZawCM-0001yH-T8 for qemu-block@nongnu.org; Sat, 12 Sep 2015 21:35:20 -0400 Received: from mail-qg0-x22a.google.com ([2607:f8b0:400d:c04::22a]:34580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZawCH-0001uq-J1; Sat, 12 Sep 2015 21:35:13 -0400 Received: by qgez77 with SMTP id z77so91385528qge.1; Sat, 12 Sep 2015 18:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:subject:date:message-id:cc:to:mime-version; bh=sX39PTT7SOUQ0fSnLnebL6L+pRdhyex9wq2tIcziU0A=; b=hrbaKJk0K0kXL4uWy9DkKchRpVxixBlnkDRa2fTzRp8DPcfT3KhH/2NVBXCUxBTwzi 4rx+Fg6zzjuGJHuUy6/n3z3pq5Yc8AiLeARLCyzwYHXiU8hT1OUw27fqMx90xxbLDzLi ffUzsjvtdE+3ItutK/M02qKi1dYsNqtavri3qdzPMNMYBJI4e+qU50SoZnxgH7wMcmuc +lgOfn+epm2fH8C7bBF5qWzx6LXoc0X1DtzscOf7GjCmII5ptw+gdIH1vYq64pIjGza5 9x5TBsuvZm4JXqIZBleWcEHIqsaRlJVyHJ3fgioQuhngceg0/RNyKwdCBefykde4rywn EZYw== X-Received: by 10.140.202.195 with SMTP id x186mr10916855qha.71.1442108112697; Sat, 12 Sep 2015 18:35:12 -0700 (PDT) Received: from [192.168.0.3] (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by smtp.gmail.com with ESMTPSA id c109sm3114135qga.16.2015.09.12.18.35.11 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 12 Sep 2015 18:35:12 -0700 (PDT) From: Programmingkid Content-Type: multipart/alternative; boundary=Apple-Mail-1--55557131 Date: Sat, 12 Sep 2015 21:35:10 -0400 Message-Id: <3B76BBCC-8E49-4D02-AF9C-4D952099A0CF@gmail.com> To: Kevin Wolf , qemu-devel qemu-devel Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c04::22a Cc: Qemu-block Subject: [Qemu-block] ping: [PATCH v5] raw-posix.c: Make physical devices usable in QEMU under Mac OS X host X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Sep 2015 01:35:22 -0000 --Apple-Mail-1--55557131 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > Mac OS X can be picky when it comes to allowing the user to use = physical devices > in QEMU. Most mounted volumes appear to be off limits to QEMU. If an = issue is > detected, a message is displayed showing the user how to unmount a = volume. >=20 > Signed-off-by: John Arbuckle >=20 > --- > Removed changes to GetBSDPath() to a separate patch. > This patch now depends on the GetBSDPath patch. >=20 > block/raw-posix.c | 90 = +++++++++++++++++++++++++++++++++++++--------------- > 1 files changed, 64 insertions(+), 26 deletions(-) >=20 > diff --git a/block/raw-posix.c b/block/raw-posix.c > index 67d1d48..a41006f 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -42,9 +42,8 @@ > #include > #include > #include > -//#include > #include > -#endif > +#endif /* (__APPLE__) && (__MACH__) */ > =20 > #ifdef __sun__ > #define _POSIX_PTHREAD_SEMANTICS 1 > @@ -1972,7 +1971,7 @@ BlockDriver bdrv_file =3D { > /* host device */ > =20 > #if defined(__APPLE__) && defined(__MACH__) > -static kern_return_t FindEjectableCDMedia( io_iterator_t = *mediaIterator ); > +static kern_return_t FindEjectableCDMedia(io_iterator_t = *mediaIterator); > static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char = *bsdPath, > CFIndex maxPathSize, int flags); > kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator ) > @@ -2030,7 +2029,34 @@ kern_return_t GetBSDPath(io_iterator_t = mediaIterator, char *bsdPath, > return kernResult; > } > =20 > -#endif > +/* Sets up a real cdrom for use in QEMU */ > +static bool setupCDROM(char *bsdPath) > +{ > + int index, numOfTestPartitions =3D 2, fd; > + char testPartition[MAXPATHLEN]; > + bool partitionFound =3D false; > + > + /* look for a working partition */ > + for (index =3D 0; index < numOfTestPartitions; index++) { > + snprintf(testPartition, sizeof(testPartition), "%ss%d", = bsdPath, index); > + fd =3D qemu_open(testPartition, O_RDONLY | O_BINARY | = O_LARGEFILE); > + if (fd >=3D 0) { > + partitionFound =3D true; > + qemu_close(fd); > + break; > + } > + } > + > + /* if a working partition on the device was not found */ > + if (partitionFound =3D=3D false) { > + printf("Error: Failed to find a working partition on = disc!\n"); > + } else { > + DPRINTF("Using %s as optical disc\n", testPartition); > + pstrcpy(bsdPath, MAXPATHLEN, testPartition); > + } > + return partitionFound; > +} > +#endif /* defined(__APPLE__) && defined(__MACH__) */ > =20 > static int hdev_probe_device(const char *filename) > { > @@ -2118,34 +2144,32 @@ static int hdev_open(BlockDriverState *bs, = QDict *options, int flags, > BDRVRawState *s =3D bs->opaque; > Error *local_err =3D NULL; > int ret; > + bool cdromOK =3D true; > =20 > #if defined(__APPLE__) && defined(__MACH__) > const char *filename =3D qdict_get_str(options, "filename"); > =20 > - if (strstart(filename, "/dev/cdrom", NULL)) { > - kern_return_t kernResult; > - io_iterator_t mediaIterator; > - char bsdPath[ MAXPATHLEN ]; > - int fd; > - > - kernResult =3D FindEjectableCDMedia( &mediaIterator ); > - kernResult =3D GetBSDPath(mediaIterator, bsdPath, = sizeof(bsdPath),=20 > - = flags); > - if ( bsdPath[ 0 ] !=3D '\0' ) { > - strcat(bsdPath,"s0"); > - /* some CDs don't have a partition 0 */ > - fd =3D qemu_open(bsdPath, O_RDONLY | O_BINARY | = O_LARGEFILE); > - if (fd < 0) { > - bsdPath[strlen(bsdPath)-1] =3D '1'; > + /* If using a physical device */ > + if (strstart(filename, "/dev/", NULL)) { > + char bsdPath[MAXPATHLEN]; > + > + /* If the physical device is a cdrom */ > + if (strcmp(filename, "/dev/cdrom") =3D=3D 0) { > + io_iterator_t mediaIterator; > + FindEjectableCDMedia(&mediaIterator); > + GetBSDPath(mediaIterator, bsdPath, sizeof(bsdPath), = flags); > + if (bsdPath[0] =3D=3D '\0') { > + printf("Error: failed to obtain bsd path for optical = drive!\n"); > } else { > - qemu_close(fd); > + cdromOK =3D setupCDROM(bsdPath); > + filename =3D bsdPath; > } > - filename =3D bsdPath; > - qdict_put(options, "filename", = qstring_from_str(filename)); > - } > =20 > - if ( mediaIterator ) > - IOObjectRelease( mediaIterator ); > + if (mediaIterator) { > + IOObjectRelease(mediaIterator); > + } > + } > + qdict_put(options, "filename", qstring_from_str(filename)); > } > #endif > =20 > @@ -2156,7 +2180,21 @@ static int hdev_open(BlockDriverState *bs, = QDict *options, int flags, > if (local_err) { > error_propagate(errp, local_err); > } > - return ret; > + } > + > +#if defined(__APPLE__) && defined(__MACH__) > + /* if a physical device experienced an error while being opened = */ > + if (strncmp(filename, "/dev/", 5) =3D=3D 0 && (cdromOK =3D=3D = false || ret !=3D 0)) { > + printf("If device %s is mounted on the desktop, unmount it" > + " first before using it in QEMU.\n", = filename); > + printf("Command to unmount device: diskutil unmountDisk = %s\n", > + = filename); > + printf("Command to mount device: diskutil mountDisk %s\n", = filename); > + } > +#endif /* defined(__APPLE__) && defined(__MACH__) */ > + > + if (ret < 0) { > + return ret; > } > =20 > /* Since this does ioctl the device must be already opened */ > --=20 > 1.7.5.4 I would like to know that status of this patch please.=20= --Apple-Mail-1--55557131 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
Mac OS X can be picky when it comes = to allowing the user to use physical devices
in = QEMU. Most mounted volumes appear to be off limits to QEMU. If an issue = is

Signed-off-by: John Arbuckle = <programmingkidx@gmail.com>= ;

---
Removed changes to = GetBSDPath() to a separate patch.
This patch now depends on the = GetBSDPath patch.

 block/raw-posix.c | =   90 +++++++++++++++++++++++++++++++++++++---------------

diff --git a/block/raw-posix.c = b/block/raw-posix.c
index 67d1d48..a41006f 100644
--- = a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ = -42,9 +42,8 @@
 #include = <IOKit/storage/IOMediaBSDClient.h>
 #include = <IOKit/storage/IOMedia.h>
 #include = <IOKit/storage/IOCDMedia.h>
-//#include = <IOKit/storage/IOCDTypes.h>
 #include = <CoreFoundation/CoreFoundation.h>
-#endif
 
 #ifdef __sun__
@@ -1972,7 +1971,7 @@ = BlockDriver bdrv_file =3D {
 /* host device */
 
 #if defined(__APPLE__) = && defined(__MACH__)
-static kern_return_t = FindEjectableCDMedia( io_iterator_t *mediaIterator );
 static kern_return_t GetBSDPath(io_iterator_t = mediaIterator, char *bsdPath,
         =                     =     CFIndex maxPathSize, int flags);
     return = kernResult;
 }
 
-#endif
+/* Sets up a real cdrom for = use in QEMU */
+static bool setupCDROM(char *bsdPath)
+    int index, numOfTestPartitions =3D = 2, fd;
+    char = testPartition[MAXPATHLEN];
+    bool partitionFound =3D = false;
+
+    /* look for a working partition = */
+        = snprintf(testPartition, sizeof(testPartition), "%ss%d", bsdPath, = index);
+        fd =3D = qemu_open(testPartition, O_RDONLY | O_BINARY | O_LARGEFILE);
+            = qemu_close(fd);
+            = break;
+        }
+
+    /* if a working partition on the = device was not found */
+    if (partitionFound =3D=3D= false) {
+        printf("Error: Failed = to find a working partition on disc!\n");
+    } else = {
+        pstrcpy(bsdPath, = MAXPATHLEN, testPartition);
+    }
+}
 
 static int = hdev_probe_device(const char *filename)
 {
@@ = -2118,34 +2144,32 @@ static int hdev_open(BlockDriverState *bs, QDict = *options, int flags,
     BDRVRawState *s =3D = bs->opaque;
     Error *local_err =3D = NULL;
     int ret;
 
 #if defined(__APPLE__) = && defined(__MACH__)
     const char = *filename =3D qdict_get_str(options, "filename");
 
-    if (strstart(filename, = "/dev/cdrom", NULL)) {
-        kern_return_t = kernResult;
-        io_iterator_t = mediaIterator;
-        char bsdPath[ = MAXPATHLEN ];
-        int fd;
-        kernResult =3D = FindEjectableCDMedia( &mediaIterator );
-        = kernResult =3D GetBSDPath(mediaIterator, bsdPath, = sizeof(bsdPath), 
-              =                     =                     =                   = flags);
-        if ( bsdPath[ 0 ] !=3D = '\0' ) {
-            = strcat(bsdPath,"s0");
-            /* some = CDs don't have a partition 0 */
-          =   fd =3D qemu_open(bsdPath, O_RDONLY | O_BINARY | = O_LARGEFILE);
-            if (fd = < 0) {
-              =   bsdPath[strlen(bsdPath)-1] =3D '1';
+    /* If using a = physical device */
+    if (strstart(filename, "/dev/", = NULL)) {
+        char = bsdPath[MAXPATHLEN];
+
+        /* If the physical = device is a cdrom */
+        if (strcmp(filename, = "/dev/cdrom") =3D=3D 0) {
+          =   io_iterator_t mediaIterator;
+          =   FindEjectableCDMedia(&mediaIterator);
+          =   if (bsdPath[0] =3D=3D '\0') {
+          =       printf("Error: failed to obtain bsd path for = optical drive!\n");
             } = else {
-              =   qemu_close(fd);
+              =   cdromOK =3D setupCDROM(bsdPath);
+        =         filename =3D bsdPath;
-            = qdict_put(options, "filename", qstring_from_str(filename));
 
-        if ( = mediaIterator )
-            = IOObjectRelease( mediaIterator );
+          =   if (mediaIterator) {
+          =       IOObjectRelease(mediaIterator);
+        = qdict_put(options, "filename", qstring_from_str(filename));
 #endif
 
@@ -2156,7 +2180,21 @@ static int = hdev_open(BlockDriverState *bs, QDict *options, int flags,
         }
+    }
+#if defined(__APPLE__) && = defined(__MACH__)
+    /* if a physical device experienced = an error while being opened */
+    if (strncmp(filename, = "/dev/", 5) =3D=3D 0 && (cdromOK =3D=3D false || ret !=3D 0)) = {
+              =           " first before using it in QEMU.\n", = filename);
+        printf("Command to = unmount device: diskutil unmountDisk %s\n",
+        =                     =                     =                     = filename);
+        printf("Command to = mount device: diskutil mountDisk %s\n", filename);
+#endif /* defined(__APPLE__) && = defined(__MACH__) */
+
+    if (ret < 0) {
+ =       return ret;
     }
 
     /* Since this = does ioctl the device must be already opened */
1.7.5.4

I = would like to know that status of this patch = please. 
= --Apple-Mail-1--55557131-- From MAILER-DAEMON Mon Sep 14 01:54:49 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbMj3-0008QN-Jn for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 01:54:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbMj0-0008M7-Ss for qemu-block@nongnu.org; Mon, 14 Sep 2015 01:54:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbMj0-0000jO-0q for qemu-block@nongnu.org; Mon, 14 Sep 2015 01:54:46 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:27504 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbMiu-0000CM-TJ; Mon, 14 Sep 2015 01:54:41 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2A+AgAWYPZV/5tjdVtdGQEBAYMHgT2pJgEBAQEBAQUBgQoBknwBDYdxAoEtOBQBAQEBAQEBgQqEJAEBAwE6PxALDhMlDwEsGwYBEhuICwwByXUBAQEBAQEBAwEBAQEBHYJPg12FRIUNB4QsAQSVV45Kh1SRXh8BAUKCQ4FAPDOKfQEBAQ X-IPAS-Result: A2A+AgAWYPZV/5tjdVtdGQEBAYMHgT2pJgEBAQEBAQUBgQoBknwBDYdxAoEtOBQBAQEBAQEBgQqEJAEBAwE6PxALDhMlDwEsGwYBEhuICwwByXUBAQEBAQEBAwEBAQEBHYJPg12FRIUNB4QsAQSVV45Kh1SRXh8BAUKCQ4FAPDOKfQEBAQ X-IronPort-AV: E=Sophos;i="5.17,526,1437429600"; d="scan'208";a="22479967" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 14 Sep 2015 07:54:03 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZbMiI-0006Zj-RE; Mon, 14 Sep 2015 07:54:02 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZbMiI-0005Yh-Lv; Mon, 14 Sep 2015 07:54:02 +0200 From: Alberto Garcia To: Max Reitz , Kevin Wolf In-Reply-To: <55F31075.7090101@redhat.com> References: <1be64a26c9a89ff0af4c2b1299d6c8b58361644a.1441890725.git.berto@igalia.com> <55F30DA8.4070502@redhat.com> <20150911172854.GC5164@noname.redhat.com> <55F31075.7090101@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Mon, 14 Sep 2015 07:54:02 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v3 2/4] block: Add 'ignore-backing' field to BlockdevOptionsGenericCOWFormat X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 05:54:47 -0000 On Fri 11 Sep 2015 07:33:41 PM CEST, Max Reitz wrote: >>> So why do we need the new flag? Because "backing: ''" is ugly? >> >> I guess it's just because you're the only one who actually reads the >> documentation. When discussing this, I didn't remember that we >> already had a way to express this (an additional bool wouldn't have >> been my favourite solution anyway). Thanks for catching this. > > I read the patch, it was part of the context. ;-) Oh, that was embarrassing :-) Yes, it was the discussion from two weeks ago about passing empty strings as BlockdevRef that made me think that this would be ugly. Anyway, was this ever implemented? It seems that passing a string to the 'backing' parameter is only specified in the JSON schema, but no one actually uses that. So I'll implement that for the next version of my series. Berto From MAILER-DAEMON Mon Sep 14 02:38:22 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbNPC-00074B-7z for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 02:38:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbNP9-00073y-EQ for qemu-block@nongnu.org; Mon, 14 Sep 2015 02:38:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbNP5-0001uA-9C for qemu-block@nongnu.org; Mon, 14 Sep 2015 02:38:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45757) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbNP5-0001tx-3e; Mon, 14 Sep 2015 02:38:15 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 0D9633B3C2; Mon, 14 Sep 2015 06:38:13 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8E6cBpQ013418; Mon, 14 Sep 2015 02:38:12 -0400 Date: Mon, 14 Sep 2015 14:38:10 +0800 From: Fam Zheng To: Eric Blake , ronnie sahlberg Message-ID: <20150914063810.GA31803@ad.nay.redhat.com> References: <1441951252-13439-1-git-send-email-famz@redhat.com> <55F2F141.3000809@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , Peter Lieven , qemu-devel , qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] iscsi: Add chap and "initiator-name" etc as per drive options X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 06:38:20 -0000 On Fri, 09/11 08:27, ronnie sahlberg wrote: > On Fri, Sep 11, 2015 at 8:20 AM, Eric Blake wrote: > > On 09/11/2015 12:00 AM, Fam Zheng wrote: > >> Previously we use "-iscsi id=target-iqn,user=foo,password=bar,..." to > >> specify iscsi connection parameters, unfortunately it doesn't work with > >> qemu-img. > >> > >> This patch adds per drive options to iscsi driver so that at least > >> qemu-img can use the "json:{...}" filename magic. > >> > >> Signed-off-by: Fam Zheng > >> --- > >> block/iscsi.c | 83 +++++++++++++++++++++++++++++++++++++++++++++-------------- > >> 1 file changed, 64 insertions(+), 19 deletions(-) > > > > It would be nice to also add a matching BlockdevOptionsIscsi to > > qapi/block-core.json, to allow setting these structured options from > > QMP. Separate patch is fine, but we need to do the work for ALL of the > > remaining block devices eventually, and now that you are structuring the > > command line is a good time to think about it. > > > > > >> static void iscsi_nop_timed_event(void *opaque) > >> @@ -1229,6 +1253,27 @@ static QemuOptsList runtime_opts = { > >> .name = "filename", > >> .type = QEMU_OPT_STRING, > >> .help = "URL to the iscsi image", > >> + },{ > >> + .name = "user", > >> + .type = QEMU_OPT_STRING, > >> + .help = "username for CHAP authentication to target", > >> + },{ > >> + .name = "password", > >> + .type = QEMU_OPT_STRING, > >> + .help = "password for CHAP authentication to target", > >> + },{ > > > > Also, this requires passing the password in the command line. We > > _really_ need to solve the problem of allowing the password to be passed > > via a fd or other QMP command, rather than on the command line. > > > Passing via command line is evil. It should still be possible to pass > all this via a config file to qemu : > > """ > ... > Howto use a configuration file to set iSCSI configuration options: > @example > cat >iscsi.conf < [iscsi "iqn.target.name"] > user = "me" > password = "my password" > initiator-name = "iqn.qemu.test:my-initiator" > header-digest = "CRC32C" > EOF > > qemu-system-i386 -drive file=iscsi://127.0.0.1/iqn.qemu.test/1 \ > -readconfig iscsi.conf > @end example > ... > """ I agree passing password with clear text command line is bad, but -readconfig doesn't work for qemu-img and qemu-io. Any idea how to make that work? Fam From MAILER-DAEMON Mon Sep 14 02:51:36 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbNc0-00012M-Qw for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 02:51:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbNbx-000107-Mn for qemu-block@nongnu.org; Mon, 14 Sep 2015 02:51:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbNbs-0006Gv-NF for qemu-block@nongnu.org; Mon, 14 Sep 2015 02:51:33 -0400 Received: from mx01.kamp.de ([82.141.2.16]:60413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbNbs-0006BQ-DX for qemu-block@nongnu.org; Mon, 14 Sep 2015 02:51:28 -0400 Received: (qmail 4501 invoked by uid 89); 14 Sep 2015 06:50:55 -0000 Received: from [195.62.97.28] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.7/20913. hbedv: 8.3.34.26/7.12.8.130. spamassassin: 3.4.0. Clear:RC:1(195.62.97.28):SA:0(4.1/5.0):. Processed in 1.934946 secs); 14 Sep 2015 06:50:55 -0000 Received: from smtp.kamp.de (HELO submission.kamp.de) ([195.62.97.28]) by mx01.kamp.de with ESMTPS (DHE-RSA-AES256-SHA encrypted); 14 Sep 2015 06:50:53 -0000 X-GL_Whitelist: yes Received: (qmail 2432 invoked from network); 14 Sep 2015 06:38:55 -0000 Received: from unknown (HELO ?10.113.230.194?) (pl@kamp.de@94.144.63.102) by submission.kamp.de with ESMTPS (DHE-RSA-AES256-SHA encrypted) ESMTPA; 14 Sep 2015 06:38:55 -0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) From: Peter Lieven X-Mailer: iPhone Mail (12H321) In-Reply-To: <20150914063810.GA31803@ad.nay.redhat.com> Date: Mon, 14 Sep 2015 08:50:50 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <1441951252-13439-1-git-send-email-famz@redhat.com> <55F2F141.3000809@redhat.com> <20150914063810.GA31803@ad.nay.redhat.com> To: Fam Zheng X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 82.141.2.16 Cc: Kevin Wolf , "qemu-block@nongnu.org" , qemu-devel , ronnie sahlberg , Paolo Bonzini Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] iscsi: Add chap and "initiator-name" etc as per drive options X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 06:51:35 -0000 > Am 14.09.2015 um 08:38 schrieb Fam Zheng : >=20 >> On Fri, 09/11 08:27, ronnie sahlberg wrote: >>> On Fri, Sep 11, 2015 at 8:20 AM, Eric Blake wrote: >>>> On 09/11/2015 12:00 AM, Fam Zheng wrote: >>>> Previously we use "-iscsi id=3Dtarget-iqn,user=3Dfoo,password=3Dbar,...= " to >>>> specify iscsi connection parameters, unfortunately it doesn't work with= >>>> qemu-img. >>>>=20 >>>> This patch adds per drive options to iscsi driver so that at least >>>> qemu-img can use the "json:{...}" filename magic. >>>>=20 >>>> Signed-off-by: Fam Zheng >>>> --- >>>> block/iscsi.c | 83 +++++++++++++++++++++++++++++++++++++++++++++-------= ------- >>>> 1 file changed, 64 insertions(+), 19 deletions(-) >>>=20 >>> It would be nice to also add a matching BlockdevOptionsIscsi to >>> qapi/block-core.json, to allow setting these structured options from >>> QMP. Separate patch is fine, but we need to do the work for ALL of the >>> remaining block devices eventually, and now that you are structuring the= >>> command line is a good time to think about it. >>>=20 >>>=20 >>>> static void iscsi_nop_timed_event(void *opaque) >>>> @@ -1229,6 +1253,27 @@ static QemuOptsList runtime_opts =3D { >>>> .name =3D "filename", >>>> .type =3D QEMU_OPT_STRING, >>>> .help =3D "URL to the iscsi image", >>>> + },{ >>>> + .name =3D "user", >>>> + .type =3D QEMU_OPT_STRING, >>>> + .help =3D "username for CHAP authentication to target", >>>> + },{ >>>> + .name =3D "password", >>>> + .type =3D QEMU_OPT_STRING, >>>> + .help =3D "password for CHAP authentication to target", >>>> + },{ >>>=20 >>> Also, this requires passing the password in the command line. We >>> _really_ need to solve the problem of allowing the password to be passed= >>> via a fd or other QMP command, rather than on the command line. >>=20 >>=20 >> Passing via command line is evil. It should still be possible to pass >> all this via a config file to qemu : >>=20 >> """ >> ... >> Howto use a configuration file to set iSCSI configuration options: >> @example >> cat >iscsi.conf <> [iscsi "iqn.target.name"] >> user =3D "me" >> password =3D "my password" >> initiator-name =3D "iqn.qemu.test:my-initiator" >> header-digest =3D "CRC32C" >> EOF >>=20 >> qemu-system-i386 -drive file=3Discsi://127.0.0.1/iqn.qemu.test/1 \ >> -readconfig iscsi.conf >> @end example >> ... >> """ >=20 > I agree passing password with clear text command line is bad, but -readcon= fig > doesn't work for qemu-img and qemu-io. Any idea how to make that work? you can pass the secrets via environment variables (see libiscsi readme). Peter From MAILER-DAEMON Mon Sep 14 03:27:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbOAu-0001De-GJ for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 03:27:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbOAs-0001AA-4K for qemu-block@nongnu.org; Mon, 14 Sep 2015 03:27:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbOAo-0005HC-Rx for qemu-block@nongnu.org; Mon, 14 Sep 2015 03:27:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45301) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbOAo-0005Gz-LM; Mon, 14 Sep 2015 03:27:34 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 528E3C0B2010; Mon, 14 Sep 2015 07:27:34 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8E7RVKs011173; Mon, 14 Sep 2015 03:27:32 -0400 Date: Mon, 14 Sep 2015 15:27:30 +0800 From: Fam Zheng To: Kevin Wolf Message-ID: <20150914072730.GB31803@ad.nay.redhat.com> References: <1438144934-23619-1-git-send-email-famz@redhat.com> <20150911103926.GA5164@noname.redhat.com> <20150911114653.GA11386@ad.nay.redhat.com> <20150911122214.GB5164@noname.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150911122214.GB5164@noname.redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 00/11] aio: Introduce handler type to fix nested aio_poll for dataplane X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 07:27:39 -0000 On Fri, 09/11 14:22, Kevin Wolf wrote: > Am 11.09.2015 um 13:46 hat Fam Zheng geschrieben: > > On Fri, 09/11 12:39, Kevin Wolf wrote: > > > Am 29.07.2015 um 06:42 hat Fam Zheng geschrieben: > > > > v2: Switch to disable/enable model. [Paolo] > > > > > > > > Most existing nested aio_poll()'s in block layer are inconsiderate of > > > > dispatching potential new r/w requests from ioeventfds and nbd exports, which > > > > might result in responsiveness issues (e.g. bdrv_drain_all will not return when > > > > new requests keep coming), or even wrong semantics (e.g. qmp_transaction cannot > > > > enforce atomicity due to aio_poll in bdrv_drain_all). > > > > > > > > Previous attampts to address this issue include new op blocker[1], bdrv_lock[2] > > > > and nested AioContext (patches not posted to qemu-devel). > > > > > > > > This approach is based on the idea proposed by Paolo Bonzini. The original idea > > > > is introducing "aio_context_disable_client / aio_context_enable_client to > > > > filter AioContext handlers according to the "client", e.g. > > > > AIO_CLIENT_DATAPLANE (ioeventfd), AIO_CLIENT_PROTOCOL, AIO_CLIENT_NBD_SERVER, > > > > AIO_CLIENT_CONTEXT, ... Extend aio_set_{event_notifier,fd}_handler to pass a > > > > client (type)." > > > > > > > > After this series, block layer aio_poll() will only process those "protocol" > > > > fds that are used in block I/O, plus the ctx->notifier for aio_notify(); other > > > > aio_poll()'s keep unchanged. > > > > > > > > The biggest advantage over approaches [1] and [2] is, no change is needed in > > > > virtio-{blk,scsi}-dataplane code, also this doesn't depend on converting QMP to > > > > coroutines. > > > > > > It seems that I haven't replied on the mailing list yet, even though I > > > think I already said this in person at KVM Forum: This series fixes only > > > a special case of the real problem, which is that bdrv_drain/all at a > > > single point doesn't make a lot of sense, but needs to be replaced by a > > > whole section with exclusive access, like a bdrv_drained_begin/end pair. > > > > > > To be clear: Anything that works with types of users instead of > > > individual users is bound to fall short of being a complete solution. I > > > don't prefer partial solutions when we know there is a bigger problem. > > > > > > This series addresses your immediate need of protecting against new data > > > plane requests, which it arguably achieves. The second case I always > > > have in mind is Berto's case where he has multiple streaming block jobs > > > in the same backing file chain [1]. > > > > > > This involves a bdrv_reopen() of the target BDS to make it writable, and > > > bdrv_reopen() uses bdrv_drain_all() so drivers don't have to cope with > > > running requests while reopening themselves. It can however involve > > > nested event loops for synchronous operations like bdrv_flush(), and if > > > those can process completions of block jobs, which can respond by doing > > > anything to the respective node, things can go wrong. > > > > Just to get a better idea of bdrv_drained_begin/end, could you explain how to > > use the pair to fix the above problem? > > How to use it is easy part: In bdrv_reopen_multiple(), you would replace > the existing bdrv_drain_all() with begin and you would add the > corresponding end right before the return statement. OK, so that the completion of other jobs won't happen because we only complete the relevant requests? Does block_job_pause() work here? > > > > You don't solve this by adding client types (then problematic request > > > would be PROTOCOL in your proposal and you can never exclude that), but > > > you really need to have bdrv_drained_being/end pairs, where only > > > requests issued in between are processed and everything else waits. > > > > What do you mean by "only requests issued in between are processed"? Where are > > the requests from? > > Generally speaking, you would have code that looks like this: > > bdrv_drain_begin() > ... > bdrv_something_synchronous() > ... > bdrv_drain_end() > > You want to process everything that is necessary for completing > bdrv_something_synchronous(), but nothing else. > > The trickier question is how to implement this. I know that it's much > easier to say that your series doesn't work than actually proposing > something else that works... I see the basic idea but that is still way too obscure. How would bdrv_draind_begin/end know what is necessary in completing bdrv_something_synchronous()? > > One relatively obvious answer we found when we discussed this a while > back was some kind of a recursive CoRwLock (reader = in-flight request; > writer = drained section), but that requires obviously that you're > running in a coroutine if you want to do something with a drained > request queue. > > I'm also not totally happy with the requirement of taking a reader lock > more or less everywhere. But I'm not sure yet if there is a good > alternative that can achieve the same. We're basically trying to prevent new requests from being submitted, but couldn't this blocking be a complication itself? A CoRwLock, if any, would be implemented with something like a CoQueue, but considering the existing CoQueue in BDS - throttled_reqs, aren't those what we want to keep *empty* between the bdrv_drain_begin/end pair? Now we're talking about queueing requests to another CoQueue, which feels contradictory to me. Fam From MAILER-DAEMON Mon Sep 14 04:40:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbPJe-0000iQ-Vz for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 04:40:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbPJc-0000iI-6G for qemu-block@nongnu.org; Mon, 14 Sep 2015 04:40:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbPJW-0003Yc-Na for qemu-block@nongnu.org; Mon, 14 Sep 2015 04:40:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51421) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbPJW-0003YE-8C; Mon, 14 Sep 2015 04:40:38 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 47ED02D1260; Mon, 14 Sep 2015 08:40:37 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8E8eZZv006917; Mon, 14 Sep 2015 04:40:36 -0400 Date: Mon, 14 Sep 2015 10:40:35 +0200 From: Kevin Wolf To: Fam Zheng Message-ID: <20150914084035.GA3550@noname.str.redhat.com> References: <1438144934-23619-1-git-send-email-famz@redhat.com> <20150911103926.GA5164@noname.redhat.com> <20150911114653.GA11386@ad.nay.redhat.com> <20150911122214.GB5164@noname.redhat.com> <20150914072730.GB31803@ad.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150914072730.GB31803@ad.nay.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 00/11] aio: Introduce handler type to fix nested aio_poll for dataplane X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 08:40:45 -0000 Am 14.09.2015 um 09:27 hat Fam Zheng geschrieben: > On Fri, 09/11 14:22, Kevin Wolf wrote: > > Am 11.09.2015 um 13:46 hat Fam Zheng geschrieben: > > > On Fri, 09/11 12:39, Kevin Wolf wrote: > > > > Am 29.07.2015 um 06:42 hat Fam Zheng geschrieben: > > > > > v2: Switch to disable/enable model. [Paolo] > > > > > > > > > > Most existing nested aio_poll()'s in block layer are inconsiderate of > > > > > dispatching potential new r/w requests from ioeventfds and nbd exports, which > > > > > might result in responsiveness issues (e.g. bdrv_drain_all will not return when > > > > > new requests keep coming), or even wrong semantics (e.g. qmp_transaction cannot > > > > > enforce atomicity due to aio_poll in bdrv_drain_all). > > > > > > > > > > Previous attampts to address this issue include new op blocker[1], bdrv_lock[2] > > > > > and nested AioContext (patches not posted to qemu-devel). > > > > > > > > > > This approach is based on the idea proposed by Paolo Bonzini. The original idea > > > > > is introducing "aio_context_disable_client / aio_context_enable_client to > > > > > filter AioContext handlers according to the "client", e.g. > > > > > AIO_CLIENT_DATAPLANE (ioeventfd), AIO_CLIENT_PROTOCOL, AIO_CLIENT_NBD_SERVER, > > > > > AIO_CLIENT_CONTEXT, ... Extend aio_set_{event_notifier,fd}_handler to pass a > > > > > client (type)." > > > > > > > > > > After this series, block layer aio_poll() will only process those "protocol" > > > > > fds that are used in block I/O, plus the ctx->notifier for aio_notify(); other > > > > > aio_poll()'s keep unchanged. > > > > > > > > > > The biggest advantage over approaches [1] and [2] is, no change is needed in > > > > > virtio-{blk,scsi}-dataplane code, also this doesn't depend on converting QMP to > > > > > coroutines. > > > > > > > > It seems that I haven't replied on the mailing list yet, even though I > > > > think I already said this in person at KVM Forum: This series fixes only > > > > a special case of the real problem, which is that bdrv_drain/all at a > > > > single point doesn't make a lot of sense, but needs to be replaced by a > > > > whole section with exclusive access, like a bdrv_drained_begin/end pair. > > > > > > > > To be clear: Anything that works with types of users instead of > > > > individual users is bound to fall short of being a complete solution. I > > > > don't prefer partial solutions when we know there is a bigger problem. > > > > > > > > This series addresses your immediate need of protecting against new data > > > > plane requests, which it arguably achieves. The second case I always > > > > have in mind is Berto's case where he has multiple streaming block jobs > > > > in the same backing file chain [1]. > > > > > > > > This involves a bdrv_reopen() of the target BDS to make it writable, and > > > > bdrv_reopen() uses bdrv_drain_all() so drivers don't have to cope with > > > > running requests while reopening themselves. It can however involve > > > > nested event loops for synchronous operations like bdrv_flush(), and if > > > > those can process completions of block jobs, which can respond by doing > > > > anything to the respective node, things can go wrong. > > > > > > Just to get a better idea of bdrv_drained_begin/end, could you explain how to > > > use the pair to fix the above problem? > > > > How to use it is easy part: In bdrv_reopen_multiple(), you would replace > > the existing bdrv_drain_all() with begin and you would add the > > corresponding end right before the return statement. > > OK, so that the completion of other jobs won't happen because we only complete > the relevant requests? > > Does block_job_pause() work here? If you find all block jobs that do something with the BDS, block_job_pause() would work, yes. But if you go further down that road, you end up not with a design that considers the problem, but with special casing every single user. That doesn't feel very sustainable. > > > > You don't solve this by adding client types (then problematic request > > > > would be PROTOCOL in your proposal and you can never exclude that), but > > > > you really need to have bdrv_drained_being/end pairs, where only > > > > requests issued in between are processed and everything else waits. > > > > > > What do you mean by "only requests issued in between are processed"? Where are > > > the requests from? > > > > Generally speaking, you would have code that looks like this: > > > > bdrv_drain_begin() > > ... > > bdrv_something_synchronous() > > ... > > bdrv_drain_end() > > > > You want to process everything that is necessary for completing > > bdrv_something_synchronous(), but nothing else. > > > > The trickier question is how to implement this. I know that it's much > > easier to say that your series doesn't work than actually proposing > > something else that works... > > I see the basic idea but that is still way too obscure. How would > bdrv_draind_begin/end know what is necessary in completing > bdrv_something_synchronous()? That's not about the interface, but the implementation part, which I tried to answer below. > > One relatively obvious answer we found when we discussed this a while > > back was some kind of a recursive CoRwLock (reader = in-flight request; > > writer = drained section), but that requires obviously that you're > > running in a coroutine if you want to do something with a drained > > request queue. > > > > I'm also not totally happy with the requirement of taking a reader lock > > more or less everywhere. But I'm not sure yet if there is a good > > alternative that can achieve the same. > > We're basically trying to prevent new requests from being submitted, but > couldn't this blocking be a complication itself? A CoRwLock, if any, would be > implemented with something like a CoQueue, but considering the existing CoQueue > in BDS - throttled_reqs, aren't those what we want to keep *empty* between the > bdrv_drain_begin/end pair? Now we're talking about queueing requests to > another CoQueue, which feels contradictory to me. You always queue requests _somewhere_. If they aren't queued in the block layer, they are in the virtio ring or elsewhere. I think the point of bdrv_drain() is that the block drivers don't have any pending requests; they can be queued elsewhere without hurting anyone. Kevin From MAILER-DAEMON Mon Sep 14 04:46:05 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbPOn-0002YK-Tk for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 04:46:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbPOl-0002YA-PP for qemu-block@nongnu.org; Mon, 14 Sep 2015 04:46:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbPOg-0005Pr-Pe for qemu-block@nongnu.org; Mon, 14 Sep 2015 04:46:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35130) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbPOg-0005Pj-Ke; Mon, 14 Sep 2015 04:45:58 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 1AF63C0B919C; Mon, 14 Sep 2015 08:45:57 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8E8jtku010537; Mon, 14 Sep 2015 04:45:56 -0400 Date: Mon, 14 Sep 2015 10:45:55 +0200 From: Kevin Wolf To: Alberto Garcia Message-ID: <20150914084555.GB3550@noname.str.redhat.com> References: <1be64a26c9a89ff0af4c2b1299d6c8b58361644a.1441890725.git.berto@igalia.com> <55F30DA8.4070502@redhat.com> <20150911172854.GC5164@noname.redhat.com> <55F31075.7090101@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v3 2/4] block: Add 'ignore-backing' field to BlockdevOptionsGenericCOWFormat X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 08:46:04 -0000 Am 14.09.2015 um 07:54 hat Alberto Garcia geschrieben: > On Fri 11 Sep 2015 07:33:41 PM CEST, Max Reitz wrote: > > >>> So why do we need the new flag? Because "backing: ''" is ugly? > >> > >> I guess it's just because you're the only one who actually reads the > >> documentation. When discussing this, I didn't remember that we > >> already had a way to express this (an additional bool wouldn't have > >> been my favourite solution anyway). Thanks for catching this. > > > > I read the patch, it was part of the context. ;-) > > Oh, that was embarrassing :-) Yes, it was the discussion from two weeks > ago about passing empty strings as BlockdevRef that made me think that > this would be ugly. > > Anyway, was this ever implemented? It seems that passing a string to the > 'backing' parameter is only specified in the JSON schema, but no one > actually uses that. > > So I'll implement that for the next version of my series. I have a patch that actually allows passing a node-name reference as a string here. v1 was posted a few months ago; it just turned out that I need to kill bdrv_swap() before that can work because bdrv_swap() doesn't work with nodes that have a BlockBackend attached. Of course, I didn't check what an empty string would do with my patch... Kevin From MAILER-DAEMON Mon Sep 14 05:46:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbQLH-0007Kl-IC for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 05:46:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbQLF-0007Jy-Jf for qemu-block@nongnu.org; Mon, 14 Sep 2015 05:46:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbQLC-0004ZA-CJ for qemu-block@nongnu.org; Mon, 14 Sep 2015 05:46:29 -0400 Received: from mail-vk0-f51.google.com ([209.85.213.51]:34247) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbQLC-0004Xw-8p for qemu-block@nongnu.org; Mon, 14 Sep 2015 05:46:26 -0400 Received: by vkhf67 with SMTP id f67so55709927vkh.1 for ; Mon, 14 Sep 2015 02:46:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=LudEFUyGGLJKdRRGeDTvvTAUtdDXXkI3xn5wvJre3vA=; b=ErrLvlJ2HAQ98XyXkH0jEz7grIFyW6qPJUKCUAwCxWQ+aa6faw4JIb8OE6awg4Yf62 YH8x8b+051edxI+pNkbz6uDlkQUHucRGx4eWem37P4m51m15IounKqO+YG3kykbhU/mK HP5Xls48G1rOfJxLeA7teXFXpGQkUcwnISDW21zpGvo2+sBSLm9/141mefJTJbI9VDzy xlvAo0wXB89TjwJEjsScaRHzh3m+L+BxKpX3/ojTiYxnlJlBcgBXEKG3Wy4A26KmnbLq jR3v37KxVmSIBVjq3Nur0r9BBUl+5TV0YwUukF4LkmaSXesUpMaVzJSl419B8AnujZnI UZtQ== X-Gm-Message-State: ALoCoQmK5CLn9V+4apY1wBBeGxNt3Y8RrbWKSwHPHDw50a/PnAZMTgBmH4Q7a5ho/n1SHFsh1PS0 X-Received: by 10.31.14.71 with SMTP id 68mr12420993vko.82.1442223985516; Mon, 14 Sep 2015 02:46:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.153.15 with HTTP; Mon, 14 Sep 2015 02:46:06 -0700 (PDT) In-Reply-To: <1442000463-22777-1-git-send-email-kwolf@redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> From: Peter Maydell Date: Mon, 14 Sep 2015 10:46:06 +0100 Message-ID: To: Kevin Wolf Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.213.51 Cc: QEMU Developers , Qemu-block Subject: Re: [Qemu-block] [Qemu-devel] [PULL 00/23] Block layer patches X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 09:46:30 -0000 On 11 September 2015 at 20:40, Kevin Wolf wrote: > The following changes since commit 30c38c90bd3f1bb105ebc069ac1821067c980b= 7c: > > scripts/qemu-gdb: Add brief comment describing usage (2015-09-11 17:14:= 50 +0100) > > are available in the git repository at: > > git://repo.or.cz/qemu/kevin.git tags/for-upstream > > for you to fetch changes up to 1fcbcc93872953d08cd35830d1169fed19196290: > > qcow2: Make qcow2_alloc_bytes() more explicit (2015-09-11 20:03:02 +020= 0) > > ---------------------------------------------------------------- > Block layer patches > > ---------------------------------------------------------------- Hi. I'm afraid this fails to build on 32-bit: /home/pm215/qemu/block/qcow2-refcount.c: In function =E2=80=98realloc_refco= unt_array=E2=80=99: /home/pm215/qemu/block/qcow2-refcount.c:1294:16: error: cast to pointer from integer of different size [-Werror=3Dint-to-pointer-cast] memset((void *)((uintptr_t)new_ptr + old_byte_size), 0, ^ cc1: all warnings being treated as errors /home/pm215/qemu/rules.mak:57: recipe for target 'block/qcow2-refcount.o' f= ailed make: *** [block/qcow2-refcount.o] Error 1 (old_byte_size is int64_t, so (uintptr_t)new_ptr + old_byte_size becomes a 64-bit addition, and then you cast it to a 32-bit pointer.) thanks -- PMM From MAILER-DAEMON Mon Sep 14 05:57:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbQVf-0002uY-Oo for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 05:57:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37522) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbQVd-0002ti-Iq for qemu-block@nongnu.org; Mon, 14 Sep 2015 05:57:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbQVY-0003Od-Gm for qemu-block@nongnu.org; Mon, 14 Sep 2015 05:57:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38844) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbQVY-0003NH-C2; Mon, 14 Sep 2015 05:57:08 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B900891C02; Mon, 14 Sep 2015 09:57:07 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8E9v53i009778; Mon, 14 Sep 2015 05:57:06 -0400 Date: Mon, 14 Sep 2015 11:57:05 +0200 From: Kevin Wolf To: Peter Maydell Message-ID: <20150914095705.GC3550@noname.str.redhat.com> References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: QEMU Developers , Qemu-block , mreitz@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PULL 00/23] Block layer patches X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 09:57:14 -0000 Am 14.09.2015 um 11:46 hat Peter Maydell geschrieben: > On 11 September 2015 at 20:40, Kevin Wolf wrote: > > The following changes since commit 30c38c90bd3f1bb105ebc069ac1821067c= 980b7c: > > > > scripts/qemu-gdb: Add brief comment describing usage (2015-09-11 17= :14:50 +0100) > > > > are available in the git repository at: > > > > git://repo.or.cz/qemu/kevin.git tags/for-upstream > > > > for you to fetch changes up to 1fcbcc93872953d08cd35830d1169fed191962= 90: > > > > qcow2: Make qcow2_alloc_bytes() more explicit (2015-09-11 20:03:02 = +0200) > > > > ---------------------------------------------------------------- > > Block layer patches > > > > ---------------------------------------------------------------- >=20 > Hi. I'm afraid this fails to build on 32-bit: >=20 > /home/pm215/qemu/block/qcow2-refcount.c: In function =E2=80=98realloc_r= efcount_array=E2=80=99: > /home/pm215/qemu/block/qcow2-refcount.c:1294:16: error: cast to > pointer from integer of different size [-Werror=3Dint-to-pointer-cast] > memset((void *)((uintptr_t)new_ptr + old_byte_size), 0, > ^ > cc1: all warnings being treated as errors > /home/pm215/qemu/rules.mak:57: recipe for target 'block/qcow2-refcount.= o' failed > make: *** [block/qcow2-refcount.o] Error 1 >=20 > (old_byte_size is int64_t, so (uintptr_t)new_ptr + old_byte_size > becomes a 64-bit addition, and then you cast it to a 32-bit > pointer.) Max, I think this is yours. Kevin From MAILER-DAEMON Mon Sep 14 10:08:19 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbUQd-0004nK-El for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 10:08:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUQa-0004iD-Q6 for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:08:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbUQZ-0003Si-KV for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:08:16 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:43266 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUQU-0003P0-C6; Mon, 14 Sep 2015 10:08:10 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CsAgAP1PZV/5tjdVtdGQEBAYMHVGmpLAEBAQEBAQUBgQoBknwBDYFMIgqFeQKBNjgUAQEBAQEBAYEKhCQBAQEDAQI3PxALDhMlDwEYFBsGAYhEAQjKFAEBAQEBAQEBAQEBAQEBAQEYBIYshUSFDQeELAWMeIhfhQ2CboIhnWAfAQFCghEcgVY8MwGKfAEBAQ X-IPAS-Result: A2CsAgAP1PZV/5tjdVtdGQEBAYMHVGmpLAEBAQEBAQUBgQoBknwBDYFMIgqFeQKBNjgUAQEBAQEBAYEKhCQBAQEDAQI3PxALDhMlDwEYFBsGAYhEAQjKFAEBAQEBAQEBAQEBAQEBAQEYBIYshUSFDQeELAWMeIhfhQ2CboIhnWAfAQFCghEcgVY8MwGKfAEBAQ X-IronPort-AV: E=Sophos;i="5.17,528,1437429600"; d="scan'208";a="21670939" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 14 Sep 2015 16:08:08 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZbUQS-0003W9-4e; Mon, 14 Sep 2015 16:08:08 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZbUQR-0001pV-Ut; Mon, 14 Sep 2015 16:08:08 +0200 From: Alberto Garcia To: Eric Blake , qemu-devel@nongnu.org In-Reply-To: <55F31633.6010800@redhat.com> References: <40f3f51fb44da70929f7055e95582351d1aa3f34.1441890725.git.berto@igalia.com> <55F31633.6010800@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Mon, 14 Sep 2015 16:08:07 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v3 3/4] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 14:08:18 -0000 On Fri 11 Sep 2015 07:58:11 PM CEST, Eric Blake wrote: >> +void qmp_blockdev_snapshot(const char *device, const char *snapshot, >> + Error **errp) >> +{ >> + BlockdevSnapshot snapshot_data = { >> + .device = (char *) device, >> + .snapshot = (char *) snapshot >> + }; > > Hmm. Sounds like you'd love to use my pending 'box':true qapi glue to > make this function have the saner signature of > > void qmp_blockdev_snapshot(BlockdevSnapshot *arg, Error **errp); > > rather than having to rebuild the struct yourself (with an annoying > cast to lose const) :) > https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg02599.html That's cool! We can simplify this later as you suggest. >> +Create a snapshot, by installing 'device' as the backing image of >> +'snapshot'. Additionally, if 'device' is associated with a block >> +device, the block device changes to using 'snapshot' as its new >> +active image. > > Still didn't answer the question from the earlier review of whether > the blockdev-snapshot-sync behavior of specifying the node name of an > active layer in order to not pivot the block device to the snapshot > still makes sense to support in the blockdev-snapshot case. Sorry if I overlooked the explanation, but I still didn't get the use case for this. And particularly for this command, that doesn't create any image but simply uses a previously-opened one. What would 'pivot': false do ? As far as I can see, specifying the node name of an active layer in blockdev-snapshot-sync seems to pivot the block device to the snapshot. { "execute": "blockdev-snapshot-sync", "arguments": { "node-name": "hd0", "snapshot-file": "hd1.qcow2", "snapshot-node-name": "hd1" } } (qemu) info block virtio0 (hd1): hd1.qcow2 (qcow2) Cache mode: writeback Backing file: hd0.qcow2 (chain depth: 1) Berto From MAILER-DAEMON Mon Sep 14 10:20:45 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbUce-0003Lh-81 for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 10:20:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUcY-0003Fd-6Y for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:20:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbUcU-000733-Dk for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:20:38 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:36648 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUcL-0006up-TW; Mon, 14 Sep 2015 10:20:26 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CqAgBC1vZV/5tjdVtdGQEBAYMHqmgBAQEBAQEFAYEKAZJ8AQ2FG4JWAoE2OBQBAQEBAQEBgQqEJAEBBDo/EAsOEyUPASwbBohFAcocAQEBAQEBBAEBAQEegk+DXYVEhQ0HhCwBBIx4iF+nfB8BAUKCQ4FAPIswAQEB X-IPAS-Result: A2CqAgBC1vZV/5tjdVtdGQEBAYMHqmgBAQEBAQEFAYEKAZJ8AQ2FG4JWAoE2OBQBAQEBAQEBgQqEJAEBBDo/EAsOEyUPASwbBohFAcocAQEBAQEBBAEBAQEegk+DXYVEhQ0HhCwBBIx4iF+nfB8BAUKCQ4FAPIswAQEB X-IronPort-AV: E=Sophos;i="5.17,528,1437429600"; d="scan'208";a="21676833" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 14 Sep 2015 16:20:13 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZbUc8-0003c0-DX; Mon, 14 Sep 2015 16:20:12 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZbUc8-0004eP-7Z; Mon, 14 Sep 2015 16:20:12 +0200 From: Alberto Garcia To: Kevin Wolf In-Reply-To: <20150914084555.GB3550@noname.str.redhat.com> References: <1be64a26c9a89ff0af4c2b1299d6c8b58361644a.1441890725.git.berto@igalia.com> <55F30DA8.4070502@redhat.com> <20150911172854.GC5164@noname.redhat.com> <55F31075.7090101@redhat.com> <20150914084555.GB3550@noname.str.redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Mon, 14 Sep 2015 16:20:12 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v3 2/4] block: Add 'ignore-backing' field to BlockdevOptionsGenericCOWFormat X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 14:20:42 -0000 On Mon 14 Sep 2015 10:45:55 AM CEST, Kevin Wolf wrote: >> >>> So why do we need the new flag? Because "backing: ''" is ugly? >> >> Anyway, was this ever implemented? It seems that passing a string to >> the 'backing' parameter is only specified in the JSON schema, but no >> one actually uses that. >> > I have a patch that actually allows passing a node-name reference as a > string here. v1 was posted a few months ago; it just turned out that I > need to kill bdrv_swap() before that can work because bdrv_swap() > doesn't work with nodes that have a BlockBackend attached. But there was no way to open a BDS without having a BlockBackend attached, or was there? It's possible with Max's "BlockBackend and media" series, that's why I am using it. Berto From MAILER-DAEMON Mon Sep 14 10:28:03 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbUji-0005xZ-W8 for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 10:28:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUjc-0005wp-UM for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:28:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbUjZ-0002Q7-Io for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:27:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47058) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUjZ-0002Q1-BH; Mon, 14 Sep 2015 10:27:53 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id D5F7B8C1A3; Mon, 14 Sep 2015 14:27:52 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-64.ams2.redhat.com [10.36.116.64]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EERo9d016549 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 14 Sep 2015 10:27:52 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 28709303F90D; Mon, 14 Sep 2015 16:27:50 +0200 (CEST) From: Markus Armbruster To: Wen Congyang References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> Date: Mon, 14 Sep 2015 16:27:50 +0200 In-Reply-To: <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> (Wen Congyang's message of "Thu, 10 Sep 2015 17:55:01 +0800") Message-ID: <87r3m1krdl.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 14:28:01 -0000 Wen Congyang writes: > The NBD driver needs: filename, path or (host, port, exportname). > It checks which key exists and decides use unix or inet socket. > It doesn't recognize the key type, so we can't use union, and > can't reuse InetSocketAddress. > > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei > --- > qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 40 insertions(+), 2 deletions(-) > > diff --git a/qapi/block-core.json b/qapi/block-core.json > index 11134a8..e68a59f 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -1376,12 +1376,14 @@ > # > # @host_device, @host_cdrom: Since 2.1 > # > +# @nbd: Since 2.5 > +# > # Since: 2.0 > ## > { 'enum': 'BlockdevDriver', > 'data': [ 'archipelago', 'blkdebug', 'blkverify', 'bochs', 'cloop', > 'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device', > - 'http', 'https', 'null-aio', 'null-co', 'parallels', > + 'http', 'https', 'nbd', 'null-aio', 'null-co', 'parallels', > 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx', > 'vmdk', 'vpc', 'vvfat' ] } > > @@ -1797,6 +1799,42 @@ > '*read-pattern': 'QuorumReadPattern' } } > > ## > +# @BlockdevOptionsNBD > +# > +# Driver specific block device options for NBD > +# > +# @filename: #optional unix or inet path. The format is: > +# unix: nbd+unix:///export?socket=path or > +# nbd:unix:path:exportname=export > +# inet: nbd[+tcp]://host[:port]/export or > +# nbd:host[:port]:exportname=export > +# > +# @path: #optional filesystem path to use > +# > +# @host: #optional host part of the address > +# > +# @port: #optional port part of the address > +# > +# @ipv4: #optional whether to accept IPv4 addresses, default try both IPv4 > +# and IPv6 > +# > +# @ipv6: #optional whether to accept IPv6 addresses, default try both IPv4 > +# and IPv6 > +# > +# @export: #optional the NBD export name > +# > +# Since: 2.5 > +## > +{ 'struct': 'BlockdevOptionsNBD', > + 'data': { '*filename': 'str', > + '*path': 'str', > + '*host': 'str', > + '*port': 'str', > + '*ipv4': 'bool', > + '*ipv6': 'bool', > + '*export': 'str' } } > + > +## I'm afraid this doesn't address Eric's review of your v2. In v2, you had { 'struct': 'BlockdevOptionsNBD', 'base': 'InetSocketAddress', 'data': { '*export': 'str' } } Eric observed that InetSocketAddress can represent a port range. Since NBD doesn't support a range, he suggested to have two types rather than InetSocketAddress: one to represent a single port, and another one to represent a port range. He further suggested to make the single port type a base type of the port range type. Eric further observed that support for the nbd+unix transport was missing, and suggested to have a union type combining the various transports. Instead of that, you simply replaced InetSocketAddress by a bunch of optional arguments with (unspoken!) conditions, such as "either filename, or path+host". That's not how we want things done in the schema. If we decide we want types separate for single ports and port range, you need those two types. For either one, you need a union type combining transports. It already exists for port ranges: SocketAddress. You need to create the other. We can then discuss names. For me, InetSocketAddress and SocketAddress strongly suggest single port. I'd prefer naming the port range types *AddressRange or something. If we decide separate types for single port and port ranges aren't worthwhile, you can simply use SocketAddress where your v2 used InetSocketAddress. Eric, how strongly do you feel about separating the two? > # @BlockdevOptions > # > # Options for creating a block device. > @@ -1822,7 +1860,7 @@ > 'http': 'BlockdevOptionsFile', > 'https': 'BlockdevOptionsFile', > # TODO iscsi: Wait for structured options > -# TODO nbd: Should take InetSocketAddress for 'host'? > + 'nbd': 'BlockdevOptionsNBD', > # TODO nfs: Wait for structured options > 'null-aio': 'BlockdevOptionsNull', > 'null-co': 'BlockdevOptionsNull', From MAILER-DAEMON Mon Sep 14 10:37:06 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbUsU-0005SZ-8l for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 10:37:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUsL-0005LA-T0 for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:37:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbUsH-00062M-TZ for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:36:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40530) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUsH-000629-KO; Mon, 14 Sep 2015 10:36:53 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id CCFE4A063B; Mon, 14 Sep 2015 14:36:52 +0000 (UTC) Received: from [10.36.116.86] (ovpn-116-86.ams2.redhat.com [10.36.116.86]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EEamsJ025653 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 14 Sep 2015 10:36:50 -0400 To: Kevin Wolf , Peter Maydell References: <1442000463-22777-1-git-send-email-kwolf@redhat.com> <20150914095705.GC3550@noname.str.redhat.com> From: Max Reitz Message-ID: <55F6DB80.8030905@redhat.com> Date: Mon, 14 Sep 2015 16:36:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150914095705.GC3550@noname.str.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="cOVLqGX8XBk4DVKl1WCfFVPUnEaK8f4fG" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: QEMU Developers , Qemu-block Subject: Re: [Qemu-block] [Qemu-devel] [PULL 00/23] Block layer patches X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 14:37:03 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --cOVLqGX8XBk4DVKl1WCfFVPUnEaK8f4fG Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 14.09.2015 11:57, Kevin Wolf wrote: > Am 14.09.2015 um 11:46 hat Peter Maydell geschrieben: >> On 11 September 2015 at 20:40, Kevin Wolf wrote: >>> The following changes since commit 30c38c90bd3f1bb105ebc069ac1821067c= 980b7c: >>> >>> scripts/qemu-gdb: Add brief comment describing usage (2015-09-11 17= :14:50 +0100) >>> >>> are available in the git repository at: >>> >>> git://repo.or.cz/qemu/kevin.git tags/for-upstream >>> >>> for you to fetch changes up to 1fcbcc93872953d08cd35830d1169fed191962= 90: >>> >>> qcow2: Make qcow2_alloc_bytes() more explicit (2015-09-11 20:03:02 = +0200) >>> >>> ---------------------------------------------------------------- >>> Block layer patches >>> >>> ---------------------------------------------------------------- >> >> Hi. I'm afraid this fails to build on 32-bit: >> >> /home/pm215/qemu/block/qcow2-refcount.c: In function =E2=80=98realloc_= refcount_array=E2=80=99: >> /home/pm215/qemu/block/qcow2-refcount.c:1294:16: error: cast to >> pointer from integer of different size [-Werror=3Dint-to-pointer-cast]= >> memset((void *)((uintptr_t)new_ptr + old_byte_size), 0, >> ^ >> cc1: all warnings being treated as errors >> /home/pm215/qemu/rules.mak:57: recipe for target 'block/qcow2-refcount= =2Eo' failed >> make: *** [block/qcow2-refcount.o] Error 1 >> >> (old_byte_size is int64_t, so (uintptr_t)new_ptr + old_byte_size >> becomes a 64-bit addition, and then you cast it to a 32-bit >> pointer.) >=20 > Max, I think this is yours. Indeed, I'll send a v3 for "qcow2: Make size_to_clusters() return uint64_t" and "iotests: Add test for checking large image files". You decide whether you are going to include them in a new pull request or just drop them for now. Max --cOVLqGX8XBk4DVKl1WCfFVPUnEaK8f4fG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV9tuAAAoJEDuxQgLoOKytNNEIAJ/VIRwikhmvaHtykjUYUSe0 oDHPH9uJhCmDmyHOhv0pWeDi/j33cFT2SleBIq/dkKUVw4y3bq8OuYJUQlN5hX9R HcLat3ewRbjIbjQjjMhyqpBLuWJoaM5KObMFLffyRSHMjlRpuHTUZf2q5g3ARUt/ ENtyHxV77ed2I9LPEFxOY53p5a+LNF8Z4+G7ZYhFAv5rcXZcbzUgLhIDvBtjkxTH QlpJJPLKiS/EE2480xHt77+ovAafMp0gzqN1ma7mGOWPwFFw/l0rE/1vQX7LRGTQ Uko0DOkCCv7jzxFADm2p8KiKOMpysakm7S92lP3rmXAVJCVMgoDx2LQ0sskEvUU= =V0AD -----END PGP SIGNATURE----- --cOVLqGX8XBk4DVKl1WCfFVPUnEaK8f4fG-- From MAILER-DAEMON Mon Sep 14 10:39:57 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbUvF-000899-Rn for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 10:39:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUvE-00087E-4X for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:39:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbUvA-0006ab-Vk for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:39:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41306) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUvA-0006aO-Ri; Mon, 14 Sep 2015 10:39:52 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 8DE963FE65; Mon, 14 Sep 2015 14:39:52 +0000 (UTC) Received: from localhost (ovpn-116-86.ams2.redhat.com [10.36.116.86]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EEdmkt002553 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 14 Sep 2015 10:39:51 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 14 Sep 2015 16:39:46 +0200 Message-Id: <1442241588-25672-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH v3 0/2] qcow2: Make size_to_clusters() return uint64_t X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 14:39:57 -0000 Some callers actually expected that function to return uint64_t. As it turns out, it doesn't. Fix that. v3: - Patch 1: Fix build for sizeof(void *) < 8 machines [Peter] git-backport-diff against v2: Key: [----] : patches are identical [####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively 001/2:[0002] [FC] 'qcow2: Make size_to_clusters() return uint64_t' 002/2:[----] [--] 'iotests: Add test for checking large image files' Max Reitz (2): qcow2: Make size_to_clusters() return uint64_t iotests: Add test for checking large image files block/qcow2-cluster.c | 30 ++++++++++++------- block/qcow2-refcount.c | 12 +++++--- block/qcow2.h | 6 ++-- tests/qemu-iotests/138 | 73 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/138.out | 9 ++++++ tests/qemu-iotests/group | 1 + 6 files changed, 113 insertions(+), 18 deletions(-) create mode 100755 tests/qemu-iotests/138 create mode 100644 tests/qemu-iotests/138.out -- 2.5.2 From MAILER-DAEMON Mon Sep 14 10:40:07 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbUvO-0008IS-Vu for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 10:40:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUvM-0008EN-2I for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:40:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbUvH-0006bq-IQ for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:40:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45448) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUvH-0006bk-Ba; Mon, 14 Sep 2015 10:39:59 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 0FA67225; Mon, 14 Sep 2015 14:39:59 +0000 (UTC) Received: from localhost (ovpn-116-86.ams2.redhat.com [10.36.116.86]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EEdum3028263 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 14 Sep 2015 10:39:58 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 14 Sep 2015 16:39:48 +0200 Message-Id: <1442241588-25672-3-git-send-email-mreitz@redhat.com> In-Reply-To: <1442241588-25672-1-git-send-email-mreitz@redhat.com> References: <1442241588-25672-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH v3 2/2] iotests: Add test for checking large image files X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 14:40:05 -0000 Add a test for checking a qcow2 file with a multiple of 2^32 clusters. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- tests/qemu-iotests/138 | 73 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/138.out | 9 ++++++ tests/qemu-iotests/group | 1 + 3 files changed, 83 insertions(+) create mode 100755 tests/qemu-iotests/138 create mode 100644 tests/qemu-iotests/138.out diff --git a/tests/qemu-iotests/138 b/tests/qemu-iotests/138 new file mode 100755 index 0000000..a5c3464 --- /dev/null +++ b/tests/qemu-iotests/138 @@ -0,0 +1,73 @@ +#!/bin/bash +# +# General test case for qcow2's image check +# +# Copyright (C) 2015 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=mreitz@redhat.com + +seq="$(basename $0)" +echo "QA output created by $seq" + +here="$PWD" +tmp=/tmp/$$ +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +# This tests qocw2-specific low-level functionality +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +echo +echo '=== Check on an image with a multiple of 2^32 clusters ===' +echo + +IMGOPTS=$(_optstr_add "$IMGOPTS" "cluster_size=512") \ + _make_test_img 512 + +# Allocate L2 table +$QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io + +# Put the data cluster at a multiple of 2 TB, resulting in the image apparently +# having a multiple of 2^32 clusters +# (To be more specific: It is at 32 PB) +poke_file "$TEST_IMG" 2048 "\x80\x80\x00\x00\x00\x00\x00\x00" + +# An offset of 32 PB results in qemu-img check having to allocate an in-memory +# refcount table of 128 TB (16 bit refcounts, 512 byte clusters). +# This should be generally too much for any system and thus fail. +# What this test is checking is that the qcow2 driver actually tries to allocate +# such a large amount of memory (and is consequently aborting) instead of having +# truncated the cluster count somewhere (which would result in much less memory +# being allocated and then a segfault occurring). +_check_test_img + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/138.out b/tests/qemu-iotests/138.out new file mode 100644 index 0000000..3fe911f --- /dev/null +++ b/tests/qemu-iotests/138.out @@ -0,0 +1,9 @@ +QA output created by 138 + +=== Check on an image with a multiple of 2^32 clusters === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=512 +wrote 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +qemu-img: Check failed: Cannot allocate memory +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 3a6a8f0..439b1d2 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -135,3 +135,4 @@ 134 rw auto quick 135 rw auto 137 rw auto +138 rw auto quick -- 2.5.2 From MAILER-DAEMON Mon Sep 14 10:40:11 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbUvT-0008Qz-6G for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 10:40:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUvL-0008ED-Jg for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:40:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbUvE-0006bH-RC for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:40:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50428) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUvE-0006bA-H4; Mon, 14 Sep 2015 10:39:56 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 3C8C93B3C2; Mon, 14 Sep 2015 14:39:56 +0000 (UTC) Received: from localhost (ovpn-116-86.ams2.redhat.com [10.36.116.86]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EEdr22032376 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 14 Sep 2015 10:39:55 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 14 Sep 2015 16:39:47 +0200 Message-Id: <1442241588-25672-2-git-send-email-mreitz@redhat.com> In-Reply-To: <1442241588-25672-1-git-send-email-mreitz@redhat.com> References: <1442241588-25672-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH v3 1/2] qcow2: Make size_to_clusters() return uint64_t X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 14:40:10 -0000 Sadly, some images may have more clusters than what can be represented using a plain int. We should be prepared for that case (in qcow2_check_refcounts() we actually were trying to catch that case, but since size_to_clusters() truncated the returned value, that check never did anything useful). Cc: qemu-stable Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 30 +++++++++++++++++++----------- block/qcow2-refcount.c | 12 ++++++++---- block/qcow2.h | 6 +++--- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 2975b83..dc217e7 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -298,7 +298,7 @@ fail: * as contiguous. (This allows it, for example, to stop at the first compressed * cluster which may require a different handling) */ -static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size, +static int count_contiguous_clusters(int nb_clusters, int cluster_size, uint64_t *l2_table, uint64_t stop_flags) { int i; @@ -321,7 +321,7 @@ static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size, return i; } -static int count_contiguous_free_clusters(uint64_t nb_clusters, uint64_t *l2_table) +static int count_contiguous_free_clusters(int nb_clusters, uint64_t *l2_table) { int i; @@ -495,6 +495,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, if (nb_needed > nb_available) { nb_needed = nb_available; } + assert(nb_needed <= INT_MAX); *cluster_offset = 0; @@ -530,6 +531,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); *cluster_offset = be64_to_cpu(l2_table[l2_index]); + + /* nb_needed <= INT_MAX, thus nb_clusters <= INT_MAX, too */ nb_clusters = size_to_clusters(s, nb_needed << 9); ret = qcow2_get_cluster_type(*cluster_offset); @@ -840,7 +843,7 @@ err: static int count_cow_clusters(BDRVQcow2State *s, int nb_clusters, uint64_t *l2_table, int l2_index) { - int i; + uint64_t i; for (i = 0; i < nb_clusters; i++) { uint64_t l2_entry = be64_to_cpu(l2_table[l2_index + i]); @@ -960,7 +963,7 @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset, int l2_index; uint64_t cluster_offset; uint64_t *l2_table; - unsigned int nb_clusters; + uint64_t nb_clusters; unsigned int keep_clusters; int ret; @@ -979,6 +982,7 @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset, l2_index = offset_to_l2_index(s, guest_offset); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); /* Find L2 entry for the first involved cluster */ ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index); @@ -1061,7 +1065,7 @@ out: * restarted, but the whole request should not be failed. */ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, - uint64_t *host_offset, unsigned int *nb_clusters) + uint64_t *host_offset, uint64_t *nb_clusters) { BDRVQcow2State *s = bs->opaque; @@ -1079,7 +1083,7 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, *host_offset = cluster_offset; return 0; } else { - int ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters); + int64_t ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters); if (ret < 0) { return ret; } @@ -1115,7 +1119,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, int l2_index; uint64_t *l2_table; uint64_t entry; - unsigned int nb_clusters; + uint64_t nb_clusters; int ret; uint64_t alloc_cluster_offset; @@ -1133,6 +1137,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, l2_index = offset_to_l2_index(s, guest_offset); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); /* Find L2 entry for the first involved cluster */ ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index); @@ -1426,7 +1431,8 @@ int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) * clusters. */ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, - unsigned int nb_clusters, enum qcow2_discard_type type, bool full_discard) + uint64_t nb_clusters, enum qcow2_discard_type type, + bool full_discard) { BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; @@ -1441,6 +1447,7 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, /* Limit nb_clusters to one L2 table */ nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); for (i = 0; i < nb_clusters; i++) { uint64_t old_l2_entry; @@ -1503,7 +1510,7 @@ int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, { BDRVQcow2State *s = bs->opaque; uint64_t end_offset; - unsigned int nb_clusters; + uint64_t nb_clusters; int ret; end_offset = offset + (nb_sectors << BDRV_SECTOR_BITS); @@ -1545,7 +1552,7 @@ fail: * clusters. */ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, - unsigned int nb_clusters) + uint64_t nb_clusters) { BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; @@ -1560,6 +1567,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, /* Limit nb_clusters to one L2 table */ nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); for (i = 0; i < nb_clusters; i++) { uint64_t old_offset; @@ -1584,7 +1592,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors) { BDRVQcow2State *s = bs->opaque; - unsigned int nb_clusters; + uint64_t nb_clusters; int ret; /* The zero flag is only supported by version 3 and newer */ diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 53e3e9f..d9f234a 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -875,8 +875,8 @@ int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size) return offset; } -int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, - int nb_clusters) +int64_t qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, + int64_t nb_clusters) { BDRVQcow2State *s = bs->opaque; uint64_t cluster_index, refcount; @@ -1259,7 +1259,7 @@ static size_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries) static int realloc_refcount_array(BDRVQcow2State *s, void **array, int64_t *size, int64_t new_size) { - size_t old_byte_size, new_byte_size; + int64_t old_byte_size, new_byte_size; void *new_ptr; /* Round to clusters so the array can be directly written to disk */ @@ -1275,13 +1275,17 @@ static int realloc_refcount_array(BDRVQcow2State *s, void **array, assert(new_byte_size > 0); + if (new_byte_size > SIZE_MAX) { + return -ENOMEM; + } + new_ptr = g_try_realloc(*array, new_byte_size); if (!new_ptr) { return -ENOMEM; } if (new_byte_size > old_byte_size) { - memset((void *)((uintptr_t)new_ptr + old_byte_size), 0, + memset((char *)new_ptr + old_byte_size, 0, new_byte_size - old_byte_size); } diff --git a/block/qcow2.h b/block/qcow2.h index 61f1b57..d700bf1 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -415,7 +415,7 @@ static inline int64_t offset_into_cluster(BDRVQcow2State *s, int64_t offset) return offset & (s->cluster_size - 1); } -static inline int size_to_clusters(BDRVQcow2State *s, int64_t size) +static inline uint64_t size_to_clusters(BDRVQcow2State *s, uint64_t size) { return (size + (s->cluster_size - 1)) >> s->cluster_bits; } @@ -509,8 +509,8 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs, int64_t cluster_index, enum qcow2_discard_type type); int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size); -int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, - int nb_clusters); +int64_t qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, + int64_t nb_clusters); int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size); void qcow2_free_clusters(BlockDriverState *bs, int64_t offset, int64_t size, -- 2.5.2 From MAILER-DAEMON Mon Sep 14 10:44:53 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbV00-0002Rs-EO for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 10:44:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUzx-0002N8-CJ for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:44:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbUzu-0000IC-LI for qemu-block@nongnu.org; Mon, 14 Sep 2015 10:44:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51647) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUzu-0000Hy-Ee; Mon, 14 Sep 2015 10:44:46 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id E0E1EAB0; Mon, 14 Sep 2015 14:36:20 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-64.ams2.redhat.com [10.36.116.64]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EEaINZ025181 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 14 Sep 2015 10:36:19 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 62056303F90D; Mon, 14 Sep 2015 16:36:17 +0200 (CEST) From: Markus Armbruster To: Wen Congyang References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> Date: Mon, 14 Sep 2015 16:36:17 +0200 In-Reply-To: <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> (Wen Congyang's message of "Thu, 10 Sep 2015 17:55:04 +0800") Message-ID: <87mvwpkqzi.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 14:44:50 -0000 Wen Congyang writes: > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei > --- > blockdev.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ > qapi/block-core.json | 34 +++++++++++++++++++++++++++++++++ > qmp-commands.hx | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 134 insertions(+) > > diff --git a/blockdev.c b/blockdev.c > index bd47756..0a40607 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -3413,6 +3413,53 @@ fail: > qmp_output_visitor_cleanup(ov); > } > > +void qmp_x_child_add(const char *parent, const char *child, > + Error **errp) > +{ > + BlockDriverState *parent_bs, *child_bs; > + Error *local_err = NULL; > + > + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); > + if (!parent_bs) { > + error_propagate(errp, local_err); > + return; > + } > + > + child_bs = bdrv_find_node(child); > + if (!child_bs) { > + error_setg(errp, "Node '%s' not found", child); > + return; > + } > + > + bdrv_add_child(parent_bs, child_bs, &local_err); > + if (local_err) { > + error_propagate(errp, local_err); > + } > +} > + > +void qmp_child_del(const char *parent, const char *child, Error **errp) > +{ > + BlockDriverState *parent_bs, *child_bs; > + Error *local_err = NULL; > + > + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); > + if (!parent_bs) { > + error_propagate(errp, local_err); > + return; > + } > + > + child_bs = bdrv_find_node(child); > + if (!child_bs) { > + error_setg(errp, "Node '%s' not found", child); > + return; > + } > + > + bdrv_del_child(parent_bs, child_bs, &local_err); > + if (local_err) { > + error_propagate(errp, local_err); > + } > +} > + > BlockJobInfoList *qmp_query_block_jobs(Error **errp) > { > BlockJobInfoList *head = NULL, **p_next = &head; > diff --git a/qapi/block-core.json b/qapi/block-core.json > index e68a59f..b959577 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -2272,3 +2272,37 @@ > ## > { 'command': 'block-set-write-threshold', > 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } > + > +## > +# @x-child-add > +# > +# Add a new child to the parent BDS. Currently only the Quorum driver > +# implements this feature. This is useful to fix a broken quorum child. > +# > +# @parent: graph node name or id which the child will be added to. > +# > +# @child: graph node name that will be added. > +# > +# Note: this command is experimental, and not a stable API. > +# > +# Since: 2.5 > +## > +{ 'command': 'x-child-add', > + 'data' : { 'parent': 'str', 'child': 'str' } } > + > +## > +# @child-del > +# > +# Remove a child from the parent BDS. Currently only the Quorum driver > +# implements this feature. This is useful to fix a broken quorum child. > +# Note, you can't remove a child if it would bring the quorum below its > +# threshold. > +# > +# @parent: graph node name or id from which the child will removed. > +# > +# @child: graph node name that will be removed. > +# > +# Since: 2.5 > +## > +{ 'command': 'child-del', > + 'data' : { 'parent': 'str', 'child': 'str' } } Why is x-child-add experimental, but child-del isn't? Please explain both in the schema and in the commit message. > diff --git a/qmp-commands.hx b/qmp-commands.hx > index 495670b..139a23b 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -4053,6 +4053,59 @@ Example: > EQMP > > { > + .name = "x-child-add", > + .args_type = "parent:B,child:B", > + .mhandler.cmd_new = qmp_marshal_input_x_child_add, > + }, > + > +SQMP > +x-child-add > +------------ > + > +Add a child to a quorum node. > + > +Arguments: > + > +- "parent": the quorum's id or node name > +- "child": the child node-name which will be added Node name parameters are usually named node-name or, if there's more than one, FOO-node-name. Unless we want to abandon that convention, this should therefore be node-name and child-node-name, or parent-node name and child-node-name. > + > +Note: this command is experimental, and not a stable API. > + > +Example: > + > +-> { "execute": "x-child-add", > + "arguments": { "parent": "disk1", "child": "new_node" } } > +<- { "return": {} } > + > +EQMP > + > + { > + .name = "child-del", Documentation and schema have x-child-add, actual command is child-add. Oops. > + .args_type = "parent:B,child:B", > + .mhandler.cmd_new = qmp_marshal_input_child_del, > + }, > + > +SQMP > +child-del > +------------ > + > +Delete a child from a quorum node. It can be used to remove a broken > +quorum child. > + > +Arguments: > + > +- "parent": the quorum's id or node name > +- "child": the child node-name which will be removed Same comment as on x-child-add's parameter names. > + > +Example: > + > +-> { "execute": "child-del", > + "arguments": { "parent": "disk1", "child": "new_node" } } > +<- { "return": {} } > + > +EQMP > + > + { > .name = "query-named-block-nodes", > .args_type = "", > .mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes, From MAILER-DAEMON Mon Sep 14 11:04:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbVJ0-0005IU-5p for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 11:04:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbVIt-0005Hh-08 for qemu-block@nongnu.org; Mon, 14 Sep 2015 11:04:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbVIm-0002Li-RZ for qemu-block@nongnu.org; Mon, 14 Sep 2015 11:04:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbVIm-0002Lc-M2; Mon, 14 Sep 2015 11:04:16 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id BECC88C1D5; Mon, 14 Sep 2015 15:04:15 +0000 (UTC) Received: from [10.3.113.35] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EF4Dau025567; Mon, 14 Sep 2015 11:04:14 -0400 To: Peter Lieven , Fam Zheng References: <1441951252-13439-1-git-send-email-famz@redhat.com> <55F2F141.3000809@redhat.com> <20150914063810.GA31803@ad.nay.redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55F6E1E9.9090307@redhat.com> Date: Mon, 14 Sep 2015 09:04:09 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="vk9mQdorgthUf8RTDiGEGaJMk94H9csDF" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , "qemu-block@nongnu.org" , qemu-devel , ronnie sahlberg Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] iscsi: Add chap and "initiator-name" etc as per drive options X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 15:04:28 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --vk9mQdorgthUf8RTDiGEGaJMk94H9csDF Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/14/2015 12:50 AM, Peter Lieven wrote: >>>> It would be nice to also add a matching BlockdevOptionsIscsi to >>>> qapi/block-core.json, to allow setting these structured options from= >>>> QMP. Separate patch is fine, but we need to do the work for ALL of = the >>>> remaining block devices eventually, and now that you are structuring= the >>>> command line is a good time to think about it. >>>> >>>> >>> Passing via command line is evil. It should still be possible to pass= >>> all this via a config file to qemu : >>> >> >> I agree passing password with clear text command line is bad, but -rea= dconfig >> doesn't work for qemu-img and qemu-io. Any idea how to make that work= ? >=20 > you can pass the secrets via environment variables (see libiscsi readme= ). Environment variables are no more secure than command line parameters - both are visible via ps to other processes, and hence relatively insecure. We need a way to pass secrets over a file descriptor, whether that file descriptor be a config file, or whether it be a pipe. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --vk9mQdorgthUf8RTDiGEGaJMk94H9csDF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV9uHtAAoJEKeha0olJ0Nqv0EIAJIvo3RrUcydeuP4Iy55Sp64 XqKVzCPO2gXhOs/C0sDTE84yr7Bj5BsjK+HkgTPETuL4u4bZc1kPNROaOFOGyTnT Exrw6RW96i6dVa9rgA0kpHpLtrLYOiybJwmAAnLfLOmxLok54NLylYGITcvfzWd5 ItEnGfSFkxPfKD6fYHRdt/R0hMV2NmFsqAE7j84Tf8t0dQ/pzZEUb6Jfyx+DPWg/ 3PLg4kqyvQrsByjIjQEe5c6mYSyNiHuW4kMBvtuuog9gR7LZfyJ/lMORhLdJnG8a eNoS87kuSqgdBajrltqgUfQq+WS+b04NfrkUGExPm/nWxVXkfGtlht/p7xeg7+A= =J23x -----END PGP SIGNATURE----- --vk9mQdorgthUf8RTDiGEGaJMk94H9csDF-- From MAILER-DAEMON Mon Sep 14 11:25:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbVdL-0004F2-QY for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 11:25:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbVdJ-0004Ef-KL for qemu-block@nongnu.org; Mon, 14 Sep 2015 11:25:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbVdG-0002Ck-UF for qemu-block@nongnu.org; Mon, 14 Sep 2015 11:25:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51335) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbVdG-0002Bt-MA; Mon, 14 Sep 2015 11:25:26 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 2C4242F5184; Mon, 14 Sep 2015 15:25:26 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EFPODX004048; Mon, 14 Sep 2015 11:25:25 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 14 Sep 2015 17:25:20 +0200 Message-Id: <1442244321-2305-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL v2 00/23] Block layer patches X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 15:25:30 -0000 The following changes since commit 2b750d9d261bda7f75b39dfc1e1e5f22502929d5: Merge remote-tracking branch 'remotes/aurel/tags/pull-sh4-next-20150913' into staging (2015-09-14 10:46:38 +0100) are available in the git repository at: git://repo.or.cz/qemu/kevin.git tags/for-upstream for you to fetch changes up to 2ac01520be8717f3492b10a083c3e0e22cb52cda: qcow2: Make qcow2_alloc_bytes() more explicit (2015-09-14 16:51:37 +0200) ---------------------------------------------------------------- Block layer patches (v2) ---------------------------------------------------------------- Kevin Wolf (14): qcow2: Rename BDRVQcowState to BDRVQcow2State block: Allow specifying driver-specific options to reopen qemu-io: Remove duplicate 'open' error message qemu-io: Add command 'reopen' qcow2: Improve error message qcow2: Factor out qcow2_update_options() qcow2: Move qcow2_update_options() call up qcow2: Move rest of option handling to qcow2_update_options() qcow2: Leave s unchanged on qcow2_update_options() failure qcow2: Fix memory leak in qcow2_update_options() error path qcow2: Make qcow2_update_options() suitable for transactions qcow2: Support updating driver-specific options in reopen qemu-iotests: Reopen qcow2 with lazy-refcounts change qemu-iotests: More qcow2 reopen tests Max Reitz (8): block: Always pass NULL as drv for bdrv_open() block: Drop drv parameter from bdrv_open() block: Drop drv parameter from bdrv_open_inherit() block: Drop drv parameter from bdrv_fill_options() block: Drop bdrv_find_whitelisted_format() qcow2: Make size_to_clusters() return uint64_t iotests: Add test for checking large image files qcow2: Make qcow2_alloc_bytes() more explicit Radoslav Gerganov (1): vmdk: Fix next_cluster_sector for compressed write block.c | 150 +++++++------- block/block-backend.c | 2 +- block/commit.c | 4 +- block/parallels.c | 2 +- block/qcow.c | 2 +- block/qcow2-cache.c | 14 +- block/qcow2-cluster.c | 76 +++---- block/qcow2-refcount.c | 76 ++++--- block/qcow2-snapshot.c | 20 +- block/qcow2.c | 486 +++++++++++++++++++++++++++++---------------- block/qcow2.h | 26 +-- block/qed.c | 2 +- block/sheepdog.c | 5 +- block/vdi.c | 2 +- block/vhdx.c | 2 +- block/vmdk.c | 15 +- block/vpc.c | 2 +- block/vvfat.c | 8 +- blockdev.c | 72 +++---- include/block/block.h | 9 +- qemu-io-cmds.c | 90 +++++++++ qemu-io.c | 1 - tests/qemu-iotests/039 | 27 +++ tests/qemu-iotests/039.out | 18 ++ tests/qemu-iotests/137 | 145 ++++++++++++++ tests/qemu-iotests/137.out | 42 ++++ tests/qemu-iotests/138 | 73 +++++++ tests/qemu-iotests/138.out | 9 + tests/qemu-iotests/group | 2 + 29 files changed, 973 insertions(+), 409 deletions(-) create mode 100755 tests/qemu-iotests/137 create mode 100644 tests/qemu-iotests/137.out create mode 100755 tests/qemu-iotests/138 create mode 100644 tests/qemu-iotests/138.out From MAILER-DAEMON Mon Sep 14 11:25:32 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbVdM-0004GH-UJ for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 11:25:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbVdJ-0004Eg-Kz for qemu-block@nongnu.org; Mon, 14 Sep 2015 11:25:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbVdH-0002Dp-Ou for qemu-block@nongnu.org; Mon, 14 Sep 2015 11:25:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33640) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbVdH-0002DS-HZ; Mon, 14 Sep 2015 11:25:27 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 2B0F1C0B918D; Mon, 14 Sep 2015 15:25:27 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EFPODY004048; Mon, 14 Sep 2015 11:25:26 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 14 Sep 2015 17:25:21 +0200 Message-Id: <1442244321-2305-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1442244321-2305-1-git-send-email-kwolf@redhat.com> References: <1442244321-2305-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL v2 20/23] qcow2: Make size_to_clusters() return uint64_t X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 15:25:31 -0000 From: Max Reitz Sadly, some images may have more clusters than what can be represented using a plain int. We should be prepared for that case (in qcow2_check_refcounts() we actually were trying to catch that case, but since size_to_clusters() truncated the returned value, that check never did anything useful). Cc: qemu-stable Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/qcow2-cluster.c | 28 ++++++++++++++++++---------- block/qcow2-refcount.c | 12 ++++++++---- block/qcow2.h | 6 +++--- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 412ee27..6ede629 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -298,7 +298,7 @@ fail: * as contiguous. (This allows it, for example, to stop at the first compressed * cluster which may require a different handling) */ -static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size, +static int count_contiguous_clusters(int nb_clusters, int cluster_size, uint64_t *l2_table, uint64_t stop_flags) { int i; @@ -321,7 +321,7 @@ static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size, return i; } -static int count_contiguous_free_clusters(uint64_t nb_clusters, uint64_t *l2_table) +static int count_contiguous_free_clusters(int nb_clusters, uint64_t *l2_table) { int i; @@ -495,6 +495,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, if (nb_needed > nb_available) { nb_needed = nb_available; } + assert(nb_needed <= INT_MAX); *cluster_offset = 0; @@ -530,6 +531,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); *cluster_offset = be64_to_cpu(l2_table[l2_index]); + + /* nb_needed <= INT_MAX, thus nb_clusters <= INT_MAX, too */ nb_clusters = size_to_clusters(s, nb_needed << 9); ret = qcow2_get_cluster_type(*cluster_offset); @@ -960,7 +963,7 @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset, int l2_index; uint64_t cluster_offset; uint64_t *l2_table; - unsigned int nb_clusters; + uint64_t nb_clusters; unsigned int keep_clusters; int ret; @@ -979,6 +982,7 @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset, l2_index = offset_to_l2_index(s, guest_offset); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); /* Find L2 entry for the first involved cluster */ ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index); @@ -1061,7 +1065,7 @@ out: * restarted, but the whole request should not be failed. */ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, - uint64_t *host_offset, unsigned int *nb_clusters) + uint64_t *host_offset, uint64_t *nb_clusters) { BDRVQcow2State *s = bs->opaque; @@ -1079,7 +1083,7 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, *host_offset = cluster_offset; return 0; } else { - int ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters); + int64_t ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters); if (ret < 0) { return ret; } @@ -1115,7 +1119,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, int l2_index; uint64_t *l2_table; uint64_t entry; - unsigned int nb_clusters; + uint64_t nb_clusters; int ret; uint64_t alloc_cluster_offset; @@ -1133,6 +1137,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, l2_index = offset_to_l2_index(s, guest_offset); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); /* Find L2 entry for the first involved cluster */ ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index); @@ -1426,7 +1431,8 @@ int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) * clusters. */ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, - unsigned int nb_clusters, enum qcow2_discard_type type, bool full_discard) + uint64_t nb_clusters, enum qcow2_discard_type type, + bool full_discard) { BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; @@ -1441,6 +1447,7 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, /* Limit nb_clusters to one L2 table */ nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); for (i = 0; i < nb_clusters; i++) { uint64_t old_l2_entry; @@ -1503,7 +1510,7 @@ int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, { BDRVQcow2State *s = bs->opaque; uint64_t end_offset; - unsigned int nb_clusters; + uint64_t nb_clusters; int ret; end_offset = offset + (nb_sectors << BDRV_SECTOR_BITS); @@ -1545,7 +1552,7 @@ fail: * clusters. */ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, - unsigned int nb_clusters) + uint64_t nb_clusters) { BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; @@ -1560,6 +1567,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, /* Limit nb_clusters to one L2 table */ nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); + assert(nb_clusters <= INT_MAX); for (i = 0; i < nb_clusters; i++) { uint64_t old_offset; @@ -1584,7 +1592,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset, int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors) { BDRVQcow2State *s = bs->opaque; - unsigned int nb_clusters; + uint64_t nb_clusters; int ret; /* The zero flag is only supported by version 3 and newer */ diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index b780bb9..a49d59e 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -875,8 +875,8 @@ int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size) return offset; } -int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, - int nb_clusters) +int64_t qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, + int64_t nb_clusters) { BDRVQcow2State *s = bs->opaque; uint64_t cluster_index, refcount; @@ -1259,7 +1259,7 @@ static size_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries) static int realloc_refcount_array(BDRVQcow2State *s, void **array, int64_t *size, int64_t new_size) { - size_t old_byte_size, new_byte_size; + int64_t old_byte_size, new_byte_size; void *new_ptr; /* Round to clusters so the array can be directly written to disk */ @@ -1275,13 +1275,17 @@ static int realloc_refcount_array(BDRVQcow2State *s, void **array, assert(new_byte_size > 0); + if (new_byte_size > SIZE_MAX) { + return -ENOMEM; + } + new_ptr = g_try_realloc(*array, new_byte_size); if (!new_ptr) { return -ENOMEM; } if (new_byte_size > old_byte_size) { - memset((void *)((uintptr_t)new_ptr + old_byte_size), 0, + memset((char *)new_ptr + old_byte_size, 0, new_byte_size - old_byte_size); } diff --git a/block/qcow2.h b/block/qcow2.h index 61f1b57..d700bf1 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -415,7 +415,7 @@ static inline int64_t offset_into_cluster(BDRVQcow2State *s, int64_t offset) return offset & (s->cluster_size - 1); } -static inline int size_to_clusters(BDRVQcow2State *s, int64_t size) +static inline uint64_t size_to_clusters(BDRVQcow2State *s, uint64_t size) { return (size + (s->cluster_size - 1)) >> s->cluster_bits; } @@ -509,8 +509,8 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs, int64_t cluster_index, enum qcow2_discard_type type); int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size); -int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, - int nb_clusters); +int64_t qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, + int64_t nb_clusters); int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size); void qcow2_free_clusters(BlockDriverState *bs, int64_t offset, int64_t size, -- 1.8.3.1 From MAILER-DAEMON Mon Sep 14 11:34:59 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbVmV-0000Cg-2U for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 11:34:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbVmO-0000BS-4Q for qemu-block@nongnu.org; Mon, 14 Sep 2015 11:34:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbVmL-0006E3-DW for qemu-block@nongnu.org; Mon, 14 Sep 2015 11:34:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43227) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbVmL-0006Bs-9Q; Mon, 14 Sep 2015 11:34:49 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 1C7D0341AD9; Mon, 14 Sep 2015 15:34:47 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8EFYiDF008285; Mon, 14 Sep 2015 11:34:45 -0400 Date: Mon, 14 Sep 2015 17:34:44 +0200 From: Kevin Wolf To: Markus Armbruster Message-ID: <20150914153444.GD3550@noname.str.redhat.com> References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> <87mvwpkqzi.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87mvwpkqzi.fsf@blackfin.pond.sub.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang , zhanghailiang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 15:34:57 -0000 Am 14.09.2015 um 16:36 hat Markus Armbruster geschrieben: > Wen Congyang writes: > > diff --git a/qmp-commands.hx b/qmp-commands.hx > > index 495670b..139a23b 100644 > > --- a/qmp-commands.hx > > +++ b/qmp-commands.hx > > @@ -4053,6 +4053,59 @@ Example: > > EQMP > > > > { > > + .name = "x-child-add", > > + .args_type = "parent:B,child:B", > > + .mhandler.cmd_new = qmp_marshal_input_x_child_add, > > + }, > > + > > +SQMP > > +x-child-add > > +------------ > > + > > +Add a child to a quorum node. > > + > > +Arguments: > > + > > +- "parent": the quorum's id or node name > > +- "child": the child node-name which will be added > > Node name parameters are usually named node-name or, if there's more > than one, FOO-node-name. Unless we want to abandon that convention, > this should therefore be node-name and child-node-name, or parent-node > name and child-node-name. Didn't we come to the conclusion that foo-node-name is redundant and should just be foo, leaving things like node-name only for cases where there is no foo? Kevin From MAILER-DAEMON Mon Sep 14 11:37:11 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbVod-0001MF-Aw for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 11:37:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbVoa-0001M1-VL for qemu-block@nongnu.org; Mon, 14 Sep 2015 11:37:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbVoW-0007qT-Lo for qemu-block@nongnu.org; Mon, 14 Sep 2015 11:37:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33328) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbVoW-0007qL-Fg; Mon, 14 Sep 2015 11:37:04 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id D8971AACC6; Mon, 14 Sep 2015 15:37:03 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8EFb0BS014040; Mon, 14 Sep 2015 11:37:01 -0400 Date: Mon, 14 Sep 2015 17:37:00 +0200 From: Kevin Wolf To: Wen Congyang Message-ID: <20150914153700.GE3550@noname.str.redhat.com> References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: zhanghailiang , qemu block , Markus Armbruster , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , qemu devel , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 15:37:09 -0000 Am 10.09.2015 um 11:55 hat Wen Congyang geschrieben: > +## > +# @x-child-add > +# > +# Add a new child to the parent BDS. Currently only the Quorum driver > +# implements this feature. This is useful to fix a broken quorum child. > +# > +# @parent: graph node name or id which the child will be added to. > +# > +# @child: graph node name that will be added. > +# > +# Note: this command is experimental, and not a stable API. > +# > +# Since: 2.5 > +## > +{ 'command': 'x-child-add', > + 'data' : { 'parent': 'str', 'child': 'str' } } This is probably not future-proof and only made for the special case of quorum. Specifically, one thing I'm missing is some way to specfiy what kind of child the new node is when a node can take different types of children (e.g. bs->file and bs->backing_hd). Kevin From MAILER-DAEMON Mon Sep 14 11:47:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbVyN-0005Yr-NM for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 11:47:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbVyK-0005VB-30 for qemu-block@nongnu.org; Mon, 14 Sep 2015 11:47:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbVyG-00049k-1u for qemu-block@nongnu.org; Mon, 14 Sep 2015 11:47:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbVyF-00049c-RH; Mon, 14 Sep 2015 11:47:07 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 5D300A9A; Mon, 14 Sep 2015 15:47:07 +0000 (UTC) Received: from [10.3.113.35] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EFl68L018826; Mon, 14 Sep 2015 11:47:06 -0400 To: Markus Armbruster , Wen Congyang References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55F6EBF5.2090101@redhat.com> Date: Mon, 14 Sep 2015 09:47:01 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87r3m1krdl.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wvCdGoTUMn1tRDiGrAbI8Jk13QuakEEvN" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 15:47:13 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --wvCdGoTUMn1tRDiGrAbI8Jk13QuakEEvN Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/14/2015 08:27 AM, Markus Armbruster wrote: > Wen Congyang writes: >=20 >> The NBD driver needs: filename, path or (host, port, exportname). >> It checks which key exists and decides use unix or inet socket. >> It doesn't recognize the key type, so we can't use union, and >> can't reuse InetSocketAddress. >> >> Signed-off-by: Wen Congyang >> Signed-off-by: zhanghailiang >> Signed-off-by: Gonglei >> --- >> qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- >> 1 file changed, 40 insertions(+), 2 deletions(-) >> >> ## >> +# @BlockdevOptionsNBD >> +# >> +# Driver specific block device options for NBD >> +# >> +# @filename: #optional unix or inet path. The format is: >> +# unix: nbd+unix:///export?socket=3Dpath or >> +# nbd:unix:path:exportname=3Dexport >> +# inet: nbd[+tcp]://host[:port]/export or >> +# nbd:host[:port]:exportname=3Dexport Yuck. You are passing structured data through a single 'str', when you SHOULD be passing it through structured JSON. Just because we have a filename shorthand for convenience does NOT mean that we want to expose that convenience in QMP. Instead, we really want the breakdown of the pieces (here, using abbreviated syntax of an inline base, since there are pending qapi patches that will allow it): { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } { 'union': 'BlockdevOptionsNBD', 'base': { 'transport': 'NBDTransport', 'export': 'str' }, 'discriminator': 'transport', 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } { 'struct': 'NBDInet', 'data': { 'host': 'str', '*port': 'int', '*ipv4': 'bool', '*ipv6': 'bool' } } > I'm afraid this doesn't address Eric's review of your v2. Agreed; we still don't have the right interface. > Eric further observed that support for the nbd+unix transport was > missing, and suggested to have a union type combining the various > transports. And I just spelled out above what that should look like. >=20 > If we decide separate types for single port and port ranges aren't > worthwhile, you can simply use SocketAddress where your v2 used > InetSocketAddress. I'm not sure if my 'NBDInet' above makes any more sense than reusing 'SocketAddress' (and if we do reuse 'SocketAddress', we have the further question of whether to split out socket ranges as a separate type so that SocketAddress becomes a single-port identity). >=20 > Eric, how strongly do you feel about separating the two? I'm more worried about properly using a union type to represent unix vs. tcp, and less worried about SocketAddress vs. range types vs creating a new type (although in the long run, fixing ranges to be in a properly named type rather than re-inventing the struct across multiple transports is a good goal). But you are quite correct that I do not like the v3 proposal, because it encodes far too much information into a single '*filename':'str', which is not the qapi way. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --wvCdGoTUMn1tRDiGrAbI8Jk13QuakEEvN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV9uv1AAoJEKeha0olJ0Nqf1oIAJwLS2O6SFKSvoCyoZGEFa+O 3j59tPLxWjNkp3BLPJA9SZCbaBTULEbwHGybYf+ftnGvUiQlhMNeEtG4u+Ow1PGs aGunrTxFLW9Pe5sot2EYNlTcN7XUsZQgJpQrM/9iK46GJpHioNsmKyw4wfT1x50y zjFy6Qjg9of/aRMHEq5M6IqNrcn0yszXSzC4kcQq/eXhrjtA0k9RuFjdTbBxNR6n GtWFo9rQaq8hUh8Rqea/Et82KBb3HpfmJuvyImoWBrX+nOTt55yzz6PuQz65etp8 Lf6UjqixAZbPswp9nURv8bW/YN/4hH/Hb++LXe6vzFjtW6Ie6Lu3mIWjijEU/Fo= =roTC -----END PGP SIGNATURE----- --wvCdGoTUMn1tRDiGrAbI8Jk13QuakEEvN-- From MAILER-DAEMON Mon Sep 14 12:03:20 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbWDw-00087b-5Y for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 12:03:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbWDt-00083t-MY for qemu-block@nongnu.org; Mon, 14 Sep 2015 12:03:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbWDq-0003B6-H9 for qemu-block@nongnu.org; Mon, 14 Sep 2015 12:03:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51137) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbWDq-0003AQ-Bi; Mon, 14 Sep 2015 12:03:14 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 83492461D3; Mon, 14 Sep 2015 16:03:13 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EG3CFw032692; Mon, 14 Sep 2015 12:03:12 -0400 To: Fam Zheng References: <1441927256-24625-1-git-send-email-jsnow@redhat.com> <1441927256-24625-2-git-send-email-jsnow@redhat.com> <20150911031141.GA2592@ad.nay.redhat.com> From: John Snow Message-ID: <55F6EFC0.3090501@redhat.com> Date: Mon, 14 Sep 2015 12:03:12 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150911031141.GA2592@ad.nay.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 1/1] atapi: abort transfers with 0 byte limits X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 16:03:18 -0000 On 09/10/2015 11:11 PM, Fam Zheng wrote: > On Thu, 09/10 19:20, John Snow wrote: >> >> + /* Nondata commands permit the byte_count_limit to be 0. >> + * If this is a data-transferring PIO command and BCL is 0, >> + * we abort at the /ATA/ level, not the ATAPI level. >> + * See ATA8 ACS3 section 7.17.6.49 and 7.21.5 */ >> + if (!(atapi_cmd_table[s->io_buffer[0]].flags & NONDATA)) { >> + /* TODO: Check IDENTIFY data word 125 for default BCL (currently 0) */ >> + uint16_t byte_count_limit = s->lcyl | (s->hcyl << 8); >> + if !(byte_count_limit || s->atapi_dma) { > > !( ? > > Fam > Ugh. Thinko'd the outer (), and didn't apparently rebuild. :( From MAILER-DAEMON Mon Sep 14 12:07:55 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbWIN-0001wj-Fw for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 12:07:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbWIJ-0001qz-75 for qemu-block@nongnu.org; Mon, 14 Sep 2015 12:07:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbWII-00062F-2H for qemu-block@nongnu.org; Mon, 14 Sep 2015 12:07:51 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:51687 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbWIE-0005hk-F3; Mon, 14 Sep 2015 12:07:46 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2ChCgBC8PZV/5tjdVtdGQEBAYMHgT2BTKdiAQEBAQEBBQGBCgGSfAENh3ICgTo4FAEBAQEBAQGBCoQkAQEEeRBRPBsZiDIByloBAQgigk+DXYllbAcXhBUFjHhxh26He4UDmn4fAQFCghEcgVc7M4p9AQEB X-IPAS-Result: A2ChCgBC8PZV/5tjdVtdGQEBAYMHgT2BTKdiAQEBAQEBBQGBCgGSfAENh3ICgTo4FAEBAQEBAQGBCoQkAQEEeRBRPBsZiDIByloBAQgigk+DXYllbAcXhBUFjHhxh26He4UDmn4fAQFCghEcgVc7M4p9AQEB X-IronPort-AV: E=Sophos;i="5.17,529,1437429600"; d="scan'208";a="21718882" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 14 Sep 2015 18:07:44 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZbWIC-0004uU-IW; Mon, 14 Sep 2015 18:07:44 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZbWCq-0004ch-6X; Mon, 14 Sep 2015 19:02:12 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Mon, 14 Sep 2015 19:01:37 +0300 Message-Id: X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v4 1/4] block: rename BlockdevSnapshot to BlockdevSnapshotSync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 16:07:52 -0000 We will introduce the 'blockdev-snapshot' command that will require its own struct for the parameters, so we need to rename this one in order to avoid name clashes. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake --- blockdev.c | 2 +- qapi-schema.json | 2 +- qapi/block-core.json | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/blockdev.c b/blockdev.c index 3f42863..6b787c1 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1166,7 +1166,7 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, bool has_format, const char *format, bool has_mode, NewImageMode mode, Error **errp) { - BlockdevSnapshot snapshot = { + BlockdevSnapshotSync snapshot = { .has_device = has_device, .device = (char *) device, .has_node_name = has_node_name, diff --git a/qapi-schema.json b/qapi-schema.json index 1521eb7..c32dc20 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1496,7 +1496,7 @@ ## { 'union': 'TransactionAction', 'data': { - 'blockdev-snapshot-sync': 'BlockdevSnapshot', + 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', 'drive-backup': 'DriveBackup', 'blockdev-backup': 'BlockdevBackup', 'abort': 'Abort', diff --git a/qapi/block-core.json b/qapi/block-core.json index cb99cad..ec50f06 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -682,7 +682,7 @@ 'data': [ 'existing', 'absolute-paths' ] } ## -# @BlockdevSnapshot +# @BlockdevSnapshotSync # # Either @device or @node-name must be set but not both. # @@ -699,7 +699,7 @@ # @mode: #optional whether and how QEMU should create a new image, default is # 'absolute-paths'. ## -{ 'struct': 'BlockdevSnapshot', +{ 'struct': 'BlockdevSnapshotSync', 'data': { '*device': 'str', '*node-name': 'str', 'snapshot-file': 'str', '*snapshot-node-name': 'str', '*format': 'str', '*mode': 'NewImageMode' } } @@ -790,7 +790,7 @@ # # Generates a synchronous snapshot of a block device. # -# For the arguments, see the documentation of BlockdevSnapshot. +# For the arguments, see the documentation of BlockdevSnapshotSync. # # Returns: nothing on success # If @device is not a valid block device, DeviceNotFound @@ -798,7 +798,7 @@ # Since 0.14.0 ## { 'command': 'blockdev-snapshot-sync', - 'data': 'BlockdevSnapshot' } + 'data': 'BlockdevSnapshotSync' } ## # @change-backing-file -- 2.5.1 From MAILER-DAEMON Mon Sep 14 12:07:56 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbWIO-0001xr-It for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 12:07:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbWIK-0001sU-Mc for qemu-block@nongnu.org; Mon, 14 Sep 2015 12:07:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbWII-00065E-UF for qemu-block@nongnu.org; Mon, 14 Sep 2015 12:07:52 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:51696 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbWIE-0005my-1U; Mon, 14 Sep 2015 12:07:46 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2ChCgBC8PZV/5tjdVtdGQEBAYMHgT2BTKdiAQEBAQEBBQGBCgGSfAENh3ICgTo4FAEBAQEBAQGBCoQkAQEEJ1IQUTwbGRuIFwHKWgErhiyJZWwHhCwFhzKFRnGHbox+mn4fAQFCghEcgVc7M4p9AQEB X-IPAS-Result: A2ChCgBC8PZV/5tjdVtdGQEBAYMHgT2BTKdiAQEBAQEBBQGBCgGSfAENh3ICgTo4FAEBAQEBAQGBCoQkAQEEJ1IQUTwbGRuIFwHKWgErhiyJZWwHhCwFhzKFRnGHbox+mn4fAQFCghEcgVc7M4p9AQEB X-IronPort-AV: E=Sophos;i="5.17,529,1437429600"; d="scan'208";a="21718867" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 14 Sep 2015 18:07:42 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZbWIA-0004uU-Ik; Mon, 14 Sep 2015 18:07:42 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZbWCq-0004cp-8X; Mon, 14 Sep 2015 19:02:12 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Mon, 14 Sep 2015 19:01:39 +0300 Message-Id: <0feb7566cff42d8625ed7263de73fc59225e125f.1442245236.git.berto@igalia.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v4 3/4] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 16:07:54 -0000 One of the limitations of the 'blockdev-snapshot-sync' command is that it does not allow passing BlockdevOptions to the newly created snapshots, so they are always opened using the default values. Extending the command to allow passing options is not a practical solution because there is overlap between those options and some of the existing parameters of the command. This patch introduces a new 'blockdev-snapshot' command with a simpler interface: it just takes two references to existing block devices that will be used as the source and target for the snapshot. Since the main difference between the two commands is that one of them creates and opens the target image, while the other uses an already opened one, the bulk of the implementation is shared. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Cc: Max Reitz --- blockdev.c | 163 ++++++++++++++++++++++++++++++++------------------- qapi-schema.json | 2 + qapi/block-core.json | 28 +++++++++ qmp-commands.hx | 38 ++++++++++++ 4 files changed, 171 insertions(+), 60 deletions(-) diff --git a/blockdev.c b/blockdev.c index 6b787c1..18fdb5c 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1183,6 +1183,18 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, &snapshot, errp); } +void qmp_blockdev_snapshot(const char *device, const char *snapshot, + Error **errp) +{ + BlockdevSnapshot snapshot_data = { + .device = (char *) device, + .snapshot = (char *) snapshot + }; + + blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT, + &snapshot_data, errp); +} + void qmp_blockdev_snapshot_internal_sync(const char *device, const char *name, Error **errp) @@ -1521,57 +1533,48 @@ typedef struct ExternalSnapshotState { static void external_snapshot_prepare(BlkTransactionState *common, Error **errp) { - int flags, ret; - QDict *options; + int flags = 0, ret; + QDict *options = NULL; Error *local_err = NULL; - bool has_device = false; + /* Device and node name of the image to generate the snapshot from */ const char *device; - bool has_node_name = false; const char *node_name; - bool has_snapshot_node_name = false; - const char *snapshot_node_name; + /* Reference to the new image (for 'blockdev-snapshot') */ + const char *snapshot_ref; + /* File name of the new image (for 'blockdev-snapshot-sync') */ const char *new_image_file; - const char *format = "qcow2"; - enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; ExternalSnapshotState *state = DO_UPCAST(ExternalSnapshotState, common, common); TransactionAction *action = common->action; - /* get parameters */ - g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC); - - has_device = action->blockdev_snapshot_sync->has_device; - device = action->blockdev_snapshot_sync->device; - has_node_name = action->blockdev_snapshot_sync->has_node_name; - node_name = action->blockdev_snapshot_sync->node_name; - has_snapshot_node_name = - action->blockdev_snapshot_sync->has_snapshot_node_name; - snapshot_node_name = action->blockdev_snapshot_sync->snapshot_node_name; - - new_image_file = action->blockdev_snapshot_sync->snapshot_file; - if (action->blockdev_snapshot_sync->has_format) { - format = action->blockdev_snapshot_sync->format; - } - if (action->blockdev_snapshot_sync->has_mode) { - mode = action->blockdev_snapshot_sync->mode; + /* 'blockdev-snapshot' and 'blockdev-snapshot-sync' have similar + * purpose but a different set of parameters */ + switch (action->kind) { + case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT: + { + BlockdevSnapshot *s = action->blockdev_snapshot; + device = s->device; + node_name = s->device; + new_image_file = NULL; + snapshot_ref = s->snapshot; + } + break; + case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC: + { + BlockdevSnapshotSync *s = action->blockdev_snapshot_sync; + device = s->has_device ? s->device : NULL; + node_name = s->has_node_name ? s->node_name : NULL; + new_image_file = s->snapshot_file; + snapshot_ref = NULL; + } + break; + default: + g_assert_not_reached(); } /* start processing */ - state->old_bs = bdrv_lookup_bs(has_device ? device : NULL, - has_node_name ? node_name : NULL, - &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - - if (has_node_name && !has_snapshot_node_name) { - error_setg(errp, "New snapshot node name missing"); - return; - } - - if (has_snapshot_node_name && bdrv_find_node(snapshot_node_name)) { - error_setg(errp, "New snapshot node name already existing"); + state->old_bs = bdrv_lookup_bs(device, node_name, errp); + if (!state->old_bs) { return; } @@ -1601,35 +1604,69 @@ static void external_snapshot_prepare(BlkTransactionState *common, return; } - flags = state->old_bs->open_flags; + if (action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC) { + BlockdevSnapshotSync *s = action->blockdev_snapshot_sync; + const char *format = s->has_format ? s->format : "qcow2"; + enum NewImageMode mode; + const char *snapshot_node_name = + s->has_snapshot_node_name ? s->snapshot_node_name : NULL; - /* create new image w/backing file */ - if (mode != NEW_IMAGE_MODE_EXISTING) { - bdrv_img_create(new_image_file, format, - state->old_bs->filename, - state->old_bs->drv->format_name, - NULL, -1, flags, &local_err, false); - if (local_err) { - error_propagate(errp, local_err); + if (node_name && !snapshot_node_name) { + error_setg(errp, "New snapshot node name missing"); return; } - } - options = qdict_new(); - if (has_snapshot_node_name) { - qdict_put(options, "node-name", - qstring_from_str(snapshot_node_name)); + if (snapshot_node_name && bdrv_find_node(snapshot_node_name)) { + error_setg(errp, "New snapshot node name already exists"); + return; + } + + flags = state->old_bs->open_flags; + + /* create new image w/backing file */ + mode = s->has_mode ? s->mode : NEW_IMAGE_MODE_ABSOLUTE_PATHS; + if (mode != NEW_IMAGE_MODE_EXISTING) { + bdrv_img_create(new_image_file, format, + state->old_bs->filename, + state->old_bs->drv->format_name, + NULL, -1, flags, &local_err, false); + if (local_err) { + error_propagate(errp, local_err); + return; + } + } + + options = qdict_new(); + if (s->has_snapshot_node_name) { + qdict_put(options, "node-name", + qstring_from_str(snapshot_node_name)); + } + qdict_put(options, "driver", qstring_from_str(format)); + + flags |= BDRV_O_NO_BACKING; } - qdict_put(options, "driver", qstring_from_str(format)); - /* TODO Inherit bs->options or only take explicit options with an - * extended QMP command? */ assert(state->new_bs == NULL); - ret = bdrv_open(&state->new_bs, new_image_file, NULL, options, - flags | BDRV_O_NO_BACKING, &local_err); + ret = bdrv_open(&state->new_bs, new_image_file, snapshot_ref, options, + flags, errp); /* We will manually add the backing_hd field to the bs later */ if (ret != 0) { - error_propagate(errp, local_err); + return; + } + + if (state->new_bs->blk != NULL) { + error_setg(errp, "The snapshot is already in use by %s", + blk_name(state->new_bs->blk)); + return; + } + + if (bdrv_op_is_blocked(state->new_bs, BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT, + errp)) { + return; + } + + if (state->new_bs->backing_hd != NULL) { + error_setg(errp, "The snapshot already has a backing image"); } } @@ -1818,6 +1855,12 @@ static void abort_commit(BlkTransactionState *common) } static const BdrvActionOps actions[] = { + [TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT] = { + .instance_size = sizeof(ExternalSnapshotState), + .prepare = external_snapshot_prepare, + .commit = external_snapshot_commit, + .abort = external_snapshot_abort, + }, [TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC] = { .instance_size = sizeof(ExternalSnapshotState), .prepare = external_snapshot_prepare, diff --git a/qapi-schema.json b/qapi-schema.json index c32dc20..71dacea 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1493,9 +1493,11 @@ # abort since 1.6 # blockdev-snapshot-internal-sync since 1.7 # blockdev-backup since 2.3 +# blockdev-snapshot since 2.5 ## { 'union': 'TransactionAction', 'data': { + 'blockdev-snapshot': 'BlockdevSnapshot', 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', 'drive-backup': 'DriveBackup', 'blockdev-backup': 'BlockdevBackup', diff --git a/qapi/block-core.json b/qapi/block-core.json index ec50f06..328c155 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -705,6 +705,21 @@ '*format': 'str', '*mode': 'NewImageMode' } } ## +# @BlockdevSnapshot +# +# @device: device or node name to generate the snapshot from. +# +# @snapshot: reference to the existing block device that will be used +# for the snapshot. It must not have a current backing file +# (this can be achieved by passing "backing": "" to +# blockdev-add). +# +# Since 2.5 +## +{ 'struct': 'BlockdevSnapshot', + 'data': { 'device': 'str', 'snapshot': 'str' } } + +## # @DriveBackup # # @device: the name of the device which should be copied. @@ -800,6 +815,19 @@ { 'command': 'blockdev-snapshot-sync', 'data': 'BlockdevSnapshotSync' } + +## +# @blockdev-snapshot +# +# Generates a snapshot of a block device. +# +# For the arguments, see the documentation of BlockdevSnapshot. +# +# Since 2.5 +## +{ 'command': 'blockdev-snapshot', + 'data': 'BlockdevSnapshot' } + ## # @change-backing-file # diff --git a/qmp-commands.hx b/qmp-commands.hx index 495670b..516f935 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1454,6 +1454,44 @@ Example: EQMP { + .name = "blockdev-snapshot", + .args_type = "device:s,snapshot:s", + .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot, + }, + +SQMP +blockdev-snapshot +----------------- +Since 2.5 + +Create a snapshot, by installing 'device' as the backing image of +'snapshot'. Additionally, if 'device' is associated with a block +device, the block device changes to using 'snapshot' as its new active +image. + +Arguments: + +- "device": snapshot source (json-string) +- "snapshot": snapshot target (json-string) + +Example: + +-> { "execute": "blockdev-add", + "arguments": { "options": { "driver": "qcow2", + "node-name": "node1534", + "file": { "driver": "file", + "filename": "hd1.qcow2" }, + "backing": "" } } } + +<- { "return": {} } + +-> { "execute": "blockdev-snapshot", "arguments": { "device": "ide-hd0", + "snapshot": "node1534" } } +<- { "return": {} } + +EQMP + + { .name = "blockdev-snapshot-internal-sync", .args_type = "device:B,name:s", .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot_internal_sync, -- 2.5.1 From MAILER-DAEMON Mon Sep 14 12:07:57 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbWIP-000205-Qv for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 12:07:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbWIK-0001rx-Aw for qemu-block@nongnu.org; Mon, 14 Sep 2015 12:07:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbWII-00064F-L9 for qemu-block@nongnu.org; Mon, 14 Sep 2015 12:07:52 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:51687 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbWID-0005hk-Km; Mon, 14 Sep 2015 12:07:45 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BmAwBC8PZV/5tjdVtdGQEBAYMHgT2pLgEBAQEBAQUBgQoBknwBDYQ8gzYCgTo4FAEBAQEBAQGBCoQkAQEEeRBRPBsZiDIByloBK4YsilEHhCwFjHhxh26Mfpp+HwEBQoQEOzOKfQEBAQ X-IPAS-Result: A2BmAwBC8PZV/5tjdVtdGQEBAYMHgT2pLgEBAQEBAQUBgQoBknwBDYQ8gzYCgTo4FAEBAQEBAQGBCoQkAQEEeRBRPBsZiDIByloBK4YsilEHhCwFjHhxh26Mfpp+HwEBQoQEOzOKfQEBAQ X-IronPort-AV: E=Sophos;i="5.17,529,1437429600"; d="scan'208";a="21718861" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 14 Sep 2015 18:07:40 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZbWI8-0004uU-LU; Mon, 14 Sep 2015 18:07:40 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZbWCq-0004ct-9B; Mon, 14 Sep 2015 19:02:12 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Mon, 14 Sep 2015 19:01:40 +0300 Message-Id: <2a2e8ccd4899f5ca09940792f8469d90f0e762f5.1442245236.git.berto@igalia.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v4 4/4] block: add tests for the 'blockdev-snapshot' command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 16:07:57 -0000 Signed-off-by: Alberto Garcia --- tests/qemu-iotests/085 | 102 ++++++++++++++++++++++++++++++++++++++++++--- tests/qemu-iotests/085.out | 34 ++++++++++++++- 2 files changed, 128 insertions(+), 8 deletions(-) diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085 index 56cd6f8..532eb0e 100755 --- a/tests/qemu-iotests/085 +++ b/tests/qemu-iotests/085 @@ -7,6 +7,7 @@ # snapshots are performed. # # Copyright (C) 2014 Red Hat, Inc. +# Copyright (C) 2015 Igalia, S.L. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,17 +35,17 @@ status=1 # failure is the default! snapshot_virt0="snapshot-v0.qcow2" snapshot_virt1="snapshot-v1.qcow2" -MAX_SNAPSHOTS=10 +SNAPSHOTS=10 _cleanup() { _cleanup_qemu - for i in $(seq 1 ${MAX_SNAPSHOTS}) + for i in $(seq 1 ${SNAPSHOTS}) do rm -f "${TEST_DIR}/${i}-${snapshot_virt0}" rm -f "${TEST_DIR}/${i}-${snapshot_virt1}" done - _cleanup_test_img + rm -f "${TEST_IMG}.1" "${TEST_IMG}.2" } trap "_cleanup; exit \$status" 0 1 2 3 15 @@ -85,18 +86,50 @@ function create_group_snapshot() _send_qemu_cmd $h "${cmd}" "return" } +# ${1}: unique identifier for the snapshot filename +# ${2}: true: open backing images; false: don't open them (default) +function add_snapshot_image() +{ + if [ "${2}" = "true" ]; then + extra_params="" + else + extra_params="'backing': '', " + fi + base_image="${TEST_DIR}/$((${1}-1))-${snapshot_virt0}" + snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}" + _make_test_img -b "${base_image}" "$size" + mv "${TEST_IMG}" "${snapshot_file}" + cmd="{ 'execute': 'blockdev-add', 'arguments': + { 'options': + { 'driver': 'qcow2', 'node-name': 'snap_"${1}"', "${extra_params}" + 'file': + { 'driver': 'file', 'filename': '"${snapshot_file}"' } } } }" + _send_qemu_cmd $h "${cmd}" "return" +} + +# ${1}: unique identifier for the snapshot filename +# ${2}: expected response, defaults to 'return' +function blockdev_snapshot() +{ + cmd="{ 'execute': 'blockdev-snapshot', + 'arguments': { 'device': 'virtio0', + 'snapshot':'snap_"${1}"' } }" + _send_qemu_cmd $h "${cmd}" "${2:-return}" +} + size=128M _make_test_img $size -mv "${TEST_IMG}" "${TEST_IMG}.orig" +mv "${TEST_IMG}" "${TEST_IMG}.1" _make_test_img $size +mv "${TEST_IMG}" "${TEST_IMG}.2" echo echo === Running QEMU === echo qemu_comm_method="qmp" -_launch_qemu -drive file="${TEST_IMG}.orig",if=virtio -drive file="${TEST_IMG}",if=virtio +_launch_qemu -drive file="${TEST_IMG}.1",if=virtio -drive file="${TEST_IMG}.2",if=virtio h=$QEMU_HANDLE echo @@ -105,6 +138,8 @@ echo _send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return" +# Tests for the blockdev-snapshot-sync command + echo echo === Create a single snapshot on virtio0 === echo @@ -132,11 +167,66 @@ echo echo === Create several transactional group snapshots === echo -for i in $(seq 2 ${MAX_SNAPSHOTS}) +for i in $(seq 2 ${SNAPSHOTS}) do create_group_snapshot ${i} done +# Tests for the blockdev-snapshot command + +echo +echo === Create a couple of snapshots using blockdev-snapshot === +echo + +SNAPSHOTS=$((${SNAPSHOTS}+1)) +add_snapshot_image ${SNAPSHOTS} +blockdev_snapshot ${SNAPSHOTS} + +SNAPSHOTS=$((${SNAPSHOTS}+1)) +add_snapshot_image ${SNAPSHOTS} +blockdev_snapshot ${SNAPSHOTS} + +echo +echo === Invalid command - snapshot node used as active layer === +echo + +blockdev_snapshot ${SNAPSHOTS} error + +_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot', + 'arguments': { 'device':'virtio0', + 'snapshot':'virtio0' } + }" "error" + +_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot', + 'arguments': { 'device':'virtio0', + 'snapshot':'virtio1' } + }" "error" + +echo +echo === Invalid command - snapshot node used as backing hd === +echo + +blockdev_snapshot $((${SNAPSHOTS}-1)) error + +echo +echo === Invalid command - snapshot node has a backing image === +echo + +SNAPSHOTS=$((${SNAPSHOTS}+1)) +add_snapshot_image ${SNAPSHOTS} true +blockdev_snapshot ${SNAPSHOTS} error + +echo +echo === Invalid command - The node does not exist === +echo + +blockdev_snapshot $((${SNAPSHOTS}+1)) error + +_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot', + 'arguments': { 'device':'nodevice', + 'snapshot':'snap_"${SNAPSHOTS}"' } + }" "error" + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out index 5eb8b94..2238f6d 100644 --- a/tests/qemu-iotests/085.out +++ b/tests/qemu-iotests/085.out @@ -11,7 +11,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 === Create a single snapshot on virtio0 === -Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/t.qcow2.orig' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 +Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/t.qcow2.1' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 {"return": {}} === Invalid command - missing device and nodename === @@ -26,7 +26,7 @@ Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file === Create several transactional group snapshots === Formatting 'TEST_DIR/2-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/1-snapshot-v0.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 -Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/t.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 +Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/t.qcow2.2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 {"return": {}} Formatting 'TEST_DIR/3-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/2-snapshot-v0.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/3-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/2-snapshot-v1.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 @@ -52,4 +52,34 @@ Formatting 'TEST_DIR/9-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file Formatting 'TEST_DIR/10-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/9-snapshot-v0.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file='TEST_DIR/9-snapshot-v1.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 {"return": {}} + +=== Create a couple of snapshots using blockdev-snapshot === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file='TEST_DIR/10-snapshot-v0.IMGFMT' +{"return": {}} +{"return": {}} +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file='TEST_DIR/11-snapshot-v0.IMGFMT' +{"return": {}} +{"return": {}} + +=== Invalid command - snapshot node used as active layer === + +{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio0"}} +{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio0"}} +{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio1"}} + +=== Invalid command - snapshot node used as backing hd === + +{"error": {"class": "GenericError", "desc": "Node 'snap_11' is busy: node is used as backing hd of 'virtio0'"}} + +=== Invalid command - snapshot node has a backing image === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file='TEST_DIR/12-snapshot-v0.IMGFMT' +{"return": {}} +{"error": {"class": "GenericError", "desc": "The snapshot already has a backing image"}} + +=== Invalid command - The node does not exist === + +{"error": {"class": "GenericError", "desc": "Cannot find device=snap_14 nor node_name=snap_14"}} +{"error": {"class": "GenericError", "desc": "Cannot find device=nodevice nor node_name=nodevice"}} *** done -- 2.5.1 From MAILER-DAEMON Mon Sep 14 12:08:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbWIT-00024p-Td for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 12:08:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbWIO-0001yn-Ve for qemu-block@nongnu.org; Mon, 14 Sep 2015 12:08:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbWIJ-00065o-1K for qemu-block@nongnu.org; Mon, 14 Sep 2015 12:07:56 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:51688 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbWID-0005hl-Kt; Mon, 14 Sep 2015 12:07:45 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AVAwBC8PZV/5tjdVtdGQEBAYMHVGmpKQUBAQEBAQEFAYEKAZJ8AQ2BTSIKhXmBPDgUAQEBAQEBAYEKhCYBBAIkUoEJFIhmAQjKegSGLIpRHoQVBYcyhUZxh26FDYUPgmKBTJB9iDUfAQFCgUoBgjk7MwGKfAEBAQ X-IPAS-Result: A2AVAwBC8PZV/5tjdVtdGQEBAYMHVGmpKQUBAQEBAQEFAYEKAZJ8AQ2BTSIKhXmBPDgUAQEBAQEBAYEKhCYBBAIkUoEJFIhmAQjKegSGLIpRHoQVBYcyhUZxh26FDYUPgmKBTJB9iDUfAQFCgUoBgjk7MwGKfAEBAQ X-IronPort-AV: E=Sophos;i="5.17,529,1437429600"; d="scan'208";a="21718865" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 14 Sep 2015 18:07:41 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZbWI9-0004uU-K9; Mon, 14 Sep 2015 18:07:41 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZbWCq-0004cd-5U; Mon, 14 Sep 2015 19:02:12 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Mon, 14 Sep 2015 19:01:36 +0300 Message-Id: X-Mailer: git-send-email 2.5.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v4 0/4] Add 'blockdev-snapshot' command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 16:08:00 -0000 This version uses 'backing': '' instead of 'ignore-backing' as discussed in the previous thread. Regards, Berto v4: - Implement the support for 'backing': '', drop 'ignore-backing', and update iotest 085 accordingly. - Include sample 'blockdev-add' call in the 'blockdev-snapshot' documentation. - Clarify that the snapshot must not have a backing file in the BlockdevSnapshot documentation. - Update error message ("...node name already existing" -> "...exists"). v3: https://lists.gnu.org/archive/html/qemu-block/2015-09/msg00272.html - Add 'ignore-backing' field to BlockdevOptionsGenericCOWFormat. This allows opening images but not their backing images. - Check for op blockers in the snapshot node and make sure that it doesn't have any backing image. - Remove extra check for the existence of the snapshot node: bdrv_open() already does that. - Extend iotest 085 to add tests for 'blockdev-snapshot'. - Replace local_err with errp in some places where the former is unnecessary. - Update command description. - Add 'since' tag to the 'blockdev-snapshot' field in TransactionAction. v2: https://lists.gnu.org/archive/html/qemu-block/2015-09/msg00094.html - Add 'blockdev-snapshot' command instead of allowing passing options to 'blockdev-snapshot-sync'. - Rename BlockdevSnapshot to BlockdevSnapshotSync v1: https://lists.gnu.org/archive/html/qemu-block/2015-08/msg00236.html Alberto Garcia (4): block: rename BlockdevSnapshot to BlockdevSnapshotSync block: support passing 'backing': '' to 'blockdev-add' block: add a 'blockdev-snapshot' QMP command block: add tests for the 'blockdev-snapshot' command block.c | 7 ++ blockdev.c | 165 ++++++++++++++++++++++++++++----------------- qapi-schema.json | 4 +- qapi/block-core.json | 34 +++++++++- qmp-commands.hx | 38 +++++++++++ tests/qemu-iotests/085 | 102 ++++++++++++++++++++++++++-- tests/qemu-iotests/085.out | 34 +++++++++- 7 files changed, 311 insertions(+), 73 deletions(-) -- 2.5.1 From MAILER-DAEMON Mon Sep 14 12:07:56 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbWIO-0001yC-Nh for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 12:07:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbWIL-0001tI-R6 for qemu-block@nongnu.org; Mon, 14 Sep 2015 12:07:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbWIH-00061g-Up for qemu-block@nongnu.org; Mon, 14 Sep 2015 12:07:53 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:51688 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbWIE-0005hl-9m; Mon, 14 Sep 2015 12:07:46 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AFAwBC8PZV/5tjdVtdGQEBAYMHgT2pLgEBAQEBAQUBgQoBknwBDYdyAoE6OBQBAQEBAQEBgQqEJAEBBCdSEFE8GxmIMgHKWgEBCCKGLIpRBxeEFQWNaYdujH6afh8BAUKEBDszin0BAQE X-IPAS-Result: A2AFAwBC8PZV/5tjdVtdGQEBAYMHgT2pLgEBAQEBAQUBgQoBknwBDYdyAoE6OBQBAQEBAQEBgQqEJAEBBCdSEFE8GxmIMgHKWgEBCCKGLIpRBxeEFQWNaYdujH6afh8BAUKEBDszin0BAQE X-IronPort-AV: E=Sophos;i="5.17,529,1437429600"; d="scan'208";a="21718874" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 14 Sep 2015 18:07:43 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZbWIB-0004uU-J4; Mon, 14 Sep 2015 18:07:43 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZbWCq-0004cl-7k; Mon, 14 Sep 2015 19:02:12 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Mon, 14 Sep 2015 19:01:38 +0300 Message-Id: X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v4 2/4] block: support passing 'backing': '' to 'blockdev-add' X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 16:07:54 -0000 Passing an empty string allows opening an image but not its backing file. This was already described in the API documentation, only the implementation was missing. This is useful for creating snapshots using images opened with blockdev-add, since they are not supposed to have a backing image before the operation. Signed-off-by: Alberto Garcia --- block.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block.c b/block.c index 22d3b0e..ad1792d 100644 --- a/block.c +++ b/block.c @@ -1402,6 +1402,7 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, BlockDriverState *file = NULL, *bs; BlockDriver *drv = NULL; const char *drvname; + const char *backing; Error *local_err = NULL; int snapshot_flags = 0; @@ -1469,6 +1470,12 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, assert(drvname || !(flags & BDRV_O_PROTOCOL)); + backing = qdict_get_try_str(options, "backing"); + if (backing && *backing == '\0') { + flags |= BDRV_O_NO_BACKING; + } + qdict_del(options, "backing"); + bs->open_flags = flags; bs->options = options; options = qdict_clone_shallow(options); -- 2.5.1 From MAILER-DAEMON Mon Sep 14 12:10:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbWKP-0003F8-Ta for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 12:10:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbWKL-0003D1-5n for qemu-block@nongnu.org; Mon, 14 Sep 2015 12:09:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbWKH-0003yN-U2 for qemu-block@nongnu.org; Mon, 14 Sep 2015 12:09:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39695) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbWKH-0003xy-Nf; Mon, 14 Sep 2015 12:09:53 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 3C425C057874; Mon, 14 Sep 2015 16:09:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-64.ams2.redhat.com [10.36.116.64]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EG9pkB032474 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 14 Sep 2015 12:09:52 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 11953303F90D; Mon, 14 Sep 2015 18:09:51 +0200 (CEST) From: Markus Armbruster To: Kevin Wolf References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> <87mvwpkqzi.fsf@blackfin.pond.sub.org> <20150914153444.GD3550@noname.str.redhat.com> Date: Mon, 14 Sep 2015 18:09:51 +0200 In-Reply-To: <20150914153444.GD3550@noname.str.redhat.com> (Kevin Wolf's message of "Mon, 14 Sep 2015 17:34:44 +0200") Message-ID: <87lhc9kmnk.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 16:09:59 -0000 Kevin Wolf writes: > Am 14.09.2015 um 16:36 hat Markus Armbruster geschrieben: >> Wen Congyang writes: >> > diff --git a/qmp-commands.hx b/qmp-commands.hx >> > index 495670b..139a23b 100644 >> > --- a/qmp-commands.hx >> > +++ b/qmp-commands.hx >> > @@ -4053,6 +4053,59 @@ Example: >> > EQMP >> > >> > { >> > + .name = "x-child-add", >> > + .args_type = "parent:B,child:B", >> > + .mhandler.cmd_new = qmp_marshal_input_x_child_add, >> > + }, >> > + >> > +SQMP >> > +x-child-add >> > +------------ >> > + >> > +Add a child to a quorum node. >> > + >> > +Arguments: >> > + >> > +- "parent": the quorum's id or node name >> > +- "child": the child node-name which will be added >> >> Node name parameters are usually named node-name or, if there's more >> than one, FOO-node-name. Unless we want to abandon that convention, >> this should therefore be node-name and child-node-name, or parent-node >> name and child-node-name. > > Didn't we come to the conclusion that foo-node-name is redundant and > should just be foo, leaving things like node-name only for cases where > there is no foo? I don't remember :) I'm fine with simpler names. From MAILER-DAEMON Mon Sep 14 14:01:36 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbY4N-0004XV-Jo for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 14:01:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbY4K-0004RU-Ix for qemu-block@nongnu.org; Mon, 14 Sep 2015 14:01:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbY4G-0002Wt-Hl for qemu-block@nongnu.org; Mon, 14 Sep 2015 14:01:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48762) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbY4G-0002Vn-9x; Mon, 14 Sep 2015 14:01:28 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id E8F958C1A6; Mon, 14 Sep 2015 18:01:27 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EI1QW0007063; Mon, 14 Sep 2015 14:01:27 -0400 From: John Snow To: qemu-block@nongnu.org Date: Mon, 14 Sep 2015 14:01:25 -0400 Message-Id: <1442253685-23349-2-git-send-email-jsnow@redhat.com> In-Reply-To: <1442253685-23349-1-git-send-email-jsnow@redhat.com> References: <1442253685-23349-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PATCH v3 1/1] atapi: abort transfers with 0 byte limits X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 18:01:33 -0000 We're supposed to abort on transfers like this, unless we fill Word 125 of our IDENTIFY data with a default transfer size, which we don't currently do. This is an ATA error, not a SCSI/ATAPI one. See ATA8-ACS3 sections 7.17.6.49 or 7.21.5. If we don't do this, QEMU will loop forever trying to transfer zero bytes, which isn't particularly useful. Signed-off-by: John Snow --- hw/ide/atapi.c | 32 +++++++++++++++++++++++++++----- hw/ide/core.c | 2 +- hw/ide/internal.h | 1 + 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 79dd167..747f466 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -1169,20 +1169,28 @@ enum { * 4.1.8) */ CHECK_READY = 0x02, + + /* + * Commands flagged with NONDATA do not in any circumstances return + * any data via ide_atapi_cmd_reply. These commands are exempt from + * the normal byte_count_limit constraints. + * See ATA8-ACS3 "7.21.5 Byte Count Limit" + */ + NONDATA = 0x04, }; static const struct { void (*handler)(IDEState *s, uint8_t *buf); int flags; } atapi_cmd_table[0x100] = { - [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY }, + [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY | NONDATA }, [ 0x03 ] = { cmd_request_sense, ALLOW_UA }, [ 0x12 ] = { cmd_inquiry, ALLOW_UA }, - [ 0x1b ] = { cmd_start_stop_unit, 0 }, /* [1] */ - [ 0x1e ] = { cmd_prevent_allow_medium_removal, 0 }, + [ 0x1b ] = { cmd_start_stop_unit, NONDATA }, /* [1] */ + [ 0x1e ] = { cmd_prevent_allow_medium_removal, NONDATA }, [ 0x25 ] = { cmd_read_cdvd_capacity, CHECK_READY }, [ 0x28 ] = { cmd_read, /* (10) */ CHECK_READY }, - [ 0x2b ] = { cmd_seek, CHECK_READY }, + [ 0x2b ] = { cmd_seek, CHECK_READY | NONDATA }, [ 0x43 ] = { cmd_read_toc_pma_atip, CHECK_READY }, [ 0x46 ] = { cmd_get_configuration, ALLOW_UA }, [ 0x4a ] = { cmd_get_event_status_notification, ALLOW_UA }, @@ -1190,7 +1198,7 @@ static const struct { [ 0x5a ] = { cmd_mode_sense, /* (10) */ 0 }, [ 0xa8 ] = { cmd_read, /* (12) */ CHECK_READY }, [ 0xad ] = { cmd_read_dvd_structure, CHECK_READY }, - [ 0xbb ] = { cmd_set_speed, 0 }, + [ 0xbb ] = { cmd_set_speed, NONDATA }, [ 0xbd ] = { cmd_mechanism_status, 0 }, [ 0xbe ] = { cmd_read_cd, CHECK_READY }, /* [1] handler detects and reports not ready condition itself */ @@ -1251,6 +1259,20 @@ void ide_atapi_cmd(IDEState *s) return; } + /* Nondata commands permit the byte_count_limit to be 0. + * If this is a data-transferring PIO command and BCL is 0, + * we abort at the /ATA/ level, not the ATAPI level. + * See ATA8 ACS3 section 7.17.6.49 and 7.21.5 */ + if (!(atapi_cmd_table[s->io_buffer[0]].flags & NONDATA)) { + /* TODO: Check IDENTIFY data word 125 for default BCL (currently 0) */ + uint16_t byte_count_limit = s->lcyl | (s->hcyl << 8); + if (!(byte_count_limit || s->atapi_dma)) { + /* TODO: Move abort back into core.c and make static inline again */ + ide_abort_command(s); + return; + } + } + /* Execute the command */ if (atapi_cmd_table[s->io_buffer[0]].handler) { atapi_cmd_table[s->io_buffer[0]].handler(s, buf); diff --git a/hw/ide/core.c b/hw/ide/core.c index 50449ca..28cf535 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -457,7 +457,7 @@ BlockAIOCB *ide_issue_trim(BlockBackend *blk, return &iocb->common; } -static inline void ide_abort_command(IDEState *s) +void ide_abort_command(IDEState *s) { ide_transfer_stop(s); s->status = READY_STAT | ERR_STAT; diff --git a/hw/ide/internal.h b/hw/ide/internal.h index 30fdcbc..40e1aa4 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -537,6 +537,7 @@ void ide_set_sector(IDEState *s, int64_t sector_num); void ide_start_dma(IDEState *s, BlockCompletionFunc *cb); void ide_dma_error(IDEState *s); +void ide_abort_command(IDEState *s); void ide_atapi_cmd_ok(IDEState *s); void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc); -- 2.4.3 From MAILER-DAEMON Mon Sep 14 14:01:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbY4S-0004gd-Ir for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 14:01:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbY4L-0004Tf-Ff for qemu-block@nongnu.org; Mon, 14 Sep 2015 14:01:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbY4F-0002Up-PX for qemu-block@nongnu.org; Mon, 14 Sep 2015 14:01:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54650) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbY4F-0002Ty-L4; Mon, 14 Sep 2015 14:01:27 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 47814461D6; Mon, 14 Sep 2015 18:01:27 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EI1QVx007063; Mon, 14 Sep 2015 14:01:26 -0400 From: John Snow To: qemu-block@nongnu.org Date: Mon, 14 Sep 2015 14:01:24 -0400 Message-Id: <1442253685-23349-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [PATCH v3 0/1] atapi: abort transfers with 0 byte limits X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 18:01:39 -0000 v3: Sigh, fix my thinko: "if (!(...))", not "if !(...)" v2: Make sure we only abort PIO commands if BCL is zero, not DMA. ________________________________________________________________________________ For convenience, this branch is available at: https://github.com/jnsnow/qemu.git branch atapi-bclimit https://github.com/jnsnow/qemu/tree/atapi-bclimit This version is tagged atapi-bclimit-v3: https://github.com/jnsnow/qemu/releases/tag/atapi-bclimit-v3 John Snow (1): atapi: abort transfers with 0 byte limits hw/ide/atapi.c | 32 +++++++++++++++++++++++++++----- hw/ide/core.c | 2 +- hw/ide/internal.h | 1 + 3 files changed, 29 insertions(+), 6 deletions(-) -- 2.4.3 From MAILER-DAEMON Mon Sep 14 14:04:16 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbY6x-0000pb-Vz for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 14:04:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbY6w-0000mK-2s for qemu-block@nongnu.org; Mon, 14 Sep 2015 14:04:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbY6s-0003ZR-Oc for qemu-block@nongnu.org; Mon, 14 Sep 2015 14:04:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49622) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbY6s-0003ZN-JO; Mon, 14 Sep 2015 14:04:10 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id CA81EA2C04; Mon, 14 Sep 2015 18:04:09 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EI46cj013150; Mon, 14 Sep 2015 14:04:08 -0400 To: Michael Tokarev , qemu-block@nongnu.org References: <1441816082-21031-1-git-send-email-jsnow@redhat.com> <55F27B1D.4030901@msgid.tls.msk.ru> From: John Snow Message-ID: <55F70C16.1070302@redhat.com> Date: Mon, 14 Sep 2015 14:04:06 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F27B1D.4030901@msgid.tls.msk.ru> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefano.stabellini@eu.citrix.com, armbru@redhat.com, qemu-devel@nongnu.org, ppandit@redhat.com, luodalongde@gmail.com, liuling-it@360.cn Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] ide: fix ATAPI command permissions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 18:04:15 -0000 On 09/11/2015 02:56 AM, Michael Tokarev wrote: > 09.09.2015 19:28, John Snow wrote: >> We're a little too lenient with what we'll let an ATAPI drive handle. >> Clamp down on the IDE command execution table to remove CD_OK permissions >> from commands that are not and have never been ATAPI commands. > > FWIW, this issue has been assigned CVE-2015-6855 identifier, which > can be reflected in the commit message when applying. Since this > issue has security impact, it might be a good idea to add > > Cc: qemu-stable@nongnu.org > > Thanks, > > /mjt > I'm still awaiting review/acks, but would you like me to re-send this patch to trivial, or just fwd/reply-to? Thanks, --js From MAILER-DAEMON Mon Sep 14 14:09:38 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbYCA-0001UE-Gm for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 14:09:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbYC8-0001PZ-Ap for qemu-block@nongnu.org; Mon, 14 Sep 2015 14:09:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbYC7-0005vn-Ey for qemu-block@nongnu.org; Mon, 14 Sep 2015 14:09:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37816) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbYC7-0005ve-9g; Mon, 14 Sep 2015 14:09:35 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id C84E096C9; Mon, 14 Sep 2015 18:09:33 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EI9W5J016847; Mon, 14 Sep 2015 14:09:32 -0400 To: qemu-block@nongnu.org References: <1441926555-19471-1-git-send-email-jsnow@redhat.com> From: John Snow Message-ID: <55F70D5C.9060409@redhat.com> Date: Mon, 14 Sep 2015 14:09:32 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441926555-19471-1-git-send-email-jsnow@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, zuban32s@gmail.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 0/4] ide: simple ATAPI tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 18:09:37 -0000 On 09/10/2015 07:09 PM, John Snow wrote: > We don't have any CDROM tests yet. > So, add some for the PCI/BMDMA HBA. > > === > v2: > === > > - Some readability feedback from Markus > - Added an IRQ poll for the DRQ read loop > > ________________________________________________________________________________ > > For convenience, this branch is available at: > https://github.com/jnsnow/qemu.git branch ide-atapi-test > https://github.com/jnsnow/qemu/tree/ide-atapi-test > > This version is tagged ide-atapi-test-v2: > https://github.com/jnsnow/qemu/releases/tag/ide-atapi-test-v2 > > John Snow (4): > qtest/ahci: use generate_pattern everywhere > qtest/ahci: export generate_pattern > ide-test: add cdrom pio test > ide-test: add cdrom dma test > > tests/ahci-test.c | 43 +-------- > tests/ide-test.c | 245 ++++++++++++++++++++++++++++++++++++++++++++++---- > tests/libqos/libqos.c | 26 ++++++ > tests/libqos/libqos.h | 1 + > 4 files changed, 258 insertions(+), 57 deletions(-) > Thanks, applied to my IDE tree: https://github.com/jnsnow/qemu/commits/ide https://github.com/jnsnow/qemu.git --js From MAILER-DAEMON Mon Sep 14 14:44:03 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbYjT-0001sp-QF for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 14:44:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbYjS-0001sb-5v for qemu-block@nongnu.org; Mon, 14 Sep 2015 14:44:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbYjP-0001Pn-0z for qemu-block@nongnu.org; Mon, 14 Sep 2015 14:44:02 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:42099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbYjO-0001PI-Px; Mon, 14 Sep 2015 14:43:58 -0400 Received: from tsrv.tls.msk.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id DED3F417C9; Mon, 14 Sep 2015 21:43:48 +0300 (MSK) Received: from [192.168.88.2] (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.tls.msk.ru (Postfix) with ESMTP id C0B09A58; Mon, 14 Sep 2015 21:43:48 +0300 (MSK) Message-ID: <55F71564.1010906@msgid.tls.msk.ru> Date: Mon, 14 Sep 2015 21:43:48 +0300 From: Michael Tokarev Organization: Telecom Service, JSC User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: John Snow , qemu-block@nongnu.org References: <1441816082-21031-1-git-send-email-jsnow@redhat.com> <55F27B1D.4030901@msgid.tls.msk.ru> <55F70C16.1070302@redhat.com> In-Reply-To: <55F70C16.1070302@redhat.com> OpenPGP: id=804465C5 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 86.62.121.231 Cc: kwolf@redhat.com, stefano.stabellini@eu.citrix.com, armbru@redhat.com, qemu-devel@nongnu.org, ppandit@redhat.com, luodalongde@gmail.com, liuling-it@360.cn Subject: Re: [Qemu-block] [PATCH] ide: fix ATAPI command permissions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 18:44:03 -0000 14.09.2015 21:04, John Snow wrote: > On 09/11/2015 02:56 AM, Michael Tokarev wrote: >> 09.09.2015 19:28, John Snow wrote: >>> We're a little too lenient with what we'll let an ATAPI drive handle. >>> Clamp down on the IDE command execution table to remove CD_OK permissions >>> from commands that are not and have never been ATAPI commands. >> >> FWIW, this issue has been assigned CVE-2015-6855 identifier, which >> can be reflected in the commit message when applying. Since this >> issue has security impact, it might be a good idea to add >> >> Cc: qemu-stable@nongnu.org > > I'm still awaiting review/acks, but would you like me to re-send this > patch to trivial, or just fwd/reply-to? I think it is anything but trivial ;) Well, the semantics is trivial, but it isn't -trivial material per se. I suggested add a Cc to qemu-stable, this can be done at commit, together with mentioning the CVE# assigned meanwhile, and I don't know who will commit it, Kevin? Thanks, /mjt From MAILER-DAEMON Mon Sep 14 14:50:00 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbYpE-0004gF-Hi for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 14:50:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbYpC-0004co-Az for qemu-block@nongnu.org; Mon, 14 Sep 2015 14:49:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbYp9-0003Gf-5P for qemu-block@nongnu.org; Mon, 14 Sep 2015 14:49:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38584) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbYp8-0003GO-VI; Mon, 14 Sep 2015 14:49:55 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 473A7341AD9; Mon, 14 Sep 2015 18:49:54 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EInpoH009592; Mon, 14 Sep 2015 14:49:52 -0400 To: Michael Tokarev , qemu-block@nongnu.org References: <1441816082-21031-1-git-send-email-jsnow@redhat.com> <55F27B1D.4030901@msgid.tls.msk.ru> <55F70C16.1070302@redhat.com> <55F71564.1010906@msgid.tls.msk.ru> From: John Snow Message-ID: <55F716CF.4050306@redhat.com> Date: Mon, 14 Sep 2015 14:49:51 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F71564.1010906@msgid.tls.msk.ru> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefano.stabellini@eu.citrix.com, armbru@redhat.com, qemu-devel@nongnu.org, ppandit@redhat.com, luodalongde@gmail.com, liuling-it@360.cn Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] ide: fix ATAPI command permissions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 18:49:59 -0000 On 09/14/2015 02:43 PM, Michael Tokarev wrote: > 14.09.2015 21:04, John Snow wrote: >> On 09/11/2015 02:56 AM, Michael Tokarev wrote: >>> 09.09.2015 19:28, John Snow wrote: >>>> We're a little too lenient with what we'll let an ATAPI drive handle. >>>> Clamp down on the IDE command execution table to remove CD_OK permissions >>>> from commands that are not and have never been ATAPI commands. >>> >>> FWIW, this issue has been assigned CVE-2015-6855 identifier, which >>> can be reflected in the commit message when applying. Since this >>> issue has security impact, it might be a good idea to add >>> >>> Cc: qemu-stable@nongnu.org >> >> I'm still awaiting review/acks, but would you like me to re-send this >> patch to trivial, or just fwd/reply-to? > > I think it is anything but trivial ;) Well, the semantics is trivial, > but it isn't -trivial material per se. > > I suggested add a Cc to qemu-stable, this can be done at commit, > together with mentioning the CVE# assigned meanwhile, and I don't > know who will commit it, Kevin? > > Thanks, > > /mjt > I'll be sending the pullreq through my tree, but I was waiting on at least an ACK or so before I went ahead. I can add CC: qemu-stable to the patch on-pull if that's sufficient for you. --js From MAILER-DAEMON Mon Sep 14 21:40:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbfEN-0002HJ-Eu for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 21:40:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbfEL-0002Gh-3q for qemu-block@nongnu.org; Mon, 14 Sep 2015 21:40:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbfEG-0008J3-Qo for qemu-block@nongnu.org; Mon, 14 Sep 2015 21:40:21 -0400 Received: from [59.151.112.132] (port=33347 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbfEG-0008EG-5a; Mon, 14 Sep 2015 21:40:16 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100712651" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Sep 2015 09:42:55 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8F1dkDd009486; Tue, 15 Sep 2015 09:39:46 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 15 Sep 2015 09:40:00 +0800 To: Eric Blake , Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> From: Wen Congyang Message-ID: <55F776CC.3050601@cn.fujitsu.com> Date: Tue, 15 Sep 2015 09:39:24 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F6EBF5.2090101@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 01:40:22 -0000 On 09/14/2015 11:47 PM, Eric Blake wrote: > On 09/14/2015 08:27 AM, Markus Armbruster wrote: >> Wen Congyang writes: >> >>> The NBD driver needs: filename, path or (host, port, exportname). >>> It checks which key exists and decides use unix or inet socket. >>> It doesn't recognize the key type, so we can't use union, and >>> can't reuse InetSocketAddress. >>> >>> Signed-off-by: Wen Congyang >>> Signed-off-by: zhanghailiang >>> Signed-off-by: Gonglei >>> --- >>> qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- >>> 1 file changed, 40 insertions(+), 2 deletions(-) >>> > >>> ## >>> +# @BlockdevOptionsNBD >>> +# >>> +# Driver specific block device options for NBD >>> +# >>> +# @filename: #optional unix or inet path. The format is: >>> +# unix: nbd+unix:///export?socket=path or >>> +# nbd:unix:path:exportname=export >>> +# inet: nbd[+tcp]://host[:port]/export or >>> +# nbd:host[:port]:exportname=export > > Yuck. You are passing structured data through a single 'str', when you > SHOULD be passing it through structured JSON. Just because we have a > filename shorthand for convenience does NOT mean that we want to expose > that convenience in QMP. Instead, we really want the breakdown of the > pieces (here, using abbreviated syntax of an inline base, since there > are pending qapi patches that will allow it): Do you mean that: there is no need to support filename? > > { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } NBD only uses tcp, it doesn't support udp. > { 'union': 'BlockdevOptionsNBD', > 'base': { 'transport': 'NBDTransport', 'export': 'str' }, > 'discriminator': 'transport', > 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } > { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } unix socket needs a path, and I think we can use UnixSocketAddress here. > { 'struct': 'NBDInet', 'data': { 'host': 'str', '*port': 'int', > '*ipv4': 'bool', '*ipv6': 'bool' } } Thanks for the above, and I will try it. > > >> I'm afraid this doesn't address Eric's review of your v2. > > Agreed; we still don't have the right interface. > > >> Eric further observed that support for the nbd+unix transport was >> missing, and suggested to have a union type combining the various >> transports. > > And I just spelled out above what that should look like. > >> >> If we decide separate types for single port and port ranges aren't >> worthwhile, you can simply use SocketAddress where your v2 used >> InetSocketAddress. > > I'm not sure if my 'NBDInet' above makes any more sense than reusing > 'SocketAddress' (and if we do reuse 'SocketAddress', we have the further > question of whether to split out socket ranges as a separate type so > that SocketAddress becomes a single-port identity). > >> >> Eric, how strongly do you feel about separating the two? > > I'm more worried about properly using a union type to represent unix vs. > tcp, and less worried about SocketAddress vs. range types vs creating a > new type (although in the long run, fixing ranges to be in a properly > named type rather than re-inventing the struct across multiple > transports is a good goal). But you are quite correct that I do not > like the v3 proposal, because it encodes far too much information into a > single '*filename':'str', which is not the qapi way. > From MAILER-DAEMON Mon Sep 14 22:21:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zbfrh-0004ka-Fo for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 22:21:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbfre-0004kF-U4 for qemu-block@nongnu.org; Mon, 14 Sep 2015 22:21:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zbfrb-0007zn-MA for qemu-block@nongnu.org; Mon, 14 Sep 2015 22:20:58 -0400 Received: from [59.151.112.132] (port=6038 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbfra-0007z6-2S; Mon, 14 Sep 2015 22:20:55 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100714659" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Sep 2015 10:23:40 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8F2KW4p012474; Tue, 15 Sep 2015 10:20:33 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 15 Sep 2015 10:20:47 +0800 To: Eric Blake , Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> From: Wen Congyang Message-ID: <55F78059.4030309@cn.fujitsu.com> Date: Tue, 15 Sep 2015 10:20:09 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F6EBF5.2090101@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 02:21:00 -0000 On 09/14/2015 11:47 PM, Eric Blake wrote: > On 09/14/2015 08:27 AM, Markus Armbruster wrote: >> Wen Congyang writes: >> >>> The NBD driver needs: filename, path or (host, port, exportname). >>> It checks which key exists and decides use unix or inet socket. >>> It doesn't recognize the key type, so we can't use union, and >>> can't reuse InetSocketAddress. >>> >>> Signed-off-by: Wen Congyang >>> Signed-off-by: zhanghailiang >>> Signed-off-by: Gonglei >>> --- >>> qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- >>> 1 file changed, 40 insertions(+), 2 deletions(-) >>> > >>> ## >>> +# @BlockdevOptionsNBD >>> +# >>> +# Driver specific block device options for NBD >>> +# >>> +# @filename: #optional unix or inet path. The format is: >>> +# unix: nbd+unix:///export?socket=path or >>> +# nbd:unix:path:exportname=export >>> +# inet: nbd[+tcp]://host[:port]/export or >>> +# nbd:host[:port]:exportname=export > > Yuck. You are passing structured data through a single 'str', when you > SHOULD be passing it through structured JSON. Just because we have a > filename shorthand for convenience does NOT mean that we want to expose > that convenience in QMP. Instead, we really want the breakdown of the > pieces (here, using abbreviated syntax of an inline base, since there > are pending qapi patches that will allow it): > > { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } > { 'union': 'BlockdevOptionsNBD', > 'base': { 'transport': 'NBDTransport', 'export': 'str' }, > 'discriminator': 'transport', > 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } Building fails: GEN qmp-commands.h In file included from /work/src/qemu/qapi-schema.json:9: In file included from /work/src/qemu/qapi/block.json:6: /work/src/qemu/qapi/block-core.json:1844: Flat union 'BlockdevOptionsNBD' must have a string base field Makefile:286: recipe for target 'qmp-commands.h' failed make: *** [qmp-commands.h] Error 1 What about this: { 'struct': 'BlockdevOptionsNBDBase', 'data': { 'transport': 'NBDTransport', 'export': 'str' } } { 'union': 'BlockdevOptionsNBD', 'base': 'BlockdevOptionsNBDBase', 'discriminator': 'transport', 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } Thanks Wen Congyang > { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } > { 'struct': 'NBDInet', 'data': { 'host': 'str', '*port': 'int', > '*ipv4': 'bool', '*ipv6': 'bool' } } > > >> I'm afraid this doesn't address Eric's review of your v2. > > Agreed; we still don't have the right interface. > > >> Eric further observed that support for the nbd+unix transport was >> missing, and suggested to have a union type combining the various >> transports. > > And I just spelled out above what that should look like. > >> >> If we decide separate types for single port and port ranges aren't >> worthwhile, you can simply use SocketAddress where your v2 used >> InetSocketAddress. > > I'm not sure if my 'NBDInet' above makes any more sense than reusing > 'SocketAddress' (and if we do reuse 'SocketAddress', we have the further > question of whether to split out socket ranges as a separate type so > that SocketAddress becomes a single-port identity). > >> >> Eric, how strongly do you feel about separating the two? > > I'm more worried about properly using a union type to represent unix vs. > tcp, and less worried about SocketAddress vs. range types vs creating a > new type (although in the long run, fixing ranges to be in a properly > named type rather than re-inventing the struct across multiple > transports is a good goal). But you are quite correct that I do not > like the v3 proposal, because it encodes far too much information into a > single '*filename':'str', which is not the qapi way. > From MAILER-DAEMON Mon Sep 14 22:27:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zbfxy-00067u-FY for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 22:27:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbfxw-000679-HG for qemu-block@nongnu.org; Mon, 14 Sep 2015 22:27:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zbfxt-0002HN-R0 for qemu-block@nongnu.org; Mon, 14 Sep 2015 22:27:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54437) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbfxt-0002HC-MB; Mon, 14 Sep 2015 22:27:25 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 278CE8C1B8; Tue, 15 Sep 2015 02:27:24 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8F2RLtX008530; Mon, 14 Sep 2015 22:27:23 -0400 Date: Tue, 15 Sep 2015 10:27:21 +0800 From: Fam Zheng To: Alberto Garcia Message-ID: <20150915022721.GE14016@ad.nay.redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 2/4] block: support passing 'backing': '' to 'blockdev-add' X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 02:27:29 -0000 On Mon, 09/14 19:01, Alberto Garcia wrote: > Passing an empty string allows opening an image but not its backing > file. This was already described in the API documentation, only the > implementation was missing. > > This is useful for creating snapshots using images opened with > blockdev-add, since they are not supposed to have a backing image > before the operation. > > Signed-off-by: Alberto Garcia > --- > block.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/block.c b/block.c > index 22d3b0e..ad1792d 100644 > --- a/block.c > +++ b/block.c > @@ -1402,6 +1402,7 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, > BlockDriverState *file = NULL, *bs; > BlockDriver *drv = NULL; > const char *drvname; > + const char *backing; > Error *local_err = NULL; > int snapshot_flags = 0; > > @@ -1469,6 +1470,12 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, > > assert(drvname || !(flags & BDRV_O_PROTOCOL)); > > + backing = qdict_get_try_str(options, "backing"); > + if (backing && *backing == '\0') { > + flags |= BDRV_O_NO_BACKING; > + } > + qdict_del(options, "backing"); > + > bs->open_flags = flags; > bs->options = options; > options = qdict_clone_shallow(options); > -- > 2.5.1 > > Specifying a non-empty "backing" will be a slient nop now, but it used to be an error before. Should we return an error? Fam From MAILER-DAEMON Mon Sep 14 22:28:41 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zbfz7-00075L-F0 for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 22:28:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbfz5-00072j-OT for qemu-block@nongnu.org; Mon, 14 Sep 2015 22:28:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zbfz4-0002RM-GT for qemu-block@nongnu.org; Mon, 14 Sep 2015 22:28:39 -0400 Received: from [59.151.112.132] (port=56171 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbfyy-0002Qq-R6; Mon, 14 Sep 2015 22:28:34 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100715129" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Sep 2015 10:31:21 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8F2SDBX013579; Tue, 15 Sep 2015 10:28:13 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 15 Sep 2015 10:28:27 +0800 To: Eric Blake , Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F78059.4030309@cn.fujitsu.com> From: Wen Congyang Message-ID: <55F78225.404@cn.fujitsu.com> Date: Tue, 15 Sep 2015 10:27:49 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F78059.4030309@cn.fujitsu.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 02:28:40 -0000 On 09/15/2015 10:20 AM, Wen Congyang wrote: > On 09/14/2015 11:47 PM, Eric Blake wrote: >> On 09/14/2015 08:27 AM, Markus Armbruster wrote: >>> Wen Congyang writes: >>> >>>> The NBD driver needs: filename, path or (host, port, exportname). >>>> It checks which key exists and decides use unix or inet socket. >>>> It doesn't recognize the key type, so we can't use union, and >>>> can't reuse InetSocketAddress. >>>> >>>> Signed-off-by: Wen Congyang >>>> Signed-off-by: zhanghailiang >>>> Signed-off-by: Gonglei >>>> --- >>>> qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- >>>> 1 file changed, 40 insertions(+), 2 deletions(-) >>>> >> >>>> ## >>>> +# @BlockdevOptionsNBD >>>> +# >>>> +# Driver specific block device options for NBD >>>> +# >>>> +# @filename: #optional unix or inet path. The format is: >>>> +# unix: nbd+unix:///export?socket=path or >>>> +# nbd:unix:path:exportname=export >>>> +# inet: nbd[+tcp]://host[:port]/export or >>>> +# nbd:host[:port]:exportname=export >> >> Yuck. You are passing structured data through a single 'str', when you >> SHOULD be passing it through structured JSON. Just because we have a >> filename shorthand for convenience does NOT mean that we want to expose >> that convenience in QMP. Instead, we really want the breakdown of the >> pieces (here, using abbreviated syntax of an inline base, since there >> are pending qapi patches that will allow it): >> >> { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } >> { 'union': 'BlockdevOptionsNBD', >> 'base': { 'transport': 'NBDTransport', 'export': 'str' }, >> 'discriminator': 'transport', >> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } > > Building fails: > GEN qmp-commands.h > In file included from /work/src/qemu/qapi-schema.json:9: > In file included from /work/src/qemu/qapi/block.json:6: > /work/src/qemu/qapi/block-core.json:1844: Flat union 'BlockdevOptionsNBD' must have a string base field > Makefile:286: recipe for target 'qmp-commands.h' failed > make: *** [qmp-commands.h] Error 1 > > What about this: > { 'struct': 'BlockdevOptionsNBDBase', > 'data': { 'transport': 'NBDTransport', 'export': 'str' } } > { 'union': 'BlockdevOptionsNBD', > 'base': 'BlockdevOptionsNBDBase', > 'discriminator': 'transport', > 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } Another problem: In file included from /work/src/qemu/qapi-schema.json:9: In file included from /work/src/qemu/qapi/block.json:6: /work/src/qemu/qapi/block-core.json:1866: Member 'nbd' of union 'BlockdevOptions' cannot use union type 'BlockdevOptionsNBD' Makefile:286: recipe for target 'qmp-commands.h' failed Thanks Wen Congyang > > Thanks > Wen Congyang > >> { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } >> { 'struct': 'NBDInet', 'data': { 'host': 'str', '*port': 'int', >> '*ipv4': 'bool', '*ipv6': 'bool' } } >> >> >>> I'm afraid this doesn't address Eric's review of your v2. >> >> Agreed; we still don't have the right interface. >> >> >>> Eric further observed that support for the nbd+unix transport was >>> missing, and suggested to have a union type combining the various >>> transports. >> >> And I just spelled out above what that should look like. >> >>> >>> If we decide separate types for single port and port ranges aren't >>> worthwhile, you can simply use SocketAddress where your v2 used >>> InetSocketAddress. >> >> I'm not sure if my 'NBDInet' above makes any more sense than reusing >> 'SocketAddress' (and if we do reuse 'SocketAddress', we have the further >> question of whether to split out socket ranges as a separate type so >> that SocketAddress becomes a single-port identity). >> >>> >>> Eric, how strongly do you feel about separating the two? >> >> I'm more worried about properly using a union type to represent unix vs. >> tcp, and less worried about SocketAddress vs. range types vs creating a >> new type (although in the long run, fixing ranges to be in a properly >> named type rather than re-inventing the struct across multiple >> transports is a good goal). But you are quite correct that I do not >> like the v3 proposal, because it encodes far too much information into a >> single '*filename':'str', which is not the qapi way. >> > > > . > From MAILER-DAEMON Mon Sep 14 22:34:48 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zbg52-0000v3-5F for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 22:34:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbg4z-0000uB-JF for qemu-block@nongnu.org; Mon, 14 Sep 2015 22:34:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zbg4w-0004NZ-Us for qemu-block@nongnu.org; Mon, 14 Sep 2015 22:34:45 -0400 Received: from [59.151.112.132] (port=1658 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbg4w-0004M6-87; Mon, 14 Sep 2015 22:34:42 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100715404" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Sep 2015 10:37:24 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8F2YGF4013967; Tue, 15 Sep 2015 10:34:16 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 15 Sep 2015 10:34:30 +0800 To: Kevin Wolf References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> <20150914153700.GE3550@noname.str.redhat.com> From: Wen Congyang Message-ID: <55F78392.3010202@cn.fujitsu.com> Date: Tue, 15 Sep 2015 10:33:54 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150914153700.GE3550@noname.str.redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: zhanghailiang , qemu block , Markus Armbruster , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , qemu devel , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 02:34:46 -0000 On 09/14/2015 11:37 PM, Kevin Wolf wrote: > Am 10.09.2015 um 11:55 hat Wen Congyang geschrieben: >> +## >> +# @x-child-add >> +# >> +# Add a new child to the parent BDS. Currently only the Quorum driver >> +# implements this feature. This is useful to fix a broken quorum child. >> +# >> +# @parent: graph node name or id which the child will be added to. >> +# >> +# @child: graph node name that will be added. >> +# >> +# Note: this command is experimental, and not a stable API. >> +# >> +# Since: 2.5 >> +## >> +{ 'command': 'x-child-add', >> + 'data' : { 'parent': 'str', 'child': 'str' } } > > This is probably not future-proof and only made for the special case of > quorum. Specifically, one thing I'm missing is some way to specfiy what > kind of child the new node is when a node can take different types of > children (e.g. bs->file and bs->backing_hd). Currently, we only add/remove quorum's child. We can add a new parameter to specify the type in the furture to support more things. Thanks Wen Congyang > > Kevin > . > From MAILER-DAEMON Mon Sep 14 22:40:58 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbgB0-000382-Nn for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 22:40:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbgAy-00037w-1p for qemu-block@nongnu.org; Mon, 14 Sep 2015 22:40:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbgAu-0007GU-QK for qemu-block@nongnu.org; Mon, 14 Sep 2015 22:40:55 -0400 Received: from [59.151.112.132] (port=38237 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbgAs-0007Eo-US; Mon, 14 Sep 2015 22:40:52 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100715719" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Sep 2015 10:43:40 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8F2eWXj014575; Tue, 15 Sep 2015 10:40:33 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 15 Sep 2015 10:40:47 +0800 To: Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> <87mvwpkqzi.fsf@blackfin.pond.sub.org> From: Wen Congyang Message-ID: <55F7850A.5050109@cn.fujitsu.com> Date: Tue, 15 Sep 2015 10:40:10 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87mvwpkqzi.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 02:40:58 -0000 On 09/14/2015 10:36 PM, Markus Armbruster wrote: > Wen Congyang writes: > >> Signed-off-by: Wen Congyang >> Signed-off-by: zhanghailiang >> Signed-off-by: Gonglei >> --- >> blockdev.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ >> qapi/block-core.json | 34 +++++++++++++++++++++++++++++++++ >> qmp-commands.hx | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 3 files changed, 134 insertions(+) >> >> diff --git a/blockdev.c b/blockdev.c >> index bd47756..0a40607 100644 >> --- a/blockdev.c >> +++ b/blockdev.c >> @@ -3413,6 +3413,53 @@ fail: >> qmp_output_visitor_cleanup(ov); >> } >> >> +void qmp_x_child_add(const char *parent, const char *child, >> + Error **errp) >> +{ >> + BlockDriverState *parent_bs, *child_bs; >> + Error *local_err = NULL; >> + >> + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); >> + if (!parent_bs) { >> + error_propagate(errp, local_err); >> + return; >> + } >> + >> + child_bs = bdrv_find_node(child); >> + if (!child_bs) { >> + error_setg(errp, "Node '%s' not found", child); >> + return; >> + } >> + >> + bdrv_add_child(parent_bs, child_bs, &local_err); >> + if (local_err) { >> + error_propagate(errp, local_err); >> + } >> +} >> + >> +void qmp_child_del(const char *parent, const char *child, Error **errp) >> +{ >> + BlockDriverState *parent_bs, *child_bs; >> + Error *local_err = NULL; >> + >> + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); >> + if (!parent_bs) { >> + error_propagate(errp, local_err); >> + return; >> + } >> + >> + child_bs = bdrv_find_node(child); >> + if (!child_bs) { >> + error_setg(errp, "Node '%s' not found", child); >> + return; >> + } >> + >> + bdrv_del_child(parent_bs, child_bs, &local_err); >> + if (local_err) { >> + error_propagate(errp, local_err); >> + } >> +} >> + >> BlockJobInfoList *qmp_query_block_jobs(Error **errp) >> { >> BlockJobInfoList *head = NULL, **p_next = &head; >> diff --git a/qapi/block-core.json b/qapi/block-core.json >> index e68a59f..b959577 100644 >> --- a/qapi/block-core.json >> +++ b/qapi/block-core.json >> @@ -2272,3 +2272,37 @@ >> ## >> { 'command': 'block-set-write-threshold', >> 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } >> + >> +## >> +# @x-child-add >> +# >> +# Add a new child to the parent BDS. Currently only the Quorum driver >> +# implements this feature. This is useful to fix a broken quorum child. >> +# >> +# @parent: graph node name or id which the child will be added to. >> +# >> +# @child: graph node name that will be added. >> +# >> +# Note: this command is experimental, and not a stable API. >> +# >> +# Since: 2.5 >> +## >> +{ 'command': 'x-child-add', >> + 'data' : { 'parent': 'str', 'child': 'str' } } >> + >> +## >> +# @child-del >> +# >> +# Remove a child from the parent BDS. Currently only the Quorum driver >> +# implements this feature. This is useful to fix a broken quorum child. >> +# Note, you can't remove a child if it would bring the quorum below its >> +# threshold. >> +# >> +# @parent: graph node name or id from which the child will removed. >> +# >> +# @child: graph node name that will be removed. >> +# >> +# Since: 2.5 >> +## >> +{ 'command': 'child-del', >> + 'data' : { 'parent': 'str', 'child': 'str' } } > > Why is x-child-add experimental, but child-del isn't? Please explain > both in the schema and in the commit message. No special reason. Should I put child-del in experimental namespace? > >> diff --git a/qmp-commands.hx b/qmp-commands.hx >> index 495670b..139a23b 100644 >> --- a/qmp-commands.hx >> +++ b/qmp-commands.hx >> @@ -4053,6 +4053,59 @@ Example: >> EQMP >> >> { >> + .name = "x-child-add", >> + .args_type = "parent:B,child:B", >> + .mhandler.cmd_new = qmp_marshal_input_x_child_add, >> + }, >> + >> +SQMP >> +x-child-add >> +------------ >> + >> +Add a child to a quorum node. >> + >> +Arguments: >> + >> +- "parent": the quorum's id or node name >> +- "child": the child node-name which will be added > > Node name parameters are usually named node-name or, if there's more > than one, FOO-node-name. Unless we want to abandon that convention, > this should therefore be node-name and child-node-name, or parent-node > name and child-node-name. parent can be top BDS, so it can be id. node-name is a very common name, and I think child or child-node-name is better. > >> + >> +Note: this command is experimental, and not a stable API. >> + >> +Example: >> + >> +-> { "execute": "x-child-add", >> + "arguments": { "parent": "disk1", "child": "new_node" } } >> +<- { "return": {} } >> + >> +EQMP >> + >> + { >> + .name = "child-del", > > Documentation and schema have x-child-add, actual command is child-add. > Oops. Here is child-del.... > >> + .args_type = "parent:B,child:B", >> + .mhandler.cmd_new = qmp_marshal_input_child_del, >> + }, >> + >> +SQMP >> +child-del >> +------------ >> + >> +Delete a child from a quorum node. It can be used to remove a broken >> +quorum child. >> + >> +Arguments: >> + >> +- "parent": the quorum's id or node name >> +- "child": the child node-name which will be removed > > Same comment as on x-child-add's parameter names. > >> + >> +Example: >> + >> +-> { "execute": "child-del", >> + "arguments": { "parent": "disk1", "child": "new_node" } } >> +<- { "return": {} } >> + >> +EQMP >> + >> + { >> .name = "query-named-block-nodes", >> .args_type = "", >> .mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes, > . > From MAILER-DAEMON Mon Sep 14 23:47:00 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbhCu-0006FQ-I0 for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 23:47:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbhCr-0006EY-E5 for qemu-block@nongnu.org; Mon, 14 Sep 2015 23:46:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbhCo-0002F9-8G for qemu-block@nongnu.org; Mon, 14 Sep 2015 23:46:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35129) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbhCo-0002F2-0l; Mon, 14 Sep 2015 23:46:54 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id AE6938C1A3; Tue, 15 Sep 2015 03:46:51 +0000 (UTC) Received: from [10.3.113.35] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8F3knPp001160; Mon, 14 Sep 2015 23:46:50 -0400 To: Wen Congyang , Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F78059.4030309@cn.fujitsu.com> <55F78225.404@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55F794A4.5060903@redhat.com> Date: Mon, 14 Sep 2015 21:46:44 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F78225.404@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wo3fB7HPW9wD5tbCARmo1CB2R9pUi4lxt" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 03:46:58 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --wo3fB7HPW9wD5tbCARmo1CB2R9pUi4lxt Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/14/2015 08:27 PM, Wen Congyang wrote: >> Building fails: >> GEN qmp-commands.h >> In file included from /work/src/qemu/qapi-schema.json:9: >> In file included from /work/src/qemu/qapi/block.json:6: >> /work/src/qemu/qapi/block-core.json:1844: Flat union 'BlockdevOptionsN= BD' must have a string base field >> Makefile:286: recipe for target 'qmp-commands.h' failed >> make: *** [qmp-commands.h] Error 1 Yep, doesn't work until pending qapi patches land. >> >> What about this: >> { 'struct': 'BlockdevOptionsNBDBase', >> 'data': { 'transport': 'NBDTransport', 'export': 'str' } } >> { 'union': 'BlockdevOptionsNBD', >> 'base': 'BlockdevOptionsNBDBase', >> 'discriminator': 'transport', >> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } >=20 > Another problem: > In file included from /work/src/qemu/qapi-schema.json:9: > In file included from /work/src/qemu/qapi/block.json:6: > /work/src/qemu/qapi/block-core.json:1866: Member 'nbd' of union 'Blockd= evOptions' cannot use union type 'BlockdevOptionsNBD' > Makefile:286: recipe for target 'qmp-commands.h' failed Yep. Artificial restriction; we hope to lift it soon, but don't have enough qapi patches in place for that one yet (I have not posted my work in progress to get us that far). Possible workaround in the meantime - instead of trying to go with a nice flat union (where all QMP keys are in the same {} level), we can use nesting (structs that add another {} to include the unions). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --wo3fB7HPW9wD5tbCARmo1CB2R9pUi4lxt Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV95SkAAoJEKeha0olJ0NqkosH/ApMonnPUUq1ADR3lvDAFtE0 KftONq1b7ht81kcTaAj59039Z/4/HAP9pnXP6g8PqbOtBPwMeeWf8AdrcltuTt3n n2TgOnUQACiNjxwPiiPKu5OE91r3XZ1s0+ky1Z7GYlOTF3M+/x2EqVjwIXRO1T9Q FiFYY4Qk0j1UvWIJZK1MqOVXOg7MXCRIJi587JkU1u2h9IaMNWkPWRvh87pnCO7R PdfcekEGKpHMorJOzskVzY7QxLIsABOzL5Ln5t7Jq8nqVsVogB2G5MPortVy+eJr osyTD6HAkyE+tosOje6SzXSUJy8LbClxpHqbmdeLzk8zQ8b/62vSjHRdWuI7qlc= =ueJg -----END PGP SIGNATURE----- --wo3fB7HPW9wD5tbCARmo1CB2R9pUi4lxt-- From MAILER-DAEMON Mon Sep 14 23:59:07 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbhOd-0000PS-D4 for mharc-qemu-block@gnu.org; Mon, 14 Sep 2015 23:59:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbhOa-0000Lb-Ji for qemu-block@nongnu.org; Mon, 14 Sep 2015 23:59:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbhOZ-000644-LC for qemu-block@nongnu.org; Mon, 14 Sep 2015 23:59:04 -0400 Received: from [59.151.112.132] (port=21122 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbhOV-00062f-5k; Mon, 14 Sep 2015 23:58:59 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100718752" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Sep 2015 12:01:47 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8F3weZZ019243; Tue, 15 Sep 2015 11:58:40 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 15 Sep 2015 11:58:54 +0800 To: Eric Blake , Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F78059.4030309@cn.fujitsu.com> <55F78225.404@cn.fujitsu.com> <55F794A4.5060903@redhat.com> From: Wen Congyang Message-ID: <55F7975B.4050405@cn.fujitsu.com> Date: Tue, 15 Sep 2015 11:58:19 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F794A4.5060903@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 03:59:05 -0000 On 09/15/2015 11:46 AM, Eric Blake wrote: > On 09/14/2015 08:27 PM, Wen Congyang wrote: >>> Building fails: >>> GEN qmp-commands.h >>> In file included from /work/src/qemu/qapi-schema.json:9: >>> In file included from /work/src/qemu/qapi/block.json:6: >>> /work/src/qemu/qapi/block-core.json:1844: Flat union 'BlockdevOptionsNBD' must have a string base field >>> Makefile:286: recipe for target 'qmp-commands.h' failed >>> make: *** [qmp-commands.h] Error 1 > > Yep, doesn't work until pending qapi patches land. This patchset: qapi: QMP introspection? > >>> >>> What about this: >>> { 'struct': 'BlockdevOptionsNBDBase', >>> 'data': { 'transport': 'NBDTransport', 'export': 'str' } } >>> { 'union': 'BlockdevOptionsNBD', >>> 'base': 'BlockdevOptionsNBDBase', >>> 'discriminator': 'transport', >>> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } >> >> Another problem: >> In file included from /work/src/qemu/qapi-schema.json:9: >> In file included from /work/src/qemu/qapi/block.json:6: >> /work/src/qemu/qapi/block-core.json:1866: Member 'nbd' of union 'BlockdevOptions' cannot use union type 'BlockdevOptionsNBD' >> Makefile:286: recipe for target 'qmp-commands.h' failed > > Yep. Artificial restriction; we hope to lift it soon, but don't have > enough qapi patches in place for that one yet (I have not posted my work > in progress to get us that far). > > Possible workaround in the meantime - instead of trying to go with a > nice flat union (where all QMP keys are in the same {} level), we can > use nesting (structs that add another {} to include the unions). How to include the unions to a structs? Use 'base'? Thanks Wen Congyang > From MAILER-DAEMON Tue Sep 15 02:43:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zbjxf-0003k7-NO for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 02:43:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbjxd-0003iT-Q0 for qemu-block@nongnu.org; Tue, 15 Sep 2015 02:43:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zbjxc-0000i4-UD for qemu-block@nongnu.org; Tue, 15 Sep 2015 02:43:25 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:19812 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbjxX-0000O5-OK; Tue, 15 Sep 2015 02:43:19 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AuBgDZvPdV/5tjdVtdGQEBAYMHgT2pMgEBAQEBAQUBgQoBkw2HcgKBNzkTAQEBAQEBAYEKhCQBAQMBOj8FCwshJQ8BLBsGE4gmDAHKQQEBAQEBBQEBAQEehiyFRIUNB4QsAQSVXKgGIgFAgkOBQDwziioBAQE X-IPAS-Result: A2AuBgDZvPdV/5tjdVtdGQEBAYMHgT2pMgEBAQEBAQUBgQoBkw2HcgKBNzkTAQEBAQEBAYEKhCQBAQMBOj8FCwshJQ8BLBsGE4gmDAHKQQEBAQEBBQEBAQEehiyFRIUNB4QsAQSVXKgGIgFAgkOBQDwziioBAQE X-IronPort-AV: E=Sophos;i="5.17,533,1437429600"; d="scan'208";a="22521671" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 15 Sep 2015 08:42:40 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1Zbjwu-00050y-2T; Tue, 15 Sep 2015 08:42:40 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1Zbjwt-0001vf-T1; Tue, 15 Sep 2015 08:42:39 +0200 From: Alberto Garcia To: Fam Zheng In-Reply-To: <20150915022721.GE14016@ad.nay.redhat.com> References: <20150915022721.GE14016@ad.nay.redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Tue, 15 Sep 2015 08:42:39 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 2/4] block: support passing 'backing': '' to 'blockdev-add' X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 06:43:26 -0000 On Tue 15 Sep 2015 04:27:21 AM CEST, Fam Zheng wrote: >> + backing = qdict_get_try_str(options, "backing"); >> + if (backing && *backing == '\0') { >> + flags |= BDRV_O_NO_BACKING; >> + } >> + qdict_del(options, "backing"); >> + > Specifying a non-empty "backing" will be a slient nop now, but it used > to be an error before. Should we return an error? Ah, yes, I think it should return an error. Thanks! --- a/block.c +++ b/block.c @@ -1473,8 +1473,8 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, backing = qdict_get_try_str(options, "backing"); if (backing && *backing == '\0') { flags |= BDRV_O_NO_BACKING; + qdict_del(options, "backing"); } - qdict_del(options, "backing"); Berto From MAILER-DAEMON Tue Sep 15 02:53:20 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zbk7E-0006CJ-Qw for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 02:53:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbk7B-0006C5-W9 for qemu-block@nongnu.org; Tue, 15 Sep 2015 02:53:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zbk77-0004fj-Q2 for qemu-block@nongnu.org; Tue, 15 Sep 2015 02:53:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbk77-0004fU-I3; Tue, 15 Sep 2015 02:53:13 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B79C12F810B; Tue, 15 Sep 2015 06:53:12 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8F6r88J009376 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Sep 2015 02:53:11 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 00EFE303F916; Tue, 15 Sep 2015 08:53:07 +0200 (CEST) From: Markus Armbruster To: John Snow References: <1441816082-21031-1-git-send-email-jsnow@redhat.com> Date: Tue, 15 Sep 2015 08:53:07 +0200 In-Reply-To: <1441816082-21031-1-git-send-email-jsnow@redhat.com> (John Snow's message of "Wed, 9 Sep 2015 12:28:02 -0400") Message-ID: <87r3m0897w.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, stefano.stabellini@eu.citrix.com, qemu-devel@nongnu.org, ppandit@redhat.com, luodalongde@gmail.com, liuling-it@360.cn Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] ide: fix ATAPI command permissions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 06:53:19 -0000 John Snow writes: > We're a little too lenient with what we'll let an ATAPI drive handle. > Clamp down on the IDE command execution table to remove CD_OK permissions > from commands that are not and have never been ATAPI commands. > > For ATAPI command validity, please see: > - ATA4 Section 6.5 ("PACKET Command feature set") > - ATA8/ACS Section 4.3 ("The PACKET feature set") > - ACS3 Section 4.3 ("The PACKET feature set") > > ACS3 has a historical command validity table in Table B.4 > ("Historical Command Assignments") that can be referenced to find when > a command was introduced, deprecated, obsoleted, etc. > > The only reference for ATAPI command validity is by checking that > version's PACKET feature set section. > > ATAPI was introduced by T13 into ATA4, all commands retired prior to ATA4 > therefore are assumed to have never been ATAPI commands. > > Mandatory commands, as listed in ATA8-ACS3, are: > > - DEVICE RESET > - EXECUTE DEVICE DIAGNOSTIC > - IDENTIFY DEVICE > - IDENTIFY PACKET DEVICE > - NOP > - PACKET > - READ SECTOR(S) > - SET FEATURES > > Optional commands as listed in ATA8-ACS3, are: > > - FLUSH CACHE > - READ LOG DMA EXT > - READ LOG EXT > - WRITE LOG DMA EXT > - WRITE LOG EXT > > All other commands are illegal to send to an ATAPI device and should > be rejected by the device. We could perhaps argue about "should be rejected by the device", but I think the weaker "a device is free to reject it" still suffices to support your patch. > CD_OK removal justifications: > > 0x06 WIN_DSM Defined in ACS2. Not valid for ATAPI. > 0x21 WIN_READ_ONCE Retired in ATA5. Not ATAPI in ATA4. > 0x94 WIN_STANDBYNOW2 Retired in ATA4. Did not coexist with ATAPI. > 0x95 WIN_IDLEIMMEDIATE2 Retired in ATA4. Did not coexist with ATAPI. > 0x96 WIN_STANDBY2 Retired in ATA4. Did not coexist with ATAPI. > 0x97 WIN_SETIDLE2 Retired in ATA4. Did not coexist with ATAPI. > 0x98 WIN_CHECKPOWERMODE2 Retired in ATA4. Did not coexist with ATAPI. > 0x99 WIN_SLEEPNOW2 Retired in ATA4. Did not coexist with ATAPI. > 0xE0 WIN_STANDBYNOW1 Not part of ATAPI in ATA4, ACS or ACS3. > 0xE1 WIN_IDLEIMMDIATE Not part of ATAPI in ATA4, ACS or ACS3. > 0xE2 WIN_STANDBY Not part of ATAPI in ATA4, ACS or ACS3. > 0xE3 WIN_SETIDLE1 Not part of ATAPI in ATA4, ACS or ACS3. > 0xE4 WIN_CHECKPOWERMODE1 Not part of ATAPI in ATA4, ACS or ACS3. > 0xE5 WIN_SLEEPNOW1 Not part of ATAPI in ATA4, ACS or ACS3. > 0xF8 WIN_READ_NATIVE_MAX Obsoleted in ACS3. Not ATAPI in ATA4 or ACS. Actual patch matches this list. > This patch fixes a divide by zero fault that can be caused by sending > the WIN_READ_NATIVE_MAX command to an empty ATAPI drive, which causes > it to attempt to use zeroed CHS values to perform sector arithmetic. > > Reported-by: Qinghao Tang > Signed-off-by: John Snow I appreciate you going to the root of the problem instead of merely fixing the narrow bug. Could a similar argument be made for dropping CFA_OK from some commands? Do we still need this conditional in cmd_read_native_max()? /* Refuse if no sectors are addressable (e.g. medium not inserted) */ if (s->nb_sectors == 0) { ide_abort_command(s); return true; } Why does it fail at guarding the CHS use from empty ATAPI drives before your patch? From MAILER-DAEMON Tue Sep 15 03:37:32 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zbko0-0007xT-3R for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 03:37:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbknv-0007x8-7f for qemu-block@nongnu.org; Tue, 15 Sep 2015 03:37:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zbknq-0006Hx-P5 for qemu-block@nongnu.org; Tue, 15 Sep 2015 03:37:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50557) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbknq-0006H6-HU; Tue, 15 Sep 2015 03:37:22 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 51EA3FA9CE; Tue, 15 Sep 2015 07:37:20 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8F7bIFW021244 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Sep 2015 03:37:19 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D1B87303F916; Tue, 15 Sep 2015 09:37:17 +0200 (CEST) From: Markus Armbruster To: Wen Congyang References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F776CC.3050601@cn.fujitsu.com> Date: Tue, 15 Sep 2015 09:37:17 +0200 In-Reply-To: <55F776CC.3050601@cn.fujitsu.com> (Wen Congyang's message of "Tue, 15 Sep 2015 09:39:24 +0800") Message-ID: <87fv2g876a.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 07:37:31 -0000 Wen Congyang writes: > On 09/14/2015 11:47 PM, Eric Blake wrote: >> On 09/14/2015 08:27 AM, Markus Armbruster wrote: >>> Wen Congyang writes: >>> >>>> The NBD driver needs: filename, path or (host, port, exportname). >>>> It checks which key exists and decides use unix or inet socket. >>>> It doesn't recognize the key type, so we can't use union, and >>>> can't reuse InetSocketAddress. >>>> >>>> Signed-off-by: Wen Congyang >>>> Signed-off-by: zhanghailiang >>>> Signed-off-by: Gonglei >>>> --- >>>> qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- >>>> 1 file changed, 40 insertions(+), 2 deletions(-) >>>> >> >>>> ## >>>> +# @BlockdevOptionsNBD >>>> +# >>>> +# Driver specific block device options for NBD >>>> +# >>>> +# @filename: #optional unix or inet path. The format is: >>>> +# unix: nbd+unix:///export?socket=path or >>>> +# nbd:unix:path:exportname=export >>>> +# inet: nbd[+tcp]://host[:port]/export or >>>> +# nbd:host[:port]:exportname=export >> >> Yuck. You are passing structured data through a single 'str', when you >> SHOULD be passing it through structured JSON. Just because we have a >> filename shorthand for convenience does NOT mean that we want to expose >> that convenience in QMP. Instead, we really want the breakdown of the >> pieces (here, using abbreviated syntax of an inline base, since there >> are pending qapi patches that will allow it): > > Do you mean that: there is no need to support filename? Rule of thumb: if the QMP command handler needs to parse a string argument, that argument should be a complex QAPI type instead. Example: @filename needs to be parsed into its components, either * protocol unix, socket path, export name, or * protocol tcp, host, port, export name Since there's an either/or, the complex QAPI type should be a union. >> { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } > > NBD only uses tcp, it doesn't support udp. > >> { 'union': 'BlockdevOptionsNBD', >> 'base': { 'transport': 'NBDTransport', 'export': 'str' }, >> 'discriminator': 'transport', >> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } >> { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } > > unix socket needs a path, and I think we can use UnixSocketAddress here. Yes, we should try to reuse common types like SocketAddress, InetSocketAddress, UnixSocketAddress. Perhaps it could be as simple as { 'struct': 'BlockdevOptionsNBD', 'data': { 'addr: 'SocketAddress', 'export': 'str' } } Eric, what do you think? >> { 'struct': 'NBDInet', 'data': { 'host': 'str', '*port': 'int', >> '*ipv4': 'bool', '*ipv6': 'bool' } } > > Thanks for the above, and I will try it. [...] From MAILER-DAEMON Tue Sep 15 03:49:19 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbkzP-00039F-6a for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 03:49:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbkzL-00038T-M1 for qemu-block@nongnu.org; Tue, 15 Sep 2015 03:49:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbkzI-0003I0-9a for qemu-block@nongnu.org; Tue, 15 Sep 2015 03:49:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56168) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbkzH-0003Hu-On; Tue, 15 Sep 2015 03:49:12 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 22D6AC0B2010; Tue, 15 Sep 2015 07:49:11 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8F7n8GX003654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Sep 2015 03:49:09 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 66E73303F916; Tue, 15 Sep 2015 09:49:07 +0200 (CEST) From: Markus Armbruster To: Wen Congyang References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> <87mvwpkqzi.fsf@blackfin.pond.sub.org> <55F7850A.5050109@cn.fujitsu.com> Date: Tue, 15 Sep 2015 09:49:07 +0200 In-Reply-To: <55F7850A.5050109@cn.fujitsu.com> (Wen Congyang's message of "Tue, 15 Sep 2015 10:40:10 +0800") Message-ID: <87613c86mk.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 07:49:17 -0000 Wen Congyang writes: > On 09/14/2015 10:36 PM, Markus Armbruster wrote: >> Wen Congyang writes: >> >>> Signed-off-by: Wen Congyang >>> Signed-off-by: zhanghailiang >>> Signed-off-by: Gonglei >>> --- >>> blockdev.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ >>> qapi/block-core.json | 34 +++++++++++++++++++++++++++++++++ >>> qmp-commands.hx | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ >>> 3 files changed, 134 insertions(+) >>> >>> diff --git a/blockdev.c b/blockdev.c >>> index bd47756..0a40607 100644 >>> --- a/blockdev.c >>> +++ b/blockdev.c >>> @@ -3413,6 +3413,53 @@ fail: >>> qmp_output_visitor_cleanup(ov); >>> } >>> >>> +void qmp_x_child_add(const char *parent, const char *child, >>> + Error **errp) >>> +{ >>> + BlockDriverState *parent_bs, *child_bs; >>> + Error *local_err = NULL; >>> + >>> + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); >>> + if (!parent_bs) { >>> + error_propagate(errp, local_err); >>> + return; >>> + } >>> + >>> + child_bs = bdrv_find_node(child); >>> + if (!child_bs) { >>> + error_setg(errp, "Node '%s' not found", child); >>> + return; >>> + } >>> + >>> + bdrv_add_child(parent_bs, child_bs, &local_err); >>> + if (local_err) { >>> + error_propagate(errp, local_err); >>> + } >>> +} >>> + >>> +void qmp_child_del(const char *parent, const char *child, Error **errp) >>> +{ >>> + BlockDriverState *parent_bs, *child_bs; >>> + Error *local_err = NULL; >>> + >>> + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); >>> + if (!parent_bs) { >>> + error_propagate(errp, local_err); >>> + return; >>> + } >>> + >>> + child_bs = bdrv_find_node(child); >>> + if (!child_bs) { >>> + error_setg(errp, "Node '%s' not found", child); >>> + return; >>> + } >>> + >>> + bdrv_del_child(parent_bs, child_bs, &local_err); >>> + if (local_err) { >>> + error_propagate(errp, local_err); >>> + } >>> +} >>> + >>> BlockJobInfoList *qmp_query_block_jobs(Error **errp) >>> { >>> BlockJobInfoList *head = NULL, **p_next = &head; >>> diff --git a/qapi/block-core.json b/qapi/block-core.json >>> index e68a59f..b959577 100644 >>> --- a/qapi/block-core.json >>> +++ b/qapi/block-core.json >>> @@ -2272,3 +2272,37 @@ >>> ## >>> { 'command': 'block-set-write-threshold', >>> 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } >>> + >>> +## >>> +# @x-child-add >>> +# >>> +# Add a new child to the parent BDS. Currently only the Quorum driver >>> +# implements this feature. This is useful to fix a broken quorum child. >>> +# >>> +# @parent: graph node name or id which the child will be added to. >>> +# >>> +# @child: graph node name that will be added. >>> +# >>> +# Note: this command is experimental, and not a stable API. >>> +# >>> +# Since: 2.5 >>> +## >>> +{ 'command': 'x-child-add', >>> + 'data' : { 'parent': 'str', 'child': 'str' } } >>> + >>> +## >>> +# @child-del >>> +# >>> +# Remove a child from the parent BDS. Currently only the Quorum driver >>> +# implements this feature. This is useful to fix a broken quorum child. >>> +# Note, you can't remove a child if it would bring the quorum below its >>> +# threshold. >>> +# >>> +# @parent: graph node name or id from which the child will removed. >>> +# >>> +# @child: graph node name that will be removed. >>> +# >>> +# Since: 2.5 >>> +## >>> +{ 'command': 'child-del', >>> + 'data' : { 'parent': 'str', 'child': 'str' } } >> >> Why is x-child-add experimental, but child-del isn't? Please explain >> both in the schema and in the commit message. > > No special reason. Should I put child-del in experimental namespace? I found the reason for x-child-add in your v2: child-add ------------ Add a child to a quorum node. This command is still a work in progress. It doesn't support all block drivers. Stay away from it unless you want it to help with its development. Eric suggested to rename it to x-child-add, and you did. Good. You also shortened the "work in progress" note to just "Note: this command is experimental, and not a stable API." I'd like to have a more verbose note explaining *why* the command is experimental, both here and in qmp-commands.hx. "It doesn't support all block drivers" is a reason. Are the any others? Is child-del similarly unfinished? If yes, make it x-child-del to save us from later grief. If no: is child-del is only useful together with x-child-add? Then make it x-child-del regardless. >>> diff --git a/qmp-commands.hx b/qmp-commands.hx >>> index 495670b..139a23b 100644 >>> --- a/qmp-commands.hx >>> +++ b/qmp-commands.hx >>> @@ -4053,6 +4053,59 @@ Example: >>> EQMP >>> >>> { >>> + .name = "x-child-add", >>> + .args_type = "parent:B,child:B", >>> + .mhandler.cmd_new = qmp_marshal_input_x_child_add, >>> + }, >>> + >>> +SQMP >>> +x-child-add >>> +------------ >>> + >>> +Add a child to a quorum node. >>> + >>> +Arguments: >>> + >>> +- "parent": the quorum's id or node name >>> +- "child": the child node-name which will be added >> >> Node name parameters are usually named node-name or, if there's more >> than one, FOO-node-name. Unless we want to abandon that convention, >> this should therefore be node-name and child-node-name, or parent-node >> name and child-node-name. > > parent can be top BDS, so it can be id. node-name is a very common name, > and I think child or child-node-name is better. Kevin pointed out we want to move to names without a -node-name suffix. >>> + >>> +Note: this command is experimental, and not a stable API. >>> + >>> +Example: >>> + >>> +-> { "execute": "x-child-add", >>> + "arguments": { "parent": "disk1", "child": "new_node" } } >>> +<- { "return": {} } >>> + >>> +EQMP >>> + >>> + { >>> + .name = "child-del", >> >> Documentation and schema have x-child-add, actual command is child-add. >> Oops. > > Here is child-del.... You're right. I got confused... >>> + .args_type = "parent:B,child:B", >>> + .mhandler.cmd_new = qmp_marshal_input_child_del, >>> + }, >>> + >>> +SQMP >>> +child-del >>> +------------ >>> + >>> +Delete a child from a quorum node. It can be used to remove a broken >>> +quorum child. >>> + >>> +Arguments: >>> + >>> +- "parent": the quorum's id or node name >>> +- "child": the child node-name which will be removed >> >> Same comment as on x-child-add's parameter names. >> >>> + >>> +Example: >>> + >>> +-> { "execute": "child-del", >>> + "arguments": { "parent": "disk1", "child": "new_node" } } >>> +<- { "return": {} } >>> + >>> +EQMP >>> + >>> + { >>> .name = "query-named-block-nodes", >>> .args_type = "", >>> .mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes, >> . >> From MAILER-DAEMON Tue Sep 15 03:58:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zbl83-0000Lw-UU for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 03:58:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbl7x-0000F8-MZ for qemu-block@nongnu.org; Tue, 15 Sep 2015 03:58:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zbl7r-0007zE-EB for qemu-block@nongnu.org; Tue, 15 Sep 2015 03:58:09 -0400 Received: from [59.151.112.132] (port=13989 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbl7k-0007xz-M7; Tue, 15 Sep 2015 03:57:58 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100727426" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Sep 2015 16:00:45 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8F7vcKx002857; Tue, 15 Sep 2015 15:57:38 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 15 Sep 2015 15:57:52 +0800 To: Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> <87mvwpkqzi.fsf@blackfin.pond.sub.org> <55F7850A.5050109@cn.fujitsu.com> <87613c86mk.fsf@blackfin.pond.sub.org> From: Wen Congyang Message-ID: <55F7CF5B.4070707@cn.fujitsu.com> Date: Tue, 15 Sep 2015 15:57:15 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87613c86mk.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 07:58:14 -0000 On 09/15/2015 03:49 PM, Markus Armbruster wrote: > Wen Congyang writes: > >> On 09/14/2015 10:36 PM, Markus Armbruster wrote: >>> Wen Congyang writes: >>> >>>> Signed-off-by: Wen Congyang >>>> Signed-off-by: zhanghailiang >>>> Signed-off-by: Gonglei >>>> --- >>>> blockdev.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ >>>> qapi/block-core.json | 34 +++++++++++++++++++++++++++++++++ >>>> qmp-commands.hx | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ >>>> 3 files changed, 134 insertions(+) >>>> >>>> diff --git a/blockdev.c b/blockdev.c >>>> index bd47756..0a40607 100644 >>>> --- a/blockdev.c >>>> +++ b/blockdev.c >>>> @@ -3413,6 +3413,53 @@ fail: >>>> qmp_output_visitor_cleanup(ov); >>>> } >>>> >>>> +void qmp_x_child_add(const char *parent, const char *child, >>>> + Error **errp) >>>> +{ >>>> + BlockDriverState *parent_bs, *child_bs; >>>> + Error *local_err = NULL; >>>> + >>>> + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); >>>> + if (!parent_bs) { >>>> + error_propagate(errp, local_err); >>>> + return; >>>> + } >>>> + >>>> + child_bs = bdrv_find_node(child); >>>> + if (!child_bs) { >>>> + error_setg(errp, "Node '%s' not found", child); >>>> + return; >>>> + } >>>> + >>>> + bdrv_add_child(parent_bs, child_bs, &local_err); >>>> + if (local_err) { >>>> + error_propagate(errp, local_err); >>>> + } >>>> +} >>>> + >>>> +void qmp_child_del(const char *parent, const char *child, Error **errp) >>>> +{ >>>> + BlockDriverState *parent_bs, *child_bs; >>>> + Error *local_err = NULL; >>>> + >>>> + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); >>>> + if (!parent_bs) { >>>> + error_propagate(errp, local_err); >>>> + return; >>>> + } >>>> + >>>> + child_bs = bdrv_find_node(child); >>>> + if (!child_bs) { >>>> + error_setg(errp, "Node '%s' not found", child); >>>> + return; >>>> + } >>>> + >>>> + bdrv_del_child(parent_bs, child_bs, &local_err); >>>> + if (local_err) { >>>> + error_propagate(errp, local_err); >>>> + } >>>> +} >>>> + >>>> BlockJobInfoList *qmp_query_block_jobs(Error **errp) >>>> { >>>> BlockJobInfoList *head = NULL, **p_next = &head; >>>> diff --git a/qapi/block-core.json b/qapi/block-core.json >>>> index e68a59f..b959577 100644 >>>> --- a/qapi/block-core.json >>>> +++ b/qapi/block-core.json >>>> @@ -2272,3 +2272,37 @@ >>>> ## >>>> { 'command': 'block-set-write-threshold', >>>> 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } >>>> + >>>> +## >>>> +# @x-child-add >>>> +# >>>> +# Add a new child to the parent BDS. Currently only the Quorum driver >>>> +# implements this feature. This is useful to fix a broken quorum child. >>>> +# >>>> +# @parent: graph node name or id which the child will be added to. >>>> +# >>>> +# @child: graph node name that will be added. >>>> +# >>>> +# Note: this command is experimental, and not a stable API. >>>> +# >>>> +# Since: 2.5 >>>> +## >>>> +{ 'command': 'x-child-add', >>>> + 'data' : { 'parent': 'str', 'child': 'str' } } >>>> + >>>> +## >>>> +# @child-del >>>> +# >>>> +# Remove a child from the parent BDS. Currently only the Quorum driver >>>> +# implements this feature. This is useful to fix a broken quorum child. >>>> +# Note, you can't remove a child if it would bring the quorum below its >>>> +# threshold. >>>> +# >>>> +# @parent: graph node name or id from which the child will removed. >>>> +# >>>> +# @child: graph node name that will be removed. >>>> +# >>>> +# Since: 2.5 >>>> +## >>>> +{ 'command': 'child-del', >>>> + 'data' : { 'parent': 'str', 'child': 'str' } } >>> >>> Why is x-child-add experimental, but child-del isn't? Please explain >>> both in the schema and in the commit message. >> >> No special reason. Should I put child-del in experimental namespace? > > I found the reason for x-child-add in your v2: > > child-add > ------------ > > Add a child to a quorum node. > > This command is still a work in progress. It doesn't support all > block drivers. Stay away from it unless you want it to help with > its development. > > Eric suggested to rename it to x-child-add, and you did. Good. You > also shortened the "work in progress" note to just "Note: this command > is experimental, and not a stable API." I'd like to have a more verbose > note explaining *why* the command is experimental, both here and in > qmp-commands.hx. "It doesn't support all block drivers" is a reason. > Are the any others? Currently, it only for quorum. But in the future, we can use this command to do more thing. For example: bs->file, bs->backing_hd, ... > > Is child-del similarly unfinished? If yes, make it x-child-del to save > us from later grief. > > If no: is child-del is only useful together with x-child-add? Then make > it x-child-del regardless. child-del is only useful together with x-child-add. I will rename it to x-child-del in the next version. Thanks Wen Congyang > >>>> diff --git a/qmp-commands.hx b/qmp-commands.hx >>>> index 495670b..139a23b 100644 >>>> --- a/qmp-commands.hx >>>> +++ b/qmp-commands.hx >>>> @@ -4053,6 +4053,59 @@ Example: >>>> EQMP >>>> >>>> { >>>> + .name = "x-child-add", >>>> + .args_type = "parent:B,child:B", >>>> + .mhandler.cmd_new = qmp_marshal_input_x_child_add, >>>> + }, >>>> + >>>> +SQMP >>>> +x-child-add >>>> +------------ >>>> + >>>> +Add a child to a quorum node. >>>> + >>>> +Arguments: >>>> + >>>> +- "parent": the quorum's id or node name >>>> +- "child": the child node-name which will be added >>> >>> Node name parameters are usually named node-name or, if there's more >>> than one, FOO-node-name. Unless we want to abandon that convention, >>> this should therefore be node-name and child-node-name, or parent-node >>> name and child-node-name. >> >> parent can be top BDS, so it can be id. node-name is a very common name, >> and I think child or child-node-name is better. > > Kevin pointed out we want to move to names without a -node-name suffix. > >>>> + >>>> +Note: this command is experimental, and not a stable API. >>>> + >>>> +Example: >>>> + >>>> +-> { "execute": "x-child-add", >>>> + "arguments": { "parent": "disk1", "child": "new_node" } } >>>> +<- { "return": {} } >>>> + >>>> +EQMP >>>> + >>>> + { >>>> + .name = "child-del", >>> >>> Documentation and schema have x-child-add, actual command is child-add. >>> Oops. >> >> Here is child-del.... > > You're right. I got confused... > >>>> + .args_type = "parent:B,child:B", >>>> + .mhandler.cmd_new = qmp_marshal_input_child_del, >>>> + }, >>>> + >>>> +SQMP >>>> +child-del >>>> +------------ >>>> + >>>> +Delete a child from a quorum node. It can be used to remove a broken >>>> +quorum child. >>>> + >>>> +Arguments: >>>> + >>>> +- "parent": the quorum's id or node name >>>> +- "child": the child node-name which will be removed >>> >>> Same comment as on x-child-add's parameter names. >>> >>>> + >>>> +Example: >>>> + >>>> +-> { "execute": "child-del", >>>> + "arguments": { "parent": "disk1", "child": "new_node" } } >>>> +<- { "return": {} } >>>> + >>>> +EQMP >>>> + >>>> + { >>>> .name = "query-named-block-nodes", >>>> .args_type = "", >>>> .mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes, >>> . >>> > . > From MAILER-DAEMON Tue Sep 15 04:02:48 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZblCS-0001mM-DS for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 04:02:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZblCN-0001fM-3E for qemu-block@nongnu.org; Tue, 15 Sep 2015 04:02:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZblCJ-0001Er-DQ for qemu-block@nongnu.org; Tue, 15 Sep 2015 04:02:43 -0400 Received: from [59.151.112.132] (port=48584 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZblCB-00018j-0X; Tue, 15 Sep 2015 04:02:31 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100727609" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Sep 2015 16:05:19 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8F82Bjq003184; Tue, 15 Sep 2015 16:02:11 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Tue, 15 Sep 2015 16:02:26 +0800 To: Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F776CC.3050601@cn.fujitsu.com> <87fv2g876a.fsf@blackfin.pond.sub.org> From: Wen Congyang Message-ID: <55F7D06D.1080205@cn.fujitsu.com> Date: Tue, 15 Sep 2015 16:01:49 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87fv2g876a.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 08:02:46 -0000 On 09/15/2015 03:37 PM, Markus Armbruster wrote: > Wen Congyang writes: > >> On 09/14/2015 11:47 PM, Eric Blake wrote: >>> On 09/14/2015 08:27 AM, Markus Armbruster wrote: >>>> Wen Congyang writes: >>>> >>>>> The NBD driver needs: filename, path or (host, port, exportname). >>>>> It checks which key exists and decides use unix or inet socket. >>>>> It doesn't recognize the key type, so we can't use union, and >>>>> can't reuse InetSocketAddress. >>>>> >>>>> Signed-off-by: Wen Congyang >>>>> Signed-off-by: zhanghailiang >>>>> Signed-off-by: Gonglei >>>>> --- >>>>> qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- >>>>> 1 file changed, 40 insertions(+), 2 deletions(-) >>>>> >>> >>>>> ## >>>>> +# @BlockdevOptionsNBD >>>>> +# >>>>> +# Driver specific block device options for NBD >>>>> +# >>>>> +# @filename: #optional unix or inet path. The format is: >>>>> +# unix: nbd+unix:///export?socket=path or >>>>> +# nbd:unix:path:exportname=export >>>>> +# inet: nbd[+tcp]://host[:port]/export or >>>>> +# nbd:host[:port]:exportname=export >>> >>> Yuck. You are passing structured data through a single 'str', when you >>> SHOULD be passing it through structured JSON. Just because we have a >>> filename shorthand for convenience does NOT mean that we want to expose >>> that convenience in QMP. Instead, we really want the breakdown of the >>> pieces (here, using abbreviated syntax of an inline base, since there >>> are pending qapi patches that will allow it): >> >> Do you mean that: there is no need to support filename? > > Rule of thumb: if the QMP command handler needs to parse a string > argument, that argument should be a complex QAPI type instead. > > Example: @filename needs to be parsed into its components, either > > * protocol unix, socket path, export name, or > * protocol tcp, host, port, export name > > Since there's an either/or, the complex QAPI type should be a union. > >>> { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } >> >> NBD only uses tcp, it doesn't support udp. >> >>> { 'union': 'BlockdevOptionsNBD', >>> 'base': { 'transport': 'NBDTransport', 'export': 'str' }, >>> 'discriminator': 'transport', >>> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } >>> { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } >> >> unix socket needs a path, and I think we can use UnixSocketAddress here. > > Yes, we should try to reuse common types like SocketAddress, > InetSocketAddress, UnixSocketAddress. > > Perhaps it could be as simple as > > { 'struct': 'BlockdevOptionsNBD', > 'data': { 'addr: 'SocketAddress', 'export': 'str' } } The problem is that: NBD doesn't use the fd. Another question is: what key will we see in nbd_open()? "addr.host" or "host"? Thanks Wen Congyang > > Eric, what do you think? > >>> { 'struct': 'NBDInet', 'data': { 'host': 'str', '*port': 'int', >>> '*ipv4': 'bool', '*ipv6': 'bool' } } >> >> Thanks for the above, and I will try it. > > [...] > . > From MAILER-DAEMON Tue Sep 15 04:06:57 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZblGT-0003jU-Ch for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 04:06:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZblGL-0003iX-1u for qemu-block@nongnu.org; Tue, 15 Sep 2015 04:06:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZblGG-0004IO-Aw for qemu-block@nongnu.org; Tue, 15 Sep 2015 04:06:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZblGG-0004IA-2v; Tue, 15 Sep 2015 04:06:44 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 965E08E68A; Tue, 15 Sep 2015 08:06:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8F86fGo012858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Sep 2015 04:06:42 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1B1A3303F916; Tue, 15 Sep 2015 10:06:41 +0200 (CEST) From: Markus Armbruster To: John Snow References: <1442253685-23349-1-git-send-email-jsnow@redhat.com> <1442253685-23349-2-git-send-email-jsnow@redhat.com> Date: Tue, 15 Sep 2015 10:06:41 +0200 In-Reply-To: <1442253685-23349-2-git-send-email-jsnow@redhat.com> (John Snow's message of "Mon, 14 Sep 2015 14:01:25 -0400") Message-ID: <87twqw6r8u.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/1] atapi: abort transfers with 0 byte limits X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 08:06:55 -0000 John Snow writes: > We're supposed to abort on transfers like this, unless we fill > Word 125 of our IDENTIFY data with a default transfer size, which > we don't currently do. > > This is an ATA error, not a SCSI/ATAPI one. > See ATA8-ACS3 sections 7.17.6.49 or 7.21.5. Reading... yes, that's what the spec says. > If we don't do this, QEMU will loop forever trying to transfer > zero bytes, which isn't particularly useful. Out of curiosity: which loop? > Signed-off-by: John Snow > --- > hw/ide/atapi.c | 32 +++++++++++++++++++++++++++----- > hw/ide/core.c | 2 +- > hw/ide/internal.h | 1 + > 3 files changed, 29 insertions(+), 6 deletions(-) > > diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c > index 79dd167..747f466 100644 > --- a/hw/ide/atapi.c > +++ b/hw/ide/atapi.c > @@ -1169,20 +1169,28 @@ enum { > * 4.1.8) > */ > CHECK_READY = 0x02, > + > + /* > + * Commands flagged with NONDATA do not in any circumstances return > + * any data via ide_atapi_cmd_reply. These commands are exempt from > + * the normal byte_count_limit constraints. > + * See ATA8-ACS3 "7.21.5 Byte Count Limit" Aside: that section is bizarre even for ATA. Missing piece: what tells you which commands are to be flagged NONDATA? > + */ > + NONDATA = 0x04, > }; > > static const struct { > void (*handler)(IDEState *s, uint8_t *buf); > int flags; > } atapi_cmd_table[0x100] = { > - [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY }, > + [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY | NONDATA }, > [ 0x03 ] = { cmd_request_sense, ALLOW_UA }, > [ 0x12 ] = { cmd_inquiry, ALLOW_UA }, > - [ 0x1b ] = { cmd_start_stop_unit, 0 }, /* [1] */ > - [ 0x1e ] = { cmd_prevent_allow_medium_removal, 0 }, > + [ 0x1b ] = { cmd_start_stop_unit, NONDATA }, /* [1] */ > + [ 0x1e ] = { cmd_prevent_allow_medium_removal, NONDATA }, > [ 0x25 ] = { cmd_read_cdvd_capacity, CHECK_READY }, > [ 0x28 ] = { cmd_read, /* (10) */ CHECK_READY }, > - [ 0x2b ] = { cmd_seek, CHECK_READY }, > + [ 0x2b ] = { cmd_seek, CHECK_READY | NONDATA }, > [ 0x43 ] = { cmd_read_toc_pma_atip, CHECK_READY }, > [ 0x46 ] = { cmd_get_configuration, ALLOW_UA }, > [ 0x4a ] = { cmd_get_event_status_notification, ALLOW_UA }, > @@ -1190,7 +1198,7 @@ static const struct { > [ 0x5a ] = { cmd_mode_sense, /* (10) */ 0 }, > [ 0xa8 ] = { cmd_read, /* (12) */ CHECK_READY }, > [ 0xad ] = { cmd_read_dvd_structure, CHECK_READY }, > - [ 0xbb ] = { cmd_set_speed, 0 }, > + [ 0xbb ] = { cmd_set_speed, NONDATA }, > [ 0xbd ] = { cmd_mechanism_status, 0 }, > [ 0xbe ] = { cmd_read_cd, CHECK_READY }, > /* [1] handler detects and reports not ready condition itself */ > @@ -1251,6 +1259,20 @@ void ide_atapi_cmd(IDEState *s) > return; > } > > + /* Nondata commands permit the byte_count_limit to be 0. > + * If this is a data-transferring PIO command and BCL is 0, > + * we abort at the /ATA/ level, not the ATAPI level. > + * See ATA8 ACS3 section 7.17.6.49 and 7.21.5 */ > + if (!(atapi_cmd_table[s->io_buffer[0]].flags & NONDATA)) { > + /* TODO: Check IDENTIFY data word 125 for default BCL (currently 0) */ > + uint16_t byte_count_limit = s->lcyl | (s->hcyl << 8); You might want to wrap s->lcyl | (s->hcyl << 8) in a helper function some day. Not in this patch, though. > + if (!(byte_count_limit || s->atapi_dma)) { > + /* TODO: Move abort back into core.c and make static inline again */ Not sure about the inline part, but that's not this patch's to judge. > + ide_abort_command(s); > + return; > + } > + } > + Let's see whether I can slash through the negations here... This is for a non-NONDATA command (outer conditional). In other words, we're expecting data. Unless either byte_count_limit is non-zero or atapi_dma is true (inner conditional), we abort the command. In other words: if byte_count_limit is non-zero, we'll be PIO-ing some data, so we're good. If atapi_dma is true, we'll be DMA-ing some data, so we're good. Else, no data will be coming, contradicting our expectation. The command is invalid, and we abort. Correct? > /* Execute the command */ > if (atapi_cmd_table[s->io_buffer[0]].handler) { > atapi_cmd_table[s->io_buffer[0]].handler(s, buf); > diff --git a/hw/ide/core.c b/hw/ide/core.c > index 50449ca..28cf535 100644 > --- a/hw/ide/core.c > +++ b/hw/ide/core.c > @@ -457,7 +457,7 @@ BlockAIOCB *ide_issue_trim(BlockBackend *blk, > return &iocb->common; > } > > -static inline void ide_abort_command(IDEState *s) > +void ide_abort_command(IDEState *s) > { > ide_transfer_stop(s); > s->status = READY_STAT | ERR_STAT; > diff --git a/hw/ide/internal.h b/hw/ide/internal.h > index 30fdcbc..40e1aa4 100644 > --- a/hw/ide/internal.h > +++ b/hw/ide/internal.h > @@ -537,6 +537,7 @@ void ide_set_sector(IDEState *s, int64_t sector_num); > > void ide_start_dma(IDEState *s, BlockCompletionFunc *cb); > void ide_dma_error(IDEState *s); > +void ide_abort_command(IDEState *s); > > void ide_atapi_cmd_ok(IDEState *s); > void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc); From MAILER-DAEMON Tue Sep 15 04:26:56 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZblZo-0002hi-27 for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 04:26:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZblZl-0002f6-Dn for qemu-block@nongnu.org; Tue, 15 Sep 2015 04:26:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZblZi-0005cV-9D for qemu-block@nongnu.org; Tue, 15 Sep 2015 04:26:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39762) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZblZi-0005cR-36; Tue, 15 Sep 2015 04:26:50 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 60AB28E3FC; Tue, 15 Sep 2015 08:26:49 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8F8QifQ025215; Tue, 15 Sep 2015 04:26:44 -0400 Date: Tue, 15 Sep 2015 10:26:43 +0200 From: Kevin Wolf To: John Snow Message-ID: <20150915082643.GA3986@noname.str.redhat.com> References: <1441816082-21031-1-git-send-email-jsnow@redhat.com> <55F27B1D.4030901@msgid.tls.msk.ru> <55F70C16.1070302@redhat.com> <55F71564.1010906@msgid.tls.msk.ru> <55F716CF.4050306@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55F716CF.4050306@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, stefano.stabellini@eu.citrix.com, armbru@redhat.com, qemu-stable@nongnu.org, Michael Tokarev , qemu-devel@nongnu.org, ppandit@redhat.com, luodalongde@gmail.com, liuling-it@360.cn Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] ide: fix ATAPI command permissions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 08:26:54 -0000 Am 14.09.2015 um 20:49 hat John Snow geschrieben: > On 09/14/2015 02:43 PM, Michael Tokarev wrote: > > 14.09.2015 21:04, John Snow wrote: > >> On 09/11/2015 02:56 AM, Michael Tokarev wrote: > >>> 09.09.2015 19:28, John Snow wrote: > >>>> We're a little too lenient with what we'll let an ATAPI drive handle. > >>>> Clamp down on the IDE command execution table to remove CD_OK permissions > >>>> from commands that are not and have never been ATAPI commands. > >>> > >>> FWIW, this issue has been assigned CVE-2015-6855 identifier, which > >>> can be reflected in the commit message when applying. Since this > >>> issue has security impact, it might be a good idea to add > >>> > >>> Cc: qemu-stable@nongnu.org > >> > >> I'm still awaiting review/acks, but would you like me to re-send this > >> patch to trivial, or just fwd/reply-to? > > > > I think it is anything but trivial ;) Well, the semantics is trivial, > > but it isn't -trivial material per se. > > > > I suggested add a Cc to qemu-stable, this can be done at commit, > > together with mentioning the CVE# assigned meanwhile, and I don't > > know who will commit it, Kevin? > > > > Thanks, > > > > /mjt > > > > I'll be sending the pullreq through my tree, but I was waiting on at > least an ACK or so before I went ahead. > > I can add CC: qemu-stable to the patch on-pull if that's sufficient for you. Ideally, stable patches should have a "Cc: qemu-stable@nongnu.org" line in the commit message, too. Just adding that on pull should be enough. Also copying the list for this reply so that there is some trace of the patch on it. Kevin From MAILER-DAEMON Tue Sep 15 04:56:58 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zbm2s-0000gu-0K for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 04:56:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbm2n-0000Zs-Rn for qemu-block@nongnu.org; Tue, 15 Sep 2015 04:56:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zbm2n-0002Kb-0d for qemu-block@nongnu.org; Tue, 15 Sep 2015 04:56:53 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:14092 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbm2h-0002Ht-Pp; Tue, 15 Sep 2015 04:56:47 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AuBgD83PdV/5tjdVteGQEBAYMHgT2pMgEBAQEBAQUBgQoBkw2HcgKBPDkTAQEBAQEBAYEKhCQBAQQnEz8QCw4TJQ8BLBsGARKIMgHJYwEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsAQSVXKgGIwI+hAM8M4oqAQEB X-IPAS-Result: A2AuBgD83PdV/5tjdVteGQEBAYMHgT2pMgEBAQEBAQUBgQoBkw2HcgKBPDkTAQEBAQEBAYEKhCQBAQQnEz8QCw4TJQ8BLBsGARKIMgHJYwEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsAQSVXKgGIwI+hAM8M4oqAQEB X-IronPort-AV: E=Sophos;i="5.17,534,1437429600"; d="scan'208";a="22086388" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 15 Sep 2015 10:56:44 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1Zbm2e-0006HG-PG; Tue, 15 Sep 2015 10:56:44 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1Zbm2e-0002UX-Ig; Tue, 15 Sep 2015 10:56:44 +0200 From: Alberto Garcia To: Kevin Wolf , Wen Congyang In-Reply-To: <20150914153700.GE3550@noname.str.redhat.com> References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> <20150914153700.GE3550@noname.str.redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Tue, 15 Sep 2015 10:56:44 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: zhanghailiang , qemu block , Markus Armbruster , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , qemu devel , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 08:56:54 -0000 On Mon 14 Sep 2015 05:37:00 PM CEST, Kevin Wolf wrote: >> +{ 'command': 'x-child-add', >> + 'data' : { 'parent': 'str', 'child': 'str' } } > > This is probably not future-proof and only made for the special case > of quorum. Specifically, one thing I'm missing is some way to specfiy > what kind of child the new node is when a node can take different > types of children (e.g. bs->file and bs->backing_hd). Children here are specified by child roles, aren't they? We could have a ChildRole enum with 'file', 'format' and 'backing' that would be passed to this command and use the same enumeration in bdrv_open_image() rather than a pointer to BdrvChildRole. Berto From MAILER-DAEMON Tue Sep 15 05:20:51 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbmPz-0006d1-Sx for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 05:20:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbmPx-0006bQ-SH for qemu-block@nongnu.org; Tue, 15 Sep 2015 05:20:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbmPu-0004rb-QP for qemu-block@nongnu.org; Tue, 15 Sep 2015 05:20:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41837) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbmPu-0004qg-JB; Tue, 15 Sep 2015 05:20:46 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 685862F812D; Tue, 15 Sep 2015 09:20:45 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8F9KgoX007829; Tue, 15 Sep 2015 05:20:42 -0400 Date: Tue, 15 Sep 2015 11:20:42 +0200 From: Kevin Wolf To: Alberto Garcia Message-ID: <20150915092042.GB3986@noname.str.redhat.com> References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> <20150914153700.GE3550@noname.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu block , Wen Congyang , Markus Armbruster , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , qemu devel , Gonglei , Stefan Hajnoczi , Yang Hongyang , zhanghailiang Subject: Re: [Qemu-block] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 09:20:51 -0000 Am 15.09.2015 um 10:56 hat Alberto Garcia geschrieben: > On Mon 14 Sep 2015 05:37:00 PM CEST, Kevin Wolf wrote: > > >> +{ 'command': 'x-child-add', > >> + 'data' : { 'parent': 'str', 'child': 'str' } } > > > > This is probably not future-proof and only made for the special case > > of quorum. Specifically, one thing I'm missing is some way to specfiy > > what kind of child the new node is when a node can take different > > types of children (e.g. bs->file and bs->backing_hd). > > Children here are specified by child roles, aren't they? Possibly, but actually, currently I'm inclined to think that they aren't. Child roles are still relatively new, though, so it's hard to say if this is just because we didn't use them in that way so far, or because they are really the wrong tool. What I can say is that traditionally children are identified by option names. Block drivers assign a ChildRole when processing the option, and both are equivalent only if the same ChildRole is never used for two different children. I believe that that's currently true, but I'm doubtful whether it will remain this way (even looking at blkverify, which has one &child_file and one &child_format, things start to look a bit confusing). Possibly the right and consistent way to change the set of children would be through a QMP command exposing bdrv_reopen(), which would also be used for changing other options at runtime. My current pull request adds the qemu-io (and therefore HMP) way of doing this, but finding a good QMP interface will still be a challenge. > We could have a ChildRole enum with 'file', 'format' and 'backing' that > would be passed to this command and use the same enumeration in > bdrv_open_image() rather than a pointer to BdrvChildRole. Yes, that would be an option if ChildRole turned out to be enough. Kevin From MAILER-DAEMON Tue Sep 15 05:26:55 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbmVr-0006dC-R6 for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 05:26:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbmVp-0006YL-7G for qemu-block@nongnu.org; Tue, 15 Sep 2015 05:26:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbmVk-0008HO-7E for qemu-block@nongnu.org; Tue, 15 Sep 2015 05:26:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43043) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbmVk-0008H5-1q; Tue, 15 Sep 2015 05:26:48 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 989282EAAB0; Tue, 15 Sep 2015 09:26:47 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8F9Qiv5011310; Tue, 15 Sep 2015 05:26:45 -0400 Date: Tue, 15 Sep 2015 11:26:44 +0200 From: Kevin Wolf To: Alberto Garcia Message-ID: <20150915092644.GC3986@noname.str.redhat.com> References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> <20150914153700.GE3550@noname.str.redhat.com> <20150915092042.GB3986@noname.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150915092042.GB3986@noname.str.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu block , Wen Congyang , qemu devel , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Markus Armbruster , Gonglei , Stefan Hajnoczi , Yang Hongyang , zhanghailiang Subject: Re: [Qemu-block] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 09:26:54 -0000 Am 15.09.2015 um 11:20 hat Kevin Wolf geschrieben: > Am 15.09.2015 um 10:56 hat Alberto Garcia geschrieben: > > On Mon 14 Sep 2015 05:37:00 PM CEST, Kevin Wolf wrote: > > > > >> +{ 'command': 'x-child-add', > > >> + 'data' : { 'parent': 'str', 'child': 'str' } } > > > > > > This is probably not future-proof and only made for the special case > > > of quorum. Specifically, one thing I'm missing is some way to specfiy > > > what kind of child the new node is when a node can take different > > > types of children (e.g. bs->file and bs->backing_hd). > > > > Children here are specified by child roles, aren't they? > > Possibly, but actually, currently I'm inclined to think that they > aren't. Child roles are still relatively new, though, so it's hard to > say if this is just because we didn't use them in that way so far, or > because they are really the wrong tool. > > What I can say is that traditionally children are identified by option > names. Block drivers assign a ChildRole when processing the option, and > both are equivalent only if the same ChildRole is never used for two > different children. I believe that that's currently true, but I'm > doubtful whether it will remain this way (even looking at blkverify, > which has one &child_file and one &child_format, things start to look a > bit confusing). What I wanted to mention, but forgot to do, is that obviously we could use more specific ChildRoles than &child_file and &child_format, essentially creating one ChildRole per option and making them equivalent this way. I'm not sure if that would be a good or a bad idea. > Possibly the right and consistent way to change the set of children > would be through a QMP command exposing bdrv_reopen(), which would also > be used for changing other options at runtime. > > My current pull request adds the qemu-io (and therefore HMP) way of > doing this, but finding a good QMP interface will still be a challenge. > > > We could have a ChildRole enum with 'file', 'format' and 'backing' that > > would be passed to this command and use the same enumeration in > > bdrv_open_image() rather than a pointer to BdrvChildRole. > > Yes, that would be an option if ChildRole turned out to be enough. > > Kevin > From MAILER-DAEMON Tue Sep 15 05:34:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbmdS-0003gW-Vf for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 05:34:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbmdQ-0003f4-9R for qemu-block@nongnu.org; Tue, 15 Sep 2015 05:34:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbmdL-0002VK-B0 for qemu-block@nongnu.org; Tue, 15 Sep 2015 05:34:44 -0400 Received: from mail-vk0-f50.google.com ([209.85.213.50]:34152) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbmdL-0002Uz-7y for qemu-block@nongnu.org; Tue, 15 Sep 2015 05:34:39 -0400 Received: by vkhf67 with SMTP id f67so75802147vkh.1 for ; Tue, 15 Sep 2015 02:34:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=BNzYrKpJ+5d4f4mnfYvH5AB1hutDLyVOCp7Us3UF0jE=; b=IFegoeb4Tj4lzxgkpDdrACH677hunF3cQePtkrcIlmaen6VuIXNoU1x8JQN5Fd/bGX xWnO2xA++o4TUn0VgRWm8VEbBlTELcyniFyoO6/R82lNn4EpfMjsQGUSJoGwbQyFldxB +86x+0B1DissglvinvwSulvRQSHtVz77WvtxycyCCPwCXbWoG6z8ZsaW9YjeOzIPxxVD ZL9hINWXgeoqg4c+3yByXnLIUzbHGSCWUkJHEIQHQL+nOLgsU1/lf/kIEqRT3f1KEmdw e34M/38obmkQ+oarO0BYeL0yDO4eF2Y6zrIorGewmWTmbxKRQQwQkWptfGnpreHKPvue dVLA== X-Gm-Message-State: ALoCoQkQe9wPpQwbsmNGZdORPXd96qqloK6Ns5DlGrqBLJULzD/zhLUl0ExmEO3S6Ae/aL46Jkq8 X-Received: by 10.31.1.214 with SMTP id 205mr19412750vkb.90.1442309678636; Tue, 15 Sep 2015 02:34:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.153.15 with HTTP; Tue, 15 Sep 2015 02:34:19 -0700 (PDT) In-Reply-To: <1442244321-2305-1-git-send-email-kwolf@redhat.com> References: <1442244321-2305-1-git-send-email-kwolf@redhat.com> From: Peter Maydell Date: Tue, 15 Sep 2015 10:34:19 +0100 Message-ID: To: Kevin Wolf Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.213.50 Cc: QEMU Developers , Qemu-block Subject: Re: [Qemu-block] [Qemu-devel] [PULL v2 00/23] Block layer patches X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 09:34:45 -0000 On 14 September 2015 at 16:25, Kevin Wolf wrote: > The following changes since commit 2b750d9d261bda7f75b39dfc1e1e5f22502929d5: > > Merge remote-tracking branch 'remotes/aurel/tags/pull-sh4-next-20150913' into staging (2015-09-14 10:46:38 +0100) > > are available in the git repository at: > > > git://repo.or.cz/qemu/kevin.git tags/for-upstream > > for you to fetch changes up to 2ac01520be8717f3492b10a083c3e0e22cb52cda: > > qcow2: Make qcow2_alloc_bytes() more explicit (2015-09-14 16:51:37 +0200) > > ---------------------------------------------------------------- > Block layer patches (v2) Applied, thanks. -- PMM From MAILER-DAEMON Tue Sep 15 07:13:06 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZboAb-0003nl-Ul for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 07:13:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZboAZ-0003jn-BY for qemu-block@nongnu.org; Tue, 15 Sep 2015 07:13:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZboAY-0003Ql-0n for qemu-block@nongnu.org; Tue, 15 Sep 2015 07:13:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZboAX-0003QZ-Po; Tue, 15 Sep 2015 07:13:01 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 3B97391C1A; Tue, 15 Sep 2015 11:12:57 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8FBCrb6001638 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Sep 2015 07:12:55 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 529ED303F916; Tue, 15 Sep 2015 13:12:53 +0200 (CEST) From: Markus Armbruster To: Wen Congyang References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F776CC.3050601@cn.fujitsu.com> <87fv2g876a.fsf@blackfin.pond.sub.org> <55F7D06D.1080205@cn.fujitsu.com> Date: Tue, 15 Sep 2015 13:12:53 +0200 In-Reply-To: <55F7D06D.1080205@cn.fujitsu.com> (Wen Congyang's message of "Tue, 15 Sep 2015 16:01:49 +0800") Message-ID: <87mvwo3phm.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 11:13:04 -0000 Wen Congyang writes: > On 09/15/2015 03:37 PM, Markus Armbruster wrote: >> Wen Congyang writes: >> >>> On 09/14/2015 11:47 PM, Eric Blake wrote: >>>> On 09/14/2015 08:27 AM, Markus Armbruster wrote: >>>>> Wen Congyang writes: >>>>> >>>>>> The NBD driver needs: filename, path or (host, port, exportname). >>>>>> It checks which key exists and decides use unix or inet socket. >>>>>> It doesn't recognize the key type, so we can't use union, and >>>>>> can't reuse InetSocketAddress. >>>>>> >>>>>> Signed-off-by: Wen Congyang >>>>>> Signed-off-by: zhanghailiang >>>>>> Signed-off-by: Gonglei >>>>>> --- >>>>>> qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- >>>>>> 1 file changed, 40 insertions(+), 2 deletions(-) >>>>>> >>>> >>>>>> ## >>>>>> +# @BlockdevOptionsNBD >>>>>> +# >>>>>> +# Driver specific block device options for NBD >>>>>> +# >>>>>> +# @filename: #optional unix or inet path. The format is: >>>>>> +# unix: nbd+unix:///export?socket=path or >>>>>> +# nbd:unix:path:exportname=export >>>>>> +# inet: nbd[+tcp]://host[:port]/export or >>>>>> +# nbd:host[:port]:exportname=export >>>> >>>> Yuck. You are passing structured data through a single 'str', when you >>>> SHOULD be passing it through structured JSON. Just because we have a >>>> filename shorthand for convenience does NOT mean that we want to expose >>>> that convenience in QMP. Instead, we really want the breakdown of the >>>> pieces (here, using abbreviated syntax of an inline base, since there >>>> are pending qapi patches that will allow it): >>> >>> Do you mean that: there is no need to support filename? >> >> Rule of thumb: if the QMP command handler needs to parse a string >> argument, that argument should be a complex QAPI type instead. >> >> Example: @filename needs to be parsed into its components, either >> >> * protocol unix, socket path, export name, or >> * protocol tcp, host, port, export name >> >> Since there's an either/or, the complex QAPI type should be a union. >> >>>> { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } >>> >>> NBD only uses tcp, it doesn't support udp. >>> >>>> { 'union': 'BlockdevOptionsNBD', >>>> 'base': { 'transport': 'NBDTransport', 'export': 'str' }, >>>> 'discriminator': 'transport', >>>> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } >>>> { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } >>> >>> unix socket needs a path, and I think we can use UnixSocketAddress here. >> >> Yes, we should try to reuse common types like SocketAddress, >> InetSocketAddress, UnixSocketAddress. >> >> Perhaps it could be as simple as >> >> { 'struct': 'BlockdevOptionsNBD', >> 'data': { 'addr: 'SocketAddress', 'export': 'str' } } > > The problem is that: NBD doesn't use the fd. Is that fundamental, or just a matter of implementation? > Another question is: what key will we see in nbd_open()? "addr.host" > or "host"? As long as nbd_config() looks for "host" in the options QDict, we need to put "host". > Thanks > Wen Congyang > >> >> Eric, what do you think? >> >>>> { 'struct': 'NBDInet', 'data': { 'host': 'str', '*port': 'int', >>>> '*ipv4': 'bool', '*ipv6': 'bool' } } >>> >>> Thanks for the above, and I will try it. >> >> [...] >> . >> From MAILER-DAEMON Tue Sep 15 09:22:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbqBo-0008GY-Rc for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 09:22:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbqBh-0006zL-6J for qemu-block@nongnu.org; Tue, 15 Sep 2015 09:22:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zbq1C-0007xq-5l for qemu-block@nongnu.org; Tue, 15 Sep 2015 09:11:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59636) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbq1B-0007xm-UG; Tue, 15 Sep 2015 09:11:30 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id EB2B62F9101; Tue, 15 Sep 2015 13:11:26 +0000 (UTC) Received: from [10.3.113.35] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8FDBDVK019976; Tue, 15 Sep 2015 09:11:14 -0400 To: Wen Congyang , Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F78059.4030309@cn.fujitsu.com> <55F78225.404@cn.fujitsu.com> <55F794A4.5060903@redhat.com> <55F7975B.4050405@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55F818F1.9070201@redhat.com> Date: Tue, 15 Sep 2015 07:11:13 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F7975B.4050405@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="F3qxue89eNrn07wxQwhHCsvR6HucOt8Am" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 13:22:27 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --F3qxue89eNrn07wxQwhHCsvR6HucOt8Am Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/14/2015 09:58 PM, Wen Congyang wrote: > On 09/15/2015 11:46 AM, Eric Blake wrote: >> On 09/14/2015 08:27 PM, Wen Congyang wrote: >>>> Building fails: >>>> GEN qmp-commands.h >>>> In file included from /work/src/qemu/qapi-schema.json:9: >>>> In file included from /work/src/qemu/qapi/block.json:6: >>>> /work/src/qemu/qapi/block-core.json:1844: Flat union 'BlockdevOption= sNBD' must have a string base field >>>> Makefile:286: recipe for target 'qmp-commands.h' failed >>>> make: *** [qmp-commands.h] Error 1 >> >> Yep, doesn't work until pending qapi patches land. >=20 > This patchset: qapi: QMP introspection? That, and "qapi-ify netdev_add, and other post-introspection cleanups" https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg02580.html and "qapi: support anonymous inline base" https://lists.gnu.org/archive/html/qemu-devel/2015-08/msg02346.html [still needs rebasing to latest versions of the other series] >> >> Possible workaround in the meantime - instead of trying to go with a >> nice flat union (where all QMP keys are in the same {} level), we can >> use nesting (structs that add another {} to include the unions). >=20 > How to include the unions to a structs? Use 'base'? Conceptually, by adding a layer of nesting. On the wire, instead of: { "switch1":"value", "switch2":"value", "body2":"blah" } you would instead have: { "switch1":"value", "data": { "switch2":"value", "body2":"blah" } } Anywhere in qapi that you try to have: { 'union': ..., 'data':{'switch1':'Union'}} you instead create a wrapper type: { 'struct':'Wrapper', 'data':{'data':'Union'}} { 'union': ..., 'data':{'switch1':'Wrapper'}} What I don't know is whether the extra QMP nesting makes it easier or harder to support the existing NBD command line options, and it would ultimately be nice to have unified support so that anything we can do on the command line can be expressed in QMP; and anything we can do in QMP can be expressed on the command line without undue nesting. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --F3qxue89eNrn07wxQwhHCsvR6HucOt8Am Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV+BjxAAoJEKeha0olJ0NqdNUIAJOA/mI7T4VCtWAPoXv0Gz0/ K6jy1hlDLlUJAlp8WxZHtHpvfxnq5hl9Gy/eEC4/PYaSNmtalPsAw+uu//JYYqaV JbIgelsxBHVi/iZAZPZeRbAJWiMVNFVhir1256ppG2ojjutHd8/iBEdzvRv7lqCu cQDA4mN8IzA6m70O2PKILhVdYcT+/GZs6q24Xj8ZiH9yTt5d0cvMnBbj91AlkE87 htyLfk+ol0m9ZWKpdBYArDDHX5Mk/PmN+PTV2pupeePEHD/fQ5myIIW4V4OJF/rv zNtwUhW9rvv1BjXSnl6jl7b4PFIR23jdSRCzqLM0Z67O7RQJ/Mm+OkBtFcyDuxU= =1Cop -----END PGP SIGNATURE----- --F3qxue89eNrn07wxQwhHCsvR6HucOt8Am-- From MAILER-DAEMON Tue Sep 15 09:22:59 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbqCI-0000Wx-V6 for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 09:22:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbqC9-0000Gh-GX for qemu-block@nongnu.org; Tue, 15 Sep 2015 09:22:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zbpto-0003cw-53 for qemu-block@nongnu.org; Tue, 15 Sep 2015 09:03:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54878) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbptn-0003bl-Tf; Tue, 15 Sep 2015 09:03:52 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 8D3F68EA49; Tue, 15 Sep 2015 13:03:48 +0000 (UTC) Received: from [10.3.113.35] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8FD3iwv008025; Tue, 15 Sep 2015 09:03:45 -0400 To: Markus Armbruster , Wen Congyang References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F776CC.3050601@cn.fujitsu.com> <87fv2g876a.fsf@blackfin.pond.sub.org> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55F8172B.5020209@redhat.com> Date: Tue, 15 Sep 2015 07:03:39 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87fv2g876a.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="fo4pLkHCqPRmFSKvehQB2PL0k9oXNCrIf" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 13:22:54 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --fo4pLkHCqPRmFSKvehQB2PL0k9oXNCrIf Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/15/2015 01:37 AM, Markus Armbruster wrote: >>>>> +# @filename: #optional unix or inet path. The format is: >>>>> +# unix: nbd+unix:///export?socket=3Dpath or >>>>> +# nbd:unix:path:exportname=3Dexport >>>>> +# inet: nbd[+tcp]://host[:port]/export or >>>>> +# nbd:host[:port]:exportname=3Dexport >>> > Since there's an either/or, the complex QAPI type should be a union. >=20 >>> { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } >> >> NBD only uses tcp, it doesn't support udp. Fair enough. >> >>> { 'union': 'BlockdevOptionsNBD', >>> 'base': { 'transport': 'NBDTransport', 'export': 'str' }, >>> 'discriminator': 'transport', >>> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } }= >>> { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } >> >> unix socket needs a path, and I think we can use UnixSocketAddress her= e. Sure, if that works, you could do 'unix':'UnixSocketAddress' instead of inventing 'NBDUnix'. >=20 > Yes, we should try to reuse common types like SocketAddress, > InetSocketAddress, UnixSocketAddress. Well, we've already questioned whether 'InetSocketAddress' needs to be fixed to be separate from a socket range, but it can be a separate fix. >=20 > Perhaps it could be as simple as >=20 > { 'struct': 'BlockdevOptionsNBD', > 'data': { 'addr: 'SocketAddress', 'export': 'str' } } >=20 > Eric, what do you think? It has more nesting on the wire, but should work. That is, to express "nbd+unix:///export?socket=3Dpath", the QMP would be: { "export":"export", "addr":{ "type":"unix", "data":{ "path": "str"}}} instead of a nicer: { "export":"export", "type":"unix", "path":"str" } but the advantage of working now rather than waiting on qapi fixes in the pipeline has its benefit. There's also the question of how to handle 'fd', if NBD can't reuse an existing fd but must be given a unix socket filename or tcp host/port destination. Documenting that we reject a combination may be okay, except that it is harder to introspect later if the combination is no longer rejected because we later add support. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --fo4pLkHCqPRmFSKvehQB2PL0k9oXNCrIf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV+BcrAAoJEKeha0olJ0NqtwAIAKGjfvHge9IGjE8jDpbe6aiA 5UER7HsfJ0CFVUS+7+S8BGaQ2OFzco6YeF4uCDi6NFBMk799tCBzeQ6rwlQTi42P 2Q1l08NMgpy0ec2GdLIQQDidD2zQc19qyTcVwAQ1WsDBxtNB6cPyLmFlWV5PvZwe KQ1W2YHBJ6X5Bs5WWpHL/m0SOCScyYd6fV2FV7WsMXGAoVVnA+mBsJDdCM8wH+AN 6LGbuMx5jN2l+U22zHcAmRMpBo9Of5Ls1j4HAybIoW48ptM5eUjHX7nXhdYjVEop 5BA0ObG1n8yaG/hrC6AwNfMjznEOLlAtQZ4283gRVfSnNWdija9VGmknWPAznqE= =+X/q -----END PGP SIGNATURE----- --fo4pLkHCqPRmFSKvehQB2PL0k9oXNCrIf-- From MAILER-DAEMON Tue Sep 15 09:45:25 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbqY1-0005fP-O2 for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 09:45:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbqXz-0005c9-Lk for qemu-block@nongnu.org; Tue, 15 Sep 2015 09:45:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbqXv-0008HJ-C3 for qemu-block@nongnu.org; Tue, 15 Sep 2015 09:45:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33209) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbqFm-0007ul-UB; Tue, 15 Sep 2015 09:26:35 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 742B591EA0; Tue, 15 Sep 2015 13:26:34 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8FDQTI5024269; Tue, 15 Sep 2015 09:26:30 -0400 Date: Tue, 15 Sep 2015 15:26:29 +0200 From: Kevin Wolf To: Eric Blake Message-ID: <20150915132629.GD3986@noname.str.redhat.com> References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F776CC.3050601@cn.fujitsu.com> <87fv2g876a.fsf@blackfin.pond.sub.org> <55F8172B.5020209@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wRRV7LY7NUeQGEoC" Content-Disposition: inline In-Reply-To: <55F8172B.5020209@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu block , Jiang Yunhong , Dong Eddie , Markus Armbruster , qemu devel , Gonglei , Stefan Hajnoczi , Yang Hongyang , "Dr. David Alan Gilbert" , zhanghailiang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 13:45:24 -0000 --wRRV7LY7NUeQGEoC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 15.09.2015 um 15:03 hat Eric Blake geschrieben: > On 09/15/2015 01:37 AM, Markus Armbruster wrote: >=20 > >>>>> +# @filename: #optional unix or inet path. The format is: > >>>>> +# unix: nbd+unix:///export?socket=3Dpath or > >>>>> +# nbd:unix:path:exportname=3Dexport > >>>>> +# inet: nbd[+tcp]://host[:port]/export or > >>>>> +# nbd:host[:port]:exportname=3Dexport > >>> >=20 > > Since there's an either/or, the complex QAPI type should be a union. > >=20 > >>> { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } > >> > >> NBD only uses tcp, it doesn't support udp. >=20 > Fair enough. >=20 > >> > >>> { 'union': 'BlockdevOptionsNBD', > >>> 'base': { 'transport': 'NBDTransport', 'export': 'str' }, > >>> 'discriminator': 'transport', > >>> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } > >>> { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } > >> > >> unix socket needs a path, and I think we can use UnixSocketAddress her= e. >=20 > Sure, if that works, you could do 'unix':'UnixSocketAddress' instead of > inventing 'NBDUnix'. >=20 > >=20 > > Yes, we should try to reuse common types like SocketAddress, > > InetSocketAddress, UnixSocketAddress. >=20 > Well, we've already questioned whether 'InetSocketAddress' needs to be > fixed to be separate from a socket range, but it can be a separate fix. >=20 > >=20 > > Perhaps it could be as simple as > >=20 > > { 'struct': 'BlockdevOptionsNBD', > > 'data': { 'addr: 'SocketAddress', 'export': 'str' } } > >=20 > > Eric, what do you think? >=20 > It has more nesting on the wire, but should work. That is, to express > "nbd+unix:///export?socket=3Dpath", the QMP would be: >=20 > { "export":"export", "addr":{ "type":"unix", "data":{ "path": "str"}}} >=20 > instead of a nicer: >=20 > { "export":"export", "type":"unix", "path":"str" } >=20 > but the advantage of working now rather than waiting on qapi fixes in > the pipeline has its benefit. Both patches are for 2.5 anyway. Is the benefit of getting this in before the QAPI series really that big that we should go with an ugly syntax? > There's also the question of how to handle 'fd', if NBD can't reuse an > existing fd but must be given a unix socket filename or tcp host/port > destination. Documenting that we reject a combination may be okay, > except that it is harder to introspect later if the combination is no > longer rejected because we later add support. How about implementing fd suppor instead? Kevin --wRRV7LY7NUeQGEoC Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJV+ByFAAoJEH8JsnLIjy/W5FAQAK5jMznGONwerjKhP4CznFoF JGpP3G7r8sEDaup0XoS+fwkiajcjJ55w8YhM0eytzypVJWzOb//jZ8wQn2nEVWEf 63qP5m2rv9OV/FEI2X4no8YXXz0Pao2D7g42rMZCW87keTaNK2j7kcZKoDEOIzRo hogCXx60RR0C2dmA7PpG/F5zIxoqcNOsigIzoniQXMzPnKEQIe1mZcGoExxvhnwo mMaQ28HVL5k3fvPqLJ4HUTzy7I5o/4p9Kfcch/fv4dSlZdtVtyjTfI937GcB7mYu Ih8saZ+qtAqbs+/hPp9oHTUEqPUxQf4QHoFQ5ShCgWsPAvSsaraCiNBnQPXevuRt 7KT1L81lcJLxVg8//6bzNFUerPtOsJp4USnKWmU5KGibYQqy3X/JUt9ZLDU+BJ6N kPDzk7eAi3+Smf1MnyUR/TKdQNdAkW9UuSx5iqvDfYgWjfp/hQWzWrsd1yUbV/3F fSY7wsuLQDiyUT7Td92CiIQI5x24mvPnJy4m3+iI49uDxWHjwN5JiaMKzQ6H6Xo9 8RIzSxovIxMXMrW73YT6L20CfywltSqo3wKlAScNgj7df/y1PjxRq6zm1bq0kUSc 5q/dE5jyezKqLhntn43AM9m5tafMfETM5QsI9WpJnbe0ajSLL3vCl7R8OZ7QPmNg Oaia0SIu4lB4fNWre6Pq =QoY4 -----END PGP SIGNATURE----- --wRRV7LY7NUeQGEoC-- From MAILER-DAEMON Tue Sep 15 11:52:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbsWY-0006iW-MF for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 11:52:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbsWS-0006fe-Kz for qemu-block@nongnu.org; Tue, 15 Sep 2015 11:52:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbsWP-00045C-6X for qemu-block@nongnu.org; Tue, 15 Sep 2015 11:51:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56063) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbsWO-00044N-U2; Tue, 15 Sep 2015 11:51:53 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 16926C0B2006; Tue, 15 Sep 2015 15:51:51 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8FFpogN022668; Tue, 15 Sep 2015 11:51:51 -0400 To: Markus Armbruster References: <1442253685-23349-1-git-send-email-jsnow@redhat.com> <1442253685-23349-2-git-send-email-jsnow@redhat.com> <87twqw6r8u.fsf@blackfin.pond.sub.org> From: John Snow X-Enigmail-Draft-Status: N1110 Message-ID: <55F83E96.8050006@redhat.com> Date: Tue, 15 Sep 2015 11:51:50 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87twqw6r8u.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/1] atapi: abort transfers with 0 byte limits X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 15:52:01 -0000 On 09/15/2015 04:06 AM, Markus Armbruster wrote: > John Snow writes: > >> We're supposed to abort on transfers like this, unless we fill >> Word 125 of our IDENTIFY data with a default transfer size, which >> we don't currently do. >> >> This is an ATA error, not a SCSI/ATAPI one. >> See ATA8-ACS3 sections 7.17.6.49 or 7.21.5. > > Reading... yes, that's what the spec says. > Yep, we're in a weird no man's land between IDE and SCSI here. We need the ATAPI device to decipher the packet, but we need the IDE device to abort. >> If we don't do this, QEMU will loop forever trying to transfer >> zero bytes, which isn't particularly useful. > > Out of curiosity: which loop? > ide_atapi_cmd_reply_end callback loop -- it can compute the BCL as zero and it very busily loops transmitting 0 bytes each iteration. >> Signed-off-by: John Snow >> --- >> hw/ide/atapi.c | 32 +++++++++++++++++++++++++++----- >> hw/ide/core.c | 2 +- >> hw/ide/internal.h | 1 + >> 3 files changed, 29 insertions(+), 6 deletions(-) >> >> diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c >> index 79dd167..747f466 100644 >> --- a/hw/ide/atapi.c >> +++ b/hw/ide/atapi.c >> @@ -1169,20 +1169,28 @@ enum { >> * 4.1.8) >> */ >> CHECK_READY = 0x02, >> + >> + /* >> + * Commands flagged with NONDATA do not in any circumstances return >> + * any data via ide_atapi_cmd_reply. These commands are exempt from >> + * the normal byte_count_limit constraints. >> + * See ATA8-ACS3 "7.21.5 Byte Count Limit" > > Aside: that section is bizarre even for ATA. > > Missing piece: what tells you which commands are to be flagged NONDATA? > They do not invoke ide_atapi_cmd_reply. This is not an ATA designation, just a practical flag to classify our handlers. I went through each function to check manually. >> + */ >> + NONDATA = 0x04, >> }; >> >> static const struct { >> void (*handler)(IDEState *s, uint8_t *buf); >> int flags; >> } atapi_cmd_table[0x100] = { >> - [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY }, >> + [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY | NONDATA }, >> [ 0x03 ] = { cmd_request_sense, ALLOW_UA }, >> [ 0x12 ] = { cmd_inquiry, ALLOW_UA }, >> - [ 0x1b ] = { cmd_start_stop_unit, 0 }, /* [1] */ >> - [ 0x1e ] = { cmd_prevent_allow_medium_removal, 0 }, >> + [ 0x1b ] = { cmd_start_stop_unit, NONDATA }, /* [1] */ >> + [ 0x1e ] = { cmd_prevent_allow_medium_removal, NONDATA }, >> [ 0x25 ] = { cmd_read_cdvd_capacity, CHECK_READY }, >> [ 0x28 ] = { cmd_read, /* (10) */ CHECK_READY }, >> - [ 0x2b ] = { cmd_seek, CHECK_READY }, >> + [ 0x2b ] = { cmd_seek, CHECK_READY | NONDATA }, >> [ 0x43 ] = { cmd_read_toc_pma_atip, CHECK_READY }, >> [ 0x46 ] = { cmd_get_configuration, ALLOW_UA }, >> [ 0x4a ] = { cmd_get_event_status_notification, ALLOW_UA }, >> @@ -1190,7 +1198,7 @@ static const struct { >> [ 0x5a ] = { cmd_mode_sense, /* (10) */ 0 }, >> [ 0xa8 ] = { cmd_read, /* (12) */ CHECK_READY }, >> [ 0xad ] = { cmd_read_dvd_structure, CHECK_READY }, >> - [ 0xbb ] = { cmd_set_speed, 0 }, >> + [ 0xbb ] = { cmd_set_speed, NONDATA }, >> [ 0xbd ] = { cmd_mechanism_status, 0 }, >> [ 0xbe ] = { cmd_read_cd, CHECK_READY }, >> /* [1] handler detects and reports not ready condition itself */ >> @@ -1251,6 +1259,20 @@ void ide_atapi_cmd(IDEState *s) >> return; >> } >> >> + /* Nondata commands permit the byte_count_limit to be 0. >> + * If this is a data-transferring PIO command and BCL is 0, >> + * we abort at the /ATA/ level, not the ATAPI level. >> + * See ATA8 ACS3 section 7.17.6.49 and 7.21.5 */ >> + if (!(atapi_cmd_table[s->io_buffer[0]].flags & NONDATA)) { >> + /* TODO: Check IDENTIFY data word 125 for default BCL (currently 0) */ >> + uint16_t byte_count_limit = s->lcyl | (s->hcyl << 8); > > You might want to wrap s->lcyl | (s->hcyl << 8) in a helper function > some day. Not in this patch, though. > >> + if (!(byte_count_limit || s->atapi_dma)) { >> + /* TODO: Move abort back into core.c and make static inline again */ > > Not sure about the inline part, but that's not this patch's to judge. > I basically meant, "The way it was." Ideally this function will have a return mechanism to the core layer, but that groundwork isn't there right now, because ide_exec_cmd is not (guaranteed to be) an ancestor in the callchain here. This usually gets invoked as a response to an ioport write instead, and there isn't really any command life cycle code there yet. >> + ide_abort_command(s); >> + return; >> + } >> + } >> + > > Let's see whether I can slash through the negations here... > > This is for a non-NONDATA command (outer conditional). In other words, > we're expecting data. > Yes. Sorry for the negations, but it was easier to classify things as NONDATA (the exception) than DATA (what most commands do.) > Unless either byte_count_limit is non-zero or atapi_dma is true (inner > conditional), we abort the command. In other words: if byte_count_limit > is non-zero, we'll be PIO-ing some data, so we're good. If atapi_dma is > true, we'll be DMA-ing some data, so we're good. Else, no data will be > coming, contradicting our expectation. The command is invalid, and we > abort. > > Correct? > I don't think I understand "Else, no data will be coming, contradicting our expectation. The command is invalid, and we abort," though the rest of this reads correctly to me. If a command has not set the BCL or the DMA flag, but NONDATA is absent -- we /are/ expecting data, but the guest has neglected to tell us how much data to send per "DRQ loop." The spec says we should abort in this case. (And for infinite loop problems, QEMU should oblige the spec.) So the logic is this: if (data_command) { if (!dma) { if (!bcl) { /* problem */ } } } or: if (!nondata && !(bcl || dma)) { /* problem */ } If this is a DATA command: - If it's DMA, we're fine. DMA commands don't use the BCL. - If BCL is non-zero, we're fine for either DMA or PIO cases. - If BCL is zero AND dma is false, we have a problem. Abort. It might be easier to read as (!bcl && !dma), I guess, but for some reason I felt compelled to write it as (!(bcl || dma)). >> /* Execute the command */ >> if (atapi_cmd_table[s->io_buffer[0]].handler) { >> atapi_cmd_table[s->io_buffer[0]].handler(s, buf); >> diff --git a/hw/ide/core.c b/hw/ide/core.c >> index 50449ca..28cf535 100644 >> --- a/hw/ide/core.c >> +++ b/hw/ide/core.c >> @@ -457,7 +457,7 @@ BlockAIOCB *ide_issue_trim(BlockBackend *blk, >> return &iocb->common; >> } >> >> -static inline void ide_abort_command(IDEState *s) >> +void ide_abort_command(IDEState *s) >> { >> ide_transfer_stop(s); >> s->status = READY_STAT | ERR_STAT; >> diff --git a/hw/ide/internal.h b/hw/ide/internal.h >> index 30fdcbc..40e1aa4 100644 >> --- a/hw/ide/internal.h >> +++ b/hw/ide/internal.h >> @@ -537,6 +537,7 @@ void ide_set_sector(IDEState *s, int64_t sector_num); >> >> void ide_start_dma(IDEState *s, BlockCompletionFunc *cb); >> void ide_dma_error(IDEState *s); >> +void ide_abort_command(IDEState *s); >> >> void ide_atapi_cmd_ok(IDEState *s); >> void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc); HTH, --js From MAILER-DAEMON Tue Sep 15 12:42:37 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbtJV-0006KC-Oj for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 12:42:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbtJR-0006CP-9C for qemu-block@nongnu.org; Tue, 15 Sep 2015 12:42:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbtJO-0004aF-2S for qemu-block@nongnu.org; Tue, 15 Sep 2015 12:42:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43370) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbtJN-0004Zo-R2; Tue, 15 Sep 2015 12:42:30 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 7C8C230ED8E; Tue, 15 Sep 2015 16:42:28 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8FGgQcX029250; Tue, 15 Sep 2015 12:42:27 -0400 To: Markus Armbruster References: <1441816082-21031-1-git-send-email-jsnow@redhat.com> <87r3m0897w.fsf@blackfin.pond.sub.org> From: John Snow X-Enigmail-Draft-Status: N1110 Message-ID: <55F84A72.3000806@redhat.com> Date: Tue, 15 Sep 2015 12:42:26 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87r3m0897w.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, stefano.stabellini@eu.citrix.com, qemu-devel@nongnu.org, ppandit@redhat.com, luodalongde@gmail.com, liuling-it@360.cn Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] ide: fix ATAPI command permissions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 16:42:34 -0000 On 09/15/2015 02:53 AM, Markus Armbruster wrote: > John Snow writes: > >> We're a little too lenient with what we'll let an ATAPI drive handle. >> Clamp down on the IDE command execution table to remove CD_OK permissions >> from commands that are not and have never been ATAPI commands. >> >> For ATAPI command validity, please see: >> - ATA4 Section 6.5 ("PACKET Command feature set") >> - ATA8/ACS Section 4.3 ("The PACKET feature set") >> - ACS3 Section 4.3 ("The PACKET feature set") >> >> ACS3 has a historical command validity table in Table B.4 >> ("Historical Command Assignments") that can be referenced to find when >> a command was introduced, deprecated, obsoleted, etc. >> >> The only reference for ATAPI command validity is by checking that >> version's PACKET feature set section. >> >> ATAPI was introduced by T13 into ATA4, all commands retired prior to ATA4 >> therefore are assumed to have never been ATAPI commands. >> >> Mandatory commands, as listed in ATA8-ACS3, are: >> >> - DEVICE RESET >> - EXECUTE DEVICE DIAGNOSTIC >> - IDENTIFY DEVICE >> - IDENTIFY PACKET DEVICE >> - NOP >> - PACKET >> - READ SECTOR(S) >> - SET FEATURES >> >> Optional commands as listed in ATA8-ACS3, are: >> >> - FLUSH CACHE >> - READ LOG DMA EXT >> - READ LOG EXT >> - WRITE LOG DMA EXT >> - WRITE LOG EXT >> >> All other commands are illegal to send to an ATAPI device and should >> be rejected by the device. > > We could perhaps argue about "should be rejected by the device", but I > think the weaker "a device is free to reject it" still suffices to > support your patch. > Sure -- I suppose drives CAN support a superset if they want to. In my mind, anything above the ATAPI spec should be justified directly with "Guest X breaks without it." >> CD_OK removal justifications: >> >> 0x06 WIN_DSM Defined in ACS2. Not valid for ATAPI. >> 0x21 WIN_READ_ONCE Retired in ATA5. Not ATAPI in ATA4. >> 0x94 WIN_STANDBYNOW2 Retired in ATA4. Did not coexist with ATAPI. >> 0x95 WIN_IDLEIMMEDIATE2 Retired in ATA4. Did not coexist with ATAPI. >> 0x96 WIN_STANDBY2 Retired in ATA4. Did not coexist with ATAPI. >> 0x97 WIN_SETIDLE2 Retired in ATA4. Did not coexist with ATAPI. >> 0x98 WIN_CHECKPOWERMODE2 Retired in ATA4. Did not coexist with ATAPI. >> 0x99 WIN_SLEEPNOW2 Retired in ATA4. Did not coexist with ATAPI. >> 0xE0 WIN_STANDBYNOW1 Not part of ATAPI in ATA4, ACS or ACS3. >> 0xE1 WIN_IDLEIMMDIATE Not part of ATAPI in ATA4, ACS or ACS3. >> 0xE2 WIN_STANDBY Not part of ATAPI in ATA4, ACS or ACS3. >> 0xE3 WIN_SETIDLE1 Not part of ATAPI in ATA4, ACS or ACS3. >> 0xE4 WIN_CHECKPOWERMODE1 Not part of ATAPI in ATA4, ACS or ACS3. >> 0xE5 WIN_SLEEPNOW1 Not part of ATAPI in ATA4, ACS or ACS3. >> 0xF8 WIN_READ_NATIVE_MAX Obsoleted in ACS3. Not ATAPI in ATA4 or ACS. > > Actual patch matches this list. > >> This patch fixes a divide by zero fault that can be caused by sending >> the WIN_READ_NATIVE_MAX command to an empty ATAPI drive, which causes >> it to attempt to use zeroed CHS values to perform sector arithmetic. >> >> Reported-by: Qinghao Tang >> Signed-off-by: John Snow > > I appreciate you going to the root of the problem instead of merely > fixing the narrow bug. > > Could a similar argument be made for dropping CFA_OK from some commands? > Very likely, but that's another patch. I didn't audit that yet. > Do we still need this conditional in cmd_read_native_max()? > > /* Refuse if no sectors are addressable (e.g. medium not inserted) */ > if (s->nb_sectors == 0) { > ide_abort_command(s); > return true; > } > > Why does it fail at guarding the CHS use from empty ATAPI drives before > your patch? > Because I misunderstood the real reason myself, and my POC test was a little bananas. This works *with* a CDROM inserted, not without. So s->nb_sectors can be non-zero, and ide_set_sector then triggers e.g. SIGFPE. If you'll save me the re-spin, I can fix that part of the commit message in my staging branch. --js From MAILER-DAEMON Tue Sep 15 14:11:34 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zbuha-0002Bc-0B for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 14:11:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbuhX-0002Al-98 for qemu-block@nongnu.org; Tue, 15 Sep 2015 14:11:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbuhT-0004iN-37 for qemu-block@nongnu.org; Tue, 15 Sep 2015 14:11:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48142) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbuhS-0004gc-JP; Tue, 15 Sep 2015 14:11:26 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B6D6EC0B9184; Tue, 15 Sep 2015 18:11:25 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8FIBMmu013928 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Sep 2015 14:11:24 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5F9A3303F916; Tue, 15 Sep 2015 20:11:22 +0200 (CEST) From: Markus Armbruster To: John Snow References: <1441816082-21031-1-git-send-email-jsnow@redhat.com> <87r3m0897w.fsf@blackfin.pond.sub.org> <55F84A72.3000806@redhat.com> Date: Tue, 15 Sep 2015 20:11:22 +0200 In-Reply-To: <55F84A72.3000806@redhat.com> (John Snow's message of "Tue, 15 Sep 2015 12:42:26 -0400") Message-ID: <87zj0n5z91.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, stefano.stabellini@eu.citrix.com, qemu-devel@nongnu.org, ppandit@redhat.com, luodalongde@gmail.com, liuling-it@360.cn Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] ide: fix ATAPI command permissions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 18:11:32 -0000 John Snow writes: > On 09/15/2015 02:53 AM, Markus Armbruster wrote: >> John Snow writes: >> >>> We're a little too lenient with what we'll let an ATAPI drive handle. >>> Clamp down on the IDE command execution table to remove CD_OK permissions >>> from commands that are not and have never been ATAPI commands. >>> >>> For ATAPI command validity, please see: >>> - ATA4 Section 6.5 ("PACKET Command feature set") >>> - ATA8/ACS Section 4.3 ("The PACKET feature set") >>> - ACS3 Section 4.3 ("The PACKET feature set") >>> >>> ACS3 has a historical command validity table in Table B.4 >>> ("Historical Command Assignments") that can be referenced to find when >>> a command was introduced, deprecated, obsoleted, etc. >>> >>> The only reference for ATAPI command validity is by checking that >>> version's PACKET feature set section. >>> >>> ATAPI was introduced by T13 into ATA4, all commands retired prior to ATA4 >>> therefore are assumed to have never been ATAPI commands. >>> >>> Mandatory commands, as listed in ATA8-ACS3, are: >>> >>> - DEVICE RESET >>> - EXECUTE DEVICE DIAGNOSTIC >>> - IDENTIFY DEVICE >>> - IDENTIFY PACKET DEVICE >>> - NOP >>> - PACKET >>> - READ SECTOR(S) >>> - SET FEATURES >>> >>> Optional commands as listed in ATA8-ACS3, are: >>> >>> - FLUSH CACHE >>> - READ LOG DMA EXT >>> - READ LOG EXT >>> - WRITE LOG DMA EXT >>> - WRITE LOG EXT >>> >>> All other commands are illegal to send to an ATAPI device and should >>> be rejected by the device. >> >> We could perhaps argue about "should be rejected by the device", but I >> think the weaker "a device is free to reject it" still suffices to >> support your patch. >> > > Sure -- I suppose drives CAN support a superset if they want to. In my > mind, anything above the ATAPI spec should be justified directly with > "Guest X breaks without it." > >>> CD_OK removal justifications: >>> >>> 0x06 WIN_DSM Defined in ACS2. Not valid for ATAPI. >>> 0x21 WIN_READ_ONCE Retired in ATA5. Not ATAPI in ATA4. >>> 0x94 WIN_STANDBYNOW2 Retired in ATA4. Did not coexist with ATAPI. >>> 0x95 WIN_IDLEIMMEDIATE2 Retired in ATA4. Did not coexist with ATAPI. >>> 0x96 WIN_STANDBY2 Retired in ATA4. Did not coexist with ATAPI. >>> 0x97 WIN_SETIDLE2 Retired in ATA4. Did not coexist with ATAPI. >>> 0x98 WIN_CHECKPOWERMODE2 Retired in ATA4. Did not coexist with ATAPI. >>> 0x99 WIN_SLEEPNOW2 Retired in ATA4. Did not coexist with ATAPI. >>> 0xE0 WIN_STANDBYNOW1 Not part of ATAPI in ATA4, ACS or ACS3. >>> 0xE1 WIN_IDLEIMMDIATE Not part of ATAPI in ATA4, ACS or ACS3. >>> 0xE2 WIN_STANDBY Not part of ATAPI in ATA4, ACS or ACS3. >>> 0xE3 WIN_SETIDLE1 Not part of ATAPI in ATA4, ACS or ACS3. >>> 0xE4 WIN_CHECKPOWERMODE1 Not part of ATAPI in ATA4, ACS or ACS3. >>> 0xE5 WIN_SLEEPNOW1 Not part of ATAPI in ATA4, ACS or ACS3. >>> 0xF8 WIN_READ_NATIVE_MAX Obsoleted in ACS3. Not ATAPI in ATA4 or ACS. >> >> Actual patch matches this list. >> >>> This patch fixes a divide by zero fault that can be caused by sending >>> the WIN_READ_NATIVE_MAX command to an empty ATAPI drive, which causes >>> it to attempt to use zeroed CHS values to perform sector arithmetic. >>> >>> Reported-by: Qinghao Tang >>> Signed-off-by: John Snow >> >> I appreciate you going to the root of the problem instead of merely >> fixing the narrow bug. >> >> Could a similar argument be made for dropping CFA_OK from some commands? >> > > Very likely, but that's another patch. I didn't audit that yet. > >> Do we still need this conditional in cmd_read_native_max()? >> >> /* Refuse if no sectors are addressable (e.g. medium not inserted) */ >> if (s->nb_sectors == 0) { >> ide_abort_command(s); >> return true; >> } >> >> Why does it fail at guarding the CHS use from empty ATAPI drives before >> your patch? >> > > Because I misunderstood the real reason myself, and my POC test was a > little bananas. This works *with* a CDROM inserted, not without. > > So s->nb_sectors can be non-zero, and ide_set_sector then triggers e.g. > SIGFPE. > > If you'll save me the re-spin, I can fix that part of the commit message > in my staging branch. Let me paraphrase to make sure I got you. If the drive is empty, the guard aborts the command correctly. If the drive isn't empty, the guard doesn't abort. The code then goes on and happily uses CHS. However, ATAPI devices don't have CHS geometry, see ide_dev_initfn(): if (kind != IDE_CD) { blkconf_geometry(&dev->conf, &dev->chs_trans, 65536, 16, 255, &err); if (err) { error_report_err(err); return -1; } } Therefore, CHS is all zero, and the code using it blows up. Correct? From MAILER-DAEMON Tue Sep 15 14:22:41 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbusL-0007TN-73 for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 14:22:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbusI-0007T0-60 for qemu-block@nongnu.org; Tue, 15 Sep 2015 14:22:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbusE-0000Tp-5K for qemu-block@nongnu.org; Tue, 15 Sep 2015 14:22:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49691) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbusD-0000Tk-TS; Tue, 15 Sep 2015 14:22:34 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 8032D3B3C7; Tue, 15 Sep 2015 18:22:32 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8FIMU8b023579; Tue, 15 Sep 2015 14:22:31 -0400 To: Markus Armbruster References: <1441816082-21031-1-git-send-email-jsnow@redhat.com> <87r3m0897w.fsf@blackfin.pond.sub.org> <55F84A72.3000806@redhat.com> <87zj0n5z91.fsf@blackfin.pond.sub.org> From: John Snow X-Enigmail-Draft-Status: N1110 Message-ID: <55F861E6.4090500@redhat.com> Date: Tue, 15 Sep 2015 14:22:30 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87zj0n5z91.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, stefano.stabellini@eu.citrix.com, qemu-devel@nongnu.org, ppandit@redhat.com, luodalongde@gmail.com, liuling-it@360.cn Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] ide: fix ATAPI command permissions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 18:22:39 -0000 On 09/15/2015 02:11 PM, Markus Armbruster wrote: > John Snow writes: > >> On 09/15/2015 02:53 AM, Markus Armbruster wrote: >>> John Snow writes: >>> >>>> We're a little too lenient with what we'll let an ATAPI drive handle. >>>> Clamp down on the IDE command execution table to remove CD_OK permissions >>>> from commands that are not and have never been ATAPI commands. >>>> >>>> For ATAPI command validity, please see: >>>> - ATA4 Section 6.5 ("PACKET Command feature set") >>>> - ATA8/ACS Section 4.3 ("The PACKET feature set") >>>> - ACS3 Section 4.3 ("The PACKET feature set") >>>> >>>> ACS3 has a historical command validity table in Table B.4 >>>> ("Historical Command Assignments") that can be referenced to find when >>>> a command was introduced, deprecated, obsoleted, etc. >>>> >>>> The only reference for ATAPI command validity is by checking that >>>> version's PACKET feature set section. >>>> >>>> ATAPI was introduced by T13 into ATA4, all commands retired prior to ATA4 >>>> therefore are assumed to have never been ATAPI commands. >>>> >>>> Mandatory commands, as listed in ATA8-ACS3, are: >>>> >>>> - DEVICE RESET >>>> - EXECUTE DEVICE DIAGNOSTIC >>>> - IDENTIFY DEVICE >>>> - IDENTIFY PACKET DEVICE >>>> - NOP >>>> - PACKET >>>> - READ SECTOR(S) >>>> - SET FEATURES >>>> >>>> Optional commands as listed in ATA8-ACS3, are: >>>> >>>> - FLUSH CACHE >>>> - READ LOG DMA EXT >>>> - READ LOG EXT >>>> - WRITE LOG DMA EXT >>>> - WRITE LOG EXT >>>> >>>> All other commands are illegal to send to an ATAPI device and should >>>> be rejected by the device. >>> >>> We could perhaps argue about "should be rejected by the device", but I >>> think the weaker "a device is free to reject it" still suffices to >>> support your patch. >>> >> >> Sure -- I suppose drives CAN support a superset if they want to. In my >> mind, anything above the ATAPI spec should be justified directly with >> "Guest X breaks without it." >> >>>> CD_OK removal justifications: >>>> >>>> 0x06 WIN_DSM Defined in ACS2. Not valid for ATAPI. >>>> 0x21 WIN_READ_ONCE Retired in ATA5. Not ATAPI in ATA4. >>>> 0x94 WIN_STANDBYNOW2 Retired in ATA4. Did not coexist with ATAPI. >>>> 0x95 WIN_IDLEIMMEDIATE2 Retired in ATA4. Did not coexist with ATAPI. >>>> 0x96 WIN_STANDBY2 Retired in ATA4. Did not coexist with ATAPI. >>>> 0x97 WIN_SETIDLE2 Retired in ATA4. Did not coexist with ATAPI. >>>> 0x98 WIN_CHECKPOWERMODE2 Retired in ATA4. Did not coexist with ATAPI. >>>> 0x99 WIN_SLEEPNOW2 Retired in ATA4. Did not coexist with ATAPI. >>>> 0xE0 WIN_STANDBYNOW1 Not part of ATAPI in ATA4, ACS or ACS3. >>>> 0xE1 WIN_IDLEIMMDIATE Not part of ATAPI in ATA4, ACS or ACS3. >>>> 0xE2 WIN_STANDBY Not part of ATAPI in ATA4, ACS or ACS3. >>>> 0xE3 WIN_SETIDLE1 Not part of ATAPI in ATA4, ACS or ACS3. >>>> 0xE4 WIN_CHECKPOWERMODE1 Not part of ATAPI in ATA4, ACS or ACS3. >>>> 0xE5 WIN_SLEEPNOW1 Not part of ATAPI in ATA4, ACS or ACS3. >>>> 0xF8 WIN_READ_NATIVE_MAX Obsoleted in ACS3. Not ATAPI in ATA4 or ACS. >>> >>> Actual patch matches this list. >>> >>>> This patch fixes a divide by zero fault that can be caused by sending >>>> the WIN_READ_NATIVE_MAX command to an empty ATAPI drive, which causes >>>> it to attempt to use zeroed CHS values to perform sector arithmetic. >>>> >>>> Reported-by: Qinghao Tang >>>> Signed-off-by: John Snow >>> >>> I appreciate you going to the root of the problem instead of merely >>> fixing the narrow bug. >>> >>> Could a similar argument be made for dropping CFA_OK from some commands? >>> >> >> Very likely, but that's another patch. I didn't audit that yet. >> >>> Do we still need this conditional in cmd_read_native_max()? >>> >>> /* Refuse if no sectors are addressable (e.g. medium not inserted) */ >>> if (s->nb_sectors == 0) { >>> ide_abort_command(s); >>> return true; >>> } >>> >>> Why does it fail at guarding the CHS use from empty ATAPI drives before >>> your patch? >>> >> >> Because I misunderstood the real reason myself, and my POC test was a >> little bananas. This works *with* a CDROM inserted, not without. >> >> So s->nb_sectors can be non-zero, and ide_set_sector then triggers e.g. >> SIGFPE. >> >> If you'll save me the re-spin, I can fix that part of the commit message >> in my staging branch. > > Let me paraphrase to make sure I got you. > > If the drive is empty, the guard aborts the command correctly. > > If the drive isn't empty, the guard doesn't abort. The code then goes > on and happily uses CHS. However, ATAPI devices don't have CHS > geometry, see ide_dev_initfn(): > > if (kind != IDE_CD) { > blkconf_geometry(&dev->conf, &dev->chs_trans, 65536, 16, 255, &err); > if (err) { > error_report_err(err); > return -1; > } > } > > Therefore, CHS is all zero, and the code using it blows up. > > Correct? > Indeed. I had wrongly assumed previously that the CHS values actually did get initialized (incorrectly) if a CD was present at boot, but I was wrong. Coincidentally, the patch is still correct regardless of my wrong assumption. :) --js From MAILER-DAEMON Tue Sep 15 14:51:05 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZbvJp-00083t-Bn for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 14:51:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbvJi-0007yv-L1 for qemu-block@nongnu.org; Tue, 15 Sep 2015 14:51:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbvJf-0004R3-Nf for qemu-block@nongnu.org; Tue, 15 Sep 2015 14:50:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48323) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbvJf-0004Qv-7t; Tue, 15 Sep 2015 14:50:55 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 6BDF72F812D; Tue, 15 Sep 2015 18:50:54 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8FIopRR006471 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Sep 2015 14:50:53 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 04A1C303F916; Tue, 15 Sep 2015 20:50:50 +0200 (CEST) From: Markus Armbruster To: John Snow References: <1441816082-21031-1-git-send-email-jsnow@redhat.com> <87r3m0897w.fsf@blackfin.pond.sub.org> <55F84A72.3000806@redhat.com> <87zj0n5z91.fsf@blackfin.pond.sub.org> <55F861E6.4090500@redhat.com> Date: Tue, 15 Sep 2015 20:50:50 +0200 In-Reply-To: <55F861E6.4090500@redhat.com> (John Snow's message of "Tue, 15 Sep 2015 14:22:30 -0400") Message-ID: <87oah34iut.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, stefano.stabellini@eu.citrix.com, qemu-devel@nongnu.org, ppandit@redhat.com, luodalongde@gmail.com, liuling-it@360.cn Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] ide: fix ATAPI command permissions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 18:51:03 -0000 John Snow writes: > On 09/15/2015 02:11 PM, Markus Armbruster wrote: >> John Snow writes: >> >>> On 09/15/2015 02:53 AM, Markus Armbruster wrote: >>>> John Snow writes: >>>> >>>>> We're a little too lenient with what we'll let an ATAPI drive handle. >>>>> Clamp down on the IDE command execution table to remove CD_OK permissions >>>>> from commands that are not and have never been ATAPI commands. >>>>> >>>>> For ATAPI command validity, please see: >>>>> - ATA4 Section 6.5 ("PACKET Command feature set") >>>>> - ATA8/ACS Section 4.3 ("The PACKET feature set") >>>>> - ACS3 Section 4.3 ("The PACKET feature set") >>>>> >>>>> ACS3 has a historical command validity table in Table B.4 >>>>> ("Historical Command Assignments") that can be referenced to find when >>>>> a command was introduced, deprecated, obsoleted, etc. >>>>> >>>>> The only reference for ATAPI command validity is by checking that >>>>> version's PACKET feature set section. >>>>> >>>>> ATAPI was introduced by T13 into ATA4, all commands retired prior to ATA4 >>>>> therefore are assumed to have never been ATAPI commands. >>>>> >>>>> Mandatory commands, as listed in ATA8-ACS3, are: >>>>> >>>>> - DEVICE RESET >>>>> - EXECUTE DEVICE DIAGNOSTIC >>>>> - IDENTIFY DEVICE >>>>> - IDENTIFY PACKET DEVICE >>>>> - NOP >>>>> - PACKET >>>>> - READ SECTOR(S) >>>>> - SET FEATURES >>>>> >>>>> Optional commands as listed in ATA8-ACS3, are: >>>>> >>>>> - FLUSH CACHE >>>>> - READ LOG DMA EXT >>>>> - READ LOG EXT >>>>> - WRITE LOG DMA EXT >>>>> - WRITE LOG EXT >>>>> >>>>> All other commands are illegal to send to an ATAPI device and should >>>>> be rejected by the device. >>>> >>>> We could perhaps argue about "should be rejected by the device", but I >>>> think the weaker "a device is free to reject it" still suffices to >>>> support your patch. >>>> >>> >>> Sure -- I suppose drives CAN support a superset if they want to. In my >>> mind, anything above the ATAPI spec should be justified directly with >>> "Guest X breaks without it." >>> >>>>> CD_OK removal justifications: >>>>> >>>>> 0x06 WIN_DSM Defined in ACS2. Not valid for ATAPI. >>>>> 0x21 WIN_READ_ONCE Retired in ATA5. Not ATAPI in ATA4. >>>>> 0x94 WIN_STANDBYNOW2 Retired in ATA4. Did not coexist with ATAPI. >>>>> 0x95 WIN_IDLEIMMEDIATE2 Retired in ATA4. Did not coexist with ATAPI. >>>>> 0x96 WIN_STANDBY2 Retired in ATA4. Did not coexist with ATAPI. >>>>> 0x97 WIN_SETIDLE2 Retired in ATA4. Did not coexist with ATAPI. >>>>> 0x98 WIN_CHECKPOWERMODE2 Retired in ATA4. Did not coexist with ATAPI. >>>>> 0x99 WIN_SLEEPNOW2 Retired in ATA4. Did not coexist with ATAPI. >>>>> 0xE0 WIN_STANDBYNOW1 Not part of ATAPI in ATA4, ACS or ACS3. >>>>> 0xE1 WIN_IDLEIMMDIATE Not part of ATAPI in ATA4, ACS or ACS3. >>>>> 0xE2 WIN_STANDBY Not part of ATAPI in ATA4, ACS or ACS3. >>>>> 0xE3 WIN_SETIDLE1 Not part of ATAPI in ATA4, ACS or ACS3. >>>>> 0xE4 WIN_CHECKPOWERMODE1 Not part of ATAPI in ATA4, ACS or ACS3. >>>>> 0xE5 WIN_SLEEPNOW1 Not part of ATAPI in ATA4, ACS or ACS3. >>>>> 0xF8 WIN_READ_NATIVE_MAX Obsoleted in ACS3. Not ATAPI in ATA4 or ACS. >>>> >>>> Actual patch matches this list. >>>> >>>>> This patch fixes a divide by zero fault that can be caused by sending >>>>> the WIN_READ_NATIVE_MAX command to an empty ATAPI drive, which causes >>>>> it to attempt to use zeroed CHS values to perform sector arithmetic. >>>>> >>>>> Reported-by: Qinghao Tang >>>>> Signed-off-by: John Snow >>>> >>>> I appreciate you going to the root of the problem instead of merely >>>> fixing the narrow bug. >>>> >>>> Could a similar argument be made for dropping CFA_OK from some commands? >>>> >>> >>> Very likely, but that's another patch. I didn't audit that yet. >>> >>>> Do we still need this conditional in cmd_read_native_max()? >>>> >>>> /* Refuse if no sectors are addressable (e.g. medium not inserted) */ >>>> if (s->nb_sectors == 0) { >>>> ide_abort_command(s); >>>> return true; >>>> } >>>> >>>> Why does it fail at guarding the CHS use from empty ATAPI drives before >>>> your patch? >>>> >>> >>> Because I misunderstood the real reason myself, and my POC test was a >>> little bananas. This works *with* a CDROM inserted, not without. >>> >>> So s->nb_sectors can be non-zero, and ide_set_sector then triggers e.g. >>> SIGFPE. >>> >>> If you'll save me the re-spin, I can fix that part of the commit message >>> in my staging branch. >> >> Let me paraphrase to make sure I got you. >> >> If the drive is empty, the guard aborts the command correctly. >> >> If the drive isn't empty, the guard doesn't abort. The code then goes >> on and happily uses CHS. However, ATAPI devices don't have CHS >> geometry, see ide_dev_initfn(): >> >> if (kind != IDE_CD) { >> blkconf_geometry(&dev->conf, &dev->chs_trans, 65536, 16, 255, &err); >> if (err) { >> error_report_err(err); >> return -1; >> } >> } >> >> Therefore, CHS is all zero, and the code using it blows up. >> >> Correct? >> > > Indeed. I had wrongly assumed previously that the CHS values actually > did get initialized (incorrectly) if a CD was present at boot, but I was > wrong. > > Coincidentally, the patch is still correct regardless of my wrong > assumption. :) With a corrected commit message: Reviewed-by: Markus Armbruster From MAILER-DAEMON Tue Sep 15 15:13:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zbvf3-0006ZZ-6R for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 15:13:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbvf0-0006YS-GW for qemu-block@nongnu.org; Tue, 15 Sep 2015 15:12:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zbvev-0005kD-Kg for qemu-block@nongnu.org; Tue, 15 Sep 2015 15:12:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54549) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zbvev-0005k9-Cp; Tue, 15 Sep 2015 15:12:53 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 72BA7C0B200A; Tue, 15 Sep 2015 19:12:52 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8FJCotC018668; Tue, 15 Sep 2015 15:12:51 -0400 To: Markus Armbruster References: <1441816082-21031-1-git-send-email-jsnow@redhat.com> <87r3m0897w.fsf@blackfin.pond.sub.org> <55F84A72.3000806@redhat.com> <87zj0n5z91.fsf@blackfin.pond.sub.org> <55F861E6.4090500@redhat.com> <87oah34iut.fsf@blackfin.pond.sub.org> From: John Snow Message-ID: <55F86DB2.8060900@redhat.com> Date: Tue, 15 Sep 2015 15:12:50 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87oah34iut.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, stefano.stabellini@eu.citrix.com, qemu-devel@nongnu.org, ppandit@redhat.com, luodalongde@gmail.com, liuling-it@360.cn Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] ide: fix ATAPI command permissions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 19:13:00 -0000 On 09/15/2015 02:50 PM, Markus Armbruster wrote: > John Snow writes: > >> On 09/15/2015 02:11 PM, Markus Armbruster wrote: >>> John Snow writes: >>> >>>> On 09/15/2015 02:53 AM, Markus Armbruster wrote: >>>>> John Snow writes: >>>>> >>>>>> We're a little too lenient with what we'll let an ATAPI drive handle. >>>>>> Clamp down on the IDE command execution table to remove CD_OK permissions >>>>>> from commands that are not and have never been ATAPI commands. >>>>>> >>>>>> For ATAPI command validity, please see: >>>>>> - ATA4 Section 6.5 ("PACKET Command feature set") >>>>>> - ATA8/ACS Section 4.3 ("The PACKET feature set") >>>>>> - ACS3 Section 4.3 ("The PACKET feature set") >>>>>> >>>>>> ACS3 has a historical command validity table in Table B.4 >>>>>> ("Historical Command Assignments") that can be referenced to find when >>>>>> a command was introduced, deprecated, obsoleted, etc. >>>>>> >>>>>> The only reference for ATAPI command validity is by checking that >>>>>> version's PACKET feature set section. >>>>>> >>>>>> ATAPI was introduced by T13 into ATA4, all commands retired prior to ATA4 >>>>>> therefore are assumed to have never been ATAPI commands. >>>>>> >>>>>> Mandatory commands, as listed in ATA8-ACS3, are: >>>>>> >>>>>> - DEVICE RESET >>>>>> - EXECUTE DEVICE DIAGNOSTIC >>>>>> - IDENTIFY DEVICE >>>>>> - IDENTIFY PACKET DEVICE >>>>>> - NOP >>>>>> - PACKET >>>>>> - READ SECTOR(S) >>>>>> - SET FEATURES >>>>>> >>>>>> Optional commands as listed in ATA8-ACS3, are: >>>>>> >>>>>> - FLUSH CACHE >>>>>> - READ LOG DMA EXT >>>>>> - READ LOG EXT >>>>>> - WRITE LOG DMA EXT >>>>>> - WRITE LOG EXT >>>>>> >>>>>> All other commands are illegal to send to an ATAPI device and should >>>>>> be rejected by the device. >>>>> >>>>> We could perhaps argue about "should be rejected by the device", but I >>>>> think the weaker "a device is free to reject it" still suffices to >>>>> support your patch. >>>>> >>>> >>>> Sure -- I suppose drives CAN support a superset if they want to. In my >>>> mind, anything above the ATAPI spec should be justified directly with >>>> "Guest X breaks without it." >>>> >>>>>> CD_OK removal justifications: >>>>>> >>>>>> 0x06 WIN_DSM Defined in ACS2. Not valid for ATAPI. >>>>>> 0x21 WIN_READ_ONCE Retired in ATA5. Not ATAPI in ATA4. >>>>>> 0x94 WIN_STANDBYNOW2 Retired in ATA4. Did not coexist with ATAPI. >>>>>> 0x95 WIN_IDLEIMMEDIATE2 Retired in ATA4. Did not coexist with ATAPI. >>>>>> 0x96 WIN_STANDBY2 Retired in ATA4. Did not coexist with ATAPI. >>>>>> 0x97 WIN_SETIDLE2 Retired in ATA4. Did not coexist with ATAPI. >>>>>> 0x98 WIN_CHECKPOWERMODE2 Retired in ATA4. Did not coexist with ATAPI. >>>>>> 0x99 WIN_SLEEPNOW2 Retired in ATA4. Did not coexist with ATAPI. >>>>>> 0xE0 WIN_STANDBYNOW1 Not part of ATAPI in ATA4, ACS or ACS3. >>>>>> 0xE1 WIN_IDLEIMMDIATE Not part of ATAPI in ATA4, ACS or ACS3. >>>>>> 0xE2 WIN_STANDBY Not part of ATAPI in ATA4, ACS or ACS3. >>>>>> 0xE3 WIN_SETIDLE1 Not part of ATAPI in ATA4, ACS or ACS3. >>>>>> 0xE4 WIN_CHECKPOWERMODE1 Not part of ATAPI in ATA4, ACS or ACS3. >>>>>> 0xE5 WIN_SLEEPNOW1 Not part of ATAPI in ATA4, ACS or ACS3. >>>>>> 0xF8 WIN_READ_NATIVE_MAX Obsoleted in ACS3. Not ATAPI in ATA4 or ACS. >>>>> >>>>> Actual patch matches this list. >>>>> >>>>>> This patch fixes a divide by zero fault that can be caused by sending >>>>>> the WIN_READ_NATIVE_MAX command to an empty ATAPI drive, which causes >>>>>> it to attempt to use zeroed CHS values to perform sector arithmetic. >>>>>> >>>>>> Reported-by: Qinghao Tang >>>>>> Signed-off-by: John Snow >>>>> >>>>> I appreciate you going to the root of the problem instead of merely >>>>> fixing the narrow bug. >>>>> >>>>> Could a similar argument be made for dropping CFA_OK from some commands? >>>>> >>>> >>>> Very likely, but that's another patch. I didn't audit that yet. >>>> >>>>> Do we still need this conditional in cmd_read_native_max()? >>>>> >>>>> /* Refuse if no sectors are addressable (e.g. medium not inserted) */ >>>>> if (s->nb_sectors == 0) { >>>>> ide_abort_command(s); >>>>> return true; >>>>> } >>>>> >>>>> Why does it fail at guarding the CHS use from empty ATAPI drives before >>>>> your patch? >>>>> >>>> >>>> Because I misunderstood the real reason myself, and my POC test was a >>>> little bananas. This works *with* a CDROM inserted, not without. >>>> >>>> So s->nb_sectors can be non-zero, and ide_set_sector then triggers e.g. >>>> SIGFPE. >>>> >>>> If you'll save me the re-spin, I can fix that part of the commit message >>>> in my staging branch. >>> >>> Let me paraphrase to make sure I got you. >>> >>> If the drive is empty, the guard aborts the command correctly. >>> >>> If the drive isn't empty, the guard doesn't abort. The code then goes >>> on and happily uses CHS. However, ATAPI devices don't have CHS >>> geometry, see ide_dev_initfn(): >>> >>> if (kind != IDE_CD) { >>> blkconf_geometry(&dev->conf, &dev->chs_trans, 65536, 16, 255, &err); >>> if (err) { >>> error_report_err(err); >>> return -1; >>> } >>> } >>> >>> Therefore, CHS is all zero, and the code using it blows up. >>> >>> Correct? >>> >> >> Indeed. I had wrongly assumed previously that the CHS values actually >> did get initialized (incorrectly) if a CD was present at boot, but I was >> wrong. >> >> Coincidentally, the patch is still correct regardless of my wrong >> assumption. :) > > With a corrected commit message: > Reviewed-by: Markus Armbruster > Thanks, applied to my IDE tree: https://github.com/jnsnow/qemu/commits/ide https://github.com/jnsnow/qemu.git --js From MAILER-DAEMON Tue Sep 15 22:17:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zc2I0-0005Pp-DE for mharc-qemu-block@gnu.org; Tue, 15 Sep 2015 22:17:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc2Hx-0005Le-Av for qemu-block@nongnu.org; Tue, 15 Sep 2015 22:17:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zc2Ht-0002Ud-6I for qemu-block@nongnu.org; Tue, 15 Sep 2015 22:17:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc2Hs-0002UL-V6; Tue, 15 Sep 2015 22:17:33 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id D819E8AE6C; Wed, 16 Sep 2015 02:17:31 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-31.rdu2.redhat.com [10.10.116.31]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8G2HTxf018720; Tue, 15 Sep 2015 22:17:30 -0400 From: Laszlo Ersek To: qemu-devel@nongnu.org Date: Wed, 16 Sep 2015 04:17:26 +0200 Message-Id: <1442369846-31890-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org Subject: [Qemu-block] [PATCH] hw/ide/ahci: advance IO buffer offset in multi-sector PIO transfer X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 02:17:38 -0000 The "MdeModulePkg/Bus/Ata/AtaAtapiPassThru" driver in edk2 submits a three sector long PIO read, when booting off various Fedora installer ISOs in UEFI mode. With DEBUG_IDE, DEBUG_IDE_ATAPI, DEBUG_AIO and DEBUG_AHCI enabled, plus a DPRINTF(ad->port_no, "offset=%d\n", offset); at the beginning of ahci_populate_sglist(), we get the following debug output: > fis: > 00:27 80 a0 00 00 fe ff e0 00 00 00 00 00 00 00 00 > 10:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 20:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 30:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 40:28 00 00 00 00 38 00 00 03 00 00 00 00 00 00 00 > 50:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 60:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 70:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > fis: > 00:28 00 00 00 00 38 00 00 03 00 00 00 00 00 00 00 > ide: CMD=a0 > ATAPI limit=0xfffe packet: 28 00 00 00 00 38 00 00 03 00 00 00 > read pio: LBA=56 nb_sectors=3 > reply: tx_size=6144 elem_tx_size=0 index=2048 > byte_count_limit=65534 > ahci: ahci_populate_sglist: [0] offset=0 > ahci: ahci_dma_prepare_buf: [0] len=0x800 > ahci: ahci_start_transfer: [0] reading 2048 bytes on atapi w/ sglist > reply: tx_size=4096 elem_tx_size=4096 index=2048 > ahci: ahci_populate_sglist: [0] offset=0 > ahci: ahci_dma_prepare_buf: [0] len=0x800 > ahci: ahci_start_transfer: [0] reading 2048 bytes on atapi w/ sglist > reply: tx_size=2048 elem_tx_size=2048 index=2048 > ahci: ahci_populate_sglist: [0] offset=0 > ahci: ahci_dma_prepare_buf: [0] len=0x800 > ahci: ahci_start_transfer: [0] reading 2048 bytes on atapi w/ sglist > reply: tx_size=0 elem_tx_size=0 index=2048 > ahci: ahci_cmd_done: [0] cmd done > [...] The following functions play recursive ping-pong, because ide_atapi_cmd_reply_end() segments the request into individual 2KB sectors: ide_transfer_start() <-----------------------+ ahci_start_transfer() via funcptr | | ahci_dma_prepare_buf() | ahci_populate_sglist() | | dma_buf_read() | | ahci_commit_buf() | | ide_atapi_cmd_reply_end() via funcptr | ide_transfer_start() ------------------+ The ahci_populate_sglist() correctly sets up the scatter-gather list for dma_buf_read(), based on the Physical Region Descriptors passed in by the guest. However, the offset into that scatter-gather list remains constant zero as ide_atapi_cmd_reply_end() wades through every sector of the three sector long PIO transfer. The consequence is that the first 2KB of the guest buffer(s), speaking "linearizedly", is repeatedly overwritten with the next CD-ROM sector. At the end of the transfer, the sector last read is visible in the first 2KB of the guest buffer(s), and the rest of the guest buffer(s) remains unwritten. Looking at the DMA request path; especially comparing the context of ahci_commit_buf() between its two callers ahci_dma_rw_buf() and ahci_start_transfer(), it seems like the latter forgets to advance "s->io_buffer_offset". Adding that increment enables the guest to receive valid data. Cc: John Snow Cc: qemu-block@nongnu.org Signed-off-by: Laszlo Ersek --- Notes: I spent the better half of the night on this bug, so please be gentle. :) hw/ide/ahci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 44f6e27..b975c9f 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1291,6 +1291,8 @@ out: /* Update number of transferred bytes, destroy sglist */ ahci_commit_buf(dma, size); + s->io_buffer_offset += size; + s->end_transfer_func(s); if (!(s->status & DRQ_STAT)) { -- 1.8.3.1 From MAILER-DAEMON Wed Sep 16 02:00:46 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zc5lt-0000e1-Ko for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 02:00:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc5lm-0000be-8D for qemu-block@nongnu.org; Wed, 16 Sep 2015 02:00:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zc5ll-0001Ck-8D for qemu-block@nongnu.org; Wed, 16 Sep 2015 02:00:38 -0400 Received: from [59.151.112.132] (port=22996 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc5le-00012V-Vc; Wed, 16 Sep 2015 02:00:32 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100768844" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 16 Sep 2015 14:03:10 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8G603Rc019268; Wed, 16 Sep 2015 14:00:03 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 16 Sep 2015 14:00:18 +0800 To: Markus Armbruster , Eric Blake References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F776CC.3050601@cn.fujitsu.com> <87fv2g876a.fsf@blackfin.pond.sub.org> <55F7D06D.1080205@cn.fujitsu.com> <87mvwo3phm.fsf@blackfin.pond.sub.org> From: Wen Congyang Message-ID: <55F9054F.1000001@cn.fujitsu.com> Date: Wed, 16 Sep 2015 13:59:43 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87mvwo3phm.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 06:00:44 -0000 On 09/15/2015 07:12 PM, Markus Armbruster wrote: > Wen Congyang writes: > >> On 09/15/2015 03:37 PM, Markus Armbruster wrote: >>> Wen Congyang writes: >>> >>>> On 09/14/2015 11:47 PM, Eric Blake wrote: >>>>> On 09/14/2015 08:27 AM, Markus Armbruster wrote: >>>>>> Wen Congyang writes: >>>>>> >>>>>>> The NBD driver needs: filename, path or (host, port, exportname). >>>>>>> It checks which key exists and decides use unix or inet socket. >>>>>>> It doesn't recognize the key type, so we can't use union, and >>>>>>> can't reuse InetSocketAddress. >>>>>>> >>>>>>> Signed-off-by: Wen Congyang >>>>>>> Signed-off-by: zhanghailiang >>>>>>> Signed-off-by: Gonglei >>>>>>> --- >>>>>>> qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- >>>>>>> 1 file changed, 40 insertions(+), 2 deletions(-) >>>>>>> >>>>> >>>>>>> ## >>>>>>> +# @BlockdevOptionsNBD >>>>>>> +# >>>>>>> +# Driver specific block device options for NBD >>>>>>> +# >>>>>>> +# @filename: #optional unix or inet path. The format is: >>>>>>> +# unix: nbd+unix:///export?socket=path or >>>>>>> +# nbd:unix:path:exportname=export >>>>>>> +# inet: nbd[+tcp]://host[:port]/export or >>>>>>> +# nbd:host[:port]:exportname=export >>>>> >>>>> Yuck. You are passing structured data through a single 'str', when you >>>>> SHOULD be passing it through structured JSON. Just because we have a >>>>> filename shorthand for convenience does NOT mean that we want to expose >>>>> that convenience in QMP. Instead, we really want the breakdown of the >>>>> pieces (here, using abbreviated syntax of an inline base, since there >>>>> are pending qapi patches that will allow it): >>>> >>>> Do you mean that: there is no need to support filename? >>> >>> Rule of thumb: if the QMP command handler needs to parse a string >>> argument, that argument should be a complex QAPI type instead. >>> >>> Example: @filename needs to be parsed into its components, either >>> >>> * protocol unix, socket path, export name, or >>> * protocol tcp, host, port, export name >>> >>> Since there's an either/or, the complex QAPI type should be a union. >>> >>>>> { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } >>>> >>>> NBD only uses tcp, it doesn't support udp. >>>> >>>>> { 'union': 'BlockdevOptionsNBD', >>>>> 'base': { 'transport': 'NBDTransport', 'export': 'str' }, >>>>> 'discriminator': 'transport', >>>>> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } >>>>> { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } >>>> >>>> unix socket needs a path, and I think we can use UnixSocketAddress here. >>> >>> Yes, we should try to reuse common types like SocketAddress, >>> InetSocketAddress, UnixSocketAddress. >>> >>> Perhaps it could be as simple as >>> >>> { 'struct': 'BlockdevOptionsNBD', >>> 'data': { 'addr: 'SocketAddress', 'export': 'str' } } >> >> The problem is that: NBD doesn't use the fd. > > Is that fundamental, or just a matter of implementation? > >> Another question is: what key will we see in nbd_open()? "addr.host" >> or "host"? > > As long as nbd_config() looks for "host" in the options QDict, we need > to put "host". Yes, we need "host" in nbd_config(), but we pass "addr.data.host" to it. How to avoid this problem? Thanks Wen Congyang > >> Thanks >> Wen Congyang >> >>> >>> Eric, what do you think? >>> >>>>> { 'struct': 'NBDInet', 'data': { 'host': 'str', '*port': 'int', >>>>> '*ipv4': 'bool', '*ipv6': 'bool' } } >>>> >>>> Thanks for the above, and I will try it. >>> >>> [...] >>> . >>> > . > From MAILER-DAEMON Wed Sep 16 02:31:57 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zc6G5-0001g3-SX for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 02:31:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc6G2-0001aE-Ff for qemu-block@nongnu.org; Wed, 16 Sep 2015 02:31:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zc6G1-0001TI-3k for qemu-block@nongnu.org; Wed, 16 Sep 2015 02:31:54 -0400 Received: from [59.151.112.132] (port=23353 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc6Fu-0001Qm-0b; Wed, 16 Sep 2015 02:31:46 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100770039" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 16 Sep 2015 14:34:32 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8G6VPBs021151; Wed, 16 Sep 2015 14:31:25 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 16 Sep 2015 14:31:40 +0800 To: Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> <87mvwpkqzi.fsf@blackfin.pond.sub.org> <55F7850A.5050109@cn.fujitsu.com> <87613c86mk.fsf@blackfin.pond.sub.org> From: Wen Congyang Message-ID: <55F90CAA.5060403@cn.fujitsu.com> Date: Wed, 16 Sep 2015 14:31:06 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87613c86mk.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 06:31:56 -0000 On 09/15/2015 03:49 PM, Markus Armbruster wrote: > Wen Congyang writes: > >> On 09/14/2015 10:36 PM, Markus Armbruster wrote: >>> Wen Congyang writes: >>> >>>> Signed-off-by: Wen Congyang >>>> Signed-off-by: zhanghailiang >>>> Signed-off-by: Gonglei >>>> --- >>>> blockdev.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ >>>> qapi/block-core.json | 34 +++++++++++++++++++++++++++++++++ >>>> qmp-commands.hx | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ >>>> 3 files changed, 134 insertions(+) >>>> >>>> diff --git a/blockdev.c b/blockdev.c >>>> index bd47756..0a40607 100644 >>>> --- a/blockdev.c >>>> +++ b/blockdev.c >>>> @@ -3413,6 +3413,53 @@ fail: >>>> qmp_output_visitor_cleanup(ov); >>>> } >>>> >>>> +void qmp_x_child_add(const char *parent, const char *child, >>>> + Error **errp) >>>> +{ >>>> + BlockDriverState *parent_bs, *child_bs; >>>> + Error *local_err = NULL; >>>> + >>>> + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); >>>> + if (!parent_bs) { >>>> + error_propagate(errp, local_err); >>>> + return; >>>> + } >>>> + >>>> + child_bs = bdrv_find_node(child); >>>> + if (!child_bs) { >>>> + error_setg(errp, "Node '%s' not found", child); >>>> + return; >>>> + } >>>> + >>>> + bdrv_add_child(parent_bs, child_bs, &local_err); >>>> + if (local_err) { >>>> + error_propagate(errp, local_err); >>>> + } >>>> +} >>>> + >>>> +void qmp_child_del(const char *parent, const char *child, Error **errp) >>>> +{ >>>> + BlockDriverState *parent_bs, *child_bs; >>>> + Error *local_err = NULL; >>>> + >>>> + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); >>>> + if (!parent_bs) { >>>> + error_propagate(errp, local_err); >>>> + return; >>>> + } >>>> + >>>> + child_bs = bdrv_find_node(child); >>>> + if (!child_bs) { >>>> + error_setg(errp, "Node '%s' not found", child); >>>> + return; >>>> + } >>>> + >>>> + bdrv_del_child(parent_bs, child_bs, &local_err); >>>> + if (local_err) { >>>> + error_propagate(errp, local_err); >>>> + } >>>> +} >>>> + >>>> BlockJobInfoList *qmp_query_block_jobs(Error **errp) >>>> { >>>> BlockJobInfoList *head = NULL, **p_next = &head; >>>> diff --git a/qapi/block-core.json b/qapi/block-core.json >>>> index e68a59f..b959577 100644 >>>> --- a/qapi/block-core.json >>>> +++ b/qapi/block-core.json >>>> @@ -2272,3 +2272,37 @@ >>>> ## >>>> { 'command': 'block-set-write-threshold', >>>> 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } >>>> + >>>> +## >>>> +# @x-child-add >>>> +# >>>> +# Add a new child to the parent BDS. Currently only the Quorum driver >>>> +# implements this feature. This is useful to fix a broken quorum child. >>>> +# >>>> +# @parent: graph node name or id which the child will be added to. >>>> +# >>>> +# @child: graph node name that will be added. >>>> +# >>>> +# Note: this command is experimental, and not a stable API. >>>> +# >>>> +# Since: 2.5 >>>> +## >>>> +{ 'command': 'x-child-add', >>>> + 'data' : { 'parent': 'str', 'child': 'str' } } >>>> + >>>> +## >>>> +# @child-del >>>> +# >>>> +# Remove a child from the parent BDS. Currently only the Quorum driver >>>> +# implements this feature. This is useful to fix a broken quorum child. >>>> +# Note, you can't remove a child if it would bring the quorum below its >>>> +# threshold. >>>> +# >>>> +# @parent: graph node name or id from which the child will removed. >>>> +# >>>> +# @child: graph node name that will be removed. >>>> +# >>>> +# Since: 2.5 >>>> +## >>>> +{ 'command': 'child-del', >>>> + 'data' : { 'parent': 'str', 'child': 'str' } } >>> >>> Why is x-child-add experimental, but child-del isn't? Please explain >>> both in the schema and in the commit message. >> >> No special reason. Should I put child-del in experimental namespace? > > I found the reason for x-child-add in your v2: > > child-add > ------------ > > Add a child to a quorum node. > > This command is still a work in progress. It doesn't support all > block drivers. Stay away from it unless you want it to help with > its development. > > Eric suggested to rename it to x-child-add, and you did. Good. You > also shortened the "work in progress" note to just "Note: this command > is experimental, and not a stable API." I'd like to have a more verbose > note explaining *why* the command is experimental, both here and in > qmp-commands.hx. "It doesn't support all block drivers" is a reason. > Are the any others? > > Is child-del similarly unfinished? If yes, make it x-child-del to save > us from later grief. > > If no: is child-del is only useful together with x-child-add? Then make > it x-child-del regardless. I have another question: if the command is experimental, we have the prefix "x-". Which prefix is used for hmp command? Thanks Wen Congyang > >>>> diff --git a/qmp-commands.hx b/qmp-commands.hx >>>> index 495670b..139a23b 100644 >>>> --- a/qmp-commands.hx >>>> +++ b/qmp-commands.hx >>>> @@ -4053,6 +4053,59 @@ Example: >>>> EQMP >>>> >>>> { >>>> + .name = "x-child-add", >>>> + .args_type = "parent:B,child:B", >>>> + .mhandler.cmd_new = qmp_marshal_input_x_child_add, >>>> + }, >>>> + >>>> +SQMP >>>> +x-child-add >>>> +------------ >>>> + >>>> +Add a child to a quorum node. >>>> + >>>> +Arguments: >>>> + >>>> +- "parent": the quorum's id or node name >>>> +- "child": the child node-name which will be added >>> >>> Node name parameters are usually named node-name or, if there's more >>> than one, FOO-node-name. Unless we want to abandon that convention, >>> this should therefore be node-name and child-node-name, or parent-node >>> name and child-node-name. >> >> parent can be top BDS, so it can be id. node-name is a very common name, >> and I think child or child-node-name is better. > > Kevin pointed out we want to move to names without a -node-name suffix. > >>>> + >>>> +Note: this command is experimental, and not a stable API. >>>> + >>>> +Example: >>>> + >>>> +-> { "execute": "x-child-add", >>>> + "arguments": { "parent": "disk1", "child": "new_node" } } >>>> +<- { "return": {} } >>>> + >>>> +EQMP >>>> + >>>> + { >>>> + .name = "child-del", >>> >>> Documentation and schema have x-child-add, actual command is child-add. >>> Oops. >> >> Here is child-del.... > > You're right. I got confused... > >>>> + .args_type = "parent:B,child:B", >>>> + .mhandler.cmd_new = qmp_marshal_input_child_del, >>>> + }, >>>> + >>>> +SQMP >>>> +child-del >>>> +------------ >>>> + >>>> +Delete a child from a quorum node. It can be used to remove a broken >>>> +quorum child. >>>> + >>>> +Arguments: >>>> + >>>> +- "parent": the quorum's id or node name >>>> +- "child": the child node-name which will be removed >>> >>> Same comment as on x-child-add's parameter names. >>> >>>> + >>>> +Example: >>>> + >>>> +-> { "execute": "child-del", >>>> + "arguments": { "parent": "disk1", "child": "new_node" } } >>>> +<- { "return": {} } >>>> + >>>> +EQMP >>>> + >>>> + { >>>> .name = "query-named-block-nodes", >>>> .args_type = "", >>>> .mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes, >>> . >>> > . > From MAILER-DAEMON Wed Sep 16 03:12:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zc6t3-0001Oy-HW for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 03:12:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc6sx-0001Fu-5m for qemu-block@nongnu.org; Wed, 16 Sep 2015 03:12:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zc6sw-0002yy-3d for qemu-block@nongnu.org; Wed, 16 Sep 2015 03:12:07 -0400 Received: from [59.151.112.132] (port=42322 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc6sk-0002sc-4c; Wed, 16 Sep 2015 03:11:56 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100771486" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 16 Sep 2015 15:14:40 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8G7BXVa023413; Wed, 16 Sep 2015 15:11:33 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 16 Sep 2015 15:11:48 +0800 To: Eric Blake , Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F78059.4030309@cn.fujitsu.com> <55F78225.404@cn.fujitsu.com> <55F794A4.5060903@redhat.com> <55F7975B.4050405@cn.fujitsu.com> <55F818F1.9070201@redhat.com> From: Wen Congyang Message-ID: <55F91612.6010300@cn.fujitsu.com> Date: Wed, 16 Sep 2015 15:11:14 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F818F1.9070201@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 07:12:12 -0000 On 09/15/2015 09:11 PM, Eric Blake wrote: > On 09/14/2015 09:58 PM, Wen Congyang wrote: >> On 09/15/2015 11:46 AM, Eric Blake wrote: >>> On 09/14/2015 08:27 PM, Wen Congyang wrote: >>>>> Building fails: >>>>> GEN qmp-commands.h >>>>> In file included from /work/src/qemu/qapi-schema.json:9: >>>>> In file included from /work/src/qemu/qapi/block.json:6: >>>>> /work/src/qemu/qapi/block-core.json:1844: Flat union 'BlockdevOptionsNBD' must have a string base field >>>>> Makefile:286: recipe for target 'qmp-commands.h' failed >>>>> make: *** [qmp-commands.h] Error 1 >>> >>> Yep, doesn't work until pending qapi patches land. >> >> This patchset: qapi: QMP introspection? > > That, and "qapi-ify netdev_add, and other post-introspection cleanups" > https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg02580.html > > and "qapi: support anonymous inline base" > https://lists.gnu.org/archive/html/qemu-devel/2015-08/msg02346.html > [still needs rebasing to latest versions of the other series] > > >>> >>> Possible workaround in the meantime - instead of trying to go with a >>> nice flat union (where all QMP keys are in the same {} level), we can >>> use nesting (structs that add another {} to include the unions). >> >> How to include the unions to a structs? Use 'base'? > > Conceptually, by adding a layer of nesting. On the wire, instead of: > > { "switch1":"value", "switch2":"value", "body2":"blah" } > > you would instead have: > > { "switch1":"value", "data": { "switch2":"value", "body2":"blah" } } > > Anywhere in qapi that you try to have: > { 'union': ..., 'data':{'switch1':'Union'}} > > you instead create a wrapper type: > { 'struct':'Wrapper', 'data':{'data':'Union'}} > { 'union': ..., 'data':{'switch1':'Wrapper'}} If so, the option is "data.switch1" not "switch1" > > > What I don't know is whether the extra QMP nesting makes it easier or > harder to support the existing NBD command line options, and it would Yes, it is harder to support it. Thanks Wen Congyang > ultimately be nice to have unified support so that anything we can do on > the command line can be expressed in QMP; and anything we can do in QMP > can be expressed on the command line without undue nesting. > From MAILER-DAEMON Wed Sep 16 04:21:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zc7y7-0000YZ-Cs for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 04:21:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc7xw-0000VW-6C for qemu-block@nongnu.org; Wed, 16 Sep 2015 04:21:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zc7xt-0001hU-0X for qemu-block@nongnu.org; Wed, 16 Sep 2015 04:21:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36344) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc7xs-0001fU-Oz; Wed, 16 Sep 2015 04:21:16 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id BEB3FFA9CE; Wed, 16 Sep 2015 08:21:15 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8G8LDHT024710 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Sep 2015 04:21:14 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9FDB5303F90D; Wed, 16 Sep 2015 10:21:12 +0200 (CEST) From: Markus Armbruster To: Wen Congyang References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F776CC.3050601@cn.fujitsu.com> <87fv2g876a.fsf@blackfin.pond.sub.org> <55F7D06D.1080205@cn.fujitsu.com> <87mvwo3phm.fsf@blackfin.pond.sub.org> <55F9054F.1000001@cn.fujitsu.com> Date: Wed, 16 Sep 2015 10:21:12 +0200 In-Reply-To: <55F9054F.1000001@cn.fujitsu.com> (Wen Congyang's message of "Wed, 16 Sep 2015 13:59:43 +0800") Message-ID: <87r3lyzsef.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 08:21:24 -0000 Wen Congyang writes: > On 09/15/2015 07:12 PM, Markus Armbruster wrote: >> Wen Congyang writes: >> >>> On 09/15/2015 03:37 PM, Markus Armbruster wrote: >>>> Wen Congyang writes: >>>> >>>>> On 09/14/2015 11:47 PM, Eric Blake wrote: >>>>>> On 09/14/2015 08:27 AM, Markus Armbruster wrote: >>>>>>> Wen Congyang writes: >>>>>>> >>>>>>>> The NBD driver needs: filename, path or (host, port, exportname). >>>>>>>> It checks which key exists and decides use unix or inet socket. >>>>>>>> It doesn't recognize the key type, so we can't use union, and >>>>>>>> can't reuse InetSocketAddress. >>>>>>>> >>>>>>>> Signed-off-by: Wen Congyang >>>>>>>> Signed-off-by: zhanghailiang >>>>>>>> Signed-off-by: Gonglei >>>>>>>> --- >>>>>>>> qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- >>>>>>>> 1 file changed, 40 insertions(+), 2 deletions(-) >>>>>>>> >>>>>> >>>>>>>> ## >>>>>>>> +# @BlockdevOptionsNBD >>>>>>>> +# >>>>>>>> +# Driver specific block device options for NBD >>>>>>>> +# >>>>>>>> +# @filename: #optional unix or inet path. The format is: >>>>>>>> +# unix: nbd+unix:///export?socket=path or >>>>>>>> +# nbd:unix:path:exportname=export >>>>>>>> +# inet: nbd[+tcp]://host[:port]/export or >>>>>>>> +# nbd:host[:port]:exportname=export >>>>>> >>>>>> Yuck. You are passing structured data through a single 'str', when you >>>>>> SHOULD be passing it through structured JSON. Just because we have a >>>>>> filename shorthand for convenience does NOT mean that we want to expose >>>>>> that convenience in QMP. Instead, we really want the breakdown of the >>>>>> pieces (here, using abbreviated syntax of an inline base, since there >>>>>> are pending qapi patches that will allow it): >>>>> >>>>> Do you mean that: there is no need to support filename? >>>> >>>> Rule of thumb: if the QMP command handler needs to parse a string >>>> argument, that argument should be a complex QAPI type instead. >>>> >>>> Example: @filename needs to be parsed into its components, either >>>> >>>> * protocol unix, socket path, export name, or >>>> * protocol tcp, host, port, export name >>>> >>>> Since there's an either/or, the complex QAPI type should be a union. >>>> >>>>>> { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } >>>>> >>>>> NBD only uses tcp, it doesn't support udp. >>>>> >>>>>> { 'union': 'BlockdevOptionsNBD', >>>>>> 'base': { 'transport': 'NBDTransport', 'export': 'str' }, >>>>>> 'discriminator': 'transport', >>>>>> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } >>>>>> { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } >>>>> >>>>> unix socket needs a path, and I think we can use UnixSocketAddress here. >>>> >>>> Yes, we should try to reuse common types like SocketAddress, >>>> InetSocketAddress, UnixSocketAddress. >>>> >>>> Perhaps it could be as simple as >>>> >>>> { 'struct': 'BlockdevOptionsNBD', >>>> 'data': { 'addr: 'SocketAddress', 'export': 'str' } } >>> >>> The problem is that: NBD doesn't use the fd. >> >> Is that fundamental, or just a matter of implementation? Question still open. >>> Another question is: what key will we see in nbd_open()? "addr.host" >>> or "host"? >> >> As long as nbd_config() looks for "host" in the options QDict, we need >> to put "host". > > Yes, we need "host" in nbd_config(), but we pass "addr.data.host" to it. > > How to avoid this problem? Where is the code constructing the QDict? From MAILER-DAEMON Wed Sep 16 04:25:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zc81r-0003cP-Ff for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 04:25:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc81o-0003YG-5Q for qemu-block@nongnu.org; Wed, 16 Sep 2015 04:25:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zc81m-0003Vp-Mh for qemu-block@nongnu.org; Wed, 16 Sep 2015 04:25:19 -0400 Received: from [59.151.112.132] (port=53166 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc81h-0003QR-FY; Wed, 16 Sep 2015 04:25:14 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100774316" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 16 Sep 2015 16:28:02 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8G8OtCa027950; Wed, 16 Sep 2015 16:24:55 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 16 Sep 2015 16:25:10 +0800 To: Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F776CC.3050601@cn.fujitsu.com> <87fv2g876a.fsf@blackfin.pond.sub.org> <55F7D06D.1080205@cn.fujitsu.com> <87mvwo3phm.fsf@blackfin.pond.sub.org> <55F9054F.1000001@cn.fujitsu.com> <87r3lyzsef.fsf@blackfin.pond.sub.org> From: Wen Congyang Message-ID: <55F92745.6040904@cn.fujitsu.com> Date: Wed, 16 Sep 2015 16:24:37 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87r3lyzsef.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 08:25:21 -0000 On 09/16/2015 04:21 PM, Markus Armbruster wrote: > Wen Congyang writes: > >> On 09/15/2015 07:12 PM, Markus Armbruster wrote: >>> Wen Congyang writes: >>> >>>> On 09/15/2015 03:37 PM, Markus Armbruster wrote: >>>>> Wen Congyang writes: >>>>> >>>>>> On 09/14/2015 11:47 PM, Eric Blake wrote: >>>>>>> On 09/14/2015 08:27 AM, Markus Armbruster wrote: >>>>>>>> Wen Congyang writes: >>>>>>>> >>>>>>>>> The NBD driver needs: filename, path or (host, port, exportname). >>>>>>>>> It checks which key exists and decides use unix or inet socket. >>>>>>>>> It doesn't recognize the key type, so we can't use union, and >>>>>>>>> can't reuse InetSocketAddress. >>>>>>>>> >>>>>>>>> Signed-off-by: Wen Congyang >>>>>>>>> Signed-off-by: zhanghailiang >>>>>>>>> Signed-off-by: Gonglei >>>>>>>>> --- >>>>>>>>> qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- >>>>>>>>> 1 file changed, 40 insertions(+), 2 deletions(-) >>>>>>>>> >>>>>>> >>>>>>>>> ## >>>>>>>>> +# @BlockdevOptionsNBD >>>>>>>>> +# >>>>>>>>> +# Driver specific block device options for NBD >>>>>>>>> +# >>>>>>>>> +# @filename: #optional unix or inet path. The format is: >>>>>>>>> +# unix: nbd+unix:///export?socket=path or >>>>>>>>> +# nbd:unix:path:exportname=export >>>>>>>>> +# inet: nbd[+tcp]://host[:port]/export or >>>>>>>>> +# nbd:host[:port]:exportname=export >>>>>>> >>>>>>> Yuck. You are passing structured data through a single 'str', when you >>>>>>> SHOULD be passing it through structured JSON. Just because we have a >>>>>>> filename shorthand for convenience does NOT mean that we want to expose >>>>>>> that convenience in QMP. Instead, we really want the breakdown of the >>>>>>> pieces (here, using abbreviated syntax of an inline base, since there >>>>>>> are pending qapi patches that will allow it): >>>>>> >>>>>> Do you mean that: there is no need to support filename? >>>>> >>>>> Rule of thumb: if the QMP command handler needs to parse a string >>>>> argument, that argument should be a complex QAPI type instead. >>>>> >>>>> Example: @filename needs to be parsed into its components, either >>>>> >>>>> * protocol unix, socket path, export name, or >>>>> * protocol tcp, host, port, export name >>>>> >>>>> Since there's an either/or, the complex QAPI type should be a union. >>>>> >>>>>>> { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } >>>>>> >>>>>> NBD only uses tcp, it doesn't support udp. >>>>>> >>>>>>> { 'union': 'BlockdevOptionsNBD', >>>>>>> 'base': { 'transport': 'NBDTransport', 'export': 'str' }, >>>>>>> 'discriminator': 'transport', >>>>>>> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } >>>>>>> { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } >>>>>> >>>>>> unix socket needs a path, and I think we can use UnixSocketAddress here. >>>>> >>>>> Yes, we should try to reuse common types like SocketAddress, >>>>> InetSocketAddress, UnixSocketAddress. >>>>> >>>>> Perhaps it could be as simple as >>>>> >>>>> { 'struct': 'BlockdevOptionsNBD', >>>>> 'data': { 'addr: 'SocketAddress', 'export': 'str' } } >>>> >>>> The problem is that: NBD doesn't use the fd. >>> >>> Is that fundamental, or just a matter of implementation? > > Question still open. > >>>> Another question is: what key will we see in nbd_open()? "addr.host" >>>> or "host"? >>> >>> As long as nbd_config() looks for "host" in the options QDict, we need >>> to put "host". >> >> Yes, we need "host" in nbd_config(), but we pass "addr.data.host" to it. >> >> How to avoid this problem? > > Where is the code constructing the QDict? The QDict is constructed in qmp_blockdev_add(): visit_type_BlockdevOptions(qmp_output_get_visitor(ov), &options, NULL, &local_err); if (local_err) { error_propagate(errp, local_err); goto fail; } obj = qmp_output_get_qobject(ov); qdict = qobject_to_qdict(obj); qdict_flatten(qdict); Thanks Wen Congyang > . > From MAILER-DAEMON Wed Sep 16 04:29:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zc85r-0005Om-8d for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 04:29:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc85o-0005Ob-8k for qemu-block@nongnu.org; Wed, 16 Sep 2015 04:29:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zc85k-0006Xa-02 for qemu-block@nongnu.org; Wed, 16 Sep 2015 04:29:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc85j-0006XD-OC; Wed, 16 Sep 2015 04:29:23 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 25BAFC0B200D; Wed, 16 Sep 2015 08:29:23 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8G8TLo5028091 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Sep 2015 04:29:22 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 642D4303F90D; Wed, 16 Sep 2015 10:29:20 +0200 (CEST) From: Markus Armbruster To: Wen Congyang References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-5-git-send-email-wency@cn.fujitsu.com> <87mvwpkqzi.fsf@blackfin.pond.sub.org> <55F7850A.5050109@cn.fujitsu.com> <87613c86mk.fsf@blackfin.pond.sub.org> <55F90CAA.5060403@cn.fujitsu.com> Date: Wed, 16 Sep 2015 10:29:20 +0200 In-Reply-To: <55F90CAA.5060403@cn.fujitsu.com> (Wen Congyang's message of "Wed, 16 Sep 2015 14:31:06 +0800") Message-ID: <87lhc6zs0v.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 4/5] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 08:29:29 -0000 Wen Congyang writes: > On 09/15/2015 03:49 PM, Markus Armbruster wrote: >> Wen Congyang writes: >> >>> On 09/14/2015 10:36 PM, Markus Armbruster wrote: >>>> Wen Congyang writes: >>>> >>>>> Signed-off-by: Wen Congyang >>>>> Signed-off-by: zhanghailiang >>>>> Signed-off-by: Gonglei >>>>> --- >>>>> blockdev.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ >>>>> qapi/block-core.json | 34 +++++++++++++++++++++++++++++++++ >>>>> qmp-commands.hx | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ >>>>> 3 files changed, 134 insertions(+) >>>>> >>>>> diff --git a/blockdev.c b/blockdev.c >>>>> index bd47756..0a40607 100644 >>>>> --- a/blockdev.c >>>>> +++ b/blockdev.c >>>>> @@ -3413,6 +3413,53 @@ fail: >>>>> qmp_output_visitor_cleanup(ov); >>>>> } >>>>> >>>>> +void qmp_x_child_add(const char *parent, const char *child, >>>>> + Error **errp) >>>>> +{ >>>>> + BlockDriverState *parent_bs, *child_bs; >>>>> + Error *local_err = NULL; >>>>> + >>>>> + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); >>>>> + if (!parent_bs) { >>>>> + error_propagate(errp, local_err); >>>>> + return; >>>>> + } >>>>> + >>>>> + child_bs = bdrv_find_node(child); >>>>> + if (!child_bs) { >>>>> + error_setg(errp, "Node '%s' not found", child); >>>>> + return; >>>>> + } >>>>> + >>>>> + bdrv_add_child(parent_bs, child_bs, &local_err); >>>>> + if (local_err) { >>>>> + error_propagate(errp, local_err); >>>>> + } >>>>> +} >>>>> + >>>>> +void qmp_child_del(const char *parent, const char *child, Error **errp) >>>>> +{ >>>>> + BlockDriverState *parent_bs, *child_bs; >>>>> + Error *local_err = NULL; >>>>> + >>>>> + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); >>>>> + if (!parent_bs) { >>>>> + error_propagate(errp, local_err); >>>>> + return; >>>>> + } >>>>> + >>>>> + child_bs = bdrv_find_node(child); >>>>> + if (!child_bs) { >>>>> + error_setg(errp, "Node '%s' not found", child); >>>>> + return; >>>>> + } >>>>> + >>>>> + bdrv_del_child(parent_bs, child_bs, &local_err); >>>>> + if (local_err) { >>>>> + error_propagate(errp, local_err); >>>>> + } >>>>> +} >>>>> + >>>>> BlockJobInfoList *qmp_query_block_jobs(Error **errp) >>>>> { >>>>> BlockJobInfoList *head = NULL, **p_next = &head; >>>>> diff --git a/qapi/block-core.json b/qapi/block-core.json >>>>> index e68a59f..b959577 100644 >>>>> --- a/qapi/block-core.json >>>>> +++ b/qapi/block-core.json >>>>> @@ -2272,3 +2272,37 @@ >>>>> ## >>>>> { 'command': 'block-set-write-threshold', >>>>> 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } >>>>> + >>>>> +## >>>>> +# @x-child-add >>>>> +# >>>>> +# Add a new child to the parent BDS. Currently only the Quorum driver >>>>> +# implements this feature. This is useful to fix a broken quorum child. >>>>> +# >>>>> +# @parent: graph node name or id which the child will be added to. >>>>> +# >>>>> +# @child: graph node name that will be added. >>>>> +# >>>>> +# Note: this command is experimental, and not a stable API. >>>>> +# >>>>> +# Since: 2.5 >>>>> +## >>>>> +{ 'command': 'x-child-add', >>>>> + 'data' : { 'parent': 'str', 'child': 'str' } } >>>>> + >>>>> +## >>>>> +# @child-del >>>>> +# >>>>> +# Remove a child from the parent BDS. Currently only the Quorum driver >>>>> +# implements this feature. This is useful to fix a broken quorum child. >>>>> +# Note, you can't remove a child if it would bring the quorum below its >>>>> +# threshold. >>>>> +# >>>>> +# @parent: graph node name or id from which the child will removed. >>>>> +# >>>>> +# @child: graph node name that will be removed. >>>>> +# >>>>> +# Since: 2.5 >>>>> +## >>>>> +{ 'command': 'child-del', >>>>> + 'data' : { 'parent': 'str', 'child': 'str' } } >>>> >>>> Why is x-child-add experimental, but child-del isn't? Please explain >>>> both in the schema and in the commit message. >>> >>> No special reason. Should I put child-del in experimental namespace? >> >> I found the reason for x-child-add in your v2: >> >> child-add >> ------------ >> >> Add a child to a quorum node. >> >> This command is still a work in progress. It doesn't support all >> block drivers. Stay away from it unless you want it to help with >> its development. >> >> Eric suggested to rename it to x-child-add, and you did. Good. You >> also shortened the "work in progress" note to just "Note: this command >> is experimental, and not a stable API." I'd like to have a more verbose >> note explaining *why* the command is experimental, both here and in >> qmp-commands.hx. "It doesn't support all block drivers" is a reason. >> Are the any others? >> >> Is child-del similarly unfinished? If yes, make it x-child-del to save >> us from later grief. >> >> If no: is child-del is only useful together with x-child-add? Then make >> it x-child-del regardless. > > I have another question: if the command is experimental, we have the > prefix "x-". > Which prefix is used for hmp command? HMP is not a stable interface, so generally don't bother marking experimental interfaces. That said, I'd probably keep HMP and QMP command name the same to minimize confusion. [...] From MAILER-DAEMON Wed Sep 16 07:18:36 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcAjU-0000fb-GZ for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 07:18:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcAjP-0000Z4-Co for qemu-block@nongnu.org; Wed, 16 Sep 2015 07:18:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcAjM-00025n-18 for qemu-block@nongnu.org; Wed, 16 Sep 2015 07:18:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32820) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcAjL-00025e-Qc; Wed, 16 Sep 2015 07:18:27 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 21C5755; Wed, 16 Sep 2015 11:18:27 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GBIOrT016330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Sep 2015 07:18:26 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1B7AC303F90D; Wed, 16 Sep 2015 13:18:24 +0200 (CEST) From: Markus Armbruster To: Wen Congyang References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F776CC.3050601@cn.fujitsu.com> <87fv2g876a.fsf@blackfin.pond.sub.org> <55F7D06D.1080205@cn.fujitsu.com> <87mvwo3phm.fsf@blackfin.pond.sub.org> <55F9054F.1000001@cn.fujitsu.com> <87r3lyzsef.fsf@blackfin.pond.sub.org> <55F92745.6040904@cn.fujitsu.com> Date: Wed, 16 Sep 2015 13:18:24 +0200 In-Reply-To: <55F92745.6040904@cn.fujitsu.com> (Wen Congyang's message of "Wed, 16 Sep 2015 16:24:37 +0800") Message-ID: <87bnd2y5mn.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 11:18:32 -0000 Wen Congyang writes: > On 09/16/2015 04:21 PM, Markus Armbruster wrote: >> Wen Congyang writes: >> >>> On 09/15/2015 07:12 PM, Markus Armbruster wrote: >>>> Wen Congyang writes: >>>> >>>>> On 09/15/2015 03:37 PM, Markus Armbruster wrote: >>>>>> Wen Congyang writes: >>>>>> >>>>>>> On 09/14/2015 11:47 PM, Eric Blake wrote: >>>>>>>> On 09/14/2015 08:27 AM, Markus Armbruster wrote: >>>>>>>>> Wen Congyang writes: >>>>>>>>> >>>>>>>>>> The NBD driver needs: filename, path or (host, port, exportname). >>>>>>>>>> It checks which key exists and decides use unix or inet socket. >>>>>>>>>> It doesn't recognize the key type, so we can't use union, and >>>>>>>>>> can't reuse InetSocketAddress. >>>>>>>>>> >>>>>>>>>> Signed-off-by: Wen Congyang >>>>>>>>>> Signed-off-by: zhanghailiang >>>>>>>>>> Signed-off-by: Gonglei >>>>>>>>>> --- >>>>>>>>>> qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- >>>>>>>>>> 1 file changed, 40 insertions(+), 2 deletions(-) >>>>>>>>>> >>>>>>>> >>>>>>>>>> ## >>>>>>>>>> +# @BlockdevOptionsNBD >>>>>>>>>> +# >>>>>>>>>> +# Driver specific block device options for NBD >>>>>>>>>> +# >>>>>>>>>> +# @filename: #optional unix or inet path. The format is: >>>>>>>>>> +# unix: nbd+unix:///export?socket=path or >>>>>>>>>> +# nbd:unix:path:exportname=export >>>>>>>>>> +# inet: nbd[+tcp]://host[:port]/export or >>>>>>>>>> +# nbd:host[:port]:exportname=export >>>>>>>> >>>>>>>> Yuck. You are passing structured data through a single 'str', when you >>>>>>>> SHOULD be passing it through structured JSON. Just because we have a >>>>>>>> filename shorthand for convenience does NOT mean that we want to expose >>>>>>>> that convenience in QMP. Instead, we really want the breakdown of the >>>>>>>> pieces (here, using abbreviated syntax of an inline base, since there >>>>>>>> are pending qapi patches that will allow it): >>>>>>> >>>>>>> Do you mean that: there is no need to support filename? >>>>>> >>>>>> Rule of thumb: if the QMP command handler needs to parse a string >>>>>> argument, that argument should be a complex QAPI type instead. >>>>>> >>>>>> Example: @filename needs to be parsed into its components, either >>>>>> >>>>>> * protocol unix, socket path, export name, or >>>>>> * protocol tcp, host, port, export name >>>>>> >>>>>> Since there's an either/or, the complex QAPI type should be a union. >>>>>> >>>>>>>> { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } >>>>>>> >>>>>>> NBD only uses tcp, it doesn't support udp. >>>>>>> >>>>>>>> { 'union': 'BlockdevOptionsNBD', >>>>>>>> 'base': { 'transport': 'NBDTransport', 'export': 'str' }, >>>>>>>> 'discriminator': 'transport', >>>>>>>> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } >>>>>>>> { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } >>>>>>> >>>>>>> unix socket needs a path, and I think we can use UnixSocketAddress here. >>>>>> >>>>>> Yes, we should try to reuse common types like SocketAddress, >>>>>> InetSocketAddress, UnixSocketAddress. >>>>>> >>>>>> Perhaps it could be as simple as >>>>>> >>>>>> { 'struct': 'BlockdevOptionsNBD', >>>>>> 'data': { 'addr: 'SocketAddress', 'export': 'str' } } >>>>> >>>>> The problem is that: NBD doesn't use the fd. >>>> >>>> Is that fundamental, or just a matter of implementation? >> >> Question still open. Question still open. >>>>> Another question is: what key will we see in nbd_open()? "addr.host" >>>>> or "host"? >>>> >>>> As long as nbd_config() looks for "host" in the options QDict, we need >>>> to put "host". >>> >>> Yes, we need "host" in nbd_config(), but we pass "addr.data.host" to it. >>> >>> How to avoid this problem? >> >> Where is the code constructing the QDict? > > The QDict is constructed in qmp_blockdev_add(): > visit_type_BlockdevOptions(qmp_output_get_visitor(ov), > &options, NULL, &local_err); > if (local_err) { > error_propagate(errp, local_err); > goto fail; > } > > obj = qmp_output_get_qobject(ov); > qdict = qobject_to_qdict(obj); > > qdict_flatten(qdict); Okay. Long term, I'd like to see us get rid of the conversions between QAPI-generated types and QDict / QemuOpts. Short term, you need to co-evolve the QDict-based code such as nbd_config() with the QAPI interfaces. Keeping the QAPI interface clean is more important than minimizing the implementation work, because we're free to mess with the implementation, but releasing a QAPI interface makes it ABI, so we better get it right. From MAILER-DAEMON Wed Sep 16 09:32:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcCpH-0002ql-LA for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 09:32:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56012) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcCpF-0002q9-4V for qemu-block@nongnu.org; Wed, 16 Sep 2015 09:32:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcCpB-0000ti-VO for qemu-block@nongnu.org; Wed, 16 Sep 2015 09:32:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcCpB-0000sh-Ql; Wed, 16 Sep 2015 09:32:37 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id D3F6BC0B9196; Wed, 16 Sep 2015 13:32:36 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8GDWZg2005925; Wed, 16 Sep 2015 09:32:35 -0400 Date: Wed, 16 Sep 2015 15:32:34 +0200 From: Kevin Wolf To: qemu-block@nongnu.org, rgerganov@vmware.com Message-ID: <20150916133234.GA3980@noname.str.redhat.com> References: <20120530234408.16043.24886.malonedeb@chaenomeles.canonical.com> <20150916121131.10679.62163.malone@chaenomeles.canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150916121131.10679.62163.malone@chaenomeles.canonical.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: famz@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [Bug 1006655] Re: Can't convert to vmdk with the streamOptimized subformat X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 13:32:42 -0000 Am 16.09.2015 um 14:11 hat Radoslav Gerganov geschrieben: > My patch has landed: > https://github.com/qemu/qemu/commit/3efffc3292d94271a15b1606b4a56adf6c6f04ed > > I think we can resolve this bug as fixed. Just one note for those how > are trying to use streamOptimized images with VMware: you need to patch > the VMDK version because VMware products accept only version 3 for > streamOptimized: > > # Set VMDK version 3 for foo.vmdk > $ printf '\x03' | dd conv=notrunc of=foo.vmdk bs=1 seek=$((0x4)) Then I guess this is how qemu-img should create the image in the first place. After all, compatibility with VMware is the only reason why the VMDK driver exists. Radoslav or Fam, can one of you send a patch for this? Kevin From MAILER-DAEMON Wed Sep 16 09:52:37 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcD8X-0003YG-UW for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 09:52:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcD8V-0003Xd-Qv for qemu-block@nongnu.org; Wed, 16 Sep 2015 09:52:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcD8Q-0002zI-R6 for qemu-block@nongnu.org; Wed, 16 Sep 2015 09:52:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59968) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcD8Q-0002yO-MI; Wed, 16 Sep 2015 09:52:30 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id BC4ADC0B919C; Wed, 16 Sep 2015 13:52:29 +0000 (UTC) Received: from localhost.localdomain.com (vpn1-5-41.ams2.redhat.com [10.36.5.41]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GDqRAJ024368; Wed, 16 Sep 2015 09:52:28 -0400 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Wed, 16 Sep 2015 14:52:21 +0100 Message-Id: <1442411543-28513-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , "Daniel P. Berrange" , qemu-block@nongnu.org Subject: [Qemu-block] [PATCH v1 0/2] Remove use of QemuOpts from the nbd code X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 13:52:36 -0000 The intent is for all the callers of the util/qemu-sockets.c APIs to be converted to use the QAPI SocketAddress variants, with the QemuOpts variants eventually being deleted entirely. With that in mind, this small series converts the NBD client and server to use the QAPI SocketAddress object. This only leaves the VNC server using QemuOpts for socket setup, which will be converted shortly. Daniel P. Berrange (2): nbd: convert to use the QAPI SocketAddress object qemu-nbd: convert to use the QAPI SocketAddress object block/nbd.c | 69 +++++++++++++++++++++------------------- qemu-nbd.c | 102 ++++++++++++++++++++++-------------------------------------- 2 files changed, 75 insertions(+), 96 deletions(-) -- 2.4.3 From MAILER-DAEMON Wed Sep 16 09:52:39 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcD8Z-0003ZH-1A for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 09:52:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcD8V-0003Xc-QY for qemu-block@nongnu.org; Wed, 16 Sep 2015 09:52:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcD8R-00030s-Q5 for qemu-block@nongnu.org; Wed, 16 Sep 2015 09:52:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59971) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcD8R-00030L-IO; Wed, 16 Sep 2015 09:52:31 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 3773FC0B91AC; Wed, 16 Sep 2015 13:52:31 +0000 (UTC) Received: from localhost.localdomain.com (vpn1-5-41.ams2.redhat.com [10.36.5.41]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GDqRAK024368; Wed, 16 Sep 2015 09:52:29 -0400 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Wed, 16 Sep 2015 14:52:22 +0100 Message-Id: <1442411543-28513-2-git-send-email-berrange@redhat.com> In-Reply-To: <1442411543-28513-1-git-send-email-berrange@redhat.com> References: <1442411543-28513-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , "Daniel P. Berrange" , qemu-block@nongnu.org Subject: [Qemu-block] [PATCH v1 1/2] nbd: convert to use the QAPI SocketAddress object X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 13:52:37 -0000 The nbd block driver currently uses a QemuOpts object when setting up sockets. Switch it over to use the QAPI SocketAddress object instead. Signed-off-by: Daniel P. Berrange --- block/nbd.c | 69 +++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/block/nbd.c b/block/nbd.c index 2176186..b3ba54a 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -43,7 +43,6 @@ typedef struct BDRVNBDState { NbdClientSession client; - QemuOpts *socket_opts; } BDRVNBDState; static int nbd_parse_uri(const char *filename, QDict *options) @@ -190,10 +189,10 @@ out: g_free(file); } -static void nbd_config(BDRVNBDState *s, QDict *options, char **export, - Error **errp) +static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options, char **export, + Error **errp) { - Error *local_err = NULL; + SocketAddress *saddr; if (qdict_haskey(options, "path") == qdict_haskey(options, "host")) { if (qdict_haskey(options, "path")) { @@ -201,28 +200,37 @@ static void nbd_config(BDRVNBDState *s, QDict *options, char **export, } else { error_setg(errp, "one of path and host must be specified."); } - return; + return NULL; } - s->client.is_unix = qdict_haskey(options, "path"); - s->socket_opts = qemu_opts_create(&socket_optslist, NULL, 0, - &error_abort); + saddr = g_new0(SocketAddress, 1); - qemu_opts_absorb_qdict(s->socket_opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; + if (qdict_haskey(options, "path")) { + saddr->kind = SOCKET_ADDRESS_KIND_UNIX; + saddr->q_unix = g_new0(UnixSocketAddress, 1); + saddr->q_unix->path = g_strdup(qdict_get_str(options, "path")); + qdict_del(options, "path"); + } else { + saddr->kind = SOCKET_ADDRESS_KIND_INET; + saddr->inet = g_new0(InetSocketAddress, 1); + saddr->inet->host = g_strdup(qdict_get_str(options, "host")); + if (!qdict_get_try_str(options, "port")) { + saddr->inet->port = g_strdup_printf("%d", NBD_DEFAULT_PORT); + } else { + saddr->inet->port = g_strdup(qdict_get_str(options, "port")); + } + qdict_del(options, "host"); + qdict_del(options, "port"); } - if (!qemu_opt_get(s->socket_opts, "port")) { - qemu_opt_set_number(s->socket_opts, "port", NBD_DEFAULT_PORT, - &error_abort); - } + s->client.is_unix = saddr->kind == SOCKET_ADDRESS_KIND_UNIX; *export = g_strdup(qdict_get_try_str(options, "export")); if (*export) { qdict_del(options, "export"); } + + return saddr; } NbdClientSession *nbd_get_client_session(BlockDriverState *bs) @@ -231,26 +239,24 @@ NbdClientSession *nbd_get_client_session(BlockDriverState *bs) return &s->client; } -static int nbd_establish_connection(BlockDriverState *bs, Error **errp) +static int nbd_establish_connection(BlockDriverState *bs, + SocketAddress *saddr, + Error **errp) { BDRVNBDState *s = bs->opaque; int sock; - if (s->client.is_unix) { - sock = unix_connect_opts(s->socket_opts, errp, NULL, NULL); - } else { - sock = inet_connect_opts(s->socket_opts, errp, NULL, NULL); - if (sock >= 0) { - socket_set_nodelay(sock); - } - } + sock = socket_connect(saddr, errp, NULL, NULL); - /* Failed to establish connection */ if (sock < 0) { logout("Failed to establish connection to NBD server\n"); return -EIO; } + if (!s->client.is_unix) { + socket_set_nodelay(sock); + } + return sock; } @@ -261,10 +267,11 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, char *export = NULL; int result, sock; Error *local_err = NULL; + SocketAddress *saddr; /* Pop the config into our state object. Exit if invalid. */ - nbd_config(s, options, &export, &local_err); - if (local_err) { + saddr = nbd_config(s, options, &export, &local_err); + if (!saddr) { error_propagate(errp, local_err); return -EINVAL; } @@ -272,7 +279,8 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, /* establish TCP connection, return error if it fails * TODO: Configurable retry-until-timeout behaviour. */ - sock = nbd_establish_connection(bs, errp); + sock = nbd_establish_connection(bs, saddr, errp); + qapi_free_SocketAddress(saddr); if (sock < 0) { g_free(export); return sock; @@ -315,9 +323,6 @@ static int nbd_co_discard(BlockDriverState *bs, int64_t sector_num, static void nbd_close(BlockDriverState *bs) { - BDRVNBDState *s = bs->opaque; - - qemu_opts_del(s->socket_opts); nbd_client_close(bs); } -- 2.4.3 From MAILER-DAEMON Wed Sep 16 09:52:41 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcD8b-0003bS-EG for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 09:52:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcD8Y-0003Ym-ME for qemu-block@nongnu.org; Wed, 16 Sep 2015 09:52:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcD8T-00032k-6G for qemu-block@nongnu.org; Wed, 16 Sep 2015 09:52:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56599) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcD8T-000329-0A; Wed, 16 Sep 2015 09:52:33 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id A5E2F157773; Wed, 16 Sep 2015 13:52:32 +0000 (UTC) Received: from localhost.localdomain.com (vpn1-5-41.ams2.redhat.com [10.36.5.41]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GDqRAL024368; Wed, 16 Sep 2015 09:52:31 -0400 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Wed, 16 Sep 2015 14:52:23 +0100 Message-Id: <1442411543-28513-3-git-send-email-berrange@redhat.com> In-Reply-To: <1442411543-28513-1-git-send-email-berrange@redhat.com> References: <1442411543-28513-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , "Daniel P. Berrange" , qemu-block@nongnu.org Subject: [Qemu-block] [PATCH v1 2/2] qemu-nbd: convert to use the QAPI SocketAddress object X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 13:52:40 -0000 The qemu-nbd program currently uses a QemuOpts objects when setting up sockets. Switch it over to use the QAPI SocketAddress objects instead. Signed-off-by: Daniel P. Berrange --- qemu-nbd.c | 102 +++++++++++++++++++++++-------------------------------------- 1 file changed, 38 insertions(+), 64 deletions(-) diff --git a/qemu-nbd.c b/qemu-nbd.c index 9518b75..6428c15 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -49,7 +49,7 @@ static NBDExport *exp; static int verbose; static char *srcpath; -static char *sockpath; +static SocketAddress *saddr; static int persistent = 0; static enum { RUNNING, TERMINATE, TERMINATING, TERMINATED } state; static int shared = 1; @@ -213,52 +213,6 @@ static void termsig_handler(int signum) qemu_notify_event(); } -static void combine_addr(char *buf, size_t len, const char* address, - uint16_t port) -{ - /* If the address-part contains a colon, it's an IPv6 IP so needs [] */ - if (strstr(address, ":")) { - snprintf(buf, len, "[%s]:%u", address, port); - } else { - snprintf(buf, len, "%s:%u", address, port); - } -} - -static int tcp_socket_incoming(const char *address, uint16_t port) -{ - char address_and_port[128]; - Error *local_err = NULL; - - combine_addr(address_and_port, 128, address, port); - int fd = inet_listen(address_and_port, NULL, 0, SOCK_STREAM, 0, &local_err); - - if (local_err != NULL) { - error_report_err(local_err); - } - return fd; -} - -static int unix_socket_incoming(const char *path) -{ - Error *local_err = NULL; - int fd = unix_listen(path, NULL, 0, &local_err); - - if (local_err != NULL) { - error_report_err(local_err); - } - return fd; -} - -static int unix_socket_outgoing(const char *path) -{ - Error *local_err = NULL; - int fd = unix_connect(path, &local_err); - - if (local_err != NULL) { - error_report_err(local_err); - } - return fd; -} static void *show_parts(void *arg) { @@ -287,8 +241,10 @@ static void *nbd_client_thread(void *arg) pthread_t show_parts_thread; Error *local_error = NULL; - sock = unix_socket_outgoing(sockpath); + + sock = socket_connect(saddr, &local_error, NULL, NULL); if (sock < 0) { + error_report_err(local_error); goto out; } @@ -399,6 +355,33 @@ static void nbd_update_server_fd_handler(int fd) } } + +static SocketAddress *nbd_build_socket_address(const char *sockpath, + const char *bindto, + const char *port) +{ + SocketAddress *saddr; + + saddr = g_new0(SocketAddress, 1); + if (sockpath) { + saddr->kind = SOCKET_ADDRESS_KIND_UNIX; + saddr->q_unix = g_new0(UnixSocketAddress, 1); + saddr->q_unix->path = g_strdup(sockpath); + } else { + saddr->kind = SOCKET_ADDRESS_KIND_INET; + saddr->inet = g_new0(InetSocketAddress, 1); + saddr->inet->host = g_strdup(bindto); + if (port) { + saddr->inet->port = g_strdup(port); + } else { + saddr->inet->port = g_strdup_printf("%d", NBD_DEFAULT_PORT); + } + } + + return saddr; +} + + int main(int argc, char **argv) { BlockBackend *blk; @@ -407,8 +390,9 @@ int main(int argc, char **argv) uint32_t nbdflags = 0; bool disconnect = false; const char *bindto = "0.0.0.0"; + const char *port = NULL; + char *sockpath = NULL; char *device = NULL; - int port = NBD_DEFAULT_PORT; off_t fd_size; QemuOpts *sn_opts = NULL; const char *sn_id_or_name = NULL; @@ -441,7 +425,6 @@ int main(int argc, char **argv) }; int ch; int opt_ind = 0; - int li; char *end; int flags = BDRV_O_RDWR; int partition = -1; @@ -529,14 +512,7 @@ int main(int argc, char **argv) bindto = optarg; break; case 'p': - li = strtol(optarg, &end, 0); - if (*end) { - errx(EXIT_FAILURE, "Invalid port `%s'", optarg); - } - if (li < 1 || li > 65535) { - errx(EXIT_FAILURE, "Port out of range `%s'", optarg); - } - port = (uint16_t)li; + port = optarg; break; case 'o': dev_offset = strtoll (optarg, &end, 0); @@ -695,6 +671,8 @@ int main(int argc, char **argv) snprintf(sockpath, 128, SOCKET_PATH, basename(device)); } + saddr = nbd_build_socket_address(sockpath, bindto, port); + if (qemu_init_main_loop(&local_err)) { error_report_err(local_err); exit(EXIT_FAILURE); @@ -752,13 +730,9 @@ int main(int argc, char **argv) errx(EXIT_FAILURE, "%s", error_get_pretty(local_err)); } - if (sockpath) { - fd = unix_socket_incoming(sockpath); - } else { - fd = tcp_socket_incoming(bindto, port); - } - + fd = socket_listen(saddr, &local_err); if (fd < 0) { + error_report_err(local_err); return 1; } -- 2.4.3 From MAILER-DAEMON Wed Sep 16 10:02:49 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcDIP-0001m3-ML for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 10:02:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDIK-0001lB-9U for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:02:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcDIE-0000VK-Jt for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:02:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDIE-0000VE-E2; Wed, 16 Sep 2015 10:02:38 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 2F20A368E3; Wed, 16 Sep 2015 14:02:37 +0000 (UTC) Received: from [10.3.113.35] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GE2agi026957; Wed, 16 Sep 2015 10:02:36 -0400 To: "Daniel P. Berrange" , qemu-devel@nongnu.org References: <1442411543-28513-1-git-send-email-berrange@redhat.com> <1442411543-28513-2-git-send-email-berrange@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55F97678.1050201@redhat.com> Date: Wed, 16 Sep 2015 08:02:32 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442411543-28513-2-git-send-email-berrange@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uWcT2Am8j5vb1mQSmfgLlNa6i0D1XNG5p" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , Wen Congyang , qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v1 1/2] nbd: convert to use the QAPI SocketAddress object X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 14:02:48 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --uWcT2Am8j5vb1mQSmfgLlNa6i0D1XNG5p Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/16/2015 07:52 AM, Daniel P. Berrange wrote: > The nbd block driver currently uses a QemuOpts object > when setting up sockets. Switch it over to use the > QAPI SocketAddress object instead. >=20 > Signed-off-by: Daniel P. Berrange > --- > block/nbd.c | 69 +++++++++++++++++++++++++++++++++--------------------= -------- > 1 file changed, 37 insertions(+), 32 deletions(-) Reviewed-by: Eric Blake Wen - this patch will help in your efforts to expose NBD via blockdev-add QMP. > - if (!qemu_opt_get(s->socket_opts, "port")) { > - qemu_opt_set_number(s->socket_opts, "port", NBD_DEFAULT_PORT, > - &error_abort); > - } > + s->client.is_unix =3D saddr->kind =3D=3D SOCKET_ADDRESS_KIND_UNIX;= > =20 Minor conflict with my pending patch to rename the C representation of qapi unions to spell things with 'type': https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg02598.html but as that needs to be rebased once Markus' introspection lands, you don't have to wait for it. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --uWcT2Am8j5vb1mQSmfgLlNa6i0D1XNG5p Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV+XZ4AAoJEKeha0olJ0NqQDEIAJdJI3W7sTTzNNiBQZ85X7xo pMR1hUIC58IZLrelKAphyGov15o/V9iUsqsWp9dpyt67yYpCVAzO1peG3JguU/b7 0eI4snifqenkPw6Idg5y9F629XYS/y2OBtz8s9n8a2tliuEmIo2XTUSkKrrPYNbh aN7SkXN07LtN575i1U7hRquqDoFvExehu68bys+CjNtjcBAUqMWQI0hwibIr0rik mtGr/SUN9baf/ifEtzZjNkAe4Wj4itk7kC0j0ET/mhJaBYxUqnuRF7GsVJeHjj5B u8JjjIysgrKBV3K8LTGyvO9+4II8TeDY8dwi1DjG9Jj2PuB+slCcwy6kEuAIgB4= =af80 -----END PGP SIGNATURE----- --uWcT2Am8j5vb1mQSmfgLlNa6i0D1XNG5p-- From MAILER-DAEMON Wed Sep 16 10:08:44 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcDO8-0006Jc-BI for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 10:08:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDO5-0006JG-UO for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:08:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcDO1-0003PE-Tm for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:08:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDO1-0003P5-OL; Wed, 16 Sep 2015 10:08:37 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 421FEA89; Wed, 16 Sep 2015 14:08:37 +0000 (UTC) Received: from [10.3.113.35] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GE8apA024632; Wed, 16 Sep 2015 10:08:36 -0400 To: "Daniel P. Berrange" , qemu-devel@nongnu.org References: <1442411543-28513-1-git-send-email-berrange@redhat.com> <1442411543-28513-3-git-send-email-berrange@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55F977E3.2060807@redhat.com> Date: Wed, 16 Sep 2015 08:08:35 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442411543-28513-3-git-send-email-berrange@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="GTpccD6l2uB0kO7EDUOgVTK4PJlnCJPJa" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v1 2/2] qemu-nbd: convert to use the QAPI SocketAddress object X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 14:08:43 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --GTpccD6l2uB0kO7EDUOgVTK4PJlnCJPJa Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/16/2015 07:52 AM, Daniel P. Berrange wrote: > The qemu-nbd program currently uses a QemuOpts objects > when setting up sockets. Switch it over to use the > QAPI SocketAddress objects instead. >=20 > Signed-off-by: Daniel P. Berrange > --- > qemu-nbd.c | 102 +++++++++++++++++++++++------------------------------= -------- > 1 file changed, 38 insertions(+), 64 deletions(-) >=20 > +static SocketAddress *nbd_build_socket_address(const char *sockpath, > + const char *bindto, > + const char *port) > +{ > + SocketAddress *saddr; > + > + saddr =3D g_new0(SocketAddress, 1); > + if (sockpath) { > + saddr->kind =3D SOCKET_ADDRESS_KIND_UNIX; More minor conflicts with my qapi cleanups. Not a show-stopper. > + saddr->q_unix =3D g_new0(UnixSocketAddress, 1); > + saddr->q_unix->path =3D g_strdup(sockpath); > + } else { > + saddr->kind =3D SOCKET_ADDRESS_KIND_INET; > + saddr->inet =3D g_new0(InetSocketAddress, 1); > + saddr->inet->host =3D g_strdup(bindto); > + if (port) { > + saddr->inet->port =3D g_strdup(port); > + } else { > + saddr->inet->port =3D g_strdup_printf("%d", NBD_DEFAULT_PO= RT); The qapi type is gross for requiring port as a string. But we have plans to clean that up, not a showstopper for this patch. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --GTpccD6l2uB0kO7EDUOgVTK4PJlnCJPJa Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV+XfjAAoJEKeha0olJ0NqXGAIAKg1q/F0O5QH08KU6z6/wxkb 6qRJ+sgeM/+D+lN67kS/crUNE58kbqfnIwB65NYQUWEADGm/fbCny5gu5YtrhKZY +XSHmiFBs+Pi3K/pdMR4fGd8LKA43KCdK7FlV2Pk3UGA/qRHtkDjo73EKYYTDKjd xGUmbyJPpO/kziA/hF8WzJAEM1BNSUv9nJxPrqHdciiKENhzOA6JqlIwUgA/Xkf4 ZCdFyB4ha8xR8btiiaNbJ/ufEd8bCWUVvqCDbsU5qfL+9igJfLJKpC5KL95x5h2U CwulURBTGKn4hL6oz9j/buaFx43aFlMEeYJ40A63tQs+/+hGB63z1Gg5Wrm9igI= =yc/r -----END PGP SIGNATURE----- --GTpccD6l2uB0kO7EDUOgVTK4PJlnCJPJa-- From MAILER-DAEMON Wed Sep 16 10:11:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcDR5-000061-9M for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 10:11:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDQx-00004v-Qf for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:11:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcDQo-0005YK-4U for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:11:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54387) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDQn-0005YF-T3; Wed, 16 Sep 2015 10:11:30 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 794124092A; Wed, 16 Sep 2015 14:11:29 +0000 (UTC) Received: from scv.usersys.redhat.com (vpn-59-155.rdu2.redhat.com [10.10.59.155]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GEBSgJ026931; Wed, 16 Sep 2015 10:11:28 -0400 To: Laszlo Ersek , qemu-devel@nongnu.org References: <1442369846-31890-1-git-send-email-lersek@redhat.com> From: John Snow Message-ID: <55F97890.6080807@redhat.com> Date: Wed, 16 Sep 2015 10:11:28 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442369846-31890-1-git-send-email-lersek@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] hw/ide/ahci: advance IO buffer offset in multi-sector PIO transfer X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 14:11:45 -0000 On 09/15/2015 10:17 PM, Laszlo Ersek wrote: > The "MdeModulePkg/Bus/Ata/AtaAtapiPassThru" driver in edk2 submits a three > sector long PIO read, when booting off various Fedora installer ISOs in > UEFI mode. With DEBUG_IDE, DEBUG_IDE_ATAPI, DEBUG_AIO and DEBUG_AHCI > enabled, plus a > > DPRINTF(ad->port_no, "offset=%d\n", offset); > > at the beginning of ahci_populate_sglist(), we get the following debug > output: > >> fis: >> 00:27 80 a0 00 00 fe ff e0 00 00 00 00 00 00 00 00 >> 10:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >> 20:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >> 30:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >> 40:28 00 00 00 00 38 00 00 03 00 00 00 00 00 00 00 >> 50:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >> 60:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >> 70:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >> fis: >> 00:28 00 00 00 00 38 00 00 03 00 00 00 00 00 00 00 >> ide: CMD=a0 >> ATAPI limit=0xfffe packet: 28 00 00 00 00 38 00 00 03 00 00 00 >> read pio: LBA=56 nb_sectors=3 >> reply: tx_size=6144 elem_tx_size=0 index=2048 >> byte_count_limit=65534 >> ahci: ahci_populate_sglist: [0] offset=0 >> ahci: ahci_dma_prepare_buf: [0] len=0x800 >> ahci: ahci_start_transfer: [0] reading 2048 bytes on atapi w/ sglist >> reply: tx_size=4096 elem_tx_size=4096 index=2048 >> ahci: ahci_populate_sglist: [0] offset=0 >> ahci: ahci_dma_prepare_buf: [0] len=0x800 >> ahci: ahci_start_transfer: [0] reading 2048 bytes on atapi w/ sglist >> reply: tx_size=2048 elem_tx_size=2048 index=2048 >> ahci: ahci_populate_sglist: [0] offset=0 >> ahci: ahci_dma_prepare_buf: [0] len=0x800 >> ahci: ahci_start_transfer: [0] reading 2048 bytes on atapi w/ sglist >> reply: tx_size=0 elem_tx_size=0 index=2048 >> ahci: ahci_cmd_done: [0] cmd done >> [...] > > The following functions play recursive ping-pong, because > ide_atapi_cmd_reply_end() segments the request into individual 2KB > sectors: > > ide_transfer_start() <-----------------------+ > ahci_start_transfer() via funcptr | > | > ahci_dma_prepare_buf() | > ahci_populate_sglist() | > | > dma_buf_read() | > | > ahci_commit_buf() | > | > ide_atapi_cmd_reply_end() via funcptr | > ide_transfer_start() ------------------+ > > The ahci_populate_sglist() correctly sets up the scatter-gather list for > dma_buf_read(), based on the Physical Region Descriptors passed in by the > guest. However, the offset into that scatter-gather list remains constant > zero as ide_atapi_cmd_reply_end() wades through every sector of the three > sector long PIO transfer. > > The consequence is that the first 2KB of the guest buffer(s), speaking > "linearizedly", is repeatedly overwritten with the next CD-ROM sector. At > the end of the transfer, the sector last read is visible in the first 2KB > of the guest buffer(s), and the rest of the guest buffer(s) remains > unwritten. > > Looking at the DMA request path; especially comparing the context of > ahci_commit_buf() between its two callers ahci_dma_rw_buf() and > ahci_start_transfer(), it seems like the latter forgets to advance > "s->io_buffer_offset". > > Adding that increment enables the guest to receive valid data. > > Cc: John Snow > Cc: qemu-block@nongnu.org > Signed-off-by: Laszlo Ersek > --- > > Notes: > I spent the better half of the night on this bug, so please be gentle. > :) > Oh no :( > hw/ide/ahci.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c > index 44f6e27..b975c9f 100644 > --- a/hw/ide/ahci.c > +++ b/hw/ide/ahci.c > @@ -1291,6 +1291,8 @@ out: > /* Update number of transferred bytes, destroy sglist */ > ahci_commit_buf(dma, size); > > + s->io_buffer_offset += size; > + > s->end_transfer_func(s); > > if (!(s->status & DRQ_STAT)) { > Whoops, I think this does the same thing as: [Qemu-devel] [PATCH 1/1] ide: unify io_buffer_offset increments which I currently have staged in my IDE tree: https://github.com/jnsnow/qemu/commits/ide From MAILER-DAEMON Wed Sep 16 10:13:48 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcDT2-0001Gw-82 for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 10:13:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDSz-0001GZ-Vf for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:13:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcDSu-0006Cn-3i for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:13:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35069) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDSt-0006Ci-VA; Wed, 16 Sep 2015 10:13:40 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 8822F5369; Wed, 16 Sep 2015 14:13:39 +0000 (UTC) Received: from redhat.com (vpn1-5-41.ams2.redhat.com [10.36.5.41]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GEDZk6002639 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Sep 2015 10:13:38 -0400 Date: Wed, 16 Sep 2015 15:13:35 +0100 From: "Daniel P. Berrange" To: Eric Blake Message-ID: <20150916141335.GF21184@redhat.com> References: <1442411543-28513-1-git-send-email-berrange@redhat.com> <1442411543-28513-3-git-send-email-berrange@redhat.com> <55F977E3.2060807@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <55F977E3.2060807@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v1 2/2] qemu-nbd: convert to use the QAPI SocketAddress object X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 14:13:47 -0000 On Wed, Sep 16, 2015 at 08:08:35AM -0600, Eric Blake wrote: > On 09/16/2015 07:52 AM, Daniel P. Berrange wrote: > > The qemu-nbd program currently uses a QemuOpts objects > > when setting up sockets. Switch it over to use the > > QAPI SocketAddress objects instead. > > > > Signed-off-by: Daniel P. Berrange > > --- > > qemu-nbd.c | 102 +++++++++++++++++++++++-------------------------------------- > > 1 file changed, 38 insertions(+), 64 deletions(-) > > > > > +static SocketAddress *nbd_build_socket_address(const char *sockpath, > > + const char *bindto, > > + const char *port) > > +{ > > + SocketAddress *saddr; > > + > > + saddr = g_new0(SocketAddress, 1); > > + if (sockpath) { > > + saddr->kind = SOCKET_ADDRESS_KIND_UNIX; > > More minor conflicts with my qapi cleanups. Not a show-stopper. > > > + saddr->q_unix = g_new0(UnixSocketAddress, 1); > > + saddr->q_unix->path = g_strdup(sockpath); > > + } else { > > + saddr->kind = SOCKET_ADDRESS_KIND_INET; > > + saddr->inet = g_new0(InetSocketAddress, 1); > > + saddr->inet->host = g_strdup(bindto); > > + if (port) { > > + saddr->inet->port = g_strdup(port); > > + } else { > > + saddr->inet->port = g_strdup_printf("%d", NBD_DEFAULT_PORT); > > The qapi type is gross for requiring port as a string. But we have plans > to clean that up, not a showstopper for this patch. On the contrary - QAPI is correct in requiring this, as it lets you provide a service name (as defined in /etc/services) instead of a numeric port, and getaddrinfo() will look that up and convert to numeric format. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From MAILER-DAEMON Wed Sep 16 10:21:49 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcDan-0005A0-LE for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 10:21:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDal-00059n-Bu for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:21:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcDai-0002AU-7c for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:21:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDai-0002AM-2K; Wed, 16 Sep 2015 10:21:44 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 699F25C; Wed, 16 Sep 2015 14:21:43 +0000 (UTC) Received: from [10.36.112.66] (ovpn-112-66.ams2.redhat.com [10.36.112.66]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GELdCj009490 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 16 Sep 2015 10:21:41 -0400 To: "Daniel P. Berrange" , qemu-devel@nongnu.org References: <1442411543-28513-1-git-send-email-berrange@redhat.com> <1442411543-28513-2-git-send-email-berrange@redhat.com> From: Paolo Bonzini Message-ID: <55F97AF3.4060700@redhat.com> Date: Wed, 16 Sep 2015 16:21:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442411543-28513-2-git-send-email-berrange@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v1 1/2] nbd: convert to use the QAPI SocketAddress object X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 14:21:48 -0000 On 16/09/2015 15:52, Daniel P. Berrange wrote: > + saddr = nbd_config(s, options, &export, &local_err); You can use errp directly here. Otherwise looks fine. Paolo > + if (!saddr) { > error_propagate(errp, local_err); > return -EINVAL; > } From MAILER-DAEMON Wed Sep 16 10:23:49 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcDcj-0006AA-8n for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 10:23:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDch-0006A0-Ky for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:23:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcDce-0002gi-GL for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:23:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDce-0002gT-Bm; Wed, 16 Sep 2015 10:23:44 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 07CCD2F9; Wed, 16 Sep 2015 14:23:44 +0000 (UTC) Received: from [10.36.112.66] (ovpn-112-66.ams2.redhat.com [10.36.112.66]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GENeMe013158 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 16 Sep 2015 10:23:42 -0400 To: "Daniel P. Berrange" , Eric Blake References: <1442411543-28513-1-git-send-email-berrange@redhat.com> <1442411543-28513-3-git-send-email-berrange@redhat.com> <55F977E3.2060807@redhat.com> <20150916141335.GF21184@redhat.com> From: Paolo Bonzini Message-ID: <55F97B6B.7040504@redhat.com> Date: Wed, 16 Sep 2015 16:23:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150916141335.GF21184@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v1 2/2] qemu-nbd: convert to use the QAPI SocketAddress object X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 14:23:48 -0000 On 16/09/2015 16:13, Daniel P. Berrange wrote: > > The qapi type is gross for requiring port as a string. But we have plans > > to clean that up, not a showstopper for this patch. > > On the contrary - QAPI is correct in requiring this, as it lets you > provide a service name (as defined in /etc/services) instead of a > numeric port, and getaddrinfo() will look that up and convert to > numeric format. Was going to say the same. :) I'll fix up patch 1 and apply both. Paolo From MAILER-DAEMON Wed Sep 16 10:24:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcDdf-00076a-Qv for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 10:24:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDdd-00076L-85 for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:24:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcDdZ-0002yt-8R for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:24:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40248) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDdZ-0002yn-4C; Wed, 16 Sep 2015 10:24:41 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id C8D2EC0B918D; Wed, 16 Sep 2015 14:24:40 +0000 (UTC) Received: from [10.3.113.35] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GEOeia011266; Wed, 16 Sep 2015 10:24:40 -0400 To: "Daniel P. Berrange" References: <1442411543-28513-1-git-send-email-berrange@redhat.com> <1442411543-28513-3-git-send-email-berrange@redhat.com> <55F977E3.2060807@redhat.com> <20150916141335.GF21184@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55F97BA7.8080909@redhat.com> Date: Wed, 16 Sep 2015 08:24:39 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150916141335.GF21184@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Oa2LVvIgGMeUe51Ous4BatSdtSlIjFrSN" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v1 2/2] qemu-nbd: convert to use the QAPI SocketAddress object X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 14:24:46 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Oa2LVvIgGMeUe51Ous4BatSdtSlIjFrSN Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/16/2015 08:13 AM, Daniel P. Berrange wrote: > On Wed, Sep 16, 2015 at 08:08:35AM -0600, Eric Blake wrote: >> On 09/16/2015 07:52 AM, Daniel P. Berrange wrote: >>> The qemu-nbd program currently uses a QemuOpts objects >>> when setting up sockets. Switch it over to use the >>> QAPI SocketAddress objects instead. >>> >>> + if (port) { >>> + saddr->inet->port =3D g_strdup(port); >>> + } else { >>> + saddr->inet->port =3D g_strdup_printf("%d", NBD_DEFAULT_= PORT); >> >> The qapi type is gross for requiring port as a string. But we have pla= ns >> to clean that up, not a showstopper for this patch. >=20 > On the contrary - QAPI is correct in requiring this, as it lets you > provide a service name (as defined in /etc/services) instead of a > numeric port, and getaddrinfo() will look that up and convert to > numeric format. What it SHOULD be doing it taking an 'alternate' that allows both a string (for getaddrinfo lookup) and an int (for direct port usage), rather than overloading a string for both uses. But as I said, that should be a future cleanup, affecting more uses of the qapi type than just this patch. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Oa2LVvIgGMeUe51Ous4BatSdtSlIjFrSN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV+XunAAoJEKeha0olJ0NqyvcH/3Y6Hjrti96lD8HRMe19knNU 46WYw/hQcXV2VkHTtwCfVgzXA5oGELRsAcqoJLKSTmgGm8Mikg/o3H0ubbgTrIKd 0hwege8sKG3bhs5Tbq+v+LeS5fp22GMqhlBcClz34my+KlbO65xLOzijCNHyn07I JGoWl4HwDX4gv5PPnV4esuRYL3Z3Hl8PwsfhrXL3G6o8dD/2XWsfHq68WLnuWxAv Q5s5rerCHiEuu8G4sdVwwMa5O1SRw41uWD83ksn0HpFvCi+05oTaIGie6WcyMhJy qnsglibDIkXnCMF2LPx+3dDZEbWYFVFVtHN1O6Ce2rJChO7QU2AaUoo3ZjPX6Hg= =FYIG -----END PGP SIGNATURE----- --Oa2LVvIgGMeUe51Ous4BatSdtSlIjFrSN-- From MAILER-DAEMON Wed Sep 16 10:41:12 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcDtY-0005wb-LK for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 10:41:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDtV-0005vx-GW for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:41:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcDtR-0002G9-11 for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:41:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34331) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcDtQ-0002Fy-PJ; Wed, 16 Sep 2015 10:41:04 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 3095C91C18; Wed, 16 Sep 2015 14:41:04 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-38.rdu2.redhat.com [10.10.116.38]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GEf2MU025468; Wed, 16 Sep 2015 10:41:02 -0400 To: John Snow , qemu-devel@nongnu.org References: <1442369846-31890-1-git-send-email-lersek@redhat.com> <55F97890.6080807@redhat.com> From: Laszlo Ersek Message-ID: <55F97F7D.3050801@redhat.com> Date: Wed, 16 Sep 2015 16:41:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F97890.6080807@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] hw/ide/ahci: advance IO buffer offset in multi-sector PIO transfer X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 14:41:10 -0000 On 09/16/15 16:11, John Snow wrote: > > > On 09/15/2015 10:17 PM, Laszlo Ersek wrote: >> The "MdeModulePkg/Bus/Ata/AtaAtapiPassThru" driver in edk2 submits a three >> sector long PIO read, when booting off various Fedora installer ISOs in >> UEFI mode. With DEBUG_IDE, DEBUG_IDE_ATAPI, DEBUG_AIO and DEBUG_AHCI >> enabled, plus a >> >> DPRINTF(ad->port_no, "offset=%d\n", offset); >> >> at the beginning of ahci_populate_sglist(), we get the following debug >> output: >> >>> fis: >>> 00:27 80 a0 00 00 fe ff e0 00 00 00 00 00 00 00 00 >>> 10:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >>> 20:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >>> 30:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >>> 40:28 00 00 00 00 38 00 00 03 00 00 00 00 00 00 00 >>> 50:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >>> 60:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >>> 70:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >>> fis: >>> 00:28 00 00 00 00 38 00 00 03 00 00 00 00 00 00 00 >>> ide: CMD=a0 >>> ATAPI limit=0xfffe packet: 28 00 00 00 00 38 00 00 03 00 00 00 >>> read pio: LBA=56 nb_sectors=3 >>> reply: tx_size=6144 elem_tx_size=0 index=2048 >>> byte_count_limit=65534 >>> ahci: ahci_populate_sglist: [0] offset=0 >>> ahci: ahci_dma_prepare_buf: [0] len=0x800 >>> ahci: ahci_start_transfer: [0] reading 2048 bytes on atapi w/ sglist >>> reply: tx_size=4096 elem_tx_size=4096 index=2048 >>> ahci: ahci_populate_sglist: [0] offset=0 >>> ahci: ahci_dma_prepare_buf: [0] len=0x800 >>> ahci: ahci_start_transfer: [0] reading 2048 bytes on atapi w/ sglist >>> reply: tx_size=2048 elem_tx_size=2048 index=2048 >>> ahci: ahci_populate_sglist: [0] offset=0 >>> ahci: ahci_dma_prepare_buf: [0] len=0x800 >>> ahci: ahci_start_transfer: [0] reading 2048 bytes on atapi w/ sglist >>> reply: tx_size=0 elem_tx_size=0 index=2048 >>> ahci: ahci_cmd_done: [0] cmd done >>> [...] >> >> The following functions play recursive ping-pong, because >> ide_atapi_cmd_reply_end() segments the request into individual 2KB >> sectors: >> >> ide_transfer_start() <-----------------------+ >> ahci_start_transfer() via funcptr | >> | >> ahci_dma_prepare_buf() | >> ahci_populate_sglist() | >> | >> dma_buf_read() | >> | >> ahci_commit_buf() | >> | >> ide_atapi_cmd_reply_end() via funcptr | >> ide_transfer_start() ------------------+ >> >> The ahci_populate_sglist() correctly sets up the scatter-gather list for >> dma_buf_read(), based on the Physical Region Descriptors passed in by the >> guest. However, the offset into that scatter-gather list remains constant >> zero as ide_atapi_cmd_reply_end() wades through every sector of the three >> sector long PIO transfer. >> >> The consequence is that the first 2KB of the guest buffer(s), speaking >> "linearizedly", is repeatedly overwritten with the next CD-ROM sector. At >> the end of the transfer, the sector last read is visible in the first 2KB >> of the guest buffer(s), and the rest of the guest buffer(s) remains >> unwritten. >> >> Looking at the DMA request path; especially comparing the context of >> ahci_commit_buf() between its two callers ahci_dma_rw_buf() and >> ahci_start_transfer(), it seems like the latter forgets to advance >> "s->io_buffer_offset". >> >> Adding that increment enables the guest to receive valid data. >> >> Cc: John Snow >> Cc: qemu-block@nongnu.org >> Signed-off-by: Laszlo Ersek >> --- >> >> Notes: >> I spent the better half of the night on this bug, so please be gentle. >> :) >> > > Oh no :( > >> hw/ide/ahci.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c >> index 44f6e27..b975c9f 100644 >> --- a/hw/ide/ahci.c >> +++ b/hw/ide/ahci.c >> @@ -1291,6 +1291,8 @@ out: >> /* Update number of transferred bytes, destroy sglist */ >> ahci_commit_buf(dma, size); >> >> + s->io_buffer_offset += size; >> + >> s->end_transfer_func(s); >> >> if (!(s->status & DRQ_STAT)) { >> > > Whoops, I think this does the same thing as: > [Qemu-devel] [PATCH 1/1] ide: unify io_buffer_offset increments For that patch, currently with commit hash 38526a48bb40e3b2a045ca5a9418d1a9bfc2aeb2 in your tree: Tested-by: Laszlo Ersek Thanks! Laszlo > which I currently have staged in my IDE tree: > https://github.com/jnsnow/qemu/commits/ide > From MAILER-DAEMON Wed Sep 16 10:53:21 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcE5J-0006Ty-OH for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 10:53:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcE5I-0006R1-0Z for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:53:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcE5E-0008Mf-Px for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:53:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45767) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcE5E-0008Ma-J1; Wed, 16 Sep 2015 10:53:16 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 30207A2C00; Wed, 16 Sep 2015 14:53:16 +0000 (UTC) Received: from [10.3.113.35] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GErEYd001470; Wed, 16 Sep 2015 10:53:14 -0400 To: Markus Armbruster , Wen Congyang References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F776CC.3050601@cn.fujitsu.com> <87fv2g876a.fsf@blackfin.pond.sub.org> <55F7D06D.1080205@cn.fujitsu.com> <87mvwo3phm.fsf@blackfin.pond.sub.org> <55F9054F.1000001@cn.fujitsu.com> <87r3lyzsef.fsf@blackfin.pond.sub.org> <55F92745.6040904@cn.fujitsu.com> <87bnd2y5mn.fsf@blackfin.pond.sub.org> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55F98256.8080304@redhat.com> Date: Wed, 16 Sep 2015 08:53:10 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87bnd2y5mn.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Vr37Wlmg267SupXrOjpu245WrSOh6OfMU" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 14:53:21 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Vr37Wlmg267SupXrOjpu245WrSOh6OfMU Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/16/2015 05:18 AM, Markus Armbruster wrote: >>>>>>> Perhaps it could be as simple as >>>>>>> >>>>>>> { 'struct': 'BlockdevOptionsNBD', >>>>>>> 'data': { 'addr: 'SocketAddress', 'export': 'str' } } >>>>>> >>>>>> The problem is that: NBD doesn't use the fd. >>>>> >>>>> Is that fundamental, or just a matter of implementation? >>> >>> Question still open. >=20 > Question still open. Dan's patches didn't address it... > Long term, I'd like to see us get rid of the conversions between > QAPI-generated types and QDict / QemuOpts. >=20 > Short term, you need to co-evolve the QDict-based code such as > nbd_config() with the QAPI interfaces. =2E..but DO affect the short-term, by starting the conversion over to using the QAPI type more fully: https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg04383.html >=20 > Keeping the QAPI interface clean is more important than minimizing the > implementation work, because we're free to mess with the implementation= , > but releasing a QAPI interface makes it ABI, so we better get it right.= Especially once the QAPI interface is actually used by a QMP command (there are places where we are using qapi internally for ease in command line handling, but not exposing the structures through QMP yet). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Vr37Wlmg267SupXrOjpu245WrSOh6OfMU Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV+YJWAAoJEKeha0olJ0NqKbAH/2Y/hrB6wUnzi/KfZO02ydZX saVwbwU5YSWzMoss9qYVRSYRNZ26lQjzc+tkUJ6O5BH/4r8isnoc+Yz8hQU2n7JJ LnSPKEEMsfa/V/8wzQ7ccGdpbDECLxsZGtk1bGiTsx6FlBXpDY/nWUgkr4Z81qHU BDRKLNSVopFCQCpzWELpFs2I02IiJ28VO055UVf6vPXte6QQ5HUv4l3V1XfsP4Ha V8wu6UgYmcjFJMnwZ+yzZM31qI5R7dS+hlooZBMptymZWLei2xKM2XQNobLk2Og2 4A0o0e4cLpPVzpN1s3STCO40fvwuPGt97PPI3zaapJBUHriz4n6eu4dpStRjlAc= =MuMl -----END PGP SIGNATURE----- --Vr37Wlmg267SupXrOjpu245WrSOh6OfMU-- From MAILER-DAEMON Wed Sep 16 10:55:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcE79-00017h-4e for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 10:55:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcE73-0000xI-W7 for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:55:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcE6y-0000Qy-19 for qemu-block@nongnu.org; Wed, 16 Sep 2015 10:55:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcE6x-0000Pe-HZ; Wed, 16 Sep 2015 10:55:03 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id A59808EA26; Wed, 16 Sep 2015 14:55:02 +0000 (UTC) Received: from [10.3.113.35] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GEt17M028948; Wed, 16 Sep 2015 10:55:01 -0400 To: Wen Congyang , Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F78059.4030309@cn.fujitsu.com> <55F78225.404@cn.fujitsu.com> <55F794A4.5060903@redhat.com> <55F7975B.4050405@cn.fujitsu.com> <55F818F1.9070201@redhat.com> <55F91612.6010300@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55F982C4.7080101@redhat.com> Date: Wed, 16 Sep 2015 08:55:00 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F91612.6010300@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="HvL20mlmLCSSgoitTQP6S2wNa8ATt0xxI" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 14:55:14 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --HvL20mlmLCSSgoitTQP6S2wNa8ATt0xxI Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/16/2015 01:11 AM, Wen Congyang wrote: >>>> Possible workaround in the meantime - instead of trying to go with a= >>>> nice flat union (where all QMP keys are in the same {} level), we ca= n >>>> use nesting (structs that add another {} to include the unions). >>> >>> How to include the unions to a structs? Use 'base'? >> >> Conceptually, by adding a layer of nesting. On the wire, instead of: >> >> { "switch1":"value", "switch2":"value", "body2":"blah" } >> >> you would instead have: >> >> { "switch1":"value", "data": { "switch2":"value", "body2":"blah" } } >> >> Anywhere in qapi that you try to have: >> { 'union': ..., 'data':{'switch1':'Union'}} >> >> you instead create a wrapper type: >> { 'struct':'Wrapper', 'data':{'data':'Union'}} >> { 'union': ..., 'data':{'switch1':'Wrapper'}} >=20 > If so, the option is "data.switch1" not "switch1" >=20 >> >> >> What I don't know is whether the extra QMP nesting makes it easier or >> harder to support the existing NBD command line options, and it would >=20 > Yes, it is harder to support it. All the more reason to push the qapi improvements through, so that qapi can expose a flat union and not make the command line have to go through ugly nesting. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --HvL20mlmLCSSgoitTQP6S2wNa8ATt0xxI Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV+YLEAAoJEKeha0olJ0NqubYH/3+MRMbNNN03x7sDge+ceqor 79KvNS20bUXEXophQSzD21/Ll2ngAE9xfrSe3HfKsM3DV/duERnsooI5nr1UcKZD X/87M2IwK8ckxz6WyB8rPBqfrbCKxwWrTttXuuwVIj9/QojEe14OAI/mQG0IRbGz HoviJDCDfbELD9fGpr8FGQAKjl0Ko5W0NTP/qOaUKVUUSKjRU9OgoHK2zSOBDUQy 6qga0BDec7cD7NSqbb6Tlp9UNfq4UYTFItx0zX3LFa7AHPv4DMwARrHXGa1fPMqv URBzrRKVGdT9KOqJ8qm7kdQZCBglHQ/4WESxhb1S9ZJ9Z9cRyMxEUutiYN8S2H8= =mH9g -----END PGP SIGNATURE----- --HvL20mlmLCSSgoitTQP6S2wNa8ATt0xxI-- From MAILER-DAEMON Wed Sep 16 11:10:07 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcELX-0006jS-86 for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 11:10:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcELR-0006c7-Il for qemu-block@nongnu.org; Wed, 16 Sep 2015 11:10:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcELO-00078o-9J for qemu-block@nongnu.org; Wed, 16 Sep 2015 11:10:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40392) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcELN-00078i-SR; Wed, 16 Sep 2015 11:09:58 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 775D78EA2F; Wed, 16 Sep 2015 15:09:57 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GF9tLN018613 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 16 Sep 2015 11:09:56 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0375A303F90D; Wed, 16 Sep 2015 17:09:54 +0200 (CEST) From: Markus Armbruster To: John Snow References: <1442253685-23349-1-git-send-email-jsnow@redhat.com> <1442253685-23349-2-git-send-email-jsnow@redhat.com> <87twqw6r8u.fsf@blackfin.pond.sub.org> <55F83E96.8050006@redhat.com> Date: Wed, 16 Sep 2015 17:09:54 +0200 In-Reply-To: <55F83E96.8050006@redhat.com> (John Snow's message of "Tue, 15 Sep 2015 11:51:50 -0400") Message-ID: <87y4g6o0xp.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/1] atapi: abort transfers with 0 byte limits X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 15:10:06 -0000 John Snow writes: > On 09/15/2015 04:06 AM, Markus Armbruster wrote: >> John Snow writes: >> >>> We're supposed to abort on transfers like this, unless we fill >>> Word 125 of our IDENTIFY data with a default transfer size, which >>> we don't currently do. >>> >>> This is an ATA error, not a SCSI/ATAPI one. >>> See ATA8-ACS3 sections 7.17.6.49 or 7.21.5. >> >> Reading... yes, that's what the spec says. >> > > Yep, we're in a weird no man's land between IDE and SCSI here. We need > the ATAPI device to decipher the packet, but we need the IDE device to > abort. > >>> If we don't do this, QEMU will loop forever trying to transfer >>> zero bytes, which isn't particularly useful. >> >> Out of curiosity: which loop? >> > > ide_atapi_cmd_reply_end callback loop -- it can compute the BCL as zero > and it very busily loops transmitting 0 bytes each iteration. Should we assert "making progress" there? >>> Signed-off-by: John Snow >>> --- >>> hw/ide/atapi.c | 32 +++++++++++++++++++++++++++----- >>> hw/ide/core.c | 2 +- >>> hw/ide/internal.h | 1 + >>> 3 files changed, 29 insertions(+), 6 deletions(-) >>> >>> diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c >>> index 79dd167..747f466 100644 >>> --- a/hw/ide/atapi.c >>> +++ b/hw/ide/atapi.c >>> @@ -1169,20 +1169,28 @@ enum { >>> * 4.1.8) >>> */ >>> CHECK_READY = 0x02, >>> + >>> + /* >>> + * Commands flagged with NONDATA do not in any circumstances return >>> + * any data via ide_atapi_cmd_reply. These commands are exempt from >>> + * the normal byte_count_limit constraints. >>> + * See ATA8-ACS3 "7.21.5 Byte Count Limit" >> >> Aside: that section is bizarre even for ATA. >> >> Missing piece: what tells you which commands are to be flagged NONDATA? >> > > They do not invoke ide_atapi_cmd_reply. This is not an ATA designation, > just a practical flag to classify our handlers. I went through each > function to check manually. Ah, got it. >>> + */ >>> + NONDATA = 0x04, >>> }; >>> >>> static const struct { >>> void (*handler)(IDEState *s, uint8_t *buf); >>> int flags; >>> } atapi_cmd_table[0x100] = { >>> - [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY }, >>> + [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY | NONDATA }, >>> [ 0x03 ] = { cmd_request_sense, ALLOW_UA }, >>> [ 0x12 ] = { cmd_inquiry, ALLOW_UA }, >>> - [ 0x1b ] = { cmd_start_stop_unit, 0 }, /* [1] */ >>> - [ 0x1e ] = { cmd_prevent_allow_medium_removal, 0 }, >>> + [ 0x1b ] = { cmd_start_stop_unit, NONDATA }, /* [1] */ >>> + [ 0x1e ] = { cmd_prevent_allow_medium_removal, NONDATA }, >>> [ 0x25 ] = { cmd_read_cdvd_capacity, CHECK_READY }, >>> [ 0x28 ] = { cmd_read, /* (10) */ CHECK_READY }, >>> - [ 0x2b ] = { cmd_seek, CHECK_READY }, >>> + [ 0x2b ] = { cmd_seek, CHECK_READY | NONDATA }, >>> [ 0x43 ] = { cmd_read_toc_pma_atip, CHECK_READY }, >>> [ 0x46 ] = { cmd_get_configuration, ALLOW_UA }, >>> [ 0x4a ] = { cmd_get_event_status_notification, ALLOW_UA }, >>> @@ -1190,7 +1198,7 @@ static const struct { >>> [ 0x5a ] = { cmd_mode_sense, /* (10) */ 0 }, >>> [ 0xa8 ] = { cmd_read, /* (12) */ CHECK_READY }, >>> [ 0xad ] = { cmd_read_dvd_structure, CHECK_READY }, >>> - [ 0xbb ] = { cmd_set_speed, 0 }, >>> + [ 0xbb ] = { cmd_set_speed, NONDATA }, >>> [ 0xbd ] = { cmd_mechanism_status, 0 }, >>> [ 0xbe ] = { cmd_read_cd, CHECK_READY }, >>> /* [1] handler detects and reports not ready condition itself */ >>> @@ -1251,6 +1259,20 @@ void ide_atapi_cmd(IDEState *s) >>> return; >>> } >>> >>> + /* Nondata commands permit the byte_count_limit to be 0. >>> + * If this is a data-transferring PIO command and BCL is 0, >>> + * we abort at the /ATA/ level, not the ATAPI level. >>> + * See ATA8 ACS3 section 7.17.6.49 and 7.21.5 */ >>> + if (!(atapi_cmd_table[s->io_buffer[0]].flags & NONDATA)) { >>> + /* TODO: Check IDENTIFY data word 125 for default BCL (currently 0) */ >>> + uint16_t byte_count_limit = s->lcyl | (s->hcyl << 8); >> >> You might want to wrap s->lcyl | (s->hcyl << 8) in a helper function >> some day. Not in this patch, though. >> >>> + if (!(byte_count_limit || s->atapi_dma)) { >>> + /* TODO: Move abort back into core.c and make static inline again >>> */ >> >> Not sure about the inline part, but that's not this patch's to judge. >> > > I basically meant, "The way it was." Ideally this function will have a > return mechanism to the core layer, but that groundwork isn't there > right now, because ide_exec_cmd is not (guaranteed to be) an ancestor in > the callchain here. > > This usually gets invoked as a response to an ioport write instead, and > there isn't really any command life cycle code there yet. > >>> + ide_abort_command(s); >>> + return; >>> + } >>> + } >>> + >> >> Let's see whether I can slash through the negations here... >> >> This is for a non-NONDATA command (outer conditional). In other words, >> we're expecting data. >> > > Yes. Sorry for the negations, but it was easier to classify things as > NONDATA (the exception) than DATA (what most commands do.) Less churn, too. >> Unless either byte_count_limit is non-zero or atapi_dma is true (inner >> conditional), we abort the command. In other words: if byte_count_limit >> is non-zero, we'll be PIO-ing some data, so we're good. If atapi_dma is >> true, we'll be DMA-ing some data, so we're good. Else, no data will be >> coming, contradicting our expectation. The command is invalid, and we >> abort. >> >> Correct? >> > > I don't think I understand "Else, no data will be coming, contradicting > our expectation. The command is invalid, and we abort," though the rest > of this reads correctly to me. Let me try again. if byte_count_limit is non-zero, we'll be PIO-ing some data, so we're good else if atapi_dma is true, we'll be DMA-ing some data, so we're good else we won't transfer any data only commands with NONDATA set may do that but NONDATA isn't set! command is invalid, abort it > If a command has not set the BCL or the DMA flag, but NONDATA is absent > -- we /are/ expecting data, but the guest has neglected to tell us how > much data to send per "DRQ loop." The spec says we should abort in this > case. (And for infinite loop problems, QEMU should oblige the spec.) > > So the logic is this: > > if (data_command) { > if (!dma) { > if (!bcl) { > /* problem */ > } > } > } > > or: > > if (!nondata && !(bcl || dma)) { /* problem */ } > > > If this is a DATA command: > - If it's DMA, we're fine. DMA commands don't use the BCL. > - If BCL is non-zero, we're fine for either DMA or PIO cases. > - If BCL is zero AND dma is false, we have a problem. Abort. Sounds like I got it. > It might be easier to read as (!bcl && !dma), I guess, but for some > reason I felt compelled to write it as (!(bcl || dma)). I think I'd write !bcl && !dma. Your choice. >>> /* Execute the command */ >>> if (atapi_cmd_table[s->io_buffer[0]].handler) { >>> atapi_cmd_table[s->io_buffer[0]].handler(s, buf); >>> diff --git a/hw/ide/core.c b/hw/ide/core.c >>> index 50449ca..28cf535 100644 >>> --- a/hw/ide/core.c >>> +++ b/hw/ide/core.c >>> @@ -457,7 +457,7 @@ BlockAIOCB *ide_issue_trim(BlockBackend *blk, >>> return &iocb->common; >>> } >>> >>> -static inline void ide_abort_command(IDEState *s) >>> +void ide_abort_command(IDEState *s) >>> { >>> ide_transfer_stop(s); >>> s->status = READY_STAT | ERR_STAT; >>> diff --git a/hw/ide/internal.h b/hw/ide/internal.h >>> index 30fdcbc..40e1aa4 100644 >>> --- a/hw/ide/internal.h >>> +++ b/hw/ide/internal.h >>> @@ -537,6 +537,7 @@ void ide_set_sector(IDEState *s, int64_t sector_num); >>> >>> void ide_start_dma(IDEState *s, BlockCompletionFunc *cb); >>> void ide_dma_error(IDEState *s); >>> +void ide_abort_command(IDEState *s); >>> >>> void ide_atapi_cmd_ok(IDEState *s); >>> void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc); > > HTH, > --js Assuming I indeed got it: Reviewed-by: Markus Armbruster From MAILER-DAEMON Wed Sep 16 11:24:17 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcEZF-0004UQ-NB for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 11:24:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcEZ9-0004L4-SY for qemu-block@nongnu.org; Wed, 16 Sep 2015 11:24:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcEZ4-0004nk-UJ for qemu-block@nongnu.org; Wed, 16 Sep 2015 11:24:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcEZ4-0004nf-L2; Wed, 16 Sep 2015 11:24:06 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 0033D8CF6F; Wed, 16 Sep 2015 15:24:05 +0000 (UTC) Received: from scv.usersys.redhat.com (vpn-58-21.rdu2.redhat.com [10.10.58.21]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GFO4IS028064; Wed, 16 Sep 2015 11:24:05 -0400 To: Markus Armbruster References: <1442253685-23349-1-git-send-email-jsnow@redhat.com> <1442253685-23349-2-git-send-email-jsnow@redhat.com> <87twqw6r8u.fsf@blackfin.pond.sub.org> <55F83E96.8050006@redhat.com> <87y4g6o0xp.fsf@blackfin.pond.sub.org> From: John Snow Message-ID: <55F98994.4010200@redhat.com> Date: Wed, 16 Sep 2015 11:24:04 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87y4g6o0xp.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/1] atapi: abort transfers with 0 byte limits X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 15:24:17 -0000 On 09/16/2015 11:09 AM, Markus Armbruster wrote: > John Snow writes: > >> On 09/15/2015 04:06 AM, Markus Armbruster wrote: >>> John Snow writes: >>> >>>> We're supposed to abort on transfers like this, unless we fill >>>> Word 125 of our IDENTIFY data with a default transfer size, which >>>> we don't currently do. >>>> >>>> This is an ATA error, not a SCSI/ATAPI one. >>>> See ATA8-ACS3 sections 7.17.6.49 or 7.21.5. >>> >>> Reading... yes, that's what the spec says. >>> >> >> Yep, we're in a weird no man's land between IDE and SCSI here. We need >> the ATAPI device to decipher the packet, but we need the IDE device to >> abort. >> >>>> If we don't do this, QEMU will loop forever trying to transfer >>>> zero bytes, which isn't particularly useful. >>> >>> Out of curiosity: which loop? >>> >> >> ide_atapi_cmd_reply_end callback loop -- it can compute the BCL as zero >> and it very busily loops transmitting 0 bytes each iteration. > > Should we assert "making progress" there? > Yes, though I think I'm more eager to just rewrite that mother of all callback loops. >>>> Signed-off-by: John Snow >>>> --- >>>> hw/ide/atapi.c | 32 +++++++++++++++++++++++++++----- >>>> hw/ide/core.c | 2 +- >>>> hw/ide/internal.h | 1 + >>>> 3 files changed, 29 insertions(+), 6 deletions(-) >>>> >>>> diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c >>>> index 79dd167..747f466 100644 >>>> --- a/hw/ide/atapi.c >>>> +++ b/hw/ide/atapi.c >>>> @@ -1169,20 +1169,28 @@ enum { >>>> * 4.1.8) >>>> */ >>>> CHECK_READY = 0x02, >>>> + >>>> + /* >>>> + * Commands flagged with NONDATA do not in any circumstances return >>>> + * any data via ide_atapi_cmd_reply. These commands are exempt from >>>> + * the normal byte_count_limit constraints. >>>> + * See ATA8-ACS3 "7.21.5 Byte Count Limit" >>> >>> Aside: that section is bizarre even for ATA. >>> >>> Missing piece: what tells you which commands are to be flagged NONDATA? >>> >> >> They do not invoke ide_atapi_cmd_reply. This is not an ATA designation, >> just a practical flag to classify our handlers. I went through each >> function to check manually. > > Ah, got it. > >>>> + */ >>>> + NONDATA = 0x04, >>>> }; >>>> >>>> static const struct { >>>> void (*handler)(IDEState *s, uint8_t *buf); >>>> int flags; >>>> } atapi_cmd_table[0x100] = { >>>> - [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY }, >>>> + [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY | NONDATA }, >>>> [ 0x03 ] = { cmd_request_sense, ALLOW_UA }, >>>> [ 0x12 ] = { cmd_inquiry, ALLOW_UA }, >>>> - [ 0x1b ] = { cmd_start_stop_unit, 0 }, /* [1] */ >>>> - [ 0x1e ] = { cmd_prevent_allow_medium_removal, 0 }, >>>> + [ 0x1b ] = { cmd_start_stop_unit, NONDATA }, /* [1] */ >>>> + [ 0x1e ] = { cmd_prevent_allow_medium_removal, NONDATA }, >>>> [ 0x25 ] = { cmd_read_cdvd_capacity, CHECK_READY }, >>>> [ 0x28 ] = { cmd_read, /* (10) */ CHECK_READY }, >>>> - [ 0x2b ] = { cmd_seek, CHECK_READY }, >>>> + [ 0x2b ] = { cmd_seek, CHECK_READY | NONDATA }, >>>> [ 0x43 ] = { cmd_read_toc_pma_atip, CHECK_READY }, >>>> [ 0x46 ] = { cmd_get_configuration, ALLOW_UA }, >>>> [ 0x4a ] = { cmd_get_event_status_notification, ALLOW_UA }, >>>> @@ -1190,7 +1198,7 @@ static const struct { >>>> [ 0x5a ] = { cmd_mode_sense, /* (10) */ 0 }, >>>> [ 0xa8 ] = { cmd_read, /* (12) */ CHECK_READY }, >>>> [ 0xad ] = { cmd_read_dvd_structure, CHECK_READY }, >>>> - [ 0xbb ] = { cmd_set_speed, 0 }, >>>> + [ 0xbb ] = { cmd_set_speed, NONDATA }, >>>> [ 0xbd ] = { cmd_mechanism_status, 0 }, >>>> [ 0xbe ] = { cmd_read_cd, CHECK_READY }, >>>> /* [1] handler detects and reports not ready condition itself */ >>>> @@ -1251,6 +1259,20 @@ void ide_atapi_cmd(IDEState *s) >>>> return; >>>> } >>>> >>>> + /* Nondata commands permit the byte_count_limit to be 0. >>>> + * If this is a data-transferring PIO command and BCL is 0, >>>> + * we abort at the /ATA/ level, not the ATAPI level. >>>> + * See ATA8 ACS3 section 7.17.6.49 and 7.21.5 */ >>>> + if (!(atapi_cmd_table[s->io_buffer[0]].flags & NONDATA)) { >>>> + /* TODO: Check IDENTIFY data word 125 for default BCL (currently 0) */ >>>> + uint16_t byte_count_limit = s->lcyl | (s->hcyl << 8); >>> >>> You might want to wrap s->lcyl | (s->hcyl << 8) in a helper function >>> some day. Not in this patch, though. >>> >>>> + if (!(byte_count_limit || s->atapi_dma)) { >>>> + /* TODO: Move abort back into core.c and make static inline again >>>> */ >>> >>> Not sure about the inline part, but that's not this patch's to judge. >>> >> >> I basically meant, "The way it was." Ideally this function will have a >> return mechanism to the core layer, but that groundwork isn't there >> right now, because ide_exec_cmd is not (guaranteed to be) an ancestor in >> the callchain here. >> >> This usually gets invoked as a response to an ioport write instead, and >> there isn't really any command life cycle code there yet. >> >>>> + ide_abort_command(s); >>>> + return; >>>> + } >>>> + } >>>> + >>> >>> Let's see whether I can slash through the negations here... >>> >>> This is for a non-NONDATA command (outer conditional). In other words, >>> we're expecting data. >>> >> >> Yes. Sorry for the negations, but it was easier to classify things as >> NONDATA (the exception) than DATA (what most commands do.) > > Less churn, too. > >>> Unless either byte_count_limit is non-zero or atapi_dma is true (inner >>> conditional), we abort the command. In other words: if byte_count_limit >>> is non-zero, we'll be PIO-ing some data, so we're good. If atapi_dma is >>> true, we'll be DMA-ing some data, so we're good. Else, no data will be >>> coming, contradicting our expectation. The command is invalid, and we >>> abort. >>> >>> Correct? >>> >> >> I don't think I understand "Else, no data will be coming, contradicting >> our expectation. The command is invalid, and we abort," though the rest >> of this reads correctly to me. > > Let me try again. > > if byte_count_limit is non-zero, > we'll be PIO-ing some data, so we're good > else if atapi_dma is true, > we'll be DMA-ing some data, so we're good > else > we won't transfer any data > only commands with NONDATA set may do that > but NONDATA isn't set! > command is invalid, abort it > I understand your perspective now. From the perspective of well-formed commands, the only possible option if BCL is zero and atapi_dma is false is that this *must* be a NONDATA command [if it is well-formed]. If that isn't true, the command is not well formed. Your interpretation was correct. >> If a command has not set the BCL or the DMA flag, but NONDATA is absent >> -- we /are/ expecting data, but the guest has neglected to tell us how >> much data to send per "DRQ loop." The spec says we should abort in this >> case. (And for infinite loop problems, QEMU should oblige the spec.) >> >> So the logic is this: >> >> if (data_command) { >> if (!dma) { >> if (!bcl) { >> /* problem */ >> } >> } >> } >> >> or: >> >> if (!nondata && !(bcl || dma)) { /* problem */ } >> >> >> If this is a DATA command: >> - If it's DMA, we're fine. DMA commands don't use the BCL. >> - If BCL is non-zero, we're fine for either DMA or PIO cases. >> - If BCL is zero AND dma is false, we have a problem. Abort. > > Sounds like I got it. > >> It might be easier to read as (!bcl && !dma), I guess, but for some >> reason I felt compelled to write it as (!(bcl || dma)). > > I think I'd write !bcl && !dma. Your choice. > >>>> /* Execute the command */ >>>> if (atapi_cmd_table[s->io_buffer[0]].handler) { >>>> atapi_cmd_table[s->io_buffer[0]].handler(s, buf); >>>> diff --git a/hw/ide/core.c b/hw/ide/core.c >>>> index 50449ca..28cf535 100644 >>>> --- a/hw/ide/core.c >>>> +++ b/hw/ide/core.c >>>> @@ -457,7 +457,7 @@ BlockAIOCB *ide_issue_trim(BlockBackend *blk, >>>> return &iocb->common; >>>> } >>>> >>>> -static inline void ide_abort_command(IDEState *s) >>>> +void ide_abort_command(IDEState *s) >>>> { >>>> ide_transfer_stop(s); >>>> s->status = READY_STAT | ERR_STAT; >>>> diff --git a/hw/ide/internal.h b/hw/ide/internal.h >>>> index 30fdcbc..40e1aa4 100644 >>>> --- a/hw/ide/internal.h >>>> +++ b/hw/ide/internal.h >>>> @@ -537,6 +537,7 @@ void ide_set_sector(IDEState *s, int64_t sector_num); >>>> >>>> void ide_start_dma(IDEState *s, BlockCompletionFunc *cb); >>>> void ide_dma_error(IDEState *s); >>>> +void ide_abort_command(IDEState *s); >>>> >>>> void ide_atapi_cmd_ok(IDEState *s); >>>> void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc); >> >> HTH, >> --js > > Assuming I indeed got it: > Reviewed-by: Markus Armbruster > Indeed. Thank you, Markus! --js From MAILER-DAEMON Wed Sep 16 11:36:39 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcElD-0006ou-GS for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 11:36:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcElA-0006o1-1K for qemu-block@nongnu.org; Wed, 16 Sep 2015 11:36:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcEl5-0002JL-VE for qemu-block@nongnu.org; Wed, 16 Sep 2015 11:36:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41062) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcEl5-0002Iw-KR; Wed, 16 Sep 2015 11:36:31 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 3ED19461E3; Wed, 16 Sep 2015 15:36:31 +0000 (UTC) Received: from scv.usersys.redhat.com (vpn-58-21.rdu2.redhat.com [10.10.58.21]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GFaU1Q006299; Wed, 16 Sep 2015 11:36:30 -0400 To: Markus Armbruster References: <1442253685-23349-1-git-send-email-jsnow@redhat.com> <1442253685-23349-2-git-send-email-jsnow@redhat.com> <87twqw6r8u.fsf@blackfin.pond.sub.org> <55F83E96.8050006@redhat.com> <87y4g6o0xp.fsf@blackfin.pond.sub.org> From: John Snow Message-ID: <55F98C7E.9080704@redhat.com> Date: Wed, 16 Sep 2015 11:36:30 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87y4g6o0xp.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/1] atapi: abort transfers with 0 byte limits X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 15:36:37 -0000 On 09/16/2015 11:09 AM, Markus Armbruster wrote: > John Snow writes: > >> On 09/15/2015 04:06 AM, Markus Armbruster wrote: >>> John Snow writes: >>> >>>> We're supposed to abort on transfers like this, unless we fill >>>> Word 125 of our IDENTIFY data with a default transfer size, which >>>> we don't currently do. >>>> >>>> This is an ATA error, not a SCSI/ATAPI one. >>>> See ATA8-ACS3 sections 7.17.6.49 or 7.21.5. >>> >>> Reading... yes, that's what the spec says. >>> >> >> Yep, we're in a weird no man's land between IDE and SCSI here. We need >> the ATAPI device to decipher the packet, but we need the IDE device to >> abort. >> >>>> If we don't do this, QEMU will loop forever trying to transfer >>>> zero bytes, which isn't particularly useful. >>> >>> Out of curiosity: which loop? >>> >> >> ide_atapi_cmd_reply_end callback loop -- it can compute the BCL as zero >> and it very busily loops transmitting 0 bytes each iteration. > > Should we assert "making progress" there? > >>>> Signed-off-by: John Snow >>>> --- >>>> hw/ide/atapi.c | 32 +++++++++++++++++++++++++++----- >>>> hw/ide/core.c | 2 +- >>>> hw/ide/internal.h | 1 + >>>> 3 files changed, 29 insertions(+), 6 deletions(-) >>>> >>>> diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c >>>> index 79dd167..747f466 100644 >>>> --- a/hw/ide/atapi.c >>>> +++ b/hw/ide/atapi.c >>>> @@ -1169,20 +1169,28 @@ enum { >>>> * 4.1.8) >>>> */ >>>> CHECK_READY = 0x02, >>>> + >>>> + /* >>>> + * Commands flagged with NONDATA do not in any circumstances return >>>> + * any data via ide_atapi_cmd_reply. These commands are exempt from >>>> + * the normal byte_count_limit constraints. >>>> + * See ATA8-ACS3 "7.21.5 Byte Count Limit" >>> >>> Aside: that section is bizarre even for ATA. >>> >>> Missing piece: what tells you which commands are to be flagged NONDATA? >>> >> >> They do not invoke ide_atapi_cmd_reply. This is not an ATA designation, >> just a practical flag to classify our handlers. I went through each >> function to check manually. > > Ah, got it. > >>>> + */ >>>> + NONDATA = 0x04, >>>> }; >>>> >>>> static const struct { >>>> void (*handler)(IDEState *s, uint8_t *buf); >>>> int flags; >>>> } atapi_cmd_table[0x100] = { >>>> - [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY }, >>>> + [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY | NONDATA }, >>>> [ 0x03 ] = { cmd_request_sense, ALLOW_UA }, >>>> [ 0x12 ] = { cmd_inquiry, ALLOW_UA }, >>>> - [ 0x1b ] = { cmd_start_stop_unit, 0 }, /* [1] */ >>>> - [ 0x1e ] = { cmd_prevent_allow_medium_removal, 0 }, >>>> + [ 0x1b ] = { cmd_start_stop_unit, NONDATA }, /* [1] */ >>>> + [ 0x1e ] = { cmd_prevent_allow_medium_removal, NONDATA }, >>>> [ 0x25 ] = { cmd_read_cdvd_capacity, CHECK_READY }, >>>> [ 0x28 ] = { cmd_read, /* (10) */ CHECK_READY }, >>>> - [ 0x2b ] = { cmd_seek, CHECK_READY }, >>>> + [ 0x2b ] = { cmd_seek, CHECK_READY | NONDATA }, >>>> [ 0x43 ] = { cmd_read_toc_pma_atip, CHECK_READY }, >>>> [ 0x46 ] = { cmd_get_configuration, ALLOW_UA }, >>>> [ 0x4a ] = { cmd_get_event_status_notification, ALLOW_UA }, >>>> @@ -1190,7 +1198,7 @@ static const struct { >>>> [ 0x5a ] = { cmd_mode_sense, /* (10) */ 0 }, >>>> [ 0xa8 ] = { cmd_read, /* (12) */ CHECK_READY }, >>>> [ 0xad ] = { cmd_read_dvd_structure, CHECK_READY }, >>>> - [ 0xbb ] = { cmd_set_speed, 0 }, >>>> + [ 0xbb ] = { cmd_set_speed, NONDATA }, >>>> [ 0xbd ] = { cmd_mechanism_status, 0 }, >>>> [ 0xbe ] = { cmd_read_cd, CHECK_READY }, >>>> /* [1] handler detects and reports not ready condition itself */ >>>> @@ -1251,6 +1259,20 @@ void ide_atapi_cmd(IDEState *s) >>>> return; >>>> } >>>> >>>> + /* Nondata commands permit the byte_count_limit to be 0. >>>> + * If this is a data-transferring PIO command and BCL is 0, >>>> + * we abort at the /ATA/ level, not the ATAPI level. >>>> + * See ATA8 ACS3 section 7.17.6.49 and 7.21.5 */ >>>> + if (!(atapi_cmd_table[s->io_buffer[0]].flags & NONDATA)) { >>>> + /* TODO: Check IDENTIFY data word 125 for default BCL (currently 0) */ >>>> + uint16_t byte_count_limit = s->lcyl | (s->hcyl << 8); >>> >>> You might want to wrap s->lcyl | (s->hcyl << 8) in a helper function >>> some day. Not in this patch, though. >>> >>>> + if (!(byte_count_limit || s->atapi_dma)) { >>>> + /* TODO: Move abort back into core.c and make static inline again >>>> */ >>> >>> Not sure about the inline part, but that's not this patch's to judge. >>> >> >> I basically meant, "The way it was." Ideally this function will have a >> return mechanism to the core layer, but that groundwork isn't there >> right now, because ide_exec_cmd is not (guaranteed to be) an ancestor in >> the callchain here. >> >> This usually gets invoked as a response to an ioport write instead, and >> there isn't really any command life cycle code there yet. >> >>>> + ide_abort_command(s); >>>> + return; >>>> + } >>>> + } >>>> + >>> >>> Let's see whether I can slash through the negations here... >>> >>> This is for a non-NONDATA command (outer conditional). In other words, >>> we're expecting data. >>> >> >> Yes. Sorry for the negations, but it was easier to classify things as >> NONDATA (the exception) than DATA (what most commands do.) > > Less churn, too. > >>> Unless either byte_count_limit is non-zero or atapi_dma is true (inner >>> conditional), we abort the command. In other words: if byte_count_limit >>> is non-zero, we'll be PIO-ing some data, so we're good. If atapi_dma is >>> true, we'll be DMA-ing some data, so we're good. Else, no data will be >>> coming, contradicting our expectation. The command is invalid, and we >>> abort. >>> >>> Correct? >>> >> >> I don't think I understand "Else, no data will be coming, contradicting >> our expectation. The command is invalid, and we abort," though the rest >> of this reads correctly to me. > > Let me try again. > > if byte_count_limit is non-zero, > we'll be PIO-ing some data, so we're good > else if atapi_dma is true, > we'll be DMA-ing some data, so we're good > else > we won't transfer any data > only commands with NONDATA set may do that > but NONDATA isn't set! > command is invalid, abort it > >> If a command has not set the BCL or the DMA flag, but NONDATA is absent >> -- we /are/ expecting data, but the guest has neglected to tell us how >> much data to send per "DRQ loop." The spec says we should abort in this >> case. (And for infinite loop problems, QEMU should oblige the spec.) >> >> So the logic is this: >> >> if (data_command) { >> if (!dma) { >> if (!bcl) { >> /* problem */ >> } >> } >> } >> >> or: >> >> if (!nondata && !(bcl || dma)) { /* problem */ } >> >> >> If this is a DATA command: >> - If it's DMA, we're fine. DMA commands don't use the BCL. >> - If BCL is non-zero, we're fine for either DMA or PIO cases. >> - If BCL is zero AND dma is false, we have a problem. Abort. > > Sounds like I got it. > >> It might be easier to read as (!bcl && !dma), I guess, but for some >> reason I felt compelled to write it as (!(bcl || dma)). > > I think I'd write !bcl && !dma. Your choice. > >>>> /* Execute the command */ >>>> if (atapi_cmd_table[s->io_buffer[0]].handler) { >>>> atapi_cmd_table[s->io_buffer[0]].handler(s, buf); >>>> diff --git a/hw/ide/core.c b/hw/ide/core.c >>>> index 50449ca..28cf535 100644 >>>> --- a/hw/ide/core.c >>>> +++ b/hw/ide/core.c >>>> @@ -457,7 +457,7 @@ BlockAIOCB *ide_issue_trim(BlockBackend *blk, >>>> return &iocb->common; >>>> } >>>> >>>> -static inline void ide_abort_command(IDEState *s) >>>> +void ide_abort_command(IDEState *s) >>>> { >>>> ide_transfer_stop(s); >>>> s->status = READY_STAT | ERR_STAT; >>>> diff --git a/hw/ide/internal.h b/hw/ide/internal.h >>>> index 30fdcbc..40e1aa4 100644 >>>> --- a/hw/ide/internal.h >>>> +++ b/hw/ide/internal.h >>>> @@ -537,6 +537,7 @@ void ide_set_sector(IDEState *s, int64_t sector_num); >>>> >>>> void ide_start_dma(IDEState *s, BlockCompletionFunc *cb); >>>> void ide_dma_error(IDEState *s); >>>> +void ide_abort_command(IDEState *s); >>>> >>>> void ide_atapi_cmd_ok(IDEState *s); >>>> void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc); >> >> HTH, >> --js > > Assuming I indeed got it: > Reviewed-by: Markus Armbruster > Thanks, applied to my IDE tree: https://github.com/jnsnow/qemu/commits/ide https://github.com/jnsnow/qemu.git --js From MAILER-DAEMON Wed Sep 16 11:37:34 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcEm5-0007ky-V3 for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 11:37:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcEm3-0007hd-BD for qemu-block@nongnu.org; Wed, 16 Sep 2015 11:37:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcElz-0002Zm-Ar for qemu-block@nongnu.org; Wed, 16 Sep 2015 11:37:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60655) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcElz-0002ZZ-60; Wed, 16 Sep 2015 11:37:27 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id E08AFC0B918D; Wed, 16 Sep 2015 15:37:26 +0000 (UTC) Received: from scv.usersys.redhat.com (vpn-58-21.rdu2.redhat.com [10.10.58.21]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GFbQMs004941; Wed, 16 Sep 2015 11:37:26 -0400 To: qemu-block@nongnu.org References: <1441140641-17631-1-git-send-email-jsnow@redhat.com> From: John Snow Message-ID: <55F98CB5.3070806@redhat.com> Date: Wed, 16 Sep 2015 11:37:25 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1441140641-17631-1-git-send-email-jsnow@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 0/4] ahci: clean up signature generation X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 15:37:32 -0000 On 09/01/2015 04:50 PM, John Snow wrote: > Ultimately, clean up the signature generation and as a result, tidy up > the port_reset and init_d2h functions. > > ________________________________________________________________________________ > > For convenience, this branch is available at: > https://github.com/jnsnow/qemu.git branch ahci-sigfix > https://github.com/jnsnow/qemu/tree/ahci-sigfix > > This version is tagged ahci-sigfix-v1: > https://github.com/jnsnow/qemu/releases/tag/ahci-sigfix-v1 > > John Snow (4): > ahci: remove dead reset code > ahci: fix signature generation > ahci: remove cmd_fis argument from write_fis_d2h > ahci: clean up initial d2h semantics > > hw/ide/ahci.c | 53 ++++++++++++++++++++++++++++++----------------------- > 1 file changed, 30 insertions(+), 23 deletions(-) > Ping -- Stefan, you had some comments on the predecessor to this patch for 2.4, does this look saner to you? From MAILER-DAEMON Wed Sep 16 14:27:25 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcHQT-0004ED-SN for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 14:27:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcHQS-0004E4-6j for qemu-block@nongnu.org; Wed, 16 Sep 2015 14:27:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcHQO-0006uD-PR for qemu-block@nongnu.org; Wed, 16 Sep 2015 14:27:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44184) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcHQO-0006t0-Iy; Wed, 16 Sep 2015 14:27:20 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 4CD5FC0B91AF; Wed, 16 Sep 2015 18:27:19 +0000 (UTC) Received: from localhost (ovpn-112-77.phx2.redhat.com [10.3.112.77]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8GIRHH7001128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Wed, 16 Sep 2015 14:27:18 -0400 Date: Wed, 16 Sep 2015 14:27:16 -0400 From: Jeff Cody To: Wen Congyang Message-ID: <20150916182716.GA29557@localhost.localdomain> References: <1441682913-14320-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441682913-14320-1-git-send-email-wency@cn.fujitsu.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , qemu block , qemu devel , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v2 0/2] Block: don't do copy-on-read in before_write_notifier X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 18:27:25 -0000 On Tue, Sep 08, 2015 at 11:28:31AM +0800, Wen Congyang wrote: > If we do copy-on-read in before_write_notifier, qemu will be crashed. The > backtrace is: > Program terminated with signal 6, Aborted. > #0 0x00007f5d69207b55 in raise () from /lib64/libc.so.6 > (gdb) bt > #0 0x00007f5d69207b55 in raise () from /lib64/libc.so.6 > #1 0x00007f5d69209131 in abort () from /lib64/libc.so.6 > #2 0x00007f5d69200a10 in __assert_fail () from /lib64/libc.so.6 > #3 0x00007f5d6cb3a0d5 in wait_serialising_requests (self=0x7f5d36feeae0) at block/io.c:452 > #4 0x00007f5d6cb3ae79 in bdrv_aligned_preadv (bs=0x7f5d6d570170, req=0x7f5d36feeae0, offset=93585408, bytes=65536, align=512, qiov=0x7f5d36feec90, flags=1) > at block/io.c:847 > #5 0x00007f5d6cb3b3cc in bdrv_co_do_preadv (bs=0x7f5d6d570170, offset=93585408, bytes=65536, qiov=0x7f5d36feec90, flags=BDRV_REQ_COPY_ON_READ) > at block/io.c:971 > #6 0x00007f5d6cb3b497 in bdrv_co_do_readv (bs=0x7f5d6d570170, sector_num=182784, nb_sectors=128, qiov=0x7f5d36feec90, flags=0) at block/io.c:993 > #7 0x00007f5d6cb3b504 in bdrv_co_readv (bs=0x7f5d6d570170, sector_num=182784, nb_sectors=128, qiov=0x7f5d36feec90) at block/io.c:1002 > #8 0x00007f5d6c8eaf42 in backup_do_cow (bs=0x7f5d6d570170, sector_num=182784, nb_sectors=8, error_is_read=0x0) at block/backup.c:132 > #9 0x00007f5d6c8eb6cf in backup_before_write_notify (notifier=0x7f5d435fcf30, opaque=0x7f5d36feee40) at block/backup.c:193 > #10 0x00007f5d6cb9ec33 in notifier_with_return_list_notify (list=0x7f5d6d5731f8, data=0x7f5d36feee40) at util/notify.c:65 > #11 0x00007f5d6cb3bcc8 in bdrv_aligned_pwritev (bs=0x7f5d6d570170, req=0x7f5d36feee40, offset=93585408, bytes=4096, qiov=0x7f5d6eef4cf8, flags=0) > at block/io.c:1126 > #12 0x00007f5d6cb3c79e in bdrv_co_do_pwritev (bs=0x7f5d6d570170, offset=93585408, bytes=4096, qiov=0x7f5d6eef4cf8, flags=0) at block/io.c:1364 > #13 0x00007f5d6cb3c867 in bdrv_co_do_writev (bs=0x7f5d6d570170, sector_num=182784, nb_sectors=8, qiov=0x7f5d6eef4cf8, flags=0) at block/io.c:1388 > #14 0x00007f5d6cb3ea09 in bdrv_co_do_rw (opaque=0x7f5d38465ee0) at block/io.c:2123 > #15 0x00007f5d6caeb03d in coroutine_trampoline (i0=944146112, i1=32605) at coroutine-ucontext.c:80 > #16 0x00007f5d69218be0 in __correctly_grouped_prefixwc () from /lib64/libc.so.6 > #17 0x0000000000000000 in ?? () > > > Wen Congyang (2): > block: Introduce a new API bdrv_co_no_copy_on_readv() > Backup: don't do copy-on-read in before_write_notifier > > block/backup.c | 20 ++++++++++++++------ > block/io.c | 12 +++++++++++- > include/block/block.h | 9 ++++++--- > trace-events | 1 + > 4 files changed, 32 insertions(+), 10 deletions(-) > > -- > 2.4.3 > Thanks, applied to my block branch: git://github.com/codyprime/qemu-kvm-jtc.git block -Jeff From MAILER-DAEMON Wed Sep 16 21:05:38 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcNdp-00033U-Ru for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 21:05:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcNdm-0002z5-Je for qemu-block@nongnu.org; Wed, 16 Sep 2015 21:05:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcNdl-00078S-9V for qemu-block@nongnu.org; Wed, 16 Sep 2015 21:05:34 -0400 Received: from [59.151.112.132] (port=13144 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcNdf-00073z-Cw; Wed, 16 Sep 2015 21:05:28 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100803340" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 17 Sep 2015 09:08:11 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8H154NR023060; Thu, 17 Sep 2015 09:05:04 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Thu, 17 Sep 2015 09:05:20 +0800 To: Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F776CC.3050601@cn.fujitsu.com> <87fv2g876a.fsf@blackfin.pond.sub.org> <55F7D06D.1080205@cn.fujitsu.com> <87mvwo3phm.fsf@blackfin.pond.sub.org> <55F9054F.1000001@cn.fujitsu.com> <87r3lyzsef.fsf@blackfin.pond.sub.org> <55F92745.6040904@cn.fujitsu.com> <87bnd2y5mn.fsf@blackfin.pond.sub.org> From: Wen Congyang Message-ID: <55FA11AE.8020407@cn.fujitsu.com> Date: Thu, 17 Sep 2015 09:04:46 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87bnd2y5mn.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 01:05:36 -0000 On 09/16/2015 07:18 PM, Markus Armbruster wrote: > Wen Congyang writes: > >> On 09/16/2015 04:21 PM, Markus Armbruster wrote: >>> Wen Congyang writes: >>> >>>> On 09/15/2015 07:12 PM, Markus Armbruster wrote: >>>>> Wen Congyang writes: >>>>> >>>>>> On 09/15/2015 03:37 PM, Markus Armbruster wrote: >>>>>>> Wen Congyang writes: >>>>>>> >>>>>>>> On 09/14/2015 11:47 PM, Eric Blake wrote: >>>>>>>>> On 09/14/2015 08:27 AM, Markus Armbruster wrote: >>>>>>>>>> Wen Congyang writes: >>>>>>>>>> >>>>>>>>>>> The NBD driver needs: filename, path or (host, port, exportname). >>>>>>>>>>> It checks which key exists and decides use unix or inet socket. >>>>>>>>>>> It doesn't recognize the key type, so we can't use union, and >>>>>>>>>>> can't reuse InetSocketAddress. >>>>>>>>>>> >>>>>>>>>>> Signed-off-by: Wen Congyang >>>>>>>>>>> Signed-off-by: zhanghailiang >>>>>>>>>>> Signed-off-by: Gonglei >>>>>>>>>>> --- >>>>>>>>>>> qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- >>>>>>>>>>> 1 file changed, 40 insertions(+), 2 deletions(-) >>>>>>>>>>> >>>>>>>>> >>>>>>>>>>> ## >>>>>>>>>>> +# @BlockdevOptionsNBD >>>>>>>>>>> +# >>>>>>>>>>> +# Driver specific block device options for NBD >>>>>>>>>>> +# >>>>>>>>>>> +# @filename: #optional unix or inet path. The format is: >>>>>>>>>>> +# unix: nbd+unix:///export?socket=path or >>>>>>>>>>> +# nbd:unix:path:exportname=export >>>>>>>>>>> +# inet: nbd[+tcp]://host[:port]/export or >>>>>>>>>>> +# nbd:host[:port]:exportname=export >>>>>>>>> >>>>>>>>> Yuck. You are passing structured data through a single 'str', when you >>>>>>>>> SHOULD be passing it through structured JSON. Just because we have a >>>>>>>>> filename shorthand for convenience does NOT mean that we want to expose >>>>>>>>> that convenience in QMP. Instead, we really want the breakdown of the >>>>>>>>> pieces (here, using abbreviated syntax of an inline base, since there >>>>>>>>> are pending qapi patches that will allow it): >>>>>>>> >>>>>>>> Do you mean that: there is no need to support filename? >>>>>>> >>>>>>> Rule of thumb: if the QMP command handler needs to parse a string >>>>>>> argument, that argument should be a complex QAPI type instead. >>>>>>> >>>>>>> Example: @filename needs to be parsed into its components, either >>>>>>> >>>>>>> * protocol unix, socket path, export name, or >>>>>>> * protocol tcp, host, port, export name >>>>>>> >>>>>>> Since there's an either/or, the complex QAPI type should be a union. >>>>>>> >>>>>>>>> { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } >>>>>>>> >>>>>>>> NBD only uses tcp, it doesn't support udp. >>>>>>>> >>>>>>>>> { 'union': 'BlockdevOptionsNBD', >>>>>>>>> 'base': { 'transport': 'NBDTransport', 'export': 'str' }, >>>>>>>>> 'discriminator': 'transport', >>>>>>>>> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } >>>>>>>>> { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } >>>>>>>> >>>>>>>> unix socket needs a path, and I think we can use UnixSocketAddress here. >>>>>>> >>>>>>> Yes, we should try to reuse common types like SocketAddress, >>>>>>> InetSocketAddress, UnixSocketAddress. >>>>>>> >>>>>>> Perhaps it could be as simple as >>>>>>> >>>>>>> { 'struct': 'BlockdevOptionsNBD', >>>>>>> 'data': { 'addr: 'SocketAddress', 'export': 'str' } } >>>>>> >>>>>> The problem is that: NBD doesn't use the fd. >>>>> >>>>> Is that fundamental, or just a matter of implementation? >>> >>> Question still open. > > Question still open. It is just a matter of implementation. For other drivers, if the user specifies an unknown option, we will report the error before calling qmp_blockdev_add(). If we allow the user specify fd, we may report the error in bdrv_open(). > >>>>>> Another question is: what key will we see in nbd_open()? "addr.host" >>>>>> or "host"? >>>>> >>>>> As long as nbd_config() looks for "host" in the options QDict, we need >>>>> to put "host". >>>> >>>> Yes, we need "host" in nbd_config(), but we pass "addr.data.host" to it. >>>> >>>> How to avoid this problem? >>> >>> Where is the code constructing the QDict? >> >> The QDict is constructed in qmp_blockdev_add(): >> visit_type_BlockdevOptions(qmp_output_get_visitor(ov), >> &options, NULL, &local_err); >> if (local_err) { >> error_propagate(errp, local_err); >> goto fail; >> } >> >> obj = qmp_output_get_qobject(ov); >> qdict = qobject_to_qdict(obj); >> >> qdict_flatten(qdict); > > Okay. > > Long term, I'd like to see us get rid of the conversions between > QAPI-generated types and QDict / QemuOpts. > > Short term, you need to co-evolve the QDict-based code such as > nbd_config() with the QAPI interfaces. > > Keeping the QAPI interface clean is more important than minimizing the > implementation work, because we're free to mess with the implementation, > but releasing a QAPI interface makes it ABI, so we better get it right. > . > From MAILER-DAEMON Wed Sep 16 21:07:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcNfr-0004Y5-Q7 for mharc-qemu-block@gnu.org; Wed, 16 Sep 2015 21:07:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcNfp-0004TQ-5D for qemu-block@nongnu.org; Wed, 16 Sep 2015 21:07:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcNfo-00080c-6X for qemu-block@nongnu.org; Wed, 16 Sep 2015 21:07:41 -0400 Received: from [59.151.112.132] (port=31081 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcNfj-0007ym-E5; Wed, 16 Sep 2015 21:07:35 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100803483" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 17 Sep 2015 09:10:19 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8H17D36023198; Thu, 17 Sep 2015 09:07:13 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Thu, 17 Sep 2015 09:07:28 +0800 To: Eric Blake , Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F776CC.3050601@cn.fujitsu.com> <87fv2g876a.fsf@blackfin.pond.sub.org> <55F7D06D.1080205@cn.fujitsu.com> <87mvwo3phm.fsf@blackfin.pond.sub.org> <55F9054F.1000001@cn.fujitsu.com> <87r3lyzsef.fsf@blackfin.pond.sub.org> <55F92745.6040904@cn.fujitsu.com> <87bnd2y5mn.fsf@blackfin.pond.sub.org> <55F98256.8080304@redhat.com> From: Wen Congyang Message-ID: <55FA122F.8080608@cn.fujitsu.com> Date: Thu, 17 Sep 2015 09:06:55 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F98256.8080304@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 01:07:42 -0000 On 09/16/2015 10:53 PM, Eric Blake wrote: > On 09/16/2015 05:18 AM, Markus Armbruster wrote: > >>>>>>>> Perhaps it could be as simple as >>>>>>>> >>>>>>>> { 'struct': 'BlockdevOptionsNBD', >>>>>>>> 'data': { 'addr: 'SocketAddress', 'export': 'str' } } >>>>>>> >>>>>>> The problem is that: NBD doesn't use the fd. >>>>>> >>>>>> Is that fundamental, or just a matter of implementation? >>>> >>>> Question still open. >> >> Question still open. > > Dan's patches didn't address it... > >> Long term, I'd like to see us get rid of the conversions between >> QAPI-generated types and QDict / QemuOpts. >> >> Short term, you need to co-evolve the QDict-based code such as >> nbd_config() with the QAPI interfaces. > > ...but DO affect the short-term, by starting the conversion over to > using the QAPI type more fully: > https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg04383.html The problem still exists with this patch, because we pass "addr.data.host" to nbd_open(). Thanks Wen Congyang > >> >> Keeping the QAPI interface clean is more important than minimizing the >> implementation work, because we're free to mess with the implementation, >> but releasing a QAPI interface makes it ABI, so we better get it right. > > Especially once the QAPI interface is actually used by a QMP command > (there are places where we are using qapi internally for ease in command > line handling, but not exposing the structures through QMP yet). > From MAILER-DAEMON Thu Sep 17 00:55:32 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcREJ-00021D-Uk for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 00:55:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcRED-0001xb-S8 for qemu-block@nongnu.org; Thu, 17 Sep 2015 00:55:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcRE8-00029S-IH for qemu-block@nongnu.org; Thu, 17 Sep 2015 00:55:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59678) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcRE8-00026y-8Y; Thu, 17 Sep 2015 00:55:20 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 1A269AACC2; Thu, 17 Sep 2015 04:55:19 +0000 (UTC) Received: from localhost (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8H4tHYB017822; Thu, 17 Sep 2015 00:55:18 -0400 Date: Thu, 17 Sep 2015 12:55:17 +0800 From: Fam Zheng To: Kevin Wolf Message-ID: <20150917045517.GB11527@ad.nay.redhat.com> References: <20120530234408.16043.24886.malonedeb@chaenomeles.canonical.com> <20150916121131.10679.62163.malone@chaenomeles.canonical.com> <20150916133234.GA3980@noname.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150916133234.GA3980@noname.str.redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [Bug 1006655] Re: Can't convert to vmdk with the streamOptimized subformat X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 04:55:30 -0000 On Wed, 09/16 15:32, Kevin Wolf wrote: > Am 16.09.2015 um 14:11 hat Radoslav Gerganov geschrieben: > > My patch has landed: > > https://github.com/qemu/qemu/commit/3efffc3292d94271a15b1606b4a56adf6c6f04ed > > > > I think we can resolve this bug as fixed. Just one note for those how > > are trying to use streamOptimized images with VMware: you need to patch > > the VMDK version because VMware products accept only version 3 for > > streamOptimized: > > > > # Set VMDK version 3 for foo.vmdk > > $ printf '\x03' | dd conv=notrunc of=foo.vmdk bs=1 seek=$((0x4)) > > Then I guess this is how qemu-img should create the image in the first > place. After all, compatibility with VMware is the only reason why the > VMDK driver exists. > > Radoslav or Fam, can one of you send a patch for this? I'll send a patch. Fam From MAILER-DAEMON Thu Sep 17 01:01:51 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcRKR-0004u1-7O for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 01:01:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcRKO-0004t3-GU for qemu-block@nongnu.org; Thu, 17 Sep 2015 01:01:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcRKL-0005q8-6b for qemu-block@nongnu.org; Thu, 17 Sep 2015 01:01:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50704) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcRKK-0005pf-Vt; Thu, 17 Sep 2015 01:01:45 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id DF5CC2F5164; Thu, 17 Sep 2015 05:01:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-27.ams2.redhat.com [10.36.116.27]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8H51esY027676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 17 Sep 2015 01:01:42 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3FEF5303F90D; Thu, 17 Sep 2015 07:01:40 +0200 (CEST) From: Markus Armbruster To: Wen Congyang References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> <87r3m1krdl.fsf@blackfin.pond.sub.org> <55F6EBF5.2090101@redhat.com> <55F776CC.3050601@cn.fujitsu.com> <87fv2g876a.fsf@blackfin.pond.sub.org> <55F7D06D.1080205@cn.fujitsu.com> <87mvwo3phm.fsf@blackfin.pond.sub.org> <55F9054F.1000001@cn.fujitsu.com> <87r3lyzsef.fsf@blackfin.pond.sub.org> <55F92745.6040904@cn.fujitsu.com> <87bnd2y5mn.fsf@blackfin.pond.sub.org> <55FA11AE.8020407@cn.fujitsu.com> Date: Thu, 17 Sep 2015 07:01:40 +0200 In-Reply-To: <55FA11AE.8020407@cn.fujitsu.com> (Wen Congyang's message of "Thu, 17 Sep 2015 09:04:46 +0800") Message-ID: <87k2rphc5n.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 05:01:49 -0000 Wen Congyang writes: > On 09/16/2015 07:18 PM, Markus Armbruster wrote: >> Wen Congyang writes: >> >>> On 09/16/2015 04:21 PM, Markus Armbruster wrote: >>>> Wen Congyang writes: >>>> >>>>> On 09/15/2015 07:12 PM, Markus Armbruster wrote: >>>>>> Wen Congyang writes: >>>>>> >>>>>>> On 09/15/2015 03:37 PM, Markus Armbruster wrote: >>>>>>>> Wen Congyang writes: >>>>>>>> >>>>>>>>> On 09/14/2015 11:47 PM, Eric Blake wrote: >>>>>>>>>> On 09/14/2015 08:27 AM, Markus Armbruster wrote: >>>>>>>>>>> Wen Congyang writes: >>>>>>>>>>> >>>>>>>>>>>> The NBD driver needs: filename, path or (host, port, exportname). >>>>>>>>>>>> It checks which key exists and decides use unix or inet socket. >>>>>>>>>>>> It doesn't recognize the key type, so we can't use union, and >>>>>>>>>>>> can't reuse InetSocketAddress. >>>>>>>>>>>> >>>>>>>>>>>> Signed-off-by: Wen Congyang >>>>>>>>>>>> Signed-off-by: zhanghailiang >>>>>>>>>>>> Signed-off-by: Gonglei >>>>>>>>>>>> --- >>>>>>>>>>>> qapi/block-core.json | 42 >>>>>>>>>>>> ++++++++++++++++++++++++++++++++++++++++-- >>>>>>>>>>>> 1 file changed, 40 insertions(+), 2 deletions(-) >>>>>>>>>>>> >>>>>>>>>> >>>>>>>>>>>> ## >>>>>>>>>>>> +# @BlockdevOptionsNBD >>>>>>>>>>>> +# >>>>>>>>>>>> +# Driver specific block device options for NBD >>>>>>>>>>>> +# >>>>>>>>>>>> +# @filename: #optional unix or inet path. The format is: >>>>>>>>>>>> +# unix: nbd+unix:///export?socket=path or >>>>>>>>>>>> +# nbd:unix:path:exportname=export >>>>>>>>>>>> +# inet: nbd[+tcp]://host[:port]/export or >>>>>>>>>>>> +# nbd:host[:port]:exportname=export >>>>>>>>>> >>>>>>>>>> Yuck. You are passing structured data through a single 'str', when you >>>>>>>>>> SHOULD be passing it through structured JSON. Just because we have a >>>>>>>>>> filename shorthand for convenience does NOT mean that we >>>>>>>>>> want to expose >>>>>>>>>> that convenience in QMP. Instead, we really want the breakdown of the >>>>>>>>>> pieces (here, using abbreviated syntax of an inline base, since there >>>>>>>>>> are pending qapi patches that will allow it): >>>>>>>>> >>>>>>>>> Do you mean that: there is no need to support filename? >>>>>>>> >>>>>>>> Rule of thumb: if the QMP command handler needs to parse a string >>>>>>>> argument, that argument should be a complex QAPI type instead. >>>>>>>> >>>>>>>> Example: @filename needs to be parsed into its components, either >>>>>>>> >>>>>>>> * protocol unix, socket path, export name, or >>>>>>>> * protocol tcp, host, port, export name >>>>>>>> >>>>>>>> Since there's an either/or, the complex QAPI type should be a union. >>>>>>>> >>>>>>>>>> { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } >>>>>>>>> >>>>>>>>> NBD only uses tcp, it doesn't support udp. >>>>>>>>> >>>>>>>>>> { 'union': 'BlockdevOptionsNBD', >>>>>>>>>> 'base': { 'transport': 'NBDTransport', 'export': 'str' }, >>>>>>>>>> 'discriminator': 'transport', >>>>>>>>>> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } >>>>>>>>>> { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } >>>>>>>>> >>>>>>>>> unix socket needs a path, and I think we can use >>>>>>>>> UnixSocketAddress here. >>>>>>>> >>>>>>>> Yes, we should try to reuse common types like SocketAddress, >>>>>>>> InetSocketAddress, UnixSocketAddress. >>>>>>>> >>>>>>>> Perhaps it could be as simple as >>>>>>>> >>>>>>>> { 'struct': 'BlockdevOptionsNBD', >>>>>>>> 'data': { 'addr: 'SocketAddress', 'export': 'str' } } >>>>>>> >>>>>>> The problem is that: NBD doesn't use the fd. >>>>>> >>>>>> Is that fundamental, or just a matter of implementation? >>>> >>>> Question still open. >> >> Question still open. > > It is just a matter of implementation. For other drivers, if the user specifies > an unknown option, we will report the error before calling qmp_blockdev_add(). > > If we allow the user specify fd, we may report the error in bdrv_open(). In general, we want fd support, because it lets us confine QEMU more tightly, and open / connect / bind stuff in libvirt. Not this patch's problem, of course. In this particular case, since fd support is possible, we want its introduction be visible in introspection. The obvious way for that is to use a union of exactly the *SocketAddress types that are actually supported. Now: new one containing InetSocketAddress and UnixSocketAddress. Once fd is supported as well, SocketAddress. [...] From MAILER-DAEMON Thu Sep 17 01:04:21 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcRMr-000694-Rh for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 01:04:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcRMp-00068C-9H for qemu-block@nongnu.org; Thu, 17 Sep 2015 01:04:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcRMm-00070B-1Z for qemu-block@nongnu.org; Thu, 17 Sep 2015 01:04:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51070) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcRMl-0006zz-TH; Thu, 17 Sep 2015 01:04:15 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 7F25E2F90C3; Thu, 17 Sep 2015 05:04:15 +0000 (UTC) Received: from ad.nay.redhat.com. (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8H54BXD031636; Thu, 17 Sep 2015 01:04:12 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 17 Sep 2015 13:04:10 +0800 Message-Id: <1442466250-27787-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-block@nongnu.org Subject: [Qemu-block] [PATCH] vmdk: Create streamOptimized as version 3 X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 05:04:20 -0000 VMware products accept only version 3 for streamOptimized, let's bump the version. Reported-by: Radoslav Gerganov Signed-off-by: Fam Zheng --- block/vmdk.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block/vmdk.c b/block/vmdk.c index be0d640..37326c3 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1651,7 +1651,13 @@ static int vmdk_create_extent(const char *filename, int64_t filesize, } magic = cpu_to_be32(VMDK4_MAGIC); memset(&header, 0, sizeof(header)); - header.version = zeroed_grain ? 2 : 1; + if (compress) { + header.version = 3; + } else if (zeroed_grain) { + header.version = 2; + } else { + header.version = 1; + } header.flags = VMDK4_FLAG_RGD | VMDK4_FLAG_NL_DETECT | (compress ? VMDK4_FLAG_COMPRESS | VMDK4_FLAG_MARKER : 0) | (zeroed_grain ? VMDK4_FLAG_ZERO_GRAIN : 0); -- 2.4.3 From MAILER-DAEMON Thu Sep 17 04:30:44 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcUaa-0001z2-C9 for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 04:30:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcUaW-0001u2-Jw for qemu-block@nongnu.org; Thu, 17 Sep 2015 04:30:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcUaR-0003dl-Ka for qemu-block@nongnu.org; Thu, 17 Sep 2015 04:30:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50244) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcUaR-0003df-GJ; Thu, 17 Sep 2015 04:30:35 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id DFD302F90D7; Thu, 17 Sep 2015 08:30:34 +0000 (UTC) Received: from localhost (ovpn-112-46.ams2.redhat.com [10.36.112.46]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8H8UXcT018774; Thu, 17 Sep 2015 04:30:34 -0400 Date: Thu, 17 Sep 2015 09:30:33 +0100 From: Stefan Hajnoczi To: John Snow Message-ID: <20150917083033.GD21734@stefanha-thinkpad.redhat.com> References: <1441140641-17631-1-git-send-email-jsnow@redhat.com> <1441140641-17631-3-git-send-email-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441140641-17631-3-git-send-email-jsnow@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, armbru@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 2/4] ahci: fix signature generation X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 08:30:42 -0000 On Tue, Sep 01, 2015 at 04:50:39PM -0400, John Snow wrote: > The initial register device-to-host FIS no longer needs to specially > set certain fields, as these can be handled generically by setting those > fields explicitly with the signatures we want at port reset time. > > (1) Signatures are decomposed into their four component registers and > set upon (AHCI) port reset. > (2) the signature cache register is no longer set manually per-each > device type, but instead just once during ahci_init_d2h. > > Signed-off-by: John Snow > --- > hw/ide/ahci.c | 32 ++++++++++++++++++++------------ > 1 file changed, 20 insertions(+), 12 deletions(-) > > diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c > index d04a161..3c50ccb 100644 > --- a/hw/ide/ahci.c > +++ b/hw/ide/ahci.c > @@ -542,20 +542,31 @@ static void ahci_init_d2h(AHCIDevice *ad) > { > uint8_t init_fis[20]; > IDEState *ide_state = &ad->port.ifs[0]; > + AHCIPortRegs *pr = &ad->port_regs; > > memset(init_fis, 0, sizeof(init_fis)); > > - init_fis[4] = 1; > - init_fis[12] = 1; > - > - if (ide_state->drive_kind == IDE_CD) { > - init_fis[5] = ide_state->lcyl; > - init_fis[6] = ide_state->hcyl; > - } > + /* We're emulating receiving the first Reg H2D Fis from the device; > + * Update the SIG register, but otherwise procede as normal. */ s/procede/proceed/ From MAILER-DAEMON Thu Sep 17 04:40:19 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcUjr-0005Kr-JB for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 04:40:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcUjn-0005IN-Q1 for qemu-block@nongnu.org; Thu, 17 Sep 2015 04:40:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcUjj-0000kN-Pq for qemu-block@nongnu.org; Thu, 17 Sep 2015 04:40:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53539) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcUjj-0000k7-LF; Thu, 17 Sep 2015 04:40:11 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 30A468CF73; Thu, 17 Sep 2015 08:40:11 +0000 (UTC) Received: from localhost (ovpn-112-46.ams2.redhat.com [10.36.112.46]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8H8e9or025436; Thu, 17 Sep 2015 04:40:10 -0400 Date: Thu, 17 Sep 2015 09:40:09 +0100 From: Stefan Hajnoczi To: John Snow Message-ID: <20150917084009.GE21734@stefanha-thinkpad.redhat.com> References: <1441140641-17631-1-git-send-email-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441140641-17631-1-git-send-email-jsnow@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, armbru@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 0/4] ahci: clean up signature generation X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 08:40:16 -0000 On Tue, Sep 01, 2015 at 04:50:37PM -0400, John Snow wrote: > Ultimately, clean up the signature generation and as a result, tidy up > the port_reset and init_d2h functions. > > ________________________________________________________________________________ > > For convenience, this branch is available at: > https://github.com/jnsnow/qemu.git branch ahci-sigfix > https://github.com/jnsnow/qemu/tree/ahci-sigfix > > This version is tagged ahci-sigfix-v1: > https://github.com/jnsnow/qemu/releases/tag/ahci-sigfix-v1 > > John Snow (4): > ahci: remove dead reset code > ahci: fix signature generation > ahci: remove cmd_fis argument from write_fis_d2h > ahci: clean up initial d2h semantics > > hw/ide/ahci.c | 53 ++++++++++++++++++++++++++++++----------------------- > 1 file changed, 30 insertions(+), 23 deletions(-) > > -- > 2.4.3 > Reviewed-by: Stefan Hajnoczi From MAILER-DAEMON Thu Sep 17 04:56:00 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcUz2-0004Gw-KF for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 04:56:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcUz1-0004Gi-59 for qemu-block@nongnu.org; Thu, 17 Sep 2015 04:55:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcUz0-0007Hn-0e for qemu-block@nongnu.org; Thu, 17 Sep 2015 04:55:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38546) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcUyz-0007HV-RV; Thu, 17 Sep 2015 04:55:57 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 46896C0B918D; Thu, 17 Sep 2015 08:55:57 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8H8ttN8031425; Thu, 17 Sep 2015 04:55:56 -0400 Date: Thu, 17 Sep 2015 10:55:55 +0200 From: Kevin Wolf To: Fam Zheng Message-ID: <20150917085555.GB4884@noname.redhat.com> References: <1442466250-27787-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442466250-27787-1-git-send-email-famz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH] vmdk: Create streamOptimized as version 3 X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 08:56:00 -0000 Am 17.09.2015 um 07:04 hat Fam Zheng geschrieben: > VMware products accept only version 3 for streamOptimized, let's bump > the version. > > Reported-by: Radoslav Gerganov > Signed-off-by: Fam Zheng Radoslav, can I have your Reviewed-by and/or Tested-by for this patch? Kevin > block/vmdk.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/block/vmdk.c b/block/vmdk.c > index be0d640..37326c3 100644 > --- a/block/vmdk.c > +++ b/block/vmdk.c > @@ -1651,7 +1651,13 @@ static int vmdk_create_extent(const char *filename, int64_t filesize, > } > magic = cpu_to_be32(VMDK4_MAGIC); > memset(&header, 0, sizeof(header)); > - header.version = zeroed_grain ? 2 : 1; > + if (compress) { > + header.version = 3; > + } else if (zeroed_grain) { > + header.version = 2; > + } else { > + header.version = 1; > + } > header.flags = VMDK4_FLAG_RGD | VMDK4_FLAG_NL_DETECT > | (compress ? VMDK4_FLAG_COMPRESS | VMDK4_FLAG_MARKER : 0) > | (zeroed_grain ? VMDK4_FLAG_ZERO_GRAIN : 0); > -- > 2.4.3 > From MAILER-DAEMON Thu Sep 17 09:48:35 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYB-0001Y5-Lr for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:48:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZY5-0001X5-9V for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZY4-0001sJ-Bc for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZY4-0001qp-73; Thu, 17 Sep 2015 09:48:28 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 3E18DC0B91A2; Thu, 17 Sep 2015 13:48:27 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHg030423; Thu, 17 Sep 2015 09:48:25 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:04 +0200 Message-Id: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 00/16] block: Get rid of bdrv_swap() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:48:35 -0000 bdrv_swap() has always been an ugly hack that we would rather have avoided. When it was introduced, we simply didn't have the infrastructure to update pointers instead of transplanting the contents of BDS object, so we grudgingly added bdrv_swap() as a quick solution. Meanwhile, most of the infrastructure exists and this series implements the final step necessary to implement the required functionality in a less adventurous way. Kevin Wolf (16): block: Introduce BDS.file_child vmdk: Use BdrvChild instead of BDS for references to extents blkverify: Convert s->test_file to BdrvChild quorum: Convert to BdrvChild block: Convert bs->file to BdrvChild block: Remove bdrv_open_image() block: Convert bs->backing_hd to BdrvChild block: Manage backing file references in bdrv_set_backing_hd() block: Split bdrv_move_feature_fields() block/io: Make bdrv_requests_pending() public block-backend: Add blk_set_bs() block: Introduce parents list block: Implement bdrv_append() without bdrv_swap() blockjob: Store device name at job creation block: Add and use bdrv_replace_in_backing_chain() block: Remove bdrv_swap() block.c | 465 +++++++++++++++++++--------------------------- block/blkdebug.c | 32 ++-- block/blkverify.c | 68 +++---- block/block-backend.c | 16 ++ block/bochs.c | 8 +- block/cloop.c | 10 +- block/dmg.c | 20 +- block/io.c | 76 ++++---- block/mirror.c | 19 +- block/parallels.c | 38 ++-- block/qapi.c | 10 +- block/qcow.c | 46 ++--- block/qcow2-cache.c | 11 +- block/qcow2-cluster.c | 42 +++-- block/qcow2-refcount.c | 45 ++--- block/qcow2-snapshot.c | 30 +-- block/qcow2.c | 68 +++---- block/qed-table.c | 4 +- block/qed.c | 51 +++-- block/quorum.c | 63 ++++--- block/raw_bsd.c | 40 ++-- block/snapshot.c | 12 +- block/stream.c | 27 +-- block/vdi.c | 17 +- block/vhdx-log.c | 25 +-- block/vhdx.c | 36 ++-- block/vmdk.c | 133 ++++++------- block/vpc.c | 34 ++-- block/vvfat.c | 19 +- blockdev.c | 6 +- blockjob.c | 8 +- include/block/block.h | 15 +- include/block/block_int.h | 20 +- include/block/blockjob.h | 8 + include/qemu/queue.h | 6 - qemu-img.c | 24 +-- 36 files changed, 755 insertions(+), 797 deletions(-) -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:48:39 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYF-0001dF-5f for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:48:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYC-0001Yt-3L for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZYA-0001xI-My for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54811) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYA-0001wh-FB; Thu, 17 Sep 2015 09:48:34 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 23B2D8EA3A; Thu, 17 Sep 2015 13:48:34 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHj030423; Thu, 17 Sep 2015 09:48:32 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:07 +0200 Message-Id: <1442497700-2536-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 03/16] blkverify: Convert s->test_file to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:48:37 -0000 Signed-off-by: Kevin Wolf --- block/blkverify.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/block/blkverify.c b/block/blkverify.c index d277e63..6b71622 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -14,7 +14,7 @@ #include "qapi/qmp/qstring.h" typedef struct { - BlockDriverState *test_file; + BdrvChild *test_file; } BDRVBlkverifyState; typedef struct BlkverifyAIOCB BlkverifyAIOCB; @@ -132,12 +132,12 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags, } /* Open the test file */ - assert(s->test_file == NULL); - ret = bdrv_open_image(&s->test_file, qemu_opt_get(opts, "x-image"), options, - "test", bs, &child_format, false, &local_err); - if (ret < 0) { + s->test_file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, + "test", bs, &child_format, false, + &local_err); + if (local_err) { + ret = -EINVAL; error_propagate(errp, local_err); - s->test_file = NULL; goto fail; } @@ -151,7 +151,7 @@ static void blkverify_close(BlockDriverState *bs) { BDRVBlkverifyState *s = bs->opaque; - bdrv_unref(s->test_file); + bdrv_unref_child(bs, s->test_file); s->test_file = NULL; } @@ -159,7 +159,7 @@ static int64_t blkverify_getlength(BlockDriverState *bs) { BDRVBlkverifyState *s = bs->opaque; - return bdrv_getlength(s->test_file); + return bdrv_getlength(s->test_file->bs); } static BlkverifyAIOCB *blkverify_aio_get(BlockDriverState *bs, bool is_write, @@ -242,7 +242,7 @@ static BlockAIOCB *blkverify_aio_readv(BlockDriverState *bs, qemu_iovec_init(&acb->raw_qiov, acb->qiov->niov); qemu_iovec_clone(&acb->raw_qiov, qiov, acb->buf); - bdrv_aio_readv(s->test_file, sector_num, qiov, nb_sectors, + bdrv_aio_readv(s->test_file->bs, sector_num, qiov, nb_sectors, blkverify_aio_cb, acb); bdrv_aio_readv(bs->file, sector_num, &acb->raw_qiov, nb_sectors, blkverify_aio_cb, acb); @@ -257,7 +257,7 @@ static BlockAIOCB *blkverify_aio_writev(BlockDriverState *bs, BlkverifyAIOCB *acb = blkverify_aio_get(bs, true, sector_num, qiov, nb_sectors, cb, opaque); - bdrv_aio_writev(s->test_file, sector_num, qiov, nb_sectors, + bdrv_aio_writev(s->test_file->bs, sector_num, qiov, nb_sectors, blkverify_aio_cb, acb); bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, blkverify_aio_cb, acb); @@ -271,7 +271,7 @@ static BlockAIOCB *blkverify_aio_flush(BlockDriverState *bs, BDRVBlkverifyState *s = bs->opaque; /* Only flush test file, the raw file is not important */ - return bdrv_aio_flush(s->test_file, cb, opaque); + return bdrv_aio_flush(s->test_file->bs, cb, opaque); } static bool blkverify_recurse_is_first_non_filter(BlockDriverState *bs, @@ -285,7 +285,7 @@ static bool blkverify_recurse_is_first_non_filter(BlockDriverState *bs, return true; } - return bdrv_recurse_is_first_non_filter(s->test_file, candidate); + return bdrv_recurse_is_first_non_filter(s->test_file->bs, candidate); } /* Propagate AioContext changes to ->test_file */ @@ -293,7 +293,7 @@ static void blkverify_detach_aio_context(BlockDriverState *bs) { BDRVBlkverifyState *s = bs->opaque; - bdrv_detach_aio_context(s->test_file); + bdrv_detach_aio_context(s->test_file->bs); } static void blkverify_attach_aio_context(BlockDriverState *bs, @@ -301,7 +301,7 @@ static void blkverify_attach_aio_context(BlockDriverState *bs, { BDRVBlkverifyState *s = bs->opaque; - bdrv_attach_aio_context(s->test_file, new_context); + bdrv_attach_aio_context(s->test_file->bs, new_context); } static void blkverify_refresh_filename(BlockDriverState *bs) @@ -309,24 +309,25 @@ static void blkverify_refresh_filename(BlockDriverState *bs) BDRVBlkverifyState *s = bs->opaque; /* bs->file has already been refreshed */ - bdrv_refresh_filename(s->test_file); + bdrv_refresh_filename(s->test_file->bs); - if (bs->file->full_open_options && s->test_file->full_open_options) { + if (bs->file->full_open_options && s->test_file->bs->full_open_options) { QDict *opts = qdict_new(); qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("blkverify"))); QINCREF(bs->file->full_open_options); qdict_put_obj(opts, "raw", QOBJECT(bs->file->full_open_options)); - QINCREF(s->test_file->full_open_options); - qdict_put_obj(opts, "test", QOBJECT(s->test_file->full_open_options)); + QINCREF(s->test_file->bs->full_open_options); + qdict_put_obj(opts, "test", + QOBJECT(s->test_file->bs->full_open_options)); bs->full_open_options = opts; } - if (bs->file->exact_filename[0] && s->test_file->exact_filename[0]) { + if (bs->file->exact_filename[0] && s->test_file->bs->exact_filename[0]) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "blkverify:%s:%s", - bs->file->exact_filename, s->test_file->exact_filename); + bs->file->exact_filename, s->test_file->bs->exact_filename); } } -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:48:41 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYH-0001hh-EU for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:48:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZY9-0001XH-Mg for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZY5-0001tg-QX for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZY5-0001tT-MF; Thu, 17 Sep 2015 09:48:29 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 58FBD2E2424; Thu, 17 Sep 2015 13:48:29 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHh030423; Thu, 17 Sep 2015 09:48:27 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:05 +0200 Message-Id: <1442497700-2536-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 01/16] block: Introduce BDS.file_child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:48:39 -0000 Store the BdrvChild for bs->file. At this point, bs->file_child->bs just duplicates the bs->file pointer. Later, it will completely replace it. Signed-off-by: Kevin Wolf --- block.c | 12 +++++++++--- include/block/block_int.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 6268e37..2e9e5e2 100644 --- a/block.c +++ b/block.c @@ -1487,11 +1487,17 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, assert(file == NULL); bs->open_flags = flags; - ret = bdrv_open_image(&file, filename, options, "file", - bs, &child_file, true, &local_err); - if (ret < 0) { + + bs->file_child = bdrv_open_child(filename, options, "file", bs, + &child_file, true, &local_err); + if (local_err) { + ret = -EINVAL; goto fail; } + + if (bs->file_child) { + file = bs->file_child->bs; + } } /* Image format probing */ diff --git a/include/block/block_int.h b/include/block/block_int.h index 14ad4c3..d0dd93e 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -381,6 +381,7 @@ struct BlockDriverState { BlockDriverState *backing_hd; BdrvChild *backing_child; BlockDriverState *file; + BdrvChild *file_child; NotifierList close_notifiers; -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:48:39 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYF-0001dd-AP for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:48:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYB-0001YI-RF for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZY8-0001vz-CJ for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZY8-0001vv-3V; Thu, 17 Sep 2015 09:48:32 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id BE25C461E4; Thu, 17 Sep 2015 13:48:31 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHi030423; Thu, 17 Sep 2015 09:48:29 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:06 +0200 Message-Id: <1442497700-2536-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 02/16] vmdk: Use BdrvChild instead of BDS for references to extents X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:48:37 -0000 Signed-off-by: Kevin Wolf --- block/vmdk.c | 99 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 51 insertions(+), 48 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index be0d640..9702132 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -87,7 +87,7 @@ typedef struct { #define L2_CACHE_SIZE 16 typedef struct VmdkExtent { - BlockDriverState *file; + BdrvChild *file; bool flat; bool compressed; bool has_marker; @@ -221,8 +221,8 @@ static void vmdk_free_extents(BlockDriverState *bs) g_free(e->l2_cache); g_free(e->l1_backup_table); g_free(e->type); - if (e->file != bs->file) { - bdrv_unref(e->file); + if (e->file != bs->file_child) { + bdrv_unref_child(bs, e->file); } } g_free(s->extents); @@ -367,7 +367,7 @@ static int vmdk_parent_open(BlockDriverState *bs) /* Create and append extent to the extent array. Return the added VmdkExtent * address. return NULL if allocation failed. */ static int vmdk_add_extent(BlockDriverState *bs, - BlockDriverState *file, bool flat, int64_t sectors, + BdrvChild *file, bool flat, int64_t sectors, int64_t l1_offset, int64_t l1_backup_offset, uint32_t l1_size, int l2_size, uint64_t cluster_sectors, @@ -392,7 +392,7 @@ static int vmdk_add_extent(BlockDriverState *bs, return -EFBIG; } - nb_sectors = bdrv_nb_sectors(file); + nb_sectors = bdrv_nb_sectors(file->bs); if (nb_sectors < 0) { return nb_sectors; } @@ -439,14 +439,14 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent, return -ENOMEM; } - ret = bdrv_pread(extent->file, + ret = bdrv_pread(extent->file->bs, extent->l1_table_offset, extent->l1_table, l1_size); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read l1 table from extent '%s'", - extent->file->filename); + extent->file->bs->filename); goto fail_l1; } for (i = 0; i < extent->l1_size; i++) { @@ -459,14 +459,14 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent, ret = -ENOMEM; goto fail_l1; } - ret = bdrv_pread(extent->file, + ret = bdrv_pread(extent->file->bs, extent->l1_backup_table_offset, extent->l1_backup_table, l1_size); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read l1 backup table from extent '%s'", - extent->file->filename); + extent->file->bs->filename); goto fail_l1b; } for (i = 0; i < extent->l1_size; i++) { @@ -485,7 +485,7 @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent, } static int vmdk_open_vmfs_sparse(BlockDriverState *bs, - BlockDriverState *file, + BdrvChild *file, int flags, Error **errp) { int ret; @@ -493,11 +493,11 @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs, VMDK3Header header; VmdkExtent *extent; - ret = bdrv_pread(file, sizeof(magic), &header, sizeof(header)); + ret = bdrv_pread(file->bs, sizeof(magic), &header, sizeof(header)); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read header from file '%s'", - file->filename); + file->bs->filename); return ret; } ret = vmdk_add_extent(bs, file, false, @@ -559,7 +559,7 @@ static char *vmdk_read_desc(BlockDriverState *file, uint64_t desc_offset, } static int vmdk_open_vmdk4(BlockDriverState *bs, - BlockDriverState *file, + BdrvChild *file, int flags, QDict *options, Error **errp) { int ret; @@ -570,17 +570,17 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, BDRVVmdkState *s = bs->opaque; int64_t l1_backup_offset = 0; - ret = bdrv_pread(file, sizeof(magic), &header, sizeof(header)); + ret = bdrv_pread(file->bs, sizeof(magic), &header, sizeof(header)); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read header from file '%s'", - file->filename); + file->bs->filename); return -EINVAL; } if (header.capacity == 0) { uint64_t desc_offset = le64_to_cpu(header.desc_offset); if (desc_offset) { - char *buf = vmdk_read_desc(file, desc_offset << 9, errp); + char *buf = vmdk_read_desc(file->bs, desc_offset << 9, errp); if (!buf) { return -EINVAL; } @@ -620,7 +620,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, } QEMU_PACKED eos_marker; } QEMU_PACKED footer; - ret = bdrv_pread(file, + ret = bdrv_pread(file->bs, bs->file->total_sectors * 512 - 1536, &footer, sizeof(footer)); if (ret < 0) { @@ -675,7 +675,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, if (le32_to_cpu(header.flags) & VMDK4_FLAG_RGD) { l1_backup_offset = le64_to_cpu(header.rgd_offset) << 9; } - if (bdrv_nb_sectors(file) < le64_to_cpu(header.grain_offset)) { + if (bdrv_nb_sectors(file->bs) < le64_to_cpu(header.grain_offset)) { error_setg(errp, "File truncated, expecting at least %" PRId64 " bytes", (int64_t)(le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE)); @@ -739,8 +739,7 @@ static int vmdk_parse_description(const char *desc, const char *opt_name, } /* Open an extent file and append to bs array */ -static int vmdk_open_sparse(BlockDriverState *bs, - BlockDriverState *file, int flags, +static int vmdk_open_sparse(BlockDriverState *bs, BdrvChild *file, int flags, char *buf, QDict *options, Error **errp) { uint32_t magic; @@ -773,10 +772,11 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, int64_t sectors = 0; int64_t flat_offset; char *extent_path; - BlockDriverState *extent_file; + BdrvChild *extent_file; BDRVVmdkState *s = bs->opaque; VmdkExtent *extent; char extent_opt_prefix[32]; + Error *local_err = NULL; while (*p) { /* parse extent line in one of below formats: @@ -825,16 +825,16 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, extent_path = g_malloc0(PATH_MAX); path_combine(extent_path, PATH_MAX, desc_file_path, fname); - extent_file = NULL; ret = snprintf(extent_opt_prefix, 32, "extents.%d", s->num_extents); assert(ret < 32); - ret = bdrv_open_image(&extent_file, extent_path, options, - extent_opt_prefix, bs, &child_file, false, errp); + extent_file = bdrv_open_child(extent_path, options, extent_opt_prefix, + bs, &child_file, false, &local_err); g_free(extent_path); - if (ret) { - return ret; + if (local_err) { + error_propagate(errp, local_err); + return -EINVAL; } /* save to extents array */ @@ -844,13 +844,13 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, ret = vmdk_add_extent(bs, extent_file, true, sectors, 0, 0, 0, 0, 0, &extent, errp); if (ret < 0) { - bdrv_unref(extent_file); + bdrv_unref_child(bs, extent_file); return ret; } extent->flat_start_offset = flat_offset << 9; } else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) { /* SPARSE extent and VMFSSPARSE extent are both "COWD" sparse file*/ - char *buf = vmdk_read_desc(extent_file, 0, errp); + char *buf = vmdk_read_desc(extent_file->bs, 0, errp); if (!buf) { ret = -EINVAL; } else { @@ -859,13 +859,13 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, } g_free(buf); if (ret) { - bdrv_unref(extent_file); + bdrv_unref_child(bs, extent_file); return ret; } extent = &s->extents[s->num_extents - 1]; } else { error_setg(errp, "Unsupported extent type '%s'", type); - bdrv_unref(extent_file); + bdrv_unref_child(bs, extent_file); return -ENOTSUP; } extent->type = g_strdup(type); @@ -927,7 +927,8 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, switch (magic) { case VMDK3_MAGIC: case VMDK4_MAGIC: - ret = vmdk_open_sparse(bs, bs->file, flags, buf, options, errp); + ret = vmdk_open_sparse(bs, bs->file_child, flags, buf, options, + errp); s->desc_offset = 0x200; break; default: @@ -1028,7 +1029,7 @@ static int get_whole_cluster(BlockDriverState *bs, goto exit; } } - ret = bdrv_write(extent->file, cluster_sector_num, whole_grain, + ret = bdrv_write(extent->file->bs, cluster_sector_num, whole_grain, skip_start_sector); if (ret < 0) { ret = VMDK_ERROR; @@ -1046,7 +1047,7 @@ static int get_whole_cluster(BlockDriverState *bs, goto exit; } } - ret = bdrv_write(extent->file, cluster_sector_num + skip_end_sector, + ret = bdrv_write(extent->file->bs, cluster_sector_num + skip_end_sector, whole_grain + (skip_end_sector << BDRV_SECTOR_BITS), extent->cluster_sectors - skip_end_sector); if (ret < 0) { @@ -1066,7 +1067,7 @@ static int vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data, offset = cpu_to_le32(offset); /* update L2 table */ if (bdrv_pwrite_sync( - extent->file, + extent->file->bs, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(offset)), &offset, sizeof(offset)) < 0) { @@ -1076,7 +1077,7 @@ static int vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data, if (extent->l1_backup_table_offset != 0) { m_data->l2_offset = extent->l1_backup_table[m_data->l1_index]; if (bdrv_pwrite_sync( - extent->file, + extent->file->bs, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(offset)), &offset, sizeof(offset)) < 0) { @@ -1166,7 +1167,7 @@ static int get_cluster_offset(BlockDriverState *bs, } l2_table = extent->l2_cache + (min_index * extent->l2_size); if (bdrv_pread( - extent->file, + extent->file->bs, (int64_t)l2_offset * 512, l2_table, extent->l2_size * sizeof(uint32_t) @@ -1274,7 +1275,7 @@ static int64_t coroutine_fn vmdk_co_get_block_status(BlockDriverState *bs, break; case VMDK_OK: ret = BDRV_BLOCK_DATA; - if (extent->file == bs->file && !extent->compressed) { + if (extent->file == bs->file_child && !extent->compressed) { ret |= BDRV_BLOCK_OFFSET_VALID | offset; } @@ -1320,7 +1321,7 @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, write_len = buf_len + sizeof(VmdkGrainMarker); } write_offset = cluster_offset + offset_in_cluster, - ret = bdrv_pwrite(extent->file, write_offset, write_buf, write_len); + ret = bdrv_pwrite(extent->file->bs, write_offset, write_buf, write_len); write_end_sector = DIV_ROUND_UP(write_offset + write_len, BDRV_SECTOR_SIZE); @@ -1355,7 +1356,7 @@ static int vmdk_read_extent(VmdkExtent *extent, int64_t cluster_offset, if (!extent->compressed) { - ret = bdrv_pread(extent->file, + ret = bdrv_pread(extent->file->bs, cluster_offset + offset_in_cluster, buf, nb_sectors * 512); if (ret == nb_sectors * 512) { @@ -1369,7 +1370,7 @@ static int vmdk_read_extent(VmdkExtent *extent, int64_t cluster_offset, buf_bytes = cluster_bytes * 2; cluster_buf = g_malloc(buf_bytes); uncomp_buf = g_malloc(cluster_bytes); - ret = bdrv_pread(extent->file, + ret = bdrv_pread(extent->file->bs, cluster_offset, cluster_buf, buf_bytes); if (ret < 0) { @@ -2035,7 +2036,7 @@ static coroutine_fn int vmdk_co_flush(BlockDriverState *bs) int ret = 0; for (i = 0; i < s->num_extents; i++) { - err = bdrv_co_flush(s->extents[i].file); + err = bdrv_co_flush(s->extents[i].file->bs); if (err < 0) { ret = err; } @@ -2055,10 +2056,10 @@ static int64_t vmdk_get_allocated_file_size(BlockDriverState *bs) return ret; } for (i = 0; i < s->num_extents; i++) { - if (s->extents[i].file == bs->file) { + if (s->extents[i].file == bs->file_child) { continue; } - r = bdrv_get_allocated_file_size(s->extents[i].file); + r = bdrv_get_allocated_file_size(s->extents[i].file->bs); if (r < 0) { return r; } @@ -2076,7 +2077,7 @@ static int vmdk_has_zero_init(BlockDriverState *bs) * return 0. */ for (i = 0; i < s->num_extents; i++) { if (s->extents[i].flat) { - if (!bdrv_has_zero_init(s->extents[i].file)) { + if (!bdrv_has_zero_init(s->extents[i].file->bs)) { return 0; } } @@ -2089,7 +2090,7 @@ static ImageInfo *vmdk_get_extent_info(VmdkExtent *extent) ImageInfo *info = g_new0(ImageInfo, 1); *info = (ImageInfo){ - .filename = g_strdup(extent->file->filename), + .filename = g_strdup(extent->file->bs->filename), .format = g_strdup(extent->type), .virtual_size = extent->sectors * BDRV_SECTOR_SIZE, .compressed = extent->compressed, @@ -2135,7 +2136,9 @@ static int vmdk_check(BlockDriverState *bs, BdrvCheckResult *result, PRId64 "\n", sector_num); break; } - if (ret == VMDK_OK && cluster_offset >= bdrv_getlength(extent->file)) { + if (ret == VMDK_OK && + cluster_offset >= bdrv_getlength(extent->file->bs)) + { fprintf(stderr, "ERROR: cluster offset for sector %" PRId64 " points after EOF\n", sector_num); @@ -2211,7 +2214,7 @@ static void vmdk_detach_aio_context(BlockDriverState *bs) int i; for (i = 0; i < s->num_extents; i++) { - bdrv_detach_aio_context(s->extents[i].file); + bdrv_detach_aio_context(s->extents[i].file->bs); } } @@ -2222,7 +2225,7 @@ static void vmdk_attach_aio_context(BlockDriverState *bs, int i; for (i = 0; i < s->num_extents; i++) { - bdrv_attach_aio_context(s->extents[i].file, new_context); + bdrv_attach_aio_context(s->extents[i].file->bs, new_context); } } -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:48:41 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYH-0001i0-JE for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:48:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYE-0001cV-I1 for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZYD-0001zn-6H for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59182) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYC-0001yz-UF; Thu, 17 Sep 2015 09:48:37 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 800A1C0B2004; Thu, 17 Sep 2015 13:48:36 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHk030423; Thu, 17 Sep 2015 09:48:34 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:08 +0200 Message-Id: <1442497700-2536-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 04/16] quorum: Convert to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:48:40 -0000 Signed-off-by: Kevin Wolf --- block/quorum.c | 63 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index 8fe53b4..8e6e2dc 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -64,7 +64,7 @@ typedef struct QuorumVotes { /* the following structure holds the state of one quorum instance */ typedef struct BDRVQuorumState { - BlockDriverState **bs; /* children BlockDriverStates */ + BdrvChild **children; /* children BlockDriverStates */ int num_children; /* children count */ int threshold; /* if less than threshold children reads gave the * same result a quorum error occurs. @@ -336,7 +336,7 @@ static void quorum_report_bad_versions(BDRVQuorumState *s, continue; } QLIST_FOREACH(item, &version->items, next) { - quorum_report_bad(acb, s->bs[item->index]->node_name, 0); + quorum_report_bad(acb, s->children[item->index]->bs->node_name, 0); } } } @@ -369,8 +369,9 @@ static bool quorum_rewrite_bad_versions(BDRVQuorumState *s, QuorumAIOCB *acb, continue; } QLIST_FOREACH(item, &version->items, next) { - bdrv_aio_writev(s->bs[item->index], acb->sector_num, acb->qiov, - acb->nb_sectors, quorum_rewrite_aio_cb, acb); + bdrv_aio_writev(s->children[item->index]->bs, acb->sector_num, + acb->qiov, acb->nb_sectors, quorum_rewrite_aio_cb, + acb); } } @@ -639,13 +640,13 @@ static BlockAIOCB *read_quorum_children(QuorumAIOCB *acb) int i; for (i = 0; i < s->num_children; i++) { - acb->qcrs[i].buf = qemu_blockalign(s->bs[i], acb->qiov->size); + acb->qcrs[i].buf = qemu_blockalign(s->children[i]->bs, acb->qiov->size); qemu_iovec_init(&acb->qcrs[i].qiov, acb->qiov->niov); qemu_iovec_clone(&acb->qcrs[i].qiov, acb->qiov, acb->qcrs[i].buf); } for (i = 0; i < s->num_children; i++) { - bdrv_aio_readv(s->bs[i], acb->sector_num, &acb->qcrs[i].qiov, + bdrv_aio_readv(s->children[i]->bs, acb->sector_num, &acb->qcrs[i].qiov, acb->nb_sectors, quorum_aio_cb, &acb->qcrs[i]); } @@ -656,12 +657,12 @@ static BlockAIOCB *read_fifo_child(QuorumAIOCB *acb) { BDRVQuorumState *s = acb->common.bs->opaque; - acb->qcrs[acb->child_iter].buf = qemu_blockalign(s->bs[acb->child_iter], - acb->qiov->size); + acb->qcrs[acb->child_iter].buf = + qemu_blockalign(s->children[acb->child_iter]->bs, acb->qiov->size); qemu_iovec_init(&acb->qcrs[acb->child_iter].qiov, acb->qiov->niov); qemu_iovec_clone(&acb->qcrs[acb->child_iter].qiov, acb->qiov, acb->qcrs[acb->child_iter].buf); - bdrv_aio_readv(s->bs[acb->child_iter], acb->sector_num, + bdrv_aio_readv(s->children[acb->child_iter]->bs, acb->sector_num, &acb->qcrs[acb->child_iter].qiov, acb->nb_sectors, quorum_aio_cb, &acb->qcrs[acb->child_iter]); @@ -702,8 +703,8 @@ static BlockAIOCB *quorum_aio_writev(BlockDriverState *bs, int i; for (i = 0; i < s->num_children; i++) { - acb->qcrs[i].aiocb = bdrv_aio_writev(s->bs[i], sector_num, qiov, - nb_sectors, &quorum_aio_cb, + acb->qcrs[i].aiocb = bdrv_aio_writev(s->children[i]->bs, sector_num, + qiov, nb_sectors, &quorum_aio_cb, &acb->qcrs[i]); } @@ -717,12 +718,12 @@ static int64_t quorum_getlength(BlockDriverState *bs) int i; /* check that all file have the same length */ - result = bdrv_getlength(s->bs[0]); + result = bdrv_getlength(s->children[0]->bs); if (result < 0) { return result; } for (i = 1; i < s->num_children; i++) { - int64_t value = bdrv_getlength(s->bs[i]); + int64_t value = bdrv_getlength(s->children[i]->bs); if (value < 0) { return value; } @@ -741,7 +742,7 @@ static void quorum_invalidate_cache(BlockDriverState *bs, Error **errp) int i; for (i = 0; i < s->num_children; i++) { - bdrv_invalidate_cache(s->bs[i], &local_err); + bdrv_invalidate_cache(s->children[i]->bs, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -762,7 +763,7 @@ static coroutine_fn int quorum_co_flush(BlockDriverState *bs) error_votes.compare = quorum_64bits_compare; for (i = 0; i < s->num_children; i++) { - result = bdrv_co_flush(s->bs[i]); + result = bdrv_co_flush(s->children[i]->bs); result_value.l = result; quorum_count_vote(&error_votes, &result_value, i); } @@ -782,7 +783,7 @@ static bool quorum_recurse_is_first_non_filter(BlockDriverState *bs, int i; for (i = 0; i < s->num_children; i++) { - bool perm = bdrv_recurse_is_first_non_filter(s->bs[i], + bool perm = bdrv_recurse_is_first_non_filter(s->children[i]->bs, candidate); if (perm) { return true; @@ -923,7 +924,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, } /* allocate the children BlockDriverState array */ - s->bs = g_new0(BlockDriverState *, s->num_children); + s->children = g_new0(BdrvChild *, s->num_children); opened = g_new0(bool, s->num_children); for (i = 0; i < s->num_children; i++) { @@ -931,9 +932,10 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, ret = snprintf(indexstr, 32, "children.%d", i); assert(ret < 32); - ret = bdrv_open_image(&s->bs[i], NULL, options, indexstr, bs, - &child_format, false, &local_err); - if (ret < 0) { + s->children[i] = bdrv_open_child(NULL, options, indexstr, bs, + &child_format, false, &local_err); + if (local_err) { + ret = -EINVAL; goto close_exit; } @@ -949,9 +951,9 @@ close_exit: if (!opened[i]) { continue; } - bdrv_unref(s->bs[i]); + bdrv_unref_child(bs, s->children[i]); } - g_free(s->bs); + g_free(s->children); g_free(opened); exit: qemu_opts_del(opts); @@ -968,10 +970,10 @@ static void quorum_close(BlockDriverState *bs) int i; for (i = 0; i < s->num_children; i++) { - bdrv_unref(s->bs[i]); + bdrv_unref(s->children[i]->bs); } - g_free(s->bs); + g_free(s->children); } static void quorum_detach_aio_context(BlockDriverState *bs) @@ -980,7 +982,7 @@ static void quorum_detach_aio_context(BlockDriverState *bs) int i; for (i = 0; i < s->num_children; i++) { - bdrv_detach_aio_context(s->bs[i]); + bdrv_detach_aio_context(s->children[i]->bs); } } @@ -991,7 +993,7 @@ static void quorum_attach_aio_context(BlockDriverState *bs, int i; for (i = 0; i < s->num_children; i++) { - bdrv_attach_aio_context(s->bs[i], new_context); + bdrv_attach_aio_context(s->children[i]->bs, new_context); } } @@ -1003,16 +1005,17 @@ static void quorum_refresh_filename(BlockDriverState *bs) int i; for (i = 0; i < s->num_children; i++) { - bdrv_refresh_filename(s->bs[i]); - if (!s->bs[i]->full_open_options) { + bdrv_refresh_filename(s->children[i]->bs); + if (!s->children[i]->bs->full_open_options) { return; } } children = qlist_new(); for (i = 0; i < s->num_children; i++) { - QINCREF(s->bs[i]->full_open_options); - qlist_append_obj(children, QOBJECT(s->bs[i]->full_open_options)); + QINCREF(s->children[i]->bs->full_open_options); + qlist_append_obj(children, + QOBJECT(s->children[i]->bs->full_open_options)); } opts = qdict_new(); -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:48:51 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYR-0001z5-6y for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:48:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYL-0001oC-3k for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZYJ-00024c-Ap for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54863) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYJ-00024Q-6d; Thu, 17 Sep 2015 09:48:43 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id D4F708EA57; Thu, 17 Sep 2015 13:48:42 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHm030423; Thu, 17 Sep 2015 09:48:40 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:10 +0200 Message-Id: <1442497700-2536-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 06/16] block: Remove bdrv_open_image() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:48:49 -0000 It is unused now. Signed-off-by: Kevin Wolf --- block.c | 34 ---------------------------------- include/block/block.h | 4 ---- 2 files changed, 38 deletions(-) diff --git a/block.c b/block.c index 93d713b..3992241 100644 --- a/block.c +++ b/block.c @@ -1279,40 +1279,6 @@ done: return c; } -/* - * This is a version of bdrv_open_child() that returns 0/-EINVAL instead of - * a BdrvChild object. - * - * If allow_none is true, no image will be opened if filename is false and no - * BlockdevRef is given. *pbs will remain unchanged and 0 will be returned. - * - * To conform with the behavior of bdrv_open(), *pbs has to be NULL. - */ -int bdrv_open_image(BlockDriverState **pbs, const char *filename, - QDict *options, const char *bdref_key, - BlockDriverState* parent, const BdrvChildRole *child_role, - bool allow_none, Error **errp) -{ - Error *local_err = NULL; - BdrvChild *c; - - assert(pbs); - assert(*pbs == NULL); - - c = bdrv_open_child(filename, options, bdref_key, parent, child_role, - allow_none, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return -EINVAL; - } - - if (c != NULL) { - *pbs = c->bs; - } - - return 0; -} - int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp) { /* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */ diff --git a/include/block/block.h b/include/block/block.h index 79b2e91..130477c 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -204,10 +204,6 @@ void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old); void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top); int bdrv_parse_cache_flags(const char *mode, int *flags); int bdrv_parse_discard_flags(const char *mode, int *flags); -int bdrv_open_image(BlockDriverState **pbs, const char *filename, - QDict *options, const char *bdref_key, - BlockDriverState* parent, const BdrvChildRole *child_role, - bool allow_none, Error **errp); BdrvChild *bdrv_open_child(const char *filename, QDict *options, const char *bdref_key, BlockDriverState* parent, -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:48:57 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYX-0002Ap-O3 for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:48:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYU-00025G-On for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZYO-00026F-MM for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59265) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYO-000262-DZ; Thu, 17 Sep 2015 09:48:48 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 13366C04FF81; Thu, 17 Sep 2015 13:48:48 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHo030423; Thu, 17 Sep 2015 09:48:45 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:12 +0200 Message-Id: <1442497700-2536-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 08/16] block: Manage backing file references in bdrv_set_backing_hd() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:48:56 -0000 This simplifies the code somewhat, especially when dropping whole backing file subchains. The exception is the mirroring code that does adventurous things with bdrv_swap() and in order to keep it working, I had to duplicate most of bdrv_set_backing_hd() locally. We'll get rid again of this ugliness shortly. Signed-off-by: Kevin Wolf --- block.c | 35 ++++++++++++++--------------------- block/mirror.c | 17 ++++++++++++----- block/stream.c | 21 --------------------- block/vvfat.c | 6 +++++- include/block/block.h | 1 + 5 files changed, 32 insertions(+), 48 deletions(-) diff --git a/block.c b/block.c index fb94567..743f82e 100644 --- a/block.c +++ b/block.c @@ -1094,7 +1094,7 @@ static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, return child; } -static void bdrv_detach_child(BdrvChild *child) +void bdrv_detach_child(BdrvChild *child) { QLIST_REMOVE(child, next); g_free(child); @@ -1112,13 +1112,20 @@ void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child) bdrv_unref(child_bs); } +/* + * Sets the backing file link of a BDS. A new reference is created; callers + * which don't need their own reference any more must call bdrv_unref(). + */ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd) { + if (backing_hd) { + bdrv_ref(backing_hd); + } if (bs->backing) { assert(bs->backing_blocker); bdrv_op_unblock_all(bs->backing->bs, bs->backing_blocker); - bdrv_detach_child(bs->backing); + bdrv_unref_child(bs, bs->backing); } else if (backing_hd) { error_setg(&bs->backing_blocker, "node is used as backing hd of '%s'", @@ -1214,7 +1221,10 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) goto free_exit; } + /* Hook up the backing file link; drop our reference, bs owns the + * backing_hd reference now */ bdrv_set_backing_hd(bs, backing_hd); + bdrv_unref(backing_hd); free_exit: g_free(backing_filename); @@ -1884,11 +1894,7 @@ void bdrv_close(BlockDriverState *bs) bs->drv->bdrv_close(bs); - if (bs->backing) { - BlockDriverState *backing_hd = bs->backing->bs; - bdrv_set_backing_hd(bs, NULL); - bdrv_unref(backing_hd); - } + bdrv_set_backing_hd(bs, NULL); if (bs->file != NULL) { bdrv_unref(bs->file->bs); @@ -2427,12 +2433,9 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top, BlockDriverState *intermediate; BlockDriverState *base_bs = NULL; BlockDriverState *new_top_bs = NULL; - BlkIntermediateStates *intermediate_state, *next; + BlkIntermediateStates *intermediate_state; int ret = -EIO; - QSIMPLEQ_HEAD(states_to_delete, BlkIntermediateStates) states_to_delete; - QSIMPLEQ_INIT(&states_to_delete); - if (!top->drv || !base->drv) { goto exit; } @@ -2459,7 +2462,6 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top, while (intermediate) { intermediate_state = g_new0(BlkIntermediateStates, 1); intermediate_state->bs = intermediate; - QSIMPLEQ_INSERT_TAIL(&states_to_delete, intermediate_state, entry); if (backing_bs(intermediate) == base) { base_bs = backing_bs(intermediate); @@ -2482,17 +2484,8 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top, } bdrv_set_backing_hd(new_top_bs, base_bs); - QSIMPLEQ_FOREACH_SAFE(intermediate_state, &states_to_delete, entry, next) { - /* so that bdrv_close() does not recursively close the chain */ - bdrv_set_backing_hd(intermediate_state->bs, NULL); - bdrv_unref(intermediate_state->bs); - } ret = 0; - exit: - QSIMPLEQ_FOREACH_SAFE(intermediate_state, &states_to_delete, entry, next) { - g_free(intermediate_state); - } return ret; } diff --git a/block/mirror.c b/block/mirror.c index 259e11a..571da27 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -370,11 +370,18 @@ static void mirror_exit(BlockJob *job, void *opaque) bdrv_swap(s->target, to_replace); if (s->common.driver->job_type == BLOCK_JOB_TYPE_COMMIT) { /* drop the bs loop chain formed by the swap: break the loop then - * trigger the unref from the top one */ - BlockDriverState *p = s->base->backing - ? s->base->backing->bs : NULL; - bdrv_set_backing_hd(s->base, NULL); - bdrv_unref(p); + * trigger the unref */ + /* FIXME This duplicates bdrv_set_backing_hd(), except for the + * actual detach/unref so that the loop can be broken. When + * bdrv_swap() gets replaced, this will become sane again. */ + BlockDriverState *backing = s->base->backing->bs; + assert(s->base->backing_blocker); + bdrv_op_unblock_all(s->base->backing->bs, s->base->backing_blocker); + error_free(s->base->backing_blocker); + s->base->backing_blocker = NULL; + bdrv_detach_child(s->base->backing); + s->base->backing = NULL; + bdrv_unref(backing); } } if (s->to_replace) { diff --git a/block/stream.c b/block/stream.c index ece7b58..c20aedb 100644 --- a/block/stream.c +++ b/block/stream.c @@ -55,28 +55,7 @@ static int coroutine_fn stream_populate(BlockDriverState *bs, static void close_unused_images(BlockDriverState *top, BlockDriverState *base, const char *base_id) { - BlockDriverState *intermediate; - intermediate = top->backing ? top->backing->bs : NULL; - - /* Must assign before bdrv_delete() to prevent traversing dangling pointer - * while we delete backing image instances. - */ bdrv_set_backing_hd(top, base); - - while (intermediate) { - BlockDriverState *unused; - - /* reached base */ - if (intermediate == base) { - break; - } - - unused = intermediate; - intermediate = intermediate->backing ? intermediate->backing->bs : NULL; - bdrv_set_backing_hd(unused, NULL); - bdrv_unref(unused); - } - bdrv_refresh_limits(top, NULL); } diff --git a/block/vvfat.c b/block/vvfat.c index 7c4b0f5..b41055a 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -2923,6 +2923,7 @@ static BlockDriver vvfat_write_target = { static int enable_write_target(BDRVVVFATState *s, Error **errp) { BlockDriver *bdrv_qcow = NULL; + BlockDriverState *backing; QemuOpts *opts = NULL; int ret; int size = sector2cluster(s, s->sector_count); @@ -2971,7 +2972,10 @@ static int enable_write_target(BDRVVVFATState *s, Error **errp) unlink(s->qcow_filename); #endif - bdrv_set_backing_hd(s->bs, bdrv_new()); + backing = bdrv_new(); + bdrv_set_backing_hd(s->bs, backing); + bdrv_unref(backing); + s->bs->backing->bs->drv = &vvfat_write_target; s->bs->backing->bs->opaque = g_new(void *, 1); *(void**)s->bs->backing->bs->opaque = s; diff --git a/include/block/block.h b/include/block/block.h index 130477c..6dc6766 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -510,6 +510,7 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs); void bdrv_ref(BlockDriverState *bs); void bdrv_unref(BlockDriverState *bs); void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child); +void bdrv_detach_child(BdrvChild *child); bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp); void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason); -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:48:59 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYZ-0002Dj-I9 for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:48:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYU-00024X-BM for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZYM-00025s-C4 for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38105) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYM-00025O-04; Thu, 17 Sep 2015 09:48:46 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id A2BEEA2C26; Thu, 17 Sep 2015 13:48:45 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHn030423; Thu, 17 Sep 2015 09:48:43 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:11 +0200 Message-Id: <1442497700-2536-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 07/16] block: Convert bs->backing_hd to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:48:57 -0000 This is the final step in converting all of the BlockDriverState pointers that block drivers use to BdrvChild. After this patch, bs->children contains the full list of child nodes that are referenced by a given BDS, and these children are only referenced through BdrvChild, so that updating the pointer in there is enough for changing edges in the graph. Signed-off-by: Kevin Wolf --- block.c | 116 +++++++++++++++++++++++++--------------------- block/io.c | 24 +++++----- block/mirror.c | 7 +-- block/qapi.c | 8 ++-- block/qcow.c | 4 +- block/qcow2-cluster.c | 4 +- block/qcow2.c | 6 +-- block/qed.c | 12 ++--- block/stream.c | 10 ++-- block/vmdk.c | 21 +++++---- block/vvfat.c | 6 +-- blockdev.c | 6 +-- include/block/block_int.h | 12 +++-- qemu-img.c | 8 ++-- 14 files changed, 130 insertions(+), 114 deletions(-) diff --git a/block.c b/block.c index 3992241..fb94567 100644 --- a/block.c +++ b/block.c @@ -721,7 +721,7 @@ const BdrvChildRole child_format = { }; /* - * Returns the flags that bs->backing_hd should get, based on the given flags + * Returns the flags that bs->backing should get, based on the given flags * for the parent BDS */ static int bdrv_backing_flags(int flags) @@ -1115,32 +1115,31 @@ void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child) void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd) { - if (bs->backing_hd) { + if (bs->backing) { assert(bs->backing_blocker); - bdrv_op_unblock_all(bs->backing_hd, bs->backing_blocker); - bdrv_detach_child(bs->backing_child); + bdrv_op_unblock_all(bs->backing->bs, bs->backing_blocker); + bdrv_detach_child(bs->backing); } else if (backing_hd) { error_setg(&bs->backing_blocker, "node is used as backing hd of '%s'", bdrv_get_device_or_node_name(bs)); } - bs->backing_hd = backing_hd; if (!backing_hd) { error_free(bs->backing_blocker); bs->backing_blocker = NULL; - bs->backing_child = NULL; + bs->backing = NULL; goto out; } - bs->backing_child = bdrv_attach_child(bs, backing_hd, &child_backing); + bs->backing = bdrv_attach_child(bs, backing_hd, &child_backing); bs->open_flags &= ~BDRV_O_NO_BACKING; pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_hd->filename); pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_hd->drv ? backing_hd->drv->format_name : ""); - bdrv_op_block_all(bs->backing_hd, bs->backing_blocker); + bdrv_op_block_all(backing_hd, bs->backing_blocker); /* Otherwise we won't be able to commit due to check in bdrv_commit */ - bdrv_op_unblock(bs->backing_hd, BLOCK_OP_TYPE_COMMIT_TARGET, + bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_COMMIT_TARGET, bs->backing_blocker); out: bdrv_refresh_limits(bs, NULL); @@ -1161,7 +1160,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) BlockDriverState *backing_hd; Error *local_err = NULL; - if (bs->backing_hd != NULL) { + if (bs->backing != NULL) { QDECREF(options); goto free_exit; } @@ -1201,7 +1200,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) qdict_put(options, "driver", qstring_from_str(bs->backing_format)); } - assert(bs->backing_hd == NULL); + assert(bs->backing == NULL); ret = bdrv_open_inherit(&backing_hd, *backing_filename ? backing_filename : NULL, NULL, options, 0, bs, &child_backing, &local_err); @@ -1885,8 +1884,8 @@ void bdrv_close(BlockDriverState *bs) bs->drv->bdrv_close(bs); - if (bs->backing_hd) { - BlockDriverState *backing_hd = bs->backing_hd; + if (bs->backing) { + BlockDriverState *backing_hd = bs->backing->bs; bdrv_set_backing_hd(bs, NULL); bdrv_unref(backing_hd); } @@ -2204,20 +2203,20 @@ int bdrv_commit(BlockDriverState *bs) if (!drv) return -ENOMEDIUM; - if (!bs->backing_hd) { + if (!bs->backing) { return -ENOTSUP; } if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT_SOURCE, NULL) || - bdrv_op_is_blocked(bs->backing_hd, BLOCK_OP_TYPE_COMMIT_TARGET, NULL)) { + bdrv_op_is_blocked(bs->backing->bs, BLOCK_OP_TYPE_COMMIT_TARGET, NULL)) { return -EBUSY; } - ro = bs->backing_hd->read_only; - open_flags = bs->backing_hd->open_flags; + ro = bs->backing->bs->read_only; + open_flags = bs->backing->bs->open_flags; if (ro) { - if (bdrv_reopen(bs->backing_hd, open_flags | BDRV_O_RDWR, NULL)) { + if (bdrv_reopen(bs->backing->bs, open_flags | BDRV_O_RDWR, NULL)) { return -EACCES; } } @@ -2228,7 +2227,7 @@ int bdrv_commit(BlockDriverState *bs) goto ro_cleanup; } - backing_length = bdrv_getlength(bs->backing_hd); + backing_length = bdrv_getlength(bs->backing->bs); if (backing_length < 0) { ret = backing_length; goto ro_cleanup; @@ -2238,7 +2237,7 @@ int bdrv_commit(BlockDriverState *bs) * grow the backing file image if possible. If not possible, * we must return an error */ if (length > backing_length) { - ret = bdrv_truncate(bs->backing_hd, length); + ret = bdrv_truncate(bs->backing->bs, length); if (ret < 0) { goto ro_cleanup; } @@ -2247,7 +2246,7 @@ int bdrv_commit(BlockDriverState *bs) total_sectors = length >> BDRV_SECTOR_BITS; /* qemu_try_blockalign() for bs will choose an alignment that works for - * bs->backing_hd as well, so no need to compare the alignment manually. */ + * bs->backing->bs as well, so no need to compare the alignment manually. */ buf = qemu_try_blockalign(bs, COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE); if (buf == NULL) { ret = -ENOMEM; @@ -2265,7 +2264,7 @@ int bdrv_commit(BlockDriverState *bs) goto ro_cleanup; } - ret = bdrv_write(bs->backing_hd, sector, buf, n); + ret = bdrv_write(bs->backing->bs, sector, buf, n); if (ret < 0) { goto ro_cleanup; } @@ -2284,8 +2283,8 @@ int bdrv_commit(BlockDriverState *bs) * Make sure all data we wrote to the backing device is actually * stable on disk. */ - if (bs->backing_hd) { - bdrv_flush(bs->backing_hd); + if (bs->backing) { + bdrv_flush(bs->backing->bs); } ret = 0; @@ -2294,7 +2293,7 @@ ro_cleanup: if (ro) { /* ignoring error return here */ - bdrv_reopen(bs->backing_hd, open_flags & ~BDRV_O_RDWR, NULL); + bdrv_reopen(bs->backing->bs, open_flags & ~BDRV_O_RDWR, NULL); } return ret; @@ -2308,7 +2307,7 @@ int bdrv_commit_all(void) AioContext *aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); - if (bs->drv && bs->backing_hd) { + if (bs->drv && bs->backing) { int ret = bdrv_commit(bs); if (ret < 0) { aio_context_release(aio_context); @@ -2365,11 +2364,20 @@ int bdrv_change_backing_file(BlockDriverState *bs, BlockDriverState *bdrv_find_overlay(BlockDriverState *active, BlockDriverState *bs) { - while (active && bs != active->backing_hd) { - active = active->backing_hd; + while (active) { + if (active->backing) { + if (bs == active->backing->bs) { + return active; + } + active = active->backing->bs; + } else if (bs == NULL) { + return active; + } else { + return NULL; + } } - return active; + return NULL; } /* Given a BDS, searches for the base layer. */ @@ -2436,9 +2444,9 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top, goto exit; } - /* special case of new_top_bs->backing_hd already pointing to base - nothing + /* special case of new_top_bs->backing->bs already pointing to base - nothing * to do, no intermediate images */ - if (new_top_bs->backing_hd == base) { + if (backing_bs(new_top_bs) == base) { ret = 0; goto exit; } @@ -2453,11 +2461,11 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top, intermediate_state->bs = intermediate; QSIMPLEQ_INSERT_TAIL(&states_to_delete, intermediate_state, entry); - if (intermediate->backing_hd == base) { - base_bs = intermediate->backing_hd; + if (backing_bs(intermediate) == base) { + base_bs = backing_bs(intermediate); break; } - intermediate = intermediate->backing_hd; + intermediate = backing_bs(intermediate); } if (base_bs == NULL) { /* something went wrong, we did not end at the base. safely @@ -2676,25 +2684,27 @@ void bdrv_set_enable_write_cache(BlockDriverState *bs, bool wce) int bdrv_is_encrypted(BlockDriverState *bs) { - if (bs->backing_hd && bs->backing_hd->encrypted) + if (bs->backing && bs->backing->bs->encrypted) { return 1; + } return bs->encrypted; } int bdrv_key_required(BlockDriverState *bs) { - BlockDriverState *backing_hd = bs->backing_hd; + BdrvChild *backing = bs->backing; - if (backing_hd && backing_hd->encrypted && !backing_hd->valid_key) + if (backing && backing->bs->encrypted && !backing->bs->valid_key) { return 1; + } return (bs->encrypted && !bs->valid_key); } int bdrv_set_key(BlockDriverState *bs, const char *key) { int ret; - if (bs->backing_hd && bs->backing_hd->encrypted) { - ret = bdrv_set_key(bs->backing_hd, key); + if (bs->backing && bs->backing->bs->encrypted) { + ret = bdrv_set_key(bs->backing->bs, key); if (ret < 0) return ret; if (!bs->encrypted) @@ -2861,7 +2871,7 @@ BlockDriverState *bdrv_lookup_bs(const char *device, bool bdrv_chain_contains(BlockDriverState *top, BlockDriverState *base) { while (top && top != base) { - top = top->backing_hd; + top = backing_bs(top); } return top != NULL; @@ -2919,7 +2929,7 @@ int bdrv_has_zero_init(BlockDriverState *bs) /* If BS is a copy on write image, it is initialized to the contents of the base image, which may not be zeroes. */ - if (bs->backing_hd) { + if (bs->backing) { return 0; } if (bs->drv->bdrv_has_zero_init) { @@ -2934,7 +2944,7 @@ bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs) { BlockDriverInfo bdi; - if (bs->backing_hd) { + if (bs->backing) { return false; } @@ -2949,7 +2959,7 @@ bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs) { BlockDriverInfo bdi; - if (bs->backing_hd || !(bs->open_flags & BDRV_O_UNMAP)) { + if (bs->backing || !(bs->open_flags & BDRV_O_UNMAP)) { return false; } @@ -2962,7 +2972,7 @@ bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs) const char *bdrv_get_encrypted_filename(BlockDriverState *bs) { - if (bs->backing_hd && bs->backing_hd->encrypted) + if (bs->backing && bs->backing->bs->encrypted) return bs->backing_file; else if (bs->encrypted) return bs->filename; @@ -3087,13 +3097,13 @@ BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, is_protocol = path_has_protocol(backing_file); - for (curr_bs = bs; curr_bs->backing_hd; curr_bs = curr_bs->backing_hd) { + for (curr_bs = bs; curr_bs->backing; curr_bs = curr_bs->backing->bs) { /* If either of the filename paths is actually a protocol, then * compare unmodified paths; otherwise make paths relative */ if (is_protocol || path_has_protocol(curr_bs->backing_file)) { if (strcmp(backing_file, curr_bs->backing_file) == 0) { - retval = curr_bs->backing_hd; + retval = curr_bs->backing->bs; break; } } else { @@ -3117,7 +3127,7 @@ BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, } if (strcmp(backing_file_full, filename_full) == 0) { - retval = curr_bs->backing_hd; + retval = curr_bs->backing->bs; break; } } @@ -3135,11 +3145,11 @@ int bdrv_get_backing_file_depth(BlockDriverState *bs) return 0; } - if (!bs->backing_hd) { + if (!bs->backing) { return 0; } - return 1 + bdrv_get_backing_file_depth(bs->backing_hd); + return 1 + bdrv_get_backing_file_depth(bs->backing->bs); } void bdrv_init(void) @@ -3902,8 +3912,8 @@ void bdrv_detach_aio_context(BlockDriverState *bs) if (bs->file) { bdrv_detach_aio_context(bs->file->bs); } - if (bs->backing_hd) { - bdrv_detach_aio_context(bs->backing_hd); + if (bs->backing) { + bdrv_detach_aio_context(bs->backing->bs); } bs->aio_context = NULL; @@ -3920,8 +3930,8 @@ void bdrv_attach_aio_context(BlockDriverState *bs, bs->aio_context = new_context; - if (bs->backing_hd) { - bdrv_attach_aio_context(bs->backing_hd, new_context); + if (bs->backing) { + bdrv_attach_aio_context(bs->backing->bs, new_context); } if (bs->file) { bdrv_attach_aio_context(bs->file->bs, new_context); diff --git a/block/io.c b/block/io.c index 8a27efa..d7e742a 100644 --- a/block/io.c +++ b/block/io.c @@ -170,24 +170,24 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.opt_mem_alignment = getpagesize(); } - if (bs->backing_hd) { - bdrv_refresh_limits(bs->backing_hd, &local_err); + if (bs->backing) { + bdrv_refresh_limits(bs->backing->bs, &local_err); if (local_err) { error_propagate(errp, local_err); return; } bs->bl.opt_transfer_length = MAX(bs->bl.opt_transfer_length, - bs->backing_hd->bl.opt_transfer_length); + bs->backing->bs->bl.opt_transfer_length); bs->bl.max_transfer_length = MIN_NON_ZERO(bs->bl.max_transfer_length, - bs->backing_hd->bl.max_transfer_length); + bs->backing->bs->bl.max_transfer_length); bs->bl.opt_mem_alignment = MAX(bs->bl.opt_mem_alignment, - bs->backing_hd->bl.opt_mem_alignment); + bs->backing->bs->bl.opt_mem_alignment); bs->bl.min_mem_alignment = MAX(bs->bl.min_mem_alignment, - bs->backing_hd->bl.min_mem_alignment); + bs->backing->bs->bl.min_mem_alignment); } /* Then let the driver override it */ @@ -227,7 +227,7 @@ static bool bdrv_requests_pending(BlockDriverState *bs) if (bs->file && bdrv_requests_pending(bs->file->bs)) { return true; } - if (bs->backing_hd && bdrv_requests_pending(bs->backing_hd)) { + if (bs->backing && bdrv_requests_pending(bs->backing->bs)) { return true; } return false; @@ -1495,8 +1495,8 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, } else { if (bdrv_unallocated_blocks_are_zero(bs)) { ret |= BDRV_BLOCK_ZERO; - } else if (bs->backing_hd) { - BlockDriverState *bs2 = bs->backing_hd; + } else if (bs->backing) { + BlockDriverState *bs2 = bs->backing->bs; int64_t nb_sectors2 = bdrv_nb_sectors(bs2); if (nb_sectors2 >= 0 && sector_num >= nb_sectors2) { ret |= BDRV_BLOCK_ZERO; @@ -1541,7 +1541,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs, int64_t ret = 0; assert(bs != base); - for (p = bs; p != base; p = p->backing_hd) { + for (p = bs; p != base; p = backing_bs(p)) { ret = bdrv_co_get_block_status(p, sector_num, nb_sectors, pnum); if (ret < 0 || ret & BDRV_BLOCK_ALLOCATED) { break; @@ -1604,7 +1604,7 @@ int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { - return bdrv_get_block_status_above(bs, bs->backing_hd, + return bdrv_get_block_status_above(bs, backing_bs(bs), sector_num, nb_sectors, pnum); } @@ -1662,7 +1662,7 @@ int bdrv_is_allocated_above(BlockDriverState *top, n = pnum_inter; } - intermediate = intermediate->backing_hd; + intermediate = intermediate->backing ? intermediate->backing->bs : NULL; } *pnum = n; diff --git a/block/mirror.c b/block/mirror.c index a258926..259e11a 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -371,7 +371,8 @@ static void mirror_exit(BlockJob *job, void *opaque) if (s->common.driver->job_type == BLOCK_JOB_TYPE_COMMIT) { /* drop the bs loop chain formed by the swap: break the loop then * trigger the unref from the top one */ - BlockDriverState *p = s->base->backing_hd; + BlockDriverState *p = s->base->backing + ? s->base->backing->bs : NULL; bdrv_set_backing_hd(s->base, NULL); bdrv_unref(p); } @@ -431,7 +432,7 @@ static void coroutine_fn mirror_run(void *opaque) */ bdrv_get_backing_filename(s->target, backing_filename, sizeof(backing_filename)); - if (backing_filename[0] && !s->target->backing_hd) { + if (backing_filename[0] && !s->target->backing) { ret = bdrv_get_info(s->target, &bdi); if (ret < 0) { goto immediate_exit; @@ -764,7 +765,7 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, return; } is_none_mode = mode == MIRROR_SYNC_MODE_NONE; - base = mode == MIRROR_SYNC_MODE_TOP ? bs->backing_hd : NULL; + base = mode == MIRROR_SYNC_MODE_TOP && bs->backing ? bs->backing->bs : NULL; mirror_start_job(bs, target, replaces, speed, granularity, buf_size, on_source_error, on_target_error, unmap, cb, opaque, errp, diff --git a/block/qapi.c b/block/qapi.c index 0c4654e..355ba32 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -110,8 +110,8 @@ BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs, Error **errp) qapi_free_BlockDeviceInfo(info); return NULL; } - if (bs0->drv && bs0->backing_hd) { - bs0 = bs0->backing_hd; + if (bs0->drv && bs0->backing) { + bs0 = bs0->backing->bs; (*p_image_info)->has_backing_image = true; p_image_info = &((*p_image_info)->backing_image); } else { @@ -362,9 +362,9 @@ static BlockStats *bdrv_query_stats(const BlockDriverState *bs, s->parent = bdrv_query_stats(bs->file->bs, query_backing); } - if (query_backing && bs->backing_hd) { + if (query_backing && bs->backing) { s->has_backing = true; - s->backing = bdrv_query_stats(bs->backing_hd, query_backing); + s->backing = bdrv_query_stats(bs->backing->bs, query_backing); } return s; diff --git a/block/qcow.c b/block/qcow.c index 4d20cd5..b0f2d96 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -596,13 +596,13 @@ static coroutine_fn int qcow_co_readv(BlockDriverState *bs, int64_t sector_num, } if (!cluster_offset) { - if (bs->backing_hd) { + if (bs->backing) { /* read from the base image */ hd_iov.iov_base = (void *)buf; hd_iov.iov_len = n * 512; qemu_iovec_init_external(&hd_qiov, &hd_iov, 1); qemu_co_mutex_unlock(&s->lock); - ret = bdrv_co_readv(bs->backing_hd, sector_num, + ret = bdrv_co_readv(bs->backing->bs, sector_num, n, &hd_qiov); qemu_co_mutex_lock(&s->lock); if (ret < 0) { diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 7844f8e..71a8d13 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1474,7 +1474,7 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, */ switch (qcow2_get_cluster_type(old_l2_entry)) { case QCOW2_CLUSTER_UNALLOCATED: - if (full_discard || !bs->backing_hd) { + if (full_discard || !bs->backing) { continue; } break; @@ -1708,7 +1708,7 @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table, } if (!preallocated) { - if (!bs->backing_hd) { + if (!bs->backing) { /* not backed; therefore we can simply deallocate the * cluster */ l2_table[j] = 0; diff --git a/block/qcow2.c b/block/qcow2.c index 38b2797..bacc4f2 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1369,9 +1369,9 @@ static coroutine_fn int qcow2_co_readv(BlockDriverState *bs, int64_t sector_num, switch (ret) { case QCOW2_CLUSTER_UNALLOCATED: - if (bs->backing_hd) { + if (bs->backing) { /* read from the base image */ - n1 = qcow2_backing_read1(bs->backing_hd, &hd_qiov, + n1 = qcow2_backing_read1(bs->backing->bs, &hd_qiov, sector_num, cur_nr_sectors); if (n1 > 0) { QEMUIOVector local_qiov; @@ -1382,7 +1382,7 @@ static coroutine_fn int qcow2_co_readv(BlockDriverState *bs, int64_t sector_num, BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); qemu_co_mutex_unlock(&s->lock); - ret = bdrv_co_readv(bs->backing_hd, sector_num, + ret = bdrv_co_readv(bs->backing->bs, sector_num, n1, &local_qiov); qemu_co_mutex_lock(&s->lock); diff --git a/block/qed.c b/block/qed.c index d953f8c..0af81dc 100644 --- a/block/qed.c +++ b/block/qed.c @@ -772,8 +772,8 @@ static void qed_read_backing_file(BDRVQEDState *s, uint64_t pos, /* If there is a backing file, get its length. Treat the absence of a * backing file like a zero length backing file. */ - if (s->bs->backing_hd) { - int64_t l = bdrv_getlength(s->bs->backing_hd); + if (s->bs->backing) { + int64_t l = bdrv_getlength(s->bs->backing->bs); if (l < 0) { cb(opaque, l); return; @@ -802,7 +802,7 @@ static void qed_read_backing_file(BDRVQEDState *s, uint64_t pos, qemu_iovec_concat(*backing_qiov, qiov, 0, size); BLKDBG_EVENT(s->bs->file, BLKDBG_READ_BACKING_AIO); - bdrv_aio_readv(s->bs->backing_hd, pos / BDRV_SECTOR_SIZE, + bdrv_aio_readv(s->bs->backing->bs, pos / BDRV_SECTOR_SIZE, *backing_qiov, size / BDRV_SECTOR_SIZE, cb, opaque); } @@ -1081,7 +1081,7 @@ static void qed_aio_write_main(void *opaque, int ret) if (acb->find_cluster_ret == QED_CLUSTER_FOUND) { next_fn = qed_aio_next_io; } else { - if (s->bs->backing_hd) { + if (s->bs->backing) { next_fn = qed_aio_write_flush_before_l2_update; } else { next_fn = qed_aio_write_l2_update_cb; @@ -1139,7 +1139,7 @@ static void qed_aio_write_prefill(void *opaque, int ret) static bool qed_should_set_need_check(BDRVQEDState *s) { /* The flush before L2 update path ensures consistency */ - if (s->bs->backing_hd) { + if (s->bs->backing) { return false; } @@ -1443,7 +1443,7 @@ static int coroutine_fn bdrv_qed_co_write_zeroes(BlockDriverState *bs, struct iovec iov; /* Refuse if there are untouched backing file sectors */ - if (bs->backing_hd) { + if (bs->backing) { if (qed_offset_into_cluster(s, sector_num * BDRV_SECTOR_SIZE) != 0) { return -ENOTSUP; } diff --git a/block/stream.c b/block/stream.c index ab0bd05..ece7b58 100644 --- a/block/stream.c +++ b/block/stream.c @@ -56,7 +56,7 @@ static void close_unused_images(BlockDriverState *top, BlockDriverState *base, const char *base_id) { BlockDriverState *intermediate; - intermediate = top->backing_hd; + intermediate = top->backing ? top->backing->bs : NULL; /* Must assign before bdrv_delete() to prevent traversing dangling pointer * while we delete backing image instances. @@ -72,7 +72,7 @@ static void close_unused_images(BlockDriverState *top, BlockDriverState *base, } unused = intermediate; - intermediate = intermediate->backing_hd; + intermediate = intermediate->backing ? intermediate->backing->bs : NULL; bdrv_set_backing_hd(unused, NULL); bdrv_unref(unused); } @@ -121,7 +121,7 @@ static void coroutine_fn stream_run(void *opaque) int n = 0; void *buf; - if (!bs->backing_hd) { + if (!bs->backing) { block_job_completed(&s->common, 0); return; } @@ -166,8 +166,8 @@ wait: } else if (ret >= 0) { /* Copy if allocated in the intermediate images. Limit to the * known-unallocated area [sector_num, sector_num+n). */ - ret = bdrv_is_allocated_above(bs->backing_hd, base, - sector_num, n, &n); + ret = bdrv_is_allocated_above(bs->backing ? bs->backing->bs : NULL, + base, sector_num, n, &n); /* Finish early if end of backing file has been reached */ if (ret == 0 && n == 0) { diff --git a/block/vmdk.c b/block/vmdk.c index 9f7e7db..0effb7d 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -308,10 +308,11 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid) static int vmdk_is_cid_valid(BlockDriverState *bs) { BDRVVmdkState *s = bs->opaque; - BlockDriverState *p_bs = bs->backing_hd; uint32_t cur_pcid; - if (!s->cid_checked && p_bs) { + if (!s->cid_checked && bs->backing) { + BlockDriverState *p_bs = bs->backing->bs; + cur_pcid = vmdk_read_cid(p_bs, 0); if (s->parent_cid != cur_pcid) { /* CID not valid */ @@ -1006,7 +1007,7 @@ static int get_whole_cluster(BlockDriverState *bs, cluster_bytes = extent->cluster_sectors << BDRV_SECTOR_BITS; whole_grain = qemu_blockalign(bs, cluster_bytes); - if (!bs->backing_hd) { + if (!bs->backing) { memset(whole_grain, 0, skip_start_sector << BDRV_SECTOR_BITS); memset(whole_grain + (skip_end_sector << BDRV_SECTOR_BITS), 0, cluster_bytes - (skip_end_sector << BDRV_SECTOR_BITS)); @@ -1015,15 +1016,15 @@ static int get_whole_cluster(BlockDriverState *bs, assert(skip_end_sector <= extent->cluster_sectors); /* we will be here if it's first write on non-exist grain(cluster). * try to read from parent image, if exist */ - if (bs->backing_hd && !vmdk_is_cid_valid(bs)) { + if (bs->backing && !vmdk_is_cid_valid(bs)) { ret = VMDK_ERROR; goto exit; } /* Read backing data before skip range */ if (skip_start_sector > 0) { - if (bs->backing_hd) { - ret = bdrv_read(bs->backing_hd, sector_num, + if (bs->backing) { + ret = bdrv_read(bs->backing->bs, sector_num, whole_grain, skip_start_sector); if (ret < 0) { ret = VMDK_ERROR; @@ -1039,8 +1040,8 @@ static int get_whole_cluster(BlockDriverState *bs, } /* Read backing data after skip range */ if (skip_end_sector < extent->cluster_sectors) { - if (bs->backing_hd) { - ret = bdrv_read(bs->backing_hd, sector_num + skip_end_sector, + if (bs->backing) { + ret = bdrv_read(bs->backing->bs, sector_num + skip_end_sector, whole_grain + (skip_end_sector << BDRV_SECTOR_BITS), extent->cluster_sectors - skip_end_sector); if (ret < 0) { @@ -1433,11 +1434,11 @@ static int vmdk_read(BlockDriverState *bs, int64_t sector_num, } if (ret != VMDK_OK) { /* if not allocated, try to read from parent image, if exist */ - if (bs->backing_hd && ret != VMDK_ZEROED) { + if (bs->backing && ret != VMDK_ZEROED) { if (!vmdk_is_cid_valid(bs)) { return -EINVAL; } - ret = bdrv_read(bs->backing_hd, sector_num, buf, n); + ret = bdrv_read(bs->backing->bs, sector_num, buf, n); if (ret < 0) { return ret; } diff --git a/block/vvfat.c b/block/vvfat.c index 7ddc962..7c4b0f5 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -2972,9 +2972,9 @@ static int enable_write_target(BDRVVVFATState *s, Error **errp) #endif bdrv_set_backing_hd(s->bs, bdrv_new()); - s->bs->backing_hd->drv = &vvfat_write_target; - s->bs->backing_hd->opaque = g_new(void *, 1); - *(void**)s->bs->backing_hd->opaque = s; + s->bs->backing->bs->drv = &vvfat_write_target; + s->bs->backing->bs->opaque = g_new(void *, 1); + *(void**)s->bs->backing->bs->opaque = s; return 0; diff --git a/blockdev.c b/blockdev.c index 32b04b4..bc158ff 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2508,10 +2508,10 @@ void qmp_drive_backup(const char *device, const char *target, /* See if we have a backing HD we can use to create our new image * on top of. */ if (sync == MIRROR_SYNC_MODE_TOP) { - source = bs->backing_hd; - if (!source) { + if (!bs->backing) { sync = MIRROR_SYNC_MODE_FULL; } + source = bs->backing->bs; } if (sync == MIRROR_SYNC_MODE_NONE) { source = bs; @@ -2716,7 +2716,7 @@ void qmp_drive_mirror(const char *device, const char *target, } flags = bs->open_flags | BDRV_O_RDWR; - source = bs->backing_hd; + source = bs->backing ? bs->backing->bs : NULL; if (!source && sync == MIRROR_SYNC_MODE_TOP) { sync = MIRROR_SYNC_MODE_FULL; } diff --git a/include/block/block_int.h b/include/block/block_int.h index 98936c9..90971c0 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -378,8 +378,7 @@ struct BlockDriverState { QDict *full_open_options; char exact_filename[PATH_MAX]; - BlockDriverState *backing_hd; - BdrvChild *backing_child; + BdrvChild *backing; BdrvChild *file; NotifierList close_notifiers; @@ -458,6 +457,11 @@ struct BlockDriverState { NotifierWithReturn write_threshold_notifier; }; +static inline BlockDriverState *backing_bs(BlockDriverState *bs) +{ + return bs->backing ? bs->backing->bs : NULL; +} + /* Essential block drivers which must always be statically linked into qemu, and * which therefore can be accessed without using bdrv_find_format() */ @@ -496,7 +500,7 @@ void bdrv_add_before_write_notifier(BlockDriverState *bs, * * May be called from .bdrv_detach_aio_context() to detach children from the * current #AioContext. This is only needed by block drivers that manage their - * own children. Both ->file and ->backing_hd are automatically handled and + * own children. Both ->file and ->backing are automatically handled and * block drivers should not call this function on them explicitly. */ void bdrv_detach_aio_context(BlockDriverState *bs); @@ -506,7 +510,7 @@ void bdrv_detach_aio_context(BlockDriverState *bs); * * May be called from .bdrv_attach_aio_context() to attach children to the new * #AioContext. This is only needed by block drivers that manage their own - * children. Both ->file and ->backing_hd are automatically handled and block + * children. Both ->file and ->backing are automatically handled and block * drivers should not call this function on them explicitly. */ void bdrv_attach_aio_context(BlockDriverState *bs, diff --git a/qemu-img.c b/qemu-img.c index 6ff4e85..c4454da 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -747,11 +747,11 @@ static int img_commit(int argc, char **argv) /* This is different from QMP, which by default uses the deepest file in * the backing chain (i.e., the very base); however, the traditional * behavior of qemu-img commit is using the immediate backing file. */ - base_bs = bs->backing_hd; - if (!base_bs) { + if (!bs->backing) { error_setg(&local_err, "Image does not have a backing file"); goto done; } + base_bs = bs->backing->bs; } cbi = (CommonBlockJobCBInfo){ @@ -2206,11 +2206,11 @@ static int get_block_status(BlockDriverState *bs, int64_t sector_num, if (ret & (BDRV_BLOCK_ZERO|BDRV_BLOCK_DATA)) { break; } - bs = bs->backing_hd; - if (bs == NULL) { + if (bs->backing == NULL) { ret = 0; break; } + bs = bs->backing->bs; depth++; } -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:49:00 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYa-0002Fj-J5 for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:49:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYY-0002DA-LO for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZYT-00028u-5n for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36214) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYT-00028i-1A; Thu, 17 Sep 2015 09:48:53 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id A28D37F; Thu, 17 Sep 2015 13:48:52 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHq030423; Thu, 17 Sep 2015 09:48:50 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:14 +0200 Message-Id: <1442497700-2536-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 10/16] block/io: Make bdrv_requests_pending() public X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:48:59 -0000 Signed-off-by: Kevin Wolf --- block/io.c | 2 +- include/block/block_int.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index d7e742a..81371e6 100644 --- a/block/io.c +++ b/block/io.c @@ -213,7 +213,7 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs) } /* Check if any requests are in-flight (including throttled requests) */ -static bool bdrv_requests_pending(BlockDriverState *bs) +bool bdrv_requests_pending(BlockDriverState *bs) { if (!QLIST_EMPTY(&bs->tracked_requests)) { return true; diff --git a/include/block/block_int.h b/include/block/block_int.h index 90971c0..4598101 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -667,5 +667,6 @@ bool blk_dev_is_medium_locked(BlockBackend *blk); void blk_dev_resize_cb(BlockBackend *blk); void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors); +bool bdrv_requests_pending(BlockDriverState *bs); #endif /* BLOCK_INT_H */ -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:49:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYb-0002Ik-Nj for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:49:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYQ-0001yF-U4 for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:49:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZYH-00023x-HJ for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYG-00022m-Sd; Thu, 17 Sep 2015 09:48:41 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 8A9C8461DB; Thu, 17 Sep 2015 13:48:40 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHl030423; Thu, 17 Sep 2015 09:48:36 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:09 +0200 Message-Id: <1442497700-2536-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 05/16] block: Convert bs->file to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:49:00 -0000 This patch removes the temporary duplication between bs->file and bs->file_child by converting everything to BdrvChild. Signed-off-by: Kevin Wolf --- block.c | 61 ++++++++++++++++++++++------------------------ block/blkdebug.c | 32 ++++++++++++------------ block/blkverify.c | 33 ++++++++++++++----------- block/bochs.c | 8 +++--- block/cloop.c | 10 ++++---- block/dmg.c | 20 +++++++-------- block/io.c | 50 +++++++++++++++++++------------------- block/parallels.c | 38 +++++++++++++++-------------- block/qapi.c | 2 +- block/qcow.c | 42 +++++++++++++++++--------------- block/qcow2-cache.c | 11 +++++---- block/qcow2-cluster.c | 38 +++++++++++++++++------------ block/qcow2-refcount.c | 45 ++++++++++++++++++---------------- block/qcow2-snapshot.c | 30 ++++++++++++----------- block/qcow2.c | 62 ++++++++++++++++++++++++----------------------- block/qed-table.c | 4 +-- block/qed.c | 32 ++++++++++++------------ block/raw_bsd.c | 40 +++++++++++++++--------------- block/snapshot.c | 12 ++++----- block/vdi.c | 17 +++++++------ block/vhdx-log.c | 25 ++++++++++--------- block/vhdx.c | 36 ++++++++++++++------------- block/vmdk.c | 27 +++++++++++---------- block/vpc.c | 34 ++++++++++++++------------ include/block/block.h | 8 +++++- include/block/block_int.h | 3 +-- 26 files changed, 377 insertions(+), 343 deletions(-) diff --git a/block.c b/block.c index 2e9e5e2..93d713b 100644 --- a/block.c +++ b/block.c @@ -809,7 +809,7 @@ static QemuOptsList bdrv_runtime_opts = { * * Removes all processed options from *options. */ -static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file, +static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file, QDict *options, int flags, BlockDriver *drv, Error **errp) { int ret, open_flags; @@ -823,7 +823,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file, assert(options != NULL && bs->options != options); if (file != NULL) { - filename = file->filename; + filename = file->bs->filename; } else { filename = qdict_get_try_str(options, "filename"); } @@ -1401,7 +1401,8 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, const BdrvChildRole *child_role, Error **errp) { int ret; - BlockDriverState *file = NULL, *bs; + BdrvChild *file = NULL; + BlockDriverState *bs; BlockDriver *drv = NULL; const char *drvname; Error *local_err = NULL; @@ -1485,25 +1486,20 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, flags = bdrv_backing_flags(flags); } - assert(file == NULL); bs->open_flags = flags; - bs->file_child = bdrv_open_child(filename, options, "file", bs, - &child_file, true, &local_err); + file = bdrv_open_child(filename, options, "file", bs, + &child_file, true, &local_err); if (local_err) { ret = -EINVAL; goto fail; } - - if (bs->file_child) { - file = bs->file_child->bs; - } } /* Image format probing */ bs->probed = !drv; if (!drv && file) { - ret = find_image_format(file, filename, &drv, &local_err); + ret = find_image_format(file->bs, filename, &drv, &local_err); if (ret < 0) { goto fail; } @@ -1526,7 +1522,7 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, } if (file && (bs->file != file)) { - bdrv_unref(file); + bdrv_unref_child(bs, file); file = NULL; } @@ -1587,7 +1583,7 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, fail: if (file != NULL) { - bdrv_unref(file); + bdrv_unref_child(bs, file); } QDECREF(bs->options); QDECREF(options); @@ -1929,6 +1925,11 @@ void bdrv_close(BlockDriverState *bs) bdrv_unref(backing_hd); } + if (bs->file != NULL) { + bdrv_unref(bs->file->bs); + bs->file = NULL; + } + QLIST_FOREACH_SAFE(child, &bs->children, next, next) { /* TODO Remove bdrv_unref() from drivers' close function and use * bdrv_unref_child() here */ @@ -1953,11 +1954,6 @@ void bdrv_close(BlockDriverState *bs) bs->options = NULL; QDECREF(bs->full_open_options); bs->full_open_options = NULL; - - if (bs->file != NULL) { - bdrv_unref(bs->file); - bs->file = NULL; - } } if (bs->blk) { @@ -2565,7 +2561,7 @@ int64_t bdrv_get_allocated_file_size(BlockDriverState *bs) return drv->bdrv_get_allocated_file_size(bs); } if (bs->file) { - return bdrv_get_allocated_file_size(bs->file); + return bdrv_get_allocated_file_size(bs->file->bs); } return -ENOTSUP; } @@ -3047,7 +3043,7 @@ int bdrv_debug_breakpoint(BlockDriverState *bs, const char *event, const char *tag) { while (bs && bs->drv && !bs->drv->bdrv_debug_breakpoint) { - bs = bs->file; + bs = bs->file ? bs->file->bs : NULL; } if (bs && bs->drv && bs->drv->bdrv_debug_breakpoint) { @@ -3060,7 +3056,7 @@ int bdrv_debug_breakpoint(BlockDriverState *bs, const char *event, int bdrv_debug_remove_breakpoint(BlockDriverState *bs, const char *tag) { while (bs && bs->drv && !bs->drv->bdrv_debug_remove_breakpoint) { - bs = bs->file; + bs = bs->file ? bs->file->bs : NULL; } if (bs && bs->drv && bs->drv->bdrv_debug_remove_breakpoint) { @@ -3073,7 +3069,7 @@ int bdrv_debug_remove_breakpoint(BlockDriverState *bs, const char *tag) int bdrv_debug_resume(BlockDriverState *bs, const char *tag) { while (bs && (!bs->drv || !bs->drv->bdrv_debug_resume)) { - bs = bs->file; + bs = bs->file ? bs->file->bs : NULL; } if (bs && bs->drv && bs->drv->bdrv_debug_resume) { @@ -3086,7 +3082,7 @@ int bdrv_debug_resume(BlockDriverState *bs, const char *tag) bool bdrv_debug_is_suspended(BlockDriverState *bs, const char *tag) { while (bs && bs->drv && !bs->drv->bdrv_debug_is_suspended) { - bs = bs->file; + bs = bs->file ? bs->file->bs : NULL; } if (bs && bs->drv && bs->drv->bdrv_debug_is_suspended) { @@ -3208,7 +3204,7 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) if (bs->drv->bdrv_invalidate_cache) { bs->drv->bdrv_invalidate_cache(bs, &local_err); } else if (bs->file) { - bdrv_invalidate_cache(bs->file, &local_err); + bdrv_invalidate_cache(bs->file->bs, &local_err); } if (local_err) { error_propagate(errp, local_err); @@ -3938,7 +3934,7 @@ void bdrv_detach_aio_context(BlockDriverState *bs) bs->drv->bdrv_detach_aio_context(bs); } if (bs->file) { - bdrv_detach_aio_context(bs->file); + bdrv_detach_aio_context(bs->file->bs); } if (bs->backing_hd) { bdrv_detach_aio_context(bs->backing_hd); @@ -3962,7 +3958,7 @@ void bdrv_attach_aio_context(BlockDriverState *bs, bdrv_attach_aio_context(bs->backing_hd, new_context); } if (bs->file) { - bdrv_attach_aio_context(bs->file, new_context); + bdrv_attach_aio_context(bs->file->bs, new_context); } if (bs->drv->bdrv_attach_aio_context) { bs->drv->bdrv_attach_aio_context(bs, new_context); @@ -4174,7 +4170,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) /* This BDS's file name will most probably depend on its file's name, so * refresh that first */ if (bs->file) { - bdrv_refresh_filename(bs->file); + bdrv_refresh_filename(bs->file->bs); } if (drv->bdrv_refresh_filename) { @@ -4202,19 +4198,20 @@ void bdrv_refresh_filename(BlockDriverState *bs) /* If no specific options have been given for this BDS, the filename of * the underlying file should suffice for this one as well */ - if (bs->file->exact_filename[0] && !has_open_options) { - strcpy(bs->exact_filename, bs->file->exact_filename); + if (bs->file->bs->exact_filename[0] && !has_open_options) { + strcpy(bs->exact_filename, bs->file->bs->exact_filename); } /* Reconstructing the full options QDict is simple for most format block * drivers, as long as the full options are known for the underlying * file BDS. The full options QDict of that file BDS should somehow * contain a representation of the filename, therefore the following * suffices without querying the (exact_)filename of this BDS. */ - if (bs->file->full_open_options) { + if (bs->file->bs->full_open_options) { qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str(drv->format_name))); - QINCREF(bs->file->full_open_options); - qdict_put_obj(opts, "file", QOBJECT(bs->file->full_open_options)); + QINCREF(bs->file->bs->full_open_options); + qdict_put_obj(opts, "file", + QOBJECT(bs->file->bs->full_open_options)); bs->full_open_options = opts; } else { diff --git a/block/blkdebug.c b/block/blkdebug.c index bc247f4..117fce6 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -427,10 +427,10 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, s->state = 1; /* Open the backing file */ - assert(bs->file == NULL); - ret = bdrv_open_image(&bs->file, qemu_opt_get(opts, "x-image"), options, "image", - bs, &child_file, false, &local_err); - if (ret < 0) { + bs->file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "image", + bs, &child_file, false, &local_err); + if (local_err) { + ret = -EINVAL; error_propagate(errp, local_err); goto out; } @@ -449,7 +449,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, goto out; fail_unref: - bdrv_unref(bs->file); + bdrv_unref(bs->file->bs); out: qemu_opts_del(opts); return ret; @@ -510,7 +510,8 @@ static BlockAIOCB *blkdebug_aio_readv(BlockDriverState *bs, return inject_error(bs, cb, opaque, rule); } - return bdrv_aio_readv(bs->file, sector_num, qiov, nb_sectors, cb, opaque); + return bdrv_aio_readv(bs->file->bs, sector_num, qiov, nb_sectors, + cb, opaque); } static BlockAIOCB *blkdebug_aio_writev(BlockDriverState *bs, @@ -532,7 +533,8 @@ static BlockAIOCB *blkdebug_aio_writev(BlockDriverState *bs, return inject_error(bs, cb, opaque, rule); } - return bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, cb, opaque); + return bdrv_aio_writev(bs->file->bs, sector_num, qiov, nb_sectors, + cb, opaque); } static BlockAIOCB *blkdebug_aio_flush(BlockDriverState *bs, @@ -551,7 +553,7 @@ static BlockAIOCB *blkdebug_aio_flush(BlockDriverState *bs, return inject_error(bs, cb, opaque, rule); } - return bdrv_aio_flush(bs->file, cb, opaque); + return bdrv_aio_flush(bs->file->bs, cb, opaque); } @@ -716,12 +718,12 @@ static bool blkdebug_debug_is_suspended(BlockDriverState *bs, const char *tag) static int64_t blkdebug_getlength(BlockDriverState *bs) { - return bdrv_getlength(bs->file); + return bdrv_getlength(bs->file->bs); } static int blkdebug_truncate(BlockDriverState *bs, int64_t offset) { - return bdrv_truncate(bs->file, offset); + return bdrv_truncate(bs->file->bs, offset); } static void blkdebug_refresh_filename(BlockDriverState *bs) @@ -741,24 +743,24 @@ static void blkdebug_refresh_filename(BlockDriverState *bs) } } - if (force_json && !bs->file->full_open_options) { + if (force_json && !bs->file->bs->full_open_options) { /* The config file cannot be recreated, so creating a plain filename * is impossible */ return; } - if (!force_json && bs->file->exact_filename[0]) { + if (!force_json && bs->file->bs->exact_filename[0]) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "blkdebug:%s:%s", qdict_get_try_str(bs->options, "config") ?: "", - bs->file->exact_filename); + bs->file->bs->exact_filename); } opts = qdict_new(); qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("blkdebug"))); - QINCREF(bs->file->full_open_options); - qdict_put_obj(opts, "image", QOBJECT(bs->file->full_open_options)); + QINCREF(bs->file->bs->full_open_options); + qdict_put_obj(opts, "image", QOBJECT(bs->file->bs->full_open_options)); for (e = qdict_first(bs->options); e; e = qdict_next(bs->options, e)) { if (strcmp(qdict_entry_key(e), "x-image") && diff --git a/block/blkverify.c b/block/blkverify.c index 6b71622..f8655ad 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -123,10 +123,10 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags, } /* Open the raw file */ - assert(bs->file == NULL); - ret = bdrv_open_image(&bs->file, qemu_opt_get(opts, "x-raw"), options, - "raw", bs, &child_file, false, &local_err); - if (ret < 0) { + bs->file = bdrv_open_child(qemu_opt_get(opts, "x-raw"), options, "raw", + bs, &child_file, false, &local_err); + if (local_err) { + ret = -EINVAL; error_propagate(errp, local_err); goto fail; } @@ -238,13 +238,13 @@ static BlockAIOCB *blkverify_aio_readv(BlockDriverState *bs, nb_sectors, cb, opaque); acb->verify = blkverify_verify_readv; - acb->buf = qemu_blockalign(bs->file, qiov->size); + acb->buf = qemu_blockalign(bs->file->bs, qiov->size); qemu_iovec_init(&acb->raw_qiov, acb->qiov->niov); qemu_iovec_clone(&acb->raw_qiov, qiov, acb->buf); bdrv_aio_readv(s->test_file->bs, sector_num, qiov, nb_sectors, blkverify_aio_cb, acb); - bdrv_aio_readv(bs->file, sector_num, &acb->raw_qiov, nb_sectors, + bdrv_aio_readv(bs->file->bs, sector_num, &acb->raw_qiov, nb_sectors, blkverify_aio_cb, acb); return &acb->common; } @@ -259,7 +259,7 @@ static BlockAIOCB *blkverify_aio_writev(BlockDriverState *bs, bdrv_aio_writev(s->test_file->bs, sector_num, qiov, nb_sectors, blkverify_aio_cb, acb); - bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, + bdrv_aio_writev(bs->file->bs, sector_num, qiov, nb_sectors, blkverify_aio_cb, acb); return &acb->common; } @@ -279,7 +279,7 @@ static bool blkverify_recurse_is_first_non_filter(BlockDriverState *bs, { BDRVBlkverifyState *s = bs->opaque; - bool perm = bdrv_recurse_is_first_non_filter(bs->file, candidate); + bool perm = bdrv_recurse_is_first_non_filter(bs->file->bs, candidate); if (perm) { return true; @@ -308,15 +308,17 @@ static void blkverify_refresh_filename(BlockDriverState *bs) { BDRVBlkverifyState *s = bs->opaque; - /* bs->file has already been refreshed */ + /* bs->file->bs has already been refreshed */ bdrv_refresh_filename(s->test_file->bs); - if (bs->file->full_open_options && s->test_file->bs->full_open_options) { + if (bs->file->bs->full_open_options + && s->test_file->bs->full_open_options) + { QDict *opts = qdict_new(); qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("blkverify"))); - QINCREF(bs->file->full_open_options); - qdict_put_obj(opts, "raw", QOBJECT(bs->file->full_open_options)); + QINCREF(bs->file->bs->full_open_options); + qdict_put_obj(opts, "raw", QOBJECT(bs->file->bs->full_open_options)); QINCREF(s->test_file->bs->full_open_options); qdict_put_obj(opts, "test", QOBJECT(s->test_file->bs->full_open_options)); @@ -324,10 +326,13 @@ static void blkverify_refresh_filename(BlockDriverState *bs) bs->full_open_options = opts; } - if (bs->file->exact_filename[0] && s->test_file->bs->exact_filename[0]) { + if (bs->file->bs->exact_filename[0] + && s->test_file->bs->exact_filename[0]) + { snprintf(bs->exact_filename, sizeof(bs->exact_filename), "blkverify:%s:%s", - bs->file->exact_filename, s->test_file->bs->exact_filename); + bs->file->bs->exact_filename, + s->test_file->bs->exact_filename); } } diff --git a/block/bochs.c b/block/bochs.c index 199ac2b..18949b9 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -103,7 +103,7 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags, bs->read_only = 1; // no write support yet - ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs)); + ret = bdrv_pread(bs->file->bs, 0, &bochs, sizeof(bochs)); if (ret < 0) { return ret; } @@ -137,7 +137,7 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags, return -ENOMEM; } - ret = bdrv_pread(bs->file, le32_to_cpu(bochs.header), s->catalog_bitmap, + ret = bdrv_pread(bs->file->bs, le32_to_cpu(bochs.header), s->catalog_bitmap, s->catalog_size * 4); if (ret < 0) { goto fail; @@ -206,7 +206,7 @@ static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num) (s->extent_blocks + s->bitmap_blocks)); /* read in bitmap for current extent */ - ret = bdrv_pread(bs->file, bitmap_offset + (extent_offset / 8), + ret = bdrv_pread(bs->file->bs, bitmap_offset + (extent_offset / 8), &bitmap_entry, 1); if (ret < 0) { return ret; @@ -229,7 +229,7 @@ static int bochs_read(BlockDriverState *bs, int64_t sector_num, if (block_offset < 0) { return block_offset; } else if (block_offset > 0) { - ret = bdrv_pread(bs->file, block_offset, buf, 512); + ret = bdrv_pread(bs->file->bs, block_offset, buf, 512); if (ret < 0) { return ret; } diff --git a/block/cloop.c b/block/cloop.c index f328be0..4190ae0 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -66,7 +66,7 @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags, bs->read_only = 1; /* read header */ - ret = bdrv_pread(bs->file, 128, &s->block_size, 4); + ret = bdrv_pread(bs->file->bs, 128, &s->block_size, 4); if (ret < 0) { return ret; } @@ -92,7 +92,7 @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } - ret = bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4); + ret = bdrv_pread(bs->file->bs, 128 + 4, &s->n_blocks, 4); if (ret < 0) { return ret; } @@ -123,7 +123,7 @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags, return -ENOMEM; } - ret = bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size); + ret = bdrv_pread(bs->file->bs, 128 + 4 + 4, s->offsets, offsets_size); if (ret < 0) { goto fail; } @@ -203,8 +203,8 @@ static inline int cloop_read_block(BlockDriverState *bs, int block_num) int ret; uint32_t bytes = s->offsets[block_num + 1] - s->offsets[block_num]; - ret = bdrv_pread(bs->file, s->offsets[block_num], s->compressed_block, - bytes); + ret = bdrv_pread(bs->file->bs, s->offsets[block_num], + s->compressed_block, bytes); if (ret != bytes) { return -1; } diff --git a/block/dmg.c b/block/dmg.c index 9f25281..546a6f5 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -85,7 +85,7 @@ static int read_uint64(BlockDriverState *bs, int64_t offset, uint64_t *result) uint64_t buffer; int ret; - ret = bdrv_pread(bs->file, offset, &buffer, 8); + ret = bdrv_pread(bs->file->bs, offset, &buffer, 8); if (ret < 0) { return ret; } @@ -99,7 +99,7 @@ static int read_uint32(BlockDriverState *bs, int64_t offset, uint32_t *result) uint32_t buffer; int ret; - ret = bdrv_pread(bs->file, offset, &buffer, 4); + ret = bdrv_pread(bs->file->bs, offset, &buffer, 4); if (ret < 0) { return ret; } @@ -354,7 +354,7 @@ static int dmg_read_resource_fork(BlockDriverState *bs, DmgHeaderState *ds, offset += 4; buffer = g_realloc(buffer, count); - ret = bdrv_pread(bs->file, offset, buffer, count); + ret = bdrv_pread(bs->file->bs, offset, buffer, count); if (ret < 0) { goto fail; } @@ -391,7 +391,7 @@ static int dmg_read_plist_xml(BlockDriverState *bs, DmgHeaderState *ds, buffer = g_malloc(info_length + 1); buffer[info_length] = '\0'; - ret = bdrv_pread(bs->file, info_begin, buffer, info_length); + ret = bdrv_pread(bs->file->bs, info_begin, buffer, info_length); if (ret != info_length) { ret = -EINVAL; goto fail; @@ -446,7 +446,7 @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags, ds.max_sectors_per_chunk = 1; /* locate the UDIF trailer */ - offset = dmg_find_koly_offset(bs->file, errp); + offset = dmg_find_koly_offset(bs->file->bs, errp); if (offset < 0) { ret = offset; goto fail; @@ -514,9 +514,9 @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags, } /* initialize zlib engine */ - s->compressed_chunk = qemu_try_blockalign(bs->file, + s->compressed_chunk = qemu_try_blockalign(bs->file->bs, ds.max_compressed_size + 1); - s->uncompressed_chunk = qemu_try_blockalign(bs->file, + s->uncompressed_chunk = qemu_try_blockalign(bs->file->bs, 512 * ds.max_sectors_per_chunk); if (s->compressed_chunk == NULL || s->uncompressed_chunk == NULL) { ret = -ENOMEM; @@ -592,7 +592,7 @@ static inline int dmg_read_chunk(BlockDriverState *bs, uint64_t sector_num) case 0x80000005: { /* zlib compressed */ /* we need to buffer, because only the chunk as whole can be * inflated. */ - ret = bdrv_pread(bs->file, s->offsets[chunk], + ret = bdrv_pread(bs->file->bs, s->offsets[chunk], s->compressed_chunk, s->lengths[chunk]); if (ret != s->lengths[chunk]) { return -1; @@ -616,7 +616,7 @@ static inline int dmg_read_chunk(BlockDriverState *bs, uint64_t sector_num) case 0x80000006: /* bzip2 compressed */ /* we need to buffer, because only the chunk as whole can be * inflated. */ - ret = bdrv_pread(bs->file, s->offsets[chunk], + ret = bdrv_pread(bs->file->bs, s->offsets[chunk], s->compressed_chunk, s->lengths[chunk]); if (ret != s->lengths[chunk]) { return -1; @@ -641,7 +641,7 @@ static inline int dmg_read_chunk(BlockDriverState *bs, uint64_t sector_num) break; #endif /* CONFIG_BZIP2 */ case 1: /* copy */ - ret = bdrv_pread(bs->file, s->offsets[chunk], + ret = bdrv_pread(bs->file->bs, s->offsets[chunk], s->uncompressed_chunk, s->lengths[chunk]); if (ret != s->lengths[chunk]) { return -1; diff --git a/block/io.c b/block/io.c index d4bc83b..8a27efa 100644 --- a/block/io.c +++ b/block/io.c @@ -156,15 +156,15 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) /* Take some limits from the children as a default */ if (bs->file) { - bdrv_refresh_limits(bs->file, &local_err); + bdrv_refresh_limits(bs->file->bs, &local_err); if (local_err) { error_propagate(errp, local_err); return; } - bs->bl.opt_transfer_length = bs->file->bl.opt_transfer_length; - bs->bl.max_transfer_length = bs->file->bl.max_transfer_length; - bs->bl.min_mem_alignment = bs->file->bl.min_mem_alignment; - bs->bl.opt_mem_alignment = bs->file->bl.opt_mem_alignment; + bs->bl.opt_transfer_length = bs->file->bs->bl.opt_transfer_length; + bs->bl.max_transfer_length = bs->file->bs->bl.max_transfer_length; + bs->bl.min_mem_alignment = bs->file->bs->bl.min_mem_alignment; + bs->bl.opt_mem_alignment = bs->file->bs->bl.opt_mem_alignment; } else { bs->bl.min_mem_alignment = 512; bs->bl.opt_mem_alignment = getpagesize(); @@ -224,7 +224,7 @@ static bool bdrv_requests_pending(BlockDriverState *bs) if (!qemu_co_queue_empty(&bs->throttled_reqs[1])) { return true; } - if (bs->file && bdrv_requests_pending(bs->file)) { + if (bs->file && bdrv_requests_pending(bs->file->bs)) { return true; } if (bs->backing_hd && bdrv_requests_pending(bs->backing_hd)) { @@ -1127,13 +1127,13 @@ static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs, if (ret < 0) { /* Do nothing, write notifier decided to fail this request */ } else if (flags & BDRV_REQ_ZERO_WRITE) { - BLKDBG_EVENT(bs, BLKDBG_PWRITEV_ZERO); + bdrv_debug_event(bs, BLKDBG_PWRITEV_ZERO); ret = bdrv_co_do_write_zeroes(bs, sector_num, nb_sectors, flags); } else { - BLKDBG_EVENT(bs, BLKDBG_PWRITEV); + bdrv_debug_event(bs, BLKDBG_PWRITEV); ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov); } - BLKDBG_EVENT(bs, BLKDBG_PWRITEV_DONE); + bdrv_debug_event(bs, BLKDBG_PWRITEV_DONE); if (ret == 0 && !bs->enable_write_cache) { ret = bdrv_co_flush(bs); @@ -1182,13 +1182,13 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BlockDriverState *bs, /* RMW the unaligned part before head. */ mark_request_serialising(req, align); wait_serialising_requests(req); - BLKDBG_EVENT(bs, BLKDBG_PWRITEV_RMW_HEAD); + bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_HEAD); ret = bdrv_aligned_preadv(bs, req, offset & ~(align - 1), align, align, &local_qiov, 0); if (ret < 0) { goto fail; } - BLKDBG_EVENT(bs, BLKDBG_PWRITEV_RMW_AFTER_HEAD); + bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_HEAD); memset(buf + head_padding_bytes, 0, zero_bytes); ret = bdrv_aligned_pwritev(bs, req, offset & ~(align - 1), align, @@ -1220,13 +1220,13 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BlockDriverState *bs, /* RMW the unaligned part after tail. */ mark_request_serialising(req, align); wait_serialising_requests(req); - BLKDBG_EVENT(bs, BLKDBG_PWRITEV_RMW_TAIL); + bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL); ret = bdrv_aligned_preadv(bs, req, offset, align, align, &local_qiov, 0); if (ret < 0) { goto fail; } - BLKDBG_EVENT(bs, BLKDBG_PWRITEV_RMW_AFTER_TAIL); + bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_TAIL); memset(buf, 0, bytes); ret = bdrv_aligned_pwritev(bs, req, offset, align, @@ -1297,13 +1297,13 @@ static int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs, }; qemu_iovec_init_external(&head_qiov, &head_iov, 1); - BLKDBG_EVENT(bs, BLKDBG_PWRITEV_RMW_HEAD); + bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_HEAD); ret = bdrv_aligned_preadv(bs, &req, offset & ~(align - 1), align, align, &head_qiov, 0); if (ret < 0) { goto fail; } - BLKDBG_EVENT(bs, BLKDBG_PWRITEV_RMW_AFTER_HEAD); + bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_HEAD); qemu_iovec_init(&local_qiov, qiov->niov + 2); qemu_iovec_add(&local_qiov, head_buf, offset & (align - 1)); @@ -1331,13 +1331,13 @@ static int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs, }; qemu_iovec_init_external(&tail_qiov, &tail_iov, 1); - BLKDBG_EVENT(bs, BLKDBG_PWRITEV_RMW_TAIL); + bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL); ret = bdrv_aligned_preadv(bs, &req, (offset + bytes) & ~(align - 1), align, align, &tail_qiov, 0); if (ret < 0) { goto fail; } - BLKDBG_EVENT(bs, BLKDBG_PWRITEV_RMW_AFTER_TAIL); + bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_TAIL); if (!use_local_qiov) { qemu_iovec_init(&local_qiov, qiov->niov + 1); @@ -1486,7 +1486,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, if (ret & BDRV_BLOCK_RAW) { assert(ret & BDRV_BLOCK_OFFSET_VALID); - return bdrv_get_block_status(bs->file, ret >> BDRV_SECTOR_BITS, + return bdrv_get_block_status(bs->file->bs, ret >> BDRV_SECTOR_BITS, *pnum, pnum); } @@ -1509,7 +1509,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, (ret & BDRV_BLOCK_OFFSET_VALID)) { int file_pnum; - ret2 = bdrv_co_get_block_status(bs->file, ret >> BDRV_SECTOR_BITS, + ret2 = bdrv_co_get_block_status(bs->file->bs, ret >> BDRV_SECTOR_BITS, *pnum, &file_pnum); if (ret2 >= 0) { /* Ignore errors. This is just providing extra information, it @@ -1713,7 +1713,7 @@ int bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) } else if (drv->bdrv_save_vmstate) { return drv->bdrv_save_vmstate(bs, qiov, pos); } else if (bs->file) { - return bdrv_writev_vmstate(bs->file, qiov, pos); + return bdrv_writev_vmstate(bs->file->bs, qiov, pos); } return -ENOTSUP; @@ -1728,7 +1728,7 @@ int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf, if (drv->bdrv_load_vmstate) return drv->bdrv_load_vmstate(bs, buf, pos, size); if (bs->file) - return bdrv_load_vmstate(bs->file, buf, pos, size); + return bdrv_load_vmstate(bs->file->bs, buf, pos, size); return -ENOTSUP; } @@ -2356,7 +2356,7 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs) * in the case of cache=unsafe, so there are no useless flushes. */ flush_parent: - return bdrv_co_flush(bs->file); + return bs->file ? bdrv_co_flush(bs->file->bs) : 0; } int bdrv_flush(BlockDriverState *bs) @@ -2584,7 +2584,7 @@ void bdrv_io_plug(BlockDriverState *bs) if (drv && drv->bdrv_io_plug) { drv->bdrv_io_plug(bs); } else if (bs->file) { - bdrv_io_plug(bs->file); + bdrv_io_plug(bs->file->bs); } } @@ -2594,7 +2594,7 @@ void bdrv_io_unplug(BlockDriverState *bs) if (drv && drv->bdrv_io_unplug) { drv->bdrv_io_unplug(bs); } else if (bs->file) { - bdrv_io_unplug(bs->file); + bdrv_io_unplug(bs->file->bs); } } @@ -2604,7 +2604,7 @@ void bdrv_flush_io_queue(BlockDriverState *bs) if (drv && drv->bdrv_flush_io_queue) { drv->bdrv_flush_io_queue(bs); } else if (bs->file) { - bdrv_flush_io_queue(bs->file); + bdrv_flush_io_queue(bs->file->bs); } bdrv_start_throttled_reqs(bs); } diff --git a/block/parallels.c b/block/parallels.c index 5cd6ec3..4f79293 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -202,13 +202,13 @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, to_allocate = (sector_num + *pnum + s->tracks - 1) / s->tracks - idx; space = to_allocate * s->tracks; - if (s->data_end + space > bdrv_getlength(bs->file) >> BDRV_SECTOR_BITS) { + if (s->data_end + space > bdrv_getlength(bs->file->bs) >> BDRV_SECTOR_BITS) { int ret; space += s->prealloc_size; if (s->prealloc_mode == PRL_PREALLOC_MODE_FALLOCATE) { - ret = bdrv_write_zeroes(bs->file, s->data_end, space, 0); + ret = bdrv_write_zeroes(bs->file->bs, s->data_end, space, 0); } else { - ret = bdrv_truncate(bs->file, + ret = bdrv_truncate(bs->file->bs, (s->data_end + space) << BDRV_SECTOR_BITS); } if (ret < 0) { @@ -244,7 +244,8 @@ static coroutine_fn int parallels_co_flush_to_os(BlockDriverState *bs) if (off + to_write > s->header_size) { to_write = s->header_size - off; } - ret = bdrv_pwrite(bs->file, off, (uint8_t *)s->header + off, to_write); + ret = bdrv_pwrite(bs->file->bs, off, (uint8_t *)s->header + off, + to_write); if (ret < 0) { qemu_co_mutex_unlock(&s->lock); return ret; @@ -303,7 +304,7 @@ static coroutine_fn int parallels_co_writev(BlockDriverState *bs, qemu_iovec_reset(&hd_qiov); qemu_iovec_concat(&hd_qiov, qiov, bytes_done, nbytes); - ret = bdrv_co_writev(bs->file, position, n, &hd_qiov); + ret = bdrv_co_writev(bs->file->bs, position, n, &hd_qiov); if (ret < 0) { break; } @@ -343,7 +344,7 @@ static coroutine_fn int parallels_co_readv(BlockDriverState *bs, qemu_iovec_reset(&hd_qiov); qemu_iovec_concat(&hd_qiov, qiov, bytes_done, nbytes); - ret = bdrv_co_readv(bs->file, position, n, &hd_qiov); + ret = bdrv_co_readv(bs->file->bs, position, n, &hd_qiov); if (ret < 0) { break; } @@ -369,7 +370,7 @@ static int parallels_check(BlockDriverState *bs, BdrvCheckResult *res, bool flush_bat = false; int cluster_size = s->tracks << BDRV_SECTOR_BITS; - size = bdrv_getlength(bs->file); + size = bdrv_getlength(bs->file->bs); if (size < 0) { res->check_errors++; return size; @@ -424,7 +425,7 @@ static int parallels_check(BlockDriverState *bs, BdrvCheckResult *res, } if (flush_bat) { - ret = bdrv_pwrite_sync(bs->file, 0, s->header, s->header_size); + ret = bdrv_pwrite_sync(bs->file->bs, 0, s->header, s->header_size); if (ret < 0) { res->check_errors++; return ret; @@ -440,7 +441,7 @@ static int parallels_check(BlockDriverState *bs, BdrvCheckResult *res, size - res->image_end_offset); res->leaks += count; if (fix & BDRV_FIX_LEAKS) { - ret = bdrv_truncate(bs->file, res->image_end_offset); + ret = bdrv_truncate(bs->file->bs, res->image_end_offset); if (ret < 0) { res->check_errors++; return ret; @@ -546,12 +547,13 @@ static int parallels_probe(const uint8_t *buf, int buf_size, static int parallels_update_header(BlockDriverState *bs) { BDRVParallelsState *s = bs->opaque; - unsigned size = MAX(bdrv_opt_mem_align(bs->file), sizeof(ParallelsHeader)); + unsigned size = MAX(bdrv_opt_mem_align(bs->file->bs), + sizeof(ParallelsHeader)); if (size > s->header_size) { size = s->header_size; } - return bdrv_pwrite_sync(bs->file, 0, s->header, size); + return bdrv_pwrite_sync(bs->file->bs, 0, s->header, size); } static int parallels_open(BlockDriverState *bs, QDict *options, int flags, @@ -564,7 +566,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, Error *local_err = NULL; char *buf; - ret = bdrv_pread(bs->file, 0, &ph, sizeof(ph)); + ret = bdrv_pread(bs->file->bs, 0, &ph, sizeof(ph)); if (ret < 0) { goto fail; } @@ -603,8 +605,8 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, } size = bat_entry_off(s->bat_size); - s->header_size = ROUND_UP(size, bdrv_opt_mem_align(bs->file)); - s->header = qemu_try_blockalign(bs->file, s->header_size); + s->header_size = ROUND_UP(size, bdrv_opt_mem_align(bs->file->bs)); + s->header = qemu_try_blockalign(bs->file->bs, s->header_size); if (s->header == NULL) { ret = -ENOMEM; goto fail; @@ -619,7 +621,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, s->header_size = size; } - ret = bdrv_pread(bs->file, 0, s->header, s->header_size); + ret = bdrv_pread(bs->file->bs, 0, s->header, s->header_size); if (ret < 0) { goto fail; } @@ -663,8 +665,8 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, if (local_err != NULL) { goto fail_options; } - if (!bdrv_has_zero_init(bs->file) || - bdrv_truncate(bs->file, bdrv_getlength(bs->file)) != 0) { + if (!bdrv_has_zero_init(bs->file->bs) || + bdrv_truncate(bs->file->bs, bdrv_getlength(bs->file->bs)) != 0) { s->prealloc_mode = PRL_PREALLOC_MODE_FALLOCATE; } @@ -707,7 +709,7 @@ static void parallels_close(BlockDriverState *bs) } if (bs->open_flags & BDRV_O_RDWR) { - bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS); + bdrv_truncate(bs->file->bs, s->data_end << BDRV_SECTOR_BITS); } g_free(s->bat_dirty_bmap); diff --git a/block/qapi.c b/block/qapi.c index 2ce5097..0c4654e 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -359,7 +359,7 @@ static BlockStats *bdrv_query_stats(const BlockDriverState *bs, if (bs->file) { s->has_parent = true; - s->parent = bdrv_query_stats(bs->file, query_backing); + s->parent = bdrv_query_stats(bs->file->bs, query_backing); } if (query_backing && bs->backing_hd) { diff --git a/block/qcow.c b/block/qcow.c index 6e35db1..4d20cd5 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -100,7 +100,7 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, int ret; QCowHeader header; - ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); + ret = bdrv_pread(bs->file->bs, 0, &header, sizeof(header)); if (ret < 0) { goto fail; } @@ -193,7 +193,7 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, goto fail; } - ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, + ret = bdrv_pread(bs->file->bs, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)); if (ret < 0) { goto fail; @@ -205,7 +205,7 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, /* alloc L2 cache (max. 64k * 16 * 8 = 8 MB) */ s->l2_cache = - qemu_try_blockalign(bs->file, + qemu_try_blockalign(bs->file->bs, s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t)); if (s->l2_cache == NULL) { error_setg(errp, "Could not allocate L2 table cache"); @@ -224,7 +224,7 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, ret = -EINVAL; goto fail; } - ret = bdrv_pread(bs->file, header.backing_file_offset, + ret = bdrv_pread(bs->file->bs, header.backing_file_offset, bs->backing_file, len); if (ret < 0) { goto fail; @@ -369,13 +369,13 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, if (!allocate) return 0; /* allocate a new l2 entry */ - l2_offset = bdrv_getlength(bs->file); + l2_offset = bdrv_getlength(bs->file->bs); /* round to cluster size */ l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1); /* update the L1 entry */ s->l1_table[l1_index] = l2_offset; tmp = cpu_to_be64(l2_offset); - if (bdrv_pwrite_sync(bs->file, + if (bdrv_pwrite_sync(bs->file->bs, s->l1_table_offset + l1_index * sizeof(tmp), &tmp, sizeof(tmp)) < 0) return 0; @@ -405,11 +405,12 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, l2_table = s->l2_cache + (min_index << s->l2_bits); if (new_l2_table) { memset(l2_table, 0, s->l2_size * sizeof(uint64_t)); - if (bdrv_pwrite_sync(bs->file, l2_offset, l2_table, + if (bdrv_pwrite_sync(bs->file->bs, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) < 0) return 0; } else { - if (bdrv_pread(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) != + if (bdrv_pread(bs->file->bs, l2_offset, l2_table, + s->l2_size * sizeof(uint64_t)) != s->l2_size * sizeof(uint64_t)) return 0; } @@ -430,20 +431,21 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, overwritten */ if (decompress_cluster(bs, cluster_offset) < 0) return 0; - cluster_offset = bdrv_getlength(bs->file); + cluster_offset = bdrv_getlength(bs->file->bs); cluster_offset = (cluster_offset + s->cluster_size - 1) & ~(s->cluster_size - 1); /* write the cluster content */ - if (bdrv_pwrite(bs->file, cluster_offset, s->cluster_cache, s->cluster_size) != + if (bdrv_pwrite(bs->file->bs, cluster_offset, s->cluster_cache, + s->cluster_size) != s->cluster_size) return -1; } else { - cluster_offset = bdrv_getlength(bs->file); + cluster_offset = bdrv_getlength(bs->file->bs); if (allocate == 1) { /* round to cluster size */ cluster_offset = (cluster_offset + s->cluster_size - 1) & ~(s->cluster_size - 1); - bdrv_truncate(bs->file, cluster_offset + s->cluster_size); + bdrv_truncate(bs->file->bs, cluster_offset + s->cluster_size); /* if encrypted, we must initialize the cluster content which won't be written */ if (bs->encrypted && @@ -463,7 +465,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, errno = EIO; return -1; } - if (bdrv_pwrite(bs->file, cluster_offset + i * 512, + if (bdrv_pwrite(bs->file->bs, cluster_offset + i * 512, s->cluster_data, 512) != 512) return -1; } @@ -477,7 +479,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, /* update L2 table */ tmp = cpu_to_be64(cluster_offset); l2_table[l2_index] = tmp; - if (bdrv_pwrite_sync(bs->file, l2_offset + l2_index * sizeof(tmp), + if (bdrv_pwrite_sync(bs->file->bs, l2_offset + l2_index * sizeof(tmp), &tmp, sizeof(tmp)) < 0) return 0; } @@ -546,7 +548,7 @@ static int decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) if (s->cluster_cache_offset != coffset) { csize = cluster_offset >> (63 - s->cluster_bits); csize &= (s->cluster_size - 1); - ret = bdrv_pread(bs->file, coffset, s->cluster_data, csize); + ret = bdrv_pread(bs->file->bs, coffset, s->cluster_data, csize); if (ret != csize) return -1; if (decompress_buffer(s->cluster_cache, s->cluster_size, @@ -625,7 +627,7 @@ static coroutine_fn int qcow_co_readv(BlockDriverState *bs, int64_t sector_num, hd_iov.iov_len = n * 512; qemu_iovec_init_external(&hd_qiov, &hd_iov, 1); qemu_co_mutex_unlock(&s->lock); - ret = bdrv_co_readv(bs->file, + ret = bdrv_co_readv(bs->file->bs, (cluster_offset >> 9) + index_in_cluster, n, &hd_qiov); qemu_co_mutex_lock(&s->lock); @@ -727,7 +729,7 @@ static coroutine_fn int qcow_co_writev(BlockDriverState *bs, int64_t sector_num, hd_iov.iov_len = n * 512; qemu_iovec_init_external(&hd_qiov, &hd_iov, 1); qemu_co_mutex_unlock(&s->lock); - ret = bdrv_co_writev(bs->file, + ret = bdrv_co_writev(bs->file->bs, (cluster_offset >> 9) + index_in_cluster, n, &hd_qiov); qemu_co_mutex_lock(&s->lock); @@ -879,10 +881,10 @@ static int qcow_make_empty(BlockDriverState *bs) int ret; memset(s->l1_table, 0, l1_length); - if (bdrv_pwrite_sync(bs->file, s->l1_table_offset, s->l1_table, + if (bdrv_pwrite_sync(bs->file->bs, s->l1_table_offset, s->l1_table, l1_length) < 0) return -1; - ret = bdrv_truncate(bs->file, s->l1_table_offset + l1_length); + ret = bdrv_truncate(bs->file->bs, s->l1_table_offset + l1_length); if (ret < 0) return ret; @@ -962,7 +964,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, } cluster_offset &= s->cluster_offset_mask; - ret = bdrv_pwrite(bs->file, cluster_offset, out_buf, out_len); + ret = bdrv_pwrite(bs->file->bs, cluster_offset, out_buf, out_len); if (ret < 0) { goto fail; } diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 7b14c5c..86dd7f2 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -127,7 +127,7 @@ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables) c = g_new0(Qcow2Cache, 1); c->size = num_tables; c->entries = g_try_new0(Qcow2CachedTable, num_tables); - c->table_array = qemu_try_blockalign(bs->file, + c->table_array = qemu_try_blockalign(bs->file->bs, (size_t) num_tables * s->cluster_size); if (!c->entries || !c->table_array) { @@ -185,7 +185,7 @@ static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i) if (c->depends) { ret = qcow2_cache_flush_dependency(bs, c); } else if (c->depends_on_flush) { - ret = bdrv_flush(bs->file); + ret = bdrv_flush(bs->file->bs); if (ret >= 0) { c->depends_on_flush = false; } @@ -216,7 +216,7 @@ static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i) BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE); } - ret = bdrv_pwrite(bs->file, c->entries[i].offset, + ret = bdrv_pwrite(bs->file->bs, c->entries[i].offset, qcow2_cache_get_table_addr(bs, c, i), s->cluster_size); if (ret < 0) { return ret; @@ -244,7 +244,7 @@ int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c) } if (result == 0) { - ret = bdrv_flush(bs->file); + ret = bdrv_flush(bs->file->bs); if (ret < 0) { result = ret; } @@ -356,7 +356,8 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qcow2Cache *c, BLKDBG_EVENT(bs->file, BLKDBG_L2_LOAD); } - ret = bdrv_pread(bs->file, offset, qcow2_cache_get_table_addr(bs, c, i), + ret = bdrv_pread(bs->file->bs, offset, + qcow2_cache_get_table_addr(bs, c, i), s->cluster_size); if (ret < 0) { return ret; diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 6ede629..7844f8e 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -72,7 +72,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, #endif new_l1_size2 = sizeof(uint64_t) * new_l1_size; - new_l1_table = qemu_try_blockalign(bs->file, + new_l1_table = qemu_try_blockalign(bs->file->bs, align_offset(new_l1_size2, 512)); if (new_l1_table == NULL) { return -ENOMEM; @@ -105,7 +105,8 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_WRITE_TABLE); for(i = 0; i < s->l1_size; i++) new_l1_table[i] = cpu_to_be64(new_l1_table[i]); - ret = bdrv_pwrite_sync(bs->file, new_l1_table_offset, new_l1_table, new_l1_size2); + ret = bdrv_pwrite_sync(bs->file->bs, new_l1_table_offset, + new_l1_table, new_l1_size2); if (ret < 0) goto fail; for(i = 0; i < s->l1_size; i++) @@ -115,7 +116,8 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ACTIVATE_TABLE); cpu_to_be32w((uint32_t*)data, new_l1_size); stq_be_p(data + 4, new_l1_table_offset); - ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, l1_size), data,sizeof(data)); + ret = bdrv_pwrite_sync(bs->file->bs, offsetof(QCowHeader, l1_size), + data, sizeof(data)); if (ret < 0) { goto fail; } @@ -182,8 +184,9 @@ int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index) } BLKDBG_EVENT(bs->file, BLKDBG_L1_UPDATE); - ret = bdrv_pwrite_sync(bs->file, s->l1_table_offset + 8 * l1_start_index, - buf, sizeof(buf)); + ret = bdrv_pwrite_sync(bs->file->bs, + s->l1_table_offset + 8 * l1_start_index, + buf, sizeof(buf)); if (ret < 0) { return ret; } @@ -440,7 +443,8 @@ static int coroutine_fn copy_sectors(BlockDriverState *bs, } BLKDBG_EVENT(bs->file, BLKDBG_COW_WRITE); - ret = bdrv_co_writev(bs->file, (cluster_offset >> 9) + n_start, n, &qiov); + ret = bdrv_co_writev(bs->file->bs, (cluster_offset >> 9) + n_start, n, + &qiov); if (ret < 0) { goto out; } @@ -817,7 +821,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m) /* * If this was a COW, we need to decrease the refcount of the old cluster. - * Also flush bs->file to get the right order for L2 and refcount update. + * Also flush bs->file->bs to get the right order for L2 and refcount update. * * Don't discard clusters that reach a refcount of 0 (e.g. compressed * clusters), the next write will reuse them anyway. @@ -1412,7 +1416,8 @@ int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) sector_offset = coffset & 511; csize = nb_csectors * 512 - sector_offset; BLKDBG_EVENT(bs->file, BLKDBG_READ_COMPRESSED); - ret = bdrv_read(bs->file, coffset >> 9, s->cluster_data, nb_csectors); + ret = bdrv_read(bs->file->bs, coffset >> 9, s->cluster_data, + nb_csectors); if (ret < 0) { return ret; } @@ -1645,7 +1650,7 @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table, if (!is_active_l1) { /* inactive L2 tables require a buffer to be stored in when loading * them from disk */ - l2_table = qemu_try_blockalign(bs->file, s->cluster_size); + l2_table = qemu_try_blockalign(bs->file->bs, s->cluster_size); if (l2_table == NULL) { return -ENOMEM; } @@ -1679,8 +1684,8 @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table, (void **)&l2_table); } else { /* load inactive L2 tables from disk */ - ret = bdrv_read(bs->file, l2_offset / BDRV_SECTOR_SIZE, - (void *)l2_table, s->cluster_sectors); + ret = bdrv_read(bs->file->bs, l2_offset / BDRV_SECTOR_SIZE, + (void *)l2_table, s->cluster_sectors); } if (ret < 0) { goto fail; @@ -1754,7 +1759,7 @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table, goto fail; } - ret = bdrv_write_zeroes(bs->file, offset / BDRV_SECTOR_SIZE, + ret = bdrv_write_zeroes(bs->file->bs, offset / BDRV_SECTOR_SIZE, s->cluster_sectors, 0); if (ret < 0) { if (!preallocated) { @@ -1787,8 +1792,8 @@ static int expand_zero_clusters_in_l1(BlockDriverState *bs, uint64_t *l1_table, goto fail; } - ret = bdrv_write(bs->file, l2_offset / BDRV_SECTOR_SIZE, - (void *)l2_table, s->cluster_sectors); + ret = bdrv_write(bs->file->bs, l2_offset / BDRV_SECTOR_SIZE, + (void *)l2_table, s->cluster_sectors); if (ret < 0) { goto fail; } @@ -1861,8 +1866,9 @@ int qcow2_expand_zero_clusters(BlockDriverState *bs, l1_table = g_realloc(l1_table, l1_sectors * BDRV_SECTOR_SIZE); - ret = bdrv_read(bs->file, s->snapshots[i].l1_table_offset / - BDRV_SECTOR_SIZE, (void *)l1_table, l1_sectors); + ret = bdrv_read(bs->file->bs, + s->snapshots[i].l1_table_offset / BDRV_SECTOR_SIZE, + (void *)l1_table, l1_sectors); if (ret < 0) { goto fail; } diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 2110839..4b81c8d 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -101,7 +101,7 @@ int qcow2_refcount_init(BlockDriverState *bs) goto fail; } BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD); - ret = bdrv_pread(bs->file, s->refcount_table_offset, + ret = bdrv_pread(bs->file->bs, s->refcount_table_offset, s->refcount_table, refcount_table_size2); if (ret < 0) { goto fail; @@ -431,7 +431,7 @@ static int alloc_refcount_block(BlockDriverState *bs, if (refcount_table_index < s->refcount_table_size) { uint64_t data64 = cpu_to_be64(new_block); BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP); - ret = bdrv_pwrite_sync(bs->file, + ret = bdrv_pwrite_sync(bs->file->bs, s->refcount_table_offset + refcount_table_index * sizeof(uint64_t), &data64, sizeof(data64)); if (ret < 0) { @@ -535,7 +535,7 @@ static int alloc_refcount_block(BlockDriverState *bs, /* Write refcount blocks to disk */ BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS); - ret = bdrv_pwrite_sync(bs->file, meta_offset, new_blocks, + ret = bdrv_pwrite_sync(bs->file->bs, meta_offset, new_blocks, blocks_clusters * s->cluster_size); g_free(new_blocks); new_blocks = NULL; @@ -549,7 +549,7 @@ static int alloc_refcount_block(BlockDriverState *bs, } BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE); - ret = bdrv_pwrite_sync(bs->file, table_offset, new_table, + ret = bdrv_pwrite_sync(bs->file->bs, table_offset, new_table, table_size * sizeof(uint64_t)); if (ret < 0) { goto fail_table; @@ -564,8 +564,9 @@ static int alloc_refcount_block(BlockDriverState *bs, cpu_to_be64w((uint64_t*)data, table_offset); cpu_to_be32w((uint32_t*)(data + 8), table_clusters); BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE); - ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, refcount_table_offset), - data, sizeof(data)); + ret = bdrv_pwrite_sync(bs->file->bs, + offsetof(QCowHeader, refcount_table_offset), + data, sizeof(data)); if (ret < 0) { goto fail_table; } @@ -613,7 +614,7 @@ void qcow2_process_discards(BlockDriverState *bs, int ret) /* Discard is optional, ignore the return value */ if (ret >= 0) { - bdrv_discard(bs->file, + bdrv_discard(bs->file->bs, d->offset >> BDRV_SECTOR_BITS, d->bytes >> BDRV_SECTOR_BITS); } @@ -1068,7 +1069,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs, } l1_allocated = true; - ret = bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size2); + ret = bdrv_pread(bs->file->bs, l1_table_offset, l1_table, l1_size2); if (ret < 0) { goto fail; } @@ -1221,7 +1222,8 @@ fail: cpu_to_be64s(&l1_table[i]); } - ret = bdrv_pwrite_sync(bs->file, l1_table_offset, l1_table, l1_size2); + ret = bdrv_pwrite_sync(bs->file->bs, l1_table_offset, + l1_table, l1_size2); for (i = 0; i < l1_size; i++) { be64_to_cpus(&l1_table[i]); @@ -1376,7 +1378,7 @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, l2_size = s->l2_size * sizeof(uint64_t); l2_table = g_malloc(l2_size); - ret = bdrv_pread(bs->file, l2_offset, l2_table, l2_size); + ret = bdrv_pread(bs->file->bs, l2_offset, l2_table, l2_size); if (ret < 0) { fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n"); res->check_errors++; @@ -1508,7 +1510,7 @@ static int check_refcounts_l1(BlockDriverState *bs, res->check_errors++; goto fail; } - ret = bdrv_pread(bs->file, l1_table_offset, l1_table, l1_size2); + ret = bdrv_pread(bs->file->bs, l1_table_offset, l1_table, l1_size2); if (ret < 0) { fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n"); res->check_errors++; @@ -1606,7 +1608,7 @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res, } } - ret = bdrv_pread(bs->file, l2_offset, l2_table, + ret = bdrv_pread(bs->file->bs, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)); if (ret < 0) { fprintf(stderr, "ERROR: Could not read L2 table: %s\n", @@ -1658,7 +1660,8 @@ static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res, goto fail; } - ret = bdrv_pwrite(bs->file, l2_offset, l2_table, s->cluster_size); + ret = bdrv_pwrite(bs->file->bs, l2_offset, l2_table, + s->cluster_size); if (ret < 0) { fprintf(stderr, "ERROR: Could not write L2 table: %s\n", strerror(-ret)); @@ -1713,11 +1716,11 @@ static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res, goto resize_fail; } - ret = bdrv_truncate(bs->file, offset + s->cluster_size); + ret = bdrv_truncate(bs->file->bs, offset + s->cluster_size); if (ret < 0) { goto resize_fail; } - size = bdrv_getlength(bs->file); + size = bdrv_getlength(bs->file->bs); if (size < 0) { ret = size; goto resize_fail; @@ -2091,7 +2094,7 @@ write_refblocks: on_disk_refblock = (void *)((char *) *refcount_table + refblock_index * s->cluster_size); - ret = bdrv_write(bs->file, refblock_offset / BDRV_SECTOR_SIZE, + ret = bdrv_write(bs->file->bs, refblock_offset / BDRV_SECTOR_SIZE, on_disk_refblock, s->cluster_sectors); if (ret < 0) { fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret)); @@ -2140,7 +2143,7 @@ write_refblocks: } assert(reftable_size < INT_MAX / sizeof(uint64_t)); - ret = bdrv_pwrite(bs->file, reftable_offset, on_disk_reftable, + ret = bdrv_pwrite(bs->file->bs, reftable_offset, on_disk_reftable, reftable_size * sizeof(uint64_t)); if (ret < 0) { fprintf(stderr, "ERROR writing reftable: %s\n", strerror(-ret)); @@ -2152,8 +2155,8 @@ write_refblocks: reftable_offset); cpu_to_be32w(&reftable_offset_and_clusters.reftable_clusters, size_to_clusters(s, reftable_size * sizeof(uint64_t))); - ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, - refcount_table_offset), + ret = bdrv_pwrite_sync(bs->file->bs, offsetof(QCowHeader, + refcount_table_offset), &reftable_offset_and_clusters, sizeof(reftable_offset_and_clusters)); if (ret < 0) { @@ -2191,7 +2194,7 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, bool rebuild = false; int ret; - size = bdrv_getlength(bs->file); + size = bdrv_getlength(bs->file->bs); if (size < 0) { res->check_errors++; return size; @@ -2400,7 +2403,7 @@ int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset, return -ENOMEM; } - ret = bdrv_pread(bs->file, l1_ofs, l1, l1_sz2); + ret = bdrv_pread(bs->file->bs, l1_ofs, l1, l1_sz2); if (ret < 0) { g_free(l1); return ret; diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 92f4dfc..def7201 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -64,7 +64,7 @@ int qcow2_read_snapshots(BlockDriverState *bs) for(i = 0; i < s->nb_snapshots; i++) { /* Read statically sized part of the snapshot header */ offset = align_offset(offset, 8); - ret = bdrv_pread(bs->file, offset, &h, sizeof(h)); + ret = bdrv_pread(bs->file->bs, offset, &h, sizeof(h)); if (ret < 0) { goto fail; } @@ -83,7 +83,7 @@ int qcow2_read_snapshots(BlockDriverState *bs) name_size = be16_to_cpu(h.name_size); /* Read extra data */ - ret = bdrv_pread(bs->file, offset, &extra, + ret = bdrv_pread(bs->file->bs, offset, &extra, MIN(sizeof(extra), extra_data_size)); if (ret < 0) { goto fail; @@ -102,7 +102,7 @@ int qcow2_read_snapshots(BlockDriverState *bs) /* Read snapshot ID */ sn->id_str = g_malloc(id_str_size + 1); - ret = bdrv_pread(bs->file, offset, sn->id_str, id_str_size); + ret = bdrv_pread(bs->file->bs, offset, sn->id_str, id_str_size); if (ret < 0) { goto fail; } @@ -111,7 +111,7 @@ int qcow2_read_snapshots(BlockDriverState *bs) /* Read snapshot name */ sn->name = g_malloc(name_size + 1); - ret = bdrv_pread(bs->file, offset, sn->name, name_size); + ret = bdrv_pread(bs->file->bs, offset, sn->name, name_size); if (ret < 0) { goto fail; } @@ -214,25 +214,25 @@ static int qcow2_write_snapshots(BlockDriverState *bs) h.name_size = cpu_to_be16(name_size); offset = align_offset(offset, 8); - ret = bdrv_pwrite(bs->file, offset, &h, sizeof(h)); + ret = bdrv_pwrite(bs->file->bs, offset, &h, sizeof(h)); if (ret < 0) { goto fail; } offset += sizeof(h); - ret = bdrv_pwrite(bs->file, offset, &extra, sizeof(extra)); + ret = bdrv_pwrite(bs->file->bs, offset, &extra, sizeof(extra)); if (ret < 0) { goto fail; } offset += sizeof(extra); - ret = bdrv_pwrite(bs->file, offset, sn->id_str, id_str_size); + ret = bdrv_pwrite(bs->file->bs, offset, sn->id_str, id_str_size); if (ret < 0) { goto fail; } offset += id_str_size; - ret = bdrv_pwrite(bs->file, offset, sn->name, name_size); + ret = bdrv_pwrite(bs->file->bs, offset, sn->name, name_size); if (ret < 0) { goto fail; } @@ -254,7 +254,7 @@ static int qcow2_write_snapshots(BlockDriverState *bs) header_data.nb_snapshots = cpu_to_be32(s->nb_snapshots); header_data.snapshots_offset = cpu_to_be64(snapshots_offset); - ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, nb_snapshots), + ret = bdrv_pwrite_sync(bs->file->bs, offsetof(QCowHeader, nb_snapshots), &header_data, sizeof(header_data)); if (ret < 0) { goto fail; @@ -396,7 +396,7 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) goto fail; } - ret = bdrv_pwrite(bs->file, sn->l1_table_offset, l1_table, + ret = bdrv_pwrite(bs->file->bs, sn->l1_table_offset, l1_table, s->l1_size * sizeof(uint64_t)); if (ret < 0) { goto fail; @@ -509,7 +509,8 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) goto fail; } - ret = bdrv_pread(bs->file, sn->l1_table_offset, sn_l1_table, sn_l1_bytes); + ret = bdrv_pread(bs->file->bs, sn->l1_table_offset, + sn_l1_table, sn_l1_bytes); if (ret < 0) { goto fail; } @@ -526,7 +527,7 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) goto fail; } - ret = bdrv_pwrite_sync(bs->file, s->l1_table_offset, sn_l1_table, + ret = bdrv_pwrite_sync(bs->file->bs, s->l1_table_offset, sn_l1_table, cur_l1_bytes); if (ret < 0) { goto fail; @@ -706,13 +707,14 @@ int qcow2_snapshot_load_tmp(BlockDriverState *bs, return -EFBIG; } new_l1_bytes = sn->l1_size * sizeof(uint64_t); - new_l1_table = qemu_try_blockalign(bs->file, + new_l1_table = qemu_try_blockalign(bs->file->bs, align_offset(new_l1_bytes, 512)); if (new_l1_table == NULL) { return -ENOMEM; } - ret = bdrv_pread(bs->file, sn->l1_table_offset, new_l1_table, new_l1_bytes); + ret = bdrv_pread(bs->file->bs, sn->l1_table_offset, + new_l1_table, new_l1_bytes); if (ret < 0) { error_setg(errp, "Failed to read l1 table for snapshot"); qemu_vfree(new_l1_table); diff --git a/block/qcow2.c b/block/qcow2.c index 56ad808..38b2797 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -104,7 +104,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, printf("attempting to read extended header in offset %lu\n", offset); #endif - ret = bdrv_pread(bs->file, offset, &ext, sizeof(ext)); + ret = bdrv_pread(bs->file->bs, offset, &ext, sizeof(ext)); if (ret < 0) { error_setg_errno(errp, -ret, "qcow2_read_extension: ERROR: " "pread fail from offset %" PRIu64, offset); @@ -132,7 +132,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, sizeof(bs->backing_format)); return 2; } - ret = bdrv_pread(bs->file, offset, bs->backing_format, ext.len); + ret = bdrv_pread(bs->file->bs, offset, bs->backing_format, ext.len); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: ext_backing_format: " "Could not read format name"); @@ -148,7 +148,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, case QCOW2_EXT_MAGIC_FEATURE_TABLE: if (p_feature_table != NULL) { void* feature_table = g_malloc0(ext.len + 2 * sizeof(Qcow2Feature)); - ret = bdrv_pread(bs->file, offset , feature_table, ext.len); + ret = bdrv_pread(bs->file->bs, offset , feature_table, ext.len); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: ext_feature_table: " "Could not read table"); @@ -169,7 +169,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, uext->len = ext.len; QLIST_INSERT_HEAD(&s->unknown_header_ext, uext, next); - ret = bdrv_pread(bs->file, offset , uext->data, uext->len); + ret = bdrv_pread(bs->file->bs, offset , uext->data, uext->len); if (ret < 0) { error_setg_errno(errp, -ret, "ERROR: unknown extension: " "Could not read data"); @@ -260,12 +260,12 @@ int qcow2_mark_dirty(BlockDriverState *bs) } val = cpu_to_be64(s->incompatible_features | QCOW2_INCOMPAT_DIRTY); - ret = bdrv_pwrite(bs->file, offsetof(QCowHeader, incompatible_features), + ret = bdrv_pwrite(bs->file->bs, offsetof(QCowHeader, incompatible_features), &val, sizeof(val)); if (ret < 0) { return ret; } - ret = bdrv_flush(bs->file); + ret = bdrv_flush(bs->file->bs); if (ret < 0) { return ret; } @@ -828,7 +828,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, uint64_t ext_end; uint64_t l1_vm_state_index; - ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); + ret = bdrv_pread(bs->file->bs, 0, &header, sizeof(header)); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read qcow2 header"); goto fail; @@ -903,7 +903,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, if (header.header_length > sizeof(header)) { s->unknown_header_fields_size = header.header_length - sizeof(header); s->unknown_header_fields = g_malloc(s->unknown_header_fields_size); - ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields, + ret = bdrv_pread(bs->file->bs, sizeof(header), s->unknown_header_fields, s->unknown_header_fields_size); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read unknown qcow2 header " @@ -1056,14 +1056,14 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, if (s->l1_size > 0) { - s->l1_table = qemu_try_blockalign(bs->file, + s->l1_table = qemu_try_blockalign(bs->file->bs, align_offset(s->l1_size * sizeof(uint64_t), 512)); if (s->l1_table == NULL) { error_setg(errp, "Could not allocate L1 table"); ret = -ENOMEM; goto fail; } - ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, + ret = bdrv_pread(bs->file->bs, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read L1 table"); @@ -1082,7 +1082,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, s->cluster_cache = g_malloc(s->cluster_size); /* one more sector for decompressed data alignment */ - s->cluster_data = qemu_try_blockalign(bs->file, QCOW_MAX_CRYPT_CLUSTERS + s->cluster_data = qemu_try_blockalign(bs->file->bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size + 512); if (s->cluster_data == NULL) { error_setg(errp, "Could not allocate temporary cluster buffer"); @@ -1119,7 +1119,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, ret = -EINVAL; goto fail; } - ret = bdrv_pread(bs->file, header.backing_file_offset, + ret = bdrv_pread(bs->file->bs, header.backing_file_offset, bs->backing_file, len); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read backing file name"); @@ -1429,8 +1429,9 @@ static coroutine_fn int qcow2_co_readv(BlockDriverState *bs, int64_t sector_num, */ if (!cluster_data) { cluster_data = - qemu_try_blockalign(bs->file, QCOW_MAX_CRYPT_CLUSTERS - * s->cluster_size); + qemu_try_blockalign(bs->file->bs, + QCOW_MAX_CRYPT_CLUSTERS + * s->cluster_size); if (cluster_data == NULL) { ret = -ENOMEM; goto fail; @@ -1446,7 +1447,7 @@ static coroutine_fn int qcow2_co_readv(BlockDriverState *bs, int64_t sector_num, BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); qemu_co_mutex_unlock(&s->lock); - ret = bdrv_co_readv(bs->file, + ret = bdrv_co_readv(bs->file->bs, (cluster_offset >> 9) + index_in_cluster, cur_nr_sectors, &hd_qiov); qemu_co_mutex_lock(&s->lock); @@ -1543,7 +1544,7 @@ static coroutine_fn int qcow2_co_writev(BlockDriverState *bs, Error *err = NULL; assert(s->cipher); if (!cluster_data) { - cluster_data = qemu_try_blockalign(bs->file, + cluster_data = qemu_try_blockalign(bs->file->bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); if (cluster_data == NULL) { @@ -1580,7 +1581,7 @@ static coroutine_fn int qcow2_co_writev(BlockDriverState *bs, BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); trace_qcow2_writev_data(qemu_coroutine_self(), (cluster_offset >> 9) + index_in_cluster); - ret = bdrv_co_writev(bs->file, + ret = bdrv_co_writev(bs->file->bs, (cluster_offset >> 9) + index_in_cluster, cur_nr_sectors, &hd_qiov); qemu_co_mutex_lock(&s->lock); @@ -1703,7 +1704,7 @@ static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp) qcow2_close(bs); - bdrv_invalidate_cache(bs->file, &local_err); + bdrv_invalidate_cache(bs->file->bs, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -1911,7 +1912,7 @@ int qcow2_update_header(BlockDriverState *bs) } /* Write the new header */ - ret = bdrv_pwrite(bs->file, 0, header, s->cluster_size); + ret = bdrv_pwrite(bs->file->bs, 0, header, s->cluster_size); if (ret < 0) { goto fail; } @@ -1991,7 +1992,8 @@ static int preallocate(BlockDriverState *bs) if (host_offset != 0) { uint8_t buf[BDRV_SECTOR_SIZE]; memset(buf, 0, BDRV_SECTOR_SIZE); - ret = bdrv_write(bs->file, (host_offset >> BDRV_SECTOR_BITS) + num - 1, + ret = bdrv_write(bs->file->bs, + (host_offset >> BDRV_SECTOR_BITS) + num - 1, buf, 1); if (ret < 0) { return ret; @@ -2403,7 +2405,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset) /* write updated header.size */ offset = cpu_to_be64(offset); - ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, size), + ret = bdrv_pwrite_sync(bs->file->bs, offsetof(QCowHeader, size), &offset, sizeof(uint64_t)); if (ret < 0) { return ret; @@ -2427,8 +2429,8 @@ static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num, if (nb_sectors == 0) { /* align end of file to a sector boundary to ease reading with sector based I/Os */ - cluster_offset = bdrv_getlength(bs->file); - return bdrv_truncate(bs->file, cluster_offset); + cluster_offset = bdrv_getlength(bs->file->bs); + return bdrv_truncate(bs->file->bs, cluster_offset); } if (nb_sectors != s->cluster_sectors) { @@ -2495,7 +2497,7 @@ static int qcow2_write_compressed(BlockDriverState *bs, int64_t sector_num, } BLKDBG_EVENT(bs->file, BLKDBG_WRITE_COMPRESSED); - ret = bdrv_pwrite(bs->file, cluster_offset, out_buf, out_len); + ret = bdrv_pwrite(bs->file->bs, cluster_offset, out_buf, out_len); if (ret < 0) { goto fail; } @@ -2544,7 +2546,7 @@ static int make_completely_empty(BlockDriverState *bs) /* After this call, neither the in-memory nor the on-disk refcount * information accurately describe the actual references */ - ret = bdrv_write_zeroes(bs->file, s->l1_table_offset / BDRV_SECTOR_SIZE, + ret = bdrv_write_zeroes(bs->file->bs, s->l1_table_offset / BDRV_SECTOR_SIZE, l1_clusters * s->cluster_sectors, 0); if (ret < 0) { goto fail_broken_refcounts; @@ -2558,7 +2560,7 @@ static int make_completely_empty(BlockDriverState *bs) * overwrite parts of the existing refcount and L1 table, which is not * an issue because the dirty flag is set, complete data loss is in fact * desired and partial data loss is consequently fine as well */ - ret = bdrv_write_zeroes(bs->file, s->cluster_size / BDRV_SECTOR_SIZE, + ret = bdrv_write_zeroes(bs->file->bs, s->cluster_size / BDRV_SECTOR_SIZE, (2 + l1_clusters) * s->cluster_size / BDRV_SECTOR_SIZE, 0); /* This call (even if it failed overall) may have overwritten on-disk @@ -2578,7 +2580,7 @@ static int make_completely_empty(BlockDriverState *bs) cpu_to_be64w(&l1_ofs_rt_ofs_cls.l1_offset, 3 * s->cluster_size); cpu_to_be64w(&l1_ofs_rt_ofs_cls.reftable_offset, s->cluster_size); cpu_to_be32w(&l1_ofs_rt_ofs_cls.reftable_clusters, 1); - ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, l1_table_offset), + ret = bdrv_pwrite_sync(bs->file->bs, offsetof(QCowHeader, l1_table_offset), &l1_ofs_rt_ofs_cls, sizeof(l1_ofs_rt_ofs_cls)); if (ret < 0) { goto fail_broken_refcounts; @@ -2609,7 +2611,7 @@ static int make_completely_empty(BlockDriverState *bs) /* Enter the first refblock into the reftable */ rt_entry = cpu_to_be64(2 * s->cluster_size); - ret = bdrv_pwrite_sync(bs->file, s->cluster_size, + ret = bdrv_pwrite_sync(bs->file->bs, s->cluster_size, &rt_entry, sizeof(rt_entry)); if (ret < 0) { goto fail_broken_refcounts; @@ -2634,7 +2636,7 @@ static int make_completely_empty(BlockDriverState *bs) goto fail; } - ret = bdrv_truncate(bs->file, (3 + l1_clusters) * s->cluster_size); + ret = bdrv_truncate(bs->file->bs, (3 + l1_clusters) * s->cluster_size); if (ret < 0) { goto fail; } @@ -2769,7 +2771,7 @@ static void dump_refcounts(BlockDriverState *bs) int64_t nb_clusters, k, k1, size; int refcount; - size = bdrv_getlength(bs->file); + size = bdrv_getlength(bs->file->bs); nb_clusters = size_to_clusters(s, size); for(k = 0; k < nb_clusters;) { k1 = k; diff --git a/block/qed-table.c b/block/qed-table.c index 513aa87..f4219b8 100644 --- a/block/qed-table.c +++ b/block/qed-table.c @@ -63,7 +63,7 @@ static void qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, read_table_cb->iov.iov_len = s->header.cluster_size * s->header.table_size, qemu_iovec_init_external(qiov, &read_table_cb->iov, 1); - bdrv_aio_readv(s->bs->file, offset / BDRV_SECTOR_SIZE, qiov, + bdrv_aio_readv(s->bs->file->bs, offset / BDRV_SECTOR_SIZE, qiov, qiov->size / BDRV_SECTOR_SIZE, qed_read_table_cb, read_table_cb); } @@ -152,7 +152,7 @@ static void qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, /* Adjust for offset into table */ offset += start * sizeof(uint64_t); - bdrv_aio_writev(s->bs->file, offset / BDRV_SECTOR_SIZE, + bdrv_aio_writev(s->bs->file->bs, offset / BDRV_SECTOR_SIZE, &write_table_cb->qiov, write_table_cb->qiov.size / BDRV_SECTOR_SIZE, qed_write_table_cb, write_table_cb); diff --git a/block/qed.c b/block/qed.c index a7ff1d9..d953f8c 100644 --- a/block/qed.c +++ b/block/qed.c @@ -82,7 +82,7 @@ int qed_write_header_sync(BDRVQEDState *s) int ret; qed_header_cpu_to_le(&s->header, &le); - ret = bdrv_pwrite(s->bs->file, 0, &le, sizeof(le)); + ret = bdrv_pwrite(s->bs->file->bs, 0, &le, sizeof(le)); if (ret != sizeof(le)) { return ret; } @@ -119,7 +119,7 @@ static void qed_write_header_read_cb(void *opaque, int ret) /* Update header */ qed_header_cpu_to_le(&s->header, (QEDHeader *)write_header_cb->buf); - bdrv_aio_writev(s->bs->file, 0, &write_header_cb->qiov, + bdrv_aio_writev(s->bs->file->bs, 0, &write_header_cb->qiov, write_header_cb->nsectors, qed_write_header_cb, write_header_cb); } @@ -152,7 +152,7 @@ static void qed_write_header(BDRVQEDState *s, BlockCompletionFunc cb, write_header_cb->iov.iov_len = len; qemu_iovec_init_external(&write_header_cb->qiov, &write_header_cb->iov, 1); - bdrv_aio_readv(s->bs->file, 0, &write_header_cb->qiov, nsectors, + bdrv_aio_readv(s->bs->file->bs, 0, &write_header_cb->qiov, nsectors, qed_write_header_read_cb, write_header_cb); } @@ -392,7 +392,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags, s->bs = bs; QSIMPLEQ_INIT(&s->allocating_write_reqs); - ret = bdrv_pread(bs->file, 0, &le_header, sizeof(le_header)); + ret = bdrv_pread(bs->file->bs, 0, &le_header, sizeof(le_header)); if (ret < 0) { return ret; } @@ -416,7 +416,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags, } /* Round down file size to the last cluster */ - file_size = bdrv_getlength(bs->file); + file_size = bdrv_getlength(bs->file->bs); if (file_size < 0) { return file_size; } @@ -452,7 +452,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } - ret = qed_read_string(bs->file, s->header.backing_filename_offset, + ret = qed_read_string(bs->file->bs, s->header.backing_filename_offset, s->header.backing_filename_size, bs->backing_file, sizeof(bs->backing_file)); if (ret < 0) { @@ -471,7 +471,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags, * feature is no longer valid. */ if ((s->header.autoclear_features & ~QED_AUTOCLEAR_FEATURE_MASK) != 0 && - !bdrv_is_read_only(bs->file) && !(flags & BDRV_O_INCOMING)) { + !bdrv_is_read_only(bs->file->bs) && !(flags & BDRV_O_INCOMING)) { s->header.autoclear_features &= QED_AUTOCLEAR_FEATURE_MASK; ret = qed_write_header_sync(s); @@ -480,7 +480,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags, } /* From here on only known autoclear feature bits are valid */ - bdrv_flush(bs->file); + bdrv_flush(bs->file->bs); } s->l1_table = qed_alloc_table(s); @@ -498,7 +498,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags, * potentially inconsistent images to be opened read-only. This can * aid data recovery from an otherwise inconsistent image. */ - if (!bdrv_is_read_only(bs->file) && + if (!bdrv_is_read_only(bs->file->bs) && !(flags & BDRV_O_INCOMING)) { BdrvCheckResult result = {0}; @@ -541,7 +541,7 @@ static void bdrv_qed_close(BlockDriverState *bs) bdrv_qed_detach_aio_context(bs); /* Ensure writes reach stable storage */ - bdrv_flush(bs->file); + bdrv_flush(bs->file->bs); /* Clean shutdown, no check required on next open */ if (s->header.features & QED_F_NEED_CHECK) { @@ -839,7 +839,7 @@ static void qed_copy_from_backing_file_write(void *opaque, int ret) } BLKDBG_EVENT(s->bs->file, BLKDBG_COW_WRITE); - bdrv_aio_writev(s->bs->file, copy_cb->offset / BDRV_SECTOR_SIZE, + bdrv_aio_writev(s->bs->file->bs, copy_cb->offset / BDRV_SECTOR_SIZE, ©_cb->qiov, copy_cb->qiov.size / BDRV_SECTOR_SIZE, qed_copy_from_backing_file_cb, copy_cb); } @@ -1055,7 +1055,7 @@ static void qed_aio_write_flush_before_l2_update(void *opaque, int ret) QEDAIOCB *acb = opaque; BDRVQEDState *s = acb_to_s(acb); - if (!bdrv_aio_flush(s->bs->file, qed_aio_write_l2_update_cb, opaque)) { + if (!bdrv_aio_flush(s->bs->file->bs, qed_aio_write_l2_update_cb, opaque)) { qed_aio_complete(acb, -EIO); } } @@ -1089,7 +1089,7 @@ static void qed_aio_write_main(void *opaque, int ret) } BLKDBG_EVENT(s->bs->file, BLKDBG_WRITE_AIO); - bdrv_aio_writev(s->bs->file, offset / BDRV_SECTOR_SIZE, + bdrv_aio_writev(s->bs->file->bs, offset / BDRV_SECTOR_SIZE, &acb->cur_qiov, acb->cur_qiov.size / BDRV_SECTOR_SIZE, next_fn, acb); } @@ -1321,7 +1321,7 @@ static void qed_aio_read_data(void *opaque, int ret, } BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); - bdrv_aio_readv(bs->file, offset / BDRV_SECTOR_SIZE, + bdrv_aio_readv(bs->file->bs, offset / BDRV_SECTOR_SIZE, &acb->cur_qiov, acb->cur_qiov.size / BDRV_SECTOR_SIZE, qed_aio_next_io, acb); return; @@ -1580,7 +1580,7 @@ static int bdrv_qed_change_backing_file(BlockDriverState *bs, } /* Write new header */ - ret = bdrv_pwrite_sync(bs->file, 0, buffer, buffer_len); + ret = bdrv_pwrite_sync(bs->file->bs, 0, buffer, buffer_len); g_free(buffer); if (ret == 0) { memcpy(&s->header, &new_header, sizeof(new_header)); @@ -1596,7 +1596,7 @@ static void bdrv_qed_invalidate_cache(BlockDriverState *bs, Error **errp) bdrv_qed_close(bs); - bdrv_invalidate_cache(bs->file, &local_err); + bdrv_invalidate_cache(bs->file->bs, &local_err); if (local_err) { error_propagate(errp, local_err); return; diff --git a/block/raw_bsd.c b/block/raw_bsd.c index e3d2d04..63ee911 100644 --- a/block/raw_bsd.c +++ b/block/raw_bsd.c @@ -52,7 +52,7 @@ static int coroutine_fn raw_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); - return bdrv_co_readv(bs->file, sector_num, nb_sectors, qiov); + return bdrv_co_readv(bs->file->bs, sector_num, nb_sectors, qiov); } static int coroutine_fn raw_co_writev(BlockDriverState *bs, int64_t sector_num, @@ -75,7 +75,7 @@ static int coroutine_fn raw_co_writev(BlockDriverState *bs, int64_t sector_num, return 0; } - buf = qemu_try_blockalign(bs->file, 512); + buf = qemu_try_blockalign(bs->file->bs, 512); if (!buf) { ret = -ENOMEM; goto fail; @@ -102,7 +102,7 @@ static int coroutine_fn raw_co_writev(BlockDriverState *bs, int64_t sector_num, } BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); - ret = bdrv_co_writev(bs->file, sector_num, nb_sectors, qiov); + ret = bdrv_co_writev(bs->file->bs, sector_num, nb_sectors, qiov); fail: if (qiov == &local_qiov) { @@ -125,58 +125,58 @@ static int coroutine_fn raw_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors, BdrvRequestFlags flags) { - return bdrv_co_write_zeroes(bs->file, sector_num, nb_sectors, flags); + return bdrv_co_write_zeroes(bs->file->bs, sector_num, nb_sectors, flags); } static int coroutine_fn raw_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { - return bdrv_co_discard(bs->file, sector_num, nb_sectors); + return bdrv_co_discard(bs->file->bs, sector_num, nb_sectors); } static int64_t raw_getlength(BlockDriverState *bs) { - return bdrv_getlength(bs->file); + return bdrv_getlength(bs->file->bs); } static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { - return bdrv_get_info(bs->file, bdi); + return bdrv_get_info(bs->file->bs, bdi); } static void raw_refresh_limits(BlockDriverState *bs, Error **errp) { - bs->bl = bs->file->bl; + bs->bl = bs->file->bs->bl; } static int raw_truncate(BlockDriverState *bs, int64_t offset) { - return bdrv_truncate(bs->file, offset); + return bdrv_truncate(bs->file->bs, offset); } static int raw_is_inserted(BlockDriverState *bs) { - return bdrv_is_inserted(bs->file); + return bdrv_is_inserted(bs->file->bs); } static int raw_media_changed(BlockDriverState *bs) { - return bdrv_media_changed(bs->file); + return bdrv_media_changed(bs->file->bs); } static void raw_eject(BlockDriverState *bs, bool eject_flag) { - bdrv_eject(bs->file, eject_flag); + bdrv_eject(bs->file->bs, eject_flag); } static void raw_lock_medium(BlockDriverState *bs, bool locked) { - bdrv_lock_medium(bs->file, locked); + bdrv_lock_medium(bs->file->bs, locked); } static int raw_ioctl(BlockDriverState *bs, unsigned long int req, void *buf) { - return bdrv_ioctl(bs->file, req, buf); + return bdrv_ioctl(bs->file->bs, req, buf); } static BlockAIOCB *raw_aio_ioctl(BlockDriverState *bs, @@ -184,12 +184,12 @@ static BlockAIOCB *raw_aio_ioctl(BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque) { - return bdrv_aio_ioctl(bs->file, req, buf, cb, opaque); + return bdrv_aio_ioctl(bs->file->bs, req, buf, cb, opaque); } static int raw_has_zero_init(BlockDriverState *bs) { - return bdrv_has_zero_init(bs->file); + return bdrv_has_zero_init(bs->file->bs); } static int raw_create(const char *filename, QemuOpts *opts, Error **errp) @@ -207,7 +207,7 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp) static int raw_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { - bs->sg = bs->file->sg; + bs->sg = bs->file->bs->sg; if (bs->probed && !bdrv_is_read_only(bs)) { fprintf(stderr, @@ -217,7 +217,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, "raw images, write operations on block 0 will be restricted.\n" " Specify the 'raw' format explicitly to remove the " "restrictions.\n", - bs->file->filename); + bs->file->bs->filename); } return 0; @@ -237,12 +237,12 @@ static int raw_probe(const uint8_t *buf, int buf_size, const char *filename) static int raw_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz) { - return bdrv_probe_blocksizes(bs->file, bsz); + return bdrv_probe_blocksizes(bs->file->bs, bsz); } static int raw_probe_geometry(BlockDriverState *bs, HDGeometry *geo) { - return bdrv_probe_geometry(bs->file, geo); + return bdrv_probe_geometry(bs->file->bs, geo); } BlockDriver bdrv_raw = { diff --git a/block/snapshot.c b/block/snapshot.c index 49e143e..89500f2 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -149,7 +149,7 @@ int bdrv_can_snapshot(BlockDriverState *bs) if (!drv->bdrv_snapshot_create) { if (bs->file != NULL) { - return bdrv_can_snapshot(bs->file); + return bdrv_can_snapshot(bs->file->bs); } return 0; } @@ -168,7 +168,7 @@ int bdrv_snapshot_create(BlockDriverState *bs, return drv->bdrv_snapshot_create(bs, sn_info); } if (bs->file) { - return bdrv_snapshot_create(bs->file, sn_info); + return bdrv_snapshot_create(bs->file->bs, sn_info); } return -ENOTSUP; } @@ -188,10 +188,10 @@ int bdrv_snapshot_goto(BlockDriverState *bs, if (bs->file) { drv->bdrv_close(bs); - ret = bdrv_snapshot_goto(bs->file, snapshot_id); + ret = bdrv_snapshot_goto(bs->file->bs, snapshot_id); open_ret = drv->bdrv_open(bs, NULL, bs->open_flags, NULL); if (open_ret < 0) { - bdrv_unref(bs->file); + bdrv_unref(bs->file->bs); bs->drv = NULL; return open_ret; } @@ -245,7 +245,7 @@ int bdrv_snapshot_delete(BlockDriverState *bs, return drv->bdrv_snapshot_delete(bs, snapshot_id, name, errp); } if (bs->file) { - return bdrv_snapshot_delete(bs->file, snapshot_id, name, errp); + return bdrv_snapshot_delete(bs->file->bs, snapshot_id, name, errp); } error_setg(errp, "Block format '%s' used by device '%s' " "does not support internal snapshot deletion", @@ -283,7 +283,7 @@ int bdrv_snapshot_list(BlockDriverState *bs, return drv->bdrv_snapshot_list(bs, psn_info); } if (bs->file) { - return bdrv_snapshot_list(bs->file, psn_info); + return bdrv_snapshot_list(bs->file->bs, psn_info); } return -ENOTSUP; } diff --git a/block/vdi.c b/block/vdi.c index 062a654..17626d4 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -399,7 +399,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags, logout("\n"); - ret = bdrv_read(bs->file, 0, (uint8_t *)&header, 1); + ret = bdrv_read(bs->file->bs, 0, (uint8_t *)&header, 1); if (ret < 0) { goto fail; } @@ -490,13 +490,14 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags, bmap_size = header.blocks_in_image * sizeof(uint32_t); bmap_size = DIV_ROUND_UP(bmap_size, SECTOR_SIZE); - s->bmap = qemu_try_blockalign(bs->file, bmap_size * SECTOR_SIZE); + s->bmap = qemu_try_blockalign(bs->file->bs, bmap_size * SECTOR_SIZE); if (s->bmap == NULL) { ret = -ENOMEM; goto fail; } - ret = bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size); + ret = bdrv_read(bs->file->bs, s->bmap_sector, (uint8_t *)s->bmap, + bmap_size); if (ret < 0) { goto fail_free_bmap; } @@ -585,7 +586,7 @@ static int vdi_co_read(BlockDriverState *bs, uint64_t offset = s->header.offset_data / SECTOR_SIZE + (uint64_t)bmap_entry * s->block_sectors + sector_in_block; - ret = bdrv_read(bs->file, offset, buf, n_sectors); + ret = bdrv_read(bs->file->bs, offset, buf, n_sectors); } logout("%u sectors read\n", n_sectors); @@ -653,7 +654,7 @@ static int vdi_co_write(BlockDriverState *bs, * acquire the lock and thus the padded cluster is written before * the other coroutines can write to the affected area. */ qemu_co_mutex_lock(&s->write_lock); - ret = bdrv_write(bs->file, offset, block, s->block_sectors); + ret = bdrv_write(bs->file->bs, offset, block, s->block_sectors); qemu_co_mutex_unlock(&s->write_lock); } else { uint64_t offset = s->header.offset_data / SECTOR_SIZE + @@ -669,7 +670,7 @@ static int vdi_co_write(BlockDriverState *bs, * that that write operation has returned (there may be other writes * in flight, but they do not concern this very operation). */ qemu_co_mutex_unlock(&s->write_lock); - ret = bdrv_write(bs->file, offset, buf, n_sectors); + ret = bdrv_write(bs->file->bs, offset, buf, n_sectors); } nb_sectors -= n_sectors; @@ -694,7 +695,7 @@ static int vdi_co_write(BlockDriverState *bs, assert(VDI_IS_ALLOCATED(bmap_first)); *header = s->header; vdi_header_to_le(header); - ret = bdrv_write(bs->file, 0, block, 1); + ret = bdrv_write(bs->file->bs, 0, block, 1); g_free(block); block = NULL; @@ -712,7 +713,7 @@ static int vdi_co_write(BlockDriverState *bs, base = ((uint8_t *)&s->bmap[0]) + bmap_first * SECTOR_SIZE; logout("will write %u block map sectors starting from entry %u\n", n_sectors, bmap_first); - ret = bdrv_write(bs->file, offset, base, n_sectors); + ret = bdrv_write(bs->file->bs, offset, base, n_sectors); } return ret; diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 47fec63..47ae4b1 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -81,7 +81,7 @@ static int vhdx_log_peek_hdr(BlockDriverState *bs, VHDXLogEntries *log, offset = log->offset + read; - ret = bdrv_pread(bs->file, offset, hdr, sizeof(VHDXLogEntryHeader)); + ret = bdrv_pread(bs->file->bs, offset, hdr, sizeof(VHDXLogEntryHeader)); if (ret < 0) { goto exit; } @@ -141,7 +141,7 @@ static int vhdx_log_read_sectors(BlockDriverState *bs, VHDXLogEntries *log, } offset = log->offset + read; - ret = bdrv_pread(bs->file, offset, buffer, VHDX_LOG_SECTOR_SIZE); + ret = bdrv_pread(bs->file->bs, offset, buffer, VHDX_LOG_SECTOR_SIZE); if (ret < 0) { goto exit; } @@ -191,7 +191,8 @@ static int vhdx_log_write_sectors(BlockDriverState *bs, VHDXLogEntries *log, /* full */ break; } - ret = bdrv_pwrite(bs->file, offset, buffer_tmp, VHDX_LOG_SECTOR_SIZE); + ret = bdrv_pwrite(bs->file->bs, offset, buffer_tmp, + VHDX_LOG_SECTOR_SIZE); if (ret < 0) { goto exit; } @@ -353,7 +354,7 @@ static int vhdx_log_read_desc(BlockDriverState *bs, BDRVVHDXState *s, } desc_sectors = vhdx_compute_desc_sectors(hdr.descriptor_count); - desc_entries = qemu_try_blockalign(bs->file, + desc_entries = qemu_try_blockalign(bs->file->bs, desc_sectors * VHDX_LOG_SECTOR_SIZE); if (desc_entries == NULL) { ret = -ENOMEM; @@ -462,7 +463,7 @@ static int vhdx_log_flush_desc(BlockDriverState *bs, VHDXLogDescriptor *desc, /* count is only > 1 if we are writing zeroes */ for (i = 0; i < count; i++) { - ret = bdrv_pwrite_sync(bs->file, file_offset, buffer, + ret = bdrv_pwrite_sync(bs->file->bs, file_offset, buffer, VHDX_LOG_SECTOR_SIZE); if (ret < 0) { goto exit; @@ -509,7 +510,7 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVHDXState *s, /* if the log shows a FlushedFileOffset larger than our current file * size, then that means the file has been truncated / corrupted, and * we must refused to open it / use it */ - if (hdr_tmp.flushed_file_offset > bdrv_getlength(bs->file)) { + if (hdr_tmp.flushed_file_offset > bdrv_getlength(bs->file->bs)) { ret = -EINVAL; goto exit; } @@ -539,12 +540,12 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVHDXState *s, goto exit; } } - if (bdrv_getlength(bs->file) < desc_entries->hdr.last_file_offset) { + if (bdrv_getlength(bs->file->bs) < desc_entries->hdr.last_file_offset) { new_file_size = desc_entries->hdr.last_file_offset; if (new_file_size % (1024*1024)) { /* round up to nearest 1MB boundary */ new_file_size = ((new_file_size >> 20) + 1) << 20; - bdrv_truncate(bs->file, new_file_size); + bdrv_truncate(bs->file->bs, new_file_size); } } qemu_vfree(desc_entries); @@ -908,8 +909,8 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHDXState *s, .sequence_number = s->log.sequence, .descriptor_count = sectors, .reserved = 0, - .flushed_file_offset = bdrv_getlength(bs->file), - .last_file_offset = bdrv_getlength(bs->file), + .flushed_file_offset = bdrv_getlength(bs->file->bs), + .last_file_offset = bdrv_getlength(bs->file->bs), }; new_hdr.log_guid = header->log_guid; @@ -940,7 +941,7 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHDXState *s, if (i == 0 && leading_length) { /* partial sector at the front of the buffer */ - ret = bdrv_pread(bs->file, file_offset, merged_sector, + ret = bdrv_pread(bs->file->bs, file_offset, merged_sector, VHDX_LOG_SECTOR_SIZE); if (ret < 0) { goto exit; @@ -950,7 +951,7 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHDXState *s, sector_write = merged_sector; } else if (i == sectors - 1 && trailing_length) { /* partial sector at the end of the buffer */ - ret = bdrv_pread(bs->file, + ret = bdrv_pread(bs->file->bs, file_offset, merged_sector + trailing_length, VHDX_LOG_SECTOR_SIZE - trailing_length); diff --git a/block/vhdx.c b/block/vhdx.c index d3bb1bd..2fe9a5e 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -375,7 +375,7 @@ static int vhdx_update_header(BlockDriverState *bs, BDRVVHDXState *s, inactive_header->log_guid = *log_guid; } - ret = vhdx_write_header(bs->file, inactive_header, header_offset, true); + ret = vhdx_write_header(bs->file->bs, inactive_header, header_offset, true); if (ret < 0) { goto exit; } @@ -427,7 +427,8 @@ static void vhdx_parse_header(BlockDriverState *bs, BDRVVHDXState *s, /* We have to read the whole VHDX_HEADER_SIZE instead of * sizeof(VHDXHeader), because the checksum is over the whole * region */ - ret = bdrv_pread(bs->file, VHDX_HEADER1_OFFSET, buffer, VHDX_HEADER_SIZE); + ret = bdrv_pread(bs->file->bs, VHDX_HEADER1_OFFSET, buffer, + VHDX_HEADER_SIZE); if (ret < 0) { goto fail; } @@ -443,7 +444,8 @@ static void vhdx_parse_header(BlockDriverState *bs, BDRVVHDXState *s, } } - ret = bdrv_pread(bs->file, VHDX_HEADER2_OFFSET, buffer, VHDX_HEADER_SIZE); + ret = bdrv_pread(bs->file->bs, VHDX_HEADER2_OFFSET, buffer, + VHDX_HEADER_SIZE); if (ret < 0) { goto fail; } @@ -516,7 +518,7 @@ static int vhdx_open_region_tables(BlockDriverState *bs, BDRVVHDXState *s) * whole block */ buffer = qemu_blockalign(bs, VHDX_HEADER_BLOCK_SIZE); - ret = bdrv_pread(bs->file, VHDX_REGION_TABLE_OFFSET, buffer, + ret = bdrv_pread(bs->file->bs, VHDX_REGION_TABLE_OFFSET, buffer, VHDX_HEADER_BLOCK_SIZE); if (ret < 0) { goto fail; @@ -629,7 +631,7 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s) buffer = qemu_blockalign(bs, VHDX_METADATA_TABLE_MAX_SIZE); - ret = bdrv_pread(bs->file, s->metadata_rt.file_offset, buffer, + ret = bdrv_pread(bs->file->bs, s->metadata_rt.file_offset, buffer, VHDX_METADATA_TABLE_MAX_SIZE); if (ret < 0) { goto exit; @@ -732,7 +734,7 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s) goto exit; } - ret = bdrv_pread(bs->file, + ret = bdrv_pread(bs->file->bs, s->metadata_entries.file_parameters_entry.offset + s->metadata_rt.file_offset, &s->params, @@ -767,7 +769,7 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s) /* determine virtual disk size, logical sector size, * and phys sector size */ - ret = bdrv_pread(bs->file, + ret = bdrv_pread(bs->file->bs, s->metadata_entries.virtual_disk_size_entry.offset + s->metadata_rt.file_offset, &s->virtual_disk_size, @@ -775,7 +777,7 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s) if (ret < 0) { goto exit; } - ret = bdrv_pread(bs->file, + ret = bdrv_pread(bs->file->bs, s->metadata_entries.logical_sector_size_entry.offset + s->metadata_rt.file_offset, &s->logical_sector_size, @@ -783,7 +785,7 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BDRVVHDXState *s) if (ret < 0) { goto exit; } - ret = bdrv_pread(bs->file, + ret = bdrv_pread(bs->file->bs, s->metadata_entries.phys_sector_size_entry.offset + s->metadata_rt.file_offset, &s->physical_sector_size, @@ -906,7 +908,7 @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags, QLIST_INIT(&s->regions); /* validate the file signature */ - ret = bdrv_pread(bs->file, 0, &signature, sizeof(uint64_t)); + ret = bdrv_pread(bs->file->bs, 0, &signature, sizeof(uint64_t)); if (ret < 0) { goto fail; } @@ -959,13 +961,13 @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags, } /* s->bat is freed in vhdx_close() */ - s->bat = qemu_try_blockalign(bs->file, s->bat_rt.length); + s->bat = qemu_try_blockalign(bs->file->bs, s->bat_rt.length); if (s->bat == NULL) { ret = -ENOMEM; goto fail; } - ret = bdrv_pread(bs->file, s->bat_offset, s->bat, s->bat_rt.length); + ret = bdrv_pread(bs->file->bs, s->bat_offset, s->bat, s->bat_rt.length); if (ret < 0) { goto fail; } @@ -1118,7 +1120,7 @@ static coroutine_fn int vhdx_co_readv(BlockDriverState *bs, int64_t sector_num, break; case PAYLOAD_BLOCK_FULLY_PRESENT: qemu_co_mutex_unlock(&s->lock); - ret = bdrv_co_readv(bs->file, + ret = bdrv_co_readv(bs->file->bs, sinfo.file_offset >> BDRV_SECTOR_BITS, sinfo.sectors_avail, &hd_qiov); qemu_co_mutex_lock(&s->lock); @@ -1156,12 +1158,12 @@ exit: static int vhdx_allocate_block(BlockDriverState *bs, BDRVVHDXState *s, uint64_t *new_offset) { - *new_offset = bdrv_getlength(bs->file); + *new_offset = bdrv_getlength(bs->file->bs); /* per the spec, the address for a block is in units of 1MB */ *new_offset = ROUND_UP(*new_offset, 1024 * 1024); - return bdrv_truncate(bs->file, *new_offset + s->block_size); + return bdrv_truncate(bs->file->bs, *new_offset + s->block_size); } /* @@ -1260,7 +1262,7 @@ static coroutine_fn int vhdx_co_writev(BlockDriverState *bs, int64_t sector_num, /* Queue another write of zero buffers if the underlying file * does not zero-fill on file extension */ - if (bdrv_has_zero_init(bs->file) == 0) { + if (bdrv_has_zero_init(bs->file->bs) == 0) { use_zero_buffers = true; /* zero fill the front, if any */ @@ -1327,7 +1329,7 @@ static coroutine_fn int vhdx_co_writev(BlockDriverState *bs, int64_t sector_num, } /* block exists, so we can just overwrite it */ qemu_co_mutex_unlock(&s->lock); - ret = bdrv_co_writev(bs->file, + ret = bdrv_co_writev(bs->file->bs, sinfo.file_offset >> BDRV_SECTOR_BITS, sectors_to_write, &hd_qiov); qemu_co_mutex_lock(&s->lock); diff --git a/block/vmdk.c b/block/vmdk.c index 9702132..9f7e7db 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -221,7 +221,7 @@ static void vmdk_free_extents(BlockDriverState *bs) g_free(e->l2_cache); g_free(e->l1_backup_table); g_free(e->type); - if (e->file != bs->file_child) { + if (e->file != bs->file) { bdrv_unref_child(bs, e->file); } } @@ -248,7 +248,7 @@ static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent) BDRVVmdkState *s = bs->opaque; int ret; - ret = bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE); + ret = bdrv_pread(bs->file->bs, s->desc_offset, desc, DESC_SIZE); if (ret < 0) { return 0; } @@ -278,7 +278,7 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid) BDRVVmdkState *s = bs->opaque; int ret; - ret = bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE); + ret = bdrv_pread(bs->file->bs, s->desc_offset, desc, DESC_SIZE); if (ret < 0) { return ret; } @@ -297,7 +297,7 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid) pstrcat(desc, sizeof(desc), tmp_desc); } - ret = bdrv_pwrite_sync(bs->file, s->desc_offset, desc, DESC_SIZE); + ret = bdrv_pwrite_sync(bs->file->bs, s->desc_offset, desc, DESC_SIZE); if (ret < 0) { return ret; } @@ -340,7 +340,7 @@ static int vmdk_parent_open(BlockDriverState *bs) int ret; desc[DESC_SIZE] = '\0'; - ret = bdrv_pread(bs->file, s->desc_offset, desc, DESC_SIZE); + ret = bdrv_pread(bs->file->bs, s->desc_offset, desc, DESC_SIZE); if (ret < 0) { return ret; } @@ -621,7 +621,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, } QEMU_PACKED footer; ret = bdrv_pread(file->bs, - bs->file->total_sectors * 512 - 1536, + bs->file->bs->total_sectors * 512 - 1536, &footer, sizeof(footer)); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read footer"); @@ -819,7 +819,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, !desc_file_path[0]) { error_setg(errp, "Cannot use relative extent paths with VMDK " - "descriptor file '%s'", bs->file->filename); + "descriptor file '%s'", bs->file->bs->filename); return -EINVAL; } @@ -905,7 +905,8 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, } s->create_type = g_strdup(ct); s->desc_offset = 0; - ret = vmdk_parse_extents(buf, bs, bs->file->exact_filename, options, errp); + ret = vmdk_parse_extents(buf, bs, bs->file->bs->exact_filename, options, + errp); exit: return ret; } @@ -918,7 +919,7 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, BDRVVmdkState *s = bs->opaque; uint32_t magic; - buf = vmdk_read_desc(bs->file, 0, errp); + buf = vmdk_read_desc(bs->file->bs, 0, errp); if (!buf) { return -EINVAL; } @@ -927,7 +928,7 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, switch (magic) { case VMDK3_MAGIC: case VMDK4_MAGIC: - ret = vmdk_open_sparse(bs, bs->file_child, flags, buf, options, + ret = vmdk_open_sparse(bs, bs->file, flags, buf, options, errp); s->desc_offset = 0x200; break; @@ -1275,7 +1276,7 @@ static int64_t coroutine_fn vmdk_co_get_block_status(BlockDriverState *bs, break; case VMDK_OK: ret = BDRV_BLOCK_DATA; - if (extent->file == bs->file_child && !extent->compressed) { + if (extent->file == bs->file && !extent->compressed) { ret |= BDRV_BLOCK_OFFSET_VALID | offset; } @@ -2051,12 +2052,12 @@ static int64_t vmdk_get_allocated_file_size(BlockDriverState *bs) int64_t r; BDRVVmdkState *s = bs->opaque; - ret = bdrv_get_allocated_file_size(bs->file); + ret = bdrv_get_allocated_file_size(bs->file->bs); if (ret < 0) { return ret; } for (i = 0; i < s->num_extents; i++) { - if (s->extents[i].file == bs->file_child) { + if (s->extents[i].file == bs->file) { continue; } r = bdrv_get_allocated_file_size(s->extents[i].file->bs); diff --git a/block/vpc.c b/block/vpc.c index 2b3b518..299d373 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -172,14 +172,14 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, int disk_type = VHD_DYNAMIC; int ret; - ret = bdrv_pread(bs->file, 0, s->footer_buf, HEADER_SIZE); + ret = bdrv_pread(bs->file->bs, 0, s->footer_buf, HEADER_SIZE); if (ret < 0) { goto fail; } footer = (VHDFooter *) s->footer_buf; if (strncmp(footer->creator, "conectix", 8)) { - int64_t offset = bdrv_getlength(bs->file); + int64_t offset = bdrv_getlength(bs->file->bs); if (offset < 0) { ret = offset; goto fail; @@ -189,7 +189,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, } /* If a fixed disk, the footer is found only at the end of the file */ - ret = bdrv_pread(bs->file, offset-HEADER_SIZE, s->footer_buf, + ret = bdrv_pread(bs->file->bs, offset-HEADER_SIZE, s->footer_buf, HEADER_SIZE); if (ret < 0) { goto fail; @@ -232,7 +232,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, } if (disk_type == VHD_DYNAMIC) { - ret = bdrv_pread(bs->file, be64_to_cpu(footer->data_offset), buf, + ret = bdrv_pread(bs->file->bs, be64_to_cpu(footer->data_offset), buf, HEADER_SIZE); if (ret < 0) { goto fail; @@ -280,7 +280,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, pagetable_size = (uint64_t) s->max_table_entries * 4; - s->pagetable = qemu_try_blockalign(bs->file, pagetable_size); + s->pagetable = qemu_try_blockalign(bs->file->bs, pagetable_size); if (s->pagetable == NULL) { ret = -ENOMEM; goto fail; @@ -288,7 +288,8 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, s->bat_offset = be64_to_cpu(dyndisk_header->table_offset); - ret = bdrv_pread(bs->file, s->bat_offset, s->pagetable, pagetable_size); + ret = bdrv_pread(bs->file->bs, s->bat_offset, s->pagetable, + pagetable_size); if (ret < 0) { goto fail; } @@ -308,7 +309,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, } } - if (s->free_data_block_offset > bdrv_getlength(bs->file)) { + if (s->free_data_block_offset > bdrv_getlength(bs->file->bs)) { error_setg(errp, "block-vpc: free_data_block_offset points after " "the end of file. The image has been truncated."); ret = -EINVAL; @@ -383,7 +384,7 @@ static inline int64_t get_sector_offset(BlockDriverState *bs, s->last_bitmap_offset = bitmap_offset; memset(bitmap, 0xff, s->bitmap_size); - bdrv_pwrite_sync(bs->file, bitmap_offset, bitmap, s->bitmap_size); + bdrv_pwrite_sync(bs->file->bs, bitmap_offset, bitmap, s->bitmap_size); } return block_offset; @@ -401,7 +402,7 @@ static int rewrite_footer(BlockDriverState* bs) BDRVVPCState *s = bs->opaque; int64_t offset = s->free_data_block_offset; - ret = bdrv_pwrite_sync(bs->file, offset, s->footer_buf, HEADER_SIZE); + ret = bdrv_pwrite_sync(bs->file->bs, offset, s->footer_buf, HEADER_SIZE); if (ret < 0) return ret; @@ -436,7 +437,7 @@ static int64_t alloc_block(BlockDriverState* bs, int64_t sector_num) // Initialize the block's bitmap memset(bitmap, 0xff, s->bitmap_size); - ret = bdrv_pwrite_sync(bs->file, s->free_data_block_offset, bitmap, + ret = bdrv_pwrite_sync(bs->file->bs, s->free_data_block_offset, bitmap, s->bitmap_size); if (ret < 0) { return ret; @@ -451,7 +452,7 @@ static int64_t alloc_block(BlockDriverState* bs, int64_t sector_num) // Write BAT entry to disk bat_offset = s->bat_offset + (4 * index); bat_value = cpu_to_be32(s->pagetable[index]); - ret = bdrv_pwrite_sync(bs->file, bat_offset, &bat_value, 4); + ret = bdrv_pwrite_sync(bs->file->bs, bat_offset, &bat_value, 4); if (ret < 0) goto fail; @@ -485,7 +486,7 @@ static int vpc_read(BlockDriverState *bs, int64_t sector_num, VHDFooter *footer = (VHDFooter *) s->footer_buf; if (be32_to_cpu(footer->type) == VHD_FIXED) { - return bdrv_read(bs->file, sector_num, buf, nb_sectors); + return bdrv_read(bs->file->bs, sector_num, buf, nb_sectors); } while (nb_sectors > 0) { offset = get_sector_offset(bs, sector_num, 0); @@ -499,7 +500,7 @@ static int vpc_read(BlockDriverState *bs, int64_t sector_num, if (offset == -1) { memset(buf, 0, sectors * BDRV_SECTOR_SIZE); } else { - ret = bdrv_pread(bs->file, offset, buf, + ret = bdrv_pread(bs->file->bs, offset, buf, sectors * BDRV_SECTOR_SIZE); if (ret != sectors * BDRV_SECTOR_SIZE) { return -1; @@ -534,7 +535,7 @@ static int vpc_write(BlockDriverState *bs, int64_t sector_num, VHDFooter *footer = (VHDFooter *) s->footer_buf; if (be32_to_cpu(footer->type) == VHD_FIXED) { - return bdrv_write(bs->file, sector_num, buf, nb_sectors); + return bdrv_write(bs->file->bs, sector_num, buf, nb_sectors); } while (nb_sectors > 0) { offset = get_sector_offset(bs, sector_num, 1); @@ -551,7 +552,8 @@ static int vpc_write(BlockDriverState *bs, int64_t sector_num, return -1; } - ret = bdrv_pwrite(bs->file, offset, buf, sectors * BDRV_SECTOR_SIZE); + ret = bdrv_pwrite(bs->file->bs, offset, buf, + sectors * BDRV_SECTOR_SIZE); if (ret != sectors * BDRV_SECTOR_SIZE) { return -1; } @@ -878,7 +880,7 @@ static int vpc_has_zero_init(BlockDriverState *bs) VHDFooter *footer = (VHDFooter *) s->footer_buf; if (be32_to_cpu(footer->type) == VHD_FIXED) { - return bdrv_has_zero_init(bs->file); + return bdrv_has_zero_init(bs->file->bs); } else { return 1; } diff --git a/include/block/block.h b/include/block/block.h index ef67353..79b2e91 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -582,7 +582,13 @@ typedef enum { BLKDBG_EVENT_MAX, } BlkDebugEvent; -#define BLKDBG_EVENT(bs, evt) bdrv_debug_event(bs, evt) +#define BLKDBG_EVENT(child, evt) \ + do { \ + if (child) { \ + bdrv_debug_event(child->bs, evt); \ + } \ + } while(0) + void bdrv_debug_event(BlockDriverState *bs, BlkDebugEvent event); int bdrv_debug_breakpoint(BlockDriverState *bs, const char *event, diff --git a/include/block/block_int.h b/include/block/block_int.h index d0dd93e..98936c9 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -380,8 +380,7 @@ struct BlockDriverState { BlockDriverState *backing_hd; BdrvChild *backing_child; - BlockDriverState *file; - BdrvChild *file_child; + BdrvChild *file; NotifierList close_notifiers; -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:49:03 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYc-0002Ko-Ur for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:49:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYW-00027r-3j for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:49:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZYV-00029k-CJ for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36245) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYV-00029M-7w; Thu, 17 Sep 2015 09:48:55 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id E0F208E6F0; Thu, 17 Sep 2015 13:48:54 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHr030423; Thu, 17 Sep 2015 09:48:52 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:15 +0200 Message-Id: <1442497700-2536-12-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 11/16] block-backend: Add blk_set_bs() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:49:01 -0000 It allows changing the BlockDriverState that a BlockBackend points to. Signed-off-by: Kevin Wolf --- block/block-backend.c | 16 ++++++++++++++++ include/block/block_int.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index c2e8732..a2afcff 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -239,6 +239,22 @@ BlockDriverState *blk_bs(BlockBackend *blk) } /* + * Changes the BlockDriverState attached to @blk + */ +void blk_set_bs(BlockBackend *blk, BlockDriverState *bs) +{ + bdrv_ref(bs); + + if (blk->bs) { + blk->bs->blk = NULL; + bdrv_unref(blk->bs); + } + + blk->bs = bs; + bs->blk = blk; +} + +/* * Return @blk's DriveInfo if any, else null. */ DriveInfo *blk_legacy_dinfo(BlockBackend *blk) diff --git a/include/block/block_int.h b/include/block/block_int.h index 4598101..cfcae52 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -659,6 +659,8 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target, BlockCompletionFunc *cb, void *opaque, Error **errp); +void blk_set_bs(BlockBackend *blk, BlockDriverState *bs); + void blk_dev_change_media_cb(BlockBackend *blk, bool load); bool blk_dev_has_removable_media(BlockBackend *blk); void blk_dev_eject_request(BlockBackend *blk, bool force); -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:48:59 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYY-0002DE-Rt for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:48:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYT-00022P-C2 for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZYQ-00028G-RR for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:48:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56140) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYQ-00027g-MC; Thu, 17 Sep 2015 09:48:50 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 5630A4C502; Thu, 17 Sep 2015 13:48:50 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHp030423; Thu, 17 Sep 2015 09:48:48 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:13 +0200 Message-Id: <1442497700-2536-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 09/16] block: Split bdrv_move_feature_fields() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:48:57 -0000 After bdrv_swap(), some fields must be moved back to their original BDS to compensate for the effects that a swap of the contents of the objects has while keeping the old addresses. Other fields must be moved back because they should logically be moved and must stay on top When replacing bdrv_swap() with operations changing the pointers in the parents, we only need the latter and must avoid swapping the former. Split the function accordingly. Signed-off-by: Kevin Wolf --- block.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/block.c b/block.c index 743f82e..7930f3c 100644 --- a/block.c +++ b/block.c @@ -1984,6 +1984,8 @@ static void bdrv_rebind(BlockDriverState *bs) } } +/* Fields that need to stay with the top-level BDS, no matter whether the + * address of the top-level BDS stays the same or not. */ static void bdrv_move_feature_fields(BlockDriverState *bs_dest, BlockDriverState *bs_src) { @@ -2019,7 +2021,13 @@ static void bdrv_move_feature_fields(BlockDriverState *bs_dest, /* dirty bitmap */ bs_dest->dirty_bitmaps = bs_src->dirty_bitmaps; +} +/* Fields that only need to be swapped if the contents of BDSes is swapped + * rather than pointers being changed in the parents. */ +static void bdrv_move_reference_fields(BlockDriverState *bs_dest, + BlockDriverState *bs_src) +{ /* reference count */ bs_dest->refcnt = bs_src->refcnt; @@ -2090,6 +2098,10 @@ void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old) bdrv_move_feature_fields(bs_old, bs_new); bdrv_move_feature_fields(bs_new, &tmp); + bdrv_move_reference_fields(&tmp, bs_old); + bdrv_move_reference_fields(bs_old, bs_new); + bdrv_move_reference_fields(bs_new, &tmp); + /* bs_new must remain unattached */ assert(!bs_new->blk); -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:49:08 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYi-0002Uz-5M for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:49:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYd-0002Kr-11 for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:49:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZYa-0002Ge-D4 for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:49:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYZ-0002FV-UD; Thu, 17 Sep 2015 09:49:00 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 90439A2C22; Thu, 17 Sep 2015 13:48:59 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHt030423; Thu, 17 Sep 2015 09:48:57 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:17 +0200 Message-Id: <1442497700-2536-14-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 13/16] block: Implement bdrv_append() without bdrv_swap() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:49:04 -0000 Remember all parent nodes and just change the pointers there instead of swapping the contents of the BlockDriverState. Handling of snapshot=on must be moved further down in bdrv_open() because *pbs (which is the bs pointer in the BlockBackend) must already be set before bdrv_append() is called. Otherwise bdrv_append() changes the BB's pointer to the temporary snapshot, but bdrv_open() overwrites it with the read-only original image. Signed-off-by: Kevin Wolf --- block.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 81 insertions(+), 28 deletions(-) diff --git a/block.c b/block.c index c196f83..98fc17c 100644 --- a/block.c +++ b/block.c @@ -1516,15 +1516,6 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, bdrv_refresh_filename(bs); - /* For snapshot=on, create a temporary qcow2 overlay. bs points to the - * temporary snapshot afterwards. */ - if (snapshot_flags) { - ret = bdrv_append_temp_snapshot(bs, snapshot_flags, &local_err); - if (local_err) { - goto close_and_fail; - } - } - /* Check if any unknown options were used */ if (options && (qdict_size(options) != 0)) { const QDictEntry *entry = qdict_first(options); @@ -1556,6 +1547,16 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, QDECREF(options); *pbs = bs; + + /* For snapshot=on, create a temporary qcow2 overlay. bs points to the + * temporary snapshot afterwards. */ + if (snapshot_flags) { + ret = bdrv_append_temp_snapshot(bs, snapshot_flags, &local_err); + if (local_err) { + goto close_and_fail; + } + } + return 0; fail: @@ -1999,20 +2000,6 @@ static void bdrv_move_feature_fields(BlockDriverState *bs_dest, bs_dest->enable_write_cache = bs_src->enable_write_cache; - /* i/o throttled req */ - bs_dest->throttle_state = bs_src->throttle_state, - bs_dest->io_limits_enabled = bs_src->io_limits_enabled; - bs_dest->pending_reqs[0] = bs_src->pending_reqs[0]; - bs_dest->pending_reqs[1] = bs_src->pending_reqs[1]; - bs_dest->throttled_reqs[0] = bs_src->throttled_reqs[0]; - bs_dest->throttled_reqs[1] = bs_src->throttled_reqs[1]; - memcpy(&bs_dest->round_robin, - &bs_src->round_robin, - sizeof(bs_dest->round_robin)); - memcpy(&bs_dest->throttle_timers, - &bs_src->throttle_timers, - sizeof(ThrottleTimers)); - /* r/w error */ bs_dest->on_read_error = bs_src->on_read_error; bs_dest->on_write_error = bs_src->on_write_error; @@ -2026,10 +2013,25 @@ static void bdrv_move_feature_fields(BlockDriverState *bs_dest, } /* Fields that only need to be swapped if the contents of BDSes is swapped - * rather than pointers being changed in the parents. */ + * rather than pointers being changed in the parents, and throttling fields + * because only bdrv_swap() messes with internals of throttling. */ static void bdrv_move_reference_fields(BlockDriverState *bs_dest, BlockDriverState *bs_src) { + /* i/o throttled req */ + bs_dest->throttle_state = bs_src->throttle_state, + bs_dest->io_limits_enabled = bs_src->io_limits_enabled; + bs_dest->pending_reqs[0] = bs_src->pending_reqs[0]; + bs_dest->pending_reqs[1] = bs_src->pending_reqs[1]; + bs_dest->throttled_reqs[0] = bs_src->throttled_reqs[0]; + bs_dest->throttled_reqs[1] = bs_src->throttled_reqs[1]; + memcpy(&bs_dest->round_robin, + &bs_src->round_robin, + sizeof(bs_dest->round_robin)); + memcpy(&bs_dest->throttle_timers, + &bs_src->throttle_timers, + sizeof(ThrottleTimers)); + /* reference count */ bs_dest->refcnt = bs_src->refcnt; @@ -2155,6 +2157,42 @@ void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old) bdrv_rebind(bs_old); } +static void change_parent_backing_link(BlockDriverState *from, + BlockDriverState *to) +{ + BdrvChild *c, *next; + + QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) { + assert(c->role != &child_backing); + c->bs = to; + QLIST_REMOVE(c, next_parent); + QLIST_INSERT_HEAD(&to->parents, c, next_parent); + } + if (from->blk) { + blk_set_bs(from->blk, to); + if (!to->device_list.tqe_prev) { + QTAILQ_INSERT_BEFORE(from, to, device_list); + } + QTAILQ_REMOVE(&bdrv_states, from, device_list); + } +} + +static void swap_feature_fields(BlockDriverState *bs_top, + BlockDriverState *bs_new) +{ + BlockDriverState tmp; + + bdrv_move_feature_fields(&tmp, bs_top); + bdrv_move_feature_fields(bs_top, bs_new); + bdrv_move_feature_fields(bs_new, &tmp); + + assert(!bs_new->io_limits_enabled); + if (bs_top->io_limits_enabled) { + bdrv_io_limits_enable(bs_new, throttle_group_get_name(bs_top)); + bdrv_io_limits_disable(bs_top); + } +} + /* * Add new bs contents at the top of an image chain while the chain is * live, while keeping required fields on the top layer. @@ -2165,14 +2203,29 @@ void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old) * bs_new must not be attached to a BlockBackend. * * This function does not create any image files. + * + * bdrv_append() takes ownership of a bs_new reference and unrefs it because + * that's what the callers commonly need. bs_new will be referenced by the old + * parents of bs_top after bdrv_append() returns. If the caller needs to keep a + * reference of its own, it must call bdrv_ref(). */ void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top) { - bdrv_swap(bs_new, bs_top); + assert(!bdrv_requests_pending(bs_top)); + assert(!bdrv_requests_pending(bs_new)); + + bdrv_ref(bs_top); + change_parent_backing_link(bs_top, bs_new); + + /* Some fields always stay on top of the backing file chain */ + swap_feature_fields(bs_top, bs_new); + + bdrv_set_backing_hd(bs_new, bs_top); + bdrv_unref(bs_top); - /* The contents of 'tmp' will become bs_top, as we are - * swapping bs_new and bs_top contents. */ - bdrv_set_backing_hd(bs_top, bs_new); + /* bs_new is now referenced by its new parents, we don't need the + * additional reference any more. */ + bdrv_unref(bs_new); } static void bdrv_delete(BlockDriverState *bs) -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:49:09 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYj-0002YZ-OO for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:49:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYg-0002RC-AZ for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:49:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZYe-0002Ji-Uk for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:49:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59380) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYe-0002Jc-LV; Thu, 17 Sep 2015 09:49:04 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 55E54C0B203A; Thu, 17 Sep 2015 13:49:04 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHv030423; Thu, 17 Sep 2015 09:49:02 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:19 +0200 Message-Id: <1442497700-2536-16-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 15/16] block: Add and use bdrv_replace_in_backing_chain() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:49:08 -0000 This cleans up the mess we left behind in the mirror code after the previous patch. Instead of using bdrv_swap(), just change pointers. The interface change of the mirror job that callers must consider is that after job completion, their local BDS pointers still point to the same node now. qemu-img must change its code accordingly (which makes it easier to understand); the other callers stays unchanged because after completion they don't do anything with the BDS, but just with the job, and the job is still owned by the source BDS. Signed-off-by: Kevin Wolf --- block.c | 32 +++++++++++++++++++++++++++++++- block/mirror.c | 23 +++++++---------------- include/block/block.h | 4 +++- qemu-img.c | 16 ++++++++-------- 4 files changed, 49 insertions(+), 26 deletions(-) diff --git a/block.c b/block.c index 98fc17c..7c21659 100644 --- a/block.c +++ b/block.c @@ -1095,7 +1095,7 @@ static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, return child; } -void bdrv_detach_child(BdrvChild *child) +static void bdrv_detach_child(BdrvChild *child) { QLIST_REMOVE(child, next); QLIST_REMOVE(child, next_parent); @@ -2228,6 +2228,36 @@ void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top) bdrv_unref(bs_new); } +void bdrv_replace_in_backing_chain(BlockDriverState *old, BlockDriverState *new) +{ + assert(!bdrv_requests_pending(old)); + assert(!bdrv_requests_pending(new)); + + bdrv_ref(old); + + if (old->blk) { + /* As long as these fields aren't in BlockBackend, but in the top-level + * BlockDriverState, it's not possible for a BDS to have two BBs. + * + * We really want to copy the fields from old to new, but we go for a + * swap instead so that pointers aren't duplicated and cause trouble. + * (Also, bdrv_swap() used to do the same.) */ + assert(!new->blk); + swap_feature_fields(old, new); + } + change_parent_backing_link(old, new); + + /* Change backing files if a previously independent node is added to the + * chain. For active commit, we replace top by its own (indirect) backing + * file and don't do anything here so we don't build a loop. */ + if (new->backing == NULL && !bdrv_chain_contains(backing_bs(old), new)) { + bdrv_set_backing_hd(new, backing_bs(old)); + bdrv_set_backing_hd(old, NULL); + } + + bdrv_unref(old); +} + static void bdrv_delete(BlockDriverState *bs) { assert(!bs->job); diff --git a/block/mirror.c b/block/mirror.c index 571da27..443d97c 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -353,6 +353,11 @@ static void mirror_exit(BlockJob *job, void *opaque) MirrorBlockJob *s = container_of(job, MirrorBlockJob, common); MirrorExitData *data = opaque; AioContext *replace_aio_context = NULL; + BlockDriverState *src = s->common.bs; + + /* Make sure that the source BDS doesn't go away before we called + * block_job_completed(). */ + bdrv_ref(src); if (s->to_replace) { replace_aio_context = bdrv_get_aio_context(s->to_replace); @@ -367,22 +372,7 @@ static void mirror_exit(BlockJob *job, void *opaque) if (bdrv_get_flags(s->target) != bdrv_get_flags(to_replace)) { bdrv_reopen(s->target, bdrv_get_flags(to_replace), NULL); } - bdrv_swap(s->target, to_replace); - if (s->common.driver->job_type == BLOCK_JOB_TYPE_COMMIT) { - /* drop the bs loop chain formed by the swap: break the loop then - * trigger the unref */ - /* FIXME This duplicates bdrv_set_backing_hd(), except for the - * actual detach/unref so that the loop can be broken. When - * bdrv_swap() gets replaced, this will become sane again. */ - BlockDriverState *backing = s->base->backing->bs; - assert(s->base->backing_blocker); - bdrv_op_unblock_all(s->base->backing->bs, s->base->backing_blocker); - error_free(s->base->backing_blocker); - s->base->backing_blocker = NULL; - bdrv_detach_child(s->base->backing); - s->base->backing = NULL; - bdrv_unref(backing); - } + bdrv_replace_in_backing_chain(to_replace, s->target); } if (s->to_replace) { bdrv_op_unblock_all(s->to_replace, s->replace_blocker); @@ -396,6 +386,7 @@ static void mirror_exit(BlockJob *job, void *opaque) bdrv_unref(s->target); block_job_completed(&s->common, data->ret); g_free(data); + bdrv_unref(src); } static void coroutine_fn mirror_run(void *opaque) diff --git a/include/block/block.h b/include/block/block.h index 6dc6766..a046bd0 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -202,6 +202,9 @@ BlockDriverState *bdrv_new(void); void bdrv_make_anon(BlockDriverState *bs); void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old); void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top); +void bdrv_replace_in_backing_chain(BlockDriverState *old, + BlockDriverState *new); + int bdrv_parse_cache_flags(const char *mode, int *flags); int bdrv_parse_discard_flags(const char *mode, int *flags); BdrvChild *bdrv_open_child(const char *filename, @@ -510,7 +513,6 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs); void bdrv_ref(BlockDriverState *bs); void bdrv_unref(BlockDriverState *bs); void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child); -void bdrv_detach_child(BdrvChild *child); bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp); void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason); diff --git a/qemu-img.c b/qemu-img.c index c4454da..575013b 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -765,12 +765,12 @@ static int img_commit(int argc, char **argv) goto done; } - /* The block job will swap base_bs and bs (which is not what we really want - * here, but okay) and unref base_bs (after the swap, i.e., the old top - * image). In order to still be able to empty that top image afterwards, - * increment the reference counter here preemptively. */ + /* When the block job completes, the BlockBackend reference will point to + * the old backing file. In order to avoid that the top image is already + * deleted, so we can still empty it afterwards, increment the reference + * counter here preemptively. */ if (!drop) { - bdrv_ref(base_bs); + bdrv_ref(bs); } run_block_job(bs->job, &local_err); @@ -778,8 +778,8 @@ static int img_commit(int argc, char **argv) goto unref_backing; } - if (!drop && base_bs->drv->bdrv_make_empty) { - ret = base_bs->drv->bdrv_make_empty(base_bs); + if (!drop && bs->drv->bdrv_make_empty) { + ret = bs->drv->bdrv_make_empty(bs); if (ret) { error_setg_errno(&local_err, -ret, "Could not empty %s", filename); @@ -789,7 +789,7 @@ static int img_commit(int argc, char **argv) unref_backing: if (!drop) { - bdrv_unref(base_bs); + bdrv_unref(bs); } done: -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:49:08 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYi-0002Vd-DF for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:49:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYd-0002LV-BT for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:49:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZYc-0002IZ-GB for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:49:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54992) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYc-0002IP-9l; Thu, 17 Sep 2015 09:49:02 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id EF81B8EA2E; Thu, 17 Sep 2015 13:49:01 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHu030423; Thu, 17 Sep 2015 09:48:59 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:18 +0200 Message-Id: <1442497700-2536-15-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 14/16] blockjob: Store device name at job creation X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:49:04 -0000 Some block jobs change the block device graph on completion. This means that the device that owns the job and originally was addressed with its device name may no longer be what the corresponding BlockBackend points to. Previously, the effects of bdrv_swap() ensured that the job was (at least partially) transferred to the target image. Events that contain the device name could still use bdrv_get_device_name(job->bs) and get the same result. After removing bdrv_swap(), this won't work any more. Instead, save the device name at job creation and use that copy for the events. Signed-off-by: Kevin Wolf --- blockjob.c | 8 +++++--- include/block/blockjob.h | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/blockjob.c b/blockjob.c index 62bb906..1b5e535 100644 --- a/blockjob.c +++ b/blockjob.c @@ -54,6 +54,7 @@ void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs, bdrv_op_unblock(bs, BLOCK_OP_TYPE_DATAPLANE, job->blocker); job->driver = driver; + job->id = g_strdup(bdrv_get_device_name(bs)); job->bs = bs; job->cb = cb; job->opaque = opaque; @@ -81,6 +82,7 @@ void block_job_release(BlockDriverState *bs) bs->job = NULL; bdrv_op_unblock_all(bs, job->blocker); error_free(job->blocker); + g_free(job->id); g_free(job); } @@ -291,7 +293,7 @@ static void block_job_iostatus_set_err(BlockJob *job, int error) void block_job_event_cancelled(BlockJob *job) { qapi_event_send_block_job_cancelled(job->driver->job_type, - bdrv_get_device_name(job->bs), + job->id, job->len, job->offset, job->speed, @@ -301,7 +303,7 @@ void block_job_event_cancelled(BlockJob *job) void block_job_event_completed(BlockJob *job, const char *msg) { qapi_event_send_block_job_completed(job->driver->job_type, - bdrv_get_device_name(job->bs), + job->id, job->len, job->offset, job->speed, @@ -315,7 +317,7 @@ void block_job_event_ready(BlockJob *job) job->ready = true; qapi_event_send_block_job_ready(job->driver->job_type, - bdrv_get_device_name(job->bs), + job->id, job->len, job->offset, job->speed, &error_abort); diff --git a/include/block/blockjob.h b/include/block/blockjob.h index dd9d5e6..289b13f 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -65,6 +65,14 @@ struct BlockJob { BlockDriverState *bs; /** + * The ID of the block job. Currently the BlockBackend name of the BDS + * owning the job at the time when the job is started. + * + * TODO Decouple block job IDs from BlockBackend names + */ + char *id; + + /** * The coroutine that executes the job. If not NULL, it is * reentered when busy is false and the job is cancelled. */ -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:49:17 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYr-0002nO-Ep for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:49:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYi-0002XL-Se for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:49:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZYh-0002Kf-C4 for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:49:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55025) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYh-0002KT-2R; Thu, 17 Sep 2015 09:49:07 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B85CC3C222; Thu, 17 Sep 2015 13:49:06 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHw030423; Thu, 17 Sep 2015 09:49:04 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:20 +0200 Message-Id: <1442497700-2536-17-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 16/16] block: Remove bdrv_swap() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:49:13 -0000 bdrv_swap() is unused now. Remove it and all functions that have no other users than bdrv_swap(). In particular, this removes the .bdrv_rebind callbacks from block drivers. Signed-off-by: Kevin Wolf --- block.c | 155 +--------------------------------------------- block/qed.c | 7 --- block/vvfat.c | 7 --- include/block/block_int.h | 1 - include/qemu/queue.h | 6 -- 5 files changed, 1 insertion(+), 175 deletions(-) diff --git a/block.c b/block.c index 7c21659..5973409 100644 --- a/block.c +++ b/block.c @@ -1980,15 +1980,7 @@ void bdrv_make_anon(BlockDriverState *bs) bs->node_name[0] = '\0'; } -static void bdrv_rebind(BlockDriverState *bs) -{ - if (bs->drv && bs->drv->bdrv_rebind) { - bs->drv->bdrv_rebind(bs); - } -} - -/* Fields that need to stay with the top-level BDS, no matter whether the - * address of the top-level BDS stays the same or not. */ +/* Fields that need to stay with the top-level BDS */ static void bdrv_move_feature_fields(BlockDriverState *bs_dest, BlockDriverState *bs_src) { @@ -2012,151 +2004,6 @@ static void bdrv_move_feature_fields(BlockDriverState *bs_dest, bs_dest->dirty_bitmaps = bs_src->dirty_bitmaps; } -/* Fields that only need to be swapped if the contents of BDSes is swapped - * rather than pointers being changed in the parents, and throttling fields - * because only bdrv_swap() messes with internals of throttling. */ -static void bdrv_move_reference_fields(BlockDriverState *bs_dest, - BlockDriverState *bs_src) -{ - /* i/o throttled req */ - bs_dest->throttle_state = bs_src->throttle_state, - bs_dest->io_limits_enabled = bs_src->io_limits_enabled; - bs_dest->pending_reqs[0] = bs_src->pending_reqs[0]; - bs_dest->pending_reqs[1] = bs_src->pending_reqs[1]; - bs_dest->throttled_reqs[0] = bs_src->throttled_reqs[0]; - bs_dest->throttled_reqs[1] = bs_src->throttled_reqs[1]; - memcpy(&bs_dest->round_robin, - &bs_src->round_robin, - sizeof(bs_dest->round_robin)); - memcpy(&bs_dest->throttle_timers, - &bs_src->throttle_timers, - sizeof(ThrottleTimers)); - - /* reference count */ - bs_dest->refcnt = bs_src->refcnt; - - /* job */ - bs_dest->job = bs_src->job; - - /* keep the same entry in bdrv_states */ - bs_dest->device_list = bs_src->device_list; - bs_dest->blk = bs_src->blk; - bs_dest->parents = bs_src->parents; - - memcpy(bs_dest->op_blockers, bs_src->op_blockers, - sizeof(bs_dest->op_blockers)); -} - -/* - * Swap bs contents for two image chains while they are live, - * while keeping required fields on the BlockDriverState that is - * actually attached to a device. - * - * This will modify the BlockDriverState fields, and swap contents - * between bs_new and bs_old. Both bs_new and bs_old are modified. - * - * bs_new must not be attached to a BlockBackend. - * - * This function does not create any image files. - */ -void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old) -{ - BlockDriverState tmp; - BdrvChild *child; - - bdrv_drain(bs_new); - bdrv_drain(bs_old); - - /* The code needs to swap the node_name but simply swapping node_list won't - * work so first remove the nodes from the graph list, do the swap then - * insert them back if needed. - */ - if (bs_new->node_name[0] != '\0') { - QTAILQ_REMOVE(&graph_bdrv_states, bs_new, node_list); - } - if (bs_old->node_name[0] != '\0') { - QTAILQ_REMOVE(&graph_bdrv_states, bs_old, node_list); - } - - /* If the BlockDriverState is part of a throttling group acquire - * its lock since we're going to mess with the protected fields. - * Otherwise there's no need to worry since no one else can touch - * them. */ - if (bs_old->throttle_state) { - throttle_group_lock(bs_old); - } - - /* bs_new must be unattached and shouldn't have anything fancy enabled */ - assert(!bs_new->blk); - assert(QLIST_EMPTY(&bs_new->dirty_bitmaps)); - assert(bs_new->job == NULL); - assert(bs_new->io_limits_enabled == false); - assert(bs_new->throttle_state == NULL); - assert(!throttle_timers_are_initialized(&bs_new->throttle_timers)); - - tmp = *bs_new; - *bs_new = *bs_old; - *bs_old = tmp; - - /* there are some fields that should not be swapped, move them back */ - bdrv_move_feature_fields(&tmp, bs_old); - bdrv_move_feature_fields(bs_old, bs_new); - bdrv_move_feature_fields(bs_new, &tmp); - - bdrv_move_reference_fields(&tmp, bs_old); - bdrv_move_reference_fields(bs_old, bs_new); - bdrv_move_reference_fields(bs_new, &tmp); - - /* bs_new must remain unattached */ - assert(!bs_new->blk); - - /* Check a few fields that should remain attached to the device */ - assert(bs_new->job == NULL); - assert(bs_new->io_limits_enabled == false); - assert(bs_new->throttle_state == NULL); - assert(!throttle_timers_are_initialized(&bs_new->throttle_timers)); - - /* Release the ThrottleGroup lock */ - if (bs_old->throttle_state) { - throttle_group_unlock(bs_old); - } - - /* insert the nodes back into the graph node list if needed */ - if (bs_new->node_name[0] != '\0') { - QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs_new, node_list); - } - if (bs_old->node_name[0] != '\0') { - QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs_old, node_list); - } - - /* - * Update lh_first.le_prev for non-empty lists. - * - * The head of the op blocker list doesn't change because it is moved back - * in bdrv_move_feature_fields(). - */ - assert(QLIST_EMPTY(&bs_old->tracked_requests)); - assert(QLIST_EMPTY(&bs_new->tracked_requests)); - - QLIST_FIX_HEAD_PTR(&bs_new->children, next); - QLIST_FIX_HEAD_PTR(&bs_old->children, next); - - /* Update references in bs->opaque and children */ - QLIST_FOREACH(child, &bs_old->children, next) { - if (child->bs->inherits_from == bs_new) { - child->bs->inherits_from = bs_old; - } - } - QLIST_FOREACH(child, &bs_new->children, next) { - if (child->bs->inherits_from == bs_old) { - child->bs->inherits_from = bs_new; - } - } - - bdrv_rebind(bs_new); - bdrv_rebind(bs_old); -} - static void change_parent_backing_link(BlockDriverState *from, BlockDriverState *to) { diff --git a/block/qed.c b/block/qed.c index 0af81dc..5ea05d4 100644 --- a/block/qed.c +++ b/block/qed.c @@ -354,12 +354,6 @@ static void qed_cancel_need_check_timer(BDRVQEDState *s) timer_del(s->need_check_timer); } -static void bdrv_qed_rebind(BlockDriverState *bs) -{ - BDRVQEDState *s = bs->opaque; - s->bs = bs; -} - static void bdrv_qed_detach_aio_context(BlockDriverState *bs) { BDRVQEDState *s = bs->opaque; @@ -1664,7 +1658,6 @@ static BlockDriver bdrv_qed = { .supports_backing = true, .bdrv_probe = bdrv_qed_probe, - .bdrv_rebind = bdrv_qed_rebind, .bdrv_open = bdrv_qed_open, .bdrv_close = bdrv_qed_close, .bdrv_reopen_prepare = bdrv_qed_reopen_prepare, diff --git a/block/vvfat.c b/block/vvfat.c index b41055a..b184eca 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -985,12 +985,6 @@ static BDRVVVFATState *vvv = NULL; static int enable_write_target(BDRVVVFATState *s, Error **errp); static int is_consistent(BDRVVVFATState *s); -static void vvfat_rebind(BlockDriverState *bs) -{ - BDRVVVFATState *s = bs->opaque; - s->bs = bs; -} - static QemuOptsList runtime_opts = { .name = "vvfat", .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), @@ -3012,7 +3006,6 @@ static BlockDriver bdrv_vvfat = { .bdrv_parse_filename = vvfat_parse_filename, .bdrv_file_open = vvfat_open, .bdrv_close = vvfat_close, - .bdrv_rebind = vvfat_rebind, .bdrv_read = vvfat_co_read, .bdrv_write = vvfat_co_write, diff --git a/include/block/block_int.h b/include/block/block_int.h index 52ea7c0..c0e6513 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -122,7 +122,6 @@ struct BlockDriver { int (*bdrv_write)(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors); void (*bdrv_close)(BlockDriverState *bs); - void (*bdrv_rebind)(BlockDriverState *bs); int (*bdrv_create)(const char *filename, QemuOpts *opts, Error **errp); int (*bdrv_set_key)(BlockDriverState *bs, const char *key); int (*bdrv_make_empty)(BlockDriverState *bs); diff --git a/include/qemu/queue.h b/include/qemu/queue.h index a8d3cb8..f781aa2 100644 --- a/include/qemu/queue.h +++ b/include/qemu/queue.h @@ -117,12 +117,6 @@ struct { \ } \ } while (/*CONSTCOND*/0) -#define QLIST_FIX_HEAD_PTR(head, field) do { \ - if ((head)->lh_first != NULL) { \ - (head)->lh_first->field.le_prev = &(head)->lh_first; \ - } \ -} while (/*CONSTCOND*/0) - #define QLIST_INSERT_AFTER(listelm, elm, field) do { \ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ (listelm)->field.le_next->field.le_prev = \ -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 09:49:08 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcZYi-0002WI-J7 for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 09:49:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYe-0002NB-BA for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:49:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcZYY-0002DI-Gc for qemu-block@nongnu.org; Thu, 17 Sep 2015 09:49:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56191) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcZYY-0002Cu-BQ; Thu, 17 Sep 2015 09:48:58 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id BD714AB840; Thu, 17 Sep 2015 13:48:57 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-129.ams2.redhat.com [10.36.116.129]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HDmNHs030423; Thu, 17 Sep 2015 09:48:55 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 17 Sep 2015 15:48:16 +0200 Message-Id: <1442497700-2536-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-block] [PATCH 12/16] block: Introduce parents list X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 13:49:05 -0000 Signed-off-by: Kevin Wolf --- block.c | 3 +++ include/block/block_int.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/block.c b/block.c index 7930f3c..c196f83 100644 --- a/block.c +++ b/block.c @@ -1090,6 +1090,7 @@ static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, }; QLIST_INSERT_HEAD(&parent_bs->children, child, next); + QLIST_INSERT_HEAD(&child_bs->parents, child, next_parent); return child; } @@ -1097,6 +1098,7 @@ static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, void bdrv_detach_child(BdrvChild *child) { QLIST_REMOVE(child, next); + QLIST_REMOVE(child, next_parent); g_free(child); } @@ -2037,6 +2039,7 @@ static void bdrv_move_reference_fields(BlockDriverState *bs_dest, /* keep the same entry in bdrv_states */ bs_dest->device_list = bs_src->device_list; bs_dest->blk = bs_src->blk; + bs_dest->parents = bs_src->parents; memcpy(bs_dest->op_blockers, bs_src->op_blockers, sizeof(bs_dest->op_blockers)); diff --git a/include/block/block_int.h b/include/block/block_int.h index cfcae52..52ea7c0 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -339,6 +339,7 @@ struct BdrvChild { BlockDriverState *bs; const BdrvChildRole *role; QLIST_ENTRY(BdrvChild) next; + QLIST_ENTRY(BdrvChild) next_parent; }; /* @@ -445,6 +446,7 @@ struct BlockDriverState { * parent node of this node. */ BlockDriverState *inherits_from; QLIST_HEAD(, BdrvChild) children; + QLIST_HEAD(, BdrvChild) parents; QDict *options; BlockdevDetectZeroesOptions detect_zeroes; -- 1.8.3.1 From MAILER-DAEMON Thu Sep 17 10:35:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcaHJ-0003fR-AY for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 10:35:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcaHB-0003RB-UT for qemu-block@nongnu.org; Thu, 17 Sep 2015 10:35:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcaHA-0000OO-QS for qemu-block@nongnu.org; Thu, 17 Sep 2015 10:35:05 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:16559 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcaH4-0008Qg-2r; Thu, 17 Sep 2015 10:34:58 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2C7CACfzvpV/5tjdVtdGQEBAYMHAVNpgUynVQUBAQEBAQEFAYEKAYMOj3cBDYFqC4JHgzaBQzgUAQEBAQEBAYEKhSNPTjQJiCkBzBWGLIpRhDMFhzSFSHGHNj6NBoFNjGyFLINIg20fAQFCgUoBgjluiioBAQE X-IPAS-Result: A2C7CACfzvpV/5tjdVtdGQEBAYMHAVNpgUynVQUBAQEBAQEFAYEKAYMOj3cBDYFqC4JHgzaBQzgUAQEBAQEBAYEKhSNPTjQJiCkBzBWGLIpRhDMFhzSFSHGHNj6NBoFNjGyFLINIg20fAQFCgUoBgjluiioBAQE X-IronPort-AV: E=Sophos;i="5.17,547,1437429600"; d="scan'208";a="24122833" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 17 Sep 2015 16:34:15 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZcaGJ-00023J-Ln; Thu, 17 Sep 2015 16:34:11 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZcaG6-0000xp-B9; Thu, 17 Sep 2015 17:33:58 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 17 Sep 2015 17:33:06 +0300 Message-Id: <1442500386-3668-1-git-send-email-berto@igalia.com> X-Mailer: git-send-email 2.5.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org Subject: [Qemu-block] [PATCH] throttle: test that snapshots move the throttling configuration X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 14:35:11 -0000 If a snapshot is performed on a device that has I/O limits they should be moved to the target image (the new active layer). Signed-off-by: Alberto Garcia --- tests/qemu-iotests/096 | 69 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/096.out | 5 ++++ tests/qemu-iotests/group | 1 + 3 files changed, 75 insertions(+) create mode 100644 tests/qemu-iotests/096 create mode 100644 tests/qemu-iotests/096.out diff --git a/tests/qemu-iotests/096 b/tests/qemu-iotests/096 new file mode 100644 index 0000000..e34204b --- /dev/null +++ b/tests/qemu-iotests/096 @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# +# Test that snapshots move the throttling configuration to the active +# layer +# +# Copyright (C) 2015 Igalia, S.L. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import iotests +import os + +class TestLiveSnapshot(iotests.QMPTestCase): + base_img = os.path.join(iotests.test_dir, 'base.img') + target_img = os.path.join(iotests.test_dir, 'target.img') + group = 'mygroup' + iops = 6000 + iops_size = 1024 + + def setUp(self): + opts = [] + opts.append('node-name=base') + opts.append('throttling.group=%s' % self.group) + opts.append('throttling.iops-total=%d' % self.iops) + opts.append('throttling.iops-size=%d' % self.iops_size) + iotests.qemu_img('create', '-f', iotests.imgfmt, self.base_img, '100M') + self.vm = iotests.VM().add_drive(self.base_img, ','.join(opts)) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + os.remove(self.base_img) + os.remove(self.target_img) + + def checkConfig(self, active_layer): + result = self.vm.qmp('query-named-block-nodes') + for r in result['return']: + if r['node-name'] == active_layer: + self.assertEqual(r['group'], self.group) + self.assertEqual(r['iops'], self.iops) + self.assertEqual(r['iops_size'], self.iops_size) + else: + self.assertFalse(r.has_key('group')) + self.assertEqual(r['iops'], 0) + self.assertFalse(r.has_key('iops_size')) + + def testSnapshot(self): + self.checkConfig('base') + self.vm.qmp('blockdev-snapshot-sync', + node_name = 'base', + snapshot_node_name = 'target', + snapshot_file = self.target_img, + format = iotests.imgfmt) + self.checkConfig('target') + +if __name__ == '__main__': + iotests.main(supported_fmts=['qcow2']) diff --git a/tests/qemu-iotests/096.out b/tests/qemu-iotests/096.out new file mode 100644 index 0000000..ae1213e --- /dev/null +++ b/tests/qemu-iotests/096.out @@ -0,0 +1,5 @@ +. +---------------------------------------------------------------------- +Ran 1 tests + +OK diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 439b1d2..30c784e 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -102,6 +102,7 @@ 093 auto 094 rw auto quick 095 rw auto quick +096 rw auto quick 097 rw auto backing 098 rw auto backing quick 099 rw auto quick -- 2.5.1 From MAILER-DAEMON Thu Sep 17 14:35:10 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zce1W-0001Ss-11 for mharc-qemu-block@gnu.org; Thu, 17 Sep 2015 14:35:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zce1T-0001RB-Pt for qemu-block@nongnu.org; Thu, 17 Sep 2015 14:35:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zce1Q-00062w-LA for qemu-block@nongnu.org; Thu, 17 Sep 2015 14:35:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33516) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zce1Q-00060j-Gn; Thu, 17 Sep 2015 14:35:04 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 8D6428E6E1; Thu, 17 Sep 2015 18:35:03 +0000 (UTC) Received: from scv.usersys.redhat.com (vpn-48-80.rdu2.redhat.com [10.10.48.80]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8HIZ2bA002846; Thu, 17 Sep 2015 14:35:02 -0400 To: Stefan Hajnoczi References: <1441140641-17631-1-git-send-email-jsnow@redhat.com> <20150917084009.GE21734@stefanha-thinkpad.redhat.com> From: John Snow Message-ID: <55FB07D6.2040209@redhat.com> Date: Thu, 17 Sep 2015 14:35:02 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150917084009.GE21734@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, armbru@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 0/4] ahci: clean up signature generation X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2015 18:35:08 -0000 On 09/17/2015 04:40 AM, Stefan Hajnoczi wrote: > On Tue, Sep 01, 2015 at 04:50:37PM -0400, John Snow wrote: >> Ultimately, clean up the signature generation and as a result, tidy up >> the port_reset and init_d2h functions. >> >> ________________________________________________________________________________ >> >> For convenience, this branch is available at: >> https://github.com/jnsnow/qemu.git branch ahci-sigfix >> https://github.com/jnsnow/qemu/tree/ahci-sigfix >> >> This version is tagged ahci-sigfix-v1: >> https://github.com/jnsnow/qemu/releases/tag/ahci-sigfix-v1 >> >> John Snow (4): >> ahci: remove dead reset code >> ahci: fix signature generation >> ahci: remove cmd_fis argument from write_fis_d2h >> ahci: clean up initial d2h semantics >> >> hw/ide/ahci.c | 53 ++++++++++++++++++++++++++++++----------------------- >> 1 file changed, 30 insertions(+), 23 deletions(-) >> >> -- >> 2.4.3 >> > > Reviewed-by: Stefan Hajnoczi > With the comment in patch 2 fixed: Thanks, applied to my IDE tree: https://github.com/jnsnow/qemu/commits/ide https://github.com/jnsnow/qemu.git --js From MAILER-DAEMON Fri Sep 18 05:02:10 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcrYY-0004hx-3E for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 05:02:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcrYW-0004ew-52 for qemu-block@nongnu.org; Fri, 18 Sep 2015 05:02:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcrYV-0007xt-Da for qemu-block@nongnu.org; Fri, 18 Sep 2015 05:02:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56518) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcrYV-0007xI-9O; Fri, 18 Sep 2015 05:02:07 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id D679AC0B2B5C; Fri, 18 Sep 2015 09:02:06 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-119.ams2.redhat.com [10.36.116.119]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8I923vI015317; Fri, 18 Sep 2015 05:02:05 -0400 Date: Fri, 18 Sep 2015 11:02:03 +0200 From: Kevin Wolf To: Vasiliy Tolstov Message-ID: <20150918090203.GA4320@noname.redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: mitake.hitoshi@lab.ntt.co.jp, namei.unix@gmail.com, sheepdog@lists.wpkg.org, qemu-devel , qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] internal snapshots with sheepdog X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 09:02:09 -0000 Am 11.09.2015 um 17:49 hat Vasiliy Tolstov geschrieben: > Hi! qcow2 have abilit to store vm state inside qcow2 file in space > that not allocated to guest, but if i want to store vm state inside > sheepdog storage with raw image what is the preferred place to store > memory data? > I simply can create additional vdi equa to memory size of the guest > and save memory to this file... Doesn't sheepdog already support storing snapshots in the same image? I thought it would just work; at least, there's some code there for it. Kevin From MAILER-DAEMON Fri Sep 18 05:04:18 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zcrac-0008Ek-Bx for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 05:04:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcraW-00084C-6a for qemu-block@nongnu.org; Fri, 18 Sep 2015 05:04:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcraR-0000KR-8G for qemu-block@nongnu.org; Fri, 18 Sep 2015 05:04:12 -0400 Received: from mail-la0-x22d.google.com ([2a00:1450:4010:c03::22d]:34053) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcraQ-0000KI-JW for qemu-block@nongnu.org; Fri, 18 Sep 2015 05:04:07 -0400 Received: by lahg1 with SMTP id g1so26923022lah.1 for ; Fri, 18 Sep 2015 02:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=selfip.ru; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=U4XjjtOVosVpAXwCBbJuBwmGRmlIQz1W39qLQx95RTY=; b=IllrNhaVNly/69afMu+t8BPqsw/fJYFAVWdMPgoGFRaFrFFLoS9sU+PHyp196CaMz9 9vhSkMeGCAHp8pqsbgoZTFdeQthTbvDLRiSaDkWDt6AsDWYeljch/XZ7fPz/ewCEGn6H rrC7gKVTFAU8WvKrGioxh0Bk2CwVV9AMGsrJA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-type; bh=U4XjjtOVosVpAXwCBbJuBwmGRmlIQz1W39qLQx95RTY=; b=CVS/W1gpBwA7ep7yjLbca0jrSrlCvLYiolVy1T2vlfyqiLyBHrjYPvVq5NfHu8ZBLV zyEKn6+OkoVuhRYrrYgR8k/zsaXK1up8zdEsTM/fQaWcQaDdU2dZIZd50sVerVjgejWF Nz7riQw72la0YprY37UlDmQb+HHrOE/EPguDIGGebjGQry5vFmR2mzy5NSnWwhJt9QF7 7aq2UL9eUp8lvU1RWDa4i3wexfusUU6Aesy2jZe+GIAhffTc40gKqIUv91BykYDe6SZJ CE5EWaJC419ha1xA1aQNcZtxiXrOCbNeEld9l4On+eMB8RceL+wekB+u2VE/ezSjtDwa LhLw== X-Gm-Message-State: ALoCoQkoiEiI3ccBGl6wYnCungOdEW63740/tXmaN9KEsPc/MmAcTLCYdD30BPErrwHB3dCpIkrU X-Received: by 10.152.2.162 with SMTP id 2mr736901lav.102.1442567045299; Fri, 18 Sep 2015 02:04:05 -0700 (PDT) MIME-Version: 1.0 Sender: vase@selfip.ru Received: by 10.25.153.197 with HTTP; Fri, 18 Sep 2015 02:03:50 -0700 (PDT) X-Originating-IP: [85.143.178.166] In-Reply-To: <20150918090203.GA4320@noname.redhat.com> References: <20150918090203.GA4320@noname.redhat.com> From: Vasiliy Tolstov Date: Fri, 18 Sep 2015 12:03:50 +0300 X-Google-Sender-Auth: z1tkS-6nISqAakVn3t3mNxDO534 Message-ID: To: Kevin Wolf Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22d Cc: mitake.hitoshi@lab.ntt.co.jp, namei.unix@gmail.com, sheepdog@lists.wpkg.org, qemu-devel , qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] internal snapshots with sheepdog X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 09:04:16 -0000 2015-09-18 12:02 GMT+03:00 Kevin Wolf : > Doesn't sheepdog already support storing snapshots in the same image? > I thought it would just work; at least, there's some code there for it. Yes, qemu and sheepdog have ability to create internal snapshot, i miss that, but when i'm try in libvirt create live snapshot - libvirt says, that this is not possible with raw image. -- Vasiliy Tolstov, e-mail: v.tolstov@selfip.ru From MAILER-DAEMON Fri Sep 18 05:49:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcsI7-0001Mp-QD for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 05:49:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcsI1-0001M1-TH for qemu-block@nongnu.org; Fri, 18 Sep 2015 05:49:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcsHy-0001Ku-N2 for qemu-block@nongnu.org; Fri, 18 Sep 2015 05:49:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcsHy-0001Kn-IX; Fri, 18 Sep 2015 05:49:06 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 136B95BA0F; Fri, 18 Sep 2015 09:49:06 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-119.ams2.redhat.com [10.36.116.119]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8I9n2Kq012397; Fri, 18 Sep 2015 05:49:04 -0400 Date: Fri, 18 Sep 2015 11:49:02 +0200 From: Kevin Wolf To: Vasiliy Tolstov Message-ID: <20150918094902.GB4320@noname.redhat.com> References: <20150918090203.GA4320@noname.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: sheepdog@lists.wpkg.org, qemu-block@nongnu.org, mitake.hitoshi@lab.ntt.co.jp, qemu-devel , libvir-list@redhat.com, namei.unix@gmail.com Subject: Re: [Qemu-block] [Qemu-devel] internal snapshots with sheepdog X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 09:49:13 -0000 Am 18.09.2015 um 11:03 hat Vasiliy Tolstov geschrieben: > 2015-09-18 12:02 GMT+03:00 Kevin Wolf : > > Doesn't sheepdog already support storing snapshots in the same image? > > I thought it would just work; at least, there's some code there for it. > > Yes, qemu and sheepdog have ability to create internal snapshot, i > miss that, but when i'm try in libvirt create live snapshot - libvirt > says, that this is not possible with raw image. Then I guess your mail should be directed to the libvirt list instead (CCed). Kevin From MAILER-DAEMON Fri Sep 18 06:14:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcsgW-0007IK-UD for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 06:14:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcsgU-0007FP-Hd for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:14:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcsgT-0006jI-9j for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:14:26 -0400 Received: from [59.151.112.132] (port=15594 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcsgN-0006cY-GI; Fri, 18 Sep 2015 06:14:19 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100865615" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Sep 2015 18:16:44 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8IADZxx018084; Fri, 18 Sep 2015 18:13:35 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 18 Sep 2015 18:13:51 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Fri, 18 Sep 2015 18:13:11 +0800 Message-ID: <1442571195-27116-1-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Yang Hongyang Subject: [Qemu-block] [PATCH v4 0/4] qapi: child add/delete support X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 10:14:27 -0000 If quorum's child is broken, we can use mirror job to replace it. But sometimes, the user only need to remove the broken child, and add it later when the problem is fixed. It is based on the following patch: http://lists.nongnu.org/archive/html/qemu-devel/2015-09/msg04579.html ChangLog: v4: 1. drop nbd driver's implementation. We can use human-monitor-command to do it. 2. Rename the command name. v3: 1. Don't open BDS in bdrv_add_child(). Use the existing BDS which is created by the QMP command blockdev-add. 2. The driver NBD can support filename, path, host:port now. v2: 1. Use bdrv_get_device_or_node_name() instead of new function bdrv_get_id_or_node_name() 2. Update the error message 3. Update the documents in block-core.json Wen Congyang (4): Add new block driver interface to add/delete a BDS's child quorum: implement bdrv_add_child() and bdrv_del_child() qmp: add monitor command to add/remove a child hmp: add monitor command to add/remove a child block.c | 56 ++++++++++++++++++++++++++++++++++-- block/quorum.c | 72 +++++++++++++++++++++++++++++++++++++++++++++-- blockdev.c | 48 +++++++++++++++++++++++++++++++ hmp-commands.hx | 28 ++++++++++++++++++ hmp.c | 20 +++++++++++++ hmp.h | 2 ++ include/block/block.h | 8 ++++++ include/block/block_int.h | 5 ++++ qapi/block-core.json | 34 ++++++++++++++++++++++ qmp-commands.hx | 54 +++++++++++++++++++++++++++++++++++ 10 files changed, 322 insertions(+), 5 deletions(-) -- 2.4.3 From MAILER-DAEMON Fri Sep 18 06:14:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcsgZ-0007Kg-CQ for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 06:14:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcsgU-0007FR-Qd for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:14:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcsgT-0006jV-H5 for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:14:26 -0400 Received: from [59.151.112.132] (port=65469 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcsgM-0006dt-Ln; Fri, 18 Sep 2015 06:14:20 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100865617" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Sep 2015 18:16:46 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8IADbPJ018087; Fri, 18 Sep 2015 18:13:37 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 18 Sep 2015 18:13:53 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Fri, 18 Sep 2015 18:13:12 +0800 Message-ID: <1442571195-27116-2-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1442571195-27116-1-git-send-email-wency@cn.fujitsu.com> References: <1442571195-27116-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v4 1/4] Add new block driver interface to add/delete a BDS's child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 10:14:29 -0000 In some cases, we want to take a quorum child offline, and take another child online. Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ include/block/block.h | 5 +++++ include/block/block_int.h | 5 +++++ 3 files changed, 60 insertions(+) diff --git a/block.c b/block.c index e815d73..bb7657b 100644 --- a/block.c +++ b/block.c @@ -4265,3 +4265,53 @@ BlockAcctStats *bdrv_get_stats(BlockDriverState *bs) { return &bs->stats; } + +/* + * Hot add/remove a BDS's child. So the user can take a child offline when + * it is broken and take a new child online + */ +void bdrv_add_child(BlockDriverState *parent_bs, BlockDriverState *child_bs, + Error **errp) +{ + + if (!parent_bs->drv || !parent_bs->drv->bdrv_add_child) { + error_setg(errp, "The BDS %s doesn't support adding a child", + bdrv_get_device_or_node_name(parent_bs)); + return; + } + + if (!QLIST_EMPTY(&child_bs->parents)) { + error_setg(errp, "The BDS %s already has parent", + child_bs->node_name); + return; + } + + parent_bs->drv->bdrv_add_child(parent_bs, child_bs, errp); +} + +void bdrv_del_child(BlockDriverState *parent_bs, BlockDriverState *child_bs, + Error **errp) +{ + BdrvChild *child; + + if (!parent_bs->drv || !parent_bs->drv->bdrv_del_child) { + error_setg(errp, "The BDS %s doesn't support removing a child", + bdrv_get_device_or_node_name(parent_bs)); + return; + } + + QLIST_FOREACH(child, &parent_bs->children, next) { + if (child->bs == child_bs) { + break; + } + } + + if (!child) { + error_setg(errp, "The BDS %s is not the BDS %s's child", + bdrv_get_device_or_node_name(child_bs), + bdrv_get_device_or_node_name(parent_bs)); + return; + } + + parent_bs->drv->bdrv_del_child(parent_bs, child_bs, errp); +} diff --git a/include/block/block.h b/include/block/block.h index ef67353..665c56f 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -616,4 +616,9 @@ void bdrv_flush_io_queue(BlockDriverState *bs); BlockAcctStats *bdrv_get_stats(BlockDriverState *bs); +void bdrv_add_child(BlockDriverState *parent, BlockDriverState *child, + Error **errp); +void bdrv_del_child(BlockDriverState *parent, BlockDriverState *child, + Error **errp); + #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index 2f2c47b..64cbc55 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -288,6 +288,11 @@ struct BlockDriver { */ int (*bdrv_probe_geometry)(BlockDriverState *bs, HDGeometry *geo); + void (*bdrv_add_child)(BlockDriverState *parent, BlockDriverState *child, + Error **errp); + void (*bdrv_del_child)(BlockDriverState *parent, BlockDriverState *child, + Error **errp); + QLIST_ENTRY(BlockDriver) list; }; -- 2.4.3 From MAILER-DAEMON Fri Sep 18 06:14:35 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zcsgd-0007Rg-M5 for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 06:14:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcsgX-0007Jh-Qk for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:14:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcsgW-0006ls-Sd for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:14:29 -0400 Received: from [59.151.112.132] (port=54934 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcsgP-0006fW-K3; Fri, 18 Sep 2015 06:14:22 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100865621" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Sep 2015 18:16:49 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8IADfji018099; Fri, 18 Sep 2015 18:13:41 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 18 Sep 2015 18:13:57 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Fri, 18 Sep 2015 18:13:15 +0800 Message-ID: <1442571195-27116-5-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1442571195-27116-1-git-send-email-wency@cn.fujitsu.com> References: <1442571195-27116-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Luiz Capitulino , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v4 4/4] hmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 10:14:34 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Cc: Luiz Capitulino --- hmp-commands.hx | 28 ++++++++++++++++++++++++++++ hmp.c | 20 ++++++++++++++++++++ hmp.h | 2 ++ 3 files changed, 50 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index a511004..6c5fe82 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -193,6 +193,34 @@ actions (drive options rerror, werror). ETEXI { + .name = "blockdev_child_add", + .args_type = "id:B,child:B", + .params = "parent child", + .help = "add a child to a BDS", + .mhandler.cmd = hmp_blockdev_child_add, + }, + +STEXI +@item blockdev_child_add @var{parent device} @var{child device} +@findex blockdev_child_add +Add a child to the block device. +ETEXI + + { + .name = "blockdev_child_del", + .args_type = "id:B,child:B", + .params = "parent child", + .help = "remove a child from a BDS", + .mhandler.cmd = hmp_blockdev_child_del, + }, + +STEXI +@item blockdev_child_del @var{parent device} @var{child device} +@findex blockdev_child_del +Remove a child from the parent device. +ETEXI + + { .name = "change", .args_type = "device:B,target:F,arg:s?", .params = "device filename [format]", diff --git a/hmp.c b/hmp.c index 3f807b7..1dc1bed 100644 --- a/hmp.c +++ b/hmp.c @@ -2325,3 +2325,23 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict) qapi_free_RockerOfDpaGroupList(list); } + +void hmp_blockdev_child_add(Monitor *mon, const QDict *qdict) +{ + const char *id = qdict_get_str(qdict, "id"); + const char *child_id = qdict_get_str(qdict, "child"); + Error *local_err = NULL; + + qmp_x_blockdev_child_add(id, child_id, &local_err); + hmp_handle_error(mon, &local_err); +} + +void hmp_blockdev_child_del(Monitor *mon, const QDict *qdict) +{ + const char *id = qdict_get_str(qdict, "id"); + const char *child_id = qdict_get_str(qdict, "child"); + Error *local_err = NULL; + + qmp_x_blockdev_child_del(id, child_id, &local_err); + hmp_handle_error(mon, &local_err); +} diff --git a/hmp.h b/hmp.h index 81656c3..3033648 100644 --- a/hmp.h +++ b/hmp.h @@ -130,5 +130,7 @@ void hmp_rocker(Monitor *mon, const QDict *qdict); void hmp_rocker_ports(Monitor *mon, const QDict *qdict); void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict); void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict); +void hmp_blockdev_child_add(Monitor *mon, const QDict *qdict); +void hmp_blockdev_child_del(Monitor *mon, const QDict *qdict); #endif -- 2.4.3 From MAILER-DAEMON Fri Sep 18 06:14:36 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zcsge-0007UR-S3 for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 06:14:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcsgb-0007OY-S7 for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:14:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcsgZ-0006n0-B1 for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:14:33 -0400 Received: from [59.151.112.132] (port=15594 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcsgP-0006cY-TR; Fri, 18 Sep 2015 06:14:23 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100865619" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Sep 2015 18:16:47 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8IADdLb018095; Fri, 18 Sep 2015 18:13:39 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 18 Sep 2015 18:13:55 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Fri, 18 Sep 2015 18:13:14 +0800 Message-ID: <1442571195-27116-4-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1442571195-27116-1-git-send-email-wency@cn.fujitsu.com> References: <1442571195-27116-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v4 3/4] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 10:14:35 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- blockdev.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++ qapi/block-core.json | 34 +++++++++++++++++++++++++++++++++ qmp-commands.hx | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) diff --git a/blockdev.c b/blockdev.c index 32b04b4..8da0ffb 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3086,6 +3086,54 @@ fail: qmp_output_visitor_cleanup(ov); } +void qmp_x_blockdev_child_add(const char *parent, const char *child, + Error **errp) +{ + BlockDriverState *parent_bs, *child_bs; + Error *local_err = NULL; + + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); + if (!parent_bs) { + error_propagate(errp, local_err); + return; + } + + child_bs = bdrv_find_node(child); + if (!child_bs) { + error_setg(errp, "Node '%s' not found", child); + return; + } + + bdrv_add_child(parent_bs, child_bs, &local_err); + if (local_err) { + error_propagate(errp, local_err); + } +} + +void qmp_x_blockdev_child_del(const char *parent, const char *child, + Error **errp) +{ + BlockDriverState *parent_bs, *child_bs; + Error *local_err = NULL; + + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); + if (!parent_bs) { + error_propagate(errp, local_err); + return; + } + + child_bs = bdrv_find_node(child); + if (!child_bs) { + error_setg(errp, "Node '%s' not found", child); + return; + } + + bdrv_del_child(parent_bs, child_bs, &local_err); + if (local_err) { + error_propagate(errp, local_err); + } +} + BlockJobInfoList *qmp_query_block_jobs(Error **errp) { BlockJobInfoList *head = NULL, **p_next = &head; diff --git a/qapi/block-core.json b/qapi/block-core.json index bb2189e..9418f05 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2114,3 +2114,37 @@ ## { 'command': 'block-set-write-threshold', 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } + +## +# @x-blockdev-child-add +# +# Add a new child to the parent BDS. Currently only the Quorum driver +# implements this feature. This is useful to fix a broken quorum child. +# +# @parent: graph node name or id which the child will be added to. +# +# @child: graph node name that will be added. +# +# Note: this command is experimental, and not a stable API. +# +# Since: 2.5 +## +{ 'command': 'x-blockdev-child-add', + 'data' : { 'parent': 'str', 'child': 'str' } } + +## +# @x-blockdev-child-del +# +# Remove a child from the parent BDS. Currently only the Quorum driver +# implements this feature. This is useful to fix a broken quorum child. +# Note, you can't remove a child if it would bring the quorum below its +# threshold. +# +# @parent: graph node name or id from which the child will removed. +# +# @child: graph node name that will be removed. +# +# Since: 2.5 +## +{ 'command': 'x-blockdev-child-del', + 'data' : { 'parent': 'str', 'child': 'str' } } diff --git a/qmp-commands.hx b/qmp-commands.hx index 9848fd8..11a007d 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3897,6 +3897,60 @@ Example (2): EQMP { + .name = "x-blockdev-child-add", + .args_type = "parent:B,child:B", + .mhandler.cmd_new = qmp_marshal_input_x_blockdev_child_add, + }, + +SQMP +x-blockdev-child-add +------------ + +Add a child to a quorum node. + +Arguments: + +- "parent": the quorum's id or node name +- "child": the child node-name which will be added + +Note: this command is experimental, and not a stable API. It doesn't +support all kinds of child, and not support all block drivers. + +Example: + +-> { "execute": "x-blockdev-child-add", + "arguments": { "parent": "disk1", "child": "new_node" } } +<- { "return": {} } + +EQMP + + { + .name = "x-blockdev-child-del", + .args_type = "parent:B,child:B", + .mhandler.cmd_new = qmp_marshal_input_x_blockdev_child_del, + }, + +SQMP +x-blockdev-child-del +------------ + +Delete a child from a quorum node. It can be used to remove a broken +quorum child. + +Arguments: + +- "parent": the quorum's id or node name +- "child": the child node-name which will be removed + +Example: + +-> { "execute": "x-blockdev-child-del", + "arguments": { "parent": "disk1", "child": "new_node" } } +<- { "return": {} } + +EQMP + + { .name = "query-named-block-nodes", .args_type = "", .mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes, -- 2.4.3 From MAILER-DAEMON Fri Sep 18 06:14:32 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcsgZ-0007LD-J3 for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 06:14:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcsgU-0007FS-Qv for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:14:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcsgT-0006jQ-GP for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:14:26 -0400 Received: from [59.151.112.132] (port=54934 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcsgN-0006fW-7Y; Fri, 18 Sep 2015 06:14:20 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100865618" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Sep 2015 18:16:46 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8IADclb018091; Fri, 18 Sep 2015 18:13:38 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 18 Sep 2015 18:13:54 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Fri, 18 Sep 2015 18:13:13 +0800 Message-ID: <1442571195-27116-3-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1442571195-27116-1-git-send-email-wency@cn.fujitsu.com> References: <1442571195-27116-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v4 2/4] quorum: implement bdrv_add_child() and bdrv_del_child() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 10:14:29 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block.c | 6 ++--- block/quorum.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++-- include/block/block.h | 3 +++ 3 files changed, 76 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index bb7657b..4dc0e29 100644 --- a/block.c +++ b/block.c @@ -1079,9 +1079,9 @@ static int bdrv_fill_options(QDict **options, const char **pfilename, return 0; } -static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, - BlockDriverState *child_bs, - const BdrvChildRole *child_role) +BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, + BlockDriverState *child_bs, + const BdrvChildRole *child_role) { BdrvChild *child = g_new(BdrvChild, 1); *child = (BdrvChild) { diff --git a/block/quorum.c b/block/quorum.c index 8fe53b4..111a57b 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -66,6 +66,9 @@ typedef struct QuorumVotes { typedef struct BDRVQuorumState { BlockDriverState **bs; /* children BlockDriverStates */ int num_children; /* children count */ + int max_children; /* The maximum children count, we need to reallocate + * bs if num_children grows larger than maximum. + */ int threshold; /* if less than threshold children reads gave the * same result a quorum error occurs. */ @@ -874,9 +877,9 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, ret = -EINVAL; goto exit; } - if (s->num_children < 2) { + if (s->num_children < 1) { error_setg(&local_err, - "Number of provided children must be greater than 1"); + "Number of provided children must be 1 or more"); ret = -EINVAL; goto exit; } @@ -925,6 +928,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, /* allocate the children BlockDriverState array */ s->bs = g_new0(BlockDriverState *, s->num_children); opened = g_new0(bool, s->num_children); + s->max_children = s->num_children; for (i = 0; i < s->num_children; i++) { char indexstr[32]; @@ -995,6 +999,67 @@ static void quorum_attach_aio_context(BlockDriverState *bs, } } +static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs, + Error **errp) +{ + BDRVQuorumState *s = bs->opaque; + + bdrv_drain(bs); + + if (s->num_children == s->max_children) { + if (s->max_children >= INT_MAX) { + error_setg(errp, "Too many children"); + return; + } + + s->bs = g_renew(BlockDriverState *, s->bs, s->max_children + 1); + s->bs[s->num_children] = NULL; + s->max_children++; + } + + bdrv_ref(child_bs); + bdrv_attach_child(bs, child_bs, &child_format); + s->bs[s->num_children++] = child_bs; +} + +static void quorum_del_child(BlockDriverState *bs, BlockDriverState *child_bs, + Error **errp) +{ + BDRVQuorumState *s = bs->opaque; + BdrvChild *child; + int i; + + for (i = 0; i < s->num_children; i++) { + if (s->bs[i] == child_bs) { + break; + } + } + + QLIST_FOREACH(child, &bs->children, next) { + if (child->bs == child_bs) { + break; + } + } + + /* we have checked it in bdrv_del_child() */ + assert(i < s->num_children && child); + + if (s->num_children <= s->threshold) { + error_setg(errp, + "The number of children cannot be lower than the vote threshold %d", + s->threshold); + return; + } + + bdrv_drain(bs); + /* We can safely remove this child now */ + memmove(&s->bs[i], &s->bs[i + 1], + (s->num_children - i - 1) * sizeof(void *)); + s->num_children--; + s->bs[s->num_children] = NULL; + bdrv_unref_child(bs, child); +} + static void quorum_refresh_filename(BlockDriverState *bs) { BDRVQuorumState *s = bs->opaque; @@ -1049,6 +1114,9 @@ static BlockDriver bdrv_quorum = { .bdrv_detach_aio_context = quorum_detach_aio_context, .bdrv_attach_aio_context = quorum_attach_aio_context, + .bdrv_add_child = quorum_add_child, + .bdrv_del_child = quorum_del_child, + .is_filter = true, .bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter, }; diff --git a/include/block/block.h b/include/block/block.h index 665c56f..bd97399 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -514,6 +514,9 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs); void bdrv_ref(BlockDriverState *bs); void bdrv_unref(BlockDriverState *bs); void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child); +BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, + BlockDriverState *child_bs, + const BdrvChildRole *child_role); bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp); void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason); -- 2.4.3 From MAILER-DAEMON Fri Sep 18 06:35:14 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zct0c-00084X-9y for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 06:35:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zct0V-00080c-Rr for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:35:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zct0S-00017i-LA for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:35:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59926) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zct0S-000156-GK; Fri, 18 Sep 2015 06:35:04 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id B27162D1258; Fri, 18 Sep 2015 10:35:03 +0000 (UTC) Received: from [10.36.116.139] (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IAZ01R001482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 18 Sep 2015 06:35:02 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: From: Max Reitz Message-ID: <55FBE8D4.10606@redhat.com> Date: Fri, 18 Sep 2015 12:35:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rXDVhilidSxl856RadCwtv5IfuhfuEgFl" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v4 1/4] block: rename BlockdevSnapshot to BlockdevSnapshotSync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 10:35:13 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rXDVhilidSxl856RadCwtv5IfuhfuEgFl Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 14.09.2015 18:01, Alberto Garcia wrote: > We will introduce the 'blockdev-snapshot' command that will require > its own struct for the parameters, so we need to rename this one in > order to avoid name clashes. >=20 > Signed-off-by: Alberto Garcia > Reviewed-by: Eric Blake > --- > blockdev.c | 2 +- > qapi-schema.json | 2 +- > qapi/block-core.json | 8 ++++---- > 3 files changed, 6 insertions(+), 6 deletions(-) Reviewed-by: Max Reitz --rXDVhilidSxl856RadCwtv5IfuhfuEgFl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV++jUAAoJEDuxQgLoOKytdQkH/39BLxjJaAYSXXVHuCqajwmw yOT+4KglKMTZc2tjlbblv3quePHi68c/TrscvRlumNyLa7QkRtN3cqTM2B3h0edd yEaMpOXfBVszRFNz7Jtn8NxXHbDRDPEs8FR5Y6TsPmp52+DjVTsIUv2+t71QAFcz 7Vemz+XbPvaeKJO58IP8u8jiupLnxDLSw+lLHY12j6H3qZ+JC057UZHZB2SWsEmA /F8bNvWevBqPhmv9mBZdROOxUvc5gNmEvUu/ywFcME6Y3mYwG8DuqNsTeE7zpZ6o dH/ojAeuneqLaUEF2SuFP81x/phWaqwITMs7L5dy07Wo5b27KeHOk5ag8TaQKPU= =dZRa -----END PGP SIGNATURE----- --rXDVhilidSxl856RadCwtv5IfuhfuEgFl-- From MAILER-DAEMON Fri Sep 18 06:37:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zct2k-00028q-7v for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 06:37:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zct2h-00026E-Gn for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:37:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zct2g-000302-NS for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:37:23 -0400 Received: from mail-la0-x242.google.com ([2a00:1450:4010:c03::242]:34784) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zct2e-0002xv-JX; Fri, 18 Sep 2015 06:37:20 -0400 Received: by lamp12 with SMTP id p12so2825356lam.1; Fri, 18 Sep 2015 03:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=aOHwQSi7PoFKQGBRyVYK5E2Ui/ZbE6WzK9L8pI3TPiI=; b=s07uKE2kZno93HvhGt5Wq0YCa3y5rp9FcIjPKEs8gqf/I+wj/ghA5S9rg+9fUxfSjB ik4lVCbktW9fILpu+Gq1+1gV+26XsfUVsSAgc/H0VduLhniirFRpSLxduzHwBGUaGJVf XDoaXXDb53HliyH83Nu015TwUFLzoZMgO7xoBUpWeEEBCOy9xMrqP9/IyOuisoO8eHXu afy3/IWCi85QrLgahK6lPuBQtzVaVYg9RWsGKM99GouQCxqBhZnFP3KxSdnn912k7lp2 ji6BDQxwvKDNNrshTrrwq+aYJJdLt6GqftiEs2TTCz9wKL0ETXdGtauM6IekeEmZz9B8 omoA== MIME-Version: 1.0 X-Received: by 10.112.184.196 with SMTP id ew4mr2743916lbc.17.1442572639363; Fri, 18 Sep 2015 03:37:19 -0700 (PDT) Received: by 10.25.16.165 with HTTP; Fri, 18 Sep 2015 03:37:19 -0700 (PDT) In-Reply-To: <20150918094902.GB4320@noname.redhat.com> References: <20150918090203.GA4320@noname.redhat.com> <20150918094902.GB4320@noname.redhat.com> Date: Fri, 18 Sep 2015 19:37:19 +0900 Message-ID: From: Hitoshi Mitake To: Kevin Wolf Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::242 Cc: sheepdog , qemu-block@nongnu.org, libvir-list@redhat.com, qemu-devel , Vasiliy Tolstov , Jason Noble Subject: Re: [Qemu-block] [sheepdog] [Qemu-devel] internal snapshots with sheepdog X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 10:37:24 -0000 On Fri, Sep 18, 2015 at 6:49 PM, Kevin Wolf wrote: > Am 18.09.2015 um 11:03 hat Vasiliy Tolstov geschrieben: >> 2015-09-18 12:02 GMT+03:00 Kevin Wolf : >> > Doesn't sheepdog already support storing snapshots in the same image? >> > I thought it would just work; at least, there's some code there for it. >> >> Yes, qemu and sheepdog have ability to create internal snapshot, i >> miss that, but when i'm try in libvirt create live snapshot - libvirt >> says, that this is not possible with raw image. > > Then I guess your mail should be directed to the libvirt list instead > (CCed). The problem can be seen with libvirt v1.2.12 based on the report from Jason: https://github.com/sheepdog/sheepdog/issues/157 Seems that the commit f7c1410b0ee5b878e81f2eddf86c609947a9b27c of libvirt is causing this problem. Fortunately, Jason is already working on solving this regression. Thanks, Hitoshi > > Kevin > -- > sheepdog mailing list > sheepdog@lists.wpkg.org > https://lists.wpkg.org/mailman/listinfo/sheepdog From MAILER-DAEMON Fri Sep 18 06:45:08 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZctAC-00041V-Ac for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 06:45:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZctA9-0003xy-M5 for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZctA4-0006Eh-JO for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:45:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46210) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZctA4-0006EK-Ep; Fri, 18 Sep 2015 06:45:00 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 411EAA8B; Fri, 18 Sep 2015 10:44:59 +0000 (UTC) Received: from [10.36.116.139] (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IAiuYb031989 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 18 Sep 2015 06:44:57 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <0feb7566cff42d8625ed7263de73fc59225e125f.1442245236.git.berto@igalia.com> From: Max Reitz Message-ID: <55FBEB27.6080702@redhat.com> Date: Fri, 18 Sep 2015 12:44:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <0feb7566cff42d8625ed7263de73fc59225e125f.1442245236.git.berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QQHXaaoemAsVPbS8p3gr6lf1ufUesOstc" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v4 3/4] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 10:45:06 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --QQHXaaoemAsVPbS8p3gr6lf1ufUesOstc Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 14.09.2015 18:01, Alberto Garcia wrote: > One of the limitations of the 'blockdev-snapshot-sync' command is that > it does not allow passing BlockdevOptions to the newly created > snapshots, so they are always opened using the default values. >=20 > Extending the command to allow passing options is not a practical > solution because there is overlap between those options and some of > the existing parameters of the command. >=20 > This patch introduces a new 'blockdev-snapshot' command with a simpler > interface: it just takes two references to existing block devices that > will be used as the source and target for the snapshot. >=20 > Since the main difference between the two commands is that one of them > creates and opens the target image, while the other uses an already > opened one, the bulk of the implementation is shared. >=20 > Signed-off-by: Alberto Garcia > Reviewed-by: Eric Blake > Cc: Max Reitz > --- > blockdev.c | 163 ++++++++++++++++++++++++++++++++-----------= -------- > qapi-schema.json | 2 + > qapi/block-core.json | 28 +++++++++ > qmp-commands.hx | 38 ++++++++++++ > 4 files changed, 171 insertions(+), 60 deletions(-) Reviewed-by: Max Reitz --QQHXaaoemAsVPbS8p3gr6lf1ufUesOstc Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV++snAAoJEDuxQgLoOKytVhQIAJuNf5D3NAiSdSF+9DnyfpUx 09cQKgYg5+x/9yH8KhIFsFxUVmjrDU8a9Sf8LGow8+WYHkOT4+Miyvk1UliduN5C QUumv7ZIfkeatMy7xtNQ9sQamm7MC7kQwN4roU7w/a8Tz0mDX7Nb71pY/OH4uBzi b0/lakpMo2weUo4s6YTPgTDiU2cpmHbVuCgiO3V9Z+uHcQ80AmkXpaOvhWs0KEX4 uoQ7r32i3nTiX38bidgLmbJpsOwKU25CNkFWreq66HyI5tCmUjMvfGsCWvEMFZ+f pjmZo/Nq3OQgWpMNK1M9F8S/38H+zMeaV4kYsMBz8eS1zu3dwVCFqX5LGo7q3g0= =Enop -----END PGP SIGNATURE----- --QQHXaaoemAsVPbS8p3gr6lf1ufUesOstc-- From MAILER-DAEMON Fri Sep 18 06:50:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZctF9-00067s-MV for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 06:50:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZctF3-00064M-5C for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:50:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZctEy-0002v0-2Z for qemu-block@nongnu.org; Fri, 18 Sep 2015 06:50:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZctEx-0002u1-Tq; Fri, 18 Sep 2015 06:50:04 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 26DB7550D7; Fri, 18 Sep 2015 10:50:03 +0000 (UTC) Received: from [10.36.116.139] (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IAnxsX002672 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 18 Sep 2015 06:50:01 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <2a2e8ccd4899f5ca09940792f8469d90f0e762f5.1442245236.git.berto@igalia.com> From: Max Reitz Message-ID: <55FBEC57.7050506@redhat.com> Date: Fri, 18 Sep 2015 12:49:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <2a2e8ccd4899f5ca09940792f8469d90f0e762f5.1442245236.git.berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BW8NeEDC6GCi7I9gnwV5wQxEXqWsPlUtv" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v4 4/4] block: add tests for the 'blockdev-snapshot' command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 10:50:14 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --BW8NeEDC6GCi7I9gnwV5wQxEXqWsPlUtv Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 14.09.2015 18:01, Alberto Garcia wrote: > Signed-off-by: Alberto Garcia > --- > tests/qemu-iotests/085 | 102 +++++++++++++++++++++++++++++++++++++= +++++--- > tests/qemu-iotests/085.out | 34 ++++++++++++++- > 2 files changed, 128 insertions(+), 8 deletions(-) Looks good, but the output diff needs a rebase due to fe646693. Max --BW8NeEDC6GCi7I9gnwV5wQxEXqWsPlUtv Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV++xXAAoJEDuxQgLoOKyt75wH/iLV60P7xXb+gl6/Z66kiZ81 KLEeuvdzzjgx6Kl6qDWlchccTGr9th9MBKn3+MiHav3OIQ8wiDEmpGhLW+p3QXjk MqiZD+8jfVI81VHtk6TTG8Kq4zLUIAtIPh8iYP2Esd2Uqp0DMgKRPtsIgwLfwvDK eUKkmfZCnzkWxQC6NBCZqiH+/WwjSJV9avxm5ToB8HZ2DPh9R66uyCsZfRuZzWpw xFIJkze283u2FdmYyPOVlSMvX9rzcnmYTTYAjltmvkG+xnEeRPal14W21ti2vEQe sqpLNFa0bn0SQ7rXLbEiviRFCY5apooP4TVVTLaJblwvuj40Dk6C3YOJle9D4R4= =AvmZ -----END PGP SIGNATURE----- --BW8NeEDC6GCi7I9gnwV5wQxEXqWsPlUtv-- From MAILER-DAEMON Fri Sep 18 07:03:10 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZctRe-0005hJ-Bz for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 07:03:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZctRc-0005ew-Ef for qemu-block@nongnu.org; Fri, 18 Sep 2015 07:03:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZctRY-0006PP-BI for qemu-block@nongnu.org; Fri, 18 Sep 2015 07:03:08 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:40523 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZctRY-0006PD-51; Fri, 18 Sep 2015 07:03:04 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2D1AgA67vtV/5tjdVtdGQEBAYMHgT2pKgEBAQEBAQUBgQoBkwYBDYdyAoE2OBQBAQEBAQEBgQqEJAEBAwE6PwULCw4TJQ8BLBsGARIbiAsMAcs2AQEBAQEBBAEBAQEBHYYshUSFDQeELAEEjH2IZY5UjS+DZIg5HwEBQoIRHIFWPDOJbQEBAQ X-IPAS-Result: A2D1AgA67vtV/5tjdVtdGQEBAYMHgT2pKgEBAQEBAQUBgQoBkwYBDYdyAoE2OBQBAQEBAQEBgQqEJAEBAwE6PwULCw4TJQ8BLBsGARIbiAsMAcs2AQEBAQEBBAEBAQEBHYYshUSFDQeELAEEjH2IZY5UjS+DZIg5HwEBQoIRHIFWPDOJbQEBAQ X-IronPort-AV: E=Sophos;i="5.17,552,1437429600"; d="scan'208";a="24454748" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 18 Sep 2015 13:03:01 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZctRV-00079F-Gf; Fri, 18 Sep 2015 13:03:01 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZctRV-0005gj-Av; Fri, 18 Sep 2015 13:03:01 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Fri, 18 Sep 2015 13:03:01 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 00/16] block: Get rid of bdrv_swap() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 11:03:09 -0000 On Thu 17 Sep 2015 03:48:04 PM CEST, Kevin Wolf wrote: > bdrv_swap() has always been an ugly hack that we would rather have > avoided. When it was introduced, we simply didn't have the > infrastructure to update pointers instead of transplanting the > contents of BDS object, so we grudgingly added bdrv_swap() as a quick > solution. Meanwhile, most of the infrastructure exists and this > series implements the final step necessary to implement the required > functionality in a less adventurous way. I didn't have the chance to debug this further, but with this series if I make a snapshot of a device with ongoing I/O I get lots of errors in the guest: Buffer I/O error on device vda1, logical block 3801549 end_request: I/O error, dev vda, sector 7604516 [...] The drive is attached with -drive if=virtio,file=foo.qcow2,node-name=bar Berto From MAILER-DAEMON Fri Sep 18 07:46:52 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zcu7w-0002p8-Hq for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 07:46:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcu7t-0002oB-G6 for qemu-block@nongnu.org; Fri, 18 Sep 2015 07:46:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcu7q-0000PN-6R for qemu-block@nongnu.org; Fri, 18 Sep 2015 07:46:49 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:29876 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcu7p-0000Nj-VW; Fri, 18 Sep 2015 07:46:46 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CUBwAO+ftV/5tjdVtdGQEBAYMHqmcBAQEBAQEFAYEKAZMUhRyCVgKBMjkTAQEBAQEBAYEKhCQBAQQnEz8QCw4TJQ8BLBsGAYhEAcs7AQEBAQEBBAEBAQEBHYYshUSFDQeELAEElWKHf5QEjB0jAT+CERyBVjyIWCSBJAEBAQ X-IPAS-Result: A2CUBwAO+ftV/5tjdVtdGQEBAYMHqmcBAQEBAQEFAYEKAZMUhRyCVgKBMjkTAQEBAQEBAYEKhCQBAQQnEz8QCw4TJQ8BLBsGAYhEAcs7AQEBAQEBBAEBAQEBHYYshUSFDQeELAEElWKHf5QEjB0jAT+CERyBVjyIWCSBJAEBAQ X-IronPort-AV: E=Sophos;i="5.17,552,1437429600"; d="scan'208";a="23952332" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 18 Sep 2015 13:45:56 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1Zcu72-0007V9-Bf; Fri, 18 Sep 2015 13:45:56 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1Zcu72-0005Q0-5D; Fri, 18 Sep 2015 13:45:56 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-14-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-14-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Fri, 18 Sep 2015 13:45:56 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 13/16] block: Implement bdrv_append() without bdrv_swap() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 11:46:50 -0000 On Thu 17 Sep 2015 03:48:17 PM CEST, Kevin Wolf wrote: > +static void swap_feature_fields(BlockDriverState *bs_top, > + BlockDriverState *bs_new) > +{ > + BlockDriverState tmp; > + > + bdrv_move_feature_fields(&tmp, bs_top); > + bdrv_move_feature_fields(bs_top, bs_new); > + bdrv_move_feature_fields(bs_new, &tmp); > + > + assert(!bs_new->io_limits_enabled); > + if (bs_top->io_limits_enabled) { > + bdrv_io_limits_enable(bs_new, throttle_group_get_name(bs_top)); > + bdrv_io_limits_disable(bs_top); > + } > +} I would use 'if (bs_top->throttle_state != NULL)' instead. That pointer is set if and only if the BDS has I/O limits set. bs->io_limits_enabled can be set to false in order to bypass the limits temporarily without removing the BDS's throttling settings (e.g in bdrv_read_unthrottled()). I actually think that we can get rid of io_limits_enabled in several places (if not completely), but I will take care of that in a separate patch. The only scenario that could cause problems is if bs->throttle_state is set but bs->io_limits_enabled is false when swap_feature_fields() is called, but I don't think that's possible in this case. Berto From MAILER-DAEMON Fri Sep 18 08:24:33 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcuiP-0005hi-Oc for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 08:24:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcuiL-0005hO-2A for qemu-block@nongnu.org; Fri, 18 Sep 2015 08:24:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcuiH-0006Z2-Sd for qemu-block@nongnu.org; Fri, 18 Sep 2015 08:24:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34953) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcuiH-0006YI-Na; Fri, 18 Sep 2015 08:24:25 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 7843BC0B91B0; Fri, 18 Sep 2015 12:24:24 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-119.ams2.redhat.com [10.36.116.119]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8ICOLwc024342; Fri, 18 Sep 2015 08:24:22 -0400 Date: Fri, 18 Sep 2015 14:24:21 +0200 From: Kevin Wolf To: Alberto Garcia Message-ID: <20150918122421.GE4320@noname.redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-14-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, armbru@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 13/16] block: Implement bdrv_append() without bdrv_swap() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 12:24:33 -0000 Am 18.09.2015 um 13:45 hat Alberto Garcia geschrieben: > On Thu 17 Sep 2015 03:48:17 PM CEST, Kevin Wolf wrote: > > > +static void swap_feature_fields(BlockDriverState *bs_top, > > + BlockDriverState *bs_new) > > +{ > > + BlockDriverState tmp; > > + > > + bdrv_move_feature_fields(&tmp, bs_top); > > + bdrv_move_feature_fields(bs_top, bs_new); > > + bdrv_move_feature_fields(bs_new, &tmp); > > + > > + assert(!bs_new->io_limits_enabled); > > + if (bs_top->io_limits_enabled) { > > + bdrv_io_limits_enable(bs_new, throttle_group_get_name(bs_top)); > > + bdrv_io_limits_disable(bs_top); > > + } > > +} > > I would use 'if (bs_top->throttle_state != NULL)' instead. That pointer > is set if and only if the BDS has I/O limits set. > > bs->io_limits_enabled can be set to false in order to bypass the limits > temporarily without removing the BDS's throttling settings (e.g in > bdrv_read_unthrottled()). > > I actually think that we can get rid of io_limits_enabled in several > places (if not completely), but I will take care of that in a separate > patch. > > The only scenario that could cause problems is if bs->throttle_state is > set but bs->io_limits_enabled is false when swap_feature_fields() is > called, but I don't think that's possible in this case. So something like this? (Specifically, is the assertion right?) assert(!bs_new->throttle_state); if (bs_top->throttle_state) { assert(bs_top->io_limits_enabled); bdrv_io_limits_enable(bs_new, throttle_group_get_name(bs_top)); bdrv_io_limits_disable(bs_top); } If the assertion doesn't hold true, I guess we would need to call throttle_group_register() directly for the cases where io_limits_enabled wasn't true. Kevin From MAILER-DAEMON Fri Sep 18 08:58:42 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcvFS-0003eb-3X for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 08:58:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvFP-0003dZ-K1 for qemu-block@nongnu.org; Fri, 18 Sep 2015 08:58:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcvFL-0003Bx-G0 for qemu-block@nongnu.org; Fri, 18 Sep 2015 08:58:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvFL-0003Bo-9H; Fri, 18 Sep 2015 08:58:35 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 9F69FA8E; Fri, 18 Sep 2015 12:58:34 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8ICwWTi006442 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 08:58:33 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C90F9303F916; Fri, 18 Sep 2015 14:58:31 +0200 (CEST) From: Markus Armbruster To: Jeff Cody References: <45295c490f1d7c2c2209a19fba8c656967d03d5b.1441140367.git.jcody@redhat.com> Date: Fri, 18 Sep 2015 14:58:31 +0200 In-Reply-To: <45295c490f1d7c2c2209a19fba8c656967d03d5b.1441140367.git.jcody@redhat.com> (Jeff Cody's message of "Tue, 1 Sep 2015 18:30:15 -0400") Message-ID: <87twqr3mvc.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, programmingkidx@gmail.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 1/2] util - add automated ID generation utility X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 12:58:40 -0000 Jeff Cody writes: > Multiple sub-systems in QEMU may find it useful to generate IDs > for objects that a user may reference via QMP or HMP. This patch > presents a standardized way to do it, so that automatic ID generation > follows the same rules. > > This patch enforces the following rules when generating an ID: > > 1.) Guarantee no collisions with a user-specified ID > 2.) Identify the sub-system the ID belongs to > 3.) Guarantee of uniqueness > 4.) Spoiling predictability, to avoid creating an assumption > of object ordering and parsing (i.e., we don't want users to think > they can guess the next ID based on prior behavior). > > The scheme for this is as follows (no spaces): > > # subsys D RR > Reserved char --| | | | > Subsystem String ----| | | > Unique number (64-bit) --| | > Two-digit random number ---| > > For example, a generated node-name for the block sub-system may look > like this: > > #block076 > > The caller of id_generate() is responsible for freeing the generated > node name string with g_free(). > > Signed-off-by: Jeff Cody > --- > include/qemu-common.h | 8 ++++++++ > util/id.c | 36 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 44 insertions(+) > > diff --git a/include/qemu-common.h b/include/qemu-common.h > index bbaffd1..f6b0105 100644 > --- a/include/qemu-common.h > +++ b/include/qemu-common.h > @@ -237,6 +237,14 @@ int64_t strtosz_suffix_unit(const char *nptr, char **end, > #define STR_OR_NULL(str) ((str) ? (str) : "null") > > /* id.c */ > + > +typedef enum IdSubSystems { > + ID_QDEV, > + ID_BLOCK, > + ID_MAX /* last element, used as array size */ > +} IdSubSystems; > + > +char *id_generate(IdSubSystems); > bool id_wellformed(const char *id); > > /* path.c */ > diff --git a/util/id.c b/util/id.c > index 09b22fb..9457f2d 100644 > --- a/util/id.c > +++ b/util/id.c > @@ -26,3 +26,39 @@ bool id_wellformed(const char *id) > } > return true; > } > + > +#define ID_SPECIAL_CHAR '#' > + > +static const char * const id_subsys_str[] = { Like Eric, I'd prefer *const. > + [ID_QDEV] = "qdev", > + [ID_BLOCK] = "block", > +}; > + > +/* Generates an ID of the form: Style nit: wing you comments on both ends, please. > + * > + * "#block146", > + * > + * where: > + * - "#" is always the reserved character '#' > + * - "block" refers to the subsystem identifed via IdSubSystems > + * and id_subsys_str[] > + * - "1" is a unique number (up to a uint64_t) for the subsystem > + * - "46" is a zero-padded two digit pseudo-random number Recommend to note that the value does not satisfy id_wellformed(). I'd specify a bit more losely: /* * Generates an ID of the form PREFIX SUBSYSTEM NUMBER * where * - PREFIX is the reserved character '#' * - SUBSYSTEM identifies the subsystem creating the ID * - NUMBER is a decimal number unique within SUBSYSTEM. * Example: "#block146" * * Note that these IDs do not satisfy id_wellformed(). > + * > + * The caller is responsible for freeing the returned string with g_free() > + */ > +char *id_generate(IdSubSystems id) > +{ > + static uint64_t id_counters[ID_MAX]; > + uint32_t rnd; > + > + assert(id < ID_MAX); > + assert(id_subsys_str[id]); > + > + rnd = g_random_int_range(0, 99); 99 is off by one: "Returns a random gint32 equally distributed over the range [begin ..end -1]." > + > + return g_strdup_printf("%c%s%" PRIu64 "%02" PRId32, ID_SPECIAL_CHAR, > + id_subsys_str[id], > + id_counters[id]++, > + rnd); > +} From MAILER-DAEMON Fri Sep 18 09:04:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcvKc-0005XY-FD for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 09:04:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvKZ-0005SK-6g for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:04:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcvKV-00057t-3N for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:03:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvKU-000572-SH; Fri, 18 Sep 2015 09:03:55 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 251478CF73; Fri, 18 Sep 2015 13:03:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8ID3pVS010158 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 09:03:53 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6010C303F916; Fri, 18 Sep 2015 15:03:51 +0200 (CEST) From: Markus Armbruster To: Jeff Cody References: Date: Fri, 18 Sep 2015 15:03:51 +0200 In-Reply-To: (Jeff Cody's message of "Tue, 1 Sep 2015 18:30:16 -0400") Message-ID: <87fv2b3mmg.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, programmingkidx@gmail.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 2/2] block: auto-generated node-names X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 13:04:00 -0000 Jeff Cody writes: > If a node-name is not specified, automatically generate the node-name. > > Generated node-names will use the "block" sub-system identifier. > > Reviewed-by: Eric Blake > Reviewed-by: John Snow > Signed-off-by: Jeff Cody > --- > block.c | 25 ++++++++++++++++--------- > 1 file changed, 16 insertions(+), 9 deletions(-) > > diff --git a/block.c b/block.c > index d088ee0..892e127 100644 > --- a/block.c > +++ b/block.c > @@ -771,32 +771,39 @@ static void bdrv_assign_node_name(BlockDriverState *bs, > const char *node_name, > Error **errp) > { > + char *gen_node_name = NULL; > + > if (!node_name) { > - return; > - } > - > - /* Check for empty string or invalid characters */ > - if (!id_wellformed(node_name)) { > - error_setg(errp, "Invalid node name"); > - return; > + gen_node_name = id_generate(ID_BLOCK); > + node_name = gen_node_name; I'd do node_name = gen_node_name = id_generate(ID_BLOCK); but that's clearly a matter of taste. > + } else { > + /* Check for empty string or invalid characters, but not if it is > + * generated (generated names use characters not available to the user) > + * */ Untidy comment. Make it: /* * Check for empty string or invalid characters, but not if it * is generated (generated names use characters not available to * the user) */ > + if (!id_wellformed(node_name)) { > + error_setg(errp, "Invalid node name"); > + return; > + } > } I'd probably do an else if here. Additional benefit: smaller diff. > > /* takes care of avoiding namespaces collisions */ > if (blk_by_name(node_name)) { > error_setg(errp, "node-name=%s is conflicting with a device id", > node_name); > - return; > + goto out; > } > > /* takes care of avoiding duplicates node names */ > if (bdrv_find_node(node_name)) { > error_setg(errp, "Duplicate node name"); > - return; > + goto out; > } > > /* copy node name into the bs and insert it into the graph list */ > pstrcpy(bs->node_name, sizeof(bs->node_name), node_name); > QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list); > +out: > + g_free(gen_node_name); > } > > static QemuOptsList bdrv_runtime_opts = { From MAILER-DAEMON Fri Sep 18 09:06:33 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcvN3-0008Pp-Mz for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 09:06:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvN1-0008OH-J3 for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:06:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcvMx-0005yO-V2 for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:06:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40495) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvMx-0005yF-Ph; Fri, 18 Sep 2015 09:06:27 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 3A4278E6E0; Fri, 18 Sep 2015 13:06:27 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8ID6Ppb015678 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 09:06:26 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2F2C4303F916; Fri, 18 Sep 2015 15:06:25 +0200 (CEST) From: Markus Armbruster To: Jeff Cody References: Date: Fri, 18 Sep 2015 15:06:25 +0200 In-Reply-To: (Jeff Cody's message of "Tue, 1 Sep 2015 18:30:14 -0400") Message-ID: <87bncz3mi6.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, programmingkidx@gmail.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 0/2] Auto-generated IDs X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 13:06:32 -0000 Jeff Cody writes: > Changes from RFC v1: > > Patch 1: Several typos / grammatical errors (thanks Eric, John) > Make id_subsys_str[] const pointer to const strings (thanks Eric) > Moved id_subsys_str[] out from id_generate() (thanks John) > Assert on null string for given id (thanks Eric) > Zero-pad the 2-digit random # (thanks John) > > Patch 2: None > > Born from the conversation on qemu-devel, this generation scheme uses the > format ultimately proposed by Kevin, after list discussion. > > It attempts to keep the ID strings as small as possible, while fulfilling: > > 1.) Guarantee no collisions with a user-specified ID > 2.) Identify the sub-system the ID belongs to > 3.) Guarantee of uniqueness > 4.) Spoiling predictibility, to avoid creating an assumption > of object ordering and parsing (i.e., we don't want users to think > they can guess the next ID based on prior behavior). > > See patch 1 for the generation scheme details. Since PATCH 1 defines an ID for the qdev subsystem, I expected a patch to put it to use. As long as there is none, PATCH 1 shouldn't define ID_QDEV. Looks good apart from a harmless off-by-one and a few style nits. From MAILER-DAEMON Fri Sep 18 09:16:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcvWq-00043l-Su for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 09:16:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvWn-0003zb-Tz for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:16:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcvWm-0005MZ-RY for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:16:37 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:55144 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvWh-0005CU-Eu; Fri, 18 Sep 2015 09:16:31 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2C1BwAXDvxV/5tjdVtdGQEBgwhUaaklBQEBAQEBAQUBgQoBkxSBUB8KhXmBNDkTAQEBAQEBAYEKhCYBBAIkUk86FIhmAQjLcQSGLIpRHoQVBYc0hUlxh3SFEYUTgmOBTZETiDkjAT+BSgGCOW4BiWwBAQE X-IPAS-Result: A2C1BwAXDvxV/5tjdVtdGQEBgwhUaaklBQEBAQEBAQUBgQoBkxSBUB8KhXmBNDkTAQEBAQEBAYEKhCYBBAIkUk86FIhmAQjLcQSGLIpRHoQVBYc0hUlxh3SFEYUTgmOBTZETiDkjAT+BSgGCOW4BiWwBAQE X-IronPort-AV: E=Sophos;i="5.17,552,1437429600"; d="scan'208";a="24536868" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 18 Sep 2015 15:16:23 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZcvWZ-0008R8-BM; Fri, 18 Sep 2015 15:16:23 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZcvWL-0002r4-0g; Fri, 18 Sep 2015 16:16:09 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 18 Sep 2015 16:16:01 +0300 Message-Id: X-Mailer: git-send-email 2.5.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 0/4] Add 'blockdev-snapshot' command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 13:16:39 -0000 This fixes the problem detect by Fam: the previous series was deleting the 'backing' option for 'blockdev-add' even if it contained a non-empty string. The code is also rebased on top of the current master. In particular the test output had to be adapted because of fe646693. Again, this depends on Max's BlockBackend and media series: https://lists.gnu.org/archive/html/qemu-block/2015-07/msg00382.html Berto v5: - Don't delete the 'backing' option if it contains something different from an empty string. - Rebase on top of the current master. v4: https://lists.gnu.org/archive/html/qemu-block/2015-09/msg00372.html - Implement the support for 'backing': '', drop 'ignore-backing', and update iotest 085 accordingly. - Include sample 'blockdev-add' call in the 'blockdev-snapshot' documentation. - Clarify that the snapshot must not have a backing file in the BlockdevSnapshot documentation. - Update error message ("...node name already existing" -> "...exists"). v3: https://lists.gnu.org/archive/html/qemu-block/2015-09/msg00272.html - Add 'ignore-backing' field to BlockdevOptionsGenericCOWFormat. This allows opening images but not their backing images. - Check for op blockers in the snapshot node and make sure that it doesn't have any backing image. - Remove extra check for the existence of the snapshot node: bdrv_open() already does that. - Extend iotest 085 to add tests for 'blockdev-snapshot'. - Replace local_err with errp in some places where the former is unnecessary. - Update command description. - Add 'since' tag to the 'blockdev-snapshot' field in TransactionAction. v2: https://lists.gnu.org/archive/html/qemu-block/2015-09/msg00094.html - Add 'blockdev-snapshot' command instead of allowing passing options to 'blockdev-snapshot-sync'. - Rename BlockdevSnapshot to BlockdevSnapshotSync v1: https://lists.gnu.org/archive/html/qemu-block/2015-08/msg00236.html Alberto Garcia (4): block: rename BlockdevSnapshot to BlockdevSnapshotSync block: support passing 'backing': '' to 'blockdev-add' block: add a 'blockdev-snapshot' QMP command block: add tests for the 'blockdev-snapshot' command block.c | 7 ++ blockdev.c | 165 ++++++++++++++++++++++++++++----------------- qapi-schema.json | 4 +- qapi/block-core.json | 34 +++++++++- qmp-commands.hx | 38 +++++++++++ tests/qemu-iotests/085 | 102 ++++++++++++++++++++++++++-- tests/qemu-iotests/085.out | 34 +++++++++- 7 files changed, 311 insertions(+), 73 deletions(-) -- 2.5.1 From MAILER-DAEMON Fri Sep 18 09:16:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcvWt-00047S-0P for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 09:16:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvWo-0003zx-5j for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:16:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcvWm-0005M7-Cf for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:16:38 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:55155 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvWh-0005Fn-QV; Fri, 18 Sep 2015 09:16:32 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2C4BAAXDvxV/5tjdVtdGQEBAYMHgT2BTKdeAQEBAQEBBQGBCgGTBgENh3ICgTI4FAEBAQEBAQGBCoQkAQEEJ1IQPxI8GxkbiBcBy1EshiyJZWwHhCwFhzSFSXGHdI0HmxkfAQFCgUpHHIFXboltAQEB X-IPAS-Result: A2C4BAAXDvxV/5tjdVtdGQEBAYMHgT2BTKdeAQEBAQEBBQGBCgGTBgENh3ICgTI4FAEBAQEBAQGBCoQkAQEEJ1IQPxI8GxkbiBcBy1EshiyJZWwHhCwFhzSFSXGHdI0HmxkfAQFCgUpHHIFXboltAQEB X-IronPort-AV: E=Sophos;i="5.17,552,1437429600"; d="scan'208";a="24536871" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 18 Sep 2015 15:16:24 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZcvWZ-0008RB-AF; Fri, 18 Sep 2015 15:16:23 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZcvWL-0002rF-5h; Fri, 18 Sep 2015 16:16:09 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 18 Sep 2015 16:16:04 +0300 Message-Id: X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 3/4] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 13:16:41 -0000 One of the limitations of the 'blockdev-snapshot-sync' command is that it does not allow passing BlockdevOptions to the newly created snapshots, so they are always opened using the default values. Extending the command to allow passing options is not a practical solution because there is overlap between those options and some of the existing parameters of the command. This patch introduces a new 'blockdev-snapshot' command with a simpler interface: it just takes two references to existing block devices that will be used as the source and target for the snapshot. Since the main difference between the two commands is that one of them creates and opens the target image, while the other uses an already opened one, the bulk of the implementation is shared. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- blockdev.c | 163 ++++++++++++++++++++++++++++++++------------------- qapi-schema.json | 2 + qapi/block-core.json | 28 +++++++++ qmp-commands.hx | 38 ++++++++++++ 4 files changed, 171 insertions(+), 60 deletions(-) diff --git a/blockdev.c b/blockdev.c index 6b787c1..18fdb5c 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1183,6 +1183,18 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, &snapshot, errp); } +void qmp_blockdev_snapshot(const char *device, const char *snapshot, + Error **errp) +{ + BlockdevSnapshot snapshot_data = { + .device = (char *) device, + .snapshot = (char *) snapshot + }; + + blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT, + &snapshot_data, errp); +} + void qmp_blockdev_snapshot_internal_sync(const char *device, const char *name, Error **errp) @@ -1521,57 +1533,48 @@ typedef struct ExternalSnapshotState { static void external_snapshot_prepare(BlkTransactionState *common, Error **errp) { - int flags, ret; - QDict *options; + int flags = 0, ret; + QDict *options = NULL; Error *local_err = NULL; - bool has_device = false; + /* Device and node name of the image to generate the snapshot from */ const char *device; - bool has_node_name = false; const char *node_name; - bool has_snapshot_node_name = false; - const char *snapshot_node_name; + /* Reference to the new image (for 'blockdev-snapshot') */ + const char *snapshot_ref; + /* File name of the new image (for 'blockdev-snapshot-sync') */ const char *new_image_file; - const char *format = "qcow2"; - enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; ExternalSnapshotState *state = DO_UPCAST(ExternalSnapshotState, common, common); TransactionAction *action = common->action; - /* get parameters */ - g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC); - - has_device = action->blockdev_snapshot_sync->has_device; - device = action->blockdev_snapshot_sync->device; - has_node_name = action->blockdev_snapshot_sync->has_node_name; - node_name = action->blockdev_snapshot_sync->node_name; - has_snapshot_node_name = - action->blockdev_snapshot_sync->has_snapshot_node_name; - snapshot_node_name = action->blockdev_snapshot_sync->snapshot_node_name; - - new_image_file = action->blockdev_snapshot_sync->snapshot_file; - if (action->blockdev_snapshot_sync->has_format) { - format = action->blockdev_snapshot_sync->format; - } - if (action->blockdev_snapshot_sync->has_mode) { - mode = action->blockdev_snapshot_sync->mode; + /* 'blockdev-snapshot' and 'blockdev-snapshot-sync' have similar + * purpose but a different set of parameters */ + switch (action->kind) { + case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT: + { + BlockdevSnapshot *s = action->blockdev_snapshot; + device = s->device; + node_name = s->device; + new_image_file = NULL; + snapshot_ref = s->snapshot; + } + break; + case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC: + { + BlockdevSnapshotSync *s = action->blockdev_snapshot_sync; + device = s->has_device ? s->device : NULL; + node_name = s->has_node_name ? s->node_name : NULL; + new_image_file = s->snapshot_file; + snapshot_ref = NULL; + } + break; + default: + g_assert_not_reached(); } /* start processing */ - state->old_bs = bdrv_lookup_bs(has_device ? device : NULL, - has_node_name ? node_name : NULL, - &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - - if (has_node_name && !has_snapshot_node_name) { - error_setg(errp, "New snapshot node name missing"); - return; - } - - if (has_snapshot_node_name && bdrv_find_node(snapshot_node_name)) { - error_setg(errp, "New snapshot node name already existing"); + state->old_bs = bdrv_lookup_bs(device, node_name, errp); + if (!state->old_bs) { return; } @@ -1601,35 +1604,69 @@ static void external_snapshot_prepare(BlkTransactionState *common, return; } - flags = state->old_bs->open_flags; + if (action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC) { + BlockdevSnapshotSync *s = action->blockdev_snapshot_sync; + const char *format = s->has_format ? s->format : "qcow2"; + enum NewImageMode mode; + const char *snapshot_node_name = + s->has_snapshot_node_name ? s->snapshot_node_name : NULL; - /* create new image w/backing file */ - if (mode != NEW_IMAGE_MODE_EXISTING) { - bdrv_img_create(new_image_file, format, - state->old_bs->filename, - state->old_bs->drv->format_name, - NULL, -1, flags, &local_err, false); - if (local_err) { - error_propagate(errp, local_err); + if (node_name && !snapshot_node_name) { + error_setg(errp, "New snapshot node name missing"); return; } - } - options = qdict_new(); - if (has_snapshot_node_name) { - qdict_put(options, "node-name", - qstring_from_str(snapshot_node_name)); + if (snapshot_node_name && bdrv_find_node(snapshot_node_name)) { + error_setg(errp, "New snapshot node name already exists"); + return; + } + + flags = state->old_bs->open_flags; + + /* create new image w/backing file */ + mode = s->has_mode ? s->mode : NEW_IMAGE_MODE_ABSOLUTE_PATHS; + if (mode != NEW_IMAGE_MODE_EXISTING) { + bdrv_img_create(new_image_file, format, + state->old_bs->filename, + state->old_bs->drv->format_name, + NULL, -1, flags, &local_err, false); + if (local_err) { + error_propagate(errp, local_err); + return; + } + } + + options = qdict_new(); + if (s->has_snapshot_node_name) { + qdict_put(options, "node-name", + qstring_from_str(snapshot_node_name)); + } + qdict_put(options, "driver", qstring_from_str(format)); + + flags |= BDRV_O_NO_BACKING; } - qdict_put(options, "driver", qstring_from_str(format)); - /* TODO Inherit bs->options or only take explicit options with an - * extended QMP command? */ assert(state->new_bs == NULL); - ret = bdrv_open(&state->new_bs, new_image_file, NULL, options, - flags | BDRV_O_NO_BACKING, &local_err); + ret = bdrv_open(&state->new_bs, new_image_file, snapshot_ref, options, + flags, errp); /* We will manually add the backing_hd field to the bs later */ if (ret != 0) { - error_propagate(errp, local_err); + return; + } + + if (state->new_bs->blk != NULL) { + error_setg(errp, "The snapshot is already in use by %s", + blk_name(state->new_bs->blk)); + return; + } + + if (bdrv_op_is_blocked(state->new_bs, BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT, + errp)) { + return; + } + + if (state->new_bs->backing_hd != NULL) { + error_setg(errp, "The snapshot already has a backing image"); } } @@ -1818,6 +1855,12 @@ static void abort_commit(BlkTransactionState *common) } static const BdrvActionOps actions[] = { + [TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT] = { + .instance_size = sizeof(ExternalSnapshotState), + .prepare = external_snapshot_prepare, + .commit = external_snapshot_commit, + .abort = external_snapshot_abort, + }, [TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC] = { .instance_size = sizeof(ExternalSnapshotState), .prepare = external_snapshot_prepare, diff --git a/qapi-schema.json b/qapi-schema.json index 45a85db..296da01 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1496,9 +1496,11 @@ # abort since 1.6 # blockdev-snapshot-internal-sync since 1.7 # blockdev-backup since 2.3 +# blockdev-snapshot since 2.5 ## { 'union': 'TransactionAction', 'data': { + 'blockdev-snapshot': 'BlockdevSnapshot', 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', 'drive-backup': 'DriveBackup', 'blockdev-backup': 'BlockdevBackup', diff --git a/qapi/block-core.json b/qapi/block-core.json index ff00e0b..0e6bd05 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -705,6 +705,21 @@ '*format': 'str', '*mode': 'NewImageMode' } } ## +# @BlockdevSnapshot +# +# @device: device or node name to generate the snapshot from. +# +# @snapshot: reference to the existing block device that will be used +# for the snapshot. It must not have a current backing file +# (this can be achieved by passing "backing": "" to +# blockdev-add). +# +# Since 2.5 +## +{ 'struct': 'BlockdevSnapshot', + 'data': { 'device': 'str', 'snapshot': 'str' } } + +## # @DriveBackup # # @device: the name of the device which should be copied. @@ -800,6 +815,19 @@ { 'command': 'blockdev-snapshot-sync', 'data': 'BlockdevSnapshotSync' } + +## +# @blockdev-snapshot +# +# Generates a snapshot of a block device. +# +# For the arguments, see the documentation of BlockdevSnapshot. +# +# Since 2.5 +## +{ 'command': 'blockdev-snapshot', + 'data': 'BlockdevSnapshot' } + ## # @change-backing-file # diff --git a/qmp-commands.hx b/qmp-commands.hx index 495670b..516f935 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1454,6 +1454,44 @@ Example: EQMP { + .name = "blockdev-snapshot", + .args_type = "device:s,snapshot:s", + .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot, + }, + +SQMP +blockdev-snapshot +----------------- +Since 2.5 + +Create a snapshot, by installing 'device' as the backing image of +'snapshot'. Additionally, if 'device' is associated with a block +device, the block device changes to using 'snapshot' as its new active +image. + +Arguments: + +- "device": snapshot source (json-string) +- "snapshot": snapshot target (json-string) + +Example: + +-> { "execute": "blockdev-add", + "arguments": { "options": { "driver": "qcow2", + "node-name": "node1534", + "file": { "driver": "file", + "filename": "hd1.qcow2" }, + "backing": "" } } } + +<- { "return": {} } + +-> { "execute": "blockdev-snapshot", "arguments": { "device": "ide-hd0", + "snapshot": "node1534" } } +<- { "return": {} } + +EQMP + + { .name = "blockdev-snapshot-internal-sync", .args_type = "device:B,name:s", .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot_internal_sync, -- 2.5.1 From MAILER-DAEMON Fri Sep 18 09:16:44 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcvWt-00048F-SX for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 09:16:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvWp-00042u-LU for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:16:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcvWl-0005KN-E0 for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:16:39 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:55155 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvWi-0005Fn-Pp; Fri, 18 Sep 2015 09:16:32 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2C3BAAXDvxV/5tjdVtdGQEBAYMHgT2BTKdeAQEBAQEBBQGBCgGTBgENh3ICgTI4FAEBAQEBAQGBCoQkAQEEeRA/EjwbGYgyActRASuCT4NdiWVsBxeEFQWMfXGHdId/hQibGR8BAUKBSkccgVduiW0BAQE X-IPAS-Result: A2C3BAAXDvxV/5tjdVtdGQEBAYMHgT2BTKdeAQEBAQEBBQGBCgGTBgENh3ICgTI4FAEBAQEBAQGBCoQkAQEEeRA/EjwbGYgyActRASuCT4NdiWVsBxeEFQWMfXGHdId/hQibGR8BAUKBSkccgVduiW0BAQE X-IronPort-AV: E=Sophos;i="5.17,552,1437429600"; d="scan'208";a="24536872" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 18 Sep 2015 15:16:24 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZcvWZ-0008R9-EW; Fri, 18 Sep 2015 15:16:23 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZcvWL-0002r7-2S; Fri, 18 Sep 2015 16:16:09 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 18 Sep 2015 16:16:02 +0300 Message-Id: <7d2d8109f1cd23696e84d24c1d0e1afdc4c968b1.1442581571.git.berto@igalia.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 1/4] block: rename BlockdevSnapshot to BlockdevSnapshotSync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 13:16:41 -0000 We will introduce the 'blockdev-snapshot' command that will require its own struct for the parameters, so we need to rename this one in order to avoid name clashes. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- blockdev.c | 2 +- qapi-schema.json | 2 +- qapi/block-core.json | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/blockdev.c b/blockdev.c index 3f42863..6b787c1 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1166,7 +1166,7 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, bool has_format, const char *format, bool has_mode, NewImageMode mode, Error **errp) { - BlockdevSnapshot snapshot = { + BlockdevSnapshotSync snapshot = { .has_device = has_device, .device = (char *) device, .has_node_name = has_node_name, diff --git a/qapi-schema.json b/qapi-schema.json index 0d5190b..45a85db 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1499,7 +1499,7 @@ ## { 'union': 'TransactionAction', 'data': { - 'blockdev-snapshot-sync': 'BlockdevSnapshot', + 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', 'drive-backup': 'DriveBackup', 'blockdev-backup': 'BlockdevBackup', 'abort': 'Abort', diff --git a/qapi/block-core.json b/qapi/block-core.json index 11134a8..ff00e0b 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -682,7 +682,7 @@ 'data': [ 'existing', 'absolute-paths' ] } ## -# @BlockdevSnapshot +# @BlockdevSnapshotSync # # Either @device or @node-name must be set but not both. # @@ -699,7 +699,7 @@ # @mode: #optional whether and how QEMU should create a new image, default is # 'absolute-paths'. ## -{ 'struct': 'BlockdevSnapshot', +{ 'struct': 'BlockdevSnapshotSync', 'data': { '*device': 'str', '*node-name': 'str', 'snapshot-file': 'str', '*snapshot-node-name': 'str', '*format': 'str', '*mode': 'NewImageMode' } } @@ -790,7 +790,7 @@ # # Generates a synchronous snapshot of a block device. # -# For the arguments, see the documentation of BlockdevSnapshot. +# For the arguments, see the documentation of BlockdevSnapshotSync. # # Returns: nothing on success # If @device is not a valid block device, DeviceNotFound @@ -798,7 +798,7 @@ # Since 0.14.0 ## { 'command': 'blockdev-snapshot-sync', - 'data': 'BlockdevSnapshot' } + 'data': 'BlockdevSnapshotSync' } ## # @change-backing-file -- 2.5.1 From MAILER-DAEMON Fri Sep 18 09:16:46 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcvWw-0004C6-3r for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 09:16:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvWp-00042r-K5 for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:16:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcvWl-0005KU-FE for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:16:39 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:55144 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvWg-0005CU-Jv; Fri, 18 Sep 2015 09:16:30 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2D0AgAXDvxV/5tjdVtdGQEBAYMHgT2pKgEBAQEBAQUBgQoBkwYBDYdyAoEyOBQBAQEBAQEBgQqEJAEBBCdSED8SPBsZiDIBy1EBK4YsilEHF4QVBY1uh3SNB5sZHwEBQoFKgjpuiW0BAQE X-IPAS-Result: A2D0AgAXDvxV/5tjdVtdGQEBAYMHgT2pKgEBAQEBAQUBgQoBkwYBDYdyAoEyOBQBAQEBAQEBgQqEJAEBBCdSED8SPBsZiDIBy1EBK4YsilEHF4QVBY1uh3SNB5sZHwEBQoFKgjpuiW0BAQE X-IronPort-AV: E=Sophos;i="5.17,552,1437429600"; d="scan'208";a="24536862" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 18 Sep 2015 15:16:23 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZcvWZ-0008RC-3e; Fri, 18 Sep 2015 15:16:23 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZcvWL-0002rB-3p; Fri, 18 Sep 2015 16:16:09 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 18 Sep 2015 16:16:03 +0300 Message-Id: <40dd21e6f39ce3c6412b6d568a85c3f226fa3bd2.1442581571.git.berto@igalia.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 2/4] block: support passing 'backing': '' to 'blockdev-add' X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 13:16:45 -0000 Passing an empty string allows opening an image but not its backing file. This was already described in the API documentation, only the implementation was missing. This is useful for creating snapshots using images opened with blockdev-add, since they are not supposed to have a backing image before the operation. Signed-off-by: Alberto Garcia --- block.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block.c b/block.c index e8fccfe..cb147b0 100644 --- a/block.c +++ b/block.c @@ -1402,6 +1402,7 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, BlockDriverState *file = NULL, *bs; BlockDriver *drv = NULL; const char *drvname; + const char *backing; Error *local_err = NULL; int snapshot_flags = 0; @@ -1469,6 +1470,12 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, assert(drvname || !(flags & BDRV_O_PROTOCOL)); + backing = qdict_get_try_str(options, "backing"); + if (backing && *backing == '\0') { + flags |= BDRV_O_NO_BACKING; + qdict_del(options, "backing"); + } + bs->open_flags = flags; bs->options = options; options = qdict_clone_shallow(options); -- 2.5.1 From MAILER-DAEMON Fri Sep 18 09:16:50 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcvX0-0004Ii-7P for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 09:16:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvWu-00048s-8W for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:16:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcvWq-0005RY-Vv for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:16:44 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:55144 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvWi-0005CU-25; Fri, 18 Sep 2015 09:16:32 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AlAwAXDvxV/5tjdVtdGQEBAYMHgT2pKgEBAQEBAQUBgQoBkwYBDYQ8gzYCgTI4FAEBAQEBAQGBCoQkAQEEeRA/EjwbGYgyActRLIYsilEHhCwFjH1xh3SNB5sZHwEBQoFKgjpuiW0BAQE X-IPAS-Result: A2AlAwAXDvxV/5tjdVtdGQEBAYMHgT2pKgEBAQEBAQUBgQoBkwYBDYQ8gzYCgTI4FAEBAQEBAQGBCoQkAQEEeRA/EjwbGYgyActRLIYsilEHhCwFjH1xh3SNB5sZHwEBQoFKgjpuiW0BAQE X-IronPort-AV: E=Sophos;i="5.17,552,1437429600"; d="scan'208";a="24536870" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 18 Sep 2015 15:16:24 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZcvWZ-0008RA-AC; Fri, 18 Sep 2015 15:16:23 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZcvWL-0002rJ-6p; Fri, 18 Sep 2015 16:16:09 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 18 Sep 2015 16:16:05 +0300 Message-Id: X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 4/4] block: add tests for the 'blockdev-snapshot' command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 13:16:49 -0000 Signed-off-by: Alberto Garcia --- tests/qemu-iotests/085 | 102 ++++++++++++++++++++++++++++++++++++++++++--- tests/qemu-iotests/085.out | 34 ++++++++++++++- 2 files changed, 128 insertions(+), 8 deletions(-) diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085 index 56cd6f8..532eb0e 100755 --- a/tests/qemu-iotests/085 +++ b/tests/qemu-iotests/085 @@ -7,6 +7,7 @@ # snapshots are performed. # # Copyright (C) 2014 Red Hat, Inc. +# Copyright (C) 2015 Igalia, S.L. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,17 +35,17 @@ status=1 # failure is the default! snapshot_virt0="snapshot-v0.qcow2" snapshot_virt1="snapshot-v1.qcow2" -MAX_SNAPSHOTS=10 +SNAPSHOTS=10 _cleanup() { _cleanup_qemu - for i in $(seq 1 ${MAX_SNAPSHOTS}) + for i in $(seq 1 ${SNAPSHOTS}) do rm -f "${TEST_DIR}/${i}-${snapshot_virt0}" rm -f "${TEST_DIR}/${i}-${snapshot_virt1}" done - _cleanup_test_img + rm -f "${TEST_IMG}.1" "${TEST_IMG}.2" } trap "_cleanup; exit \$status" 0 1 2 3 15 @@ -85,18 +86,50 @@ function create_group_snapshot() _send_qemu_cmd $h "${cmd}" "return" } +# ${1}: unique identifier for the snapshot filename +# ${2}: true: open backing images; false: don't open them (default) +function add_snapshot_image() +{ + if [ "${2}" = "true" ]; then + extra_params="" + else + extra_params="'backing': '', " + fi + base_image="${TEST_DIR}/$((${1}-1))-${snapshot_virt0}" + snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}" + _make_test_img -b "${base_image}" "$size" + mv "${TEST_IMG}" "${snapshot_file}" + cmd="{ 'execute': 'blockdev-add', 'arguments': + { 'options': + { 'driver': 'qcow2', 'node-name': 'snap_"${1}"', "${extra_params}" + 'file': + { 'driver': 'file', 'filename': '"${snapshot_file}"' } } } }" + _send_qemu_cmd $h "${cmd}" "return" +} + +# ${1}: unique identifier for the snapshot filename +# ${2}: expected response, defaults to 'return' +function blockdev_snapshot() +{ + cmd="{ 'execute': 'blockdev-snapshot', + 'arguments': { 'device': 'virtio0', + 'snapshot':'snap_"${1}"' } }" + _send_qemu_cmd $h "${cmd}" "${2:-return}" +} + size=128M _make_test_img $size -mv "${TEST_IMG}" "${TEST_IMG}.orig" +mv "${TEST_IMG}" "${TEST_IMG}.1" _make_test_img $size +mv "${TEST_IMG}" "${TEST_IMG}.2" echo echo === Running QEMU === echo qemu_comm_method="qmp" -_launch_qemu -drive file="${TEST_IMG}.orig",if=virtio -drive file="${TEST_IMG}",if=virtio +_launch_qemu -drive file="${TEST_IMG}.1",if=virtio -drive file="${TEST_IMG}.2",if=virtio h=$QEMU_HANDLE echo @@ -105,6 +138,8 @@ echo _send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return" +# Tests for the blockdev-snapshot-sync command + echo echo === Create a single snapshot on virtio0 === echo @@ -132,11 +167,66 @@ echo echo === Create several transactional group snapshots === echo -for i in $(seq 2 ${MAX_SNAPSHOTS}) +for i in $(seq 2 ${SNAPSHOTS}) do create_group_snapshot ${i} done +# Tests for the blockdev-snapshot command + +echo +echo === Create a couple of snapshots using blockdev-snapshot === +echo + +SNAPSHOTS=$((${SNAPSHOTS}+1)) +add_snapshot_image ${SNAPSHOTS} +blockdev_snapshot ${SNAPSHOTS} + +SNAPSHOTS=$((${SNAPSHOTS}+1)) +add_snapshot_image ${SNAPSHOTS} +blockdev_snapshot ${SNAPSHOTS} + +echo +echo === Invalid command - snapshot node used as active layer === +echo + +blockdev_snapshot ${SNAPSHOTS} error + +_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot', + 'arguments': { 'device':'virtio0', + 'snapshot':'virtio0' } + }" "error" + +_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot', + 'arguments': { 'device':'virtio0', + 'snapshot':'virtio1' } + }" "error" + +echo +echo === Invalid command - snapshot node used as backing hd === +echo + +blockdev_snapshot $((${SNAPSHOTS}-1)) error + +echo +echo === Invalid command - snapshot node has a backing image === +echo + +SNAPSHOTS=$((${SNAPSHOTS}+1)) +add_snapshot_image ${SNAPSHOTS} true +blockdev_snapshot ${SNAPSHOTS} error + +echo +echo === Invalid command - The node does not exist === +echo + +blockdev_snapshot $((${SNAPSHOTS}+1)) error + +_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot', + 'arguments': { 'device':'nodevice', + 'snapshot':'snap_"${SNAPSHOTS}"' } + }" "error" + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out index a6cf19e..52292ea 100644 --- a/tests/qemu-iotests/085.out +++ b/tests/qemu-iotests/085.out @@ -11,7 +11,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 === Create a single snapshot on virtio0 === -Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2.orig backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 +Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2.1 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 {"return": {}} === Invalid command - missing device and nodename === @@ -26,7 +26,7 @@ Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file === Create several transactional group snapshots === Formatting 'TEST_DIR/2-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/1-snapshot-v0.qcow2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 -Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 +Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2.2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 {"return": {}} Formatting 'TEST_DIR/3-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/2-snapshot-v0.qcow2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/3-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/2-snapshot-v1.qcow2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 @@ -52,4 +52,34 @@ Formatting 'TEST_DIR/9-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file Formatting 'TEST_DIR/10-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/9-snapshot-v0.qcow2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/9-snapshot-v1.qcow2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 {"return": {}} + +=== Create a couple of snapshots using blockdev-snapshot === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/10-snapshot-v0.IMGFMT +{"return": {}} +{"return": {}} +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/11-snapshot-v0.IMGFMT +{"return": {}} +{"return": {}} + +=== Invalid command - snapshot node used as active layer === + +{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio0"}} +{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio0"}} +{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio1"}} + +=== Invalid command - snapshot node used as backing hd === + +{"error": {"class": "GenericError", "desc": "Node 'snap_11' is busy: node is used as backing hd of 'virtio0'"}} + +=== Invalid command - snapshot node has a backing image === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/12-snapshot-v0.IMGFMT +{"return": {}} +{"error": {"class": "GenericError", "desc": "The snapshot already has a backing image"}} + +=== Invalid command - The node does not exist === + +{"error": {"class": "GenericError", "desc": "Cannot find device=snap_14 nor node_name=snap_14"}} +{"error": {"class": "GenericError", "desc": "Cannot find device=nodevice nor node_name=nodevice"}} *** done -- 2.5.1 From MAILER-DAEMON Fri Sep 18 09:31:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcvlD-0003Mk-Ed for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 09:31:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcvl7-0003M4-9i for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:31:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcvl1-0000rU-F1 for qemu-block@nongnu.org; Fri, 18 Sep 2015 09:31:25 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:15027 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcvl1-0000qV-7m; Fri, 18 Sep 2015 09:31:19 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CUBwBtEfxV/5tjdVtdGQEBAYMHqmcBAQEBAQEFAYEKAZMUhRyCVgKBMjkTAQEBAQEBAYEKhCQBAQMBJxM/BQsLDhMlDwEsGwaIOQwBy04BAQEBAQUBAQEBHoYshUSFDQeELAEElWKHf5QEjB0jAT+CERyBVjyIWCSBJAEBAQ X-IPAS-Result: A2CUBwBtEfxV/5tjdVtdGQEBAYMHqmcBAQEBAQEFAYEKAZMUhRyCVgKBMjkTAQEBAQEBAYEKhCQBAQMBJxM/BQsLDhMlDwEsGwaIOQwBy04BAQEBAQUBAQEBHoYshUSFDQeELAEElWKHf5QEjB0jAT+CERyBVjyIWCSBJAEBAQ X-IronPort-AV: E=Sophos;i="5.17,553,1437429600"; d="scan'208";a="24543689" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 18 Sep 2015 15:31:13 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1Zcvkv-00005r-Ak; Fri, 18 Sep 2015 15:31:13 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1Zcvkv-0000Fp-4c; Fri, 18 Sep 2015 15:31:13 +0200 From: Alberto Garcia To: Kevin Wolf In-Reply-To: <20150918122421.GE4320@noname.redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-14-git-send-email-kwolf@redhat.com> <20150918122421.GE4320@noname.redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Fri, 18 Sep 2015 15:31:13 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: qemu-block@nongnu.org, armbru@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 13/16] block: Implement bdrv_append() without bdrv_swap() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 13:31:30 -0000 On Fri 18 Sep 2015 02:24:21 PM CEST, Kevin Wolf wrote: >> > +static void swap_feature_fields(BlockDriverState *bs_top, >> > + BlockDriverState *bs_new) >> > +{ >> > + BlockDriverState tmp; >> > + >> > + bdrv_move_feature_fields(&tmp, bs_top); >> > + bdrv_move_feature_fields(bs_top, bs_new); >> > + bdrv_move_feature_fields(bs_new, &tmp); >> > + >> > + assert(!bs_new->io_limits_enabled); >> > + if (bs_top->io_limits_enabled) { >> > + bdrv_io_limits_enable(bs_new, throttle_group_get_name(bs_top)); >> > + bdrv_io_limits_disable(bs_top); >> > + } >> > +} >> >> I would use 'if (bs_top->throttle_state != NULL)' instead. That pointer >> is set if and only if the BDS has I/O limits set. >> >> bs->io_limits_enabled can be set to false in order to bypass the limits >> temporarily without removing the BDS's throttling settings (e.g in >> bdrv_read_unthrottled()). >> >> I actually think that we can get rid of io_limits_enabled in several >> places (if not completely), but I will take care of that in a separate >> patch. >> >> The only scenario that could cause problems is if bs->throttle_state is >> set but bs->io_limits_enabled is false when swap_feature_fields() is >> called, but I don't think that's possible in this case. > > So something like this? (Specifically, is the assertion right?) > > assert(!bs_new->throttle_state); > if (bs_top->throttle_state) { > assert(bs_top->io_limits_enabled); > bdrv_io_limits_enable(bs_new, throttle_group_get_name(bs_top)); > bdrv_io_limits_disable(bs_top); > } Yes, I think that's fine. > If the assertion doesn't hold true, I guess we would need to call > throttle_group_register() directly for the cases where > io_limits_enabled wasn't true. If io_limits_enabled is not true but throttle_state is set it means that there's an ongoing request that needs to bypass the I/O limits. There's two places where that can happen: 1) bdrv_start_throttled_reqs(), that's either a result of bdrv_io_limits_disable() or bdrv_flush_io_queue() (i.e. bdrv_drain()). 2) blk_read_unthrottled() (that comes from hd_geometry_guess()). Is there any scenario where the feature fields can be swapped in the middle of one of these two operations? I understand that the BDS must be drained first, that's why I don't think there's any risk. Berto From MAILER-DAEMON Fri Sep 18 10:23:58 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcwZy-0001Ex-1U for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 10:23:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcwZv-0001EL-JI for qemu-block@nongnu.org; Fri, 18 Sep 2015 10:23:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcwZq-00015S-It for qemu-block@nongnu.org; Fri, 18 Sep 2015 10:23:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51121) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcwZq-00014G-CW; Fri, 18 Sep 2015 10:23:50 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 61D23345A95; Fri, 18 Sep 2015 14:23:49 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-119.ams2.redhat.com [10.36.116.119]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8IENkYF012536; Fri, 18 Sep 2015 10:23:47 -0400 Date: Fri, 18 Sep 2015 16:23:46 +0200 From: Kevin Wolf To: Alberto Garcia Message-ID: <20150918142346.GF4320@noname.redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-14-git-send-email-kwolf@redhat.com> <20150918122421.GE4320@noname.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, armbru@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 13/16] block: Implement bdrv_append() without bdrv_swap() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 14:23:56 -0000 Am 18.09.2015 um 15:31 hat Alberto Garcia geschrieben: > On Fri 18 Sep 2015 02:24:21 PM CEST, Kevin Wolf wrote: > > >> > +static void swap_feature_fields(BlockDriverState *bs_top, > >> > + BlockDriverState *bs_new) > >> > +{ > >> > + BlockDriverState tmp; > >> > + > >> > + bdrv_move_feature_fields(&tmp, bs_top); > >> > + bdrv_move_feature_fields(bs_top, bs_new); > >> > + bdrv_move_feature_fields(bs_new, &tmp); > >> > + > >> > + assert(!bs_new->io_limits_enabled); > >> > + if (bs_top->io_limits_enabled) { > >> > + bdrv_io_limits_enable(bs_new, throttle_group_get_name(bs_top)); > >> > + bdrv_io_limits_disable(bs_top); > >> > + } > >> > +} > >> > >> I would use 'if (bs_top->throttle_state != NULL)' instead. That pointer > >> is set if and only if the BDS has I/O limits set. > >> > >> bs->io_limits_enabled can be set to false in order to bypass the limits > >> temporarily without removing the BDS's throttling settings (e.g in > >> bdrv_read_unthrottled()). > >> > >> I actually think that we can get rid of io_limits_enabled in several > >> places (if not completely), but I will take care of that in a separate > >> patch. > >> > >> The only scenario that could cause problems is if bs->throttle_state is > >> set but bs->io_limits_enabled is false when swap_feature_fields() is > >> called, but I don't think that's possible in this case. > > > > So something like this? (Specifically, is the assertion right?) > > > > assert(!bs_new->throttle_state); > > if (bs_top->throttle_state) { > > assert(bs_top->io_limits_enabled); > > bdrv_io_limits_enable(bs_new, throttle_group_get_name(bs_top)); > > bdrv_io_limits_disable(bs_top); > > } > > Yes, I think that's fine. > > > If the assertion doesn't hold true, I guess we would need to call > > throttle_group_register() directly for the cases where > > io_limits_enabled wasn't true. > > If io_limits_enabled is not true but throttle_state is set it means that > there's an ongoing request that needs to bypass the I/O limits. > > There's two places where that can happen: > > 1) bdrv_start_throttled_reqs(), that's either a result of > bdrv_io_limits_disable() or bdrv_flush_io_queue() > (i.e. bdrv_drain()). > > 2) blk_read_unthrottled() (that comes from hd_geometry_guess()). > > Is there any scenario where the feature fields can be swapped in the > middle of one of these two operations? I understand that the BDS must be > drained first, that's why I don't think there's any risk. Yes, I'm asserting !bdrv_requests_pending() for both BDSes, so that should be fine. (But I neglect to actually drain requests in mirror.c. That's probably a bug.) Kevin From MAILER-DAEMON Fri Sep 18 10:37:34 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zcwn8-0008DH-Sp for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 10:37:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcwn7-0008DA-7S for qemu-block@nongnu.org; Fri, 18 Sep 2015 10:37:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcwn2-0001bS-2D for qemu-block@nongnu.org; Fri, 18 Sep 2015 10:37:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcwn1-0001bK-Tl; Fri, 18 Sep 2015 10:37:28 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 10206C0A1490; Fri, 18 Sep 2015 14:37:27 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IEbPdZ021572; Fri, 18 Sep 2015 10:37:25 -0400 To: Vasiliy Tolstov , Kevin Wolf References: <20150918090203.GA4320@noname.redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC21A1.5030400@redhat.com> Date: Fri, 18 Sep 2015 08:37:21 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0PDI37f5oEsxx1QCeHBSqXxXXpxWKCGmp" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: mitake.hitoshi@lab.ntt.co.jp, namei.unix@gmail.com, sheepdog@lists.wpkg.org, qemu-devel , qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] internal snapshots with sheepdog X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 14:37:34 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --0PDI37f5oEsxx1QCeHBSqXxXXpxWKCGmp Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 03:03 AM, Vasiliy Tolstov wrote: > 2015-09-18 12:02 GMT+03:00 Kevin Wolf : >> Doesn't sheepdog already support storing snapshots in the same image? >> I thought it would just work; at least, there's some code there for it= =2E >=20 >=20 > Yes, qemu and sheepdog have ability to create internal snapshot, i > miss that, but when i'm try in libvirt create live snapshot - libvirt > says, that this is not possible with raw image. That may be a case of libvirt being over-conservative because no one has provided a patch to utilize what qemu provides. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --0PDI37f5oEsxx1QCeHBSqXxXXpxWKCGmp Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/CGhAAoJEKeha0olJ0NqwP8IAKkC4268708T5bdQ5lj5H/Bp GgSJ0aoT5KoSac0tajOzMxzKUAeXd7ShSGl8rg4T3WgWghgqw69NRxedVesotM6F Qlf8FSMzUg2QSFDqqTkohM2LR/KQ13GA9FrSh7Md5QR4FYD2i6MaLukaY3S0MGhn YV7qyLlbWI0c2dok7NJJvjBRCz4etaGufnYXDwuf+YbKUiEGCj3ApGOHOXD1qCi/ 6EaAJY3g1+9N3Ctf4NyinbNEUZp9lZm3Ql1U6f3dKLf+h/UyCPuWdxtQHLNjK6Im Tdt821HKpTHXOpWu2wYyr+SZuSdToj4fCtCgFXR3B+SpEV7ahbeKKacz2JvHxgs= =74qE -----END PGP SIGNATURE----- --0PDI37f5oEsxx1QCeHBSqXxXXpxWKCGmp-- From MAILER-DAEMON Fri Sep 18 10:41:35 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zcwr0-0007EN-Um for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 10:41:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcwqu-00078y-2X for qemu-block@nongnu.org; Fri, 18 Sep 2015 10:41:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcwqp-0003SK-QO for qemu-block@nongnu.org; Fri, 18 Sep 2015 10:41:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcwqp-0003SG-Lk; Fri, 18 Sep 2015 10:41:23 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B25CFA327B; Fri, 18 Sep 2015 14:41:22 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IEfL3E018269; Fri, 18 Sep 2015 10:41:22 -0400 To: Alberto Garcia , Fam Zheng References: <20150915022721.GE14016@ad.nay.redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC2291.1030902@redhat.com> Date: Fri, 18 Sep 2015 08:41:21 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="i9SVu6IeOJ8NJvavMgSAUEtXC0mnE3QrC" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-block@nongnu.org, qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v4 2/4] block: support passing 'backing': '' to 'blockdev-add' X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 14:41:33 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --i9SVu6IeOJ8NJvavMgSAUEtXC0mnE3QrC Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/15/2015 12:42 AM, Alberto Garcia wrote: > On Tue 15 Sep 2015 04:27:21 AM CEST, Fam Zheng wrote:= >=20 >>> + backing =3D qdict_get_try_str(options, "backing"); >>> + if (backing && *backing =3D=3D '\0') { >>> + flags |=3D BDRV_O_NO_BACKING; >>> + } >>> + qdict_del(options, "backing"); >>> + >=20 >> Specifying a non-empty "backing" will be a slient nop now, but it used= >> to be an error before. Should we return an error? >=20 > Ah, yes, I think it should return an error. Thanks! With this squashed in, Reviewed-by: Eric Blake >=20 > --- a/block.c > +++ b/block.c > @@ -1473,8 +1473,8 @@ static int bdrv_open_inherit(BlockDriverState > **pbs, const char *filename, > backing =3D qdict_get_try_str(options, "backing"); > if (backing && *backing =3D=3D '\0') { > flags |=3D BDRV_O_NO_BACKING; > + qdict_del(options, "backing"); > } > - qdict_del(options, "backing"); >=20 > Berto >=20 >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --i9SVu6IeOJ8NJvavMgSAUEtXC0mnE3QrC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/CKRAAoJEKeha0olJ0Nq7n0H/3fN1+LHyoNPKJ8wtNopknfr p5ExCtrdCmZTRMisBGoGtDe9/7qSA/XbmWaJCPBM0o7JwmyVANGBrJVEMKrOrZu5 x+T5T8wSM/1T84GWh/nNyPx3Kf64UycNR3jqJbDB0xiqhfnhzqSfQo6vEXLwcPcV Lh2hBfNAep0uo0mYcee5BK/uoD9WNntLN7psaOibYXXF6Z3cwVh4U/VGyi4bkiHz lbiFa0iQukCIA/10tFchuabOi+sMAaNqv2s8G7pYL+AFajuVVZgPXmpp4K/j39oK PxaS93s2Ue94OqyIcSoMV4QrfNyG2X+I8ulQqLd+28yTHGrlLTH6kT3FmWikYXI= =fSL/ -----END PGP SIGNATURE----- --i9SVu6IeOJ8NJvavMgSAUEtXC0mnE3QrC-- From MAILER-DAEMON Fri Sep 18 10:49:17 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcwyS-0004Ws-Us for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 10:49:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcwyP-0004W8-Lz for qemu-block@nongnu.org; Fri, 18 Sep 2015 10:49:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcwyL-0006xL-Lo for qemu-block@nongnu.org; Fri, 18 Sep 2015 10:49:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39611) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcwyL-0006xD-FB; Fri, 18 Sep 2015 10:49:09 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 86A75C0A1461; Fri, 18 Sep 2015 14:49:08 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IEn7r4031893; Fri, 18 Sep 2015 10:49:07 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <0feb7566cff42d8625ed7263de73fc59225e125f.1442245236.git.berto@igalia.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <55FC2462.9080000@redhat.com> Date: Fri, 18 Sep 2015 08:49:06 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <0feb7566cff42d8625ed7263de73fc59225e125f.1442245236.git.berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="44EW36iXMRrvqHDnvVcu2WqUeOwqjpsQ3" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v4 3/4] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 14:49:15 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --44EW36iXMRrvqHDnvVcu2WqUeOwqjpsQ3 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/14/2015 10:01 AM, Alberto Garcia wrote: > One of the limitations of the 'blockdev-snapshot-sync' command is that > it does not allow passing BlockdevOptions to the newly created > snapshots, so they are always opened using the default values. >=20 > Extending the command to allow passing options is not a practical > solution because there is overlap between those options and some of > the existing parameters of the command. >=20 > This patch introduces a new 'blockdev-snapshot' command with a simpler > interface: it just takes two references to existing block devices that > will be used as the source and target for the snapshot. >=20 > Since the main difference between the two commands is that one of them > creates and opens the target image, while the other uses an already > opened one, the bulk of the implementation is shared. >=20 > Signed-off-by: Alberto Garcia > Reviewed-by: Eric Blake > Cc: Max Reitz > --- > +++ b/qapi/block-core.json > @@ -705,6 +705,21 @@ > '*format': 'str', '*mode': 'NewImageMode' } } > =20 > ## > +# @BlockdevSnapshot > +# > +# @device: device or node name to generate the snapshot from. I'm still wondering if 'node' is a better name than 'device' here. > +# > +# @snapshot: reference to the existing block device that will be used > +# for the snapshot. It must not have a current backing file= > +# (this can be achieved by passing "backing": "" to > +# blockdev-add). Possibly confusing terminology. Let's consider: the act of creating a snapshot says to go from: image1 [read-write] to image1 [read-only] <- image2 [read-write] that is, image1 is now the snapshot of the state in time we executed the command, and image2 is the delta from what happened since the snapshot. Therefore, image2 is NOT the snapshot. Naming the command 'blockdev-snapshot' is fine, but I think we can have better names for the arguments. Better wording might be: @device: device or node that will have a snapshot created @overlay: reference to existing block device that will become the overlay of device, as part of creating the snapshot. It must not have a current backing file... > +Example: > + > +-> { "execute": "blockdev-add", > + "arguments": { "options": { "driver": "qcow2", > + "node-name": "node1534", > + "file": { "driver": "file"= , > + "filename": "hd1= =2Eqcow2" }, > + "backing": "" } } } > + > +<- { "return": {} } > + > +-> { "execute": "blockdev-snapshot", "arguments": { "device": "ide-hd0= ", > + "snapshot": "node1= 534" } } > +<- { "return": {} } The example would need tweaking if we rename members of the command, but it definitely helps. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --44EW36iXMRrvqHDnvVcu2WqUeOwqjpsQ3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/CRiAAoJEKeha0olJ0NqACoIAJwfWtOUhaLHGTK5Ydh9RT9V 0ZL/Wv/l4euPy4n6f0yYpTP51cHlJ796yyduYCgh8OZTbb9rvWpfBa9g/4N+C1kr f8ALRqVmbotDnGxgJ5WSa/RjjWLGh6VrHlyykeMPQ5aacUCfQatSX45j1zkzXhNd NgL6kffthSa4r+SUK2fbWPc37+FpICP0zUEBzZWkfE0Q8UNzOjyYbCuiJAxJ/kHZ cuZh8pe+rt8LNl31/HhZSF03FqovOuWqLW/veNhpHGchOb4mjRJMrh+WtMV+2xK9 OihbxDLlL1OB8mFrr5RBTGvxkAOn+vQy1sviMWb85QJwbhsJc8I+jxs4nwOCRx8= =+UTN -----END PGP SIGNATURE----- --44EW36iXMRrvqHDnvVcu2WqUeOwqjpsQ3-- From MAILER-DAEMON Fri Sep 18 10:52:11 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zcx1H-0006ZG-6d for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 10:52:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcx1F-0006Y2-1r for qemu-block@nongnu.org; Fri, 18 Sep 2015 10:52:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcx19-0008TT-U4 for qemu-block@nongnu.org; Fri, 18 Sep 2015 10:52:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43006) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcx19-0008TH-Pt; Fri, 18 Sep 2015 10:52:03 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 10E2292384; Fri, 18 Sep 2015 14:52:03 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IEq1r2026601; Fri, 18 Sep 2015 10:52:01 -0400 To: Wen Congyang , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi References: <1442571195-27116-1-git-send-email-wency@cn.fujitsu.com> <1442571195-27116-2-git-send-email-wency@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC2511.6090806@redhat.com> Date: Fri, 18 Sep 2015 08:52:01 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442571195-27116-2-git-send-email-wency@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6Pef5wEaqxqJxAxTa6TaqQIIBvtfmAI3L" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [PATCH v4 1/4] Add new block driver interface to add/delete a BDS's child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 14:52:10 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --6Pef5wEaqxqJxAxTa6TaqQIIBvtfmAI3L Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 04:13 AM, Wen Congyang wrote: > In some cases, we want to take a quorum child offline, and take > another child online. >=20 > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei > --- > block.c | 50 +++++++++++++++++++++++++++++++++++++++= ++++++++ > include/block/block.h | 5 +++++ > include/block/block_int.h | 5 +++++ > 3 files changed, 60 insertions(+) >=20 > +void bdrv_del_child(BlockDriverState *parent_bs, BlockDriverState *chi= ld_bs, > + Error **errp) > +{ > + BdrvChild *child; > + if (!child) { > + error_setg(errp, "The BDS %s is not the BDS %s's child", > + bdrv_get_device_or_node_name(child_bs), > + bdrv_get_device_or_node_name(parent_bs)); Better would be: "BDS %s is not a child of %s" With that, Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --6Pef5wEaqxqJxAxTa6TaqQIIBvtfmAI3L Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/CURAAoJEKeha0olJ0NqDP8IAIr5QjWmOtCu4o55axBEitCl 9S6fecW2qocOB4Uf3RPIpolui6OJgzJdPnxESRjM6N+XJ2t7gI1RaQxrCCPoo1rd Y/Nnbn5DWZ6z9wqOiRqR9aSx+o1GpGZirOklM/Ad0DgUVb2VEUyp2aiNmgHg75XJ 8Od6iTtmkSO/IFb0lfz6Z3J4kHxiTX1NUn7cHIQQmV/frEztCFaoksaYVTLICodL Bp7AEPVe/LjBd7XUPZquxWggg1FGbrn/dRr6Uiso8EgxBvnmyTIHsetsS8kAErVo 4Y0NIEaulAfbt4Qq7TcHXVJiCR47MdC8xBORtIBhgouSAPJABuJM8aSXovB0ylw= =Kb9c -----END PGP SIGNATURE----- --6Pef5wEaqxqJxAxTa6TaqQIIBvtfmAI3L-- From MAILER-DAEMON Fri Sep 18 10:58:14 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zcx78-0002Rl-Hx for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 10:58:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcx75-0002M0-QD for qemu-block@nongnu.org; Fri, 18 Sep 2015 10:58:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcx72-0004qB-Gf for qemu-block@nongnu.org; Fri, 18 Sep 2015 10:58:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcx72-0004pg-9t; Fri, 18 Sep 2015 10:58:08 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id B2DA9C0B9885; Fri, 18 Sep 2015 14:58:07 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IEw6as003390; Fri, 18 Sep 2015 10:58:06 -0400 To: Wen Congyang , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi References: <1442571195-27116-1-git-send-email-wency@cn.fujitsu.com> <1442571195-27116-4-git-send-email-wency@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC267D.1000700@redhat.com> Date: Fri, 18 Sep 2015 08:58:05 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442571195-27116-4-git-send-email-wency@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="FTo88mB8EUx7u4LF8lGLVOcucF4Jb2ruu" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [PATCH v4 3/4] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 14:58:13 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --FTo88mB8EUx7u4LF8lGLVOcucF4Jb2ruu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 04:13 AM, Wen Congyang wrote: > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei Commit message should probably mention the name of the new commands. Also, if you still want the command to be experimental, it would be nice to explain in the commit message why you have chosen that, and what might change in the future to make us either commit to the interface or replace it with a better one. > --- > blockdev.c | 48 ++++++++++++++++++++++++++++++++++++++++++++= ++ > qapi/block-core.json | 34 +++++++++++++++++++++++++++++++++ > qmp-commands.hx | 54 ++++++++++++++++++++++++++++++++++++++++++++= ++++++++ > 3 files changed, 136 insertions(+) > +SQMP > +x-blockdev-child-add > +------------ > + > +Add a child to a quorum node. > + > +Arguments: > + > +- "parent": the quorum's id or node name > +- "child": the child node-name which will be added > + > +Note: this command is experimental, and not a stable API. It doesn't > +support all kinds of child, and not support all block drivers. s/of child/of children/ s/and not support/nor/ > + > +Example: > + > +-> { "execute": "x-blockdev-child-add", > + "arguments": { "parent": "disk1", "child": "new_node" } } > +<- { "return": {} } Might be nice to extend the example to show the blockdev-add that created "new_node" before this command plugs it in. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --FTo88mB8EUx7u4LF8lGLVOcucF4Jb2ruu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/CZ+AAoJEKeha0olJ0Nq0GcH/jCFODkoLEtYpJdMlfNi3v3Y TP6ySRzmON8WAoU2saFCgL/7yHN0zEaOnxfwFSmRwIaDB4Jgyu06N/MwRe8AmY7a rLicpaQR+tgWjvf7jH0rwUJ6x8DKQ6hIqpcWa0ctluze70EdmuaqkDeRs5TdAqe0 U5rwc162iKE4qoukPsJ+rjrrjAXVLu6I0T0Fo6n+SpTHJsaXEVL31nZwqEyXLSGe YXDCsaI8AOhQzaANn/KB1N/2v1/531vmr+HlMVqbcroWNgK5bGsm4rLLyY+eMiqZ sOqK19eqOQtqH4RWfd6dmuhBIos1TlVABuOqxD+dnLCXqwocM1JAEdqEXA5pTCc= =ov8H -----END PGP SIGNATURE----- --FTo88mB8EUx7u4LF8lGLVOcucF4Jb2ruu-- From MAILER-DAEMON Fri Sep 18 11:00:12 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zcx92-0005zI-44 for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:00:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcx8z-0005sg-0t for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:00:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcx8t-0006yz-DY for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:00:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36636) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcx8t-0006xq-3w; Fri, 18 Sep 2015 11:00:03 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 7CFC42FE82B; Fri, 18 Sep 2015 15:00:02 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IF00i5031690; Fri, 18 Sep 2015 11:00:00 -0400 To: Wen Congyang , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi References: <1442571195-27116-1-git-send-email-wency@cn.fujitsu.com> <1442571195-27116-5-git-send-email-wency@cn.fujitsu.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC26F0.5010507@redhat.com> Date: Fri, 18 Sep 2015 09:00:00 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442571195-27116-5-git-send-email-wency@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="IujMmJP9EjMom4rPFleh1ofg2iEhG4fMS" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Luiz Capitulino , Gonglei , Yang Hongyang Subject: Re: [Qemu-block] [PATCH v4 4/4] hmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:00:10 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --IujMmJP9EjMom4rPFleh1ofg2iEhG4fMS Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 04:13 AM, Wen Congyang wrote: > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei > Cc: Luiz Capitulino > --- > hmp-commands.hx | 28 ++++++++++++++++++++++++++++ > hmp.c | 20 ++++++++++++++++++++ > hmp.h | 2 ++ > 3 files changed, 50 insertions(+) >=20 > + > +STEXI > +@item blockdev_child_add @var{parent device} @var{child device} This produces poor-looking info that makes it appear that the command takes 4 parameters, with two of those parameters both named 'device'. I'd use just: @item blockdev_child_add @var{parent} @var{child} > +STEXI > +@item blockdev_child_del @var{parent device} @var{child device} Likewise. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --IujMmJP9EjMom4rPFleh1ofg2iEhG4fMS Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/CbwAAoJEKeha0olJ0Nq2hIIAI+BJYJQeApBgJY8A5zOwDAS W/njHZqF6CV/k12VZjmZPp85r6noB/J4scYHJ+b9zZy5lpYbexnWgwL6COTIt9YH ReSv/6XosUVlL6c6V4TxwAJu2EFmmY6u2/vQs0eqtKjy/yPdIInMOkdI793DCJYv yPTW//zX34jsyRjOgvHkGjxTeqBgB4sh2DamaXdU392Jyy9dUgA4d5mMHlprkA5K A8LuaX/DTeaU6iow2Qp7bMoSXlLwUPvjC1DJFIPidwxtlCDwJDSop9qd3AtsOORo EOGVcdmGPbc07+bVCsFlZumVjvL3dzrRE6SNMMWd8OgSCEudQJ3Ie+UVx18mFTU= =VEBy -----END PGP SIGNATURE----- --IujMmJP9EjMom4rPFleh1ofg2iEhG4fMS-- From MAILER-DAEMON Fri Sep 18 11:12:37 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxL3-0005AG-No for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:12:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxL1-00059h-Iw for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:12:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxKy-0002Jt-DY for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:12:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46425) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxKy-0002Jn-7V; Fri, 18 Sep 2015 11:12:32 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 9F1FDC0A1497; Fri, 18 Sep 2015 15:12:31 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFCUgL011125; Fri, 18 Sep 2015 11:12:31 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC29DE.6020601@redhat.com> Date: Fri, 18 Sep 2015 09:12:30 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jp244Un8SoxKMp7j7B3SKM4FKklr8dX0P" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v5 0/4] Add 'blockdev-snapshot' command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:12:36 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jp244Un8SoxKMp7j7B3SKM4FKklr8dX0P Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 07:16 AM, Alberto Garcia wrote: > This fixes the problem detect by Fam: the previous series was deleting > the 'backing' option for 'blockdev-add' even if it contained a > non-empty string. >=20 > The code is also rebased on top of the current master. In particular > the test output had to be adapted because of fe646693. >=20 > Again, this depends on Max's BlockBackend and media series: >=20 > https://lists.gnu.org/archive/html/qemu-block/2015-07/msg00382.html >=20 > Berto >=20 > v5: > - Don't delete the 'backing' option if it contains something different > from an empty string. > - Rebase on top of the current master. Oops, I added some review comments on v4 before seeing that you had already posted v5. I have some potential naming changes to 3/4 that should be considered (namely, s/snapshot/overlay/ for the name of the node that is being added to the chain); and which may necessitate a v6. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --jp244Un8SoxKMp7j7B3SKM4FKklr8dX0P Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/CneAAoJEKeha0olJ0NqQz4H/i3A3q8IpgaOTxuWJwgmBTCk IbXGBsUEcxW1+LCIBKzZ8ksy5ELdmmim1lVEdjZpWy2qamdXnhseDNVoki+nKvNk jcXqewZQkTW9EbI5h7KHsgitpGtBRdmlw4A0yjY9oHJxAV5eb7rmMNT+mT4keEll jsWMbHimpGu/BsLxQ+mSjSkvqoQI/tvj/E4cEFMIE3s+kyN4SrImCEWkG4f4ifaA PlyKJtPv5Z/o5N991pKs+pN2r8c0MS+2bBsnWhncqPX5m6xU5gJWb5EQ1Phjk6wM xYLHTRV/F63ycDKSG7DvRpanVLODg+qSVkCSdi7h6zOczRhZHVuYMIgbxFo2J1E= =ym/U -----END PGP SIGNATURE----- --jp244Un8SoxKMp7j7B3SKM4FKklr8dX0P-- From MAILER-DAEMON Fri Sep 18 11:23:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxVX-0005gc-RD for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:23:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37586) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVS-0005YA-9N for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxVM-0005dP-Ob for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52201) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVM-0005dC-Fl; Fri, 18 Sep 2015 11:23:16 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 205F624B; Fri, 18 Sep 2015 15:23:16 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNDUF023500 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:15 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:35 +0200 Message-Id: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 00/38] blockdev: BlockBackend and media X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:24 -0000 This series reworks a lot regarding BlockBackend and media. Basically, it allows empty BlockBackends, that is BBs without a BDS tree. Before this series, empty drives are represented by a BlockBackend with an empty BDS attached to it (a BDS with a NULL driver). However, now we have BlockBackends, thus an empty drive should be represented by a BlockBackend without any BDS tree attached to it. This is what this series does. Quick and early summary for the v5 changes: - Rebase on master - Addressed Kevin's comments for v4 Justification for each of the patches and their order: -- Preparation before _is_inserted() patches -- 1: Patch 9 will not take care not to break host floppy support, so that support needs to be removed first. 2: Needed for patch 3, so that blockdev-added BDSs without a BB still get the BDRV_O_INCOMING flag set. 3: Needed for patch 4. Patch 25 is a follow-up after BDS-less BBs are allowed. 4: bdrv_close_all() is broken ("block: Rework bdrv_close_all()"). Patch 7 will break iotest 071 (actually, just make the problem apparent). So this patch is required to work around the issue. (with "the issue" being that bdrv_close_all() does not unref() the BDSs it is closing, but just force-closes everything, even if the BDS may still be in use somewhere) -- _is_inserted() patches -- 5: General clean-up work, nice to have before patch 7 (and goes in tune with patch 6). 6: Using the same BB as a guest device means that the data read from there should be exactly the same. Opening the guest tray should therefore result in no data being readable. This is what we then need this function for. 7: General clean-up work (in the _is_inserted() area). 8: General clean-up work (in the _is_inserted() area). 9: General clean-up work (also regarding _is_inserted()). 10: Required so inserting a floppy will not result in the tray being reported as closed (you need to "push in" the floppy first, using blockdev-close-tray). It's here in the "_is_inserted() patches area" because I feel like that's a very related topic. -- Support for BDS-less BBs -- 11: Preparation for BDS-less BBs 12: Preparation for BDS-less BBs 13: Preparation for BDS-less BBs (BB properties should be in the BB, and not in the root BDS) 14: Patch 15 removes BlockAcctStats from the BDS, but wr_highest_sector is BDS-dependent, so it needs to stay here 15: Preparation for BDS-less BBs (BB properties should be in the BB, and not in the root BDS) 16: Preparation for BDS-less BBs (BB properties should be in the BB, and not in the root BDS) 17: Preparation for BDS-less BBs (Removing a BDS tree should retain some properties for legacy reasons, which must therefore be stored in the BB(RS)) 18: Preparation for BDS-less BBs 19: Preparation for BDS-less BBs 20: Preparation for BDS-less BBs 21: Ability to add BDS trees to empty BBs ("inserting a medium") 22: Preparation for BDS-less BBs (needs patch 21) 23: One goal of this series, and fixes the "opening tray" event for empty drives when shutting down qemu 24: Needed for patch 25 25: Completion of what patch 3 begun 26: Ability to detach BDS trees from BBs -- "Atomic" QMP tray operations -- 27: blockdev-open-tray 28: blockdev-close-tray 29: blockdev-remove-medium 30: blockdev-insert-medium -- Reimplementation of change/eject -- 31: eject 32: change 33: Clean-up patch -- New QMP blockdev-change-medium command -- 34: New QMP command 35: Use for HMP change command 36: Add flag to that command for changing the read-only access mode (which was my original intention for this series) 37: Same flag for HMP -- Tests -- 38: iotests are always nice, so here is one v5: - Patch 1: [Kevin] - Drop fd_open() stub, use the FreeBSD implementation for every platform - s/2\.4/2.5/ - Patch 2: Added, required for patch 3 [Kevin] - Patch 3: @drv parameter has been dropped from bdrv_open() - Patch 4: Fix up some blockdev-add invocations [Kevin] - Patch 7: Good thing we have a generic children list now, we can use that for a more generic recursive bdrv_is_inserted() [Kevein] - Patch 10: As of 2711fd33a4b18c5e35a6f7efe57b5d868def829e (-nodefaults for the iotests) the tests previously broken by this patch no longer have the affected output, thereby making fixing them unnecessary - Patch 22: Rebase conflicts due to the @drv dropping patches - Patch 23: - Rebase conflict due the new patch 2 (a good thing) - Same as for patch 10: The tests no longer need to be fixed - Patch 25: Rebase conflicts due to the @drv dropping patches - Patch 32: Rebase conflicts due to the @drv dropping patches git-backport-diff against v4: Key: [----] : patches are identical [####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively 001/38:[0011] [FC] 'block: Remove host floppy support' 002/38:[down] 'block: Set BDRV_O_INCOMING in bdrv_fill_options()' 003/38:[0002] [FC] 'blockdev: Allow creation of BDS trees without BB' 004/38:[0020] [FC] 'iotests: Only create BB if necessary' 005/38:[----] [--] 'block: Make bdrv_is_inserted() return a bool' 006/38:[----] [--] 'block: Add blk_is_available()' 007/38:[0013] [FC] 'block: Make bdrv_is_inserted() recursive' 008/38:[down] 'block/raw_bsd: Drop raw_is_inserted()' 009/38:[----] [--] 'block: Invoke change media CB before NULLing drv' 010/38:[0069] [FC] 'hw/block/fdc: Implement tray status' 011/38:[----] [--] 'hw/usb-storage: Check whether BB is inserted' 012/38:[----] [--] 'block: Fix BB AIOCB AioContext without BDS' 013/38:[----] [--] 'block: Move guest_block_size into BlockBackend' 014/38:[----] [--] 'block: Remove wr_highest_sector from BlockAcctStats' 015/38:[----] [--] 'block: Move BlockAcctStats into BlockBackend' 016/38:[----] [--] 'block: Move I/O status and error actions into BB' 017/38:[----] [--] 'block: Add BlockBackendRootState' 018/38:[----] [--] 'block: Make some BB functions fall back to BBRS' 019/38:[----] [--] 'block: Fail requests to empty BlockBackend' 020/38:[----] [--] 'block: Prepare remaining BB functions for NULL BDS' 021/38:[----] [--] 'block: Add blk_insert_bs()' 022/38:[0010] [FC] 'block: Prepare for NULL BDS' 023/38:[0057] [FC] 'blockdev: Do not create BDS for empty drive' 024/38:[----] [--] 'blockdev: Pull out blockdev option extraction' 025/38:[0004] [FC] 'blockdev: Allow more options for BB-less BDS tree' 026/38:[----] [--] 'block: Add blk_remove_bs()' 027/38:[----] [--] 'blockdev: Add blockdev-open-tray' 028/38:[----] [--] 'blockdev: Add blockdev-close-tray' 029/38:[----] [--] 'blockdev: Add blockdev-remove-medium' 030/38:[----] [--] 'blockdev: Add blockdev-insert-medium' 031/38:[----] [--] 'blockdev: Implement eject with basic operations' 032/38:[0032] [FC] 'blockdev: Implement change with basic operations' 033/38:[----] [--] 'block: Inquire tray state before tray-moved events' 034/38:[----] [-C] 'qmp: Introduce blockdev-change-medium' 035/38:[----] [--] 'hmp: Use blockdev-change-medium for change command' 036/38:[----] [--] 'blockdev: read-only-mode for blockdev-change-medium' 037/38:[----] [--] 'hmp: Add read-only-mode option to change command' 038/38:[----] [--] 'iotests: Add test for change-related QMP commands' Max Reitz (38): block: Remove host floppy support block: Set BDRV_O_INCOMING in bdrv_fill_options() blockdev: Allow creation of BDS trees without BB iotests: Only create BB if necessary block: Make bdrv_is_inserted() return a bool block: Add blk_is_available() block: Make bdrv_is_inserted() recursive block/raw_bsd: Drop raw_is_inserted() block: Invoke change media CB before NULLing drv hw/block/fdc: Implement tray status hw/usb-storage: Check whether BB is inserted block: Fix BB AIOCB AioContext without BDS block: Move guest_block_size into BlockBackend block: Remove wr_highest_sector from BlockAcctStats block: Move BlockAcctStats into BlockBackend block: Move I/O status and error actions into BB block: Add BlockBackendRootState block: Make some BB functions fall back to BBRS block: Fail requests to empty BlockBackend block: Prepare remaining BB functions for NULL BDS block: Add blk_insert_bs() block: Prepare for NULL BDS blockdev: Do not create BDS for empty drive blockdev: Pull out blockdev option extraction blockdev: Allow more options for BB-less BDS tree block: Add blk_remove_bs() blockdev: Add blockdev-open-tray blockdev: Add blockdev-close-tray blockdev: Add blockdev-remove-medium blockdev: Add blockdev-insert-medium blockdev: Implement eject with basic operations blockdev: Implement change with basic operations block: Inquire tray state before tray-moved events qmp: Introduce blockdev-change-medium hmp: Use blockdev-change-medium for change command blockdev: read-only-mode for blockdev-change-medium hmp: Add read-only-mode option to change command iotests: Add test for change-related QMP commands block.c | 180 ++------ block/accounting.c | 8 - block/backup.c | 17 +- block/block-backend.c | 387 +++++++++++++++-- block/commit.c | 3 +- block/io.c | 10 +- block/mirror.c | 17 +- block/qapi.c | 36 +- block/raw-posix.c | 230 +---------- block/raw_bsd.c | 6 - block/stream.c | 3 +- blockdev.c | 916 +++++++++++++++++++++++++++++------------ blockjob.c | 5 +- hmp-commands.hx | 20 +- hmp.c | 47 ++- hw/block/fdc.c | 20 +- hw/block/xen_disk.c | 4 +- hw/usb/dev-storage.c | 30 +- include/block/accounting.h | 3 - include/block/block.h | 16 +- include/block/block_int.h | 25 +- include/qemu/typedefs.h | 1 + include/sysemu/block-backend.h | 14 +- include/sysemu/blockdev.h | 2 - migration/block.c | 5 + monitor.c | 4 + qapi-schema.json | 6 +- qapi/block-core.json | 138 ++++++- qmp-commands.hx | 213 +++++++++- qmp.c | 9 +- tests/fdc-test.c | 4 +- tests/qemu-iotests/071 | 54 ++- tests/qemu-iotests/071.out | 12 +- tests/qemu-iotests/081 | 18 +- tests/qemu-iotests/081.out | 5 +- tests/qemu-iotests/087 | 2 +- tests/qemu-iotests/087.out | 4 +- tests/qemu-iotests/118 | 638 ++++++++++++++++++++++++++++ tests/qemu-iotests/118.out | 5 + tests/qemu-iotests/group | 1 + 40 files changed, 2294 insertions(+), 824 deletions(-) create mode 100755 tests/qemu-iotests/118 create mode 100644 tests/qemu-iotests/118.out -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:23:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxVZ-0005ig-3A for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:23:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVW-0005eB-As for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxVS-0005gO-Ee for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42498) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVS-0005gG-9y; Fri, 18 Sep 2015 11:23:22 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id E75D3A35B9; Fri, 18 Sep 2015 15:23:21 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNJPP023526 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:21 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:37 +0200 Message-Id: <1442589793-7105-3-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 02/38] block: Set BDRV_O_INCOMING in bdrv_fill_options() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:27 -0000 This flag should not be set for the root BDS only, but for any BDS that is being created while incoming migration is pending, so setting it is moved from blockdev_init() to bdrv_fill_options(). Signed-off-by: Max Reitz --- block.c | 4 ++++ blockdev.c | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index 6268e37..51d8c51 100644 --- a/block.c +++ b/block.c @@ -1076,6 +1076,10 @@ static int bdrv_fill_options(QDict **options, const char **pfilename, } } + if (runstate_check(RUN_STATE_INMIGRATE)) { + *flags |= BDRV_O_INCOMING; + } + return 0; } diff --git a/blockdev.c b/blockdev.c index 32b04b4..ab6eaea 100644 --- a/blockdev.c +++ b/blockdev.c @@ -539,10 +539,6 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, bdrv_flags |= BDRV_O_COPY_ON_READ; } - if (runstate_check(RUN_STATE_INMIGRATE)) { - bdrv_flags |= BDRV_O_INCOMING; - } - bdrv_flags |= ro ? 0 : BDRV_O_RDWR; blk = blk_new_open(qemu_opts_id(opts), file, NULL, bs_opts, bdrv_flags, -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:23:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxVZ-0005jk-Kr for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:23:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVW-0005eC-An for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxVV-0005iH-AB for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42521) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVV-0005hz-46; Fri, 18 Sep 2015 11:23:25 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id B089A91C16; Fri, 18 Sep 2015 15:23:24 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNMZX018570 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:23 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:38 +0200 Message-Id: <1442589793-7105-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 03/38] blockdev: Allow creation of BDS trees without BB X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:27 -0000 If the "id" field is missing from the options given to blockdev-add, just omit the BlockBackend and create the BlockDriverState tree alone. However, if "id" is missing, "node-name" must be specified; otherwise, the BDS tree would no longer be accessible. Many BDS options which are not parsed by bdrv_open() (like caching) cannot be specified for these BB-less BDS trees yet. A future patch will remove this limitation. Signed-off-by: Max Reitz --- blockdev.c | 44 +++++++++++++++++++++++++++++++------------- qapi/block-core.json | 13 +++++++++---- tests/qemu-iotests/087 | 2 +- tests/qemu-iotests/087.out | 4 ++-- 4 files changed, 43 insertions(+), 20 deletions(-) diff --git a/blockdev.c b/blockdev.c index ab6eaea..013583b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3028,17 +3028,12 @@ out: void qmp_blockdev_add(BlockdevOptions *options, Error **errp) { QmpOutputVisitor *ov = qmp_output_visitor_new(); - BlockBackend *blk; + BlockDriverState *bs; + BlockBackend *blk = NULL; QObject *obj; QDict *qdict; Error *local_err = NULL; - /* Require an ID in the top level */ - if (!options->has_id) { - error_setg(errp, "Block device needs an ID"); - goto fail; - } - /* TODO Sort it out in raw-posix and drive_new(): Reject aio=native with * cache.direct=false instead of silently switching to aio=threads, except * when called from drive_new(). @@ -3066,14 +3061,37 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp) qdict_flatten(qdict); - blk = blockdev_init(NULL, qdict, &local_err); - if (local_err) { - error_propagate(errp, local_err); - goto fail; + if (options->has_id) { + blk = blockdev_init(NULL, qdict, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto fail; + } + + bs = blk_bs(blk); + } else { + int ret; + + if (!qdict_get_try_str(qdict, "node-name")) { + error_setg(errp, "'id' and/or 'node-name' need to be specified for " + "the root node"); + goto fail; + } + + bs = NULL; + ret = bdrv_open(&bs, NULL, NULL, qdict, BDRV_O_RDWR | BDRV_O_CACHE_WB, + errp); + if (ret < 0) { + goto fail; + } } - if (bdrv_key_required(blk_bs(blk))) { - blk_unref(blk); + if (bs && bdrv_key_required(bs)) { + if (blk) { + blk_unref(blk); + } else { + bdrv_unref(bs); + } error_setg(errp, "blockdev-add doesn't support encrypted devices"); goto fail; } diff --git a/qapi/block-core.json b/qapi/block-core.json index c042561..425fdab 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1393,9 +1393,12 @@ # # @driver: block driver name # @id: #optional id by which the new block device can be referred to. -# This is a required option on the top level of blockdev-add, and -# currently not allowed on any other level. -# @node-name: #optional the name of a block driver state node (Since 2.0) +# This option is only allowed on the top level of blockdev-add. +# A BlockBackend will be created by blockdev-add if and only if +# this option is given. +# @node-name: #optional the name of a block driver state node (Since 2.0). +# This option is required on the top level of blockdev-add if +# the @id option is not given there. # @discard: #optional discard-related options (default: ignore) # @cache: #optional cache-related options # @aio: #optional AIO backend (default: threads) @@ -1859,7 +1862,9 @@ ## # @blockdev-add: # -# Creates a new block device. +# Creates a new block device. If the @id option is given at the top level, a +# BlockBackend will be created; otherwise, @node-name is mandatory at the top +# level and no BlockBackend will be created. # # This command is still a work in progress. It doesn't support all # block drivers, it lacks a matching blockdev-del, and more. Stay diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087 index 8694749..af44299 100755 --- a/tests/qemu-iotests/087 +++ b/tests/qemu-iotests/087 @@ -54,7 +54,7 @@ size=128M _make_test_img $size echo -echo === Missing ID === +echo === Missing ID and node-name === echo run_qemu <) id 1ZcxVS-0005YB-9I for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxVP-0005et-T6 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVP-0005eP-K5; Fri, 18 Sep 2015 11:23:19 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 41524AB4; Fri, 18 Sep 2015 15:23:19 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNGjO018542 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:18 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:36 +0200 Message-Id: <1442589793-7105-2-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 01/38] block: Remove host floppy support X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:24 -0000 It has been deprecated as of 2.3, so we can now remove it. Signed-off-by: Max Reitz --- block/raw-posix.c | 222 ++------------------------------------------------- qapi/block-core.json | 9 +-- 2 files changed, 9 insertions(+), 222 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 30df8ad..e650c9b 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -127,11 +127,6 @@ do { \ #define FTYPE_FILE 0 #define FTYPE_CD 1 -#define FTYPE_FD 2 - -/* if the FD is not accessed during that time (in ns), we try to - reopen it to see if the disk has been changed */ -#define FD_OPEN_TIMEOUT (1000000000) #define MAX_BLOCKSIZE 4096 @@ -141,13 +136,6 @@ typedef struct BDRVRawState { int open_flags; size_t buf_align; -#if defined(__linux__) - /* linux floppy specific */ - int64_t fd_open_time; - int64_t fd_error_time; - int fd_got_error; - int fd_media_changed; -#endif #ifdef CONFIG_LINUX_AIO int use_aio; void *aio_ctx; @@ -626,7 +614,7 @@ static int raw_reopen_prepare(BDRVReopenState *state, } #endif - if (s->type == FTYPE_FD || s->type == FTYPE_CD) { + if (s->type == FTYPE_CD) { raw_s->open_flags |= O_NONBLOCK; } @@ -2178,47 +2166,6 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags, } #if defined(__linux__) -/* Note: we do not have a reliable method to detect if the floppy is - present. The current method is to try to open the floppy at every - I/O and to keep it opened during a few hundreds of ms. */ -static int fd_open(BlockDriverState *bs) -{ - BDRVRawState *s = bs->opaque; - int last_media_present; - - if (s->type != FTYPE_FD) - return 0; - last_media_present = (s->fd >= 0); - if (s->fd >= 0 && - (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->fd_open_time) >= FD_OPEN_TIMEOUT) { - qemu_close(s->fd); - s->fd = -1; - DPRINTF("Floppy closed\n"); - } - if (s->fd < 0) { - if (s->fd_got_error && - (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->fd_error_time) < FD_OPEN_TIMEOUT) { - DPRINTF("No floppy (open delayed)\n"); - return -EIO; - } - s->fd = qemu_open(bs->filename, s->open_flags & ~O_NONBLOCK); - if (s->fd < 0) { - s->fd_error_time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); - s->fd_got_error = 1; - if (last_media_present) - s->fd_media_changed = 1; - DPRINTF("No floppy\n"); - return -EIO; - } - DPRINTF("Floppy opened\n"); - } - if (!last_media_present) - s->fd_media_changed = 1; - s->fd_open_time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); - s->fd_got_error = 0; - return 0; -} - static int hdev_ioctl(BlockDriverState *bs, unsigned long int req, void *buf) { BDRVRawState *s = bs->opaque; @@ -2247,8 +2194,8 @@ static BlockAIOCB *hdev_aio_ioctl(BlockDriverState *bs, pool = aio_get_thread_pool(bdrv_get_aio_context(bs)); return thread_pool_submit_aio(pool, aio_worker, acb, cb, opaque); } +#endif /* linux */ -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) static int fd_open(BlockDriverState *bs) { BDRVRawState *s = bs->opaque; @@ -2258,14 +2205,6 @@ static int fd_open(BlockDriverState *bs) return 0; return -EIO; } -#else /* !linux && !FreeBSD */ - -static int fd_open(BlockDriverState *bs) -{ - return 0; -} - -#endif /* !linux && !FreeBSD */ static coroutine_fn BlockAIOCB *hdev_aio_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors, @@ -2309,14 +2248,13 @@ static int hdev_create(const char *filename, QemuOpts *opts, int64_t total_size = 0; bool has_prefix; - /* This function is used by all three protocol block drivers and therefore - * any of these three prefixes may be given. + /* This function is used by both protocol block drivers and therefore either + * of these prefixes may be given. * The return value has to be stored somewhere, otherwise this is an error * due to -Werror=unused-value. */ has_prefix = strstart(filename, "host_device:", &filename) || - strstart(filename, "host_cdrom:" , &filename) || - strstart(filename, "host_floppy:", &filename); + strstart(filename, "host_cdrom:" , &filename); (void)has_prefix; @@ -2396,155 +2334,6 @@ static BlockDriver bdrv_host_device = { #endif }; -#ifdef __linux__ -static void floppy_parse_filename(const char *filename, QDict *options, - Error **errp) -{ - /* The prefix is optional, just as for "file". */ - strstart(filename, "host_floppy:", &filename); - - qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename))); -} - -static int floppy_open(BlockDriverState *bs, QDict *options, int flags, - Error **errp) -{ - BDRVRawState *s = bs->opaque; - Error *local_err = NULL; - int ret; - - s->type = FTYPE_FD; - - /* open will not fail even if no floppy is inserted, so add O_NONBLOCK */ - ret = raw_open_common(bs, options, flags, O_NONBLOCK, &local_err); - if (ret) { - if (local_err) { - error_propagate(errp, local_err); - } - return ret; - } - - /* close fd so that we can reopen it as needed */ - qemu_close(s->fd); - s->fd = -1; - s->fd_media_changed = 1; - - error_report("Host floppy pass-through is deprecated"); - error_printf("Support for it will be removed in a future release.\n"); - return 0; -} - -static int floppy_probe_device(const char *filename) -{ - int fd, ret; - int prio = 0; - struct floppy_struct fdparam; - struct stat st; - - if (strstart(filename, "/dev/fd", NULL) && - !strstart(filename, "/dev/fdset/", NULL) && - !strstart(filename, "/dev/fd/", NULL)) { - prio = 50; - } - - fd = qemu_open(filename, O_RDONLY | O_NONBLOCK); - if (fd < 0) { - goto out; - } - ret = fstat(fd, &st); - if (ret == -1 || !S_ISBLK(st.st_mode)) { - goto outc; - } - - /* Attempt to detect via a floppy specific ioctl */ - ret = ioctl(fd, FDGETPRM, &fdparam); - if (ret >= 0) - prio = 100; - -outc: - qemu_close(fd); -out: - return prio; -} - - -static int floppy_is_inserted(BlockDriverState *bs) -{ - return fd_open(bs) >= 0; -} - -static int floppy_media_changed(BlockDriverState *bs) -{ - BDRVRawState *s = bs->opaque; - int ret; - - /* - * XXX: we do not have a true media changed indication. - * It does not work if the floppy is changed without trying to read it. - */ - fd_open(bs); - ret = s->fd_media_changed; - s->fd_media_changed = 0; - DPRINTF("Floppy changed=%d\n", ret); - return ret; -} - -static void floppy_eject(BlockDriverState *bs, bool eject_flag) -{ - BDRVRawState *s = bs->opaque; - int fd; - - if (s->fd >= 0) { - qemu_close(s->fd); - s->fd = -1; - } - fd = qemu_open(bs->filename, s->open_flags | O_NONBLOCK); - if (fd >= 0) { - if (ioctl(fd, FDEJECT, 0) < 0) - perror("FDEJECT"); - qemu_close(fd); - } -} - -static BlockDriver bdrv_host_floppy = { - .format_name = "host_floppy", - .protocol_name = "host_floppy", - .instance_size = sizeof(BDRVRawState), - .bdrv_needs_filename = true, - .bdrv_probe_device = floppy_probe_device, - .bdrv_parse_filename = floppy_parse_filename, - .bdrv_file_open = floppy_open, - .bdrv_close = raw_close, - .bdrv_reopen_prepare = raw_reopen_prepare, - .bdrv_reopen_commit = raw_reopen_commit, - .bdrv_reopen_abort = raw_reopen_abort, - .bdrv_create = hdev_create, - .create_opts = &raw_create_opts, - - .bdrv_aio_readv = raw_aio_readv, - .bdrv_aio_writev = raw_aio_writev, - .bdrv_aio_flush = raw_aio_flush, - .bdrv_refresh_limits = raw_refresh_limits, - .bdrv_io_plug = raw_aio_plug, - .bdrv_io_unplug = raw_aio_unplug, - .bdrv_flush_io_queue = raw_aio_flush_io_queue, - - .bdrv_truncate = raw_truncate, - .bdrv_getlength = raw_getlength, - .has_variable_length = true, - .bdrv_get_allocated_file_size - = raw_get_allocated_file_size, - - .bdrv_detach_aio_context = raw_detach_aio_context, - .bdrv_attach_aio_context = raw_attach_aio_context, - - /* removable device support */ - .bdrv_is_inserted = floppy_is_inserted, - .bdrv_media_changed = floppy_media_changed, - .bdrv_eject = floppy_eject, -}; -#endif - #if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) static void cdrom_parse_filename(const char *filename, QDict *options, Error **errp) @@ -2822,7 +2611,6 @@ static void bdrv_file_init(void) bdrv_register(&bdrv_file); bdrv_register(&bdrv_host_device); #ifdef __linux__ - bdrv_register(&bdrv_host_floppy); bdrv_register(&bdrv_host_cdrom); #endif #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) diff --git a/qapi/block-core.json b/qapi/block-core.json index bb2189e..c042561 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -215,10 +215,11 @@ # @drv: the name of the block format used to open the backing device. As of # 0.14.0 this can be: 'blkdebug', 'bochs', 'cloop', 'cow', 'dmg', # 'file', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device', -# 'host_floppy', 'http', 'https', 'nbd', 'parallels', 'qcow', +# 'http', 'https', 'nbd', 'parallels', 'qcow', # 'qcow2', 'raw', 'tftp', 'vdi', 'vmdk', 'vpc', 'vvfat' # 2.2: 'archipelago' added, 'cow' dropped # 2.3: 'host_floppy' deprecated +# 2.5: 'host_floppy' dropped # # @backing_file: #optional the name of the backing file (for copy-on-write) # @@ -1373,15 +1374,14 @@ # # Drivers that are supported in block device operations. # -# @host_device, @host_cdrom, @host_floppy: Since 2.1 -# @host_floppy: deprecated since 2.3 +# @host_device, @host_cdrom: Since 2.1 # # Since: 2.0 ## { 'enum': 'BlockdevDriver', 'data': [ 'archipelago', 'blkdebug', 'blkverify', 'bochs', 'cloop', 'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device', - 'host_floppy', 'http', 'https', 'null-aio', 'null-co', 'parallels', + 'http', 'https', 'null-aio', 'null-co', 'parallels', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] } @@ -1816,7 +1816,6 @@ # TODO gluster: Wait for structured options 'host_cdrom': 'BlockdevOptionsFile', 'host_device':'BlockdevOptionsFile', - 'host_floppy':'BlockdevOptionsFile', 'http': 'BlockdevOptionsFile', 'https': 'BlockdevOptionsFile', # TODO iscsi: Wait for structured options -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:23:37 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxVg-0005xk-WC for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:23:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVe-0005su-K1 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxVd-0005n5-TU for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43211) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVd-0005md-Hl; Fri, 18 Sep 2015 11:23:33 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 2AA0A2FAA9F; Fri, 18 Sep 2015 15:23:33 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNV1d023513 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:32 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:41 +0200 Message-Id: <1442589793-7105-7-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 06/38] block: Add blk_is_available() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:35 -0000 blk_is_available() returns true iff the BDS is inserted (which means blk_bs() is not NULL and bdrv_is_inserted() returns true) and if the tray of the guest device is closed. blk_is_inserted() is changed to return true only if blk_bs() is not NULL. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- block/block-backend.c | 7 ++++++- include/sysemu/block-backend.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index 5ad2dd4..cf30cad 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -754,7 +754,12 @@ void blk_invalidate_cache(BlockBackend *blk, Error **errp) bool blk_is_inserted(BlockBackend *blk) { - return bdrv_is_inserted(blk->bs); + return blk->bs && bdrv_is_inserted(blk->bs); +} + +bool blk_is_available(BlockBackend *blk) +{ + return blk_is_inserted(blk) && !blk_dev_is_tray_open(blk); } void blk_lock_medium(BlockBackend *blk, bool locked) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 8f2bf10..1e19d1b 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -131,6 +131,7 @@ int blk_enable_write_cache(BlockBackend *blk); void blk_set_enable_write_cache(BlockBackend *blk, bool wce); void blk_invalidate_cache(BlockBackend *blk, Error **errp); bool blk_is_inserted(BlockBackend *blk); +bool blk_is_available(BlockBackend *blk); void blk_lock_medium(BlockBackend *blk, bool locked); void blk_eject(BlockBackend *blk, bool eject_flag); int blk_get_flags(BlockBackend *blk); -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:23:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxVk-00065o-L2 for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:23:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVc-0005oa-Ek for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxVY-0005k4-E0 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43484) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVY-0005js-4Y; Fri, 18 Sep 2015 11:23:28 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B2D0E8EA4A; Fri, 18 Sep 2015 15:23:27 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNPVL016387 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:26 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:39 +0200 Message-Id: <1442589793-7105-5-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 04/38] iotests: Only create BB if necessary X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:38 -0000 Tests 071 and 081 test giving references in blockdev-add. It is not necessary to create a BlockBackend here, so omit it. While at it, fix up some blockdev-add invocations in the vicinity (s/raw/$IMGFMT/ in 081, drop the format BDS for blkverify's raw child in 071). Signed-off-by: Max Reitz --- tests/qemu-iotests/071 | 54 ++++++++++++++++++++++++++++++++++++++-------- tests/qemu-iotests/071.out | 12 +++++++---- tests/qemu-iotests/081 | 18 +++++++++++++--- tests/qemu-iotests/081.out | 5 +++-- 4 files changed, 71 insertions(+), 18 deletions(-) diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071 index 9eaa49b..92ab991 100755 --- a/tests/qemu-iotests/071 +++ b/tests/qemu-iotests/071 @@ -104,11 +104,20 @@ echo echo "=== Testing blkdebug on existing block device ===" echo -run_qemu -drive "file=$TEST_IMG,format=raw,if=none,id=drive0" <) id 1ZcxVc-0005ob-Eh for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxVb-0005l7-2o for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42567) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVa-0005ky-So; Fri, 18 Sep 2015 11:23:31 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 75B4FAED61; Fri, 18 Sep 2015 15:23:30 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNSbH023479 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:29 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:40 +0200 Message-Id: <1442589793-7105-6-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 05/38] block: Make bdrv_is_inserted() return a bool X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:33 -0000 Make bdrv_is_inserted(), blk_is_inserted(), and the callback BlockDriver.bdrv_is_inserted() return a bool. Suggested-by: Eric Blake Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- block.c | 12 +++++++----- block/block-backend.c | 2 +- block/raw-posix.c | 8 +++----- block/raw_bsd.c | 2 +- include/block/block.h | 2 +- include/block/block_int.h | 2 +- include/sysemu/block-backend.h | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/block.c b/block.c index 51d8c51..4a089e6 100644 --- a/block.c +++ b/block.c @@ -3244,14 +3244,16 @@ void bdrv_invalidate_cache_all(Error **errp) /** * Return TRUE if the media is present */ -int bdrv_is_inserted(BlockDriverState *bs) +bool bdrv_is_inserted(BlockDriverState *bs) { BlockDriver *drv = bs->drv; - if (!drv) - return 0; - if (!drv->bdrv_is_inserted) - return 1; + if (!drv) { + return false; + } + if (!drv->bdrv_is_inserted) { + return true; + } return drv->bdrv_is_inserted(bs); } diff --git a/block/block-backend.c b/block/block-backend.c index c2e8732..5ad2dd4 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -752,7 +752,7 @@ void blk_invalidate_cache(BlockBackend *blk, Error **errp) bdrv_invalidate_cache(blk->bs, errp); } -int blk_is_inserted(BlockBackend *blk) +bool blk_is_inserted(BlockBackend *blk) { return bdrv_is_inserted(blk->bs); } diff --git a/block/raw-posix.c b/block/raw-posix.c index e650c9b..d6e88e3 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -2389,15 +2389,13 @@ out: return prio; } -static int cdrom_is_inserted(BlockDriverState *bs) +static bool cdrom_is_inserted(BlockDriverState *bs) { BDRVRawState *s = bs->opaque; int ret; ret = ioctl(s->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT); - if (ret == CDS_DISC_OK) - return 1; - return 0; + return ret == CDS_DISC_OK; } static void cdrom_eject(BlockDriverState *bs, bool eject_flag) @@ -2523,7 +2521,7 @@ static int cdrom_reopen(BlockDriverState *bs) return 0; } -static int cdrom_is_inserted(BlockDriverState *bs) +static bool cdrom_is_inserted(BlockDriverState *bs) { return raw_getlength(bs) > 0; } diff --git a/block/raw_bsd.c b/block/raw_bsd.c index e3d2d04..d718583 100644 --- a/block/raw_bsd.c +++ b/block/raw_bsd.c @@ -154,7 +154,7 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset) return bdrv_truncate(bs->file, offset); } -static int raw_is_inserted(BlockDriverState *bs) +static bool raw_is_inserted(BlockDriverState *bs) { return bdrv_is_inserted(bs->file); } diff --git a/include/block/block.h b/include/block/block.h index ef67353..c9cc62b 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -397,7 +397,7 @@ int bdrv_is_read_only(BlockDriverState *bs); int bdrv_is_sg(BlockDriverState *bs); int bdrv_enable_write_cache(BlockDriverState *bs); void bdrv_set_enable_write_cache(BlockDriverState *bs, bool wce); -int bdrv_is_inserted(BlockDriverState *bs); +bool bdrv_is_inserted(BlockDriverState *bs); int bdrv_media_changed(BlockDriverState *bs); void bdrv_lock_medium(BlockDriverState *bs, bool locked); void bdrv_eject(BlockDriverState *bs, bool eject_flag); diff --git a/include/block/block_int.h b/include/block/block_int.h index 14ad4c3..f3b3354 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -213,7 +213,7 @@ struct BlockDriver { const char *backing_file, const char *backing_fmt); /* removable device specific */ - int (*bdrv_is_inserted)(BlockDriverState *bs); + bool (*bdrv_is_inserted)(BlockDriverState *bs); int (*bdrv_media_changed)(BlockDriverState *bs); void (*bdrv_eject)(BlockDriverState *bs, bool eject_flag); void (*bdrv_lock_medium)(BlockDriverState *bs, bool locked); diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 8fc960f..8f2bf10 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -130,7 +130,7 @@ int blk_is_sg(BlockBackend *blk); int blk_enable_write_cache(BlockBackend *blk); void blk_set_enable_write_cache(BlockBackend *blk, bool wce); void blk_invalidate_cache(BlockBackend *blk, Error **errp); -int blk_is_inserted(BlockBackend *blk); +bool blk_is_inserted(BlockBackend *blk); void blk_lock_medium(BlockBackend *blk, bool locked); void blk_eject(BlockBackend *blk, bool eject_flag); int blk_get_flags(BlockBackend *blk); -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:23:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxVr-0006IX-Hd for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:23:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVn-0006Aa-4X for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxVl-0005rc-Vj for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVl-0005rT-RB; Fri, 18 Sep 2015 11:23:41 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 752258E6E3; Fri, 18 Sep 2015 15:23:41 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNd3q018730 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:40 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:44 +0200 Message-Id: <1442589793-7105-10-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 09/38] block: Invoke change media CB before NULLing drv X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:44 -0000 In order to handle host device passthrough, some guest device models may call blk_is_inserted() to check whether the medium is inserted on the host, when checking the guest tray status. This tray status is inquired by blk_dev_change_media_cb(); because bdrv_is_inserted() (invoked by blk_is_inserted()) always returns 0 for BDS with drv set to NULL, blk_dev_change_media_cb() should therefore be called before drv is set to NULL. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- block.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index c4fa299..661c621 100644 --- a/block.c +++ b/block.c @@ -1916,6 +1916,10 @@ void bdrv_close(BlockDriverState *bs) bdrv_drain(bs); /* in case flush left pending I/O */ notifier_list_notify(&bs->close_notifiers, bs); + if (bs->blk) { + blk_dev_change_media_cb(bs->blk, false); + } + if (bs->drv) { BdrvChild *child, *next; @@ -1958,10 +1962,6 @@ void bdrv_close(BlockDriverState *bs) } } - if (bs->blk) { - blk_dev_change_media_cb(bs->blk, false); - } - /*throttling disk I/O limits*/ if (bs->io_limits_enabled) { bdrv_io_limits_disable(bs); -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:23:41 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxVl-00066Q-0T for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:23:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVh-0005ya-A5 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxVg-0005oJ-JR for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42599) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVg-0005o8-EB; Fri, 18 Sep 2015 11:23:36 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id EB604A19B5; Fri, 18 Sep 2015 15:23:35 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNXSw018665 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:35 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:42 +0200 Message-Id: <1442589793-7105-8-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 07/38] block: Make bdrv_is_inserted() recursive X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:38 -0000 If bdrv_is_inserted() is called on the top level BDS, it should make sure all nodes in the BDS tree are actually inserted. Signed-off-by: Max Reitz --- block.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 4a089e6..c4fa299 100644 --- a/block.c +++ b/block.c @@ -3247,14 +3247,20 @@ void bdrv_invalidate_cache_all(Error **errp) bool bdrv_is_inserted(BlockDriverState *bs) { BlockDriver *drv = bs->drv; + BdrvChild *child; if (!drv) { return false; } - if (!drv->bdrv_is_inserted) { - return true; + if (drv->bdrv_is_inserted) { + return drv->bdrv_is_inserted(bs); } - return drv->bdrv_is_inserted(bs); + QLIST_FOREACH(child, &bs->children, next) { + if (!bdrv_is_inserted(child->bs)) { + return false; + } + } + return true; } /** -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:23:50 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxVu-0006Nv-IB for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:23:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVp-0006F7-ST for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxVo-0005tR-Qx for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57278) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVo-0005t4-KH; Fri, 18 Sep 2015 11:23:44 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 4502D8C1AA; Fri, 18 Sep 2015 15:23:44 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNgNK023609 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:43 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:45 +0200 Message-Id: <1442589793-7105-11-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 10/38] hw/block/fdc: Implement tray status X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:47 -0000 The tray of an FDD is open iff there is no medium inserted (there are only two states for an FDD: "medium inserted" or "no medium inserted"). Signed-off-by: Max Reitz --- hw/block/fdc.c | 20 ++++++++++++++++---- tests/fdc-test.c | 4 +--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 6686a72..4292ece 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -192,6 +192,8 @@ typedef struct FDrive { uint8_t ro; /* Is read-only */ uint8_t media_changed; /* Is media changed */ uint8_t media_rate; /* Data rate of medium */ + + bool media_inserted; /* Is there a medium in the tray */ } FDrive; static void fd_init(FDrive *drv) @@ -261,7 +263,7 @@ static int fd_seek(FDrive *drv, uint8_t head, uint8_t track, uint8_t sect, #endif drv->head = head; if (drv->track != track) { - if (drv->blk != NULL && blk_is_inserted(drv->blk)) { + if (drv->media_inserted) { drv->media_changed = 0; } ret = 1; @@ -270,7 +272,7 @@ static int fd_seek(FDrive *drv, uint8_t head, uint8_t track, uint8_t sect, drv->sect = sect; } - if (drv->blk == NULL || !blk_is_inserted(drv->blk)) { + if (!drv->media_inserted) { ret = 2; } @@ -296,7 +298,7 @@ static void fd_revalidate(FDrive *drv) ro = blk_is_read_only(drv->blk); pick_geometry(drv->blk, &nb_heads, &max_track, &last_sect, drv->drive, &drive, &rate); - if (!blk_is_inserted(drv->blk)) { + if (!drv->media_inserted) { FLOPPY_DPRINTF("No disk in drive\n"); } else { FLOPPY_DPRINTF("Floppy disk (%d h %d t %d s) %s\n", nb_heads, @@ -692,7 +694,7 @@ static bool fdrive_media_changed_needed(void *opaque) { FDrive *drive = opaque; - return (drive->blk != NULL && drive->media_changed != 1); + return (drive->media_inserted && drive->media_changed != 1); } static const VMStateDescription vmstate_fdrive_media_changed = { @@ -2184,12 +2186,21 @@ static void fdctrl_change_cb(void *opaque, bool load) { FDrive *drive = opaque; + drive->media_inserted = load && drive->blk && blk_is_inserted(drive->blk); + drive->media_changed = 1; fd_revalidate(drive); } +static bool fdctrl_is_tray_open(void *opaque) +{ + FDrive *drive = opaque; + return !drive->media_inserted; +} + static const BlockDevOps fdctrl_block_ops = { .change_media_cb = fdctrl_change_cb, + .is_tray_open = fdctrl_is_tray_open, }; /* Init functions */ @@ -2217,6 +2228,7 @@ static void fdctrl_connect_drives(FDCtrl *fdctrl, Error **errp) fdctrl_change_cb(drive, 0); if (drive->blk) { blk_set_dev_ops(drive->blk, &fdctrl_block_ops, drive); + drive->media_inserted = blk_is_inserted(drive->blk); } } } diff --git a/tests/fdc-test.c b/tests/fdc-test.c index 416394f..b5a4696 100644 --- a/tests/fdc-test.c +++ b/tests/fdc-test.c @@ -304,9 +304,7 @@ static void test_media_insert(void) qmp_discard_response("{'execute':'change', 'arguments':{" " 'device':'floppy0', 'target': %s, 'arg': 'raw' }}", test_image); - qmp_discard_response(""); /* ignore event - (FIXME open -> open transition?!) */ - qmp_discard_response(""); /* ignore event */ + qmp_discard_response(""); /* ignore event (open -> close) */ dir = inb(FLOPPY_BASE + reg_dir); assert_bit_set(dir, DSKCHG); -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:23:52 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxVw-0006Rc-5e for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:23:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVs-0006KD-4l for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxVr-0005uG-FS for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVr-0005uA-BR; Fri, 18 Sep 2015 11:23:47 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id F1E448E6EC; Fri, 18 Sep 2015 15:23:46 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNiim018417 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:46 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:46 +0200 Message-Id: <1442589793-7105-12-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 11/38] hw/usb-storage: Check whether BB is inserted X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:49 -0000 Only call bdrv_add_key() on the BlockDriverState if it is not NULL. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- hw/usb/dev-storage.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 9a4e7dc..597d8fd 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -613,20 +613,22 @@ static void usb_msd_realize_storage(USBDevice *dev, Error **errp) return; } - bdrv_add_key(blk_bs(blk), NULL, &err); - if (err) { - if (monitor_cur_is_qmp()) { - error_propagate(errp, err); - return; - } - error_free(err); - err = NULL; - if (cur_mon) { - monitor_read_bdrv_key_start(cur_mon, blk_bs(blk), - usb_msd_password_cb, s); - s->dev.auto_attach = 0; - } else { - autostart = 0; + if (blk_bs(blk)) { + bdrv_add_key(blk_bs(blk), NULL, &err); + if (err) { + if (monitor_cur_is_qmp()) { + error_propagate(errp, err); + return; + } + error_free(err); + err = NULL; + if (cur_mon) { + monitor_read_bdrv_key_start(cur_mon, blk_bs(blk), + usb_msd_password_cb, s); + s->dev.auto_attach = 0; + } else { + autostart = 0; + } } } -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:23:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxVr-0006J4-NM for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:23:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVn-0006AS-3b for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxVj-0005qa-C5 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVj-0005pR-0o; Fri, 18 Sep 2015 11:23:39 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id A5E95C0B2E01; Fri, 18 Sep 2015 15:23:38 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNa57023550 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:38 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:43 +0200 Message-Id: <1442589793-7105-9-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 08/38] block/raw_bsd: Drop raw_is_inserted() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:44 -0000 With the new automatically-recursive implementation of bdrv_is_inserted() checking by default whether all the children of a BDS are inserted, we can drop raw's own implementation. Signed-off-by: Max Reitz --- block/raw_bsd.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/block/raw_bsd.c b/block/raw_bsd.c index d718583..891a1fa 100644 --- a/block/raw_bsd.c +++ b/block/raw_bsd.c @@ -154,11 +154,6 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset) return bdrv_truncate(bs->file, offset); } -static bool raw_is_inserted(BlockDriverState *bs) -{ - return bdrv_is_inserted(bs->file); -} - static int raw_media_changed(BlockDriverState *bs) { return bdrv_media_changed(bs->file); @@ -264,7 +259,6 @@ BlockDriver bdrv_raw = { .bdrv_refresh_limits = &raw_refresh_limits, .bdrv_probe_blocksizes = &raw_probe_blocksizes, .bdrv_probe_geometry = &raw_probe_geometry, - .bdrv_is_inserted = &raw_is_inserted, .bdrv_media_changed = &raw_media_changed, .bdrv_eject = &raw_eject, .bdrv_lock_medium = &raw_lock_medium, -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:23:57 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxW1-0006Yq-8Q for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:23:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVy-0006Sk-0U for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxVu-0005vP-E8 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVu-0005vB-9D; Fri, 18 Sep 2015 11:23:50 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id E757A83F8E; Fri, 18 Sep 2015 15:23:49 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNlkl018800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:49 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:47 +0200 Message-Id: <1442589793-7105-13-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 12/38] block: Fix BB AIOCB AioContext without BDS X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:55 -0000 Fix the BlockBackend's AIOCB AioContext for aborting AIO in case there is no BDS. If there is no implementation of AIOCBInfo::get_aio_context() the AioContext is derived from the BDS the AIOCB belongs to. If that BDS is NULL (because it has been removed from the BB) this will not work. This patch makes blk_get_aio_context() fall back to the main loop context if the BDS pointer is NULL and implements AIOCBInfo::get_aio_context() (blk_aiocb_get_aio_context()) which invokes blk_get_aio_context(). Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- block/block-backend.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index cf30cad..501130b 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -18,6 +18,8 @@ /* Number of coroutines to reserve per attached device model */ #define COROUTINE_POOL_RESERVATION 64 +static AioContext *blk_aiocb_get_aio_context(BlockAIOCB *acb); + struct BlockBackend { char *name; int refcnt; @@ -34,10 +36,12 @@ struct BlockBackend { typedef struct BlockBackendAIOCB { BlockAIOCB common; QEMUBH *bh; + BlockBackend *blk; int ret; } BlockBackendAIOCB; static const AIOCBInfo block_backend_aiocb_info = { + .get_aio_context = blk_aiocb_get_aio_context, .aiocb_size = sizeof(BlockBackendAIOCB), }; @@ -541,6 +545,7 @@ static BlockAIOCB *abort_aio_request(BlockBackend *blk, BlockCompletionFunc *cb, QEMUBH *bh; acb = blk_aio_get(&block_backend_aiocb_info, blk, cb, opaque); + acb->blk = blk; acb->ret = ret; bh = aio_bh_new(blk_get_aio_context(blk), error_callback_bh, acb); @@ -814,7 +819,17 @@ void blk_op_unblock_all(BlockBackend *blk, Error *reason) AioContext *blk_get_aio_context(BlockBackend *blk) { - return bdrv_get_aio_context(blk->bs); + if (blk->bs) { + return bdrv_get_aio_context(blk->bs); + } else { + return qemu_get_aio_context(); + } +} + +static AioContext *blk_aiocb_get_aio_context(BlockAIOCB *acb) +{ + BlockBackendAIOCB *blk_acb = DO_UPCAST(BlockBackendAIOCB, common, acb); + return blk_get_aio_context(blk_acb->blk); } void blk_set_aio_context(BlockBackend *blk, AioContext *new_context) -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxW6-0006kH-DC for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38110) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxW1-0006Z0-A2 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxW0-0005wt-3c for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55770) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVz-0005wh-T6; Fri, 18 Sep 2015 11:23:56 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 8816AC0B91BE; Fri, 18 Sep 2015 15:23:55 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNrBf023698 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:54 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:49 +0200 Message-Id: <1442589793-7105-15-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 14/38] block: Remove wr_highest_sector from BlockAcctStats X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:58 -0000 BlockAcctStats contains statistics about the data transferred from and to the device; wr_highest_sector does not fit in with the rest. Furthermore, those statistics are supposed to be specific for a certain device and not necessarily for a BDS (see the comment above bdrv_get_stats()); on the other hand, wr_highest_sector may be a rather important information to know for each BDS. When BlockAcctStats is finally removed from the BDS, we will want to keep wr_highest_sector in the BDS. Finally, wr_highest_sector is renamed to wr_highest_offset and given the appropriate meaning. Externally, it is represented as an offset so there is no point in doing something different internally. Its definition is changed to match that in qapi/block-core.json which is "the offset after the greatest byte written to". Doing so should not cause any harm since if external programs tried to calculate the volume usage by (wr_highest_offset + 512) / volume_size, after this patch they will just assume the volume to be full slightly earlier than before. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- block/accounting.c | 8 -------- block/io.c | 4 +++- block/qapi.c | 4 ++-- include/block/accounting.h | 3 --- include/block/block_int.h | 3 +++ qmp-commands.hx | 4 ++-- 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/block/accounting.c b/block/accounting.c index 01d594f..a423560 100644 --- a/block/accounting.c +++ b/block/accounting.c @@ -47,14 +47,6 @@ void block_acct_done(BlockAcctStats *stats, BlockAcctCookie *cookie) } -void block_acct_highest_sector(BlockAcctStats *stats, int64_t sector_num, - unsigned int nb_sectors) -{ - if (stats->wr_highest_sector < sector_num + nb_sectors - 1) { - stats->wr_highest_sector = sector_num + nb_sectors - 1; - } -} - void block_acct_merge_done(BlockAcctStats *stats, enum BlockAcctType type, int num_requests) { diff --git a/block/io.c b/block/io.c index d4bc83b..21cc82a 100644 --- a/block/io.c +++ b/block/io.c @@ -1141,7 +1141,9 @@ static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs, bdrv_set_dirty(bs, sector_num, nb_sectors); - block_acct_highest_sector(&bs->stats, sector_num, nb_sectors); + if (bs->wr_highest_offset < offset + bytes) { + bs->wr_highest_offset = offset + bytes; + } if (ret >= 0) { bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors); diff --git a/block/qapi.c b/block/qapi.c index 2ce5097..d3cbc80 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -350,13 +350,13 @@ static BlockStats *bdrv_query_stats(const BlockDriverState *bs, s->stats->wr_operations = bs->stats.nr_ops[BLOCK_ACCT_WRITE]; s->stats->rd_merged = bs->stats.merged[BLOCK_ACCT_READ]; s->stats->wr_merged = bs->stats.merged[BLOCK_ACCT_WRITE]; - s->stats->wr_highest_offset = - bs->stats.wr_highest_sector * BDRV_SECTOR_SIZE; s->stats->flush_operations = bs->stats.nr_ops[BLOCK_ACCT_FLUSH]; s->stats->wr_total_time_ns = bs->stats.total_time_ns[BLOCK_ACCT_WRITE]; s->stats->rd_total_time_ns = bs->stats.total_time_ns[BLOCK_ACCT_READ]; s->stats->flush_total_time_ns = bs->stats.total_time_ns[BLOCK_ACCT_FLUSH]; + s->stats->wr_highest_offset = bs->wr_highest_offset; + if (bs->file) { s->has_parent = true; s->parent = bdrv_query_stats(bs->file, query_backing); diff --git a/include/block/accounting.h b/include/block/accounting.h index 4c406cf..66637cd 100644 --- a/include/block/accounting.h +++ b/include/block/accounting.h @@ -40,7 +40,6 @@ typedef struct BlockAcctStats { uint64_t nr_ops[BLOCK_MAX_IOTYPE]; uint64_t total_time_ns[BLOCK_MAX_IOTYPE]; uint64_t merged[BLOCK_MAX_IOTYPE]; - uint64_t wr_highest_sector; } BlockAcctStats; typedef struct BlockAcctCookie { @@ -52,8 +51,6 @@ typedef struct BlockAcctCookie { void block_acct_start(BlockAcctStats *stats, BlockAcctCookie *cookie, int64_t bytes, enum BlockAcctType type); void block_acct_done(BlockAcctStats *stats, BlockAcctCookie *cookie); -void block_acct_highest_sector(BlockAcctStats *stats, int64_t sector_num, - unsigned int nb_sectors); void block_acct_merge_done(BlockAcctStats *stats, enum BlockAcctType type, int num_requests); diff --git a/include/block/block_int.h b/include/block/block_int.h index b7e1e16..67e05ac 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -403,6 +403,9 @@ struct BlockDriverState { /* I/O stats (display with "info blockstats"). */ BlockAcctStats stats; + /* Offset after the highest byte written to */ + uint64_t wr_highest_offset; + /* I/O Limits */ BlockLimits bl; diff --git a/qmp-commands.hx b/qmp-commands.hx index 9848fd8..8343289 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2481,8 +2481,8 @@ Each json-object contain the following: - "wr_total_time_ns": total time spend on writes in nano-seconds (json-int) - "rd_total_time_ns": total time spend on reads in nano-seconds (json-int) - "flush_total_time_ns": total time spend on cache flushes in nano-seconds (json-int) - - "wr_highest_offset": Highest offset of a sector written since the - BlockDriverState has been opened (json-int) + - "wr_highest_offset": The offset after the greatest byte written to the + BlockDriverState since it has been opened (json-int) - "rd_merged": number of read requests that have been merged into another request (json-int) - "wr_merged": number of write requests that have been merged into -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:23:57 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxW1-0006Zd-Gm for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:23:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVy-0006T3-3b for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxVx-0005vt-5t for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:23:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxVw-0005vm-Vg; Fri, 18 Sep 2015 11:23:53 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 9A1E3A9A; Fri, 18 Sep 2015 15:23:52 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNoNZ018455 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:51 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:48 +0200 Message-Id: <1442589793-7105-14-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 13/38] block: Move guest_block_size into BlockBackend X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:23:55 -0000 guest_block_size is a guest device property so it should be moved into the interface between block layer and guest devices, which is the BlockBackend. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- block.c | 7 ------- block/block-backend.c | 7 +++++-- include/block/block.h | 1 - include/block/block_int.h | 3 --- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/block.c b/block.c index 661c621..55357c4 100644 --- a/block.c +++ b/block.c @@ -852,7 +852,6 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file, goto fail_opts; } - bs->guest_block_size = 512; bs->request_alignment = 512; bs->zero_beyond_eof = true; open_flags = bdrv_open_flags(bs, flags); @@ -2021,7 +2020,6 @@ static void bdrv_move_feature_fields(BlockDriverState *bs_dest, /* move some fields that need to stay attached to the device */ /* dev info */ - bs_dest->guest_block_size = bs_src->guest_block_size; bs_dest->copy_on_read = bs_src->copy_on_read; bs_dest->enable_write_cache = bs_src->enable_write_cache; @@ -3311,11 +3309,6 @@ void bdrv_lock_medium(BlockDriverState *bs, bool locked) } } -void bdrv_set_guest_block_size(BlockDriverState *bs, int align) -{ - bs->guest_block_size = align; -} - BdrvDirtyBitmap *bdrv_find_dirty_bitmap(BlockDriverState *bs, const char *name) { BdrvDirtyBitmap *bm; diff --git a/block/block-backend.c b/block/block-backend.c index 501130b..ff862ad 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -31,6 +31,9 @@ struct BlockBackend { /* TODO change to DeviceState when all users are qdevified */ const BlockDevOps *dev_ops; void *dev_opaque; + + /* the block size for which the guest device expects atomicity */ + int guest_block_size; }; typedef struct BlockBackendAIOCB { @@ -334,7 +337,7 @@ void blk_detach_dev(BlockBackend *blk, void *dev) blk->dev = NULL; blk->dev_ops = NULL; blk->dev_opaque = NULL; - bdrv_set_guest_block_size(blk->bs, 512); + blk->guest_block_size = 512; blk_unref(blk); } @@ -789,7 +792,7 @@ int blk_get_max_transfer_length(BlockBackend *blk) void blk_set_guest_block_size(BlockBackend *blk, int align) { - bdrv_set_guest_block_size(blk->bs, align); + blk->guest_block_size = align; } void *blk_blockalign(BlockBackend *blk, size_t size) diff --git a/include/block/block.h b/include/block/block.h index c9cc62b..3e818f4 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -464,7 +464,6 @@ void bdrv_img_create(const char *filename, const char *fmt, size_t bdrv_min_mem_align(BlockDriverState *bs); /* Returns optimal alignment in bytes for bounce buffer */ size_t bdrv_opt_mem_align(BlockDriverState *bs); -void bdrv_set_guest_block_size(BlockDriverState *bs, int align); void *qemu_blockalign(BlockDriverState *bs, size_t size); void *qemu_blockalign0(BlockDriverState *bs, size_t size); void *qemu_try_blockalign(BlockDriverState *bs, size_t size); diff --git a/include/block/block_int.h b/include/block/block_int.h index f3b3354..b7e1e16 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -412,9 +412,6 @@ struct BlockDriverState { /* Alignment requirement for offset/length of I/O requests */ unsigned int request_alignment; - /* the block size for which the guest device expects atomicity */ - int guest_block_size; - /* do we need to tell the quest if we have a volatile write cache? */ int enable_write_cache; -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:06 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWA-0006qz-71 for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxW7-0006mp-Vu for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxW2-0005xp-WD for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42703) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxW2-0005xk-Pv; Fri, 18 Sep 2015 11:23:58 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 665D7BC90F; Fri, 18 Sep 2015 15:23:58 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNuoC016650 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:23:57 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:50 +0200 Message-Id: <1442589793-7105-16-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 15/38] block: Move BlockAcctStats into BlockBackend X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:05 -0000 As the comment above bdrv_get_stats() says, BlockAcctStats is something which belongs to the device instead of each BlockDriverState. This patch therefore moves it into the BlockBackend. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- block.c | 11 ----------- block/block-backend.c | 5 ++++- block/io.c | 6 +++++- block/qapi.c | 24 ++++++++++++++---------- include/block/block.h | 2 -- include/block/block_int.h | 3 --- 6 files changed, 23 insertions(+), 28 deletions(-) diff --git a/block.c b/block.c index 55357c4..f81ef23 100644 --- a/block.c +++ b/block.c @@ -4256,14 +4256,3 @@ void bdrv_refresh_filename(BlockDriverState *bs) QDECREF(json); } } - -/* This accessor function purpose is to allow the device models to access the - * BlockAcctStats structure embedded inside a BlockDriverState without being - * aware of the BlockDriverState structure layout. - * It will go away when the BlockAcctStats structure will be moved inside - * the device models. - */ -BlockAcctStats *bdrv_get_stats(BlockDriverState *bs) -{ - return &bs->stats; -} diff --git a/block/block-backend.c b/block/block-backend.c index ff862ad..310ca50 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -34,6 +34,9 @@ struct BlockBackend { /* the block size for which the guest device expects atomicity */ int guest_block_size; + + /* I/O stats (display with "info blockstats"). */ + BlockAcctStats stats; }; typedef struct BlockBackendAIOCB { @@ -875,7 +878,7 @@ void blk_io_unplug(BlockBackend *blk) BlockAcctStats *blk_get_stats(BlockBackend *blk) { - return bdrv_get_stats(blk->bs); + return &blk->stats; } void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk, diff --git a/block/io.c b/block/io.c index 21cc82a..08b50c0 100644 --- a/block/io.c +++ b/block/io.c @@ -23,6 +23,7 @@ */ #include "trace.h" +#include "sysemu/block-backend.h" #include "block/blockjob.h" #include "block/block_int.h" #include "block/throttle-groups.h" @@ -1895,7 +1896,10 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs, } } - block_acct_merge_done(&bs->stats, BLOCK_ACCT_WRITE, num_reqs - outidx - 1); + if (bs->blk) { + block_acct_merge_done(blk_get_stats(bs->blk), BLOCK_ACCT_WRITE, + num_reqs - outidx - 1); + } return outidx + 1; } diff --git a/block/qapi.c b/block/qapi.c index d3cbc80..2d1ef87 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -344,16 +344,20 @@ static BlockStats *bdrv_query_stats(const BlockDriverState *bs, } s->stats = g_malloc0(sizeof(*s->stats)); - s->stats->rd_bytes = bs->stats.nr_bytes[BLOCK_ACCT_READ]; - s->stats->wr_bytes = bs->stats.nr_bytes[BLOCK_ACCT_WRITE]; - s->stats->rd_operations = bs->stats.nr_ops[BLOCK_ACCT_READ]; - s->stats->wr_operations = bs->stats.nr_ops[BLOCK_ACCT_WRITE]; - s->stats->rd_merged = bs->stats.merged[BLOCK_ACCT_READ]; - s->stats->wr_merged = bs->stats.merged[BLOCK_ACCT_WRITE]; - s->stats->flush_operations = bs->stats.nr_ops[BLOCK_ACCT_FLUSH]; - s->stats->wr_total_time_ns = bs->stats.total_time_ns[BLOCK_ACCT_WRITE]; - s->stats->rd_total_time_ns = bs->stats.total_time_ns[BLOCK_ACCT_READ]; - s->stats->flush_total_time_ns = bs->stats.total_time_ns[BLOCK_ACCT_FLUSH]; + if (bs->blk) { + BlockAcctStats *stats = blk_get_stats(bs->blk); + + s->stats->rd_bytes = stats->nr_bytes[BLOCK_ACCT_READ]; + s->stats->wr_bytes = stats->nr_bytes[BLOCK_ACCT_WRITE]; + s->stats->rd_operations = stats->nr_ops[BLOCK_ACCT_READ]; + s->stats->wr_operations = stats->nr_ops[BLOCK_ACCT_WRITE]; + s->stats->rd_merged = stats->merged[BLOCK_ACCT_READ]; + s->stats->wr_merged = stats->merged[BLOCK_ACCT_WRITE]; + s->stats->flush_operations = stats->nr_ops[BLOCK_ACCT_FLUSH]; + s->stats->wr_total_time_ns = stats->total_time_ns[BLOCK_ACCT_WRITE]; + s->stats->rd_total_time_ns = stats->total_time_ns[BLOCK_ACCT_READ]; + s->stats->flush_total_time_ns = stats->total_time_ns[BLOCK_ACCT_FLUSH]; + } s->stats->wr_highest_offset = bs->wr_highest_offset; diff --git a/include/block/block.h b/include/block/block.h index 3e818f4..960eb98 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -613,6 +613,4 @@ void bdrv_io_plug(BlockDriverState *bs); void bdrv_io_unplug(BlockDriverState *bs); void bdrv_flush_io_queue(BlockDriverState *bs); -BlockAcctStats *bdrv_get_stats(BlockDriverState *bs); - #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index 67e05ac..0376508 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -400,9 +400,6 @@ struct BlockDriverState { unsigned pending_reqs[2]; QLIST_ENTRY(BlockDriverState) round_robin; - /* I/O stats (display with "info blockstats"). */ - BlockAcctStats stats; - /* Offset after the highest byte written to */ uint64_t wr_highest_offset; -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:10 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWE-0006z5-Gw for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWA-0006sL-Oa for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxW9-000607-Nu for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52407) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxW9-0005zz-Gl; Fri, 18 Sep 2015 11:24:05 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 286748E707; Fri, 18 Sep 2015 15:24:05 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFO27p023854 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:04 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:52 +0200 Message-Id: <1442589793-7105-18-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 17/38] block: Add BlockBackendRootState X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:08 -0000 This structure will store some of the state of the root BDS if the BDS tree is removed, so that state can be restored once a new BDS tree is inserted. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block/block-backend.c | 37 +++++++++++++++++++++++++++++++++++++ include/block/block_int.h | 10 ++++++++++ include/qemu/typedefs.h | 1 + include/sysemu/block-backend.h | 2 ++ 4 files changed, 50 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index 1f2cd9b..9590be5 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -13,6 +13,7 @@ #include "sysemu/block-backend.h" #include "block/block_int.h" #include "block/blockjob.h" +#include "block/throttle-groups.h" #include "sysemu/blockdev.h" #include "sysemu/sysemu.h" #include "qapi-event.h" @@ -37,6 +38,10 @@ struct BlockBackend { /* the block size for which the guest device expects atomicity */ int guest_block_size; + /* If the BDS tree is removed, some of its options are stored here (which + * can be used to restore those options in the new BDS on insert) */ + BlockBackendRootState root_state; + /* I/O stats (display with "info blockstats"). */ BlockAcctStats stats; @@ -161,6 +166,7 @@ static void blk_delete(BlockBackend *blk) bdrv_unref(blk->bs); blk->bs = NULL; } + g_free(blk->root_state.throttle_group_name); /* Avoid double-remove after blk_hide_on_behalf_of_hmp_drive_del() */ if (blk->name[0]) { QTAILQ_REMOVE(&blk_backends, blk, link); @@ -1050,3 +1056,34 @@ int blk_probe_geometry(BlockBackend *blk, HDGeometry *geo) { return bdrv_probe_geometry(blk->bs, geo); } + +/* + * Updates the BlockBackendRootState object with data from the currently + * attached BlockDriverState. + */ +void blk_update_root_state(BlockBackend *blk) +{ + assert(blk->bs); + + blk->root_state.open_flags = blk->bs->open_flags; + blk->root_state.read_only = blk->bs->read_only; + blk->root_state.detect_zeroes = blk->bs->detect_zeroes; + + blk->root_state.io_limits_enabled = blk->bs->io_limits_enabled; + + g_free(blk->root_state.throttle_group_name); + if (blk->bs->throttle_state) { + throttle_get_config(blk->bs->throttle_state, + &blk->root_state.throttle_config); + blk->root_state.throttle_group_name = + g_strdup(throttle_group_get_name(blk->bs)); + } else { + blk->root_state.throttle_config = (ThrottleConfig){}; + blk->root_state.throttle_group_name = NULL; + } +} + +BlockBackendRootState *blk_get_root_state(BlockBackend *blk) +{ + return &blk->root_state; +} diff --git a/include/block/block_int.h b/include/block/block_int.h index bd35570..ca1eefa 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -449,6 +449,16 @@ struct BlockDriverState { NotifierWithReturn write_threshold_notifier; }; +struct BlockBackendRootState { + int open_flags; + bool read_only; + BlockdevDetectZeroesOptions detect_zeroes; + + bool io_limits_enabled; + ThrottleConfig throttle_config; + char *throttle_group_name; +}; + /* Essential block drivers which must always be statically linked into qemu, and * which therefore can be accessed without using bdrv_find_format() */ diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 97ac727..5105cc7 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -11,6 +11,7 @@ typedef struct AddressSpace AddressSpace; typedef struct AioContext AioContext; typedef struct AudioState AudioState; typedef struct BlockBackend BlockBackend; +typedef struct BlockBackendRootState BlockBackendRootState; typedef struct BlockDriverState BlockDriverState; typedef struct BusClass BusClass; typedef struct BusState BusState; diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index eafcef0..52e35a1 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -163,6 +163,8 @@ void blk_add_close_notifier(BlockBackend *blk, Notifier *notify); void blk_io_plug(BlockBackend *blk); void blk_io_unplug(BlockBackend *blk); BlockAcctStats *blk_get_stats(BlockBackend *blk); +BlockBackendRootState *blk_get_root_state(BlockBackend *blk); +void blk_update_root_state(BlockBackend *blk); void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk, BlockCompletionFunc *cb, void *opaque); -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:11 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWF-00070M-0v for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWC-0006vy-Pd for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWC-00060r-4u for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42758) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWC-00060Z-0G; Fri, 18 Sep 2015 11:24:08 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id A425991C16; Fri, 18 Sep 2015 15:24:07 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFO5XN023795 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:07 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:53 +0200 Message-Id: <1442589793-7105-19-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 18/38] block: Make some BB functions fall back to BBRS X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:09 -0000 If there is no BDS tree attached to a BlockBackend, functions that can do so should fall back to the BlockBackendRootState structure (which are blk_is_read_only() and blk_get_flags(), because the read-only status and the "open flags" are part of the BBRS). Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block/block-backend.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 9590be5..417374f 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -852,7 +852,11 @@ void blk_error_action(BlockBackend *blk, BlockErrorAction action, int blk_is_read_only(BlockBackend *blk) { - return bdrv_is_read_only(blk->bs); + if (blk->bs) { + return bdrv_is_read_only(blk->bs); + } else { + return blk->root_state.read_only; + } } int blk_is_sg(BlockBackend *blk) @@ -897,7 +901,11 @@ void blk_eject(BlockBackend *blk, bool eject_flag) int blk_get_flags(BlockBackend *blk) { - return bdrv_get_flags(blk->bs); + if (blk->bs) { + return bdrv_get_flags(blk->bs); + } else { + return blk->root_state.open_flags; + } } int blk_get_max_transfer_length(BlockBackend *blk) -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:10 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWE-0006ze-Mo for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxW9-0006p8-F8 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxW6-0005yb-U2 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42729) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxW6-0005yS-I9; Fri, 18 Sep 2015 11:24:02 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 2F1D7A35B9; Fri, 18 Sep 2015 15:24:02 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFNxcW016685 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:00 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:51 +0200 Message-Id: <1442589793-7105-17-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 16/38] block: Move I/O status and error actions into BB X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:08 -0000 These options are only relevant for the user of a whole BDS tree (like a guest device or a block job) and should thus be moved into the BlockBackend. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block.c | 125 ----------------------------------------- block/backup.c | 17 ++++-- block/block-backend.c | 116 ++++++++++++++++++++++++++++++++++++-- block/commit.c | 3 +- block/mirror.c | 17 ++++-- block/qapi.c | 4 +- block/stream.c | 3 +- blockdev.c | 6 +- blockjob.c | 5 +- include/block/block.h | 11 ---- include/block/block_int.h | 6 -- include/sysemu/block-backend.h | 7 +++ qmp.c | 6 +- 13 files changed, 158 insertions(+), 168 deletions(-) diff --git a/block.c b/block.c index f81ef23..67a39fb 100644 --- a/block.c +++ b/block.c @@ -257,7 +257,6 @@ BlockDriverState *bdrv_new(void) for (i = 0; i < BLOCK_OP_TYPE_MAX; i++) { QLIST_INIT(&bs->op_blockers[i]); } - bdrv_iostatus_disable(bs); notifier_list_init(&bs->close_notifiers); notifier_with_return_list_init(&bs->before_write_notifiers); qemu_co_queue_init(&bs->throttled_reqs[0]); @@ -2038,14 +2037,6 @@ static void bdrv_move_feature_fields(BlockDriverState *bs_dest, &bs_src->throttle_timers, sizeof(ThrottleTimers)); - /* r/w error */ - bs_dest->on_read_error = bs_src->on_read_error; - bs_dest->on_write_error = bs_src->on_write_error; - - /* i/o status */ - bs_dest->iostatus_enabled = bs_src->iostatus_enabled; - bs_dest->iostatus = bs_src->iostatus; - /* dirty bitmap */ bs_dest->dirty_bitmaps = bs_src->dirty_bitmaps; @@ -2605,82 +2596,6 @@ void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr) *nb_sectors_ptr = nb_sectors < 0 ? 0 : nb_sectors; } -void bdrv_set_on_error(BlockDriverState *bs, BlockdevOnError on_read_error, - BlockdevOnError on_write_error) -{ - bs->on_read_error = on_read_error; - bs->on_write_error = on_write_error; -} - -BlockdevOnError bdrv_get_on_error(BlockDriverState *bs, bool is_read) -{ - return is_read ? bs->on_read_error : bs->on_write_error; -} - -BlockErrorAction bdrv_get_error_action(BlockDriverState *bs, bool is_read, int error) -{ - BlockdevOnError on_err = is_read ? bs->on_read_error : bs->on_write_error; - - switch (on_err) { - case BLOCKDEV_ON_ERROR_ENOSPC: - return (error == ENOSPC) ? - BLOCK_ERROR_ACTION_STOP : BLOCK_ERROR_ACTION_REPORT; - case BLOCKDEV_ON_ERROR_STOP: - return BLOCK_ERROR_ACTION_STOP; - case BLOCKDEV_ON_ERROR_REPORT: - return BLOCK_ERROR_ACTION_REPORT; - case BLOCKDEV_ON_ERROR_IGNORE: - return BLOCK_ERROR_ACTION_IGNORE; - default: - abort(); - } -} - -static void send_qmp_error_event(BlockDriverState *bs, - BlockErrorAction action, - bool is_read, int error) -{ - IoOperationType optype; - - optype = is_read ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE; - qapi_event_send_block_io_error(bdrv_get_device_name(bs), optype, action, - bdrv_iostatus_is_enabled(bs), - error == ENOSPC, strerror(error), - &error_abort); -} - -/* This is done by device models because, while the block layer knows - * about the error, it does not know whether an operation comes from - * the device or the block layer (from a job, for example). - */ -void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action, - bool is_read, int error) -{ - assert(error >= 0); - - if (action == BLOCK_ERROR_ACTION_STOP) { - /* First set the iostatus, so that "info block" returns an iostatus - * that matches the events raised so far (an additional error iostatus - * is fine, but not a lost one). - */ - bdrv_iostatus_set_err(bs, error); - - /* Then raise the request to stop the VM and the event. - * qemu_system_vmstop_request_prepare has two effects. First, - * it ensures that the STOP event always comes after the - * BLOCK_IO_ERROR event. Second, it ensures that even if management - * can observe the STOP event and do a "cont" before the STOP - * event is issued, the VM will not stop. In this case, vm_start() - * also ensures that the STOP/RESUME pair of events is emitted. - */ - qemu_system_vmstop_request_prepare(); - send_qmp_error_event(bs, action, is_read, error); - qemu_system_vmstop_request(RUN_STATE_IO_ERROR); - } else { - send_qmp_error_event(bs, action, is_read, error); - } -} - int bdrv_is_read_only(BlockDriverState *bs) { return bs->read_only; @@ -3706,46 +3621,6 @@ bool bdrv_op_blocker_is_empty(BlockDriverState *bs) return true; } -void bdrv_iostatus_enable(BlockDriverState *bs) -{ - bs->iostatus_enabled = true; - bs->iostatus = BLOCK_DEVICE_IO_STATUS_OK; -} - -/* The I/O status is only enabled if the drive explicitly - * enables it _and_ the VM is configured to stop on errors */ -bool bdrv_iostatus_is_enabled(const BlockDriverState *bs) -{ - return (bs->iostatus_enabled && - (bs->on_write_error == BLOCKDEV_ON_ERROR_ENOSPC || - bs->on_write_error == BLOCKDEV_ON_ERROR_STOP || - bs->on_read_error == BLOCKDEV_ON_ERROR_STOP)); -} - -void bdrv_iostatus_disable(BlockDriverState *bs) -{ - bs->iostatus_enabled = false; -} - -void bdrv_iostatus_reset(BlockDriverState *bs) -{ - if (bdrv_iostatus_is_enabled(bs)) { - bs->iostatus = BLOCK_DEVICE_IO_STATUS_OK; - if (bs->job) { - block_job_iostatus_reset(bs->job); - } - } -} - -void bdrv_iostatus_set_err(BlockDriverState *bs, int error) -{ - assert(bdrv_iostatus_is_enabled(bs)); - if (bs->iostatus == BLOCK_DEVICE_IO_STATUS_OK) { - bs->iostatus = error == ENOSPC ? BLOCK_DEVICE_IO_STATUS_NOSPACE : - BLOCK_DEVICE_IO_STATUS_FAILED; - } -} - void bdrv_img_create(const char *filename, const char *fmt, const char *base_filename, const char *base_fmt, char *options, uint64_t img_size, int flags, diff --git a/block/backup.c b/block/backup.c index 965654d..c61e4c3 100644 --- a/block/backup.c +++ b/block/backup.c @@ -21,6 +21,7 @@ #include "block/blockjob.h" #include "qapi/qmp/qerror.h" #include "qemu/ratelimit.h" +#include "sysemu/block-backend.h" #define BACKUP_CLUSTER_BITS 16 #define BACKUP_CLUSTER_SIZE (1 << BACKUP_CLUSTER_BITS) @@ -208,7 +209,9 @@ static void backup_iostatus_reset(BlockJob *job) { BackupBlockJob *s = container_of(job, BackupBlockJob, common); - bdrv_iostatus_reset(s->target); + if (s->target->blk) { + blk_iostatus_reset(s->target->blk); + } } static const BlockJobDriver backup_job_driver = { @@ -352,8 +355,10 @@ static void coroutine_fn backup_run(void *opaque) job->bitmap = hbitmap_alloc(end, 0); bdrv_set_enable_write_cache(target, true); - bdrv_set_on_error(target, on_target_error, on_target_error); - bdrv_iostatus_enable(target); + if (target->blk) { + blk_set_on_error(target->blk, on_target_error, on_target_error); + blk_iostatus_enable(target->blk); + } bdrv_add_before_write_notifier(bs, &before_write); @@ -443,7 +448,9 @@ static void coroutine_fn backup_run(void *opaque) } hbitmap_free(job->bitmap); - bdrv_iostatus_disable(target); + if (target->blk) { + blk_iostatus_disable(target->blk); + } bdrv_op_unblock_all(target, job->common.blocker); data = g_malloc(sizeof(*data)); @@ -472,7 +479,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target, if ((on_source_error == BLOCKDEV_ON_ERROR_STOP || on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) && - !bdrv_iostatus_is_enabled(bs)) { + (!bs->blk || !blk_iostatus_is_enabled(bs->blk))) { error_setg(errp, QERR_INVALID_PARAMETER, "on-source-error"); return; } diff --git a/block/block-backend.c b/block/block-backend.c index 310ca50..1f2cd9b 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -12,7 +12,9 @@ #include "sysemu/block-backend.h" #include "block/block_int.h" +#include "block/blockjob.h" #include "sysemu/blockdev.h" +#include "sysemu/sysemu.h" #include "qapi-event.h" /* Number of coroutines to reserve per attached device model */ @@ -37,6 +39,10 @@ struct BlockBackend { /* I/O stats (display with "info blockstats"). */ BlockAcctStats stats; + + BlockdevOnError on_read_error, on_write_error; + bool iostatus_enabled; + BlockDeviceIoStatus iostatus; }; typedef struct BlockBackendAIOCB { @@ -313,7 +319,7 @@ int blk_attach_dev(BlockBackend *blk, void *dev) } blk_ref(blk); blk->dev = dev; - bdrv_iostatus_reset(blk->bs); + blk_iostatus_reset(blk); return 0; } @@ -445,7 +451,47 @@ void blk_dev_resize_cb(BlockBackend *blk) void blk_iostatus_enable(BlockBackend *blk) { - bdrv_iostatus_enable(blk->bs); + blk->iostatus_enabled = true; + blk->iostatus = BLOCK_DEVICE_IO_STATUS_OK; +} + +/* The I/O status is only enabled if the drive explicitly + * enables it _and_ the VM is configured to stop on errors */ +bool blk_iostatus_is_enabled(const BlockBackend *blk) +{ + return (blk->iostatus_enabled && + (blk->on_write_error == BLOCKDEV_ON_ERROR_ENOSPC || + blk->on_write_error == BLOCKDEV_ON_ERROR_STOP || + blk->on_read_error == BLOCKDEV_ON_ERROR_STOP)); +} + +BlockDeviceIoStatus blk_iostatus(const BlockBackend *blk) +{ + return blk->iostatus; +} + +void blk_iostatus_disable(BlockBackend *blk) +{ + blk->iostatus_enabled = false; +} + +void blk_iostatus_reset(BlockBackend *blk) +{ + if (blk_iostatus_is_enabled(blk)) { + blk->iostatus = BLOCK_DEVICE_IO_STATUS_OK; + if (blk->bs && blk->bs->job) { + block_job_iostatus_reset(blk->bs->job); + } + } +} + +void blk_iostatus_set_err(BlockBackend *blk, int error) +{ + assert(blk_iostatus_is_enabled(blk)); + if (blk->iostatus == BLOCK_DEVICE_IO_STATUS_OK) { + blk->iostatus = error == ENOSPC ? BLOCK_DEVICE_IO_STATUS_NOSPACE : + BLOCK_DEVICE_IO_STATUS_FAILED; + } } static int blk_check_byte_request(BlockBackend *blk, int64_t offset, @@ -721,21 +767,81 @@ void blk_drain_all(void) bdrv_drain_all(); } +void blk_set_on_error(BlockBackend *blk, BlockdevOnError on_read_error, + BlockdevOnError on_write_error) +{ + blk->on_read_error = on_read_error; + blk->on_write_error = on_write_error; +} + BlockdevOnError blk_get_on_error(BlockBackend *blk, bool is_read) { - return bdrv_get_on_error(blk->bs, is_read); + return is_read ? blk->on_read_error : blk->on_write_error; } BlockErrorAction blk_get_error_action(BlockBackend *blk, bool is_read, int error) { - return bdrv_get_error_action(blk->bs, is_read, error); + BlockdevOnError on_err = blk_get_on_error(blk, is_read); + + switch (on_err) { + case BLOCKDEV_ON_ERROR_ENOSPC: + return (error == ENOSPC) ? + BLOCK_ERROR_ACTION_STOP : BLOCK_ERROR_ACTION_REPORT; + case BLOCKDEV_ON_ERROR_STOP: + return BLOCK_ERROR_ACTION_STOP; + case BLOCKDEV_ON_ERROR_REPORT: + return BLOCK_ERROR_ACTION_REPORT; + case BLOCKDEV_ON_ERROR_IGNORE: + return BLOCK_ERROR_ACTION_IGNORE; + default: + abort(); + } } +static void send_qmp_error_event(BlockBackend *blk, + BlockErrorAction action, + bool is_read, int error) +{ + IoOperationType optype; + + optype = is_read ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE; + qapi_event_send_block_io_error(blk_name(blk), optype, action, + blk_iostatus_is_enabled(blk), + error == ENOSPC, strerror(error), + &error_abort); +} + +/* This is done by device models because, while the block layer knows + * about the error, it does not know whether an operation comes from + * the device or the block layer (from a job, for example). + */ void blk_error_action(BlockBackend *blk, BlockErrorAction action, bool is_read, int error) { - bdrv_error_action(blk->bs, action, is_read, error); + assert(error >= 0); + + if (action == BLOCK_ERROR_ACTION_STOP) { + /* First set the iostatus, so that "info block" returns an iostatus + * that matches the events raised so far (an additional error iostatus + * is fine, but not a lost one). + */ + blk_iostatus_set_err(blk, error); + + /* Then raise the request to stop the VM and the event. + * qemu_system_vmstop_request_prepare has two effects. First, + * it ensures that the STOP event always comes after the + * BLOCK_IO_ERROR event. Second, it ensures that even if management + * can observe the STOP event and do a "cont" before the STOP + * event is issued, the VM will not stop. In this case, vm_start() + * also ensures that the STOP/RESUME pair of events is emitted. + */ + qemu_system_vmstop_request_prepare(); + send_qmp_error_event(blk, action, is_read, error); + qemu_system_vmstop_request(RUN_STATE_IO_ERROR); + } else { + send_qmp_error_event(blk, action, is_read, error); + } } int blk_is_read_only(BlockBackend *blk) diff --git a/block/commit.c b/block/commit.c index d12e26f..fdebe87 100644 --- a/block/commit.c +++ b/block/commit.c @@ -17,6 +17,7 @@ #include "block/blockjob.h" #include "qapi/qmp/qerror.h" #include "qemu/ratelimit.h" +#include "sysemu/block-backend.h" enum { /* @@ -213,7 +214,7 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base, if ((on_error == BLOCKDEV_ON_ERROR_STOP || on_error == BLOCKDEV_ON_ERROR_ENOSPC) && - !bdrv_iostatus_is_enabled(bs)) { + (!bs->blk || !blk_iostatus_is_enabled(bs->blk))) { error_setg(errp, "Invalid parameter combination"); return; } diff --git a/block/mirror.c b/block/mirror.c index a258926..56c18b1 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -14,6 +14,7 @@ #include "trace.h" #include "block/blockjob.h" #include "block/block_int.h" +#include "sysemu/block-backend.h" #include "qapi/qmp/qerror.h" #include "qemu/ratelimit.h" #include "qemu/bitmap.h" @@ -598,7 +599,9 @@ immediate_exit: g_free(s->cow_bitmap); g_free(s->in_flight_bitmap); bdrv_release_dirty_bitmap(bs, s->dirty_bitmap); - bdrv_iostatus_disable(s->target); + if (s->target->blk) { + blk_iostatus_disable(s->target->blk); + } data = g_malloc(sizeof(*data)); data->ret = ret; @@ -620,7 +623,9 @@ static void mirror_iostatus_reset(BlockJob *job) { MirrorBlockJob *s = container_of(job, MirrorBlockJob, common); - bdrv_iostatus_reset(s->target); + if (s->target->blk) { + blk_iostatus_reset(s->target->blk); + } } static void mirror_complete(BlockJob *job, Error **errp) @@ -704,7 +709,7 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target, if ((on_source_error == BLOCKDEV_ON_ERROR_STOP || on_source_error == BLOCKDEV_ON_ERROR_ENOSPC) && - !bdrv_iostatus_is_enabled(bs)) { + (!bs->blk || !blk_iostatus_is_enabled(bs->blk))) { error_setg(errp, QERR_INVALID_PARAMETER, "on-source-error"); return; } @@ -740,8 +745,10 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target, return; } bdrv_set_enable_write_cache(s->target, true); - bdrv_set_on_error(s->target, on_target_error, on_target_error); - bdrv_iostatus_enable(s->target); + if (s->target->blk) { + blk_set_on_error(s->target->blk, on_target_error, on_target_error); + blk_iostatus_enable(s->target->blk); + } s->common.co = qemu_coroutine_create(mirror_run); trace_mirror_start(bs, s, s->common.co, opaque); qemu_coroutine_enter(s->common.co, s); diff --git a/block/qapi.c b/block/qapi.c index 2d1ef87..f295692 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -301,9 +301,9 @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, info->tray_open = blk_dev_is_tray_open(blk); } - if (bdrv_iostatus_is_enabled(bs)) { + if (blk_iostatus_is_enabled(blk)) { info->has_io_status = true; - info->io_status = bs->iostatus; + info->io_status = blk_iostatus(blk); } if (!QLIST_EMPTY(&bs->dirty_bitmaps)) { diff --git a/block/stream.c b/block/stream.c index ab0bd05..a0b090d 100644 --- a/block/stream.c +++ b/block/stream.c @@ -16,6 +16,7 @@ #include "block/blockjob.h" #include "qapi/qmp/qerror.h" #include "qemu/ratelimit.h" +#include "sysemu/block-backend.h" enum { /* @@ -250,7 +251,7 @@ void stream_start(BlockDriverState *bs, BlockDriverState *base, if ((on_error == BLOCKDEV_ON_ERROR_STOP || on_error == BLOCKDEV_ON_ERROR_ENOSPC) && - !bdrv_iostatus_is_enabled(bs)) { + (!bs->blk || !blk_iostatus_is_enabled(bs->blk))) { error_setg(errp, QERR_INVALID_PARAMETER, "on-error"); return; } diff --git a/blockdev.c b/blockdev.c index 013583b..01d422e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -551,7 +551,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, bs->detect_zeroes = detect_zeroes; - bdrv_set_on_error(bs, on_read_error, on_write_error); + blk_set_on_error(blk, on_read_error, on_write_error); /* disk I/O throttling */ if (throttle_enabled(&cfg)) { @@ -2170,8 +2170,8 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict) if (blk_get_attached_dev(blk)) { blk_hide_on_behalf_of_hmp_drive_del(blk); /* Further I/O must not pause the guest */ - bdrv_set_on_error(bs, BLOCKDEV_ON_ERROR_REPORT, - BLOCKDEV_ON_ERROR_REPORT); + blk_set_on_error(blk, BLOCKDEV_ON_ERROR_REPORT, + BLOCKDEV_ON_ERROR_REPORT); } else { blk_unref(blk); } diff --git a/blockjob.c b/blockjob.c index 62bb906..ca4be94 100644 --- a/blockjob.c +++ b/blockjob.c @@ -29,6 +29,7 @@ #include "block/block.h" #include "block/blockjob.h" #include "block/block_int.h" +#include "sysemu/block-backend.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/qjson.h" #include "block/coroutine.h" @@ -353,8 +354,8 @@ BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs, job->user_paused = true; block_job_pause(job); block_job_iostatus_set_err(job, error); - if (bs != job->bs) { - bdrv_iostatus_set_err(bs, error); + if (bs->blk && bs != job->bs) { + blk_iostatus_set_err(bs->blk, error); } } return action; diff --git a/include/block/block.h b/include/block/block.h index 960eb98..11c0316 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -173,11 +173,6 @@ typedef enum BlockOpType { BLOCK_OP_TYPE_MAX, } BlockOpType; -void bdrv_iostatus_enable(BlockDriverState *bs); -void bdrv_iostatus_reset(BlockDriverState *bs); -void bdrv_iostatus_disable(BlockDriverState *bs); -bool bdrv_iostatus_is_enabled(const BlockDriverState *bs); -void bdrv_iostatus_set_err(BlockDriverState *bs, int error); void bdrv_info_print(Monitor *mon, const QObject *data); void bdrv_info(Monitor *mon, QObject **ret_data); void bdrv_stats_print(Monitor *mon, const QObject *data); @@ -387,12 +382,6 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, int64_t sector_num, int nb_sectors, int *pnum); -void bdrv_set_on_error(BlockDriverState *bs, BlockdevOnError on_read_error, - BlockdevOnError on_write_error); -BlockdevOnError bdrv_get_on_error(BlockDriverState *bs, bool is_read); -BlockErrorAction bdrv_get_error_action(BlockDriverState *bs, bool is_read, int error); -void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action, - bool is_read, int error); int bdrv_is_read_only(BlockDriverState *bs); int bdrv_is_sg(BlockDriverState *bs); int bdrv_enable_write_cache(BlockDriverState *bs); diff --git a/include/block/block_int.h b/include/block/block_int.h index 0376508..bd35570 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -415,12 +415,6 @@ struct BlockDriverState { /* do we need to tell the quest if we have a volatile write cache? */ int enable_write_cache; - /* NOTE: the following infos are only hints for real hardware - drivers. They are not used by the block driver */ - BlockdevOnError on_read_error, on_write_error; - bool iostatus_enabled; - BlockDeviceIoStatus iostatus; - /* the following member gives a name to every node on the bs graph. */ char node_name[32]; /* element of the list of named nodes building the graph */ diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 1e19d1b..eafcef0 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -76,6 +76,11 @@ BlockDriverState *blk_bs(BlockBackend *blk); void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk); void blk_iostatus_enable(BlockBackend *blk); +bool blk_iostatus_is_enabled(const BlockBackend *blk); +BlockDeviceIoStatus blk_iostatus(const BlockBackend *blk); +void blk_iostatus_disable(BlockBackend *blk); +void blk_iostatus_reset(BlockBackend *blk); +void blk_iostatus_set_err(BlockBackend *blk, int error); int blk_attach_dev(BlockBackend *blk, void *dev); void blk_attach_dev_nofail(BlockBackend *blk, void *dev); void blk_detach_dev(BlockBackend *blk, void *dev); @@ -120,6 +125,8 @@ int blk_flush(BlockBackend *blk); int blk_flush_all(void); void blk_drain(BlockBackend *blk); void blk_drain_all(void); +void blk_set_on_error(BlockBackend *blk, BlockdevOnError on_read_error, + BlockdevOnError on_write_error); BlockdevOnError blk_get_on_error(BlockBackend *blk, bool is_read); BlockErrorAction blk_get_error_action(BlockBackend *blk, bool is_read, int error); diff --git a/qmp.c b/qmp.c index 9623c80..8c3dca8 100644 --- a/qmp.c +++ b/qmp.c @@ -24,6 +24,7 @@ #include "sysemu/arch_init.h" #include "hw/qdev.h" #include "sysemu/blockdev.h" +#include "sysemu/block-backend.h" #include "qom/qom-qobject.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/qobject.h" @@ -170,6 +171,7 @@ SpiceInfo *qmp_query_spice(Error **errp) void qmp_cont(Error **errp) { Error *local_err = NULL; + BlockBackend *blk; BlockDriverState *bs; if (runstate_needs_reset()) { @@ -179,8 +181,8 @@ void qmp_cont(Error **errp) return; } - for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) { - bdrv_iostatus_reset(bs); + for (blk = blk_next(NULL); blk; blk = blk_next(blk)) { + blk_iostatus_reset(blk); } for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) { bdrv_add_key(bs, NULL, &local_err); -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:20 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWO-0007ID-Mq for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38320) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWJ-00077y-2t for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWF-00061q-5h for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41348) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWE-00061g-VD; Fri, 18 Sep 2015 11:24:11 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 9AFFE83F9B; Fri, 18 Sep 2015 15:24:10 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFO8Ii023912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:09 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:54 +0200 Message-Id: <1442589793-7105-20-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 19/38] block: Fail requests to empty BlockBackend X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:16 -0000 If there is no BlockDriverState in a BlockBackend or if the tray of the guest device is open, fail all requests (where that is possible) with -ENOMEDIUM. The reason the status of the guest device is taken into account is because once the guest device's tray is opened, any request on the same BlockBackend as the guest uses should fail. If the BDS tree is supposed to be usable even after ejecting it from the guest, a different BlockBackend must be used. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block/block-backend.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index 417374f..0da4be9 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -509,7 +509,7 @@ static int blk_check_byte_request(BlockBackend *blk, int64_t offset, return -EIO; } - if (!blk_is_inserted(blk)) { + if (!blk_is_available(blk)) { return -ENOMEDIUM; } @@ -648,6 +648,10 @@ int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int count) int64_t blk_getlength(BlockBackend *blk) { + if (!blk_is_available(blk)) { + return -ENOMEDIUM; + } + return bdrv_getlength(blk->bs); } @@ -658,6 +662,10 @@ void blk_get_geometry(BlockBackend *blk, uint64_t *nb_sectors_ptr) int64_t blk_nb_sectors(BlockBackend *blk) { + if (!blk_is_available(blk)) { + return -ENOMEDIUM; + } + return bdrv_nb_sectors(blk->bs); } @@ -688,6 +696,10 @@ BlockAIOCB *blk_aio_writev(BlockBackend *blk, int64_t sector_num, BlockAIOCB *blk_aio_flush(BlockBackend *blk, BlockCompletionFunc *cb, void *opaque) { + if (!blk_is_available(blk)) { + return abort_aio_request(blk, cb, opaque, -ENOMEDIUM); + } + return bdrv_aio_flush(blk->bs, cb, opaque); } @@ -729,12 +741,20 @@ int blk_aio_multiwrite(BlockBackend *blk, BlockRequest *reqs, int num_reqs) int blk_ioctl(BlockBackend *blk, unsigned long int req, void *buf) { + if (!blk_is_available(blk)) { + return -ENOMEDIUM; + } + return bdrv_ioctl(blk->bs, req, buf); } BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf, BlockCompletionFunc *cb, void *opaque) { + if (!blk_is_available(blk)) { + return abort_aio_request(blk, cb, opaque, -ENOMEDIUM); + } + return bdrv_aio_ioctl(blk->bs, req, buf, cb, opaque); } @@ -750,11 +770,19 @@ int blk_co_discard(BlockBackend *blk, int64_t sector_num, int nb_sectors) int blk_co_flush(BlockBackend *blk) { + if (!blk_is_available(blk)) { + return -ENOMEDIUM; + } + return bdrv_co_flush(blk->bs); } int blk_flush(BlockBackend *blk) { + if (!blk_is_available(blk)) { + return -ENOMEDIUM; + } + return bdrv_flush(blk->bs); } @@ -876,6 +904,11 @@ void blk_set_enable_write_cache(BlockBackend *blk, bool wce) void blk_invalidate_cache(BlockBackend *blk, Error **errp) { + if (!blk->bs) { + error_setg(errp, "Device '%s' has no medium", blk->name); + return; + } + bdrv_invalidate_cache(blk->bs, errp); } @@ -1031,6 +1064,10 @@ int blk_write_compressed(BlockBackend *blk, int64_t sector_num, int blk_truncate(BlockBackend *blk, int64_t offset) { + if (!blk_is_available(blk)) { + return -ENOMEDIUM; + } + return bdrv_truncate(blk->bs, offset); } @@ -1047,21 +1084,37 @@ int blk_discard(BlockBackend *blk, int64_t sector_num, int nb_sectors) int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, int64_t pos, int size) { + if (!blk_is_available(blk)) { + return -ENOMEDIUM; + } + return bdrv_save_vmstate(blk->bs, buf, pos, size); } int blk_load_vmstate(BlockBackend *blk, uint8_t *buf, int64_t pos, int size) { + if (!blk_is_available(blk)) { + return -ENOMEDIUM; + } + return bdrv_load_vmstate(blk->bs, buf, pos, size); } int blk_probe_blocksizes(BlockBackend *blk, BlockSizes *bsz) { + if (!blk_is_available(blk)) { + return -ENOMEDIUM; + } + return bdrv_probe_blocksizes(blk->bs, bsz); } int blk_probe_geometry(BlockBackend *blk, HDGeometry *geo) { + if (!blk_is_available(blk)) { + return -ENOMEDIUM; + } + return bdrv_probe_geometry(blk->bs, geo); } -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWU-0007SW-Bj for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWO-0007Hi-Fy for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWK-00063f-Kd for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41374) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWK-00063U-GT; Fri, 18 Sep 2015 11:24:16 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 2B0C66E; Fri, 18 Sep 2015 15:24:16 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOEmU023966 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:15 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:56 +0200 Message-Id: <1442589793-7105-22-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 21/38] block: Add blk_insert_bs() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:24 -0000 This function associates the given BlockDriverState with the given BlockBackend. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- block/block-backend.c | 16 ++++++++++++++++ include/sysemu/block-backend.h | 1 + 2 files changed, 17 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index 33145f8..652385e 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -314,6 +314,22 @@ void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk) } /* + * Associates a new BlockDriverState with @blk. + */ +void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs) +{ + if (bs->blk == blk) { + return; + } + + assert(!blk->bs); + assert(!bs->blk); + bdrv_ref(bs); + blk->bs = bs; + bs->blk = blk; +} + +/* * Attach device model @dev to @blk. * Return 0 on success, -EBUSY when a device model is attached already. */ diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 52e35a1..9306a52 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -72,6 +72,7 @@ BlockBackend *blk_by_name(const char *name); BlockBackend *blk_next(BlockBackend *blk); BlockDriverState *blk_bs(BlockBackend *blk); +void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs); void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk); -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:21 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWO-0007In-Vj for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWJ-000784-3X for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWI-00062d-5B for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55847) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWH-00062U-Uy; Fri, 18 Sep 2015 11:24:14 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 9998EC0B986C; Fri, 18 Sep 2015 15:24:13 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOB8e018636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:12 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:55 +0200 Message-Id: <1442589793-7105-21-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 20/38] block: Prepare remaining BB functions for NULL BDS X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:16 -0000 There are several BlockBackend functions which, in theory, cannot fail. This patch makes them cope with the BlockDriverState pointer being NULL by making them fall back to some default action like ignoring the value in setters and returning the default in getters. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block/block-backend.c | 76 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 16 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 0da4be9..33145f8 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -657,7 +657,11 @@ int64_t blk_getlength(BlockBackend *blk) void blk_get_geometry(BlockBackend *blk, uint64_t *nb_sectors_ptr) { - bdrv_get_geometry(blk->bs, nb_sectors_ptr); + if (!blk->bs) { + *nb_sectors_ptr = 0; + } else { + bdrv_get_geometry(blk->bs, nb_sectors_ptr); + } } int64_t blk_nb_sectors(BlockBackend *blk) @@ -889,17 +893,27 @@ int blk_is_read_only(BlockBackend *blk) int blk_is_sg(BlockBackend *blk) { + if (!blk->bs) { + return 0; + } + return bdrv_is_sg(blk->bs); } int blk_enable_write_cache(BlockBackend *blk) { + if (!blk->bs) { + return 0; + } + return bdrv_enable_write_cache(blk->bs); } void blk_set_enable_write_cache(BlockBackend *blk, bool wce) { - bdrv_set_enable_write_cache(blk->bs, wce); + if (blk->bs) { + bdrv_set_enable_write_cache(blk->bs, wce); + } } void blk_invalidate_cache(BlockBackend *blk, Error **errp) @@ -924,12 +938,16 @@ bool blk_is_available(BlockBackend *blk) void blk_lock_medium(BlockBackend *blk, bool locked) { - bdrv_lock_medium(blk->bs, locked); + if (blk->bs) { + bdrv_lock_medium(blk->bs, locked); + } } void blk_eject(BlockBackend *blk, bool eject_flag) { - bdrv_eject(blk->bs, eject_flag); + if (blk->bs) { + bdrv_eject(blk->bs, eject_flag); + } } int blk_get_flags(BlockBackend *blk) @@ -943,7 +961,11 @@ int blk_get_flags(BlockBackend *blk) int blk_get_max_transfer_length(BlockBackend *blk) { - return blk->bs->bl.max_transfer_length; + if (blk->bs) { + return blk->bs->bl.max_transfer_length; + } else { + return 0; + } } void blk_set_guest_block_size(BlockBackend *blk, int align) @@ -958,22 +980,32 @@ void *blk_blockalign(BlockBackend *blk, size_t size) bool blk_op_is_blocked(BlockBackend *blk, BlockOpType op, Error **errp) { + if (!blk->bs) { + return false; + } + return bdrv_op_is_blocked(blk->bs, op, errp); } void blk_op_unblock(BlockBackend *blk, BlockOpType op, Error *reason) { - bdrv_op_unblock(blk->bs, op, reason); + if (blk->bs) { + bdrv_op_unblock(blk->bs, op, reason); + } } void blk_op_block_all(BlockBackend *blk, Error *reason) { - bdrv_op_block_all(blk->bs, reason); + if (blk->bs) { + bdrv_op_block_all(blk->bs, reason); + } } void blk_op_unblock_all(BlockBackend *blk, Error *reason) { - bdrv_op_unblock_all(blk->bs, reason); + if (blk->bs) { + bdrv_op_unblock_all(blk->bs, reason); + } } AioContext *blk_get_aio_context(BlockBackend *blk) @@ -993,15 +1025,19 @@ static AioContext *blk_aiocb_get_aio_context(BlockAIOCB *acb) void blk_set_aio_context(BlockBackend *blk, AioContext *new_context) { - bdrv_set_aio_context(blk->bs, new_context); + if (blk->bs) { + bdrv_set_aio_context(blk->bs, new_context); + } } void blk_add_aio_context_notifier(BlockBackend *blk, void (*attached_aio_context)(AioContext *new_context, void *opaque), void (*detach_aio_context)(void *opaque), void *opaque) { - bdrv_add_aio_context_notifier(blk->bs, attached_aio_context, - detach_aio_context, opaque); + if (blk->bs) { + bdrv_add_aio_context_notifier(blk->bs, attached_aio_context, + detach_aio_context, opaque); + } } void blk_remove_aio_context_notifier(BlockBackend *blk, @@ -1010,23 +1046,31 @@ void blk_remove_aio_context_notifier(BlockBackend *blk, void (*detach_aio_context)(void *), void *opaque) { - bdrv_remove_aio_context_notifier(blk->bs, attached_aio_context, - detach_aio_context, opaque); + if (blk->bs) { + bdrv_remove_aio_context_notifier(blk->bs, attached_aio_context, + detach_aio_context, opaque); + } } void blk_add_close_notifier(BlockBackend *blk, Notifier *notify) { - bdrv_add_close_notifier(blk->bs, notify); + if (blk->bs) { + bdrv_add_close_notifier(blk->bs, notify); + } } void blk_io_plug(BlockBackend *blk) { - bdrv_io_plug(blk->bs); + if (blk->bs) { + bdrv_io_plug(blk->bs); + } } void blk_io_unplug(BlockBackend *blk) { - bdrv_io_unplug(blk->bs); + if (blk->bs) { + bdrv_io_unplug(blk->bs); + } } BlockAcctStats *blk_get_stats(BlockBackend *blk) -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:37 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWf-0007mo-0k for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWb-0007ff-8R for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWV-00067e-90 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52521) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWV-00067L-2Z; Fri, 18 Sep 2015 11:24:27 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id B52338E704; Fri, 18 Sep 2015 15:24:26 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOOjC019088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:25 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:59 +0200 Message-Id: <1442589793-7105-25-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 24/38] blockdev: Pull out blockdev option extraction X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:35 -0000 Extract some of the blockdev option extraction code from blockdev_init() into its own function. This simplifies blockdev_init() and will allow reusing the code in a different function added in a follow-up patch. Signed-off-by: Max Reitz --- blockdev.c | 209 +++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 113 insertions(+), 96 deletions(-) diff --git a/blockdev.c b/blockdev.c index e76a7de..688ee5f 100644 --- a/blockdev.c +++ b/blockdev.c @@ -350,25 +350,128 @@ static bool check_throttle_config(ThrottleConfig *cfg, Error **errp) typedef enum { MEDIA_DISK, MEDIA_CDROM } DriveMediaType; +static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags, + ThrottleConfig *throttle_cfg, BlockdevDetectZeroesOptions *detect_zeroes, + const char **throttling_group, Error **errp) +{ + const char *discard; + Error *local_error = NULL; +#ifdef CONFIG_LINUX_AIO + const char *aio; +#endif + + if (!qemu_opt_get_bool(opts, "read-only", false)) { + *bdrv_flags |= BDRV_O_RDWR; + } + if (qemu_opt_get_bool(opts, "copy-on-read", false)) { + *bdrv_flags |= BDRV_O_COPY_ON_READ; + } + + if ((discard = qemu_opt_get(opts, "discard")) != NULL) { + if (bdrv_parse_discard_flags(discard, bdrv_flags) != 0) { + error_setg(errp, "Invalid discard option"); + return; + } + } + + if (qemu_opt_get_bool(opts, BDRV_OPT_CACHE_WB, true)) { + *bdrv_flags |= BDRV_O_CACHE_WB; + } + if (qemu_opt_get_bool(opts, BDRV_OPT_CACHE_DIRECT, false)) { + *bdrv_flags |= BDRV_O_NOCACHE; + } + if (qemu_opt_get_bool(opts, BDRV_OPT_CACHE_NO_FLUSH, false)) { + *bdrv_flags |= BDRV_O_NO_FLUSH; + } + +#ifdef CONFIG_LINUX_AIO + if ((aio = qemu_opt_get(opts, "aio")) != NULL) { + if (!strcmp(aio, "native")) { + *bdrv_flags |= BDRV_O_NATIVE_AIO; + } else if (!strcmp(aio, "threads")) { + /* this is the default */ + } else { + error_setg(errp, "invalid aio option"); + return; + } + } +#endif + + /* disk I/O throttling */ + memset(throttle_cfg, 0, sizeof(*throttle_cfg)); + throttle_cfg->buckets[THROTTLE_BPS_TOTAL].avg = + qemu_opt_get_number(opts, "throttling.bps-total", 0); + throttle_cfg->buckets[THROTTLE_BPS_READ].avg = + qemu_opt_get_number(opts, "throttling.bps-read", 0); + throttle_cfg->buckets[THROTTLE_BPS_WRITE].avg = + qemu_opt_get_number(opts, "throttling.bps-write", 0); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL].avg = + qemu_opt_get_number(opts, "throttling.iops-total", 0); + throttle_cfg->buckets[THROTTLE_OPS_READ].avg = + qemu_opt_get_number(opts, "throttling.iops-read", 0); + throttle_cfg->buckets[THROTTLE_OPS_WRITE].avg = + qemu_opt_get_number(opts, "throttling.iops-write", 0); + + throttle_cfg->buckets[THROTTLE_BPS_TOTAL].max = + qemu_opt_get_number(opts, "throttling.bps-total-max", 0); + throttle_cfg->buckets[THROTTLE_BPS_READ].max = + qemu_opt_get_number(opts, "throttling.bps-read-max", 0); + throttle_cfg->buckets[THROTTLE_BPS_WRITE].max = + qemu_opt_get_number(opts, "throttling.bps-write-max", 0); + throttle_cfg->buckets[THROTTLE_OPS_TOTAL].max = + qemu_opt_get_number(opts, "throttling.iops-total-max", 0); + throttle_cfg->buckets[THROTTLE_OPS_READ].max = + qemu_opt_get_number(opts, "throttling.iops-read-max", 0); + throttle_cfg->buckets[THROTTLE_OPS_WRITE].max = + qemu_opt_get_number(opts, "throttling.iops-write-max", 0); + + throttle_cfg->op_size = + qemu_opt_get_number(opts, "throttling.iops-size", 0); + + *throttling_group = qemu_opt_get(opts, "throttling.group"); + + if (!check_throttle_config(throttle_cfg, errp)) { + return; + } + + *detect_zeroes = + qapi_enum_parse(BlockdevDetectZeroesOptions_lookup, + qemu_opt_get(opts, "detect-zeroes"), + BLOCKDEV_DETECT_ZEROES_OPTIONS_MAX, + BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF, + &local_error); + if (local_error) { + error_propagate(errp, local_error); + return; + } + + if (*detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP && + !(*bdrv_flags & BDRV_O_UNMAP)) + { + error_setg(errp, "setting detect-zeroes to unmap is not allowed " + "without setting discard operation to unmap"); + return; + } +} + /* Takes the ownership of bs_opts */ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, Error **errp) { const char *buf; - int ro = 0; int bdrv_flags = 0; int on_read_error, on_write_error; BlockBackend *blk; BlockDriverState *bs; ThrottleConfig cfg; int snapshot = 0; - bool copy_on_read; Error *error = NULL; QemuOpts *opts; const char *id; bool has_driver_specific_opts; - BlockdevDetectZeroesOptions detect_zeroes; - const char *throttling_group; + BlockdevDetectZeroesOptions detect_zeroes = + BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF; + const char *throttling_group = NULL; /* Check common options by copying from bs_opts to opts, all other options * stay in bs_opts for processing by bdrv_open(). */ @@ -393,38 +496,13 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, /* extract parameters */ snapshot = qemu_opt_get_bool(opts, "snapshot", 0); - ro = qemu_opt_get_bool(opts, "read-only", 0); - copy_on_read = qemu_opt_get_bool(opts, "copy-on-read", false); - - if ((buf = qemu_opt_get(opts, "discard")) != NULL) { - if (bdrv_parse_discard_flags(buf, &bdrv_flags) != 0) { - error_setg(errp, "invalid discard option"); - goto early_err; - } - } - if (qemu_opt_get_bool(opts, BDRV_OPT_CACHE_WB, true)) { - bdrv_flags |= BDRV_O_CACHE_WB; - } - if (qemu_opt_get_bool(opts, BDRV_OPT_CACHE_DIRECT, false)) { - bdrv_flags |= BDRV_O_NOCACHE; - } - if (qemu_opt_get_bool(opts, BDRV_OPT_CACHE_NO_FLUSH, false)) { - bdrv_flags |= BDRV_O_NO_FLUSH; - } - -#ifdef CONFIG_LINUX_AIO - if ((buf = qemu_opt_get(opts, "aio")) != NULL) { - if (!strcmp(buf, "native")) { - bdrv_flags |= BDRV_O_NATIVE_AIO; - } else if (!strcmp(buf, "threads")) { - /* this is the default */ - } else { - error_setg(errp, "invalid aio option"); - goto early_err; - } + extract_common_blockdev_options(opts, &bdrv_flags, &cfg, &detect_zeroes, + &throttling_group, &error); + if (error) { + error_propagate(errp, error); + goto early_err; } -#endif if ((buf = qemu_opt_get(opts, "format")) != NULL) { if (is_help_option(buf)) { @@ -441,43 +519,6 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, qdict_put(bs_opts, "driver", qstring_from_str(buf)); } - /* disk I/O throttling */ - memset(&cfg, 0, sizeof(cfg)); - cfg.buckets[THROTTLE_BPS_TOTAL].avg = - qemu_opt_get_number(opts, "throttling.bps-total", 0); - cfg.buckets[THROTTLE_BPS_READ].avg = - qemu_opt_get_number(opts, "throttling.bps-read", 0); - cfg.buckets[THROTTLE_BPS_WRITE].avg = - qemu_opt_get_number(opts, "throttling.bps-write", 0); - cfg.buckets[THROTTLE_OPS_TOTAL].avg = - qemu_opt_get_number(opts, "throttling.iops-total", 0); - cfg.buckets[THROTTLE_OPS_READ].avg = - qemu_opt_get_number(opts, "throttling.iops-read", 0); - cfg.buckets[THROTTLE_OPS_WRITE].avg = - qemu_opt_get_number(opts, "throttling.iops-write", 0); - - cfg.buckets[THROTTLE_BPS_TOTAL].max = - qemu_opt_get_number(opts, "throttling.bps-total-max", 0); - cfg.buckets[THROTTLE_BPS_READ].max = - qemu_opt_get_number(opts, "throttling.bps-read-max", 0); - cfg.buckets[THROTTLE_BPS_WRITE].max = - qemu_opt_get_number(opts, "throttling.bps-write-max", 0); - cfg.buckets[THROTTLE_OPS_TOTAL].max = - qemu_opt_get_number(opts, "throttling.iops-total-max", 0); - cfg.buckets[THROTTLE_OPS_READ].max = - qemu_opt_get_number(opts, "throttling.iops-read-max", 0); - cfg.buckets[THROTTLE_OPS_WRITE].max = - qemu_opt_get_number(opts, "throttling.iops-write-max", 0); - - cfg.op_size = qemu_opt_get_number(opts, "throttling.iops-size", 0); - - throttling_group = qemu_opt_get(opts, "throttling.group"); - - if (!check_throttle_config(&cfg, &error)) { - error_propagate(errp, error); - goto early_err; - } - on_write_error = BLOCKDEV_ON_ERROR_ENOSPC; if ((buf = qemu_opt_get(opts, "werror")) != NULL) { on_write_error = parse_block_error_action(buf, 0, &error); @@ -496,40 +537,16 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, } } - detect_zeroes = - qapi_enum_parse(BlockdevDetectZeroesOptions_lookup, - qemu_opt_get(opts, "detect-zeroes"), - BLOCKDEV_DETECT_ZEROES_OPTIONS_MAX, - BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF, - &error); - if (error) { - error_propagate(errp, error); - goto early_err; - } - - if (detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP && - !(bdrv_flags & BDRV_O_UNMAP)) { - error_setg(errp, "setting detect-zeroes to unmap is not allowed " - "without setting discard operation to unmap"); - goto early_err; - } - if (snapshot) { /* always use cache=unsafe with snapshot */ bdrv_flags &= ~BDRV_O_CACHE_MASK; bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH); } - if (copy_on_read) { - bdrv_flags |= BDRV_O_COPY_ON_READ; - } - if (runstate_check(RUN_STATE_INMIGRATE)) { bdrv_flags |= BDRV_O_INCOMING; } - bdrv_flags |= ro ? 0 : BDRV_O_RDWR; - /* init */ if ((!file || !*file) && !has_driver_specific_opts) { BlockBackendRootState *blk_rs; @@ -541,7 +558,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, blk_rs = blk_get_root_state(blk); blk_rs->open_flags = bdrv_flags; - blk_rs->read_only = ro; + blk_rs->read_only = !(bdrv_flags & BDRV_O_RDWR); blk_rs->detect_zeroes = detect_zeroes; if (throttle_enabled(&cfg)) { -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:42 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWk-0007xf-JP for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWe-0007mD-KJ for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWd-0006BF-Hx for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41459) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWd-0006Aw-Bs; Fri, 18 Sep 2015 11:24:35 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 076B8C9D23; Fri, 18 Sep 2015 15:24:35 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOWoq024136 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:34 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:23:02 +0200 Message-Id: <1442589793-7105-28-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 27/38] blockdev: Add blockdev-open-tray X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:38 -0000 Signed-off-by: Max Reitz --- blockdev.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ qapi/block-core.json | 23 +++++++++++++++++++++++ qmp-commands.hx | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) diff --git a/blockdev.c b/blockdev.c index 647ce0b..6bc5841 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2059,6 +2059,55 @@ out: aio_context_release(aio_context); } +void qmp_blockdev_open_tray(const char *device, bool has_force, bool force, + Error **errp) +{ + BlockBackend *blk; + BlockDriverState *bs; + AioContext *aio_context = NULL; + + if (!has_force) { + force = false; + } + + blk = blk_by_name(device); + if (!blk) { + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + "Device '%s' not found", device); + return; + } + + if (!blk_dev_has_removable_media(blk)) { + error_setg(errp, "Device '%s' is not removable", device); + return; + } + + if (blk_dev_is_tray_open(blk)) { + return; + } + + bs = blk_bs(blk); + if (bs) { + aio_context = bdrv_get_aio_context(bs); + aio_context_acquire(aio_context); + + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_EJECT, errp)) { + goto out; + } + } + + if (blk_dev_is_medium_locked(blk)) { + blk_dev_eject_request(blk, force); + } else { + blk_dev_change_media_cb(blk, false); + } + +out: + if (aio_context) { + aio_context_release(aio_context); + } +} + /* throttling disk I/O limits */ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, int64_t bps_wr, diff --git a/qapi/block-core.json b/qapi/block-core.json index 425fdab..b9b4a24 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1876,6 +1876,29 @@ ## { 'command': 'blockdev-add', 'data': { 'options': 'BlockdevOptions' } } +## +# @blockdev-open-tray: +# +# Opens a block device's tray. If there is a block driver state tree inserted as +# a medium, it will become inaccessible to the guest (but it will remain +# associated to the block device, so closing the tray will make it accessible +# again). +# +# If the tray was already open before, this will be a no-op. +# +# @device: block device name +# +# @force: #optional if false (the default), an eject request will be sent to +# the guest if it has locked the tray (and the tray will not be opened +# immediately); if true, the tray will be opened regardless of whether +# it is locked +# +# Since: 2.5 +## +{ 'command': 'blockdev-open-tray', + 'data': { 'device': 'str', + '*force': 'bool' } } + ## # @BlockErrorAction diff --git a/qmp-commands.hx b/qmp-commands.hx index 8343289..f6ea5ea 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3897,6 +3897,45 @@ Example (2): EQMP { + .name = "blockdev-open-tray", + .args_type = "device:s,force:b?", + .mhandler.cmd_new = qmp_marshal_input_blockdev_open_tray, + }, + +SQMP +blockdev-open-tray +------------------ + +Opens a block device's tray. If there is a block driver state tree inserted as a +medium, it will become inaccessible to the guest (but it will remain associated +to the block device, so closing the tray will make it accessible again). + +If the tray was already open before, this will be a no-op. + +Arguments: + +- "device": block device name (json-string) +- "force": if false (the default), an eject request will be sent to the guest if + it has locked the tray (and the tray will not be opened immediately); + if true, the tray will be opened regardless of whether it is locked + (json-bool, optional) + +Example: + +-> { "execute": "blockdev-open-tray", + "arguments": { "device": "ide1-cd0" } } + +<- { "timestamp": { "seconds": 1418751016, + "microseconds": 716996 }, + "event": "DEVICE_TRAY_MOVED", + "data": { "device": "ide1-cd0", + "tray-open": true } } + +<- { "return": {} } + +EQMP + + { .name = "query-named-block-nodes", .args_type = "", .mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes, -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:37 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWf-0007n8-A6 for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWd-0007jI-66 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWa-00069m-Op for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49578) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWa-00069b-KF; Fri, 18 Sep 2015 11:24:32 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 4988EC0798E9; Fri, 18 Sep 2015 15:24:32 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOUL3019169 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:31 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:23:01 +0200 Message-Id: <1442589793-7105-27-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 26/38] block: Add blk_remove_bs() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:36 -0000 This function removes the BlockDriverState associated with the given BlockBackend from that BB and sets the BDS pointer in the BB to NULL. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block/block-backend.c | 22 +++++++++++++++++++++- include/sysemu/block-backend.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index 652385e..66ecc07 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -314,6 +314,22 @@ void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk) } /* + * Disassociates the currently associated BlockDriverState from @blk. + */ +void blk_remove_bs(BlockBackend *blk) +{ + if (!blk->bs) { + return; + } + + blk_update_root_state(blk); + + bdrv_unref(blk->bs); + blk->bs->blk = NULL; + blk->bs = NULL; +} + +/* * Associates a new BlockDriverState with @blk. */ void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs) @@ -323,9 +339,13 @@ void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs) } assert(!blk->bs); - assert(!bs->blk); bdrv_ref(bs); blk->bs = bs; + + if (bs->blk) { + blk_remove_bs(bs->blk); + } + bs->blk = blk; } diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 9306a52..14a6d32 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -72,6 +72,7 @@ BlockBackend *blk_by_name(const char *name); BlockBackend *blk_next(BlockBackend *blk); BlockDriverState *blk_bs(BlockBackend *blk); +void blk_remove_bs(BlockBackend *blk); void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs); void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk); -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWX-0007Xh-SW for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWS-0007OM-23 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWP-00065B-Hd for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52489) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWP-000652-89; Fri, 18 Sep 2015 11:24:21 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id DFE938E69C; Fri, 18 Sep 2015 15:24:20 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOHWq018722 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:19 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:57 +0200 Message-Id: <1442589793-7105-23-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 22/38] block: Prepare for NULL BDS X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:26 -0000 blk_bs() will not necessarily return a non-NULL value any more (unless blk_is_available() is true or it can be assumed to otherwise, e.g. because it is called immediately after a successful blk_new_with_bs() or blk_new_open()). Signed-off-by: Max Reitz --- block.c | 5 ++ block/qapi.c | 4 +- blockdev.c | 201 ++++++++++++++++++++++++++++++++++------------------ hw/block/xen_disk.c | 4 +- migration/block.c | 5 ++ monitor.c | 4 ++ 6 files changed, 153 insertions(+), 70 deletions(-) diff --git a/block.c b/block.c index 67a39fb..7776871 100644 --- a/block.c +++ b/block.c @@ -2787,6 +2787,11 @@ BlockDriverState *bdrv_lookup_bs(const char *device, blk = blk_by_name(device); if (blk) { + if (!blk_bs(blk)) { + error_setg(errp, "Device '%s' has no medium", device); + return NULL; + } + return blk_bs(blk); } } diff --git a/block/qapi.c b/block/qapi.c index f295692..e936ba7 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -306,12 +306,12 @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, info->io_status = blk_iostatus(blk); } - if (!QLIST_EMPTY(&bs->dirty_bitmaps)) { + if (bs && !QLIST_EMPTY(&bs->dirty_bitmaps)) { info->has_dirty_bitmaps = true; info->dirty_bitmaps = bdrv_query_dirty_bitmaps(bs); } - if (bs->drv) { + if (bs && bs->drv) { info->has_inserted = true; info->inserted = bdrv_block_device_info(bs, errp); if (info->inserted == NULL) { diff --git a/blockdev.c b/blockdev.c index 01d422e..6168b09 100644 --- a/blockdev.c +++ b/blockdev.c @@ -124,14 +124,16 @@ void blockdev_mark_auto_del(BlockBackend *blk) return; } - aio_context = bdrv_get_aio_context(bs); - aio_context_acquire(aio_context); + if (bs) { + aio_context = bdrv_get_aio_context(bs); + aio_context_acquire(aio_context); - if (bs->job) { - block_job_cancel(bs->job); - } + if (bs->job) { + block_job_cancel(bs->job); + } - aio_context_release(aio_context); + aio_context_release(aio_context); + } dinfo->auto_del = 1; } @@ -229,8 +231,8 @@ bool drive_check_orphaned(void) dinfo->type != IF_NONE) { fprintf(stderr, "Warning: Orphaned drive without device: " "id=%s,file=%s,if=%s,bus=%d,unit=%d\n", - blk_name(blk), blk_bs(blk)->filename, if_name[dinfo->type], - dinfo->bus, dinfo->unit); + blk_name(blk), blk_bs(blk) ? blk_bs(blk)->filename : "", + if_name[dinfo->type], dinfo->bus, dinfo->unit); rs = true; } } @@ -1040,6 +1042,10 @@ void hmp_commit(Monitor *mon, const QDict *qdict) monitor_printf(mon, "Device '%s' not found\n", device); return; } + if (!blk_is_available(blk)) { + monitor_printf(mon, "Device '%s' has no medium\n", device); + return; + } ret = bdrv_commit(blk_bs(blk)); } if (ret < 0) { @@ -1119,7 +1125,9 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device, "Device '%s' not found", device); return NULL; } - bs = blk_bs(blk); + + aio_context = blk_get_aio_context(blk); + aio_context_acquire(aio_context); if (!has_id) { id = NULL; @@ -1131,11 +1139,14 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device, if (!id && !name) { error_setg(errp, "Name or id must be provided"); - return NULL; + goto out_aio_context; } - aio_context = bdrv_get_aio_context(bs); - aio_context_acquire(aio_context); + if (!blk_is_available(blk)) { + error_setg(errp, "Device '%s' has no medium", device); + goto out_aio_context; + } + bs = blk_bs(blk); if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_INTERNAL_SNAPSHOT_DELETE, errp)) { goto out_aio_context; @@ -1309,16 +1320,16 @@ static void internal_snapshot_prepare(BlkTransactionState *common, "Device '%s' not found", device); return; } - bs = blk_bs(blk); /* AioContext is released in .clean() */ - state->aio_context = bdrv_get_aio_context(bs); + state->aio_context = blk_get_aio_context(blk); aio_context_acquire(state->aio_context); - if (!bdrv_is_inserted(bs)) { + if (!blk_is_available(blk)) { error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); return; } + bs = blk_bs(blk); if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_INTERNAL_SNAPSHOT, errp)) { return; @@ -1570,7 +1581,6 @@ typedef struct DriveBackupState { static void drive_backup_prepare(BlkTransactionState *common, Error **errp) { DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common); - BlockDriverState *bs; BlockBackend *blk; DriveBackup *backup; Error *local_err = NULL; @@ -1584,12 +1594,16 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp) "Device '%s' not found", backup->device); return; } - bs = blk_bs(blk); /* AioContext is released in .clean() */ - state->aio_context = bdrv_get_aio_context(bs); + state->aio_context = blk_get_aio_context(blk); aio_context_acquire(state->aio_context); + if (!blk_is_available(blk)) { + error_setg(errp, "Device '%s' has no medium", backup->device); + return; + } + qmp_drive_backup(backup->device, backup->target, backup->has_format, backup->format, backup->sync, @@ -1604,7 +1618,7 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp) return; } - state->bs = bs; + state->bs = blk_bs(blk); state->job = state->bs->job; } @@ -1639,8 +1653,7 @@ static void blockdev_backup_prepare(BlkTransactionState *common, Error **errp) { BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common); BlockdevBackup *backup; - BlockDriverState *bs, *target; - BlockBackend *blk; + BlockBackend *blk, *target; Error *local_err = NULL; assert(common->action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); @@ -1651,18 +1664,16 @@ static void blockdev_backup_prepare(BlkTransactionState *common, Error **errp) error_setg(errp, "Device '%s' not found", backup->device); return; } - bs = blk_bs(blk); - blk = blk_by_name(backup->target); - if (!blk) { + target = blk_by_name(backup->target); + if (!target) { error_setg(errp, "Device '%s' not found", backup->target); return; } - target = blk_bs(blk); /* AioContext is released in .clean() */ - state->aio_context = bdrv_get_aio_context(bs); - if (state->aio_context != bdrv_get_aio_context(target)) { + state->aio_context = blk_get_aio_context(blk); + if (state->aio_context != blk_get_aio_context(target)) { state->aio_context = NULL; error_setg(errp, "Backup between two IO threads is not implemented"); return; @@ -1680,7 +1691,7 @@ static void blockdev_backup_prepare(BlkTransactionState *common, Error **errp) return; } - state->bs = bs; + state->bs = blk_bs(blk); state->job = state->bs->job; } @@ -1818,10 +1829,10 @@ static void eject_device(BlockBackend *blk, int force, Error **errp) BlockDriverState *bs = blk_bs(blk); AioContext *aio_context; - aio_context = bdrv_get_aio_context(bs); + aio_context = blk_get_aio_context(blk); aio_context_acquire(aio_context); - if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_EJECT, errp)) { + if (bs && bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_EJECT, errp)) { goto out; } if (!blk_dev_has_removable_media(blk)) { @@ -1839,7 +1850,9 @@ static void eject_device(BlockBackend *blk, int force, Error **errp) } } - bdrv_close(bs); + if (bs) { + bdrv_close(bs); + } out: aio_context_release(aio_context); @@ -1884,10 +1897,12 @@ void qmp_block_passwd(bool has_device, const char *device, } /* Assumes AioContext is held */ -static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename, +static void qmp_bdrv_open_encrypted(BlockDriverState **pbs, + const char *filename, int bdrv_flags, const char *format, const char *password, Error **errp) { + BlockDriverState *bs; Error *local_err = NULL; QDict *options = NULL; int ret; @@ -1897,11 +1912,12 @@ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename, qdict_put(options, "driver", qstring_from_str(format)); } - ret = bdrv_open(&bs, filename, NULL, options, bdrv_flags, &local_err); + ret = bdrv_open(pbs, filename, NULL, options, bdrv_flags, &local_err); if (ret < 0) { error_propagate(errp, local_err); return; } + bs = *pbs; bdrv_add_key(bs, password, errp); } @@ -1913,6 +1929,7 @@ void qmp_change_blockdev(const char *device, const char *filename, BlockDriverState *bs; AioContext *aio_context; int bdrv_flags; + bool new_bs; Error *err = NULL; blk = blk_by_name(device); @@ -1922,8 +1939,9 @@ void qmp_change_blockdev(const char *device, const char *filename, return; } bs = blk_bs(blk); + new_bs = !bs; - aio_context = bdrv_get_aio_context(bs); + aio_context = blk_get_aio_context(blk); aio_context_acquire(aio_context); eject_device(blk, 0, &err); @@ -1932,10 +1950,18 @@ void qmp_change_blockdev(const char *device, const char *filename, goto out; } - bdrv_flags = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR; - bdrv_flags |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0; + bdrv_flags = blk_is_read_only(blk) ? 0 : BDRV_O_RDWR; + bdrv_flags |= blk_get_root_state(blk)->open_flags & ~BDRV_O_RDWR; - qmp_bdrv_open_encrypted(bs, filename, bdrv_flags, format, NULL, errp); + qmp_bdrv_open_encrypted(&bs, filename, bdrv_flags, format, NULL, &err); + if (err) { + error_propagate(errp, err); + } else if (new_bs) { + blk_insert_bs(blk, bs); + /* Has been sent automatically by bdrv_open() if blk_bs(blk) was not + * NULL */ + blk_dev_change_media_cb(blk, true); + } out: aio_context_release(aio_context); @@ -1975,7 +2001,15 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, "Device '%s' not found", device); return; } + + aio_context = blk_get_aio_context(blk); + aio_context_acquire(aio_context); + bs = blk_bs(blk); + if (!bs) { + error_setg(errp, "Device '%s' has no medium", device); + goto out; + } memset(&cfg, 0, sizeof(cfg)); cfg.buckets[THROTTLE_BPS_TOTAL].avg = bps; @@ -2010,12 +2044,9 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, } if (!check_throttle_config(&cfg, errp)) { - return; + goto out; } - aio_context = bdrv_get_aio_context(bs); - aio_context_acquire(aio_context); - if (throttle_enabled(&cfg)) { /* Enable I/O limits if they're not enabled yet, otherwise * just update the throttling group. */ @@ -2031,6 +2062,7 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, bdrv_io_limits_disable(bs); } +out: aio_context_release(aio_context); } @@ -2143,7 +2175,6 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict) error_report("Device '%s' not found", id); return; } - bs = blk_bs(blk); if (!blk_legacy_dinfo(blk)) { error_report("Deleting device added with blockdev-add" @@ -2151,16 +2182,19 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict) return; } - aio_context = bdrv_get_aio_context(bs); + aio_context = blk_get_aio_context(blk); aio_context_acquire(aio_context); - if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) { + bs = blk_bs(blk); + if (bs && bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) { error_report_err(local_err); aio_context_release(aio_context); return; } - bdrv_close(bs); + if (bs) { + bdrv_close(bs); + } /* if we have a device attached to this BlockDriverState * then we need to make the drive anonymous until the device @@ -2293,11 +2327,16 @@ void qmp_block_stream(const char *device, "Device '%s' not found", device); return; } - bs = blk_bs(blk); - aio_context = bdrv_get_aio_context(bs); + aio_context = blk_get_aio_context(blk); aio_context_acquire(aio_context); + if (!blk_is_available(blk)) { + error_setg(errp, "Device '%s' has no medium", device); + goto out; + } + bs = blk_bs(blk); + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_STREAM, errp)) { goto out; } @@ -2368,11 +2407,16 @@ void qmp_block_commit(const char *device, "Device '%s' not found", device); return; } - bs = blk_bs(blk); - aio_context = bdrv_get_aio_context(bs); + aio_context = blk_get_aio_context(blk); aio_context_acquire(aio_context); + if (!blk_is_available(blk)) { + error_setg(errp, "Device '%s' has no medium", device); + goto out; + } + bs = blk_bs(blk); + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT_SOURCE, errp)) { goto out; } @@ -2478,17 +2522,17 @@ void qmp_drive_backup(const char *device, const char *target, "Device '%s' not found", device); return; } - bs = blk_bs(blk); - aio_context = bdrv_get_aio_context(bs); + aio_context = blk_get_aio_context(blk); aio_context_acquire(aio_context); /* Although backup_run has this check too, we need to use bs->drv below, so * do an early check redundantly. */ - if (!bdrv_is_inserted(bs)) { + if (!blk_is_available(blk)) { error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); goto out; } + bs = blk_bs(blk); if (!has_format) { format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name; @@ -2585,7 +2629,7 @@ void qmp_blockdev_backup(const char *device, const char *target, BlockdevOnError on_target_error, Error **errp) { - BlockBackend *blk; + BlockBackend *blk, *target_blk; BlockDriverState *bs; BlockDriverState *target_bs; Error *local_err = NULL; @@ -2606,17 +2650,27 @@ void qmp_blockdev_backup(const char *device, const char *target, error_setg(errp, "Device '%s' not found", device); return; } - bs = blk_bs(blk); - aio_context = bdrv_get_aio_context(bs); + aio_context = blk_get_aio_context(blk); aio_context_acquire(aio_context); - blk = blk_by_name(target); - if (!blk) { + if (!blk_is_available(blk)) { + error_setg(errp, "Device '%s' has no medium", device); + goto out; + } + bs = blk_bs(blk); + + target_blk = blk_by_name(target); + if (!target_blk) { error_setg(errp, "Device '%s' not found", target); goto out; } - target_bs = blk_bs(blk); + + if (!blk_is_available(target_blk)) { + error_setg(errp, "Device '%s' has no medium", target); + goto out; + } + target_bs = blk_bs(target_blk); bdrv_ref(target_bs); bdrv_set_aio_context(target_bs, aio_context); @@ -2693,15 +2747,15 @@ void qmp_drive_mirror(const char *device, const char *target, "Device '%s' not found", device); return; } - bs = blk_bs(blk); - aio_context = bdrv_get_aio_context(bs); + aio_context = blk_get_aio_context(blk); aio_context_acquire(aio_context); - if (!bdrv_is_inserted(bs)) { + if (!blk_is_available(blk)) { error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); goto out; } + bs = blk_bs(blk); if (!has_format) { format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name; @@ -2831,17 +2885,22 @@ static BlockJob *find_block_job(const char *device, AioContext **aio_context, BlockBackend *blk; BlockDriverState *bs; + *aio_context = NULL; + blk = blk_by_name(device); if (!blk) { goto notfound; } - bs = blk_bs(blk); - *aio_context = bdrv_get_aio_context(bs); + *aio_context = blk_get_aio_context(blk); aio_context_acquire(*aio_context); + if (!blk_is_available(blk)) { + goto notfound; + } + bs = blk_bs(blk); + if (!bs->job) { - aio_context_release(*aio_context); goto notfound; } @@ -2850,7 +2909,10 @@ static BlockJob *find_block_job(const char *device, AioContext **aio_context, notfound: error_set(errp, ERROR_CLASS_DEVICE_NOT_ACTIVE, "No active block job on device '%s'", device); - *aio_context = NULL; + if (*aio_context) { + aio_context_release(*aio_context); + *aio_context = NULL; + } return NULL; } @@ -2957,11 +3019,16 @@ void qmp_change_backing_file(const char *device, "Device '%s' not found", device); return; } - bs = blk_bs(blk); - aio_context = bdrv_get_aio_context(bs); + aio_context = blk_get_aio_context(blk); aio_context_acquire(aio_context); + if (!blk_is_available(blk)) { + error_setg(errp, "Device '%s' has no medium", device); + goto out; + } + bs = blk_bs(blk); + image_bs = bdrv_lookup_bs(NULL, image_node_name, &local_err); if (local_err) { error_propagate(errp, local_err); diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c index 36d7398..1bbc111 100644 --- a/hw/block/xen_disk.c +++ b/hw/block/xen_disk.c @@ -931,9 +931,11 @@ static int blk_connect(struct XenDevice *xendev) blk_attach_dev_nofail(blkdev->blk, blkdev); blkdev->file_size = blk_getlength(blkdev->blk); if (blkdev->file_size < 0) { + BlockDriverState *bs = blk_bs(blkdev->blk); + const char *drv_name = bs ? bdrv_get_format_name(bs) : NULL; xen_be_printf(&blkdev->xendev, 1, "blk_getlength: %d (%s) | drv %s\n", (int)blkdev->file_size, strerror(-blkdev->file_size), - bdrv_get_format_name(blk_bs(blkdev->blk)) ?: "-"); + drv_name ?: "-"); blkdev->file_size = 0; } diff --git a/migration/block.c b/migration/block.c index ed865ed..f7bb1e0 100644 --- a/migration/block.c +++ b/migration/block.c @@ -808,6 +808,11 @@ static int block_load(QEMUFile *f, void *opaque, int version_id) return -EINVAL; } bs = blk_bs(blk); + if (!bs) { + fprintf(stderr, "Block device %s has no medium\n", + device_name); + return -EINVAL; + } if (bs != bs_prev) { bs_prev = bs; diff --git a/monitor.c b/monitor.c index 1f43263..94b7267 100644 --- a/monitor.c +++ b/monitor.c @@ -4130,6 +4130,10 @@ int monitor_read_block_device_key(Monitor *mon, const char *device, monitor_printf(mon, "Device not found %s\n", device); return -1; } + if (!blk_bs(blk)) { + monitor_printf(mon, "Device '%s' has no medium\n", device); + return -1; + } bdrv_add_key(blk_bs(blk), NULL, &err); if (err) { -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:48 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWq-00087k-KZ for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWn-00082q-TK for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWi-0006Dc-WD for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43540) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWi-0006DY-Py; Fri, 18 Sep 2015 11:24:40 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 726E72FE803; Fri, 18 Sep 2015 15:24:40 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOcra024218 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:39 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:23:04 +0200 Message-Id: <1442589793-7105-30-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 29/38] blockdev: Add blockdev-remove-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:47 -0000 Signed-off-by: Max Reitz --- blockdev.c | 30 ++++++++++++++++++++++++++++++ qapi/block-core.json | 15 +++++++++++++++ qmp-commands.hx | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) diff --git a/blockdev.c b/blockdev.c index d07bf8a..b7835e4 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2131,6 +2131,36 @@ void qmp_blockdev_close_tray(const char *device, Error **errp) blk_dev_change_media_cb(blk, true); } +void qmp_blockdev_remove_medium(const char *device, Error **errp) +{ + BlockBackend *blk; + bool has_device; + + blk = blk_by_name(device); + if (!blk) { + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + "Device '%s' not found", device); + return; + } + + /* For BBs without a device, we can exchange the BDS tree at will */ + has_device = blk_get_attached_dev(blk); + + if (has_device && !blk_dev_has_removable_media(blk)) { + error_setg(errp, "Device '%s' is not removable", device); + return; + } + + if (has_device && !blk_dev_is_tray_open(blk)) { + error_setg(errp, "Tray of device '%s' is not open", device); + return; + } + + if (blk_bs(blk)) { + blk_remove_bs(blk); + } +} + /* throttling disk I/O limits */ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, int64_t bps_wr, diff --git a/qapi/block-core.json b/qapi/block-core.json index 1a51829..8edf5d9 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1915,6 +1915,21 @@ { 'command': 'blockdev-close-tray', 'data': { 'device': 'str' } } +## +# @blockdev-remove-medium: +# +# Removes a medium (a block driver state tree) from a block device. That block +# device's tray must currently be open. +# +# If the tray is open and there is no medium inserted, this will be a no-op. +# +# @device: block device name +# +# Since: 2.5 +## +{ 'command': 'blockdev-remove-medium', + 'data': { 'device': 'str' } } + ## # @BlockErrorAction diff --git a/qmp-commands.hx b/qmp-commands.hx index 7c7125a..a9594a7 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3971,6 +3971,51 @@ Example: EQMP { + .name = "blockdev-remove-medium", + .args_type = "device:s", + .mhandler.cmd_new = qmp_marshal_input_blockdev_remove_medium, + }, + +SQMP +blockdev-remove-medium +---------------------- + +Removes a medium (a block driver state tree) from a block device. That block +device's tray must currently be open. + +If the tray is open and there is no medium inserted, this will be a no-op. + +Arguments: + +- "device": block device name (json-string) + +Example: + +-> { "execute": "blockdev-remove-medium", + "arguments": { "device": "ide1-cd0" } } + +<- { "error": { "class": "GenericError", + "desc": "Tray of device 'ide1-cd0' is not open" } } + +-> { "execute": "blockdev-open-tray", + "arguments": { "device": "ide1-cd0" } } + +<- { "timestamp": { "seconds": 1418751627, + "microseconds": 549958 }, + "event": "DEVICE_TRAY_MOVED", + "data": { "device": "ide1-cd0", + "tray-open": true } } + +<- { "return": {} } + +-> { "execute": "blockdev-remove-medium", + "arguments": { "device": "ide1-cd0" } } + +<- { "return": {} } + +EQMP + + { .name = "query-named-block-nodes", .args_type = "", .mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes, -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:49 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWr-00089a-QK for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWp-00085b-AL for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWo-0006FG-JU for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52632) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWo-0006FA-Em; Fri, 18 Sep 2015 11:24:46 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 20D508E6FC; Fri, 18 Sep 2015 15:24:46 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOiSj019002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:45 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:23:06 +0200 Message-Id: <1442589793-7105-32-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 31/38] blockdev: Implement eject with basic operations X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:48 -0000 Implement 'eject' by calling blockdev-open-tray and blockdev-remove-medium. Signed-off-by: Max Reitz --- blockdev.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/blockdev.c b/blockdev.c index bbcea00..2644a4a 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1952,16 +1952,15 @@ out: void qmp_eject(const char *device, bool has_force, bool force, Error **errp) { - BlockBackend *blk; + Error *local_err = NULL; - blk = blk_by_name(device); - if (!blk) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, - "Device '%s' not found", device); + qmp_blockdev_open_tray(device, has_force, force, &local_err); + if (local_err) { + error_propagate(errp, local_err); return; } - eject_device(blk, force, errp); + qmp_blockdev_remove_medium(device, errp); } void qmp_block_passwd(bool has_device, const char *device, -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWl-0007zV-FP for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWh-0007qS-4X for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWg-0006CI-8l for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWg-0006C5-2B; Fri, 18 Sep 2015 11:24:38 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id B25FF2F90C6; Fri, 18 Sep 2015 15:24:37 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOZ5m019204 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:37 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:23:03 +0200 Message-Id: <1442589793-7105-29-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 28/38] blockdev: Add blockdev-close-tray X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:40 -0000 Signed-off-by: Max Reitz --- blockdev.c | 23 +++++++++++++++++++++++ qapi/block-core.json | 16 ++++++++++++++++ qmp-commands.hx | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/blockdev.c b/blockdev.c index 6bc5841..d07bf8a 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2108,6 +2108,29 @@ out: } } +void qmp_blockdev_close_tray(const char *device, Error **errp) +{ + BlockBackend *blk; + + blk = blk_by_name(device); + if (!blk) { + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + "Device '%s' not found", device); + return; + } + + if (!blk_dev_has_removable_media(blk)) { + error_setg(errp, "Device '%s' is not removable", device); + return; + } + + if (!blk_dev_is_tray_open(blk)) { + return; + } + + blk_dev_change_media_cb(blk, true); +} + /* throttling disk I/O limits */ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, int64_t bps_wr, diff --git a/qapi/block-core.json b/qapi/block-core.json index b9b4a24..1a51829 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1899,6 +1899,22 @@ 'data': { 'device': 'str', '*force': 'bool' } } +## +# @blockdev-close-tray: +# +# Closes a block device's tray. If there is a block driver state tree associated +# with the block device (which is currently ejected), that tree will be loaded +# as the medium. +# +# If the tray was already closed before, this will be a no-op. +# +# @device: block device name +# +# Since: 2.5 +## +{ 'command': 'blockdev-close-tray', + 'data': { 'device': 'str' } } + ## # @BlockErrorAction diff --git a/qmp-commands.hx b/qmp-commands.hx index f6ea5ea..7c7125a 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3936,6 +3936,41 @@ Example: EQMP { + .name = "blockdev-close-tray", + .args_type = "device:s", + .mhandler.cmd_new = qmp_marshal_input_blockdev_close_tray, + }, + +SQMP +blockdev-close-tray +------------------- + +Closes a block device's tray. If there is a block driver state tree associated +with the block device (which is currently ejected), that tree will be loaded as +the medium. + +If the tray was already closed before, this will be a no-op. + +Arguments: + +- "device": block device name (json-string) + +Example: + +-> { "execute": "blockdev-close-tray", + "arguments": { "device": "ide1-cd0" } } + +<- { "timestamp": { "seconds": 1418751345, + "microseconds": 272147 }, + "event": "DEVICE_TRAY_MOVED", + "data": { "device": "ide1-cd0", + "tray-open": false } } + +<- { "return": {} } + +EQMP + + { .name = "query-named-block-nodes", .args_type = "", .mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes, -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWX-0007XH-Cx for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWS-0007QP-U7 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWS-000665-5m for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWR-00065k-VZ; Fri, 18 Sep 2015 11:24:24 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 9FA3FA2C00; Fri, 18 Sep 2015 15:24:23 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOLNG018736 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:22 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:22:58 +0200 Message-Id: <1442589793-7105-24-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 23/38] blockdev: Do not create BDS for empty drive X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:26 -0000 Do not use "rudimentary" BDSs for empty drives any longer (for freshly created drives). After a follow-up patch, empty drives will generally use a NULL BDS, not only the freshly created drives. Signed-off-by: Max Reitz --- blockdev.c | 72 ++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/blockdev.c b/blockdev.c index 6168b09..e76a7de 100644 --- a/blockdev.c +++ b/blockdev.c @@ -514,16 +514,44 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, goto early_err; } + if (snapshot) { + /* always use cache=unsafe with snapshot */ + bdrv_flags &= ~BDRV_O_CACHE_MASK; + bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH); + } + + if (copy_on_read) { + bdrv_flags |= BDRV_O_COPY_ON_READ; + } + + if (runstate_check(RUN_STATE_INMIGRATE)) { + bdrv_flags |= BDRV_O_INCOMING; + } + + bdrv_flags |= ro ? 0 : BDRV_O_RDWR; + /* init */ if ((!file || !*file) && !has_driver_specific_opts) { - blk = blk_new_with_bs(qemu_opts_id(opts), errp); + BlockBackendRootState *blk_rs; + + blk = blk_new(qemu_opts_id(opts), errp); if (!blk) { goto early_err; } - bs = blk_bs(blk); - bs->open_flags = snapshot ? BDRV_O_SNAPSHOT : 0; - bs->read_only = ro; + blk_rs = blk_get_root_state(blk); + blk_rs->open_flags = bdrv_flags; + blk_rs->read_only = ro; + blk_rs->detect_zeroes = detect_zeroes; + + if (throttle_enabled(&cfg)) { + if (!throttling_group) { + throttling_group = blk_name(blk); + } + blk_rs->io_limits_enabled = true; + blk_rs->throttle_config = cfg; + blk_rs->throttle_group_name = g_strdup(throttling_group); + } QDECREF(bs_opts); } else { @@ -531,42 +559,30 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, file = NULL; } - if (snapshot) { - /* always use cache=unsafe with snapshot */ - bdrv_flags &= ~BDRV_O_CACHE_MASK; - bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH); - } - - if (copy_on_read) { - bdrv_flags |= BDRV_O_COPY_ON_READ; - } - - bdrv_flags |= ro ? 0 : BDRV_O_RDWR; - blk = blk_new_open(qemu_opts_id(opts), file, NULL, bs_opts, bdrv_flags, errp); if (!blk) { goto err_no_bs_opts; } bs = blk_bs(blk); - } - bs->detect_zeroes = detect_zeroes; + bs->detect_zeroes = detect_zeroes; - blk_set_on_error(blk, on_read_error, on_write_error); + /* disk I/O throttling */ + if (throttle_enabled(&cfg)) { + if (!throttling_group) { + throttling_group = blk_name(blk); + } + bdrv_io_limits_enable(bs, throttling_group); + bdrv_set_io_limits(bs, &cfg); + } - /* disk I/O throttling */ - if (throttle_enabled(&cfg)) { - if (!throttling_group) { - throttling_group = blk_name(blk); + if (bdrv_key_required(bs)) { + autostart = 0; } - bdrv_io_limits_enable(bs, throttling_group); - bdrv_set_io_limits(bs, &cfg); } - if (bdrv_key_required(bs)) { - autostart = 0; - } + blk_set_on_error(blk, on_read_error, on_write_error); err_no_bs_opts: qemu_opts_del(opts); -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:59 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxX0-0008QE-JS for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWs-0008Bu-Sd for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWr-0006GJ-OD for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWr-0006G6-HI; Fri, 18 Sep 2015 11:24:49 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 091BEAB4; Fri, 18 Sep 2015 15:24:49 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOkAe024285 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:48 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:23:07 +0200 Message-Id: <1442589793-7105-33-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 32/38] blockdev: Implement change with basic operations X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:56 -0000 Implement 'change' on block devices by calling blockdev-open-tray, blockdev-remove-medium, blockdev-insert-medium (a variation of that which does not need a node-name) and blockdev-close-tray. Signed-off-by: Max Reitz --- blockdev.c | 181 +++++++++++++++++++++++++------------------------------------ 1 file changed, 75 insertions(+), 106 deletions(-) diff --git a/blockdev.c b/blockdev.c index 2644a4a..3882033 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1915,41 +1915,6 @@ exit: } } - -static void eject_device(BlockBackend *blk, int force, Error **errp) -{ - BlockDriverState *bs = blk_bs(blk); - AioContext *aio_context; - - aio_context = blk_get_aio_context(blk); - aio_context_acquire(aio_context); - - if (bs && bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_EJECT, errp)) { - goto out; - } - if (!blk_dev_has_removable_media(blk)) { - error_setg(errp, "Device '%s' is not removable", - bdrv_get_device_name(bs)); - goto out; - } - - if (blk_dev_is_medium_locked(blk) && !blk_dev_is_tray_open(blk)) { - blk_dev_eject_request(blk, force); - if (!force) { - error_setg(errp, "Device '%s' is locked", - bdrv_get_device_name(bs)); - goto out; - } - } - - if (bs) { - bdrv_close(bs); - } - -out: - aio_context_release(aio_context); -} - void qmp_eject(const char *device, bool has_force, bool force, Error **errp) { Error *local_err = NULL; @@ -1987,77 +1952,6 @@ void qmp_block_passwd(bool has_device, const char *device, aio_context_release(aio_context); } -/* Assumes AioContext is held */ -static void qmp_bdrv_open_encrypted(BlockDriverState **pbs, - const char *filename, - int bdrv_flags, const char *format, - const char *password, Error **errp) -{ - BlockDriverState *bs; - Error *local_err = NULL; - QDict *options = NULL; - int ret; - - if (format) { - options = qdict_new(); - qdict_put(options, "driver", qstring_from_str(format)); - } - - ret = bdrv_open(pbs, filename, NULL, options, bdrv_flags, &local_err); - if (ret < 0) { - error_propagate(errp, local_err); - return; - } - bs = *pbs; - - bdrv_add_key(bs, password, errp); -} - -void qmp_change_blockdev(const char *device, const char *filename, - const char *format, Error **errp) -{ - BlockBackend *blk; - BlockDriverState *bs; - AioContext *aio_context; - int bdrv_flags; - bool new_bs; - Error *err = NULL; - - blk = blk_by_name(device); - if (!blk) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, - "Device '%s' not found", device); - return; - } - bs = blk_bs(blk); - new_bs = !bs; - - aio_context = blk_get_aio_context(blk); - aio_context_acquire(aio_context); - - eject_device(blk, 0, &err); - if (err) { - error_propagate(errp, err); - goto out; - } - - bdrv_flags = blk_is_read_only(blk) ? 0 : BDRV_O_RDWR; - bdrv_flags |= blk_get_root_state(blk)->open_flags & ~BDRV_O_RDWR; - - qmp_bdrv_open_encrypted(&bs, filename, bdrv_flags, format, NULL, &err); - if (err) { - error_propagate(errp, err); - } else if (new_bs) { - blk_insert_bs(blk, bs); - /* Has been sent automatically by bdrv_open() if blk_bs(blk) was not - * NULL */ - blk_dev_change_media_cb(blk, true); - } - -out: - aio_context_release(aio_context); -} - void qmp_blockdev_open_tray(const char *device, bool has_force, bool force, Error **errp) { @@ -2208,6 +2102,81 @@ void qmp_blockdev_insert_medium(const char *device, const char *node_name, qmp_blockdev_insert_anon_medium(device, bs, errp); } +void qmp_change_blockdev(const char *device, const char *filename, + const char *format, Error **errp) +{ + BlockBackend *blk; + BlockBackendRootState *blk_rs; + BlockDriverState *medium_bs = NULL; + int bdrv_flags, ret; + QDict *options = NULL; + Error *err = NULL; + + blk = blk_by_name(device); + if (!blk) { + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + "Device '%s' not found", device); + goto fail; + } + + if (blk_bs(blk)) { + blk_update_root_state(blk); + } + + blk_rs = blk_get_root_state(blk); + bdrv_flags = blk_rs->read_only ? 0 : BDRV_O_RDWR; + bdrv_flags |= blk_rs->open_flags & ~BDRV_O_RDWR; + + if (format) { + options = qdict_new(); + qdict_put(options, "driver", qstring_from_str(format)); + } + + assert(!medium_bs); + ret = bdrv_open(&medium_bs, filename, NULL, options, bdrv_flags, errp); + if (ret < 0) { + goto fail; + } + + medium_bs->detect_zeroes = blk_rs->detect_zeroes; + if (blk_rs->io_limits_enabled) { + bdrv_io_limits_enable(medium_bs, blk_rs->throttle_group_name); + bdrv_set_io_limits(medium_bs, &blk_rs->throttle_config); + } + + bdrv_add_key(medium_bs, NULL, &err); + if (err) { + error_propagate(errp, err); + goto fail; + } + + qmp_blockdev_open_tray(device, false, false, &err); + if (err) { + error_propagate(errp, err); + goto fail; + } + + qmp_blockdev_remove_medium(device, &err); + if (err) { + error_propagate(errp, err); + goto fail; + } + + qmp_blockdev_insert_anon_medium(device, medium_bs, &err); + if (err) { + error_propagate(errp, err); + goto fail; + } + + qmp_blockdev_close_tray(device, errp); + +fail: + /* If the medium has been inserted, the device has its own reference, so + * ours must be relinquished; and if it has not been inserted successfully, + * the reference must be relinquished anyway */ + bdrv_unref(medium_bs); +} + /* throttling disk I/O limits */ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, int64_t bps_wr, -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:59 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxX0-0008Qa-ON for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWy-0008LY-4v for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWu-0006H5-2l for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42976) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWt-0006Gh-Uo; Fri, 18 Sep 2015 11:24:52 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 98A0991C16; Fri, 18 Sep 2015 15:24:51 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOnXJ024174 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:51 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:23:08 +0200 Message-Id: <1442589793-7105-34-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 33/38] block: Inquire tray state before tray-moved events X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:57 -0000 blk_dev_change_media_cb() is called for all potential tray movements; however, it is possible to request closing the tray but nothing actually happening (on a floppy disk drive without a medium). Thus, the actual tray status should be inquired before sending a tray-moved event (and an event should be sent whenever the status changed). Checking @load is now superfluous; it was necessary because it was possible to change a medium without having explicitly opened the tray and closed it again (or it might have been possible, at least). This is no longer possible, though. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block/block-backend.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 66ecc07..09efb8b 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -422,18 +422,15 @@ void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void blk_dev_change_media_cb(BlockBackend *blk, bool load) { if (blk->dev_ops && blk->dev_ops->change_media_cb) { - bool tray_was_closed = !blk_dev_is_tray_open(blk); + bool tray_was_open, tray_is_open; + tray_was_open = blk_dev_is_tray_open(blk); blk->dev_ops->change_media_cb(blk->dev_opaque, load); - if (tray_was_closed) { - /* tray open */ - qapi_event_send_device_tray_moved(blk_name(blk), - true, &error_abort); - } - if (load) { - /* tray close */ - qapi_event_send_device_tray_moved(blk_name(blk), - false, &error_abort); + tray_is_open = blk_dev_is_tray_open(blk); + + if (tray_was_open != tray_is_open) { + qapi_event_send_device_tray_moved(blk_name(blk), tray_is_open, + &error_abort); } } } -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWw-0008I9-Bq for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWn-00082w-Tz for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWm-0006EK-2o for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41503) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWl-0006EC-RF; Fri, 18 Sep 2015 11:24:44 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 7EC8B83F81; Fri, 18 Sep 2015 15:24:43 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOfQ5019277 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:42 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:23:05 +0200 Message-Id: <1442589793-7105-31-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 30/38] blockdev: Add blockdev-insert-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:52 -0000 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). Signed-off-by: Max Reitz --- blockdev.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ qapi/block-core.json | 17 +++++++++++++++++ qmp-commands.hx | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) diff --git a/blockdev.c b/blockdev.c index b7835e4..bbcea00 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2161,6 +2161,54 @@ void qmp_blockdev_remove_medium(const char *device, Error **errp) } } +static void qmp_blockdev_insert_anon_medium(const char *device, + BlockDriverState *bs, Error **errp) +{ + BlockBackend *blk; + bool has_device; + + blk = blk_by_name(device); + if (!blk) { + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + "Device '%s' not found", device); + return; + } + + /* For BBs without a device, we can exchange the BDS tree at will */ + has_device = blk_get_attached_dev(blk); + + if (has_device && !blk_dev_has_removable_media(blk)) { + error_setg(errp, "Device '%s' is not removable", device); + return; + } + + if (has_device && !blk_dev_is_tray_open(blk)) { + error_setg(errp, "Tray of device '%s' is not open", device); + return; + } + + if (blk_bs(blk)) { + error_setg(errp, "There already is a medium in device '%s'", device); + return; + } + + blk_insert_bs(blk, bs); +} + +void qmp_blockdev_insert_medium(const char *device, const char *node_name, + Error **errp) +{ + BlockDriverState *bs; + + bs = bdrv_find_node(node_name); + if (!bs) { + error_setg(errp, "Node '%s' not found", node_name); + return; + } + + qmp_blockdev_insert_anon_medium(device, bs, errp); +} + /* throttling disk I/O limits */ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd, int64_t bps_wr, diff --git a/qapi/block-core.json b/qapi/block-core.json index 8edf5d9..81a1f19 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1930,6 +1930,23 @@ { 'command': 'blockdev-remove-medium', 'data': { 'device': 'str' } } +## +# @blockdev-insert-medium: +# +# Inserts a medium (a block driver state tree) into a block device. That block +# device's tray must currently be open and there must be no medium inserted +# already. +# +# @device: block device name +# +# @node-name: name of a node in the block driver state graph +# +# Since: 2.5 +## +{ 'command': 'blockdev-insert-medium', + 'data': { 'device': 'str', + 'node-name': 'str'} } + ## # @BlockErrorAction diff --git a/qmp-commands.hx b/qmp-commands.hx index a9594a7..38a0f5f 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -4016,6 +4016,43 @@ Example: EQMP { + .name = "blockdev-insert-medium", + .args_type = "device:s,node-name:s", + .mhandler.cmd_new = qmp_marshal_input_blockdev_insert_medium, + }, + +SQMP +blockdev-insert-medium +---------------------- + +Inserts a medium (a block driver state tree) into a block device. That block +device's tray must currently be open and there must be no medium inserted +already. + +Arguments: + +- "device": block device name (json-string) +- "node-name": root node of the BDS tree to insert into the block device + +Example: + +-> { "execute": "blockdev-add", + "arguments": { "options": { "node-name": "node0", + "driver": "raw", + "file": { "driver": "file", + "filename": "fedora.iso" } } } } + +<- { "return": {} } + +-> { "execute": "blockdev-insert-medium", + "arguments": { "device": "ide1-cd0", + "node-name": "node0" } } + +<- { "return": {} } + +EQMP + + { .name = "query-named-block-nodes", .args_type = "", .mhandler.cmd_new = qmp_marshal_input_query_named_block_nodes, -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:25:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxX4-0008W0-33 for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:25:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxX0-0008Q6-Hi for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWz-0006Ib-Ne for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43620) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWz-0006IO-C6; Fri, 18 Sep 2015 11:24:57 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 0D15B2F5187; Fri, 18 Sep 2015 15:24:57 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOtTW024241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:56 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:23:10 +0200 Message-Id: <1442589793-7105-36-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 35/38] hmp: Use blockdev-change-medium for change command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:59 -0000 Use separate code paths for the two overloaded functions of the 'change' HMP command, and invoke the 'blockdev-change-medium' QMP command if used on a block device (by calling qmp_blockdev_change_medium()). Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- hmp.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/hmp.c b/hmp.c index 3f807b7..a753a0f 100644 --- a/hmp.c +++ b/hmp.c @@ -1317,22 +1317,25 @@ void hmp_change(Monitor *mon, const QDict *qdict) const char *arg = qdict_get_try_str(qdict, "arg"); Error *err = NULL; - if (strcmp(device, "vnc") == 0 && - (strcmp(target, "passwd") == 0 || - strcmp(target, "password") == 0)) { - if (!arg) { - monitor_read_password(mon, hmp_change_read_arg, NULL); + if (strcmp(device, "vnc") == 0) { + if (strcmp(target, "passwd") == 0 || + strcmp(target, "password") == 0) { + if (!arg) { + monitor_read_password(mon, hmp_change_read_arg, NULL); + return; + } + } + qmp_change("vnc", target, !!arg, arg, &err); + } else { + qmp_blockdev_change_medium(device, target, !!arg, arg, &err); + if (err && + error_get_class(err) == ERROR_CLASS_DEVICE_ENCRYPTED) { + error_free(err); + monitor_read_block_device_key(mon, device, NULL, NULL); return; } } - qmp_change(device, target, !!arg, arg, &err); - if (err && - error_get_class(err) == ERROR_CLASS_DEVICE_ENCRYPTED) { - error_free(err); - monitor_read_block_device_key(mon, device, NULL, NULL); - return; - } hmp_handle_error(mon, &err); } -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:25:08 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxXA-0000GC-C0 for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:25:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxX1-0008RZ-Tp for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:25:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWw-0006He-W4 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56030) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWw-0006HX-OV; Fri, 18 Sep 2015 11:24:54 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 6C9C7C0B56FC; Fri, 18 Sep 2015 15:24:54 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOql2024342 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:53 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:23:09 +0200 Message-Id: <1442589793-7105-35-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 34/38] qmp: Introduce blockdev-change-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:25:01 -0000 Introduce a new QMP command 'blockdev-change-medium' which is intended to replace the 'change' command for block devices. The existing function qmp_change_blockdev() is accordingly renamed to qmp_blockdev_change_medium(). Signed-off-by: Max Reitz --- blockdev.c | 7 ++++--- include/sysemu/blockdev.h | 2 -- qapi-schema.json | 6 ++++-- qapi/block-core.json | 23 +++++++++++++++++++++++ qmp-commands.hx | 31 +++++++++++++++++++++++++++++++ qmp.c | 2 +- 6 files changed, 63 insertions(+), 8 deletions(-) diff --git a/blockdev.c b/blockdev.c index 3882033..2ef0745 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2102,8 +2102,9 @@ void qmp_blockdev_insert_medium(const char *device, const char *node_name, qmp_blockdev_insert_anon_medium(device, bs, errp); } -void qmp_change_blockdev(const char *device, const char *filename, - const char *format, Error **errp) +void qmp_blockdev_change_medium(const char *device, const char *filename, + bool has_format, const char *format, + Error **errp) { BlockBackend *blk; BlockBackendRootState *blk_rs; @@ -2127,7 +2128,7 @@ void qmp_change_blockdev(const char *device, const char *filename, bdrv_flags = blk_rs->read_only ? 0 : BDRV_O_RDWR; bdrv_flags |= blk_rs->open_flags & ~BDRV_O_RDWR; - if (format) { + if (has_format) { options = qdict_new(); qdict_put(options, "driver", qstring_from_str(format)); } diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index 3104150..553b53c 100644 --- a/include/sysemu/blockdev.h +++ b/include/sysemu/blockdev.h @@ -63,8 +63,6 @@ DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type); /* device-hotplug */ -void qmp_change_blockdev(const char *device, const char *filename, - const char *format, Error **errp); void hmp_commit(Monitor *mon, const QDict *qdict); void hmp_drive_del(Monitor *mon, const QDict *qdict); #endif diff --git a/qapi-schema.json b/qapi-schema.json index 2bada60..0d5190b 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1809,8 +1809,10 @@ # device's password. The behavior of reads and writes to the block # device between when these calls are executed is undefined. # -# Notes: It is strongly recommended that this interface is not used especially -# for changing block devices. +# Notes: This interface is deprecated, and it is strongly recommended that you +# avoid using it. For changing block devices, use +# blockdev-change-medium; for changing VNC parameters, use +# change-vnc-password. # # Since: 0.14.0 ## diff --git a/qapi/block-core.json b/qapi/block-core.json index 81a1f19..b8cc18a 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1949,6 +1949,29 @@ ## +# @blockdev-change-medium: +# +# Changes the medium inserted into a block device by ejecting the current medium +# and loading a new image file which is inserted as the new medium (this command +# combines blockdev-open-tray, blockdev-remove-medium, blockdev-insert-medium +# and blockdev-close-tray). +# +# @device: block device name +# +# @filename: filename of the new image to be loaded +# +# @format: #optional, format to open the new image with (defaults to +# the probed format) +# +# Since: 2.5 +## +{ 'command': 'blockdev-change-medium', + 'data': { 'device': 'str', + 'filename': 'str', + '*format': 'str' } } + + +## # @BlockErrorAction # # An enumeration of action that has been taken when a DISK I/O occurs diff --git a/qmp-commands.hx b/qmp-commands.hx index 38a0f5f..538b3d1 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -4115,6 +4115,37 @@ Example: EQMP { + .name = "blockdev-change-medium", + .args_type = "device:B,filename:F,format:s?", + .mhandler.cmd_new = qmp_marshal_input_blockdev_change_medium, + }, + +SQMP +blockdev-change-medium +---------------------- + +Changes the medium inserted into a block device by ejecting the current medium +and loading a new image file which is inserted as the new medium. + +Arguments: + +- "device": device name (json-string) +- "filename": filename of the new image (json-string) +- "format": format of the new image (json-string, optional) + +Examples: + +1. Change a removable medium + +-> { "execute": "blockdev-change-medium", + "arguments": { "device": "ide1-cd0", + "filename": "/srv/images/Fedora-12-x86_64-DVD.iso", + "format": "raw" } } +<- { "return": {} } + +EQMP + + { .name = "query-memdev", .args_type = "", .mhandler.cmd_new = qmp_marshal_input_query_memdev, diff --git a/qmp.c b/qmp.c index 8c3dca8..941fc39 100644 --- a/qmp.c +++ b/qmp.c @@ -419,7 +419,7 @@ void qmp_change(const char *device, const char *target, if (strcmp(device, "vnc") == 0) { qmp_change_vnc(target, has_arg, arg, errp); } else { - qmp_change_blockdev(device, target, arg, errp); + qmp_blockdev_change_medium(device, target, has_arg, arg, errp); } } -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:24:38 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxWg-0007pJ-HS for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:24:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWd-0007jK-63 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxWY-00068g-6j for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:24:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52542) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxWX-00068b-Vj; Fri, 18 Sep 2015 11:24:30 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id A14E48E6E4; Fri, 18 Sep 2015 15:24:29 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFORpt018816 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:28 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:23:00 +0200 Message-Id: <1442589793-7105-26-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 25/38] blockdev: Allow more options for BB-less BDS tree X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:24:36 -0000 Most of the options which blockdev_init() parses for both the BlockBackend and the root BDS are valid for just the root BDS as well (e.g. read-only). This patch allows specifying these options even if not creating a BlockBackend. Signed-off-by: Max Reitz --- blockdev.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 154 insertions(+), 6 deletions(-) diff --git a/blockdev.c b/blockdev.c index 688ee5f..647ce0b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -612,6 +612,65 @@ err_no_opts: return NULL; } +static QemuOptsList qemu_root_bds_opts; + +/* Takes the ownership of bs_opts */ +static BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp) +{ + BlockDriverState *bs; + QemuOpts *opts; + Error *local_error = NULL; + ThrottleConfig cfg; + BlockdevDetectZeroesOptions detect_zeroes; + const char *throttling_group = NULL; + int ret; + int bdrv_flags = 0; + + opts = qemu_opts_create(&qemu_root_bds_opts, NULL, 1, errp); + if (!opts) { + goto fail; + } + + qemu_opts_absorb_qdict(opts, bs_opts, &local_error); + if (local_error) { + error_propagate(errp, local_error); + goto fail; + } + + extract_common_blockdev_options(opts, &bdrv_flags, &cfg, &detect_zeroes, + &throttling_group, &local_error); + if (local_error) { + error_propagate(errp, local_error); + goto fail; + } + + bs = NULL; + ret = bdrv_open(&bs, NULL, NULL, bs_opts, bdrv_flags, errp); + if (ret < 0) { + goto fail_no_bs_opts; + } + + bs->detect_zeroes = detect_zeroes; + + /* disk I/O throttling */ + if (throttle_enabled(&cfg)) { + if (!throttling_group) { + throttling_group = bdrv_get_node_name(bs); + } + bdrv_io_limits_enable(bs, throttling_group); + bdrv_set_io_limits(bs, &cfg); + } + +fail_no_bs_opts: + qemu_opts_del(opts); + return bs; + +fail: + qemu_opts_del(opts); + QDECREF(bs_opts); + return NULL; +} + static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to, Error **errp) { @@ -3170,18 +3229,14 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp) bs = blk_bs(blk); } else { - int ret; - if (!qdict_get_try_str(qdict, "node-name")) { error_setg(errp, "'id' and/or 'node-name' need to be specified for " "the root node"); goto fail; } - bs = NULL; - ret = bdrv_open(&bs, NULL, NULL, qdict, BDRV_O_RDWR | BDRV_O_CACHE_WB, - errp); - if (ret < 0) { + bs = bds_tree_init(qdict, errp); + if (!bs) { goto fail; } } @@ -3336,6 +3391,99 @@ QemuOptsList qemu_common_drive_opts = { }, }; +static QemuOptsList qemu_root_bds_opts = { + .name = "root-bds", + .head = QTAILQ_HEAD_INITIALIZER(qemu_common_drive_opts.head), + .desc = { + { + .name = "discard", + .type = QEMU_OPT_STRING, + .help = "discard operation (ignore/off, unmap/on)", + },{ + .name = "cache.writeback", + .type = QEMU_OPT_BOOL, + .help = "enables writeback mode for any caches", + },{ + .name = "cache.direct", + .type = QEMU_OPT_BOOL, + .help = "enables use of O_DIRECT (bypass the host page cache)", + },{ + .name = "cache.no-flush", + .type = QEMU_OPT_BOOL, + .help = "ignore any flush requests for the device", + },{ + .name = "aio", + .type = QEMU_OPT_STRING, + .help = "host AIO implementation (threads, native)", + },{ + .name = "read-only", + .type = QEMU_OPT_BOOL, + .help = "open drive file as read-only", + },{ + .name = "throttling.iops-total", + .type = QEMU_OPT_NUMBER, + .help = "limit total I/O operations per second", + },{ + .name = "throttling.iops-read", + .type = QEMU_OPT_NUMBER, + .help = "limit read operations per second", + },{ + .name = "throttling.iops-write", + .type = QEMU_OPT_NUMBER, + .help = "limit write operations per second", + },{ + .name = "throttling.bps-total", + .type = QEMU_OPT_NUMBER, + .help = "limit total bytes per second", + },{ + .name = "throttling.bps-read", + .type = QEMU_OPT_NUMBER, + .help = "limit read bytes per second", + },{ + .name = "throttling.bps-write", + .type = QEMU_OPT_NUMBER, + .help = "limit write bytes per second", + },{ + .name = "throttling.iops-total-max", + .type = QEMU_OPT_NUMBER, + .help = "I/O operations burst", + },{ + .name = "throttling.iops-read-max", + .type = QEMU_OPT_NUMBER, + .help = "I/O operations read burst", + },{ + .name = "throttling.iops-write-max", + .type = QEMU_OPT_NUMBER, + .help = "I/O operations write burst", + },{ + .name = "throttling.bps-total-max", + .type = QEMU_OPT_NUMBER, + .help = "total bytes burst", + },{ + .name = "throttling.bps-read-max", + .type = QEMU_OPT_NUMBER, + .help = "total bytes read burst", + },{ + .name = "throttling.bps-write-max", + .type = QEMU_OPT_NUMBER, + .help = "total bytes write burst", + },{ + .name = "throttling.iops-size", + .type = QEMU_OPT_NUMBER, + .help = "when limiting by iops max size of an I/O in bytes", + },{ + .name = "copy-on-read", + .type = QEMU_OPT_BOOL, + .help = "copy read data from backing file into image file", + },{ + .name = "detect-zeroes", + .type = QEMU_OPT_STRING, + .help = "try to optimize zero writes (off, on, unmap)", + }, + { /* end of list */ } + }, +}; + QemuOptsList qemu_drive_opts = { .name = "drive", .head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head), -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:25:14 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxXG-0000SZ-HO for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:25:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxX9-0000DI-9S for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:25:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxX2-0006JW-C9 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:25:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49713) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxX2-0006JL-5q; Fri, 18 Sep 2015 11:25:00 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id D462CC0A1460; Fri, 18 Sep 2015 15:24:59 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFOvGj019453 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:24:59 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:23:11 +0200 Message-Id: <1442589793-7105-37-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 36/38] blockdev: read-only-mode for blockdev-change-medium X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:25:13 -0000 Add an option to qmp_blockdev_change_medium() which allows changing the read-only status of the block device whose medium is changed. Some drives do not have a inherently fixed read-only status; for instance, floppy disks can be set read-only or writable independently of the drive. Some users may find it useful to be able to therefore change the read-only status of a block device when changing the medium. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- blockdev.c | 25 ++++++++++++++++++++++++- hmp.c | 2 +- qapi/block-core.json | 24 +++++++++++++++++++++++- qmp-commands.hx | 24 +++++++++++++++++++++++- qmp.c | 3 ++- 5 files changed, 73 insertions(+), 5 deletions(-) diff --git a/blockdev.c b/blockdev.c index 2ef0745..4731843 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2104,6 +2104,8 @@ void qmp_blockdev_insert_medium(const char *device, const char *node_name, void qmp_blockdev_change_medium(const char *device, const char *filename, bool has_format, const char *format, + bool has_read_only, + BlockdevChangeReadOnlyMode read_only, Error **errp) { BlockBackend *blk; @@ -2125,7 +2127,28 @@ void qmp_blockdev_change_medium(const char *device, const char *filename, } blk_rs = blk_get_root_state(blk); - bdrv_flags = blk_rs->read_only ? 0 : BDRV_O_RDWR; + + if (!has_read_only) { + read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN; + } + + switch (read_only) { + case BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN: + bdrv_flags = blk_rs->read_only ? 0 : BDRV_O_RDWR; + break; + + case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_ONLY: + bdrv_flags = 0; + break; + + case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_WRITE: + bdrv_flags = BDRV_O_RDWR; + break; + + default: + abort(); + } + bdrv_flags |= blk_rs->open_flags & ~BDRV_O_RDWR; if (has_format) { diff --git a/hmp.c b/hmp.c index a753a0f..5ea7ef2 100644 --- a/hmp.c +++ b/hmp.c @@ -1327,7 +1327,7 @@ void hmp_change(Monitor *mon, const QDict *qdict) } qmp_change("vnc", target, !!arg, arg, &err); } else { - qmp_blockdev_change_medium(device, target, !!arg, arg, &err); + qmp_blockdev_change_medium(device, target, !!arg, arg, false, 0, &err); if (err && error_get_class(err) == ERROR_CLASS_DEVICE_ENCRYPTED) { error_free(err); diff --git a/qapi/block-core.json b/qapi/block-core.json index b8cc18a..5f12af7 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1949,6 +1949,24 @@ ## +# @BlockdevChangeReadOnlyMode: +# +# Specifies the new read-only mode of a block device subject to the +# @blockdev-change-medium command. +# +# @retain: Retains the current read-only mode +# +# @read-only: Makes the device read-only +# +# @read-write: Makes the device writable +# +# Since: 2.3 +## +{ 'enum': 'BlockdevChangeReadOnlyMode', + 'data': ['retain', 'read-only', 'read-write'] } + + +## # @blockdev-change-medium: # # Changes the medium inserted into a block device by ejecting the current medium @@ -1963,12 +1981,16 @@ # @format: #optional, format to open the new image with (defaults to # the probed format) # +# @read-only-mode: #optional, change the read-only mode of the device; defaults +# to 'retain' +# # Since: 2.5 ## { 'command': 'blockdev-change-medium', 'data': { 'device': 'str', 'filename': 'str', - '*format': 'str' } } + '*format': 'str', + '*read-only-mode': 'BlockdevChangeReadOnlyMode' } } ## diff --git a/qmp-commands.hx b/qmp-commands.hx index 538b3d1..495670b 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -4116,7 +4116,7 @@ EQMP { .name = "blockdev-change-medium", - .args_type = "device:B,filename:F,format:s?", + .args_type = "device:B,filename:F,format:s?,read-only-mode:s?", .mhandler.cmd_new = qmp_marshal_input_blockdev_change_medium, }, @@ -4132,6 +4132,8 @@ Arguments: - "device": device name (json-string) - "filename": filename of the new image (json-string) - "format": format of the new image (json-string, optional) +- "read-only-mode": new read-only mode (json-string, optional) + - Possible values: "retain" (default), "read-only", "read-write" Examples: @@ -4143,6 +4145,26 @@ Examples: "format": "raw" } } <- { "return": {} } +2. Load a read-only medium into a writable drive + +-> { "execute": "blockdev-change-medium", + "arguments": { "device": "isa-fd0", + "filename": "/srv/images/ro.img", + "format": "raw", + "read-only-mode": "retain" } } + +<- { "error": + { "class": "GenericError", + "desc": "Could not open '/srv/images/ro.img': Permission denied" } } + +-> { "execute": "blockdev-change-medium", + "arguments": { "device": "isa-fd0", + "filename": "/srv/images/ro.img", + "format": "raw", + "read-only-mode": "read-only" } } + +<- { "return": {} } + EQMP { diff --git a/qmp.c b/qmp.c index 941fc39..961c739 100644 --- a/qmp.c +++ b/qmp.c @@ -419,7 +419,8 @@ void qmp_change(const char *device, const char *target, if (strcmp(device, "vnc") == 0) { qmp_change_vnc(target, has_arg, arg, errp); } else { - qmp_blockdev_change_medium(device, target, has_arg, arg, errp); + qmp_blockdev_change_medium(device, target, has_arg, arg, false, 0, + errp); } } -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:25:10 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxXC-0000KQ-Ol for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:25:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxX9-0000DJ-6F for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:25:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxX5-0006Nc-6R for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:25:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxX5-0006N1-09; Fri, 18 Sep 2015 11:25:03 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id A5AFF91E9F; Fri, 18 Sep 2015 15:25:02 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFP0xT024310 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:25:01 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:23:12 +0200 Message-Id: <1442589793-7105-38-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 37/38] hmp: Add read-only-mode option to change command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:25:09 -0000 Expose the new read-only-mode option of 'blockdev-change-medium' for the 'change' HMP command. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- hmp-commands.hx | 20 +++++++++++++++++--- hmp.c | 22 +++++++++++++++++++++- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index a511004..00fb390 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -194,8 +194,8 @@ ETEXI { .name = "change", - .args_type = "device:B,target:F,arg:s?", - .params = "device filename [format]", + .args_type = "device:B,target:F,arg:s?,read-only-mode:s?", + .params = "device filename [format [read-only-mode]]", .help = "change a removable medium, optional format", .mhandler.cmd = hmp_change, }, @@ -206,7 +206,7 @@ STEXI Change the configuration of a device. @table @option -@item change @var{diskdevice} @var{filename} [@var{format}] +@item change @var{diskdevice} @var{filename} [@var{format} [@var{read-only-mode}]] Change the medium for a removable disk device to point to @var{filename}. eg @example @@ -215,6 +215,20 @@ Change the medium for a removable disk device to point to @var{filename}. eg @var{format} is optional. +@var{read-only-mode} may be used to change the read-only status of the device. +It accepts the following values: + +@table @var +@item retain +Retains the current status; this is the default. + +@item read-only +Makes the device read-only. + +@item read-write +Makes the device writable. +@end table + @item change vnc @var{display},@var{options} Change the configuration of the VNC server. The valid syntax for @var{display} and @var{options} are described at @ref{sec_invocation}. eg diff --git a/hmp.c b/hmp.c index 5ea7ef2..6e2bbc8 100644 --- a/hmp.c +++ b/hmp.c @@ -27,6 +27,7 @@ #include "qapi/opts-visitor.h" #include "qapi/qmp/qerror.h" #include "qapi/string-output-visitor.h" +#include "qapi/util.h" #include "qapi-visit.h" #include "ui/console.h" #include "block/qapi.h" @@ -1315,9 +1316,16 @@ void hmp_change(Monitor *mon, const QDict *qdict) const char *device = qdict_get_str(qdict, "device"); const char *target = qdict_get_str(qdict, "target"); const char *arg = qdict_get_try_str(qdict, "arg"); + const char *read_only = qdict_get_try_str(qdict, "read-only-mode"); + BlockdevChangeReadOnlyMode read_only_mode = 0; Error *err = NULL; if (strcmp(device, "vnc") == 0) { + if (read_only) { + monitor_printf(mon, + "Parameter 'read-only-mode' is invalid for VNC"); + return; + } if (strcmp(target, "passwd") == 0 || strcmp(target, "password") == 0) { if (!arg) { @@ -1327,7 +1335,19 @@ void hmp_change(Monitor *mon, const QDict *qdict) } qmp_change("vnc", target, !!arg, arg, &err); } else { - qmp_blockdev_change_medium(device, target, !!arg, arg, false, 0, &err); + if (read_only) { + read_only_mode = + qapi_enum_parse(BlockdevChangeReadOnlyMode_lookup, + read_only, BLOCKDEV_CHANGE_READ_ONLY_MODE_MAX, + BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN, &err); + if (err) { + hmp_handle_error(mon, &err); + return; + } + } + + qmp_blockdev_change_medium(device, target, !!arg, arg, + !!read_only, read_only_mode, &err); if (err && error_get_class(err) == ERROR_CLASS_DEVICE_ENCRYPTED) { error_free(err); -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:25:19 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxXK-0000aQ-O8 for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:25:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxXC-0000Iq-1g for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:25:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxX9-0006Y2-1g for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:25:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43055) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxX8-0006WG-MR; Fri, 18 Sep 2015 11:25:06 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 5D325BE28E; Fri, 18 Sep 2015 15:25:06 +0000 (UTC) Received: from localhost (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFP3S7017452 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 18 Sep 2015 11:25:04 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 18 Sep 2015 17:23:13 +0200 Message-Id: <1442589793-7105-39-git-send-email-mreitz@redhat.com> In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v5 38/38] iotests: Add test for change-related QMP commands X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:25:17 -0000 Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- tests/qemu-iotests/118 | 638 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/118.out | 5 + tests/qemu-iotests/group | 1 + 3 files changed, 644 insertions(+) create mode 100755 tests/qemu-iotests/118 create mode 100644 tests/qemu-iotests/118.out diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118 new file mode 100755 index 0000000..915e439 --- /dev/null +++ b/tests/qemu-iotests/118 @@ -0,0 +1,638 @@ +#!/usr/bin/env python +# +# Test case for the QMP 'change' command and all other associated +# commands +# +# Copyright (C) 2015 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import os +import stat +import time +import iotests +from iotests import qemu_img + +old_img = os.path.join(iotests.test_dir, 'test0.img') +new_img = os.path.join(iotests.test_dir, 'test1.img') + +class ChangeBaseClass(iotests.QMPTestCase): + has_opened = False + has_closed = False + + def process_events(self): + for event in self.vm.get_qmp_events(wait=False): + if (event['event'] == 'DEVICE_TRAY_MOVED' and + event['data']['device'] == 'drive0'): + if event['data']['tray-open'] == False: + self.has_closed = True + else: + self.has_opened = True + + def wait_for_open(self): + timeout = time.clock() + 3 + while not self.has_opened and time.clock() < timeout: + self.process_events() + if not self.has_opened: + self.fail('Timeout while waiting for the tray to open') + + def wait_for_close(self): + timeout = time.clock() + 3 + while not self.has_closed and time.clock() < timeout: + self.process_events() + if not self.has_opened: + self.fail('Timeout while waiting for the tray to close') + +class GeneralChangeTestsBaseClass(ChangeBaseClass): + def test_change(self): + result = self.vm.qmp('change', device='drive0', target=new_img, + arg=iotests.imgfmt) + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + self.wait_for_close() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) + + def test_blockdev_change_medium(self): + result = self.vm.qmp('blockdev-change-medium', device='drive0', + filename=new_img, + format=iotests.imgfmt) + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + self.wait_for_close() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) + + def test_eject(self): + result = self.vm.qmp('eject', device='drive0', force=True) + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', True) + self.assert_qmp_absent(result, 'return[0]/inserted') + + def test_tray_eject_change(self): + result = self.vm.qmp('eject', device='drive0', force=True) + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', True) + self.assert_qmp_absent(result, 'return[0]/inserted') + + result = self.vm.qmp('blockdev-change-medium', device='drive0', + filename=new_img, + format=iotests.imgfmt) + self.assert_qmp(result, 'return', {}) + + self.wait_for_close() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) + + def test_tray_open_close(self): + result = self.vm.qmp('blockdev-open-tray', device='drive0', force=True) + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', True) + if self.was_empty == True: + self.assert_qmp_absent(result, 'return[0]/inserted') + else: + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + result = self.vm.qmp('blockdev-close-tray', device='drive0') + self.assert_qmp(result, 'return', {}) + + if self.has_real_tray or not self.was_empty: + self.wait_for_close() + + result = self.vm.qmp('query-block') + if self.has_real_tray or not self.was_empty: + self.assert_qmp(result, 'return[0]/tray_open', False) + else: + self.assert_qmp(result, 'return[0]/tray_open', True) + if self.was_empty == True: + self.assert_qmp_absent(result, 'return[0]/inserted') + else: + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + def test_tray_eject_close(self): + result = self.vm.qmp('eject', device='drive0', force=True) + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', True) + self.assert_qmp_absent(result, 'return[0]/inserted') + + result = self.vm.qmp('blockdev-close-tray', device='drive0') + self.assert_qmp(result, 'return', {}) + + if self.has_real_tray: + self.wait_for_close() + + result = self.vm.qmp('query-block') + if self.has_real_tray: + self.assert_qmp(result, 'return[0]/tray_open', False) + else: + self.assert_qmp(result, 'return[0]/tray_open', True) + self.assert_qmp_absent(result, 'return[0]/inserted') + + def test_tray_open_change(self): + result = self.vm.qmp('blockdev-open-tray', device='drive0', force=True) + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', True) + if self.was_empty == True: + self.assert_qmp_absent(result, 'return[0]/inserted') + else: + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + result = self.vm.qmp('blockdev-change-medium', device='drive0', + filename=new_img, + format=iotests.imgfmt) + self.assert_qmp(result, 'return', {}) + + self.wait_for_close() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) + + def test_cycle(self): + result = self.vm.qmp('blockdev-add', + options={'node-name': 'new', + 'driver': iotests.imgfmt, + 'file': {'filename': new_img, + 'driver': 'file'}}) + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('blockdev-open-tray', device='drive0', force=True) + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', True) + if self.was_empty == True: + self.assert_qmp_absent(result, 'return[0]/inserted') + else: + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + result = self.vm.qmp('blockdev-remove-medium', device='drive0') + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', True) + self.assert_qmp_absent(result, 'return[0]/inserted') + + result = self.vm.qmp('blockdev-insert-medium', device='drive0', + node_name='new') + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', True) + self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) + + result = self.vm.qmp('blockdev-close-tray', device='drive0') + self.assert_qmp(result, 'return', {}) + + self.wait_for_close() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) + + def test_close_on_closed(self): + result = self.vm.qmp('blockdev-close-tray', device='drive0') + # Should be a no-op + self.assert_qmp(result, 'return', {}) + self.assertEquals(self.vm.get_qmp_events(wait=False), []) + + def test_remove_on_closed(self): + if self.has_opened: + # Empty floppy drive + return + + result = self.vm.qmp('blockdev-remove-medium', device='drive0') + self.assert_qmp(result, 'error/class', 'GenericError') + + def test_insert_on_closed(self): + if self.has_opened: + # Empty floppy drive + return + + result = self.vm.qmp('blockdev-add', + options={'node-name': 'new', + 'driver': iotests.imgfmt, + 'file': {'filename': new_img, + 'driver': 'file'}}) + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('blockdev-insert-medium', device='drive0', + node_name='new') + self.assert_qmp(result, 'error/class', 'GenericError') + +class TestInitiallyFilled(GeneralChangeTestsBaseClass): + was_empty = False + + def setUp(self, media, interface): + qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k') + qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') + self.vm = iotests.VM().add_drive(old_img, 'media=%s' % media, interface) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + os.remove(old_img) + os.remove(new_img) + + def test_insert_on_filled(self): + result = self.vm.qmp('blockdev-add', + options={'node-name': 'new', + 'driver': iotests.imgfmt, + 'file': {'filename': new_img, + 'driver': 'file'}}) + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('blockdev-open-tray', device='drive0') + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + + result = self.vm.qmp('blockdev-insert-medium', device='drive0', + node_name='new') + self.assert_qmp(result, 'error/class', 'GenericError') + +class TestInitiallyEmpty(GeneralChangeTestsBaseClass): + was_empty = True + + def setUp(self, media, interface): + qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') + self.vm = iotests.VM().add_drive(None, 'media=%s' % media, interface) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + os.remove(new_img) + + def test_remove_on_empty(self): + result = self.vm.qmp('blockdev-open-tray', device='drive0') + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + + result = self.vm.qmp('blockdev-remove-medium', device='drive0') + # Should be a no-op + self.assert_qmp(result, 'return', {}) + +class TestCDInitiallyFilled(TestInitiallyFilled): + TestInitiallyFilled = TestInitiallyFilled + has_real_tray = True + + def setUp(self): + self.TestInitiallyFilled.setUp(self, 'cdrom', 'ide') + +class TestCDInitiallyEmpty(TestInitiallyEmpty): + TestInitiallyEmpty = TestInitiallyEmpty + has_real_tray = True + + def setUp(self): + self.TestInitiallyEmpty.setUp(self, 'cdrom', 'ide') + +class TestFloppyInitiallyFilled(TestInitiallyFilled): + TestInitiallyFilled = TestInitiallyFilled + has_real_tray = False + + def setUp(self): + self.TestInitiallyFilled.setUp(self, 'disk', 'floppy') + +class TestFloppyInitiallyEmpty(TestInitiallyEmpty): + TestInitiallyEmpty = TestInitiallyEmpty + has_real_tray = False + + def setUp(self): + self.TestInitiallyEmpty.setUp(self, 'disk', 'floppy') + # FDDs not having a real tray and there not being a medium inside the + # tray at startup means the tray will be considered open + self.has_opened = True + +class TestChangeReadOnly(ChangeBaseClass): + def setUp(self): + qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k') + qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') + self.vm = iotests.VM() + + def tearDown(self): + self.vm.shutdown() + os.chmod(old_img, 0666) + os.chmod(new_img, 0666) + os.remove(old_img) + os.remove(new_img) + + def test_ro_ro_retain(self): + os.chmod(old_img, 0444) + os.chmod(new_img, 0444) + self.vm.add_drive(old_img, 'media=disk,read-only=on', 'floppy') + self.vm.launch() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', True) + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + result = self.vm.qmp('blockdev-change-medium', device='drive0', + filename=new_img, + format=iotests.imgfmt, + read_only_mode='retain') + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + self.wait_for_close() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', True) + self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) + + def test_ro_rw_retain(self): + os.chmod(old_img, 0444) + self.vm.add_drive(old_img, 'media=disk,read-only=on', 'floppy') + self.vm.launch() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', True) + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + result = self.vm.qmp('blockdev-change-medium', device='drive0', + filename=new_img, + format=iotests.imgfmt, + read_only_mode='retain') + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + self.wait_for_close() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', True) + self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) + + def test_rw_ro_retain(self): + os.chmod(new_img, 0444) + self.vm.add_drive(old_img, 'media=disk', 'floppy') + self.vm.launch() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + result = self.vm.qmp('blockdev-change-medium', device='drive0', + filename=new_img, + format=iotests.imgfmt, + read_only_mode='retain') + self.assert_qmp(result, 'error/class', 'GenericError') + + self.assertEquals(self.vm.get_qmp_events(wait=False), []) + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + def test_ro_rw(self): + os.chmod(old_img, 0444) + self.vm.add_drive(old_img, 'media=disk,read-only=on', 'floppy') + self.vm.launch() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', True) + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + result = self.vm.qmp('blockdev-change-medium', + device='drive0', + filename=new_img, + format=iotests.imgfmt, + read_only_mode='read-write') + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + self.wait_for_close() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) + + def test_rw_ro(self): + os.chmod(new_img, 0444) + self.vm.add_drive(old_img, 'media=disk', 'floppy') + self.vm.launch() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + result = self.vm.qmp('blockdev-change-medium', + device='drive0', + filename=new_img, + format=iotests.imgfmt, + read_only_mode='read-only') + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + self.wait_for_close() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', True) + self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) + + def test_make_rw_ro(self): + self.vm.add_drive(old_img, 'media=disk', 'floppy') + self.vm.launch() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + result = self.vm.qmp('blockdev-change-medium', + device='drive0', + filename=new_img, + format=iotests.imgfmt, + read_only_mode='read-only') + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + self.wait_for_close() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', True) + self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) + + def test_make_ro_rw(self): + os.chmod(new_img, 0444) + self.vm.add_drive(old_img, 'media=disk', 'floppy') + self.vm.launch() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + result = self.vm.qmp('blockdev-change-medium', + device='drive0', + filename=new_img, + format=iotests.imgfmt, + read_only_mode='read-write') + self.assert_qmp(result, 'error/class', 'GenericError') + + self.assertEquals(self.vm.get_qmp_events(wait=False), []) + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + def test_make_rw_ro_by_retain(self): + os.chmod(old_img, 0444) + self.vm.add_drive(old_img, 'media=disk,read-only=on', 'floppy') + self.vm.launch() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', True) + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + result = self.vm.qmp('blockdev-change-medium', device='drive0', + filename=new_img, + format=iotests.imgfmt, + read_only_mode='retain') + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + self.wait_for_close() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', True) + self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) + + def test_make_ro_rw_by_retain(self): + os.chmod(new_img, 0444) + self.vm.add_drive(old_img, 'media=disk', 'floppy') + self.vm.launch() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + result = self.vm.qmp('blockdev-change-medium', device='drive0', + filename=new_img, + format=iotests.imgfmt, + read_only_mode='retain') + self.assert_qmp(result, 'error/class', 'GenericError') + + self.assertEquals(self.vm.get_qmp_events(wait=False), []) + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + def test_rw_ro_cycle(self): + os.chmod(new_img, 0444) + self.vm.add_drive(old_img, 'media=disk', 'floppy') + self.vm.launch() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + result = self.vm.qmp('blockdev-add', + options={'node-name': 'new', + 'driver': iotests.imgfmt, + 'read-only': True, + 'file': {'filename': new_img, + 'driver': 'file'}}) + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('blockdev-open-tray', device='drive0', force=True) + self.assert_qmp(result, 'return', {}) + + self.wait_for_open() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', True) + self.assert_qmp(result, 'return[0]/inserted/ro', False) + self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) + + result = self.vm.qmp('blockdev-remove-medium', device='drive0') + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', True) + self.assert_qmp_absent(result, 'return[0]/inserted') + + result = self.vm.qmp('blockdev-insert-medium', device='drive0', + node_name='new') + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', True) + self.assert_qmp(result, 'return[0]/inserted/ro', True) + self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) + + result = self.vm.qmp('blockdev-close-tray', device='drive0') + self.assert_qmp(result, 'return', {}) + + self.wait_for_close() + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/tray_open', False) + self.assert_qmp(result, 'return[0]/inserted/ro', True) + self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) + +GeneralChangeTestsBaseClass = None +TestInitiallyFilled = None +TestInitiallyEmpty = None + +if __name__ == '__main__': + iotests.main() diff --git a/tests/qemu-iotests/118.out b/tests/qemu-iotests/118.out new file mode 100644 index 0000000..7d4a8ca --- /dev/null +++ b/tests/qemu-iotests/118.out @@ -0,0 +1,5 @@ +.......................................................... +---------------------------------------------------------------------- +Ran 58 tests + +OK diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 439b1d2..85329af 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -121,6 +121,7 @@ 114 rw auto quick 115 rw auto 116 rw auto quick +118 rw auto 119 rw auto quick 120 rw auto quick 121 rw auto -- 2.5.2 From MAILER-DAEMON Fri Sep 18 11:31:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxdJ-0001in-E3 for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:31:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxdC-0001Wr-PH for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:31:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcxd9-0002QR-3E for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:31:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcxd8-0002QG-VF; Fri, 18 Sep 2015 11:31:19 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id A156FA3D55; Fri, 18 Sep 2015 15:31:18 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFVHcV029871; Fri, 18 Sep 2015 11:31:17 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-2-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC2E41.4010706@redhat.com> Date: Fri, 18 Sep 2015 09:31:13 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442589793-7105-2-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PXtUIdOdDXXnCHxQljN6iD4OWIQCE3Iwf" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 01/38] block: Remove host floppy support X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:31:27 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --PXtUIdOdDXXnCHxQljN6iD4OWIQCE3Iwf Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 09:22 AM, Max Reitz wrote: > It has been deprecated as of 2.3, so we can now remove it. >=20 > Signed-off-by: Max Reitz > --- > block/raw-posix.c | 222 ++-----------------------------------------= -------- > qapi/block-core.json | 9 +-- > 2 files changed, 9 insertions(+), 222 deletions(-) Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --PXtUIdOdDXXnCHxQljN6iD4OWIQCE3Iwf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/C5BAAoJEKeha0olJ0Nqei0H/0kvwNEGkbGOVRcw9wtsMfI8 Z0AQa+dmfNFDhsKAoC9cVgFtwH/xKRFjJUlLH1N9bMRW1MG7APVn0knb7wupvTZd Cyv2+o5TNab96L/ukNPZ/s/9fWecQn4Reap5I+wj9fMhzDQBJKbD3kXp1S1IuP7R +10c9rP+QWdzx1ehOBITMS9GKj5+tXTY93z63eX0eFl68Bp1bOWK7HMf9gPgM+4s 2beYhTg3nsCHN5TnOUDaL94W3skCwMXT4HmYWHtWvk9hnHUUpt6qEUOCDkt6Shzn r7GC5z8y1MpslA3SBmW6ZnAkbyvLQ4DFNZof9GbwGo5lgWQsPOBmFmyg34FRVO4= =G5u6 -----END PGP SIGNATURE----- --PXtUIdOdDXXnCHxQljN6iD4OWIQCE3Iwf-- From MAILER-DAEMON Fri Sep 18 11:32:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zcxe3-000350-Hf for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:32:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcxdw-0002sp-Ic for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:32:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcxdv-0002v5-QV for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:32:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcxdv-0002un-M5; Fri, 18 Sep 2015 11:32:07 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 6735A550CD; Fri, 18 Sep 2015 15:32:07 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFW6qm025592; Fri, 18 Sep 2015 11:32:06 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-3-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC2E75.3050101@redhat.com> Date: Fri, 18 Sep 2015 09:32:05 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442589793-7105-3-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="DXCCdS67CjAMN1rmrF7WanxF8gC5r8Kje" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 02/38] block: Set BDRV_O_INCOMING in bdrv_fill_options() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:32:14 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --DXCCdS67CjAMN1rmrF7WanxF8gC5r8Kje Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 09:22 AM, Max Reitz wrote: > This flag should not be set for the root BDS only, but for any BDS that= > is being created while incoming migration is pending, so setting it is > moved from blockdev_init() to bdrv_fill_options(). >=20 > Signed-off-by: Max Reitz > --- > block.c | 4 ++++ > blockdev.c | 4 ---- > 2 files changed, 4 insertions(+), 4 deletions(-) Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --DXCCdS67CjAMN1rmrF7WanxF8gC5r8Kje Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/C51AAoJEKeha0olJ0NqKkgH/i5Rm8t+YXcUPIg4ggJxcEJk xyeTGoNfylp1Z1zy3kzXsfrDydvXwtDitPpZQ0NQh2uygHKwOllFB9vwg8LzAaee mz9Ocg7MFDr0FiujFpxDl4S526yvt8rcr2bLg8PJXeWbpFhFiiipbOc58NTrNNb8 51KfSeFaW47DpqLXHWdauw6Dx7KhNy1VHAK4UgVK8F1ryKVJEIAhy4aRt45Dy1Os 5xV5XKhw7QNqEu4D9rOSH8cZPklMrHRnCq7KH0zdFE3QVGIaKs120h9rykC6/JBX MUNjOWemxSkWt6bNFec/SAADtg/yHwKot1Wahywoy6UWYMOHseojQjCWXN4Boyk= =7Ykl -----END PGP SIGNATURE----- --DXCCdS67CjAMN1rmrF7WanxF8gC5r8Kje-- From MAILER-DAEMON Fri Sep 18 11:34:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxgV-0007MQ-Ne for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:34:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxgR-0007Dk-0T for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:34:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxgQ-0004dr-5L for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:34:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59341) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxgQ-0004de-0l; Fri, 18 Sep 2015 11:34:42 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id B2246C0B2E00; Fri, 18 Sep 2015 15:34:40 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFYdRR027085; Fri, 18 Sep 2015 11:34:39 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-4-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC2F0F.4050107@redhat.com> Date: Fri, 18 Sep 2015 09:34:39 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442589793-7105-4-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="HfKQTSaVFd3I4oUBj6RWgS85taKmfvWqF" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 03/38] blockdev: Allow creation of BDS trees without BB X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:34:44 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --HfKQTSaVFd3I4oUBj6RWgS85taKmfvWqF Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 09:22 AM, Max Reitz wrote: > If the "id" field is missing from the options given to blockdev-add, > just omit the BlockBackend and create the BlockDriverState tree alone. >=20 > However, if "id" is missing, "node-name" must be specified; otherwise, > the BDS tree would no longer be accessible. >=20 > Many BDS options which are not parsed by bdrv_open() (like caching) > cannot be specified for these BB-less BDS trees yet. A future patch wil= l > remove this limitation. >=20 > Signed-off-by: Max Reitz > --- > blockdev.c | 44 +++++++++++++++++++++++++++++++-------= ------ > qapi/block-core.json | 13 +++++++++---- > tests/qemu-iotests/087 | 2 +- > tests/qemu-iotests/087.out | 4 ++-- > 4 files changed, 43 insertions(+), 20 deletions(-) >=20 Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --HfKQTSaVFd3I4oUBj6RWgS85taKmfvWqF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/C8PAAoJEKeha0olJ0NqUJUH/jdZCZP7yLgZdvbvoDJ5NMvi KbHe2H99+ChY6sQtmNUChoQfzLGK1GzqXKaJ72+nYErFJS9XAQbNG/xVbNyUa8l1 8DQZ8uaIl77+q2KW9qm66Wp0yNRPr5eeBry6v3J8IoGxjL9wgtKtE3SyYT02pjxc UtE3oISkzlxSHxgC6vQAboIT48sqCC1rFrgo0UOnGfBnRbK0XP6OVebb3Z4iL06D FlqfS7VUShZlmESJs0DGt7X1b0ZxBOkNr4I1KwR0m42CNy2eTXPJTu0D1RWp7WFf IBpg0NtsbkSVSy0YKmzGO8/eZAB+3/ZwfwcgjIf5sHhI1dtLr+pesJgRT0frndg= =FNVH -----END PGP SIGNATURE----- --HfKQTSaVFd3I4oUBj6RWgS85taKmfvWqF-- From MAILER-DAEMON Fri Sep 18 11:41:50 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcxnK-0002Ws-2e for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:41:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxnH-0002RS-53 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:41:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxnG-00013x-AT for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:41:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48800) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxnG-00012e-5Q; Fri, 18 Sep 2015 11:41:46 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id AF13F8CF56; Fri, 18 Sep 2015 15:41:45 +0000 (UTC) Received: from [10.36.116.139] (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFfg7v030235 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 18 Sep 2015 11:41:44 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <40dd21e6f39ce3c6412b6d568a85c3f226fa3bd2.1442581571.git.berto@igalia.com> From: Max Reitz Message-ID: <55FC30B6.8060808@redhat.com> Date: Fri, 18 Sep 2015 17:41:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <40dd21e6f39ce3c6412b6d568a85c3f226fa3bd2.1442581571.git.berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="b3Q7p6Sq34BLQOQvrchbBU2CpACUJUrtq" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v5 2/4] block: support passing 'backing': '' to 'blockdev-add' X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:41:48 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --b3Q7p6Sq34BLQOQvrchbBU2CpACUJUrtq Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 18.09.2015 15:16, Alberto Garcia wrote: > Passing an empty string allows opening an image but not its backing > file. This was already described in the API documentation, only the > implementation was missing. >=20 > This is useful for creating snapshots using images opened with > blockdev-add, since they are not supposed to have a backing image > before the operation. >=20 > Signed-off-by: Alberto Garcia > --- > block.c | 7 +++++++ > 1 file changed, 7 insertions(+) Reviewed-by: Max Reitz --b3Q7p6Sq34BLQOQvrchbBU2CpACUJUrtq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV/DC2AAoJEDuxQgLoOKyt1zwH/iQjHMD7nI50RduGnAkCj6fE 3mNMGRO3PG9edi6TQtoqW7TL/usb9PzAFtfjYeGHpHgkO+ZjviC2vkcOszZnu1sU fexWNkzPvzmGb1C6EMqxM1AHlV8KcC0RqkcFzwzQwU103OmtKz2XuT0QSujs8FAA dMHBNe1t4lvnsWXEB9L8gP0JME4JUcHd8pRN7OQnSmCPA3FopBj14ye0fwXq9BCt UZwu9uTMy7O53Z8pBC3jvrK4nplUDwFse3CmblMhOZmZ0cg+kB3P4FSIgqgP7m6e e2cVC75XAbnv2oeUqhbo2fzW7g2/7DvpShKkm7kLN6JGenrdVkLwPfVy/hGxjkY= =wHxo -----END PGP SIGNATURE----- --b3Q7p6Sq34BLQOQvrchbBU2CpACUJUrtq-- From MAILER-DAEMON Fri Sep 18 11:45:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zcxqb-0000EP-BV for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:45:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxqZ-00008w-3V for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:45:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcxqY-0003Gw-9D for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:45:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49876) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcxqY-0003Gh-4h; Fri, 18 Sep 2015 11:45:10 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id A293E8CF73; Fri, 18 Sep 2015 15:45:09 +0000 (UTC) Received: from [10.36.116.139] (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFj6HQ002175 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 18 Sep 2015 11:45:07 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: From: Max Reitz Message-ID: <55FC3181.8040107@redhat.com> Date: Fri, 18 Sep 2015 17:45:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="B5Rh9H9avohdGteTHw1gLI07sCwgI1qq0" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v5 4/4] block: add tests for the 'blockdev-snapshot' command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:45:12 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --B5Rh9H9avohdGteTHw1gLI07sCwgI1qq0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 18.09.2015 15:16, Alberto Garcia wrote: > Signed-off-by: Alberto Garcia > --- > tests/qemu-iotests/085 | 102 +++++++++++++++++++++++++++++++++++++= +++++--- > tests/qemu-iotests/085.out | 34 ++++++++++++++- > 2 files changed, 128 insertions(+), 8 deletions(-) Reviewed-by: Max Reitz --B5Rh9H9avohdGteTHw1gLI07sCwgI1qq0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV/DGBAAoJEDuxQgLoOKyt0RIH/3NmOh7NBh0+SVyKixSfX5V6 hQSy5iwuN73e4U52u5R/5Kluuk5gDrFT9hyYCofcOZ0f0UNEAxbZqtUhPTtOdEce ejeHuh4bS5pHMtdc8e2+8mG+KXPcpBbK7GBGRjm0ClTTDHC0gRStE7445alUPkh5 rRsm8eE693oBX726f02YWdfp1bbrmOOWTJBQI0gsGWHirvZnxFuB5triUfSXCN96 C8N+9nx1te0ed+XUauB/CSD/JytjnMj1IS5LpGaa8vQrEawR9e68XtHyenzBTOK5 +TjtasYdBG+t6oNPs7pKUOLrhD2oQhbGvgW2dXgbY2wrlO39ORUTOtZ2Dpfb13s= =k28s -----END PGP SIGNATURE----- --B5Rh9H9avohdGteTHw1gLI07sCwgI1qq0-- From MAILER-DAEMON Fri Sep 18 11:54:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zcxzr-0004TF-41 for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 11:54:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcxzn-0004ND-S2 for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:54:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcxzk-0002ba-KS for qemu-block@nongnu.org; Fri, 18 Sep 2015 11:54:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39161) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcxzk-0002bJ-8n; Fri, 18 Sep 2015 11:54:40 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B42F18C1DF; Fri, 18 Sep 2015 15:54:39 +0000 (UTC) Received: from [10.36.116.139] (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IFsbGJ007400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 18 Sep 2015 11:54:38 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <1442500386-3668-1-git-send-email-berto@igalia.com> From: Max Reitz Message-ID: <55FC33BC.5080803@redhat.com> Date: Fri, 18 Sep 2015 17:54:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442500386-3668-1-git-send-email-berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PxfJP8oj1r4IcN8krLHHuQpXoqCw4RTic" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH] throttle: test that snapshots move the throttling configuration X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 15:54:45 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --PxfJP8oj1r4IcN8krLHHuQpXoqCw4RTic Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 16:33, Alberto Garcia wrote: > If a snapshot is performed on a device that has I/O limits they should > be moved to the target image (the new active layer). >=20 > Signed-off-by: Alberto Garcia > --- > tests/qemu-iotests/096 | 69 ++++++++++++++++++++++++++++++++++++++= ++++++++ > tests/qemu-iotests/096.out | 5 ++++ > tests/qemu-iotests/group | 1 + > 3 files changed, 75 insertions(+) > create mode 100644 tests/qemu-iotests/096 > create mode 100644 tests/qemu-iotests/096.out Looks good, I'd just like to throw in that 096 is in use by my looks-dead-but-actually-is-not and only-waiting-for-the-blockbackend-and-media-series-to-get-merged series "block: Rework bdrv_close_all()": http://lists.nongnu.org/archive/html/qemu-block/2015-03/msg00048.html But then again, once the prerequisites are met, I'll have to send a new version of that series anyway... So, since 096 is not a magic number I'm extremely keen on keeping in my greedy claws: Reviewed-by: Max Reitz --PxfJP8oj1r4IcN8krLHHuQpXoqCw4RTic Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJV/DO8AAoJEDuxQgLoOKythTcIAIom9AWQ6dg/VBXo/DkDBb4A fEf0EQw2t/6EFVe9Aq2fO0oFvTWHaODblicSNLlD5l508SRBu2KZVwaS6V5SFOHl 2rMgiF99VwoJF6SYplKshJICMOclVUj6biH0QBNIqCNIZEbCvtG2Lc42VXkze7v7 tE96sImR+QZlO7lxmtIGY4QeOQVPpsKx6a4jYoqMCih+Vk6TGki+emAf8jW3Bdbr Pdm6+iYxZHHjIjng02F2O31wjhfjoDNoxdMIFimszltwDtm1Ssx67I5GLKyhthjK LREB1U0D2TBXuuhlYWZy7IrH2WRZJb/D/ktxbR2xdeCieqhUbOrfo3jgyT9gXE0= =WSpr -----END PGP SIGNATURE----- --PxfJP8oj1r4IcN8krLHHuQpXoqCw4RTic-- From MAILER-DAEMON Fri Sep 18 12:00:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zcy5O-0005ys-Hh for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 12:00:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcy5L-0005ti-5B for qemu-block@nongnu.org; Fri, 18 Sep 2015 12:00:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcy5H-0006cl-TB for qemu-block@nongnu.org; Fri, 18 Sep 2015 12:00:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52951) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcy5H-0006cd-G8; Fri, 18 Sep 2015 12:00:23 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id EECEF461EE; Fri, 18 Sep 2015 16:00:22 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IG0LPw017619; Fri, 18 Sep 2015 12:00:22 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-5-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC3515.8040901@redhat.com> Date: Fri, 18 Sep 2015 10:00:21 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442589793-7105-5-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="8oKiVQxnm9p78OqqDHnccmF8G0kWm6uoh" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 04/38] iotests: Only create BB if necessary X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 16:00:28 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --8oKiVQxnm9p78OqqDHnccmF8G0kWm6uoh Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 09:22 AM, Max Reitz wrote: > Tests 071 and 081 test giving references in blockdev-add. It is not > necessary to create a BlockBackend here, so omit it. >=20 > While at it, fix up some blockdev-add invocations in the vicinity > (s/raw/$IMGFMT/ in 081, drop the format BDS for blkverify's raw child i= n > 071). >=20 > Signed-off-by: Max Reitz > --- > tests/qemu-iotests/071 | 54 ++++++++++++++++++++++++++++++++++++++= -------- > tests/qemu-iotests/071.out | 12 +++++++---- > tests/qemu-iotests/081 | 18 +++++++++++++--- > tests/qemu-iotests/081.out | 5 +++-- > 4 files changed, 71 insertions(+), 18 deletions(-) >=20 Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --8oKiVQxnm9p78OqqDHnccmF8G0kWm6uoh Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/DUVAAoJEKeha0olJ0NqRqQIAJT+k82j4Oyj8PzQmKketnhQ 8AVv1hiEra41B4H6hmzUVlU4jRjRB0PQb4Yn3LJRs/J6zz5WziP/BxUikNZ/hyLh BGtEUpt+EoX0gVji3W3wMD0eVxlo/nrvHkanVGKV2uxqRjcsaS7j/k2kKGcnhxJe /aXLpbOfp94Lt97EDFxbFvg9/nn5SvKzF1PIBIK+5DHU4ET5Po+r6CnY51X1v+uX BCczFdKfweOMD+Wg4KpjMkXvxmXb7iRZ7umFfxqp31SI+qPLNzKScBdI0N/6zUq/ 1SwNU6W5/mFxIDOoMM5cxI7e/BpugCYN2a5HVcRoUJzEJbRUc6ZQ2fNkDC8zxwc= =u9UA -----END PGP SIGNATURE----- --8oKiVQxnm9p78OqqDHnccmF8G0kWm6uoh-- From MAILER-DAEMON Fri Sep 18 12:20:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcyOd-0005Sj-8J for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 12:20:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcyOa-0005Rh-Sv for qemu-block@nongnu.org; Fri, 18 Sep 2015 12:20:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcyOW-0007HS-2i for qemu-block@nongnu.org; Fri, 18 Sep 2015 12:20:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46688) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcyOV-0007H1-Ue; Fri, 18 Sep 2015 12:20:16 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 376CFA9A; Fri, 18 Sep 2015 16:20:15 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IGKEOe024742; Fri, 18 Sep 2015 12:20:14 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-8-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC39BD.6050108@redhat.com> Date: Fri, 18 Sep 2015 10:20:13 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442589793-7105-8-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="FTe9WmaJ3uCtO0e1V73LHpjwbfAlQlXQw" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 07/38] block: Make bdrv_is_inserted() recursive X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 16:20:21 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --FTe9WmaJ3uCtO0e1V73LHpjwbfAlQlXQw Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 09:22 AM, Max Reitz wrote: > If bdrv_is_inserted() is called on the top level BDS, it should make > sure all nodes in the BDS tree are actually inserted. >=20 > Signed-off-by: Max Reitz > --- > block.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) >=20 Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --FTe9WmaJ3uCtO0e1V73LHpjwbfAlQlXQw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/Dm9AAoJEKeha0olJ0Nq/SUH/ivSalvI2yHNMfmOpxLQ4fw0 +Oz6LLcFqcR7+1hNY+LY2avXvDW1VfiA9bHknojW3oc5uGSLnu2n/MDrtMcLmMAA U8F5KiDKGrDvbp6lj64caZC4xfVYGpyDwf37fbwOQmQgPaz8Kw3h7ya8loOwDaur JegAaA4ZW/8IqwCw4PH3nCKemI/vn0hQ+9Ki1laYzPZ7ySlTJV/yPmyRb2cN/DIS ktyVU1G2Rz6yJupW1Loy7kJ9e7/2S7G0yVc+j5ZtMDdAhGLWSIAkqOGUK19fLRRp gF0I0gJul+SDzTLUb+cHaZjLkH97lfLv+jFi1E1NeyTX7j2W/p+gxwR2A69yWm0= =fTVr -----END PGP SIGNATURE----- --FTe9WmaJ3uCtO0e1V73LHpjwbfAlQlXQw-- From MAILER-DAEMON Fri Sep 18 12:20:59 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcyPD-000619-IS for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 12:20:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcyPB-0005yM-KW for qemu-block@nongnu.org; Fri, 18 Sep 2015 12:20:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcyP6-0007i4-Pr for qemu-block@nongnu.org; Fri, 18 Sep 2015 12:20:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcyP6-0007hh-GJ; Fri, 18 Sep 2015 12:20:52 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 0B4A491E87; Fri, 18 Sep 2015 16:20:52 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IGKolD027071; Fri, 18 Sep 2015 12:20:51 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-9-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC39E2.8050107@redhat.com> Date: Fri, 18 Sep 2015 10:20:50 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442589793-7105-9-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="OFS2m03v3iTh5dHl9W0Iux63UpiP3lqQ9" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 08/38] block/raw_bsd: Drop raw_is_inserted() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 16:20:59 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --OFS2m03v3iTh5dHl9W0Iux63UpiP3lqQ9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 09:22 AM, Max Reitz wrote: > With the new automatically-recursive implementation of > bdrv_is_inserted() checking by default whether all the children of a BD= S > are inserted, we can drop raw's own implementation. >=20 > Signed-off-by: Max Reitz > --- > block/raw_bsd.c | 6 ------ > 1 file changed, 6 deletions(-) >=20 Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --OFS2m03v3iTh5dHl9W0Iux63UpiP3lqQ9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/DniAAoJEKeha0olJ0NqsOAH/0kfSk6Ei3+RsrDYEQhLgIq/ yoZ7SDp4q3A1EUvHW483ts7qUCK6lYP8jdNBS3v1rHGz87vB4ghmfty9Y1J2OoPT CBMsbqoRH2/eq/ymi/f6wIOjQ+waYmJPEoEMXwKlPbcuwChx669UJb90dunz1fKc PlsrmNJwMmd43wlYoM8Kk673N+ixATqU+Ab92Yixy5MTGbUcR18gD7L36bB6mDcy KJRSNeh7xD/R8PRv2tTpnjZiU/EcoxtAbb3bqxZXoktFe7Z15KS9uaFk15MRR0w4 uFjzlb0+LeFZf0yP/vd4IsJQe68ONTmgNAXNSNzY69SJwLC2zuNRk5m6+KBNtaY= =YItd -----END PGP SIGNATURE----- --OFS2m03v3iTh5dHl9W0Iux63UpiP3lqQ9-- From MAILER-DAEMON Fri Sep 18 12:23:00 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcyR9-0008EJ-MC for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 12:22:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcyR7-0008AZ-H7 for qemu-block@nongnu.org; Fri, 18 Sep 2015 12:22:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcyR4-0001LK-Ez for qemu-block@nongnu.org; Fri, 18 Sep 2015 12:22:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33140) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcyR4-0001L6-Ak; Fri, 18 Sep 2015 12:22:54 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id EBC5196C7; Fri, 18 Sep 2015 16:22:53 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IGMqgP000718; Fri, 18 Sep 2015 12:22:53 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-10-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC3A5C.2060207@redhat.com> Date: Fri, 18 Sep 2015 10:22:52 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442589793-7105-10-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="obnvd3MfTQvrXWXPfBB9NMWsa4JCWDPHV" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 09/38] block: Invoke change media CB before NULLing drv X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 16:22:58 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --obnvd3MfTQvrXWXPfBB9NMWsa4JCWDPHV Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 09:22 AM, Max Reitz wrote: > In order to handle host device passthrough, some guest device models > may call blk_is_inserted() to check whether the medium is inserted on > the host, when checking the guest tray status. >=20 > This tray status is inquired by blk_dev_change_media_cb(); because > bdrv_is_inserted() (invoked by blk_is_inserted()) always returns 0 for Stale comment - you just fixed bdrv_is_inserted() to return false rather than 0 in commit 5/38. > BDS with drv set to NULL, blk_dev_change_media_cb() should therefore be= > called before drv is set to NULL. >=20 > Signed-off-by: Max Reitz > Reviewed-by: Eric Blake > Reviewed-by: Alberto Garcia > --- > block.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) R-b still stands. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --obnvd3MfTQvrXWXPfBB9NMWsa4JCWDPHV Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/DpcAAoJEKeha0olJ0NqJhIIAJpzhcq66NMvJxpKt4Fm7FzZ MpK0Nm89iQux53xdz6jXxfPpHmbPWbeWIbZLtoC1OxhLRkHwvCrg+/RD+vf5PK70 MdFW5WR1WNQ3rikpsDVWJqF8OzdIF0eovjVpW8D1GHK1qTdKt7Ycggupc+MyNmYu upQHM+baQKAJGtSRL7i7jnz3kXjotRhIFctWOgwABfCHfL8Nf2A/lfuD4HpU+Wwo tYBXUjL4rU/VCu6xU0NKYukKzvbXKAj0dmRcIoZgJArr4vB9YL8bzQ9QSeRs8nzz AU9RYsDkP4SE0IDDx/BMdD2jI2caG+m5FxwZ+kaq7jnDuufTwzc/JT9QepKWru8= =OoUK -----END PGP SIGNATURE----- --obnvd3MfTQvrXWXPfBB9NMWsa4JCWDPHV-- From MAILER-DAEMON Fri Sep 18 12:24:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZcySt-00020U-Ed for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 12:24:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcySr-0001yC-8d for qemu-block@nongnu.org; Fri, 18 Sep 2015 12:24:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcySn-0002kt-Pq for qemu-block@nongnu.org; Fri, 18 Sep 2015 12:24:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42444) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcySn-0002kX-Ka; Fri, 18 Sep 2015 12:24:41 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 4BB6E8E69C; Fri, 18 Sep 2015 16:24:41 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IGOeHE001546; Fri, 18 Sep 2015 12:24:40 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-11-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC3AC7.7050700@redhat.com> Date: Fri, 18 Sep 2015 10:24:39 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442589793-7105-11-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rTgj5o0LElG7xQiQ8r6UHsFmVhxLXTH8n" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 10/38] hw/block/fdc: Implement tray status X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 16:24:46 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rTgj5o0LElG7xQiQ8r6UHsFmVhxLXTH8n Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 09:22 AM, Max Reitz wrote: > The tray of an FDD is open iff there is no medium inserted (there are > only two states for an FDD: "medium inserted" or "no medium inserted").= >=20 > Signed-off-by: Max Reitz > --- > hw/block/fdc.c | 20 ++++++++++++++++---- > tests/fdc-test.c | 4 +--- > 2 files changed, 17 insertions(+), 7 deletions(-) >=20 Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --rTgj5o0LElG7xQiQ8r6UHsFmVhxLXTH8n Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/DrIAAoJEKeha0olJ0NqrvsH/0CiiZbQEE8OGog6piU1qERT O+Q4X3ld8UDe/FSm0yvl6GJihuJLpvkv/1Op2bSIQ7WLJI43DJwE+5Nkq6HIDN9l HtK+Glofp1iw3oJmtsf/0/C1eKBBciI696Y4aPhuGUDdRVHE6RZuc2XpasuIUPYd d50hNE71V5uXdkkZw6KsJ5KRUM4O5kTX+/6+jkUG/0QNFIRf3IPHIfp91HOODyeF qsSXF/6SCeyTO1lEe0q3XK/Os0GMyWzSgjFz7ZLtopEvOKehXNrT4+RX4L8RGYsB 6sVnRj/v+Hna4tYZIuZAwd4qZ7ArX3nfhas4Wb5AU/hSuhpkxKCs2HzsK52DAeE= =eeBm -----END PGP SIGNATURE----- --rTgj5o0LElG7xQiQ8r6UHsFmVhxLXTH8n-- From MAILER-DAEMON Fri Sep 18 12:59:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zcz0U-0006Kc-5J for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 12:59:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcz0S-0006KO-5g for qemu-block@nongnu.org; Fri, 18 Sep 2015 12:59:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zcz0O-0003Lj-1G for qemu-block@nongnu.org; Fri, 18 Sep 2015 12:59:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56023) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zcz0N-0003LH-Q0; Fri, 18 Sep 2015 12:59:23 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id D26088C1AA; Fri, 18 Sep 2015 16:59:22 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IGxLwk017056; Fri, 18 Sep 2015 12:59:22 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-15-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC42E2.2020207@redhat.com> Date: Fri, 18 Sep 2015 10:59:14 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442589793-7105-15-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lvbV6IijHUGkCNpxS8CuPLAssvL9t5wxL" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 14/38] block: Remove wr_highest_sector from BlockAcctStats X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 16:59:29 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --lvbV6IijHUGkCNpxS8CuPLAssvL9t5wxL Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 09:22 AM, Max Reitz wrote: > BlockAcctStats contains statistics about the data transferred from and > to the device; wr_highest_sector does not fit in with the rest. >=20 > Furthermore, those statistics are supposed to be specific for a certain= > device and not necessarily for a BDS (see the comment above > bdrv_get_stats()); on the other hand, wr_highest_sector may be a rather= > important information to know for each BDS. When BlockAcctStats is > finally removed from the BDS, we will want to keep wr_highest_sector in= > the BDS. >=20 > Finally, wr_highest_sector is renamed to wr_highest_offset and given th= e > appropriate meaning. Externally, it is represented as an offset so ther= e > is no point in doing something different internally. Its definition is > changed to match that in qapi/block-core.json which is "the offset afte= r > the greatest byte written to". Doing so should not cause any harm since= > if external programs tried to calculate the volume usage by > (wr_highest_offset + 512) / volume_size, after this patch they will jus= t > assume the volume to be full slightly earlier than before. >=20 > Signed-off-by: Max Reitz > Reviewed-by: Eric Blake > Reviewed-by: Alberto Garcia Still holds, but... > +++ b/qmp-commands.hx > @@ -2481,8 +2481,8 @@ Each json-object contain the following: > - "wr_total_time_ns": total time spend on writes in nano-seconds (= json-int) > - "rd_total_time_ns": total time spend on reads in nano-seconds (j= son-int) > - "flush_total_time_ns": total time spend on cache flushes in nano= -seconds (json-int) > - - "wr_highest_offset": Highest offset of a sector written since th= e > - BlockDriverState has been opened (json-int)= > + - "wr_highest_offset": The offset after the greatest byte written = to the > + BlockDriverState since it has been opened (= json-int) =2E..someday, I'd really like to have this stat show as non-zero even whe= n first opening the device (before writing to it). Right now, you have no clue how full a backing device is prior to starting a block-commit; you have to start writing to it to get a feel for its current usage. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --lvbV6IijHUGkCNpxS8CuPLAssvL9t5wxL Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/ELjAAoJEKeha0olJ0NqVGcIAKAAcVgMRs7IxchZpC6nJuZP wmBIqXjdfSTn+H5/OykqDPsgZHYoZ7XPzK6zDKkIdokSRsV0WMPP6Uk5xyaAqMwm 3fxGksyVeHs2OtFnmWzXu4YXweMw3ptRi6C0xC/a7s7C5wIKbidIm5lSxBQHKdZM XSDJA0X44UTnJ4896TdyX5rVPf6pK7eXHt1Lv++VORGJrj+C5XpPjPs6K72HVAGj Yn+P6DxciSIOrona+dXTaAShRqkOutaGl1YQ90wPIAmy2+00jehoyTBJWvRx90Ks 22/dX1Ztvls5rKW1tTrSLniKS6Pgn4WxDpR/T+QC8EPT3tDxD03tA9i70nxrQlk= =26ht -----END PGP SIGNATURE----- --lvbV6IijHUGkCNpxS8CuPLAssvL9t5wxL-- From MAILER-DAEMON Fri Sep 18 15:42:18 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zd1Y2-0001GE-P6 for mharc-qemu-block@gnu.org; Fri, 18 Sep 2015 15:42:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zd1Xz-0001CN-Lk for qemu-block@nongnu.org; Fri, 18 Sep 2015 15:42:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zd1Xu-0003fb-OK for qemu-block@nongnu.org; Fri, 18 Sep 2015 15:42:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46565) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zd1Xu-0003f1-JY; Fri, 18 Sep 2015 15:42:10 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id CD7F0461F0; Fri, 18 Sep 2015 19:42:09 +0000 (UTC) Received: from [10.3.113.175] (ovpn-113-175.phx2.redhat.com [10.3.113.175]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8IJg82l005789; Fri, 18 Sep 2015 15:42:08 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-23-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <55FC690B.6000806@redhat.com> Date: Fri, 18 Sep 2015 13:42:03 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442589793-7105-23-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="A3uVE1VduVavFHPCPm3rFR3RuShBPRgs4" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Wen Congyang , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 22/38] block: Prepare for NULL BDS X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2015 19:42:16 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --A3uVE1VduVavFHPCPm3rFR3RuShBPRgs4 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/18/2015 09:22 AM, Max Reitz wrote: > blk_bs() will not necessarily return a non-NULL value any more (unless > blk_is_available() is true or it can be assumed to otherwise, e.g. > because it is called immediately after a successful blk_new_with_bs() o= r > blk_new_open()). >=20 > Signed-off-by: Max Reitz > --- > block.c | 5 ++ > block/qapi.c | 4 +- > blockdev.c | 201 ++++++++++++++++++++++++++++++++++----------= -------- > hw/block/xen_disk.c | 4 +- > migration/block.c | 5 ++ > monitor.c | 4 ++ > 6 files changed, 153 insertions(+), 70 deletions(-) >=20 Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --A3uVE1VduVavFHPCPm3rFR3RuShBPRgs4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV/GkMAAoJEKeha0olJ0NqiIEH/jDQyqY1SBeixklhwHZe69en ef4Qap96MLepnYubdG3M0LwFJxz4HZEK0NArFusFTSZtyMrwGzxDCiWrrViPvLW+ f44tjI5CJNY6NnWFV9E6fXCVVEKKzooa7/2GY7Fn3/yNALxIbxnbvXHYiaWccoVW a5zcrWizvW/rjk4OzS+AlNtTtxX7TgXzBIEgnYHXndabmeakMii8w30YDBH11mf3 76JjJpGTS58kNVlrLNqSpWhtEA7B78AgflBq0k2aijKfKCMe7EZ82GNoU1IiEWoU gOTp2n4wmvWisORcOtnQSjQJOihN0QKSCXBsWZdFxr+LInpU3eqF+2q/a3UUSoQ= =FYgd -----END PGP SIGNATURE----- --A3uVE1VduVavFHPCPm3rFR3RuShBPRgs4-- From MAILER-DAEMON Mon Sep 21 03:03:09 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zdv81-000684-Ca for mharc-qemu-block@gnu.org; Mon, 21 Sep 2015 03:03:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zdv7z-00066O-G3 for qemu-block@nongnu.org; Mon, 21 Sep 2015 03:03:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zdv7y-0005hY-Gb for qemu-block@nongnu.org; Mon, 21 Sep 2015 03:03:07 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:53394 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zdv7s-0005X6-1v; Mon, 21 Sep 2015 03:03:00 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AhAgA+qv9V/5tjdVtdGQEBAYMIVGmpHwEBAQEBAQUBgQoBkwwBDYFVHAqFeQKBLTgUAQEBAQEBAYEKhCQBAQECAQECNz8QCw4TJQ8BGBQbBgESiCYMAQjJYQEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsBZVkhRGFE4R2mQcfAQFCgkOBQDwzAYlsAQEB X-IPAS-Result: A2AhAgA+qv9V/5tjdVtdGQEBAYMIVGmpHwEBAQEBAQUBgQoBkwwBDYFVHAqFeQKBLTgUAQEBAQEBAYEKhCQBAQECAQECNz8QCw4TJQ8BGBQbBgESiCYMAQjJYQEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsBZVkhRGFE4R2mQcfAQFCgkOBQDwzAYlsAQEB X-IronPort-AV: E=Sophos;i="5.17,566,1437429600"; d="scan'208";a="24573266" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 21 Sep 2015 09:02:22 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1Zdv7G-0002i4-3r; Mon, 21 Sep 2015 09:02:22 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1Zdv7F-0002u4-Ty; Mon, 21 Sep 2015 09:02:21 +0200 From: Alberto Garcia To: Max Reitz , qemu-devel@nongnu.org In-Reply-To: <55FC33BC.5080803@redhat.com> References: <1442500386-3668-1-git-send-email-berto@igalia.com> <55FC33BC.5080803@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Mon, 21 Sep 2015 09:02:21 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH] throttle: test that snapshots move the throttling configuration X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 07:03:08 -0000 On Fri 18 Sep 2015 05:54:36 PM CEST, Max Reitz wrote: >> create mode 100644 tests/qemu-iotests/096 >> create mode 100644 tests/qemu-iotests/096.out > > Looks good, I'd just like to throw in that 096 is in use by my > looks-dead-but-actually-is-not and > only-waiting-for-the-blockbackend-and-media-series-to-get-merged series > "block: Rework bdrv_close_all()": > http://lists.nongnu.org/archive/html/qemu-block/2015-03/msg00048.html Ah, I don't care about the number, if someone wants to change it when applying my patch I have no problem with that. Berto From MAILER-DAEMON Mon Sep 21 03:57:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zdvyd-00005F-6U for mharc-qemu-block@gnu.org; Mon, 21 Sep 2015 03:57:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zdvyb-000054-Lx for qemu-block@nongnu.org; Mon, 21 Sep 2015 03:57:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZdvyY-0002TU-Ef for qemu-block@nongnu.org; Mon, 21 Sep 2015 03:57:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38180) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdvyY-0002Sd-6c; Mon, 21 Sep 2015 03:57:26 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 1D4272DD313; Mon, 21 Sep 2015 07:57:25 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-93.ams2.redhat.com [10.36.116.93]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8L7vMGt025094; Mon, 21 Sep 2015 03:57:22 -0400 Date: Mon, 21 Sep 2015 09:57:21 +0200 From: Kevin Wolf To: Eric Blake Message-ID: <20150921075721.GA3518@noname.redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-15-git-send-email-mreitz@redhat.com> <55FC42E2.2020207@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EVF5PPMfhYS0aIcm" Content-Disposition: inline In-Reply-To: <55FC42E2.2020207@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu-block@nongnu.org, Markus Armbruster , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Subject: Re: [Qemu-block] [PATCH v5 14/38] block: Remove wr_highest_sector from BlockAcctStats X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 07:57:30 -0000 --EVF5PPMfhYS0aIcm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 18.09.2015 um 18:59 hat Eric Blake geschrieben: > On 09/18/2015 09:22 AM, Max Reitz wrote: > > BlockAcctStats contains statistics about the data transferred from and > > to the device; wr_highest_sector does not fit in with the rest. > >=20 > > Furthermore, those statistics are supposed to be specific for a certain > > device and not necessarily for a BDS (see the comment above > > bdrv_get_stats()); on the other hand, wr_highest_sector may be a rather > > important information to know for each BDS. When BlockAcctStats is > > finally removed from the BDS, we will want to keep wr_highest_sector in > > the BDS. > >=20 > > Finally, wr_highest_sector is renamed to wr_highest_offset and given the > > appropriate meaning. Externally, it is represented as an offset so there > > is no point in doing something different internally. Its definition is > > changed to match that in qapi/block-core.json which is "the offset after > > the greatest byte written to". Doing so should not cause any harm since > > if external programs tried to calculate the volume usage by > > (wr_highest_offset + 512) / volume_size, after this patch they will just > > assume the volume to be full slightly earlier than before. > >=20 > > Signed-off-by: Max Reitz > > Reviewed-by: Eric Blake > > Reviewed-by: Alberto Garcia >=20 > Still holds, but... >=20 > > +++ b/qmp-commands.hx > > @@ -2481,8 +2481,8 @@ Each json-object contain the following: > > - "wr_total_time_ns": total time spend on writes in nano-seconds (= json-int) > > - "rd_total_time_ns": total time spend on reads in nano-seconds (j= son-int) > > - "flush_total_time_ns": total time spend on cache flushes in nano= -seconds (json-int) > > - - "wr_highest_offset": Highest offset of a sector written since the > > - BlockDriverState has been opened (json-int) > > + - "wr_highest_offset": The offset after the greatest byte written = to the > > + BlockDriverState since it has been opened (= json-int) >=20 > ...someday, I'd really like to have this stat show as non-zero even when > first opening the device (before writing to it). Right now, you have no > clue how full a backing device is prior to starting a block-commit; you > have to start writing to it to get a feel for its current usage. With which value would it start? You don't want the file/device size because for block devices that's more than is actually used yet. What you really want to know is a number for the parent node, which isn't readily available for qcow2 (you would have to scan the refcounts in the last refcount block on startup) and doesn't really exist for most other formats (very few of them can be used on block devices, most rely on the file size). Kevin --EVF5PPMfhYS0aIcm Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJV/7hhAAoJEH8JsnLIjy/WjHcP/14iRoTMNkCXfyCV5PMOaiu6 OybZkb+mZ1M/PIJgyQVSlJ3vurkQDte1bkDx+zpypxaT8t+mMQmuJ7YFuTlchfoY Sjxu0BeFWe0+0AfiikyAUz6Bh/MoqSuBQRMJDlGwHR920a45VmhTNBOCaVpsn0Q4 OBsRrT9d6A6IdaDruri+hhqJXB8/XPEmdR66iyro4iJXg4idsgiJZstJdtXiYsu1 papA9VA4DhKTzK8eyICFT0pByDjukExvA7/cIgrf9YHF7quOaUoZ9ZqndDynUYOb hjmD9F/o7/hgEnm5FwYMdBKhME/bgl5RIWxhjt+EtCWAmS5yP16u0wZCdpKUV2RO OQz+5iKSTjYceXLVXlsO5HPQ9R+Y2EaSVYvrd38YjANLR4mCMvohGvp99cFZThDu u+C53TGraHkst1hScrVvtlyDJTVhii+9kD2JqjtVQilP3/d/3BbCQ9Zk/LM6X8Mj LtGxPolre47mg4hh7sYiI9wzMzUAlFZmpUqK33AW9TPJv1z4+sgcd4jkF2oVmhGq i9cgbh+js0bcVngsqLLogFe7ztjBZnaojjK67e9eoaYkQ3Xib77mSpixRcSU1u3H E3TN6a9sPfCrA4bG+4a+eUihFvAtyrIgapCSSpqeVicTnP6/5jzViaznSlz3DWkn VzjHpmw+Ly0PT2NUVPf0 =BznO -----END PGP SIGNATURE----- --EVF5PPMfhYS0aIcm-- From MAILER-DAEMON Mon Sep 21 08:26:24 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Ze0Aq-00013a-FX for mharc-qemu-block@gnu.org; Mon, 21 Sep 2015 08:26:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze0Am-0000zc-9r for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ze0Ah-0003tX-Al for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:20 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:40305 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze0Ag-0003sg-UQ for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:15 -0400 Received: (qmail 25988 invoked by uid 89); 21 Sep 2015 12:26:13 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.7/20927. hbedv: 8.3.34.26/7.12.12.28. spamassassin: 3.4.0. Clear:RC:1(82.141.1.145):SA:0(-1.2/5.0):. Processed in 0.975237 secs); 21 Sep 2015 12:26:13 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 21 Sep 2015 12:26:12 -0000 X-GL_Whitelist: yes Received: from lieven-pc (lieven-pc.kamp-intra.net [172.21.12.60]) by dns.kamp-intra.net (Postfix) with ESMTP id 05DC3E005A; Mon, 21 Sep 2015 14:25:32 +0200 (CEST) Received: by lieven-pc (Postfix, from userid 1000) id 9F68420B34; Mon, 21 Sep 2015 14:25:31 +0200 (CEST) From: Peter Lieven To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 21 Sep 2015 14:25:23 +0200 Message-Id: <1442838328-23117-1-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, Peter Lieven Subject: [Qemu-block] [PATCH 0/5] ide: avoid main-loop hang on CDROM/NFS failure X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 12:26:21 -0000 This series aims at avoiding a hanging main-loop if a vserver has a CDROM image mounted from a NFS share and that NFS share goes down. Typical situation is that users mount an CDROM ISO to install something and then forget to eject that CDROM afterwards. As a consequence this mounted CD is able to bring down the whole vserver if the backend NFS share is unreachable. This is bad especially if the CDROM itself is not needed anymore at this point. This series aims at fixing 3 blocking I/O operations that would hang if the NFS server is unavailable: - ATAPI PIO read requests used sync calls to blk_read, convert them to an async variant. - If a busmaster DMA request is cancelled all requests are drained. Convert the drain to an async request canceling. - query-block in the HMP or QMP hangs because it indirectly calls bdrv_get_allocated_file_size. Note that Patch 5 is only included for completeness. Peter Peter Lieven (5): ide/atapi: make PIO read requests async ide/atapi: blk_aio_readv may return NULL ide: add support for cancelable read requests ide/atapi: enable cancelable requests block/nfs: cache allocated filesize for read-only files block/nfs.c | 36 ++++++++++++++++++++++++++ hw/ide/atapi.c | 75 +++++++++++++++++++++++++++++++++++-------------------- hw/ide/core.c | 55 ++++++++++++++++++++++++++++++++++++++++ hw/ide/internal.h | 16 ++++++++++++ hw/ide/pci.c | 42 ++++++++++++++++++++----------- 5 files changed, 183 insertions(+), 41 deletions(-) -- 1.9.1 From MAILER-DAEMON Mon Sep 21 08:26:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Ze0As-00017d-Bv for mharc-qemu-block@gnu.org; Mon, 21 Sep 2015 08:26:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze0Am-0000zZ-9l for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ze0Ah-0003tJ-8r for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:20 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:40122 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze0Ag-0003sf-U8 for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:15 -0400 Received: (qmail 26012 invoked by uid 89); 21 Sep 2015 12:26:13 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.7/20927. hbedv: 8.3.34.26/7.12.12.28. spamassassin: 3.4.0. Clear:RC:1(82.141.1.145):SA:0(-1.2/5.0):. Processed in 1.057724 secs); 21 Sep 2015 12:26:13 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 21 Sep 2015 12:26:12 -0000 X-GL_Whitelist: yes Received: from lieven-pc (lieven-pc.kamp-intra.net [172.21.12.60]) by dns.kamp-intra.net (Postfix) with ESMTP id 07571E0065; Mon, 21 Sep 2015 14:25:32 +0200 (CEST) Received: by lieven-pc (Postfix, from userid 1000) id A10B920B32; Mon, 21 Sep 2015 14:25:31 +0200 (CEST) From: Peter Lieven To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 21 Sep 2015 14:25:24 +0200 Message-Id: <1442838328-23117-2-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442838328-23117-1-git-send-email-pl@kamp.de> References: <1442838328-23117-1-git-send-email-pl@kamp.de> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, Peter Lieven Subject: [Qemu-block] [PATCH 1/5] ide/atapi: make PIO read requests async X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 12:26:21 -0000 PIO read requests on the ATAPI interface used to be sync blk requests. This has to siginificant drawbacks. First the main loop hangs util an I/O request is completed and secondly if the I/O request does not complete (e.g. due to an unresponsive storage) Qemu hangs completely. Signed-off-by: Peter Lieven --- hw/ide/atapi.c | 69 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 747f466..9257e1c 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -105,31 +105,51 @@ static void cd_data_to_raw(uint8_t *buf, int lba) memset(buf, 0, 288); } -static int cd_read_sector(IDEState *s, int lba, uint8_t *buf, int sector_size) +static void cd_read_sector_cb(void *opaque, int ret) { - int ret; + IDEState *s = opaque; - switch(sector_size) { - case 2048: - block_acct_start(blk_get_stats(s->blk), &s->acct, - 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); - ret = blk_read(s->blk, (int64_t)lba << 2, buf, 4); - block_acct_done(blk_get_stats(s->blk), &s->acct); - break; - case 2352: - block_acct_start(blk_get_stats(s->blk), &s->acct, - 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); - ret = blk_read(s->blk, (int64_t)lba << 2, buf + 16, 4); - block_acct_done(blk_get_stats(s->blk), &s->acct); - if (ret < 0) - return ret; - cd_data_to_raw(buf, lba); - break; - default: - ret = -EIO; - break; + block_acct_done(blk_get_stats(s->blk), &s->acct); + + if (ret < 0) { + ide_atapi_io_error(s, ret); + return; + } + + if (s->cd_sector_size == 2352) { + cd_data_to_raw(s->io_buffer, s->lba); } - return ret; + + s->lba++; + s->io_buffer_index = 0; + s->status &= ~BUSY_STAT; + + ide_atapi_cmd_reply_end(s); +} + +static int cd_read_sector(IDEState *s, int lba, void *buf, int sector_size) +{ + if (sector_size != 2048 && sector_size != 2352) { + return -EINVAL; + } + + s->iov.iov_base = buf; + if (sector_size == 2352) { + buf += 4; + } + + s->iov.iov_len = 4 * BDRV_SECTOR_SIZE; + qemu_iovec_init_external(&s->qiov, &s->iov, 1); + + if (blk_aio_readv(s->blk, (int64_t)lba << 2, &s->qiov, 4, + cd_read_sector_cb, s) == NULL) { + return -EIO; + } + + block_acct_start(blk_get_stats(s->blk), &s->acct, + 4 * BDRV_SECTOR_SIZE, BLOCK_ACCT_READ); + s->status |= BUSY_STAT; + return 0; } void ide_atapi_cmd_ok(IDEState *s) @@ -190,10 +210,8 @@ void ide_atapi_cmd_reply_end(IDEState *s) ret = cd_read_sector(s, s->lba, s->io_buffer, s->cd_sector_size); if (ret < 0) { ide_atapi_io_error(s, ret); - return; } - s->lba++; - s->io_buffer_index = 0; + return; } if (s->elementary_transfer_size > 0) { /* there are some data left to transmit in this elementary @@ -275,7 +293,6 @@ static void ide_atapi_cmd_read_pio(IDEState *s, int lba, int nb_sectors, s->io_buffer_index = sector_size; s->cd_sector_size = sector_size; - s->status = READY_STAT | SEEK_STAT; ide_atapi_cmd_reply_end(s); } -- 1.9.1 From MAILER-DAEMON Mon Sep 21 08:26:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Ze0As-00018F-Uo for mharc-qemu-block@gnu.org; Mon, 21 Sep 2015 08:26:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze0An-0000zo-BO for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ze0Ai-0003uG-80 for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:21 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:51198 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze0Ah-0003ty-UW for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:16 -0400 Received: (qmail 26030 invoked by uid 89); 21 Sep 2015 12:26:14 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.7/20927. hbedv: 8.3.34.26/7.12.12.28. spamassassin: 3.4.0. Clear:RC:1(82.141.1.145):SA:0(-1.2/5.0):. Processed in 1.25182 secs); 21 Sep 2015 12:26:14 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 21 Sep 2015 12:26:12 -0000 X-GL_Whitelist: yes Received: from lieven-pc (lieven-pc.kamp-intra.net [172.21.12.60]) by dns.kamp-intra.net (Postfix) with ESMTP id 1238EE006B; Mon, 21 Sep 2015 14:25:32 +0200 (CEST) Received: by lieven-pc (Postfix, from userid 1000) id B21EB20B34; Mon, 21 Sep 2015 14:25:31 +0200 (CEST) From: Peter Lieven To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 21 Sep 2015 14:25:27 +0200 Message-Id: <1442838328-23117-5-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442838328-23117-1-git-send-email-pl@kamp.de> References: <1442838328-23117-1-git-send-email-pl@kamp.de> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, Peter Lieven Subject: [Qemu-block] [PATCH 4/5] ide/atapi: enable cancelable requests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 12:26:22 -0000 Signed-off-by: Peter Lieven --- hw/ide/atapi.c | 4 ++-- hw/ide/core.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index b209ed9..ab45495 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -141,7 +141,7 @@ static int cd_read_sector(IDEState *s, int lba, void *buf, int sector_size) s->iov.iov_len = 4 * BDRV_SECTOR_SIZE; qemu_iovec_init_external(&s->qiov, &s->iov, 1); - if (blk_aio_readv(s->blk, (int64_t)lba << 2, &s->qiov, 4, + if (ide_readv_cancelable(s, (int64_t)lba << 2, &s->qiov, 4, cd_read_sector_cb, s) == NULL) { return -EIO; } @@ -368,7 +368,7 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret) s->bus->dma->iov.iov_len = n * 4 * 512; qemu_iovec_init_external(&s->bus->dma->qiov, &s->bus->dma->iov, 1); - s->bus->dma->aiocb = blk_aio_readv(s->blk, (int64_t)s->lba << 2, + s->bus->dma->aiocb = ide_readv_cancelable(s, (int64_t)s->lba << 2, &s->bus->dma->qiov, n * 4, ide_atapi_cmd_read_dma_cb, s); if (s->bus->dma->aiocb == NULL) { diff --git a/hw/ide/core.c b/hw/ide/core.c index 24547ce..5c7a346 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2330,6 +2330,7 @@ int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind, if (kind == IDE_CD) { blk_set_dev_ops(blk, &ide_cd_block_ops, s); blk_set_guest_block_size(blk, 2048); + s->requests_cancelable = true; } else { if (!blk_is_inserted(s->blk)) { error_report("Device needs media, but drive is empty"); -- 1.9.1 From MAILER-DAEMON Mon Sep 21 08:26:24 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Ze0Aq-000137-9M for mharc-qemu-block@gnu.org; Mon, 21 Sep 2015 08:26:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze0Am-0000zY-9U for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ze0Ah-0003ti-9k for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:20 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:34609 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze0Ag-0003sh-UF for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:15 -0400 Received: (qmail 26001 invoked by uid 89); 21 Sep 2015 12:26:13 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.7/20927. hbedv: 8.3.34.26/7.12.12.28. spamassassin: 3.4.0. Clear:RC:1(82.141.1.145):SA:0(-1.2/5.0):. Processed in 0.882257 secs); 21 Sep 2015 12:26:13 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 21 Sep 2015 12:26:12 -0000 X-GL_Whitelist: yes Received: from lieven-pc (lieven-pc.kamp-intra.net [172.21.12.60]) by dns.kamp-intra.net (Postfix) with ESMTP id 0952AE0067; Mon, 21 Sep 2015 14:25:32 +0200 (CEST) Received: by lieven-pc (Postfix, from userid 1000) id A39CF20D64; Mon, 21 Sep 2015 14:25:31 +0200 (CEST) From: Peter Lieven To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 21 Sep 2015 14:25:25 +0200 Message-Id: <1442838328-23117-3-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442838328-23117-1-git-send-email-pl@kamp.de> References: <1442838328-23117-1-git-send-email-pl@kamp.de> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, Peter Lieven Subject: [Qemu-block] [PATCH 2/5] ide/atapi: blk_aio_readv may return NULL X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 12:26:21 -0000 Signed-off-by: Peter Lieven --- hw/ide/atapi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 9257e1c..b209ed9 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -371,6 +371,10 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret) s->bus->dma->aiocb = blk_aio_readv(s->blk, (int64_t)s->lba << 2, &s->bus->dma->qiov, n * 4, ide_atapi_cmd_read_dma_cb, s); + if (s->bus->dma->aiocb == NULL) { + ide_atapi_io_error(s, -EIO); + goto eot; + } return; eot: -- 1.9.1 From MAILER-DAEMON Mon Sep 21 08:26:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Ze0As-00017w-I1 for mharc-qemu-block@gnu.org; Mon, 21 Sep 2015 08:26:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze0Am-0000zd-A8 for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ze0Ah-0003tp-E6 for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:20 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:52028 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze0Ag-0003sj-Tg for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:15 -0400 Received: (qmail 26023 invoked by uid 89); 21 Sep 2015 12:26:14 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.7/20927. hbedv: 8.3.34.26/7.12.12.28. spamassassin: 3.4.0. Clear:RC:1(82.141.1.145):SA:0(-1.2/5.0):. Processed in 1.192882 secs); 21 Sep 2015 12:26:14 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 21 Sep 2015 12:26:12 -0000 X-GL_Whitelist: yes Received: from lieven-pc (lieven-pc.kamp-intra.net [172.21.12.60]) by dns.kamp-intra.net (Postfix) with ESMTP id 1025FE0069; Mon, 21 Sep 2015 14:25:32 +0200 (CEST) Received: by lieven-pc (Postfix, from userid 1000) id A664320D66; Mon, 21 Sep 2015 14:25:31 +0200 (CEST) From: Peter Lieven To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 21 Sep 2015 14:25:26 +0200 Message-Id: <1442838328-23117-4-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442838328-23117-1-git-send-email-pl@kamp.de> References: <1442838328-23117-1-git-send-email-pl@kamp.de> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, Peter Lieven Subject: [Qemu-block] [PATCH 3/5] ide: add support for cancelable read requests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 12:26:22 -0000 this patch adds a new aio readv compatible function which copies all data through a bounce buffer. The benefit is that these requests can be flagged as canceled to avoid guest memory corruption when a canceled request is completed by the backend at a later stage. If an IDE protocol wants to use this function it has to pipe all read requests through ide_readv_cancelable and it may then enable requests_cancelable in the IDEState. If this state is enable we can avoid the blocking blk_drain_all in case of a BMDMA reset. Currently only read operations are cancelable thus we can only use this logic for read-only devices. Signed-off-by: Peter Lieven --- hw/ide/core.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/ide/internal.h | 16 ++++++++++++++++ hw/ide/pci.c | 42 ++++++++++++++++++++++++++++-------------- 3 files changed, 98 insertions(+), 14 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 317406d..24547ce 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -561,6 +561,59 @@ static bool ide_sect_range_ok(IDEState *s, return true; } +static void ide_readv_cancelable_cb(void *opaque, int ret) +{ + IDECancelableRequest *req = opaque; + if (!req->canceled) { + if (!ret) { + qemu_iovec_from_buf(req->org_qiov, 0, req->buf, req->org_qiov->size); + } + req->org_cb(req->org_opaque, ret); + } + QLIST_REMOVE(req, list); + qemu_vfree(req->buf); + qemu_iovec_destroy(&req->qiov); + g_free(req); +} + +#define MAX_CANCELABLE_REQS 16 + +BlockAIOCB *ide_readv_cancelable(IDEState *s, int64_t sector_num, + QEMUIOVector *iov, int nb_sectors, + BlockCompletionFunc *cb, void *opaque) +{ + BlockAIOCB *aioreq; + IDECancelableRequest *req; + int c = 0; + + QLIST_FOREACH(req, &s->cancelable_requests, list) { + c++; + } + if (c > MAX_CANCELABLE_REQS) { + return NULL; + } + + req = g_new0(IDECancelableRequest, 1); + qemu_iovec_init(&req->qiov, 1); + req->buf = qemu_blockalign(blk_bs(s->blk), iov->size); + qemu_iovec_add(&req->qiov, req->buf, iov->size); + req->org_qiov = iov; + req->org_cb = cb; + req->org_opaque = opaque; + + aioreq = blk_aio_readv(s->blk, sector_num, &req->qiov, nb_sectors, + ide_readv_cancelable_cb, req); + if (aioreq == NULL) { + qemu_vfree(req->buf); + qemu_iovec_destroy(&req->qiov); + g_free(req); + } else { + QLIST_INSERT_HEAD(&s->cancelable_requests, req, list); + } + + return aioreq; +} + static void ide_sector_read(IDEState *s); static void ide_sector_read_cb(void *opaque, int ret) @@ -805,6 +858,7 @@ void ide_start_dma(IDEState *s, BlockCompletionFunc *cb) s->bus->retry_unit = s->unit; s->bus->retry_sector_num = ide_get_sector(s); s->bus->retry_nsector = s->nsector; + s->bus->s = s; if (s->bus->dma->ops->start_dma) { s->bus->dma->ops->start_dma(s->bus->dma, s, cb); } diff --git a/hw/ide/internal.h b/hw/ide/internal.h index 05e93ff..ad188c2 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -343,6 +343,16 @@ enum ide_dma_cmd { #define ide_cmd_is_read(s) \ ((s)->dma_cmd == IDE_DMA_READ) +typedef struct IDECancelableRequest { + QLIST_ENTRY(IDECancelableRequest) list; + QEMUIOVector qiov; + uint8_t *buf; + QEMUIOVector *org_qiov; + BlockCompletionFunc *org_cb; + void *org_opaque; + bool canceled; +} IDECancelableRequest; + /* NOTE: IDEState represents in fact one drive */ struct IDEState { IDEBus *bus; @@ -396,6 +406,8 @@ struct IDEState { BlockAIOCB *pio_aiocb; struct iovec iov; QEMUIOVector qiov; + QLIST_HEAD(, IDECancelableRequest) cancelable_requests; + bool requests_cancelable; /* ATA DMA state */ int32_t io_buffer_offset; int32_t io_buffer_size; @@ -468,6 +480,7 @@ struct IDEBus { uint8_t retry_unit; int64_t retry_sector_num; uint32_t retry_nsector; + IDEState *s; }; #define TYPE_IDE_DEVICE "ide-device" @@ -572,6 +585,9 @@ void ide_set_inactive(IDEState *s, bool more); BlockAIOCB *ide_issue_trim(BlockBackend *blk, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockCompletionFunc *cb, void *opaque); +BlockAIOCB *ide_readv_cancelable(IDEState *s, int64_t sector_num, + QEMUIOVector *iov, int nb_sectors, + BlockCompletionFunc *cb, void *opaque); /* hw/ide/atapi.c */ void ide_atapi_cmd(IDEState *s); diff --git a/hw/ide/pci.c b/hw/ide/pci.c index d31ff88..5587183 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -240,21 +240,35 @@ void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val) /* Ignore writes to SSBM if it keeps the old value */ if ((val & BM_CMD_START) != (bm->cmd & BM_CMD_START)) { if (!(val & BM_CMD_START)) { - /* - * We can't cancel Scatter Gather DMA in the middle of the - * operation or a partial (not full) DMA transfer would reach - * the storage so we wait for completion instead (we beahve - * like if the DMA was completed by the time the guest trying - * to cancel dma with bmdma_cmd_writeb with BM_CMD_START not - * set). - * - * In the future we'll be able to safely cancel the I/O if the - * whole DMA operation will be submitted to disk with a single - * aio operation with preadv/pwritev. - */ if (bm->bus->dma->aiocb) { - blk_drain_all(); - assert(bm->bus->dma->aiocb == NULL); + if (bm->bus->s && bm->bus->s->requests_cancelable) { + /* + * If the used IDE protocol supports request cancelation we + * can flag requests as canceled here and disable DMA. + * The IDE protocol used MUST use ide_readv_cancelable for all + * read operations and then subsequently can enable this code + * path. Currently this is only supported for read-only + * devices. + */ + IDECancelableRequest *req; + QLIST_FOREACH(req, &bm->bus->s->cancelable_requests, list) { + if (!req->canceled) { + req->org_cb(req->org_opaque, -ECANCELED); + } + req->canceled = true; + } + } else { + /* + * We can't cancel Scatter Gather DMA in the middle of the + * operation or a partial (not full) DMA transfer would reach + * the storage so we wait for completion instead (we beahve + * like if the DMA was completed by the time the guest trying + * to cancel dma with bmdma_cmd_writeb with BM_CMD_START not + * set). + */ + blk_drain_all(); + assert(bm->bus->dma->aiocb == NULL); + } } bm->status &= ~BM_STATUS_DMAING; } else { -- 1.9.1 From MAILER-DAEMON Mon Sep 21 09:17:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Ze0yg-0005pO-Hr for mharc-qemu-block@gnu.org; Mon, 21 Sep 2015 09:17:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze0Bj-0001Ln-9B for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:27:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ze0BL-0004BZ-NM for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:27:00 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:38732 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze0BL-0004BN-CY for qemu-block@nongnu.org; Mon, 21 Sep 2015 08:26:55 -0400 Received: (qmail 26062 invoked by uid 89); 21 Sep 2015 12:26:54 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.7/20927. hbedv: 8.3.34.26/7.12.12.28. spamassassin: 3.4.0. Clear:RC:1(82.141.1.145):SA:0(-1.2/5.0):. Processed in 0.957727 secs); 21 Sep 2015 12:26:54 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 21 Sep 2015 12:26:53 -0000 X-GL_Whitelist: yes Received: from lieven-pc (lieven-pc.kamp-intra.net [172.21.12.60]) by dns.kamp-intra.net (Postfix) with ESMTP id 148ECE006D; Mon, 21 Sep 2015 14:25:32 +0200 (CEST) Received: by lieven-pc (Postfix, from userid 1000) id B427120D64; Mon, 21 Sep 2015 14:25:31 +0200 (CEST) From: Peter Lieven To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 21 Sep 2015 14:25:28 +0200 Message-Id: <1442838328-23117-6-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442838328-23117-1-git-send-email-pl@kamp.de> References: <1442838328-23117-1-git-send-email-pl@kamp.de> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, Peter Lieven Subject: [Qemu-block] [PATCH 5/5] block/nfs: cache allocated filesize for read-only files X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 13:17:52 -0000 If the file is readonly its not expected to grow so save the blocking call to nfs_fstat_async and use the value saved at connection time. Also important the monitor (and thus the main loop) will not hang if block device info is queried and the NFS share is unresponsive. Signed-off-by: Peter Lieven Reviewed-by: Max Reitz Reviewed-by: Jeff Cody --- block/nfs.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/block/nfs.c b/block/nfs.c index c026ff6..5ffd19f 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -43,6 +43,7 @@ typedef struct NFSClient { int events; bool has_zero_init; AioContext *aio_context; + blkcnt_t st_blocks; } NFSClient; typedef struct NFSRPC { @@ -374,6 +375,7 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename, } ret = DIV_ROUND_UP(st.st_size, BDRV_SECTOR_SIZE); + client->st_blocks = st.st_blocks; client->has_zero_init = S_ISREG(st.st_mode); goto out; fail: @@ -464,6 +466,11 @@ static int64_t nfs_get_allocated_file_size(BlockDriverState *bs) NFSRPC task = {0}; struct stat st; + if (bdrv_is_read_only(bs) && + !(bs->open_flags & BDRV_O_NOCACHE)) { + return client->st_blocks * 512; + } + task.st = &st; if (nfs_fstat_async(client->context, client->fh, nfs_co_generic_cb, &task) != 0) { @@ -484,6 +491,34 @@ static int nfs_file_truncate(BlockDriverState *bs, int64_t offset) return nfs_ftruncate(client->context, client->fh, offset); } +/* Note that this will not re-establish a connection with the NFS server + * - it is effectively a NOP. */ +static int nfs_reopen_prepare(BDRVReopenState *state, + BlockReopenQueue *queue, Error **errp) +{ + NFSClient *client = state->bs->opaque; + struct stat st; + int ret = 0; + + if (state->flags & BDRV_O_RDWR && bdrv_is_read_only(state->bs)) { + error_setg(errp, "Cannot open a read-only mount as read-write"); + return -EACCES; + } + + /* Update cache for read-only reopens */ + if (!(state->flags & BDRV_O_RDWR)) { + ret = nfs_fstat(client->context, client->fh, &st); + if (ret < 0) { + error_setg(errp, "Failed to fstat file: %s", + nfs_get_error(client->context)); + return ret; + } + client->st_blocks = st.st_blocks; + } + + return 0; +} + static BlockDriver bdrv_nfs = { .format_name = "nfs", .protocol_name = "nfs", @@ -499,6 +534,7 @@ static BlockDriver bdrv_nfs = { .bdrv_file_open = nfs_file_open, .bdrv_close = nfs_file_close, .bdrv_create = nfs_file_create, + .bdrv_reopen_prepare = nfs_reopen_prepare, .bdrv_co_readv = nfs_co_readv, .bdrv_co_writev = nfs_co_writev, -- 1.9.1 From MAILER-DAEMON Mon Sep 21 11:54:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Ze3Pl-000830-DF for mharc-qemu-block@gnu.org; Mon, 21 Sep 2015 11:54:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze3Pf-0007wr-Va for qemu-block@nongnu.org; Mon, 21 Sep 2015 11:54:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ze3Pd-00031z-58 for qemu-block@nongnu.org; Mon, 21 Sep 2015 11:53:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35392) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze3Pc-00031v-Vo; Mon, 21 Sep 2015 11:53:53 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 8FAD1C0B9185; Mon, 21 Sep 2015 15:53:52 +0000 (UTC) Received: from [10.3.113.166] (ovpn-113-166.phx2.redhat.com [10.3.113.166]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8LFrpfV017559; Mon, 21 Sep 2015 11:53:51 -0400 To: Kevin Wolf References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-15-git-send-email-mreitz@redhat.com> <55FC42E2.2020207@redhat.com> <20150921075721.GA3518@noname.redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <5600280F.4050009@redhat.com> Date: Mon, 21 Sep 2015 09:53:51 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150921075721.GA3518@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="R7ECJLeDkb96km0ejXj73aeOFkCxK7bJF" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu-block@nongnu.org, Markus Armbruster , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Subject: Re: [Qemu-block] [PATCH v5 14/38] block: Remove wr_highest_sector from BlockAcctStats X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 15:54:00 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --R7ECJLeDkb96km0ejXj73aeOFkCxK7bJF Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/21/2015 01:57 AM, Kevin Wolf wrote: >>> + - "wr_highest_offset": The offset after the greatest byte writte= n to the >>> + BlockDriverState since it has been opened= (json-int) >> >> ...someday, I'd really like to have this stat show as non-zero even wh= en >> first opening the device (before writing to it). Right now, you have n= o >> clue how full a backing device is prior to starting a block-commit; yo= u >> have to start writing to it to get a feel for its current usage. >=20 > With which value would it start? You don't want the file/device size > because for block devices that's more than is actually used yet. >=20 > What you really want to know is a number for the parent node, which > isn't readily available for qcow2 (you would have to scan the refcounts= > in the last refcount block on startup) and doesn't really exist for mos= t > other formats (very few of them can be used on block devices, most rely= > on the file size). Libvirt only uses the stat on qcow2 format atop block devices, and uses it precisely because that is the one place where relying on device size is wrong. And yes, it really WOULD be nice for the value to read the last refcount block on startup, as that IS the correct value. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --R7ECJLeDkb96km0ejXj73aeOFkCxK7bJF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWACgPAAoJEKeha0olJ0NqLGYIAIIKZc7fFFSEM16W1UV8hXel 8KNhBfaujhOgb8H0JkW8iRyIMcUARZTwo6ghgni44XB3UxQ/L7FzPK9iuxWQZpZC H/D/XRGbmQ8anibKiveQYcBtUYvnOWQseWcde0PkEiDycX3i97UyrYh6vqxTrZKF NRMQ9vA39H1xg2iDiDL71Abj9icOqmLOtKIERUvrI4tFuq5EgpgpHcq3lj9Q0WF7 l+WDfs7R7/Sip/S86mljxDmf7RRzuzw0/a8E8f+iDROwYgYmVjoaedGsIPZQLc7Z YDql/482Q2O+55u+1EttElnZjf2PiGknXsoPE8bIvcAZPOW0x3qhTdE6pErhiiE= =fGL+ -----END PGP SIGNATURE----- --R7ECJLeDkb96km0ejXj73aeOFkCxK7bJF-- From MAILER-DAEMON Mon Sep 21 16:58:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Ze8AQ-00007q-Kq for mharc-qemu-block@gnu.org; Mon, 21 Sep 2015 16:58:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze8AN-00006s-Tq for qemu-block@nongnu.org; Mon, 21 Sep 2015 16:58:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ze8AI-0004Vq-UE for qemu-block@nongnu.org; Mon, 21 Sep 2015 16:58:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48210) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze8AI-0004VM-Ow; Mon, 21 Sep 2015 16:58:22 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 6446BC0B91A3; Mon, 21 Sep 2015 20:58:22 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8LKwKkH017223; Mon, 21 Sep 2015 16:58:20 -0400 To: Peter Lieven , qemu-devel@nongnu.org, qemu-block@nongnu.org References: <1442838328-23117-1-git-send-email-pl@kamp.de> From: John Snow Message-ID: <56006F6C.5050606@redhat.com> Date: Mon, 21 Sep 2015 16:58:20 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442838328-23117-1-git-send-email-pl@kamp.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 0/5] ide: avoid main-loop hang on CDROM/NFS failure X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 20:58:28 -0000 On 09/21/2015 08:25 AM, Peter Lieven wrote: > This series aims at avoiding a hanging main-loop if a vserver has a > CDROM image mounted from a NFS share and that NFS share goes down. > Typical situation is that users mount an CDROM ISO to install something > and then forget to eject that CDROM afterwards. > As a consequence this mounted CD is able to bring down the > whole vserver if the backend NFS share is unreachable. This is bad > especially if the CDROM itself is not needed anymore at this point. > > This series aims at fixing 3 blocking I/O operations that would > hang if the NFS server is unavailable: > - ATAPI PIO read requests used sync calls to blk_read, convert > them to an async variant. > - If a busmaster DMA request is cancelled all requests are drained. > Convert the drain to an async request canceling. > - query-block in the HMP or QMP hangs because it indirectly calls > bdrv_get_allocated_file_size. > > Note that Patch 5 is only included for completeness. > > Peter > > Peter Lieven (5): > ide/atapi: make PIO read requests async > ide/atapi: blk_aio_readv may return NULL > ide: add support for cancelable read requests > ide/atapi: enable cancelable requests > block/nfs: cache allocated filesize for read-only files > > block/nfs.c | 36 ++++++++++++++++++++++++++ > hw/ide/atapi.c | 75 +++++++++++++++++++++++++++++++++++-------------------- > hw/ide/core.c | 55 ++++++++++++++++++++++++++++++++++++++++ > hw/ide/internal.h | 16 ++++++++++++ > hw/ide/pci.c | 42 ++++++++++++++++++++----------- > 5 files changed, 183 insertions(+), 41 deletions(-) > I assume this supersedes both: [Qemu-devel] [PATCH 0/2] ide/atapi: partially avoid deadlock if the storage backend is dead and [Qemu-devel] [PATCH] ide/atapi: make PIO read requests async right? --js From MAILER-DAEMON Mon Sep 21 17:22:05 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Ze8XF-0005tc-HC for mharc-qemu-block@gnu.org; Mon, 21 Sep 2015 17:22:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51275) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze8XB-0005rw-QA for qemu-block@nongnu.org; Mon, 21 Sep 2015 17:22:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ze8X7-0001b7-Tc for qemu-block@nongnu.org; Mon, 21 Sep 2015 17:22:01 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:60053 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze8X7-0001Zx-JB for qemu-block@nongnu.org; Mon, 21 Sep 2015 17:21:57 -0400 Received: (qmail 16169 invoked by uid 89); 21 Sep 2015 21:21:55 -0000 Received: from [195.62.97.28] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.7/20930. hbedv: 8.3.34.32/7.12.12.42. spamassassin: 3.4.0. Clear:RC:1(195.62.97.28):SA:0(-1.1/5.0):. Processed in 1.423701 secs); 21 Sep 2015 21:21:55 -0000 Received: from smtp.kamp.de (HELO submission.kamp.de) ([195.62.97.28]) by mx01.kamp.de with ESMTPS (DHE-RSA-AES256-SHA encrypted); 21 Sep 2015 21:21:53 -0000 X-GL_Whitelist: yes Received: (qmail 27918 invoked from network); 21 Sep 2015 21:09:34 -0000 Received: from unknown (HELO ?82.141.7.26?) (pl@kamp.de@82.141.7.26) by submission.kamp.de with ESMTPS (DHE-RSA-AES256-SHA encrypted) ESMTPA; 21 Sep 2015 21:09:34 -0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) From: Peter Lieven X-Mailer: iPhone Mail (13A344) In-Reply-To: <56006F6C.5050606@redhat.com> Date: Mon, 21 Sep 2015 23:22:05 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <78B92BE9-2F1E-470F-8C2F-2BBC4E813DB4@kamp.de> References: <1442838328-23117-1-git-send-email-pl@kamp.de> <56006F6C.5050606@redhat.com> To: John Snow X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 0/5] ide: avoid main-loop hang on CDROM/NFS failure X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 21:22:03 -0000 > Am 21.09.2015 um 22:58 schrieb John Snow : >=20 >=20 >=20 >> On 09/21/2015 08:25 AM, Peter Lieven wrote: >> This series aims at avoiding a hanging main-loop if a vserver has a >> CDROM image mounted from a NFS share and that NFS share goes down. >> Typical situation is that users mount an CDROM ISO to install something >> and then forget to eject that CDROM afterwards. >> As a consequence this mounted CD is able to bring down the >> whole vserver if the backend NFS share is unreachable. This is bad >> especially if the CDROM itself is not needed anymore at this point. >>=20 >> This series aims at fixing 3 blocking I/O operations that would >> hang if the NFS server is unavailable: >> - ATAPI PIO read requests used sync calls to blk_read, convert >> them to an async variant. >> - If a busmaster DMA request is cancelled all requests are drained. >> Convert the drain to an async request canceling. >> - query-block in the HMP or QMP hangs because it indirectly calls >> bdrv_get_allocated_file_size. >>=20 >> Note that Patch 5 is only included for completeness. >>=20 >> Peter >>=20 >> Peter Lieven (5): >> ide/atapi: make PIO read requests async >> ide/atapi: blk_aio_readv may return NULL >> ide: add support for cancelable read requests >> ide/atapi: enable cancelable requests >> block/nfs: cache allocated filesize for read-only files >>=20 >> block/nfs.c | 36 ++++++++++++++++++++++++++ >> hw/ide/atapi.c | 75 +++++++++++++++++++++++++++++++++++---------------= ----- >> hw/ide/core.c | 55 ++++++++++++++++++++++++++++++++++++++++ >> hw/ide/internal.h | 16 ++++++++++++ >> hw/ide/pci.c | 42 ++++++++++++++++++++----------- >> 5 files changed, 183 insertions(+), 41 deletions(-) >=20 > I assume this supersedes both: >=20 > [Qemu-devel] [PATCH 0/2] ide/atapi: partially avoid deadlock if the > storage backend is dead >=20 > and >=20 > [Qemu-devel] [PATCH] ide/atapi: make PIO read requests async >=20 > right? yes, the first patch was wrong as Stefan pointed out and the second is the s= ame version as previously on the list. Peter=20 >=20 > --js From MAILER-DAEMON Mon Sep 21 17:58:55 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Ze96s-000092-SM for mharc-qemu-block@gnu.org; Mon, 21 Sep 2015 17:58:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze96c-0008An-KN for qemu-block@nongnu.org; Mon, 21 Sep 2015 17:58:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ze96b-00017n-Jn for qemu-block@nongnu.org; Mon, 21 Sep 2015 17:58:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53547) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze96b-00017O-6x; Mon, 21 Sep 2015 17:58:37 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id D1A33C0A1494; Mon, 21 Sep 2015 21:58:36 +0000 (UTC) Received: from red.redhat.com (ovpn-113-166.phx2.redhat.com [10.3.113.166]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8LLw4bw027229; Mon, 21 Sep 2015 17:58:35 -0400 From: Eric Blake To: qemu-devel@nongnu.org Date: Mon, 21 Sep 2015 15:57:52 -0600 Message-Id: <1442872682-6523-37-git-send-email-eblake@redhat.com> In-Reply-To: <1442872682-6523-1-git-send-email-eblake@redhat.com> References: <1442872682-6523-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , ehabkost@redhat.com, "open list:Block layer core" , armbru@redhat.com, Gerd Hoffmann , DirtY.iCE.hu@gmail.com, marcandre.lureau@redhat.com Subject: [Qemu-block] [PATCH v5 36/46] qapi: Avoid use of 'data' member of qapi unions X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 21:58:39 -0000 qapi code generators currently create a 'void *data' member as part of the anonymous union embedded in the C struct corresponding to a qapi union. However, directly assigning to this member of the union feels a bit fishy, when we can directly use the rest of the struct instead. Signed-off-by: Eric Blake --- blockdev.c | 22 ++++++++++++---------- ui/input.c | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/blockdev.c b/blockdev.c index bf8a7a2..28a3375 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1052,14 +1052,11 @@ void hmp_commit(Monitor *mon, const QDict *qdict) } } -static void blockdev_do_action(int type, void *data, Error **errp) +static void blockdev_do_action(TransactionAction *action, Error **errp) { - TransactionAction action; TransactionActionList list; - action.type = type; - action.data = data; - list.value = &action; + list.value = action; list.next = NULL; qmp_transaction(&list, errp); } @@ -1085,8 +1082,11 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, .has_mode = has_mode, .mode = mode, }; - blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC, - &snapshot, errp); + TransactionAction action = { + .type = TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC, + .blockdev_snapshot_sync = &snapshot, + }; + blockdev_do_action(&action, errp); } void qmp_blockdev_snapshot_internal_sync(const char *device, @@ -1097,9 +1097,11 @@ void qmp_blockdev_snapshot_internal_sync(const char *device, .device = (char *) device, .name = (char *) name }; - - blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_INTERNAL_SYNC, - &snapshot, errp); + TransactionAction action = { + .type = TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_INTERNAL_SYNC, + .blockdev_snapshot_internal_sync = &snapshot, + }; + blockdev_do_action(&action, errp); } SnapshotInfo *qmp_blockdev_snapshot_delete_internal_sync(const char *device, diff --git a/ui/input.c b/ui/input.c index fd86571..edd237d 100644 --- a/ui/input.c +++ b/ui/input.c @@ -452,7 +452,7 @@ InputEvent *qemu_input_event_new_move(InputEventKind kind, InputMoveEvent *move = g_new0(InputMoveEvent, 1); evt->type = kind; - evt->data = move; + evt->rel = move; /* also would work as evt->abs */ move->axis = axis; move->value = value; return evt; -- 2.4.3 From MAILER-DAEMON Mon Sep 21 17:58:55 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Ze96t-00009c-4m for mharc-qemu-block@gnu.org; Mon, 21 Sep 2015 17:58:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze96a-000885-No for qemu-block@nongnu.org; Mon, 21 Sep 2015 17:58:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ze96X-00014z-1j for qemu-block@nongnu.org; Mon, 21 Sep 2015 17:58:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46820) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze96W-00014r-My; Mon, 21 Sep 2015 17:58:33 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 5522D2F90FB; Mon, 21 Sep 2015 21:58:32 +0000 (UTC) Received: from red.redhat.com (ovpn-113-166.phx2.redhat.com [10.3.113.166]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8LLw4br027229; Mon, 21 Sep 2015 17:58:30 -0400 From: Eric Blake To: qemu-devel@nongnu.org Date: Mon, 21 Sep 2015 15:57:47 -0600 Message-Id: <1442872682-6523-32-git-send-email-eblake@redhat.com> In-Reply-To: <1442872682-6523-1-git-send-email-eblake@redhat.com> References: <1442872682-6523-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , ehabkost@redhat.com, "open list:qcow2" , "Michael S. Tsirkin" , Jason Wang , armbru@redhat.com, Luiz Capitulino , Igor Mammedov , Paolo Bonzini , Gerd Hoffmann , DirtY.iCE.hu@gmail.com, marcandre.lureau@redhat.com, Michael Roth Subject: [Qemu-block] [PATCH v5 31/46] qapi: use 'type' in generated C code to match QMP union wire form X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 21:58:40 -0000 When dealing with simple qapi unions, the code was generating a discriminator field of 'kind' even though the discriminator is sent as 'type' over QMP. Renaming things to match gets us one step closer to reusing common generator code for both simple and flat unions, without having to special case the naming choice for simple unions. It also gets rid of some TODO markers in using the raw QAPISchemaObjectTypeVariants.tag_name field, although we can't yet convert that field to private until later fixes to alternate types also quit using it. However, this patch does not rename the generated enum, which is still 'unionnameKind'; if we wanted, a further patch could generate implicit enums as 'unionnameType', with even more churn to C code to react, and probably update the qapi generator to reserve the 'fooType' namespace instead of 'fooKind', or better yet ensure that generated names do not conflict with user names. But that is a lot harder, as we already have existing qapi usage of types that end in 'Type'. Signed-off-by: Eric Blake --- block/qcow2.c | 2 +- block/vmdk.c | 2 +- blockdev.c | 16 ++++++++-------- hmp.c | 12 ++++++------ hw/input/hid.c | 2 +- hw/input/ps2.c | 2 +- hw/input/virtio-input-hid.c | 2 +- hw/mem/pc-dimm.c | 2 +- net/dump.c | 2 +- net/hub.c | 2 +- net/l2tpv3.c | 2 +- net/net.c | 20 ++++++++++---------- net/slirp.c | 2 +- net/socket.c | 2 +- net/tap.c | 4 ++-- net/vhost-user.c | 2 +- numa.c | 4 ++-- qemu-char.c | 24 ++++++++++++------------ scripts/qapi-types.py | 7 ++----- scripts/qapi-visit.py | 9 +-------- tests/test-qmp-commands.c | 2 +- tests/test-qmp-input-visitor.c | 8 ++++---- tests/test-qmp-output-visitor.c | 6 +++--- tpm.c | 2 +- ui/input-keymap.c | 10 +++++----- ui/input-legacy.c | 2 +- ui/input.c | 22 +++++++++++----------- util/qemu-sockets.c | 12 ++++++------ 28 files changed, 87 insertions(+), 97 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 56ad808..28aa74d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2736,7 +2736,7 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs) ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1); *spec_info = (ImageInfoSpecific){ - .kind = IMAGE_INFO_SPECIFIC_KIND_QCOW2, + .type = IMAGE_INFO_SPECIFIC_KIND_QCOW2, { .qcow2 = g_new(ImageInfoSpecificQCow2, 1), }, diff --git a/block/vmdk.c b/block/vmdk.c index be0d640..695780c 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2156,7 +2156,7 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs) ImageInfoList **next; *spec_info = (ImageInfoSpecific){ - .kind = IMAGE_INFO_SPECIFIC_KIND_VMDK, + .type = IMAGE_INFO_SPECIFIC_KIND_VMDK, { .vmdk = g_new0(ImageInfoSpecificVmdk, 1), }, diff --git a/blockdev.c b/blockdev.c index 32b04b4..bf8a7a2 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1052,12 +1052,12 @@ void hmp_commit(Monitor *mon, const QDict *qdict) } } -static void blockdev_do_action(int kind, void *data, Error **errp) +static void blockdev_do_action(int type, void *data, Error **errp) { TransactionAction action; TransactionActionList list; - action.kind = kind; + action.type = type; action.data = data; list.value = &action; list.next = NULL; @@ -1297,7 +1297,7 @@ static void internal_snapshot_prepare(BlkTransactionState *common, InternalSnapshotState *state; int ret1; - g_assert(common->action->kind == + g_assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_INTERNAL_SYNC); internal = common->action->blockdev_snapshot_internal_sync; state = DO_UPCAST(InternalSnapshotState, common, common); @@ -1439,7 +1439,7 @@ static void external_snapshot_prepare(BlkTransactionState *common, TransactionAction *action = common->action; /* get parameters */ - g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC); + g_assert(action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC); has_device = action->blockdev_snapshot_sync->has_device; device = action->blockdev_snapshot_sync->device; @@ -1579,7 +1579,7 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp) DriveBackup *backup; Error *local_err = NULL; - assert(common->action->kind == TRANSACTION_ACTION_KIND_DRIVE_BACKUP); + assert(common->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP); backup = common->action->drive_backup; blk = blk_by_name(backup->device); @@ -1647,7 +1647,7 @@ static void blockdev_backup_prepare(BlkTransactionState *common, Error **errp) BlockBackend *blk; Error *local_err = NULL; - assert(common->action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); + assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); backup = common->action->blockdev_backup; blk = blk_by_name(backup->device); @@ -1774,9 +1774,9 @@ void qmp_transaction(TransactionActionList *dev_list, Error **errp) dev_info = dev_entry->value; dev_entry = dev_entry->next; - assert(dev_info->kind < ARRAY_SIZE(actions)); + assert(dev_info->type < ARRAY_SIZE(actions)); - ops = &actions[dev_info->kind]; + ops = &actions[dev_info->type]; assert(ops->instance_size > 0); state = g_malloc0(ops->instance_size); diff --git a/hmp.c b/hmp.c index 3f807b7..849b292 100644 --- a/hmp.c +++ b/hmp.c @@ -830,9 +830,9 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) c, TpmModel_lookup[ti->model]); monitor_printf(mon, " \\ %s: type=%s", - ti->id, TpmTypeOptionsKind_lookup[ti->options->kind]); + ti->id, TpmTypeOptionsKind_lookup[ti->options->type]); - switch (ti->options->kind) { + switch (ti->options->type) { case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH: tpo = ti->options->passthrough; monitor_printf(mon, "%s%s%s%s", @@ -1714,14 +1714,14 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) if (*endp != '\0') { goto err_out; } - keylist->value->kind = KEY_VALUE_KIND_NUMBER; + keylist->value->type = KEY_VALUE_KIND_NUMBER; keylist->value->number = value; } else { int idx = index_from_key(keyname_buf); if (idx == Q_KEY_CODE_MAX) { goto err_out; } - keylist->value->kind = KEY_VALUE_KIND_QCODE; + keylist->value->type = KEY_VALUE_KIND_QCODE; keylist->value->qcode = idx; } @@ -1937,12 +1937,12 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict) value = info->value; if (value) { - switch (value->kind) { + switch (value->type) { case MEMORY_DEVICE_INFO_KIND_DIMM: di = value->dimm; monitor_printf(mon, "Memory device [%s]: \"%s\"\n", - MemoryDeviceInfoKind_lookup[value->kind], + MemoryDeviceInfoKind_lookup[value->type], di->id ? di->id : ""); monitor_printf(mon, " addr: 0x%" PRIx64 "\n", di->addr); monitor_printf(mon, " slot: %" PRId64 "\n", di->slot); diff --git a/hw/input/hid.c b/hw/input/hid.c index 21ebd9e..ac02f88 100644 --- a/hw/input/hid.c +++ b/hw/input/hid.c @@ -119,7 +119,7 @@ static void hid_pointer_event(DeviceState *dev, QemuConsole *src, assert(hs->n < QUEUE_LENGTH); e = &hs->ptr.queue[(hs->head + hs->n) & QUEUE_MASK]; - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_REL: if (evt->rel->axis == INPUT_AXIS_X) { e->xdx += evt->rel->value; diff --git a/hw/input/ps2.c b/hw/input/ps2.c index fdbe565..58decf2 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -393,7 +393,7 @@ static void ps2_mouse_event(DeviceState *dev, QemuConsole *src, if (!(s->mouse_status & MOUSE_STATUS_ENABLED)) return; - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_REL: if (evt->rel->axis == INPUT_AXIS_X) { s->mouse_dx += evt->rel->value; diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index 4d85dad..362dad3 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -191,7 +191,7 @@ static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src, virtio_input_event event; int qcode; - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_KEY: qcode = qemu_input_key_value_to_qcode(evt->key->key); if (qcode && keymap_qcode[qcode]) { diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index bb04862..a444195 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -196,7 +196,7 @@ ram_addr_t get_current_ram_size(void) MemoryDeviceInfo *value = info->value; if (value) { - switch (value->kind) { + switch (value->type) { case MEMORY_DEVICE_INFO_KIND_DIMM: size += value->dimm->size; break; diff --git a/net/dump.c b/net/dump.c index d80fa94..a1f99c3 100644 --- a/net/dump.c +++ b/net/dump.c @@ -154,7 +154,7 @@ int net_init_dump(const Netdev *netdev, const char *name, char def_file[128]; const NetdevDumpOptions *dump; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_DUMP); dump = netdev->opts->dump; assert(peer); diff --git a/net/hub.c b/net/hub.c index 29f65b2..047d861 100644 --- a/net/hub.c +++ b/net/hub.c @@ -285,7 +285,7 @@ int net_init_hubport(const Netdev *netdev, const char *name, { const NetdevHubPortOptions *hubport; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_HUBPORT); assert(!peer); hubport = netdev->opts->hubport; diff --git a/net/l2tpv3.c b/net/l2tpv3.c index d2f8431..bdb13fa 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -545,7 +545,7 @@ int net_init_l2tpv3(const Netdev *netdev, s->queue_tail = 0; s->header_mismatch = false; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_L2TPV3); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_L2TPV3); l2tpv3 = netdev->opts->l2tpv3; if (l2tpv3->has_ipv6 && l2tpv3->ipv6) { diff --git a/net/net.c b/net/net.c index 4d99b48..94a3d18 100644 --- a/net/net.c +++ b/net/net.c @@ -820,7 +820,7 @@ static int net_init_nic(const Netdev *netdev, const char *name, NICInfo *nd; const NetLegacyNicOptions *nic; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_NIC); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_NIC); nic = netdev->opts->nic; idx = nic_get_free_idx(); @@ -924,9 +924,9 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) opts = netdev->opts; name = netdev->id; - if (opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP || - opts->kind == NET_CLIENT_OPTIONS_KIND_NIC || - !net_client_init_fun[opts->kind]) { + if (opts->type == NET_CLIENT_OPTIONS_KIND_DUMP || + opts->type == NET_CLIENT_OPTIONS_KIND_NIC || + !net_client_init_fun[opts->type]) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a netdev backend type"); return -1; @@ -939,16 +939,16 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) /* missing optional values have been initialized to "all bits zero" */ name = net->has_id ? net->id : net->name; - if (opts->kind == NET_CLIENT_OPTIONS_KIND_NONE) { + if (opts->type == NET_CLIENT_OPTIONS_KIND_NONE) { return 0; /* nothing to do */ } - if (opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT) { + if (opts->type == NET_CLIENT_OPTIONS_KIND_HUBPORT) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a net type"); return -1; } - if (!net_client_init_fun[opts->kind]) { + if (!net_client_init_fun[opts->type]) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a net backend type (maybe it is not compiled " "into this binary)"); @@ -956,17 +956,17 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) } /* Do not add to a vlan if it's a nic with a netdev= parameter. */ - if (opts->kind != NET_CLIENT_OPTIONS_KIND_NIC || + if (opts->type != NET_CLIENT_OPTIONS_KIND_NIC || !opts->nic->has_netdev) { peer = net_hub_add_port(net->has_vlan ? net->vlan : 0, NULL); } } - if (net_client_init_fun[opts->kind](netdev, name, peer, errp) < 0) { + if (net_client_init_fun[opts->type](netdev, name, peer, errp) < 0) { /* FIXME drop when all init functions store an Error */ if (errp && !*errp) { error_setg(errp, QERR_DEVICE_INIT_FAILED, - NetClientOptionsKind_lookup[opts->kind]); + NetClientOptionsKind_lookup[opts->type]); } return -1; } diff --git a/net/slirp.c b/net/slirp.c index 0fc2c52..e160b9c 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -746,7 +746,7 @@ int net_init_slirp(const Netdev *netdev, const char *name, const NetdevUserOptions *user; const char **dnssearch; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_USER); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_USER); user = netdev->opts->user; vnet = user->has_net ? g_strdup(user->net) : diff --git a/net/socket.c b/net/socket.c index 75f693c..7f949e2 100644 --- a/net/socket.c +++ b/net/socket.c @@ -706,7 +706,7 @@ int net_init_socket(const Netdev *netdev, const char *name, Error *err = NULL; const NetdevSocketOptions *sock; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_SOCKET); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_SOCKET); sock = netdev->opts->socket; if (sock->has_fd + sock->has_listen + sock->has_connect + sock->has_mcast + diff --git a/net/tap.c b/net/tap.c index 263f807..aecc759 100644 --- a/net/tap.c +++ b/net/tap.c @@ -565,7 +565,7 @@ int net_init_bridge(const Netdev *netdev, const char *name, TAPState *s; int fd, vnet_hdr; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_BRIDGE); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_BRIDGE); bridge = netdev->opts->bridge; helper = bridge->has_helper ? bridge->helper : DEFAULT_BRIDGE_HELPER; @@ -728,7 +728,7 @@ int net_init_tap(const Netdev *netdev, const char *name, const char *vhostfdname; char ifname[128]; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_TAP); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_TAP); tap = netdev->opts->tap; queues = tap->has_queues ? tap->queues : 1; vhostfdname = tap->has_vhostfd ? tap->vhostfd : NULL; diff --git a/net/vhost-user.c b/net/vhost-user.c index 20981a9..8597ec4 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -229,7 +229,7 @@ int net_init_vhost_user(const Netdev *netdev, const char *name, const NetdevVhostUserOptions *vhost_user_opts; CharDriverState *chr; - assert(netdev->opts->kind == NET_CLIENT_OPTIONS_KIND_VHOST_USER); + assert(netdev->opts->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER); vhost_user_opts = netdev->opts->vhost_user; chr = net_vhost_parse_chardev(vhost_user_opts, errp); diff --git a/numa.c b/numa.c index e9b18f5..16a8c41 100644 --- a/numa.c +++ b/numa.c @@ -226,7 +226,7 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error **errp) goto error; } - switch (object->kind) { + switch (object->type) { case NUMA_OPTIONS_KIND_NODE: numa_node_parse(object->node, opts, &err); if (err) { @@ -487,7 +487,7 @@ static void numa_stat_memory_devices(uint64_t node_mem[]) MemoryDeviceInfo *value = info->value; if (value) { - switch (value->kind) { + switch (value->type) { case MEMORY_DEVICE_INFO_KIND_DIMM: node_mem[value->dimm->node] += value->dimm->size; break; diff --git a/qemu-char.c b/qemu-char.c index 653ea10..a0379f2 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -122,7 +122,7 @@ static int SocketAddress_to_str(char *dest, int max_len, const char *prefix, SocketAddress *addr, bool is_listen, bool is_telnet) { - switch (addr->kind) { + switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: return snprintf(dest, max_len, "%s%s:%s:%s%s", prefix, is_telnet ? "telnet" : "tcp", addr->inet->host, @@ -3567,11 +3567,11 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend, addr = g_new0(SocketAddress, 1); if (path) { - addr->kind = SOCKET_ADDRESS_KIND_UNIX; + addr->type = SOCKET_ADDRESS_KIND_UNIX; addr->q_unix = g_new0(UnixSocketAddress, 1); addr->q_unix->path = g_strdup(path); } else { - addr->kind = SOCKET_ADDRESS_KIND_INET; + addr->type = SOCKET_ADDRESS_KIND_INET; addr->inet = g_new0(InetSocketAddress, 1); addr->inet->host = g_strdup(host); addr->inet->port = g_strdup(port); @@ -3616,7 +3616,7 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend, backend->udp = g_new0(ChardevUdp, 1); addr = g_new0(SocketAddress, 1); - addr->kind = SOCKET_ADDRESS_KIND_INET; + addr->type = SOCKET_ADDRESS_KIND_INET; addr->inet = g_new0(InetSocketAddress, 1); addr->inet->host = g_strdup(host); addr->inet->port = g_strdup(port); @@ -3629,7 +3629,7 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend, if (has_local) { backend->udp->has_local = true; addr = g_new0(SocketAddress, 1); - addr->kind = SOCKET_ADDRESS_KIND_INET; + addr->type = SOCKET_ADDRESS_KIND_INET; addr->inet = g_new0(InetSocketAddress, 1); addr->inet->host = g_strdup(localaddr); addr->inet->port = g_strdup(localport); @@ -3701,7 +3701,7 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, } chr = NULL; - backend->kind = cd->kind; + backend->type = cd->kind; if (cd->parse) { cd->parse(opts, backend, &local_err); if (local_err) { @@ -3719,7 +3719,7 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, qapi_free_ChardevReturn(ret); backend = g_new0(ChardevBackend, 1); backend->mux = g_new0(ChardevMux, 1); - backend->kind = CHARDEV_BACKEND_KIND_MUX; + backend->type = CHARDEV_BACKEND_KIND_MUX; backend->mux->chardev = g_strdup(bid); ret = qmp_chardev_add(id, backend, errp); if (!ret) { @@ -4148,7 +4148,7 @@ static CharDriverState *qmp_chardev_open_socket(ChardevSocket *sock, s->fd = -1; s->listen_fd = -1; - s->is_unix = addr->kind == SOCKET_ADDRESS_KIND_UNIX; + s->is_unix = addr->type == SOCKET_ADDRESS_KIND_UNIX; s->is_listen = is_listen; s->is_telnet = is_telnet; s->do_nodelay = do_nodelay; @@ -4222,7 +4222,7 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, return NULL; } - switch (backend->kind) { + switch (backend->type) { case CHARDEV_BACKEND_KIND_FILE: chr = qmp_chardev_open_file(backend->file, errp); break; @@ -4293,7 +4293,7 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, chr = qemu_chr_open_ringbuf(backend->ringbuf, errp); break; default: - error_setg(errp, "unknown chardev backend (%d)", backend->kind); + error_setg(errp, "unknown chardev backend (%d)", backend->type); break; } @@ -4309,9 +4309,9 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, if (chr) { chr->label = g_strdup(id); chr->avail_connections = - (backend->kind == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1; + (backend->type == CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX : 1; if (!chr->filename) { - chr->filename = g_strdup(ChardevBackendKind_lookup[backend->kind]); + chr->filename = g_strdup(ChardevBackendKind_lookup[backend->type]); } if (!chr->explicit_be_open) { qemu_chr_be_event(chr, CHR_EVENT_OPENED); diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index fe998a1..7eb7f35 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -110,13 +110,10 @@ struct %(c_name)s { tag_name = 'type' else: ret += mcgen(''' - %(c_type)s kind; + %(c_type)s type; ''', c_type=c_name(variants.tag_member.type.name)) - # TODO ugly special case for simple union - # Use same tag name in C as on the wire to get rid of - # it, then: tag_name = variants.tag_member.name - tag_name = 'kind' + tag_name = variants.tag_member.name # FIXME: What purpose does data serve, besides preventing a union that # has a branch named 'data'? We use it in qapi-visit.py to decide diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 898a32b..2b3b6a3 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -277,9 +277,6 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error c_name=c_name(name)) tag_key = variants.tag_member.name - if not variants.tag_name: - # we pointlessly use a different key for simple unions - tag_key = 'type' ret += mcgen(''' visit_type_%(c_type)s(v, &(*obj)->%(c_name)s, "%(name)s", &err); if (err) { @@ -288,11 +285,7 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error switch ((*obj)->%(c_name)s) { ''', c_type=variants.tag_member.type.c_name(), - # TODO ugly special case for simple union - # Use same tag name in C as on the wire to get rid of - # it, then: c_name=c_name(variants.tag_member.name) - c_name=c_name(variants.tag_name or 'kind'), - name=tag_key) + c_name=c_name(tag_key), name=tag_key) for var in variants.variants: # TODO ugly special case for simple union diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index 681ec65..d3b8d8f 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -64,7 +64,7 @@ __org_qemu_x_Union1 *qmp___org_qemu_x_command(__org_qemu_x_EnumList *a, { __org_qemu_x_Union1 *ret = g_new0(__org_qemu_x_Union1, 1); - ret->kind = ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; + ret->type = ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH; ret->__org_qemu_x_branch = strdup("blah1"); return ret; diff --git a/tests/test-qmp-input-visitor.c b/tests/test-qmp-input-visitor.c index bc9ed04..8928f86 100644 --- a/tests/test-qmp-input-visitor.c +++ b/tests/test-qmp-input-visitor.c @@ -549,7 +549,7 @@ static void test_native_list_integer_helper(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &err); g_assert(err == NULL); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->kind, ==, kind); + g_assert_cmpint(cvalue->type, ==, kind); switch (kind) { case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: { @@ -713,7 +713,7 @@ static void test_visitor_in_native_list_bool(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &err); g_assert(err == NULL); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->kind, ==, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN); + g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_BOOLEAN); for (i = 0, elem = cvalue->boolean; elem; elem = elem->next, i++) { g_assert_cmpint(elem->value, ==, (i % 3 == 0) ? 1 : 0); @@ -749,7 +749,7 @@ static void test_visitor_in_native_list_string(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &err); g_assert(err == NULL); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->kind, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING); + g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_STRING); for (i = 0, elem = cvalue->string; elem; elem = elem->next, i++) { gchar str[8]; @@ -789,7 +789,7 @@ static void test_visitor_in_native_list_number(TestInputVisitorData *data, visit_type_UserDefNativeListUnion(v, &cvalue, NULL, &err); g_assert(err == NULL); g_assert(cvalue != NULL); - g_assert_cmpint(cvalue->kind, ==, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER); + g_assert_cmpint(cvalue->type, ==, USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER); for (i = 0, elem = cvalue->number; elem; elem = elem->next, i++) { GString *double_expected = g_string_new(""); diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c index 0f72b5d..6d6f79c 100644 --- a/tests/test-qmp-output-visitor.c +++ b/tests/test-qmp-output-visitor.c @@ -556,7 +556,7 @@ static void test_visitor_out_empty(TestOutputVisitorData *data, static void init_native_list(UserDefNativeListUnion *cvalue) { int i; - switch (cvalue->kind) { + switch (cvalue->type) { case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: { intList **list = &cvalue->integer; for (i = 0; i < 32; i++) { @@ -777,14 +777,14 @@ static void test_native_list(TestOutputVisitorData *data, Error *err = NULL; QObject *obj; - cvalue->kind = kind; + cvalue->type = kind; init_native_list(cvalue); visit_type_UserDefNativeListUnion(data->ov, &cvalue, NULL, &err); g_assert(err == NULL); obj = qmp_output_get_qobject(data->qov); - check_native_list(obj, cvalue->kind); + check_native_list(obj, cvalue->type); qapi_free_UserDefNativeListUnion(cvalue); qobject_decref(obj); } diff --git a/tpm.c b/tpm.c index 4e9b109..fcab81c 100644 --- a/tpm.c +++ b/tpm.c @@ -260,7 +260,7 @@ static TPMInfo *qmp_query_tpm_inst(TPMBackend *drv) switch (drv->ops->type) { case TPM_TYPE_PASSTHROUGH: - res->options->kind = TPM_TYPE_OPTIONS_KIND_PASSTHROUGH; + res->options->type = TPM_TYPE_OPTIONS_KIND_PASSTHROUGH; tpo = g_new0(TPMPassthroughOptions, 1); res->options->passthrough = tpo; if (drv->path) { diff --git a/ui/input-keymap.c b/ui/input-keymap.c index 7635cb0..088523d 100644 --- a/ui/input-keymap.c +++ b/ui/input-keymap.c @@ -139,10 +139,10 @@ static int number_to_qcode[0x100]; int qemu_input_key_value_to_number(const KeyValue *value) { - if (value->kind == KEY_VALUE_KIND_QCODE) { + if (value->type == KEY_VALUE_KIND_QCODE) { return qcode_to_number[value->qcode]; } else { - assert(value->kind == KEY_VALUE_KIND_NUMBER); + assert(value->type == KEY_VALUE_KIND_NUMBER); return value->number; } } @@ -166,10 +166,10 @@ int qemu_input_key_number_to_qcode(uint8_t nr) int qemu_input_key_value_to_qcode(const KeyValue *value) { - if (value->kind == KEY_VALUE_KIND_QCODE) { + if (value->type == KEY_VALUE_KIND_QCODE) { return value->qcode; } else { - assert(value->kind == KEY_VALUE_KIND_NUMBER); + assert(value->type == KEY_VALUE_KIND_NUMBER); return qemu_input_key_number_to_qcode(value->number); } } @@ -180,7 +180,7 @@ int qemu_input_key_value_to_scancode(const KeyValue *value, bool down, int keycode = qemu_input_key_value_to_number(value); int count = 0; - if (value->kind == KEY_VALUE_KIND_QCODE && + if (value->type == KEY_VALUE_KIND_QCODE && value->qcode == Q_KEY_CODE_PAUSE) { /* specific case */ int v = down ? 0 : 0x80; diff --git a/ui/input-legacy.c b/ui/input-legacy.c index e50f296..6149648 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -150,7 +150,7 @@ static void legacy_mouse_event(DeviceState *dev, QemuConsole *src, }; QEMUPutMouseEntry *s = (QEMUPutMouseEntry *)dev; - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_BTN: if (evt->btn->down) { s->buttons |= bmap[evt->btn->button]; diff --git a/ui/input.c b/ui/input.c index 1a552d1..fd86571 100644 --- a/ui/input.c +++ b/ui/input.c @@ -147,10 +147,10 @@ void qmp_x_input_send_event(bool has_console, int64_t console, for (e = events; e != NULL; e = e->next) { InputEvent *event = e->value; - if (!qemu_input_find_handler(1 << event->kind, con)) { + if (!qemu_input_find_handler(1 << event->type, con)) { error_setg(errp, "Input handler not found for " "event type %s", - InputEventKind_lookup[event->kind]); + InputEventKind_lookup[event->type]); return; } } @@ -197,9 +197,9 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt) if (src) { idx = qemu_console_get_index(src); } - switch (evt->kind) { + switch (evt->type) { case INPUT_EVENT_KIND_KEY: - switch (evt->key->key->kind) { + switch (evt->key->key->type) { case KEY_VALUE_KIND_NUMBER: qcode = qemu_input_key_number_to_qcode(evt->key->key->number); name = QKeyCode_lookup[qcode]; @@ -311,12 +311,12 @@ void qemu_input_event_send(QemuConsole *src, InputEvent *evt) qemu_input_event_trace(src, evt); /* pre processing */ - if (graphic_rotate && (evt->kind == INPUT_EVENT_KIND_ABS)) { + if (graphic_rotate && (evt->type == INPUT_EVENT_KIND_ABS)) { qemu_input_transform_abs_rotate(evt); } /* send event */ - s = qemu_input_find_handler(1 << evt->kind, src); + s = qemu_input_find_handler(1 << evt->type, src); if (!s) { return; } @@ -349,7 +349,7 @@ InputEvent *qemu_input_event_new_key(KeyValue *key, bool down) { InputEvent *evt = g_new0(InputEvent, 1); evt->key = g_new0(InputKeyEvent, 1); - evt->kind = INPUT_EVENT_KIND_KEY; + evt->type = INPUT_EVENT_KIND_KEY; evt->key->key = key; evt->key->down = down; return evt; @@ -372,7 +372,7 @@ void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down) void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down) { KeyValue *key = g_new0(KeyValue, 1); - key->kind = KEY_VALUE_KIND_NUMBER; + key->type = KEY_VALUE_KIND_NUMBER; key->number = num; qemu_input_event_send_key(src, key, down); } @@ -380,7 +380,7 @@ void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down) void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down) { KeyValue *key = g_new0(KeyValue, 1); - key->kind = KEY_VALUE_KIND_QCODE; + key->type = KEY_VALUE_KIND_QCODE; key->qcode = q; qemu_input_event_send_key(src, key, down); } @@ -399,7 +399,7 @@ InputEvent *qemu_input_event_new_btn(InputButton btn, bool down) { InputEvent *evt = g_new0(InputEvent, 1); evt->btn = g_new0(InputBtnEvent, 1); - evt->kind = INPUT_EVENT_KIND_BTN; + evt->type = INPUT_EVENT_KIND_BTN; evt->btn->button = btn; evt->btn->down = down; return evt; @@ -451,7 +451,7 @@ InputEvent *qemu_input_event_new_move(InputEventKind kind, InputEvent *evt = g_new0(InputEvent, 1); InputMoveEvent *move = g_new0(InputMoveEvent, 1); - evt->kind = kind; + evt->type = kind; evt->data = move; move->axis = axis; move->value = value; diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 2add83a..277b139 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -904,7 +904,7 @@ SocketAddress *socket_parse(const char *str, Error **errp) error_setg(errp, "invalid Unix socket address"); goto fail; } else { - addr->kind = SOCKET_ADDRESS_KIND_UNIX; + addr->type = SOCKET_ADDRESS_KIND_UNIX; addr->q_unix = g_new(UnixSocketAddress, 1); addr->q_unix->path = g_strdup(str + 5); } @@ -913,12 +913,12 @@ SocketAddress *socket_parse(const char *str, Error **errp) error_setg(errp, "invalid file descriptor address"); goto fail; } else { - addr->kind = SOCKET_ADDRESS_KIND_FD; + addr->type = SOCKET_ADDRESS_KIND_FD; addr->fd = g_new(String, 1); addr->fd->str = g_strdup(str + 3); } } else { - addr->kind = SOCKET_ADDRESS_KIND_INET; + addr->type = SOCKET_ADDRESS_KIND_INET; addr->inet = inet_parse(str, errp); if (addr->inet == NULL) { goto fail; @@ -938,7 +938,7 @@ int socket_connect(SocketAddress *addr, Error **errp, int fd; opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); - switch (addr->kind) { + switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: inet_addr_to_opts(opts, addr->inet); fd = inet_connect_opts(opts, errp, callback, opaque); @@ -970,7 +970,7 @@ int socket_listen(SocketAddress *addr, Error **errp) int fd; opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); - switch (addr->kind) { + switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: inet_addr_to_opts(opts, addr->inet); fd = inet_listen_opts(opts, 0, errp); @@ -998,7 +998,7 @@ int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp) int fd; opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); - switch (remote->kind) { + switch (remote->type) { case SOCKET_ADDRESS_KIND_INET: inet_addr_to_opts(opts, remote->inet); if (local) { -- 2.4.3 From MAILER-DAEMON Tue Sep 22 02:14:11 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeGqB-0003OO-0W for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 02:14:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49526) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeGq7-0003N3-T6 for qemu-block@nongnu.org; Tue, 22 Sep 2015 02:14:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeGq4-0000xQ-NG for qemu-block@nongnu.org; Tue, 22 Sep 2015 02:14:07 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:60789 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeGq4-0000vA-CV for qemu-block@nongnu.org; Tue, 22 Sep 2015 02:14:04 -0400 Received: (qmail 5073 invoked by uid 89); 22 Sep 2015 06:14:02 -0000 Received: from [195.62.97.28] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.7/20930. hbedv: 8.3.34.32/7.12.12.52. spamassassin: 3.4.0. Clear:RC:1(195.62.97.28):SA:0(-2.0/5.0):. Processed in 2.426837 secs); 22 Sep 2015 06:14:02 -0000 Received: from smtp.kamp.de (HELO submission.kamp.de) ([195.62.97.28]) by mx01.kamp.de with ESMTPS (DHE-RSA-AES256-SHA encrypted); 22 Sep 2015 06:13:59 -0000 X-GL_Whitelist: yes Received: (qmail 29030 invoked from network); 22 Sep 2015 06:01:40 -0000 Received: from lieven-pc.kamp-intra.net (HELO ?172.21.12.60?) (pl@kamp.de@172.21.12.60) by submission.kamp.de with ESMTPS (DHE-RSA-AES128-SHA encrypted) ESMTPA; 22 Sep 2015 06:01:40 -0000 To: Stefan Hajnoczi References: <1435047135-31647-1-git-send-email-pl@kamp.de> <20150625131806.GG4419@stefanha-thinkpad.redhat.com> From: Peter Lieven Message-ID: <5600F1A6.2080900@kamp.de> Date: Tue, 22 Sep 2015 08:13:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150625131806.GG4419@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, ronniesahlberg@gmail.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH] block/nfs: add support for setting debug level X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 06:14:09 -0000 Am 25.06.2015 um 15:18 schrieb Stefan Hajnoczi: > On Tue, Jun 23, 2015 at 10:12:15AM +0200, Peter Lieven wrote: >> upcoming libnfs versions will support logging debug messages. Add >> support for it in qemu through an URL parameter. >> >> Signed-off-by: Peter Lieven >> --- >> block/nfs.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/block/nfs.c b/block/nfs.c >> index ca9e24e..f7388a3 100644 >> --- a/block/nfs.c >> +++ b/block/nfs.c >> @@ -329,6 +329,10 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename, >> } else if (!strcmp(qp->p[i].name, "readahead")) { >> nfs_set_readahead(client->context, val); >> #endif >> +#ifdef LIBNFS_FEATURE_DEBUG >> + } else if (!strcmp(qp->p[i].name, "debug")) { >> + nfs_set_debug(client->context, val); >> +#endif >> } else { >> error_setg(errp, "Unknown NFS parameter name: %s", >> qp->p[i].name); > Untrusted users may be able to set these options since they are encoded > in the URI. I'm imagining a hosting or cloud scenario like OpenStack. > > A verbose debug level spams stderr and could consume a lot of disk > space. > > (The uid and gid options are probably okay since the NFS server cannot > trust the uid/gid coming from QEMU anyway.) > > I think we can merge this patch for QEMU 2.4 but I'd like to have a > discussion about the security risk of encoding libnfs options in the > URI. > > CCed Eric Blake in case libvirt is affected. > > Has anyone thought about this and what are the rules? As I hadn't time to work further on the best way to add options for NFS (and other protocols), would it be feasible to allow passing debug as an URL parameter, but limit the maximum debug level to limit a possible security impact (flooding logs)? If a higher debug level is needed it can be set via device specific options as soon there is a common scheme for them. Peter From MAILER-DAEMON Tue Sep 22 03:45:20 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeIGO-0005yi-7F for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 03:45:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeIGH-0005ne-RK for qemu-block@nongnu.org; Tue, 22 Sep 2015 03:45:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeIGG-0003DJ-JY for qemu-block@nongnu.org; Tue, 22 Sep 2015 03:45:13 -0400 Received: from [59.151.112.132] (port=36638 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeIGC-0002wA-Ux; Tue, 22 Sep 2015 03:45:09 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100968690" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 22 Sep 2015 15:47:45 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8M7iffB011260; Tue, 22 Sep 2015 15:44:41 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 22 Sep 2015 15:44:59 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Tue, 22 Sep 2015 15:44:21 +0800 Message-ID: <1442907862-21376-4-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> References: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v5 3/4] qmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 07:45:16 -0000 The new QMP command name is x-blockdev-child-add, and x-blockdev-child-del. It justs for adding/removing quorum's child now, and don't support all kinds of children, nor all block drivers. So it is experimental now. Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- blockdev.c | 48 +++++++++++++++++++++++++++++++++++++++++ qapi/block-core.json | 34 +++++++++++++++++++++++++++++ qmp-commands.hx | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) diff --git a/blockdev.c b/blockdev.c index 32b04b4..8da0ffb 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3086,6 +3086,54 @@ fail: qmp_output_visitor_cleanup(ov); } +void qmp_x_blockdev_child_add(const char *parent, const char *child, + Error **errp) +{ + BlockDriverState *parent_bs, *child_bs; + Error *local_err = NULL; + + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); + if (!parent_bs) { + error_propagate(errp, local_err); + return; + } + + child_bs = bdrv_find_node(child); + if (!child_bs) { + error_setg(errp, "Node '%s' not found", child); + return; + } + + bdrv_add_child(parent_bs, child_bs, &local_err); + if (local_err) { + error_propagate(errp, local_err); + } +} + +void qmp_x_blockdev_child_del(const char *parent, const char *child, + Error **errp) +{ + BlockDriverState *parent_bs, *child_bs; + Error *local_err = NULL; + + parent_bs = bdrv_lookup_bs(parent, parent, &local_err); + if (!parent_bs) { + error_propagate(errp, local_err); + return; + } + + child_bs = bdrv_find_node(child); + if (!child_bs) { + error_setg(errp, "Node '%s' not found", child); + return; + } + + bdrv_del_child(parent_bs, child_bs, &local_err); + if (local_err) { + error_propagate(errp, local_err); + } +} + BlockJobInfoList *qmp_query_block_jobs(Error **errp) { BlockJobInfoList *head = NULL, **p_next = &head; diff --git a/qapi/block-core.json b/qapi/block-core.json index bb2189e..9418f05 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2114,3 +2114,37 @@ ## { 'command': 'block-set-write-threshold', 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } + +## +# @x-blockdev-child-add +# +# Add a new child to the parent BDS. Currently only the Quorum driver +# implements this feature. This is useful to fix a broken quorum child. +# +# @parent: graph node name or id which the child will be added to. +# +# @child: graph node name that will be added. +# +# Note: this command is experimental, and not a stable API. +# +# Since: 2.5 +## +{ 'command': 'x-blockdev-child-add', + 'data' : { 'parent': 'str', 'child': 'str' } } + +## +# @x-blockdev-child-del +# +# Remove a child from the parent BDS. Currently only the Quorum driver +# implements this feature. This is useful to fix a broken quorum child. +# Note, you can't remove a child if it would bring the quorum below its +# threshold. +# +# @parent: graph node name or id from which the child will removed. +# +# @child: graph node name that will be removed. +# +# Since: 2.5 +## +{ 'command': 'x-blockdev-child-del', + 'data' : { 'parent': 'str', 'child': 'str' } } diff --git a/qmp-commands.hx b/qmp-commands.hx index 66f0300..36e75b1 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3916,6 +3916,67 @@ Example (2): EQMP { + .name = "x-blockdev-child-add", + .args_type = "parent:B,child:B", + .mhandler.cmd_new = qmp_marshal_x_blockdev_child_add, + }, + +SQMP +x-blockdev-child-add +------------ + +Add a child to a quorum node. + +Arguments: + +- "parent": the quorum's id or node name +- "child": the child node-name which will be added + +Note: this command is experimental, and not a stable API. It doesn't +support all kinds of children, nor all block drivers. + +Example: + +-> { "execute": blockdev-add", + "arguments": { "options": { "driver": "raw", + "node-name": "new_node", + "id": "test_new_node", + "file": { "driver": "file", + "filename": "test.raw" } } } } +<- { "return": {} } +-> { "execute": "x-blockdev-child-add", + "arguments": { "parent": "disk1", "child": "new_node" } } +<- { "return": {} } + +EQMP + + { + .name = "x-blockdev-child-del", + .args_type = "parent:B,child:B", + .mhandler.cmd_new = qmp_marshal_x_blockdev_child_del, + }, + +SQMP +x-blockdev-child-del +------------ + +Delete a child from a quorum node. It can be used to remove a broken +quorum child. + +Arguments: + +- "parent": the quorum's id or node name +- "child": the child node-name which will be removed + +Example: + +-> { "execute": "x-blockdev-child-del", + "arguments": { "parent": "disk1", "child": "new_node" } } +<- { "return": {} } + +EQMP + + { .name = "query-named-block-nodes", .args_type = "", .mhandler.cmd_new = qmp_marshal_query_named_block_nodes, -- 2.4.3 From MAILER-DAEMON Tue Sep 22 03:45:21 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeIGP-00060W-CY for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 03:45:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeIGL-0005sH-1L for qemu-block@nongnu.org; Tue, 22 Sep 2015 03:45:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeIGH-0003Df-Hz for qemu-block@nongnu.org; Tue, 22 Sep 2015 03:45:16 -0400 Received: from [59.151.112.132] (port=11289 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeIGE-0002vu-PD; Tue, 22 Sep 2015 03:45:11 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100968687" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 22 Sep 2015 15:47:41 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8M7ibw7011249; Tue, 22 Sep 2015 15:44:37 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 22 Sep 2015 15:44:55 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Tue, 22 Sep 2015 15:44:18 +0800 Message-ID: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Yang Hongyang Subject: [Qemu-block] [PATCH v5 0/4] qapi: child add/delete support X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 07:45:18 -0000 If quorum's child is broken, we can use mirror job to replace it. But sometimes, the user only need to remove the broken child, and add it later when the problem is fixed. It is based on the following patch: http://lists.nongnu.org/archive/html/qemu-devel/2015-09/msg04579.html ChangLog: v5: 1. Address Eric Blake's comments v4: 1. drop nbd driver's implementation. We can use human-monitor-command to do it. 2. Rename the command name. v3: 1. Don't open BDS in bdrv_add_child(). Use the existing BDS which is created by the QMP command blockdev-add. 2. The driver NBD can support filename, path, host:port now. v2: 1. Use bdrv_get_device_or_node_name() instead of new function bdrv_get_id_or_node_name() 2. Update the error message 3. Update the documents in block-core.json Wen Congyang (4): Add new block driver interface to add/delete a BDS's child quorum: implement bdrv_add_child() and bdrv_del_child() qmp: add monitor command to add/remove a child hmp: add monitor command to add/remove a child block.c | 56 ++++++++++++++++++++++++++++++++++-- block/quorum.c | 72 +++++++++++++++++++++++++++++++++++++++++++++-- blockdev.c | 48 +++++++++++++++++++++++++++++++ hmp-commands.hx | 28 ++++++++++++++++++ hmp.c | 20 +++++++++++++ hmp.h | 2 ++ include/block/block.h | 8 ++++++ include/block/block_int.h | 5 ++++ qapi/block-core.json | 34 ++++++++++++++++++++++ qmp-commands.hx | 61 +++++++++++++++++++++++++++++++++++++++ 10 files changed, 329 insertions(+), 5 deletions(-) -- 2.4.3 From MAILER-DAEMON Tue Sep 22 03:45:22 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeIGQ-000637-Ix for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 03:45:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeIGL-0005uO-UE for qemu-block@nongnu.org; Tue, 22 Sep 2015 03:45:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeIGK-0003ET-Sk for qemu-block@nongnu.org; Tue, 22 Sep 2015 03:45:17 -0400 Received: from [59.151.112.132] (port=39366 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeIGD-0002w0-LT; Tue, 22 Sep 2015 03:45:10 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100968688" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 22 Sep 2015 15:47:43 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8M7idLQ011254; Tue, 22 Sep 2015 15:44:39 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 22 Sep 2015 15:44:56 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Tue, 22 Sep 2015 15:44:19 +0800 Message-ID: <1442907862-21376-2-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> References: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v5 1/4] Add new block driver interface to add/delete a BDS's child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 07:45:19 -0000 In some cases, we want to take a quorum child offline, and take another child online. Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Reviewed-by: Eric Blake --- block.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ include/block/block.h | 5 +++++ include/block/block_int.h | 5 +++++ 3 files changed, 60 insertions(+) diff --git a/block.c b/block.c index e815d73..1b25e43 100644 --- a/block.c +++ b/block.c @@ -4265,3 +4265,53 @@ BlockAcctStats *bdrv_get_stats(BlockDriverState *bs) { return &bs->stats; } + +/* + * Hot add/remove a BDS's child. So the user can take a child offline when + * it is broken and take a new child online + */ +void bdrv_add_child(BlockDriverState *parent_bs, BlockDriverState *child_bs, + Error **errp) +{ + + if (!parent_bs->drv || !parent_bs->drv->bdrv_add_child) { + error_setg(errp, "The BDS %s doesn't support adding a child", + bdrv_get_device_or_node_name(parent_bs)); + return; + } + + if (!QLIST_EMPTY(&child_bs->parents)) { + error_setg(errp, "The BDS %s already has parent", + child_bs->node_name); + return; + } + + parent_bs->drv->bdrv_add_child(parent_bs, child_bs, errp); +} + +void bdrv_del_child(BlockDriverState *parent_bs, BlockDriverState *child_bs, + Error **errp) +{ + BdrvChild *child; + + if (!parent_bs->drv || !parent_bs->drv->bdrv_del_child) { + error_setg(errp, "The BDS %s doesn't support removing a child", + bdrv_get_device_or_node_name(parent_bs)); + return; + } + + QLIST_FOREACH(child, &parent_bs->children, next) { + if (child->bs == child_bs) { + break; + } + } + + if (!child) { + error_setg(errp, "BDS %s is not a child of %s", + bdrv_get_device_or_node_name(child_bs), + bdrv_get_device_or_node_name(parent_bs)); + return; + } + + parent_bs->drv->bdrv_del_child(parent_bs, child_bs, errp); +} diff --git a/include/block/block.h b/include/block/block.h index ef67353..665c56f 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -616,4 +616,9 @@ void bdrv_flush_io_queue(BlockDriverState *bs); BlockAcctStats *bdrv_get_stats(BlockDriverState *bs); +void bdrv_add_child(BlockDriverState *parent, BlockDriverState *child, + Error **errp); +void bdrv_del_child(BlockDriverState *parent, BlockDriverState *child, + Error **errp); + #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index 2f2c47b..64cbc55 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -288,6 +288,11 @@ struct BlockDriver { */ int (*bdrv_probe_geometry)(BlockDriverState *bs, HDGeometry *geo); + void (*bdrv_add_child)(BlockDriverState *parent, BlockDriverState *child, + Error **errp); + void (*bdrv_del_child)(BlockDriverState *parent, BlockDriverState *child, + Error **errp); + QLIST_ENTRY(BlockDriver) list; }; -- 2.4.3 From MAILER-DAEMON Tue Sep 22 03:45:20 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeIGO-0005zE-CY for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 03:45:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeIGK-0005sD-SL for qemu-block@nongnu.org; Tue, 22 Sep 2015 03:45:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeIGH-0003Da-HF for qemu-block@nongnu.org; Tue, 22 Sep 2015 03:45:16 -0400 Received: from [59.151.112.132] (port=36638 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeIGE-0002wA-Uj; Tue, 22 Sep 2015 03:45:11 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100968691" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 22 Sep 2015 15:47:47 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8M7igKg011263; Tue, 22 Sep 2015 15:44:42 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 22 Sep 2015 15:45:00 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Tue, 22 Sep 2015 15:44:22 +0800 Message-ID: <1442907862-21376-5-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> References: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Luiz Capitulino , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v5 4/4] hmp: add monitor command to add/remove a child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 07:45:18 -0000 The new command is blockdev_child_add and blockdev_child_del. It does the same thing as the QMP command x-blockdev-child-add and x-blockdev-child-del. Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Cc: Luiz Capitulino --- hmp-commands.hx | 28 ++++++++++++++++++++++++++++ hmp.c | 20 ++++++++++++++++++++ hmp.h | 2 ++ 3 files changed, 50 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index a511004..57adb7d 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -193,6 +193,34 @@ actions (drive options rerror, werror). ETEXI { + .name = "blockdev_child_add", + .args_type = "id:B,child:B", + .params = "parent child", + .help = "add a child to a BDS", + .mhandler.cmd = hmp_blockdev_child_add, + }, + +STEXI +@item blockdev_child_add @var{parent} @var{child} +@findex blockdev_child_add +Add a child to the block device. +ETEXI + + { + .name = "blockdev_child_del", + .args_type = "id:B,child:B", + .params = "parent child", + .help = "remove a child from a BDS", + .mhandler.cmd = hmp_blockdev_child_del, + }, + +STEXI +@item blockdev_child_del @var{parent} @var{child} +@findex blockdev_child_del +Remove a child from the parent device. +ETEXI + + { .name = "change", .args_type = "device:B,target:F,arg:s?", .params = "device filename [format]", diff --git a/hmp.c b/hmp.c index 3f807b7..1dc1bed 100644 --- a/hmp.c +++ b/hmp.c @@ -2325,3 +2325,23 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict) qapi_free_RockerOfDpaGroupList(list); } + +void hmp_blockdev_child_add(Monitor *mon, const QDict *qdict) +{ + const char *id = qdict_get_str(qdict, "id"); + const char *child_id = qdict_get_str(qdict, "child"); + Error *local_err = NULL; + + qmp_x_blockdev_child_add(id, child_id, &local_err); + hmp_handle_error(mon, &local_err); +} + +void hmp_blockdev_child_del(Monitor *mon, const QDict *qdict) +{ + const char *id = qdict_get_str(qdict, "id"); + const char *child_id = qdict_get_str(qdict, "child"); + Error *local_err = NULL; + + qmp_x_blockdev_child_del(id, child_id, &local_err); + hmp_handle_error(mon, &local_err); +} diff --git a/hmp.h b/hmp.h index 81656c3..3033648 100644 --- a/hmp.h +++ b/hmp.h @@ -130,5 +130,7 @@ void hmp_rocker(Monitor *mon, const QDict *qdict); void hmp_rocker_ports(Monitor *mon, const QDict *qdict); void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict); void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict); +void hmp_blockdev_child_add(Monitor *mon, const QDict *qdict); +void hmp_blockdev_child_del(Monitor *mon, const QDict *qdict); #endif -- 2.4.3 From MAILER-DAEMON Tue Sep 22 03:45:21 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeIGO-0005zj-Rz for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 03:45:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeIGL-0005sF-1T for qemu-block@nongnu.org; Tue, 22 Sep 2015 03:45:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeIGI-0003Ds-4g for qemu-block@nongnu.org; Tue, 22 Sep 2015 03:45:16 -0400 Received: from [59.151.112.132] (port=36638 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeIGA-0002wA-Va; Tue, 22 Sep 2015 03:45:07 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100968689" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 22 Sep 2015 15:47:44 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8M7ieMR011257; Tue, 22 Sep 2015 15:44:40 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 22 Sep 2015 15:44:58 +0800 From: Wen Congyang To: qemu devel , Eric Blake , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Date: Tue, 22 Sep 2015 15:44:20 +0800 Message-ID: <1442907862-21376-3-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> References: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v5 2/4] quorum: implement bdrv_add_child() and bdrv_del_child() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 07:45:18 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block.c | 6 ++--- block/quorum.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++-- include/block/block.h | 3 +++ 3 files changed, 76 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 1b25e43..01f6d69 100644 --- a/block.c +++ b/block.c @@ -1079,9 +1079,9 @@ static int bdrv_fill_options(QDict **options, const char **pfilename, return 0; } -static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, - BlockDriverState *child_bs, - const BdrvChildRole *child_role) +BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, + BlockDriverState *child_bs, + const BdrvChildRole *child_role) { BdrvChild *child = g_new(BdrvChild, 1); *child = (BdrvChild) { diff --git a/block/quorum.c b/block/quorum.c index 8fe53b4..111a57b 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -66,6 +66,9 @@ typedef struct QuorumVotes { typedef struct BDRVQuorumState { BlockDriverState **bs; /* children BlockDriverStates */ int num_children; /* children count */ + int max_children; /* The maximum children count, we need to reallocate + * bs if num_children grows larger than maximum. + */ int threshold; /* if less than threshold children reads gave the * same result a quorum error occurs. */ @@ -874,9 +877,9 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, ret = -EINVAL; goto exit; } - if (s->num_children < 2) { + if (s->num_children < 1) { error_setg(&local_err, - "Number of provided children must be greater than 1"); + "Number of provided children must be 1 or more"); ret = -EINVAL; goto exit; } @@ -925,6 +928,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, /* allocate the children BlockDriverState array */ s->bs = g_new0(BlockDriverState *, s->num_children); opened = g_new0(bool, s->num_children); + s->max_children = s->num_children; for (i = 0; i < s->num_children; i++) { char indexstr[32]; @@ -995,6 +999,67 @@ static void quorum_attach_aio_context(BlockDriverState *bs, } } +static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs, + Error **errp) +{ + BDRVQuorumState *s = bs->opaque; + + bdrv_drain(bs); + + if (s->num_children == s->max_children) { + if (s->max_children >= INT_MAX) { + error_setg(errp, "Too many children"); + return; + } + + s->bs = g_renew(BlockDriverState *, s->bs, s->max_children + 1); + s->bs[s->num_children] = NULL; + s->max_children++; + } + + bdrv_ref(child_bs); + bdrv_attach_child(bs, child_bs, &child_format); + s->bs[s->num_children++] = child_bs; +} + +static void quorum_del_child(BlockDriverState *bs, BlockDriverState *child_bs, + Error **errp) +{ + BDRVQuorumState *s = bs->opaque; + BdrvChild *child; + int i; + + for (i = 0; i < s->num_children; i++) { + if (s->bs[i] == child_bs) { + break; + } + } + + QLIST_FOREACH(child, &bs->children, next) { + if (child->bs == child_bs) { + break; + } + } + + /* we have checked it in bdrv_del_child() */ + assert(i < s->num_children && child); + + if (s->num_children <= s->threshold) { + error_setg(errp, + "The number of children cannot be lower than the vote threshold %d", + s->threshold); + return; + } + + bdrv_drain(bs); + /* We can safely remove this child now */ + memmove(&s->bs[i], &s->bs[i + 1], + (s->num_children - i - 1) * sizeof(void *)); + s->num_children--; + s->bs[s->num_children] = NULL; + bdrv_unref_child(bs, child); +} + static void quorum_refresh_filename(BlockDriverState *bs) { BDRVQuorumState *s = bs->opaque; @@ -1049,6 +1114,9 @@ static BlockDriver bdrv_quorum = { .bdrv_detach_aio_context = quorum_detach_aio_context, .bdrv_attach_aio_context = quorum_attach_aio_context, + .bdrv_add_child = quorum_add_child, + .bdrv_del_child = quorum_del_child, + .is_filter = true, .bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter, }; diff --git a/include/block/block.h b/include/block/block.h index 665c56f..bd97399 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -514,6 +514,9 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs); void bdrv_ref(BlockDriverState *bs); void bdrv_unref(BlockDriverState *bs); void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child); +BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, + BlockDriverState *child_bs, + const BdrvChildRole *child_role); bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp); void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason); -- 2.4.3 From MAILER-DAEMON Tue Sep 22 05:22:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeJmB-0000pn-Eo for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 05:22:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeJm8-0000mZ-R7 for qemu-block@nongnu.org; Tue, 22 Sep 2015 05:22:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeJm7-0006sE-Po for qemu-block@nongnu.org; Tue, 22 Sep 2015 05:22:12 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:16070 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeJm3-0006ho-EW; Tue, 22 Sep 2015 05:22:07 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2D0BQDZHAFW/5tjdVtdGQEBAYMIgT2pLgEBAQEBBQGBCgGTHod0AoE9ORMBAQEBAQEBgQqEJQEBBDo/EAsOEyUPASwbBgESiDIBvCeOfwEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsAQSMfYhojlaHVolAiDojAj6EAzwziW0BAQE X-IPAS-Result: A2D0BQDZHAFW/5tjdVtdGQEBAYMIgT2pLgEBAQEBBQGBCgGTHod0AoE9ORMBAQEBAQEBgQqEJQEBBDo/EAsOEyUPASwbBgESiDIBvCeOfwEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsAQSMfYhojlaHVolAiDojAj6EAzwziW0BAQE X-IronPort-AV: E=Sophos;i="5.17,572,1437429600"; d="scan'208";a="25591518" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 22 Sep 2015 11:21:29 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZeJlQ-0000nm-Ur; Tue, 22 Sep 2015 11:21:29 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZeJlQ-0007Zi-OD; Tue, 22 Sep 2015 11:21:28 +0200 From: Alberto Garcia To: Eric Blake , qemu-devel@nongnu.org In-Reply-To: <55FC2462.9080000@redhat.com> References: <0feb7566cff42d8625ed7263de73fc59225e125f.1442245236.git.berto@igalia.com> <55FC2462.9080000@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Tue, 22 Sep 2015 11:21:28 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v4 3/4] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 09:22:13 -0000 On Fri 18 Sep 2015 04:49:06 PM CEST, Eric Blake wrote: >> +# @BlockdevSnapshot >> +# >> +# @device: device or node name to generate the snapshot from. > > I'm still wondering if 'node' is a better name than 'device' here. I don't have a strong preference. Kevin, Max, ... any opinions? >> +# >> +# @snapshot: reference to the existing block device that will be used >> +# for the snapshot. It must not have a current backing file >> +# (this can be achieved by passing "backing": "" to >> +# blockdev-add). > > Possibly confusing terminology. > > Let's consider: the act of creating a snapshot says to go from: > > image1 [read-write] > > to > > image1 [read-only] <- image2 [read-write] > > that is, image1 is now the snapshot of the state in time we executed the > command, and image2 is the delta from what happened since the snapshot. > Therefore, image2 is NOT the snapshot. Naming the command > 'blockdev-snapshot' is fine, but I think we can have better names for > the arguments. > > Better wording might be: > > @device: device or node that will have a snapshot created > > @overlay: reference to existing block device that will become the > overlay of device, as part of creating the snapshot. It must not have > a current backing file... I think you are right. I'll update the descriptions as you suggest. The problem is that, incorrectly or not, we are already using 'snapshot' to refer to the overlays, e.g in BlockdevSnapshotSync: # @device: #optional the name of the device to generate the snapshot # from. # @node-name: #optional graph node name to generate the snapshot from # (Since 2.0) # @snapshot-file: the target of the new image. A new file will be # created. # @snapshot-node-name: #optional the graph node name of the new image # (Since 2.0) I'll wait a bit in case someone wants to say something about the names of the parameters. Berto From MAILER-DAEMON Tue Sep 22 05:32:11 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeJvn-0004i3-6j for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 05:32:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeJvl-0004hs-Ju for qemu-block@nongnu.org; Tue, 22 Sep 2015 05:32:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeJvg-0003Ri-L8 for qemu-block@nongnu.org; Tue, 22 Sep 2015 05:32:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeJvg-0003RQ-Fr; Tue, 22 Sep 2015 05:32:04 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id AF91C8E694; Tue, 22 Sep 2015 09:32:03 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8M9W1Z0027385; Tue, 22 Sep 2015 05:32:01 -0400 Date: Tue, 22 Sep 2015 11:32:01 +0200 From: Kevin Wolf To: Alberto Garcia Message-ID: <20150922093201.GB3999@noname.str.redhat.com> References: <0feb7566cff42d8625ed7263de73fc59225e125f.1442245236.git.berto@igalia.com> <55FC2462.9080000@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Subject: Re: [Qemu-block] [PATCH v4 3/4] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 09:32:10 -0000 Am 22.09.2015 um 11:21 hat Alberto Garcia geschrieben: > On Fri 18 Sep 2015 04:49:06 PM CEST, Eric Blake wrote: > > >> +# @BlockdevSnapshot > >> +# > >> +# @device: device or node name to generate the snapshot from. > > > > I'm still wondering if 'node' is a better name than 'device' here. > > I don't have a strong preference. Kevin, Max, ... any opinions? If I had to choose, I think I would go with 'node' indeed. > >> +# > >> +# @snapshot: reference to the existing block device that will be used > >> +# for the snapshot. It must not have a current backing file > >> +# (this can be achieved by passing "backing": "" to > >> +# blockdev-add). > > > > Possibly confusing terminology. > > > > Let's consider: the act of creating a snapshot says to go from: > > > > image1 [read-write] > > > > to > > > > image1 [read-only] <- image2 [read-write] > > > > that is, image1 is now the snapshot of the state in time we executed the > > command, and image2 is the delta from what happened since the snapshot. > > Therefore, image2 is NOT the snapshot. Naming the command > > 'blockdev-snapshot' is fine, but I think we can have better names for > > the arguments. > > > > Better wording might be: > > > > @device: device or node that will have a snapshot created > > > > @overlay: reference to existing block device that will become the > > overlay of device, as part of creating the snapshot. It must not have > > a current backing file... > > I think you are right. I'll update the descriptions as you suggest. > > The problem is that, incorrectly or not, we are already using 'snapshot' > to refer to the overlays, e.g in BlockdevSnapshotSync: Let's not worry too much about legacy commands. We know that we made some decisions in the past that we wouldn't make today. As long as we don't introduce new commands, it makes little sense to clean them up, as the requirement to maintain compatibility would result in an even worse API in the end. But for new commands, we can choose whatever we think makes most sense in the future. Kevin From MAILER-DAEMON Tue Sep 22 06:07:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeKTz-0003lE-CA for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 06:07:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeKTx-0003l5-C3 for qemu-block@nongnu.org; Tue, 22 Sep 2015 06:07:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeKTs-0008Kt-Bn for qemu-block@nongnu.org; Tue, 22 Sep 2015 06:07:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37778) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeKTs-0008Kn-6X; Tue, 22 Sep 2015 06:07:24 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id B646E8DA34; Tue, 22 Sep 2015 10:07:23 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MA7LIq030831; Tue, 22 Sep 2015 06:07:22 -0400 Date: Tue, 22 Sep 2015 12:07:21 +0200 From: Kevin Wolf To: Alberto Garcia Message-ID: <20150922100721.GC3999@noname.str.redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, armbru@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 00/16] block: Get rid of bdrv_swap() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 10:07:30 -0000 Am 18.09.2015 um 13:03 hat Alberto Garcia geschrieben: > On Thu 17 Sep 2015 03:48:04 PM CEST, Kevin Wolf wrot= e: >=20 > > bdrv_swap() has always been an ugly hack that we would rather have > > avoided. When it was introduced, we simply didn't have the > > infrastructure to update pointers instead of transplanting the > > contents of BDS object, so we grudgingly added bdrv_swap() as a quick > > solution. Meanwhile, most of the infrastructure exists and this > > series implements the final step necessary to implement the required > > functionality in a less adventurous way. >=20 > I didn't have the chance to debug this further, but with this series if > I make a snapshot of a device with ongoing I/O I get lots of errors in > the guest: >=20 > Buffer I/O error on device vda1, logical block 3801549 > end_request: I/O error, dev vda, sector 7604516 > [...] >=20 > The drive is attached with -drive if=3Dvirtio,file=3Dfoo.qcow2,node-nam= e=3Dbar This is a stupid one. Now that bdrv_append() doesn't swap the meaning of its parameters any more, the snapshotting code makes the wrong node read-only. The more important point, though, is probably that qemu-iotests never tries to write to an image after taking an internal snapshot. Perhaps we should port the monitor to qemu-io (Beno=EEt had some patches to add it t= o qemu-nbd, which should be similar; except that a "qmp" command in qemu-io could even be simpler), so we can test monitor commands more thoroughly without launching a full qemu (which allows to use the monitor commands in isolation, but mostly means that we don't do a lot of actual I/O). Anyway, patch below. Kevin diff --git a/blockdev.c b/blockdev.c index bc158ff..8926226 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1546,7 +1546,7 @@ static void external_snapshot_commit(BlkTransaction= State *common) /* We don't need (or want) to use the transactional * bdrv_reopen_multiple() across all the entries at once, because we * don't want to abort all of them if one of them fails the reopen *= / - bdrv_reopen(state->new_bs, state->new_bs->open_flags & ~BDRV_O_RDWR, + bdrv_reopen(state->old_bs, state->old_bs->open_flags & ~BDRV_O_RDWR, NULL); =20 aio_context_release(state->aio_context); From MAILER-DAEMON Tue Sep 22 07:16:09 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeLYP-0004fg-2s for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 07:16:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeLYL-0004eQ-To for qemu-block@nongnu.org; Tue, 22 Sep 2015 07:16:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeLYH-00023Q-Jy for qemu-block@nongnu.org; Tue, 22 Sep 2015 07:16:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeLYH-00021l-Ez; Tue, 22 Sep 2015 07:16:01 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 858E18C1B3; Tue, 22 Sep 2015 11:16:00 +0000 (UTC) Received: from work-vm (ovpn-116-113.ams2.redhat.com [10.36.116.113]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MBFtNu029807 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Sep 2015 07:15:57 -0400 Date: Tue, 22 Sep 2015 12:15:54 +0100 From: "Dr. David Alan Gilbert" To: Wen Congyang Message-ID: <20150922111554.GD3529@work-vm> References: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , Markus Armbruster , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [PATCH v5 0/4] qapi: child add/delete support X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 11:16:07 -0000 * Wen Congyang (wency@cn.fujitsu.com) wrote: > If quorum's child is broken, we can use mirror job to replace it. > But sometimes, the user only need to remove the broken child, and > add it later when the problem is fixed. > Hi, Two questions: 1) Do you have an example of a pair of add/remove commands that work together? (I'm not quite sure I understand where the ID for the remove comes from). 2) If the child has failed and is not responding to block operations at all (e.g a networking failure to an nbd device which may take minutes to time out); how do you recover - flush or drain on the devices hang at that point. (I was trying to test recovery from a failed secondary using the July COLO release; but the primary gets stuck in bdrv_drain or bdrv_flush if I kill the secondary in the right way). Dave > It is based on the following patch: > http://lists.nongnu.org/archive/html/qemu-devel/2015-09/msg04579.html > > ChangLog: > v5: > 1. Address Eric Blake's comments > v4: > 1. drop nbd driver's implementation. We can use human-monitor-command > to do it. > 2. Rename the command name. > v3: > 1. Don't open BDS in bdrv_add_child(). Use the existing BDS which is > created by the QMP command blockdev-add. > 2. The driver NBD can support filename, path, host:port now. > v2: > 1. Use bdrv_get_device_or_node_name() instead of new function > bdrv_get_id_or_node_name() > 2. Update the error message > 3. Update the documents in block-core.json > > Wen Congyang (4): > Add new block driver interface to add/delete a BDS's child > quorum: implement bdrv_add_child() and bdrv_del_child() > qmp: add monitor command to add/remove a child > hmp: add monitor command to add/remove a child > > block.c | 56 ++++++++++++++++++++++++++++++++++-- > block/quorum.c | 72 +++++++++++++++++++++++++++++++++++++++++++++-- > blockdev.c | 48 +++++++++++++++++++++++++++++++ > hmp-commands.hx | 28 ++++++++++++++++++ > hmp.c | 20 +++++++++++++ > hmp.h | 2 ++ > include/block/block.h | 8 ++++++ > include/block/block_int.h | 5 ++++ > qapi/block-core.json | 34 ++++++++++++++++++++++ > qmp-commands.hx | 61 +++++++++++++++++++++++++++++++++++++++ > 10 files changed, 329 insertions(+), 5 deletions(-) > > -- > 2.4.3 > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK From MAILER-DAEMON Tue Sep 22 09:29:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeNdS-0007R9-HN for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 09:29:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeNdN-0007IM-J6 for qemu-block@nongnu.org; Tue, 22 Sep 2015 09:29:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeNdM-0007Cz-7w for qemu-block@nongnu.org; Tue, 22 Sep 2015 09:29:25 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:18441 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeNdH-0007AN-JC; Tue, 22 Sep 2015 09:29:19 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2B+AgAuVwFW/5tjdVtdGQEBAYMIgT2pLgEBAQEBBQGBCpMSAQ2EPYM2AoFDOBQBAQEBAQEBgQqEJQEBBHkQPxI8GxmIMgHLJyyGLIpRB4QsBYx9cYd5jQmbIx8BAUKBSoI6boltAQEB X-IPAS-Result: A2B+AgAuVwFW/5tjdVtdGQEBAYMIgT2pLgEBAQEBBQGBCpMSAQ2EPYM2AoFDOBQBAQEBAQEBgQqEJQEBBHkQPxI8GxmIMgHLJyyGLIpRB4QsBYx9cYd5jQmbIx8BAUKBSoI6boltAQEB X-IronPort-AV: E=Sophos;i="5.17,573,1437429600"; d="scan'208";a="25639264" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 22 Sep 2015 15:29:15 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZeNdD-0004Z2-3g; Tue, 22 Sep 2015 15:29:15 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZeNcz-0008CD-Tz; Tue, 22 Sep 2015 16:29:01 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Tue, 22 Sep 2015 16:28:55 +0300 Message-Id: X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v6 4/4] block: add tests for the 'blockdev-snapshot' command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 13:29:27 -0000 Signed-off-by: Alberto Garcia Cc: Max Reitz --- tests/qemu-iotests/085 | 102 ++++++++++++++++++++++++++++++++++++++++++--- tests/qemu-iotests/085.out | 34 ++++++++++++++- 2 files changed, 128 insertions(+), 8 deletions(-) diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085 index 56cd6f8..9484117 100755 --- a/tests/qemu-iotests/085 +++ b/tests/qemu-iotests/085 @@ -7,6 +7,7 @@ # snapshots are performed. # # Copyright (C) 2014 Red Hat, Inc. +# Copyright (C) 2015 Igalia, S.L. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,17 +35,17 @@ status=1 # failure is the default! snapshot_virt0="snapshot-v0.qcow2" snapshot_virt1="snapshot-v1.qcow2" -MAX_SNAPSHOTS=10 +SNAPSHOTS=10 _cleanup() { _cleanup_qemu - for i in $(seq 1 ${MAX_SNAPSHOTS}) + for i in $(seq 1 ${SNAPSHOTS}) do rm -f "${TEST_DIR}/${i}-${snapshot_virt0}" rm -f "${TEST_DIR}/${i}-${snapshot_virt1}" done - _cleanup_test_img + rm -f "${TEST_IMG}.1" "${TEST_IMG}.2" } trap "_cleanup; exit \$status" 0 1 2 3 15 @@ -85,18 +86,50 @@ function create_group_snapshot() _send_qemu_cmd $h "${cmd}" "return" } +# ${1}: unique identifier for the snapshot filename +# ${2}: true: open backing images; false: don't open them (default) +function add_snapshot_image() +{ + if [ "${2}" = "true" ]; then + extra_params="" + else + extra_params="'backing': '', " + fi + base_image="${TEST_DIR}/$((${1}-1))-${snapshot_virt0}" + snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}" + _make_test_img -b "${base_image}" "$size" + mv "${TEST_IMG}" "${snapshot_file}" + cmd="{ 'execute': 'blockdev-add', 'arguments': + { 'options': + { 'driver': 'qcow2', 'node-name': 'snap_"${1}"', "${extra_params}" + 'file': + { 'driver': 'file', 'filename': '"${snapshot_file}"' } } } }" + _send_qemu_cmd $h "${cmd}" "return" +} + +# ${1}: unique identifier for the snapshot filename +# ${2}: expected response, defaults to 'return' +function blockdev_snapshot() +{ + cmd="{ 'execute': 'blockdev-snapshot', + 'arguments': { 'node': 'virtio0', + 'overlay':'snap_"${1}"' } }" + _send_qemu_cmd $h "${cmd}" "${2:-return}" +} + size=128M _make_test_img $size -mv "${TEST_IMG}" "${TEST_IMG}.orig" +mv "${TEST_IMG}" "${TEST_IMG}.1" _make_test_img $size +mv "${TEST_IMG}" "${TEST_IMG}.2" echo echo === Running QEMU === echo qemu_comm_method="qmp" -_launch_qemu -drive file="${TEST_IMG}.orig",if=virtio -drive file="${TEST_IMG}",if=virtio +_launch_qemu -drive file="${TEST_IMG}.1",if=virtio -drive file="${TEST_IMG}.2",if=virtio h=$QEMU_HANDLE echo @@ -105,6 +138,8 @@ echo _send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return" +# Tests for the blockdev-snapshot-sync command + echo echo === Create a single snapshot on virtio0 === echo @@ -132,11 +167,66 @@ echo echo === Create several transactional group snapshots === echo -for i in $(seq 2 ${MAX_SNAPSHOTS}) +for i in $(seq 2 ${SNAPSHOTS}) do create_group_snapshot ${i} done +# Tests for the blockdev-snapshot command + +echo +echo === Create a couple of snapshots using blockdev-snapshot === +echo + +SNAPSHOTS=$((${SNAPSHOTS}+1)) +add_snapshot_image ${SNAPSHOTS} +blockdev_snapshot ${SNAPSHOTS} + +SNAPSHOTS=$((${SNAPSHOTS}+1)) +add_snapshot_image ${SNAPSHOTS} +blockdev_snapshot ${SNAPSHOTS} + +echo +echo === Invalid command - snapshot node used as active layer === +echo + +blockdev_snapshot ${SNAPSHOTS} error + +_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot', + 'arguments': { 'node':'virtio0', + 'overlay':'virtio0' } + }" "error" + +_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot', + 'arguments': { 'node':'virtio0', + 'overlay':'virtio1' } + }" "error" + +echo +echo === Invalid command - snapshot node used as backing hd === +echo + +blockdev_snapshot $((${SNAPSHOTS}-1)) error + +echo +echo === Invalid command - snapshot node has a backing image === +echo + +SNAPSHOTS=$((${SNAPSHOTS}+1)) +add_snapshot_image ${SNAPSHOTS} true +blockdev_snapshot ${SNAPSHOTS} error + +echo +echo === Invalid command - The node does not exist === +echo + +blockdev_snapshot $((${SNAPSHOTS}+1)) error + +_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot', + 'arguments': { 'node':'nodevice', + 'overlay':'snap_"${SNAPSHOTS}"' } + }" "error" + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out index a6cf19e..52292ea 100644 --- a/tests/qemu-iotests/085.out +++ b/tests/qemu-iotests/085.out @@ -11,7 +11,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 === Create a single snapshot on virtio0 === -Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2.orig backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 +Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2.1 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 {"return": {}} === Invalid command - missing device and nodename === @@ -26,7 +26,7 @@ Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file === Create several transactional group snapshots === Formatting 'TEST_DIR/2-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/1-snapshot-v0.qcow2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 -Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 +Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/t.qcow2.2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 {"return": {}} Formatting 'TEST_DIR/3-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/2-snapshot-v0.qcow2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/3-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/2-snapshot-v1.qcow2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 @@ -52,4 +52,34 @@ Formatting 'TEST_DIR/9-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file Formatting 'TEST_DIR/10-snapshot-v0.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/9-snapshot-v0.qcow2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 size=134217728 backing_file=TEST_DIR/9-snapshot-v1.qcow2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 {"return": {}} + +=== Create a couple of snapshots using blockdev-snapshot === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/10-snapshot-v0.IMGFMT +{"return": {}} +{"return": {}} +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/11-snapshot-v0.IMGFMT +{"return": {}} +{"return": {}} + +=== Invalid command - snapshot node used as active layer === + +{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio0"}} +{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio0"}} +{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio1"}} + +=== Invalid command - snapshot node used as backing hd === + +{"error": {"class": "GenericError", "desc": "Node 'snap_11' is busy: node is used as backing hd of 'virtio0'"}} + +=== Invalid command - snapshot node has a backing image === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/12-snapshot-v0.IMGFMT +{"return": {}} +{"error": {"class": "GenericError", "desc": "The snapshot already has a backing image"}} + +=== Invalid command - The node does not exist === + +{"error": {"class": "GenericError", "desc": "Cannot find device=snap_14 nor node_name=snap_14"}} +{"error": {"class": "GenericError", "desc": "Cannot find device=nodevice nor node_name=nodevice"}} *** done -- 2.5.1 From MAILER-DAEMON Tue Sep 22 09:29:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeNdT-0007TO-PT for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 09:29:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeNdP-0007L2-Fv for qemu-block@nongnu.org; Tue, 22 Sep 2015 09:29:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeNdL-0007Cl-8b for qemu-block@nongnu.org; Tue, 22 Sep 2015 09:29:27 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:47632 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeNdG-00079r-KA; Tue, 22 Sep 2015 09:29:18 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AxBQAuVwFW/5tjdVtdGQEBAYMIgT2BTKdiAQEBAQEFAYEKkxIBDYdzAoFDOBQBAQEBAQEBgQqEJQEBBHkQPxI8GxmIMgHLJwErgk+DXYllbAcXhBUFjH1xh3mHf4UKmyMfAQFCgUpHHIFXboltAQEB X-IPAS-Result: A2AxBQAuVwFW/5tjdVtdGQEBAYMIgT2BTKdiAQEBAQEFAYEKkxIBDYdzAoFDOBQBAQEBAQEBgQqEJQEBBHkQPxI8GxmIMgHLJwErgk+DXYllbAcXhBUFjH1xh3mHf4UKmyMfAQFCgUpHHIFXboltAQEB X-IronPort-AV: E=Sophos;i="5.17,573,1437429600"; d="scan'208";a="25639260" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 22 Sep 2015 15:29:15 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZeNdD-0004Yz-0W; Tue, 22 Sep 2015 15:29:15 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZeNcz-0008By-Qr; Tue, 22 Sep 2015 16:29:01 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Tue, 22 Sep 2015 16:28:52 +0300 Message-Id: <1f3baf6c7c9508bd304ef345ebbc92ac11df5e35.1442928283.git.berto@igalia.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v6 1/4] block: rename BlockdevSnapshot to BlockdevSnapshotSync X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 13:29:28 -0000 We will introduce the 'blockdev-snapshot' command that will require its own struct for the parameters, so we need to rename this one in order to avoid name clashes. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- blockdev.c | 2 +- qapi-schema.json | 2 +- qapi/block-core.json | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/blockdev.c b/blockdev.c index 4731843..1a5b889 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1166,7 +1166,7 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, bool has_format, const char *format, bool has_mode, NewImageMode mode, Error **errp) { - BlockdevSnapshot snapshot = { + BlockdevSnapshotSync snapshot = { .has_device = has_device, .device = (char *) device, .has_node_name = has_node_name, diff --git a/qapi-schema.json b/qapi-schema.json index 0d5190b..45a85db 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1499,7 +1499,7 @@ ## { 'union': 'TransactionAction', 'data': { - 'blockdev-snapshot-sync': 'BlockdevSnapshot', + 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', 'drive-backup': 'DriveBackup', 'blockdev-backup': 'BlockdevBackup', 'abort': 'Abort', diff --git a/qapi/block-core.json b/qapi/block-core.json index 5f12af7..6b5ac02 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -682,7 +682,7 @@ 'data': [ 'existing', 'absolute-paths' ] } ## -# @BlockdevSnapshot +# @BlockdevSnapshotSync # # Either @device or @node-name must be set but not both. # @@ -699,7 +699,7 @@ # @mode: #optional whether and how QEMU should create a new image, default is # 'absolute-paths'. ## -{ 'struct': 'BlockdevSnapshot', +{ 'struct': 'BlockdevSnapshotSync', 'data': { '*device': 'str', '*node-name': 'str', 'snapshot-file': 'str', '*snapshot-node-name': 'str', '*format': 'str', '*mode': 'NewImageMode' } } @@ -790,7 +790,7 @@ # # Generates a synchronous snapshot of a block device. # -# For the arguments, see the documentation of BlockdevSnapshot. +# For the arguments, see the documentation of BlockdevSnapshotSync. # # Returns: nothing on success # If @device is not a valid block device, DeviceNotFound @@ -798,7 +798,7 @@ # Since 0.14.0 ## { 'command': 'blockdev-snapshot-sync', - 'data': 'BlockdevSnapshot' } + 'data': 'BlockdevSnapshotSync' } ## # @change-backing-file -- 2.5.1 From MAILER-DAEMON Tue Sep 22 09:29:33 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeNdV-0007W3-Rl for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 09:29:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeNdQ-0007Mh-Lj for qemu-block@nongnu.org; Tue, 22 Sep 2015 09:29:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeNdO-0007Ek-Ur for qemu-block@nongnu.org; Tue, 22 Sep 2015 09:29:28 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:47632 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeNdH-00079r-7I; Tue, 22 Sep 2015 09:29:19 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AfDQAuVwFW/5tjdVtdGQEBAYMIgT2BTKdiAQEBAQEFAYEKkyCHcwKBQzkTAQEBAQEBAYEKhCUBAQQnUhA/EjwbGRuIFwHLJyyGLIllbAeELAWHNIVJcYd5jQmbIyMBP4FKRxyBV26JbQEBAQ X-IPAS-Result: A2AfDQAuVwFW/5tjdVtdGQEBAYMIgT2BTKdiAQEBAQEFAYEKkyCHcwKBQzkTAQEBAQEBAYEKhCUBAQQnUhA/EjwbGRuIFwHLJyyGLIllbAeELAWHNIVJcYd5jQmbIyMBP4FKRxyBV26JbQEBAQ X-IronPort-AV: E=Sophos;i="5.17,573,1437429600"; d="scan'208";a="25639263" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 22 Sep 2015 15:29:15 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZeNdD-0004Z1-1i; Tue, 22 Sep 2015 15:29:15 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZeNcz-0008C8-Ss; Tue, 22 Sep 2015 16:29:01 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Tue, 22 Sep 2015 16:28:54 +0300 Message-Id: <8cc989a360a5fe38839144946c878fb9f8c6a6d5.1442928283.git.berto@igalia.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v6 3/4] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 13:29:32 -0000 One of the limitations of the 'blockdev-snapshot-sync' command is that it does not allow passing BlockdevOptions to the newly created snapshots, so they are always opened using the default values. Extending the command to allow passing options is not a practical solution because there is overlap between those options and some of the existing parameters of the command. This patch introduces a new 'blockdev-snapshot' command with a simpler interface: it just takes two references to existing block devices that will be used as the source and target for the snapshot. Since the main difference between the two commands is that one of them creates and opens the target image, while the other uses an already opened one, the bulk of the implementation is shared. Signed-off-by: Alberto Garcia Cc: Eric Blake Cc: Max Reitz --- blockdev.c | 163 ++++++++++++++++++++++++++++++++------------------- qapi-schema.json | 2 + qapi/block-core.json | 28 +++++++++ qmp-commands.hx | 38 ++++++++++++ 4 files changed, 171 insertions(+), 60 deletions(-) diff --git a/blockdev.c b/blockdev.c index 1a5b889..daf72f3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1183,6 +1183,18 @@ void qmp_blockdev_snapshot_sync(bool has_device, const char *device, &snapshot, errp); } +void qmp_blockdev_snapshot(const char *node, const char *overlay, + Error **errp) +{ + BlockdevSnapshot snapshot_data = { + .node = (char *) node, + .overlay = (char *) overlay + }; + + blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT, + &snapshot_data, errp); +} + void qmp_blockdev_snapshot_internal_sync(const char *device, const char *name, Error **errp) @@ -1521,57 +1533,48 @@ typedef struct ExternalSnapshotState { static void external_snapshot_prepare(BlkTransactionState *common, Error **errp) { - int flags, ret; - QDict *options; + int flags = 0, ret; + QDict *options = NULL; Error *local_err = NULL; - bool has_device = false; + /* Device and node name of the image to generate the snapshot from */ const char *device; - bool has_node_name = false; const char *node_name; - bool has_snapshot_node_name = false; - const char *snapshot_node_name; + /* Reference to the new image (for 'blockdev-snapshot') */ + const char *snapshot_ref; + /* File name of the new image (for 'blockdev-snapshot-sync') */ const char *new_image_file; - const char *format = "qcow2"; - enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; ExternalSnapshotState *state = DO_UPCAST(ExternalSnapshotState, common, common); TransactionAction *action = common->action; - /* get parameters */ - g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC); - - has_device = action->blockdev_snapshot_sync->has_device; - device = action->blockdev_snapshot_sync->device; - has_node_name = action->blockdev_snapshot_sync->has_node_name; - node_name = action->blockdev_snapshot_sync->node_name; - has_snapshot_node_name = - action->blockdev_snapshot_sync->has_snapshot_node_name; - snapshot_node_name = action->blockdev_snapshot_sync->snapshot_node_name; - - new_image_file = action->blockdev_snapshot_sync->snapshot_file; - if (action->blockdev_snapshot_sync->has_format) { - format = action->blockdev_snapshot_sync->format; - } - if (action->blockdev_snapshot_sync->has_mode) { - mode = action->blockdev_snapshot_sync->mode; + /* 'blockdev-snapshot' and 'blockdev-snapshot-sync' have similar + * purpose but a different set of parameters */ + switch (action->kind) { + case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT: + { + BlockdevSnapshot *s = action->blockdev_snapshot; + device = s->node; + node_name = s->node; + new_image_file = NULL; + snapshot_ref = s->overlay; + } + break; + case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC: + { + BlockdevSnapshotSync *s = action->blockdev_snapshot_sync; + device = s->has_device ? s->device : NULL; + node_name = s->has_node_name ? s->node_name : NULL; + new_image_file = s->snapshot_file; + snapshot_ref = NULL; + } + break; + default: + g_assert_not_reached(); } /* start processing */ - state->old_bs = bdrv_lookup_bs(has_device ? device : NULL, - has_node_name ? node_name : NULL, - &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - - if (has_node_name && !has_snapshot_node_name) { - error_setg(errp, "New snapshot node name missing"); - return; - } - - if (has_snapshot_node_name && bdrv_find_node(snapshot_node_name)) { - error_setg(errp, "New snapshot node name already existing"); + state->old_bs = bdrv_lookup_bs(device, node_name, errp); + if (!state->old_bs) { return; } @@ -1601,35 +1604,69 @@ static void external_snapshot_prepare(BlkTransactionState *common, return; } - flags = state->old_bs->open_flags; + if (action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC) { + BlockdevSnapshotSync *s = action->blockdev_snapshot_sync; + const char *format = s->has_format ? s->format : "qcow2"; + enum NewImageMode mode; + const char *snapshot_node_name = + s->has_snapshot_node_name ? s->snapshot_node_name : NULL; - /* create new image w/backing file */ - if (mode != NEW_IMAGE_MODE_EXISTING) { - bdrv_img_create(new_image_file, format, - state->old_bs->filename, - state->old_bs->drv->format_name, - NULL, -1, flags, &local_err, false); - if (local_err) { - error_propagate(errp, local_err); + if (node_name && !snapshot_node_name) { + error_setg(errp, "New snapshot node name missing"); return; } - } - options = qdict_new(); - if (has_snapshot_node_name) { - qdict_put(options, "node-name", - qstring_from_str(snapshot_node_name)); + if (snapshot_node_name && bdrv_find_node(snapshot_node_name)) { + error_setg(errp, "New snapshot node name already exists"); + return; + } + + flags = state->old_bs->open_flags; + + /* create new image w/backing file */ + mode = s->has_mode ? s->mode : NEW_IMAGE_MODE_ABSOLUTE_PATHS; + if (mode != NEW_IMAGE_MODE_EXISTING) { + bdrv_img_create(new_image_file, format, + state->old_bs->filename, + state->old_bs->drv->format_name, + NULL, -1, flags, &local_err, false); + if (local_err) { + error_propagate(errp, local_err); + return; + } + } + + options = qdict_new(); + if (s->has_snapshot_node_name) { + qdict_put(options, "node-name", + qstring_from_str(snapshot_node_name)); + } + qdict_put(options, "driver", qstring_from_str(format)); + + flags |= BDRV_O_NO_BACKING; } - qdict_put(options, "driver", qstring_from_str(format)); - /* TODO Inherit bs->options or only take explicit options with an - * extended QMP command? */ assert(state->new_bs == NULL); - ret = bdrv_open(&state->new_bs, new_image_file, NULL, options, - flags | BDRV_O_NO_BACKING, &local_err); + ret = bdrv_open(&state->new_bs, new_image_file, snapshot_ref, options, + flags, errp); /* We will manually add the backing_hd field to the bs later */ if (ret != 0) { - error_propagate(errp, local_err); + return; + } + + if (state->new_bs->blk != NULL) { + error_setg(errp, "The snapshot is already in use by %s", + blk_name(state->new_bs->blk)); + return; + } + + if (bdrv_op_is_blocked(state->new_bs, BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT, + errp)) { + return; + } + + if (state->new_bs->backing_hd != NULL) { + error_setg(errp, "The snapshot already has a backing image"); } } @@ -1818,6 +1855,12 @@ static void abort_commit(BlkTransactionState *common) } static const BdrvActionOps actions[] = { + [TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT] = { + .instance_size = sizeof(ExternalSnapshotState), + .prepare = external_snapshot_prepare, + .commit = external_snapshot_commit, + .abort = external_snapshot_abort, + }, [TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC] = { .instance_size = sizeof(ExternalSnapshotState), .prepare = external_snapshot_prepare, diff --git a/qapi-schema.json b/qapi-schema.json index 45a85db..296da01 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1496,9 +1496,11 @@ # abort since 1.6 # blockdev-snapshot-internal-sync since 1.7 # blockdev-backup since 2.3 +# blockdev-snapshot since 2.5 ## { 'union': 'TransactionAction', 'data': { + 'blockdev-snapshot': 'BlockdevSnapshot', 'blockdev-snapshot-sync': 'BlockdevSnapshotSync', 'drive-backup': 'DriveBackup', 'blockdev-backup': 'BlockdevBackup', diff --git a/qapi/block-core.json b/qapi/block-core.json index 6b5ac02..2563ac9 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -705,6 +705,21 @@ '*format': 'str', '*mode': 'NewImageMode' } } ## +# @BlockdevSnapshot +# +# @node: device or node name that will have a snapshot created. +# +# @overlay: reference to the existing block device that will become +# the overlay of @node, as part of creating the snapshot. +# It must not have a current backing file (this can be +# achieved by passing "backing": "" to blockdev-add). +# +# Since 2.5 +## +{ 'struct': 'BlockdevSnapshot', + 'data': { 'node': 'str', 'overlay': 'str' } } + +## # @DriveBackup # # @device: the name of the device which should be copied. @@ -800,6 +815,19 @@ { 'command': 'blockdev-snapshot-sync', 'data': 'BlockdevSnapshotSync' } + +## +# @blockdev-snapshot +# +# Generates a snapshot of a block device. +# +# For the arguments, see the documentation of BlockdevSnapshot. +# +# Since 2.5 +## +{ 'command': 'blockdev-snapshot', + 'data': 'BlockdevSnapshot' } + ## # @change-backing-file # diff --git a/qmp-commands.hx b/qmp-commands.hx index 495670b..e5bd0e0 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1454,6 +1454,44 @@ Example: EQMP { + .name = "blockdev-snapshot", + .args_type = "node:s,overlay:s", + .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot, + }, + +SQMP +blockdev-snapshot +----------------- +Since 2.5 + +Create a snapshot, by installing 'node' as the backing image of +'overlay'. Additionally, if 'node' is associated with a block +device, the block device changes to using 'overlay' as its new active +image. + +Arguments: + +- "node": device that will have a snapshot created (json-string) +- "overlay": device that will have 'node' as its backing image (json-string) + +Example: + +-> { "execute": "blockdev-add", + "arguments": { "options": { "driver": "qcow2", + "node-name": "node1534", + "file": { "driver": "file", + "filename": "hd1.qcow2" }, + "backing": "" } } } + +<- { "return": {} } + +-> { "execute": "blockdev-snapshot", "arguments": { "node": "ide-hd0", + "overlay": "node1534" } } +<- { "return": {} } + +EQMP + + { .name = "blockdev-snapshot-internal-sync", .args_type = "device:B,name:s", .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot_internal_sync, -- 2.5.1 From MAILER-DAEMON Tue Sep 22 09:29:36 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeNdY-0007aN-1C for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 09:29:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeNdP-0007Lb-Tb for qemu-block@nongnu.org; Tue, 22 Sep 2015 09:29:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeNdO-0007Ee-R7 for qemu-block@nongnu.org; Tue, 22 Sep 2015 09:29:27 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:18441 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeNdG-0007AN-W2; Tue, 22 Sep 2015 09:29:19 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AbAgAuVwFW/5tjdVtdGQEBgwlUaakoBgEBAQEBBQGBCpMSAQ2BUCAKhXmBRTgUAQEBAQEBAYEKhCcBBAIkUk86FIhmAQjLRwSGLIpRHoQVBYc0hUlxh3mFEYUUgmSBTpEaiDsfAQFCgUoBgjluAYlsAQEB X-IPAS-Result: A2AbAgAuVwFW/5tjdVtdGQEBgwlUaakoBgEBAQEBBQGBCpMSAQ2BUCAKhXmBRTgUAQEBAQEBAYEKhCcBBAIkUk86FIhmAQjLRwSGLIpRHoQVBYc0hUlxh3mFEYUUgmSBTpEaiDsfAQFCgUoBgjluAYlsAQEB X-IronPort-AV: E=Sophos;i="5.17,573,1437429600"; d="scan'208";a="25639262" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 22 Sep 2015 15:29:15 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZeNdD-0004Yy-1h; Tue, 22 Sep 2015 15:29:15 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZeNcz-0008Bv-PJ; Tue, 22 Sep 2015 16:29:01 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Tue, 22 Sep 2015 16:28:51 +0300 Message-Id: X-Mailer: git-send-email 2.5.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v6 0/4] Add 'blockdev-snapshot' command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 13:29:34 -0000 v6: - Update documentation and parameter names following Eric's suggestions: 'device' -> 'node', 'snapshot' -> 'overlay'. - Rebased on top of Max's "BlockBackend and media" v5 v5: https://lists.gnu.org/archive/html/qemu-block/2015-09/msg00483.html - Don't delete the 'backing' option if it contains something different from an empty string. - Rebase on top of the current master. v4: https://lists.gnu.org/archive/html/qemu-block/2015-09/msg00372.html - Implement the support for 'backing': '', drop 'ignore-backing', and update iotest 085 accordingly. - Include sample 'blockdev-add' call in the 'blockdev-snapshot' documentation. - Clarify that the snapshot must not have a backing file in the BlockdevSnapshot documentation. - Update error message ("...node name already existing" -> "...exists"). v3: https://lists.gnu.org/archive/html/qemu-block/2015-09/msg00272.html - Add 'ignore-backing' field to BlockdevOptionsGenericCOWFormat. This allows opening images but not their backing images. - Check for op blockers in the snapshot node and make sure that it doesn't have any backing image. - Remove extra check for the existence of the snapshot node: bdrv_open() already does that. - Extend iotest 085 to add tests for 'blockdev-snapshot'. - Replace local_err with errp in some places where the former is unnecessary. - Update command description. - Add 'since' tag to the 'blockdev-snapshot' field in TransactionAction. v2: https://lists.gnu.org/archive/html/qemu-block/2015-09/msg00094.html - Add 'blockdev-snapshot' command instead of allowing passing options to 'blockdev-snapshot-sync'. - Rename BlockdevSnapshot to BlockdevSnapshotSync v1: https://lists.gnu.org/archive/html/qemu-block/2015-08/msg00236.html Alberto Garcia (4): block: rename BlockdevSnapshot to BlockdevSnapshotSync block: support passing 'backing': '' to 'blockdev-add' block: add a 'blockdev-snapshot' QMP command block: add tests for the 'blockdev-snapshot' command block.c | 7 ++ blockdev.c | 165 ++++++++++++++++++++++++++++----------------- qapi-schema.json | 4 +- qapi/block-core.json | 34 +++++++++- qmp-commands.hx | 38 +++++++++++ tests/qemu-iotests/085 | 102 ++++++++++++++++++++++++++-- tests/qemu-iotests/085.out | 34 +++++++++- 7 files changed, 311 insertions(+), 73 deletions(-) -- 2.5.1 From MAILER-DAEMON Tue Sep 22 09:29:32 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeNdU-0007UD-2o for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 09:29:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeNdP-0007L4-GI for qemu-block@nongnu.org; Tue, 22 Sep 2015 09:29:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeNdL-0007Cq-CQ for qemu-block@nongnu.org; Tue, 22 Sep 2015 09:29:27 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:47632 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeNdG-00079r-0f; Tue, 22 Sep 2015 09:29:18 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2ACAgAuVwFW/5tjdVtdGQEBAYMIgT2pLgEBAQEBBQGBCpMSAQ2HcwKBQzgUAQEBAQEBAYEKhCUBAQQnUhA/EjwbGYgyAcsnASuGLIpRBxeEFQWNbod5jQmbIx8BAUKBSoI6boltAQEB X-IPAS-Result: A2ACAgAuVwFW/5tjdVtdGQEBAYMIgT2pLgEBAQEBBQGBCpMSAQ2HcwKBQzgUAQEBAQEBAYEKhCUBAQQnUhA/EjwbGYgyAcsnASuGLIpRBxeEFQWNbod5jQmbIx8BAUKBSoI6boltAQEB X-IronPort-AV: E=Sophos;i="5.17,573,1437429600"; d="scan'208";a="25639261" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 22 Sep 2015 15:29:15 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZeNdD-0004Z0-0a; Tue, 22 Sep 2015 15:29:15 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZeNcz-0008C3-Rw; Tue, 22 Sep 2015 16:29:01 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Tue, 22 Sep 2015 16:28:53 +0300 Message-Id: X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-block] [PATCH v6 2/4] block: support passing 'backing': '' to 'blockdev-add' X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 13:29:28 -0000 Passing an empty string allows opening an image but not its backing file. This was already described in the API documentation, only the implementation was missing. This is useful for creating snapshots using images opened with blockdev-add, since they are not supposed to have a backing image before the operation. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz Reviewed-by: Eric Blake --- block.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block.c b/block.c index 7776871..3a4cc9c 100644 --- a/block.c +++ b/block.c @@ -1406,6 +1406,7 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, BlockDriverState *file = NULL, *bs; BlockDriver *drv = NULL; const char *drvname; + const char *backing; Error *local_err = NULL; int snapshot_flags = 0; @@ -1473,6 +1474,12 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename, assert(drvname || !(flags & BDRV_O_PROTOCOL)); + backing = qdict_get_try_str(options, "backing"); + if (backing && *backing == '\0') { + flags |= BDRV_O_NO_BACKING; + qdict_del(options, "backing"); + } + bs->open_flags = flags; bs->options = options; options = qdict_clone_shallow(options); -- 2.5.1 From MAILER-DAEMON Tue Sep 22 10:17:12 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeONc-0001Mf-R5 for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 10:17:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeONY-0001M3-VP for qemu-block@nongnu.org; Tue, 22 Sep 2015 10:17:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeONU-0003no-Ig for qemu-block@nongnu.org; Tue, 22 Sep 2015 10:17:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49923) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeONU-0003nb-Bj; Tue, 22 Sep 2015 10:17:04 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id A17D3A2C18; Tue, 22 Sep 2015 14:17:03 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8MEH1Y3019132; Tue, 22 Sep 2015 10:17:01 -0400 Date: Tue, 22 Sep 2015 16:17:01 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150922141701.GD3999@noname.str.redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-18-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442589793-7105-18-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 17/38] block: Add BlockBackendRootState X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 14:17:10 -0000 Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: > This structure will store some of the state of the root BDS if the BDS > tree is removed, so that state can be restored once a new BDS tree is > inserted. This is magic that is bound to bite us sooner or later. I see that we have to do this in order to maintain compatibility, but imagine we'll have multiple BlockBackends sitting on top of the same BDS. They'll be fighting for whose throttling settings are applied. With this approach, the winner is the BlockBackend that most recently went from no medium to medium, which might just be the most surprising way to solve the problem. I'll detail one aspect of the problem below. The correct way to solve this seems to be that each BB has its own I/O throttling filter. Actually, if we could lift the throttling code to BlockBackend, that might solve the problem. I guess the same applies for the other fields in BlockBackendRootState. > Signed-off-by: Max Reitz > Reviewed-by: Eric Blake > --- > block/block-backend.c | 37 +++++++++++++++++++++++++++++++++++++ > include/block/block_int.h | 10 ++++++++++ > include/qemu/typedefs.h | 1 + > include/sysemu/block-backend.h | 2 ++ > 4 files changed, 50 insertions(+) > > diff --git a/block/block-backend.c b/block/block-backend.c > index 1f2cd9b..9590be5 100644 > --- a/block/block-backend.c > +++ b/block/block-backend.c > @@ -13,6 +13,7 @@ > #include "sysemu/block-backend.h" > #include "block/block_int.h" > #include "block/blockjob.h" > +#include "block/throttle-groups.h" > #include "sysemu/blockdev.h" > #include "sysemu/sysemu.h" > #include "qapi-event.h" > @@ -37,6 +38,10 @@ struct BlockBackend { > /* the block size for which the guest device expects atomicity */ > int guest_block_size; > > + /* If the BDS tree is removed, some of its options are stored here (which > + * can be used to restore those options in the new BDS on insert) */ > + BlockBackendRootState root_state; > + > /* I/O stats (display with "info blockstats"). */ > BlockAcctStats stats; > > @@ -161,6 +166,7 @@ static void blk_delete(BlockBackend *blk) > bdrv_unref(blk->bs); > blk->bs = NULL; > } > + g_free(blk->root_state.throttle_group_name); > /* Avoid double-remove after blk_hide_on_behalf_of_hmp_drive_del() */ > if (blk->name[0]) { > QTAILQ_REMOVE(&blk_backends, blk, link); > @@ -1050,3 +1056,34 @@ int blk_probe_geometry(BlockBackend *blk, HDGeometry *geo) > { > return bdrv_probe_geometry(blk->bs, geo); > } > + > +/* > + * Updates the BlockBackendRootState object with data from the currently > + * attached BlockDriverState. > + */ > +void blk_update_root_state(BlockBackend *blk) > +{ > + assert(blk->bs); > + > + blk->root_state.open_flags = blk->bs->open_flags; > + blk->root_state.read_only = blk->bs->read_only; > + blk->root_state.detect_zeroes = blk->bs->detect_zeroes; > + > + blk->root_state.io_limits_enabled = blk->bs->io_limits_enabled; > + > + g_free(blk->root_state.throttle_group_name); > + if (blk->bs->throttle_state) { > + throttle_get_config(blk->bs->throttle_state, > + &blk->root_state.throttle_config); > + blk->root_state.throttle_group_name = > + g_strdup(throttle_group_get_name(blk->bs)); The throttling group name is essentially a weak reference. I think making it strong is worth considering. If you attach a new BDS, if the old throttling group still exists, the new BDS is re-added there, as expected. If the throttling group has got changed limits meanwhile, you need to choose whether to apply the limits saved here or use the new limits for the BDS. I guess the latter will be the correct choice. If the old throttling group doesn't exist any more, a new one is created with the old name and limits. If two BlockBackends eject their media at separate times and the throttle group goes away, reinstantiating the throttle group by attaching a BDS to both BBs will use the config of the BB that got a new medium first (as opposed to: the latest setting the throttling group had before it was freed). If the old throttling group was freed, but then a new throttling group was created with the same name, we get attached to that new group with its new limits. This could be slightly surprising as well. Kevin From MAILER-DAEMON Tue Sep 22 10:30:19 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeOaJ-0007Sf-AH for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 10:30:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeOaH-0007SV-M1 for qemu-block@nongnu.org; Tue, 22 Sep 2015 10:30:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeOaG-0001fZ-O0 for qemu-block@nongnu.org; Tue, 22 Sep 2015 10:30:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39419) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeOaG-0001eJ-JZ; Tue, 22 Sep 2015 10:30:16 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id E7EE52CD820; Tue, 22 Sep 2015 14:30:15 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8MEUDHk002804; Tue, 22 Sep 2015 10:30:13 -0400 Date: Tue, 22 Sep 2015 16:30:12 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150922143012.GE3999@noname.str.redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-20-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442589793-7105-20-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 19/38] block: Fail requests to empty BlockBackend X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 14:30:18 -0000 Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: > If there is no BlockDriverState in a BlockBackend or if the tray of the > guest device is open, fail all requests (where that is possible) with > -ENOMEDIUM. > > The reason the status of the guest device is taken into account is > because once the guest device's tray is opened, any request on the same > BlockBackend as the guest uses should fail. If the BDS tree is supposed > to be usable even after ejecting it from the guest, a different > BlockBackend must be used. > > Signed-off-by: Max Reitz > Reviewed-by: Eric Blake Do we want to include blk_drain() to make it a no-op instead of crashing? Also, we're now introducing BlockAIOCBs with a NULL bs with your use of abort_aio_request. I haven't carefully reviewed the implications of this yet, but that should definitely be done before we merge the series. Kevin From MAILER-DAEMON Tue Sep 22 10:35:59 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeOfn-0001ea-JO for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 10:35:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeOfl-0001eM-EJ for qemu-block@nongnu.org; Tue, 22 Sep 2015 10:35:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeOfk-0001VR-F2 for qemu-block@nongnu.org; Tue, 22 Sep 2015 10:35:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38245) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeOfk-0001TV-33; Tue, 22 Sep 2015 10:35:56 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id D57838CF62; Tue, 22 Sep 2015 14:35:54 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8MEZqnn029971; Tue, 22 Sep 2015 10:35:52 -0400 Date: Tue, 22 Sep 2015 16:35:51 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150922143551.GF3999@noname.str.redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-21-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442589793-7105-21-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 20/38] block: Prepare remaining BB functions for NULL BDS X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 14:35:58 -0000 Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: > There are several BlockBackend functions which, in theory, cannot fail. > This patch makes them cope with the BlockDriverState pointer being NULL > by making them fall back to some default action like ignoring the value > in setters and returning the default in getters. > > Signed-off-by: Max Reitz > Reviewed-by: Eric Blake Hm, okay, maybe bdrv_drain() belongs here. I just reviewed the end result for completeness and didn't check which patch did what. > int blk_enable_write_cache(BlockBackend *blk) > { > + if (!blk->bs) { > + return 0; > + } > + > return bdrv_enable_write_cache(blk->bs); > } > > void blk_set_enable_write_cache(BlockBackend *blk, bool wce) > { > - bdrv_set_enable_write_cache(blk->bs, wce); > + if (blk->bs) { > + bdrv_set_enable_write_cache(blk->bs, wce); > + } > } WCE is part of the open_flags in BlockBackendRootState. The root state doesn't seem to be used yet, and I wrote about my concerns about it in reply to an earlier patch, but as long as we have it, should this query/modify the root state if no BDS is attached? Kevin From MAILER-DAEMON Tue Sep 22 10:42:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeOmJ-0006E7-66 for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 10:42:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeOmC-00066k-HH for qemu-block@nongnu.org; Tue, 22 Sep 2015 10:42:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeOm9-0005Tl-Q2 for qemu-block@nongnu.org; Tue, 22 Sep 2015 10:42:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40651) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeOm9-0005TR-H0; Tue, 22 Sep 2015 10:42:33 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id C7AA5AB104; Tue, 22 Sep 2015 14:42:32 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8MEgUdV025134; Tue, 22 Sep 2015 10:42:30 -0400 Date: Tue, 22 Sep 2015 16:42:29 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150922144229.GG3999@noname.str.redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-22-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442589793-7105-22-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 21/38] block: Add blk_insert_bs() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 14:42:42 -0000 Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: > This function associates the given BlockDriverState with the given > BlockBackend. > > Signed-off-by: Max Reitz > Reviewed-by: Eric Blake > Reviewed-by: Alberto Garcia > --- > block/block-backend.c | 16 ++++++++++++++++ > include/sysemu/block-backend.h | 1 + > 2 files changed, 17 insertions(+) > > diff --git a/block/block-backend.c b/block/block-backend.c > index 33145f8..652385e 100644 > --- a/block/block-backend.c > +++ b/block/block-backend.c > @@ -314,6 +314,22 @@ void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk) > } > > /* > + * Associates a new BlockDriverState with @blk. > + */ > +void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs) > +{ > + if (bs->blk == blk) { > + return; > + } > + > + assert(!blk->bs); > + assert(!bs->blk); Why is it useful to allow reconnecting a BDS to a BB it's already connected to? I would have expected that we can assert that this is not the case. > + bdrv_ref(bs); > + blk->bs = bs; > + bs->blk = blk; > +} My series to remove bdrv_swap() introduces a blk_set_bs() function, which looks suspiciously similar to this one, except that it allows passing a BB that already had a BDS (it gets unrefed then) and that I don't assert that the BDS isn't attached to a BB yet (I should do that). Do you think that's similar enough to have only one function? Kevin From MAILER-DAEMON Tue Sep 22 10:45:19 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeOop-0001VK-11 for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 10:45:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeOoj-0001SO-DR for qemu-block@nongnu.org; Tue, 22 Sep 2015 10:45:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeOog-0006v3-Md for qemu-block@nongnu.org; Tue, 22 Sep 2015 10:45:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeOog-0006uz-Ic; Tue, 22 Sep 2015 10:45:10 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 20A042F9108; Tue, 22 Sep 2015 14:45:10 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8MEj7mq009813; Tue, 22 Sep 2015 10:45:08 -0400 Date: Tue, 22 Sep 2015 16:45:07 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150922144507.GH3999@noname.str.redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 00/38] blockdev: BlockBackend and media X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 14:45:17 -0000 Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: > This series reworks a lot regarding BlockBackend and media. Basically, > it allows empty BlockBackends, that is BBs without a BDS tree. > > Before this series, empty drives are represented by a BlockBackend with > an empty BDS attached to it (a BDS with a NULL driver). However, now we > have BlockBackends, thus an empty drive should be represented by a > BlockBackend without any BDS tree attached to it. This is what this > series does. Patches 1-16 and 18: Reviewed-by: Kevin Wolf I had comments for 17 and 19-21, and can't seem to find a base commit that patch 22 applies cleanly to, so I'm stopping the review here, waiting for another rebase or instructions how to apply the series. Kevin From MAILER-DAEMON Tue Sep 22 11:00:20 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeP3M-0004xS-1O for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 11:00:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeP3F-0004l1-Se for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:00:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeP3E-0005RB-Im for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:00:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeP3E-0005Pu-9t; Tue, 22 Sep 2015 11:00:12 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 3462DC0A149C; Tue, 22 Sep 2015 15:00:11 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MF06K3022028 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 11:00:08 -0400 To: Kevin Wolf References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-18-git-send-email-mreitz@redhat.com> <20150922141701.GD3999@noname.str.redhat.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <56016CF5.8030709@redhat.com> Date: Tue, 22 Sep 2015 17:00:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150922141701.GD3999@noname.str.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="3QbPoTjU52kfNWSH4V2u2XaPIegnCp5JR" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 17/38] block: Add BlockBackendRootState X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 15:00:18 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --3QbPoTjU52kfNWSH4V2u2XaPIegnCp5JR Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 22.09.2015 16:17, Kevin Wolf wrote: > Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: >> This structure will store some of the state of the root BDS if the BDS= >> tree is removed, so that state can be restored once a new BDS tree is >> inserted. >=20 > This is magic that is bound to bite us sooner or later. I see that we > have to do this in order to maintain compatibility, but imagine we'll > have multiple BlockBackends sitting on top of the same BDS. They'll be > fighting for whose throttling settings are applied. With this approach,= > the winner is the BlockBackend that most recently went from no medium t= o > medium, which might just be the most surprising way to solve the > problem. Well, my first answer to this is that as far as I remember and as far as I can see right now, it's only qmp_blockdev_change_medium() that accesses this structure. This is effectively a legacy command, even though it is introduced by this series. When using the "atomic" operations, this structure will not be used. So let's examine what cases of multiple BBs on top of the same BDS we can have, that are relevant here: One of the BBs always has to be the BB belonging to a device such as a CD drive, otherwise we cannot invoke the change command. The other BB(s) can be either: (1) Also BBs belonging to CDD-like devices (let's call them "tray devices") (2) Other BBs such as block job BBs or NBD BBs In the first case, the scenario you described can indeed occur, but only if the user is indeed using the change command. I'm very much inclined to say it's the user's own fault for having multiple tray device BBs on top of a single BDS and managing them with the change command. In any case, with the current state of having throttling at the BDS level, we are guarenteed to break something, at least. In the second case, throttling will change for all the attached BBs whenever the BDS is inserted into a throttled tray device. This seems correct to me, at least as long as we have throttling on the BDS level. > I'll detail one aspect of the problem below. >=20 > The correct way to solve this seems to be that each BB has its own I/O > throttling filter. Actually, if we could lift the throttling code to > BlockBackend, that might solve the problem. So yes, as long as we have throttling on the BDS level, something may always break when having multiple BBs per BDS, because you'd probably want throttling to be on the BB level. But lifting that doesn't seem a trivial task, and I don't really know whether I want this in this series.= Especially considering that right now you cannot have multiple BBs per BD= S. All in all: Yes, before we allow multiple BBs per BDS we want throttling to be on the BB level. But this is nothing that should be done in or for this series, since right now we do not allow multiple BBs per BDS. > I guess the same applies for the other fields in BlockBackendRootState.= >=20 >> Signed-off-by: Max Reitz >> Reviewed-by: Eric Blake >> --- >> block/block-backend.c | 37 +++++++++++++++++++++++++++++++++= ++++ >> include/block/block_int.h | 10 ++++++++++ >> include/qemu/typedefs.h | 1 + >> include/sysemu/block-backend.h | 2 ++ >> 4 files changed, 50 insertions(+) >> >> diff --git a/block/block-backend.c b/block/block-backend.c >> index 1f2cd9b..9590be5 100644 >> --- a/block/block-backend.c >> +++ b/block/block-backend.c >> @@ -13,6 +13,7 @@ >> #include "sysemu/block-backend.h" >> #include "block/block_int.h" >> #include "block/blockjob.h" >> +#include "block/throttle-groups.h" >> #include "sysemu/blockdev.h" >> #include "sysemu/sysemu.h" >> #include "qapi-event.h" >> @@ -37,6 +38,10 @@ struct BlockBackend { >> /* the block size for which the guest device expects atomicity */= >> int guest_block_size; >> =20 >> + /* If the BDS tree is removed, some of its options are stored her= e (which >> + * can be used to restore those options in the new BDS on insert)= */ >> + BlockBackendRootState root_state; >> + >> /* I/O stats (display with "info blockstats"). */ >> BlockAcctStats stats; >> =20 >> @@ -161,6 +166,7 @@ static void blk_delete(BlockBackend *blk) >> bdrv_unref(blk->bs); >> blk->bs =3D NULL; >> } >> + g_free(blk->root_state.throttle_group_name); >> /* Avoid double-remove after blk_hide_on_behalf_of_hmp_drive_del(= ) */ >> if (blk->name[0]) { >> QTAILQ_REMOVE(&blk_backends, blk, link); >> @@ -1050,3 +1056,34 @@ int blk_probe_geometry(BlockBackend *blk, HDGeo= metry *geo) >> { >> return bdrv_probe_geometry(blk->bs, geo); >> } >> + >> +/* >> + * Updates the BlockBackendRootState object with data from the curren= tly >> + * attached BlockDriverState. >> + */ >> +void blk_update_root_state(BlockBackend *blk) >> +{ >> + assert(blk->bs); >> + >> + blk->root_state.open_flags =3D blk->bs->open_flags; >> + blk->root_state.read_only =3D blk->bs->read_only; >> + blk->root_state.detect_zeroes =3D blk->bs->detect_zeroes; >> + >> + blk->root_state.io_limits_enabled =3D blk->bs->io_limits_enabled;= >> + >> + g_free(blk->root_state.throttle_group_name); >> + if (blk->bs->throttle_state) { >> + throttle_get_config(blk->bs->throttle_state, >> + &blk->root_state.throttle_config); >> + blk->root_state.throttle_group_name =3D >> + g_strdup(throttle_group_get_name(blk->bs)); >=20 > The throttling group name is essentially a weak reference. I think > making it strong is worth considering. >=20 > If you attach a new BDS, if the old throttling group still exists, the > new BDS is re-added there, as expected. If the throttling group has got= > changed limits meanwhile, you need to choose whether to apply the limit= s > saved here or use the new limits for the BDS. I guess the latter will b= e > the correct choice. >=20 > If the old throttling group doesn't exist any more, a new one is create= d > with the old name and limits. If two BlockBackends eject their media at= > separate times and the throttle group goes away, reinstantiating the > throttle group by attaching a BDS to both BBs will use the config of th= e > BB that got a new medium first (as opposed to: the latest setting the > throttling group had before it was freed). >=20 > If the old throttling group was freed, but then a new throttling group > was created with the same name, we get attached to that new group with > its new limits. This could be slightly surprising as well. Yes, I'll see to making it a strong reference, and to fetching the throttle config from the throttle group (probably by using throttle_group_unregister_bs()+throttle_group_register_bs() consecutively in qmp_blockdev_change_medium(), and dropping BBRS.throttle_config). Max --3QbPoTjU52kfNWSH4V2u2XaPIegnCp5JR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAWz2AAoJEDuxQgLoOKytUdMH/1uEQvRhQNrXPumMK/PmH5S+ 4mAJiDSMfPkfqgH4vx3KrOx20eHViczqnW8EbraY10rUovaMFF5cQQc089C/+neY RZkpEr+gGIMvDb6P9U9igs8wJRJ8RFSLyEB0gStQKA7nfNI8Th7KzDfhty2PjUo9 h3S9qPOdMx6bMkVE1TNbDJfj3vozXZ+tysTPtHxohVhbW1IJWbGtYwnHPF0285u+ BTM1TGJorVRqp/3TyUibmsi6q10o8nbjUcwnptNppyHyBqPwa8gLo10NHmYi72Zq kHTmPo69FnjjAtt2KAfDcJYhZOIidBevxKI7br1quhZIROZ/fjsj2PV1INZxHBk= =9GFu -----END PGP SIGNATURE----- --3QbPoTjU52kfNWSH4V2u2XaPIegnCp5JR-- From MAILER-DAEMON Tue Sep 22 11:05:45 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeP8b-0007v2-GG for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 11:05:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeP8X-0007sT-M1 for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:05:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeP8R-0000AB-Po for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:05:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeP8R-0000A7-Gp; Tue, 22 Sep 2015 11:05:35 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id EBD948EA3B; Tue, 22 Sep 2015 15:05:34 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MF5UT2027338 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 11:05:32 -0400 To: Kevin Wolf References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-20-git-send-email-mreitz@redhat.com> <20150922143012.GE3999@noname.str.redhat.com> From: Max Reitz Message-ID: <56016E3A.1020702@redhat.com> Date: Tue, 22 Sep 2015 17:05:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150922143012.GE3999@noname.str.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="1rTGeOATLdoQS43UN3ocNhGmNaqwGcPhH" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 19/38] block: Fail requests to empty BlockBackend X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 15:05:43 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --1rTGeOATLdoQS43UN3ocNhGmNaqwGcPhH Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 22.09.2015 16:30, Kevin Wolf wrote: > Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: >> If there is no BlockDriverState in a BlockBackend or if the tray of th= e >> guest device is open, fail all requests (where that is possible) with >> -ENOMEDIUM. >> >> The reason the status of the guest device is taken into account is >> because once the guest device's tray is opened, any request on the sam= e >> BlockBackend as the guest uses should fail. If the BDS tree is suppose= d >> to be usable even after ejecting it from the guest, a different >> BlockBackend must be used. >> >> Signed-off-by: Max Reitz >> Reviewed-by: Eric Blake >=20 > Do we want to include blk_drain() to make it a no-op instead of > crashing? Yes, we do, so that would be in patch 20. Thanks for catching that. > Also, we're now introducing BlockAIOCBs with a NULL bs with your use of= > abort_aio_request. I haven't carefully reviewed the implications of thi= s > yet, but that should definitely be done before we merge the series. That should be patch 12. Max --1rTGeOATLdoQS43UN3ocNhGmNaqwGcPhH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAW46AAoJEDuxQgLoOKytD78H/R0WA4oh+JHgKRrXqqEolbop Jc8A/s3xhRTFEf6NDRk4+TGUNS5XrzSIu+20CkZZF1qechDLcqbmY7YQjcgpWsEb pg5+Mo/7ViGo+45V/Igsb9CeOhPYdBx6+F4TP9j+wkq9vC4F2iJB/5FNqcKxdiKZ Xc0SD9JXaSJie4Sj7DEy5IHgKTKY8W4hmA1kZEgU35bzRw0ghfdgIGeKxCuGkTHQ YqOi+94OYAaRJ/QuqZnT2U6ykASdXMT41QkRG5ehQsldAh5yMtGTGuRc4v5oFQjM S1+fIwCF083JW6/wrb64v92Aux8R3hMUcU60/0CZ2LWgUwgxW8E368KQ5v980oU= =hB8T -----END PGP SIGNATURE----- --1rTGeOATLdoQS43UN3ocNhGmNaqwGcPhH-- From MAILER-DAEMON Tue Sep 22 11:07:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZePAH-0002DG-2P for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 11:07:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePAE-00029G-MP for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:07:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZePA9-00017i-2h for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:07:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37300) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePA8-00017W-ST; Tue, 22 Sep 2015 11:07:21 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 7A608AA8; Tue, 22 Sep 2015 15:07:20 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8MF7IZK029510; Tue, 22 Sep 2015 11:07:19 -0400 Date: Tue, 22 Sep 2015 17:07:18 +0200 From: Kevin Wolf To: Guangmu Zhu <516009461@qq.com> Message-ID: <20150922150718.GI3999@noname.str.redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: famz@redhat.com, qemu-devel , qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] No error report when using the qemu-img.exe to convert a disk to vmdk format which is saved on a disk that has no more space X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 15:07:28 -0000 Am 22.09.2015 um 08:09 hat Guangmu Zhu geschrieben: > I used the qemu-img.exe to convert a disk to vmdk format and the output file > size could be 300 MB. However the left space of the disk the output file > located on was about 200 MB. After a while, the left space had been zero but > the program didn't stop or report any error. It was just going on as normal. > > I read the source code and found the error report was controlled by > "BlockdevOnError on_read_error, on_write_error" in "struct BlockDriverState", > which had the default value "BLOCKDEV_ON_ERROR_REPORT" for "on_read_error" and > "BLOCKDEV_ON_ERROR_ENOSPC" for "on_writer_error". The qemu-img.exe had no > option to change the default behavior of the error report. > > So I think if there were some ways to change the default value of the error > report, it might be better. Further more, I suggest we could just add some > codes to the "img_convert" function: > > 1827: out_blk = img_open("target", out_filename, out_fmt, flags, true, > quiet); > 1828: if (!out_blk) { > 1829: ret = -1; > 1830: goto out; > 1831: } > 1832: out_bs = blk_bs(out_blk); > ++ 1833: > ++ 1834: bdrv_set_on_error > (out_bs, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT); This shouldn't make any difference for qemu-img. The error handling mode is only for emulated devices in qemu proper. It looks more like VMDK is somehow failing to report an error at all whn it's running out of free disk space (though I couldn't spot an error in the code at first sight). Kevin From MAILER-DAEMON Tue Sep 22 11:07:37 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZePAP-0002Qg-4d for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 11:07:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePAL-0002Ki-C7 for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:07:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZePAF-0001BG-QH for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:07:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51534) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePAF-0001B4-Io; Tue, 22 Sep 2015 11:07:27 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 2F48514AAA; Tue, 22 Sep 2015 15:07:27 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MF7NtE013610 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 11:07:24 -0400 To: Kevin Wolf References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-21-git-send-email-mreitz@redhat.com> <20150922143551.GF3999@noname.str.redhat.com> From: Max Reitz Message-ID: <56016EAA.4030509@redhat.com> Date: Tue, 22 Sep 2015 17:07:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150922143551.GF3999@noname.str.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Baw5f1Uau9wVA09P9fUS2VLdJU8NPS2f6" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 20/38] block: Prepare remaining BB functions for NULL BDS X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 15:07:34 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Baw5f1Uau9wVA09P9fUS2VLdJU8NPS2f6 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 22.09.2015 16:35, Kevin Wolf wrote: > Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: >> There are several BlockBackend functions which, in theory, cannot fail= =2E >> This patch makes them cope with the BlockDriverState pointer being NUL= L >> by making them fall back to some default action like ignoring the valu= e >> in setters and returning the default in getters. >> >> Signed-off-by: Max Reitz >> Reviewed-by: Eric Blake >=20 > Hm, okay, maybe bdrv_drain() belongs here. I just reviewed the end > result for completeness and didn't check which patch did what. >=20 >> int blk_enable_write_cache(BlockBackend *blk) >> { >> + if (!blk->bs) { >> + return 0; >> + } >> + >> return bdrv_enable_write_cache(blk->bs); >> } >> =20 >> void blk_set_enable_write_cache(BlockBackend *blk, bool wce) >> { >> - bdrv_set_enable_write_cache(blk->bs, wce); >> + if (blk->bs) { >> + bdrv_set_enable_write_cache(blk->bs, wce); >> + } >> } >=20 > WCE is part of the open_flags in BlockBackendRootState. The root state > doesn't seem to be used yet, and I wrote about my concerns about it in > reply to an earlier patch, but as long as we have it, should this > query/modify the root state if no BDS is attached? Seems very reasonable, will do. Max --Baw5f1Uau9wVA09P9fUS2VLdJU8NPS2f6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAW6qAAoJEDuxQgLoOKyt7wcIAKNrTK0crTT71ubqSRxs3Z6q c/CAWw4PeCaQlRW/iC/bdnzI3O3n1e1O7ET/v9k7sCobO0Ycz/inc73V26Q0VK3V OJa/v2ZwXvFydEd9hxzBYxj8zyIFfgWO/EuMa8htRqq+GfKcLH6klZyK3yKu9a0e 2DWIDqpV1MpHiQcuZa+YM1Unj9WHSjuupL+76qDbr3Jted7/G2ABuG9skoGXA8En QszacA56j7jzyDuagsYVojKKBKS/BOD2Li1FcdonYN5ZDFn1usZp2T75RhwlyoUQ b301eeGklO4tKrmG2Ap40/++np+oSH/x8m8aWb7cUzRs8waXhc3xmvwSTLiEe+8= =Ea9p -----END PGP SIGNATURE----- --Baw5f1Uau9wVA09P9fUS2VLdJU8NPS2f6-- From MAILER-DAEMON Tue Sep 22 11:09:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZePCC-0005rv-40 for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 11:09:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePC6-0005hh-Jk for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:09:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZePC1-0001lT-1n for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:09:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35826) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePC0-0001lM-TC; Tue, 22 Sep 2015 11:09:16 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 7B222C0B91A8; Tue, 22 Sep 2015 15:09:16 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MF9CVY015829 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 11:09:13 -0400 To: Kevin Wolf References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <20150922144507.GH3999@noname.str.redhat.com> From: Max Reitz Message-ID: <56016F18.3030208@redhat.com> Date: Tue, 22 Sep 2015 17:09:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150922144507.GH3999@noname.str.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="K6FmgcaKjb3bBWdAgLaaeT82iFLFgoNdw" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 00/38] blockdev: BlockBackend and media X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 15:09:26 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --K6FmgcaKjb3bBWdAgLaaeT82iFLFgoNdw Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 22.09.2015 16:45, Kevin Wolf wrote: > Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: >> This series reworks a lot regarding BlockBackend and media. Basically,= >> it allows empty BlockBackends, that is BBs without a BDS tree. >> >> Before this series, empty drives are represented by a BlockBackend wit= h >> an empty BDS attached to it (a BDS with a NULL driver). However, now w= e >> have BlockBackends, thus an empty drive should be represented by a >> BlockBackend without any BDS tree attached to it. This is what this >> series does. >=20 > Patches 1-16 and 18: Reviewed-by: Kevin Wolf >=20 > I had comments for 17 and 19-21, and can't seem to find a base commit > that patch 22 applies cleanly to, so I'm stopping the review here, > waiting for another rebase or instructions how to apply the series. 16a1b6e97c2a2919fd296db4bea2f9da2ad3cc4d was my base, if that was the question. ;-) Thanks for reviewing! Max --K6FmgcaKjb3bBWdAgLaaeT82iFLFgoNdw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAW8YAAoJEDuxQgLoOKyttr0IAIQ5VNk5XqVjuQSMMHCryYHe OUntyfSc7aGNKq3qXrkSdhSXQcKHHHhZhKCdhSEuECANz7Wl/XQFpz+jevZtrK4A QnQPkymVSV3wz14TvZstvXSlpzTFyIo6J9p3YfXLcCW0L+BjA3NcYaP9EYzFfeS6 N8lJT85BqAgQK3gGWgCPcCC8tcaO6BkNMN7IG0v5t/i3w+LhGQKWT7JCe8ur8peR 1fuGwKjt/12PRhFPUP/NQ3FqaH4wGbKx7/QPMTdfnq5JLUQgDMzDSFIQQPmcQAS6 bhmuOF/Ec9esFQv1SFhfE4yTjRRijVZbQ1g8X6ho83NeeyAKoxRAKD+FdVNdpdo= =PkNx -----END PGP SIGNATURE----- --K6FmgcaKjb3bBWdAgLaaeT82iFLFgoNdw-- From MAILER-DAEMON Tue Sep 22 11:13:15 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZePFq-0004Di-RK for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 11:13:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePFk-00041f-Vw for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:13:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZePFh-0003Es-Gv for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:13:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32824) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePFh-0003Ek-BG; Tue, 22 Sep 2015 11:13:05 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id EB675C0F05DF; Tue, 22 Sep 2015 15:13:03 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8MFD1Lj007846; Tue, 22 Sep 2015 11:13:02 -0400 Date: Tue, 22 Sep 2015 17:13:01 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150922151301.GJ3999@noname.str.redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-20-git-send-email-mreitz@redhat.com> <20150922143012.GE3999@noname.str.redhat.com> <56016E3A.1020702@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="LQksG6bCIzRHxTLp" Content-Disposition: inline In-Reply-To: <56016E3A.1020702@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 19/38] block: Fail requests to empty BlockBackend X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 15:13:13 -0000 --LQksG6bCIzRHxTLp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 22.09.2015 um 17:05 hat Max Reitz geschrieben: > On 22.09.2015 16:30, Kevin Wolf wrote: > > Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: > >> If there is no BlockDriverState in a BlockBackend or if the tray of the > >> guest device is open, fail all requests (where that is possible) with > >> -ENOMEDIUM. > >> > >> The reason the status of the guest device is taken into account is > >> because once the guest device's tray is opened, any request on the same > >> BlockBackend as the guest uses should fail. If the BDS tree is supposed > >> to be usable even after ejecting it from the guest, a different > >> BlockBackend must be used. > >> > >> Signed-off-by: Max Reitz > >> Reviewed-by: Eric Blake > >=20 > > Do we want to include blk_drain() to make it a no-op instead of > > crashing? >=20 > Yes, we do, so that would be in patch 20. Thanks for catching that. >=20 > > Also, we're now introducing BlockAIOCBs with a NULL bs with your use of > > abort_aio_request. I haven't carefully reviewed the implications of this > > yet, but that should definitely be done before we merge the series. >=20 > That should be patch 12. Yes, you caught me reviewing just correctness, but not completeness of patch 12. Kevin --LQksG6bCIzRHxTLp Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJWAW/9AAoJEH8JsnLIjy/WqZgP/iA7B4gOmjZa5XpfzURuAyJ5 sHbds3yZAXzlffI8LDA7MscY5ugd+hm0IFzRfl1HfngyPdsCXCTkMufs+H4GImHs vQ/kBpsFJjxwFtDmrAU86z1jl/f7i6CT/K9Wk+DsPlxQ2L1+hhLO0h4TkOYjDcyK zdi3uW9h9DLSiJI7tx5RexKh6asG37TE8Hk31GsScreWThpRnIStrk6o9IlmD/QP Ii/9u/CeC/L5pl5FokJLWtD1Hg6Gp6k5NpILa7JiqUp0bJ8cptGSXgeGlTMh/rHA xOcDzc+qUI4E7y/Zd4ERP9sWHutJnp8jUTz2GNvDDbR4gZ71su9z8AInPTzbV7y8 Otcg/xYjk71hxkzc4fpPh3vx5vGwMP/QVL1VFdvpxtWbQEGLAju+KVHohsgIvxaJ Z7rfjnVJBMcaUwWD24i9H4QT1bDcuuTCijn2GQBS+2cpgYdi9cw0enaMr9Da8sqn Sb9I2Gr0zvuqP2Yvfe93HGRDVFVKLlZ2g1Ub28m8/4lXdH2J9YJaF1/pNtguxgCx 82bgK07O8jcoG/emYtixn0e9/J2BQ09mZRwcJWvkqdxMwCfZ61nXmNGn1o03yN2S COyFw1bBgf9ob1JMm3X/TMSvYpl7A1lKIppL/PTBnjx02r9vdwNekuJuVyPrgDE4 dpoqe329MQeQFRpH/ntl =l7Ds -----END PGP SIGNATURE----- --LQksG6bCIzRHxTLp-- From MAILER-DAEMON Tue Sep 22 11:20:36 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZePMx-0008Dg-RN for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 11:20:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePMr-00082Z-QH for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:20:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZePMq-0007nS-U8 for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:20:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39804) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePMq-0007mh-N1; Tue, 22 Sep 2015 11:20:28 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id EB8D1C0B2B49; Tue, 22 Sep 2015 15:20:27 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MFKNi2008797 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 11:20:25 -0400 To: Kevin Wolf References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-22-git-send-email-mreitz@redhat.com> <20150922144229.GG3999@noname.str.redhat.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <560171B7.1080901@redhat.com> Date: Tue, 22 Sep 2015 17:20:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150922144229.GG3999@noname.str.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gQjJuIGuNwpf1FEkirs3sCPoK9qLrcIMb" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wen Congyang , qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 21/38] block: Add blk_insert_bs() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 15:20:34 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --gQjJuIGuNwpf1FEkirs3sCPoK9qLrcIMb Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 22.09.2015 16:42, Kevin Wolf wrote: > Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: >> This function associates the given BlockDriverState with the given >> BlockBackend. >> >> Signed-off-by: Max Reitz >> Reviewed-by: Eric Blake >> Reviewed-by: Alberto Garcia >> --- >> block/block-backend.c | 16 ++++++++++++++++ >> include/sysemu/block-backend.h | 1 + >> 2 files changed, 17 insertions(+) >> >> diff --git a/block/block-backend.c b/block/block-backend.c >> index 33145f8..652385e 100644 >> --- a/block/block-backend.c >> +++ b/block/block-backend.c >> @@ -314,6 +314,22 @@ void blk_hide_on_behalf_of_hmp_drive_del(BlockBac= kend *blk) >> } >> =20 >> /* >> + * Associates a new BlockDriverState with @blk. >> + */ >> +void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs) >> +{ >> + if (bs->blk =3D=3D blk) { >> + return; >> + } >> + >> + assert(!blk->bs); >> + assert(!bs->blk); >=20 > Why is it useful to allow reconnecting a BDS to a BB it's already > connected to? I would have expected that we can assert that this is not= > the case. We can do that, too, there is no use case. It's just that I in principle don't like making things an error that do make sense and can trivially be handled gracefully. But I can see people wanting to hit an assertion as soon as something looks fishy. So I'm fine either way. I think Eric asked about the same before, so that makes two against one now. :-) >> + bdrv_ref(bs); >> + blk->bs =3D bs; >> + bs->blk =3D blk; >> +} >=20 > My series to remove bdrv_swap() introduces a blk_set_bs() function, > which looks suspiciously similar to this one, except that it allows > passing a BB that already had a BDS (it gets unrefed then) and that I > don't assert that the BDS isn't attached to a BB yet (I should do that)= =2E >=20 > Do you think that's similar enough to have only one function? Well, yours looks like blk_remove_bs()+blk_insert_bs() combined. In case we have called blk_remove_bs() before, it will effectively be the same, yes. But that difference still bothers me a bit... I'd prefer implementing blk_set_bs() by calling blk_remove_bs() and then blk_insert_bs() instead, but since these functions are not available in your bdrv_swap() series, that would prove rather difficult. I don't know. Maybe implement it separately for now, and trust that this series will stay in flight long enough for the bdrv_swap() series to get merged so I can include a commit cleaning up blk_set_bs() in this series later on? Or I can base this series on your bdrv_swap() series. Your call, as I haven't looked at it yet and thus don't know how long it'll take to get merged (albeit judging from your series in the past, it won't be too long= ). Max --gQjJuIGuNwpf1FEkirs3sCPoK9qLrcIMb Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAXG3AAoJEDuxQgLoOKytihoH/2gTkcuYoXni8JtZyZGS1Sdf QcQ+h02KX1WErkw5xp9ReRMmVoim/KfBFEk3j21CCccdQpNo7ppfRNJs9XhUAZB8 3mRcGc3OhmORA8j169eOYePK4iTLRk1ITywTLdDtpzx72powiQR040DxdY0TSWHo 1ExJm7odf+ufmOUyJ8ZwVNBFLddz9wlapujrAtt536z3Ou0i5b6Km+G70alvxhdc Z+A6HSQtjWILfIT6gWQ48BYAdB7LYcyd38yrhrF1ZUX1rFHImY4RI/sL7XW2pMjZ NeOIRJJdPzjBzOeFBB/Fi7ZyEdUnG0k1AXQIUuGBnaAX3jPAG9Gheht27t42aQU= =C6we -----END PGP SIGNATURE----- --gQjJuIGuNwpf1FEkirs3sCPoK9qLrcIMb-- From MAILER-DAEMON Tue Sep 22 11:23:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZePPf-0004TY-7F for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 11:23:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePPc-0004OF-Im for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:23:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZePPX-0000pr-JI for qemu-block@nongnu.org; Tue, 22 Sep 2015 11:23:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZePPX-0000ph-FF; Tue, 22 Sep 2015 11:23:15 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 206FF461D8; Tue, 22 Sep 2015 15:23:15 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8MFNDjp006647; Tue, 22 Sep 2015 11:23:14 -0400 Date: Tue, 22 Sep 2015 17:23:13 +0200 From: Kevin Wolf To: Markus Armbruster Message-ID: <20150922152313.GK3999@noname.str.redhat.com> References: <1442582574-14275-1-git-send-email-armbru@redhat.com> <1442582574-14275-3-git-send-email-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442582574-14275-3-git-send-email-armbru@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PULL 2/8] hmp: Allow for error message hints on HMP X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 15:23:21 -0000 Am 18.09.2015 um 15:22 hat Markus Armbruster geschrieben: > From: Eric Blake > > Commits 7216ae3d and d2828429 disabled some error message hints, > all because a change to use modern error reporting meant that the > hint would be output prior to the actual error. Fix this by making > hints a first-class member of Error. > > For example, we are now back to the pleasant: > > $ qemu-system-x86_64 --nodefaults -S --vnc :0 --chardev null,id=, > qemu-system-x86_64: --chardev null,id=,: Parameter 'id' expects an identifier > Identifiers consist of letters, digits, '-', '.', '_', starting with a letter. > > Signed-off-by: Eric Blake > Reviewed-by: Paolo Bonzini > Message-Id: <1441901956-21991-1-git-send-email-eblake@redhat.com> > Signed-off-by: Markus Armbruster This broke qemu-iotests 049. Can you please send a patch to update the reference output? Kevin --- /home/kwolf/source/qemu/tests/qemu-iotests/049.out 2015-09-14 13:44:45.347890767 +0200 +++ 049.out.bad 2015-09-22 17:20:50.131625409 +0200 @@ -118,6 +118,7 @@ qemu-img create -f qcow2 -o size=foobar TEST_DIR/t.qcow2 qemu-img: Parameter 'size' expects a size +You may use k, M, G or T suffixes for kilobytes, megabytes, gigabytes and terabytes. qemu-img: TEST_DIR/t.qcow2: Invalid options for file format 'qcow2' == Check correct interpretation of suffixes for cluster size == From MAILER-DAEMON Tue Sep 22 12:07:39 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeQ6V-000199-8D for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 12:07:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56650) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeQ6S-000166-Ra for qemu-block@nongnu.org; Tue, 22 Sep 2015 12:07:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeQ6O-0004wa-DV for qemu-block@nongnu.org; Tue, 22 Sep 2015 12:07:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54381) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeQ6O-0004vW-6s; Tue, 22 Sep 2015 12:07:32 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 4073EC0B918B; Tue, 22 Sep 2015 16:07:31 +0000 (UTC) Received: from [10.3.113.166] (ovpn-113-166.phx2.redhat.com [10.3.113.166]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MG7Tp3030040; Tue, 22 Sep 2015 12:07:29 -0400 To: Stefan Hajnoczi , Peter Lieven References: <1435047135-31647-1-git-send-email-pl@kamp.de> <20150625131806.GG4419@stefanha-thinkpad.redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <56017CC0.5010301@redhat.com> Date: Tue, 22 Sep 2015 10:07:28 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150625131806.GG4419@stefanha-thinkpad.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ffvaqp9t2Ku72IswNtFBxhQxkVJxU17jN" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, ronniesahlberg@gmail.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH] block/nfs: add support for setting debug level X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 16:07:37 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ffvaqp9t2Ku72IswNtFBxhQxkVJxU17jN Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/25/2015 07:18 AM, Stefan Hajnoczi wrote: > On Tue, Jun 23, 2015 at 10:12:15AM +0200, Peter Lieven wrote: >> upcoming libnfs versions will support logging debug messages. Add >> support for it in qemu through an URL parameter. >> >> Signed-off-by: Peter Lieven >> --- >> block/nfs.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >=20 > Untrusted users may be able to set these options since they are encoded= > in the URI. I'm imagining a hosting or cloud scenario like OpenStack. >=20 > A verbose debug level spams stderr and could consume a lot of disk > space. >=20 > (The uid and gid options are probably okay since the NFS server cannot > trust the uid/gid coming from QEMU anyway.) >=20 > I think we can merge this patch for QEMU 2.4 but I'd like to have a > discussion about the security risk of encoding libnfs options in the > URI. >=20 > CCed Eric Blake in case libvirt is affected. Libvirt doesn't (yet) support XML describing debug parameters, and its current XML does not let the user specify a raw URL, but rather the individual pieces that libvirt then concatenates into the URL. Basically, libvirt already uses a structured request, the way we eventually want working for QMP blockdev-add for NFS images, with all features broken into individual parameters within the struct rather than a URL. So from that perspective, I don't think exposing a debug parameter in the NFS URL will hurt libvirt, but it doesn't answer whether you'd have a security (log-filling) issue for uses of the URL outside of libvirt. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ffvaqp9t2Ku72IswNtFBxhQxkVJxU17jN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWAXzAAAoJEKeha0olJ0NqKXcH/2wKUL3bly5UclRmEwB/2y6b GuzeuHxQV/4zSJpB01sfB8acaD5LCfMiWLQs8xIAp3hRYo8TUyuAIjRvUnSyWq0p tq+RyWancPOGZBszkL7c2HqxXi6MIqpirEIQGpM4e7nb381iGG0noQPNe8ZhYV/a BFWRNJixwEwQz4/F1bBiO7mxjjwDUJcT+N54A+W6TZbQ+w7GHX+wwK4EhGSk0MzM uKZe/2uLCzMbSDWViSij7AFE78whDNU/6lzrtkVtXT3A6pAD3TP6Dc+GMPOONtIt QTOpYSY0u4ZsuIFBg0eY9fa1zjOXEU++KssHZEfwS7OyyOxK4kuTE6mpaPN+zn0= =N+k0 -----END PGP SIGNATURE----- --ffvaqp9t2Ku72IswNtFBxhQxkVJxU17jN-- From MAILER-DAEMON Tue Sep 22 12:38:37 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeQaT-0004VG-IQ for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 12:38:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeQaR-0004V7-Nz for qemu-block@nongnu.org; Tue, 22 Sep 2015 12:38:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeQaO-0007hw-Dj for qemu-block@nongnu.org; Tue, 22 Sep 2015 12:38:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51333) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeQaO-0007hb-6j; Tue, 22 Sep 2015 12:38:32 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id E0ED75BA36; Tue, 22 Sep 2015 16:38:31 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MGcSTT018212 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 12:38:29 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <8cc989a360a5fe38839144946c878fb9f8c6a6d5.1442928283.git.berto@igalia.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <56018403.5040209@redhat.com> Date: Tue, 22 Sep 2015 18:38:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <8cc989a360a5fe38839144946c878fb9f8c6a6d5.1442928283.git.berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="r0cg7pfha9npPdweUvs2QIe8nF6lK8AtX" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v6 3/4] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 16:38:36 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --r0cg7pfha9npPdweUvs2QIe8nF6lK8AtX Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 22.09.2015 15:28, Alberto Garcia wrote: > One of the limitations of the 'blockdev-snapshot-sync' command is that > it does not allow passing BlockdevOptions to the newly created > snapshots, so they are always opened using the default values. >=20 > Extending the command to allow passing options is not a practical > solution because there is overlap between those options and some of > the existing parameters of the command. >=20 > This patch introduces a new 'blockdev-snapshot' command with a simpler > interface: it just takes two references to existing block devices that > will be used as the source and target for the snapshot. >=20 > Since the main difference between the two commands is that one of them > creates and opens the target image, while the other uses an already > opened one, the bulk of the implementation is shared. >=20 > Signed-off-by: Alberto Garcia > Cc: Eric Blake > Cc: Max Reitz > --- > blockdev.c | 163 ++++++++++++++++++++++++++++++++-----------= -------- > qapi-schema.json | 2 + > qapi/block-core.json | 28 +++++++++ > qmp-commands.hx | 38 ++++++++++++ > 4 files changed, 171 insertions(+), 60 deletions(-) >=20 [snip] > diff --git a/qmp-commands.hx b/qmp-commands.hx > index 495670b..e5bd0e0 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -1454,6 +1454,44 @@ Example: > EQMP > =20 > { > + .name =3D "blockdev-snapshot", > + .args_type =3D "node:s,overlay:s", > + .mhandler.cmd_new =3D qmp_marshal_input_blockdev_snapshot, As of 7fad30f06eb6aa57aaa8f3d264288f24ae7646f0, this needs to be qmp_marshal_blockdev_snapshot. > + }, > + > +SQMP > +blockdev-snapshot > +----------------- > +Since 2.5 > + > +Create a snapshot, by installing 'node' as the backing image of > +'overlay'. Additionally, if 'node' is associated with a block > +device, the block device changes to using 'overlay' as its new active > +image. > + > +Arguments: > + > +- "node": device that will have a snapshot created (json-string) > +- "overlay": device that will have 'node' as its backing image (json-s= tring) > + > +Example: > + > +-> { "execute": "blockdev-add", > + "arguments": { "options": { "driver": "qcow2", > + "node-name": "node1534", > + "file": { "driver": "file"= , > + "filename": "hd1= =2Eqcow2" }, > + "backing": "" } } } > + > +<- { "return": {} } > + > +-> { "execute": "blockdev-snapshot", "arguments": { "node": "ide-hd0",= > + "overlay": "node15= 34" } } > +<- { "return": {} } > + > +EQMP > + > + { > .name =3D "blockdev-snapshot-internal-sync", > .args_type =3D "device:B,name:s", > .mhandler.cmd_new =3D qmp_marshal_input_blockdev_snapshot_inte= rnal_sync, Consequently, this context needs to be fixed up, too. With that changed: Reviewed-by: Max Reitz --r0cg7pfha9npPdweUvs2QIe8nF6lK8AtX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAYQDAAoJEDuxQgLoOKytBmMIAIxQy0sQRS4OafS/Z1MZlFGq cZcPCSXK119wnhXA5zL8SIh66AmViDQmKlj+RYQYjHDfBUne8HKIY9FDraA6Egdi j6786C2gUzlaeS+QJtnzZkSnKdo5F5DR6zWHsxVU7ihi553JE21TdqoLDkZeSXh/ kQgLeIfzoK98XMS2/2AuOe292A0BD42mrLUVx95clRrPidixx9MrOuio9VR+Zg8y Lw84P8QoHB/DIR84doCAXn5HF0hP9MDUmWPIv9BeZ1Dpe9n+zVrawtR35Afcu/5b ng/U5y/ggRBYwt8Z6L7PI4734IG9HxU4p/adVxGhZnR3wU1u9QFJ60rH1Wzo/Ws= =wlYK -----END PGP SIGNATURE----- --r0cg7pfha9npPdweUvs2QIe8nF6lK8AtX-- From MAILER-DAEMON Tue Sep 22 12:55:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeQqM-0007C0-19 for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 12:55:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeQqJ-0007BY-Sw for qemu-block@nongnu.org; Tue, 22 Sep 2015 12:55:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeQqH-0007dl-74 for qemu-block@nongnu.org; Tue, 22 Sep 2015 12:54:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54862) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeQqH-0007dT-21; Tue, 22 Sep 2015 12:54:57 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 2815A461D3; Tue, 22 Sep 2015 16:54:56 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MGsq25016500 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 12:54:54 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: From: Max Reitz Message-ID: <560187DC.6050009@redhat.com> Date: Tue, 22 Sep 2015 18:54:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="LfKPkBeuCGEIphRFPnMkd58HE6K1mluAi" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v6 4/4] block: add tests for the 'blockdev-snapshot' command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 16:55:00 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --LfKPkBeuCGEIphRFPnMkd58HE6K1mluAi Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 22.09.2015 15:28, Alberto Garcia wrote: > Signed-off-by: Alberto Garcia > Cc: Max Reitz > --- > tests/qemu-iotests/085 | 102 +++++++++++++++++++++++++++++++++++++= +++++--- > tests/qemu-iotests/085.out | 34 ++++++++++++++- > 2 files changed, 128 insertions(+), 8 deletions(-) Reviewed-by: Max Reitz --LfKPkBeuCGEIphRFPnMkd58HE6K1mluAi Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAYfcAAoJEDuxQgLoOKythMEH/2rhAIGH+I3a/TBde4P8dwBu mN/1636245eAx5DMu437TOMPJhxc14IQAMywuClsB+q6qRi4O/GJ+VvNO+X1nZ2S IAvIT4rqTRKJYsshXTuuKOzkKoUQ/4xlH9DKE5uKQNYRgVbQ7Yge0WP/glJllVUo kSUbU6e7zZjKT2yijzQp/v6jFNyCsoD6Juw6SQQr3f9/2JKz1HtZn20/h4OB+/7E ewDd1/8U3RqiUTX6hkBf65mOF3qvdBRQjgeE5nmM2uve+Fo2JkHCpiFv7qdZOXus SInk1zcTatWV6TJIXo8PEYOwcG9YBI6KyW8ccVZ8rm9CNs/peSaL2Xrpb974NIM= =6w4B -----END PGP SIGNATURE----- --LfKPkBeuCGEIphRFPnMkd58HE6K1mluAi-- From MAILER-DAEMON Tue Sep 22 13:02:56 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeQy0-0000bV-Cy for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 13:02:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeQxy-0000aR-EE for qemu-block@nongnu.org; Tue, 22 Sep 2015 13:02:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeQxv-0003U1-3Z for qemu-block@nongnu.org; Tue, 22 Sep 2015 13:02:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38241) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeQxu-0003Tr-Vd; Tue, 22 Sep 2015 13:02:51 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 5C4E267; Tue, 22 Sep 2015 17:02:50 +0000 (UTC) Received: from [10.3.113.166] (ovpn-113-166.phx2.redhat.com [10.3.113.166]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MH2n8R010918; Tue, 22 Sep 2015 13:02:49 -0400 To: Kevin Wolf , Markus Armbruster References: <1442582574-14275-1-git-send-email-armbru@redhat.com> <1442582574-14275-3-git-send-email-armbru@redhat.com> <20150922152313.GK3999@noname.str.redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <560189B3.6060602@redhat.com> Date: Tue, 22 Sep 2015 11:02:43 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150922152313.GK3999@noname.str.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gVlrF463qaBCDPjXiUd5IwePK2F8XA3d6" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PULL 2/8] hmp: Allow for error message hints on HMP X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 17:02:55 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --gVlrF463qaBCDPjXiUd5IwePK2F8XA3d6 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/22/2015 09:23 AM, Kevin Wolf wrote: > Am 18.09.2015 um 15:22 hat Markus Armbruster geschrieben: >> From: Eric Blake >> >> Commits 7216ae3d and d2828429 disabled some error message hints, >> all because a change to use modern error reporting meant that the >> hint would be output prior to the actual error. Fix this by making >> hints a first-class member of Error. >> >> For example, we are now back to the pleasant: >> >> $ qemu-system-x86_64 --nodefaults -S --vnc :0 --chardev null,id=3D, >> qemu-system-x86_64: --chardev null,id=3D,: Parameter 'id' expects an = identifier >> Identifiers consist of letters, digits, '-', '.', '_', starting with = a letter. >> >> Signed-off-by: Eric Blake >> Reviewed-by: Paolo Bonzini >> Message-Id: <1441901956-21991-1-git-send-email-eblake@redhat.com> >> Signed-off-by: Markus Armbruster >=20 > This broke qemu-iotests 049. Can you please send a patch to update the > reference output? Will do (and I guess I should run qemu-iotests more frequently. Does 'make check' suffice, or is there other magic involved?) --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --gVlrF463qaBCDPjXiUd5IwePK2F8XA3d6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWAYmzAAoJEKeha0olJ0Nq1jMIAJYiEcmqTEtv2Wzggc+yPDZI 6+NA3uEz2JADmUTP0gZ4AYw6VuibGa36AsFmUZLPXrU22mItd5+OJoJADIX/SWUn DD79Pcdsh1u1nulx7uPubtc8fXOfrAH6nZdPkCnZebThVnyILkRyw9olF2jhX8Og mjP6o26i9AJuJLlCnC6H9i6Fj4htdBADlOMAn63rEvWHRU7+5Lbtzb9XD0w49NoN gv5Mlttr10T78wUUICjeppYUSVFo0e5g2AEnZvXomylm21P4v9WZw/6+5jdf5C2Z UvIBqmMFi5/XYASvWphY7455+XfEE8aGXR7t5HYJ+sE8GAUBCxiLpJ5edhY6JZo= =SBPR -----END PGP SIGNATURE----- --gVlrF463qaBCDPjXiUd5IwePK2F8XA3d6-- From MAILER-DAEMON Tue Sep 22 13:14:57 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeR9d-00055p-0q for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 13:14:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeR9a-00054V-7S for qemu-block@nongnu.org; Tue, 22 Sep 2015 13:14:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeR9V-0002so-4m for qemu-block@nongnu.org; Tue, 22 Sep 2015 13:14:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeR9U-0002sX-UQ; Tue, 22 Sep 2015 13:14:49 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id E4901C0B918B; Tue, 22 Sep 2015 17:14:47 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MHEiST021529 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 13:14:45 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-2-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <56018C83.7030207@redhat.com> Date: Tue, 22 Sep 2015 19:14:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-2-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="CxlJblndVkDEkDfK4CnUCfWUK1bMpNH2t" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 01/16] block: Introduce BDS.file_child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 17:14:55 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --CxlJblndVkDEkDfK4CnUCfWUK1bMpNH2t Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > Store the BdrvChild for bs->file. At this point, bs->file_child->bs jus= t > duplicates the bs->file pointer. Later, it will completely replace it. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 12 +++++++++--- > include/block/block_int.h | 1 + > 2 files changed, 10 insertions(+), 3 deletions(-) Reviewed-by: Max Reitz Although I have a small comment below: >=20 > diff --git a/block.c b/block.c > index 6268e37..2e9e5e2 100644 > --- a/block.c > +++ b/block.c > @@ -1487,11 +1487,17 @@ static int bdrv_open_inherit(BlockDriverState *= *pbs, const char *filename, > =20 > assert(file =3D=3D NULL); This looks strange now, without the direct connection to bdrv_open_image(). I'd drop this... > bs->open_flags =3D flags; > - ret =3D bdrv_open_image(&file, filename, options, "file", > - bs, &child_file, true, &local_err); > - if (ret < 0) { > + > + bs->file_child =3D bdrv_open_child(filename, options, "file", = bs, > + &child_file, true, &local_err= ); > + if (local_err) { > + ret =3D -EINVAL; > goto fail; > } > + > + if (bs->file_child) { > + file =3D bs->file_child->bs; > + } And make this file =3D bs->file_child ? bs->file_child->bs : NULL (or the= respective long form, i.e. if (bs->file_child) { ... } else { file =3D NULL; }). We could even put this after this if block and drop the NULL initialization of file, but that might go overboard. Max > } > =20 > /* Image format probing */ > diff --git a/include/block/block_int.h b/include/block/block_int.h > index 14ad4c3..d0dd93e 100644 > --- a/include/block/block_int.h > +++ b/include/block/block_int.h > @@ -381,6 +381,7 @@ struct BlockDriverState { > BlockDriverState *backing_hd; > BdrvChild *backing_child; > BlockDriverState *file; > + BdrvChild *file_child; > =20 > NotifierList close_notifiers; > =20 >=20 --CxlJblndVkDEkDfK4CnUCfWUK1bMpNH2t Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAYyDAAoJEDuxQgLoOKyt13wIAK5C7WLDKgeOHR3ENbDfRIKu BOcwSPtIKCnevose8wZS8kSVsbf4TBuLqLja1BB6EiWnl0NQPfqyS4UfFOkl7D7d FkT+8X64Gx+w97CEYBT81ROKDTCKSft/RH42Lk4kH/KTN8/oMg+gxhZnF4QDBccO 6PvFsRV5weH+42y67IHedMEsx6XI57sYc29y52KtljSmb89MBfGJgh4NRgMrtqcs NcNehoQDvTPZF+xW7+wKAGhipKxU0cvyvW76OjZExYwRwCMGnaKkzR13R9aeuLPf ogLVwuUwMBrRjW7lHwVzXwCHYjIImc2P0xR0WAMVRGWjOotsNC+6+p/2MJ8naXI= =Qpsk -----END PGP SIGNATURE----- --CxlJblndVkDEkDfK4CnUCfWUK1bMpNH2t-- From MAILER-DAEMON Tue Sep 22 13:17:36 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeRCB-0006pb-VV for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 13:17:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeRC6-0006p1-KQ for qemu-block@nongnu.org; Tue, 22 Sep 2015 13:17:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeRC1-0004IO-HS for qemu-block@nongnu.org; Tue, 22 Sep 2015 13:17:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60495) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeRC1-0004IH-Aa; Tue, 22 Sep 2015 13:17:25 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id D993B8F301; Tue, 22 Sep 2015 17:17:24 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MHHK6I009850 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 13:17:22 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-2-git-send-email-kwolf@redhat.com> <56018C83.7030207@redhat.com> From: Max Reitz Message-ID: <56018D20.4030709@redhat.com> Date: Tue, 22 Sep 2015 19:17:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <56018C83.7030207@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="XK0kamoIIh1PbrnBvJejki6jJQItdmFep" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 01/16] block: Introduce BDS.file_child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 17:17:34 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --XK0kamoIIh1PbrnBvJejki6jJQItdmFep Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 22.09.2015 19:14, Max Reitz wrote: > On 17.09.2015 15:48, Kevin Wolf wrote: >> Store the BdrvChild for bs->file. At this point, bs->file_child->bs ju= st >> duplicates the bs->file pointer. Later, it will completely replace it.= >> >> Signed-off-by: Kevin Wolf >> --- >> block.c | 12 +++++++++--- >> include/block/block_int.h | 1 + >> 2 files changed, 10 insertions(+), 3 deletions(-) >=20 > Reviewed-by: Max Reitz >=20 > Although I have a small comment below: >=20 >> >> diff --git a/block.c b/block.c >> index 6268e37..2e9e5e2 100644 >> --- a/block.c >> +++ b/block.c >> @@ -1487,11 +1487,17 @@ static int bdrv_open_inherit(BlockDriverState = **pbs, const char *filename, >> =20 >> assert(file =3D=3D NULL); >=20 > This looks strange now, without the direct connection to > bdrv_open_image(). I'd drop this... >=20 >> bs->open_flags =3D flags; >> - ret =3D bdrv_open_image(&file, filename, options, "file", >> - bs, &child_file, true, &local_err); >> - if (ret < 0) { >> + >> + bs->file_child =3D bdrv_open_child(filename, options, "file",= bs, >> + &child_file, true, &local_er= r); >> + if (local_err) { >> + ret =3D -EINVAL; >> goto fail; >> } >> + >> + if (bs->file_child) { >> + file =3D bs->file_child->bs; >> + } >=20 > And make this file =3D bs->file_child ? bs->file_child->bs : NULL (or t= he > respective long form, i.e. > if (bs->file_child) { ... } else { file =3D NULL; }). >=20 > We could even put this after this if block and drop the NULL > initialization of file, but that might go overboard. And expecting something like this, I skipped ahead to patch 5, which drops this altogether. An R-b without any comments it is, then. :-) Max >> } >> =20 >> /* Image format probing */ >> diff --git a/include/block/block_int.h b/include/block/block_int.h >> index 14ad4c3..d0dd93e 100644 >> --- a/include/block/block_int.h >> +++ b/include/block/block_int.h >> @@ -381,6 +381,7 @@ struct BlockDriverState { >> BlockDriverState *backing_hd; >> BdrvChild *backing_child; >> BlockDriverState *file; >> + BdrvChild *file_child; >> =20 >> NotifierList close_notifiers; >> =20 >> >=20 >=20 --XK0kamoIIh1PbrnBvJejki6jJQItdmFep Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAY0gAAoJEDuxQgLoOKytxeQIAKzdAhJ4HcrDB+hkJimcil4W /R2SQUERADWHp7kwUMDdBIvP0cHThu4rGt2GUNHJqJOnLr9QoZIQf+o2XSNIAC22 LTdyAcHYHTmPaoxK40ShURWMHJ+ZThyFuUX8dZ2ds8KrexD4M5yIFXRYc4flF0Xu 8GKo+q64eS1NUNx5dX4HE47v9deqif7B+cTm+Np2a2VfYIDMHUMQVVAMRutMrNcO 4EYJ+s8418iu8TZ4+jGvZ9Z0tOF7yQfH34/y5VTxlwd4KeOyovPVk8XfPs1weyeK IWFXfwdAF0TWTsjR+nnwaYN4AJBTD0qh9v5lxk9vA5c9fFQRikJs7lf1ZC8oXC8= =oQBf -----END PGP SIGNATURE----- --XK0kamoIIh1PbrnBvJejki6jJQItdmFep-- From MAILER-DAEMON Tue Sep 22 13:45:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeRd8-0004zI-PI for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 13:45:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeRd5-0004yy-QS for qemu-block@nongnu.org; Tue, 22 Sep 2015 13:45:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeRd2-0006W5-Jq for qemu-block@nongnu.org; Tue, 22 Sep 2015 13:45:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46399) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeRd2-0006VJ-F5; Tue, 22 Sep 2015 13:45:20 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 05076C0A148D; Tue, 22 Sep 2015 17:45:19 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MHjGen008648 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 13:45:18 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-3-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <560193AB.6090407@redhat.com> Date: Tue, 22 Sep 2015 19:45:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-3-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Pk9ej8NMRQCPeRIDDUJ4PX2d5TTMMd8eQ" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 02/16] vmdk: Use BdrvChild instead of BDS for references to extents X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 17:45:24 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Pk9ej8NMRQCPeRIDDUJ4PX2d5TTMMd8eQ Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > block/vmdk.c | 99 +++++++++++++++++++++++++++++++---------------------= -------- > 1 file changed, 51 insertions(+), 48 deletions(-) Reviewed-by: Max Reitz --Pk9ej8NMRQCPeRIDDUJ4PX2d5TTMMd8eQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAZOrAAoJEDuxQgLoOKytEc0H/igzgxORoqJzZMHDLYvoMei9 d95E+X8YZG7QoIonAkWpdEUteX96YnvSTidnzuNHYzLZu6k2Y4QZo+jGml32jhTU v1RIW3v1SJQnGd/R/pvQzk48r3TqBLRi9pVkrW9cGbP+szxH75RqslMMLi/j8qOm KhknnSG1byKfnJAOAXGDTxTB0BcgD5xqB87lBAyZGEci/LSTAPlQ2VTu2IrEn+6F rW9i4UkGYX7rnwBypWK3RRyWw5sAY2gNMC+011p/RosrnkrGkHCCn/Lqynbv6stL AkgcqrRYV8BtDw8NGvbUeYYRaN/kZIE17o3fKfuXZ4H2lhyvlip+7UZyLaQsfs4= =oNTv -----END PGP SIGNATURE----- --Pk9ej8NMRQCPeRIDDUJ4PX2d5TTMMd8eQ-- From MAILER-DAEMON Tue Sep 22 13:51:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeRiw-0007gB-9N for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 13:51:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeRiu-0007fX-8j for qemu-block@nongnu.org; Tue, 22 Sep 2015 13:51:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeRir-0003g4-2H for qemu-block@nongnu.org; Tue, 22 Sep 2015 13:51:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48189) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeRiq-0003fy-TN; Tue, 22 Sep 2015 13:51:20 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 68CEAC0A1494; Tue, 22 Sep 2015 17:51:20 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MHpHRX011523 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 13:51:18 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-4-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <5601950F.7000001@redhat.com> Date: Tue, 22 Sep 2015 19:51:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-4-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="tN05M2iB42SXDN0BliwoAqJa9tEKxhV4B" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 03/16] blkverify: Convert s->test_file to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 17:51:24 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --tN05M2iB42SXDN0BliwoAqJa9tEKxhV4B Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > block/blkverify.c | 41 +++++++++++++++++++++-------------------- > 1 file changed, 21 insertions(+), 20 deletions(-) Reviewed-by: Max Reitz --tN05M2iB42SXDN0BliwoAqJa9tEKxhV4B Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAZUPAAoJEDuxQgLoOKytrIkH/0mNPww2yDpr2IhYyHGoj0RY gGizLcn7hsqYA39ARcB/vcxvNqwYSM0q+Sz+wvB71tjCDjaoi5VlFQGsChp0UypB WKDxpVguqH1gP6QreMiEj+MD+Ck/b01VzygeRlkBUYaDz5fibs3s/MiR2CGzGIDR BXu00Qur+vx6foEhQ3jUH4NlRQeCc2KPrkhUamyXuaiE/Ir0wUEAt50+f+tUMAWl bJjmIQjJaFLaiyQm+iW43pKYKTE6tyPua0KN5+oASyWYYlH3BMB8exKMc/V8Bn8Y Iy43vkKgwgT59Uk0X7pSGn9qebRGo8ivbq80UWHh0tivqW9982lXjQ5ajBNbQEY= =MMD4 -----END PGP SIGNATURE----- --tN05M2iB42SXDN0BliwoAqJa9tEKxhV4B-- From MAILER-DAEMON Tue Sep 22 13:57:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeRom-0004Ek-P2 for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 13:57:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeRok-00049E-Hd for qemu-block@nongnu.org; Tue, 22 Sep 2015 13:57:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeRoh-0005jM-BO for qemu-block@nongnu.org; Tue, 22 Sep 2015 13:57:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49723) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeRoh-0005jD-6F; Tue, 22 Sep 2015 13:57:23 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 98633C0798E1; Tue, 22 Sep 2015 17:57:21 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MHvHjh014800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 13:57:19 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-5-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <5601967D.6090709@redhat.com> Date: Tue, 22 Sep 2015 19:57:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-5-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wwPWaFRwvXOHhcR28xg84OAjbJbQSbe0C" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 04/16] quorum: Convert to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 17:57:27 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --wwPWaFRwvXOHhcR28xg84OAjbJbQSbe0C Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > block/quorum.c | 63 ++++++++++++++++++++++++++++++--------------------= -------- > 1 file changed, 33 insertions(+), 30 deletions(-) Reviewed-by: Max Reitz --wwPWaFRwvXOHhcR28xg84OAjbJbQSbe0C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAZZ9AAoJEDuxQgLoOKytfM8IAIXbS1QfEFG+x9s9oTH4kqK4 Mxe7x7HRKY0q9YwcjzG8w3sloIY3SAaMfpLqnE0MXEYcCmE3g31dMs1XdNGLNwc0 6bkIM3l+QQUiHwS/KGJnKdcEbEG9UFn+tpNIGNEgTtLFgrBTlgzfetbPOSoEEFx0 LAK/w8cLLGafb2sv0LEb1j0j2wHBcnQc3mlPX5qPY/PRAgjBEWUCMcS/uFe8hwwm AYmLtSwnM0Fj3ZQAFvr/9ReX1FiuRZCRH3MzyWagBwtZGn6b8xh63unWQZq5nANZ R8ZF3GbBVsKRmHpKJ5M2Bu+k3ddbxJBuhn+6VMfkdJ/xSJKZzZ32xY/DYhWOA5w= =yPzp -----END PGP SIGNATURE----- --wwPWaFRwvXOHhcR28xg84OAjbJbQSbe0C-- From MAILER-DAEMON Tue Sep 22 14:36:25 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeSQT-0003xF-C2 for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 14:36:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58587) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeSQQ-0003wa-NW for qemu-block@nongnu.org; Tue, 22 Sep 2015 14:36:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeSQN-0002ST-HY for qemu-block@nongnu.org; Tue, 22 Sep 2015 14:36:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeSQN-0002Rj-AH; Tue, 22 Sep 2015 14:36:19 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 13C63C0A148D; Tue, 22 Sep 2015 18:36:18 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MIaEsx015830 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 14:36:15 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-6-git-send-email-kwolf@redhat.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <56019F9D.9020800@redhat.com> Date: Tue, 22 Sep 2015 20:36:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-6-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Fbc8Lmb2NkXmf5TaN0C0OENjkVMh14XCV" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 05/16] block: Convert bs->file to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 18:36:23 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Fbc8Lmb2NkXmf5TaN0C0OENjkVMh14XCV Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > This patch removes the temporary duplication between bs->file and > bs->file_child by converting everything to BdrvChild. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 61 ++++++++++++++++++++++-----------------= ------- > block/blkdebug.c | 32 ++++++++++++------------ > block/blkverify.c | 33 ++++++++++++++----------- > block/bochs.c | 8 +++--- > block/cloop.c | 10 ++++---- > block/dmg.c | 20 +++++++-------- > block/io.c | 50 +++++++++++++++++++------------------- > block/parallels.c | 38 +++++++++++++++-------------- > block/qapi.c | 2 +- > block/qcow.c | 42 +++++++++++++++++--------------- > block/qcow2-cache.c | 11 +++++---- > block/qcow2-cluster.c | 38 +++++++++++++++++------------ > block/qcow2-refcount.c | 45 ++++++++++++++++++---------------- > block/qcow2-snapshot.c | 30 ++++++++++++----------- > block/qcow2.c | 62 ++++++++++++++++++++++++---------------= -------- > block/qed-table.c | 4 +-- > block/qed.c | 32 ++++++++++++------------ > block/raw_bsd.c | 40 +++++++++++++++--------------- > block/snapshot.c | 12 ++++----- > block/vdi.c | 17 +++++++------ > block/vhdx-log.c | 25 ++++++++++--------- > block/vhdx.c | 36 ++++++++++++++------------- > block/vmdk.c | 27 +++++++++++---------- > block/vpc.c | 34 ++++++++++++++------------ > include/block/block.h | 8 +++++- > include/block/block_int.h | 3 +-- > 26 files changed, 377 insertions(+), 343 deletions(-) Reviewed-by: Max Reitz > diff --git a/block.c b/block.c > index 2e9e5e2..93d713b 100644 > --- a/block.c > +++ b/block.c [...] > @@ -1929,6 +1925,11 @@ void bdrv_close(BlockDriverState *bs) > bdrv_unref(backing_hd); > } > =20 > + if (bs->file !=3D NULL) { > + bdrv_unref(bs->file->bs); I think we can use bdrv_unref_child(bs->file) here. I'd personally like it more, at least (because using bdrv_unref() and relying on the loop below is basically what the comment inside of the loop advises against). Yes, I know, eventually, we want to drop this block anyway and let the loop below handle everything using bdrv_unref_child(). But when we do that conversion, it'll be obvious to drop a bdrv_unref_child() call, whereas dropping bdrv_unref() alone isn't so obvious. Max > + bs->file =3D NULL; > + } > + > QLIST_FOREACH_SAFE(child, &bs->children, next, next) { > /* TODO Remove bdrv_unref() from drivers' close function a= nd use > * bdrv_unref_child() here */ > @@ -1953,11 +1954,6 @@ void bdrv_close(BlockDriverState *bs) > bs->options =3D NULL; > QDECREF(bs->full_open_options); > bs->full_open_options =3D NULL; > - > - if (bs->file !=3D NULL) { > - bdrv_unref(bs->file); > - bs->file =3D NULL; > - } > } > =20 > if (bs->blk) { --Fbc8Lmb2NkXmf5TaN0C0OENjkVMh14XCV Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAZ+dAAoJEDuxQgLoOKytFZYH/1EdSyh0RBAZKhZVVCDFt64E dYYi92rtjoq7DRCjga4qa8FCeUVFz+b2iANriRyvrCmnLk3udaOcXzFGAavRbb8n X8HUzZ4H4vRVCQKEct5c9pZRi6ZxAcOQ8zP7kRRw1s2fl/yr5JZJspn9tOelKb+x ir22ybi5ipStsGAruhHp9h+ESDLHOallhvTAxoxJ7TJx5COyTWaa3AduGJ/iisf5 zn3QO6NV4YqeSe/Zfr3tiP4HKISPuSEE+Qn4t8inyleLWd/bi9fwq/O/tatcUj5Z +0xDZCTobHPyZqRzkb/zBtWMW5D/Sp8N3+CQDbLdwdM+LS8HqDArlR372A7AZ6A= =gXCf -----END PGP SIGNATURE----- --Fbc8Lmb2NkXmf5TaN0C0OENjkVMh14XCV-- From MAILER-DAEMON Tue Sep 22 14:38:42 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeSSg-0006Kz-FB for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 14:38:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeSSe-0006Ir-Pk for qemu-block@nongnu.org; Tue, 22 Sep 2015 14:38:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeSSb-0003ez-Kq for qemu-block@nongnu.org; Tue, 22 Sep 2015 14:38:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeSSb-0003eA-GF; Tue, 22 Sep 2015 14:38:37 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 26E9091C17; Tue, 22 Sep 2015 18:38:37 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MIcXWg018455 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 14:38:35 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-7-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <5601A029.9090304@redhat.com> Date: Tue, 22 Sep 2015 20:38:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-7-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Uot207WLoJpdqMA8RETex7wg4X73w36e6" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 06/16] block: Remove bdrv_open_image() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 18:38:41 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Uot207WLoJpdqMA8RETex7wg4X73w36e6 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > It is unused now. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 34 ---------------------------------- > include/block/block.h | 4 ---- > 2 files changed, 38 deletions(-) Reviewed-by: Max Reitz --Uot207WLoJpdqMA8RETex7wg4X73w36e6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAaApAAoJEDuxQgLoOKytdIAH/2AOa5cLb96sJ64EzkvQsU4m 9y4B30P92ouyTtOIWA25Mj/M8/MyvZzMjfZ+5HROSzyLulRUxzw7Y2lmdJ0+Qs9L SPB3u7QyFiWfh/mFoXa/JK4UiCpjCPvOfSkzlNFh4xMWMN+auoP5F7pVEK3X+T7T wCPvdjMbYR7W/NcqodIK6YarJfu+pWFrUD52q18nDYa5P5KaXPQDIghS1XLdaQJX ofaWi1eYS3Prv9/KLtMzoRUAmnAOkbWUA0sNJ9kEUdPXQbXgikJA13xwqkkoZ62o ekLmSsvs9Dt9gyVeuqAh6do/xQBx4ny7N/Yr7oWLBlsP5Trj6KuS4qnZ9FXH6Oo= =fxUP -----END PGP SIGNATURE----- --Uot207WLoJpdqMA8RETex7wg4X73w36e6-- From MAILER-DAEMON Tue Sep 22 15:21:32 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeT88-0002WV-EB for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 15:21:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeT86-0002WB-60 for qemu-block@nongnu.org; Tue, 22 Sep 2015 15:21:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeT83-00053H-2F for qemu-block@nongnu.org; Tue, 22 Sep 2015 15:21:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33022) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeT82-00051w-Qt; Tue, 22 Sep 2015 15:21:26 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 3F0A2341AE3; Tue, 22 Sep 2015 19:21:25 +0000 (UTC) Received: from [10.36.116.63] (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MJLL5u011251 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Sep 2015 15:21:23 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-8-git-send-email-kwolf@redhat.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <5601AA30.7020809@redhat.com> Date: Tue, 22 Sep 2015 21:21:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-8-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="eG9JITQrLrOxRoQOvdHGblgHRF5e7Nc8v" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 07/16] block: Convert bs->backing_hd to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 19:21:31 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --eG9JITQrLrOxRoQOvdHGblgHRF5e7Nc8v Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > This is the final step in converting all of the BlockDriverState > pointers that block drivers use to BdrvChild. >=20 > After this patch, bs->children contains the full list of child nodes > that are referenced by a given BDS, and these children are only > referenced through BdrvChild, so that updating the pointer in there is > enough for changing edges in the graph. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 116 +++++++++++++++++++++++++-------------= -------- > block/io.c | 24 +++++----- > block/mirror.c | 7 +-- > block/qapi.c | 8 ++-- > block/qcow.c | 4 +- > block/qcow2-cluster.c | 4 +- > block/qcow2.c | 6 +-- > block/qed.c | 12 ++--- > block/stream.c | 10 ++-- > block/vmdk.c | 21 +++++---- > block/vvfat.c | 6 +-- > blockdev.c | 6 +-- > include/block/block_int.h | 12 +++-- > qemu-img.c | 8 ++-- > 14 files changed, 130 insertions(+), 114 deletions(-) >=20 [...] > diff --git a/block/io.c b/block/io.c > index 8a27efa..d7e742a 100644 > --- a/block/io.c > +++ b/block/io.c [...] > @@ -1604,7 +1604,7 @@ int64_t bdrv_get_block_status(BlockDriverState *b= s, > int64_t sector_num, > int nb_sectors, int *pnum) > { > - return bdrv_get_block_status_above(bs, bs->backing_hd, > + return bdrv_get_block_status_above(bs, backing_bs(bs), > sector_num, nb_sectors, pnum); > } > =20 > @@ -1662,7 +1662,7 @@ int bdrv_is_allocated_above(BlockDriverState *top= , > n =3D pnum_inter; > } > =20 > - intermediate =3D intermediate->backing_hd; > + intermediate =3D intermediate->backing ? intermediate->backing= ->bs : NULL; backing_bs(intermediate)? > } > =20 > *pnum =3D n; > diff --git a/block/mirror.c b/block/mirror.c > index a258926..259e11a 100644 > --- a/block/mirror.c > +++ b/block/mirror.c > @@ -371,7 +371,8 @@ static void mirror_exit(BlockJob *job, void *opaque= ) > if (s->common.driver->job_type =3D=3D BLOCK_JOB_TYPE_COMMIT) {= > /* drop the bs loop chain formed by the swap: break the lo= op then > * trigger the unref from the top one */ > - BlockDriverState *p =3D s->base->backing_hd; > + BlockDriverState *p =3D s->base->backing > + ? s->base->backing->bs : NULL; Maybe you don't want to use backing_bs() outside of the core block layer, but it could be used here, too. (There are two similar expressions in block/stream.c, and maybe elsewhere, too) > bdrv_set_backing_hd(s->base, NULL); > bdrv_unref(p); > } [...] > diff --git a/blockdev.c b/blockdev.c > index 32b04b4..bc158ff 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -2508,10 +2508,10 @@ void qmp_drive_backup(const char *device, const= char *target, > /* See if we have a backing HD we can use to create our new image > * on top of. */ > if (sync =3D=3D MIRROR_SYNC_MODE_TOP) { > - source =3D bs->backing_hd; > - if (!source) { > + if (!bs->backing) { > sync =3D MIRROR_SYNC_MODE_FULL; > } > + source =3D bs->backing->bs; That doesn't seem right. In case of !bs->backing, this won't abort but just continue and run into bs->backing->bs, which should therefore probably be backing_bs(bs) instead. > } > if (sync =3D=3D MIRROR_SYNC_MODE_NONE) { > source =3D bs; > @@ -2716,7 +2716,7 @@ void qmp_drive_mirror(const char *device, const c= har *target, > } > =20 > flags =3D bs->open_flags | BDRV_O_RDWR; > - source =3D bs->backing_hd; > + source =3D bs->backing ? bs->backing->bs : NULL; Why not source =3D backing_bs(bs)? > if (!source && sync =3D=3D MIRROR_SYNC_MODE_TOP) { > sync =3D MIRROR_SYNC_MODE_FULL; > } [...] > diff --git a/qemu-img.c b/qemu-img.c > index 6ff4e85..c4454da 100644 > --- a/qemu-img.c > +++ b/qemu-img.c [...] > @@ -2206,11 +2206,11 @@ static int get_block_status(BlockDriverState *b= s, int64_t sector_num, > if (ret & (BDRV_BLOCK_ZERO|BDRV_BLOCK_DATA)) { > break; > } > - bs =3D bs->backing_hd; > - if (bs =3D=3D NULL) { > + if (bs->backing =3D=3D NULL) { > ret =3D 0; > break; > } > + bs =3D bs->backing->bs; This changes behavior. bs needs to be set to NULL in the if (bs->backing =3D=3D NULL) block, or the break will break: Before, if bs->backing_hd =3D=3D NULL, the loop was left with bs =3D=3D NULL. Now, b= s won't be NULL anymore (but its value is used after the loop and stored in e->bs= ). Max > =20 > depth++; > } >=20 --eG9JITQrLrOxRoQOvdHGblgHRF5e7Nc8v Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAaowAAoJEDuxQgLoOKyt0fAIAKIN8kQlTrpPM+1X3dqm3s/I NrbqYFdj0IbSNpWO3T2JpxJeJ3MkNqaWfRvXh/zdsk8Xnw65yKA/kAp414vQdMIa 1swjNrGBK7moOOELa6QHGOFvVYxnm3LOsYCAr5U5Q/ppcm6xOo8o9bTKvuyGgu7g 2QsD5uIC/mVXbBQWoh5WJ/+Qbu16gBBCqzMAMz+fExLZTDGkm1p8CZMAGsqa1xaY AXFehwISmtdIrM3HchUDeIdD4BAVGzKTMKBLg0gjsKclDLsKYKNZgobquzZ1bU5A OV9OwLU6b4FixsemkaP4y3G1wR8bKbv0vI5LUkOxNvC6pzB1c2ayC3NSujgS0pE= =7Wgl -----END PGP SIGNATURE----- --eG9JITQrLrOxRoQOvdHGblgHRF5e7Nc8v-- From MAILER-DAEMON Tue Sep 22 16:17:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeU01-00066b-FK for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 16:17:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeTzw-0005zu-Pe for qemu-block@nongnu.org; Tue, 22 Sep 2015 16:17:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeTzw-0005oy-0x for qemu-block@nongnu.org; Tue, 22 Sep 2015 16:17:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeTzv-0005or-Sb; Tue, 22 Sep 2015 16:17:07 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 6F5AAC0A148D; Tue, 22 Sep 2015 20:17:07 +0000 (UTC) Received: from localhost (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MKH6Bc007165; Tue, 22 Sep 2015 16:17:06 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Tue, 22 Sep 2015 17:16:27 -0300 Message-Id: <1442952987-20187-4-git-send-email-ehabkost@redhat.com> In-Reply-To: <1442952987-20187-1-git-send-email-ehabkost@redhat.com> References: <1442952987-20187-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, Marcel Apfelbaum , "Michael S. Tsirkin" , Hannes Reinecke , Paolo Bonzini , Laszlo Ersek Subject: [Qemu-block] [PATCH 3/3] megasas: Use qemu_hw_version() instead of QEMU_VERSION X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 20:17:09 -0000 Guest visible data shouldn't change with a simple QEMU upgrade, so use qemu_hw_version() to ensure it won't change (as long as the machine class being used has hw_version set). Cc: Hannes Reinecke Cc: Paolo Bonzini Cc: qemu-block@nongnu.org Signed-off-by: Eduardo Habkost --- hw/scsi/megasas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index a04369c..e0529b1 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -757,7 +757,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) memcpy(info.product_name, base_class->product_name, 24); snprintf(info.serial_number, 32, "%s", s->hba_serial); - snprintf(info.package_version, 0x60, "%s-QEMU", QEMU_VERSION); + snprintf(info.package_version, 0x60, "%s-QEMU", qemu_hw_version()); memcpy(info.image_component[0].name, "APP", 3); snprintf(info.image_component[0].version, 10, "%s-QEMU", base_class->product_version); -- 2.1.0 From MAILER-DAEMON Tue Sep 22 16:21:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeU47-0002iJ-Kh for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 16:21:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeU45-0002fk-PV for qemu-block@nongnu.org; Tue, 22 Sep 2015 16:21:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeU42-0007pz-F0 for qemu-block@nongnu.org; Tue, 22 Sep 2015 16:21:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:50100) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeU42-0007oH-9j; Tue, 22 Sep 2015 16:21:22 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A6949AAC7; Tue, 22 Sep 2015 20:21:20 +0000 (UTC) To: Eduardo Habkost , qemu-devel@nongnu.org References: <1442952987-20187-1-git-send-email-ehabkost@redhat.com> <1442952987-20187-4-git-send-email-ehabkost@redhat.com> From: Hannes Reinecke Message-ID: <5601B838.30907@suse.de> Date: Tue, 22 Sep 2015 22:21:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442952987-20187-4-git-send-email-ehabkost@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 Cc: Paolo Bonzini , Marcel Apfelbaum , Laszlo Ersek , qemu-block@nongnu.org, "Michael S. Tsirkin" Subject: Re: [Qemu-block] [PATCH 3/3] megasas: Use qemu_hw_version() instead of QEMU_VERSION X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 20:21:26 -0000 On 09/22/2015 10:16 PM, Eduardo Habkost wrote: > Guest visible data shouldn't change with a simple QEMU upgrade, so use > qemu_hw_version() to ensure it won't change (as long as the machine > class being used has hw_version set). >=20 > Cc: Hannes Reinecke > Cc: Paolo Bonzini > Cc: qemu-block@nongnu.org > Signed-off-by: Eduardo Habkost > --- > hw/scsi/megasas.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c > index a04369c..e0529b1 100644 > --- a/hw/scsi/megasas.c > +++ b/hw/scsi/megasas.c > @@ -757,7 +757,7 @@ static int megasas_ctrl_get_info(MegasasState *s, M= egasasCmd *cmd) > =20 > memcpy(info.product_name, base_class->product_name, 24); > snprintf(info.serial_number, 32, "%s", s->hba_serial); > - snprintf(info.package_version, 0x60, "%s-QEMU", QEMU_VERSION); > + snprintf(info.package_version, 0x60, "%s-QEMU", qemu_hw_version())= ; > memcpy(info.image_component[0].name, "APP", 3); > snprintf(info.image_component[0].version, 10, "%s-QEMU", > base_class->product_version); >=20 Ah. right. Should be okay, then. Reviewed-by: Hannes Reinecke Cheers, Hannes --=20 Dr. Hannes Reinecke zSeries & Storage hare@suse.de +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg GF: J. Hawn, J. Guild, F. Imend=F6rffer, HRB 16746 (AG N=FCrnberg) From MAILER-DAEMON Tue Sep 22 16:33:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeUFy-0002Hf-TZ for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 16:33:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeUFw-0002Bm-3J for qemu-block@nongnu.org; Tue, 22 Sep 2015 16:33:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeUFr-0006dW-R7 for qemu-block@nongnu.org; Tue, 22 Sep 2015 16:33:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeUFr-0006cw-Jt; Tue, 22 Sep 2015 16:33:35 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 11410314159; Tue, 22 Sep 2015 20:33:35 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-16.rdu2.redhat.com [10.10.116.16]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MKXWPv005701; Tue, 22 Sep 2015 16:33:33 -0400 To: Eduardo Habkost , qemu-devel@nongnu.org References: <1442952987-20187-1-git-send-email-ehabkost@redhat.com> <1442952987-20187-4-git-send-email-ehabkost@redhat.com> From: Laszlo Ersek Message-ID: <5601BB1C.4040406@redhat.com> Date: Tue, 22 Sep 2015 22:33:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442952987-20187-4-git-send-email-ehabkost@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , Marcel Apfelbaum , Hannes Reinecke , qemu-block@nongnu.org, "Michael S. Tsirkin" Subject: Re: [Qemu-block] [PATCH 3/3] megasas: Use qemu_hw_version() instead of QEMU_VERSION X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 20:33:41 -0000 On 09/22/15 22:16, Eduardo Habkost wrote: > Guest visible data shouldn't change with a simple QEMU upgrade, so use > qemu_hw_version() to ensure it won't change (as long as the machine > class being used has hw_version set). > > Cc: Hannes Reinecke > Cc: Paolo Bonzini > Cc: qemu-block@nongnu.org > Signed-off-by: Eduardo Habkost > --- > hw/scsi/megasas.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c > index a04369c..e0529b1 100644 > --- a/hw/scsi/megasas.c > +++ b/hw/scsi/megasas.c > @@ -757,7 +757,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) > > memcpy(info.product_name, base_class->product_name, 24); > snprintf(info.serial_number, 32, "%s", s->hba_serial); > - snprintf(info.package_version, 0x60, "%s-QEMU", QEMU_VERSION); > + snprintf(info.package_version, 0x60, "%s-QEMU", qemu_hw_version()); > memcpy(info.image_component[0].name, "APP", 3); > snprintf(info.image_component[0].version, 10, "%s-QEMU", > base_class->product_version); > I assume you audited all uses of QEMU_VERSION, and this was the only one exposed to the guest directly. However, in "hw/usb/redirect.c", QEMU_VERSION is embedded in VERSION, and the latter is then passed to usbredirparser_init() in usbredir_create_parser(). I tried to look up the documentation for usbredirparser_init() in "/usr/include/usbredirparser.h", but I still have no clue what that "version" parameter controls. Hm... from the source code of usbredir, and stating "usbredir is the name of a network protocol for sending usb device traffic over a network connection", it looks like the version number is embedded in the hello message of that network protocol; so it shouldn't be exposed to the guest indeed. Acked-by: Laszlo Ersek Thanks Laszlo From MAILER-DAEMON Tue Sep 22 16:36:39 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeUIp-0007Zc-Ev for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 16:36:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeUIn-0007WH-Iy for qemu-block@nongnu.org; Tue, 22 Sep 2015 16:36:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeUIm-0008No-Es for qemu-block@nongnu.org; Tue, 22 Sep 2015 16:36:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48991) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeUIm-0008NJ-AR; Tue, 22 Sep 2015 16:36:36 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 0897FA2A20; Tue, 22 Sep 2015 20:36:36 +0000 (UTC) Received: from localhost (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MKaYDn026527; Tue, 22 Sep 2015 16:36:35 -0400 Date: Tue, 22 Sep 2015 17:36:28 -0300 From: Eduardo Habkost To: Laszlo Ersek Message-ID: <20150922203628.GP4004@thinpad.lan.raisama.net> References: <1442952987-20187-1-git-send-email-ehabkost@redhat.com> <1442952987-20187-4-git-send-email-ehabkost@redhat.com> <5601BB1C.4040406@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5601BB1C.4040406@redhat.com> X-Fnord: you can see the fnord User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, Marcel Apfelbaum , "Michael S. Tsirkin" , qemu-devel@nongnu.org, Hannes Reinecke , Paolo Bonzini Subject: Re: [Qemu-block] [PATCH 3/3] megasas: Use qemu_hw_version() instead of QEMU_VERSION X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 20:36:38 -0000 On Tue, Sep 22, 2015 at 10:33:32PM +0200, Laszlo Ersek wrote: > On 09/22/15 22:16, Eduardo Habkost wrote: > > Guest visible data shouldn't change with a simple QEMU upgrade, so use > > qemu_hw_version() to ensure it won't change (as long as the machine > > class being used has hw_version set). > > > > Cc: Hannes Reinecke > > Cc: Paolo Bonzini > > Cc: qemu-block@nongnu.org > > Signed-off-by: Eduardo Habkost > > --- > > hw/scsi/megasas.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c > > index a04369c..e0529b1 100644 > > --- a/hw/scsi/megasas.c > > +++ b/hw/scsi/megasas.c > > @@ -757,7 +757,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) > > > > memcpy(info.product_name, base_class->product_name, 24); > > snprintf(info.serial_number, 32, "%s", s->hba_serial); > > - snprintf(info.package_version, 0x60, "%s-QEMU", QEMU_VERSION); > > + snprintf(info.package_version, 0x60, "%s-QEMU", qemu_hw_version()); > > memcpy(info.image_component[0].name, "APP", 3); > > snprintf(info.image_component[0].version, 10, "%s-QEMU", > > base_class->product_version); > > > > I assume you audited all uses of QEMU_VERSION, and this was the only one > exposed to the guest directly. > > However, in "hw/usb/redirect.c", QEMU_VERSION is embedded in VERSION, > and the latter is then passed to usbredirparser_init() in > usbredir_create_parser(). > > I tried to look up the documentation for usbredirparser_init() in > "/usr/include/usbredirparser.h", but I still have no clue what that > "version" parameter controls. > > Hm... from the source code of usbredir, and > stating "usbredir is the name > of a network protocol for sending usb device traffic over a network > connection", it looks like the version number is embedded in the hello > message of that network protocol; so it shouldn't be exposed to the > guest indeed. Investigating how VERSION was used in usbredirparser was next on my todo-list. Thanks for doing that. :) -- Eduardo From MAILER-DAEMON Tue Sep 22 19:02:19 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeWZm-0002W5-Uk for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 19:02:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeWZl-0002TX-5f for qemu-block@nongnu.org; Tue, 22 Sep 2015 19:02:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeWZg-00043G-5o for qemu-block@nongnu.org; Tue, 22 Sep 2015 19:02:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeWZg-000435-17; Tue, 22 Sep 2015 19:02:12 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 828632F9139; Tue, 22 Sep 2015 23:02:11 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MN2AB4007903; Tue, 22 Sep 2015 19:02:10 -0400 To: Eric Blake , Kevin Wolf , Markus Armbruster References: <1442582574-14275-1-git-send-email-armbru@redhat.com> <1442582574-14275-3-git-send-email-armbru@redhat.com> <20150922152313.GK3999@noname.str.redhat.com> <560189B3.6060602@redhat.com> From: John Snow Message-ID: <5601DDF2.3060000@redhat.com> Date: Tue, 22 Sep 2015 19:02:10 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <560189B3.6060602@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PULL 2/8] hmp: Allow for error message hints on HMP X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 23:02:18 -0000 On 09/22/2015 01:02 PM, Eric Blake wrote: > On 09/22/2015 09:23 AM, Kevin Wolf wrote: >> Am 18.09.2015 um 15:22 hat Markus Armbruster geschrieben: >>> From: Eric Blake >>> >>> Commits 7216ae3d and d2828429 disabled some error message hints, >>> all because a change to use modern error reporting meant that the >>> hint would be output prior to the actual error. Fix this by making >>> hints a first-class member of Error. >>> >>> For example, we are now back to the pleasant: >>> >>> $ qemu-system-x86_64 --nodefaults -S --vnc :0 --chardev null,id=, >>> qemu-system-x86_64: --chardev null,id=,: Parameter 'id' expects an identifier >>> Identifiers consist of letters, digits, '-', '.', '_', starting with a letter. >>> >>> Signed-off-by: Eric Blake >>> Reviewed-by: Paolo Bonzini >>> Message-Id: <1441901956-21991-1-git-send-email-eblake@redhat.com> >>> Signed-off-by: Markus Armbruster >> >> This broke qemu-iotests 049. Can you please send a patch to update the >> reference output? > > Will do (and I guess I should run qemu-iotests more frequently. Does > 'make check' suffice, or is there other magic involved?) > >From the build directory: pushd tests/qemu-iotests; ./check -v -qcow2; ./check -v -raw; popd If there is a smarter way of doing it, it is unknown to me. --js From MAILER-DAEMON Tue Sep 22 19:16:17 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeWnJ-0005hs-Ti for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 19:16:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeWnH-0005hZ-FU for qemu-block@nongnu.org; Tue, 22 Sep 2015 19:16:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeWnD-0002Oq-Em for qemu-block@nongnu.org; Tue, 22 Sep 2015 19:16:15 -0400 Received: from resqmta-po-01v.sys.comcast.net ([96.114.154.160]:52037) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeWnD-0002OM-B5 for qemu-block@nongnu.org; Tue, 22 Sep 2015 19:16:11 -0400 Received: from resomta-po-04v.sys.comcast.net ([96.114.154.228]) by resqmta-po-01v.sys.comcast.net with comcast id LPFZ1r0054vw8ds01PGA7Y; Tue, 22 Sep 2015 23:16:10 +0000 Received: from red.redhat.com ([24.10.254.122]) by resomta-po-04v.sys.comcast.net with comcast id LPG11r00B2fD5rL01PG9bL; Tue, 22 Sep 2015 23:16:10 +0000 From: Eric Blake To: qemu-devel@nongnu.org Date: Tue, 22 Sep 2015 17:15:52 -0600 Message-Id: <1442963752-10950-1-git-send-email-eblake@redhat.com> X-Mailer: git-send-email 2.4.3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1442963770; bh=XMpnlJ1hTnZaVBsKMrXeraQyJirZho0z7pYeT83ZPZo=; h=Received:Received:From:To:Subject:Date:Message-Id; b=Rli1FzZwfXtYYhpqPzxPtG79LkYsyZCg1F/eahUp8pa5UT3tmMt0ixZEXloso9g97 /qfVEUXmFNKjHKJeiMSY58oqw9evNvfUdRxWOIEz4ZgUfYyn4VKQlGvpfOMgxrImRv bB6qusJskhdjyWsfJJp/ulgKvhJmmaYGxvXg0y70TNf1OmLheTShOBfITyMBOTq+E0 KBni5FbeGvUHvgyNz4qukqQI0JbVKxmUj7EV2Ydo1fQoI+yXIm8mhdkkaMQNPI1LZo clJKle5wzQe6/i+ofaiW9D0pRuGyQPAJ26cMh0m5L/zDh+vHd/j3bdBfqTJdCOV/uS KzdpGM6cvGMAQ== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 96.114.154.160 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-block@nongnu.org Subject: [Qemu-block] [PATCH] tests: Fix test 049 fallout from improved HMP error messages X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 23:16:16 -0000 Commit 50b7b000 improved HMP error messages, but forgot to update qemu-iotests to match. Reported-by: Kevin Wolf Signed-off-by: Eric Blake --- I'm not sure if this should go through Markus' "error" tree, since that's where the break was introduced, or through a "block" tree since it touches qemu-iotests. And now that I have a recipe for running qemu-iotests, I should have no excuse for repeating this type of mistake :) tests/qemu-iotests/049.out | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out index 0425ae0..a2b6703 100644 --- a/tests/qemu-iotests/049.out +++ b/tests/qemu-iotests/049.out @@ -118,6 +118,7 @@ qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes. qemu-img create -f qcow2 -o size=foobar TEST_DIR/t.qcow2 qemu-img: Parameter 'size' expects a size +You may use k, M, G or T suffixes for kilobytes, megabytes, gigabytes and terabytes. qemu-img: TEST_DIR/t.qcow2: Invalid options for file format 'qcow2' == Check correct interpretation of suffixes for cluster size == -- 2.4.3 From MAILER-DAEMON Tue Sep 22 19:23:34 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeWuM-0007nO-UY for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 19:23:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeWuL-0007nE-A3 for qemu-block@nongnu.org; Tue, 22 Sep 2015 19:23:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeWuH-0005vi-Bz for qemu-block@nongnu.org; Tue, 22 Sep 2015 19:23:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeWuH-0005uf-6I; Tue, 22 Sep 2015 19:23:29 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 82F2FA2C18; Tue, 22 Sep 2015 23:23:27 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MNNQLX023654; Tue, 22 Sep 2015 19:23:26 -0400 To: Eric Blake , qemu-devel@nongnu.org References: <1442963752-10950-1-git-send-email-eblake@redhat.com> From: John Snow Message-ID: <5601E2EE.8010109@redhat.com> Date: Tue, 22 Sep 2015 19:23:26 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442963752-10950-1-git-send-email-eblake@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] tests: Fix test 049 fallout from improved HMP error messages X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 23:23:34 -0000 On 09/22/2015 07:15 PM, Eric Blake wrote: > Commit 50b7b000 improved HMP error messages, but forgot to update > qemu-iotests to match. > > Reported-by: Kevin Wolf > Signed-off-by: Eric Blake > --- > > I'm not sure if this should go through Markus' "error" tree, > since that's where the break was introduced, or through a > "block" tree since it touches qemu-iotests. > > And now that I have a recipe for running qemu-iotests, I should > have no excuse for repeating this type of mistake :) > > tests/qemu-iotests/049.out | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out > index 0425ae0..a2b6703 100644 > --- a/tests/qemu-iotests/049.out > +++ b/tests/qemu-iotests/049.out > @@ -118,6 +118,7 @@ qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabytes. > > qemu-img create -f qcow2 -o size=foobar TEST_DIR/t.qcow2 > qemu-img: Parameter 'size' expects a size > +You may use k, M, G or T suffixes for kilobytes, megabytes, gigabytes and terabytes. > qemu-img: TEST_DIR/t.qcow2: Invalid options for file format 'qcow2' > > == Check correct interpretation of suffixes for cluster size == > Grazie, Reviewed-by: John Snow From MAILER-DAEMON Tue Sep 22 21:09:35 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZeYYx-0007dp-QE for mharc-qemu-block@gnu.org; Tue, 22 Sep 2015 21:09:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeYYv-0007dY-HC for qemu-block@nongnu.org; Tue, 22 Sep 2015 21:09:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeYYr-0003A9-3q for qemu-block@nongnu.org; Tue, 22 Sep 2015 21:09:33 -0400 Received: from [59.151.112.132] (port=43821 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeYYq-00038z-GU; Tue, 22 Sep 2015 21:09:29 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100998881" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 23 Sep 2015 09:12:08 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8N194ro008240; Wed, 23 Sep 2015 09:09:04 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 23 Sep 2015 09:09:22 +0800 To: "Dr. David Alan Gilbert" References: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> <20150922111554.GD3529@work-vm> From: Wen Congyang Message-ID: <5601FBA7.5080700@cn.fujitsu.com> Date: Wed, 23 Sep 2015 09:08:55 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150922111554.GD3529@work-vm> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , Markus Armbruster , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [PATCH v5 0/4] qapi: child add/delete support X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 01:09:34 -0000 On 09/22/2015 07:15 PM, Dr. David Alan Gilbert wrote: > * Wen Congyang (wency@cn.fujitsu.com) wrote: >> If quorum's child is broken, we can use mirror job to replace it. >> But sometimes, the user only need to remove the broken child, and >> add it later when the problem is fixed. >> > > Hi, > Two questions: > 1) Do you have an example of a pair of add/remove commands that work > together? (I'm not quite sure I understand where the ID for the remove > comes from). The command line: -drive if=virtio,id=disk1,driver=quorum,read-pattern=fifo,vote-threshold=1,children.0.file.filename=/data/images/kvm/suse/suse11_3.img,children.0.driver=raw And the QMP monitor command: {'execute':'blockdev-add', 'arguments':{'options':{'driver': 'raw', 'node-name': 'test1', 'file': {'driver': 'file', 'filename': '/dev/null'}, 'id': 'test11' } } } {'execute': 'human-monitor-command', 'arguments': {'command-line': 'drive_add buddy driver=nbd,host=192.168.3.1,port=8889,export=colo-disk1,node-name=test2,if=none'}} {'execute':'x-blockdev-child-add', 'arguments':{'parent': 'disk1', 'child': 'test1' } } {'execute':'x-blockdev-child-add', 'arguments':{'parent': 'disk1', 'child': 'test2' } } {'execute': 'x-blockdev-child-del', 'arguments': {'parent': 'disk1', 'child': 'test1' } } {'execute': 'x-blockdev-child-del', 'arguments': {'parent': 'disk1', 'child': 'test2' } } Note: the qmp monitor command doesn't support nbd now, and I use the hmp command to add a BDS. > > 2) If the child has failed and is not responding to block operations > at all (e.g a networking failure to an nbd device which may take minutes > to time out); how do you recover - flush or drain on the devices > hang at that point. If the network fails, the kernel doesn't notify the application... > > (I was trying to test recovery from a failed secondary using the July COLO > release; but the primary gets stuck in bdrv_drain or bdrv_flush if I kill > the secondary in the right way). IIRC, if the qemu is killed, the connection is closed at the same time. bdrv_drain() or bdrv_flush() should not get stuck. Thanks Wen Congyang > > Dave > > >> It is based on the following patch: >> http://lists.nongnu.org/archive/html/qemu-devel/2015-09/msg04579.html >> >> ChangLog: >> v5: >> 1. Address Eric Blake's comments >> v4: >> 1. drop nbd driver's implementation. We can use human-monitor-command >> to do it. >> 2. Rename the command name. >> v3: >> 1. Don't open BDS in bdrv_add_child(). Use the existing BDS which is >> created by the QMP command blockdev-add. >> 2. The driver NBD can support filename, path, host:port now. >> v2: >> 1. Use bdrv_get_device_or_node_name() instead of new function >> bdrv_get_id_or_node_name() >> 2. Update the error message >> 3. Update the documents in block-core.json >> >> Wen Congyang (4): >> Add new block driver interface to add/delete a BDS's child >> quorum: implement bdrv_add_child() and bdrv_del_child() >> qmp: add monitor command to add/remove a child >> hmp: add monitor command to add/remove a child >> >> block.c | 56 ++++++++++++++++++++++++++++++++++-- >> block/quorum.c | 72 +++++++++++++++++++++++++++++++++++++++++++++-- >> blockdev.c | 48 +++++++++++++++++++++++++++++++ >> hmp-commands.hx | 28 ++++++++++++++++++ >> hmp.c | 20 +++++++++++++ >> hmp.h | 2 ++ >> include/block/block.h | 8 ++++++ >> include/block/block_int.h | 5 ++++ >> qapi/block-core.json | 34 ++++++++++++++++++++++ >> qmp-commands.hx | 61 +++++++++++++++++++++++++++++++++++++++ >> 10 files changed, 329 insertions(+), 5 deletions(-) >> >> -- >> 2.4.3 >> > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK > . > From MAILER-DAEMON Wed Sep 23 02:21:20 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZedQe-0003Du-Ey for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 02:21:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZedQc-0003C3-Pn for qemu-block@nongnu.org; Wed, 23 Sep 2015 02:21:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZedQb-0001SQ-Rq for qemu-block@nongnu.org; Wed, 23 Sep 2015 02:21:18 -0400 Received: from [59.151.112.132] (port=26159 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZedQW-0001P7-Tb; Wed, 23 Sep 2015 02:21:13 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101008606" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 23 Sep 2015 14:23:51 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8N6KlJB024685; Wed, 23 Sep 2015 14:20:47 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 23 Sep 2015 14:21:05 +0800 To: Max Reitz , Kevin Wolf References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <20150922144507.GH3999@noname.str.redhat.com> <56016F18.3030208@redhat.com> From: Wen Congyang Message-ID: <560244B7.2020103@cn.fujitsu.com> Date: Wed, 23 Sep 2015 14:20:39 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <56016F18.3030208@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Subject: Re: [Qemu-block] [PATCH v5 00/38] blockdev: BlockBackend and media X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 06:21:19 -0000 On 09/22/2015 11:09 PM, Max Reitz wrote: > On 22.09.2015 16:45, Kevin Wolf wrote: >> Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: >>> This series reworks a lot regarding BlockBackend and media. Basically, >>> it allows empty BlockBackends, that is BBs without a BDS tree. >>> >>> Before this series, empty drives are represented by a BlockBackend with >>> an empty BDS attached to it (a BDS with a NULL driver). However, now we >>> have BlockBackends, thus an empty drive should be represented by a >>> BlockBackend without any BDS tree attached to it. This is what this >>> series does. >> >> Patches 1-16 and 18: Reviewed-by: Kevin Wolf >> >> I had comments for 17 and 19-21, and can't seem to find a base commit >> that patch 22 applies cleanly to, so I'm stopping the review here, >> waiting for another rebase or instructions how to apply the series. > > 16a1b6e97c2a2919fd296db4bea2f9da2ad3cc4d was my base, if that was the > question. ;-) It can be applied to the upstream qemu very easily: s/qmp_marshal_input_/qmp_marshal_/ > > Thanks for reviewing! > > Max > From MAILER-DAEMON Wed Sep 23 04:59:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zeftv-0005oD-24 for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 04:59:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zeftt-0005mg-9J for qemu-block@nongnu.org; Wed, 23 Sep 2015 04:59:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zefts-0000m7-JF for qemu-block@nongnu.org; Wed, 23 Sep 2015 04:59:41 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:8318 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zeftn-0000ka-MY; Wed, 23 Sep 2015 04:59:35 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AnBQB8aAJW/5tjdVtdGQEBAYMIqmEFAYEKmD6CVgKBRjsRAQEBAQEBAYEKhCUBAQQ6PxALDhMlDwEsGwYBiEQBywcBAQEBAQEBAwEBAQEBHYYshUSFDQeELAEEjH2IaqgvNyyEAzyKIAEBAQ X-IPAS-Result: A2AnBQB8aAJW/5tjdVtdGQEBAYMIqmEFAYEKmD6CVgKBRjsRAQEBAQEBAYEKhCUBAQQ6PxALDhMlDwEsGwYBiEQBywcBAQEBAQEBAwEBAQEBHYYshUSFDQeELAEEjH2IaqgvNyyEAzyKIAEBAQ X-IronPort-AV: E=Sophos;i="5.17,577,1437429600"; d="scan'208";a="25170231" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 23 Sep 2015 10:59:33 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1Zeftl-0000nr-6X; Wed, 23 Sep 2015 10:59:33 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1Zeftl-0004qg-0j; Wed, 23 Sep 2015 10:59:33 +0200 From: Alberto Garcia To: Max Reitz , qemu-devel@nongnu.org In-Reply-To: <56018403.5040209@redhat.com> References: <8cc989a360a5fe38839144946c878fb9f8c6a6d5.1442928283.git.berto@igalia.com> <56018403.5040209@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Wed, 23 Sep 2015 10:59:32 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v6 3/4] block: add a 'blockdev-snapshot' QMP command X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 08:59:42 -0000 On Tue 22 Sep 2015 06:38:27 PM CEST, Max Reitz wrote: >> + .name = "blockdev-snapshot", >> + .args_type = "node:s,overlay:s", >> + .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot, > > As of 7fad30f06eb6aa57aaa8f3d264288f24ae7646f0, this needs to be > qmp_marshal_blockdev_snapshot. Sure, that needs to be part of the next rebase, otherwise it won't build. Berto From MAILER-DAEMON Wed Sep 23 05:21:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZegEx-0002mj-5L for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 05:21:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZegEu-0002jK-F2 for qemu-block@nongnu.org; Wed, 23 Sep 2015 05:21:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZegEq-0003ZG-FL for qemu-block@nongnu.org; Wed, 23 Sep 2015 05:21:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48533) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZegEq-0003Yw-8P; Wed, 23 Sep 2015 05:21:20 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 5FE962F9101; Wed, 23 Sep 2015 09:21:19 +0000 (UTC) Received: from work-vm (ovpn-116-119.ams2.redhat.com [10.36.116.119]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8N9LEeB023129 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 23 Sep 2015 05:21:16 -0400 Date: Wed, 23 Sep 2015 10:21:14 +0100 From: "Dr. David Alan Gilbert" To: Wen Congyang Message-ID: <20150923092113.GB2655@work-vm> References: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> <20150922111554.GD3529@work-vm> <5601FBA7.5080700@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5601FBA7.5080700@cn.fujitsu.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , Markus Armbruster , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [PATCH v5 0/4] qapi: child add/delete support X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 09:21:25 -0000 * Wen Congyang (wency@cn.fujitsu.com) wrote: > On 09/22/2015 07:15 PM, Dr. David Alan Gilbert wrote: > > * Wen Congyang (wency@cn.fujitsu.com) wrote: > >> If quorum's child is broken, we can use mirror job to replace it. > >> But sometimes, the user only need to remove the broken child, and > >> add it later when the problem is fixed. > >> > > > > Hi, > > Two questions: > > 1) Do you have an example of a pair of add/remove commands that work > > together? (I'm not quite sure I understand where the ID for the remove > > comes from). > > The command line: > -drive if=virtio,id=disk1,driver=quorum,read-pattern=fifo,vote-threshold=1,children.0.file.filename=/data/images/kvm/suse/suse11_3.img,children.0.driver=raw > > And the QMP monitor command: > {'execute':'blockdev-add', 'arguments':{'options':{'driver': 'raw', 'node-name': 'test1', 'file': {'driver': 'file', 'filename': '/dev/null'}, 'id': 'test11' } } } > {'execute': 'human-monitor-command', 'arguments': {'command-line': 'drive_add buddy driver=nbd,host=192.168.3.1,port=8889,export=colo-disk1,node-name=test2,if=none'}} > {'execute':'x-blockdev-child-add', 'arguments':{'parent': 'disk1', 'child': 'test1' } } > {'execute':'x-blockdev-child-add', 'arguments':{'parent': 'disk1', 'child': 'test2' } } > {'execute': 'x-blockdev-child-del', 'arguments': {'parent': 'disk1', 'child': 'test1' } } > {'execute': 'x-blockdev-child-del', 'arguments': {'parent': 'disk1', 'child': 'test2' } } > > Note: the qmp monitor command doesn't support nbd now, and I use the hmp command to add a BDS. Thank you; OK I see the format has changed quite a bit from the older version; this version is a lot nicer. > > 2) If the child has failed and is not responding to block operations > > at all (e.g a networking failure to an nbd device which may take minutes > > to time out); how do you recover - flush or drain on the devices > > hang at that point. > > If the network fails, the kernel doesn't notify the application... > > > > > (I was trying to test recovery from a failed secondary using the July COLO > > release; but the primary gets stuck in bdrv_drain or bdrv_flush if I kill > > the secondary in the right way). > > IIRC, if the qemu is killed, the connection is closed at the same time. bdrv_drain() > or bdrv_flush() should not get stuck. I use kill -SIGSTOP to the secondary qemu so I think that behaves like the network fails, or if the secondary host just failed completely. You do need some way to recover from the NBD server dieing like that. It sounds like we need some way to be able to remove a blockdev that's failed like that; Paolo suggested the 'disk deadline' series could be used to time something like that out eventually, but maybe you need something that allows you to remove a child more forcibly. Dave > > Thanks > Wen Congyang > > > > > Dave > > > > > >> It is based on the following patch: > >> http://lists.nongnu.org/archive/html/qemu-devel/2015-09/msg04579.html > >> > >> ChangLog: > >> v5: > >> 1. Address Eric Blake's comments > >> v4: > >> 1. drop nbd driver's implementation. We can use human-monitor-command > >> to do it. > >> 2. Rename the command name. > >> v3: > >> 1. Don't open BDS in bdrv_add_child(). Use the existing BDS which is > >> created by the QMP command blockdev-add. > >> 2. The driver NBD can support filename, path, host:port now. > >> v2: > >> 1. Use bdrv_get_device_or_node_name() instead of new function > >> bdrv_get_id_or_node_name() > >> 2. Update the error message > >> 3. Update the documents in block-core.json > >> > >> Wen Congyang (4): > >> Add new block driver interface to add/delete a BDS's child > >> quorum: implement bdrv_add_child() and bdrv_del_child() > >> qmp: add monitor command to add/remove a child > >> hmp: add monitor command to add/remove a child > >> > >> block.c | 56 ++++++++++++++++++++++++++++++++++-- > >> block/quorum.c | 72 +++++++++++++++++++++++++++++++++++++++++++++-- > >> blockdev.c | 48 +++++++++++++++++++++++++++++++ > >> hmp-commands.hx | 28 ++++++++++++++++++ > >> hmp.c | 20 +++++++++++++ > >> hmp.h | 2 ++ > >> include/block/block.h | 8 ++++++ > >> include/block/block_int.h | 5 ++++ > >> qapi/block-core.json | 34 ++++++++++++++++++++++ > >> qmp-commands.hx | 61 +++++++++++++++++++++++++++++++++++++++ > >> 10 files changed, 329 insertions(+), 5 deletions(-) > >> > >> -- > >> 2.4.3 > >> > > -- > > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK > > . > > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK From MAILER-DAEMON Wed Sep 23 05:31:07 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZegOJ-0006Fx-Bb for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 05:31:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZegOG-0006FG-LT for qemu-block@nongnu.org; Wed, 23 Sep 2015 05:31:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZegOD-0007at-9S for qemu-block@nongnu.org; Wed, 23 Sep 2015 05:31:04 -0400 Received: from [59.151.112.132] (port=20464 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZegOC-0007NL-5i; Wed, 23 Sep 2015 05:31:01 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101015339" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 23 Sep 2015 17:33:37 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8N9UXqv002776; Wed, 23 Sep 2015 17:30:33 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 23 Sep 2015 17:30:51 +0800 To: "Dr. David Alan Gilbert" References: <1442907862-21376-1-git-send-email-wency@cn.fujitsu.com> <20150922111554.GD3529@work-vm> <5601FBA7.5080700@cn.fujitsu.com> <20150923092113.GB2655@work-vm> From: Wen Congyang Message-ID: <56027131.8020903@cn.fujitsu.com> Date: Wed, 23 Sep 2015 17:30:25 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150923092113.GB2655@work-vm> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , Markus Armbruster , Stefan Hajnoczi , Yang Hongyang Subject: Re: [Qemu-block] [PATCH v5 0/4] qapi: child add/delete support X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 09:31:06 -0000 On 09/23/2015 05:21 PM, Dr. David Alan Gilbert wrote: > * Wen Congyang (wency@cn.fujitsu.com) wrote: >> On 09/22/2015 07:15 PM, Dr. David Alan Gilbert wrote: >>> * Wen Congyang (wency@cn.fujitsu.com) wrote: >>>> If quorum's child is broken, we can use mirror job to replace it. >>>> But sometimes, the user only need to remove the broken child, and >>>> add it later when the problem is fixed. >>>> >>> >>> Hi, >>> Two questions: >>> 1) Do you have an example of a pair of add/remove commands that work >>> together? (I'm not quite sure I understand where the ID for the remove >>> comes from). >> >> The command line: >> -drive if=virtio,id=disk1,driver=quorum,read-pattern=fifo,vote-threshold=1,children.0.file.filename=/data/images/kvm/suse/suse11_3.img,children.0.driver=raw >> >> And the QMP monitor command: >> {'execute':'blockdev-add', 'arguments':{'options':{'driver': 'raw', 'node-name': 'test1', 'file': {'driver': 'file', 'filename': '/dev/null'}, 'id': 'test11' } } } >> {'execute': 'human-monitor-command', 'arguments': {'command-line': 'drive_add buddy driver=nbd,host=192.168.3.1,port=8889,export=colo-disk1,node-name=test2,if=none'}} >> {'execute':'x-blockdev-child-add', 'arguments':{'parent': 'disk1', 'child': 'test1' } } >> {'execute':'x-blockdev-child-add', 'arguments':{'parent': 'disk1', 'child': 'test2' } } >> {'execute': 'x-blockdev-child-del', 'arguments': {'parent': 'disk1', 'child': 'test1' } } >> {'execute': 'x-blockdev-child-del', 'arguments': {'parent': 'disk1', 'child': 'test2' } } >> >> Note: the qmp monitor command doesn't support nbd now, and I use the hmp command to add a BDS. > > Thank you; OK I see the format has changed quite a bit from the older version; this version > is a lot nicer. > >>> 2) If the child has failed and is not responding to block operations >>> at all (e.g a networking failure to an nbd device which may take minutes >>> to time out); how do you recover - flush or drain on the devices >>> hang at that point. >> >> If the network fails, the kernel doesn't notify the application... >> >>> >>> (I was trying to test recovery from a failed secondary using the July COLO >>> release; but the primary gets stuck in bdrv_drain or bdrv_flush if I kill >>> the secondary in the right way). >> >> IIRC, if the qemu is killed, the connection is closed at the same time. bdrv_drain() >> or bdrv_flush() should not get stuck. > > I use kill -SIGSTOP to the secondary qemu so I think that behaves like the network fails, > or if the secondary host just failed completely. You do need some way to recover from the > NBD server dieing like that. You use SIGSTOP, so there is no error in the connection, and the nbd client will wait the reply. bdrv_drain() will never end in this case. > > It sounds like we need some way to be able to remove a blockdev that's failed like that; > Paolo suggested the 'disk deadline' series could be used to time something like that > out eventually, but maybe you need something that allows you to remove > a child more forcibly. Yes, but quorum will wait bdrv_co_write() return. It is very hard to implement it now... I guess 'disk deadline' can fix these two problems. Thanks Wen Congyang > > Dave > >> >> Thanks >> Wen Congyang >> >>> >>> Dave >>> >>> >>>> It is based on the following patch: >>>> http://lists.nongnu.org/archive/html/qemu-devel/2015-09/msg04579.html >>>> >>>> ChangLog: >>>> v5: >>>> 1. Address Eric Blake's comments >>>> v4: >>>> 1. drop nbd driver's implementation. We can use human-monitor-command >>>> to do it. >>>> 2. Rename the command name. >>>> v3: >>>> 1. Don't open BDS in bdrv_add_child(). Use the existing BDS which is >>>> created by the QMP command blockdev-add. >>>> 2. The driver NBD can support filename, path, host:port now. >>>> v2: >>>> 1. Use bdrv_get_device_or_node_name() instead of new function >>>> bdrv_get_id_or_node_name() >>>> 2. Update the error message >>>> 3. Update the documents in block-core.json >>>> >>>> Wen Congyang (4): >>>> Add new block driver interface to add/delete a BDS's child >>>> quorum: implement bdrv_add_child() and bdrv_del_child() >>>> qmp: add monitor command to add/remove a child >>>> hmp: add monitor command to add/remove a child >>>> >>>> block.c | 56 ++++++++++++++++++++++++++++++++++-- >>>> block/quorum.c | 72 +++++++++++++++++++++++++++++++++++++++++++++-- >>>> blockdev.c | 48 +++++++++++++++++++++++++++++++ >>>> hmp-commands.hx | 28 ++++++++++++++++++ >>>> hmp.c | 20 +++++++++++++ >>>> hmp.h | 2 ++ >>>> include/block/block.h | 8 ++++++ >>>> include/block/block_int.h | 5 ++++ >>>> qapi/block-core.json | 34 ++++++++++++++++++++++ >>>> qmp-commands.hx | 61 +++++++++++++++++++++++++++++++++++++++ >>>> 10 files changed, 329 insertions(+), 5 deletions(-) >>>> >>>> -- >>>> 2.4.3 >>>> >>> -- >>> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK >>> . >>> >> > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK > . > From MAILER-DAEMON Wed Sep 23 08:49:03 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZejTr-00030D-EG for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 08:49:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZejTo-0002zE-Gh for qemu-block@nongnu.org; Wed, 23 Sep 2015 08:49:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZejTj-0001TH-HG for qemu-block@nongnu.org; Wed, 23 Sep 2015 08:49:00 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:28442 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZejTj-0001Iv-Ah; Wed, 23 Sep 2015 08:48:55 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2A0AgDSngJW/5tjdVtdGQEBAYMIgT2pJQEBAQEBAQUBgQoBkxcBDYdzAoFDOBQBAQEBAQEBgQqEJQEBBDo/EAsOCgklDwEsGwYBEogyAcsvAQEBAQEBAQMBAQEBAR2GLIVEhQ0HhCwBBIc0jjOoNR8BAUKEAzwziW0BAQE X-IPAS-Result: A2A0AgDSngJW/5tjdVtdGQEBAYMIgT2pJQEBAQEBAQUBgQoBkxcBDYdzAoFDOBQBAQEBAQEBgQqEJQEBBDo/EAsOCgklDwEsGwYBEogyAcsvAQEBAQEBAQMBAQEBAR2GLIVEhQ0HhCwBBIc0jjOoNR8BAUKEAzwziW0BAQE X-IronPort-AV: E=Sophos;i="5.17,577,1437429600"; d="scan'208";a="25337394" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 23 Sep 2015 14:48:17 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZejT7-0003GE-IO; Wed, 23 Sep 2015 14:48:17 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZejT7-00065R-Co; Wed, 23 Sep 2015 14:48:17 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-5-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-5-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Wed, 23 Sep 2015 14:48:17 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 04/16] quorum: Convert to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 12:49:01 -0000 On Thu 17 Sep 2015 03:48:08 PM CEST, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > block/quorum.c | 63 ++++++++++++++++++++++++++++++---------------------------- Reviewed-by: Alberto Garcia Berto From MAILER-DAEMON Wed Sep 23 09:01:37 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zejg1-0003cr-KL for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 09:01:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zejfw-0003Tr-1Z for qemu-block@nongnu.org; Wed, 23 Sep 2015 09:01:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zejfs-0006lF-0p for qemu-block@nongnu.org; Wed, 23 Sep 2015 09:01:31 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:41028 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zejfr-0006lA-R2; Wed, 23 Sep 2015 09:01:27 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CuBQBdogJW/5tjdVtdGQEBAYMIqmIBAQEBAQEFAYEKAZMlhR2CVgKBRDoSAQEBAQEBAYEKhCUBAQQnEz8QCw4TJQ8BLBsGAYhEAcsqAQEBAQEBAQMBAQEBAR2GLIVEhQ0HhCwBBJVnnA2MKCgIM4IRHIFWPIogAQEB X-IPAS-Result: A2CuBQBdogJW/5tjdVtdGQEBAYMIqmIBAQEBAQEFAYEKAZMlhR2CVgKBRDoSAQEBAQEBAYEKhCUBAQQnEz8QCw4TJQ8BLBsGAYhEAcsqAQEBAQEBAQMBAQEBAR2GLIVEhQ0HhCwBBJVnnA2MKCgIM4IRHIFWPIogAQEB X-IronPort-AV: E=Sophos;i="5.17,577,1437429600"; d="scan'208";a="25342385" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 23 Sep 2015 15:01:21 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1Zejfl-0003Kr-Ln; Wed, 23 Sep 2015 15:01:21 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1Zejfl-0000Mq-FZ; Wed, 23 Sep 2015 15:01:21 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-4-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-4-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Wed, 23 Sep 2015 15:01:21 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 03/16] blkverify: Convert s->test_file to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 13:01:36 -0000 On Thu 17 Sep 2015 03:48:07 PM CEST, Kevin Wolf wrote: > @@ -151,7 +151,7 @@ static void blkverify_close(BlockDriverState *bs) > { > BDRVBlkverifyState *s = bs->opaque; > > - bdrv_unref(s->test_file); > + bdrv_unref_child(bs, s->test_file); > s->test_file = NULL; > } You are using bdrv_unref_child() here whereas in quorum you kept bdrv_unref(). In principle both seem correct because if you don't detach the children in the driver's close function then bdrv_close() will take care of doing it, but is there a reason why you are using different methods? Berto From MAILER-DAEMON Wed Sep 23 09:11:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZejpX-0008K1-EI for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 09:11:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZejpV-0008JJ-99 for qemu-block@nongnu.org; Wed, 23 Sep 2015 09:11:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZejpR-000275-9q for qemu-block@nongnu.org; Wed, 23 Sep 2015 09:11:25 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:19805 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZejpR-00026D-3E; Wed, 23 Sep 2015 09:11:21 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2A0AgB/pAJW/5tjdVtdGQEBAYMIgT2pJQEBAQEBAQUBgQoBkxcBDYdzAoFFOBQBAQEBAQEBgQqEJQEBBDo/EAsOCgklDwEsGwYBEogyAcsrAQEBAQEBBAEBAQEBHYYshUSFDQeELAEElWecDYwoHwEBQoQDPDOJbQEBAQ X-IPAS-Result: A2A0AgB/pAJW/5tjdVtdGQEBAYMIgT2pJQEBAQEBAQUBgQoBkxcBDYdzAoFFOBQBAQEBAQEBgQqEJQEBBDo/EAsOCgklDwEsGwYBEogyAcsrAQEBAQEBBAEBAQEBHYYshUSFDQeELAEElWecDYwoHwEBQoQDPDOJbQEBAQ X-IronPort-AV: E=Sophos;i="5.17,577,1437429600"; d="scan'208";a="25346456" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 23 Sep 2015 15:10:47 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1Zejor-0003dC-4q; Wed, 23 Sep 2015 15:10:45 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1Zejoq-0002UM-VA; Wed, 23 Sep 2015 15:10:45 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-7-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-7-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Wed, 23 Sep 2015 15:10:44 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 06/16] block: Remove bdrv_open_image() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 13:11:26 -0000 On Thu 17 Sep 2015 03:48:10 PM CEST, Kevin Wolf wrote: > It is unused now. > > Signed-off-by: Kevin Wolf Reviewed-by: Alberto Garcia Berto From MAILER-DAEMON Wed Sep 23 09:21:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZejzC-00034C-6D for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 09:21:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zejz9-000330-6z for qemu-block@nongnu.org; Wed, 23 Sep 2015 09:21:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zejz6-0005yu-2c for qemu-block@nongnu.org; Wed, 23 Sep 2015 09:21:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zejz5-0005yo-Qf; Wed, 23 Sep 2015 09:21:19 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id D3EBAA2C3B; Wed, 23 Sep 2015 13:13:02 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-104.ams2.redhat.com [10.36.116.104]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8NDD0AZ018458; Wed, 23 Sep 2015 09:13:00 -0400 Date: Wed, 23 Sep 2015 15:13:00 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150923131300.GC4557@noname.redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-6-git-send-email-kwolf@redhat.com> <56019F9D.9020800@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="rS8CxjVDS/+yyDmU" Content-Disposition: inline In-Reply-To: <56019F9D.9020800@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 05/16] block: Convert bs->file to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 13:21:24 -0000 --rS8CxjVDS/+yyDmU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 22.09.2015 um 20:36 hat Max Reitz geschrieben: > On 17.09.2015 15:48, Kevin Wolf wrote: > > This patch removes the temporary duplication between bs->file and > > bs->file_child by converting everything to BdrvChild. > >=20 > > Signed-off-by: Kevin Wolf > > --- > > block.c | 61 ++++++++++++++++++++++-----------------= ------- > > block/blkdebug.c | 32 ++++++++++++------------ > > block/blkverify.c | 33 ++++++++++++++----------- > > block/bochs.c | 8 +++--- > > block/cloop.c | 10 ++++---- > > block/dmg.c | 20 +++++++-------- > > block/io.c | 50 +++++++++++++++++++------------------- > > block/parallels.c | 38 +++++++++++++++-------------- > > block/qapi.c | 2 +- > > block/qcow.c | 42 +++++++++++++++++--------------- > > block/qcow2-cache.c | 11 +++++---- > > block/qcow2-cluster.c | 38 +++++++++++++++++------------ > > block/qcow2-refcount.c | 45 ++++++++++++++++++---------------- > > block/qcow2-snapshot.c | 30 ++++++++++++----------- > > block/qcow2.c | 62 ++++++++++++++++++++++++---------------= -------- > > block/qed-table.c | 4 +-- > > block/qed.c | 32 ++++++++++++------------ > > block/raw_bsd.c | 40 +++++++++++++++--------------- > > block/snapshot.c | 12 ++++----- > > block/vdi.c | 17 +++++++------ > > block/vhdx-log.c | 25 ++++++++++--------- > > block/vhdx.c | 36 ++++++++++++++------------- > > block/vmdk.c | 27 +++++++++++---------- > > block/vpc.c | 34 ++++++++++++++------------ > > include/block/block.h | 8 +++++- > > include/block/block_int.h | 3 +-- > > 26 files changed, 377 insertions(+), 343 deletions(-) >=20 > Reviewed-by: Max Reitz >=20 > > diff --git a/block.c b/block.c > > index 2e9e5e2..93d713b 100644 > > --- a/block.c > > +++ b/block.c >=20 > [...] >=20 > > @@ -1929,6 +1925,11 @@ void bdrv_close(BlockDriverState *bs) > > bdrv_unref(backing_hd); > > } > > =20 > > + if (bs->file !=3D NULL) { > > + bdrv_unref(bs->file->bs); >=20 > I think we can use bdrv_unref_child(bs->file) here. I'd personally like > it more, at least (because using bdrv_unref() and relying on the loop > below is basically what the comment inside of the loop advises against). >=20 > Yes, I know, eventually, we want to drop this block anyway and let the > loop below handle everything using bdrv_unref_child(). But when we do > that conversion, it'll be obvious to drop a bdrv_unref_child() call, > whereas dropping bdrv_unref() alone isn't so obvious. Seems safe to do, and reads a bit nicer, so I'll change the patch accordingly. Thanks. Kevin > > + bs->file =3D NULL; > > + } > > + > > QLIST_FOREACH_SAFE(child, &bs->children, next, next) { > > /* TODO Remove bdrv_unref() from drivers' close function a= nd use > > * bdrv_unref_child() here */ > > @@ -1953,11 +1954,6 @@ void bdrv_close(BlockDriverState *bs) > > bs->options =3D NULL; > > QDECREF(bs->full_open_options); > > bs->full_open_options =3D NULL; > > - > > - if (bs->file !=3D NULL) { > > - bdrv_unref(bs->file); > > - bs->file =3D NULL; > > - } > > } > > =20 > > if (bs->blk) { >=20 --rS8CxjVDS/+yyDmU Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJWAqVbAAoJEH8JsnLIjy/WeVsQAL06aAa7e0c+UkLPp6zcutKx fuqbOyDYNArPU15SFZtD7o1JaVp/tAQ94p1i6AzCz3cp9n8OLNZsySofqEaHHQiU dY4yGxuowisUoBlB1bBpz045u0oU4qQZWrIKRSV53iIeDi1JPYue+v5Iy5RWY3qy zSOAs8rb/RebzjGDM58Qw4OVryAoTOToL/H6OrN4C4eeMiarg7TwfujxkgSAhCPQ /fMErWovb7Gj9fwjCGRd51W5ZFa1+BAl8Qy10CdeQaErifSPQdRha2B5YGEYCf1A K8UPArkk1Ohzm9wZdPvEGVi9+NFTkXg9cPJNoG5a/ZMiLKrKF0tPL8eS48+2YAmH K8GRB1owxBwG/Xp/N9fLMoFl6AThHUScXegihBf3WM79sL4TQt+R8u6Vm5Zc9oIG 1gZHOySgRCqf7X/Gu/fm3suRwO9GKkqNvJaOwQbk7rQFzURYGdDDoWnaVkyS0W3W QqXiLsFJyQ1um/g8NhosyTIroZjjucp5e8GtRWyEjNRPEkDL3imPo4gJWex0XTVK 5frLHV23lRAFOMLOrqzgeiuGBG08eNURjhNrBzascxRPrJdody2MiMp9ipK7xKie 2zHh1tLQ5qNHqxOXqonZK35WoNA2dUKb1zIf27OAI7rjWzGAQ366PaWlzVIWD1hP K1yGNomR6pUV1G2lh8Xt =OwHD -----END PGP SIGNATURE----- --rS8CxjVDS/+yyDmU-- From MAILER-DAEMON Wed Sep 23 09:24:03 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zek1j-0004hr-HZ for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 09:24:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zek1h-0004hi-AQ for qemu-block@nongnu.org; Wed, 23 Sep 2015 09:24:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zek1e-0006qI-6N for qemu-block@nongnu.org; Wed, 23 Sep 2015 09:24:01 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:52499 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zek1d-0006p1-W7; Wed, 23 Sep 2015 09:23:58 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2A0AgD4pgJW/5tjdVtdGQEBAYMIgT2pJQEBAQEBAQUBgQoBkxcBDYdzAoFFOBQBAQEBAQEBgQqEJQEBBDo/EAsOCgklDwEsGwYBEogyAcsoAQEBAQEBAQMBAQEBAR2GLIVEhQ0HhCwBBIc0jjOoNR8BAUKEAzwziW0BAQE X-IPAS-Result: A2A0AgD4pgJW/5tjdVtdGQEBAYMIgT2pJQEBAQEBAQUBgQoBkxcBDYdzAoFFOBQBAQEBAQEBgQqEJQEBBDo/EAsOCgklDwEsGwYBEogyAcsoAQEBAQEBAQMBAQEBAR2GLIVEhQ0HhCwBBIc0jjOoNR8BAUKEAzwziW0BAQE X-IronPort-AV: E=Sophos;i="5.17,577,1437429600"; d="scan'208";a="25351627" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 23 Sep 2015 15:23:55 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1Zek1b-0003jK-6I; Wed, 23 Sep 2015 15:23:55 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1Zek1b-0004j4-19; Wed, 23 Sep 2015 15:23:55 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-3-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-3-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Wed, 23 Sep 2015 15:23:54 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 02/16] vmdk: Use BdrvChild instead of BDS for references to extents X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 13:24:02 -0000 On Thu 17 Sep 2015 03:48:06 PM CEST, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > block/vmdk.c | 99 +++++++++++++++++++++++++++++++----------------------------- > 1 file changed, 51 insertions(+), 48 deletions(-) Reviewed-by: Alberto Garcia Berto From MAILER-DAEMON Wed Sep 23 09:58:32 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZekZ6-0008Oj-2D for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 09:58:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54657) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZekZ4-0008Ob-So for qemu-block@nongnu.org; Wed, 23 Sep 2015 09:58:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZekZ0-0007ko-Qw for qemu-block@nongnu.org; Wed, 23 Sep 2015 09:58:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34982) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZekZ0-0007kj-MQ; Wed, 23 Sep 2015 09:58:26 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 41AE5A8D; Wed, 23 Sep 2015 13:58:26 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-104.ams2.redhat.com [10.36.116.104]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8NDwNE8019873; Wed, 23 Sep 2015 09:58:24 -0400 Date: Wed, 23 Sep 2015 15:58:23 +0200 From: Kevin Wolf To: Alberto Garcia Message-ID: <20150923135823.GD4557@noname.redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-4-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, armbru@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 03/16] blkverify: Convert s->test_file to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 13:58:31 -0000 Am 23.09.2015 um 15:01 hat Alberto Garcia geschrieben: > On Thu 17 Sep 2015 03:48:07 PM CEST, Kevin Wolf wrote: > > > @@ -151,7 +151,7 @@ static void blkverify_close(BlockDriverState *bs) > > { > > BDRVBlkverifyState *s = bs->opaque; > > > > - bdrv_unref(s->test_file); > > + bdrv_unref_child(bs, s->test_file); > > s->test_file = NULL; > > } > > You are using bdrv_unref_child() here whereas in quorum you kept > bdrv_unref(). > > In principle both seem correct because if you don't detach the children > in the driver's close function then bdrv_close() will take care of doing > it, but is there a reason why you are using different methods? Because consistency is overrated? Or simply carelessness? In the end (not in this series), I'd like to remove all of this from the close functions (as the comment in block.c says) and let it all be handled in bdrv_close(). But until then, we should stay reasonably consistent indeed. VMDK uses bdrv_unref_child() as well, so I guess quorum is the one that should be changed? Kevin From MAILER-DAEMON Wed Sep 23 10:05:25 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zekfl-0003Eg-0S for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 10:05:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zekfj-0003Dc-6l for qemu-block@nongnu.org; Wed, 23 Sep 2015 10:05:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zekff-0001zd-LQ for qemu-block@nongnu.org; Wed, 23 Sep 2015 10:05:23 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:27122 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zekff-0001yG-En; Wed, 23 Sep 2015 10:05:19 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CuBQBnsAJW/5tjdVtdGQEBAYMIqmIBAQEBAQEFAYEKAZMlhR2CVgKBRjoSAQEBAQEBAYEKhCUBAQMBJxM/BQsLDhMlDwEsGwaIOQwByzwBAQEBAQEEAQEBAR6GLIVEhQ0HhCwBBJVnnA2MKCgNLoIRHIFWPIogAQEB X-IPAS-Result: A2CuBQBnsAJW/5tjdVtdGQEBAYMIqmIBAQEBAQEFAYEKAZMlhR2CVgKBRjoSAQEBAQEBAYEKhCUBAQMBJxM/BQsLDhMlDwEsGwaIOQwByzwBAQEBAQEEAQEBAR6GLIVEhQ0HhCwBBJVnnA2MKCgNLoIRHIFWPIogAQEB X-IronPort-AV: E=Sophos;i="5.17,577,1437429600"; d="scan'208";a="25752609" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 23 Sep 2015 16:05:17 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1Zekfc-0004Js-Fn; Wed, 23 Sep 2015 16:05:16 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1Zekfc-00051o-AM; Wed, 23 Sep 2015 16:05:16 +0200 From: Alberto Garcia To: Kevin Wolf In-Reply-To: <20150923135823.GD4557@noname.redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-4-git-send-email-kwolf@redhat.com> <20150923135823.GD4557@noname.redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Wed, 23 Sep 2015 16:05:16 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: qemu-block@nongnu.org, armbru@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 03/16] blkverify: Convert s->test_file to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 14:05:24 -0000 On Wed 23 Sep 2015 03:58:23 PM CEST, Kevin Wolf wrote: >> > @@ -151,7 +151,7 @@ static void blkverify_close(BlockDriverState *bs) >> > { >> > BDRVBlkverifyState *s = bs->opaque; >> > >> > - bdrv_unref(s->test_file); >> > + bdrv_unref_child(bs, s->test_file); >> > s->test_file = NULL; >> > } >> >> You are using bdrv_unref_child() here whereas in quorum you kept >> bdrv_unref(). >> >> In principle both seem correct because if you don't detach the >> children in the driver's close function then bdrv_close() will take >> care of doing it, but is there a reason why you are using different >> methods? > > Because consistency is overrated? Or simply carelessness? Ah ok :-) > VMDK uses bdrv_unref_child() as well, so I guess quorum is the one > that should be changed? You can keep my R-b if you do so. Berto From MAILER-DAEMON Wed Sep 23 10:11:56 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zekm3-0008BS-Rk for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 10:11:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zekm1-00086k-EH for qemu-block@nongnu.org; Wed, 23 Sep 2015 10:11:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zeklx-0006tB-EU for qemu-block@nongnu.org; Wed, 23 Sep 2015 10:11:53 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:8893 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zeklx-0006sn-7Z; Wed, 23 Sep 2015 10:11:49 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2A0AgCXsgJW/5tjdVtdGQEBAYMIgT2pJQEBAQEBAQUBgQoBkxcBDYdzAoFGOBQBAQEBAQEBgQqEJQEBBCcTPxALDgoJJQ8BLBsGARKIMgHLQQEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsAQSHNI4znA2MKB8BAUKEAzwziW0BAQE X-IPAS-Result: A2A0AgCXsgJW/5tjdVtdGQEBAYMIgT2pJQEBAQEBAQUBgQoBkxcBDYdzAoFGOBQBAQEBAQEBgQqEJQEBBCcTPxALDgoJJQ8BLBsGARKIMgHLQQEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsAQSHNI4znA2MKB8BAUKEAzwziW0BAQE X-IronPort-AV: E=Sophos;i="5.17,577,1437429600"; d="scan'208";a="25754896" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 23 Sep 2015 16:11:48 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1Zeklv-0004Ma-LC; Wed, 23 Sep 2015 16:11:47 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1Zeklv-00060U-Fl; Wed, 23 Sep 2015 16:11:47 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-4-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-4-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Wed, 23 Sep 2015 16:11:47 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 03/16] blkverify: Convert s->test_file to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 14:11:54 -0000 On Thu 17 Sep 2015 03:48:07 PM CEST, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > block/blkverify.c | 41 +++++++++++++++++++++-------------------- > 1 file changed, 21 insertions(+), 20 deletions(-) > Reviewed-by: Alberto Garcia Berto From MAILER-DAEMON Wed Sep 23 10:26:44 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zel0O-0001pQ-4x for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 10:26:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zel0K-0001m1-Sx for qemu-block@nongnu.org; Wed, 23 Sep 2015 10:26:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zel0H-0005mw-O6 for qemu-block@nongnu.org; Wed, 23 Sep 2015 10:26:40 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:11046 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zel0H-0005l8-I4; Wed, 23 Sep 2015 10:26:37 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2A0AgBAtgJW/5tjdVtdGQEBAYMIgT2pJQEBAQEBAQUBgQoBkxcBDYdzAoFHOBQBAQEBAQEBgQqEJQEBBCcTPxALDgoJJQ8BLBsGARKIMgHLRAEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsAQSVZ5wNjCgfAQFChAM8M4ltAQEB X-IPAS-Result: A2A0AgBAtgJW/5tjdVtdGQEBAYMIgT2pJQEBAQEBAQUBgQoBkxcBDYdzAoFHOBQBAQEBAQEBgQqEJQEBBCcTPxALDgoJJQ8BLBsGARKIMgHLRAEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsAQSVZ5wNjCgfAQFChAM8M4ltAQEB X-IronPort-AV: E=Sophos;i="5.17,577,1437429600"; d="scan'208";a="25759377" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 23 Sep 2015 16:26:21 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1Zel00-0004Tp-0t; Wed, 23 Sep 2015 16:26:20 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1Zekzz-0000Nm-RO; Wed, 23 Sep 2015 16:26:19 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-2-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-2-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Wed, 23 Sep 2015 16:26:19 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 01/16] block: Introduce BDS.file_child X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 14:26:41 -0000 On Thu 17 Sep 2015 03:48:05 PM CEST, Kevin Wolf wrote: > Store the BdrvChild for bs->file. At this point, bs->file_child->bs just > duplicates the bs->file pointer. Later, it will completely replace it. > > Signed-off-by: Kevin Wolf > --- Reviewed-by: Alberto Garcia Berto From MAILER-DAEMON Wed Sep 23 10:54:25 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZelRB-0002uR-Mh for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 10:54:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZelR5-0002sf-Ii for qemu-block@nongnu.org; Wed, 23 Sep 2015 10:54:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZelR0-0002sV-G7 for qemu-block@nongnu.org; Wed, 23 Sep 2015 10:54:19 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:30598 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZelR0-0002s9-9d; Wed, 23 Sep 2015 10:54:14 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CuBQApvAJW/5tjdVtdGQEBAYMIgT2pJQEBAQEBAQUBgQoBkyWHcwKBRzkTAQEBAQEBAYEKhCUBAQQnEz8QCw4TJQ8BLBsGARKIMgHLQwEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsAQSVZ6g1IgFAghEcgVY8M4ltAQEB X-IPAS-Result: A2CuBQApvAJW/5tjdVtdGQEBAYMIgT2pJQEBAQEBAQUBgQoBkyWHcwKBRzkTAQEBAQEBAYEKhCUBAQQnEz8QCw4TJQ8BLBsGARKIMgHLQwEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsAQSVZ6g1IgFAghEcgVY8M4ltAQEB X-IronPort-AV: E=Sophos;i="5.17,577,1437429600"; d="scan'208";a="25767866" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 23 Sep 2015 16:54:11 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZelQx-0004fQ-Er; Wed, 23 Sep 2015 16:54:11 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZelQx-00059v-8t; Wed, 23 Sep 2015 16:54:11 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-6-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-6-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Wed, 23 Sep 2015 16:54:11 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 05/16] block: Convert bs->file to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 14:54:24 -0000 On Thu 17 Sep 2015 03:48:09 PM CEST, Kevin Wolf wrote: > @@ -1929,6 +1925,11 @@ void bdrv_close(BlockDriverState *bs) > bdrv_unref(backing_hd); > } > > + if (bs->file != NULL) { > + bdrv_unref(bs->file->bs); > + bs->file = NULL; > + } > + With Max's suggestion of using bdrv_unref_child(bs->file) instead, Reviewed-by: Alberto Garcia Berto From MAILER-DAEMON Wed Sep 23 11:22:48 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zelse-0000NW-H7 for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 11:22:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zelsb-0000Mk-JW for qemu-block@nongnu.org; Wed, 23 Sep 2015 11:22:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZelsY-00084G-GJ for qemu-block@nongnu.org; Wed, 23 Sep 2015 11:22:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52917) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZelsY-000841-6u; Wed, 23 Sep 2015 11:22:42 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 5818E8E697; Wed, 23 Sep 2015 15:22:41 +0000 (UTC) Received: from [10.36.116.28] (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8NFMbrL015366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 23 Sep 2015 11:22:39 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-9-git-send-email-kwolf@redhat.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <5602C3BD.4060704@redhat.com> Date: Wed, 23 Sep 2015 17:22:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-9-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hf4LJLdGl710CUNoSvk7qggiUmk3mDkJc" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 08/16] block: Manage backing file references in bdrv_set_backing_hd() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 15:22:47 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --hf4LJLdGl710CUNoSvk7qggiUmk3mDkJc Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > This simplifies the code somewhat, especially when dropping whole > backing file subchains. >=20 > The exception is the mirroring code that does adventurous things with > bdrv_swap() and in order to keep it working, I had to duplicate most of= > bdrv_set_backing_hd() locally. We'll get rid again of this ugliness > shortly. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 35 ++++++++++++++--------------------- > block/mirror.c | 17 ++++++++++++----- > block/stream.c | 21 --------------------- > block/vvfat.c | 6 +++++- > include/block/block.h | 1 + > 5 files changed, 32 insertions(+), 48 deletions(-) >=20 > diff --git a/block.c b/block.c > index fb94567..743f82e 100644 > --- a/block.c > +++ b/block.c > @@ -1094,7 +1094,7 @@ static BdrvChild *bdrv_attach_child(BlockDriverSt= ate *parent_bs, > return child; > } > =20 > -static void bdrv_detach_child(BdrvChild *child) > +void bdrv_detach_child(BdrvChild *child) > { > QLIST_REMOVE(child, next); > g_free(child); > @@ -1112,13 +1112,20 @@ void bdrv_unref_child(BlockDriverState *parent,= BdrvChild *child) > bdrv_unref(child_bs); > } > =20 > +/* > + * Sets the backing file link of a BDS. A new reference is created; ca= llers > + * which don't need their own reference any more must call bdrv_unref(= ). > + */ > void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backi= ng_hd) > { > + if (backing_hd) { > + bdrv_ref(backing_hd); > + } > =20 > if (bs->backing) { > assert(bs->backing_blocker); > bdrv_op_unblock_all(bs->backing->bs, bs->backing_blocker); > - bdrv_detach_child(bs->backing); > + bdrv_unref_child(bs, bs->backing); > } else if (backing_hd) { > error_setg(&bs->backing_blocker, > "node is used as backing hd of '%s'", > @@ -1214,7 +1221,10 @@ int bdrv_open_backing_file(BlockDriverState *bs,= QDict *options, Error **errp) > goto free_exit; > } > =20 > + /* Hook up the backing file link; drop our reference, bs owns the > + * backing_hd reference now */ > bdrv_set_backing_hd(bs, backing_hd); > + bdrv_unref(backing_hd); > =20 > free_exit: > g_free(backing_filename); > @@ -1884,11 +1894,7 @@ void bdrv_close(BlockDriverState *bs) > =20 > bs->drv->bdrv_close(bs); > =20 > - if (bs->backing) { > - BlockDriverState *backing_hd =3D bs->backing->bs; > - bdrv_set_backing_hd(bs, NULL); > - bdrv_unref(backing_hd); > - } > + bdrv_set_backing_hd(bs, NULL); > =20 > if (bs->file !=3D NULL) { > bdrv_unref(bs->file->bs); > @@ -2427,12 +2433,9 @@ int bdrv_drop_intermediate(BlockDriverState *act= ive, BlockDriverState *top, > BlockDriverState *intermediate; > BlockDriverState *base_bs =3D NULL; > BlockDriverState *new_top_bs =3D NULL; > - BlkIntermediateStates *intermediate_state, *next; > + BlkIntermediateStates *intermediate_state; > int ret =3D -EIO; > =20 > - QSIMPLEQ_HEAD(states_to_delete, BlkIntermediateStates) states_to_d= elete; > - QSIMPLEQ_INIT(&states_to_delete); > - > if (!top->drv || !base->drv) { > goto exit; > } > @@ -2459,7 +2462,6 @@ int bdrv_drop_intermediate(BlockDriverState *acti= ve, BlockDriverState *top, > while (intermediate) { > intermediate_state =3D g_new0(BlkIntermediateStates, 1); > intermediate_state->bs =3D intermediate; > - QSIMPLEQ_INSERT_TAIL(&states_to_delete, intermediate_state, en= try); > =20 > if (backing_bs(intermediate) =3D=3D base) { > base_bs =3D backing_bs(intermediate); > @@ -2482,17 +2484,8 @@ int bdrv_drop_intermediate(BlockDriverState *act= ive, BlockDriverState *top, > } > bdrv_set_backing_hd(new_top_bs, base_bs); > =20 > - QSIMPLEQ_FOREACH_SAFE(intermediate_state, &states_to_delete, entry= , next) { > - /* so that bdrv_close() does not recursively close the chain *= / > - bdrv_set_backing_hd(intermediate_state->bs, NULL); > - bdrv_unref(intermediate_state->bs); > - } > ret =3D 0; > - > exit: > - QSIMPLEQ_FOREACH_SAFE(intermediate_state, &states_to_delete, entry= , next) { > - g_free(intermediate_state); > - } > return ret; > } > =20 To me that begs the question why before we didn't simply bdrv_ref(base_bs), and then bdrv_unref(top). Well, now it's even simpler, so that's good. > diff --git a/block/mirror.c b/block/mirror.c > index 259e11a..571da27 100644 > --- a/block/mirror.c > +++ b/block/mirror.c > @@ -370,11 +370,18 @@ static void mirror_exit(BlockJob *job, void *opaq= ue) > bdrv_swap(s->target, to_replace); > if (s->common.driver->job_type =3D=3D BLOCK_JOB_TYPE_COMMIT) {= > /* drop the bs loop chain formed by the swap: break the lo= op then > - * trigger the unref from the top one */ > - BlockDriverState *p =3D s->base->backing > - ? s->base->backing->bs : NULL; > - bdrv_set_backing_hd(s->base, NULL); > - bdrv_unref(p); > + * trigger the unref */ > + /* FIXME This duplicates bdrv_set_backing_hd(), except for= the > + * actual detach/unref so that the loop can be broken. Whe= n > + * bdrv_swap() gets replaced, this will become sane again.= */ > + BlockDriverState *backing =3D s->base->backing->bs; > + assert(s->base->backing_blocker); > + bdrv_op_unblock_all(s->base->backing->bs, s->base->backing= _blocker); I know it's dropped later on anwyay, but I can't stop my fingers from suggesting s/s->base->backing->bs/backing/. Anyway, with or without that: Reviewed-by: Max Reitz --hf4LJLdGl710CUNoSvk7qggiUmk3mDkJc Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAsO9AAoJEDuxQgLoOKyt5CcH/1sqDHCHL4qcN07QDbZ/bIb0 +v06SuG6DNbnwaxknrBBbKJ84Nn02HNT9mmCaMCNz3ApmIKPxR5yS8mfZwoTxWg4 bZEU+IpLYQ7BVimvFnH5U9KEXxP8DuYuFSm22dcAI/Blld1BobLGPorYldq9pAJk TNv1MkormuSq0ovozfwZnjo7+ByZqi2UsMToCmYPM5pJ2uPSxdETBKjzoasNUw2g UC5rTCOb3I4bS7VCEpn1z7acHlRs95+7JiLxu+SmCj46A41W2QN9/YR2sQH3d7ZQ qiBEeayAyZ6lolaJkwNzEL1fxrS1OnDQn60EQKC02vGYQnxmG+c0l3a4l91bpKE= =C9Zu -----END PGP SIGNATURE----- --hf4LJLdGl710CUNoSvk7qggiUmk3mDkJc-- From MAILER-DAEMON Wed Sep 23 11:41:13 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZemAT-0005jB-DB for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 11:41:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZemAM-0005ae-1J for qemu-block@nongnu.org; Wed, 23 Sep 2015 11:41:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZemAH-0008AX-2f for qemu-block@nongnu.org; Wed, 23 Sep 2015 11:41:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48363) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZemAG-00089o-UM; Wed, 23 Sep 2015 11:41:01 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 551668EA3E; Wed, 23 Sep 2015 15:41:00 +0000 (UTC) Received: from [10.36.116.28] (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8NFetkl025676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 23 Sep 2015 11:40:58 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-11-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <5602C806.1050807@redhat.com> Date: Wed, 23 Sep 2015 17:40:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-11-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lXpE5cnOfuKWpMlBcLwD0GFTqOMMk1RcN" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 10/16] block/io: Make bdrv_requests_pending() public X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 15:41:11 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --lXpE5cnOfuKWpMlBcLwD0GFTqOMMk1RcN Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > block/io.c | 2 +- > include/block/block_int.h | 1 + > 2 files changed, 2 insertions(+), 1 deletion(-) Reviewed-by: Max Reitz In addition: Shouldn't we iterate over all children in that function instead of just file and backing? Max --lXpE5cnOfuKWpMlBcLwD0GFTqOMMk1RcN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAsgGAAoJEDuxQgLoOKytGtkH/3ci5vr1nwyRCyqARRPwzqK4 boyRVs6FOPSAwiJGvMQRGVbRtQ4xV+7KHWAg6MHSy8pavf+jseQqci0a5pFRSGHm 2GZaQvhhpb3jR7uYCCIFDkIZeuEDu5ZzfK16wvkiHVXqMF0Eh3n+JUwCCnGKQ/cd kwHcnzbQASlQGekwuWeolK33+KpYZ5olZdHCXAJxlEQ30jDpDx+B5mzUHoZGveXt SZ/ZzOz3v/UudteJ1VPoCntT/p7xJqmDiaxrR+dlKPFtvt/r9FUzi9Fzl4ukSxvX d1vsNEhYzW5n8C8qGG8dfO2GQzjeVCBirk+8P9s1Y72HGm+3CTeorsCZtlv0q2w= =HeOk -----END PGP SIGNATURE----- --lXpE5cnOfuKWpMlBcLwD0GFTqOMMk1RcN-- From MAILER-DAEMON Wed Sep 23 11:46:14 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZemFK-0001fK-MJ for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 11:46:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZemFJ-0001dC-7J for qemu-block@nongnu.org; Wed, 23 Sep 2015 11:46:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZemFF-0001z6-7I for qemu-block@nongnu.org; Wed, 23 Sep 2015 11:46:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZemFF-0001yl-0v; Wed, 23 Sep 2015 11:46:09 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 949AEC0B91A9; Wed, 23 Sep 2015 15:46:08 +0000 (UTC) Received: from [10.36.116.28] (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8NFk5nX002216 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 23 Sep 2015 11:46:06 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-12-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <5602C93C.4060305@redhat.com> Date: Wed, 23 Sep 2015 17:46:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-12-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hk5JNJIltBNQLTod08bqoaOvSMovML4xu" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 11/16] block-backend: Add blk_set_bs() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 15:46:14 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --hk5JNJIltBNQLTod08bqoaOvSMovML4xu Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > It allows changing the BlockDriverState that a BlockBackend points to. >=20 > Signed-off-by: Kevin Wolf > --- > block/block-backend.c | 16 ++++++++++++++++ > include/block/block_int.h | 2 ++ > 2 files changed, 18 insertions(+) >=20 > diff --git a/block/block-backend.c b/block/block-backend.c > index c2e8732..a2afcff 100644 > --- a/block/block-backend.c > +++ b/block/block-backend.c > @@ -239,6 +239,22 @@ BlockDriverState *blk_bs(BlockBackend *blk) > } > =20 > /* > + * Changes the BlockDriverState attached to @blk > + */ > +void blk_set_bs(BlockBackend *blk, BlockDriverState *bs) > +{ > + bdrv_ref(bs); > + > + if (blk->bs) { > + blk->bs->blk =3D NULL; > + bdrv_unref(blk->bs); > + } > + > + blk->bs =3D bs; > + bs->blk =3D blk; > +} > + > +/* As discussed in the BlockBackend and media thread, you should probably assert(bs->blk =3D=3D NULL), and I'd rather have this implemented as blk_remove_bs(blk); blk_insert_bs(blk, bs);, but that's probably something that won't happen until I do so myself. Max > * Return @blk's DriveInfo if any, else null. > */ > DriveInfo *blk_legacy_dinfo(BlockBackend *blk) > diff --git a/include/block/block_int.h b/include/block/block_int.h > index 4598101..cfcae52 100644 > --- a/include/block/block_int.h > +++ b/include/block/block_int.h > @@ -659,6 +659,8 @@ void backup_start(BlockDriverState *bs, BlockDriver= State *target, > BlockCompletionFunc *cb, void *opaque, > Error **errp); > =20 > +void blk_set_bs(BlockBackend *blk, BlockDriverState *bs); > + > void blk_dev_change_media_cb(BlockBackend *blk, bool load); > bool blk_dev_has_removable_media(BlockBackend *blk); > void blk_dev_eject_request(BlockBackend *blk, bool force); >=20 --hk5JNJIltBNQLTod08bqoaOvSMovML4xu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAsk8AAoJEDuxQgLoOKyt59YIAIom4on81Ebz7IpUyaZ0HgKC 6O96xV+3MPWz9xcsrvQyo7BnmwtQsIuhwp7wFoZ1SHFs6tn9u9IxqU0ivtAz4Kjk dWVeAmfewnSz28FldYCtG6JOBP/WWMkX23E3fZEPS8T/V/egYouVGm7MiYHgh085 Mszu++aj0LQNvagBEkCnG9I+XKAy35wU94/p2jeMwQSX4DEsMMxvSKJgzqbZPwcT 2GW6eIpjI7qy/FTHRVWOjHkXvFPzVn5qOGJw3aLvcSyGW/QezpRJKg8fex3k+uKO im694ezcnuxJVeuTS0B4ydhMl6NUtir/uMG12JZMPnKEqDw6cnejnwLWW/ciHdQ= =tHAa -----END PGP SIGNATURE----- --hk5JNJIltBNQLTod08bqoaOvSMovML4xu-- From MAILER-DAEMON Wed Sep 23 11:51:48 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZemKi-0007YC-Lv for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 11:51:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZemKg-0007Xv-2m for qemu-block@nongnu.org; Wed, 23 Sep 2015 11:51:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZemKc-0005CU-0v for qemu-block@nongnu.org; Wed, 23 Sep 2015 11:51:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51810) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZemKb-0005CM-S5; Wed, 23 Sep 2015 11:51:41 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 5CFBE2FAA61; Wed, 23 Sep 2015 15:51:41 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-104.ams2.redhat.com [10.36.116.104]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8NFpbZG028782; Wed, 23 Sep 2015 11:51:38 -0400 Date: Wed, 23 Sep 2015 17:51:37 +0200 From: Kevin Wolf To: Max Reitz Message-ID: <20150923155137.GE4557@noname.redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-12-git-send-email-kwolf@redhat.com> <5602C93C.4060305@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="DSayHWYpDlRfCAAQ" Content-Disposition: inline In-Reply-To: <5602C93C.4060305@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 11/16] block-backend: Add blk_set_bs() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 15:51:47 -0000 --DSayHWYpDlRfCAAQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 23.09.2015 um 17:46 hat Max Reitz geschrieben: > On 17.09.2015 15:48, Kevin Wolf wrote: > > It allows changing the BlockDriverState that a BlockBackend points to. > >=20 > > Signed-off-by: Kevin Wolf > > --- > > block/block-backend.c | 16 ++++++++++++++++ > > include/block/block_int.h | 2 ++ > > 2 files changed, 18 insertions(+) > >=20 > > diff --git a/block/block-backend.c b/block/block-backend.c > > index c2e8732..a2afcff 100644 > > --- a/block/block-backend.c > > +++ b/block/block-backend.c > > @@ -239,6 +239,22 @@ BlockDriverState *blk_bs(BlockBackend *blk) > > } > > =20 > > /* > > + * Changes the BlockDriverState attached to @blk > > + */ > > +void blk_set_bs(BlockBackend *blk, BlockDriverState *bs) > > +{ > > + bdrv_ref(bs); > > + > > + if (blk->bs) { > > + blk->bs->blk =3D NULL; > > + bdrv_unref(blk->bs); > > + } > > + > > + blk->bs =3D bs; > > + bs->blk =3D blk; > > +} > > + > > +/* >=20 > As discussed in the BlockBackend and media thread, you should probably > assert(bs->blk =3D=3D NULL), Yes, my current branch has this already. > and I'd rather have this implemented as > blk_remove_bs(blk); blk_insert_bs(blk, bs);, but that's probably > something that won't happen until I do so myself. Let's see which series hits master first. If yours is first, I'll happily change this patch to make use of the new functions; otherwise, you get to rebase. Kevin --DSayHWYpDlRfCAAQ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJWAsqJAAoJEH8JsnLIjy/W4lkP/2MYv70IIhAcyzODCcAQvsYg 2vyT2/TFTPbtb6hsADyLgfcYLI1uOK8MiOjU39MmtlL4ZyRRAFuudRuCNKpyQFlK 8En2Tw6BTZmf626cwEoqCDVJAtayBBZsmOrTs5tIVZ6btn+KVRViyuXZZ1VzVTyl EHmIEkb104kYzzw3zfzw3H0yXMBOX6GAZUY65vXVJwAZobu4qEsmu3uR2eIjZdtz z2+NIuM8PtnPnIDGw05nwVcASFPyWKLiC2/mEz6wbyVdt9gmt6zjH1MlV73HypEb mmB2hi6MPei1cGot7U/C3ZZu2t/Ivxt/SjEEpFYqsCnWuRgWYifMRBlQDa0IMU7A 4gwj5Wab5a/hQJOhM0ccnYRMPJjoqfoqHuBEEiNB5FGKdVZpPefNvqm6WbWG6eLk BBv3FGjWqT0j64pjppjy6IzE8tIELR1e99xMfOkBvpQ8ul7TzmfP71Op9U6gqQb5 A8l70IF3hUCGpNYHUay8S1C0RAvM+Gy/fhtOnzNMlbJDyvuZpKG7A0HTpR8s8Zth OsXN5e3DCqwv1pvQBRdCEA6+muaG98kQEcvmkGBw6RUpEL0gwBgzA+tYmCYj256E XIMsdkgf1R86+F1KaqDsNGpkY5tETgVoX2Ud18cFLvKVjNsMzbuDzhdtBbUzTAsj hXOfPBBPBvxO1Utvo94W =ARax -----END PGP SIGNATURE----- --DSayHWYpDlRfCAAQ-- From MAILER-DAEMON Wed Sep 23 12:37:06 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zen2Y-0002kT-D9 for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 12:37:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zen2V-0002gV-Cz for qemu-block@nongnu.org; Wed, 23 Sep 2015 12:37:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zen2Q-0000ed-RF for qemu-block@nongnu.org; Wed, 23 Sep 2015 12:37:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34650) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zen2Q-0000eV-K9; Wed, 23 Sep 2015 12:36:58 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 40702FA9D4; Wed, 23 Sep 2015 16:36:58 +0000 (UTC) Received: from [10.36.116.28] (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8NGasqp002692 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 23 Sep 2015 12:36:56 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-10-git-send-email-kwolf@redhat.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <5602D520.3050303@redhat.com> Date: Wed, 23 Sep 2015 18:36:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-10-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="aMl8xfrvU8DQKOWPFlTcNOTbCDNdjps59" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 09/16] block: Split bdrv_move_feature_fields() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 16:37:04 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --aMl8xfrvU8DQKOWPFlTcNOTbCDNdjps59 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > After bdrv_swap(), some fields must be moved back to their original BDS= > to compensate for the effects that a swap of the contents of the object= s > has while keeping the old addresses. Other fields must be moved back > because they should logically be moved and must stay on top >=20 > When replacing bdrv_swap() with operations changing the pointers in the= > parents, we only need the latter and must avoid swapping the former. > Split the function accordingly. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) >=20 > diff --git a/block.c b/block.c > index 743f82e..7930f3c 100644 > --- a/block.c > +++ b/block.c > @@ -1984,6 +1984,8 @@ static void bdrv_rebind(BlockDriverState *bs) > } > } > =20 > +/* Fields that need to stay with the top-level BDS, no matter whether = the > + * address of the top-level BDS stays the same or not. */ > static void bdrv_move_feature_fields(BlockDriverState *bs_dest, > BlockDriverState *bs_src) > { > @@ -2019,7 +2021,13 @@ static void bdrv_move_feature_fields(BlockDriver= State *bs_dest, > =20 > /* dirty bitmap */ > bs_dest->dirty_bitmaps =3D bs_src->dirty_bitmaps; > +} > =20 > +/* Fields that only need to be swapped if the contents of BDSes is swa= pped > + * rather than pointers being changed in the parents. */ > +static void bdrv_move_reference_fields(BlockDriverState *bs_dest, > + BlockDriverState *bs_src) > +{ > /* reference count */ > bs_dest->refcnt =3D bs_src->refcnt; > =20 I'm not sure whether the op blockers should be moved in this function... I think they should be moved in bdrv_move_feasture_fields(), because they generally depend on the position within the node graph and not on the BDS itself, don't they? Max > @@ -2090,6 +2098,10 @@ void bdrv_swap(BlockDriverState *bs_new, BlockDr= iverState *bs_old) > bdrv_move_feature_fields(bs_old, bs_new); > bdrv_move_feature_fields(bs_new, &tmp); > =20 > + bdrv_move_reference_fields(&tmp, bs_old); > + bdrv_move_reference_fields(bs_old, bs_new); > + bdrv_move_reference_fields(bs_new, &tmp); > + > /* bs_new must remain unattached */ > assert(!bs_new->blk); > =20 >=20 --aMl8xfrvU8DQKOWPFlTcNOTbCDNdjps59 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEbBAEBCAAGBQJWAtUgAAoJEDuxQgLoOKyt0tEH92eIghCJGsHvPBx3mCJqSMVP Y7o82dx4coQn4kXnv9utE4cRVlJsXE1v8t9hG82vMfNBhJxwrV6X+ziqGKQMyrFK SJrK6WO/0bAAARGfvlo1T+S0o+E4qBeDh5ZHflD9XjoVXZT9a10IyR6Hqgz+7GMs AF6iF2fcPxs+6FazzPOOhjYxhz0JmNhBJ7S1DGlXfPsn5wjy6EwqZ6A3FrSjV1oq JGl/D1QW0LY8NCtiIvaZEvLbh2yTB10pPNms7pSJM1aQYMMPtOpSgCIuh8fMybqQ qq8iqg8ZeNSsFT2Tjm2to8ovwfxlihfQArJudhU+MyEPtYQN1yx9AvYbxax/rA== =Tzrp -----END PGP SIGNATURE----- --aMl8xfrvU8DQKOWPFlTcNOTbCDNdjps59-- From MAILER-DAEMON Wed Sep 23 12:37:06 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zen2Y-0002kr-Gx for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 12:37:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zen2U-0002fe-TI for qemu-block@nongnu.org; Wed, 23 Sep 2015 12:37:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zen2R-0000f7-Pm for qemu-block@nongnu.org; Wed, 23 Sep 2015 12:37:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43367) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zen2R-0000em-Gn; Wed, 23 Sep 2015 12:36:59 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 21B5FC0B1B2F; Wed, 23 Sep 2015 16:36:59 +0000 (UTC) Received: from [10.36.116.28] (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8NGasm8032250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 23 Sep 2015 12:36:56 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-14-git-send-email-kwolf@redhat.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <5602D522.5030905@redhat.com> Date: Wed, 23 Sep 2015 18:36:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-14-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="HFJ0xrC6n6BTq1JrQIjrU7iGB4AfkaL6F" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 13/16] block: Implement bdrv_append() without bdrv_swap() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 16:37:04 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --HFJ0xrC6n6BTq1JrQIjrU7iGB4AfkaL6F Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > Remember all parent nodes and just change the pointers there instead of= > swapping the contents of the BlockDriverState. >=20 > Handling of snapshot=3Don must be moved further down in bdrv_open() > because *pbs (which is the bs pointer in the BlockBackend) must already= > be set before bdrv_append() is called. Otherwise bdrv_append() changes > the BB's pointer to the temporary snapshot, but bdrv_open() overwrites > it with the read-only original image. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++---------= -------- > 1 file changed, 81 insertions(+), 28 deletions(-) >=20 > diff --git a/block.c b/block.c > index c196f83..98fc17c 100644 > --- a/block.c > +++ b/block.c > @@ -1516,15 +1516,6 @@ static int bdrv_open_inherit(BlockDriverState **= pbs, const char *filename, > =20 > bdrv_refresh_filename(bs); > =20 > - /* For snapshot=3Don, create a temporary qcow2 overlay. bs points = to the > - * temporary snapshot afterwards. */ > - if (snapshot_flags) { > - ret =3D bdrv_append_temp_snapshot(bs, snapshot_flags, &local_e= rr); > - if (local_err) { > - goto close_and_fail; > - } > - } > - > /* Check if any unknown options were used */ > if (options && (qdict_size(options) !=3D 0)) { > const QDictEntry *entry =3D qdict_first(options); > @@ -1556,6 +1547,16 @@ static int bdrv_open_inherit(BlockDriverState **= pbs, const char *filename, > =20 > QDECREF(options); > *pbs =3D bs; > + > + /* For snapshot=3Don, create a temporary qcow2 overlay. bs points = to the > + * temporary snapshot afterwards. */ > + if (snapshot_flags) { > + ret =3D bdrv_append_temp_snapshot(bs, snapshot_flags, &local_e= rr); > + if (local_err) { > + goto close_and_fail; > + } > + } > + > return 0; > =20 > fail: > @@ -1999,20 +2000,6 @@ static void bdrv_move_feature_fields(BlockDriver= State *bs_dest, > =20 > bs_dest->enable_write_cache =3D bs_src->enable_write_cache; > =20 > - /* i/o throttled req */ > - bs_dest->throttle_state =3D bs_src->throttle_state, > - bs_dest->io_limits_enabled =3D bs_src->io_limits_enabled; > - bs_dest->pending_reqs[0] =3D bs_src->pending_reqs[0]; > - bs_dest->pending_reqs[1] =3D bs_src->pending_reqs[1]; > - bs_dest->throttled_reqs[0] =3D bs_src->throttled_reqs[0]; > - bs_dest->throttled_reqs[1] =3D bs_src->throttled_reqs[1]; > - memcpy(&bs_dest->round_robin, > - &bs_src->round_robin, > - sizeof(bs_dest->round_robin)); > - memcpy(&bs_dest->throttle_timers, > - &bs_src->throttle_timers, > - sizeof(ThrottleTimers)); > - > /* r/w error */ > bs_dest->on_read_error =3D bs_src->on_read_error; > bs_dest->on_write_error =3D bs_src->on_write_error; > @@ -2026,10 +2013,25 @@ static void bdrv_move_feature_fields(BlockDrive= rState *bs_dest, > } > =20 > /* Fields that only need to be swapped if the contents of BDSes is swa= pped > - * rather than pointers being changed in the parents. */ > + * rather than pointers being changed in the parents, and throttling f= ields > + * because only bdrv_swap() messes with internals of throttling. */ > static void bdrv_move_reference_fields(BlockDriverState *bs_dest, > BlockDriverState *bs_src) > { > + /* i/o throttled req */ > + bs_dest->throttle_state =3D bs_src->throttle_state, > + bs_dest->io_limits_enabled =3D bs_src->io_limits_enabled; > + bs_dest->pending_reqs[0] =3D bs_src->pending_reqs[0]; > + bs_dest->pending_reqs[1] =3D bs_src->pending_reqs[1]; > + bs_dest->throttled_reqs[0] =3D bs_src->throttled_reqs[0]; > + bs_dest->throttled_reqs[1] =3D bs_src->throttled_reqs[1]; > + memcpy(&bs_dest->round_robin, > + &bs_src->round_robin, > + sizeof(bs_dest->round_robin)); > + memcpy(&bs_dest->throttle_timers, > + &bs_src->throttle_timers, > + sizeof(ThrottleTimers)); > + > /* reference count */ > bs_dest->refcnt =3D bs_src->refcnt; > =20 > @@ -2155,6 +2157,42 @@ void bdrv_swap(BlockDriverState *bs_new, BlockDr= iverState *bs_old) > bdrv_rebind(bs_old); > } > =20 > +static void change_parent_backing_link(BlockDriverState *from, > + BlockDriverState *to) > +{ > + BdrvChild *c, *next; > + > + QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) { > + assert(c->role !=3D &child_backing); > + c->bs =3D to; > + QLIST_REMOVE(c, next_parent); > + QLIST_INSERT_HEAD(&to->parents, c, next_parent); This drops a reference from the parent BDS to @from, and adds a new one from the parent BDS to @to. However, this is not reflected here. > + } > + if (from->blk) { > + blk_set_bs(from->blk, to); > + if (!to->device_list.tqe_prev) { > + QTAILQ_INSERT_BEFORE(from, to, device_list); > + } > + QTAILQ_REMOVE(&bdrv_states, from, device_list); > + } > +} > + > +static void swap_feature_fields(BlockDriverState *bs_top, > + BlockDriverState *bs_new) > +{ > + BlockDriverState tmp; > + > + bdrv_move_feature_fields(&tmp, bs_top); > + bdrv_move_feature_fields(bs_top, bs_new); > + bdrv_move_feature_fields(bs_new, &tmp); > + > + assert(!bs_new->io_limits_enabled); > + if (bs_top->io_limits_enabled) { > + bdrv_io_limits_enable(bs_new, throttle_group_get_name(bs_top))= ; > + bdrv_io_limits_disable(bs_top); > + } > +} > + > /* > * Add new bs contents at the top of an image chain while the chain is= > * live, while keeping required fields on the top layer. > @@ -2165,14 +2203,29 @@ void bdrv_swap(BlockDriverState *bs_new, BlockD= riverState *bs_old) > * bs_new must not be attached to a BlockBackend. > * > * This function does not create any image files. > + * > + * bdrv_append() takes ownership of a bs_new reference and unrefs it b= ecause > + * that's what the callers commonly need. bs_new will be referenced by= the old > + * parents of bs_top after bdrv_append() returns. If the caller needs = to keep a > + * reference of its own, it must call bdrv_ref(). > */ > void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top) > { > - bdrv_swap(bs_new, bs_top); > + assert(!bdrv_requests_pending(bs_top)); > + assert(!bdrv_requests_pending(bs_new)); > + > + bdrv_ref(bs_top); > + change_parent_backing_link(bs_top, bs_new); > + > + /* Some fields always stay on top of the backing file chain */ > + swap_feature_fields(bs_top, bs_new); > + > + bdrv_set_backing_hd(bs_new, bs_top); > + bdrv_unref(bs_top); > =20 > - /* The contents of 'tmp' will become bs_top, as we are > - * swapping bs_new and bs_top contents. */ > - bdrv_set_backing_hd(bs_top, bs_new); > + /* bs_new is now referenced by its new parents, we don't need the > + * additional reference any more. */ > + bdrv_unref(bs_new); > } Before, all pointers to @bs_new were moved to @bs_top. Now, they stay at @bs_new. I suppose we are assuming there are no pointers to @bs_new, should we assert that, and/or point it out in the documentation? Max > =20 > static void bdrv_delete(BlockDriverState *bs) >=20 --HFJ0xrC6n6BTq1JrQIjrU7iGB4AfkaL6F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAtUiAAoJEDuxQgLoOKytlQkH/1GMKkJsu4Q8rw/UTv1o1mpV pUFVqKOo0P240z/Ur4DUpyUBhP0Be69nDoZ+7hW0Klji9620xE6+iMmbI0dXdhX5 8v3A2X2Q+pZbYqz9mAa7618MMasngbvV/yffmmxtUS0UYl2XdBBQqpgdNtFefvf/ 0Hsb3XrP6ZPYW31aMpBiqnee0ssqzITxkhan1weEIJudUuX9JluLX3NEoYUwDfcy h9g8lFMJKZYAXTiLhOZ58TqCVYhHf53zUgRAZdJ1wtFJJwe/WgbVVcjgFenSg9JL oJlYWi3SkGs0RcEubz9j1mlo6+Lskc9R1uDGu0sVXGyAUkLjmb4+5JVrrAPgZJc= =InRD -----END PGP SIGNATURE----- --HFJ0xrC6n6BTq1JrQIjrU7iGB4AfkaL6F-- From MAILER-DAEMON Wed Sep 23 12:39:38 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zen50-0006hM-9t for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 12:39:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zen4x-0006db-VK for qemu-block@nongnu.org; Wed, 23 Sep 2015 12:39:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zen4t-0001X3-Rq for qemu-block@nongnu.org; Wed, 23 Sep 2015 12:39:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35444) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zen4t-0001Wy-N6; Wed, 23 Sep 2015 12:39:31 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 65B4C2FAA70; Wed, 23 Sep 2015 16:39:31 +0000 (UTC) Received: from [10.36.116.28] (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8NGdOjV024975 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 23 Sep 2015 12:39:28 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-13-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <5602D5BB.7060608@redhat.com> Date: Wed, 23 Sep 2015 18:39:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-13-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qk5jtLS4PvmjSL1mrM6q4l6J6D8lnk3hl" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 12/16] block: Introduce parents list X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 16:39:36 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --qk5jtLS4PvmjSL1mrM6q4l6J6D8lnk3hl Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > block.c | 3 +++ > include/block/block_int.h | 2 ++ > 2 files changed, 5 insertions(+) Reviewed-by: Max Reitz --qk5jtLS4PvmjSL1mrM6q4l6J6D8lnk3hl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAtW7AAoJEDuxQgLoOKytOz0H/jIGwg2UtLu7RSTDJVdq1HwM 3ofDJugQvcGOgMjHN06279C3w0qyKu7A8h/2DS4hKSjj9Y5eFe1TWDkzc3/BCuJD vD2XQzZo95lduxjjcVMvvVQC6CDNMjs1sxeWwaiOk0bMnog72s6G/GQe7nb9a7JG kKYcomJ0yJcQiZvgAFekismgskxZhex0Rqxzh2JID3eSVTTKRGZuNvJcnhW7oxE/ uJbsrVAg3fIUZeOaPzWRvGuBSymqiSRfFui3otXZydnTaVGl1W/BUsDgtfQHh0S0 nI1yz9iS57BZGtmlroHnur44RP28xFWrIdtIdQd/kjhwWzYx3289fbsx7WPBDQc= =fWDq -----END PGP SIGNATURE----- --qk5jtLS4PvmjSL1mrM6q4l6J6D8lnk3hl-- From MAILER-DAEMON Wed Sep 23 12:46:25 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZenBZ-00024J-Kc for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 12:46:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZenBX-0001zT-Pm for qemu-block@nongnu.org; Wed, 23 Sep 2015 12:46:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZenBU-0005Sn-Gc for qemu-block@nongnu.org; Wed, 23 Sep 2015 12:46:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37152) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZenBU-0005Sf-CK; Wed, 23 Sep 2015 12:46:20 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id D44E72F9102; Wed, 23 Sep 2015 16:46:19 +0000 (UTC) Received: from [10.36.116.28] (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8NGkEPY014858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 23 Sep 2015 12:46:17 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-15-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <5602D755.6020501@redhat.com> Date: Wed, 23 Sep 2015 18:46:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-15-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="LoU5UtP7abvC0aIheVaGKqRmsrgxR7qkq" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 14/16] blockjob: Store device name at job creation X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 16:46:24 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --LoU5UtP7abvC0aIheVaGKqRmsrgxR7qkq Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > Some block jobs change the block device graph on completion. This means= > that the device that owns the job and originally was addressed with its= > device name may no longer be what the corresponding BlockBackend points= > to. >=20 > Previously, the effects of bdrv_swap() ensured that the job was (at > least partially) transferred to the target image. Events that contain > the device name could still use bdrv_get_device_name(job->bs) and get > the same result. >=20 > After removing bdrv_swap(), this won't work any more. Instead, save the= > device name at job creation and use that copy for the events. >=20 > Signed-off-by: Kevin Wolf > --- > blockjob.c | 8 +++++--- > include/block/blockjob.h | 8 ++++++++ > 2 files changed, 13 insertions(+), 3 deletions(-) Why not %s/bdrv_get_device_name(job->bs)/job->id/? Max --LoU5UtP7abvC0aIheVaGKqRmsrgxR7qkq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAtdWAAoJEDuxQgLoOKytNOMH/2SQGXrOpo3AgDjLEDk13bxQ irnvl0H1uEXMvzYQXU1AH0bSTG6yIVPm2rvlPmLo4czYEzGV64kK89fkQirXmgQu +2IltLoOtloZoNJOwDG2seku8lOaF/gT21dCduUbdyyCeTeQEVVr2sqIB2+dpoSd kKykxD9JHyHU21mkQ0o/65ukIbdl6aDBe8w30SsDDU3YZTTodGsRSTvSqJA73++w DbN6+ZTR4qV6tKzgu4meYrC5kf8aS5W0cTdAtiyFjDxabTjGMcnIJsFJ5ETcIMrz CTAIsewjEPR4GAPERgarh+hA4ySQCNhKKAw1mHd0282XFQlt6GP1VlXxJtRf0wc= =PO6W -----END PGP SIGNATURE----- --LoU5UtP7abvC0aIheVaGKqRmsrgxR7qkq-- From MAILER-DAEMON Wed Sep 23 13:08:52 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZenXI-0001Nv-9z for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 13:08:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZenXF-0001Lx-7K for qemu-block@nongnu.org; Wed, 23 Sep 2015 13:08:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZenXC-0007dR-Gd for qemu-block@nongnu.org; Wed, 23 Sep 2015 13:08:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52289) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZenXC-0007dH-8j; Wed, 23 Sep 2015 13:08:46 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id D3FBB91588; Wed, 23 Sep 2015 17:08:45 +0000 (UTC) Received: from [10.36.116.28] (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8NH8gJ9018415 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 23 Sep 2015 13:08:43 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-16-git-send-email-kwolf@redhat.com> From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <5602DC99.5040204@redhat.com> Date: Wed, 23 Sep 2015 19:08:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-16-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5vFljDb0rO44XpPMFuHAqNvhPAqG0sgqn" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 15/16] block: Add and use bdrv_replace_in_backing_chain() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 17:08:50 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --5vFljDb0rO44XpPMFuHAqNvhPAqG0sgqn Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > This cleans up the mess we left behind in the mirror code after the > previous patch. Instead of using bdrv_swap(), just change pointers. >=20 > The interface change of the mirror job that callers must consider is > that after job completion, their local BDS pointers still point to the > same node now. qemu-img must change its code accordingly (which makes i= t > easier to understand); the other callers stays unchanged because after > completion they don't do anything with the BDS, but just with the job, > and the job is still owned by the source BDS. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 32 +++++++++++++++++++++++++++++++- > block/mirror.c | 23 +++++++---------------- > include/block/block.h | 4 +++- > qemu-img.c | 16 ++++++++-------- > 4 files changed, 49 insertions(+), 26 deletions(-) >=20 > diff --git a/block.c b/block.c > index 98fc17c..7c21659 100644 > --- a/block.c > +++ b/block.c > @@ -1095,7 +1095,7 @@ static BdrvChild *bdrv_attach_child(BlockDriverSt= ate *parent_bs, > return child; > } > =20 > -void bdrv_detach_child(BdrvChild *child) > +static void bdrv_detach_child(BdrvChild *child) > { > QLIST_REMOVE(child, next); > QLIST_REMOVE(child, next_parent); > @@ -2228,6 +2228,36 @@ void bdrv_append(BlockDriverState *bs_new, Block= DriverState *bs_top) > bdrv_unref(bs_new); > } > =20 > +void bdrv_replace_in_backing_chain(BlockDriverState *old, BlockDriverS= tate *new) > +{ > + assert(!bdrv_requests_pending(old)); > + assert(!bdrv_requests_pending(new)); > + > + bdrv_ref(old); > + > + if (old->blk) { > + /* As long as these fields aren't in BlockBackend, but in the = top-level > + * BlockDriverState, it's not possible for a BDS to have two B= Bs. > + * > + * We really want to copy the fields from old to new, but we g= o for a > + * swap instead so that pointers aren't duplicated and cause t= rouble. > + * (Also, bdrv_swap() used to do the same.) */ > + assert(!new->blk); > + swap_feature_fields(old, new); > + } > + change_parent_backing_link(old, new); > + > + /* Change backing files if a previously independent node is added = to the > + * chain. For active commit, we replace top by its own (indirect) = backing > + * file and don't do anything here so we don't build a loop. */ > + if (new->backing =3D=3D NULL && !bdrv_chain_contains(backing_bs(ol= d), new)) { > + bdrv_set_backing_hd(new, backing_bs(old)); > + bdrv_set_backing_hd(old, NULL); Wouldn't we want @old to keep its backing file? Then bdrv_append() would basically be a special case of this function, with it additionally decrementing the refcount of @bs_new. Max > + } > + > + bdrv_unref(old); > +} > + > static void bdrv_delete(BlockDriverState *bs) > { > assert(!bs->job); --5vFljDb0rO44XpPMFuHAqNvhPAqG0sgqn Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAtyZAAoJEDuxQgLoOKytjIEH/i3v4GpckgqsYhhQtXHAkBMi wQS56ILIhzMU12tMw/r+fVHIftRsspnReM1N+QFebbiGu0KrLsx52b2ALQWW0wAw shmjote0htrX2uoTjtuROhqb75SSGCWYbQwIXw9nzXIqbDCycNViAoonzyE4reU9 DcwmIIRbwhbRjcsRemga7tGecPIZobSjncQIzHMDgqbKCYdkWJCp5i2vBzJWyAuz cpQLDn5yM8dz74dFpfuCkemryrJaXO5FWrgGPAAJQ6Qx4ewdrTJLhYiYpzI6VMb/ 2H6NjRjTNI2kfLU/AnI3daiXkT4sdnYbZZjcQpoF6SLC2TmjouSaGRYrKURsAJk= =8usm -----END PGP SIGNATURE----- --5vFljDb0rO44XpPMFuHAqNvhPAqG0sgqn-- From MAILER-DAEMON Wed Sep 23 13:10:06 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZenYT-0002nD-Vo for mharc-qemu-block@gnu.org; Wed, 23 Sep 2015 13:10:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZenYN-0002m4-PJ for qemu-block@nongnu.org; Wed, 23 Sep 2015 13:10:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZenYL-00089q-47 for qemu-block@nongnu.org; Wed, 23 Sep 2015 13:09:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42621) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZenYK-00089f-U3; Wed, 23 Sep 2015 13:09:57 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 5FB4D461D2; Wed, 23 Sep 2015 17:09:56 +0000 (UTC) Received: from [10.36.116.28] (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8NH9r5u028561 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 23 Sep 2015 13:09:54 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-17-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <5602DCE0.1070809@redhat.com> Date: Wed, 23 Sep 2015 19:09:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-17-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QU0eue2XeQa4n7OqeEK2p6jcMLhBHU2MR" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH 16/16] block: Remove bdrv_swap() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2015 17:10:05 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --QU0eue2XeQa4n7OqeEK2p6jcMLhBHU2MR Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > bdrv_swap() is unused now. Remove it and all functions that have > no other users than bdrv_swap(). In particular, this removes the > .bdrv_rebind callbacks from block drivers. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 155 +-------------------------------------= -------- > block/qed.c | 7 --- > block/vvfat.c | 7 --- > include/block/block_int.h | 1 - > include/qemu/queue.h | 6 -- > 5 files changed, 1 inse Reviewed-by: Max Reitz --QU0eue2XeQa4n7OqeEK2p6jcMLhBHU2MR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAtzgAAoJEDuxQgLoOKytT6UH/0IXVoGnPyqZYMvfv5LM38QJ GEf4rNaWVpFdBhLCVCKJuOV5JN+1kZYkMGtO8xlGSLm+C9UCCsh5EJOvyG+iyUu9 7zbHbdypenjVToOPZXtywlvD5WvbVJgj69yXc4FeKzRLF/p4J7Mpa8ZtWSQxZ3do FCfbgAeZe64y1nGqnw6qjYTUJRS/qbF/s81VtQ1nya8u58WYXCsTScnk5kw+HseQ yNsnyqsF13qPAkkaIRiJdRintvwBAemAZxnBHldQFp4RhGFYc5UbPEuxjH+TijCH YCC/G/jokV0HFhTSVQxd66uaYYncILh9tS/9qfNcC4RCU4wL4SPJAAbOZOsOngQ= =adS+ -----END PGP SIGNATURE----- --QU0eue2XeQa4n7OqeEK2p6jcMLhBHU2MR-- From MAILER-DAEMON Thu Sep 24 05:14:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zf2bv-00049v-SS for mharc-qemu-block@gnu.org; Thu, 24 Sep 2015 05:14:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf2bu-00047W-1D for qemu-block@nongnu.org; Thu, 24 Sep 2015 05:14:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zf2bp-0007nN-V0 for qemu-block@nongnu.org; Thu, 24 Sep 2015 05:14:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf2bp-0007nJ-QM; Thu, 24 Sep 2015 05:14:33 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 598C68C1B8; Thu, 24 Sep 2015 09:14:33 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-88.ams2.redhat.com [10.36.116.88]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8O9EV6O015774; Thu, 24 Sep 2015 05:14:32 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 24 Sep 2015 11:14:27 +0200 Message-Id: <1443086067-8209-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, guangmuzhu@gmail.com Subject: [Qemu-block] [PATCH] raw-win32: Fix write request error handling X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2015 09:14:39 -0000 aio_worker() wrote the return code to the wrong variable. Signed-off-by: Kevin Wolf Tested-by: Guangmu Zhu --- block/raw-win32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/raw-win32.c b/block/raw-win32.c index 68f2338..b562c94 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -119,9 +119,9 @@ static int aio_worker(void *arg) case QEMU_AIO_WRITE: count = handle_aiocb_rw(aiocb); if (count == aiocb->aio_nbytes) { - count = 0; + ret = 0; } else { - count = -EINVAL; + ret = -EINVAL; } break; case QEMU_AIO_FLUSH: -- 1.8.3.1 From MAILER-DAEMON Thu Sep 24 05:39:22 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zf2zp-00034m-LZ for mharc-qemu-block@gnu.org; Thu, 24 Sep 2015 05:39:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf2zn-000315-BE for qemu-block@nongnu.org; Thu, 24 Sep 2015 05:39:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zf2zm-0000bm-JY for qemu-block@nongnu.org; Thu, 24 Sep 2015 05:39:19 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:6861 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf2zi-0000aN-Lk; Thu, 24 Sep 2015 05:39:14 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2B6AgBQxANW/5tjdVtdGQEBAYMIgT2pDwEBAQEBAQUBgQoBkxcBDYdzAoFMOBQBAQEBAQEBgQqEJQEBBDo/EAsOCgklDwEsGwYBEogyAct6AQEBAQEBAQECAQEBAQEBHIYshUSFDQeELAEElWeOWpEfiDwfAQFCgkOBQDwziWwBAQE X-IPAS-Result: A2B6AgBQxANW/5tjdVtdGQEBAYMIgT2pDwEBAQEBAQUBgQoBkxcBDYdzAoFMOBQBAQEBAQEBgQqEJQEBBDo/EAsOCgklDwEsGwYBEogyAct6AQEBAQEBAQECAQEBAQEBHIYshUSFDQeELAEElWeOWpEfiDwfAQFCgkOBQDwziWwBAQE X-IronPort-AV: E=Sophos;i="5.17,580,1437429600"; d="scan'208";a="26563526" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 24 Sep 2015 11:38:53 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1Zf2zM-0000mI-Jd; Thu, 24 Sep 2015 11:38:52 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1Zf2zM-0004tv-EN; Thu, 24 Sep 2015 11:38:52 +0200 From: Alberto Garcia To: Eric Blake , qemu-devel@nongnu.org In-Reply-To: <1442963752-10950-1-git-send-email-eblake@redhat.com> References: <1442963752-10950-1-git-send-email-eblake@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Thu, 24 Sep 2015 11:38:52 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, armbru@redhat.com, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH] tests: Fix test 049 fallout from improved HMP error messages X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2015 09:39:20 -0000 On Wed 23 Sep 2015 01:15:52 AM CEST, Eric Blake wrote: > Commit 50b7b000 improved HMP error messages, but forgot to update > qemu-iotests to match. > > Reported-by: Kevin Wolf > Signed-off-by: Eric Blake Reviewed-by: Alberto Garcia Berto From MAILER-DAEMON Thu Sep 24 05:53:14 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zf3DG-0000cb-NY for mharc-qemu-block@gnu.org; Thu, 24 Sep 2015 05:53:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf3DE-0000cL-Jv for qemu-block@nongnu.org; Thu, 24 Sep 2015 05:53:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zf3DB-0006uj-Ez for qemu-block@nongnu.org; Thu, 24 Sep 2015 05:53:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42061) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf3DB-0006uf-9n; Thu, 24 Sep 2015 05:53:09 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id C83A8C0B1B31; Thu, 24 Sep 2015 09:53:08 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-88.ams2.redhat.com [10.36.116.88]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8O9r6Is001924; Thu, 24 Sep 2015 05:53:07 -0400 Date: Thu, 24 Sep 2015 11:53:06 +0200 From: Kevin Wolf To: Eric Blake Message-ID: <20150924095306.GC4060@noname.redhat.com> References: <1442963752-10950-1-git-send-email-eblake@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442963752-10950-1-git-send-email-eblake@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, armbru@redhat.com Subject: Re: [Qemu-block] [PATCH] tests: Fix test 049 fallout from improved HMP error messages X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2015 09:53:13 -0000 Am 23.09.2015 um 01:15 hat Eric Blake geschrieben: > Commit 50b7b000 improved HMP error messages, but forgot to update > qemu-iotests to match. > > Reported-by: Kevin Wolf > Signed-off-by: Eric Blake Thanks, applied to the block branch. > I'm not sure if this should go through Markus' "error" tree, > since that's where the break was introduced, or through a > "block" tree since it touches qemu-iotests. Doesn't really matter as long as someone takes it. And if both took it, I think git should be clever enough to figure it out without merge conflicts. Kevin From MAILER-DAEMON Thu Sep 24 07:59:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zf5Bj-0001ia-4Y for mharc-qemu-block@gnu.org; Thu, 24 Sep 2015 07:59:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf5Bg-0001cg-5a for qemu-block@nongnu.org; Thu, 24 Sep 2015 07:59:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zf5Bc-0002GO-S2 for qemu-block@nongnu.org; Thu, 24 Sep 2015 07:59:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43459) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf5Bc-0002G8-Ns; Thu, 24 Sep 2015 07:59:40 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 37F79C0B2B42; Thu, 24 Sep 2015 11:59:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-56.ams2.redhat.com [10.36.116.56]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8OBxcoT005824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 24 Sep 2015 07:59:39 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id F1A40303F90D; Thu, 24 Sep 2015 13:59:37 +0200 (CEST) From: Markus Armbruster To: Kevin Wolf References: <1442963752-10950-1-git-send-email-eblake@redhat.com> <20150924095306.GC4060@noname.redhat.com> Date: Thu, 24 Sep 2015 13:59:37 +0200 In-Reply-To: <20150924095306.GC4060@noname.redhat.com> (Kevin Wolf's message of "Thu, 24 Sep 2015 11:53:06 +0200") Message-ID: <87mvwcm3iu.fsf@blackfin.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] tests: Fix test 049 fallout from improved HMP error messages X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2015 11:59:45 -0000 Kevin Wolf writes: > Am 23.09.2015 um 01:15 hat Eric Blake geschrieben: >> Commit 50b7b000 improved HMP error messages, but forgot to update >> qemu-iotests to match. >> >> Reported-by: Kevin Wolf >> Signed-off-by: Eric Blake > > Thanks, applied to the block branch. > >> I'm not sure if this should go through Markus' "error" tree, >> since that's where the break was introduced, or through a >> "block" tree since it touches qemu-iotests. You copied both maintainers, so they can figure it out. Good move. > Doesn't really matter as long as someone takes it. And if both took > it, I think git should be clever enough to figure it out without merge > conflicts. Since you took it, I won't. Thanks! From MAILER-DAEMON Thu Sep 24 08:55:19 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zf63T-0002HI-0m for mharc-qemu-block@gnu.org; Thu, 24 Sep 2015 08:55:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf63Q-0002Gd-MN for qemu-block@nongnu.org; Thu, 24 Sep 2015 08:55:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zf63O-0002Hx-1Z for qemu-block@nongnu.org; Thu, 24 Sep 2015 08:55:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44008) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf63N-0002Hn-Sh; Thu, 24 Sep 2015 08:55:13 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 83B24461C3; Thu, 24 Sep 2015 12:55:13 +0000 (UTC) Received: from [10.3.113.166] (ovpn-113-166.phx2.redhat.com [10.3.113.166]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8OCtCxa009173; Thu, 24 Sep 2015 08:55:13 -0400 To: Kevin Wolf , qemu-block@nongnu.org References: <1443086067-8209-1-git-send-email-kwolf@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <5603F2A8.9010905@redhat.com> Date: Thu, 24 Sep 2015 06:55:04 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443086067-8209-1-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jJrMJX4vHJ28gnwQhlBvIfvvAIKuuP41N" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, guangmuzhu@gmail.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] raw-win32: Fix write request error handling X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2015 12:55:17 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jJrMJX4vHJ28gnwQhlBvIfvvAIKuuP41N Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/24/2015 03:14 AM, Kevin Wolf wrote: > aio_worker() wrote the return code to the wrong variable. >=20 > Signed-off-by: Kevin Wolf > Tested-by: Guangmu Zhu > --- > block/raw-win32.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Reviewed-by: Eric Blake >=20 > diff --git a/block/raw-win32.c b/block/raw-win32.c > index 68f2338..b562c94 100644 > --- a/block/raw-win32.c > +++ b/block/raw-win32.c > @@ -119,9 +119,9 @@ static int aio_worker(void *arg) > case QEMU_AIO_WRITE: > count =3D handle_aiocb_rw(aiocb); > if (count =3D=3D aiocb->aio_nbytes) { > - count =3D 0; > + ret =3D 0; > } else { > - count =3D -EINVAL; > + ret =3D -EINVAL; > } > break; > case QEMU_AIO_FLUSH: >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --jJrMJX4vHJ28gnwQhlBvIfvvAIKuuP41N Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWA/KoAAoJEKeha0olJ0NqN0cH/ii98zXZQLSaVKdVPiYXCM4O AaLBIsU3UebYdCGyWZYvP5N+N3mdNgpBot3KiCENKRAjLtstZw9AjcpvLt/sVruD 0lxzZbImL1cpzrLLzegT1oJ7+/+u2/uNc6MwPGqJXzeC8D/+xyzPE9PL3f2l7U7I LCbPc53vNqA7RdXwKYBF5VXFQSQmw0Oebuf55vWrAE85O6+OVIwC4vgA0yzSbELp ewJuz9Vz3hIcTSx5p/VKn+stZ7NfS4shUHAz5ojvpRSB9AweE7s5lv0zf+0I1EOT rrxU4SMbCk4r8ljuwS1g5IfoS4EQBWrZ2FIBPwJcN4QTzVrDHTdHKhwy2xse72M= =kykI -----END PGP SIGNATURE----- --jJrMJX4vHJ28gnwQhlBvIfvvAIKuuP41N-- From MAILER-DAEMON Thu Sep 24 14:32:55 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfBKB-0005n9-3r for mharc-qemu-block@gnu.org; Thu, 24 Sep 2015 14:32:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfBK8-0005lv-NN for qemu-block@nongnu.org; Thu, 24 Sep 2015 14:32:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfBK5-0007Xi-I4 for qemu-block@nongnu.org; Thu, 24 Sep 2015 14:32:52 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:29603 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfBK5-0007JS-Bp; Thu, 24 Sep 2015 14:32:49 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2B6AgBYQARW/5tjdVtdGQEBAYMIqlIBAQEBAQEFAYEKAZMXAQ2FHYJWAoFKOBQBAQEBAQEBgQqEJQEBAwE6PwULCw4TJQ8BLBsGAS2ICwwBzBEBAQEBAQEEAQEBAQEdhiyFRIUNB4QsAQSVZ45ajTODbIRPg20fAQFCghEcgVY8ih8BAQE X-IPAS-Result: A2B6AgBYQARW/5tjdVtdGQEBAYMIqlIBAQEBAQEFAYEKAZMXAQ2FHYJWAoFKOBQBAQEBAQEBgQqEJQEBAwE6PwULCw4TJQ8BLBsGAS2ICwwBzBEBAQEBAQEEAQEBAQEdhiyFRIUNB4QsAQSVZ45ajTODbIRPg20fAQFCghEcgVY8ih8BAQE X-IronPort-AV: E=Sophos;i="5.17,582,1437429600"; d="scan'208";a="26315774" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 24 Sep 2015 20:32:11 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZfBJT-00075x-No; Thu, 24 Sep 2015 20:32:11 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZfBJT-0007zd-It; Thu, 24 Sep 2015 20:32:11 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-1-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Thu, 24 Sep 2015 20:32:11 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 00/16] block: Get rid of bdrv_swap() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2015 18:32:53 -0000 On Thu 17 Sep 2015 03:48:04 PM CEST, Kevin Wolf wrote: > bdrv_swap() has always been an ugly hack that we would rather have > avoided. When it was introduced, we simply didn't have the > infrastructure to update pointers instead of transplanting the > contents of BDS object, so we grudgingly added bdrv_swap() as a quick > solution. Meanwhile, most of the infrastructure exists and this > series implements the final step necessary to implement the required > functionality in a less adventurous way. I managed to crash QEMU with this series. I don't think it's a problem it the series itself, but rather some older bug that is triggered by your patches. I think I found the cause and I have a preliminary patch, I'll try to send it tomorrow. Berto From MAILER-DAEMON Thu Sep 24 17:40:34 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfEFm-0001SU-2W for mharc-qemu-block@gnu.org; Thu, 24 Sep 2015 17:40:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfEFj-0001Qs-4F for qemu-block@nongnu.org; Thu, 24 Sep 2015 17:40:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfEFf-0005dh-FW for qemu-block@nongnu.org; Thu, 24 Sep 2015 17:40:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45471) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfEFf-0005dY-8U; Thu, 24 Sep 2015 17:40:27 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id B9D2A8E704; Thu, 24 Sep 2015 21:40:26 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8OLePBd009643; Thu, 24 Sep 2015 17:40:25 -0400 From: John Snow To: qemu-block@nongnu.org Date: Thu, 24 Sep 2015 17:40:23 -0400 Message-Id: <1443130823-10723-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: famz@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-block] [RFC] transactions: add transaction-wide property X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2015 21:40:33 -0000 This replaces the per-action property as in Fam's series. Instead, we have a transaction-wide property that is shared with each action. At the action level, if a property supplied transaction-wide is disagreeable, we return error and the transaction is aborted. RFC: Where this makes sense: Any transactional actions that aren't prepared to accept this new paradigm of transactional behavior can error_setg and return. Where this may not make sense: consider the transactions which do not use BlockJobs to perform their actions, i.e. they are synchronous during the transactional phase. Because they either fail or succeed so early, we might say that of course they can support this property ... ...however, consider the case where we create a new bitmap and perform a full backup, using allow_partial=false. If the backup fails, we might well expect the bitmap to be deleted because a member of the transaction ultimately/eventually failed. However, the bitmap creation was not undone because it does not have a pending/delayed abort/commit action -- those are only for jobs in this implementation. How do we fix this? (1) We just say "No, you can't use the new block job transaction completion mechanic in conjunction with these commands," (2) We make Bitmap creation/resetting small, synchronous blockjobs that can join the BlockJobTxn Signed-off-by: John Snow --- blockdev.c | 87 ++++++++++++++++++++++++++++++++++++-------------- blockjob.c | 2 +- qapi-schema.json | 15 +++++++-- qapi/block-core.json | 26 --------------- qmp-commands.hx | 2 +- tests/qemu-iotests/124 | 12 +++---- 6 files changed, 83 insertions(+), 61 deletions(-) diff --git a/blockdev.c b/blockdev.c index 45a9fe7..02b1a83 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1061,7 +1061,7 @@ static void blockdev_do_action(int kind, void *data, Error **errp) action.data = data; list.value = &action; list.next = NULL; - qmp_transaction(&list, errp); + qmp_transaction(&list, false, NULL, errp); } void qmp_blockdev_snapshot_sync(bool has_device, const char *device, @@ -1286,6 +1286,7 @@ struct BlkActionState { TransactionAction *action; const BlkActionOps *ops; BlockJobTxn *block_job_txn; + TransactionProperties *txn_props; QSIMPLEQ_ENTRY(BlkActionState) entry; }; @@ -1322,6 +1323,12 @@ static void internal_snapshot_prepare(BlkActionState *common, name = internal->name; /* 2. check for validation */ + if (!common->txn_props->allow_partial) { + error_setg(errp, + "internal_snapshot does not support allow_partial = false"); + return; + } + blk = blk_by_name(device); if (!blk) { error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, @@ -1473,6 +1480,12 @@ static void external_snapshot_prepare(BlkActionState *common, } /* start processing */ + if (!common->txn_props->allow_partial) { + error_setg(errp, + "external_snapshot does not support allow_partial = false"); + return; + } + state->old_bs = bdrv_lookup_bs(has_device ? device : NULL, has_node_name ? node_name : NULL, &local_err); @@ -1603,14 +1616,11 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp) DriveBackupState *state = DO_UPCAST(DriveBackupState, common, common); BlockDriverState *bs; BlockBackend *blk; - DriveBackupTxn *backup_txn; DriveBackup *backup; - BlockJobTxn *txn = NULL; Error *local_err = NULL; assert(common->action->kind == TRANSACTION_ACTION_KIND_DRIVE_BACKUP); - backup_txn = common->action->drive_backup; - backup = backup_txn->base; + backup = common->action->drive_backup->base; blk = blk_by_name(backup->device); if (!blk) { @@ -1624,11 +1634,6 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp) state->aio_context = bdrv_get_aio_context(bs); aio_context_acquire(state->aio_context); - if (backup_txn->has_transactional_cancel && - backup_txn->transactional_cancel) { - txn = common->block_job_txn; - } - do_drive_backup(backup->device, backup->target, backup->has_format, backup->format, backup->sync, @@ -1637,7 +1642,7 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp) backup->has_bitmap, backup->bitmap, backup->has_on_source_error, backup->on_source_error, backup->has_on_target_error, backup->on_target_error, - txn, &local_err); + common->block_job_txn, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -1686,16 +1691,13 @@ static void do_blockdev_backup(const char *device, const char *target, static void blockdev_backup_prepare(BlkActionState *common, Error **errp) { BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common); - BlockdevBackupTxn *backup_txn; BlockdevBackup *backup; BlockDriverState *bs, *target; BlockBackend *blk; - BlockJobTxn *txn = NULL; Error *local_err = NULL; assert(common->action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); - backup_txn = common->action->blockdev_backup; - backup = backup_txn->base; + backup = common->action->blockdev_backup->base; blk = blk_by_name(backup->device); if (!blk) { @@ -1720,17 +1722,12 @@ static void blockdev_backup_prepare(BlkActionState *common, Error **errp) } aio_context_acquire(state->aio_context); - if (backup_txn->has_transactional_cancel && - backup_txn->transactional_cancel) { - txn = common->block_job_txn; - } - do_blockdev_backup(backup->device, backup->target, backup->sync, backup->has_speed, backup->speed, backup->has_on_source_error, backup->on_source_error, backup->has_on_target_error, backup->on_target_error, - txn, &local_err); + common->block_job_txn, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -1777,6 +1774,13 @@ static void block_dirty_bitmap_add_prepare(BlkActionState *common, BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState, common, common); + if (!common->txn_props->allow_partial) { + error_setg(errp, + "block_dirty_bitmap_add does not support " + "allow_partial = false"); + return; + } + action = common->action->block_dirty_bitmap_add; /* AIO context taken and released within qmp_block_dirty_bitmap_add */ qmp_block_dirty_bitmap_add(action->node, action->name, @@ -1812,6 +1816,13 @@ static void block_dirty_bitmap_clear_prepare(BlkActionState *common, common, common); BlockDirtyBitmap *action; + if (!common->txn_props->allow_partial) { + error_setg(errp, + "block_dirty_bitmap_clear does not support " + "allow_partial = false"); + return; + } + action = common->action->block_dirty_bitmap_clear; state->bitmap = block_dirty_bitmap_lookup(action->node, action->name, @@ -1914,21 +1925,45 @@ static const BlkActionOps actions[] = { } }; +/** + * Allocate a TransactionProperties structure if necessary, and fill + * that structure with desired defaults if they are unset. + */ +static TransactionProperties *get_transaction_properties(TransactionProperties *props) +{ + if (!props) { + props = g_new0(TransactionProperties, 1); + } + + if (!props->has_allow_partial) { + props->allow_partial = true; + } + + return props; +} + /* * 'Atomic' group operations. The operations are performed as a set, and if * any fail then we roll back all operations in the group. */ -void qmp_transaction(TransactionActionList *dev_list, Error **errp) +void qmp_transaction(TransactionActionList *dev_list, + bool hasTransactionProperties, + struct TransactionProperties *props, + Error **errp) { TransactionActionList *dev_entry = dev_list; - BlockJobTxn *block_job_txn; + BlockJobTxn *block_job_txn = NULL; BlkActionState *state, *next; Error *local_err = NULL; QSIMPLEQ_HEAD(snap_bdrv_states, BlkActionState) snap_bdrv_states; QSIMPLEQ_INIT(&snap_bdrv_states); - block_job_txn = block_job_txn_new(); + /* Does this transaction get *canceled* as a group on failure? */ + props = get_transaction_properties(props); + if (props->allow_partial == false) { + block_job_txn = block_job_txn_new(); + } /* drain all i/o before any operations */ bdrv_drain_all(); @@ -1950,6 +1985,7 @@ void qmp_transaction(TransactionActionList *dev_list, Error **errp) state->ops = ops; state->action = dev_info; state->block_job_txn = block_job_txn; + state->txn_props = props; QSIMPLEQ_INSERT_TAIL(&snap_bdrv_states, state, entry); state->ops->prepare(state, &local_err); @@ -1982,6 +2018,9 @@ exit: } g_free(state); } + if (!hasTransactionProperties) { + g_free(props); + } block_job_txn_unref(block_job_txn); } diff --git a/blockjob.c b/blockjob.c index 91e8d3c..00146ff 100644 --- a/blockjob.c +++ b/blockjob.c @@ -512,7 +512,7 @@ static void block_job_txn_ref(BlockJobTxn *txn) void block_job_txn_unref(BlockJobTxn *txn) { - if (--txn->refcnt == 0) { + if (txn && --txn->refcnt == 0) { g_free(txn); } } diff --git a/qapi-schema.json b/qapi-schema.json index 8769099..0f28311 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1505,14 +1505,20 @@ { 'union': 'TransactionAction', 'data': { 'blockdev-snapshot-sync': 'BlockdevSnapshot', - 'drive-backup': 'DriveBackupTxn', - 'blockdev-backup': 'BlockdevBackupTxn', + 'drive-backup': 'DriveBackup', + 'blockdev-backup': 'BlockdevBackup', 'abort': 'Abort', 'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternal', 'block-dirty-bitmap-add': 'BlockDirtyBitmapAdd', 'block-dirty-bitmap-clear': 'BlockDirtyBitmap' } } +{ 'struct': 'TransactionProperties', + 'data': { + '*allow-partial': 'bool' + } +} + ## # @transaction # @@ -1533,7 +1539,10 @@ # Since 1.1 ## { 'command': 'transaction', - 'data': { 'actions': [ 'TransactionAction' ] } } + 'data': { 'actions': [ 'TransactionAction' ], + '*properties': 'TransactionProperties' + } +} ## # @human-monitor-command: diff --git a/qapi/block-core.json b/qapi/block-core.json index 24db5c2..83742ab 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -749,19 +749,6 @@ '*on-target-error': 'BlockdevOnError' } } ## -# @DriveBackupTxn -# -# @transactional-cancel: #optional whether failure or cancellation of other -# block jobs with @transactional-cancel true in the same -# transaction causes the whole group to cancel. Default -# is false. -# -# Since: 2.5 -## -{ 'struct': 'DriveBackupTxn', 'base': 'DriveBackup', - 'data': {'*transactional-cancel': 'bool' } } - -## # @BlockdevBackup # # @device: the name of the device which should be copied. @@ -797,19 +784,6 @@ '*on-target-error': 'BlockdevOnError' } } ## -# @BlockdevBackupTxn -# -# @transactional-cancel: #optional whether failure or cancellation of other -# block jobs with @transactional-cancel true in the same -# transaction causes the whole group to cancel. Default -# is false -# -# Since: 2.5 -## -{ 'struct': 'BlockdevBackupTxn', 'base': 'BlockdevBackup', - 'data': {'*transactional-cancel': 'bool' } } - -## # @blockdev-snapshot-sync # # Generates a synchronous snapshot of a block device. diff --git a/qmp-commands.hx b/qmp-commands.hx index c388274..7c1fed9 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1262,7 +1262,7 @@ EQMP }, { .name = "transaction", - .args_type = "actions:q", + .args_type = "actions:q,properties:q?", .mhandler.cmd_new = qmp_marshal_transaction, }, diff --git a/tests/qemu-iotests/124 b/tests/qemu-iotests/124 index 33d00ef..028b346 100644 --- a/tests/qemu-iotests/124 +++ b/tests/qemu-iotests/124 @@ -456,14 +456,13 @@ class TestIncrementalBackup(iotests.QMPTestCase): transaction = [ transaction_drive_backup(drive0['id'], target0, sync='incremental', format=drive0['fmt'], mode='existing', - bitmap=dr0bm0.name, - transactional_cancel=True), + bitmap=dr0bm0.name), transaction_drive_backup(drive1['id'], target1, sync='incremental', format=drive1['fmt'], mode='existing', - bitmap=dr1bm0.name, - transactional_cancel=True), + bitmap=dr1bm0.name) ] - result = self.vm.qmp('transaction', actions=transaction) + result = self.vm.qmp('transaction', actions=transaction, + properties={'allow-partial':False} ) self.assert_qmp(result, 'return', {}) # Observe that drive0's backup is cancelled and drive1 completes with @@ -485,7 +484,8 @@ class TestIncrementalBackup(iotests.QMPTestCase): target1 = self.prepare_backup(dr1bm0) # Re-run the exact same transaction. - result = self.vm.qmp('transaction', actions=transaction) + result = self.vm.qmp('transaction', actions=transaction, + properties={'allow-partial':False}) self.assert_qmp(result, 'return', {}) # Both should complete successfully this time. -- 2.4.3 From MAILER-DAEMON Fri Sep 25 02:15:14 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfMHq-00055R-IA for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 02:15:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMHn-00051I-NX for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:15:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfMHm-0002ki-O8 for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:15:11 -0400 Received: from [59.151.112.132] (port=13077 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMHe-0002RA-PA; Fri, 25 Sep 2015 02:15:03 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101089505" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Sep 2015 14:17:43 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8P6EeYo004394; Fri, 25 Sep 2015 14:14:40 +0800 Received: from [10.167.226.52] (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Fri, 25 Sep 2015 14:14:59 +0800 To: Eric Blake , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-12-git-send-email-wency@cn.fujitsu.com> <55E724D4.4000202@redhat.com> From: Wen Congyang Message-ID: <5604E64B.4070207@cn.fujitsu.com> Date: Fri, 25 Sep 2015 14:14:35 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55E724D4.4000202@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , Michael Roth , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Luiz Capitulino , Gonglei , Yang Hongyang , zhanghailiang Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 11/16] Add new block driver interfaces to control block replication X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 06:15:12 -0000 On 09/03/2015 12:33 AM, Eric Blake wrote: > On 09/02/2015 02:51 AM, Wen Congyang wrote: >> Signed-off-by: Wen Congyang >> Signed-off-by: zhanghailiang >> Signed-off-by: Gonglei >> Cc: Luiz Capitulino >> Cc: Michael Roth >> Reviewed-by: Paolo Bonzini >> --- >> block.c | 43 +++++++++++++++++++++++++++++++++++++++++++ >> include/block/block.h | 5 +++++ >> include/block/block_int.h | 14 ++++++++++++++ >> qapi/block-core.json | 15 +++++++++++++++ >> 4 files changed, 77 insertions(+) >> > > Just an interface review for now: > >> +++ b/qapi/block-core.json >> @@ -1810,6 +1810,21 @@ >> 'data': { '*export': 'str' } } >> >> ## >> +# @ReplicationMode >> +# >> +# An enumeration of replication modes. >> +# >> +# @unprotected: Replication is not started or after failover. > > Maybe: > > Replication is either not started, or has experienced failover. This is internal state, and this mode is used to tell qemu that it is on which side. Thanks Wen Congyang > >> +# >> +# @primary: Primary mode, the vm's state will be sent to secondary QEMU. >> +# >> +# @secondary: Secondary mode, receive the vm's state from primary QEMU. >> +# >> +# Since: 2.4 > > You've missed 2.4; this should be 2.5. > >> +## >> +{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] } > > Where is 'unprotected' in this list? > From MAILER-DAEMON Fri Sep 25 02:18:22 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfMKs-0006ta-Ay for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 02:18:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKo-0006mN-Av for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfMKn-00042h-Ex for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:18 -0400 Received: from [59.151.112.132] (port=59177 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKk-0003zt-Hz; Fri, 25 Sep 2015 02:18:15 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101089646" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Sep 2015 14:20:55 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8P6Hqld004597; Fri, 25 Sep 2015 14:17:53 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 25 Sep 2015 14:18:11 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Fri, 25 Sep 2015 14:17:30 +0800 Message-ID: <1443161858-20533-3-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> References: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v10 02/10] Backup: clear all bitmap when doing block checkpoint X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 06:18:19 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Reviewed-by: Jeff Cody --- block/backup.c | 14 ++++++++++++++ blockjob.c | 11 +++++++++++ include/block/blockjob.h | 12 ++++++++++++ 3 files changed, 37 insertions(+) diff --git a/block/backup.c b/block/backup.c index c61e4c3..5e5995e 100644 --- a/block/backup.c +++ b/block/backup.c @@ -214,11 +214,25 @@ static void backup_iostatus_reset(BlockJob *job) } } +static void backup_do_checkpoint(BlockJob *job, Error **errp) +{ + BackupBlockJob *backup_job = container_of(job, BackupBlockJob, common); + + if (backup_job->sync_mode != MIRROR_SYNC_MODE_NONE) { + error_setg(errp, "The backup job only supports block checkpoint in" + " sync=none mode"); + return; + } + + hbitmap_reset_all(backup_job->bitmap); +} + static const BlockJobDriver backup_job_driver = { .instance_size = sizeof(BackupBlockJob), .job_type = BLOCK_JOB_TYPE_BACKUP, .set_speed = backup_set_speed, .iostatus_reset = backup_iostatus_reset, + .do_checkpoint = backup_do_checkpoint, }; static BlockErrorAction backup_error_action(BackupBlockJob *job, diff --git a/blockjob.c b/blockjob.c index ca4be94..ea4c44a 100644 --- a/blockjob.c +++ b/blockjob.c @@ -405,3 +405,14 @@ void block_job_defer_to_main_loop(BlockJob *job, qemu_bh_schedule(data->bh); } + +void block_job_do_checkpoint(BlockJob *job, Error **errp) +{ + if (!job->driver->do_checkpoint) { + error_setg(errp, "The job %s doesn't support block checkpoint", + BlockJobType_lookup[job->driver->job_type]); + return; + } + + job->driver->do_checkpoint(job, errp); +} diff --git a/include/block/blockjob.h b/include/block/blockjob.h index dd9d5e6..0b4f386 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -50,6 +50,9 @@ typedef struct BlockJobDriver { * manually. */ void (*complete)(BlockJob *job, Error **errp); + + /** Optional callback for job types that support checkpoint. */ + void (*do_checkpoint)(BlockJob *job, Error **errp); } BlockJobDriver; /** @@ -356,4 +359,13 @@ void block_job_defer_to_main_loop(BlockJob *job, BlockJobDeferToMainLoopFn *fn, void *opaque); +/** + * block_job_do_checkpoint: + * @job: The job. + * @errp: Error object. + * + * Do block checkpoint on the specified job. + */ +void block_job_do_checkpoint(BlockJob *job, Error **errp); + #endif -- 2.4.3 From MAILER-DAEMON Fri Sep 25 02:18:29 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfMKy-00075Y-Ky for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 02:18:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKs-0006tf-Ds for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfMKr-00045E-GE for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:22 -0400 Received: from [59.151.112.132] (port=31655 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKn-00042F-Pd; Fri, 25 Sep 2015 02:18:19 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101089650" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Sep 2015 14:20:58 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8P6HuRS004610; Fri, 25 Sep 2015 14:17:56 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 25 Sep 2015 14:18:14 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Fri, 25 Sep 2015 14:17:32 +0800 Message-ID: <1443161858-20533-5-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> References: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Yang Hongyang Subject: [Qemu-block] [PATCH v10 04/10] block: make bdrv_put_ref_bh_schedule() as a public API X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 06:18:25 -0000 Signed-off-by: Wen Congyang --- block.c | 25 +++++++++++++++++++++++++ blockdev.c | 37 ++++++------------------------------- include/block/block.h | 1 + 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/block.c b/block.c index 328c52f..f9a985c 100644 --- a/block.c +++ b/block.c @@ -3597,6 +3597,31 @@ void bdrv_unref(BlockDriverState *bs) } } +typedef struct { + QEMUBH *bh; + BlockDriverState *bs; +} BDRVPutRefBH; + +static void bdrv_put_ref_bh(void *opaque) +{ + BDRVPutRefBH *s = opaque; + + bdrv_unref(s->bs); + qemu_bh_delete(s->bh); + g_free(s); +} + +/* Release a BDS reference in a BH */ +void bdrv_put_ref_bh_schedule(BlockDriverState *bs) +{ + BDRVPutRefBH *s; + + s = g_new(BDRVPutRefBH, 1); + s->bh = qemu_bh_new(bdrv_put_ref_bh, s); + s->bs = bs; + qemu_bh_schedule(s->bh); +} + struct BdrvOpBlocker { Error *reason; QLIST_ENTRY(BdrvOpBlocker) list; diff --git a/blockdev.c b/blockdev.c index 3289cc3..11bc992 100644 --- a/blockdev.c +++ b/blockdev.c @@ -278,37 +278,6 @@ static void bdrv_format_print(void *opaque, const char *name) error_printf(" %s", name); } -typedef struct { - QEMUBH *bh; - BlockDriverState *bs; -} BDRVPutRefBH; - -static void bdrv_put_ref_bh(void *opaque) -{ - BDRVPutRefBH *s = opaque; - - bdrv_unref(s->bs); - qemu_bh_delete(s->bh); - g_free(s); -} - -/* - * Release a BDS reference in a BH - * - * It is not safe to use bdrv_unref() from a callback function when the callers - * still need the BlockDriverState. In such cases we schedule a BH to release - * the reference. - */ -static void bdrv_put_ref_bh_schedule(BlockDriverState *bs) -{ - BDRVPutRefBH *s; - - s = g_new(BDRVPutRefBH, 1); - s->bh = qemu_bh_new(bdrv_put_ref_bh, s); - s->bs = bs; - qemu_bh_schedule(s->bh); -} - static int parse_block_error_action(const char *buf, bool is_read, Error **errp) { if (!strcmp(buf, "ignore")) { @@ -2534,6 +2503,12 @@ static void block_job_cb(void *opaque, int ret) block_job_event_completed(bs->job, msg); } + + /* + * It is not safe to use bdrv_unref() from a callback function when the + * callers still need the BlockDriverState. In such cases we schedule + * a BH to release the reference. + */ bdrv_put_ref_bh_schedule(bs); } diff --git a/include/block/block.h b/include/block/block.h index e4be19f..5154388 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -505,6 +505,7 @@ void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child); BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, BlockDriverState *child_bs, const BdrvChildRole *child_role); +void bdrv_put_ref_bh_schedule(BlockDriverState *bs); bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp); void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason); -- 2.4.3 From MAILER-DAEMON Fri Sep 25 02:18:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfML0-00079K-NU for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 02:18:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKv-000702-Bc for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfMKs-00046C-SN for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:25 -0400 Received: from [59.151.112.132] (port=33739 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKp-00042z-Iu; Fri, 25 Sep 2015 02:18:20 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101089653" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Sep 2015 14:21:01 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8P6HwI2004616; Fri, 25 Sep 2015 14:17:58 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 25 Sep 2015 14:18:17 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Fri, 25 Sep 2015 14:17:34 +0800 Message-ID: <1443161858-20533-7-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> References: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Luiz Capitulino , Gonglei , Yang Hongyang , Michael Roth , zhanghailiang Subject: [Qemu-block] [PATCH v10 06/10] Add new block driver interfaces to control block replication X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 06:18:27 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Cc: Luiz Capitulino Cc: Michael Roth Reviewed-by: Paolo Bonzini --- block.c | 43 +++++++++++++++++++++++++++++++++++++++++++ include/block/block.h | 5 +++++ include/block/block_int.h | 14 ++++++++++++++ qapi/block-core.json | 13 +++++++++++++ 4 files changed, 75 insertions(+) diff --git a/block.c b/block.c index f9a985c..5cb916b 100644 --- a/block.c +++ b/block.c @@ -4253,3 +4253,46 @@ void bdrv_del_child(BlockDriverState *parent_bs, BlockDriverState *child_bs, parent_bs->drv->bdrv_del_child(parent_bs, child_bs, errp); } + +void bdrv_start_replication(BlockDriverState *bs, ReplicationMode mode, + Error **errp) +{ + BlockDriver *drv = bs->drv; + + if (drv && drv->bdrv_start_replication) { + drv->bdrv_start_replication(bs, mode, errp); + } else if (bs->file) { + bdrv_start_replication(bs->file, mode, errp); + } else { + error_setg(errp, "The BDS %s doesn't support starting block" + " replication", bs->filename); + } +} + +void bdrv_do_checkpoint(BlockDriverState *bs, Error **errp) +{ + BlockDriver *drv = bs->drv; + + if (drv && drv->bdrv_do_checkpoint) { + drv->bdrv_do_checkpoint(bs, errp); + } else if (bs->file) { + bdrv_do_checkpoint(bs->file, errp); + } else { + error_setg(errp, "The BDS %s doesn't support block checkpoint", + bs->filename); + } +} + +void bdrv_stop_replication(BlockDriverState *bs, bool failover, Error **errp) +{ + BlockDriver *drv = bs->drv; + + if (drv && drv->bdrv_stop_replication) { + drv->bdrv_stop_replication(bs, failover, errp); + } else if (bs->file) { + bdrv_stop_replication(bs->file, failover, errp); + } else { + error_setg(errp, "The BDS %s doesn't support stopping block" + " replication", bs->filename); + } +} diff --git a/include/block/block.h b/include/block/block.h index 5154388..40ef59f 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -611,4 +611,9 @@ void bdrv_add_child(BlockDriverState *parent, BlockDriverState *child, void bdrv_del_child(BlockDriverState *parent, BlockDriverState *child, Error **errp); +void bdrv_start_replication(BlockDriverState *bs, ReplicationMode mode, + Error **errp); +void bdrv_do_checkpoint(BlockDriverState *bs, Error **errp); +void bdrv_stop_replication(BlockDriverState *bs, bool failover, Error **errp); + #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index 636d0c9..ee4b8fa 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -293,6 +293,20 @@ struct BlockDriver { void (*bdrv_del_child)(BlockDriverState *parent, BlockDriverState *child, Error **errp); + void (*bdrv_start_replication)(BlockDriverState *bs, ReplicationMode mode, + Error **errp); + /* Drop Disk buffer when doing checkpoint. */ + void (*bdrv_do_checkpoint)(BlockDriverState *bs, Error **errp); + /* + * After failover, we should flush Disk buffer into secondary disk + * and stop block replication. + * + * If the guest is shutdown, we should drop Disk buffer and stop + * block representation. + */ + void (*bdrv_stop_replication)(BlockDriverState *bs, bool failover, + Error **errp); + QLIST_ENTRY(BlockDriver) list; }; diff --git a/qapi/block-core.json b/qapi/block-core.json index 000ae47..d5a177b 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1797,6 +1797,19 @@ '*read-pattern': 'QuorumReadPattern' } } ## +# @ReplicationMode +# +# An enumeration of replication modes. +# +# @primary: Primary mode, the vm's state will be sent to secondary QEMU. +# +# @secondary: Secondary mode, receive the vm's state from primary QEMU. +# +# Since: 2.5 +## +{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] } + +## # @BlockdevOptions # # Options for creating a block device. -- 2.4.3 From MAILER-DAEMON Fri Sep 25 02:18:33 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfML3-0007Ds-0y for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 02:18:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKx-00073A-Hr for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfMKw-000482-9Y for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:27 -0400 Received: from [59.151.112.132] (port=31655 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKr-00042F-M7; Fri, 25 Sep 2015 02:18:22 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101089655" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Sep 2015 14:21:03 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8P6I0mK004620; Fri, 25 Sep 2015 14:18:00 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 25 Sep 2015 14:18:19 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Fri, 25 Sep 2015 14:17:35 +0800 Message-ID: <1443161858-20533-8-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> References: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v10 07/10] quorum: implement block driver interfaces for block replication X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 06:18:28 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Reviewed-by: Alberto Garcia --- block/quorum.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index 111a57b..d647ab4 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -85,6 +85,8 @@ typedef struct BDRVQuorumState { */ QuorumReadPattern read_pattern; + + int replication_index; /* store which child supports block replication */ } BDRVQuorumState; typedef struct QuorumAIOCB QuorumAIOCB; @@ -945,6 +947,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, } g_free(opened); + s->replication_index = -1; goto exit; close_exit: @@ -1093,6 +1096,76 @@ static void quorum_refresh_filename(BlockDriverState *bs) bs->full_open_options = opts; } +static void quorum_start_replication(BlockDriverState *bs, ReplicationMode mode, + Error **errp) +{ + BDRVQuorumState *s = bs->opaque; + int count = 0, i, index; + Error *local_err = NULL; + + /* + * TODO: support REPLICATION_MODE_SECONDARY if we allow secondary + * QEMU becoming primary QEMU. + */ + if (mode != REPLICATION_MODE_PRIMARY) { + error_setg(errp, "The replication mode for quorum should be 'primary'"); + return; + } + + if (s->read_pattern != QUORUM_READ_PATTERN_FIFO) { + error_setg(errp, "Block replication needs read pattern 'fifo'"); + return; + } + + for (i = 0; i < s->num_children; i++) { + bdrv_start_replication(s->bs[i], mode, &local_err); + if (local_err) { + error_free(local_err); + local_err = NULL; + } else { + count++; + index = i; + } + } + + if (count == 0) { + error_setg(errp, "No child supports block replication"); + } else if (count > 1) { + for (i = 0; i < s->num_children; i++) { + bdrv_stop_replication(s->bs[i], false, NULL); + } + error_setg(errp, "Too many children support block replication"); + } else { + s->replication_index = index; + } +} + +static void quorum_do_checkpoint(BlockDriverState *bs, Error **errp) +{ + BDRVQuorumState *s = bs->opaque; + + if (s->replication_index < 0) { + error_setg(errp, "Block replication is not running"); + return; + } + + bdrv_do_checkpoint(s->bs[s->replication_index], errp); +} + +static void quorum_stop_replication(BlockDriverState *bs, bool failover, + Error **errp) +{ + BDRVQuorumState *s = bs->opaque; + + if (s->replication_index < 0) { + error_setg(errp, "Block replication is not running"); + return; + } + + bdrv_stop_replication(s->bs[s->replication_index], failover, errp); + s->replication_index = -1; +} + static BlockDriver bdrv_quorum = { .format_name = "quorum", .protocol_name = "quorum", @@ -1119,6 +1192,10 @@ static BlockDriver bdrv_quorum = { .is_filter = true, .bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter, + + .bdrv_start_replication = quorum_start_replication, + .bdrv_do_checkpoint = quorum_do_checkpoint, + .bdrv_stop_replication = quorum_stop_replication, }; static void bdrv_quorum_init(void) -- 2.4.3 From MAILER-DAEMON Fri Sep 25 02:18:33 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfML3-0007Ef-FD for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 02:18:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKy-000753-C4 for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfMKx-00048g-JB for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:28 -0400 Received: from [59.151.112.132] (port=31655 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKv-00042F-9B; Fri, 25 Sep 2015 02:18:25 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101089658" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Sep 2015 14:21:06 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8P6I40F004626; Fri, 25 Sep 2015 14:18:04 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 25 Sep 2015 14:18:23 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Fri, 25 Sep 2015 14:17:37 +0800 Message-ID: <1443161858-20533-10-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> References: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Yang Hongyang Subject: [Qemu-block] [PATCH v10 09/10] support replication driver in blockdev-add X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 06:18:29 -0000 Signed-off-by: Wen Congyang --- qapi/block-core.json | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index d5a177b..0907a72 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -219,7 +219,7 @@ # 'qcow2', 'raw', 'tftp', 'vdi', 'vmdk', 'vpc', 'vvfat' # 2.2: 'archipelago' added, 'cow' dropped # 2.3: 'host_floppy' deprecated -# 2.5: 'host_floppy' dropped +# 2.5: 'host_floppy' dropped, 'replication' added # # @backing_file: #optional the name of the backing file (for copy-on-write) # @@ -1375,6 +1375,7 @@ # Drivers that are supported in block device operations. # # @host_device, @host_cdrom: Since 2.1 +# @replication: Since 2.5 # # Since: 2.0 ## @@ -1382,8 +1383,8 @@ 'data': [ 'archipelago', 'blkdebug', 'blkverify', 'bochs', 'cloop', 'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device', 'http', 'https', 'null-aio', 'null-co', 'parallels', - 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx', - 'vmdk', 'vpc', 'vvfat' ] } + 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'replication', + 'tftp', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] } ## # @BlockdevOptionsBase @@ -1810,6 +1811,19 @@ { 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] } ## +# @BlockdevOptionsReplication +# +# Driver specific block device options for replication +# +# @mode: the replication mode +# +# Since: 2.5 +## +{ 'struct': 'BlockdevOptionsReplication', + 'base': 'BlockdevOptionsGenericFormat', + 'data': { 'mode': 'ReplicationMode' } } + +## # @BlockdevOptions # # Options for creating a block device. @@ -1846,6 +1860,7 @@ 'quorum': 'BlockdevOptionsQuorum', 'raw': 'BlockdevOptionsGenericFormat', # TODO rbd: Wait for structured options + 'replication':'BlockdevOptionsReplication', # TODO sheepdog: Wait for structured options # TODO ssh: Should take InetSocketAddress for 'host'? 'tftp': 'BlockdevOptionsFile', -- 2.4.3 From MAILER-DAEMON Fri Sep 25 02:18:36 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfML6-0007JM-3N for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 02:18:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKz-00075u-0M for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfMKw-00048J-VQ for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:28 -0400 Received: from [59.151.112.132] (port=59177 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKq-0003zt-7w; Fri, 25 Sep 2015 02:18:22 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101089652" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Sep 2015 14:20:59 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8P6HvxO004613; Fri, 25 Sep 2015 14:17:57 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 25 Sep 2015 14:18:16 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Fri, 25 Sep 2015 14:17:33 +0800 Message-ID: <1443161858-20533-6-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> References: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v10 05/10] docs: block replication's description X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 06:18:30 -0000 Signed-off-by: Wen Congyang Signed-off-by: Yang Hongyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- docs/block-replication.txt | 259 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 docs/block-replication.txt diff --git a/docs/block-replication.txt b/docs/block-replication.txt new file mode 100644 index 0000000..eab62df --- /dev/null +++ b/docs/block-replication.txt @@ -0,0 +1,259 @@ +Block replication +---------------------------------------- +Copyright Fujitsu, Corp. 2015 +Copyright (c) 2015 Intel Corporation +Copyright (c) 2015 HUAWEI TECHNOLOGIES CO., LTD. + +This work is licensed under the terms of the GNU GPL, version 2 or later. +See the COPYING file in the top-level directory. + +Block replication is used for continuous checkpoints. It is designed +for COLO (COurse-grain LOck-stepping) where the Secondary VM is running. +It can also be applied for FT/HA (Fault-tolerance/High Assurance) scenario, +where the Secondary VM is not running. + +This document gives an overview of block replication's design. + +== Background == +High availability solutions such as micro checkpoint and COLO will do +consecutive checkpoints. The VM state of Primary VM and Secondary VM is +identical right after a VM checkpoint, but becomes different as the VM +executes till the next checkpoint. To support disk contents checkpoint, +the modified disk contents in the Secondary VM must be buffered, and are +only dropped at next checkpoint time. To reduce the network transportation +effort at the time of checkpoint, the disk modification operations of +Primary disk are asynchronously forwarded to the Secondary node. + +== Workflow == +The following is the image of block replication workflow: + + +----------------------+ +------------------------+ + |Primary Write Requests| |Secondary Write Requests| + +----------------------+ +------------------------+ + | | + | (4) + | V + | /-------------\ + | Copy and Forward | | + |---------(1)----------+ | Disk Buffer | + | | | | + | (3) \-------------/ + | speculative ^ + | write through (2) + | | | + V V | + +--------------+ +----------------+ + | Primary Disk | | Secondary Disk | + +--------------+ +----------------+ + + 1) Primary write requests will be copied and forwarded to Secondary + QEMU. + 2) Before Primary write requests are written to Secondary disk, the + original sector content will be read from Secondary disk and + buffered in the Disk buffer, but it will not overwrite the existing + sector content (it could be from either "Secondary Write Requests" or + previous COW of "Primary Write Requests") in the Disk buffer. + 3) Primary write requests will be written to Secondary disk. + 4) Secondary write requests will be buffered in the Disk buffer and it + will overwrite the existing sector content in the buffer. + +== Architecture == +We are going to implement block replication from many basic +blocks that are already in QEMU. + + virtio-blk || + ^ || .---------- + | || | Secondary + 1 Quorum || '---------- + / \ || + / \ || + Primary 2 filter + disk ^ virtio-blk + | ^ + 3 NBD -------> 3 NBD | + client || server 2 filter + || ^ ^ +--------. || | | +Primary | || Secondary disk <--------- hidden-disk 5 <--------- active-disk 4 +--------' || | backing ^ backing + || | | + || | | + || '-------------------------' + || drive-backup sync=none 6 + +1) The disk on the primary is represented by a block device with two +children, providing replication between a primary disk and the host that +runs the secondary VM. The read pattern for quorum can be extended to +make the primary always read from the local disk instead of going through +NBD. + +2) The new block filter (the name is replication) will control the block +replication. + +3) The secondary disk receives writes from the primary VM through QEMU's +embedded NBD server (speculative write-through). + +4) The disk on the secondary is represented by a custom block device +(called active-disk). It should start as an empty disk, and the format +should support bdrv_make_empty() and backing file. + +5) The hidden-disk is created automatically. It buffers the original content +that is modified by the primary VM. It should also start as an empty disk, +and the driver supports bdrv_make_empty() and backing file. + +6) The drive-backup job(sync=none) is run to allow hidden-disk to buffer +any state that would otherwise be lost by the speculative write-through +of the NBD server into the secondary disk. So before block replication, +the primary disk and secondary disk should contain the same data. + +== Failure Handling == +There are 6 internal errors when block replication is running: +1. I/O error on primary disk +2. Forwarding primary write requests failed +3. Backup failed +4. I/O error on secondary disk +5. I/O error on active disk +6. Making active disk or hidden disk empty failed +In case 1 and 5, we just report the error to the disk layer. In case 2, 3, +4 and 6, we just report block replication's error to FT/HA manager (which +decides when to do a new checkpoint, when to do failover). +There is no internal error when doing failover. + +== New block driver interface == +We add three block driver interfaces to control block replication: +a. bdrv_start_replication() + Start block replication, called in migration/checkpoint thread. + We must call bdrv_start_replication() in secondary QEMU before + calling bdrv_start_replication() in primary QEMU. The caller + must hold the I/O mutex lock if it is in migration/checkpoint + thread. +b. bdrv_do_checkpoint() + This interface is called after all VM state is transferred to + Secondary QEMU. The Disk buffer will be dropped in this interface. + The caller must hold the I/O mutex lock if it is in migration/checkpoint + thread. +c. bdrv_stop_replication() + It is called on failover. We will flush the Disk buffer into + Secondary Disk and stop block replication. The vm should be stopped + before calling it if you use this API to shutdown the guest, or other + things except failover. The caller must hold the I/O mutex lock if it is + in migration/checkpoint thread. + +== Usage == +Primary: + -drive if=xxx,driver=quorum,read-pattern=fifo,id=colo1,vote-threshold=1\ + children.0.file.filename=1.raw,\ + children.0.driver=raw,\ + + Run qmp command in primary qemu: + { 'execute': 'blockdev-add', + 'arguments': { + 'options': { + 'driver': 'replication', + 'mode': 'primary', + 'node-name': 'nbd_client1', + 'file': { + 'host': 'xxx', + 'port': 'xxx', + 'export': 'colo1', + 'driver': 'nbd' + } + } + } + } + { 'execute': 'x-child-add', + 'arguments': { + 'parent': 'colo1', + 'child': 'nbd_client1' + } + } + Note: + 1. There should be only one NBD Client for each primary disk. + 2. host is the secondary physical machine's hostname or IP + 3. Each disk must have its own export name. + 4. It is all a single argument to -drive and you should ignore the + leading whitespace. + 5. The qmp command line must be run after running qmp command line in + secondary qemu. + +Secondary: + -drive if=none,driver=raw,file=/dev/null,id=colo1 \ + -drive if=xxx,driver=replication,mode=secondary,\ + file.file.filename=active_disk.qcow2,\ + file.driver=qcow2,\ + file.backing.file.filename=hidden_disk.qcow2,\ + file.backing.driver=qcow2,\ + file.backing.allow-write-backing-file=on,\ + file.backing.backing.file.filename=1.raw,\ + file.backing.backing.driver=raw, + file.backing.backing.allow-write-backing-file=on,\ + file.backing.backing.node-name=secondary-disk1 + + Then run qmp command in secondary qemu: + { 'execute': 'blockdev-remove-medium', + 'arguments': { + 'device': 'colo1' + } + } + { 'execute': 'blockdev-insert-medium', + 'arguments': { + 'device': 'colo1', + 'node-name': 'secondary-disk1' + } + } + { 'execute': 'nbd-server-start', + 'arguments': { + 'addr': { + 'type': inet', + 'data': { + 'host': 'xxx', + 'port': 'xxx' + } + } + } + } + { 'execute': 'nbd-server-add', + 'arguments': { + 'device': 'colo1', + 'writable': true + } + } + + Note: + 1. The export name in secondary QEMU command line is the secondary + disk's id. + 2. The export name for the same disk must be the same + 3. The qmp command nbd-server-start and nbd-server-add must be run + before running the qmp command migrate on primary QEMU + 4. Active disk, hidden disk and nbd target's length should be the + same. + 5. It is better to put active disk and hidden disk in ramdisk. + 6. It is all a single argument to -drive, and you should ignore + the leading whitespace. + +After Failover: +Primary: + The secondary host is down, so we should run the following qmp command + to remove the nbd child from the quorum: + { 'execute': 'child-del', + 'arguments': { + 'parent': 'colo1', + 'child': 'nbd_client1' + } + } + Note: there is no qmp command to remove the blockdev now + +Secondary: + The primary host is down, so we should do the following thing: + { 'execute': 'nbd-server-stop' + 'arguments': { } + } + { 'execute': 'blockdev-remove-medium' + 'arguments': { + 'device': 'colo1' + } + } + +TODO: +1. Continuous block replication +2. Shared disk -- 2.4.3 From MAILER-DAEMON Fri Sep 25 02:18:37 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfML7-0007Kv-7v for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 02:18:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfML0-00078g-7X for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfMKz-00049d-DV for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:30 -0400 Received: from [59.151.112.132] (port=31655 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKw-00042F-PH; Fri, 25 Sep 2015 02:18:27 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101089661" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Sep 2015 14:21:08 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8P6I5R9004631; Fri, 25 Sep 2015 14:18:05 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 25 Sep 2015 14:18:24 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Fri, 25 Sep 2015 14:17:38 +0800 Message-ID: <1443161858-20533-11-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> References: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v10 10/10] Add a new API to start/stop replication, do checkpoint to all BDSes X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 06:18:32 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/block/block.h | 4 +++ 2 files changed, 87 insertions(+) diff --git a/block.c b/block.c index 5cb916b..5891c4d 100644 --- a/block.c +++ b/block.c @@ -4296,3 +4296,86 @@ void bdrv_stop_replication(BlockDriverState *bs, bool failover, Error **errp) " replication", bs->filename); } } + +void bdrv_start_replication_all(ReplicationMode mode, Error **errp) +{ + BlockDriverState *bs = NULL, *temp = NULL; + Error *local_err = NULL; + + while ((bs = bdrv_next(bs))) { + if (!QLIST_EMPTY(&bs->parents)) { + /* It is not top BDS */ + continue; + } + + if (bdrv_is_read_only(bs) || !bdrv_is_inserted(bs)) { + continue; + } + + bdrv_start_replication(bs, mode, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto fail; + } + } + + return; + +fail: + while ((temp = bdrv_next(temp)) && bs != temp) { + bdrv_stop_replication(temp, false, NULL); + } +} + +void bdrv_do_checkpoint_all(Error **errp) +{ + BlockDriverState *bs = NULL; + Error *local_err = NULL; + + while ((bs = bdrv_next(bs))) { + if (!QLIST_EMPTY(&bs->parents)) { + /* It is not top BDS */ + continue; + } + + if (bdrv_is_read_only(bs) || !bdrv_is_inserted(bs)) { + continue; + } + + bdrv_do_checkpoint(bs, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + } +} + +void bdrv_stop_replication_all(bool failover, Error **errp) +{ + BlockDriverState *bs = NULL; + Error *local_err = NULL; + + while ((bs = bdrv_next(bs))) { + if (!QLIST_EMPTY(&bs->parents)) { + /* It is not top BDS */ + continue; + } + + if (bdrv_is_read_only(bs) || !bdrv_is_inserted(bs)) { + continue; + } + + bdrv_stop_replication(bs, failover, &local_err); + if (!errp) { + /* + * The caller doesn't care the result, they just + * want to stop all block's replication. + */ + continue; + } + if (local_err) { + error_propagate(errp, local_err); + return; + } + } +} diff --git a/include/block/block.h b/include/block/block.h index 40ef59f..eb6a4a2 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -616,4 +616,8 @@ void bdrv_start_replication(BlockDriverState *bs, ReplicationMode mode, void bdrv_do_checkpoint(BlockDriverState *bs, Error **errp); void bdrv_stop_replication(BlockDriverState *bs, bool failover, Error **errp); +void bdrv_start_replication_all(ReplicationMode mode, Error **errp); +void bdrv_do_checkpoint_all(Error **errp); +void bdrv_stop_replication_all(bool failover, Error **errp); + #endif -- 2.4.3 From MAILER-DAEMON Fri Sep 25 02:18:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfMKs-0006u3-Tx for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 02:18:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKo-0006mR-Lz for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfMKn-000434-Ov for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:18 -0400 Received: from [59.151.112.132] (port=59177 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKh-0003zt-UC; Fri, 25 Sep 2015 02:18:13 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101089641" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Sep 2015 14:20:52 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8P6HoDr004587; Fri, 25 Sep 2015 14:17:50 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 25 Sep 2015 14:18:09 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Fri, 25 Sep 2015 14:17:28 +0800 Message-ID: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Yang Hongyang Subject: [Qemu-block] [PATCH v10 00/10] Block replication for continuous checkpoints X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 06:18:20 -0000 Block replication is a very important feature which is used for continuous checkpoints(for example: COLO). You can the detailed information about block replication from here: http://wiki.qemu.org/Features/BlockReplication Usage: Please refer to docs/block-replication.txt This patch series is based on the following patch series: 1. http://lists.nongnu.org/archive/html/qemu-devel/2015-09/msg05514.html 2. http://lists.nongnu.org/archive/html/qemu-devel/2015-09/msg04900.html You can get the patch here: https://github.com/coloft/qemu/tree/wency/block-replication-v10 You can get the patch with framework here: https://github.com/coloft/qemu/tree/wency/colo_framework_v9.5 TODO: 1. Continuous block replication. It will be started after basic functions are accepted. Changs Log: V10: 1. Use blockdev-remove-medium and blockdev-insert-medium to replace backing reference. 2. Address the comments from Eric Blake V9: 1. Update the error messages 2. Rebase to the newest qemu 3. Split child add/delete support. These patches are sent in another patchset. V8: 1. Address Alberto Garcia's comments V7: 1. Implement adding/removing quorum child. Remove the option non-connect. 2. Simplify the backing refrence option according to Stefan Hajnoczi's suggestion V6: 1. Rebase to the newest qemu. V5: 1. Address the comments from Gong Lei 2. Speed the failover up. The secondary vm can take over very quickly even if there are too many I/O requests. V4: 1. Introduce a new driver replication to avoid touch nbd and qcow2. V3: 1: use error_setg() instead of error_set() 2. Add a new block job API 3. Active disk, hidden disk and nbd target uses the same AioContext 4. Add a testcase to test new hbitmap API V2: 1. Redesign the secondary qemu(use image-fleecing) 2. Use Error objects to return error message 3. Address the comments from Max Reitz and Eric Blake Wen Congyang (10): allow writing to the backing file Backup: clear all bitmap when doing block checkpoint Allow creating backup jobs when opening BDS block: make bdrv_put_ref_bh_schedule() as a public API docs: block replication's description Add new block driver interfaces to control block replication quorum: implement block driver interfaces for block replication Implement new driver for block replication support replication driver in blockdev-add Add a new API to start/stop replication, do checkpoint to all BDSes block.c | 192 +++++++++++++++++- block/Makefile.objs | 3 +- block/backup.c | 14 ++ block/quorum.c | 77 ++++++++ block/replication.c | 471 +++++++++++++++++++++++++++++++++++++++++++++ blockdev.c | 37 +--- blockjob.c | 11 ++ docs/block-replication.txt | 259 +++++++++++++++++++++++++ include/block/block.h | 10 + include/block/block_int.h | 14 ++ include/block/blockjob.h | 12 ++ qapi/block-core.json | 34 +++- 12 files changed, 1098 insertions(+), 36 deletions(-) create mode 100644 block/replication.c create mode 100644 docs/block-replication.txt -- 2.4.3 From MAILER-DAEMON Fri Sep 25 02:18:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfMLC-0007Tq-Ie for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 02:18:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfML4-0007GI-9s for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfML1-0004AF-2t for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:34 -0400 Received: from [59.151.112.132] (port=46267 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKw-00046x-Af; Fri, 25 Sep 2015 02:18:27 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101089657" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Sep 2015 14:21:05 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8P6I2wr004623; Fri, 25 Sep 2015 14:18:03 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 25 Sep 2015 14:18:21 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Fri, 25 Sep 2015 14:17:36 +0800 Message-ID: <1443161858-20533-9-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> References: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v10 08/10] Implement new driver for block replication X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 06:18:41 -0000 Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block/Makefile.objs | 1 + block/replication.c | 471 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 472 insertions(+) create mode 100644 block/replication.c diff --git a/block/Makefile.objs b/block/Makefile.objs index fa05f37..94c1d03 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -23,6 +23,7 @@ block-obj-$(CONFIG_LIBSSH2) += ssh.o block-obj-y += accounting.o block-obj-y += write-threshold.o block-obj-y += backup.o +block-obj-y += replication.o common-obj-y += stream.o common-obj-y += commit.o diff --git a/block/replication.c b/block/replication.c new file mode 100644 index 0000000..813f610 --- /dev/null +++ b/block/replication.c @@ -0,0 +1,471 @@ +/* + * Replication Block filter + * + * Copyright (c) 2015 HUAWEI TECHNOLOGIES CO., LTD. + * Copyright (c) 2015 Intel Corporation + * Copyright (c) 2015 FUJITSU LIMITED + * + * Author: + * Wen Congyang + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu-common.h" +#include "block/block_int.h" +#include "block/blockjob.h" +#include "block/nbd.h" + +typedef struct BDRVReplicationState { + ReplicationMode mode; + int replication_state; + BlockDriverState *active_disk; + BlockDriverState *hidden_disk; + BlockDriverState *secondary_disk; + int error; +} BDRVReplicationState; + +enum { + BLOCK_REPLICATION_NONE, /* block replication is not started */ + BLOCK_REPLICATION_RUNNING, /* block replication is running */ + BLOCK_REPLICATION_DONE, /* block replication is done(failover) */ +}; + +#define COMMIT_CLUSTER_BITS 16 +#define COMMIT_CLUSTER_SIZE (1 << COMMIT_CLUSTER_BITS) +#define COMMIT_SECTORS_PER_CLUSTER (COMMIT_CLUSTER_SIZE / BDRV_SECTOR_SIZE) + +static void replication_stop(BlockDriverState *bs, bool failover, Error **errp); + +#define REPLICATION_MODE "mode" +static QemuOptsList replication_runtime_opts = { + .name = "replication", + .head = QTAILQ_HEAD_INITIALIZER(replication_runtime_opts.head), + .desc = { + { + .name = REPLICATION_MODE, + .type = QEMU_OPT_STRING, + }, + { /* end of list */ } + }, +}; + +static int replication_open(BlockDriverState *bs, QDict *options, + int flags, Error **errp) +{ + int ret; + BDRVReplicationState *s = bs->opaque;; + Error *local_err = NULL; + QemuOpts *opts = NULL; + const char *mode; + + ret = -EINVAL; + opts = qemu_opts_create(&replication_runtime_opts, NULL, 0, &error_abort); + qemu_opts_absorb_qdict(opts, options, &local_err); + if (local_err) { + goto fail; + } + + mode = qemu_opt_get(opts, REPLICATION_MODE); + if (!mode) { + error_setg(&local_err, "Missing the option mode"); + goto fail; + } + + if (!strcmp(mode, "primary")) { + s->mode = REPLICATION_MODE_PRIMARY; + } else if (!strcmp(mode, "secondary")) { + s->mode = REPLICATION_MODE_SECONDARY; + } else { + error_setg(&local_err, + "The option mode's value should be primary or secondary"); + goto fail; + } + + ret = 0; + +fail: + qemu_opts_del(opts); + /* propagate error */ + if (local_err) { + error_propagate(errp, local_err); + } + return ret; +} + +static void replication_close(BlockDriverState *bs) +{ + BDRVReplicationState *s = bs->opaque; + + if (s->replication_state == BLOCK_REPLICATION_RUNNING) { + replication_stop(bs, false, NULL); + } +} + +static int64_t replication_getlength(BlockDriverState *bs) +{ + return bdrv_getlength(bs->file); +} + +static int replication_get_io_status(BDRVReplicationState *s) +{ + switch (s->replication_state) { + case BLOCK_REPLICATION_NONE: + return -EIO; + case BLOCK_REPLICATION_RUNNING: + return 0; + case BLOCK_REPLICATION_DONE: + return s->mode == REPLICATION_MODE_PRIMARY ? -EIO : 1; + default: + abort(); + } +} + +static int replication_return_value(BDRVReplicationState *s, int ret) +{ + if (s->mode == REPLICATION_MODE_SECONDARY) { + return ret; + } + + if (ret < 0) { + s->error = ret; + ret = 0; + } + + return ret; +} + +static coroutine_fn int replication_co_readv(BlockDriverState *bs, + int64_t sector_num, + int remaining_sectors, + QEMUIOVector *qiov) +{ + BDRVReplicationState *s = bs->opaque; + int ret; + + if (s->mode == REPLICATION_MODE_PRIMARY) { + /* We only use it to forward primary write requests */ + return -EIO; + } + + ret = replication_get_io_status(s); + if (ret < 0) { + return ret; + } + + /* + * After failover, because we don't commit active disk/hidden disk + * to secondary disk, so we should read from active disk directly. + */ + ret = bdrv_co_readv(bs->file, sector_num, remaining_sectors, qiov); + return replication_return_value(s, ret); +} + +static coroutine_fn int replication_co_writev(BlockDriverState *bs, + int64_t sector_num, + int remaining_sectors, + QEMUIOVector *qiov) +{ + BDRVReplicationState *s = bs->opaque; + QEMUIOVector hd_qiov; + uint64_t bytes_done = 0; + BlockDriverState *top = bs->file; + BlockDriverState *base = s->secondary_disk; + BlockDriverState *target; + int ret, n; + + ret = replication_get_io_status(s); + if (ret < 0) { + return ret; + } + + if (ret == 0) { + ret = bdrv_co_writev(bs->file, sector_num, remaining_sectors, qiov); + return replication_return_value(s, ret); + } + + /* + * Only write to active disk if the sectors have + * already been allocated in active disk/hidden disk. + */ + qemu_iovec_init(&hd_qiov, qiov->niov); + while (remaining_sectors > 0) { + ret = bdrv_is_allocated_above(top, base, sector_num, + remaining_sectors, &n); + if (ret < 0) { + return ret; + } + + qemu_iovec_reset(&hd_qiov); + qemu_iovec_concat(&hd_qiov, qiov, bytes_done, n * 512); + + target = ret ? top: base; + ret = bdrv_co_writev(target, sector_num, n, &hd_qiov); + if (ret < 0) { + return ret; + } + + remaining_sectors -= n; + sector_num += n; + bytes_done += n * BDRV_SECTOR_SIZE; + } + + return 0; +} + +static coroutine_fn int replication_co_discard(BlockDriverState *bs, + int64_t sector_num, + int nb_sectors) +{ + BDRVReplicationState *s = bs->opaque; + int ret; + + ret = replication_get_io_status(s); + if (ret < 0) { + return ret; + } + + if (ret == 1) { + /* It is secondary qemu and we are after failover */ + ret = bdrv_co_discard(s->secondary_disk, sector_num, nb_sectors); + if (ret) { + return ret; + } + } + + ret = bdrv_co_discard(bs->file, sector_num, nb_sectors); + return replication_return_value(s, ret); +} + +static bool replication_recurse_is_first_non_filter(BlockDriverState *bs, + BlockDriverState *candidate) +{ + return bdrv_recurse_is_first_non_filter(bs->file, candidate); +} + +static void secondary_do_checkpoint(BDRVReplicationState *s, Error **errp) +{ + Error *local_err = NULL; + int ret; + + if (!s->secondary_disk->job) { + error_setg(errp, "Backup job is cancelled unexpectedly"); + return; + } + + block_job_do_checkpoint(s->secondary_disk->job, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + ret = s->active_disk->drv->bdrv_make_empty(s->active_disk); + if (ret < 0) { + error_setg(errp, "Cannot make active disk empty"); + return; + } + + ret = s->hidden_disk->drv->bdrv_make_empty(s->hidden_disk); + if (ret < 0) { + error_setg(errp, "Cannot make hidden disk empty"); + return; + } +} + +static void backup_job_completed(void *opaque, int ret) +{ + BDRVReplicationState *s = opaque; + + if (s->replication_state != BLOCK_REPLICATION_DONE) { + /* The backup job is cancelled unexpectedly */ + s->error = -EIO; + } + + bdrv_op_block(s->hidden_disk, BLOCK_OP_TYPE_BACKUP_TARGET, + s->active_disk->backing_blocker); + bdrv_op_block(s->secondary_disk, BLOCK_OP_TYPE_BACKUP_SOURCE, + s->hidden_disk->backing_blocker); + + bdrv_put_ref_bh_schedule(s->secondary_disk); +} + +static void replication_start(BlockDriverState *bs, ReplicationMode mode, + Error **errp) +{ + BDRVReplicationState *s = bs->opaque; + int64_t active_length, hidden_length, disk_length; + AioContext *aio_context; + Error *local_err = NULL; + + if (s->replication_state != BLOCK_REPLICATION_NONE) { + error_setg(errp, "Block replication is running or done"); + return; + } + + if (s->mode != mode) { + error_setg(errp, "The parameter mode's value is invalid, needs %d," + " but receives %d", s->mode, mode); + return; + } + + switch (s->mode) { + case REPLICATION_MODE_PRIMARY: + break; + case REPLICATION_MODE_SECONDARY: + s->active_disk = bs->file; + if (!bs->file->backing_hd) { + error_setg(errp, "Active disk doesn't have backing file"); + return; + } + + s->hidden_disk = s->active_disk->backing_hd; + if (!s->hidden_disk->backing_hd) { + error_setg(errp, "Hidden disk doesn't have backing file"); + return; + } + + s->secondary_disk = s->hidden_disk->backing_hd; + if (!s->secondary_disk->blk) { + error_setg(errp, "The secondary disk doesn't have block backend"); + return; + } + + /* verify the length */ + active_length = bdrv_getlength(s->active_disk); + hidden_length = bdrv_getlength(s->hidden_disk); + disk_length = bdrv_getlength(s->secondary_disk); + if (active_length < 0 || hidden_length < 0 || disk_length < 0 || + active_length != hidden_length || hidden_length != disk_length) { + error_setg(errp, "active disk, hidden disk, secondary disk's length" + " are not the same"); + return; + } + + if (!s->active_disk->drv->bdrv_make_empty || + !s->hidden_disk->drv->bdrv_make_empty) { + error_setg(errp, + "active disk or hidden disk doesn't support make_empty"); + return; + } + + /* start backup job now */ + bdrv_op_unblock(s->hidden_disk, BLOCK_OP_TYPE_BACKUP_TARGET, + s->active_disk->backing_blocker); + bdrv_op_unblock(s->secondary_disk, BLOCK_OP_TYPE_BACKUP_SOURCE, + s->hidden_disk->backing_blocker); + bdrv_ref(s->hidden_disk); + + aio_context = bdrv_get_aio_context(bs); + aio_context_acquire(aio_context); + bdrv_set_aio_context(s->secondary_disk, aio_context); + backup_start(s->secondary_disk, s->hidden_disk, 0, + MIRROR_SYNC_MODE_NONE, NULL, BLOCKDEV_ON_ERROR_REPORT, + BLOCKDEV_ON_ERROR_REPORT, backup_job_completed, + s, &local_err); + aio_context_release(aio_context); + if (local_err) { + error_propagate(errp, local_err); + bdrv_op_block(s->hidden_disk, BLOCK_OP_TYPE_BACKUP_TARGET, + s->active_disk->backing_blocker); + bdrv_op_block(s->secondary_disk, BLOCK_OP_TYPE_BACKUP_SOURCE, + s->hidden_disk->backing_blocker); + bdrv_unref(s->hidden_disk); + return; + } + break; + default: + abort(); + } + + s->replication_state = BLOCK_REPLICATION_RUNNING; + + if (s->mode == REPLICATION_MODE_SECONDARY) { + secondary_do_checkpoint(s, errp); + } + + s->error = 0; +} + +static void replication_do_checkpoint(BlockDriverState *bs, Error **errp) +{ + BDRVReplicationState *s = bs->opaque; + + if (s->replication_state != BLOCK_REPLICATION_RUNNING) { + error_setg(errp, "Block replication is not running"); + return; + } + + if (s->error) { + error_setg(errp, "I/O error occurs"); + return; + } + + if (s->mode == REPLICATION_MODE_SECONDARY) { + secondary_do_checkpoint(s, errp); + } +} + +static void replication_stop(BlockDriverState *bs, bool failover, Error **errp) +{ + BDRVReplicationState *s = bs->opaque; + + if (s->replication_state != BLOCK_REPLICATION_RUNNING) { + error_setg(errp, "Block replication is not running"); + return; + } + + s->replication_state = BLOCK_REPLICATION_DONE; + + switch (s->mode) { + case REPLICATION_MODE_PRIMARY: + break; + case REPLICATION_MODE_SECONDARY: + if (!failover) { + /* + * The guest will be shutdown, and secondary disk is the + * same as the primary disk. Just make active disk and + * hidden disk empty. + */ + secondary_do_checkpoint(s, errp); + return; + } + + if (s->secondary_disk->job) { + block_job_cancel(s->secondary_disk->job); + } + break; + default: + abort(); + } +} + +BlockDriver bdrv_replication = { + .format_name = "replication", + .protocol_name = "replication", + .instance_size = sizeof(BDRVReplicationState), + + .bdrv_open = replication_open, + .bdrv_close = replication_close, + + .bdrv_getlength = replication_getlength, + .bdrv_co_readv = replication_co_readv, + .bdrv_co_writev = replication_co_writev, + .bdrv_co_discard = replication_co_discard, + + .is_filter = true, + .bdrv_recurse_is_first_non_filter = replication_recurse_is_first_non_filter, + + .bdrv_start_replication = replication_start, + .bdrv_do_checkpoint = replication_do_checkpoint, + .bdrv_stop_replication = replication_stop, + + .has_variable_length = true, +}; + +static void bdrv_replication_init(void) +{ + bdrv_register(&bdrv_replication); +} + +block_init(bdrv_replication_init); -- 2.4.3 From MAILER-DAEMON Fri Sep 25 02:18:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfMKt-0006vB-9E for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 02:18:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKo-0006mO-Em for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfMKn-00042n-I6 for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:18 -0400 Received: from [59.151.112.132] (port=3369 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKj-00040K-G7; Fri, 25 Sep 2015 02:18:14 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101089645" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Sep 2015 14:20:54 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8P6HpAS004591; Fri, 25 Sep 2015 14:17:51 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 25 Sep 2015 14:18:10 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Fri, 25 Sep 2015 14:17:29 +0800 Message-ID: <1443161858-20533-2-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> References: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v10 01/10] allow writing to the backing file X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 06:18:20 -0000 For block replication, we have such backing chain: secondary disk <-- hidden disk <-- active disk secondary disk is top BDS(use bacing reference), so it can be opened in read-write mode. But hidden disk is read only, and we need to write to hidden disk(backup job will write data to it). TODO: support opening backing file in read-write mode if the BDS is created by QMP command blockdev-add. Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei --- block.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 073d8d6..328c52f 100644 --- a/block.c +++ b/block.c @@ -738,6 +738,15 @@ static const BdrvChildRole child_backing = { .inherit_flags = bdrv_backing_flags, }; +static int bdrv_backing_rw_flags(int flags) +{ + return bdrv_backing_flags(flags) | BDRV_O_RDWR; +} + +static const BdrvChildRole child_backing_rw = { + .inherit_flags = bdrv_backing_rw_flags, +}; + static int bdrv_open_flags(BlockDriverState *bs, int flags) { int open_flags = flags | BDRV_O_CACHE_WB; @@ -1150,6 +1159,20 @@ out: bdrv_refresh_limits(bs, NULL); } +#define ALLOW_WRITE_BACKING_FILE "allow-write-backing-file" +static QemuOptsList backing_file_opts = { + .name = "backing_file", + .head = QTAILQ_HEAD_INITIALIZER(backing_file_opts.head), + .desc = { + { + .name = ALLOW_WRITE_BACKING_FILE, + .type = QEMU_OPT_BOOL, + .help = "allow writes to backing file", + }, + { /* end of list */ } + }, +}; + /* * Opens the backing file for a BlockDriverState if not yet open * @@ -1164,6 +1187,9 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) int ret = 0; BlockDriverState *backing_hd; Error *local_err = NULL; + QemuOpts *opts = NULL; + bool child_rw = false; + const BdrvChildRole *child_role = NULL; if (bs->backing_hd != NULL) { QDECREF(options); @@ -1176,6 +1202,18 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) } bs->open_flags &= ~BDRV_O_NO_BACKING; + + opts = qemu_opts_create(&backing_file_opts, NULL, 0, &error_abort); + qemu_opts_absorb_qdict(opts, options, &local_err); + if (local_err) { + ret = -EINVAL; + error_propagate(errp, local_err); + QDECREF(options); + goto free_exit; + } + child_rw = qemu_opt_get_bool(opts, ALLOW_WRITE_BACKING_FILE, false); + child_role = child_rw ? &child_backing_rw : &child_backing; + if (qdict_haskey(options, "file.filename")) { backing_filename[0] = '\0'; } else if (bs->backing_file[0] == '\0' && qdict_size(options) == 0) { @@ -1208,7 +1246,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) assert(bs->backing_hd == NULL); ret = bdrv_open_inherit(&backing_hd, *backing_filename ? backing_filename : NULL, - NULL, options, 0, bs, &child_backing, &local_err); + NULL, options, 0, bs, child_role, &local_err); if (ret < 0) { bdrv_unref(backing_hd); backing_hd = NULL; @@ -1222,6 +1260,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) bdrv_set_backing_hd(bs, backing_hd); free_exit: + qemu_opts_del(opts); g_free(backing_filename); return ret; } -- 2.4.3 From MAILER-DAEMON Fri Sep 25 02:18:23 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfMKt-0006w3-Jx for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 02:18:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKq-0006p2-09 for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfMKp-00044F-7l for qemu-block@nongnu.org; Fri, 25 Sep 2015 02:18:19 -0400 Received: from [59.151.112.132] (port=59177 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfMKm-0003zt-Sc; Fri, 25 Sep 2015 02:18:17 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101089649" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Sep 2015 14:20:57 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8P6Hs2o004605; Fri, 25 Sep 2015 14:17:54 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 25 Sep 2015 14:18:13 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Fri, 25 Sep 2015 14:17:31 +0800 Message-ID: <1443161858-20533-4-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> References: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Wen Congyang , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-block] [PATCH v10 03/10] Allow creating backup jobs when opening BDS X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 06:18:21 -0000 When opening BDS, we need to create backup jobs for image-fleecing. Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Reviewed-by: Stefan Hajnoczi Reviewed-by: Jeff Cody --- block/Makefile.objs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/Makefile.objs b/block/Makefile.objs index 58ef2ef..fa05f37 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -22,10 +22,10 @@ block-obj-$(CONFIG_ARCHIPELAGO) += archipelago.o block-obj-$(CONFIG_LIBSSH2) += ssh.o block-obj-y += accounting.o block-obj-y += write-threshold.o +block-obj-y += backup.o common-obj-y += stream.o common-obj-y += commit.o -common-obj-y += backup.o iscsi.o-cflags := $(LIBISCSI_CFLAGS) iscsi.o-libs := $(LIBISCSI_LIBS) -- 2.4.3 From MAILER-DAEMON Fri Sep 25 09:42:25 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfTGb-0001co-A0 for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 09:42:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfTGY-0001Xd-OP for qemu-block@nongnu.org; Fri, 25 Sep 2015 09:42:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfTGU-0000WU-QK for qemu-block@nongnu.org; Fri, 25 Sep 2015 09:42:22 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:65459 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfTGL-0000MS-32; Fri, 25 Sep 2015 09:42:09 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2B7AwAbTgVW/5tjdVtdGQEBgwkBgTyoegUBAQEBAQEFAYEKAYMOkAkBDYFrhgiBMTgUAQEBAQEBAWgihFJST040iDIBzCuGLIpRHoQVBY1uh3mNC44+RIwoHwEBQoFKAQEIAjscgVduiWwBAQE X-IPAS-Result: A2B7AwAbTgVW/5tjdVtdGQEBgwkBgTyoegUBAQEBAQEFAYEKAYMOkAkBDYFrhgiBMTgUAQEBAQEBAWgihFJST040iDIBzCuGLIpRHoQVBY1uh3mNC44+RIwoHwEBQoFKAQEIAjscgVduiWwBAQE X-IronPort-AV: E=Sophos;i="5.17,587,1437429600"; d="scan'208";a="26383216" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 25 Sep 2015 15:42:06 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZfTGI-00052M-0F; Fri, 25 Sep 2015 15:42:06 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZfTG4-0005I0-PX; Fri, 25 Sep 2015 16:41:52 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 25 Sep 2015 16:41:44 +0300 Message-Id: <1443188504-20296-1-git-send-email-berto@igalia.com> X-Mailer: git-send-email 2.5.3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH] block: disable I/O limits at the beginning of bdrv_close() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 13:42:23 -0000 Disabling I/O limits from a BDS also drains all pending throttled requests, so it should be done at the beginning of bdrv_close() with the rest of the bdrv_drain() calls before the BlockDriver is closed. Signed-off-by: Alberto Garcia --- block.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 6268e37..1f90b47 100644 --- a/block.c +++ b/block.c @@ -1907,6 +1907,12 @@ void bdrv_close(BlockDriverState *bs) if (bs->job) { block_job_cancel_sync(bs->job); } + + /* Disable I/O limits and drain all pending throttled requests */ + if (bs->io_limits_enabled) { + bdrv_io_limits_disable(bs); + } + bdrv_drain(bs); /* complete I/O */ bdrv_flush(bs); bdrv_drain(bs); /* in case flush left pending I/O */ @@ -1958,11 +1964,6 @@ void bdrv_close(BlockDriverState *bs) blk_dev_change_media_cb(bs->blk, false); } - /*throttling disk I/O limits*/ - if (bs->io_limits_enabled) { - bdrv_io_limits_disable(bs); - } - QLIST_FOREACH_SAFE(ban, &bs->aio_notifiers, list, ban_next) { g_free(ban); } -- 2.5.3 From MAILER-DAEMON Fri Sep 25 10:09:45 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfTh3-0007Z4-9H for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 10:09:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfTh0-0007Ub-JG for qemu-block@nongnu.org; Fri, 25 Sep 2015 10:09:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfTgw-0007M0-Hq for qemu-block@nongnu.org; Fri, 25 Sep 2015 10:09:42 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:50435 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfTgw-0007LA-BE; Fri, 25 Sep 2015 10:09:38 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BdBgAdVQVW/5tjdVtdGQEBAYMIgT2pAAEBAQEBAQUBgQoBkyWHcwKBKzoSAQEBAQEBAYEKhCUBAQQnEz8QCw4TJQ8BLBsGARKIMgHMEQEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsAQSVZ6g1JwE7ghEcgVY8M4lsAQEB X-IPAS-Result: A2BdBgAdVQVW/5tjdVtdGQEBAYMIgT2pAAEBAQEBAQUBgQoBkyWHcwKBKzoSAQEBAQEBAYEKhCUBAQQnEz8QCw4TJQ8BLBsGARKIMgHMEQEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsAQSVZ6g1JwE7ghEcgVY8M4lsAQEB X-IronPort-AV: E=Sophos;i="5.17,587,1437429600"; d="scan'208";a="26393442" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 25 Sep 2015 16:09:35 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZfTgt-0005Ue-Jz; Fri, 25 Sep 2015 16:09:35 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZfTgt-0000Zq-F2; Fri, 25 Sep 2015 16:09:35 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-6-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-6-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Fri, 25 Sep 2015 16:09:35 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 05/16] block: Convert bs->file to BdrvChild X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 14:09:43 -0000 On Thu 17 Sep 2015 03:48:09 PM CEST, Kevin Wolf wrote: > @@ -1929,6 +1925,11 @@ void bdrv_close(BlockDriverState *bs) > bdrv_unref(backing_hd); > } > > + if (bs->file != NULL) { > + bdrv_unref(bs->file->bs); > + bs->file = NULL; > + } > + > QLIST_FOREACH_SAFE(child, &bs->children, next, next) { > /* TODO Remove bdrv_unref() from drivers' close function and use > * bdrv_unref_child() here */ > @@ -1953,11 +1954,6 @@ void bdrv_close(BlockDriverState *bs) > bs->options = NULL; > QDECREF(bs->full_open_options); > bs->full_open_options = NULL; > - > - if (bs->file != NULL) { > - bdrv_unref(bs->file); > - bs->file = NULL; > - } > } You are moving bdrv_unref(bs->file) up in the function and this seems to be causing a problem, by turning this: bs->drv->bdrv_close(bs); bs->drv = NULL; bdrv_unref(bs->file); into this: bs->drv->bdrv_close(bs); bdrv_unref(bs->file); bs->drv = NULL; In the latter case, closing bs->file calls aio_poll(). This can trigger new requests on bs, which at that point has a valid pointer to a BlockDriver that has already been closed. If throttling is enabled on bs those requests might be queued for later. At the point in which those requests are scheduled bs->drv is already NULL, crashing QEMU. I can reproduce this easily with x-data-plane=on. I sent a separate patch that moves the bdrv_io_limits_disable() call to the beginning of bdrv_close(). That solves the crash, but I guess that this patch should also be changed. Berto From MAILER-DAEMON Fri Sep 25 10:22:41 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfTtZ-0002xx-NI for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 10:22:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfTtV-0002sC-SS for qemu-block@nongnu.org; Fri, 25 Sep 2015 10:22:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfTtQ-0007Yu-AA for qemu-block@nongnu.org; Fri, 25 Sep 2015 10:22:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49600) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfTtQ-0007Yp-4j; Fri, 25 Sep 2015 10:22:32 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id A2BFB461D8; Fri, 25 Sep 2015 14:22:31 +0000 (UTC) Received: from [10.3.113.141] (ovpn-113-141.phx2.redhat.com [10.3.113.141]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8PEMUAP030009; Fri, 25 Sep 2015 10:22:31 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <1443188504-20296-1-git-send-email-berto@igalia.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <560558A2.3020804@redhat.com> Date: Fri, 25 Sep 2015 08:22:26 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443188504-20296-1-git-send-email-berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="JmE3grb0FGdgkfwfop3faURGVoeciwaI9" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] block: disable I/O limits at the beginning of bdrv_close() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 14:22:39 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --JmE3grb0FGdgkfwfop3faURGVoeciwaI9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/25/2015 07:41 AM, Alberto Garcia wrote: > Disabling I/O limits from a BDS also drains all pending throttled > requests, so it should be done at the beginning of bdrv_close() with > the rest of the bdrv_drain() calls before the BlockDriver is closed. Can this be abused? If I have a guest running in a cloud where the cloud provider has put severe throttling limits on me, but lets me hotplug to my heart's content, couldn't I just repeatedly plug/unplug the disk to get around the throttling (every time I unplug, all writes flush at full speed, then I immediately replug to start batching up a new set of writes). In other words, shouldn't the draining still be throttled, to prevent my abuse? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --JmE3grb0FGdgkfwfop3faURGVoeciwaI9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWBViiAAoJEKeha0olJ0NqOEEH/jI4VY5qMa84u2mkQCJxaYEF a5I5GJ/F5Nb1K+PlMdJAlkLZgu09cv+P2UL3U+NOlLMt4L0Om6BYMqJiXsW69s+8 vOxmjco7ZvYuNsIbOkrToUKxNOYsCRWBFa/MrA8N+rfMtxZ4PjV7a5xeImPXtRqa F3FOSNa36nE4l9Kn7TSPv6bWaFXabxCkoKX3U1BMEBkeXWlzyyleA3Wkypzk6IIX GQs+GTyVZp4Yk8SCXN+6BN+adEwiT/vLa54bdS26J18W902L5EIfxxDzyytNdxpa pWv81lZMx4IAI4B9kxBXPkXAQyggkrKcIVMwSe3IURHSGKLNjv0KqqxbOFhM8FQ= =LXhU -----END PGP SIGNATURE----- --JmE3grb0FGdgkfwfop3faURGVoeciwaI9-- From MAILER-DAEMON Fri Sep 25 10:31:56 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfU2W-0001oE-A8 for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 10:31:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfU2O-0001ZY-En for qemu-block@nongnu.org; Fri, 25 Sep 2015 10:31:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfU2L-0003ir-33 for qemu-block@nongnu.org; Fri, 25 Sep 2015 10:31:48 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:54292 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfU2B-0003g9-CY; Fri, 25 Sep 2015 10:31:35 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BdBgD4WQVW/5tjdVtdGQEBAYMIqj4BAQEBAQEFAYEKAZMlhR2CVgKBKzkTAQEBAQEBAYEKhCUBAQMBOj8QCw4TJQ8BLBsGAYg4DAHMEgEBAQEBAQQBAQEBAR2GLIVEhQ0HhCwBBJVnnA2MKCIBQIJDgUA8ih8BAQE X-IPAS-Result: A2BdBgD4WQVW/5tjdVtdGQEBAYMIqj4BAQEBAQEFAYEKAZMlhR2CVgKBKzkTAQEBAQEBAYEKhCUBAQMBOj8QCw4TJQ8BLBsGAYg4DAHMEgEBAQEBAQQBAQEBAR2GLIVEhQ0HhCwBBJVnnA2MKCIBQIJDgUA8ih8BAQE X-IronPort-AV: E=Sophos;i="5.17,587,1437429600"; d="scan'208";a="26400887" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 25 Sep 2015 16:31:33 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZfU28-0005lR-2z; Fri, 25 Sep 2015 16:31:32 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZfU27-0006JQ-B4; Fri, 25 Sep 2015 16:31:31 +0200 From: Alberto Garcia To: Eric Blake , qemu-devel@nongnu.org In-Reply-To: <560558A2.3020804@redhat.com> References: <1443188504-20296-1-git-send-email-berto@igalia.com> <560558A2.3020804@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Fri, 25 Sep 2015 16:31:31 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] block: disable I/O limits at the beginning of bdrv_close() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 14:31:54 -0000 On Fri 25 Sep 2015 04:22:26 PM CEST, Eric Blake wrote: >> Disabling I/O limits from a BDS also drains all pending throttled >> requests, so it should be done at the beginning of bdrv_close() with >> the rest of the bdrv_drain() calls before the BlockDriver is closed. > > Can this be abused? If I have a guest running in a cloud where the > cloud provider has put severe throttling limits on me, but lets me > hotplug to my heart's content, couldn't I just repeatedly plug/unplug > the disk to get around the throttling (every time I unplug, all writes > flush at full speed, then I immediately replug to start batching up a > new set of writes). In other words, shouldn't the draining still be > throttled, to prevent my abuse? I didn't think about this case, and I don't know how practical this is, but note that bdrv_drain() (which is already at the beginning of bdrv_close()) flushes the I/O queue explicitly bypassing the limits, so other cases where a user can trigger a bdrv_drain() would also be vulnerable to this. Berto From MAILER-DAEMON Fri Sep 25 11:51:05 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfVH7-0002HU-8I for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 11:51:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVH4-0002DG-VR for qemu-block@nongnu.org; Fri, 25 Sep 2015 11:51:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfVH3-0002sb-8f for qemu-block@nongnu.org; Fri, 25 Sep 2015 11:51:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVH3-0002sQ-44; Fri, 25 Sep 2015 11:51:01 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id B5C43AED50; Fri, 25 Sep 2015 15:51:00 +0000 (UTC) Received: from localhost (ovpn-112-77.phx2.redhat.com [10.3.112.77]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8PFoxZh031111 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Fri, 25 Sep 2015 11:51:00 -0400 From: Jeff Cody To: qemu-block@nongnu.org Date: Fri, 25 Sep 2015 11:50:50 -0400 Message-Id: <1443196256-5601-2-git-send-email-jcody@redhat.com> In-Reply-To: <1443196256-5601-1-git-send-email-jcody@redhat.com> References: <1443196256-5601-1-git-send-email-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 1/7] block/nfs: fix calculation of allocated file size X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 15:51:03 -0000 From: Peter Lieven st.st_blocks is always counted in 512 byte units. Do not use st.st_blksize as multiplicator which may be larger. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Lieven Reviewed-by: Max Reitz Reviewed-by: Jeff Cody Message-id: 1440067607-14547-1-git-send-email-pl@kamp.de Signed-off-by: Jeff Cody --- block/nfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/nfs.c b/block/nfs.c index c026ff6..02eb4e4 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -475,7 +475,7 @@ static int64_t nfs_get_allocated_file_size(BlockDriverState *bs) aio_poll(client->aio_context, true); } - return (task.ret < 0 ? task.ret : st.st_blocks * st.st_blksize); + return (task.ret < 0 ? task.ret : st.st_blocks * 512); } static int nfs_file_truncate(BlockDriverState *bs, int64_t offset) -- 1.9.3 From MAILER-DAEMON Fri Sep 25 11:51:05 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfVH7-0002IV-Kt for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 11:51:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVH4-0002DE-V6 for qemu-block@nongnu.org; Fri, 25 Sep 2015 11:51:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfVH1-0002rb-OW for qemu-block@nongnu.org; Fri, 25 Sep 2015 11:51:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVH0-0002pr-Uc; Fri, 25 Sep 2015 11:50:59 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 92A8B92381; Fri, 25 Sep 2015 15:50:58 +0000 (UTC) Received: from localhost (ovpn-112-77.phx2.redhat.com [10.3.112.77]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8PFouOT029203 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Fri, 25 Sep 2015 11:50:58 -0400 From: Jeff Cody To: qemu-block@nongnu.org Date: Fri, 25 Sep 2015 11:50:49 -0400 Message-Id: <1443196256-5601-1-git-send-email-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 0/7] Block patches X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 15:51:04 -0000 The following changes since commit eb9d0ea063fc7bdfab76b84085602a9e48d13ec7: Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20150924' into staging (2015-09-24 01:32:11 +0100) are available in the git repository at: git@github.com:codyprime/qemu-kvm-jtc.git tags/block-pull-request for you to fetch changes up to e6fd57ea297ec3aad32b24090c5d3757a99df3fe: sheepdog: refine discard support (2015-09-25 10:25:19 -0400) ---------------------------------------------------------------- Block patches ---------------------------------------------------------------- Hitoshi Mitake (2): sheepdog: use per AIOCB dirty indexes for non overlapping requests sheepdog: refine discard support Liu Yuan (1): sheepdog: add reopen support Peter Lieven (2): block/nfs: fix calculation of allocated file size block/nfs: cache allocated filesize for read-only files Wen Congyang (2): block: Introduce a new API bdrv_co_no_copy_on_readv() Backup: don't do copy-on-read in before_write_notifier block/backup.c | 20 ++++-- block/io.c | 12 +++- block/nfs.c | 38 +++++++++++- block/sheepdog.c | 168 +++++++++++++++++++++++++++++++++++++++----------- include/block/block.h | 9 ++- trace-events | 1 + 6 files changed, 200 insertions(+), 48 deletions(-) -- 1.9.3 From MAILER-DAEMON Fri Sep 25 11:51:18 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfVHK-0002cw-1h for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 11:51:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVHH-0002Yi-0A for qemu-block@nongnu.org; Fri, 25 Sep 2015 11:51:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfVHC-0002wP-VE for qemu-block@nongnu.org; Fri, 25 Sep 2015 11:51:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58403) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVHC-0002wI-Oh; Fri, 25 Sep 2015 11:51:10 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 6B753C0B2E0C; Fri, 25 Sep 2015 15:51:10 +0000 (UTC) Received: from localhost (ovpn-112-77.phx2.redhat.com [10.3.112.77]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8PFp85T019344 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Fri, 25 Sep 2015 11:51:09 -0400 From: Jeff Cody To: qemu-block@nongnu.org Date: Fri, 25 Sep 2015 11:50:54 -0400 Message-Id: <1443196256-5601-6-git-send-email-jcody@redhat.com> In-Reply-To: <1443196256-5601-1-git-send-email-jcody@redhat.com> References: <1443196256-5601-1-git-send-email-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 5/7] Backup: don't do copy-on-read in before_write_notifier X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 15:51:16 -0000 From: Wen Congyang We will copy data in before_write_notifier to do backup. It is a nested I/O request, so we cannot do copy-on-read. The steps to reproduce it: 1. -drive copy-on-read=on,... // qemu option 2. drive_backup -f disk0 /path_to_backup.img // monitor command Signed-off-by: Wen Congyang Tested-by: Jeff Cody Message-id: 1441682913-14320-3-git-send-email-wency@cn.fujitsu.com Signed-off-by: Jeff Cody --- block/backup.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/block/backup.c b/block/backup.c index 965654d..5696431 100644 --- a/block/backup.c +++ b/block/backup.c @@ -89,7 +89,8 @@ static void cow_request_end(CowRequest *req) static int coroutine_fn backup_do_cow(BlockDriverState *bs, int64_t sector_num, int nb_sectors, - bool *error_is_read) + bool *error_is_read, + bool is_write_notifier) { BackupBlockJob *job = (BackupBlockJob *)bs->job; CowRequest cow_request; @@ -129,8 +130,14 @@ static int coroutine_fn backup_do_cow(BlockDriverState *bs, iov.iov_len = n * BDRV_SECTOR_SIZE; qemu_iovec_init_external(&bounce_qiov, &iov, 1); - ret = bdrv_co_readv(bs, start * BACKUP_SECTORS_PER_CLUSTER, n, - &bounce_qiov); + if (is_write_notifier) { + ret = bdrv_co_no_copy_on_readv(bs, + start * BACKUP_SECTORS_PER_CLUSTER, + n, &bounce_qiov); + } else { + ret = bdrv_co_readv(bs, start * BACKUP_SECTORS_PER_CLUSTER, n, + &bounce_qiov); + } if (ret < 0) { trace_backup_do_cow_read_fail(job, start, ret); if (error_is_read) { @@ -190,7 +197,7 @@ static int coroutine_fn backup_before_write_notify( assert((req->offset & (BDRV_SECTOR_SIZE - 1)) == 0); assert((req->bytes & (BDRV_SECTOR_SIZE - 1)) == 0); - return backup_do_cow(req->bs, sector_num, nb_sectors, NULL); + return backup_do_cow(req->bs, sector_num, nb_sectors, NULL, true); } static void backup_set_speed(BlockJob *job, int64_t speed, Error **errp) @@ -303,7 +310,8 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job) return ret; } ret = backup_do_cow(bs, cluster * BACKUP_SECTORS_PER_CLUSTER, - BACKUP_SECTORS_PER_CLUSTER, &error_is_read); + BACKUP_SECTORS_PER_CLUSTER, &error_is_read, + false); if ((ret < 0) && backup_error_action(job, error_is_read, -ret) == BLOCK_ERROR_ACTION_REPORT) { @@ -408,7 +416,7 @@ static void coroutine_fn backup_run(void *opaque) } /* FULL sync mode we copy the whole drive. */ ret = backup_do_cow(bs, start * BACKUP_SECTORS_PER_CLUSTER, - BACKUP_SECTORS_PER_CLUSTER, &error_is_read); + BACKUP_SECTORS_PER_CLUSTER, &error_is_read, false); if (ret < 0) { /* Depending on error action, fail now or retry cluster */ BlockErrorAction action = -- 1.9.3 From MAILER-DAEMON Fri Sep 25 11:51:20 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfVHM-0002i7-9s for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 11:51:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVHI-0002av-4f for qemu-block@nongnu.org; Fri, 25 Sep 2015 11:51:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfVHG-0002xQ-M0 for qemu-block@nongnu.org; Fri, 25 Sep 2015 11:51:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58418) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVHG-0002xH-DY; Fri, 25 Sep 2015 11:51:14 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 191B2C0B2E13; Fri, 25 Sep 2015 15:51:14 +0000 (UTC) Received: from localhost (ovpn-112-77.phx2.redhat.com [10.3.112.77]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8PFpB3f017577 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Fri, 25 Sep 2015 11:51:13 -0400 From: Jeff Cody To: qemu-block@nongnu.org Date: Fri, 25 Sep 2015 11:50:55 -0400 Message-Id: <1443196256-5601-7-git-send-email-jcody@redhat.com> In-Reply-To: <1443196256-5601-1-git-send-email-jcody@redhat.com> References: <1443196256-5601-1-git-send-email-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 6/7] sheepdog: use per AIOCB dirty indexes for non overlapping requests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 15:51:18 -0000 From: Hitoshi Mitake In the commit 96b14ff85acf, requests for overlapping areas are serialized. However, it cannot handle a case of non overlapping requests. In such a case, min_dirty_data_idx and max_dirty_data_idx can be overwritten by the requests and invalid inode update can happen e.g. a case like create(1, 2) and create(3, 4) are issued in parallel. This patch lets SheepdogAIOCB have dirty data indexes instead of BDRVSheepdogState for avoiding the above situation. This patch also does trivial renaming for better description: overwrapping -> overlapping Cc: Teruaki Ishizaki Cc: Vasiliy Tolstov Cc: Jeff Cody Signed-off-by: Hitoshi Mitake Tested-by: Vasiliy Tolstov Message-id: 1441076590-8015-2-git-send-email-mitake.hitoshi@lab.ntt.co.jp Signed-off-by: Jeff Cody --- block/sheepdog.c | 63 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 255372eea..08a09e9 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -318,7 +318,7 @@ enum AIOCBState { AIOCB_DISCARD_OBJ, }; -#define AIOCBOverwrapping(x, y) \ +#define AIOCBOverlapping(x, y) \ (!(x->max_affect_data_idx < y->min_affect_data_idx \ || y->max_affect_data_idx < x->min_affect_data_idx)) @@ -342,6 +342,15 @@ struct SheepdogAIOCB { uint32_t min_affect_data_idx; uint32_t max_affect_data_idx; + /* + * The difference between affect_data_idx and dirty_data_idx: + * affect_data_idx represents range of index of all request types. + * dirty_data_idx represents range of index updated by COW requests. + * dirty_data_idx is used for updating an inode object. + */ + uint32_t min_dirty_data_idx; + uint32_t max_dirty_data_idx; + QLIST_ENTRY(SheepdogAIOCB) aiocb_siblings; }; @@ -351,9 +360,6 @@ typedef struct BDRVSheepdogState { SheepdogInode inode; - uint32_t min_dirty_data_idx; - uint32_t max_dirty_data_idx; - char name[SD_MAX_VDI_LEN]; bool is_snapshot; uint32_t cache_flags; @@ -373,7 +379,7 @@ typedef struct BDRVSheepdogState { QLIST_HEAD(inflight_aio_head, AIOReq) inflight_aio_head; QLIST_HEAD(failed_aio_head, AIOReq) failed_aio_head; - CoQueue overwrapping_queue; + CoQueue overlapping_queue; QLIST_HEAD(inflight_aiocb_head, SheepdogAIOCB) inflight_aiocb_head; } BDRVSheepdogState; @@ -561,6 +567,9 @@ static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs, QEMUIOVector *qiov, acb->max_affect_data_idx = (acb->sector_num * BDRV_SECTOR_SIZE + acb->nb_sectors * BDRV_SECTOR_SIZE) / object_size; + acb->min_dirty_data_idx = UINT32_MAX; + acb->max_dirty_data_idx = 0; + return acb; } @@ -824,8 +833,8 @@ static void coroutine_fn aio_read_response(void *opaque) */ if (rsp.result == SD_RES_SUCCESS) { s->inode.data_vdi_id[idx] = s->inode.vdi_id; - s->max_dirty_data_idx = MAX(idx, s->max_dirty_data_idx); - s->min_dirty_data_idx = MIN(idx, s->min_dirty_data_idx); + acb->max_dirty_data_idx = MAX(idx, acb->max_dirty_data_idx); + acb->min_dirty_data_idx = MIN(idx, acb->min_dirty_data_idx); } } break; @@ -1471,13 +1480,11 @@ static int sd_open(BlockDriverState *bs, QDict *options, int flags, } memcpy(&s->inode, buf, sizeof(s->inode)); - s->min_dirty_data_idx = UINT32_MAX; - s->max_dirty_data_idx = 0; bs->total_sectors = s->inode.vdi_size / BDRV_SECTOR_SIZE; pstrcpy(s->name, sizeof(s->name), vdi); qemu_co_mutex_init(&s->lock); - qemu_co_queue_init(&s->overwrapping_queue); + qemu_co_queue_init(&s->overlapping_queue); qemu_opts_del(opts); g_free(buf); return 0; @@ -1989,16 +1996,16 @@ static void coroutine_fn sd_write_done(SheepdogAIOCB *acb) AIOReq *aio_req; uint32_t offset, data_len, mn, mx; - mn = s->min_dirty_data_idx; - mx = s->max_dirty_data_idx; + mn = acb->min_dirty_data_idx; + mx = acb->max_dirty_data_idx; if (mn <= mx) { /* we need to update the vdi object. */ offset = sizeof(s->inode) - sizeof(s->inode.data_vdi_id) + mn * sizeof(s->inode.data_vdi_id[0]); data_len = (mx - mn + 1) * sizeof(s->inode.data_vdi_id[0]); - s->min_dirty_data_idx = UINT32_MAX; - s->max_dirty_data_idx = 0; + acb->min_dirty_data_idx = UINT32_MAX; + acb->max_dirty_data_idx = 0; iov.iov_base = &s->inode; iov.iov_len = sizeof(s->inode); @@ -2224,12 +2231,12 @@ out: return 1; } -static bool check_overwrapping_aiocb(BDRVSheepdogState *s, SheepdogAIOCB *aiocb) +static bool check_overlapping_aiocb(BDRVSheepdogState *s, SheepdogAIOCB *aiocb) { SheepdogAIOCB *cb; QLIST_FOREACH(cb, &s->inflight_aiocb_head, aiocb_siblings) { - if (AIOCBOverwrapping(aiocb, cb)) { + if (AIOCBOverlapping(aiocb, cb)) { return true; } } @@ -2258,15 +2265,15 @@ static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num, acb->aiocb_type = AIOCB_WRITE_UDATA; retry: - if (check_overwrapping_aiocb(s, acb)) { - qemu_co_queue_wait(&s->overwrapping_queue); + if (check_overlapping_aiocb(s, acb)) { + qemu_co_queue_wait(&s->overlapping_queue); goto retry; } ret = sd_co_rw_vector(acb); if (ret <= 0) { QLIST_REMOVE(acb, aiocb_siblings); - qemu_co_queue_restart_all(&s->overwrapping_queue); + qemu_co_queue_restart_all(&s->overlapping_queue); qemu_aio_unref(acb); return ret; } @@ -2274,7 +2281,7 @@ retry: qemu_coroutine_yield(); QLIST_REMOVE(acb, aiocb_siblings); - qemu_co_queue_restart_all(&s->overwrapping_queue); + qemu_co_queue_restart_all(&s->overlapping_queue); return acb->ret; } @@ -2291,15 +2298,15 @@ static coroutine_fn int sd_co_readv(BlockDriverState *bs, int64_t sector_num, acb->aio_done_func = sd_finish_aiocb; retry: - if (check_overwrapping_aiocb(s, acb)) { - qemu_co_queue_wait(&s->overwrapping_queue); + if (check_overlapping_aiocb(s, acb)) { + qemu_co_queue_wait(&s->overlapping_queue); goto retry; } ret = sd_co_rw_vector(acb); if (ret <= 0) { QLIST_REMOVE(acb, aiocb_siblings); - qemu_co_queue_restart_all(&s->overwrapping_queue); + qemu_co_queue_restart_all(&s->overlapping_queue); qemu_aio_unref(acb); return ret; } @@ -2307,7 +2314,7 @@ retry: qemu_coroutine_yield(); QLIST_REMOVE(acb, aiocb_siblings); - qemu_co_queue_restart_all(&s->overwrapping_queue); + qemu_co_queue_restart_all(&s->overlapping_queue); return acb->ret; } @@ -2656,15 +2663,15 @@ static coroutine_fn int sd_co_discard(BlockDriverState *bs, int64_t sector_num, acb->aio_done_func = sd_finish_aiocb; retry: - if (check_overwrapping_aiocb(s, acb)) { - qemu_co_queue_wait(&s->overwrapping_queue); + if (check_overlapping_aiocb(s, acb)) { + qemu_co_queue_wait(&s->overlapping_queue); goto retry; } ret = sd_co_rw_vector(acb); if (ret <= 0) { QLIST_REMOVE(acb, aiocb_siblings); - qemu_co_queue_restart_all(&s->overwrapping_queue); + qemu_co_queue_restart_all(&s->overlapping_queue); qemu_aio_unref(acb); return ret; } @@ -2672,7 +2679,7 @@ retry: qemu_coroutine_yield(); QLIST_REMOVE(acb, aiocb_siblings); - qemu_co_queue_restart_all(&s->overwrapping_queue); + qemu_co_queue_restart_all(&s->overlapping_queue); return acb->ret; } -- 1.9.3 From MAILER-DAEMON Fri Sep 25 11:51:22 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfVHO-0002l0-3J for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 11:51:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVHG-0002YR-SN for qemu-block@nongnu.org; Fri, 25 Sep 2015 11:51:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfVHB-0002vb-0E for qemu-block@nongnu.org; Fri, 25 Sep 2015 11:51:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36621) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVHA-0002vV-FN; Fri, 25 Sep 2015 11:51:08 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 1B3D319F219; Fri, 25 Sep 2015 15:51:08 +0000 (UTC) Received: from localhost (ovpn-112-77.phx2.redhat.com [10.3.112.77]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8PFp6rn017509 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Fri, 25 Sep 2015 11:51:07 -0400 From: Jeff Cody To: qemu-block@nongnu.org Date: Fri, 25 Sep 2015 11:50:53 -0400 Message-Id: <1443196256-5601-5-git-send-email-jcody@redhat.com> In-Reply-To: <1443196256-5601-1-git-send-email-jcody@redhat.com> References: <1443196256-5601-1-git-send-email-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 4/7] block: Introduce a new API bdrv_co_no_copy_on_readv() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 15:51:19 -0000 From: Wen Congyang In some cases, we need to disable copy-on-read, and just read the data. Signed-off-by: Wen Congyang Message-id: 1441682913-14320-2-git-send-email-wency@cn.fujitsu.com Signed-off-by: Jeff Cody --- block/io.c | 12 +++++++++++- include/block/block.h | 9 ++++++--- trace-events | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/block/io.c b/block/io.c index d4bc83b..94e18e6 100644 --- a/block/io.c +++ b/block/io.c @@ -932,7 +932,8 @@ static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs, return ret; } - if (bs->copy_on_read) { + /* Don't do copy-on-read if we read data before write operation */ + if (bs->copy_on_read && !(flags & BDRV_REQ_NO_COPY_ON_READ)) { flags |= BDRV_REQ_COPY_ON_READ; } @@ -1001,6 +1002,15 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, 0); } +int coroutine_fn bdrv_co_no_copy_on_readv(BlockDriverState *bs, + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) +{ + trace_bdrv_co_no_copy_on_readv(bs, sector_num, nb_sectors); + + return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, + BDRV_REQ_NO_COPY_ON_READ); +} + int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { diff --git a/include/block/block.h b/include/block/block.h index ef67353..2dd6630 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -51,15 +51,16 @@ typedef struct BlockFragInfo { } BlockFragInfo; typedef enum { - BDRV_REQ_COPY_ON_READ = 0x1, - BDRV_REQ_ZERO_WRITE = 0x2, + BDRV_REQ_COPY_ON_READ = 0x1, + BDRV_REQ_ZERO_WRITE = 0x2, /* The BDRV_REQ_MAY_UNMAP flag is used to indicate that the block driver * is allowed to optimize a write zeroes request by unmapping (discarding) * blocks if it is guaranteed that the result will read back as * zeroes. The flag is only passed to the driver if the block device is * opened with BDRV_O_UNMAP. */ - BDRV_REQ_MAY_UNMAP = 0x4, + BDRV_REQ_MAY_UNMAP = 0x4, + BDRV_REQ_NO_COPY_ON_READ = 0x8, } BdrvRequestFlags; typedef struct BlockSizes { @@ -252,6 +253,8 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); +int coroutine_fn bdrv_co_no_copy_on_readv(BlockDriverState *bs, + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); /* diff --git a/trace-events b/trace-events index 25c53e0..a70ea9c 100644 --- a/trace-events +++ b/trace-events @@ -69,6 +69,7 @@ bdrv_aio_write_zeroes(void *bs, int64_t sector_num, int nb_sectors, int flags, v bdrv_lock_medium(void *bs, bool locked) "bs %p locked %d" bdrv_co_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" bdrv_co_copy_on_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" +bdrv_co_no_copy_on_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" bdrv_co_writev(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d" bdrv_co_write_zeroes(void *bs, int64_t sector_num, int nb_sector, int flags) "bs %p sector_num %"PRId64" nb_sectors %d flags %#x" bdrv_co_io_em(void *bs, int64_t sector_num, int nb_sectors, int is_write, void *acb) "bs %p sector_num %"PRId64" nb_sectors %d is_write %d acb %p" -- 1.9.3 From MAILER-DAEMON Fri Sep 25 11:51:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfVHS-0002uU-IB for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 11:51:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVHO-0002lA-4i for qemu-block@nongnu.org; Fri, 25 Sep 2015 11:51:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfVHJ-0002yO-7A for qemu-block@nongnu.org; Fri, 25 Sep 2015 11:51:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36659) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVHJ-0002yG-0j; Fri, 25 Sep 2015 11:51:17 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id AAE4919F21C; Fri, 25 Sep 2015 15:51:16 +0000 (UTC) Received: from localhost (ovpn-112-77.phx2.redhat.com [10.3.112.77]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8PFpELo014492 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Fri, 25 Sep 2015 11:51:16 -0400 From: Jeff Cody To: qemu-block@nongnu.org Date: Fri, 25 Sep 2015 11:50:56 -0400 Message-Id: <1443196256-5601-8-git-send-email-jcody@redhat.com> In-Reply-To: <1443196256-5601-1-git-send-email-jcody@redhat.com> References: <1443196256-5601-1-git-send-email-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 7/7] sheepdog: refine discard support X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 15:51:23 -0000 From: Hitoshi Mitake This patch refines discard support of the sheepdog driver. The existing discard mechanism was implemented on SD_OP_DISCARD_OBJ, which was introduced before fine grained reference counting on newer sheepdog. It doesn't care about relations of snapshots and clones and discards objects unconditionally. With this patch, the driver just updates an inode object for updating reference. Removing the object is done in sheep process side. Cc: Teruaki Ishizaki Cc: Vasiliy Tolstov Cc: Jeff Cody Signed-off-by: Hitoshi Mitake Tested-by: Vasiliy Tolstov Message-id: 1441076590-8015-3-git-send-email-mitake.hitoshi@lab.ntt.co.jp Signed-off-by: Jeff Cody --- block/sheepdog.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 08a09e9..e7e58b7 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -28,7 +28,6 @@ #define SD_OP_READ_OBJ 0x02 #define SD_OP_WRITE_OBJ 0x03 /* 0x04 is used internally by Sheepdog */ -#define SD_OP_DISCARD_OBJ 0x05 #define SD_OP_NEW_VDI 0x11 #define SD_OP_LOCK_VDI 0x12 @@ -861,10 +860,6 @@ static void coroutine_fn aio_read_response(void *opaque) rsp.result = SD_RES_SUCCESS; s->discard_supported = false; break; - case SD_RES_SUCCESS: - idx = data_oid_to_idx(aio_req->oid); - s->inode.data_vdi_id[idx] = 0; - break; default: break; } @@ -1179,7 +1174,13 @@ static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, hdr.flags = SD_FLAG_CMD_WRITE | flags; break; case AIOCB_DISCARD_OBJ: - hdr.opcode = SD_OP_DISCARD_OBJ; + hdr.opcode = SD_OP_WRITE_OBJ; + hdr.flags = SD_FLAG_CMD_WRITE | flags; + s->inode.data_vdi_id[data_oid_to_idx(oid)] = 0; + offset = offsetof(SheepdogInode, + data_vdi_id[data_oid_to_idx(oid)]); + oid = vid_to_vdi_oid(s->inode.vdi_id); + wlen = datalen = sizeof(uint32_t); break; } @@ -2214,7 +2215,9 @@ static int coroutine_fn sd_co_rw_vector(void *p) } aio_req = alloc_aio_req(s, acb, oid, len, offset, flags, create, - old_oid, done); + old_oid, + acb->aiocb_type == AIOCB_DISCARD_OBJ ? + 0 : done); QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings); add_aio_request(s, aio_req, acb->qiov->iov, acb->qiov->niov, @@ -2650,15 +2653,23 @@ static coroutine_fn int sd_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { SheepdogAIOCB *acb; - QEMUIOVector dummy; BDRVSheepdogState *s = bs->opaque; int ret; + QEMUIOVector discard_iov; + struct iovec iov; + uint32_t zero = 0; if (!s->discard_supported) { return 0; } - acb = sd_aio_setup(bs, &dummy, sector_num, nb_sectors); + memset(&discard_iov, 0, sizeof(discard_iov)); + memset(&iov, 0, sizeof(iov)); + iov.iov_base = &zero; + iov.iov_len = sizeof(zero); + discard_iov.iov = &iov; + discard_iov.niov = 1; + acb = sd_aio_setup(bs, &discard_iov, sector_num, nb_sectors); acb->aiocb_type = AIOCB_DISCARD_OBJ; acb->aio_done_func = sd_finish_aiocb; -- 1.9.3 From MAILER-DAEMON Fri Sep 25 12:10:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfVaI-0002Co-2I for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 12:10:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVaB-00029T-DF for qemu-block@nongnu.org; Fri, 25 Sep 2015 12:10:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfVa5-0004ft-2s for qemu-block@nongnu.org; Fri, 25 Sep 2015 12:10:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49742) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVVR-0002wQ-09; Fri, 25 Sep 2015 12:05:53 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 8A3A298C32; Fri, 25 Sep 2015 16:05:52 +0000 (UTC) Received: from localhost (ovpn-112-77.phx2.redhat.com [10.3.112.77]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8PFp3lL029310 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Fri, 25 Sep 2015 11:51:04 -0400 From: Jeff Cody To: qemu-block@nongnu.org Date: Fri, 25 Sep 2015 11:50:52 -0400 Message-Id: <1443196256-5601-4-git-send-email-jcody@redhat.com> In-Reply-To: <1443196256-5601-1-git-send-email-jcody@redhat.com> References: <1443196256-5601-1-git-send-email-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 3/7] sheepdog: add reopen support X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 16:10:49 -0000 From: Liu Yuan With reopen supported, block-commit (and offline commit) is now supported for image files whose base image uses the Sheepdog protocol driver. Cc: qemu-devel@nongnu.org Cc: Jeff Cody Cc: Kevin Wolf Cc: Stefan Hajnoczi Signed-off-by: Liu Yuan Message-id: 1440730438-24676-1-git-send-email-namei.unix@gmail.com Signed-off-by: Jeff Cody --- block/sheepdog.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/block/sheepdog.c b/block/sheepdog.c index 67ca788..255372eea 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -377,6 +377,11 @@ typedef struct BDRVSheepdogState { QLIST_HEAD(inflight_aiocb_head, SheepdogAIOCB) inflight_aiocb_head; } BDRVSheepdogState; +typedef struct BDRVSheepdogReopenState { + int fd; + int cache_flags; +} BDRVSheepdogReopenState; + static const char * sd_strerror(int err) { int i; @@ -1486,6 +1491,68 @@ out: return ret; } +static int sd_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, + Error **errp) +{ + BDRVSheepdogState *s = state->bs->opaque; + BDRVSheepdogReopenState *re_s; + int ret = 0; + + re_s = state->opaque = g_new0(BDRVSheepdogReopenState, 1); + + re_s->cache_flags = SD_FLAG_CMD_CACHE; + if (state->flags & BDRV_O_NOCACHE) { + re_s->cache_flags = SD_FLAG_CMD_DIRECT; + } + + re_s->fd = get_sheep_fd(s, errp); + if (re_s->fd < 0) { + ret = re_s->fd; + return ret; + } + + return ret; +} + +static void sd_reopen_commit(BDRVReopenState *state) +{ + BDRVSheepdogReopenState *re_s = state->opaque; + BDRVSheepdogState *s = state->bs->opaque; + + if (s->fd) { + aio_set_fd_handler(s->aio_context, s->fd, NULL, NULL, NULL); + closesocket(s->fd); + } + + s->fd = re_s->fd; + s->cache_flags = re_s->cache_flags; + + g_free(state->opaque); + state->opaque = NULL; + + return; +} + +static void sd_reopen_abort(BDRVReopenState *state) +{ + BDRVSheepdogReopenState *re_s = state->opaque; + BDRVSheepdogState *s = state->bs->opaque; + + if (re_s == NULL) { + return; + } + + if (re_s->fd) { + aio_set_fd_handler(s->aio_context, re_s->fd, NULL, NULL, NULL); + closesocket(re_s->fd); + } + + g_free(state->opaque); + state->opaque = NULL; + + return; +} + static int do_sd_create(BDRVSheepdogState *s, uint32_t *vdi_id, int snapshot, Error **errp) { @@ -2702,6 +2769,9 @@ static BlockDriver bdrv_sheepdog = { .instance_size = sizeof(BDRVSheepdogState), .bdrv_needs_filename = true, .bdrv_file_open = sd_open, + .bdrv_reopen_prepare = sd_reopen_prepare, + .bdrv_reopen_commit = sd_reopen_commit, + .bdrv_reopen_abort = sd_reopen_abort, .bdrv_close = sd_close, .bdrv_create = sd_create, .bdrv_has_zero_init = bdrv_has_zero_init_1, @@ -2735,6 +2805,9 @@ static BlockDriver bdrv_sheepdog_tcp = { .instance_size = sizeof(BDRVSheepdogState), .bdrv_needs_filename = true, .bdrv_file_open = sd_open, + .bdrv_reopen_prepare = sd_reopen_prepare, + .bdrv_reopen_commit = sd_reopen_commit, + .bdrv_reopen_abort = sd_reopen_abort, .bdrv_close = sd_close, .bdrv_create = sd_create, .bdrv_has_zero_init = bdrv_has_zero_init_1, @@ -2768,6 +2841,9 @@ static BlockDriver bdrv_sheepdog_unix = { .instance_size = sizeof(BDRVSheepdogState), .bdrv_needs_filename = true, .bdrv_file_open = sd_open, + .bdrv_reopen_prepare = sd_reopen_prepare, + .bdrv_reopen_commit = sd_reopen_commit, + .bdrv_reopen_abort = sd_reopen_abort, .bdrv_close = sd_close, .bdrv_create = sd_create, .bdrv_has_zero_init = bdrv_has_zero_init_1, -- 1.9.3 From MAILER-DAEMON Fri Sep 25 12:19:12 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfViK-0000NE-Sa for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 12:19:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfViF-0000A8-0g for qemu-block@nongnu.org; Fri, 25 Sep 2015 12:19:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfViE-00085Z-02 for qemu-block@nongnu.org; Fri, 25 Sep 2015 12:19:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49740) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfVVQ-0002wL-W4; Fri, 25 Sep 2015 12:05:53 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 8076298C30; Fri, 25 Sep 2015 16:05:52 +0000 (UTC) Received: from localhost (ovpn-112-77.phx2.redhat.com [10.3.112.77]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8PFp189029280 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Fri, 25 Sep 2015 11:51:02 -0400 From: Jeff Cody To: qemu-block@nongnu.org Date: Fri, 25 Sep 2015 11:50:51 -0400 Message-Id: <1443196256-5601-3-git-send-email-jcody@redhat.com> In-Reply-To: <1443196256-5601-1-git-send-email-jcody@redhat.com> References: <1443196256-5601-1-git-send-email-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [Qemu-block] [PULL 2/7] block/nfs: cache allocated filesize for read-only files X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 16:19:11 -0000 From: Peter Lieven If the file is readonly its not expected to grow so save the blocking call to nfs_fstat_async and use the value saved at connection time. Also important the monitor (and thus the main loop) will not hang if block device info is queried and the NFS share is unresponsive. Signed-off-by: Peter Lieven Reviewed-by: Jeff Cody Reviewed-by: Max Reitz Message-id: 1440671441-7978-1-git-send-email-pl@kamp.de Signed-off-by: Jeff Cody --- block/nfs.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/block/nfs.c b/block/nfs.c index 02eb4e4..887a98e 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -43,6 +43,7 @@ typedef struct NFSClient { int events; bool has_zero_init; AioContext *aio_context; + blkcnt_t st_blocks; } NFSClient; typedef struct NFSRPC { @@ -374,6 +375,7 @@ static int64_t nfs_client_open(NFSClient *client, const char *filename, } ret = DIV_ROUND_UP(st.st_size, BDRV_SECTOR_SIZE); + client->st_blocks = st.st_blocks; client->has_zero_init = S_ISREG(st.st_mode); goto out; fail: @@ -464,6 +466,11 @@ static int64_t nfs_get_allocated_file_size(BlockDriverState *bs) NFSRPC task = {0}; struct stat st; + if (bdrv_is_read_only(bs) && + !(bs->open_flags & BDRV_O_NOCACHE)) { + return client->st_blocks * 512; + } + task.st = &st; if (nfs_fstat_async(client->context, client->fh, nfs_co_generic_cb, &task) != 0) { @@ -484,6 +491,34 @@ static int nfs_file_truncate(BlockDriverState *bs, int64_t offset) return nfs_ftruncate(client->context, client->fh, offset); } +/* Note that this will not re-establish a connection with the NFS server + * - it is effectively a NOP. */ +static int nfs_reopen_prepare(BDRVReopenState *state, + BlockReopenQueue *queue, Error **errp) +{ + NFSClient *client = state->bs->opaque; + struct stat st; + int ret = 0; + + if (state->flags & BDRV_O_RDWR && bdrv_is_read_only(state->bs)) { + error_setg(errp, "Cannot open a read-only mount as read-write"); + return -EACCES; + } + + /* Update cache for read-only reopens */ + if (!(state->flags & BDRV_O_RDWR)) { + ret = nfs_fstat(client->context, client->fh, &st); + if (ret < 0) { + error_setg(errp, "Failed to fstat file: %s", + nfs_get_error(client->context)); + return ret; + } + client->st_blocks = st.st_blocks; + } + + return 0; +} + static BlockDriver bdrv_nfs = { .format_name = "nfs", .protocol_name = "nfs", @@ -499,6 +534,7 @@ static BlockDriver bdrv_nfs = { .bdrv_file_open = nfs_file_open, .bdrv_close = nfs_file_close, .bdrv_create = nfs_file_create, + .bdrv_reopen_prepare = nfs_reopen_prepare, .bdrv_co_readv = nfs_co_readv, .bdrv_co_writev = nfs_co_writev, -- 1.9.3 From MAILER-DAEMON Fri Sep 25 13:19:34 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfWek-0000NY-6M for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 13:19:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfWeh-0000M8-QK for qemu-block@nongnu.org; Fri, 25 Sep 2015 13:19:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfWee-00005V-2h for qemu-block@nongnu.org; Fri, 25 Sep 2015 13:19:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49210) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfWed-00005J-Tw; Fri, 25 Sep 2015 13:19:28 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 0425C2589E; Fri, 25 Sep 2015 17:19:27 +0000 (UTC) Received: from localhost (ovpn-116-68.ams2.redhat.com [10.36.116.68]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8PHJPno013624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 25 Sep 2015 13:19:26 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 25 Sep 2015 19:19:24 +0200 Message-Id: <1443201564-6510-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH] iotests: Fix test 128 for password-less sudo X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 17:19:32 -0000 As of 934659c460d46c948cf348822fda1d38556ed9a4, $QEMU_IO is generally no longer a program name, and therefore "sudo -n $QEMU_IO" will no longer work. Fix this by copying the qemu-io invocation function from common.config, making it use $sudo for invoking $QEMU_IO_PROG, and then use that function instead of $QEMU_IO. Reported-by: Fam Zheng Signed-off-by: Max Reitz --- tests/qemu-iotests/128 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/128 b/tests/qemu-iotests/128 index e2a0f2f..3d8107d 100755 --- a/tests/qemu-iotests/128 +++ b/tests/qemu-iotests/128 @@ -31,6 +31,11 @@ status=1 # failure is the default! devname="eiodev$$" sudo="" +_sudo_qemu_io_wrapper() +{ + (exec $sudo "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@") +} + _setup_eiodev() { # This test should either be run as root or with passwordless sudo @@ -76,7 +81,9 @@ TEST_IMG="/dev/mapper/$devname" echo echo "== reading from error device ==" # Opening image should succeed but the read operation should fail -$sudo $QEMU_IO --format "$IMGFMT" --nocache -c "read 0 65536" "$TEST_IMG" | _filter_qemu_io +_sudo_qemu_io_wrapper --format "$IMGFMT" --nocache \ + -c "read 0 65536" "$TEST_IMG" \ + | _filter_qemu_io # success, all done echo "*** done" -- 2.5.3 From MAILER-DAEMON Fri Sep 25 15:20:54 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfYY9-0008Dn-Vl for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 15:20:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfYY6-0008Ak-Rx for qemu-block@nongnu.org; Fri, 25 Sep 2015 15:20:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfYY2-0000WK-Up for qemu-block@nongnu.org; Fri, 25 Sep 2015 15:20:50 -0400 Received: from mail-vk0-f44.google.com ([209.85.213.44]:33648) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfYY2-0000Vf-RD for qemu-block@nongnu.org; Fri, 25 Sep 2015 15:20:46 -0400 Received: by vkgd64 with SMTP id d64so62147412vkg.0 for ; Fri, 25 Sep 2015 12:20:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc :content-type; bh=9qChuc+vUTZyDCw9qaqvkMaChoSBMuYMEdw4vOVbbUE=; b=R469jk5l5UfCiW3y5wdGOIkZkqTJzNVY0MPJgPD+SpQ50n6l4QdgrIA7Spqe6dWnqK H3bh+xG7UBECUInoAUpR9rly8QZaCNKiLUVf/aHR+2MKNVWi7FNcvenkgnhZl1csY6L0 4DNC22fsFuU40sC7Gjvzlt6yirFtLSD0Ao3l8ZBNT8L37AHMPs1LNZscZotMSp8H8Y3c 0l8szEpqmgd+3LbBU0E0sIrYn46PPZkszZDSALAasYpbg5b0D94VEGfVhy2VgdPTipR6 x1kFlOEuKxwyTWNaZzsHTjx4J/IGXNz45j9ujRl5RNx4eSXYOSQwrCnAqsfor6jE9AaG /cVg== X-Gm-Message-State: ALoCoQmHAeYicxNYfKQbaUzJIQ+XqifmBsU2L7uyARh83Mdxm4V5g4e6Vgp4JY5zI0zGeHjuKq2x X-Received: by 10.31.180.68 with SMTP id d65mr3930195vkf.27.1443208846255; Fri, 25 Sep 2015 12:20:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.153.15 with HTTP; Fri, 25 Sep 2015 12:20:26 -0700 (PDT) From: Peter Maydell Date: Fri, 25 Sep 2015 12:20:26 -0700 Message-ID: To: QEMU Developers Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.213.44 Cc: "qemu-ppc@nongnu.org" , Qemu-block Subject: [Qemu-block] ide-test fails on PPC64 big-endian host X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 19:20:51 -0000 Hi. I was looking at adding ppc64be to the set of machines I do build tests on before merging patches, but right now "make check" fails on this host. ERROR:/home/pm215/qemu/tests/ide-test.c:721:cdrom_pio_impl: assertion failed ((data) & (DRQ | DRDY) == (DRQ | DRDY)): (0x00000040 == 0x00000048) GTester: last random seed: R02S58b8c55d2bcc2ad0ddd605d5ce8483ee ** ERROR:/home/pm215/qemu/tests/ide-test.c:721:cdrom_pio_impl: assertion failed ((data) & (DRQ | DRDY) == (DRQ | DRDY)): (0x00000040 == 0x00000048) GTester: last random seed: R02S3bf67d6406a1f4ea5d8ca81bff345065 ** ERROR:/home/pm215/qemu/tests/ide-test.c:788:test_cdrom_dma: assertion failed (memcmp(pattern, rx, len) == 0): (1 == 0) GTester: last random seed: R02S2732ddb1755a1620a021eb6c59bd6281 The obvious guess is that something in the IDE code or its test harness has an accidental little-endian dependency. Would anybody care to investigate? :-) thanks -- PMM From MAILER-DAEMON Fri Sep 25 15:21:40 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfYYu-0000dX-9b for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 15:21:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfYYs-0000bN-Cf for qemu-block@nongnu.org; Fri, 25 Sep 2015 15:21:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfYYo-0001NG-FZ for qemu-block@nongnu.org; Fri, 25 Sep 2015 15:21:38 -0400 Received: from mail-vk0-f46.google.com ([209.85.213.46]:33071) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfYYo-0001Mx-CJ for qemu-block@nongnu.org; Fri, 25 Sep 2015 15:21:34 -0400 Received: by vkgd64 with SMTP id d64so62159058vkg.0 for ; Fri, 25 Sep 2015 12:21:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=7QIOJC6JyDdADEc6Zr4fcegZw1VuzXWYHG5ZYqH++ow=; b=jTHFmUp/viJlnX4hTGobIh/f2OMNFXVe2YyBW27N1VEAk7g5gGomiMFLWNJg6qH0Zq 2e2UUQA6svdZXnhZ+ty9P69MFRk3zD3Szu1kW1LShSmtOsP/knLUIE0sYVx2+58eETTG p2rJktyQvZvZJDysa5BcvavSU3fRxAawdL6L6/eU2RhEjrVoz8PwKbGJoR2oUKYUCrMm /AXMC7FLoQyhM6WwcVRQnpuZNA40rHGQEMIK/l09GvkX0a6N790e0kO/SwetTn418fit joCFfUQHjkw0DiFBXKW+gHj0UW18+22jx1m+qWNuIYfY6ZykU6NYdauZlEwCT5chDzim QM5Q== X-Gm-Message-State: ALoCoQntQYWE4HhP0hv6AdZFAwIp8FQuMf6LOxKgFNsMG117VSyyjnZRFJY/xIX3SG6Sc+KLF8IS X-Received: by 10.31.1.214 with SMTP id 205mr4373347vkb.90.1443208893962; Fri, 25 Sep 2015 12:21:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.153.15 with HTTP; Fri, 25 Sep 2015 12:21:14 -0700 (PDT) In-Reply-To: <1443196256-5601-1-git-send-email-jcody@redhat.com> References: <1443196256-5601-1-git-send-email-jcody@redhat.com> From: Peter Maydell Date: Fri, 25 Sep 2015 12:21:14 -0700 Message-ID: To: Jeff Cody Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.213.46 Cc: QEMU Developers , Qemu-block Subject: Re: [Qemu-block] [PULL 0/7] Block patches X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 19:21:39 -0000 On 25 September 2015 at 08:50, Jeff Cody wrote: > The following changes since commit eb9d0ea063fc7bdfab76b84085602a9e48d13ec7: > > Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20150924' into staging (2015-09-24 01:32:11 +0100) > > are available in the git repository at: > > > git@github.com:codyprime/qemu-kvm-jtc.git tags/block-pull-request > > for you to fetch changes up to e6fd57ea297ec3aad32b24090c5d3757a99df3fe: > > sheepdog: refine discard support (2015-09-25 10:25:19 -0400) > > ---------------------------------------------------------------- > Block patches > ---------------------------------------------------------------- > Applied, thanks. -- PMM From MAILER-DAEMON Fri Sep 25 15:22:25 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfYZd-0001af-7i for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 15:22:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfYZa-0001W4-5E for qemu-block@nongnu.org; Fri, 25 Sep 2015 15:22:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfYZW-0001l6-1z for qemu-block@nongnu.org; Fri, 25 Sep 2015 15:22:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40712) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfYZV-0001k3-Sa; Fri, 25 Sep 2015 15:22:17 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id F12A7461C3; Fri, 25 Sep 2015 19:22:16 +0000 (UTC) Received: from scv.usersys.redhat.com (vpn-55-42.rdu2.redhat.com [10.10.55.42]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8PJMGa7017209; Fri, 25 Sep 2015 15:22:16 -0400 To: Peter Maydell , QEMU Developers References: From: John Snow Message-ID: <56059EE8.7030708@redhat.com> Date: Fri, 25 Sep 2015 15:22:16 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: "qemu-ppc@nongnu.org" , Qemu-block Subject: Re: [Qemu-block] ide-test fails on PPC64 big-endian host X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 19:22:23 -0000 On 09/25/2015 03:20 PM, Peter Maydell wrote: > Hi. I was looking at adding ppc64be to the set of machines I do build > tests on before merging patches, but right now "make check" fails on > this host. > > ERROR:/home/pm215/qemu/tests/ide-test.c:721:cdrom_pio_impl: assertion > failed ((data) & (DRQ | DRDY) == (DRQ | DRDY)): (0x00000040 == > 0x00000048) > GTester: last random seed: R02S58b8c55d2bcc2ad0ddd605d5ce8483ee > ** > ERROR:/home/pm215/qemu/tests/ide-test.c:721:cdrom_pio_impl: assertion > failed ((data) & (DRQ | DRDY) == (DRQ | DRDY)): (0x00000040 == > 0x00000048) > GTester: last random seed: R02S3bf67d6406a1f4ea5d8ca81bff345065 > ** > ERROR:/home/pm215/qemu/tests/ide-test.c:788:test_cdrom_dma: assertion > failed (memcmp(pattern, rx, len) == 0): (1 == 0) > GTester: last random seed: R02S2732ddb1755a1620a021eb6c59bd6281 > > The obvious guess is that something in the IDE code or its test > harness has an accidental little-endian dependency. Would anybody > care to investigate? :-) > > thanks > -- PMM > Sigh, sorry. I'm a habitual offender of breaking ppcBE with my IDE tests. I'll fix it. :( From MAILER-DAEMON Fri Sep 25 15:25:37 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfYcj-0005uW-Il for mharc-qemu-block@gnu.org; Fri, 25 Sep 2015 15:25:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfYch-0005sv-Vh for qemu-block@nongnu.org; Fri, 25 Sep 2015 15:25:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfYce-0003Oa-RL for qemu-block@nongnu.org; Fri, 25 Sep 2015 15:25:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48448) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfYce-0003OQ-Mw; Fri, 25 Sep 2015 15:25:32 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 67E79C0F05D2; Fri, 25 Sep 2015 19:25:32 +0000 (UTC) Received: from [10.3.113.141] (ovpn-113-141.phx2.redhat.com [10.3.113.141]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8PJPV2M000398; Fri, 25 Sep 2015 15:25:31 -0400 To: Max Reitz , qemu-block@nongnu.org References: <1443201564-6510-1-git-send-email-mreitz@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <56059FAB.5070605@redhat.com> Date: Fri, 25 Sep 2015 13:25:31 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443201564-6510-1-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="J5rUircAUNwTSr9NAN8BRVpEAS5L0pdPj" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org Subject: Re: [Qemu-block] [PATCH] iotests: Fix test 128 for password-less sudo X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2015 19:25:36 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --J5rUircAUNwTSr9NAN8BRVpEAS5L0pdPj Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/25/2015 11:19 AM, Max Reitz wrote: > As of 934659c460d46c948cf348822fda1d38556ed9a4, $QEMU_IO is generally n= o > longer a program name, and therefore "sudo -n $QEMU_IO" will no longer > work. >=20 > Fix this by copying the qemu-io invocation function from common.config,= > making it use $sudo for invoking $QEMU_IO_PROG, and then use that > function instead of $QEMU_IO. >=20 > Reported-by: Fam Zheng > Signed-off-by: Max Reitz > --- > tests/qemu-iotests/128 | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --J5rUircAUNwTSr9NAN8BRVpEAS5L0pdPj Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWBZ+rAAoJEKeha0olJ0Nq75QH/0tILMWrGzq+IdR2pRMuE2sE W5NLazlVpGxHowjiOYIn6CZSTzf1dq01z8nf+TWsiV8/EdreA3tBlJ9URvyFIfzE yzF1uyY9n+VAI08ep1NI7QbNlQO4F+Kc9QNeqRO0tWc2BBRtcqMyhKKPvW0Ro12k g4QKuMYhi0ynE8/e86O6IPLM7lEGhaFu+8iEmqy3EoU+tqILvHWnWMKiaxqCoheh CHDWlVNr8uSon/F1NM3KufP+RzucCbQqSUdXEDjNI4Gftm32YOCLeqCGfisjN7m5 1IpJIAzut6ErUytUcTp8h8o9KCLtAxmx5dp1lZi7trqK5QOtqFKFNQbwSYfSi9Y= =xFyF -----END PGP SIGNATURE----- --J5rUircAUNwTSr9NAN8BRVpEAS5L0pdPj-- From MAILER-DAEMON Sat Sep 26 12:22:24 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfsEy-0007zq-Kv for mharc-qemu-block@gnu.org; Sat, 26 Sep 2015 12:22:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEv-0007un-FQ for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfsEu-0006Mm-4I for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:21 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:28761) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEt-0006Mh-Vr; Sat, 26 Sep 2015 12:22:20 -0400 Received: from Quad.localdomain (unknown [78.238.229.36]) by smtp4-g21.free.fr (Postfix) with ESMTPS id 1F3534C80A3; Sat, 26 Sep 2015 18:22:19 +0200 (CEST) From: Laurent Vivier To: qemu-trivial@nongnu.org Date: Sat, 26 Sep 2015 18:22:08 +0200 Message-Id: <1443284532-8634-7-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443284532-8634-1-git-send-email-laurent@vivier.eu> References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 212.27.42.4 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Laurent Vivier Subject: [Qemu-block] [PATCH 06/10][TRIVIAL] macio-ide: add to storage category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2015 16:22:22 -0000 macio-ide is an IDE controller, so add it to the storage category. Signed-off-by: Laurent Vivier --- hw/ide/macio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ide/macio.c b/hw/ide/macio.c index 66ac2ba..893c9b9 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -590,6 +590,7 @@ static void macio_ide_class_init(ObjectClass *oc, void *data) dc->realize = macio_ide_realizefn; dc->reset = macio_ide_reset; dc->vmsd = &vmstate_pmac; + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); } static const TypeInfo macio_ide_type_info = { -- 2.4.3 From MAILER-DAEMON Sat Sep 26 12:22:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfsF0-00083H-NQ for mharc-qemu-block@gnu.org; Sat, 26 Sep 2015 12:22:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEv-0007uu-HB for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfsEt-0006MZ-Ki for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:21 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:28740) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEt-0006MQ-G8; Sat, 26 Sep 2015 12:22:19 -0400 Received: from Quad.localdomain (unknown [78.238.229.36]) by smtp4-g21.free.fr (Postfix) with ESMTPS id 8A3AA4C8044; Sat, 26 Sep 2015 18:22:18 +0200 (CEST) From: Laurent Vivier To: qemu-trivial@nongnu.org Date: Sat, 26 Sep 2015 18:22:07 +0200 Message-Id: <1443284532-8634-6-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443284532-8634-1-git-send-email-laurent@vivier.eu> References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 212.27.42.4 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Laurent Vivier Subject: [Qemu-block] [PATCH 05/10][TRIVIAL] cuda: add to bridge category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2015 16:22:22 -0000 Cuda is a bridge between PowerMac system bus and the ADB controller, real-time clock, pram and the power management unit. So add it to the bridge category. Signed-off-by: Laurent Vivier --- hw/misc/macio/cuda.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c index f3984e3..4648458 100644 --- a/hw/misc/macio/cuda.c +++ b/hw/misc/macio/cuda.c @@ -738,6 +738,7 @@ static void cuda_class_init(ObjectClass *oc, void *data) dc->reset = cuda_reset; dc->vmsd = &vmstate_cuda; dc->props = cuda_properties; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); } static const TypeInfo cuda_type_info = { -- 2.4.3 From MAILER-DAEMON Sat Sep 26 12:22:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfsF1-00084X-LA for mharc-qemu-block@gnu.org; Sat, 26 Sep 2015 12:22:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEw-0007vM-5C for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfsEv-0006Nf-4p for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:21 -0400 Received: from smtp4-g21.free.fr ([2a01:e0c:1:1599::13]:54792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEv-0006NX-0I; Sat, 26 Sep 2015 12:22:21 -0400 Received: from Quad.localdomain (unknown [78.238.229.36]) by smtp4-g21.free.fr (Postfix) with ESMTPS id 19C114C8070; Sat, 26 Sep 2015 18:22:20 +0200 (CEST) From: Laurent Vivier To: qemu-trivial@nongnu.org Date: Sat, 26 Sep 2015 18:22:10 +0200 Message-Id: <1443284532-8634-9-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443284532-8634-1-git-send-email-laurent@vivier.eu> References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:e0c:1:1599::13 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Laurent Vivier Subject: [Qemu-block] [PATCH 08/10][TRIVIAL] macio: add to bridge category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2015 16:22:23 -0000 macio is a bridge between the PCI bus and the Mac nvram, IDE controller and PIC, so add it to the bridge category. Signed-off-by: Laurent Vivier --- hw/misc/macio/macio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c index e3c0242..c0989a0 100644 --- a/hw/misc/macio/macio.c +++ b/hw/misc/macio/macio.c @@ -393,6 +393,7 @@ static void macio_class_init(ObjectClass *klass, void *data) k->vendor_id = PCI_VENDOR_ID_APPLE; k->class_id = PCI_CLASS_OTHERS << 8; dc->props = macio_properties; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); } static const TypeInfo macio_oldworld_type_info = { -- 2.4.3 From MAILER-DAEMON Sat Sep 26 12:22:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfsF4-00088g-E6 for mharc-qemu-block@gnu.org; Sat, 26 Sep 2015 12:22:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEw-0007wG-Um for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfsEv-0006OW-W2 for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:22 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:28844) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEv-0006Nq-Ne; Sat, 26 Sep 2015 12:22:21 -0400 Received: from Quad.localdomain (unknown [78.238.229.36]) by smtp4-g21.free.fr (Postfix) with ESMTPS id 9F2004C808E; Sat, 26 Sep 2015 18:22:20 +0200 (CEST) From: Laurent Vivier To: qemu-trivial@nongnu.org Date: Sat, 26 Sep 2015 18:22:11 +0200 Message-Id: <1443284532-8634-10-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443284532-8634-1-git-send-email-laurent@vivier.eu> References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 212.27.42.4 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Laurent Vivier Subject: [Qemu-block] [PATCH 09/10][TRIVIAL] macio-nvram: add to misc category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2015 16:22:24 -0000 The macio nvram is a non volatile RAM, so add it the misc category. Signed-off-by: Laurent Vivier --- hw/nvram/mac_nvram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c index d35f8a3..9f16566 100644 --- a/hw/nvram/mac_nvram.c +++ b/hw/nvram/mac_nvram.c @@ -123,6 +123,7 @@ static void macio_nvram_class_init(ObjectClass *oc, void *data) dc->reset = macio_nvram_reset; dc->vmsd = &vmstate_macio_nvram; dc->props = macio_nvram_properties; + set_bit(DEVICE_CATEGORY_MISC, dc->categories); } static const TypeInfo macio_nvram_type_info = { -- 2.4.3 From MAILER-DAEMON Sat Sep 26 12:22:25 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfsEy-00080P-Va for mharc-qemu-block@gnu.org; Sat, 26 Sep 2015 12:22:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEv-0007us-Ga for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfsEs-0006LX-D3 for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:21 -0400 Received: from smtp4-g21.free.fr ([2a01:e0c:1:1599::13]:54613) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEr-0006KX-SY; Sat, 26 Sep 2015 12:22:18 -0400 Received: from Quad.localdomain (unknown [78.238.229.36]) by smtp4-g21.free.fr (Postfix) with ESMTPS id AD4664C806C; Sat, 26 Sep 2015 18:22:16 +0200 (CEST) From: Laurent Vivier To: qemu-trivial@nongnu.org Date: Sat, 26 Sep 2015 18:22:04 +0200 Message-Id: <1443284532-8634-3-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443284532-8634-1-git-send-email-laurent@vivier.eu> References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:e0c:1:1599::13 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Laurent Vivier Subject: [Qemu-block] [PATCH 02/10][TRIVIAL] cmd646: add to storage category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2015 16:22:22 -0000 cmd646 is an IDE controller, so add it to the storage category. Signed-off-by: Laurent Vivier --- hw/ide/cmd646.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c index 66fb9d9..27f3da2 100644 --- a/hw/ide/cmd646.c +++ b/hw/ide/cmd646.c @@ -417,6 +417,7 @@ static void cmd646_ide_class_init(ObjectClass *klass, void *data) k->config_read = cmd646_pci_config_read; k->config_write = cmd646_pci_config_write; dc->props = cmd646_ide_properties; + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); } static const TypeInfo cmd646_ide_info = { -- 2.4.3 From MAILER-DAEMON Sat Sep 26 12:22:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfsEz-00081K-Ct for mharc-qemu-block@gnu.org; Sat, 26 Sep 2015 12:22:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEv-0007uo-Fa for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfsEs-0006LL-Cc for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:21 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:28585) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEr-0006KP-Qw; Sat, 26 Sep 2015 12:22:18 -0400 Received: from Quad.localdomain (unknown [78.238.229.36]) by smtp4-g21.free.fr (Postfix) with ESMTPS id 1C0934C8062; Sat, 26 Sep 2015 18:22:15 +0200 (CEST) From: Laurent Vivier To: qemu-trivial@nongnu.org Date: Sat, 26 Sep 2015 18:22:02 +0200 Message-Id: <1443284532-8634-1-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.4.3 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 212.27.42.4 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Laurent Vivier Subject: [Qemu-block] [PATCH 00/10][TRIVIAL] Define categories for some PPC devices X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2015 16:22:22 -0000 Some PPC devices appear uncategorized in the output of "-device ?". This series tries to categorize some of them. Laurent Vivier (10): adb: add to input category cmd646: add to storage category escc: add to input category grackle: add to bridge category cuda: add to bridge category macio-ide: add to storage category uninorth: add to bridge category macio: add to bridge category macio-nvram: add to misc category openpic: add to misc category hw/char/escc.c | 1 + hw/ide/cmd646.c | 1 + hw/ide/macio.c | 1 + hw/input/adb.c | 2 ++ hw/intc/openpic.c | 1 + hw/intc/openpic_kvm.c | 1 + hw/misc/macio/cuda.c | 1 + hw/misc/macio/macio.c | 1 + hw/nvram/mac_nvram.c | 1 + hw/pci-host/grackle.c | 2 ++ hw/pci-host/uninorth.c | 8 ++++++++ 11 files changed, 20 insertions(+) -- 2.4.3 From MAILER-DAEMON Sat Sep 26 12:22:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfsF1-00083T-5o for mharc-qemu-block@gnu.org; Sat, 26 Sep 2015 12:22:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEv-0007uz-If for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfsEt-0006MH-08 for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:21 -0400 Received: from smtp4-g21.free.fr ([2a01:e0c:1:1599::13]:54685) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEs-0006Lp-RJ; Sat, 26 Sep 2015 12:22:18 -0400 Received: from Quad.localdomain (unknown [78.238.229.36]) by smtp4-g21.free.fr (Postfix) with ESMTPS id F30CC4C801D; Sat, 26 Sep 2015 18:22:17 +0200 (CEST) From: Laurent Vivier To: qemu-trivial@nongnu.org Date: Sat, 26 Sep 2015 18:22:06 +0200 Message-Id: <1443284532-8634-5-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443284532-8634-1-git-send-email-laurent@vivier.eu> References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:e0c:1:1599::13 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Laurent Vivier Subject: [Qemu-block] [PATCH 04/10][TRIVIAL] grackle: add to bridge category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2015 16:22:22 -0000 Grackle is the PCI host controller of oldworld powermac, so add it to the bridge category. Signed-off-by: Laurent Vivier --- hw/pci-host/grackle.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/pci-host/grackle.c b/hw/pci-host/grackle.c index bfe707a..ea31b72 100644 --- a/hw/pci-host/grackle.c +++ b/hw/pci-host/grackle.c @@ -146,8 +146,10 @@ static const TypeInfo grackle_pci_info = { static void pci_grackle_class_init(ObjectClass *klass, void *data) { SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); + DeviceClass *dc = DEVICE_CLASS(klass); k->init = pci_grackle_init_device; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); } static const TypeInfo grackle_pci_host_info = { -- 2.4.3 From MAILER-DAEMON Sat Sep 26 12:22:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfsF4-000899-K9 for mharc-qemu-block@gnu.org; Sat, 26 Sep 2015 12:22:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEx-0007wp-9x for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfsEw-0006Oq-D1 for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:23 -0400 Received: from smtp4-g21.free.fr ([2a01:e0c:1:1599::13]:54827) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEw-0006Oa-7H; Sat, 26 Sep 2015 12:22:22 -0400 Received: from Quad.localdomain (unknown [78.238.229.36]) by smtp4-g21.free.fr (Postfix) with ESMTPS id 53B204C8090; Sat, 26 Sep 2015 18:22:21 +0200 (CEST) From: Laurent Vivier To: qemu-trivial@nongnu.org Date: Sat, 26 Sep 2015 18:22:12 +0200 Message-Id: <1443284532-8634-11-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443284532-8634-1-git-send-email-laurent@vivier.eu> References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:e0c:1:1599::13 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Laurent Vivier Subject: [Qemu-block] [PATCH 10/10][TRIVIAL] openpic: add to misc category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2015 16:22:25 -0000 openpic is a programmable interrupt controller, so add it to the misc category. Signed-off-by: Laurent Vivier --- hw/intc/openpic.c | 1 + hw/intc/openpic_kvm.c | 1 + 2 files changed, 2 insertions(+) diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c index 14ab0e3..bfcf155 100644 --- a/hw/intc/openpic.c +++ b/hw/intc/openpic.c @@ -1643,6 +1643,7 @@ static void openpic_class_init(ObjectClass *oc, void *data) dc->props = openpic_properties; dc->reset = openpic_reset; dc->vmsd = &vmstate_openpic; + set_bit(DEVICE_CATEGORY_MISC, dc->categories); } static const TypeInfo openpic_info = { diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c index f7cac58..649f476 100644 --- a/hw/intc/openpic_kvm.c +++ b/hw/intc/openpic_kvm.c @@ -275,6 +275,7 @@ static void kvm_openpic_class_init(ObjectClass *oc, void *data) dc->realize = kvm_openpic_realize; dc->props = kvm_openpic_properties; dc->reset = kvm_openpic_reset; + set_bit(DEVICE_CATEGORY_MISC, dc->categories); } static const TypeInfo kvm_openpic_info = { -- 2.4.3 From MAILER-DAEMON Sat Sep 26 12:22:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfsF0-00082W-IG for mharc-qemu-block@gnu.org; Sat, 26 Sep 2015 12:22:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEv-0007up-Fm for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfsEs-0006LQ-Cw for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:21 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:28604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEr-0006KR-QX; Sat, 26 Sep 2015 12:22:17 -0400 Received: from Quad.localdomain (unknown [78.238.229.36]) by smtp4-g21.free.fr (Postfix) with ESMTPS id 30FDA4C8070; Sat, 26 Sep 2015 18:22:16 +0200 (CEST) From: Laurent Vivier To: qemu-trivial@nongnu.org Date: Sat, 26 Sep 2015 18:22:03 +0200 Message-Id: <1443284532-8634-2-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443284532-8634-1-git-send-email-laurent@vivier.eu> References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 212.27.42.4 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Laurent Vivier Subject: [Qemu-block] [PATCH 01/10][TRIVIAL] adb: add to input category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2015 16:22:22 -0000 The Apple Desktop Bus is used to connect a keyboard and a mouse, so add it to the input category. Signed-off-by: Laurent Vivier --- hw/input/adb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/input/adb.c b/hw/input/adb.c index a18eea2..09eead9 100644 --- a/hw/input/adb.c +++ b/hw/input/adb.c @@ -362,6 +362,7 @@ static void adb_kbd_class_init(ObjectClass *oc, void *data) akc->parent_realize = dc->realize; dc->realize = adb_kbd_realizefn; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); adc->devreq = adb_kbd_request; dc->reset = adb_kbd_reset; @@ -566,6 +567,7 @@ static void adb_mouse_class_init(ObjectClass *oc, void *data) amc->parent_realize = dc->realize; dc->realize = adb_mouse_realizefn; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); adc->devreq = adb_mouse_request; dc->reset = adb_mouse_reset; -- 2.4.3 From MAILER-DAEMON Sat Sep 26 12:22:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfsF1-00084L-Cz for mharc-qemu-block@gnu.org; Sat, 26 Sep 2015 12:22:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEv-0007uv-HE for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfsEu-0006NM-JJ for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:21 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:28791) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEu-0006Mq-Eb; Sat, 26 Sep 2015 12:22:20 -0400 Received: from Quad.localdomain (unknown [78.238.229.36]) by smtp4-g21.free.fr (Postfix) with ESMTPS id 968564C8062; Sat, 26 Sep 2015 18:22:19 +0200 (CEST) From: Laurent Vivier To: qemu-trivial@nongnu.org Date: Sat, 26 Sep 2015 18:22:09 +0200 Message-Id: <1443284532-8634-8-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443284532-8634-1-git-send-email-laurent@vivier.eu> References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 212.27.42.4 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Laurent Vivier Subject: [Qemu-block] [PATCH 07/10][TRIVIAL] uninorth: add to bridge category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2015 16:22:23 -0000 Uninorth is the mac99 PCI host controller, so add it to the bridge category. Signed-off-by: Laurent Vivier --- hw/pci-host/uninorth.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/pci-host/uninorth.c b/hw/pci-host/uninorth.c index f0144eb..215b64f 100644 --- a/hw/pci-host/uninorth.c +++ b/hw/pci-host/uninorth.c @@ -446,8 +446,10 @@ static const TypeInfo unin_internal_pci_host_info = { static void pci_unin_main_class_init(ObjectClass *klass, void *data) { SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); + DeviceClass *dc = DEVICE_CLASS(klass); sbc->init = pci_unin_main_init_device; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); } static const TypeInfo pci_unin_main_info = { @@ -460,8 +462,10 @@ static const TypeInfo pci_unin_main_info = { static void pci_u3_agp_class_init(ObjectClass *klass, void *data) { SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); + DeviceClass *dc = DEVICE_CLASS(klass); sbc->init = pci_u3_agp_init_device; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); } static const TypeInfo pci_u3_agp_info = { @@ -474,8 +478,10 @@ static const TypeInfo pci_u3_agp_info = { static void pci_unin_agp_class_init(ObjectClass *klass, void *data) { SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); + DeviceClass *dc = DEVICE_CLASS(klass); sbc->init = pci_unin_agp_init_device; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); } static const TypeInfo pci_unin_agp_info = { @@ -488,8 +494,10 @@ static const TypeInfo pci_unin_agp_info = { static void pci_unin_internal_class_init(ObjectClass *klass, void *data) { SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); + DeviceClass *dc = DEVICE_CLASS(klass); sbc->init = pci_unin_internal_init_device; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); } static const TypeInfo pci_unin_internal_info = { -- 2.4.3 From MAILER-DAEMON Sat Sep 26 12:22:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZfsF2-00085M-51 for mharc-qemu-block@gnu.org; Sat, 26 Sep 2015 12:22:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEv-0007v0-IU for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfsEs-0006Ll-Hq for qemu-block@nongnu.org; Sat, 26 Sep 2015 12:22:21 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:28677) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfsEs-0006Kp-Ce; Sat, 26 Sep 2015 12:22:18 -0400 Received: from Quad.localdomain (unknown [78.238.229.36]) by smtp4-g21.free.fr (Postfix) with ESMTPS id 4D1A74C8090; Sat, 26 Sep 2015 18:22:17 +0200 (CEST) From: Laurent Vivier To: qemu-trivial@nongnu.org Date: Sat, 26 Sep 2015 18:22:05 +0200 Message-Id: <1443284532-8634-4-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443284532-8634-1-git-send-email-laurent@vivier.eu> References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 212.27.42.4 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Laurent Vivier Subject: [Qemu-block] [PATCH 03/10][TRIVIAL] escc: add to input category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2015 16:22:23 -0000 ESCC is a serial port controller, so add it to the input category. Signed-off-by: Laurent Vivier --- hw/char/escc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/char/escc.c b/hw/char/escc.c index ba653ef..9816154 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -1035,6 +1035,7 @@ static void escc_class_init(ObjectClass *klass, void *data) dc->reset = escc_reset; dc->vmsd = &vmstate_escc; dc->props = escc_properties; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } static const TypeInfo escc_info = { -- 2.4.3 From MAILER-DAEMON Sun Sep 27 20:18:45 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgM9V-0006D3-JW for mharc-qemu-block@gnu.org; Sun, 27 Sep 2015 20:18:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgM9S-0006CB-ND for qemu-block@nongnu.org; Sun, 27 Sep 2015 20:18:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgM9P-0004ad-Ge for qemu-block@nongnu.org; Sun, 27 Sep 2015 20:18:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41002) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgM9P-0004Zo-A0; Sun, 27 Sep 2015 20:18:39 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 693D2C0AF3D7; Mon, 28 Sep 2015 00:18:37 +0000 (UTC) Received: from localhost (dhcp-14-110.nay.redhat.com [10.66.14.110]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8S0IZ2D000932; Sun, 27 Sep 2015 20:18:36 -0400 Date: Mon, 28 Sep 2015 08:18:33 +0800 From: Fam Zheng To: Alberto Garcia Message-ID: <20150928001833.GB10367@localhost.nay.redhat.com> References: <1443188504-20296-1-git-send-email-berto@igalia.com> <560558A2.3020804@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-block@nongnu.org, qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] block: disable I/O limits at the beginning of bdrv_close() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 00:18:43 -0000 On Fri, 09/25 16:31, Alberto Garcia wrote: > On Fri 25 Sep 2015 04:22:26 PM CEST, Eric Blake wrote: > > >> Disabling I/O limits from a BDS also drains all pending throttled > >> requests, so it should be done at the beginning of bdrv_close() with > >> the rest of the bdrv_drain() calls before the BlockDriver is closed. > > > > Can this be abused? If I have a guest running in a cloud where the > > cloud provider has put severe throttling limits on me, but lets me > > hotplug to my heart's content, couldn't I just repeatedly plug/unplug > > the disk to get around the throttling (every time I unplug, all writes > > flush at full speed, then I immediately replug to start batching up a > > new set of writes). In other words, shouldn't the draining still be > > throttled, to prevent my abuse? > > I didn't think about this case, and I don't know how practical this is, > but note that bdrv_drain() (which is already at the beginning of > bdrv_close()) flushes the I/O queue explicitly bypassing the limits, so > other cases where a user can trigger a bdrv_drain() would also be > vulnerable to this. > Yes, the issue is pre-existing. This patch only reordered things inside bdrv_close() so it's no worse. But indeed there is this vulnerability, maybe we should throttle the queue in all cases? Fam From MAILER-DAEMON Sun Sep 27 23:29:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgP84-0004dW-GO for mharc-qemu-block@gnu.org; Sun, 27 Sep 2015 23:29:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgP81-0004c0-HA for qemu-block@nongnu.org; Sun, 27 Sep 2015 23:29:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgP7y-0002ww-Bg for qemu-block@nongnu.org; Sun, 27 Sep 2015 23:29:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59773) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgP7y-0002wd-60; Sun, 27 Sep 2015 23:29:22 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 7DA8991C15; Mon, 28 Sep 2015 03:29:20 +0000 (UTC) Received: from localhost (ovpn-112-77.phx2.redhat.com [10.3.112.77]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8S3TIud019051 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Sun, 27 Sep 2015 23:29:20 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Sun, 27 Sep 2015 23:29:15 -0400 Message-Id: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org Subject: [Qemu-block] [PATCH 0/3] block: mirror - Write zeroes for unallocated sectors if no zero init X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 03:29:26 -0000 When doing a block mirror to a target that does not support zero init (e.g. host device and raw format), unallocated sectors on the source may lead to a corrupted target image. Unallocated sectors are skipped over during block mirror (the dirty bitmap is only loaded with allocated sectors), so whatever data is already present on the target device in those sectors will likely still be there, leading the guest to read invalid data. There are 3 patches in this series: Patch 1 allows block device dirty bitmaps to be created but not attached (i.e. placed in the dirty_bitmaps list) to a BDS. This clears the way to having a bitmap to be used to track unallocated sectors above the 'base' image. Patch 2 splits out the mirror code that invokes mirror_iteration(), so that we can in later patches run it multiple times using different bitmaps. Patch 3 introduces a 2-pass mirror streaming approach, whereas the first pass writes zeroes for unallocated source sectors (if appropriate for the image type), and the second pass writes the actual source data. Jeff Cody (3): block: allow creation of detached dirty bitmaps block: mirror - split out part of mirror_run() block: mirror - zero unallocated target sectors when zero init not present block.c | 26 +++- block/mirror.c | 302 ++++++++++++++++++++++++++++------------------ blockdev.c | 4 +- include/block/block.h | 1 + include/block/block_int.h | 3 +- migration/block.c | 2 +- qapi/block-core.json | 6 +- 7 files changed, 214 insertions(+), 130 deletions(-) -- 1.9.3 From MAILER-DAEMON Sun Sep 27 23:29:31 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgP87-0004gj-2t for mharc-qemu-block@gnu.org; Sun, 27 Sep 2015 23:29:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgP83-0004ch-Mg for qemu-block@nongnu.org; Sun, 27 Sep 2015 23:29:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgP82-0002xu-5b for qemu-block@nongnu.org; Sun, 27 Sep 2015 23:29:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60023) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgP81-0002xg-Rb; Sun, 27 Sep 2015 23:29:26 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 9565CC0AD288; Mon, 28 Sep 2015 03:29:25 +0000 (UTC) Received: from localhost (ovpn-112-77.phx2.redhat.com [10.3.112.77]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8S3TNAb019063 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Sun, 27 Sep 2015 23:29:24 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Sun, 27 Sep 2015 23:29:17 -0400 Message-Id: <0de92b950741a15b9ff085f7b102ef99ef26101c.1443410673.git.jcody@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org Subject: [Qemu-block] [PATCH 2/3] block: mirror - split out part of mirror_run() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 03:29:29 -0000 This is code relocation, to pull the part of mirror_run() that calls mirror_iteration out into a separate function. Signed-off-by: Jeff Cody --- block/mirror.c | 206 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 110 insertions(+), 96 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 8b3e89b..405e5c4 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -318,6 +318,115 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) return delay_ns; } +static int mirror_do_iteration(MirrorBlockJob *s, uint64_t last_pause_ns) +{ + int ret; + + BlockDriverState *bs = s->common.bs; + + for (;;) { + uint64_t delay_ns = 0; + int64_t cnt; + bool should_complete; + + if (s->ret < 0) { + ret = s->ret; + goto immediate_exit; + } + + cnt = bdrv_get_dirty_count(s->dirty_bitmap); + /* s->common.offset contains the number of bytes already processed so + * far, cnt is the number of dirty sectors remaining and + * s->sectors_in_flight is the number of sectors currently being + * processed; together those are the current total operation length */ + s->common.len = s->common.offset + + (cnt + s->sectors_in_flight) * BDRV_SECTOR_SIZE; + + /* Note that even when no rate limit is applied we need to yield + * periodically with no pending I/O so that bdrv_drain_all() returns. + * We do so every SLICE_TIME nanoseconds, or when there is an error, + * or when the source is clean, whichever comes first. + */ + if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - last_pause_ns < SLICE_TIME + && s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) { + if (s->in_flight == MAX_IN_FLIGHT || s->buf_free_count == 0 || + (cnt == 0 && s->in_flight > 0)) { + trace_mirror_yield(s, s->in_flight, s->buf_free_count, cnt); + s->waiting_for_io = true; + qemu_coroutine_yield(); + s->waiting_for_io = false; + continue; + } else if (cnt != 0) { + delay_ns = mirror_iteration(s); + } + } + + should_complete = false; + if (s->in_flight == 0 && cnt == 0) { + trace_mirror_before_flush(s); + ret = bdrv_flush(s->target); + if (ret < 0) { + if (mirror_error_action(s, false, -ret) == + BLOCK_ERROR_ACTION_REPORT) { + goto immediate_exit; + } + } else { + /* We're out of the streaming phase. From now on, if the job + * is cancelled we will actually complete all pending I/O and + * report completion. This way, block-job-cancel will leave + * the target in a consistent state. + */ + if (!s->synced) { + block_job_event_ready(&s->common); + s->synced = true; + } + + should_complete = s->should_complete || + block_job_is_cancelled(&s->common); + cnt = bdrv_get_dirty_count(s->dirty_bitmap); + } + } + + if (cnt == 0 && should_complete) { + /* The dirty bitmap is not updated while operations are pending. + * If we're about to exit, wait for pending operations before + * calling bdrv_get_dirty_count(bs), or we may exit while the + * source has dirty data to copy! + * + * Note that I/O can be submitted by the guest while + * mirror_populate runs. + */ + trace_mirror_before_drain(s, cnt); + bdrv_drain(bs); + cnt = bdrv_get_dirty_count(s->dirty_bitmap); + } + + ret = 0; + trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); + if (!s->synced) { + block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); + if (block_job_is_cancelled(&s->common)) { + break; + } + } else if (!should_complete) { + delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); + block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); + } else if (cnt == 0) { + /* The two disks are in sync. Exit and report successful + * completion. + */ + assert(QLIST_EMPTY(&bs->tracked_requests)); + s->common.cancelled = false; + break; + } + last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); + } + +immediate_exit: + return ret; + +} + static void mirror_free_init(MirrorBlockJob *s) { int granularity = s->granularity; @@ -485,103 +594,8 @@ static void coroutine_fn mirror_run(void *opaque) } bdrv_dirty_iter_init(s->dirty_bitmap, &s->hbi); - for (;;) { - uint64_t delay_ns = 0; - int64_t cnt; - bool should_complete; - if (s->ret < 0) { - ret = s->ret; - goto immediate_exit; - } - - cnt = bdrv_get_dirty_count(s->dirty_bitmap); - /* s->common.offset contains the number of bytes already processed so - * far, cnt is the number of dirty sectors remaining and - * s->sectors_in_flight is the number of sectors currently being - * processed; together those are the current total operation length */ - s->common.len = s->common.offset + - (cnt + s->sectors_in_flight) * BDRV_SECTOR_SIZE; - - /* Note that even when no rate limit is applied we need to yield - * periodically with no pending I/O so that bdrv_drain_all() returns. - * We do so every SLICE_TIME nanoseconds, or when there is an error, - * or when the source is clean, whichever comes first. - */ - if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - last_pause_ns < SLICE_TIME && - s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) { - if (s->in_flight == MAX_IN_FLIGHT || s->buf_free_count == 0 || - (cnt == 0 && s->in_flight > 0)) { - trace_mirror_yield(s, s->in_flight, s->buf_free_count, cnt); - s->waiting_for_io = true; - qemu_coroutine_yield(); - s->waiting_for_io = false; - continue; - } else if (cnt != 0) { - delay_ns = mirror_iteration(s); - } - } - - should_complete = false; - if (s->in_flight == 0 && cnt == 0) { - trace_mirror_before_flush(s); - ret = bdrv_flush(s->target); - if (ret < 0) { - if (mirror_error_action(s, false, -ret) == - BLOCK_ERROR_ACTION_REPORT) { - goto immediate_exit; - } - } else { - /* We're out of the streaming phase. From now on, if the job - * is cancelled we will actually complete all pending I/O and - * report completion. This way, block-job-cancel will leave - * the target in a consistent state. - */ - if (!s->synced) { - block_job_event_ready(&s->common); - s->synced = true; - } - - should_complete = s->should_complete || - block_job_is_cancelled(&s->common); - cnt = bdrv_get_dirty_count(s->dirty_bitmap); - } - } - - if (cnt == 0 && should_complete) { - /* The dirty bitmap is not updated while operations are pending. - * If we're about to exit, wait for pending operations before - * calling bdrv_get_dirty_count(bs), or we may exit while the - * source has dirty data to copy! - * - * Note that I/O can be submitted by the guest while - * mirror_populate runs. - */ - trace_mirror_before_drain(s, cnt); - bdrv_drain(bs); - cnt = bdrv_get_dirty_count(s->dirty_bitmap); - } - - ret = 0; - trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); - if (!s->synced) { - block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); - if (block_job_is_cancelled(&s->common)) { - break; - } - } else if (!should_complete) { - delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); - block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); - } else if (cnt == 0) { - /* The two disks are in sync. Exit and report successful - * completion. - */ - assert(QLIST_EMPTY(&bs->tracked_requests)); - s->common.cancelled = false; - break; - } - last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); - } + ret = mirror_do_iteration(s, last_pause_ns); immediate_exit: if (s->in_flight > 0) { -- 1.9.3 From MAILER-DAEMON Sun Sep 27 23:29:34 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgP8A-0004mP-0W for mharc-qemu-block@gnu.org; Sun, 27 Sep 2015 23:29:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgP86-0004gH-LB for qemu-block@nongnu.org; Sun, 27 Sep 2015 23:29:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgP84-00030L-Tl for qemu-block@nongnu.org; Sun, 27 Sep 2015 23:29:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgP84-000309-Jp; Sun, 27 Sep 2015 23:29:28 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 56DE88A4A7; Mon, 28 Sep 2015 03:29:28 +0000 (UTC) Received: from localhost (ovpn-112-77.phx2.redhat.com [10.3.112.77]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8S3TQXY019076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Sun, 27 Sep 2015 23:29:27 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Sun, 27 Sep 2015 23:29:18 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org Subject: [Qemu-block] [PATCH 3/3] block: mirror - zero unallocated target sectors when zero init not present X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 03:29:32 -0000 During mirror, if the target device does not have support zero initialization, a mirror may result in a corrupt image. For instance, on mirror to a host device with format = raw, whatever random data is on the target device will still be there for unallocated sectors. This is because during the mirror, we set the dirty bitmap to copy only sectors allocated above 'base'. In the case of target devices where we cannot assume unallocated sectors will be read as zeroes, we need to explicitely zero out this data. In order to avoid zeroing out all sectors of the target device prior to mirroring, we do zeroing as part of the block job. A second dirty bitmap cache is created, to track sectors that are unallocated above 'base'. These sectors are then checked for status of BDRV_BLOCK_ZERO on the target - if they are not, then zeroes are explicitly written. This only occurs under two conditions: 1. 'mode' != "existing" 2. bdrv_has_zero_init(target) == NULL We perform the mirroring through mirror_iteration() as before, except in two passes. If the above two conditions are met, the first pass is using the bitmap tracking unallocated sectors, to write the needed zeroes. Then, the second pass is performed, to mirror the actual data as before. If the above two conditions are not met, then the first pass is skipped, and only the second pass (the one with the actual data) is performed. Signed-off-by: Jeff Cody --- block/mirror.c | 109 ++++++++++++++++++++++++++++++++++------------ blockdev.c | 2 +- include/block/block_int.h | 3 +- qapi/block-core.json | 6 ++- 4 files changed, 87 insertions(+), 33 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 405e5c4..b599176 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -50,7 +50,9 @@ typedef struct MirrorBlockJob { int64_t bdev_length; unsigned long *cow_bitmap; BdrvDirtyBitmap *dirty_bitmap; - HBitmapIter hbi; + HBitmapIter zero_hbi; + HBitmapIter allocated_hbi; + HBitmapIter *hbi; uint8_t *buf; QSIMPLEQ_HEAD(, MirrorBuffer) buf_free; int buf_free_count; @@ -60,6 +62,8 @@ typedef struct MirrorBlockJob { int sectors_in_flight; int ret; bool unmap; + bool zero_unallocated; + bool zero_cycle; bool waiting_for_io; } MirrorBlockJob; @@ -166,10 +170,10 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) int pnum; int64_t ret; - s->sector_num = hbitmap_iter_next(&s->hbi); + s->sector_num = hbitmap_iter_next(s->hbi); if (s->sector_num < 0) { - bdrv_dirty_iter_init(s->dirty_bitmap, &s->hbi); - s->sector_num = hbitmap_iter_next(&s->hbi); + bdrv_dirty_iter_init(s->dirty_bitmap, s->hbi); + s->sector_num = hbitmap_iter_next(s->hbi); trace_mirror_restart_iter(s, bdrv_get_dirty_count(s->dirty_bitmap)); assert(s->sector_num >= 0); } @@ -287,7 +291,7 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) */ if (next_sector > hbitmap_next_sector && bdrv_get_dirty(source, s->dirty_bitmap, next_sector)) { - hbitmap_next_sector = hbitmap_iter_next(&s->hbi); + hbitmap_next_sector = hbitmap_iter_next(s->hbi); } next_sector += sectors_per_chunk; @@ -300,25 +304,34 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) s->sectors_in_flight += nb_sectors; trace_mirror_one_iteration(s, sector_num, nb_sectors); - ret = bdrv_get_block_status_above(source, NULL, sector_num, - nb_sectors, &pnum); - if (ret < 0 || pnum < nb_sectors || - (ret & BDRV_BLOCK_DATA && !(ret & BDRV_BLOCK_ZERO))) { - bdrv_aio_readv(source, sector_num, &op->qiov, nb_sectors, - mirror_read_complete, op); - } else if (ret & BDRV_BLOCK_ZERO) { - bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sectors, - s->unmap ? BDRV_REQ_MAY_UNMAP : 0, - mirror_write_complete, op); + if (s->zero_cycle) { + ret = bdrv_get_block_status(s->target, sector_num, nb_sectors, &pnum); + if (!(ret & BDRV_BLOCK_ZERO)) { + bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sectors, + s->unmap ? BDRV_REQ_MAY_UNMAP : 0, + mirror_write_complete, op); + } } else { - assert(!(ret & BDRV_BLOCK_DATA)); - bdrv_aio_discard(s->target, sector_num, op->nb_sectors, - mirror_write_complete, op); + ret = bdrv_get_block_status_above(source, NULL, sector_num, + nb_sectors, &pnum); + if (ret < 0 || pnum < nb_sectors || + (ret & BDRV_BLOCK_DATA && !(ret & BDRV_BLOCK_ZERO))) { + bdrv_aio_readv(source, sector_num, &op->qiov, nb_sectors, + mirror_read_complete, op); + } else if (ret & BDRV_BLOCK_ZERO) { + bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sectors, + s->unmap ? BDRV_REQ_MAY_UNMAP : 0, + mirror_write_complete, op); + } else { + assert(!(ret & BDRV_BLOCK_DATA)); + bdrv_aio_discard(s->target, sector_num, op->nb_sectors, + mirror_write_complete, op); + } } return delay_ns; } -static int mirror_do_iteration(MirrorBlockJob *s, uint64_t last_pause_ns) +static int mirror_do_iteration(MirrorBlockJob *s, uint64_t *last_pause_ns) { int ret; @@ -347,7 +360,7 @@ static int mirror_do_iteration(MirrorBlockJob *s, uint64_t last_pause_ns) * We do so every SLICE_TIME nanoseconds, or when there is an error, * or when the source is clean, whichever comes first. */ - if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - last_pause_ns < SLICE_TIME + if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - *last_pause_ns < SLICE_TIME && s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) { if (s->in_flight == MAX_IN_FLIGHT || s->buf_free_count == 0 || (cnt == 0 && s->in_flight > 0)) { @@ -371,6 +384,14 @@ static int mirror_do_iteration(MirrorBlockJob *s, uint64_t last_pause_ns) goto immediate_exit; } } else { + + if (s->zero_cycle) { + /* this is not the end of the streaming cycle, + * if we are just filling in zeroes for unallocated + * sectors prior to streaming the real data */ + goto immediate_exit; + } + /* We're out of the streaming phase. From now on, if the job * is cancelled we will actually complete all pending I/O and * report completion. This way, block-job-cancel will leave @@ -419,7 +440,7 @@ static int mirror_do_iteration(MirrorBlockJob *s, uint64_t last_pause_ns) s->common.cancelled = false; break; } - last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); + *last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); } immediate_exit: @@ -511,6 +532,15 @@ static void coroutine_fn mirror_run(void *opaque) checking for a NULL string */ int ret = 0; int n; + BdrvDirtyBitmap *zero_dirty_bitmap; + BdrvDirtyBitmap *allocated_dirty_bitmap = s->dirty_bitmap; + + zero_dirty_bitmap = bdrv_create_dirty_bitmap(s->target, + s->granularity, NULL, true, + NULL); + if (zero_dirty_bitmap == NULL) { + goto immediate_exit; + } if (block_job_is_cancelled(&s->common)) { goto immediate_exit; @@ -588,14 +618,33 @@ static void coroutine_fn mirror_run(void *opaque) assert(n > 0); if (ret == 1) { bdrv_set_dirty_bitmap(s->dirty_bitmap, sector_num, n); + } else if (s->zero_unallocated) { + bdrv_set_dirty_bitmap(zero_dirty_bitmap, sector_num, n); } sector_num += n; } } - bdrv_dirty_iter_init(s->dirty_bitmap, &s->hbi); + bdrv_dirty_iter_init(s->dirty_bitmap, &s->allocated_hbi); - ret = mirror_do_iteration(s, last_pause_ns); + if (s->zero_unallocated) { + bdrv_dirty_iter_init(zero_dirty_bitmap, &s->zero_hbi); + s->dirty_bitmap = zero_dirty_bitmap; + s->hbi = &s->zero_hbi; + + s->zero_cycle = true; + ret = mirror_do_iteration(s, &last_pause_ns); + if (ret < 0) { + goto immediate_exit; + } + + mirror_drain(s); + s->zero_cycle = false; + } + + s->dirty_bitmap = allocated_dirty_bitmap; + s->hbi = &s->allocated_hbi; + ret = mirror_do_iteration(s, &last_pause_ns); immediate_exit: if (s->in_flight > 0) { @@ -611,7 +660,8 @@ immediate_exit: qemu_vfree(s->buf); g_free(s->cow_bitmap); g_free(s->in_flight_bitmap); - bdrv_release_dirty_bitmap(bs, s->dirty_bitmap); + bdrv_release_dirty_bitmap(bs, allocated_dirty_bitmap); + bdrv_release_dirty_bitmap(NULL, zero_dirty_bitmap); bdrv_iostatus_disable(s->target); data = g_malloc(sizeof(*data)); @@ -702,7 +752,7 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target, int64_t buf_size, BlockdevOnError on_source_error, BlockdevOnError on_target_error, - bool unmap, + bool unmap, bool existing, BlockCompletionFunc *cb, void *opaque, Error **errp, const BlockJobDriver *driver, @@ -737,6 +787,7 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target, return; } + s->zero_unallocated = !existing && !bdrv_has_zero_init(target); s->replaces = g_strdup(replaces); s->on_source_error = on_source_error; s->on_target_error = on_target_error; @@ -767,7 +818,7 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, int64_t speed, uint32_t granularity, int64_t buf_size, MirrorSyncMode mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, - bool unmap, + bool unmap, bool existing, BlockCompletionFunc *cb, void *opaque, Error **errp) { @@ -782,8 +833,8 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, base = mode == MIRROR_SYNC_MODE_TOP ? bs->backing_hd : NULL; mirror_start_job(bs, target, replaces, speed, granularity, buf_size, - on_source_error, on_target_error, unmap, cb, opaque, errp, - &mirror_job_driver, is_none_mode, base); + on_source_error, on_target_error, unmap, existing, cb, + opaque, errp, &mirror_job_driver, is_none_mode, base); } void commit_active_start(BlockDriverState *bs, BlockDriverState *base, @@ -830,7 +881,7 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base, bdrv_ref(base); mirror_start_job(bs, base, NULL, speed, 0, 0, - on_error, on_error, false, cb, opaque, &local_err, + on_error, on_error, false, false, cb, opaque, &local_err, &commit_active_job_driver, false, base); if (local_err) { error_propagate(errp, local_err); diff --git a/blockdev.c b/blockdev.c index cb9f78d..c06ac60 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2816,7 +2816,7 @@ void qmp_drive_mirror(const char *device, const char *target, has_replaces ? replaces : NULL, speed, granularity, buf_size, sync, on_source_error, on_target_error, - unmap, + unmap, mode == NEW_IMAGE_MODE_EXISTING, block_job_cb, bs, &local_err); if (local_err != NULL) { bdrv_unref(target_bs); diff --git a/include/block/block_int.h b/include/block/block_int.h index 14ad4c3..21a8988 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -614,6 +614,7 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base, * @on_source_error: The action to take upon error reading from the source. * @on_target_error: The action to take upon error writing to the target. * @unmap: Whether to unmap target where source sectors only contain zeroes. + * @existing: Whether target image is an existing image prior to the QMP cmd. * @cb: Completion function for the job. * @opaque: Opaque pointer value passed to @cb. * @errp: Error object. @@ -628,7 +629,7 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, int64_t speed, uint32_t granularity, int64_t buf_size, MirrorSyncMode mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, - bool unmap, + bool unmap, bool existing, BlockCompletionFunc *cb, void *opaque, Error **errp); diff --git a/qapi/block-core.json b/qapi/block-core.json index bb2189e..033afb4 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -952,8 +952,10 @@ # broken Quorum files. (Since 2.1) # # @mode: #optional whether and how QEMU should create a new image, default is -# 'absolute-paths'. -# +# 'absolute-paths'. If mode != 'existing', and the target does not +# have zero init (sparseness), then the target image will have sectors +# zeroed out that correspond to sectors in an unallocated state in the +# source image. # @speed: #optional the maximum speed, in bytes per second # # @sync: what parts of the disk image should be copied to the destination -- 1.9.3 From MAILER-DAEMON Sun Sep 27 23:29:28 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgP84-0004dc-Kc for mharc-qemu-block@gnu.org; Sun, 27 Sep 2015 23:29:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgP81-0004bz-H1 for qemu-block@nongnu.org; Sun, 27 Sep 2015 23:29:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgP7z-0002xJ-HL for qemu-block@nongnu.org; Sun, 27 Sep 2015 23:29:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59778) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgP7z-0002x9-A2; Sun, 27 Sep 2015 23:29:23 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 0C35F91C15; Mon, 28 Sep 2015 03:29:23 +0000 (UTC) Received: from localhost (ovpn-112-77.phx2.redhat.com [10.3.112.77]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8S3TL5d000595 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Sun, 27 Sep 2015 23:29:22 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Sun, 27 Sep 2015 23:29:16 -0400 Message-Id: <9ae0ce111c95c6f76e872b12b2a6af895f5cfab6.1443410673.git.jcody@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org Subject: [Qemu-block] [PATCH 1/3] block: allow creation of detached dirty bitmaps X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 03:29:26 -0000 This allows the creation of detached dirty bitmaps, so that the block driver dirty bitmaps can be used without inserting the bitmap into the dirty bitmap list for a BDS. To free a bitmap that was created "detached = true", call bdrv_release_dirty_bitmap() with the BlockDriverState argument as NULL. Signed-off-by: Jeff Cody --- block.c | 26 ++++++++++++++++++++------ block/mirror.c | 3 ++- blockdev.c | 2 +- include/block/block.h | 1 + migration/block.c | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/block.c b/block.c index 53f7b08..1567cc2 100644 --- a/block.c +++ b/block.c @@ -3334,6 +3334,7 @@ void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bitmap) BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, uint32_t granularity, const char *name, + bool detached, Error **errp) { int64_t bitmap_size; @@ -3342,7 +3343,7 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, assert((granularity & (granularity - 1)) == 0); - if (name && bdrv_find_dirty_bitmap(bs, name)) { + if (name && !detached && bdrv_find_dirty_bitmap(bs, name)) { error_setg(errp, "Bitmap already exists: %s", name); return NULL; } @@ -3359,7 +3360,9 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, bitmap->size = bitmap_size; bitmap->name = g_strdup(name); bitmap->disabled = false; - QLIST_INSERT_HEAD(&bs->dirty_bitmaps, bitmap, list); + if (!detached) { + QLIST_INSERT_HEAD(&bs->dirty_bitmaps, bitmap, list); + } return bitmap; } @@ -3403,7 +3406,7 @@ int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs, /* Create an anonymous successor */ granularity = bdrv_dirty_bitmap_granularity(bitmap); - child = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp); + child = bdrv_create_dirty_bitmap(bs, granularity, NULL, false, errp); if (!child) { return -1; } @@ -3483,16 +3486,27 @@ static void bdrv_dirty_bitmap_truncate(BlockDriverState *bs) } } +static void bdrv_free_dirty_bitmap(BdrvDirtyBitmap *bitmap) +{ + hbitmap_free(bitmap->bitmap); + g_free(bitmap->name); + g_free(bitmap); +} + void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap) { BdrvDirtyBitmap *bm, *next; + + if (bs == NULL) { + bdrv_free_dirty_bitmap(bitmap); + return; + } + QLIST_FOREACH_SAFE(bm, &bs->dirty_bitmaps, list, next) { if (bm == bitmap) { assert(!bdrv_dirty_bitmap_frozen(bm)); QLIST_REMOVE(bitmap, list); - hbitmap_free(bitmap->bitmap); - g_free(bitmap->name); - g_free(bitmap); + bdrv_free_dirty_bitmap(bitmap); return; } } diff --git a/block/mirror.c b/block/mirror.c index a258926..8b3e89b 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -733,7 +733,8 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target, s->buf_size = ROUND_UP(buf_size, granularity); s->unmap = unmap; - s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp); + s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, false, + errp); if (!s->dirty_bitmap) { g_free(s->replaces); block_job_release(bs); diff --git a/blockdev.c b/blockdev.c index 32b04b4..cb9f78d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2069,7 +2069,7 @@ void qmp_block_dirty_bitmap_add(const char *node, const char *name, granularity = bdrv_get_default_bitmap_granularity(bs); } - bdrv_create_dirty_bitmap(bs, granularity, name, errp); + bdrv_create_dirty_bitmap(bs, granularity, name, false, errp); out: aio_context_release(aio_context); diff --git a/include/block/block.h b/include/block/block.h index ef67353..2ec1e20 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -476,6 +476,7 @@ typedef struct BdrvDirtyBitmap BdrvDirtyBitmap; BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, uint32_t granularity, const char *name, + bool detached, Error **errp); int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, diff --git a/migration/block.c b/migration/block.c index ed865ed..c3e2b86 100644 --- a/migration/block.c +++ b/migration/block.c @@ -320,7 +320,7 @@ static int set_dirty_tracking(void) QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { bmds->dirty_bitmap = bdrv_create_dirty_bitmap(bmds->bs, BLOCK_SIZE, - NULL, NULL); + NULL, false, NULL); if (!bmds->dirty_bitmap) { ret = -errno; goto fail; -- 1.9.3 From MAILER-DAEMON Mon Sep 28 11:05:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgZzv-0003mU-Oo for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 11:05:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgUNI-0004Dp-Np for qemu-block@nongnu.org; Mon, 28 Sep 2015 05:05:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgUNH-0007gx-LU for qemu-block@nongnu.org; Mon, 28 Sep 2015 05:05:32 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:51214 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgUNA-0007Ac-Ty; Mon, 28 Sep 2015 05:05:25 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2ArBQCfAQlW/5tjdVtdGQEBgwmBPakGAQEBBQGBDZMth3QCgTw5EwEBAQEBAQGBCoQlAQEDATo/EAshJQ8BLBsGE4gmDAHKZwEBAQEBBQEBAQEehiyFRIUNB4QsAQSVcJwUjDojAT+CQ4FAPDOJIQEBAQ X-IPAS-Result: A2ArBQCfAQlW/5tjdVtdGQEBgwmBPakGAQEBBQGBDZMth3QCgTw5EwEBAQEBAQGBCoQlAQEDATo/EAshJQ8BLBsGE4gmDAHKZwEBAQEBBQEBAQEehiyFRIUNB4QsAQSVcJwUjDojAT+CQ4FAPDOJIQEBAQ X-IronPort-AV: E=Sophos;i="5.17,602,1437429600"; d="scan'208";a="27972886" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 28 Sep 2015 11:04:44 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZgUMW-00057E-NL; Mon, 28 Sep 2015 11:04:44 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZgUMW-0006SJ-HZ; Mon, 28 Sep 2015 11:04:44 +0200 From: Alberto Garcia To: Fam Zheng In-Reply-To: <20150928001833.GB10367@localhost.nay.redhat.com> References: <1443188504-20296-1-git-send-email-berto@igalia.com> <560558A2.3020804@redhat.com> <20150928001833.GB10367@localhost.nay.redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Mon, 28 Sep 2015 11:04:44 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , qemu-block@nongnu.org, qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: Re: [Qemu-block] [Qemu-devel] [PATCH] block: disable I/O limits at the beginning of bdrv_close() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 09:05:38 -0000 On Mon 28 Sep 2015 02:18:33 AM CEST, Fam Zheng wrote: >> > Can this be abused? If I have a guest running in a cloud where the >> > cloud provider has put severe throttling limits on me, but lets me >> > hotplug to my heart's content, couldn't I just repeatedly >> > plug/unplug the disk to get around the throttling (every time I >> > unplug, all writes flush at full speed, then I immediately replug >> > to start batching up a new set of writes). In other words, >> > shouldn't the draining still be throttled, to prevent my abuse? >> >> I didn't think about this case, and I don't know how practical this >> is, but note that bdrv_drain() (which is already at the beginning of >> bdrv_close()) flushes the I/O queue explicitly bypassing the limits, >> so other cases where a user can trigger a bdrv_drain() would also be >> vulnerable to this. > > Yes, the issue is pre-existing. This patch only reordered things > inside bdrv_close() so it's no worse. > > But indeed there is this vulnerability, maybe we should throttle the > queue in all cases? I would like to see a test case with numbers that show how much you can actually bypass the I/O limits. Berto From MAILER-DAEMON Mon Sep 28 11:29:33 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgaMv-0002Is-7H for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 11:29:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgUm6-0001mt-F9 for qemu-block@nongnu.org; Mon, 28 Sep 2015 05:31:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgUm2-0003JE-E2 for qemu-block@nongnu.org; Mon, 28 Sep 2015 05:31:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50509) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgUm2-0003It-6s; Mon, 28 Sep 2015 05:31:06 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 3D9D43B3C2; Mon, 28 Sep 2015 09:31:05 +0000 (UTC) Received: from localhost (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8S9V28T002714; Mon, 28 Sep 2015 05:31:03 -0400 Date: Mon, 28 Sep 2015 10:31:00 +0100 From: Stefan Hajnoczi To: Kevin Wolf Message-ID: <20150928093100.GA8756@stefanha-thinkpad.redhat.com> References: <1438144934-23619-1-git-send-email-famz@redhat.com> <20150911103926.GA5164@noname.redhat.com> <20150911114653.GA11386@ad.nay.redhat.com> <20150911122214.GB5164@noname.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150911122214.GB5164@noname.redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, Fam Zheng , qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 00/11] aio: Introduce handler type to fix nested aio_poll for dataplane X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 09:31:16 -0000 On Fri, Sep 11, 2015 at 02:22:14PM +0200, Kevin Wolf wrote: > Am 11.09.2015 um 13:46 hat Fam Zheng geschrieben: > > On Fri, 09/11 12:39, Kevin Wolf wrote: > > > Am 29.07.2015 um 06:42 hat Fam Zheng geschrieben: > > > > v2: Switch to disable/enable model. [Paolo] > > > > > > > > Most existing nested aio_poll()'s in block layer are inconsiderate of > > > > dispatching potential new r/w requests from ioeventfds and nbd exports, which > > > > might result in responsiveness issues (e.g. bdrv_drain_all will not return when > > > > new requests keep coming), or even wrong semantics (e.g. qmp_transaction cannot > > > > enforce atomicity due to aio_poll in bdrv_drain_all). > > > > > > > > Previous attampts to address this issue include new op blocker[1], bdrv_lock[2] > > > > and nested AioContext (patches not posted to qemu-devel). > > > > > > > > This approach is based on the idea proposed by Paolo Bonzini. The original idea > > > > is introducing "aio_context_disable_client / aio_context_enable_client to > > > > filter AioContext handlers according to the "client", e.g. > > > > AIO_CLIENT_DATAPLANE (ioeventfd), AIO_CLIENT_PROTOCOL, AIO_CLIENT_NBD_SERVER, > > > > AIO_CLIENT_CONTEXT, ... Extend aio_set_{event_notifier,fd}_handler to pass a > > > > client (type)." > > > > > > > > After this series, block layer aio_poll() will only process those "protocol" > > > > fds that are used in block I/O, plus the ctx->notifier for aio_notify(); other > > > > aio_poll()'s keep unchanged. > > > > > > > > The biggest advantage over approaches [1] and [2] is, no change is needed in > > > > virtio-{blk,scsi}-dataplane code, also this doesn't depend on converting QMP to > > > > coroutines. > > > > > > It seems that I haven't replied on the mailing list yet, even though I > > > think I already said this in person at KVM Forum: This series fixes only > > > a special case of the real problem, which is that bdrv_drain/all at a > > > single point doesn't make a lot of sense, but needs to be replaced by a > > > whole section with exclusive access, like a bdrv_drained_begin/end pair. > > > > > > To be clear: Anything that works with types of users instead of > > > individual users is bound to fall short of being a complete solution. I > > > don't prefer partial solutions when we know there is a bigger problem. > > > > > > This series addresses your immediate need of protecting against new data > > > plane requests, which it arguably achieves. The second case I always > > > have in mind is Berto's case where he has multiple streaming block jobs > > > in the same backing file chain [1]. > > > > > > This involves a bdrv_reopen() of the target BDS to make it writable, and > > > bdrv_reopen() uses bdrv_drain_all() so drivers don't have to cope with > > > running requests while reopening themselves. It can however involve > > > nested event loops for synchronous operations like bdrv_flush(), and if > > > those can process completions of block jobs, which can respond by doing > > > anything to the respective node, things can go wrong. > > > > Just to get a better idea of bdrv_drained_begin/end, could you explain how to > > use the pair to fix the above problem? > > How to use it is easy part: In bdrv_reopen_multiple(), you would replace > the existing bdrv_drain_all() with begin and you would add the > corresponding end right before the return statement. > > > > You don't solve this by adding client types (then problematic request > > > would be PROTOCOL in your proposal and you can never exclude that), but > > > you really need to have bdrv_drained_being/end pairs, where only > > > requests issued in between are processed and everything else waits. > > > > What do you mean by "only requests issued in between are processed"? Where are > > the requests from? > > Generally speaking, you would have code that looks like this: > > bdrv_drain_begin() > ... > bdrv_something_synchronous() > ... > bdrv_drain_end() > > You want to process everything that is necessary for completing > bdrv_something_synchronous(), but nothing else. > > The trickier question is how to implement this. I know that it's much > easier to say that your series doesn't work than actually proposing > something else that works... > > One relatively obvious answer we found when we discussed this a while > back was some kind of a recursive CoRwLock (reader = in-flight request; > writer = drained section), but that requires obviously that you're > running in a coroutine if you want to do something with a drained > request queue. At one point I thought about converting vl.c:main() to run everything in a coroutine. It would allow us to eliminate synchronous operations completely. The problem is that it's quite a big change that requires protecting formerly synchronous operations against concurrency. Stefan From MAILER-DAEMON Mon Sep 28 13:02:00 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgboO-00067y-Ci for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 13:02:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgV4v-0006rf-1g for qemu-block@nongnu.org; Mon, 28 Sep 2015 05:50:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgV4q-0005XD-1S for qemu-block@nongnu.org; Mon, 28 Sep 2015 05:50:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37412) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgV4p-0005X1-Rw; Mon, 28 Sep 2015 05:50:31 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 90ED145; Mon, 28 Sep 2015 09:50:30 +0000 (UTC) Received: from localhost (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8S9oSc2031828; Mon, 28 Sep 2015 05:50:29 -0400 Date: Mon, 28 Sep 2015 10:50:26 +0100 From: Stefan Hajnoczi To: Paolo Bonzini Message-ID: <20150928095026.GB8756@stefanha-thinkpad.redhat.com> References: <1438868176-20364-1-git-send-email-pbonzini@redhat.com> <1438868176-20364-2-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438868176-20364-2-git-send-email-pbonzini@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 01/18] iothread: release iothread around aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 09:50:38 -0000 On Thu, Aug 06, 2015 at 03:35:59PM +0200, Paolo Bonzini wrote: > This is the first step towards having fine-grained critical sections in > dataplane threads, which resolves lock ordering problems between > address_space_* functions (which need the BQL when doing MMIO, even > after we complete RCU-based dispatch) and the AioContext. > > Because AioContext does not use contention callbacks anymore, the > unit test has to be changed. > > Previously applied as a0710f7995f914e3044e5899bd8ff6c43c62f916 and > then reverted. commit da5e1de95bb235330d7724316e7a29239d1359d5 Author: Stefan Hajnoczi Date: Wed Jun 3 10:15:33 2015 +0100 Revert "iothread: release iothread around aio_poll" This reverts commit a0710f7995f914e3044e5899bd8ff6c43c62f916. In qemu-devel email message <556DBF87.2020908@de.ibm.com>, Christian Borntraeger writes: Having many guests all with a kernel/ramdisk (via -kernel) and several null block devices will result in hangs. All hanging guests are in partition detection code waiting for an I/O to return so very early maybe even the first I/O. Reverting that commit "fixes" the hangs. Reverting this commit for the 2.4 release. More time is needed to investigate and correct this patch. Did we ever find the root cause for hangs caused by this patch? From MAILER-DAEMON Mon Sep 28 13:33:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgcJ5-0008AH-UY for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 13:33:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVNd-0002Nr-4y for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:09:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgVNZ-00082T-5X for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:09:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38333) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVNZ-00082J-0K; Mon, 28 Sep 2015 06:09:53 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 6C4622FAA80; Mon, 28 Sep 2015 10:09:52 +0000 (UTC) Received: from localhost (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SA9oKd004050; Mon, 28 Sep 2015 06:09:51 -0400 Date: Mon, 28 Sep 2015 11:09:48 +0100 From: Stefan Hajnoczi To: Paolo Bonzini Message-ID: <20150928100948.GC8756@stefanha-thinkpad.redhat.com> References: <1438868176-20364-1-git-send-email-pbonzini@redhat.com> <1438868176-20364-3-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438868176-20364-3-git-send-email-pbonzini@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 02/18] aio: rename bh_lock to list_lock X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 10:09:58 -0000 On Thu, Aug 06, 2015 at 03:36:00PM +0200, Paolo Bonzini wrote: > This will be used for AioHandlers too. There is going to be little > or no contention, so it is better to reuse the same lock. > > Signed-off-by: Paolo Bonzini > --- > async.c | 16 ++++++++-------- > include/block/aio.h | 2 +- > 2 files changed, 9 insertions(+), 9 deletions(-) Reviewed-by: Stefan Hajnoczi From MAILER-DAEMON Mon Sep 28 13:39:47 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgcOx-0000ZX-MG for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 13:39:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVS4-00033C-1p for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:14:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgVRz-0001f7-Vl for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:14:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57070) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVRz-0001ei-R2; Mon, 28 Sep 2015 06:14:27 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 49A638C1D6; Mon, 28 Sep 2015 10:14:27 +0000 (UTC) Received: from [10.36.112.57] (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SAENVA006720 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 06:14:25 -0400 To: Stefan Hajnoczi References: <1438868176-20364-1-git-send-email-pbonzini@redhat.com> <1438868176-20364-2-git-send-email-pbonzini@redhat.com> <20150928095026.GB8756@stefanha-thinkpad.redhat.com> From: Paolo Bonzini Message-ID: <56091300.4070000@redhat.com> Date: Mon, 28 Sep 2015 12:14:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150928095026.GB8756@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 01/18] iothread: release iothread around aio_poll X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 10:14:33 -0000 On 28/09/2015 11:50, Stefan Hajnoczi wrote: > On Thu, Aug 06, 2015 at 03:35:59PM +0200, Paolo Bonzini wrote: >> This is the first step towards having fine-grained critical sections in >> dataplane threads, which resolves lock ordering problems between >> address_space_* functions (which need the BQL when doing MMIO, even >> after we complete RCU-based dispatch) and the AioContext. >> >> Because AioContext does not use contention callbacks anymore, the >> unit test has to be changed. >> >> Previously applied as a0710f7995f914e3044e5899bd8ff6c43c62f916 and >> then reverted. > > commit da5e1de95bb235330d7724316e7a29239d1359d5 > Author: Stefan Hajnoczi > Date: Wed Jun 3 10:15:33 2015 +0100 > > Revert "iothread: release iothread around aio_poll" > > This reverts commit a0710f7995f914e3044e5899bd8ff6c43c62f916. > > In qemu-devel email message <556DBF87.2020908@de.ibm.com>, Christian > Borntraeger writes: > > Having many guests all with a kernel/ramdisk (via -kernel) and > several null block devices will result in hangs. All hanging > guests are in partition detection code waiting for an I/O to return > so very early maybe even the first I/O. > > Reverting that commit "fixes" the hangs. > > Reverting this commit for the 2.4 release. More time is needed to > investigate and correct this patch. > > Did we ever find the root cause for hangs caused by this patch? It was fixed by commit 53ec73e ("block: Use bdrv_drain to replace uncessary bdrv_drain_all", 2015-05-29)'s change to bdrv_set_aio_context. We never investigated the root cause, but I'd guess it's gone after the 2.4-rc bugfixes to AioContext. Paolo From MAILER-DAEMON Mon Sep 28 13:45:14 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgcUE-0002R7-1a for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 13:45:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVUc-0003WA-7d for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:17:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgVUZ-0003Dy-11 for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:17:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52217) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVUY-0003Dh-Sc; Mon, 28 Sep 2015 06:17:06 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id DBF34AC863; Mon, 28 Sep 2015 10:17:05 +0000 (UTC) Received: from localhost (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SAH3AH007978; Mon, 28 Sep 2015 06:17:04 -0400 Date: Mon, 28 Sep 2015 11:15:58 +0100 From: Stefan Hajnoczi To: Paolo Bonzini Message-ID: <20150928101558.GD8756@stefanha-thinkpad.redhat.com> References: <1438868176-20364-1-git-send-email-pbonzini@redhat.com> <1438868176-20364-4-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438868176-20364-4-git-send-email-pbonzini@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 03/18] qemu-thread: introduce QemuLockCnt X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 10:17:11 -0000 On Thu, Aug 06, 2015 at 03:36:01PM +0200, Paolo Bonzini wrote: > +int qemu_lockcnt_count(QemuLockCnt *lockcnt); Why use int here when the counter field is unsigned? From MAILER-DAEMON Mon Sep 28 13:45:49 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgcUn-0002uG-AH for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 13:45:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVV6-0003f5-I0 for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:17:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgVV3-0003N4-6x for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:17:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVV3-0003Mu-2A; Mon, 28 Sep 2015 06:17:37 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 8D1572F90DE; Mon, 28 Sep 2015 10:17:36 +0000 (UTC) Received: from [10.36.112.57] (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SAHWnq026979 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 06:17:34 -0400 To: Stefan Hajnoczi References: <1438868176-20364-1-git-send-email-pbonzini@redhat.com> <1438868176-20364-4-git-send-email-pbonzini@redhat.com> <20150928101558.GD8756@stefanha-thinkpad.redhat.com> From: Paolo Bonzini Message-ID: <560913BD.7060809@redhat.com> Date: Mon, 28 Sep 2015 12:17:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150928101558.GD8756@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 03/18] qemu-thread: introduce QemuLockCnt X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 10:17:41 -0000 On 28/09/2015 12:15, Stefan Hajnoczi wrote: > On Thu, Aug 06, 2015 at 03:36:01PM +0200, Paolo Bonzini wrote: >> > +int qemu_lockcnt_count(QemuLockCnt *lockcnt); > Why use int here when the counter field is unsigned? Nice catch, will fix. Paolo From MAILER-DAEMON Mon Sep 28 17:38:56 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgg8O-0000Fi-I1 for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 17:38:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVvW-0002Oi-Bb for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:44:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgVvT-0000b7-5H for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:44:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVvT-0000al-0I; Mon, 28 Sep 2015 06:44:55 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id E3BC58EA30; Mon, 28 Sep 2015 10:44:53 +0000 (UTC) Received: from [10.36.7.147] (vpn1-7-147.ams2.redhat.com [10.36.7.147]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SAioX8003475 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 06:44:51 -0400 To: Laurent Vivier , qemu-trivial@nongnu.org References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> <1443284532-8634-2-git-send-email-laurent@vivier.eu> From: Thomas Huth Message-ID: <56091A21.2030304@redhat.com> Date: Mon, 28 Sep 2015 12:44:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443284532-8634-2-git-send-email-laurent@vivier.eu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 01/10][TRIVIAL] adb: add to input category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 10:44:59 -0000 On 26/09/15 18:22, Laurent Vivier wrote: > The Apple Desktop Bus is used to connect a keyboard and a mouse, > so add it to the input category. > > Signed-off-by: Laurent Vivier > --- > hw/input/adb.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/hw/input/adb.c b/hw/input/adb.c > index a18eea2..09eead9 100644 > --- a/hw/input/adb.c > +++ b/hw/input/adb.c > @@ -362,6 +362,7 @@ static void adb_kbd_class_init(ObjectClass *oc, void *data) > > akc->parent_realize = dc->realize; > dc->realize = adb_kbd_realizefn; > + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); > > adc->devreq = adb_kbd_request; > dc->reset = adb_kbd_reset; > @@ -566,6 +567,7 @@ static void adb_mouse_class_init(ObjectClass *oc, void *data) > > amc->parent_realize = dc->realize; > dc->realize = adb_mouse_realizefn; > + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); > > adc->devreq = adb_mouse_request; > dc->reset = adb_mouse_reset; Reviewed-by: Thomas Huth From MAILER-DAEMON Mon Sep 28 17:39:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgg8U-0000Pz-90 for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 17:39:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVwq-0002YZ-DF for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:46:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgVwn-0001uQ-5s for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:46:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53408) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVwn-0001uC-0t; Mon, 28 Sep 2015 06:46:17 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 94B659159D; Mon, 28 Sep 2015 10:46:16 +0000 (UTC) Received: from [10.36.7.147] (vpn1-7-147.ams2.redhat.com [10.36.7.147]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SAkCNk004295 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 06:46:14 -0400 To: Laurent Vivier , qemu-trivial@nongnu.org References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> <1443284532-8634-3-git-send-email-laurent@vivier.eu> From: Thomas Huth Message-ID: <56091A74.6050904@redhat.com> Date: Mon, 28 Sep 2015 12:46:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443284532-8634-3-git-send-email-laurent@vivier.eu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 02/10][TRIVIAL] cmd646: add to storage category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 10:46:21 -0000 On 26/09/15 18:22, Laurent Vivier wrote: > cmd646 is an IDE controller, so add it to the > storage category. > > Signed-off-by: Laurent Vivier > --- > hw/ide/cmd646.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c > index 66fb9d9..27f3da2 100644 > --- a/hw/ide/cmd646.c > +++ b/hw/ide/cmd646.c > @@ -417,6 +417,7 @@ static void cmd646_ide_class_init(ObjectClass *klass, void *data) > k->config_read = cmd646_pci_config_read; > k->config_write = cmd646_pci_config_write; > dc->props = cmd646_ide_properties; > + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); > } Reviewed-by: Thomas Huth From MAILER-DAEMON Mon Sep 28 17:39:04 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgg8W-0000Ta-RO for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 17:39:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVxt-0002cp-2R for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:47:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgVxo-0002Lj-2X for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:47:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33768) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVxn-0002L1-T8; Mon, 28 Sep 2015 06:47:20 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 86B833B3C2; Mon, 28 Sep 2015 10:47:19 +0000 (UTC) Received: from [10.36.7.147] (vpn1-7-147.ams2.redhat.com [10.36.7.147]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SAlFto025240 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 06:47:16 -0400 To: Laurent Vivier , qemu-trivial@nongnu.org References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> <1443284532-8634-4-git-send-email-laurent@vivier.eu> From: Thomas Huth Message-ID: <56091AB3.4010207@redhat.com> Date: Mon, 28 Sep 2015 12:47:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443284532-8634-4-git-send-email-laurent@vivier.eu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 03/10][TRIVIAL] escc: add to input category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 10:47:25 -0000 On 26/09/15 18:22, Laurent Vivier wrote: > ESCC is a serial port controller, so add it > to the input category. > > Signed-off-by: Laurent Vivier > --- > hw/char/escc.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/hw/char/escc.c b/hw/char/escc.c > index ba653ef..9816154 100644 > --- a/hw/char/escc.c > +++ b/hw/char/escc.c > @@ -1035,6 +1035,7 @@ static void escc_class_init(ObjectClass *klass, void *data) > dc->reset = escc_reset; > dc->vmsd = &vmstate_escc; > dc->props = escc_properties; > + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); > } Reviewed-by: Thomas Huth From MAILER-DAEMON Mon Sep 28 17:41:20 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZggAi-0003YZ-6d for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 17:41:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVzW-0003AJ-3a for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:49:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgVzR-00039u-5C for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:49:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44301) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgVzQ-00039h-WB; Mon, 28 Sep 2015 06:49:01 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 9ADDD2FAA67; Mon, 28 Sep 2015 10:49:00 +0000 (UTC) Received: from [10.36.7.147] (vpn1-7-147.ams2.redhat.com [10.36.7.147]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SAmvZZ025574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 06:48:58 -0400 To: Laurent Vivier , qemu-trivial@nongnu.org References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> <1443284532-8634-7-git-send-email-laurent@vivier.eu> From: Thomas Huth Message-ID: <56091B18.7040004@redhat.com> Date: Mon, 28 Sep 2015 12:48:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443284532-8634-7-git-send-email-laurent@vivier.eu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 06/10][TRIVIAL] macio-ide: add to storage category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 10:49:06 -0000 On 26/09/15 18:22, Laurent Vivier wrote: > macio-ide is an IDE controller, so add it > to the storage category. > > Signed-off-by: Laurent Vivier > --- > hw/ide/macio.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/hw/ide/macio.c b/hw/ide/macio.c > index 66ac2ba..893c9b9 100644 > --- a/hw/ide/macio.c > +++ b/hw/ide/macio.c > @@ -590,6 +590,7 @@ static void macio_ide_class_init(ObjectClass *oc, void *data) > dc->realize = macio_ide_realizefn; > dc->reset = macio_ide_reset; > dc->vmsd = &vmstate_pmac; > + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); > } Reviewed-by: Thomas Huth From MAILER-DAEMON Mon Sep 28 18:01:09 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZggTt-0002gP-9s for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 18:01:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgW7i-0005Io-8w for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:57:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgW7c-0007cN-Jc for qemu-block@nongnu.org; Mon, 28 Sep 2015 06:57:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45455) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgW7c-0007cJ-EK; Mon, 28 Sep 2015 06:57:28 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 0C4812FAA7F; Mon, 28 Sep 2015 10:57:28 +0000 (UTC) Received: from [10.36.7.147] (vpn1-7-147.ams2.redhat.com [10.36.7.147]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SAvOs1013122 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 06:57:25 -0400 To: Laurent Vivier , qemu-trivial@nongnu.org References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> <1443284532-8634-5-git-send-email-laurent@vivier.eu> From: Thomas Huth Message-ID: <56091D14.6070203@redhat.com> Date: Mon, 28 Sep 2015 12:57:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443284532-8634-5-git-send-email-laurent@vivier.eu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 04/10][TRIVIAL] grackle: add to bridge category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 10:57:35 -0000 On 26/09/15 18:22, Laurent Vivier wrote: > Grackle is the PCI host controller of oldworld powermac, > so add it to the bridge category. > > Signed-off-by: Laurent Vivier > --- > hw/pci-host/grackle.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/hw/pci-host/grackle.c b/hw/pci-host/grackle.c > index bfe707a..ea31b72 100644 > --- a/hw/pci-host/grackle.c > +++ b/hw/pci-host/grackle.c > @@ -146,8 +146,10 @@ static const TypeInfo grackle_pci_info = { > static void pci_grackle_class_init(ObjectClass *klass, void *data) > { > SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); > + DeviceClass *dc = DEVICE_CLASS(klass); > > k->init = pci_grackle_init_device; > + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); > } Reviewed-by: Thomas Huth From MAILER-DAEMON Mon Sep 28 18:08:30 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zggb0-000612-2J for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 18:08:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgWEf-0005yO-Ee for qemu-block@nongnu.org; Mon, 28 Sep 2015 07:04:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgWEZ-00028M-GT for qemu-block@nongnu.org; Mon, 28 Sep 2015 07:04:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgWEZ-00028G-BG; Mon, 28 Sep 2015 07:04:39 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id E3F23C0B64B7; Mon, 28 Sep 2015 11:04:38 +0000 (UTC) Received: from [10.36.7.147] (vpn1-7-147.ams2.redhat.com [10.36.7.147]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SB4ZGh016803 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 07:04:36 -0400 To: Laurent Vivier , qemu-trivial@nongnu.org References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> <1443284532-8634-8-git-send-email-laurent@vivier.eu> From: Thomas Huth Message-ID: <56091EC3.9010007@redhat.com> Date: Mon, 28 Sep 2015 13:04:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443284532-8634-8-git-send-email-laurent@vivier.eu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 07/10][TRIVIAL] uninorth: add to bridge category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 11:04:46 -0000 On 26/09/15 18:22, Laurent Vivier wrote: > Uninorth is the mac99 PCI host controller, so add > it to the bridge category. > > Signed-off-by: Laurent Vivier > --- > hw/pci-host/uninorth.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/hw/pci-host/uninorth.c b/hw/pci-host/uninorth.c > index f0144eb..215b64f 100644 > --- a/hw/pci-host/uninorth.c > +++ b/hw/pci-host/uninorth.c > @@ -446,8 +446,10 @@ static const TypeInfo unin_internal_pci_host_info = { > static void pci_unin_main_class_init(ObjectClass *klass, void *data) > { > SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); > + DeviceClass *dc = DEVICE_CLASS(klass); > > sbc->init = pci_unin_main_init_device; > + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); > } > > static const TypeInfo pci_unin_main_info = { > @@ -460,8 +462,10 @@ static const TypeInfo pci_unin_main_info = { > static void pci_u3_agp_class_init(ObjectClass *klass, void *data) > { > SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); > + DeviceClass *dc = DEVICE_CLASS(klass); > > sbc->init = pci_u3_agp_init_device; > + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); > } > > static const TypeInfo pci_u3_agp_info = { > @@ -474,8 +478,10 @@ static const TypeInfo pci_u3_agp_info = { > static void pci_unin_agp_class_init(ObjectClass *klass, void *data) > { > SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); > + DeviceClass *dc = DEVICE_CLASS(klass); > > sbc->init = pci_unin_agp_init_device; > + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); > } > > static const TypeInfo pci_unin_agp_info = { > @@ -488,8 +494,10 @@ static const TypeInfo pci_unin_agp_info = { > static void pci_unin_internal_class_init(ObjectClass *klass, void *data) > { > SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); > + DeviceClass *dc = DEVICE_CLASS(klass); > > sbc->init = pci_unin_internal_init_device; > + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); > } Reviewed-by: Thomas Huth From MAILER-DAEMON Mon Sep 28 18:08:32 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zggb2-00065e-9r for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 18:08:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgWFD-000655-Pd for qemu-block@nongnu.org; Mon, 28 Sep 2015 07:05:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgWF9-0002au-Qs for qemu-block@nongnu.org; Mon, 28 Sep 2015 07:05:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36458) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgWF9-0002ab-Lz; Mon, 28 Sep 2015 07:05:15 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id B76E53B3C2; Mon, 28 Sep 2015 11:05:14 +0000 (UTC) Received: from [10.36.7.147] (vpn1-7-147.ams2.redhat.com [10.36.7.147]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SB5A8I004656 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 07:05:12 -0400 To: Laurent Vivier , qemu-trivial@nongnu.org References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> <1443284532-8634-9-git-send-email-laurent@vivier.eu> From: Thomas Huth Message-ID: <56091EE5.3080707@redhat.com> Date: Mon, 28 Sep 2015 13:05:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443284532-8634-9-git-send-email-laurent@vivier.eu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 08/10][TRIVIAL] macio: add to bridge category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 11:05:24 -0000 On 26/09/15 18:22, Laurent Vivier wrote: > macio is a bridge between the PCI bus and the Mac nvram, > IDE controller and PIC, so add it to the bridge category. > > Signed-off-by: Laurent Vivier > --- > hw/misc/macio/macio.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c > index e3c0242..c0989a0 100644 > --- a/hw/misc/macio/macio.c > +++ b/hw/misc/macio/macio.c > @@ -393,6 +393,7 @@ static void macio_class_init(ObjectClass *klass, void *data) > k->vendor_id = PCI_VENDOR_ID_APPLE; > k->class_id = PCI_CLASS_OTHERS << 8; > dc->props = macio_properties; > + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); > } Reviewed-by: Thomas Huth From MAILER-DAEMON Mon Sep 28 18:11:26 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zggdq-0007Ef-UB for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 18:11:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgWFY-00068n-9p for qemu-block@nongnu.org; Mon, 28 Sep 2015 07:05:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgWFX-0002qe-2U for qemu-block@nongnu.org; Mon, 28 Sep 2015 07:05:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36521) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgWFW-0002q0-JQ; Mon, 28 Sep 2015 07:05:38 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 1E75CA2C16; Mon, 28 Sep 2015 11:05:38 +0000 (UTC) Received: from [10.36.7.147] (vpn1-7-147.ams2.redhat.com [10.36.7.147]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SB5Y18012934 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 07:05:36 -0400 To: Laurent Vivier , qemu-trivial@nongnu.org References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> <1443284532-8634-10-git-send-email-laurent@vivier.eu> From: Thomas Huth Message-ID: <56091EFE.5070801@redhat.com> Date: Mon, 28 Sep 2015 13:05:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443284532-8634-10-git-send-email-laurent@vivier.eu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 09/10][TRIVIAL] macio-nvram: add to misc category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 11:05:45 -0000 On 26/09/15 18:22, Laurent Vivier wrote: > The macio nvram is a non volatile RAM, so add it > the misc category. > > Signed-off-by: Laurent Vivier > --- > hw/nvram/mac_nvram.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c > index d35f8a3..9f16566 100644 > --- a/hw/nvram/mac_nvram.c > +++ b/hw/nvram/mac_nvram.c > @@ -123,6 +123,7 @@ static void macio_nvram_class_init(ObjectClass *oc, void *data) > dc->reset = macio_nvram_reset; > dc->vmsd = &vmstate_macio_nvram; > dc->props = macio_nvram_properties; > + set_bit(DEVICE_CATEGORY_MISC, dc->categories); > } Reviewed-by: Thomas Huth From MAILER-DAEMON Mon Sep 28 18:14:50 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zggh8-00087Y-Gy for mharc-qemu-block@gnu.org; Mon, 28 Sep 2015 18:14:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgWGo-0006Gt-IZ for qemu-block@nongnu.org; Mon, 28 Sep 2015 07:06:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgWGk-0003V7-IN for qemu-block@nongnu.org; Mon, 28 Sep 2015 07:06:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgWGk-0003V2-DU; Mon, 28 Sep 2015 07:06:54 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id DB014A8A; Mon, 28 Sep 2015 11:06:53 +0000 (UTC) Received: from [10.36.7.147] (vpn1-7-147.ams2.redhat.com [10.36.7.147]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SB6oId013959 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 07:06:51 -0400 To: Laurent Vivier , qemu-trivial@nongnu.org References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> <1443284532-8634-11-git-send-email-laurent@vivier.eu> From: Thomas Huth Message-ID: <56091F4A.9070403@redhat.com> Date: Mon, 28 Sep 2015 13:06:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443284532-8634-11-git-send-email-laurent@vivier.eu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 10/10][TRIVIAL] openpic: add to misc category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 11:06:59 -0000 On 26/09/15 18:22, Laurent Vivier wrote: > openpic is a programmable interrupt controller, so > add it to the misc category. > > Signed-off-by: Laurent Vivier > --- > hw/intc/openpic.c | 1 + > hw/intc/openpic_kvm.c | 1 + > 2 files changed, 2 insertions(+) > > diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c > index 14ab0e3..bfcf155 100644 > --- a/hw/intc/openpic.c > +++ b/hw/intc/openpic.c > @@ -1643,6 +1643,7 @@ static void openpic_class_init(ObjectClass *oc, void *data) > dc->props = openpic_properties; > dc->reset = openpic_reset; > dc->vmsd = &vmstate_openpic; > + set_bit(DEVICE_CATEGORY_MISC, dc->categories); > } > > static const TypeInfo openpic_info = { > diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c > index f7cac58..649f476 100644 > --- a/hw/intc/openpic_kvm.c > +++ b/hw/intc/openpic_kvm.c > @@ -275,6 +275,7 @@ static void kvm_openpic_class_init(ObjectClass *oc, void *data) > dc->realize = kvm_openpic_realize; > dc->props = kvm_openpic_properties; > dc->reset = kvm_openpic_reset; > + set_bit(DEVICE_CATEGORY_MISC, dc->categories); > } Reviewed-by: Thomas Huth From MAILER-DAEMON Tue Sep 29 01:33:50 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgnXy-0006eQ-4F for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 01:33:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgXYv-0007fF-EI for qemu-block@nongnu.org; Mon, 28 Sep 2015 08:29:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgXYs-0008MG-6B for qemu-block@nongnu.org; Mon, 28 Sep 2015 08:29:45 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:64601 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgXYs-0008LJ-0B; Mon, 28 Sep 2015 08:29:42 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AVAgDvMQlW/5tjdVtdGQEBAYMIgT2pDAUBgQ0Bkx4BDYd0AoFDOBQBAQEBAQEBgQqEJQEBBCcTPxALDgoJJQ8BLBsGARKIMgHLIQEBAQEBAQQBAQEBAR2GLIVEgU+DPgeELAEElXCcFIw6HwEBQoIRHIFWPDOJIQEBAQ X-IPAS-Result: A2AVAgDvMQlW/5tjdVtdGQEBAYMIgT2pDAUBgQ0Bkx4BDYd0AoFDOBQBAQEBAQEBgQqEJQEBBCcTPxALDgoJJQ8BLBsGARKIMgHLIQEBAQEBAQQBAQEBAR2GLIVEgU+DPgeELAEElXCcFIw6HwEBQoIRHIFWPDOJIQEBAQ X-IronPort-AV: E=Sophos;i="5.17,602,1437429600"; d="scan'208";a="28088316" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 28 Sep 2015 14:29:39 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZgXYp-00075X-CR; Mon, 28 Sep 2015 14:29:39 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZgXYp-0005CU-67; Mon, 28 Sep 2015 14:29:39 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-9-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-9-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Mon, 28 Sep 2015 14:29:39 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 08/16] block: Manage backing file references in bdrv_set_backing_hd() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 12:29:46 -0000 On Thu 17 Sep 2015 03:48:12 PM CEST, Kevin Wolf wrote: > --- a/block/stream.c > +++ b/block/stream.c > @@ -55,28 +55,7 @@ static int coroutine_fn stream_populate(BlockDriverState *bs, > static void close_unused_images(BlockDriverState *top, BlockDriverState *base, > const char *base_id) > { > - BlockDriverState *intermediate; > - intermediate = top->backing ? top->backing->bs : NULL; > - > - /* Must assign before bdrv_delete() to prevent traversing dangling pointer > - * while we delete backing image instances. > - */ > bdrv_set_backing_hd(top, base); > - > - while (intermediate) { > - BlockDriverState *unused; > - > - /* reached base */ > - if (intermediate == base) { > - break; > - } > - > - unused = intermediate; > - intermediate = intermediate->backing ? intermediate->backing->bs : NULL; > - bdrv_set_backing_hd(unused, NULL); > - bdrv_unref(unused); > - } > - > bdrv_refresh_limits(top, NULL); > } bdrv_refresh_limits(bs, NULL) is already called at the end of bdrv_set_backing_hd(), so there's no need to call it again here. And then close_unused_images() is used only once in this file and it would only contain the bdrv_set_backing_hd() call, so you don't need a separate function anymore. Berto From MAILER-DAEMON Tue Sep 29 01:38:14 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgncE-0007su-Lf for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 01:38:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgXbF-00012u-9A for qemu-block@nongnu.org; Mon, 28 Sep 2015 08:32:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgXb9-0001OI-Mw for qemu-block@nongnu.org; Mon, 28 Sep 2015 08:32:09 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:59585 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgXb9-0001Ni-GN; Mon, 28 Sep 2015 08:32:03 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AVAgDvMQlW/5tjdVtdGQEBAYMIgT2pDAUBgQ0Bkx4BDYd0AoFDOBQBAQEBAQEBgQqEJQEBBDo/EAsOCgklDwEsGwYBEogyAcshAQEBAQEBAQMBAQEBAR2GLIVEhChlB4QsAQSVcJwUF4wjHwEBQoQDPDOHWYFIAQEB X-IPAS-Result: A2AVAgDvMQlW/5tjdVtdGQEBAYMIgT2pDAUBgQ0Bkx4BDYd0AoFDOBQBAQEBAQEBgQqEJQEBBDo/EAsOCgklDwEsGwYBEogyAcshAQEBAQEBAQMBAQEBAR2GLIVEhChlB4QsAQSVcJwUF4wjHwEBQoQDPDOHWYFIAQEB X-IronPort-AV: E=Sophos;i="5.17,602,1437429600"; d="scan'208";a="28089338" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 28 Sep 2015 14:32:01 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZgXb7-00076D-2e; Mon, 28 Sep 2015 14:32:01 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZgXb6-00066J-TO; Mon, 28 Sep 2015 14:32:00 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-11-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-11-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Mon, 28 Sep 2015 14:32:00 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 10/16] block/io: Make bdrv_requests_pending() public X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 12:32:10 -0000 On Thu 17 Sep 2015 03:48:14 PM CEST, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > block/io.c | 2 +- > include/block/block_int.h | 1 + > 2 files changed, 2 insertions(+), 1 deletion(-) Reviewed-by: Alberto Garcia Berto From MAILER-DAEMON Tue Sep 29 02:46:00 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgofo-000189-FS for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 02:46:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgYBq-0002F1-5u for qemu-block@nongnu.org; Mon, 28 Sep 2015 09:09:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgYBm-0000fn-Sj for qemu-block@nongnu.org; Mon, 28 Sep 2015 09:09:58 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:30940 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgYBm-0000fT-La; Mon, 28 Sep 2015 09:09:54 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BhBQBOOwlW/5tjdVtdGQEBAYMIqkkFAYENAZhKglYCgUI8EAEBAQEBAQGBCoQlAQEEJxM/EAsOEyUPASwbBgGIRAHLKQEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsAQSVcKhOOCuEAzyJVAEBAQ X-IPAS-Result: A2BhBQBOOwlW/5tjdVtdGQEBAYMIqkkFAYENAZhKglYCgUI8EAEBAQEBAQGBCoQlAQEEJxM/EAsOEyUPASwbBgGIRAHLKQEBAQEBAQEDAQEBAQEdhiyFRIUNB4QsAQSVcKhOOCuEAzyJVAEBAQ X-IronPort-AV: E=Sophos;i="5.17,602,1437429600"; d="scan'208";a="27903694" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 28 Sep 2015 15:09:51 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZgYBj-0007a1-O4; Mon, 28 Sep 2015 15:09:51 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZgYBj-0004zX-H1; Mon, 28 Sep 2015 15:09:51 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-13-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-13-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Mon, 28 Sep 2015 15:09:51 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 12/16] block: Introduce parents list X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 13:09:59 -0000 On Thu 17 Sep 2015 03:48:16 PM CEST, Kevin Wolf wrote: > @@ -1090,6 +1090,7 @@ static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, > }; > > QLIST_INSERT_HEAD(&parent_bs->children, child, next); > + QLIST_INSERT_HEAD(&child_bs->parents, child, next_parent); > > return child; > } Ok, I'm probably slow today, but what is this used for? :-? And why is it called 'parents'? The list doesn't contain pointers to the parents of child_bs, but to child_bs itself... I would expect a BdrvChild *parent, with parent->bs = parent_bs. Berto From MAILER-DAEMON Tue Sep 29 03:10:50 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgp3q-0000oW-4o for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 03:10:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgYPq-0007MM-BN for qemu-block@nongnu.org; Mon, 28 Sep 2015 09:24:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgYPn-0007CC-7z for qemu-block@nongnu.org; Mon, 28 Sep 2015 09:24:26 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:50387 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgYPn-0007Bk-0r; Mon, 28 Sep 2015 09:24:23 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AVAgDQPglW/5tjdVteGQEBAYMIgT2pDAUBgQ0Bkx4BDYd0AoFCOBQBAQEBAQEBgQqEJQEBBDo/EAsOCgklDwEsGwYBEogyAcssAQEBAQEBBAEBAQEBHYYshUSFDQeELAEElXCcFIw6HwEBQoQDPDOJIQEBAQ X-IPAS-Result: A2AVAgDQPglW/5tjdVteGQEBAYMIgT2pDAUBgQ0Bkx4BDYd0AoFCOBQBAQEBAQEBgQqEJQEBBDo/EAsOCgklDwEsGwYBEogyAcssAQEBAQEBBAEBAQEBHYYshUSFDQeELAEElXCcFIw6HwEBQoQDPDOJIQEBAQ X-IronPort-AV: E=Sophos;i="5.17,602,1437429600"; d="scan'208";a="27907995" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 28 Sep 2015 15:24:20 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1ZgYPk-0007ga-Cv; Mon, 28 Sep 2015 15:24:20 +0200 Received: from berto by mail.igalia.com with local (Exim) id 1ZgYPk-00080c-7G; Mon, 28 Sep 2015 15:24:20 +0200 From: Alberto Garcia To: Kevin Wolf , qemu-block@nongnu.org In-Reply-To: <1442497700-2536-17-git-send-email-kwolf@redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-17-git-send-email-kwolf@redhat.com> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Mon, 28 Sep 2015 15:24:20 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, mreitz@redhat.com Subject: Re: [Qemu-block] [PATCH 16/16] block: Remove bdrv_swap() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 13:24:32 -0000 On Thu 17 Sep 2015 03:48:20 PM CEST, Kevin Wolf wrote: > bdrv_swap() is unused now. Remove it and all functions that have > no other users than bdrv_swap(). In particular, this removes the > .bdrv_rebind callbacks from block drivers. > > Signed-off-by: Kevin Wolf Reviewed-by: Alberto Garcia Berto From MAILER-DAEMON Tue Sep 29 05:00:41 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgqm8-0002PL-Vw for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 05:00:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgZBT-0000a7-SD for qemu-block@nongnu.org; Mon, 28 Sep 2015 10:13:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgZBQ-0003pE-N9 for qemu-block@nongnu.org; Mon, 28 Sep 2015 10:13:39 -0400 Received: from mail-wi0-x22c.google.com ([2a00:1450:400c:c05::22c]:38485) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgZBQ-0003p8-HG; Mon, 28 Sep 2015 10:13:36 -0400 Received: by wiclk2 with SMTP id lk2so103566064wic.1; Mon, 28 Sep 2015 07:13:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=nCZ1zYwOIPNahTZbYGXkmPm0D+TQkn+Gp7uymc70pl4=; b=0iP/4fDPgRX4B49z8/Wxn1ZVTGPd1EKuo2QQo2ZP7BITGSbohmm5HTprMS850Fz3NS UM6TPE2DhOdCwpadTVj5mxVyjaZsoxitm13Yv6QtnuOU1mkJRoVfznsZy4O4IemkNvg2 a7nhJHPX3Krka/BdHVbIsHEsqqR3WsGmEOOoLMfV3/4zseVejscNlJNCLNUmPvbkO+lq Kbei/0/NwTvk2EXIh3zzzLHFIBR/eygNB1Buxidfg80qtDqyGO+H+sr3T7usgkcPMPle eAQW726O/HjpXzr19RBKIJt/G862Mwz4icUp5h2WtruO9mNq3RwJAIuFcJcVaY8jytuq 08PQ== X-Received: by 10.180.106.229 with SMTP id gx5mr20041192wib.24.1443449615782; Mon, 28 Sep 2015 07:13:35 -0700 (PDT) Received: from [192.168.10.165] ([94.39.140.123]) by smtp.googlemail.com with ESMTPSA id t7sm18554126wib.1.2015.09.28.07.13.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Sep 2015 07:13:35 -0700 (PDT) Sender: Paolo Bonzini To: Jeff Cody , qemu-devel@nongnu.org References: From: Paolo Bonzini Message-ID: <56094B0F.7030900@redhat.com> Date: Mon, 28 Sep 2015 16:13:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22c Cc: kwolf@redhat.com, qemu-block@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 3/3] block: mirror - zero unallocated target sectors when zero init not present X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 14:13:40 -0000 On 28/09/2015 05:29, Jeff Cody wrote: > This only occurs under two conditions: > > 1. 'mode' != "existing" > 2. bdrv_has_zero_init(target) == NULL > I'm not sure if mode != "existing" actually matters. I think what actually matters is sync == "full". The reasons are: 1) with sync != "full", unallocated target sectors should remain unallocated on the destination because they are supposed to point to the backing file. 2) even with mode == "existing" you expect the data to be consistent at the end of the mirroring Paolo From MAILER-DAEMON Tue Sep 29 05:12:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgqx8-0005Cn-PU for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 05:12:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgZFh-0001MR-GP for qemu-block@nongnu.org; Mon, 28 Sep 2015 10:18:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgZFc-0005oB-HS for qemu-block@nongnu.org; Mon, 28 Sep 2015 10:18:01 -0400 Received: from mail-wi0-x232.google.com ([2a00:1450:400c:c05::232]:34368) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgZFc-0005nm-8W; Mon, 28 Sep 2015 10:17:56 -0400 Received: by wicfx3 with SMTP id fx3so107030150wic.1; Mon, 28 Sep 2015 07:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=toiBucCHwyyrI1XABKOwp2jVzH0nzu8GsMMQszCTNhY=; b=DtmCmoMKGFD4dCGkRlMzvzSakI2nZInSc9SF1FnnPdg2CYFnEg8F7se7NGRU5Xyrau Ng/clfhoilFUGW/9j6xHJJjxzXJ65PFlJQIqZiOlID4rQ1PGslKidV+WTKFmBtwhokht aYU0eGguIwup53x7PlcoQ2H50sElZNHQtcC+wYnF72fOlMu9SPlIVXBvHx1eg57cMHG/ CXd7vr/AvPPskI41VIJoGszZZWQJ6MyH1WJPod6DejicrniqGDzpTu8rABqWdZLBXYET PDXKirKvk6n7qFGRv78wc0vSpsxlOeKvtfjnwcWYj1DzYymQyhOFKrURgDOKx1Zfr6DV 94Cg== X-Received: by 10.180.76.170 with SMTP id l10mr20732812wiw.68.1443449875542; Mon, 28 Sep 2015 07:17:55 -0700 (PDT) Received: from [192.168.10.165] ([94.39.140.123]) by smtp.googlemail.com with ESMTPSA id fs2sm18588956wib.12.2015.09.28.07.17.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Sep 2015 07:17:54 -0700 (PDT) Sender: Paolo Bonzini To: Jeff Cody , qemu-devel@nongnu.org References: <0de92b950741a15b9ff085f7b102ef99ef26101c.1443410673.git.jcody@redhat.com> From: Paolo Bonzini Message-ID: <56094C12.1060506@redhat.com> Date: Mon, 28 Sep 2015 16:17:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <0de92b950741a15b9ff085f7b102ef99ef26101c.1443410673.git.jcody@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::232 Cc: kwolf@redhat.com, qemu-block@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 2/3] block: mirror - split out part of mirror_run() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 14:18:03 -0000 On 28/09/2015 05:29, Jeff Cody wrote: > This is code relocation, to pull the part of mirror_run() that > calls mirror_iteration out into a separate function. > > Signed-off-by: Jeff Cody > --- > block/mirror.c | 206 ++++++++++++++++++++++++++++++--------------------------- > 1 file changed, 110 insertions(+), 96 deletions(-) > > diff --git a/block/mirror.c b/block/mirror.c > index 8b3e89b..405e5c4 100644 > --- a/block/mirror.c > +++ b/block/mirror.c > @@ -318,6 +318,115 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) > return delay_ns; > } > > +static int mirror_do_iteration(MirrorBlockJob *s, uint64_t last_pause_ns) > +{ > + int ret; > + > + BlockDriverState *bs = s->common.bs; > + > + for (;;) { > + uint64_t delay_ns = 0; > + int64_t cnt; > + bool should_complete; > + > + if (s->ret < 0) { > + ret = s->ret; > + goto immediate_exit; > + } You might as well replace the gotos with returns (either "return ret;" or "return s->ret;") and the breaks with "return 0;"). > + > + cnt = bdrv_get_dirty_count(s->dirty_bitmap); > + /* s->common.offset contains the number of bytes already processed so > + * far, cnt is the number of dirty sectors remaining and > + * s->sectors_in_flight is the number of sectors currently being > + * processed; together those are the current total operation length */ > + s->common.len = s->common.offset + > + (cnt + s->sectors_in_flight) * BDRV_SECTOR_SIZE; > + > + /* Note that even when no rate limit is applied we need to yield > + * periodically with no pending I/O so that bdrv_drain_all() returns. > + * We do so every SLICE_TIME nanoseconds, or when there is an error, > + * or when the source is clean, whichever comes first. > + */ > + if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - last_pause_ns < SLICE_TIME > + && s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) { > + if (s->in_flight == MAX_IN_FLIGHT || s->buf_free_count == 0 || > + (cnt == 0 && s->in_flight > 0)) { > + trace_mirror_yield(s, s->in_flight, s->buf_free_count, cnt); > + s->waiting_for_io = true; > + qemu_coroutine_yield(); > + s->waiting_for_io = false; > + continue; > + } else if (cnt != 0) { > + delay_ns = mirror_iteration(s); > + } > + } > + > + should_complete = false; > + if (s->in_flight == 0 && cnt == 0) { > + trace_mirror_before_flush(s); > + ret = bdrv_flush(s->target); > + if (ret < 0) { > + if (mirror_error_action(s, false, -ret) == > + BLOCK_ERROR_ACTION_REPORT) { > + goto immediate_exit; > + } > + } else { > + /* We're out of the streaming phase. From now on, if the job > + * is cancelled we will actually complete all pending I/O and > + * report completion. This way, block-job-cancel will leave > + * the target in a consistent state. > + */ > + if (!s->synced) { > + block_job_event_ready(&s->common); > + s->synced = true; > + } > + > + should_complete = s->should_complete || > + block_job_is_cancelled(&s->common); > + cnt = bdrv_get_dirty_count(s->dirty_bitmap); > + } > + } > + > + if (cnt == 0 && should_complete) { > + /* The dirty bitmap is not updated while operations are pending. > + * If we're about to exit, wait for pending operations before > + * calling bdrv_get_dirty_count(bs), or we may exit while the > + * source has dirty data to copy! > + * > + * Note that I/O can be submitted by the guest while > + * mirror_populate runs. > + */ > + trace_mirror_before_drain(s, cnt); > + bdrv_drain(bs); > + cnt = bdrv_get_dirty_count(s->dirty_bitmap); > + } > + > + ret = 0; > + trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); > + if (!s->synced) { > + block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); > + if (block_job_is_cancelled(&s->common)) { > + break; > + } > + } else if (!should_complete) { > + delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); > + block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); > + } else if (cnt == 0) { > + /* The two disks are in sync. Exit and report successful > + * completion. > + */ > + assert(QLIST_EMPTY(&bs->tracked_requests)); > + s->common.cancelled = false; > + break; > + } > + last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); > + } > + > +immediate_exit: > + return ret; > + > +} > + > static void mirror_free_init(MirrorBlockJob *s) > { > int granularity = s->granularity; > @@ -485,103 +594,8 @@ static void coroutine_fn mirror_run(void *opaque) > } > > bdrv_dirty_iter_init(s->dirty_bitmap, &s->hbi); > - for (;;) { > - uint64_t delay_ns = 0; > - int64_t cnt; > - bool should_complete; > > - if (s->ret < 0) { > - ret = s->ret; > - goto immediate_exit; > - } > - > - cnt = bdrv_get_dirty_count(s->dirty_bitmap); > - /* s->common.offset contains the number of bytes already processed so > - * far, cnt is the number of dirty sectors remaining and > - * s->sectors_in_flight is the number of sectors currently being > - * processed; together those are the current total operation length */ > - s->common.len = s->common.offset + > - (cnt + s->sectors_in_flight) * BDRV_SECTOR_SIZE; > - > - /* Note that even when no rate limit is applied we need to yield > - * periodically with no pending I/O so that bdrv_drain_all() returns. > - * We do so every SLICE_TIME nanoseconds, or when there is an error, > - * or when the source is clean, whichever comes first. > - */ > - if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - last_pause_ns < SLICE_TIME && > - s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) { > - if (s->in_flight == MAX_IN_FLIGHT || s->buf_free_count == 0 || > - (cnt == 0 && s->in_flight > 0)) { > - trace_mirror_yield(s, s->in_flight, s->buf_free_count, cnt); > - s->waiting_for_io = true; > - qemu_coroutine_yield(); > - s->waiting_for_io = false; > - continue; > - } else if (cnt != 0) { > - delay_ns = mirror_iteration(s); > - } > - } > - > - should_complete = false; > - if (s->in_flight == 0 && cnt == 0) { > - trace_mirror_before_flush(s); > - ret = bdrv_flush(s->target); > - if (ret < 0) { > - if (mirror_error_action(s, false, -ret) == > - BLOCK_ERROR_ACTION_REPORT) { > - goto immediate_exit; > - } > - } else { > - /* We're out of the streaming phase. From now on, if the job > - * is cancelled we will actually complete all pending I/O and > - * report completion. This way, block-job-cancel will leave > - * the target in a consistent state. > - */ > - if (!s->synced) { > - block_job_event_ready(&s->common); > - s->synced = true; > - } > - > - should_complete = s->should_complete || > - block_job_is_cancelled(&s->common); > - cnt = bdrv_get_dirty_count(s->dirty_bitmap); > - } > - } > - > - if (cnt == 0 && should_complete) { > - /* The dirty bitmap is not updated while operations are pending. > - * If we're about to exit, wait for pending operations before > - * calling bdrv_get_dirty_count(bs), or we may exit while the > - * source has dirty data to copy! > - * > - * Note that I/O can be submitted by the guest while > - * mirror_populate runs. > - */ > - trace_mirror_before_drain(s, cnt); > - bdrv_drain(bs); > - cnt = bdrv_get_dirty_count(s->dirty_bitmap); > - } > - > - ret = 0; > - trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); > - if (!s->synced) { > - block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); > - if (block_job_is_cancelled(&s->common)) { > - break; > - } > - } else if (!should_complete) { > - delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); > - block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); > - } else if (cnt == 0) { > - /* The two disks are in sync. Exit and report successful > - * completion. > - */ > - assert(QLIST_EMPTY(&bs->tracked_requests)); > - s->common.cancelled = false; > - break; > - } > - last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); > - } > + ret = mirror_do_iteration(s, last_pause_ns); > > immediate_exit: > if (s->in_flight > 0) { > From MAILER-DAEMON Tue Sep 29 05:27:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgrC3-0000pd-AZ for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 05:27:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgZLg-00026q-2o for qemu-block@nongnu.org; Mon, 28 Sep 2015 10:24:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgZLb-000112-4n for qemu-block@nongnu.org; Mon, 28 Sep 2015 10:24:12 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:59026 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgZLO-0000w5-U2; Mon, 28 Sep 2015 10:23:55 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2D3AgDXTAlW/5tjdVtdGQEBAYMIVGmpAQsFAYENAYMOkBABDYFsB4YBgUQ4FAEBAQEBAQFoIoUkT040iDIBy1iGLIpRHoQVBYcphkc/h0GFFYd6gU9GkGiIQh8BAUKBSgEBCDofgVduiSEBAQE X-IPAS-Result: A2D3AgDXTAlW/5tjdVtdGQEBAYMIVGmpAQsFAYENAYMOkBABDYFsB4YBgUQ4FAEBAQEBAQFoIoUkT040iDIBy1iGLIpRHoQVBYcphkc/h0GFFYd6gU9GkGiIQh8BAUKBSgEBCDofgVduiSEBAQE X-IronPort-AV: E=Sophos;i="5.17,602,1437429600"; d="scan'208";a="27929088" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 28 Sep 2015 16:23:50 +0200 Received: from dsl-hkibrasgw4-50df50-201.dhcp.inet.fi ([80.223.80.201] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZgZLJ-0008IY-OI; Mon, 28 Sep 2015 16:23:50 +0200 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZgZL6-0000Rb-AV; Mon, 28 Sep 2015 17:23:36 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Mon, 28 Sep 2015 17:23:00 +0300 Message-Id: <1443450180-1671-1-git-send-email-berto@igalia.com> X-Mailer: git-send-email 2.5.3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , Markus Armbruster , qemu-block@nongnu.org, Max Reitz Subject: [Qemu-block] [PATCH v2] iotests: disable core dumps in test 061 X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 14:24:13 -0000 Commit 934659c460 disabled the supression of segmentation faults in bash tests. The new output of test 061, however, assumes that a core dump will be produced if a program aborts. This is not necessarily the case because core dumps can be disabled using ulimit. Since we cannot guarantee that abort() will produce a core dump, we should use SIGKILL instead (that does not produce any) and update the test output accordingly. Signed-off-by: Alberto Garcia --- tests/qemu-iotests/061 | 8 ++++---- tests/qemu-iotests/061.out | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 index 1df887a..e191e65 100755 --- a/tests/qemu-iotests/061 +++ b/tests/qemu-iotests/061 @@ -58,8 +58,8 @@ echo echo "=== Testing dirty version downgrade ===" echo IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M -$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" 2>&1 \ - | _filter_qemu_io +$QEMU_IO -c "write -P 0x2a 0 128k" -c flush \ + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io $PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" $PYTHON qcow2.py "$TEST_IMG" dump-header @@ -92,8 +92,8 @@ echo echo "=== Testing dirty lazy_refcounts=off ===" echo IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M -$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" 2>&1 \ - | _filter_qemu_io +$QEMU_IO -c "write -P 0x2a 0 128k" -c flush \ + -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io $PYTHON qcow2.py "$TEST_IMG" dump-header $QEMU_IMG amend -o "lazy_refcounts=off" "$TEST_IMG" $PYTHON qcow2.py "$TEST_IMG" dump-header diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out index a683f46..b16bea9 100644 --- a/tests/qemu-iotests/061.out +++ b/tests/qemu-iotests/061.out @@ -57,7 +57,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 wrote 131072/131072 bytes at offset 0 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./common.config: Aborted (core dumped) ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) magic 0x514649fb version 3 backing_file_offset 0x0 @@ -215,7 +215,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 wrote 131072/131072 bytes at offset 0 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./common.config: Aborted (core dumped) ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) +./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" ) magic 0x514649fb version 3 backing_file_offset 0x0 -- 2.5.3 From MAILER-DAEMON Tue Sep 29 05:48:53 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgrWn-0008Tt-Qk for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 05:48:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgZRD-0002gQ-Cb for qemu-block@nongnu.org; Mon, 28 Sep 2015 10:29:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgZR7-0003SD-H7 for qemu-block@nongnu.org; Mon, 28 Sep 2015 10:29:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgZR7-0003S6-By; Mon, 28 Sep 2015 10:29:49 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id E066BA0B49; Mon, 28 Sep 2015 14:29:47 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SETkl9015966; Mon, 28 Sep 2015 10:29:46 -0400 To: Laurent Vivier , qemu-trivial@nongnu.org References: <1443284532-8634-1-git-send-email-laurent@vivier.eu> <1443284532-8634-7-git-send-email-laurent@vivier.eu> From: John Snow Message-ID: <56094EDA.6080505@redhat.com> Date: Mon, 28 Sep 2015 10:29:46 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443284532-8634-7-git-send-email-laurent@vivier.eu> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, qemu-block@nongnu.org, Alexander Graf Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 06/10][TRIVIAL] macio-ide: add to storage category X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 14:29:56 -0000 On 09/26/2015 12:22 PM, Laurent Vivier wrote: > macio-ide is an IDE controller, so add it > to the storage category. > > Signed-off-by: Laurent Vivier > --- > hw/ide/macio.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/hw/ide/macio.c b/hw/ide/macio.c > index 66ac2ba..893c9b9 100644 > --- a/hw/ide/macio.c > +++ b/hw/ide/macio.c > @@ -590,6 +590,7 @@ static void macio_ide_class_init(ObjectClass *oc, void *data) > dc->realize = macio_ide_realizefn; > dc->reset = macio_ide_reset; > dc->vmsd = &vmstate_pmac; > + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); > } > > static const TypeInfo macio_ide_type_info = { > Thanks, Reviewed-by: John Snow I'll leave this to be staged by whomever stages the entire series. --js From MAILER-DAEMON Tue Sep 29 05:58:27 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgrg3-0003JE-Dr for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 05:58:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgZcG-0003ta-2M for qemu-block@nongnu.org; Mon, 28 Sep 2015 10:41:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgZcC-00007c-0x for qemu-block@nongnu.org; Mon, 28 Sep 2015 10:41:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37292) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgZcB-00007B-RO; Mon, 28 Sep 2015 10:41:15 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 59A0191EA2; Mon, 28 Sep 2015 14:41:14 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8SEfCwt027572; Mon, 28 Sep 2015 10:41:12 -0400 Date: Mon, 28 Sep 2015 16:41:12 +0200 From: Kevin Wolf To: Jeff Cody Message-ID: <20150928144112.GA18068@noname.str.redhat.com> References: <9ae0ce111c95c6f76e872b12b2a6af895f5cfab6.1443410673.git.jcody@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9ae0ce111c95c6f76e872b12b2a6af895f5cfab6.1443410673.git.jcody@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 1/3] block: allow creation of detached dirty bitmaps X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 14:41:20 -0000 Am 28.09.2015 um 05:29 hat Jeff Cody geschrieben: > This allows the creation of detached dirty bitmaps, so that the > block driver dirty bitmaps can be used without inserting the > bitmap into the dirty bitmap list for a BDS. > > To free a bitmap that was created "detached = true", call > bdrv_release_dirty_bitmap() with the BlockDriverState argument > as NULL. > > Signed-off-by: Jeff Cody It this really still a proper dirty bitmap? After all, bdrv_set_dirty() doesn't affect the bitmap any more, query-block doesn't mention them etc. What is the advantage of using the dirty bitmap infrastructure instead of just using a plain bitmap without the "dirty" part? Also, the bitmap is still made for a specific BDS, especially with regards to its size. For dirty bitmaps, bdrv_truncate() calls bdrv_dirty_bitmap_truncate() in order to resize the bitmaps as well. This mechanism doesn't work any more if the bitmap isn't in the dirty bitmaps list. Do we need something like an op blocker? Though I'm not sure if an operation as basic as bdrv_truncate() can be reasonably blocked at all. Maybe we can only block the QMP resize command. Kevin From MAILER-DAEMON Tue Sep 29 06:25:06 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgs5q-000304-JH for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 06:25:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgZiR-0005Xu-G9 for qemu-block@nongnu.org; Mon, 28 Sep 2015 10:47:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgZiO-000329-7e for qemu-block@nongnu.org; Mon, 28 Sep 2015 10:47:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50633) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgZiN-00031z-Vm; Mon, 28 Sep 2015 10:47:40 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 3DE6991C15; Mon, 28 Sep 2015 14:47:39 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8SElb2t027156; Mon, 28 Sep 2015 10:47:37 -0400 Date: Mon, 28 Sep 2015 16:47:36 +0200 From: Kevin Wolf To: Jeff Cody Message-ID: <20150928144736.GB18068@noname.str.redhat.com> References: <0de92b950741a15b9ff085f7b102ef99ef26101c.1443410673.git.jcody@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0de92b950741a15b9ff085f7b102ef99ef26101c.1443410673.git.jcody@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 2/3] block: mirror - split out part of mirror_run() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 14:47:44 -0000 Am 28.09.2015 um 05:29 hat Jeff Cody geschrieben: > This is code relocation, to pull the part of mirror_run() that > calls mirror_iteration out into a separate function. > > Signed-off-by: Jeff Cody > --- > block/mirror.c | 206 ++++++++++++++++++++++++++++++--------------------------- > 1 file changed, 110 insertions(+), 96 deletions(-) > > diff --git a/block/mirror.c b/block/mirror.c > index 8b3e89b..405e5c4 100644 > --- a/block/mirror.c > +++ b/block/mirror.c > @@ -318,6 +318,115 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) > return delay_ns; > } > > +static int mirror_do_iteration(MirrorBlockJob *s, uint64_t last_pause_ns) > +{ > + int ret; > + > + BlockDriverState *bs = s->common.bs; > + > + for (;;) { > + uint64_t delay_ns = 0; > + int64_t cnt; > + bool should_complete; > + > + if (s->ret < 0) { > + ret = s->ret; > + goto immediate_exit; > + } > + > + cnt = bdrv_get_dirty_count(s->dirty_bitmap); > + /* s->common.offset contains the number of bytes already processed so > + * far, cnt is the number of dirty sectors remaining and > + * s->sectors_in_flight is the number of sectors currently being > + * processed; together those are the current total operation length */ > + s->common.len = s->common.offset + > + (cnt + s->sectors_in_flight) * BDRV_SECTOR_SIZE; > + > + /* Note that even when no rate limit is applied we need to yield > + * periodically with no pending I/O so that bdrv_drain_all() returns. > + * We do so every SLICE_TIME nanoseconds, or when there is an error, > + * or when the source is clean, whichever comes first. > + */ > + if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - last_pause_ns < SLICE_TIME > + && s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) { > + if (s->in_flight == MAX_IN_FLIGHT || s->buf_free_count == 0 || > + (cnt == 0 && s->in_flight > 0)) { > + trace_mirror_yield(s, s->in_flight, s->buf_free_count, cnt); > + s->waiting_for_io = true; > + qemu_coroutine_yield(); > + s->waiting_for_io = false; > + continue; > + } else if (cnt != 0) { > + delay_ns = mirror_iteration(s); > + } > + } > + > + should_complete = false; > + if (s->in_flight == 0 && cnt == 0) { > + trace_mirror_before_flush(s); > + ret = bdrv_flush(s->target); > + if (ret < 0) { > + if (mirror_error_action(s, false, -ret) == > + BLOCK_ERROR_ACTION_REPORT) { > + goto immediate_exit; > + } > + } else { > + /* We're out of the streaming phase. From now on, if the job > + * is cancelled we will actually complete all pending I/O and > + * report completion. This way, block-job-cancel will leave > + * the target in a consistent state. > + */ > + if (!s->synced) { > + block_job_event_ready(&s->common); > + s->synced = true; > + } > + > + should_complete = s->should_complete || > + block_job_is_cancelled(&s->common); > + cnt = bdrv_get_dirty_count(s->dirty_bitmap); > + } > + } > + > + if (cnt == 0 && should_complete) { > + /* The dirty bitmap is not updated while operations are pending. > + * If we're about to exit, wait for pending operations before > + * calling bdrv_get_dirty_count(bs), or we may exit while the > + * source has dirty data to copy! > + * > + * Note that I/O can be submitted by the guest while > + * mirror_populate runs. > + */ > + trace_mirror_before_drain(s, cnt); > + bdrv_drain(bs); > + cnt = bdrv_get_dirty_count(s->dirty_bitmap); > + } > + > + ret = 0; > + trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); > + if (!s->synced) { > + block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); > + if (block_job_is_cancelled(&s->common)) { > + break; > + } > + } else if (!should_complete) { > + delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); > + block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); > + } else if (cnt == 0) { > + /* The two disks are in sync. Exit and report successful > + * completion. > + */ > + assert(QLIST_EMPTY(&bs->tracked_requests)); > + s->common.cancelled = false; > + break; > + } > + last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); > + } > + > +immediate_exit: > + return ret; > + > +} Did you leave this additional empty line there intentionally? With or without it removed, and also with or without Paolo's suggestion regarding goto vs. return applied: Reviewed-by: Kevin Wolf From MAILER-DAEMON Tue Sep 29 08:00:16 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgtZw-0000Hd-Am for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 08:00:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zga25-0004n8-RP for qemu-block@nongnu.org; Mon, 28 Sep 2015 11:08:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zga1z-00034p-NI for qemu-block@nongnu.org; Mon, 28 Sep 2015 11:08:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zga1z-00034e-Fj; Mon, 28 Sep 2015 11:07:55 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id E6A0491E96; Mon, 28 Sep 2015 15:07:54 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8SF7r27003634; Mon, 28 Sep 2015 11:07:53 -0400 Date: Mon, 28 Sep 2015 17:07:52 +0200 From: Kevin Wolf To: Jeff Cody Message-ID: <20150928150752.GC18068@noname.str.redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 3/3] block: mirror - zero unallocated target sectors when zero init not present X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 15:08:03 -0000 Am 28.09.2015 um 05:29 hat Jeff Cody geschrieben: > During mirror, if the target device does not have support zero > initialization, a mirror may result in a corrupt image. I think you want to check this sentence. ("During mirror [...], a mirror may result [...]") > For instance, on mirror to a host device with format = raw, whatever > random data is on the target device will still be there for unallocated > sectors. > > This is because during the mirror, we set the dirty bitmap to copy only > sectors allocated above 'base'. In the case of target devices where we > cannot assume unallocated sectors will be read as zeroes, we need to > explicitely zero out this data. > > In order to avoid zeroing out all sectors of the target device prior to > mirroring, we do zeroing as part of the block job. A second dirty > bitmap cache is created, to track sectors that are unallocated above > 'base'. These sectors are then checked for status of BDRV_BLOCK_ZERO > on the target - if they are not, then zeroes are explicitly written. Why do you need a bitmap? You never change the bitmap after initialising it, so couldn't you instead just check the allocation status when you need it? In fact, why do we need two passes? I would have expected that commit dcfb3beb already does the trick, with checking allocation status and writing zeroes during the normal single pass. If that commit fails to solve the problem, I guess I first need to understand why before I can continue reviewing this one... > This only occurs under two conditions: > > 1. 'mode' != "existing" > 2. bdrv_has_zero_init(target) == NULL > > We perform the mirroring through mirror_iteration() as before, except > in two passes. If the above two conditions are met, the first pass > is using the bitmap tracking unallocated sectors, to write the needed > zeroes. Then, the second pass is performed, to mirror the actual data > as before. > > If the above two conditions are not met, then the first pass is skipped, > and only the second pass (the one with the actual data) is performed. > > Signed-off-by: Jeff Cody > --- > block/mirror.c | 109 ++++++++++++++++++++++++++++++++++------------ > blockdev.c | 2 +- > include/block/block_int.h | 3 +- > qapi/block-core.json | 6 ++- > 4 files changed, 87 insertions(+), 33 deletions(-) > > diff --git a/block/mirror.c b/block/mirror.c > index 405e5c4..b599176 100644 > --- a/block/mirror.c > +++ b/block/mirror.c > @@ -50,7 +50,9 @@ typedef struct MirrorBlockJob { > int64_t bdev_length; > unsigned long *cow_bitmap; > BdrvDirtyBitmap *dirty_bitmap; > - HBitmapIter hbi; > + HBitmapIter zero_hbi; > + HBitmapIter allocated_hbi; > + HBitmapIter *hbi; > uint8_t *buf; > QSIMPLEQ_HEAD(, MirrorBuffer) buf_free; > int buf_free_count; > @@ -60,6 +62,8 @@ typedef struct MirrorBlockJob { > int sectors_in_flight; > int ret; > bool unmap; > + bool zero_unallocated; > + bool zero_cycle; > bool waiting_for_io; > } MirrorBlockJob; > > @@ -166,10 +170,10 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) > int pnum; > int64_t ret; > > - s->sector_num = hbitmap_iter_next(&s->hbi); > + s->sector_num = hbitmap_iter_next(s->hbi); > if (s->sector_num < 0) { > - bdrv_dirty_iter_init(s->dirty_bitmap, &s->hbi); > - s->sector_num = hbitmap_iter_next(&s->hbi); > + bdrv_dirty_iter_init(s->dirty_bitmap, s->hbi); > + s->sector_num = hbitmap_iter_next(s->hbi); > trace_mirror_restart_iter(s, bdrv_get_dirty_count(s->dirty_bitmap)); > assert(s->sector_num >= 0); > } > @@ -287,7 +291,7 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) > */ > if (next_sector > hbitmap_next_sector > && bdrv_get_dirty(source, s->dirty_bitmap, next_sector)) { > - hbitmap_next_sector = hbitmap_iter_next(&s->hbi); > + hbitmap_next_sector = hbitmap_iter_next(s->hbi); > } > > next_sector += sectors_per_chunk; > @@ -300,25 +304,34 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) > s->sectors_in_flight += nb_sectors; > trace_mirror_one_iteration(s, sector_num, nb_sectors); > > - ret = bdrv_get_block_status_above(source, NULL, sector_num, > - nb_sectors, &pnum); > - if (ret < 0 || pnum < nb_sectors || > - (ret & BDRV_BLOCK_DATA && !(ret & BDRV_BLOCK_ZERO))) { > - bdrv_aio_readv(source, sector_num, &op->qiov, nb_sectors, > - mirror_read_complete, op); > - } else if (ret & BDRV_BLOCK_ZERO) { > - bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sectors, > - s->unmap ? BDRV_REQ_MAY_UNMAP : 0, > - mirror_write_complete, op); > + if (s->zero_cycle) { > + ret = bdrv_get_block_status(s->target, sector_num, nb_sectors, &pnum); > + if (!(ret & BDRV_BLOCK_ZERO)) { > + bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sectors, > + s->unmap ? BDRV_REQ_MAY_UNMAP : 0, > + mirror_write_complete, op); > + } It seems to be expected that this function always involves an AIO request and the completion event is what helps making progress. For the BDRV_BLOCK_ZERO case, we don't do that however. I'm not sure what exactly this means, but at least I think we are applying block job throttling to doing nothing with some areas of the image. > } else { > - assert(!(ret & BDRV_BLOCK_DATA)); > - bdrv_aio_discard(s->target, sector_num, op->nb_sectors, > - mirror_write_complete, op); > + ret = bdrv_get_block_status_above(source, NULL, sector_num, > + nb_sectors, &pnum); > + if (ret < 0 || pnum < nb_sectors || > + (ret & BDRV_BLOCK_DATA && !(ret & BDRV_BLOCK_ZERO))) { > + bdrv_aio_readv(source, sector_num, &op->qiov, nb_sectors, > + mirror_read_complete, op); > + } else if (ret & BDRV_BLOCK_ZERO) { > + bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sectors, > + s->unmap ? BDRV_REQ_MAY_UNMAP : 0, > + mirror_write_complete, op); > + } else { > + assert(!(ret & BDRV_BLOCK_DATA)); > + bdrv_aio_discard(s->target, sector_num, op->nb_sectors, > + mirror_write_complete, op); > + } > } > return delay_ns; > } Kevin From MAILER-DAEMON Tue Sep 29 08:10:55 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgtkF-0003cw-LD for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 08:10:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zga54-0006HR-3y for qemu-block@nongnu.org; Mon, 28 Sep 2015 11:11:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zga4y-0004VN-Vt for qemu-block@nongnu.org; Mon, 28 Sep 2015 11:11:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53001) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zga4y-0004VI-R7; Mon, 28 Sep 2015 11:11:00 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 617C4C0A1471; Mon, 28 Sep 2015 15:11:00 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t8SFAwRm007736; Mon, 28 Sep 2015 11:10:59 -0400 Date: Mon, 28 Sep 2015 17:10:58 +0200 From: Kevin Wolf To: Jeff Cody Message-ID: <20150928151058.GD18068@noname.str.redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH 3/3] block: mirror - zero unallocated target sectors when zero init not present X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 15:11:07 -0000 Am 28.09.2015 um 05:29 hat Jeff Cody geschrieben: > During mirror, if the target device does not have support zero > initialization, a mirror may result in a corrupt image. > > For instance, on mirror to a host device with format = raw, whatever > random data is on the target device will still be there for unallocated > sectors. > > This is because during the mirror, we set the dirty bitmap to copy only > sectors allocated above 'base'. In the case of target devices where we > cannot assume unallocated sectors will be read as zeroes, we need to > explicitely zero out this data. > > In order to avoid zeroing out all sectors of the target device prior to > mirroring, we do zeroing as part of the block job. A second dirty > bitmap cache is created, to track sectors that are unallocated above > 'base'. These sectors are then checked for status of BDRV_BLOCK_ZERO > on the target - if they are not, then zeroes are explicitly written. > > This only occurs under two conditions: > > 1. 'mode' != "existing" > 2. bdrv_has_zero_init(target) == NULL > > We perform the mirroring through mirror_iteration() as before, except > in two passes. If the above two conditions are met, the first pass > is using the bitmap tracking unallocated sectors, to write the needed > zeroes. Then, the second pass is performed, to mirror the actual data > as before. > > If the above two conditions are not met, then the first pass is skipped, > and only the second pass (the one with the actual data) is performed. > > Signed-off-by: Jeff Cody Also, this makes qemu-iotests 097 fail for me. Kevin From MAILER-DAEMON Tue Sep 29 08:30:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgu3P-0008V2-Dz for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 08:30:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zga7V-0001yO-Pw for qemu-block@nongnu.org; Mon, 28 Sep 2015 11:13:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zga7R-0005H4-2e for qemu-block@nongnu.org; Mon, 28 Sep 2015 11:13:37 -0400 Received: from mail-wi0-x22e.google.com ([2a00:1450:400c:c05::22e]:32769) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zga7L-0005DJ-3G; Mon, 28 Sep 2015 11:13:27 -0400 Received: by wiclk2 with SMTP id lk2so110146045wic.0; Mon, 28 Sep 2015 08:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=y/dcfNKuNu0ix0KSxnND65JkTzN4U64TDE99pYTrZus=; b=fkCwRJgQq/2ALebxKRBRI+hLSZhRwZYjmzATSvUTi08QF14UcrOcT5AVJHWVDRY+xO NxIJ6lDMuuNBQrWLnhbnGAys9HzVNYtmgLFSu8NPrWA364fIBxPpoVXRUMTmyjjnvMVp bJmBlf2A4ZaSoJQuRjFh0GcbufVH49TOm6B4x76JtugTyCC1qcj79FU7TfrM5OV5VxYD 6ovV+U+W+08ik4PBWQiz0QzlKSRoTHxYsm4ZjSBacvf2xkJgLaS0Gx+6a9p3mxglyLT6 QpHORIgGVSjb07XE+owrgFc7a+3v+8R/AkAWnkSlXlORSy5iyeCCGuUFUegDBfe7ITZZ gL6g== X-Received: by 10.180.88.164 with SMTP id bh4mr18573689wib.18.1443453206244; Mon, 28 Sep 2015 08:13:26 -0700 (PDT) Received: from localhost (host86-182-204-196.range86-182.btcentralplus.com. [86.182.204.196]) by smtp.gmail.com with ESMTPSA id nf15sm18778266wic.22.2015.09.28.08.13.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Sep 2015 08:13:25 -0700 (PDT) Date: Mon, 28 Sep 2015 16:13:23 +0100 From: Stefan Hajnoczi To: Jeff Cody Message-ID: <20150928151323.GA19184@stefanha-thinkpad.redhat.com> References: <9ae0ce111c95c6f76e872b12b2a6af895f5cfab6.1443410673.git.jcody@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9ae0ce111c95c6f76e872b12b2a6af895f5cfab6.1443410673.git.jcody@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22e Cc: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 1/3] block: allow creation of detached dirty bitmaps X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 15:13:38 -0000 On Sun, Sep 27, 2015 at 11:29:16PM -0400, Jeff Cody wrote: > This allows the creation of detached dirty bitmaps, so that the > block driver dirty bitmaps can be used without inserting the > bitmap into the dirty bitmap list for a BDS. > > To free a bitmap that was created "detached = true", call > bdrv_release_dirty_bitmap() with the BlockDriverState argument > as NULL. I wonder if just disabling the bitmap with bdrv_disable_dirty_bitmap() is enough? From MAILER-DAEMON Tue Sep 29 08:30:43 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgu3P-0008VO-JG for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 08:30:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zga7Z-00026K-Rt for qemu-block@nongnu.org; Mon, 28 Sep 2015 11:13:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zga7Z-0005KZ-2g for qemu-block@nongnu.org; Mon, 28 Sep 2015 11:13:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54865) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zga7Y-0005K7-Ub; Mon, 28 Sep 2015 11:13:41 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 0CF84915A0; Mon, 28 Sep 2015 15:13:40 +0000 (UTC) Received: from [10.36.116.59] (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SFDbBC026318 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 11:13:38 -0400 To: Alberto Garcia , qemu-devel@nongnu.org References: <1443450180-1671-1-git-send-email-berto@igalia.com> From: Max Reitz Message-ID: <56095920.30305@redhat.com> Date: Mon, 28 Sep 2015 17:13:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <1443450180-1671-1-git-send-email-berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TEW1p8E5T0ekGh0SWDOgICuPGwLiADxJR" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Markus Armbruster , qemu-block@nongnu.org Subject: Re: [Qemu-block] [PATCH v2] iotests: disable core dumps in test 061 X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 15:13:46 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --TEW1p8E5T0ekGh0SWDOgICuPGwLiADxJR Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 28.09.2015 16:23, Alberto Garcia wrote: > Commit 934659c460 disabled the supression of segmentation faults in > bash tests. The new output of test 061, however, assumes that a core > dump will be produced if a program aborts. This is not necessarily the > case because core dumps can be disabled using ulimit. >=20 > Since we cannot guarantee that abort() will produce a core dump, we > should use SIGKILL instead (that does not produce any) and update the > test output accordingly. >=20 > Signed-off-by: Alberto Garcia > --- > tests/qemu-iotests/061 | 8 ++++---- > tests/qemu-iotests/061.out | 4 ++-- > 2 files changed, 6 insertions(+), 6 deletions(-) Reviewed-by: Max Reitz --TEW1p8E5T0ekGh0SWDOgICuPGwLiADxJR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWCVkgAAoJEDuxQgLoOKytNa0H/RBmWeaGIi8L6WjQ/0+zWbW2 NY2rgpQJ7ptaxNzH0kWrzl3tctxYpY5mscNcvS7ULWxPPjTFZKO4zORbtYamlCNp OnRi0fHAvXXVL/MlIlhwdtNRr4oqCVGuO9IOPbEiKce6UsqSn5/hol+fqaF1rChg Dl3oU8n4lWM7hyV9wVR2hi0mnZA2aOzspauJZOTrdBhHau39yGKpFfeLvVrgoKJQ KncwIM/qf7pwbRmY4F7N0v9lofTdIVHzWpoaqiOG/Zjso2gWS5u6Sp6rt8M5QNEW 7h/TrLeJ0NQMvignX66eFZN5X/MkGdk6C+OHQu93Qo30TBUDd6WgmcfARrepLCY= =ymYG -----END PGP SIGNATURE----- --TEW1p8E5T0ekGh0SWDOgICuPGwLiADxJR-- From MAILER-DAEMON Tue Sep 29 08:56:22 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZguSE-0001EZ-7z for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 08:56:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgaH3-0008Lx-Tb for qemu-block@nongnu.org; Mon, 28 Sep 2015 11:23:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgaH3-0001cD-6j for qemu-block@nongnu.org; Mon, 28 Sep 2015 11:23:29 -0400 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:32871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgaGt-0001Xz-PQ; Mon, 28 Sep 2015 11:23:19 -0400 Received: by wiclk2 with SMTP id lk2so110604470wic.0; Mon, 28 Sep 2015 08:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=HuaWWLwL2QD6IGrS/28rvaqjAYPKa+APOrNB932YGKA=; b=PmNGX6S0140joUNxMR3YCsD4p98HDmTJTzrX0ZGdnmavAxGrZGR2mVBQyoClFHS4FF lafCalzQ7sMhu9nz8kiGJa9r9HJZlGJExIX/Af/umEmM4Z3fgeDDgP0ZUxh2EvJJD/rT USxHTkNNxLmRTKU64p/QkbayRW9XE3v3RVNPYXLfZ0MWNL7jxc3R9AoXQxjOKpHPVkjp 5/AtzNzTlagK3Nn118EWi1B+f5WufFuw7Ylo25tZLpEeimkcwaBcjzLKaKijdHib/8Uf E6klOpPidUKJhY4p3zKnA0tbmGWzhUR3iL7Ypm8sXSumpG4W4seIiafj0geESGboAzU/ xdqA== X-Received: by 10.194.77.4 with SMTP id o4mr25826150wjw.4.1443453799182; Mon, 28 Sep 2015 08:23:19 -0700 (PDT) Received: from localhost (host86-182-204-196.range86-182.btcentralplus.com. [86.182.204.196]) by smtp.gmail.com with ESMTPSA id he3sm18890712wjc.48.2015.09.28.08.23.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Sep 2015 08:23:18 -0700 (PDT) Date: Mon, 28 Sep 2015 16:23:16 +0100 From: Stefan Hajnoczi To: Jeff Cody Message-ID: <20150928152316.GB19184@stefanha-thinkpad.redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22b Cc: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 3/3] block: mirror - zero unallocated target sectors when zero init not present X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 15:23:34 -0000 On Sun, Sep 27, 2015 at 11:29:18PM -0400, Jeff Cody wrote: > + if (s->zero_cycle) { > + ret = bdrv_get_block_status(s->target, sector_num, nb_sectors, &pnum); > + if (!(ret & BDRV_BLOCK_ZERO)) { > + bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sectors, > + s->unmap ? BDRV_REQ_MAY_UNMAP : 0, > + mirror_write_complete, op); mirror_write_complete will advance s->common.offset. Won't the progress be incorrect if we do that for both zeroing and regular mirroring? From MAILER-DAEMON Tue Sep 29 09:40:12 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgv8e-0001J4-MM for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 09:40:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgbRj-0000vt-0G for qemu-block@nongnu.org; Mon, 28 Sep 2015 12:38:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgbRe-0007gU-U5 for qemu-block@nongnu.org; Mon, 28 Sep 2015 12:38:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41005) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgbRe-0007gF-Ne; Mon, 28 Sep 2015 12:38:30 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id BE63380091; Mon, 28 Sep 2015 16:38:29 +0000 (UTC) Received: from [10.36.116.59] (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SGcQlm026781 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 12:38:28 -0400 To: Jeff Cody , qemu-devel@nongnu.org References: <9ae0ce111c95c6f76e872b12b2a6af895f5cfab6.1443410673.git.jcody@redhat.com> From: Max Reitz Message-ID: <56096D02.5010203@redhat.com> Date: Mon, 28 Sep 2015 18:38:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <9ae0ce111c95c6f76e872b12b2a6af895f5cfab6.1443410673.git.jcody@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="n8fnKd07l4MUn33gUlQIwGNKAOLQ7sCAs" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 1/3] block: allow creation of detached dirty bitmaps X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 16:38:36 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --n8fnKd07l4MUn33gUlQIwGNKAOLQ7sCAs Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 28.09.2015 05:29, Jeff Cody wrote: > This allows the creation of detached dirty bitmaps, so that the > block driver dirty bitmaps can be used without inserting the > bitmap into the dirty bitmap list for a BDS. >=20 > To free a bitmap that was created "detached =3D true", call > bdrv_release_dirty_bitmap() with the BlockDriverState argument > as NULL. >=20 > Signed-off-by: Jeff Cody > --- > block.c | 26 ++++++++++++++++++++------ > block/mirror.c | 3 ++- > blockdev.c | 2 +- > include/block/block.h | 1 + > migration/block.c | 2 +- > 5 files changed, 25 insertions(+), 9 deletions(-) Reviewed-by: Max Reitz --n8fnKd07l4MUn33gUlQIwGNKAOLQ7sCAs Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWCW0CAAoJEDuxQgLoOKytpBsIAIqZYJfe+WyP6hXZTSYbtxjs 9M+AIcFBM84/cZJWxc7PeavcESPF4JaXn0Rogtta3feIz1QXJr1PByqBiwXt5YI+ gRjnnurBte8MY2ffnIaMCl9R11QtFYtVvpXoJ7bH1jyFO786hAXv3wFp8QTqt9QM 2HUIPwKmXczy7yfnSRO+3G4dtQU2uE0jhxSecINZsX+JNtssS87XQl9b1bifS2zp IqlgmBlqdqC7TyyIDvm0gbFfNiFAIF3dUrbLIdsBQxkDB6HKh6fjRyLs346+ys+R boc/RAUx1M7hiX/lwuzekD3BN9hxnJVrk+HBvopsTngKQ7OkEWCTF3TU9ULqwJg= =jaVt -----END PGP SIGNATURE----- --n8fnKd07l4MUn33gUlQIwGNKAOLQ7sCAs-- From MAILER-DAEMON Tue Sep 29 09:40:19 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgv8k-0001Uw-IY for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 09:40:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgbdf-0004Dw-Vu for qemu-block@nongnu.org; Mon, 28 Sep 2015 12:50:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgbdX-0004S9-4t for qemu-block@nongnu.org; Mon, 28 Sep 2015 12:50:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49953) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgbdW-0004R1-Vq; Mon, 28 Sep 2015 12:50:47 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 75816C0A146B; Mon, 28 Sep 2015 16:50:46 +0000 (UTC) Received: from [10.36.116.59] (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SGoeDM032515 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 12:50:43 -0400 To: Jeff Cody , qemu-devel@nongnu.org References: <0de92b950741a15b9ff085f7b102ef99ef26101c.1443410673.git.jcody@redhat.com> From: Max Reitz Message-ID: <56096FDF.1090009@redhat.com> Date: Mon, 28 Sep 2015 18:50:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <0de92b950741a15b9ff085f7b102ef99ef26101c.1443410673.git.jcody@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="LtsEjaMxKLWrQaDpi2uFmbFBDh4J70VaN" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 2/3] block: mirror - split out part of mirror_run() X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 16:50:56 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --LtsEjaMxKLWrQaDpi2uFmbFBDh4J70VaN Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 28.09.2015 05:29, Jeff Cody wrote: > This is code relocation, to pull the part of mirror_run() that > calls mirror_iteration out into a separate function. >=20 > Signed-off-by: Jeff Cody > --- > block/mirror.c | 206 ++++++++++++++++++++++++++++++-------------------= -------- > 1 file changed, 110 insertions(+), 96 deletions(-) Reviewed-by: Max Reitz --LtsEjaMxKLWrQaDpi2uFmbFBDh4J70VaN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWCW/fAAoJEDuxQgLoOKytzX8IAJPg/IsZqei+Z8YBGD9rri9Y g5xKqKdmjEkXqulBwg69QV0mLh3Gm4Vc18WWBmicTFxfVKqXRPoL17u2gnW4S4R0 Co6vUDmJCqObfpuJK7hE/C2pZJOdz1zyVpmAwQUNr7L6DB4pRQbH421j2bDbV/14 e4x5GTaCQWLWWmcO9RlWgx//iEEsYeWDsijkTIR9zRA201qeVfwIi5HikItwQn1r 4gSrPcnAG5EG5yoaX7VQ7k2FijAHVsjYnBBm7J4pl1D02dIHP96mBZvVb6+W+qBL nUo6SOM33vNnVQh5VX/zxa6MjTB4adeN0j/UF2T55I50pmZ5LKvqo08F/bVFHds= =7npc -----END PGP SIGNATURE----- --LtsEjaMxKLWrQaDpi2uFmbFBDh4J70VaN-- From MAILER-DAEMON Tue Sep 29 09:40:57 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgv9M-0002Ee-F4 for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 09:40:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgcHY-0007vF-2Q for qemu-block@nongnu.org; Mon, 28 Sep 2015 13:32:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgcHU-00058R-Qx for qemu-block@nongnu.org; Mon, 28 Sep 2015 13:32:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgcHU-00058J-I2; Mon, 28 Sep 2015 13:32:04 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 48DEDA464C; Mon, 28 Sep 2015 17:32:04 +0000 (UTC) Received: from [10.36.116.59] (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SHW0Xb011924 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Sep 2015 13:32:02 -0400 To: Jeff Cody , qemu-devel@nongnu.org References: From: Max Reitz X-Enigmail-Draft-Status: N1110 Message-ID: <56097990.7040007@redhat.com> Date: Mon, 28 Sep 2015 19:32:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xo61w6a5vd8jh8gGvGPi8LbfEAAEf8lKr" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-block@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [PATCH 3/3] block: mirror - zero unallocated target sectors when zero init not present X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 17:32:13 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --xo61w6a5vd8jh8gGvGPi8LbfEAAEf8lKr Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 28.09.2015 05:29, Jeff Cody wrote: > During mirror, if the target device does not have support zero > initialization, a mirror may result in a corrupt image. >=20 > For instance, on mirror to a host device with format =3D raw, whatever > random data is on the target device will still be there for unallocated= > sectors. >=20 > This is because during the mirror, we set the dirty bitmap to copy only= > sectors allocated above 'base'. In the case of target devices where we= > cannot assume unallocated sectors will be read as zeroes, we need to > explicitely zero out this data. >=20 > In order to avoid zeroing out all sectors of the target device prior to= > mirroring, we do zeroing as part of the block job. A second dirty > bitmap cache is created, to track sectors that are unallocated above > 'base'. These sectors are then checked for status of BDRV_BLOCK_ZERO > on the target - if they are not, then zeroes are explicitly written. >=20 > This only occurs under two conditions: >=20 > 1. 'mode' !=3D "existing" > 2. bdrv_has_zero_init(target) =3D=3D NULL >=20 > We perform the mirroring through mirror_iteration() as before, except > in two passes. If the above two conditions are met, the first pass > is using the bitmap tracking unallocated sectors, to write the needed > zeroes. Then, the second pass is performed, to mirror the actual data > as before. >=20 > If the above two conditions are not met, then the first pass is skipped= , > and only the second pass (the one with the actual data) is performed. >=20 > Signed-off-by: Jeff Cody > --- > block/mirror.c | 109 ++++++++++++++++++++++++++++++++++----= -------- > blockdev.c | 2 +- > include/block/block_int.h | 3 +- > qapi/block-core.json | 6 ++- > 4 files changed, 87 insertions(+), 33 deletions(-) >=20 > diff --git a/block/mirror.c b/block/mirror.c > index 405e5c4..b599176 100644 > --- a/block/mirror.c > +++ b/block/mirror.c > @@ -50,7 +50,9 @@ typedef struct MirrorBlockJob { > int64_t bdev_length; > unsigned long *cow_bitmap; > BdrvDirtyBitmap *dirty_bitmap; > - HBitmapIter hbi; > + HBitmapIter zero_hbi; > + HBitmapIter allocated_hbi; > + HBitmapIter *hbi; > uint8_t *buf; > QSIMPLEQ_HEAD(, MirrorBuffer) buf_free; > int buf_free_count; > @@ -60,6 +62,8 @@ typedef struct MirrorBlockJob { > int sectors_in_flight; > int ret; > bool unmap; > + bool zero_unallocated; > + bool zero_cycle; > bool waiting_for_io; > } MirrorBlockJob; > =20 > @@ -166,10 +170,10 @@ static uint64_t coroutine_fn mirror_iteration(Mir= rorBlockJob *s) > int pnum; > int64_t ret; > =20 > - s->sector_num =3D hbitmap_iter_next(&s->hbi); > + s->sector_num =3D hbitmap_iter_next(s->hbi); > if (s->sector_num < 0) { > - bdrv_dirty_iter_init(s->dirty_bitmap, &s->hbi); > - s->sector_num =3D hbitmap_iter_next(&s->hbi); > + bdrv_dirty_iter_init(s->dirty_bitmap, s->hbi); > + s->sector_num =3D hbitmap_iter_next(s->hbi); > trace_mirror_restart_iter(s, bdrv_get_dirty_count(s->dirty_bit= map)); > assert(s->sector_num >=3D 0); > } > @@ -287,7 +291,7 @@ static uint64_t coroutine_fn mirror_iteration(Mirro= rBlockJob *s) > */ > if (next_sector > hbitmap_next_sector > && bdrv_get_dirty(source, s->dirty_bitmap, next_sector)) {= > - hbitmap_next_sector =3D hbitmap_iter_next(&s->hbi); > + hbitmap_next_sector =3D hbitmap_iter_next(s->hbi); > } > =20 > next_sector +=3D sectors_per_chunk; > @@ -300,25 +304,34 @@ static uint64_t coroutine_fn mirror_iteration(Mir= rorBlockJob *s) > s->sectors_in_flight +=3D nb_sectors; > trace_mirror_one_iteration(s, sector_num, nb_sectors); > =20 > - ret =3D bdrv_get_block_status_above(source, NULL, sector_num, > - nb_sectors, &pnum); > - if (ret < 0 || pnum < nb_sectors || > - (ret & BDRV_BLOCK_DATA && !(ret & BDRV_BLOCK_ZERO))) { > - bdrv_aio_readv(source, sector_num, &op->qiov, nb_sectors, > - mirror_read_complete, op); > - } else if (ret & BDRV_BLOCK_ZERO) { > - bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sectors, > - s->unmap ? BDRV_REQ_MAY_UNMAP : 0, > - mirror_write_complete, op); > + if (s->zero_cycle) { > + ret =3D bdrv_get_block_status(s->target, sector_num, nb_sector= s, &pnum); > + if (!(ret & BDRV_BLOCK_ZERO)) { > + bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sector= s, > + s->unmap ? BDRV_REQ_MAY_UNMAP : 0, > + mirror_write_complete, op); > + } > } else { > - assert(!(ret & BDRV_BLOCK_DATA)); > - bdrv_aio_discard(s->target, sector_num, op->nb_sectors, > - mirror_write_complete, op); > + ret =3D bdrv_get_block_status_above(source, NULL, sector_num, > + nb_sectors, &pnum); > + if (ret < 0 || pnum < nb_sectors || > + (ret & BDRV_BLOCK_DATA && !(ret & BDRV_BLOCK_ZERO))) {= > + bdrv_aio_readv(source, sector_num, &op->qiov, nb_sectors, > + mirror_read_complete, op); > + } else if (ret & BDRV_BLOCK_ZERO) { > + bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sector= s, > + s->unmap ? BDRV_REQ_MAY_UNMAP : 0, > + mirror_write_complete, op); > + } else { > + assert(!(ret & BDRV_BLOCK_DATA)); > + bdrv_aio_discard(s->target, sector_num, op->nb_sectors, > + mirror_write_complete, op); > + } > } > return delay_ns; > } > =20 > -static int mirror_do_iteration(MirrorBlockJob *s, uint64_t last_pause_= ns) > +static int mirror_do_iteration(MirrorBlockJob *s, uint64_t *last_pause= _ns) > { > int ret; > =20 > @@ -347,7 +360,7 @@ static int mirror_do_iteration(MirrorBlockJob *s, u= int64_t last_pause_ns) > * We do so every SLICE_TIME nanoseconds, or when there is an = error, > * or when the source is clean, whichever comes first. > */ > - if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - last_pause_ns < S= LICE_TIME > + if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - *last_pause_ns < = SLICE_TIME > && s->common.iostatus =3D=3D BLOCK_DEVICE_IO_STATUS_OK) { > if (s->in_flight =3D=3D MAX_IN_FLIGHT || s->buf_free_count= =3D=3D 0 || > (cnt =3D=3D 0 && s->in_flight > 0)) { > @@ -371,6 +384,14 @@ static int mirror_do_iteration(MirrorBlockJob *s, = uint64_t last_pause_ns) > goto immediate_exit; > } > } else { > + > + if (s->zero_cycle) { > + /* this is not the end of the streaming cycle, > + * if we are just filling in zeroes for unallocate= d > + * sectors prior to streaming the real data */ > + goto immediate_exit; > + } > + > /* We're out of the streaming phase. From now on, if = the job > * is cancelled we will actually complete all pending = I/O and > * report completion. This way, block-job-cancel will= leave > @@ -419,7 +440,7 @@ static int mirror_do_iteration(MirrorBlockJob *s, u= int64_t last_pause_ns) > s->common.cancelled =3D false; > break; > } > - last_pause_ns =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); > + *last_pause_ns =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); > } > =20 > immediate_exit: > @@ -511,6 +532,15 @@ static void coroutine_fn mirror_run(void *opaque) > checking for a NULL string */ > int ret =3D 0; > int n; > + BdrvDirtyBitmap *zero_dirty_bitmap; > + BdrvDirtyBitmap *allocated_dirty_bitmap =3D s->dirty_bitmap; > + > + zero_dirty_bitmap =3D bdrv_create_dirty_bitmap(s->target, > + s->granularity, NULL,= true, > + NULL); > + if (zero_dirty_bitmap =3D=3D NULL) { > + goto immediate_exit; > + } I think I'd like the error to be reported to the user; but in any case, you have to set ret to a negative value. > =20 > if (block_job_is_cancelled(&s->common)) { > goto immediate_exit; > @@ -588,14 +618,33 @@ static void coroutine_fn mirror_run(void *opaque)= > assert(n > 0); > if (ret =3D=3D 1) { > bdrv_set_dirty_bitmap(s->dirty_bitmap, sector_num, n);= > + } else if (s->zero_unallocated) { > + bdrv_set_dirty_bitmap(zero_dirty_bitmap, sector_num, n= ); > } > sector_num +=3D n; > } > } > =20 > - bdrv_dirty_iter_init(s->dirty_bitmap, &s->hbi); > + bdrv_dirty_iter_init(s->dirty_bitmap, &s->allocated_hbi); > =20 > - ret =3D mirror_do_iteration(s, last_pause_ns); > + if (s->zero_unallocated) { > + bdrv_dirty_iter_init(zero_dirty_bitmap, &s->zero_hbi); > + s->dirty_bitmap =3D zero_dirty_bitmap; > + s->hbi =3D &s->zero_hbi; > + > + s->zero_cycle =3D true; > + ret =3D mirror_do_iteration(s, &last_pause_ns); > + if (ret < 0) { > + goto immediate_exit; > + } > + > + mirror_drain(s); > + s->zero_cycle =3D false; > + } > + > + s->dirty_bitmap =3D allocated_dirty_bitmap; > + s->hbi =3D &s->allocated_hbi; > + ret =3D mirror_do_iteration(s, &last_pause_ns); > =20 > immediate_exit: > if (s->in_flight > 0) { > @@ -611,7 +660,8 @@ immediate_exit: > qemu_vfree(s->buf); > g_free(s->cow_bitmap); > g_free(s->in_flight_bitmap); > - bdrv_release_dirty_bitmap(bs, s->dirty_bitmap); > + bdrv_release_dirty_bitmap(bs, allocated_dirty_bitmap); > + bdrv_release_dirty_bitmap(NULL, zero_dirty_bitmap); > bdrv_iostatus_disable(s->target); > =20 > data =3D g_malloc(sizeof(*data)); > @@ -702,7 +752,7 @@ static void mirror_start_job(BlockDriverState *bs, = BlockDriverState *target, > int64_t buf_size, > BlockdevOnError on_source_error, > BlockdevOnError on_target_error, > - bool unmap, > + bool unmap, bool existing, > BlockCompletionFunc *cb, > void *opaque, Error **errp, > const BlockJobDriver *driver, > @@ -737,6 +787,7 @@ static void mirror_start_job(BlockDriverState *bs, = BlockDriverState *target, > return; > } > =20 > + s->zero_unallocated =3D !existing && !bdrv_has_zero_init(target); I think this should be set only if we're doing a full mirror operation. For instance, I could do a none, top or incremental mirror to a new qcow2 file, which would give it a backing file, obviously. You're lucky in that qcow2 claims to always have zero initialization, when this is in fact not true (someone's ought to fix that...): With a backing file, an overlay file just cannot have zero initialization, it's impossible (well, unless the backing file is completely zero). So if qcow2 were to answer correctly, i.e. "No, with a backing file I do not have zero init", then this would overwrite all sectors which are supposed to be unallocated because they are present in the backing file. > s->replaces =3D g_strdup(replaces); > s->on_source_error =3D on_source_error; > s->on_target_error =3D on_target_error; > @@ -767,7 +818,7 @@ void mirror_start(BlockDriverState *bs, BlockDriver= State *target, > int64_t speed, uint32_t granularity, int64_t buf_siz= e, > MirrorSyncMode mode, BlockdevOnError on_source_error= , > BlockdevOnError on_target_error, > - bool unmap, > + bool unmap, bool existing, > BlockCompletionFunc *cb, > void *opaque, Error **errp) > { > @@ -782,8 +833,8 @@ void mirror_start(BlockDriverState *bs, BlockDriver= State *target, > base =3D mode =3D=3D MIRROR_SYNC_MODE_TOP ? bs->backing_hd : NULL;= > mirror_start_job(bs, target, replaces, > speed, granularity, buf_size, > - on_source_error, on_target_error, unmap, cb, opaq= ue, errp, > - &mirror_job_driver, is_none_mode, base); > + on_source_error, on_target_error, unmap, existing= , cb, > + opaque, errp, &mirror_job_driver, is_none_mode, b= ase); > } > =20 > void commit_active_start(BlockDriverState *bs, BlockDriverState *base,= > @@ -830,7 +881,7 @@ void commit_active_start(BlockDriverState *bs, Bloc= kDriverState *base, > =20 > bdrv_ref(base); > mirror_start_job(bs, base, NULL, speed, 0, 0, > - on_error, on_error, false, cb, opaque, &local_err= , > + on_error, on_error, false, false, cb, opaque, &lo= cal_err, This should probably be true; the commit target is already existing, after all. Also, without it being true, iotest 097 fails. > &commit_active_job_driver, false, base); > if (local_err) { > error_propagate(errp, local_err); > diff --git a/blockdev.c b/blockdev.c > index cb9f78d..c06ac60 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -2816,7 +2816,7 @@ void qmp_drive_mirror(const char *device, const c= har *target, > has_replaces ? replaces : NULL, > speed, granularity, buf_size, sync, > on_source_error, on_target_error, > - unmap, > + unmap, mode =3D=3D NEW_IMAGE_MODE_EXISTING, > block_job_cb, bs, &local_err); > if (local_err !=3D NULL) { > bdrv_unref(target_bs); > diff --git a/include/block/block_int.h b/include/block/block_int.h > index 14ad4c3..21a8988 100644 > --- a/include/block/block_int.h > +++ b/include/block/block_int.h > @@ -614,6 +614,7 @@ void commit_active_start(BlockDriverState *bs, Bloc= kDriverState *base, > * @on_source_error: The action to take upon error reading from the so= urce. > * @on_target_error: The action to take upon error writing to the targ= et. > * @unmap: Whether to unmap target where source sectors only contain z= eroes. > + * @existing: Whether target image is an existing image prior to the Q= MP cmd. > * @cb: Completion function for the job. > * @opaque: Opaque pointer value passed to @cb. > * @errp: Error object. > @@ -628,7 +629,7 @@ void mirror_start(BlockDriverState *bs, BlockDriver= State *target, > int64_t speed, uint32_t granularity, int64_t buf_siz= e, > MirrorSyncMode mode, BlockdevOnError on_source_error= , > BlockdevOnError on_target_error, > - bool unmap, > + bool unmap, bool existing, > BlockCompletionFunc *cb, > void *opaque, Error **errp); > =20 > diff --git a/qapi/block-core.json b/qapi/block-core.json > index bb2189e..033afb4 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -952,8 +952,10 @@ > # broken Quorum files. (Since 2.1) > # > # @mode: #optional whether and how QEMU should create a new image, def= ault is > -# 'absolute-paths'. > -# This empty line should stay. > +# 'absolute-paths'. If mode !=3D 'existing', and the target do= es not > +# have zero init (sparseness), then the target image will have= sectors > +# zeroed out that correspond to sectors in an unallocated stat= e in the > +# source image. As I said above, this should only happen if @sync =3D=3D 'full'. Max > # @speed: #optional the maximum speed, in bytes per second > # > # @sync: what parts of the disk image should be copied to the destinat= ion >=20 --xo61w6a5vd8jh8gGvGPi8LbfEAAEf8lKr Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWCXmQAAoJEDuxQgLoOKytoG4IAJ5wBo9NIHFQJUqjz/HL8h6u eucRVrEg7LSUZRPXl3SzfBokydbGYxpEjmfs/y7xAOsw4yPv3bVp3/MvI3rngdfu KvrjVqV7bY2D1OTnNVLD6qyzDD0QTGOGpoCminMR/D6qnLiS1QTTknmbRJ+ciutH kYXUcLhz1l9LahWIAuXUInIrOkqh3MtSn2jBszibVSlmpcNl6LlV+2g1G5yRNd+D b9Bt8AW4bwv7InOrXtpxxyx9N/7KcnvohQm2br164pYuPlAezAVkw55KOADZLw7m Pz4nzhpi+ID4qzfciIWPPdGtSClH0H2IIUQgW15kYNv9BPi67porXBoi5jtq41E= =ktP2 -----END PGP SIGNATURE----- --xo61w6a5vd8jh8gGvGPi8LbfEAAEf8lKr-- From MAILER-DAEMON Tue Sep 29 09:41:01 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zgv9R-0002Hv-4n for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 09:41:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgcOI-0000Up-HP for qemu-block@nongnu.org; Mon, 28 Sep 2015 13:39:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgcOD-0007x1-IM for qemu-block@nongnu.org; Mon, 28 Sep 2015 13:39:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39420) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgcOD-0007wx-Dk; Mon, 28 Sep 2015 13:39:01 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id E6DF5C0B64C7; Mon, 28 Sep 2015 17:39:00 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SHcxlM015456; Mon, 28 Sep 2015 13:39:00 -0400 From: John Snow To: qemu-block@nongnu.org Date: Mon, 28 Sep 2015 13:38:58 -0400 Message-Id: <1443461938-30039-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [Qemu-block] [PATCH] qtest/ide-test: ppc64be correction for ATAPI tests X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 17:39:07 -0000 the 16bit ide data register is LE by definition. Signed-off-by: John Snow --- tests/ide-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ide-test.c b/tests/ide-test.c index 5594738..b6e9e1a 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -633,7 +633,7 @@ static void send_scsi_cdb_read10(uint64_t lba, int nblocks) /* Send Packet */ for (i = 0; i < sizeof(Read10CDB)/2; i++) { - outw(IDE_BASE + reg_data, ((uint16_t *)&pkt)[i]); + outw(IDE_BASE + reg_data, cpu_to_le16(((uint16_t *)&pkt)[i])); } } @@ -733,7 +733,7 @@ static void cdrom_pio_impl(int nblocks) size_t offset = i * (limit / 2); size_t rem = (rxsize / 2) - offset; for (j = 0; j < MIN((limit / 2), rem); j++) { - rx[offset + j] = inw(IDE_BASE + reg_data); + rx[offset + j] = le16_to_cpu(inw(IDE_BASE + reg_data)); } ide_wait_intr(IDE_PRIMARY_IRQ); } -- 2.4.3 From MAILER-DAEMON Tue Sep 29 09:55:16 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgvNE-0001kX-82 for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 09:55:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgf4z-0004dD-G3 for qemu-block@nongnu.org; Mon, 28 Sep 2015 16:31:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zgf4w-0006k5-2J for qemu-block@nongnu.org; Mon, 28 Sep 2015 16:31:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgf4v-0006jo-Rb; Mon, 28 Sep 2015 16:31:18 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 4D492461C0; Mon, 28 Sep 2015 20:31:17 +0000 (UTC) Received: from [10.3.113.188] (ovpn-113-188.phx2.redhat.com [10.3.113.188]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8SKVG18019410; Mon, 28 Sep 2015 16:31:16 -0400 To: Paolo Bonzini , Jeff Cody , qemu-devel@nongnu.org References: <56094B0F.7030900@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg X-Enigmail-Draft-Status: N1110 Organization: Red Hat, Inc. Message-ID: <5609A38F.1070405@redhat.com> Date: Mon, 28 Sep 2015 14:31:11 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <56094B0F.7030900@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="HmdS1QJKbeC211CBnH62i4SCFsmKdnob1" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 3/3] block: mirror - zero unallocated target sectors when zero init not present X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 20:31:22 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --HmdS1QJKbeC211CBnH62i4SCFsmKdnob1 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/28/2015 08:13 AM, Paolo Bonzini wrote: >=20 >=20 > On 28/09/2015 05:29, Jeff Cody wrote: >> This only occurs under two conditions: >> >> 1. 'mode' !=3D "existing" >> 2. bdrv_has_zero_init(target) =3D=3D NULL >> >=20 > I'm not sure if mode !=3D "existing" actually matters. I think what > actually matters is sync =3D=3D "full". When mode =3D=3D 'existing' for a shallow mirror (sync !=3D 'full'), that= is the caller stating that the guest-visible contents of the destination match the guest-visible contents of the backing image. The only sectors to be copied are those that differ from the backing file, and we should not be zeroing unrelated sectors because the user has already promised they have the same guest-visible content as the backing image would repor= t. When mode =3D=3D 'existing' for a full mirror (sync =3D=3D 'full'), that = is the caller stating that they want every single sector of the destination written to hold the current state of the source (of course, allowing for optimizations such as skipping the write where the contents will read back the same as if the write had been performed). I think Paolo is right: we care about zeroing unallocated sectors for sync =3D=3D 'full', regardless of whether mode =3D=3D 'existing'. I also think the reason Jeff confused it for mode =3D=3D 'existing' is th= at the other modes let qemu create the file, but qemu does not create block devices (the only way to mirror to a block device is via mode =3D=3D 'existing'), and it is primarily block devices where zero init is not guaranteed. >=20 > The reasons are: >=20 > 1) with sync !=3D "full", unallocated target sectors should remain > unallocated on the destination because they are supposed to point to th= e > backing file. >=20 > 2) even with mode =3D=3D "existing" you expect the data to be consisten= t at > the end of the mirroring >=20 > Paolo >=20 >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --HmdS1QJKbeC211CBnH62i4SCFsmKdnob1 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWCaOPAAoJEKeha0olJ0Nq50wH/A9iioFcNtgRLwiKV8S5cig4 LjisK6oAfajftNkg23y2HKSv7gquCaZVO8on7Lm3NRK/wnnDWCb4C92vBT/pUzBA ZI/gaa4/DY3WxZOtqvbF58qylDwg96Vri4E+1BUx0BUWQPo4IEjgOmzRCGzF1jdS D7VEWYg7hwDH3I8AAYEh/vA9+EUK9FHYf8Zaz86Itdi9kYVR6ahN574NsRuo9b/8 vnJCfYlRTJaL7li/u1uglL9iKy7Rf21kUJv3cw2jIuUJ2vvcjGUohQiXHh859d90 SuQK19u+lF+Ex3aDy5tzZD1KSnkej92NBoYMqpMR18z8fiYLLqYRygTcOvwHXtI= =bvGC -----END PGP SIGNATURE----- --HmdS1QJKbeC211CBnH62i4SCFsmKdnob1-- From MAILER-DAEMON Tue Sep 29 09:55:48 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgvNk-0002T4-6Z for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 09:55:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgg25-0006Bp-Uf for qemu-block@nongnu.org; Mon, 28 Sep 2015 17:32:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zgg25-0001uZ-15 for qemu-block@nongnu.org; Mon, 28 Sep 2015 17:32:25 -0400 Received: from mail-qk0-x232.google.com ([2607:f8b0:400d:c09::232]:36322) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgg22-0001u6-QE; Mon, 28 Sep 2015 17:32:22 -0400 Received: by qkcf65 with SMTP id f65so73906825qkc.3; Mon, 28 Sep 2015 14:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=TDJwWXchJto1fnmH8BshA5q2vEijmo4Uzj28WXCfvzQ=; b=W8xf6TGoH18YnEXbuDx8URbMNnyOgcrirDLGkl8ByZ5ZjxAap5kU83Kkm2ZFof1I2K p4N9qjTHF8/LLo71kqbwG5vF8OsZrXcpx1wv2DSlXMlSi7aL7g5FDdMy3rCwwyANoq0w jY69uQbNxrGpPWA4XEyzl9G1/NwKojhNFy22eJuESHW1yg4CdhmSQvbFaJPg6jrmNlIx 2osfo89g7FQA+4GV46vYpiGSlvITLvlkgucrxj9esKL3CYDlDsDPhss/WESlJl2cs1UI YOvqIe9IXNNYU/mH2PBq5LznfV1KMEontSMM6dxg2eWz+a5voGFuPoXCnOERvLQMeMP6 VJuA== MIME-Version: 1.0 X-Received: by 10.55.25.160 with SMTP id 32mr24020181qkz.40.1443475942267; Mon, 28 Sep 2015 14:32:22 -0700 (PDT) Received: by 10.55.3.16 with HTTP; Mon, 28 Sep 2015 14:32:21 -0700 (PDT) Received: by 10.55.3.16 with HTTP; Mon, 28 Sep 2015 14:32:21 -0700 (PDT) In-Reply-To: <56094B0F.7030900@redhat.com> References: <56094B0F.7030900@redhat.com> Date: Mon, 28 Sep 2015 17:32:21 -0400 Message-ID: From: Jeff Cody To: Paolo Bonzini Content-Type: multipart/alternative; boundary=001a1147edc6c7e1850520d56e74 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c09::232 Cc: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 3/3] block: mirror - zero unallocated target sectors when zero init not present X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 21:32:27 -0000 --001a1147edc6c7e1850520d56e74 Content-Type: text/plain; charset=UTF-8 On Sep 28, 2015 4:12 PM, "Paolo Bonzini" wrote: > > Replying from mobile; please excuse any formatting issues. > > On 28/09/2015 05:29, Jeff Cody wrote: > > This only occurs under two conditions: > > > > 1. 'mode' != "existing" > > 2. bdrv_has_zero_init(target) == NULL > > > > I'm not sure if mode != "existing" actually matters. I think what > actually matters is sync == "full". > > The reasons are: > > 1) with sync != "full", unallocated target sectors should remain > unallocated on the destination because they are supposed to point to the > backing file. I guess that makes sense. What about the case when the target is a raw device without zero init? There is no backing file... Of course, perhaps in the raw case the user should be using sync==full anyways. > > 2) even with mode == "existing" you expect the data to be consistent at > the end of the mirroring > The reason I added the "existing" exception was so the user could avoid the time penalty of zeroing out the data if they knew the target had already explicitly been zeroed. Do you think it is fair to assume that if the user specified existing, that they take responsibility for setting up the target image how they like (including data initialization)? Or should we add another option for mirror, to allow the user to bypass the zero fill? Thanks, Jeff --001a1147edc6c7e1850520d56e74 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Sep 28, 2015 4:12 PM, "Paolo Bonzini" <pbonzini@redhat.com> wrote:
>
>

Replying from mobile; please excuse any formatting issues.

>
> On 28/09/2015 05:29, Jeff Cody wrote:
> > This only occurs under two conditions:
> >
> >=C2=A0 =C2=A0 =C2=A01. 'mode' !=3D "existing" > >=C2=A0 =C2=A0 =C2=A02. bdrv_has_zero_init(target) =3D=3D NULL
> >
>
> I'm not sure if mode !=3D "existing" actually matters.= =C2=A0 I think what
> actually matters is sync =3D=3D "full".
>
> The reasons are:
>
> 1) with sync !=3D "full", unallocated target sectors should = remain
> unallocated on the destination because they are supposed to point to t= he
> backing file.

I guess that makes sense.=C2=A0 What about=C2=A0 the case wh= en the target is a raw device without zero init?=C2=A0 There is no backing = file... Of course, perhaps in the raw case the user should be using sync=3D= =3Dfull anyways.

>
> 2) even with mode =3D=3D "existing" you expect the data to b= e consistent at
> the end of the mirroring
>

The reason I added the "existing" exception was so= the user could avoid the time penalty of zeroing out the data if they knew= the target had already explicitly been zeroed.=C2=A0 Do you think it is fa= ir to assume that if the user specified existing, that they take responsibi= lity for setting up the target image how they like (including data initiali= zation)?=C2=A0 Or should we add another option for mirror, to allow the use= r to bypass the zero fill?

Thanks,
Jeff

--001a1147edc6c7e1850520d56e74-- From MAILER-DAEMON Tue Sep 29 09:56:02 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgvNy-0002eD-Ke for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 09:56:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZggQ2-0001ld-QC for qemu-block@nongnu.org; Mon, 28 Sep 2015 17:57:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZggQ0-0006Ug-PZ for qemu-block@nongnu.org; Mon, 28 Sep 2015 17:57:10 -0400 Received: from mail-qg0-x22a.google.com ([2607:f8b0:400d:c04::22a]:34517) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZggPw-0006TD-Bg; Mon, 28 Sep 2015 17:57:04 -0400 Received: by qgez77 with SMTP id z77so134157735qge.1; Mon, 28 Sep 2015 14:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=a59ORJZtnddmz6A7l1Q1iXqmCjKK6XXddREP/VIWjrY=; b=o0UKecIL1UnfLJY7Kl/MKP61K1Udoz0QPlXCncb2R5VWh6DqzwU5TfnObWZszt83wl OaQdyLsJ9WhymQZYrh54jTenfaBhoKrcSM1urcIs0xlPzuLvUnxNLymy00PELZ0qHuEo K3QeZMZ/2IGj16nc1CfMLFA+TTKf/hBKs7LWtD8SHb4cbFVMbF5SAXkFSpWLDtNEapGx WNrZD7hEUdAd8QRnBBHuEytzqcCW8Po9t3BMvUR869YQasfw7ZENB/qMhUI7bc9obzlO khGHoX8QNpPQFyjTCELsjPMSNwdDYe2GEpo+bRyxrjkUFbWgYhWl26TV5EfH4uvGq5RR SDVQ== MIME-Version: 1.0 X-Received: by 10.140.31.37 with SMTP id e34mr25348843qge.17.1443477423948; Mon, 28 Sep 2015 14:57:03 -0700 (PDT) Received: by 10.55.3.16 with HTTP; Mon, 28 Sep 2015 14:57:03 -0700 (PDT) Received: by 10.55.3.16 with HTTP; Mon, 28 Sep 2015 14:57:03 -0700 (PDT) In-Reply-To: <20150928150752.GC18068@noname.str.redhat.com> References: <20150928150752.GC18068@noname.str.redhat.com> Date: Mon, 28 Sep 2015 17:57:03 -0400 Message-ID: From: Jeff Cody To: Kevin Wolf Content-Type: multipart/alternative; boundary=001a113a948e1889200520d5c7eb X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c04::22a Cc: stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 3/3] block: mirror - zero unallocated target sectors when zero init not present X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 21:57:12 -0000 --001a113a948e1889200520d5c7eb Content-Type: text/plain; charset=UTF-8 On Sep 28, 2015 5:31 PM, "Kevin Wolf" wrote: > (Responding from mobile phone again) > Am 28.09.2015 um 05:29 hat Jeff Cody geschrieben: > > During mirror, if the target device does not have support zero > > initialization, a mirror may result in a corrupt image. > > I think you want to check this sentence. ("During mirror [...], a > mirror may result [...]") > Yes, thanks. > > For instance, on mirror to a host device with format = raw, whatever > > random data is on the target device will still be there for unallocated > > sectors. > > > > This is because during the mirror, we set the dirty bitmap to copy only > > sectors allocated above 'base'. In the case of target devices where we > > cannot assume unallocated sectors will be read as zeroes, we need to > > explicitely zero out this data. > > > > In order to avoid zeroing out all sectors of the target device prior to > > mirroring, we do zeroing as part of the block job. A second dirty > > bitmap cache is created, to track sectors that are unallocated above > > 'base'. These sectors are then checked for status of BDRV_BLOCK_ZERO > > on the target - if they are not, then zeroes are explicitly written. > > Why do you need a bitmap? You never change the bitmap after initialising > it, so couldn't you instead just check the allocation status when you > need it? The main reason was really to maximize code reuse, and be able to use the same iteration code in the mirror coroutine. > > In fact, why do we need two passes? I would have expected that commit > dcfb3beb already does the trick, with checking allocation status and > writing zeroes during the normal single pass. > > If that commit fails to solve the problem, I guess I first need to > understand why before I can continue reviewing this one... > Responding from memory right now, but that commit only helps if the guest unmaps data, changing the sectors to unallocated after the mirror begins. However, before we get to this point we've already generated our bitmap of dirty sectors in mirror_run(), and those are explicitly only sectors that are allocated above the source. Inside the iteration, we'll only pick up the unallocated sectors if they have been changed by the guest. > > This only occurs under two conditions: > > > > 1. 'mode' != "existing" > > 2. bdrv_has_zero_init(target) == NULL > > > > We perform the mirroring through mirror_iteration() as before, except > > in two passes. If the above two conditions are met, the first pass > > is using the bitmap tracking unallocated sectors, to write the needed > > zeroes. Then, the second pass is performed, to mirror the actual data > > as before. > > > > If the above two conditions are not met, then the first pass is skipped, > > and only the second pass (the one with the actual data) is performed. > > > > Signed-off-by: Jeff Cody > > --- > > block/mirror.c | 109 ++++++++++++++++++++++++++++++++++------------ > > blockdev.c | 2 +- > > include/block/block_int.h | 3 +- > > qapi/block-core.json | 6 ++- > > 4 files changed, 87 insertions(+), 33 deletions(-) > > > > diff --git a/block/mirror.c b/block/mirror.c > > index 405e5c4..b599176 100644 > > --- a/block/mirror.c > > +++ b/block/mirror.c > > @@ -50,7 +50,9 @@ typedef struct MirrorBlockJob { > > int64_t bdev_length; > > unsigned long *cow_bitmap; > > BdrvDirtyBitmap *dirty_bitmap; > > - HBitmapIter hbi; > > + HBitmapIter zero_hbi; > > + HBitmapIter allocated_hbi; > > + HBitmapIter *hbi; > > uint8_t *buf; > > QSIMPLEQ_HEAD(, MirrorBuffer) buf_free; > > int buf_free_count; > > @@ -60,6 +62,8 @@ typedef struct MirrorBlockJob { > > int sectors_in_flight; > > int ret; > > bool unmap; > > + bool zero_unallocated; > > + bool zero_cycle; > > bool waiting_for_io; > > } MirrorBlockJob; > > > > @@ -166,10 +170,10 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) > > int pnum; > > int64_t ret; > > > > - s->sector_num = hbitmap_iter_next(&s->hbi); > > + s->sector_num = hbitmap_iter_next(s->hbi); > > if (s->sector_num < 0) { > > - bdrv_dirty_iter_init(s->dirty_bitmap, &s->hbi); > > - s->sector_num = hbitmap_iter_next(&s->hbi); > > + bdrv_dirty_iter_init(s->dirty_bitmap, s->hbi); > > + s->sector_num = hbitmap_iter_next(s->hbi); > > trace_mirror_restart_iter(s, bdrv_get_dirty_count(s->dirty_bitmap)); > > assert(s->sector_num >= 0); > > } > > @@ -287,7 +291,7 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) > > */ > > if (next_sector > hbitmap_next_sector > > && bdrv_get_dirty(source, s->dirty_bitmap, next_sector)) { > > - hbitmap_next_sector = hbitmap_iter_next(&s->hbi); > > + hbitmap_next_sector = hbitmap_iter_next(s->hbi); > > } > > > > next_sector += sectors_per_chunk; > > @@ -300,25 +304,34 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) > > s->sectors_in_flight += nb_sectors; > > trace_mirror_one_iteration(s, sector_num, nb_sectors); > > > > - ret = bdrv_get_block_status_above(source, NULL, sector_num, > > - nb_sectors, &pnum); > > - if (ret < 0 || pnum < nb_sectors || > > - (ret & BDRV_BLOCK_DATA && !(ret & BDRV_BLOCK_ZERO))) { > > - bdrv_aio_readv(source, sector_num, &op->qiov, nb_sectors, > > - mirror_read_complete, op); > > - } else if (ret & BDRV_BLOCK_ZERO) { > > - bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sectors, > > - s->unmap ? BDRV_REQ_MAY_UNMAP : 0, > > - mirror_write_complete, op); > > + if (s->zero_cycle) { > > + ret = bdrv_get_block_status(s->target, sector_num, nb_sectors, &pnum); > > + if (!(ret & BDRV_BLOCK_ZERO)) { > > + bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sectors, > > + s->unmap ? BDRV_REQ_MAY_UNMAP : 0, > > + mirror_write_complete, op); > > + } > > It seems to be expected that this function always involves an AIO > request and the completion event is what helps making progress. For the > BDRV_BLOCK_ZERO case, we don't do that however. I'm not sure what > exactly this means, but at least I think we are applying block job > throttling to doing nothing with some areas of the image. > > > } else { > > - assert(!(ret & BDRV_BLOCK_DATA)); > > - bdrv_aio_discard(s->target, sector_num, op->nb_sectors, > > - mirror_write_complete, op); > > + ret = bdrv_get_block_status_above(source, NULL, sector_num, > > + nb_sectors, &pnum); > > + if (ret < 0 || pnum < nb_sectors || > > + (ret & BDRV_BLOCK_DATA && !(ret & BDRV_BLOCK_ZERO))) { > > + bdrv_aio_readv(source, sector_num, &op->qiov, nb_sectors, > > + mirror_read_complete, op); > > + } else if (ret & BDRV_BLOCK_ZERO) { > > + bdrv_aio_write_zeroes(s->target, sector_num, op->nb_sectors, > > + s->unmap ? BDRV_REQ_MAY_UNMAP : 0, > > + mirror_write_complete, op); > > + } else { > > + assert(!(ret & BDRV_BLOCK_DATA)); > > + bdrv_aio_discard(s->target, sector_num, op->nb_sectors, > > + mirror_write_complete, op); > > + } > > } > > return delay_ns; > > } > > Kevin > --001a113a948e1889200520d5c7eb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Sep 28, 2015 5:31 PM, "Kevin Wolf" <kwolf@redhat.com> wrote:
>

(Responding from mobile phone again)

> Am 28.09.2015 um 05:29 hat Jeff Cody geschrieben:
> > During mirror, if the target device does not have support zero > > initialization, a mirror may result in a corrupt image.
>
> I think you want to check this sentence. ("During mirror [...], a=
> mirror may result [...]")
>

Yes, thanks.

> > For instance, on mirror to a host device with form= at =3D raw, whatever
> > random data is on the target device will still be there for unall= ocated
> > sectors.
> >
> > This is because during the mirror, we set the dirty bitmap to cop= y only
> > sectors allocated above 'base'.=C2=A0 In the case of targ= et devices where we
> > cannot assume unallocated sectors will be read as zeroes, we need= to
> > explicitely zero out this data.
> >
> > In order to avoid zeroing out all sectors of the target device pr= ior to
> > mirroring, we do zeroing as part of the block job.=C2=A0 A second= dirty
> > bitmap cache is created, to track sectors that are unallocated ab= ove
> > 'base'.=C2=A0 These sectors are then checked for status o= f BDRV_BLOCK_ZERO
> > on the target - if they are not, then zeroes are explicitly writt= en.
>
> Why do you need a bitmap? You never change the bitmap after initialisi= ng
> it, so couldn't you instead just check the allocation status when = you
> need it?

The main reason was really to maximize code reuse, and be ab= le to use the same iteration code in the mirror coroutine.

>
> In fact, why do we need two passes? I would have expected that commit<= br> > dcfb3beb already does the trick, with checking allocation status and > writing zeroes during the normal single pass.
>
> If that commit fails to solve the problem, I guess I first need to
> understand why before I can continue reviewing this one...
>

Responding from memory right now, but that commit only helps= if the guest unmaps data, changing the sectors to unallocated after the mi= rror begins.

However, before we get to this point we've already gener= ated our bitmap of dirty sectors in mirror_run(), and those are explicitly = only sectors that are allocated above the source.=C2=A0 Inside the iteratio= n, we'll only pick up the unallocated sectors if they have been changed= by the guest.

> > This only occurs under two conditions:
> >
> >=C2=A0 =C2=A0 =C2=A01. 'mode' !=3D "existing" > >=C2=A0 =C2=A0 =C2=A02. bdrv_has_zero_init(target) =3D=3D NULL
> >
> > We perform the mirroring through mirror_iteration() as before, ex= cept
> > in two passes.=C2=A0 If the above two conditions are met, the fir= st pass
> > is using the bitmap tracking unallocated sectors, to write the ne= eded
> > zeroes.=C2=A0 Then, the second pass is performed, to mirror the a= ctual data
> > as before.
> >
> > If the above two conditions are not met, then the first pass is s= kipped,
> > and only the second pass (the one with the actual data) is perfor= med.
> >
> > Signed-off-by: Jeff Cody <= jcody@redhat.com>
> > ---
> >=C2=A0 block/mirror.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 1= 09 ++++++++++++++++++++++++++++++++++------------
> >=C2=A0 blockdev.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 |=C2=A0 =C2=A02 +-
> >=C2=A0 include/block/block_int.h |=C2=A0 =C2=A03 +-
> >=C2=A0 qapi/block-core.json=C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A06 ++= -
> >=C2=A0 4 files changed, 87 insertions(+), 33 deletions(-)
> >
> > diff --git a/block/mirror.c b/block/mirror.c
> > index 405e5c4..b599176 100644
> > --- a/block/mirror.c
> > +++ b/block/mirror.c
> > @@ -50,7 +50,9 @@ typedef struct MirrorBlockJob {
> >=C2=A0 =C2=A0 =C2=A0 int64_t bdev_length;
> >=C2=A0 =C2=A0 =C2=A0 unsigned long *cow_bitmap;
> >=C2=A0 =C2=A0 =C2=A0 BdrvDirtyBitmap *dirty_bitmap;
> > -=C2=A0 =C2=A0 HBitmapIter hbi;
> > +=C2=A0 =C2=A0 HBitmapIter zero_hbi;
> > +=C2=A0 =C2=A0 HBitmapIter allocated_hbi;
> > +=C2=A0 =C2=A0 HBitmapIter *hbi;
> >=C2=A0 =C2=A0 =C2=A0 uint8_t *buf;
> >=C2=A0 =C2=A0 =C2=A0 QSIMPLEQ_HEAD(, MirrorBuffer) buf_free;
> >=C2=A0 =C2=A0 =C2=A0 int buf_free_count;
> > @@ -60,6 +62,8 @@ typedef struct MirrorBlockJob {
> >=C2=A0 =C2=A0 =C2=A0 int sectors_in_flight;
> >=C2=A0 =C2=A0 =C2=A0 int ret;
> >=C2=A0 =C2=A0 =C2=A0 bool unmap;
> > +=C2=A0 =C2=A0 bool zero_unallocated;
> > +=C2=A0 =C2=A0 bool zero_cycle;
> >=C2=A0 =C2=A0 =C2=A0 bool waiting_for_io;
> >=C2=A0 } MirrorBlockJob;
> >
> > @@ -166,10 +170,10 @@ static uint64_t coroutine_fn mirror_iterati= on(MirrorBlockJob *s)
> >=C2=A0 =C2=A0 =C2=A0 int pnum;
> >=C2=A0 =C2=A0 =C2=A0 int64_t ret;
> >
> > -=C2=A0 =C2=A0 s->sector_num =3D hbitmap_iter_next(&s->= hbi);
> > +=C2=A0 =C2=A0 s->sector_num =3D hbitmap_iter_next(s->hbi);=
> >=C2=A0 =C2=A0 =C2=A0 if (s->sector_num < 0) {
> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 bdrv_dirty_iter_init(s->dirty_bit= map, &s->hbi);
> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 s->sector_num =3D hbitmap_iter_ne= xt(&s->hbi);
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 bdrv_dirty_iter_init(s->dirty_bit= map, s->hbi);
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 s->sector_num =3D hbitmap_iter_ne= xt(s->hbi);
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 trace_mirror_restart_iter(s, bd= rv_get_dirty_count(s->dirty_bitmap));
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 assert(s->sector_num >=3D= 0);
> >=C2=A0 =C2=A0 =C2=A0 }
> > @@ -287,7 +291,7 @@ static uint64_t coroutine_fn mirror_iteration= (MirrorBlockJob *s)
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (next_sector > hbitmap_ne= xt_sector
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 && bdrv_g= et_dirty(source, s->dirty_bitmap, next_sector)) {
> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 hbitmap_next_sector = =3D hbitmap_iter_next(&s->hbi);
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 hbitmap_next_sector = =3D hbitmap_iter_next(s->hbi);
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
> >
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 next_sector +=3D sectors_per_ch= unk;
> > @@ -300,25 +304,34 @@ static uint64_t coroutine_fn mirror_iterati= on(MirrorBlockJob *s)
> >=C2=A0 =C2=A0 =C2=A0 s->sectors_in_flight +=3D nb_sectors;
> >=C2=A0 =C2=A0 =C2=A0 trace_mirror_one_iteration(s, sector_num, nb_= sectors);
> >
> > -=C2=A0 =C2=A0 ret =3D bdrv_get_block_status_above(source, NULL, = sector_num,
> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 nb_se= ctors, &pnum);
> > -=C2=A0 =C2=A0 if (ret < 0 || pnum < nb_sectors ||
> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (ret & BDRV_BLOCK_= DATA && !(ret & BDRV_BLOCK_ZERO))) {
> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 bdrv_aio_readv(source, sector_num, &= amp;op->qiov, nb_sectors,
> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0mirror_read_complete, op);
> > -=C2=A0 =C2=A0 } else if (ret & BDRV_BLOCK_ZERO) {
> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 bdrv_aio_write_zeroes(s->target, = sector_num, op->nb_sectors,
> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 s->unmap ? BDRV_REQ_MAY_UNMAP = : 0,
> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mirror_write_complete, op);
> > +=C2=A0 =C2=A0 if (s->zero_cycle) {
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret =3D bdrv_get_block_status(s->= target, sector_num, nb_sectors, &pnum);
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!(ret & BDRV_BLOCK_ZERO)) {<= br> > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 bdrv_aio_write_zeroes(= s->target, sector_num, op->nb_sectors,
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 s->unmap ? BDRV_= REQ_MAY_UNMAP : 0,
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mirror_write_comple= te, op);
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
>
> It seems to be expected that this function always involves an AIO
> request and the completion event is what helps making progress. For th= e
> BDRV_BLOCK_ZERO case, we don't do that however. I'm not sure w= hat
> exactly this means, but at least I think we are applying block job
> throttling to doing nothing with some areas of the image.
>
> >=C2=A0 =C2=A0 =C2=A0 } else {
> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert(!(ret & BDRV_BLOCK_DATA))= ;
> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 bdrv_aio_discard(s->target, secto= r_num, op->nb_sectors,
> > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0mirror_write_complete, op);
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret =3D bdrv_get_block_status_above(= source, NULL, sector_num,
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 nb_sectors, &pnum);
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (ret < 0 || pnum < nb_secto= rs ||
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (ret &am= p; BDRV_BLOCK_DATA && !(ret & BDRV_BLOCK_ZERO))) {
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 bdrv_aio_readv(source,= sector_num, &op->qiov, nb_sectors,
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0mirror_read_complete, op);
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 } else if (ret & BDRV_BLOCK_ZERO= ) {
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 bdrv_aio_write_zeroes(= s->target, sector_num, op->nb_sectors,
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 s->unmap ? BDRV_= REQ_MAY_UNMAP : 0,
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mirror_write_comple= te, op);
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 } else {
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 assert(!(ret & BDR= V_BLOCK_DATA));
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 bdrv_aio_discard(s->= ;target, sector_num, op->nb_sectors,
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0mirror_write_complete, op);
> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
> >=C2=A0 =C2=A0 =C2=A0 }
> >=C2=A0 =C2=A0 =C2=A0 return delay_ns;
> >=C2=A0 }
>
> Kevin
>

--001a113a948e1889200520d5c7eb-- From MAILER-DAEMON Tue Sep 29 09:56:04 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZgvO0-0002gp-9Q for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 09:56:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZggRc-0001t6-Sd for qemu-block@nongnu.org; Mon, 28 Sep 2015 17:58:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZggRb-0006rL-Js for qemu-block@nongnu.org; Mon, 28 Sep 2015 17:58:48 -0400 Received: from mail-qk0-x22b.google.com ([2607:f8b0:400d:c09::22b]:33194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZggRZ-0006qB-0H; Mon, 28 Sep 2015 17:58:45 -0400 Received: by qkas79 with SMTP id s79so9359668qka.0; Mon, 28 Sep 2015 14:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=FlEm+L7EAMcVeBrmwD+jKVcXhLUdftlCAtrnvnA2sio=; b=v8WJTno3B/PDw5omOPb+CiHG5VnQkK6NiY9OUTUzX9byzS5ITlOqlokfs94mgN+faj 0Za/mCxW0ixHEv8XkDr+aMzos+J6OUO5ILwoNGGjiDkTKdMeef6izeFTF+AhHSH9MD8F xgIxv8owHdE13bo1Bcge+Z+225Xzv0avDf3kJ+pTZnT4nen/byleO1q1og9rcvMg8N9j Mc4jnJq8E/l7o9wXXNKIw9qlopQBYh9a4wuQFCvV6w4yaXtPvCRC3n9+qnojfuFqFpSI QvuOMD37vMQ9gjR5zrTbdU1N8t0r6aFrpxOlHUyFNmedTPR4O6VWu3ZCK8idoveW2po1 bYKA== MIME-Version: 1.0 X-Received: by 10.55.192.145 with SMTP id v17mr25081523qkv.80.1443477524655; Mon, 28 Sep 2015 14:58:44 -0700 (PDT) Received: by 10.55.3.16 with HTTP; Mon, 28 Sep 2015 14:58:44 -0700 (PDT) Received: by 10.55.3.16 with HTTP; Mon, 28 Sep 2015 14:58:44 -0700 (PDT) In-Reply-To: <20150928151058.GD18068@noname.str.redhat.com> References: <20150928151058.GD18068@noname.str.redhat.com> Date: Mon, 28 Sep 2015 17:58:44 -0400 Message-ID: From: Jeff Cody To: Kevin Wolf Content-Type: multipart/alternative; boundary=001a1149a1c2193aec0520d5cdee X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c09::22b Cc: stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 3/3] block: mirror - zero unallocated target sectors when zero init not present X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 21:58:50 -0000 --001a1149a1c2193aec0520d5cdee Content-Type: text/plain; charset=UTF-8 On Sep 28, 2015 5:34 PM, "Kevin Wolf" wrote: > > Am 28.09.2015 um 05:29 hat Jeff Cody geschrieben: > > During mirror, if the target device does not have support zero > > initialization, a mirror may result in a corrupt image. > > > > For instance, on mirror to a host device with format = raw, whatever > > random data is on the target device will still be there for unallocated > > sectors. > > > > This is because during the mirror, we set the dirty bitmap to copy only > > sectors allocated above 'base'. In the case of target devices where we > > cannot assume unallocated sectors will be read as zeroes, we need to > > explicitely zero out this data. > > > > In order to avoid zeroing out all sectors of the target device prior to > > mirroring, we do zeroing as part of the block job. A second dirty > > bitmap cache is created, to track sectors that are unallocated above > > 'base'. These sectors are then checked for status of BDRV_BLOCK_ZERO > > on the target - if they are not, then zeroes are explicitly written. > > > > This only occurs under two conditions: > > > > 1. 'mode' != "existing" > > 2. bdrv_has_zero_init(target) == NULL > > > > We perform the mirroring through mirror_iteration() as before, except > > in two passes. If the above two conditions are met, the first pass > > is using the bitmap tracking unallocated sectors, to write the needed > > zeroes. Then, the second pass is performed, to mirror the actual data > > as before. > > > > If the above two conditions are not met, then the first pass is skipped, > > and only the second pass (the one with the actual data) is performed. > > > > Signed-off-by: Jeff Cody > > Also, this makes qemu-iotests 097 fail for me. > OK, thanks - I'll check that out tomorrow afternoon. I ran iotests on all the tests I thought dealt with mirror, but I must have missed that one with my grep. Jeff --001a1149a1c2193aec0520d5cdee Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Sep 28, 2015 5:34 PM, "Kevin Wolf" <kwolf@redhat.com> wrote:
>
> Am 28.09.2015 um 05:29 hat Jeff Cody geschrieben:
> > During mirror, if the target device does not have support zero > > initialization, a mirror may result in a corrupt image.
> >
> > For instance, on mirror to a host device with format =3D raw, wha= tever
> > random data is on the target device will still be there for unall= ocated
> > sectors.
> >
> > This is because during the mirror, we set the dirty bitmap to cop= y only
> > sectors allocated above 'base'.=C2=A0 In the case of targ= et devices where we
> > cannot assume unallocated sectors will be read as zeroes, we need= to
> > explicitely zero out this data.
> >
> > In order to avoid zeroing out all sectors of the target device pr= ior to
> > mirroring, we do zeroing as part of the block job.=C2=A0 A second= dirty
> > bitmap cache is created, to track sectors that are unallocated ab= ove
> > 'base'.=C2=A0 These sectors are then checked for status o= f BDRV_BLOCK_ZERO
> > on the target - if they are not, then zeroes are explicitly writt= en.
> >
> > This only occurs under two conditions:
> >
> >=C2=A0 =C2=A0 =C2=A01. 'mode' !=3D "existing" > >=C2=A0 =C2=A0 =C2=A02. bdrv_has_zero_init(target) =3D=3D NULL
> >
> > We perform the mirroring through mirror_iteration() as before, ex= cept
> > in two passes.=C2=A0 If the above two conditions are met, the fir= st pass
> > is using the bitmap tracking unallocated sectors, to write the ne= eded
> > zeroes.=C2=A0 Then, the second pass is performed, to mirror the a= ctual data
> > as before.
> >
> > If the above two conditions are not met, then the first pass is s= kipped,
> > and only the second pass (the one with the actual data) is perfor= med.
> >
> > Signed-off-by: Jeff Cody <= jcody@redhat.com>
>
> Also, this makes qemu-iotests 097 fail for me.
>

OK, thanks - I'll check that out tomorrow afternoon.=C2= =A0 I ran iotests on all the tests I thought dealt with mirror, but I must = have missed that one with my grep.

Jeff

--001a1149a1c2193aec0520d5cdee-- From MAILER-DAEMON Tue Sep 29 15:45:42 2015 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zh0qM-0000v3-7R for mharc-qemu-block@gnu.org; Tue, 29 Sep 2015 15:45:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgkyW-0004fz-IL for qemu-block@nongnu.org; Mon, 28 Sep 2015 22:49:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zgkxi-0003xS-Uz for qemu-block@nongnu.org; Mon, 28 Sep 2015 22:48:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37922) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgkxi-0003wj-Kz; Mon, 28 Sep 2015 22:48:14 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 7AEB1341AC4; Tue, 29 Sep 2015 02:48:13 +0000 (UTC) Received: from [10.3.113.188] (ovpn-113-188.phx2.redhat.com [10.3.113.188]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8T2mCwA010870; Mon, 28 Sep 2015 22:48:12 -0400 To: Jeff Cody , Paolo Bonzini References: <56094B0F.7030900@redhat.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: <5609FBE7.1070705@redhat.com> Date: Mon, 28 Sep 2015 20:48:07 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="R2MWIT8pbfdvO7TJ0torjXfuDADoBd2Ja" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 3/3] block: mirror - zero unallocated target sectors when zero init not present X-BeenThere: qemu-block@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Sep 2015 02:49:08 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --R2MWIT8pbfdvO7TJ0torjXfuDADoBd2Ja Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/28/2015 03:32 PM, Jeff Cody wrote: > I guess that makes sense. What about the case when the target is a ra= w > device without zero init? There is no backing file... Of course, perha= ps > in the raw case the user should be using sync=3D=3Dfull anyways. >=20 >> >> 2) even with mode =3D=3D "existing" you expect the data to be consiste= nt at >> the end of the mirroring >> >=20 > The reason I added the "existing" exception was so the user could avoid= the > time penalty of zeroing out the data if they knew the target had alread= y > explicitly been zeroed. Do you think it is fair to assume that if the = user > specified existing, that they take responsibility for setting up the ta= rget > image how they like (including data initialization)? Or should we add > another option for mirror, to allow the user to bypass the zero fill? mode =3D=3D 'existing' puts the burden on the caller to ensure that the f= ile they are passing in starts with known contents (either contents don't matter because we are doing sync =3D=3D 'full' to write every sector, or contents MUST initially match what the guest would see looking at the backing image when doing a shallow clone). But if there is a way for a user to pass in an existing file which they have pre-zeroed, even though the file would normally be treated as though it did not have zero fill, then the option to bypass a redundant zero fill might be useful. I'm not sure it's worth implementing without a known user, though, and I don't know that libvirt would use it. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --R2MWIT8pbfdvO7TJ0torjXfuDADoBd2Ja Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWCfvnAAoJEKeha0olJ0NqrncIAIanem7hF2kli6BziwiH4PAB MTBJdWi9tyI51fYKxvacn1pRTLHTMCbZDDJj1xcF+CDv0LiQItVVgYoChYs9NCRb 0ocOEFafzttJN/jIb9CMJs2G0zS5sLb1S6Nh60EvoIaU4LdZRJU6FMJXqxzIlVKy Kxeq+BRNpvW7+tyy9hNQQsr9DOjjyJIkcwq7hweryYlf0CVI2Kp9u9wFtdsWaoDs E6Tqx4hZJR3aMfLSwvNYMtuWfwAKURQytZjCitvhNoTjNTPacxxSO32nt8gJn7cn NcA5aWJ5dK6Iw/2XHKbRyCCI65nQbB85ujJfsXxVZvh0YCV/nYjA1NdCMDNottE= =qth3 -----END PGP SIGNATURE----- --R2MWIT8pbfdvO7TJ0torjXfuDADoBd2Ja--