qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] add bdrv->create function for host_device
Date: Thu, 26 Mar 2009 08:11:09 -0500	[thread overview]
Message-ID: <49CB7EED.7070706@us.ibm.com> (raw)
In-Reply-To: <1237258665.15350.67.camel@voxel>

Nolan wrote:
> "qemu-img convert" tries to create the destination image by calling it's
> ->create function.  host_devices do not currently have one, since host
> devices are not created like normal images are.  A reasonable analog of
> create for host devices is verifying that they have the appropriate
> properties.
>
> This patch adds that verification.
>
> It also fixes a typo that caused qemu-img to print the wrong device type
> in the error message informing the user that the destination device did
> not support creation.
>
> Signed-off-by: Nolan Leake <nolan <at> sigbus.net>
>
> Index: block-raw-posix.c
> ===================================================================
> --- block-raw-posix.c	(revision 6718)
> +++ block-raw-posix.c	(working copy)
> @@ -1132,6 +1132,32 @@
>  
>      return ioctl(s->fd, req, buf);
>  }
> +
> +static int hdev_create(const char *filename, int64_t total_size,
> +                       const char *backing_file, int flags)
> +{
> +    int fd;
> +    int ret = 0;
> +    struct stat stat_buf;
> +
> +    if (flags || backing_file)
> +        return -ENOTSUP;
> +
> +    fd = open(filename, O_WRONLY | O_BINARY);
> +    if (fd < 0)
> +        return -EIO;
> +
> +    if (fstat(fd, &stat_buf) < 0)
> +        ret = -EIO;
> +    else if (!S_ISBLK(stat_buf.st_mode))
> +        ret = -EIO;
> +    else if (lseek(fd, 0, SEEK_END) < total_size * 512)
> +        ret = -ENOSPC;
> +
> +    close(fd);
> +    return ret;
> +}
>   

I'm not quite sure how, but I think you need to have BDRV_O_FILE as a 
special case.  I think probably the easiest thing to do is to bail out 
if BDRV_O_FILE is set since a physical device cannot be growable.

Regards,

Anthony Liguori

>
>   

  reply	other threads:[~2009-03-26 13:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-17  2:57 [Qemu-devel] [PATCH] add bdrv->create function for host_device Nolan
2009-03-26 13:11 ` Anthony Liguori [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-03-27  0:03 Nolan

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=49CB7EED.7070706@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /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).