From: Jason Wang <jasowang@redhat.com>
To: Leonid Bloch <leonid.bloch@ravellosystems.com>, qemu-devel@nongnu.org
Cc: Dmitry Fleytman <dmitry@daynix.com>,
Leonid Bloch <leonid@daynix.com>,
Shmulik Ladkani <shmulik.ladkani@ravellosystems.com>
Subject: Re: [Qemu-devel] [PATCH v4 2/7] e1000: Add support for migrating the entire MAC registers' array
Date: Wed, 4 Nov 2015 10:35:03 +0800 [thread overview]
Message-ID: <56396ED7.6030806@redhat.com> (raw)
In-Reply-To: <1446549255-26172-3-git-send-email-leonid.bloch@ravellosystems.com>
On 11/03/2015 07:14 PM, Leonid Bloch wrote:
> This patch enables the migration of the entire array of MAC registers
> during live migration. The entire array is just 128 KB long, so
> practically no penalty should be felt when transmitting it, over the
> individual registers. But the advantages are more compact code, and no
> need to introduce new vmstate subsections in the future, when additional
> MAC registers will be implemented.
>
> Backward compatibility is preserved by introducing the e1000-specific
> boolean parameter "full_mac_registers", which is on by default. Setting
> it to off will enable migration to older versions of QEMU.
>
> Additionally, this parameter can be used to control the implementation of
> extra MAC registers in the future. I.e. new MAC registers may be set to
> behave differently, or not to be active at all, if "full_mac_registers"
> will be set to "off", e.g.:
>
> qemu-system-x86_64 -device e1000,full_mac_registers=off,... ...
>
> As mentioned above, the default value is "on".
>
> Signed-off-by: Leonid Bloch <leonid.bloch@ravellosystems.com>
> Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
> ---
> hw/net/e1000.c | 105 +++++++++++++++++++++++++++++++++++++++------------------
> 1 file changed, 72 insertions(+), 33 deletions(-)
>
> diff --git a/hw/net/e1000.c b/hw/net/e1000.c
> index 7036842..1190bbe 100644
> --- a/hw/net/e1000.c
> +++ b/hw/net/e1000.c
> @@ -135,8 +135,10 @@ typedef struct E1000State_st {
> /* Compatibility flags for migration to/from qemu 1.3.0 and older */
> #define E1000_FLAG_AUTONEG_BIT 0
> #define E1000_FLAG_MIT_BIT 1
> +#define E1000_FLAG_MAC_BIT 2
> #define E1000_FLAG_AUTONEG (1 << E1000_FLAG_AUTONEG_BIT)
> #define E1000_FLAG_MIT (1 << E1000_FLAG_MIT_BIT)
> +#define E1000_FLAG_MAC (1 << E1000_FLAG_MAC_BIT)
> uint32_t compat_flags;
> } E1000State;
>
> @@ -1377,6 +1379,18 @@ static bool e1000_mit_state_needed(void *opaque)
> return s->compat_flags & E1000_FLAG_MIT;
> }
>
> +static bool e1000_full_mac_needed(void *opaque)
> +{
> + E1000State *s = opaque;
> +
> + return s->compat_flags & E1000_FLAG_MAC;
> +}
> +
> +static bool e1000_compat_mac_needed(void *opaque)
> +{
> + return !e1000_full_mac_needed(opaque);
> +}
> +
> static const VMStateDescription vmstate_e1000_mit_state = {
> .name = "e1000/mit_state",
> .version_id = 1,
> @@ -1392,41 +1406,23 @@ static const VMStateDescription vmstate_e1000_mit_state = {
> }
> };
>
> -static const VMStateDescription vmstate_e1000 = {
> - .name = "e1000",
> - .version_id = 2,
> +static const VMStateDescription vmstate_e1000_full_mac_state = {
> + .name = "e1000/full_mac_state",
> + .version_id = 1,
> .minimum_version_id = 1,
> - .pre_save = e1000_pre_save,
> - .post_load = e1000_post_load,
> + .needed = e1000_full_mac_needed,
> + .fields = (VMStateField[]) {
> + VMSTATE_UINT32_ARRAY(mac_reg, E1000State, 0x8000),
> + VMSTATE_END_OF_LIST()
> + }
> +};
> +
> +static const VMStateDescription vmstate_e1000_compat_mac_state = {
> + .name = "e1000/compat_mac_state",
> + .version_id = 1,
> + .minimum_version_id = 1,
> + .needed = e1000_compat_mac_needed,
> .fields = (VMStateField[]) {
> - VMSTATE_PCI_DEVICE(parent_obj, E1000State),
> - VMSTATE_UNUSED_TEST(is_version_1, 4), /* was instance id */
> - VMSTATE_UNUSED(4), /* Was mmio_base. */
> - VMSTATE_UINT32(rxbuf_size, E1000State),
> - VMSTATE_UINT32(rxbuf_min_shift, E1000State),
> - VMSTATE_UINT32(eecd_state.val_in, E1000State),
> - VMSTATE_UINT16(eecd_state.bitnum_in, E1000State),
> - VMSTATE_UINT16(eecd_state.bitnum_out, E1000State),
> - VMSTATE_UINT16(eecd_state.reading, E1000State),
> - VMSTATE_UINT32(eecd_state.old_eecd, E1000State),
> - VMSTATE_UINT8(tx.ipcss, E1000State),
> - VMSTATE_UINT8(tx.ipcso, E1000State),
> - VMSTATE_UINT16(tx.ipcse, E1000State),
> - VMSTATE_UINT8(tx.tucss, E1000State),
> - VMSTATE_UINT8(tx.tucso, E1000State),
> - VMSTATE_UINT16(tx.tucse, E1000State),
> - VMSTATE_UINT32(tx.paylen, E1000State),
> - VMSTATE_UINT8(tx.hdr_len, E1000State),
> - VMSTATE_UINT16(tx.mss, E1000State),
> - VMSTATE_UINT16(tx.size, E1000State),
> - VMSTATE_UINT16(tx.tso_frames, E1000State),
> - VMSTATE_UINT8(tx.sum_needed, E1000State),
> - VMSTATE_INT8(tx.ip, E1000State),
> - VMSTATE_INT8(tx.tcp, E1000State),
> - VMSTATE_BUFFER(tx.header, E1000State),
> - VMSTATE_BUFFER(tx.data, E1000State),
> - VMSTATE_UINT16_ARRAY(eeprom_data, E1000State, 64),
> - VMSTATE_UINT16_ARRAY(phy_reg, E1000State, 0x20),
> VMSTATE_UINT32(mac_reg[CTRL], E1000State),
> VMSTATE_UINT32(mac_reg[EECD], E1000State),
> VMSTATE_UINT32(mac_reg[EERD], E1000State),
> @@ -1468,9 +1464,50 @@ static const VMStateDescription vmstate_e1000 = {
> VMSTATE_UINT32_SUB_ARRAY(mac_reg, E1000State, MTA, 128),
> VMSTATE_UINT32_SUB_ARRAY(mac_reg, E1000State, VFTA, 128),
> VMSTATE_END_OF_LIST()
> + }
> +};
> +
> +static const VMStateDescription vmstate_e1000 = {
> + .name = "e1000",
> + .version_id = 2,
> + .minimum_version_id = 1,
> + .pre_save = e1000_pre_save,
> + .post_load = e1000_post_load,
> + .fields = (VMStateField[]) {
> + VMSTATE_PCI_DEVICE(parent_obj, E1000State),
> + VMSTATE_UNUSED_TEST(is_version_1, 4), /* was instance id */
> + VMSTATE_UNUSED(4), /* Was mmio_base. */
> + VMSTATE_UINT32(rxbuf_size, E1000State),
> + VMSTATE_UINT32(rxbuf_min_shift, E1000State),
> + VMSTATE_UINT32(eecd_state.val_in, E1000State),
> + VMSTATE_UINT16(eecd_state.bitnum_in, E1000State),
> + VMSTATE_UINT16(eecd_state.bitnum_out, E1000State),
> + VMSTATE_UINT16(eecd_state.reading, E1000State),
> + VMSTATE_UINT32(eecd_state.old_eecd, E1000State),
> + VMSTATE_UINT8(tx.ipcss, E1000State),
> + VMSTATE_UINT8(tx.ipcso, E1000State),
> + VMSTATE_UINT16(tx.ipcse, E1000State),
> + VMSTATE_UINT8(tx.tucss, E1000State),
> + VMSTATE_UINT8(tx.tucso, E1000State),
> + VMSTATE_UINT16(tx.tucse, E1000State),
> + VMSTATE_UINT32(tx.paylen, E1000State),
> + VMSTATE_UINT8(tx.hdr_len, E1000State),
> + VMSTATE_UINT16(tx.mss, E1000State),
> + VMSTATE_UINT16(tx.size, E1000State),
> + VMSTATE_UINT16(tx.tso_frames, E1000State),
> + VMSTATE_UINT8(tx.sum_needed, E1000State),
> + VMSTATE_INT8(tx.ip, E1000State),
> + VMSTATE_INT8(tx.tcp, E1000State),
> + VMSTATE_BUFFER(tx.header, E1000State),
> + VMSTATE_BUFFER(tx.data, E1000State),
> + VMSTATE_UINT16_ARRAY(eeprom_data, E1000State, 64),
> + VMSTATE_UINT16_ARRAY(phy_reg, E1000State, 0x20),
> + VMSTATE_END_OF_LIST()
> },
> .subsections = (const VMStateDescription*[]) {
> &vmstate_e1000_mit_state,
> + &vmstate_e1000_full_mac_state,
> + &vmstate_e1000_compat_mac_state,
> NULL
> }
I'm afraid this will break migration to older qemu. Consider the case
when full_mac_registers=off, we save compat mac registers as a
subsection, this breaks the assumption on load who expect all compact
registers just after phy_reg. (You can just test this with a simple
'savevm' with full_mac_register_off and the revert this patch and do a
'loadvm'), Looks like the safe way is to just add a
vmstate_e1000_full_mac_state and keep other fields of vmstate_e1000
unmodified.
> };
> @@ -1603,6 +1640,8 @@ static Property e1000_properties[] = {
> compat_flags, E1000_FLAG_AUTONEG_BIT, true),
> DEFINE_PROP_BIT("mitigation", E1000State,
> compat_flags, E1000_FLAG_MIT_BIT, true),
> + DEFINE_PROP_BIT("full_mac_registers", E1000State,
> + compat_flags, E1000_FLAG_MAC_BIT, true),
> DEFINE_PROP_END_OF_LIST(),
> };
>
Need also turn this off for pre 2.5 machines in HW_COMPAT_2_4.
next prev parent reply other threads:[~2015-11-04 2:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-03 11:14 [Qemu-devel] [PATCH v4 0/7] e1000: Various fixes and registers' implementation Leonid Bloch
2015-11-03 11:14 ` [Qemu-devel] [PATCH v4 1/7] e1000: Cosmetic and alignment fixes Leonid Bloch
2015-11-03 11:14 ` [Qemu-devel] [PATCH v4 2/7] e1000: Add support for migrating the entire MAC registers' array Leonid Bloch
2015-11-04 2:35 ` Jason Wang [this message]
2015-11-04 14:48 ` Leonid Bloch
2015-11-05 2:35 ` Jason Wang
2015-11-03 11:14 ` [Qemu-devel] [PATCH v4 3/7] e1000: Trivial implementation of various MAC registers Leonid Bloch
2015-11-04 2:44 ` Jason Wang
2015-11-04 15:21 ` Leonid Bloch
2015-11-05 2:57 ` Jason Wang
2015-11-03 11:14 ` [Qemu-devel] [PATCH v4 4/7] e1000: Fixing the received/transmitted packets' counters Leonid Bloch
2015-11-03 11:14 ` [Qemu-devel] [PATCH v4 5/7] e1000: Fixing the received/transmitted octets' counters Leonid Bloch
2015-11-03 11:14 ` [Qemu-devel] [PATCH v4 6/7] e1000: Fixing the packet address filtering procedure Leonid Bloch
2015-11-03 11:14 ` [Qemu-devel] [PATCH v4 7/7] e1000: Implementing various counters Leonid Bloch
2015-11-04 2:46 ` Jason Wang
2015-11-04 15:44 ` Leonid Bloch
2015-11-05 3:16 ` Jason Wang
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=56396ED7.6030806@redhat.com \
--to=jasowang@redhat.com \
--cc=dmitry@daynix.com \
--cc=leonid.bloch@ravellosystems.com \
--cc=leonid@daynix.com \
--cc=qemu-devel@nongnu.org \
--cc=shmulik.ladkani@ravellosystems.com \
/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 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).