From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Stefan Weil <sw@weilnetz.de>
Cc: QEMU Developer <qemu-devel@nongnu.org>,
amit.shah@redhat.com, Jason Wang <jasowang@redhat.com>,
Li Qiang <liqiang6-s@360.cn>
Subject: Re: [Qemu-devel] [PATCH] eepro100: Fix memory leak and simplify code for VMStateDescription
Date: Fri, 14 Oct 2016 09:25:39 +0100 [thread overview]
Message-ID: <20161014082539.GA2030@work-vm> (raw)
In-Reply-To: <1476380759-18492-1-git-send-email-sw@weilnetz.de>
* Stefan Weil (sw@weilnetz.de) wrote:
> Instead of allocating a VMStateDescription for each NIC instance,
> the code now uses a single constant VMStateDescription for all
> instances. That implies that the name field is always the same.
Doesn't this break migration compatibility?
You might be able to get around that (in the forward direction only)
by adding an entry to qdev_alias_table but I'm not sure.
Dave
> Reported-by: Li Qiang <liqiang6-s@360.cn>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
> hw/net/eepro100.c | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
> index bab4dbf..6f9777d 100644
> --- a/hw/net/eepro100.c
> +++ b/hw/net/eepro100.c
> @@ -269,9 +269,6 @@ typedef struct {
> /* Configuration bytes. */
> uint8_t configuration[22];
>
> - /* vmstate for each particular nic */
> - VMStateDescription *vmstate;
> -
> /* Quasi static device properties (no need to save them). */
> uint16_t stats_size;
> bool has_extended_tcb_support;
> @@ -1787,7 +1784,8 @@ static ssize_t nic_receive(NetClientState *nc, const uint8_t * buf, size_t size)
> return size;
> }
>
> -static const VMStateDescription vmstate_eepro100 = {
> +static const VMStateDescription vmstate_e100 = {
> + .name = "e100",
> .version_id = 3,
> .minimum_version_id = 2,
> .fields = (VMStateField[]) {
> @@ -1842,7 +1840,6 @@ static void pci_nic_uninit(PCIDevice *pci_dev)
> {
> EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
>
> - vmstate_unregister(&pci_dev->qdev, s->vmstate, s);
> eeprom93xx_free(&pci_dev->qdev, s->eeprom);
> qemu_del_nic(s->nic);
> }
> @@ -1892,11 +1889,6 @@ static void e100_nic_realize(PCIDevice *pci_dev, Error **errp)
> TRACE(OTHER, logout("%s\n", qemu_get_queue(s->nic)->info_str));
>
> qemu_register_reset(nic_reset, s);
> -
> - s->vmstate = g_malloc(sizeof(vmstate_eepro100));
> - memcpy(s->vmstate, &vmstate_eepro100, sizeof(vmstate_eepro100));
> - s->vmstate->name = qemu_get_queue(s->nic)->model;
> - vmstate_register(&pci_dev->qdev, -1, s->vmstate, s);
> }
>
> static void eepro100_instance_init(Object *obj)
> @@ -2083,6 +2075,7 @@ static void eepro100_class_init(ObjectClass *klass, void *data)
> set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
> dc->props = e100_properties;
> dc->desc = info->desc;
> + dc->vmsd = &vmstate_e100;
> k->vendor_id = PCI_VENDOR_ID_INTEL;
> k->class_id = PCI_CLASS_NETWORK_ETHERNET;
> k->romfile = "pxe-eepro100.rom";
> --
> 2.1.4
>
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2016-10-14 8:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-13 17:45 [Qemu-devel] [PATCH] eepro100: Fix memory leak and simplify code for VMStateDescription Stefan Weil
2016-10-14 8:25 ` Dr. David Alan Gilbert [this message]
2016-10-15 5:35 ` Stefan Weil
2016-10-17 9:01 ` Dr. David Alan Gilbert
2016-10-21 1:53 ` Jason Wang
2016-10-21 8:06 ` Dr. David Alan Gilbert
2016-10-21 19:25 ` Stefan Weil
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=20161014082539.GA2030@work-vm \
--to=dgilbert@redhat.com \
--cc=amit.shah@redhat.com \
--cc=jasowang@redhat.com \
--cc=liqiang6-s@360.cn \
--cc=qemu-devel@nongnu.org \
--cc=sw@weilnetz.de \
/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).