From: Lonnie Mendez <lmendez19@austin.rr.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] usb-uhci.c: save/load state implementation
Date: Fri, 24 Nov 2006 18:28:38 -0600 [thread overview]
Message-ID: <1164414518.10246.12.camel@vaio> (raw)
[-- Attachment #1: Type: text/plain, Size: 730 bytes --]
lo list. Attached is a patch that implements save/load state for
the uhci controller. The code will only work well if you remove all usb
devices attached to the guest prior to saving the vm state. There is no
code yet that tries to reconstruct the ports list.
I'm sure there will need to be additional code to the handle the
case of previously attached devices - this is difficult because the
device(s) could have been removed, the device state could have changed,
etc.
Test case with windows xp guest.
(qemu) stop
(qemu) savevm test1
(qemu) quit
qemu -hda winxp.qcow2 -localtime -usb -no-acpi -kernel-kqemu -loadvm
test1
Adding the usb tablet after resuming the guest results in a functional
tablet input device.
[-- Attachment #2: qemu-uhci-savestate.diff --]
[-- Type: text/x-patch, Size: 2010 bytes --]
--- qemu/hw/usb-uhci.c 2006-08-11 20:04:27.000000000 -0500
+++ qemu/hw/usb-uhci.c 2006-11-24 17:46:18.000000000 -0600
@@ -144,6 +144,62 @@
}
}
+static void uhci_save(QEMUFile *f, void *opaque)
+{
+ UHCIState *s = opaque;
+ uint8_t num_ports = NB_PORTS;
+ int i;
+
+ pci_device_save(&s->dev, f);
+
+ qemu_put_8s(f, &num_ports);
+ for (i = 0; i < num_ports; ++i)
+ qemu_put_be16s(f, &s->ports[i].ctrl);
+ qemu_put_be16s(f, &s->cmd);
+ qemu_put_be16s(f, &s->status);
+ qemu_put_be16s(f, &s->intr);
+ qemu_put_be16s(f, &s->frnum);
+ qemu_put_be32s(f, &s->fl_base_addr);
+ qemu_put_8s(f, &s->sof_timing);
+ qemu_put_8s(f, &s->status2);
+ qemu_put_timer(f, s->frame_timer);
+ qemu_put_be32s(f, &s->pending_int_mask);
+ qemu_put_be32s(f, &s->async_qh);
+}
+
+static int uhci_load(QEMUFile* f,void* opaque,int version_id)
+{
+ UHCIState *s = opaque;
+ uint8_t num_ports;
+ int i, ret;
+
+ if (version_id > 1)
+ return -EINVAL;
+
+ ret = pci_device_load(&s->dev, f);
+ if (ret < 0)
+ return ret;
+
+ qemu_get_8s(f, &num_ports);
+ if (num_ports != NB_PORTS)
+ return -EINVAL;
+
+ for (i = 0; i < num_ports; ++i)
+ qemu_get_be16s(f, &s->ports[i].ctrl);
+ qemu_get_be16s(f, &s->cmd);
+ qemu_get_be16s(f, &s->status);
+ qemu_get_be16s(f, &s->intr);
+ qemu_get_be16s(f, &s->frnum);
+ qemu_get_be32s(f, &s->fl_base_addr);
+ qemu_get_8s(f, &s->sof_timing);
+ qemu_get_8s(f, &s->status2);
+ qemu_get_timer(f, s->frame_timer);
+ qemu_get_be32s(f, &s->pending_int_mask);
+ qemu_get_be32s(f, &s->async_qh);
+
+ return 0;
+}
+
static void uhci_ioport_writeb(void *opaque, uint32_t addr, uint32_t val)
{
UHCIState *s = opaque;
@@ -793,4 +849,6 @@
to rely on this. */
pci_register_io_region(&s->dev, 4, 0x20,
PCI_ADDRESS_SPACE_IO, uhci_map);
+
+ register_savevm("uhci", 0, 1, uhci_save, uhci_load, s);
}
reply other threads:[~2006-11-25 0:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1164414518.10246.12.camel@vaio \
--to=lmendez19@austin.rr.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 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).