All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: David Vrabel <david.vrabel@citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH v4 3/9] tools/libxc: Stream specification and some common code
Date: Wed, 7 May 2014 13:14:04 +0100	[thread overview]
Message-ID: <536A238C.1010900@citrix.com> (raw)
In-Reply-To: <1399463828.13430.19.camel@kazak.uk.xensource.com>

On 07/05/14 12:57, Ian Campbell wrote:
> On Wed, 2014-04-30 at 19:36 +0100, Andrew Cooper wrote:
>> diff --git a/tools/libxc/saverestore/stream_format.h b/tools/libxc/saverestore/stream_format.h
>> new file mode 100644
>> index 0000000..efcca60
>> --- /dev/null
>> +++ b/tools/libxc/saverestore/stream_format.h
> Reference to the spec (which doesn't appear to be in this series
> anywhere BTW)

The spec pdf is referenced in the header.  I suppose it should move into
docs/.

>
>> @@ -0,0 +1,158 @@
>> +#ifndef __STREAM_FORMAT__H
>> +#define __STREAM_FORMAT__H
>> +
>> +#include <inttypes.h>
>> +
>> +/* TODO - find somewhere more appropriate. rec_tsc_info needs it for 64bit */
> You seem to use it on all of them though. Can we not use explicit
> padding, as you seem to do for many of the other structs?

The issue with rec_tsc_info is its trailing alignment.  i.e.
sizeof(rec_tsc_info) is different between 32 and 64 bit builds, yet all
fields are at the same offset from the beginning.  Putting explicit
trailing padding would invalidate the current code writing
sizeof(rec_tsc_info) bytes into the stream.

Inside Xen when I was sorting out the __attribute__((packed))
consistency, we did agree on __packed for binary interfaces even when
not strictly necessary.

>
>> +#ifndef __packed
>> +#define __packed __attribute__((packed))
>> +#endif
>> +
>> +/*
>> + * Image Header
>> + */
>> +struct __packed ihdr
> So long as this remains confined to libxc/saverestore/*.[ch] we can
> avoid namespacing/prefixing. I suppose that is a safe assumption.

Hmm yes.  (This I suppose is still "v1 code hacking to make something work")

Probably do want some namespacing even if it does only live inside this
code, although an obvious prefix doesn't jump to mind.

>
>> +{
>> +    uint64_t marker;
>> +    uint32_t id;
>> +    uint32_t version;
>> +    uint16_t options;
>> +    uint16_t _res1;
>> +    uint32_t _res2;
>> +};
>> +
>> +#define IHDR_MARKER  0xffffffffffffffffULL
>> +#define IHDR_ID      0x58454E46U
>> +#define IHDR_VERSION 1
>> +
>> +#define _IHDR_OPT_ENDIAN 0
>> +#define IHDR_OPT_LITTLE_ENDIAN (0 << _IHDR_OPT_ENDIAN)
>> +#define IHDR_OPT_BIG_ENDIAN    (1 << _IHDR_OPT_ENDIAN)
>> +
>> +/*
>> + * Domain Header
>> + */
>> +struct __packed dhdr
>> +{
>> +    uint32_t type;
>> +    uint16_t page_shift;
>> +    uint16_t _res1;
>> +    uint32_t xen_major;
>> +    uint32_t xen_minor;
>> +};
>> +
>> +#define DHDR_TYPE_x86_pv  0x00000001U
>> +#define DHDR_TYPE_x86_hvm 0x00000002U
>> +#define DHDR_TYPE_x86_pvh 0x00000003U
>> +#define DHDR_TYPE_arm     0x00000004U
> That capitalisation here (and elsewhere) seems rather unconventional. 
>
> BTW IHDR_OPT is also inconsistent with the pattern you've established.
> TBH I'd prefer more conventional upper case #defines. I suppose you want
> to avoid enums for the ABI-confusing properties they have.
>
>

This particular bit is to match the spec, but I see what you mean.  I
shall make it consistently upper case.

I hadn't actually considered an enum.  It might be ok as each type field
is passed as a uint32_t, although changing it would be faff for no
appreciable gain.

~Andrew

  parent reply	other threads:[~2014-05-07 12:14 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-30 18:36 [PATCH v4 0/9] Migration Stream v2 Andrew Cooper
2014-04-30 18:36 ` [PATCH v4 1/9] libxc: add DECLARE_HYPERCALL_BUFFER_SHADOW() Andrew Cooper
2014-05-07 11:45   ` Ian Campbell
2014-05-07 12:00     ` David Vrabel
2014-05-07 12:06       ` Ian Campbell
2014-04-30 18:36 ` [PATCH v4 2/9] [HACK] tools/libxc: save/restore v2 framework Andrew Cooper
2014-04-30 18:36 ` [PATCH v4 3/9] tools/libxc: Stream specification and some common code Andrew Cooper
2014-05-07 11:57   ` Ian Campbell
2014-05-07 12:06     ` David Vrabel
2014-05-07 12:14     ` Andrew Cooper [this message]
2014-05-07 13:07       ` Ian Campbell
2014-05-07 13:20         ` Andrew Cooper
2014-04-30 18:36 ` [PATCH v4 4/9] tools/libxc: Scripts for inspection/valdiation of legacy and new streams Andrew Cooper
2014-05-07 12:03   ` Ian Campbell
2014-05-07 12:08     ` David Vrabel
2014-05-07 12:27     ` Andrew Cooper
2014-04-30 18:36 ` [PATCH v4 5/9] tools/libxc: common code Andrew Cooper
2014-05-07 13:03   ` Ian Campbell
2014-05-07 14:38     ` Andrew Cooper
2014-05-07 16:08       ` Ian Campbell
2014-05-07 16:30         ` Andrew Cooper
2014-05-07 16:35           ` Ian Campbell
2014-05-08  8:29       ` David Vrabel
2014-04-30 18:36 ` [PATCH v4 6/9] tools/libxc: x86 pv save implementation Andrew Cooper
2014-05-07 13:58   ` Ian Campbell
2014-05-07 15:20     ` Andrew Cooper
2014-05-07 16:15       ` Ian Campbell
2014-04-30 18:36 ` [PATCH v4 7/9] tools/libxc: x86 pv restore implementation Andrew Cooper
2014-05-07 14:10   ` Ian Campbell
2014-05-07 15:37     ` Andrew Cooper
2014-05-07 16:17       ` Ian Campbell
2014-04-30 18:36 ` [PATCH v4 8/9] tools/libxc: x86 hvm save implementation Andrew Cooper
2014-05-07 14:14   ` Ian Campbell
2014-05-07 15:39     ` Andrew Cooper
2014-04-30 18:36 ` [PATCH v4 9/9] tools/libxc: x86 hvm restore implementation Andrew Cooper
2014-05-07 14:15   ` Ian Campbell
2014-05-01 16:41 ` [PATCH v4 0/9] Migration Stream v2 Konrad Rzeszutek Wilk
2014-05-01 17:32   ` Andrew Cooper
2014-05-07 14:23 ` Ian Campbell

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=536A238C.1010900@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=david.vrabel@citrix.com \
    --cc=xen-devel@lists.xen.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.