All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Halil Pasic <pasic@linux.vnet.ibm.com>
Cc: qemu-devel@nongnu.org, Amit Shah <amit.shah@redhat.com>,
	Guenther Hutzl <hutzl@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH 2/4] tests/test-vmstate.c: prove VMStateField.start broken
Date: Tue, 18 Oct 2016 14:27:28 +0100	[thread overview]
Message-ID: <20161018132728.GH2190@work-vm> (raw)
In-Reply-To: <20161018105724.26520-3-pasic@linux.vnet.ibm.com>

* Halil Pasic (pasic@linux.vnet.ibm.com) wrote:
> The handling of VMStateField.start is currently quite broken if
> VMS_ALLOC is present (that is for VMSTATE_VBUFFER_ALLOC_UINT32) but
> fortunately also quite underutilized -- nobody is using .start != 0.
> 
> Let's prove with this patch that it's really broken (as a first
> step towards fixing things up).

You can't play this trick - patch series have to work and pass
tests after each test, otherwise it messes up people in the future
trying to do a git bisect.

Dave

> Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>
> Reviewed-by: Guenther Hutzl <hutzl@linux.vnet.ibm.com>
> ---
> 
> The idea is to remove .start support and this patch should
> be reverted, as soon this happens, or even better just
> dropped. If however dropping the support for .start encounters
> resistance, this patch should prove useful in an unexpected
> way.
> ---
>  tests/test-vmstate.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 48 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
> index 9a57aa0..a2ef4a8 100644
> --- a/tests/test-vmstate.c
> +++ b/tests/test-vmstate.c
> @@ -588,6 +588,53 @@ static void test_complex_vbuffer(void)
>  #undef FIELD_EQUAL
>  #undef BUFFER_EQUAL
>  
> +typedef struct {
> +    uint32_t vbuff_size;
> +    uint8_t *vbuff;
> +    uint64_t stuff;
> +} TestVBufStart;
> +
> +static const VMStateDescription vmstate_vbuff_alloc_start = {
> +    .name = "test/vbuff_alloc_start",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_UINT64(stuff, TestVBufStart),
> +        VMSTATE_UINT32(vbuff_size, TestVBufStart),
> +        VMSTATE_VBUFFER_ALLOC_UINT32(vbuff, TestVBufStart, 1, 0, 1, vbuff_size),
> +        VMSTATE_END_OF_LIST()
> +    }
> +
> +};
> +
> +static void load_vmstate_one_obj(const VMStateDescription *vmsd, void *obj,
> +        int version_id)
> +{
> +        QEMUFile *fload = open_test_file(false);
> +
> +        SUCCESS(vmstate_load_state(fload, vmsd, obj, version_id));
> +        qemu_fclose(fload);
> +}
> +
> +static void test_vbuff_alloc_start(void)
> +{
> +    uint8_t my_vbuff1[] = {0, 1, 2, 3};
> +    uint8_t my_vbuff2[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
> +    TestVBufStart sample = {
> +        .stuff = 1,
> +        .vbuff_size = 3,
> +        .vbuff = my_vbuff1,
> +    };
> +    TestVBufStart load_obj = {
> +        .vbuff = my_vbuff2,
> +    };
> +
> +    save_vmstate(&vmstate_vbuff_alloc_start, &sample);
> +    load_vmstate_one_obj(&vmstate_vbuff_alloc_start, &load_obj, 1);
> +    g_assert_cmpint(load_obj.stuff, ==, 0);
> +    g_assert_cmpint((uint64_t) load_obj.vbuff, !=, (uint64_t) my_vbuff2);
> +}
> +
>  int main(int argc, char **argv)
>  {
>      temp_fd = mkstemp(temp_file);
> @@ -603,8 +650,8 @@ int main(int argc, char **argv)
>      g_test_add_func("/vmstate/field_exists/save/noskip", test_save_noskip);
>      g_test_add_func("/vmstate/field_exists/save/skip", test_save_skip);
>      g_test_add_func("/vmstate/complex/vbuffer", test_complex_vbuffer);
> +    g_test_add_func("/vmstate/vbuff/alloc_start", test_vbuff_alloc_start);
>      g_test_run();
> -
>      close(temp_fd);
>      unlink(temp_file);
>  
> -- 
> 2.8.4
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2016-10-18 13:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-18 10:57 [Qemu-devel] [PATCH 0/4] remove unused VMSTateField.start Halil Pasic
2016-10-18 10:57 ` [Qemu-devel] [PATCH 1/4] tests/test-vmstate.c: Add vBuffer test Halil Pasic
2016-10-20 11:52   ` Dr. David Alan Gilbert
2016-10-18 10:57 ` [Qemu-devel] [PATCH 2/4] tests/test-vmstate.c: prove VMStateField.start broken Halil Pasic
2016-10-18 13:27   ` Dr. David Alan Gilbert [this message]
2016-10-18 13:43     ` Halil Pasic
2016-10-18 13:54       ` Dr. David Alan Gilbert
2016-10-18 15:33         ` Halil Pasic
2016-10-18 18:32           ` Dr. David Alan Gilbert
2016-10-19 11:04             ` Halil Pasic
2016-10-20 12:00               ` Dr. David Alan Gilbert
2016-10-20 13:05                 ` Halil Pasic
2016-10-18 10:57 ` [Qemu-devel] [PATCH 3/4] Revert "tests/test-vmstate.c: prove VMStateField.start broken" Halil Pasic
2016-10-18 10:57 ` [Qemu-devel] [PATCH 4/4] migration: drop unused VMStateField.start Halil Pasic
2016-10-20 12:00   ` Dr. David Alan Gilbert
2016-10-18 11:24 ` [Qemu-devel] [PATCH 0/4] remove unused VMSTateField.start no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161018132728.GH2190@work-vm \
    --to=dgilbert@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=hutzl@linux.vnet.ibm.com \
    --cc=pasic@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.