* [Qemu-devel] [PATCH] block/qcow2: Don't use cpu_to_*w()
@ 2016-06-16 16:06 Peter Maydell
2016-06-16 16:59 ` Eric Blake
2016-06-20 15:10 ` Max Reitz
0 siblings, 2 replies; 6+ messages in thread
From: Peter Maydell @ 2016-06-16 16:06 UTC (permalink / raw)
To: qemu-devel; +Cc: patches, Kevin Wolf, Max Reitz, qemu-block
Don't use the cpu_to_*w() functions, which we are trying to deprecate.
Instead either just use cpu_to_*() to do the byteswap, or use
st*_be_p() if we need to do the store somewhere other than to a
variable that's already the correct type.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
block/qcow2-cluster.c | 2 +-
block/qcow2-refcount.c | 11 +++++------
block/qcow2.c | 6 +++---
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index b04bfaf..4acf0e3 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -117,7 +117,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,
/* set new table */
BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ACTIVATE_TABLE);
- cpu_to_be32w((uint32_t*)data, new_l1_size);
+ stl_be_p(data, new_l1_size);
stq_be_p(data + 4, new_l1_table_offset);
ret = bdrv_pwrite_sync(bs->file->bs, offsetof(QCowHeader, l1_size),
data, sizeof(data));
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 66f187a..088c00f 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -565,8 +565,8 @@ static int alloc_refcount_block(BlockDriverState *bs,
uint64_t d64;
uint32_t d32;
} data;
- cpu_to_be64w(&data.d64, table_offset);
- cpu_to_be32w(&data.d32, table_clusters);
+ data.d64 = cpu_to_be64(table_offset);
+ data.d32 = cpu_to_be32(table_clusters);
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);
ret = bdrv_pwrite_sync(bs->file->bs,
offsetof(QCowHeader, refcount_table_offset),
@@ -2158,10 +2158,9 @@ write_refblocks:
}
/* Enter new reftable into the image header */
- cpu_to_be64w(&reftable_offset_and_clusters.reftable_offset,
- reftable_offset);
- cpu_to_be32w(&reftable_offset_and_clusters.reftable_clusters,
- size_to_clusters(s, reftable_size * sizeof(uint64_t)));
+ reftable_offset_and_clusters.reftable_offset = cpu_to_be64(reftable_offset);
+ reftable_offset_and_clusters.reftable_clusters =
+ cpu_to_be32(size_to_clusters(s, reftable_size * sizeof(uint64_t)));
ret = bdrv_pwrite_sync(bs->file->bs, offsetof(QCowHeader,
refcount_table_offset),
&reftable_offset_and_clusters,
diff --git a/block/qcow2.c b/block/qcow2.c
index 6f5fb81..860d7b7 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2686,9 +2686,9 @@ static int make_completely_empty(BlockDriverState *bs)
/* "Create" an empty reftable (one cluster) directly after the image
* header and an empty L1 table three clusters after the image header;
* the cluster between those two will be used as the first refblock */
- 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);
+ l1_ofs_rt_ofs_cls.l1_offset = cpu_to_be64(3 * s->cluster_size);
+ l1_ofs_rt_ofs_cls.reftable_offset = cpu_to_be64(s->cluster_size);
+ l1_ofs_rt_ofs_cls.reftable_clusters = cpu_to_be32(1);
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) {
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] block/qcow2: Don't use cpu_to_*w()
2016-06-16 16:06 [Qemu-devel] [PATCH] block/qcow2: Don't use cpu_to_*w() Peter Maydell
@ 2016-06-16 16:59 ` Eric Blake
2016-06-20 15:10 ` Max Reitz
1 sibling, 0 replies; 6+ messages in thread
From: Eric Blake @ 2016-06-16 16:59 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: Kevin Wolf, Max Reitz, qemu-block, patches
[-- Attachment #1: Type: text/plain, Size: 701 bytes --]
On 06/16/2016 10:06 AM, Peter Maydell wrote:
> Don't use the cpu_to_*w() functions, which we are trying to deprecate.
> Instead either just use cpu_to_*() to do the byteswap, or use
> st*_be_p() if we need to do the store somewhere other than to a
> variable that's already the correct type.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> block/qcow2-cluster.c | 2 +-
> block/qcow2-refcount.c | 11 +++++------
> block/qcow2.c | 6 +++---
> 3 files changed, 9 insertions(+), 10 deletions(-)
>
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] block/qcow2: Don't use cpu_to_*w()
2016-06-16 16:06 [Qemu-devel] [PATCH] block/qcow2: Don't use cpu_to_*w() Peter Maydell
2016-06-16 16:59 ` Eric Blake
@ 2016-06-20 15:10 ` Max Reitz
2016-06-28 14:17 ` Peter Maydell
1 sibling, 1 reply; 6+ messages in thread
From: Max Reitz @ 2016-06-20 15:10 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: patches, Kevin Wolf, qemu-block
[-- Attachment #1: Type: text/plain, Size: 1476 bytes --]
On 16.06.2016 18:06, Peter Maydell wrote:
> Don't use the cpu_to_*w() functions, which we are trying to deprecate.
> Instead either just use cpu_to_*() to do the byteswap, or use
> st*_be_p() if we need to do the store somewhere other than to a
> variable that's already the correct type.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> block/qcow2-cluster.c | 2 +-
> block/qcow2-refcount.c | 11 +++++------
> block/qcow2.c | 6 +++---
> 3 files changed, 9 insertions(+), 10 deletions(-)
>
[...]
> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
> index 66f187a..088c00f 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
> @@ -565,8 +565,8 @@ static int alloc_refcount_block(BlockDriverState *bs,
> uint64_t d64;
> uint32_t d32;
> } data;
This declaration is in the middle of the block, so it might have made
sense to fix that along the way. Since this is pre-existing, however:
Thanks, applied to my block tree:
https://github.com/XanClic/qemu/commits/block
Max
> - cpu_to_be64w(&data.d64, table_offset);
> - cpu_to_be32w(&data.d32, table_clusters);
> + data.d64 = cpu_to_be64(table_offset);
> + data.d32 = cpu_to_be32(table_clusters);
> BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE);
> ret = bdrv_pwrite_sync(bs->file->bs,
> offsetof(QCowHeader, refcount_table_offset),
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] block/qcow2: Don't use cpu_to_*w()
2016-06-20 15:10 ` Max Reitz
@ 2016-06-28 14:17 ` Peter Maydell
2016-06-28 15:04 ` Kevin Wolf
0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2016-06-28 14:17 UTC (permalink / raw)
To: Max Reitz; +Cc: QEMU Developers, Patch Tracking, Kevin Wolf, Qemu-block
On 20 June 2016 at 16:10, Max Reitz <mreitz@redhat.com> wrote:
> On 16.06.2016 18:06, Peter Maydell wrote:
>> Don't use the cpu_to_*w() functions, which we are trying to deprecate.
>> Instead either just use cpu_to_*() to do the byteswap, or use
>> st*_be_p() if we need to do the store somewhere other than to a
>> variable that's already the correct type.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>> block/qcow2-cluster.c | 2 +-
>> block/qcow2-refcount.c | 11 +++++------
>> block/qcow2.c | 6 +++---
>> 3 files changed, 9 insertions(+), 10 deletions(-)
>>
>
> [...]
>
>> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
>> index 66f187a..088c00f 100644
>> --- a/block/qcow2-refcount.c
>> +++ b/block/qcow2-refcount.c
>> @@ -565,8 +565,8 @@ static int alloc_refcount_block(BlockDriverState *bs,
>> uint64_t d64;
>> uint32_t d32;
>> } data;
>
> This declaration is in the middle of the block, so it might have made
> sense to fix that along the way. Since this is pre-existing, however:
>
> Thanks, applied to my block tree:
>
> https://github.com/XanClic/qemu/commits/block
Ping? I don't think this has made it into a pullreq yet, and it's
freeze day today...
thanks
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] block/qcow2: Don't use cpu_to_*w()
2016-06-28 14:17 ` Peter Maydell
@ 2016-06-28 15:04 ` Kevin Wolf
2016-06-28 15:07 ` Peter Maydell
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Wolf @ 2016-06-28 15:04 UTC (permalink / raw)
To: Peter Maydell; +Cc: Max Reitz, QEMU Developers, Patch Tracking, Qemu-block
Am 28.06.2016 um 16:17 hat Peter Maydell geschrieben:
> On 20 June 2016 at 16:10, Max Reitz <mreitz@redhat.com> wrote:
> > Thanks, applied to my block tree:
> >
> > https://github.com/XanClic/qemu/commits/block
>
> Ping? I don't think this has made it into a pullreq yet, and it's
> freeze day today...
"2016-06-28: Soft feature freeze. All features should have patches on
the list by this date; major features should have initial code
committed."
The patch is already on the list, so I don't think it's a problem if
it doesn't land in master by today.
Kevin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] block/qcow2: Don't use cpu_to_*w()
2016-06-28 15:04 ` Kevin Wolf
@ 2016-06-28 15:07 ` Peter Maydell
0 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2016-06-28 15:07 UTC (permalink / raw)
To: Kevin Wolf; +Cc: Max Reitz, QEMU Developers, Patch Tracking, Qemu-block
On 28 June 2016 at 16:04, Kevin Wolf <kwolf@redhat.com> wrote:
> Am 28.06.2016 um 16:17 hat Peter Maydell geschrieben:
>> On 20 June 2016 at 16:10, Max Reitz <mreitz@redhat.com> wrote:
>> > Thanks, applied to my block tree:
>> >
>> > https://github.com/XanClic/qemu/commits/block
>>
>> Ping? I don't think this has made it into a pullreq yet, and it's
>> freeze day today...
>
> "2016-06-28: Soft feature freeze. All features should have patches on
> the list by this date; major features should have initial code
> committed."
>
> The patch is already on the list, so I don't think it's a problem if
> it doesn't land in master by today.
True; I had forgotten our definitions of freezes :-)
thanks
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-06-28 15:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-16 16:06 [Qemu-devel] [PATCH] block/qcow2: Don't use cpu_to_*w() Peter Maydell
2016-06-16 16:59 ` Eric Blake
2016-06-20 15:10 ` Max Reitz
2016-06-28 14:17 ` Peter Maydell
2016-06-28 15:04 ` Kevin Wolf
2016-06-28 15:07 ` Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).