From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=51033 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOGvK-0005wM-By for qemu-devel@nongnu.org; Mon, 14 Jun 2010 17:10:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OOGvI-0001Xa-O1 for qemu-devel@nongnu.org; Mon, 14 Jun 2010 17:10:26 -0400 Received: from mail-iw0-f173.google.com ([209.85.214.173]:58093) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OOGvI-0001XV-IG for qemu-devel@nongnu.org; Mon, 14 Jun 2010 17:10:24 -0400 Received: by iwn10 with SMTP id 10so4595444iwn.4 for ; Mon, 14 Jun 2010 14:10:23 -0700 (PDT) Message-ID: <4C169AC0.5030305@codemonkey.ws> Date: Mon, 14 Jun 2010 16:10:24 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 1/4] savevm: refactor qemu_loadvm_state(). References: <1275549747-18061-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> <1275549747-18061-2-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> In-Reply-To: <1275549747-18061-2-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Yoshiaki Tamura Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org On 06/03/2010 02:22 AM, Yoshiaki Tamura wrote: > Split qemu_loadvm_state(), and introduce > qemu_loadvm_state_{begin,iterate,complete,async}. > qemu_loadvm_state_async() is a function to handle a single incoming > section. > > Signed-off-by: Yoshiaki Tamura > --- > savevm.c | 206 +++++++++++++++++++++++++++++++++++++++++++------------------- > sysemu.h | 2 + > 2 files changed, 146 insertions(+), 62 deletions(-) > > diff --git a/savevm.c b/savevm.c > index dc20390..aa4f98c 100644 > --- a/savevm.c > +++ b/savevm.c > @@ -1005,6 +1005,8 @@ typedef struct SaveStateEntry { > > static QTAILQ_HEAD(savevm_handlers, SaveStateEntry) savevm_handlers = > QTAILQ_HEAD_INITIALIZER(savevm_handlers); > +static QLIST_HEAD(, LoadStateEntry) loadvm_handlers = > + QLIST_HEAD_INITIALIZER(loadvm_handlers); > static int global_section_id; > > static int calculate_new_instance_id(const char *idstr) > @@ -1460,14 +1462,9 @@ typedef struct LoadStateEntry { > int version_id; > } LoadStateEntry; > > -int qemu_loadvm_state(QEMUFile *f) > +int qemu_loadvm_state_begin(QEMUFile *f) > { > - QLIST_HEAD(, LoadStateEntry) loadvm_handlers = > - QLIST_HEAD_INITIALIZER(loadvm_handlers); > - LoadStateEntry *le, *new_le; > - uint8_t section_type; > unsigned int v; > - int ret; > > v = qemu_get_be32(f); > if (v != QEMU_VM_FILE_MAGIC) > @@ -1481,73 +1478,157 @@ int qemu_loadvm_state(QEMUFile *f) > if (v != QEMU_VM_FILE_VERSION) > return -ENOTSUP; > > - while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) { > - uint32_t instance_id, version_id, section_id; > - SaveStateEntry *se; > - char idstr[257]; > - int len; > + return 0; > +} > > - switch (section_type) { > - case QEMU_VM_SECTION_START: > - case QEMU_VM_SECTION_FULL: > - /* Read section start */ > - section_id = qemu_get_be32(f); > - len = qemu_get_byte(f); > - qemu_get_buffer(f, (uint8_t *)idstr, len); > - idstr[len] = 0; > - instance_id = qemu_get_be32(f); > - version_id = qemu_get_be32(f); > - > - /* Find savevm section */ > - se = find_se(idstr, instance_id); > - if (se == NULL) { > - fprintf(stderr, "Unknown savevm section or instance '%s' %d\n", idstr, instance_id); > - ret = -EINVAL; > - goto out; > - } > +static int qemu_loadvm_state_iterate(QEMUFile *f) > +{ > + LoadStateEntry *le; > + uint32_t section_id; > + int ret; > > - /* Validate version */ > - if (version_id> se->version_id) { > - fprintf(stderr, "savevm: unsupported version %d for '%s' v%d\n", > - version_id, idstr, se->version_id); > - ret = -EINVAL; > - goto out; > - } > + section_id = qemu_get_be32(f); > But we're still blocking in qemu_get_be32() so I don't see how this makes it async. Regards, Anthony Liguori