All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Cc: pbonzini@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org,
	stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH V5 2/5] qemu-nbd: support internal snapshot export
Date: Tue, 19 Nov 2013 12:26:01 +0100	[thread overview]
Message-ID: <20131119112601.GD4040@dhcp-200-207.str.redhat.com> (raw)
In-Reply-To: <1384121021-24815-3-git-send-email-xiawenc@linux.vnet.ibm.com>

Am 10.11.2013 um 23:03 hat Wenchao Xia geschrieben:
> Now it is possible to directly export an internal snapshot, which
> can be used to probe the snapshot's contents without qemu-img
> convert.
> 
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  block/snapshot.c         |   18 +++++++++++++++++
>  include/block/snapshot.h |    8 +++++++
>  qemu-nbd.c               |   47 ++++++++++++++++++++++++++++++++++++++++++++-
>  qemu-nbd.texi            |    8 ++++++-
>  4 files changed, 78 insertions(+), 3 deletions(-)
> 
> diff --git a/block/snapshot.c b/block/snapshot.c
> index e51a7db..7cc45fa 100644
> --- a/block/snapshot.c
> +++ b/block/snapshot.c
> @@ -25,6 +25,24 @@
>  #include "block/snapshot.h"
>  #include "block/block_int.h"
>  
> +QemuOptsList internal_snapshot_opts = {
> +    .name = "snapshot",
> +    .head = QTAILQ_HEAD_INITIALIZER(internal_snapshot_opts.head),
> +    .desc = {
> +        {
> +            .name = SNAPSHOT_OPT_ID,
> +            .type = QEMU_OPT_STRING,
> +            .help = "snapshot id"
> +        },{
> +            .name = SNAPSHOT_OPT_NAME,
> +            .type = QEMU_OPT_STRING,
> +            .help = "snapshot name"
> +        },{
> +            /* end of list */
> +        }
> +    },
> +};
> +
>  int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
>                         const char *name)
>  {
> diff --git a/include/block/snapshot.h b/include/block/snapshot.h
> index d05bea7..770d9bb 100644
> --- a/include/block/snapshot.h
> +++ b/include/block/snapshot.h
> @@ -27,6 +27,14 @@
>  
>  #include "qemu-common.h"
>  #include "qapi/error.h"
> +#include "qemu/option.h"
> +
> +
> +#define SNAPSHOT_OPT_BASE       "snapshot."
> +#define SNAPSHOT_OPT_ID         "snapshot.id"
> +#define SNAPSHOT_OPT_NAME       "snapshot.name"
> +
> +extern QemuOptsList internal_snapshot_opts;
>  
>  typedef struct QEMUSnapshotInfo {
>      char id_str[128]; /* unique snapshot id */
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index c26c98e..f934eaa 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -20,6 +20,7 @@
>  #include "block/block.h"
>  #include "block/nbd.h"
>  #include "qemu/main-loop.h"
> +#include "block/snapshot.h"
>  
>  #include <stdarg.h>
>  #include <stdio.h>
> @@ -79,7 +80,14 @@ static void usage(const char *name)
>  "\n"
>  "Block device options:\n"
>  "  -r, --read-only      export read-only\n"
> -"  -s, --snapshot       use snapshot file\n"
> +"  -s, --snapshot       use FILE as an external snapshot, create a temporary\n"
> +"                       file with backing_file=FILE, redirect the write to\n"
> +"                       the temporary one\n"
> +"  -l, --load-snapshot=SNAPSHOT_PARAM\n"
> +"                       load an internal snapshot inside FILE and export it\n"
> +"                       as an read-only device, SNAPSHOT_PARAM format is\n"
> +"                       'snapshot.id=[ID],snapshot.name=[NAME]', or\n"
> +"                       '[ID_OR_NAME]'\n"
>  "  -n, --nocache        disable host cache\n"
>  "      --cache=MODE     set cache mode (none, writeback, ...)\n"
>  #ifdef CONFIG_LINUX_AIO
> @@ -315,7 +323,9 @@ int main(int argc, char **argv)
>      char *device = NULL;
>      int port = NBD_DEFAULT_PORT;
>      off_t fd_size;
> -    const char *sopt = "hVb:o:p:rsnP:c:dvk:e:f:t";
> +    QemuOpts *sn_opts = NULL;
> +    const char *sn_id_or_name = NULL;
> +    const char *sopt = "hVb:o:p:rsnP:c:dvk:e:f:tl:";
>      struct option lopt[] = {
>          { "help", 0, NULL, 'h' },
>          { "version", 0, NULL, 'V' },
> @@ -328,6 +338,7 @@ int main(int argc, char **argv)
>          { "connect", 1, NULL, 'c' },
>          { "disconnect", 0, NULL, 'd' },
>          { "snapshot", 0, NULL, 's' },
> +        { "load-snapshot", 1, NULL, 'l' },
>          { "nocache", 0, NULL, 'n' },
>          { "cache", 1, NULL, QEMU_NBD_OPT_CACHE },
>  #ifdef CONFIG_LINUX_AIO
> @@ -428,6 +439,18 @@ int main(int argc, char **argv)
>                  errx(EXIT_FAILURE, "Offset must be positive `%s'", optarg);
>              }
>              break;
> +        case 'l':
> +            if (strncmp(optarg, SNAPSHOT_OPT_BASE, strlen(SNAPSHOT_OPT_BASE))
> +                == 0) {

You can avoid this ugly line break by using strstart():

    if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) {
        ...

Kevin

  reply	other threads:[~2013-11-19 11:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-10 22:03 [Qemu-devel] [PATCH V5 0/5] export internal snapshot by qemu-nbd Wenchao Xia
2013-11-10 22:03 ` [Qemu-devel] [PATCH V5 1/5] snapshot: distinguish id and name in load_tmp Wenchao Xia
2013-11-19 11:20   ` Kevin Wolf
2013-11-22  1:52     ` Wenchao Xia
2013-11-10 22:03 ` [Qemu-devel] [PATCH V5 2/5] qemu-nbd: support internal snapshot export Wenchao Xia
2013-11-19 11:26   ` Kevin Wolf [this message]
2013-11-22  1:53     ` Wenchao Xia
2013-11-10 22:03 ` [Qemu-devel] [PATCH V5 3/5] qemu-iotests: add 058 internal snapshot export with qemu-nbd case Wenchao Xia
2013-11-19 11:29   ` Kevin Wolf
2013-11-22  6:49     ` Wenchao Xia
2013-11-10 22:03 ` [Qemu-devel] [PATCH V5 4/5] qemu-img: add -l for snapshot in convert Wenchao Xia
2013-11-10 22:03 ` [Qemu-devel] [PATCH V5 5/5] qemu-iotests: add test for snapshot in qemu-img convert Wenchao Xia
2013-11-14  2:42 ` [Qemu-devel] [PATCH V5 0/5] export internal snapshot by qemu-nbd Wenchao Xia

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=20131119112601.GD4040@dhcp-200-207.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=jcody@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=xiawenc@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.