Skip to content

Commit 0175409

Browse files
committed
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
virtio fix for 2.4 Fixes migration in virtio 1 mode. We still have a known bug with memory hotplug, it doesn't look like we can fix that in time for 2.4. Signed-off-by: Michael S. Tsirkin <[email protected]> # gpg: Signature made Wed 05 Aug 2015 15:57:39 BST using RSA key ID D28D5469 # gpg: Good signature from "Michael S. Tsirkin <[email protected]>" # gpg: aka "Michael S. Tsirkin <[email protected]>" * remotes/mst/tags/for_upstream: virtio: fix 1.0 virtqueue migration Signed-off-by: Peter Maydell <[email protected]>
2 parents e94867e + 74aae7b commit 0175409

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

hw/virtio/virtio.c

+56
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,61 @@ static bool virtio_64bit_features_needed(void *opaque)
10491049
return (vdev->host_features >> 32) != 0;
10501050
}
10511051

1052+
static bool virtio_virtqueue_needed(void *opaque)
1053+
{
1054+
VirtIODevice *vdev = opaque;
1055+
1056+
return virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1);
1057+
}
1058+
1059+
static void put_virtqueue_state(QEMUFile *f, void *pv, size_t size)
1060+
{
1061+
VirtIODevice *vdev = pv;
1062+
int i;
1063+
1064+
for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
1065+
qemu_put_be64(f, vdev->vq[i].vring.avail);
1066+
qemu_put_be64(f, vdev->vq[i].vring.used);
1067+
}
1068+
}
1069+
1070+
static int get_virtqueue_state(QEMUFile *f, void *pv, size_t size)
1071+
{
1072+
VirtIODevice *vdev = pv;
1073+
int i;
1074+
1075+
for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
1076+
vdev->vq[i].vring.avail = qemu_get_be64(f);
1077+
vdev->vq[i].vring.used = qemu_get_be64(f);
1078+
}
1079+
return 0;
1080+
}
1081+
1082+
static VMStateInfo vmstate_info_virtqueue = {
1083+
.name = "virtqueue_state",
1084+
.get = get_virtqueue_state,
1085+
.put = put_virtqueue_state,
1086+
};
1087+
1088+
static const VMStateDescription vmstate_virtio_virtqueues = {
1089+
.name = "virtio/virtqueues",
1090+
.version_id = 1,
1091+
.minimum_version_id = 1,
1092+
.needed = &virtio_virtqueue_needed,
1093+
.fields = (VMStateField[]) {
1094+
{
1095+
.name = "virtqueues",
1096+
.version_id = 0,
1097+
.field_exists = NULL,
1098+
.size = 0,
1099+
.info = &vmstate_info_virtqueue,
1100+
.flags = VMS_SINGLE,
1101+
.offset = 0,
1102+
},
1103+
VMSTATE_END_OF_LIST()
1104+
}
1105+
};
1106+
10521107
static const VMStateDescription vmstate_virtio_device_endian = {
10531108
.name = "virtio/device_endian",
10541109
.version_id = 1,
@@ -1082,6 +1137,7 @@ static const VMStateDescription vmstate_virtio = {
10821137
.subsections = (const VMStateDescription*[]) {
10831138
&vmstate_virtio_device_endian,
10841139
&vmstate_virtio_64bit_features,
1140+
&vmstate_virtio_virtqueues,
10851141
NULL
10861142
}
10871143
};

include/hw/virtio/virtio.h

+6
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ static inline bool virtio_has_feature(VirtIODevice *vdev, unsigned int fbit)
272272
return __virtio_has_feature(vdev->guest_features, fbit);
273273
}
274274

275+
static inline bool virtio_host_has_feature(VirtIODevice *vdev,
276+
unsigned int fbit)
277+
{
278+
return __virtio_has_feature(vdev->host_features, fbit);
279+
}
280+
275281
static inline bool virtio_is_big_endian(VirtIODevice *vdev)
276282
{
277283
if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) {

0 commit comments

Comments
 (0)