qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Corey Bryant <coreyb@linux.vnet.ibm.com>
Cc: aliguori@us.ibm.com, stefanb@linux.vnet.ibm.com,
	mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org,
	jschopp@linux.vnet.ibm.com, stefanha@redhat.com,
	lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/7] vnvram: VNVRAM bdrv support
Date: Fri, 24 May 2013 15:06:22 +0200	[thread overview]
Message-ID: <20130524130622.GA3426@dhcp-200-207.str.redhat.com> (raw)
In-Reply-To: <1369331087-22345-2-git-send-email-coreyb@linux.vnet.ibm.com>

Am 23.05.2013 um 19:44 hat Corey Bryant geschrieben:
> Provides low-level VNVRAM functionality that reads and writes data,
> such as an entry's binary blob, to a drive image using the block
> driver.
> 
> Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>

> +/*
> + * Increase the drive size if it's too small to fit the VNVRAM data
> + */
> +static int vnvram_drv_adjust_size(VNVRAM *vnvram)
> +{
> +    int rc = 0;
> +    int64_t needed_size;
> +
> +    needed_size = 0;
> +
> +    if (bdrv_getlength(vnvram->bds) < needed_size) {
> +        rc = bdrv_truncate(vnvram->bds, needed_size);
> +        if (rc != 0) {
> +            DPRINTF("%s: VNVRAM drive too small\n", __func__);
> +        }
> +    }
> +
> +    return rc;
> +}

This function doesn't make a whole lot of sense. It truncates the file
to size 0 if and only if bdrv_getlength() returns an error.

> +
> +/*
> + * Write a header to the drive with entry count of zero
> + */
> +static int vnvram_drv_hdr_create_empty(VNVRAM *vnvram)
> +{
> +    VNVRAMDrvHdr hdr;
> +
> +    hdr.version = VNVRAM_CURRENT_VERSION;
> +    hdr.magic = VNVRAM_MAGIC;
> +    hdr.num_entries = 0;
> +
> +    vnvram_drv_hdr_cpu_to_be((&hdr));
> +
> +    if (bdrv_pwrite(vnvram->bds, 0, (&hdr), sizeof(hdr)) != sizeof(hdr)) {
> +        DPRINTF("%s: Write of header to drive failed\n", __func__);
> +        return -EIO;
> +    }
> +
> +    vnvram->end_offset = sizeof(VNVRAMDrvHdr);
> +
> +    return 0;
> +}
> +
> +/*
> + * Read the header from the drive
> + */
> +static int vnvram_drv_hdr_read(VNVRAM *vnvram, VNVRAMDrvHdr *hdr)
> +{
> +    if (bdrv_pread(vnvram->bds, 0, hdr, sizeof(*hdr)) != sizeof(*hdr)) {
> +        DPRINTF("%s: Read of header from drive failed\n", __func__);
> +        return -EIO;
> +    }

Why do you turn all errors into -EIO instead of returning the real error
code? (More instances of the same thing follow)

> +
> +    vnvram_drv_hdr_be_to_cpu(hdr);
> +
> +    return 0;
> +}
> +}

Kevin

  reply	other threads:[~2013-05-24 13:07 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-23 17:44 [Qemu-devel] [PATCH 0/7] VNVRAM persistent storage Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 1/7] vnvram: VNVRAM bdrv support Corey Bryant
2013-05-24 13:06   ` Kevin Wolf [this message]
2013-05-24 15:33     ` Corey Bryant
2013-05-24 15:37       ` Kevin Wolf
2013-05-24 15:47         ` Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 2/7] vnvram: VNVRAM in-memory support Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 3/7] vnvram: VNVRAM bottom-half r/w scheduling support Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 4/7] vnvram: VNVRAM internal APIs Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 5/7] vnvram: VNVRAM additional debug support Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 6/7] main: Initialize VNVRAM Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 7/7] monitor: QMP/HMP support for retrieving VNVRAM details Corey Bryant
2013-05-23 17:59   ` Eric Blake
2013-05-23 18:43     ` Corey Bryant
2013-05-29 17:15   ` Luiz Capitulino
2013-05-29 17:34     ` Corey Bryant
2013-05-23 18:03 ` [Qemu-devel] [PATCH 0/7] VNVRAM persistent storage Anthony Liguori
2013-05-23 18:41   ` Corey Bryant
2013-05-23 19:15     ` Anthony Liguori
2013-05-24 15:27       ` Corey Bryant
2013-05-29 13:34         ` Anthony Liguori
2013-05-24  9:59 ` Stefan Hajnoczi
2013-05-24 12:13   ` Stefan Berger
2013-05-24 12:36     ` Stefan Hajnoczi
2013-05-24 15:39       ` Corey Bryant
2013-05-27  8:40         ` Stefan Hajnoczi

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=20130524130622.GA3426@dhcp-200-207.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=coreyb@linux.vnet.ibm.com \
    --cc=jschopp@linux.vnet.ibm.com \
    --cc=lcapitulino@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanb@linux.vnet.ibm.com \
    --cc=stefanha@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).