From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, mdroth@linux.vnet.ibm.com, quintela@redhat.com
Subject: [Qemu-devel] [PATCH 03/13] virtio-pci: convert save/load to visitors
Date: Thu, 27 Oct 2011 13:17:15 -0500 [thread overview]
Message-ID: <1319739445-17629-4-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1319739445-17629-1-git-send-email-mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
hw/virtio-pci.c | 63 +++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 52 insertions(+), 11 deletions(-)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index ca5923c..9092c02 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -103,53 +103,94 @@ static void virtio_pci_notify(void *opaque, uint16_t vector)
static void virtio_pci_save_config(void * opaque, QEMUFile *f)
{
VirtIOPCIProxy *proxy = opaque;
+ Visitor *v = qemu_file_get_visitor(f);
+ Error *err = NULL;
+
pci_device_save(&proxy->pci_dev, f);
msix_save(&proxy->pci_dev, f);
- if (msix_present(&proxy->pci_dev))
- qemu_put_be16(f, proxy->vdev->config_vector);
+ if (msix_present(&proxy->pci_dev)) {
+ visit_type_uint16(v, &proxy->vdev->config_vector,
+ "proxy.vdev.config_vector", &err);
+ }
+ if (err) {
+ error_report("error saving virtio-pci config: %s",
+ error_get_pretty(err));
+ error_free(err);
+ }
}
static void virtio_pci_save_queue(void * opaque, int n, QEMUFile *f)
{
VirtIOPCIProxy *proxy = opaque;
- if (msix_present(&proxy->pci_dev))
- qemu_put_be16(f, virtio_queue_vector(proxy->vdev, n));
+ Visitor *v = qemu_file_get_visitor(f);
+ Error *err = NULL;
+ uint16_t vector;
+
+ if (msix_present(&proxy->pci_dev)) {
+ vector = virtio_queue_vector(proxy->vdev, n);
+ visit_type_uint16(v, &vector, "vector", &err);
+ }
+ if (err) {
+ error_report("error saving virtio-pci queue: %s",
+ error_get_pretty(err));
+ error_free(err);
+ }
}
static int virtio_pci_load_config(void * opaque, QEMUFile *f)
{
VirtIOPCIProxy *proxy = opaque;
+ Visitor *v = qemu_file_get_visitor(f);
+ Error *err = NULL;
int ret;
+
ret = pci_device_load(&proxy->pci_dev, f);
if (ret) {
- return ret;
+ goto out;
}
msix_load(&proxy->pci_dev, f);
if (msix_present(&proxy->pci_dev)) {
- qemu_get_be16s(f, &proxy->vdev->config_vector);
+ visit_type_uint16(v, &proxy->vdev->config_vector,
+ "proxy.vdev.config_vector", &err);
} else {
proxy->vdev->config_vector = VIRTIO_NO_VECTOR;
}
if (proxy->vdev->config_vector != VIRTIO_NO_VECTOR) {
- return msix_vector_use(&proxy->pci_dev, proxy->vdev->config_vector);
+ ret = msix_vector_use(&proxy->pci_dev, proxy->vdev->config_vector);
}
- return 0;
+out:
+ if (err) {
+ error_report("error loading virtio-pci config: %s",
+ error_get_pretty(err));
+ error_free(err);
+ }
+ return ret;
}
static int virtio_pci_load_queue(void * opaque, int n, QEMUFile *f)
{
VirtIOPCIProxy *proxy = opaque;
+ Visitor *v = qemu_file_get_visitor(f);
+ Error *err = NULL;
uint16_t vector;
+ int ret = 0;
if (msix_present(&proxy->pci_dev)) {
- qemu_get_be16s(f, &vector);
+ visit_type_uint16(v, &vector, "vector", &err);
} else {
vector = VIRTIO_NO_VECTOR;
}
virtio_queue_set_vector(proxy->vdev, n, vector);
if (vector != VIRTIO_NO_VECTOR) {
- return msix_vector_use(&proxy->pci_dev, vector);
+ ret = msix_vector_use(&proxy->pci_dev, vector);
+ goto out;
}
- return 0;
+out:
+ if (err) {
+ error_report("error loading virtio-pci config: %s",
+ error_get_pretty(err));
+ error_free(err);
+ }
+ return ret;
}
static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy,
--
1.7.4.1
next prev parent reply other threads:[~2011-10-27 18:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-27 18:17 [Qemu-devel] [PATCH 00/13] Convert slirp/ivshmem/virtio save/load to Visitors Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 01/13] slirp: convert save/load function to visitor interface Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 02/13] ivshmem: convert save/load to visitor Michael Roth
2011-10-27 18:17 ` Michael Roth [this message]
2011-10-27 18:17 ` [Qemu-devel] [PATCH 04/13] msix: convert save/load to visitors (including interfaces) Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 05/13] openpic: convert save/load to visitors Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 06/13] i440fx: " Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 07/13] pci: convert pci_device_(save|load) interfaces to accept Visitors Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 08/13] virtio: convert common virtio save/load to visitors Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 09/13] virtio-balloon: convert " Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 10/13] virtio-blk: " Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 11/13] virtio-net: " Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 12/13] virtio-serial: " Michael Roth
2011-10-27 18:17 ` [Qemu-devel] [PATCH 13/13] virtio: convert virtio_save/virtio_load interfaces to accept Visitors Michael Roth
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=1319739445-17629-4-git-send-email-mdroth@linux.vnet.ibm.com \
--to=mdroth@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.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).