Patchwork [2/9] vring: introduce vring_restore() to restore from img

login
register
mail settings
Submitter pingfan liu
Date Feb. 21, 2013, 12:54 p.m.
Message ID <1361451293-5181-3-git-send-email-qemulist@gmail.com>
Download mbox | patch
Permalink /patch/222276/
State New
Headers show

Comments

pingfan liu - Feb. 21, 2013, 12:54 p.m.
From: Liu Ping Fan <pingfank@linux.vnet.ibm.com>

Re-initialize the members of vring correctly is required when
restored from img.

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
 hw/dataplane/vring.c |    6 ++++++
 hw/dataplane/vring.h |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/dataplane/vring.c b/hw/dataplane/vring.c
index 865bd4d..0a540b4 100644
--- a/hw/dataplane/vring.c
+++ b/hw/dataplane/vring.c
@@ -48,6 +48,12 @@  bool vring_setup(Vring *vring, VirtIODevice *vdev, int n)
     return true;
 }
 
+void vring_restore(Vring *vring, uint16_t last_avail_idx)
+{
+    vring->last_avail_idx = last_avail_idx;
+    vring->last_used_idx = vring->vr.used->idx;
+}
+
 void vring_teardown(Vring *vring)
 {
     hostmem_finalize(&vring->hostmem);
diff --git a/hw/dataplane/vring.h b/hw/dataplane/vring.h
index 0d00500..9938bf9 100644
--- a/hw/dataplane/vring.h
+++ b/hw/dataplane/vring.h
@@ -49,6 +49,7 @@  static inline void vring_set_broken(Vring *vring)
     vring->broken = true;
 }
 
+void vring_restore(Vring *vring, uint16_t last_avail_idx);
 bool vring_setup(Vring *vring, VirtIODevice *vdev, int n);
 void vring_teardown(Vring *vring);
 void vring_disable_notification(VirtIODevice *vdev, Vring *vring);