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 04/13] msix: convert save/load to visitors (including interfaces)
Date: Thu, 27 Oct 2011 13:17:16 -0500 [thread overview]
Message-ID: <1319739445-17629-5-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1319739445-17629-1-git-send-email-mdroth@linux.vnet.ibm.com>
Use visitors for serialization.
Also, with the only 2 direct users, virtio-pci and ivshmem, converted
to visitors, we can change msix save/load function to take a Visitor
directly, along with an Error object.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
hw/ivshmem.c | 4 ++--
hw/msix.c | 37 ++++++++++++++++++++++++++++---------
hw/msix.h | 4 ++--
hw/virtio-pci.c | 4 ++--
4 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/hw/ivshmem.c b/hw/ivshmem.c
index 48e27f5..8d0607d 100644
--- a/hw/ivshmem.c
+++ b/hw/ivshmem.c
@@ -573,7 +573,7 @@ static void ivshmem_save(QEMUFile* f, void *opaque)
pci_device_save(&proxy->dev, f);
if (ivshmem_has_feature(proxy, IVSHMEM_MSI)) {
- msix_save(&proxy->dev, f);
+ msix_save(&proxy->dev, v, &err);
} else {
visit_type_uint32(v, &proxy->intrstatus, "proxy.intrstatus", &err);
visit_type_uint32(v, &proxy->intrmask, "proxy.intrmask", &err);
@@ -615,7 +615,7 @@ static int ivshmem_load(QEMUFile* f, void *opaque, int version_id)
}
if (ivshmem_has_feature(proxy, IVSHMEM_MSI)) {
- msix_load(&proxy->dev, f);
+ msix_load(&proxy->dev, v, &err);
for (i = 0; i < proxy->vectors; i++) {
msix_vector_use(&proxy->dev, i);
}
diff --git a/hw/msix.c b/hw/msix.c
index b15bafc..c62eeaa 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -276,30 +276,49 @@ int msix_uninit(PCIDevice *dev, MemoryRegion *bar)
return 0;
}
-void msix_save(PCIDevice *dev, QEMUFile *f)
+static void msix_visit(Visitor *v, PCIDevice *dev, Error **errp)
{
unsigned n = dev->msix_entries_nr;
+ int i;
+ Error *err = NULL;
+ visit_start_struct(v, NULL, NULL, "msix", 0, &err);
+
+ visit_start_array(v, NULL, "msix_table_page", n * PCI_MSIX_ENTRY_SIZE, 1,
+ &err);
+ for (i = 0; i < n * PCI_MSIX_ENTRY_SIZE; i++) {
+ visit_type_uint8(v, &dev->msix_table_page[i], NULL, &err);
+ }
+ visit_end_array(v, &err);
+
+ visit_start_array(v, NULL, "msix_table_page_pending", (n + 7) / 8, 1, &err);
+ for (i = 0; i < (n + 7) / 8; i++) {
+ visit_type_uint8(v, &dev->msix_table_page[i + MSIX_PAGE_PENDING],
+ NULL, &err);
+ }
+ visit_end_array(v, &err);
+
+ visit_end_struct(v, &err);
+ error_propagate(errp, err);
+}
+
+void msix_save(PCIDevice *dev, Visitor *v, Error **errp)
+{
if (!(dev->cap_present & QEMU_PCI_CAP_MSIX)) {
return;
}
-
- qemu_put_buffer(f, dev->msix_table_page, n * PCI_MSIX_ENTRY_SIZE);
- qemu_put_buffer(f, dev->msix_table_page + MSIX_PAGE_PENDING, (n + 7) / 8);
+ msix_visit(v, dev, errp);
}
/* Should be called after restoring the config space. */
-void msix_load(PCIDevice *dev, QEMUFile *f)
+void msix_load(PCIDevice *dev, Visitor *v, Error **errp)
{
- unsigned n = dev->msix_entries_nr;
-
if (!(dev->cap_present & QEMU_PCI_CAP_MSIX)) {
return;
}
msix_free_irq_entries(dev);
- qemu_get_buffer(f, dev->msix_table_page, n * PCI_MSIX_ENTRY_SIZE);
- qemu_get_buffer(f, dev->msix_table_page + MSIX_PAGE_PENDING, (n + 7) / 8);
+ msix_visit(v, dev, errp);
}
/* Does device support MSI-X? */
diff --git a/hw/msix.h b/hw/msix.h
index 7e04336..e60ab10 100644
--- a/hw/msix.h
+++ b/hw/msix.h
@@ -13,8 +13,8 @@ void msix_write_config(PCIDevice *pci_dev, uint32_t address,
int msix_uninit(PCIDevice *d, MemoryRegion *bar);
-void msix_save(PCIDevice *dev, QEMUFile *f);
-void msix_load(PCIDevice *dev, QEMUFile *f);
+void msix_save(PCIDevice *dev, Visitor *v, Error **errp);
+void msix_load(PCIDevice *dev, Visitor *v, Error **errp);
int msix_enabled(PCIDevice *dev);
int msix_present(PCIDevice *dev);
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 9092c02..ca9cabc 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -107,7 +107,7 @@ static void virtio_pci_save_config(void * opaque, QEMUFile *f)
Error *err = NULL;
pci_device_save(&proxy->pci_dev, f);
- msix_save(&proxy->pci_dev, f);
+ msix_save(&proxy->pci_dev, v, &err);
if (msix_present(&proxy->pci_dev)) {
visit_type_uint16(v, &proxy->vdev->config_vector,
"proxy.vdev.config_vector", &err);
@@ -148,7 +148,7 @@ static int virtio_pci_load_config(void * opaque, QEMUFile *f)
if (ret) {
goto out;
}
- msix_load(&proxy->pci_dev, f);
+ msix_load(&proxy->pci_dev, v, &err);
if (msix_present(&proxy->pci_dev)) {
visit_type_uint16(v, &proxy->vdev->config_vector,
"proxy.vdev.config_vector", &err);
--
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 ` [Qemu-devel] [PATCH 03/13] virtio-pci: convert save/load to visitors Michael Roth
2011-10-27 18:17 ` Michael Roth [this message]
2011-10-27 18:17 ` [Qemu-devel] [PATCH 05/13] openpic: " 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-5-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).