qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/3] block: Image file option amendment
Date: Thu, 29 Aug 2013 14:40:31 +0200	[thread overview]
Message-ID: <521F413F.9030203@redhat.com> (raw)
In-Reply-To: <521F40CA.2080605@redhat.com>

Am 29.08.2013 14:38, schrieb Eric Blake:
> On 08/29/2013 05:20 AM, Max Reitz wrote:
>> This patch adds the "amend" option to qemu-img which allows changing
>> image options on existing image files. It also adds the generic bdrv
>> implementation which is basically just a wrapper for the image format
>> specific function.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>>   
>> +static int img_amend(int argc, char **argv)
>> +{
>> +    int c, ret = 0;
>> +    char *options = NULL;
>> +    QEMUOptionParameter *create_options = NULL, *options_param = NULL;
>> +    const char *fmt = NULL, *filename;
>> +    bool quiet = false;
>> +    BlockDriverState *bs = NULL;
>> +
>> +    for (;;) {
>> +        c = getopt(argc, argv, "h?qf:o:");
> ? is not usually listed in the string to getopt() (doing so is not
> portable to POSIX).  Besides, use of an unknown option (such as -x) will
> get mapped to '?' by getopt anyways, so your goal...
>
>> +        if (c == -1) {
>> +            break;
>> +        }
>> +
>> +        switch (c) {
>> +            case 'h':
>> +            case '?':
>> +                help();
>> +                break;
> ...of printing help on unknown options is already met without the need
> for an explicit '-?' option.
Ah, okay, thanks.

>> +
>> +    filename = argv[argc - 1];
>> +
>> +    bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR, true, quiet);
>> +    if (!bs) {
>> +        error_report("Could not open image.");
> We generally avoid trailing '.' in error messages; it might also be nice
> to report WHICH image could not be opened.
Yes, I'll fix it.

>> +    options_param = parse_option_parameters(options, create_options,
>> +            options_param);
>> +    if (options_param == NULL) {
>> +        error_report("Invalid options for file format '%s'.", fmt);
> again, no trailing '.'
>
>> +++ b/qemu-img.texi
>> @@ -282,6 +282,11 @@ sizes accordingly.  Failure to do so will result in data loss!
>>   After using this command to grow a disk image, you must use file system and
>>   partitioning tools inside the VM to actually begin using the new space on the
>>   device.
>> +
>> +@item amend [-f @var{fmt}] -o @var{options} @var{filename}
>> +
>> +Amends the image format specific @var{options} for the image file
>> +@var{filename}. Only the format @code{qcow2} supports this.
> We might add support for other file formats in the future; we'd have to
> remember to update this sentence at that time.  Could you use a more
> generic statement, such as "not all file formats support this", so we
> don't end up with stale docs if we forget to touch it down the road?
Of course.


Max

  reply	other threads:[~2013-08-29 12:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-29 11:20 [Qemu-devel] [PATCH v2 0/3] block/qcow2: Image file option amendment Max Reitz
2013-08-29 11:20 ` [Qemu-devel] [PATCH v2 1/3] block: " Max Reitz
2013-08-29 12:38   ` Eric Blake
2013-08-29 12:40     ` Max Reitz [this message]
2013-08-29 11:20 ` [Qemu-devel] [PATCH v2 2/3] qcow2: Implement bdrv_amend_options Max Reitz
2013-08-29 12:45   ` Eric Blake
2013-08-29 12:52     ` Max Reitz
2013-08-29 13:00       ` Kevin Wolf
2013-08-29 11:20 ` [Qemu-devel] [PATCH v2 3/3] qemu-iotest: qcow2 image option amendment Max Reitz

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=521F413F.9030203@redhat.com \
    --to=mreitz@redhat.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --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).