Re: [Qemu-block] [PATCH v3 02/13] qemu-nbd: Switch to qemu_set_fd_handler

2015-05-19 Thread Amit Shah
On (Tue) 19 May 2015 [11:32:56], Amit Shah wrote: On (Tue) 19 May 2015 [10:50:59], Fam Zheng wrote: Achieved by: - Remembering the server fd with a global variable, in order to access it from nbd_client_closed. - Checking nbd_can_accept() and updating server_fd handler whenever

Re: [Qemu-block] [PATCH v4 13/13] block/mirror: Block device IO during mirror exit

2015-05-19 Thread Paolo Bonzini
On 19/05/2015 13:49, Fam Zheng wrote: When block job mirror is finished, the source and target is synced. But we call bdrv_swap() later in main loop bh. If the guest write before that, target will not get the new data. This is too late. As a rule, the blocker must be established before

Re: [Qemu-block] [PATCH v3 02/13] qemu-nbd: Switch to qemu_set_fd_handler

2015-05-19 Thread Amit Shah
On (Tue) 19 May 2015 [10:50:59], Fam Zheng wrote: Achieved by: - Remembering the server fd with a global variable, in order to access it from nbd_client_closed. - Checking nbd_can_accept() and updating server_fd handler whenever client connects or disconnects. Signed-off-by: Fam

Re: [Qemu-block] [PATCH v4 13/13] block/mirror: Block device IO during mirror exit

2015-05-19 Thread Fam Zheng
On Tue, 05/19 10:04, Paolo Bonzini wrote: On 19/05/2015 13:49, Fam Zheng wrote: When block job mirror is finished, the source and target is synced. But we call bdrv_swap() later in main loop bh. If the guest write before that, target will not get the new data. This is too late. As a

Re: [Qemu-block] [PATCH v4 13/13] block/mirror: Block device IO during mirror exit

2015-05-19 Thread Paolo Bonzini
On 19/05/2015 18:48, Fam Zheng wrote: This is too late. As a rule, the blocker must be established before calling bdrv_drain, and removed on the next yield (in this case, before the assignment to last_pause_ns). I don't understand. If the blocker is removed before mirror_run returns,

Re: [Qemu-block] [Qemu-devel] [PATCH v4 13/13] block/mirror: Block device IO during mirror exit

2015-05-19 Thread Paolo Bonzini
On 19/05/2015 20:37, Fam Zheng wrote: On Tue, 05/19 10:49, Paolo Bonzini wrote: On 19/05/2015 18:48, Fam Zheng wrote: This is too late. As a rule, the blocker must be established before calling bdrv_drain, and removed on the next yield (in this case, before the assignment to

Re: [Qemu-block] [PATCH] block/mirror: Sleep periodically during bitmap scanning

2015-05-19 Thread Stefan Hajnoczi
On Wed, May 13, 2015 at 11:11:13AM +0800, Fam Zheng wrote: Before, we only yield after initializing dirty bitmap, where the QMP command would return. That may take very long, and guest IO will be blocked. Add sleep points like the later mirror iterations. Signed-off-by: Fam Zheng

Re: [Qemu-block] [Qemu-devel] [PATCH v4 13/13] block/mirror: Block device IO during mirror exit

2015-05-19 Thread Fam Zheng
On Tue, 05/19 10:49, Paolo Bonzini wrote: On 19/05/2015 18:48, Fam Zheng wrote: This is too late. As a rule, the blocker must be established before calling bdrv_drain, and removed on the next yield (in this case, before the assignment to last_pause_ns). I don't understand. If

Re: [Qemu-block] [PATCH v3 00/13] main-loop: Get rid of fd_read_poll and qemu_set_fd_handler2

2015-05-19 Thread Fam Zheng
On Tue, 05/19 16:02, Stefan Hajnoczi wrote: On Tue, May 19, 2015 at 10:50:57AM +, Fam Zheng wrote: v3: Replace previous 13 with a simple return type conversion patch. Drop RFC. This carries out the mandate in the comment of qemu_set_fd_handler2 and removes fd_read_poll from

Re: [Qemu-block] [Qemu-devel] [PATCH v4 13/13] block/mirror: Block device IO during mirror exit

2015-05-19 Thread Fam Zheng
On Tue, 05/19 12:57, Paolo Bonzini wrote: On 19/05/2015 20:37, Fam Zheng wrote: On Tue, 05/19 10:49, Paolo Bonzini wrote: On 19/05/2015 18:48, Fam Zheng wrote: This is too late. As a rule, the blocker must be established before calling bdrv_drain, and removed on the next yield

[Qemu-block] [PATCH v8 0/8] Block Throttle Group Support

2015-05-19 Thread Alberto Garcia
The previous series no longer applies after all the code that was moved to block/io.c in 61007b316c, so I rebased it. Other than that there are no changes. V8: - Rebased against the current master. V7: https://lists.gnu.org/archive/html/qemu-devel/2015-04/msg01196.html - Make

Re: [Qemu-block] [Qemu-devel] [PATCH RFC for-2.3? 5/8] fdb: Move FDCtrlISABus to header

2015-05-19 Thread Andreas Färber
Am 31.03.2015 um 03:38 schrieb John Snow: You probably meant 'fdc' ! On 03/29/2015 01:53 PM, Andreas Färber wrote: To be used for embedding the device. Add gtk-doc private/public markers for parent field. Signed-off-by: Andreas Färber afaer...@suse.de --- hw/block/fdc.c | 87

[Qemu-block] [PATCH 1/8] throttle: Extract timers from ThrottleState into a separate structure

2015-05-19 Thread Alberto Garcia
From: Benoît Canet benoit.ca...@nodalink.com Group throttling will share ThrottleState between multiple bs. As a consequence the ThrottleState will be accessed by multiple aio context. Timers are tied to their aio context so they must go out of the ThrottleState structure. This commit paves the

[Qemu-block] [PATCH 4/8] throttle: Add throttle group support

2015-05-19 Thread Alberto Garcia
The throttle group support use a cooperative round robin scheduling algorithm. The principles of the algorithm are simple: - Each BDS of the group is used as a token in a circular way. - The active BDS computes if a wait must be done and arms the right timer. - If a wait must be done the token

[Qemu-block] [PATCH 3/8] throttle: Add throttle group infrastructure tests

2015-05-19 Thread Alberto Garcia
Signed-off-by: Alberto Garcia be...@igalia.com Reviewed-by: Stefan Hajnoczi stefa...@redhat.com --- tests/test-throttle.c | 79 --- 1 file changed, 69 insertions(+), 10 deletions(-) diff --git a/tests/test-throttle.c b/tests/test-throttle.c index

[Qemu-block] [PATCH 8/8] qemu-iotests: expand test 093 to support group throttling

2015-05-19 Thread Alberto Garcia
This patch improves the test by attaching a different number of drives to the VM and putting them in the same throttling group. The test verifies that the I/O is evenly distributed among all members of the group, and that the limits are enforced. By default the test is repeated 3 times with 1, 2

Re: [Qemu-block] [Qemu-devel] [PATCH v2 4/4] tests: Use qtest_add_data_func() consistently

2015-05-19 Thread Andreas Färber
Am 27.03.2015 um 19:46 schrieb John Snow: On 03/26/2015 11:41 AM, Andreas Färber wrote: Am 25.03.2015 um 23:14 schrieb John Snow: On 03/25/2015 02:20 PM, Andreas Färber wrote: Replace uses of g_test_add_data_func() for QTest test cases. It is still valid to use it for any non-QTest test

Re: [Qemu-block] [Qemu-devel] [PATCH v3 04/13] netmap: Drop netmap_can_send

2015-05-19 Thread Stefan Hajnoczi
On Tue, May 19, 2015 at 10:51:01AM +, Fam Zheng wrote: This callback is called by main loop before polling s-fd, if it returns false, the fd will not be polled in this iteration. This is redundant with checks inside read callback. After this patch, the data will be copied from s-fd to

Re: [Qemu-block] [PATCH v4 11/11] qmp-commands.hx: Update the supported 'transaction' operations

2015-05-19 Thread Kashyap Chamarthy
On Mon, May 18, 2015 at 06:22:22PM +0200, Max Reitz wrote: On 12.05.2015 01:04, John Snow wrote: From: Kashyap Chamarthy kcham...@redhat.com Although the canonical source of reference for QMP commands is qapi-schema.json, for consistency's sake, update qmp-commands.hx to state the list of

Re: [Qemu-block] [PATCH v3 02/13] qemu-nbd: Switch to qemu_set_fd_handler

2015-05-19 Thread Stefan Hajnoczi
On Tue, May 19, 2015 at 10:50:59AM +, Fam Zheng wrote: Achieved by: - Remembering the server fd with a global variable, in order to access it from nbd_client_closed. - Checking nbd_can_accept() and updating server_fd handler whenever client connects or disconnects.

[Qemu-block] [PATCH 5/8] fdc: Code cleanup in fdctrl_write_data()

2015-05-19 Thread Kevin Wolf
Factor out a few common lines of code, reformat, improve comments. Signed-off-by: Kevin Wolf kw...@redhat.com --- hw/block/fdc.c | 62 +++--- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index

[Qemu-block] [PATCH 2/8] fdc: Rename fdctrl_set_fifo() to fdctrl_to_result_phase()

2015-05-19 Thread Kevin Wolf
What callers really do with this function is to switch from execution phase (including data transfers) to result phase where the guest can read out one or more status bytes from the FIFO (the number depends on the command). Rename the function accordingly. Signed-off-by: Kevin Wolf

[Qemu-block] [PATCH 6/8] fdc: Disentangle phases in fdctrl_read_data()

2015-05-19 Thread Kevin Wolf
This commit makes similar improvements as have already been made to the write function: Instead of relying on a flag in the MSR to distinguish controller phases, use the explicit phase that we store now. Assertions of the right MSR flags are added. Signed-off-by: Kevin Wolf kw...@redhat.com ---

[Qemu-block] [PATCH 0/8] fdc: Clean up and fix command processing

2015-05-19 Thread Kevin Wolf
This series fixes the real bug that caused CVE-2015-3456, and does some cleanup in the FIFO access functions to make the command processing more obvious. Kevin Wolf (8): fdc: Rename fdctrl_reset_fifo() to fdctrl_to_command_phase() fdc: Rename fdctrl_set_fifo() to fdctrl_to_result_phase()

[Qemu-block] [PATCH 4/8] fdc: Use phase in fdctrl_write_data()

2015-05-19 Thread Kevin Wolf
Instead of relying on a flag in the MSR to distinguish controller phases, use the explicit phase that we store now. Assertions of the right MSR flags are added. Signed-off-by: Kevin Wolf kw...@redhat.com --- hw/block/fdc.c | 67 ++ 1 file

[Qemu-block] [PATCH 7/8] fdc: Fix MSR.RQM flag

2015-05-19 Thread Kevin Wolf
The RQM bit in MSR should be set whenever the guest is supposed to access the FIFO, and it should be cleared in all other cases. This is important so the guest can't continue writing/reading the FIFO beyond the length that it's suppossed to access (see CVE-2015-3456). Commit e9077462 fixed the

[Qemu-block] [PATCH 8/8] fdc-test: Test state for existing cases more thoroughly

2015-05-19 Thread Kevin Wolf
This just adds a few additional checks of the MSR and interrupt pin to the already existing test cases. Signed-off-by: Kevin Wolf kw...@redhat.com --- tests/fdc-test.c | 34 ++ 1 file changed, 34 insertions(+) diff --git a/tests/fdc-test.c b/tests/fdc-test.c

Re: [Qemu-block] [PATCH v3 03/13] l2tpv3: Drop l2tpv3_can_send

2015-05-19 Thread Stefan Hajnoczi
On Tue, May 19, 2015 at 10:51:00AM +, Fam Zheng wrote: This callback is called by main loop before polling s-fd, if it returns false, the fd will not be polled in this iteration. This is redundant with checks inside read callback. After this patch, the data will be copied from s-fd to

[Qemu-block] [PATCH 2/8] throttle: Add throttle group infrastructure

2015-05-19 Thread Alberto Garcia
Signed-off-by: Alberto Garcia be...@igalia.com Reviewed-by: Stefan Hajnoczi stefa...@redhat.com --- block/Makefile.objs | 1 + block/throttle-groups.c | 261 include/block/block_int.h | 1 + include/block/throttle-groups.h |

[Qemu-block] [PATCH 6/8] throttle: add the name of the ThrottleGroup to BlockDeviceInfo

2015-05-19 Thread Alberto Garcia
Signed-off-by: Alberto Garcia be...@igalia.com --- block/qapi.c | 3 +++ hmp.c| 6 -- qapi/block-core.json | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index a5ac312..a738148 100644 --- a/block/qapi.c +++

[Qemu-block] [PATCH 5/8] throttle: acquire the ThrottleGroup lock in bdrv_swap()

2015-05-19 Thread Alberto Garcia
bdrv_swap() touches the fields of a BlockDriverState that are protected by the ThrottleGroup lock. Although those fields end up in their original place, they are temporarily swapped in the process, so there's a chance that an operation on a member of the same group happening on a different thread

Re: [Qemu-block] [Qemu-devel] [PATCH 3/8] fdc: Introduce fdctrl-phase

2015-05-19 Thread Peter Maydell
On 19 May 2015 at 21:52, John Snow js...@redhat.com wrote: Hmm, I think this is not purely derived state because the flags are not necessarily sufficient for regenerating that state. Yeah, if there's genuinely an underlying state machine that's not completely visible in registers you need to

Re: [Qemu-block] [Qemu-devel] [PATCH v4 06/11] block: add refcount to Job object

2015-05-19 Thread John Snow
On 05/18/2015 11:45 AM, Stefan Hajnoczi wrote: On Mon, May 11, 2015 at 07:04:21PM -0400, John Snow wrote: If we want to get at the job after the life of the job, we'll need a refcount for this object. This may occur for example if we wish to inspect the actions taken by a particular job

Re: [Qemu-block] [Qemu-devel] [PATCH 2/8] fdc: Rename fdctrl_set_fifo() to fdctrl_to_result_phase()

2015-05-19 Thread John Snow
On 05/19/2015 11:35 AM, Kevin Wolf wrote: What callers really do with this function is to switch from execution phase (including data transfers) to result phase where the guest can read out one or more status bytes from the FIFO (the number depends on the command). Rename the function

Re: [Qemu-block] [Qemu-devel] [PATCH 3/8] fdc: Introduce fdctrl-phase

2015-05-19 Thread John Snow
On 05/19/2015 11:35 AM, Kevin Wolf wrote: The floppy controller spec describes three different controller phases, which are currently not explicitly modelled in our emulation. Instead, each phase is represented by a combination of flags in registers. This patch makes explicit in which

Re: [Qemu-block] [Qemu-devel] [PATCH 3/8] fdc: Introduce fdctrl-phase

2015-05-19 Thread Peter Maydell
On 19 May 2015 at 16:35, Kevin Wolf kw...@redhat.com wrote: The floppy controller spec describes three different controller phases, which are currently not explicitly modelled in our emulation. Instead, each phase is represented by a combination of flags in registers. This patch makes

Re: [Qemu-block] [Qemu-devel] [PATCH 4/8] fdc: Use phase in fdctrl_write_data()

2015-05-19 Thread Peter Maydell
On 19 May 2015 at 16:35, Kevin Wolf kw...@redhat.com wrote: Instead of relying on a flag in the MSR to distinguish controller phases, use the explicit phase that we store now. Assertions of the right MSR flags are added. Signed-off-by: Kevin Wolf kw...@redhat.com --- hw/block/fdc.c | 67

Re: [Qemu-block] [Qemu-devel] [PATCH 1/8] fdc: Rename fdctrl_reset_fifo() to fdctrl_to_command_phase()

2015-05-19 Thread John Snow
On 05/19/2015 11:35 AM, Kevin Wolf wrote: What all callers of fdctrl_reset_fifo() really want to do is to start the command phase, where writes to the data port initiate a new command. The function doesn't only clear the FIFO, but also sets up the state so that a new command can be

Re: [Qemu-block] [Qemu-devel] [PATCH 7/8] fdc: Fix MSR.RQM flag

2015-05-19 Thread John Snow
On 05/19/2015 11:36 AM, Kevin Wolf wrote: The RQM bit in MSR should be set whenever the guest is supposed to access the FIFO, and it should be cleared in all other cases. This is important so the guest can't continue writing/reading the FIFO beyond the length that it's suppossed to access

Re: [Qemu-block] [Qemu-devel] [PATCH 5/8] fdc: Code cleanup in fdctrl_write_data()

2015-05-19 Thread John Snow
On 05/19/2015 11:35 AM, Kevin Wolf wrote: Factor out a few common lines of code, reformat, improve comments. Signed-off-by: Kevin Wolf kw...@redhat.com --- hw/block/fdc.c | 62 +++--- 1 file changed, 38 insertions(+), 24 deletions(-)

Re: [Qemu-block] [Qemu-devel] [PATCH 4/8] fdc: Use phase in fdctrl_write_data()

2015-05-19 Thread John Snow
On 05/19/2015 11:35 AM, Kevin Wolf wrote: Instead of relying on a flag in the MSR to distinguish controller phases, use the explicit phase that we store now. Assertions of the right MSR flags are added. Signed-off-by: Kevin Wolf kw...@redhat.com --- hw/block/fdc.c | 67

Re: [Qemu-block] [Qemu-devel] [PATCH 6/8] fdc: Disentangle phases in fdctrl_read_data()

2015-05-19 Thread John Snow
On 05/19/2015 11:36 AM, Kevin Wolf wrote: This commit makes similar improvements as have already been made to the write function: Instead of relying on a flag in the MSR to distinguish controller phases, use the explicit phase that we store now. Assertions of the right MSR flags are added.