From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwAos-0006EW-NI for qemu-devel@nongnu.org; Fri, 18 Jan 2013 07:13:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TwAor-0008Dq-Db for qemu-devel@nongnu.org; Fri, 18 Jan 2013 07:13:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56773) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwAor-0008Dl-5X for qemu-devel@nongnu.org; Fri, 18 Jan 2013 07:13:13 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0ICDCK2031309 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 18 Jan 2013 07:13:12 -0500 From: Juan Quintela Date: Fri, 18 Jan 2013 13:13:10 +0100 Message-ID: <874niek7u1.fsf@elfo.elfo> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] VMSTate state of the union Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel qemu-devel Hi Executive summary: Nothing changed since last time Abstract: Things missing: - cpus: They are blocked by comment that we should be able to sent generated fields. Stalled :-( - slirp: I have preleminary patches for it. Stalled on how to describe LISTS. - virtio: Stalled for even longer. Suspect are LISTS again. - rest of devices: not too much. What is the problem with lists? This is basically the current code that I have for virtio block requests. How to describe then in an easier to use place? This is basically a backport to use open code for it. The problems are: - we need to do malloc() on the receiving side - the "next" pointer can be anywhere (if they are using QLISTS' they can be using any other list structure) - They are (by definiton), a substructure, so we need to pass _also_ a vmstate for it. Any good ideas? Thanks, Juan. -static void virtio_blk_save(QEMUFile *f, void *opaque) +static const VMStateDescription vmstate_virtio_blk_req = { + .name = "virtio-blk-req", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField []) { + VMSTATE_BUFFER_UNSAFE(elem, VirtIOBlockReq, 0, sizeof(VirtQueueElement)), + VMSTATE_END_OF_LIST() + } +}; + +static void put_virtio_req(QEMUFile *f, void *pv, size_t size) { - VirtIOBlock *s = opaque; + VirtIOBlockReqHead *rq = pv; VirtIOBlockReq *req;; - virtio_save(&s->vdev, f); - - QLIST_FOREACH(req, &s->rq, next) { + QLIST_FOREACH(req, rq, next) { qemu_put_sbyte(f, 1); qemu_put_buffer(f, (unsigned char*)&req->elem, sizeof(req->elem)); } qemu_put_sbyte(f, 0); } -static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id) +static int get_virtio_req(QEMUFile *f, void *pv, size_t size) { - VirtIOBlock *s = opaque; + VirtIOBlockReqHead *rq = pv; + VirtIOBlock *s = container_of(rq, struct VirtIOBlock, rq); - if (version_id != 2) - return -EINVAL; - - virtio_load(&s->vdev, f); while (qemu_get_sbyte(f)) { VirtIOBlockReq *req = virtio_blk_alloc_request(s); qemu_get_buffer(f, (unsigned char*)&req->elem, sizeof(req->elem)); @@ -567,6 +573,25 @@ static const BlockDevOps virtio_block_ops = { .resize_cb = virtio_blk_resize, }; +const VMStateInfo vmstate_info_virtio_blk_req = { + .name = "virtio_blk_req", + .get = get_virtio_req, + .put = put_virtio_req, +}; + +static const VMStateDescription vmstate_virtio_blk = { + .name = "virtio-blk", + .version_id = 2, + .minimum_version_id = 2, + .minimum_version_id_old = 2, + .fields = (VMStateField []) { + VMSTATE_VIRTIO(vdev, VirtIOBlock), + VMSTATE_SINGLE(rq, VirtIOBlock, 0, + vmstate_info_virtio_blk_req, VirtIOBlockReqHead), + VMSTATE_END_OF_LIST() + } +}; +