All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	qemu-block@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH v3 02/10] qemu-img: add support for --object command line arg
Date: Thu, 21 Jan 2016 16:19:19 +0000	[thread overview]
Message-ID: <20160121161919.GP19835@redhat.com> (raw)
In-Reply-To: <1453199832-22523-3-git-send-email-berrange@redhat.com>

On Tue, Jan 19, 2016 at 10:37:04AM +0000, Daniel P. Berrange wrote:
> Allow creation of user creatable object types with qemu-img
> via a new --object command line arg. This will be used to supply
> passwords and/or encryption keys to the various block driver
> backends via the recently added 'secret' object type.
> 
>  # printf letmein > mypasswd.txt
>  # qemu-img info --object secret,id=sec0,file=mypasswd.txt \
>       ...other info args...
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  qemu-img-cmds.hx |  44 ++++-----
>  qemu-img.c       | 266 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  qemu-img.texi    |   8 ++
>  3 files changed, 288 insertions(+), 30 deletions(-)

> +static int object_create(void *opaque, QemuOpts *opts, Error **errp)
> +{
> +    Error *err = NULL;
> +    OptsVisitor *ov;
> +    QDict *pdict;
> +
> +    ov = opts_visitor_new(opts);
> +    pdict = qemu_opts_to_qdict(opts, NULL);
> +
> +    user_creatable_add(pdict, opts_get_visitor(ov), &err);
> +    opts_visitor_cleanup(ov);
> +    QDECREF(pdict);
> +    if (err) {
> +        error_propagate(errp, err);
> +        return -1;
> +    }
> +    return 0;
> +}
> +
>  static int GCC_FMT_ATTR(2, 3) qprintf(bool quiet, const char *fmt, ...)
>  {
>      int ret = 0;
> @@ -273,9 +309,17 @@ static int img_create(int argc, char **argv)
>      char *options = NULL;
>      Error *local_err = NULL;
>      bool quiet = false;
> +    QemuOpts *opts;
>  
>      for(;;) {
> -        c = getopt(argc, argv, "F:b:f:he6o:q");
> +        int option_index = 0;
> +        static const struct option long_options[] = {
> +            {"help", no_argument, 0, 'h'},
> +            {"object", required_argument, 0, OPTION_OBJECT},
> +            {0, 0, 0, 0}
> +        };
> +        c = getopt_long(argc, argv, "F:b:f:he6o:q",
> +                        long_options, &option_index);
>          if (c == -1) {
>              break;
>          }
> @@ -317,6 +361,13 @@ static int img_create(int argc, char **argv)
>          case 'q':
>              quiet = true;
>              break;
> +        case OPTION_OBJECT:
> +            opts = qemu_opts_parse_noisily(qemu_find_opts("object"),
> +                                           optarg, true);
> +            if (!opts) {
> +                exit(1);
> +            }
> +            break;
>          }
>      }
>  
> @@ -332,6 +383,12 @@ static int img_create(int argc, char **argv)
>      }
>      optind++;
>  
> +    if (qemu_opts_foreach(qemu_find_opts("object"),
> +                          object_create,
> +                          NULL, NULL)) {
> +        exit(1);

I realize I neeed to pass '&local_err' as the last param and
add  error_report_err(local_err); before exiting, to get errors
shown to the user.

Likewise for the qemu-io/qemu-nbd patches.


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

  reply	other threads:[~2016-01-21 16:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19 10:37 [Qemu-devel] [PATCH v3 00/10] Make qemu-img/qemu-nbd/qemu-io CLI more flexible Daniel P. Berrange
2016-01-19 10:37 ` [Qemu-devel] [PATCH v3 01/10] qom: add helpers for UserCreatable object types Daniel P. Berrange
2016-01-19 10:37 ` [Qemu-devel] [PATCH v3 02/10] qemu-img: add support for --object command line arg Daniel P. Berrange
2016-01-21 16:19   ` Daniel P. Berrange [this message]
2016-01-19 10:37 ` [Qemu-devel] [PATCH v3 03/10] qemu-nbd: " Daniel P. Berrange
2016-01-19 10:37 ` [Qemu-devel] [PATCH v3 04/10] qemu-io: " Daniel P. Berrange
2016-01-19 10:37 ` [Qemu-devel] [PATCH v3 05/10] qemu-io: allow specifying image as a set of options args Daniel P. Berrange
2016-01-19 10:37 ` [Qemu-devel] [PATCH v3 06/10] qemu-nbd: " Daniel P. Berrange
2016-01-19 10:37 ` [Qemu-devel] [PATCH v3 07/10] qemu-img: " Daniel P. Berrange
2016-01-19 10:37 ` [Qemu-devel] [PATCH v3 08/10] qemu-nbd: don't overlap long option values with short options Daniel P. Berrange
2016-01-19 10:37 ` [Qemu-devel] [PATCH v3 09/10] qemu-nbd: use no_argument/required_argument constants Daniel P. Berrange
2016-01-19 10:37 ` [Qemu-devel] [PATCH v3 10/10] qemu-io: " Daniel P. Berrange

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=20160121161919.GP19835@redhat.com \
    --to=berrange@redhat.com \
    --cc=afaerber@suse.de \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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 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.