<feed xmlns='http://www.w3.org/2005/Atom'>
<title>bwlp/qemu.git/block/throttle-groups.c, branch spice_video_codecs</title>
<subtitle>Experimental fork of QEMU with video encoding patches</subtitle>
<id>https://git.openslx.org/bwlp/qemu.git/atom/block/throttle-groups.c?h=spice_video_codecs</id>
<link rel='self' href='https://git.openslx.org/bwlp/qemu.git/atom/block/throttle-groups.c?h=spice_video_codecs'/>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/'/>
<updated>2021-02-03T14:14:00+00:00</updated>
<entry>
<title>block/throttle-groups: throttle_group_co_io_limits_intercept(): 64bit bytes</title>
<updated>2021-02-03T14:14:00+00:00</updated>
<author>
<name>Vladimir Sementsov-Ogievskiy</name>
</author>
<published>2020-12-11T18:39:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=801625e69d947b0f9291d77bb1deb7545525c66d'/>
<id>urn:sha1:801625e69d947b0f9291d77bb1deb7545525c66d</id>
<content type='text'>
The function is called from 64bit io handlers, and bytes is just passed
to throttle_account() which is 64bit too (unsigned though). So, let's
convert intermediate argument to 64bit too.

This patch is a first in the 64-bit-blocklayer series, so we are
generally moving to int64_t for both offset and bytes parameters on all
io paths. Main motivation is realization of 64-bit write_zeroes
operation for fast zeroing large disk chunks, up to the whole disk.

We chose signed type, to be consistent with off_t (which is signed) and
with possibility for signed return type (where negative value means
error).

Patch-correctness audit by Eric Blake:

  Caller has 32-bit, this patch now causes widening which is safe:
  block/block-backend.c: blk_do_preadv() passes 'unsigned int'
  block/block-backend.c: blk_do_pwritev_part() passes 'unsigned int'
  block/throttle.c: throttle_co_pwrite_zeroes() passes 'int'
  block/throttle.c: throttle_co_pdiscard() passes 'int'

  Caller has 64-bit, this patch fixes potential bug where pre-patch
  could narrow, except it's easy enough to trace that callers are still
  capped at 2G actions:
  block/throttle.c: throttle_co_preadv() passes 'uint64_t'
  block/throttle.c: throttle_co_pwritev() passes 'uint64_t'

  Implementation in question: block/throttle-groups.c
  throttle_group_co_io_limits_intercept() takes 'unsigned int bytes'
  and uses it: argument to util/throttle.c throttle_account(uint64_t)

  All safe: it patches a latent bug, and does not introduce any 64-bit
  gotchas once throttle_co_p{read,write}v are relaxed, and assuming
  throttle_account() is not buggy.

Signed-off-by: Vladimir Sementsov-Ogievskiy &lt;vsementsov@virtuozzo.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
Reviewed-by: Alberto Garcia &lt;berto@igalia.com&gt;
Message-Id: &lt;20201211183934.169161-7-vsementsov@virtuozzo.com&gt;
Signed-off-by: Eric Blake &lt;eblake@redhat.com&gt;
</content>
</entry>
<entry>
<title>block/throttle-groups: Use lock guard macros</title>
<updated>2020-12-11T16:52:39+00:00</updated>
<author>
<name>Gan Qixin</name>
</author>
<published>2020-12-03T07:50:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=3af613ebdb32453469018e5431452ce9a53ea69c'/>
<id>urn:sha1:3af613ebdb32453469018e5431452ce9a53ea69c</id>
<content type='text'>
Replace manual lock()/unlock() calls with lock guard macros
(QEMU_LOCK_GUARD/WITH_QEMU_LOCK_GUARD) in block/throttle-groups.

Signed-off-by: Gan Qixin &lt;ganqixin@huawei.com&gt;
Message-Id: &lt;20201203075055.127773-4-ganqixin@huawei.com&gt;
Signed-off-by: Kevin Wolf &lt;kwolf@redhat.com&gt;
</content>
</entry>
<entry>
<title>qemu/atomic.h: rename atomic_ to qatomic_</title>
<updated>2020-09-23T15:07:44+00:00</updated>
<author>
<name>Stefan Hajnoczi</name>
</author>
<published>2020-09-23T10:56:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=d73415a315471ac0b127ed3fad45c8ec5d711de1'/>
<id>urn:sha1:d73415a315471ac0b127ed3fad45c8ec5d711de1</id>
<content type='text'>
clang's C11 atomic_fetch_*() functions only take a C11 atomic type
pointer argument. QEMU uses direct types (int, etc) and this causes a
compiler error when a QEMU code calls these functions in a source file
that also included &lt;stdatomic.h&gt; via a system header file:

  $ CC=clang CXX=clang++ ./configure ... &amp;&amp; make
  ../util/async.c:79:17: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid)

Avoid using atomic_*() names in QEMU's atomic.h since that namespace is
used by &lt;stdatomic.h&gt;. Prefix QEMU's APIs with 'q' so that atomic.h
and &lt;stdatomic.h&gt; can co-exist. I checked /usr/include on my machine and
searched GitHub for existing "qatomic_" users but there seem to be none.

This patch was generated using:

  $ git grep -h -o '\&lt;atomic\(64\)\?_[a-z0-9_]\+' include/qemu/atomic.h | \
    sort -u &gt;/tmp/changed_identifiers
  $ for identifier in $(&lt;/tmp/changed_identifiers); do
        sed -i "s%\&lt;$identifier\&gt;%q$identifier%g" \
            $(git grep -I -l "\&lt;$identifier\&gt;")
    done

I manually fixed line-wrap issues and misaligned rST tables.

Signed-off-by: Stefan Hajnoczi &lt;stefanha@redhat.com&gt;
Reviewed-by: Philippe Mathieu-Daudé &lt;philmd@redhat.com&gt;
Acked-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Message-Id: &lt;20200923105646.47864-1-stefanha@redhat.com&gt;
</content>
</entry>
<entry>
<title>throttle-groups: Move ThrottleGroup typedef to header</title>
<updated>2020-08-27T18:04:54+00:00</updated>
<author>
<name>Eduardo Habkost</name>
</author>
<published>2020-08-25T19:20:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=7c9dcd6cabfa96ea2a89dd12041f3e63aa20a09c'/>
<id>urn:sha1:7c9dcd6cabfa96ea2a89dd12041f3e63aa20a09c</id>
<content type='text'>
Move typedef closer to the type check macros, to make it easier
to convert the code to OBJECT_DEFINE_TYPE() in the future.

Reviewed-by: Philippe Mathieu-Daudé &lt;f4bug@amsat.org&gt;
Reviewed-by: Daniel P. Berrangé &lt;berrange@redhat.com&gt;
Signed-off-by: Eduardo Habkost &lt;ehabkost@redhat.com&gt;
Tested-By: Roman Bolshakov &lt;r.bolshakov@yadro.com&gt;
Message-Id: &lt;20200825192110.3528606-17-ehabkost@redhat.com&gt;
Signed-off-by: Eduardo Habkost &lt;ehabkost@redhat.com&gt;
</content>
</entry>
<entry>
<title>qom: Change object_get_canonical_path_component() not to malloc</title>
<updated>2020-07-21T14:23:43+00:00</updated>
<author>
<name>Markus Armbruster</name>
</author>
<published>2020-07-14T16:02:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=7a309cc95b862be74711e7a35997daa3f885651a'/>
<id>urn:sha1:7a309cc95b862be74711e7a35997daa3f885651a</id>
<content type='text'>
object_get_canonical_path_component() returns a malloced copy of a
property name on success, null on failure.

19 of its 25 callers immediately free the returned copy.

Change object_get_canonical_path_component() to return the property
name directly.  Since modifying the name would be wrong, adjust the
return type to const char *.

Drop the free from the 19 callers become simpler, add the g_strdup()
to the other six.

Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Message-Id: &lt;20200714160202.3121879-4-armbru@redhat.com&gt;
Reviewed-by: Philippe Mathieu-Daudé &lt;philmd@redhat.com&gt;
Reviewed-by: Li Qiang &lt;liq3ea@gmail.com&gt;
</content>
</entry>
<entry>
<title>error: Eliminate error_propagate() with Coccinelle, part 1</title>
<updated>2020-07-10T13:18:08+00:00</updated>
<author>
<name>Markus Armbruster</name>
</author>
<published>2020-07-07T16:06:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=668f62ec621e4e2919fb7d4caa5d805764c5852d'/>
<id>urn:sha1:668f62ec621e4e2919fb7d4caa5d805764c5852d</id>
<content type='text'>
When all we do with an Error we receive into a local variable is
propagating to somewhere else, we can just as well receive it there
right away.  Convert

    if (!foo(..., &amp;err)) {
        ...
        error_propagate(errp, err);
        ...
        return ...
    }

to

    if (!foo(..., errp)) {
        ...
        ...
        return ...
    }

where nothing else needs @err.  Coccinelle script:

    @rule1 forall@
    identifier fun, err, errp, lbl;
    expression list args, args2;
    binary operator op;
    constant c1, c2;
    symbol false;
    @@
         if (
    (
    -        fun(args, &amp;err, args2)
    +        fun(args, errp, args2)
    |
    -        !fun(args, &amp;err, args2)
    +        !fun(args, errp, args2)
    |
    -        fun(args, &amp;err, args2) op c1
    +        fun(args, errp, args2) op c1
    )
            )
         {
             ... when != err
                 when != lbl:
                 when strict
    -        error_propagate(errp, err);
             ... when != err
    (
             return;
    |
             return c2;
    |
             return false;
    )
         }

    @rule2 forall@
    identifier fun, err, errp, lbl;
    expression list args, args2;
    expression var;
    binary operator op;
    constant c1, c2;
    symbol false;
    @@
    -    var = fun(args, &amp;err, args2);
    +    var = fun(args, errp, args2);
         ... when != err
         if (
    (
             var
    |
             !var
    |
             var op c1
    )
            )
         {
             ... when != err
                 when != lbl:
                 when strict
    -        error_propagate(errp, err);
             ... when != err
    (
             return;
    |
             return c2;
    |
             return false;
    |
             return var;
    )
         }

    @depends on rule1 || rule2@
    identifier err;
    @@
    -    Error *err = NULL;
         ... when != err

Not exactly elegant, I'm afraid.

The "when != lbl:" is necessary to avoid transforming

         if (fun(args, &amp;err)) {
             goto out
         }
         ...
     out:
         error_propagate(errp, err);

even though other paths to label out still need the error_propagate().
For an actual example, see sclp_realize().

Without the "when strict", Coccinelle transforms vfio_msix_setup(),
incorrectly.  I don't know what exactly "when strict" does, only that
it helps here.

The match of return is narrower than what I want, but I can't figure
out how to express "return where the operand doesn't use @err".  For
an example where it's too narrow, see vfio_intx_enable().

Silently fails to convert hw/arm/armsse.c, because Coccinelle gets
confused by ARMSSE being used both as typedef and function-like macro
there.  Converted manually.

Line breaks tidied up manually.  One nested declaration of @local_err
deleted manually.  Preexisting unwanted blank line dropped in
hw/riscv/sifive_e.c.

Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
Message-Id: &lt;20200707160613.848843-35-armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>error: Avoid unnecessary error_propagate() after error_setg()</title>
<updated>2020-07-10T13:18:08+00:00</updated>
<author>
<name>Markus Armbruster</name>
</author>
<published>2020-07-07T16:06:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=dcfe480544eef72d666cb1695624449e2c22da2d'/>
<id>urn:sha1:dcfe480544eef72d666cb1695624449e2c22da2d</id>
<content type='text'>
Replace

    error_setg(&amp;err, ...);
    error_propagate(errp, err);

by

    error_setg(errp, ...);

Related pattern:

    if (...) {
        error_setg(&amp;err, ...);
        goto out;
    }
    ...
 out:
    error_propagate(errp, err);
    return;

When all paths to label out are that way, replace by

    if (...) {
        error_setg(errp, ...);
        return;
    }

and delete the label along with the error_propagate().

When we have at most one other path that actually needs to propagate,
and maybe one at the end that where propagation is unnecessary, e.g.

    foo(..., &amp;err);
    if (err) {
        goto out;
    }
    ...
    bar(..., &amp;err);
 out:
    error_propagate(errp, err);
    return;

move the error_propagate() to where it's needed, like

    if (...) {
        foo(..., &amp;err);
        error_propagate(errp, err);
        return;
    }
    ...
    bar(..., errp);
    return;

and transform the error_setg() as above.

In some places, the transformation results in obviously unnecessary
error_propagate().  The next few commits will eliminate them.

Bonus: the elimination of gotos will make later patches in this series
easier to review.

Candidates for conversion tracked down with this Coccinelle script:

    @@
    identifier err, errp;
    expression list args;
    @@
    -    error_setg(&amp;err, args);
    +    error_setg(errp, args);
         ... when != err
         error_propagate(errp, err);

Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
Message-Id: &lt;20200707160613.848843-34-armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>qapi: Use returned bool to check for failure, manual part</title>
<updated>2020-07-10T13:18:08+00:00</updated>
<author>
<name>Markus Armbruster</name>
</author>
<published>2020-07-07T16:05:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=14217038bc9e36246d311fa8e026a01a5d7bbd42'/>
<id>urn:sha1:14217038bc9e36246d311fa8e026a01a5d7bbd42</id>
<content type='text'>
The previous commit used Coccinelle to convert from checking the Error
object to checking the return value.  Convert a few more manually.
Also tweak control flow in places to conform to the conventional "if
error bail out" pattern.

Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
Reviewed-by: Vladimir Sementsov-Ogievskiy &lt;vsementsov@virtuozzo.com&gt;
Message-Id: &lt;20200707160613.848843-20-armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>qapi: Use returned bool to check for failure, Coccinelle part</title>
<updated>2020-07-10T13:18:08+00:00</updated>
<author>
<name>Markus Armbruster</name>
</author>
<published>2020-07-07T16:05:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=62a35aaa310807fa161ca041ddb0f308faeb582b'/>
<id>urn:sha1:62a35aaa310807fa161ca041ddb0f308faeb582b</id>
<content type='text'>
The previous commit enables conversion of

    visit_foo(..., &amp;err);
    if (err) {
        ...
    }

to

    if (!visit_foo(..., errp)) {
        ...
    }

for visitor functions that now return true / false on success / error.
Coccinelle script:

    @@
    identifier fun =~ "check_list|input_type_enum|lv_start_struct|lv_type_bool|lv_type_int64|lv_type_str|lv_type_uint64|output_type_enum|parse_type_bool|parse_type_int64|parse_type_null|parse_type_number|parse_type_size|parse_type_str|parse_type_uint64|print_type_bool|print_type_int64|print_type_null|print_type_number|print_type_size|print_type_str|print_type_uint64|qapi_clone_start_alternate|qapi_clone_start_list|qapi_clone_start_struct|qapi_clone_type_bool|qapi_clone_type_int64|qapi_clone_type_null|qapi_clone_type_number|qapi_clone_type_str|qapi_clone_type_uint64|qapi_dealloc_start_list|qapi_dealloc_start_struct|qapi_dealloc_type_anything|qapi_dealloc_type_bool|qapi_dealloc_type_int64|qapi_dealloc_type_null|qapi_dealloc_type_number|qapi_dealloc_type_str|qapi_dealloc_type_uint64|qobject_input_check_list|qobject_input_check_struct|qobject_input_start_alternate|qobject_input_start_list|qobject_input_start_struct|qobject_input_type_any|qobject_input_type_bool|qobject_input_type_bool_keyval|qobject_input_type_int64|qobject_input_type_int64_keyval|qobject_input_type_null|qobject_input_type_number|qobject_input_type_number_keyval|qobject_input_type_size_keyval|qobject_input_type_str|qobject_input_type_str_keyval|qobject_input_type_uint64|qobject_input_type_uint64_keyval|qobject_output_start_list|qobject_output_start_struct|qobject_output_type_any|qobject_output_type_bool|qobject_output_type_int64|qobject_output_type_null|qobject_output_type_number|qobject_output_type_str|qobject_output_type_uint64|start_list|visit_check_list|visit_check_struct|visit_start_alternate|visit_start_list|visit_start_struct|visit_type_.*";
    expression list args;
    typedef Error;
    Error *err;
    @@
    -    fun(args, &amp;err);
    -    if (err)
    +    if (!fun(args, &amp;err))
         {
             ...
         }

A few line breaks tidied up manually.

Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
Reviewed-by: Vladimir Sementsov-Ogievskiy &lt;vsementsov@virtuozzo.com&gt;
Message-Id: &lt;20200707160613.848843-19-armbru@redhat.com&gt;
</content>
</entry>
<entry>
<title>qom: Drop parameter @errp of object_property_add() &amp; friends</title>
<updated>2020-05-15T05:07:58+00:00</updated>
<author>
<name>Markus Armbruster</name>
</author>
<published>2020-05-05T15:29:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=d2623129a7dec1d3041ad1221dda1ca49c667532'/>
<id>urn:sha1:d2623129a7dec1d3041ad1221dda1ca49c667532</id>
<content type='text'>
The only way object_property_add() can fail is when a property with
the same name already exists.  Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &amp;error_abort.

Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent.  Parentage is
also under program control, so this is a programming error, too.

We have a bit over 500 callers.  Almost half of them pass
&amp;error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.

The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.

Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &amp;error_abort, &amp;error_fatal, or a
pointer to a variable containing NULL.  Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call.  ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.

When the one appropriate choice of argument is &amp;error_abort, letting
users pick the argument is a bad idea.

Drop parameter @errp and assert the preconditions instead.

There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification".  Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().

Signed-off-by: Markus Armbruster &lt;armbru@redhat.com&gt;
Reviewed-by: Eric Blake &lt;eblake@redhat.com&gt;
Reviewed-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Message-Id: &lt;20200505152926.18877-15-armbru@redhat.com&gt;
[Two semantic rebase conflicts resolved]
</content>
</entry>
</feed>
