From: Fam Zheng <famz@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: kwolf@redhat.com, pbonzini@redhat.com, imain@redhat.com,
qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [RFC PATCH 3/4] qmp: Add "snapshot=" option to nbd-server-add
Date: Thu, 22 Aug 2013 16:53:20 +0800 [thread overview]
Message-ID: <20130822085320.GA14691@T430s.nay.redhat.com> (raw)
In-Reply-To: <20130821130203.GB11975@stefanha-thinkpad.redhat.com>
On Wed, 08/21 15:02, Stefan Hajnoczi wrote:
> On Mon, Jul 29, 2013 at 12:25:31PM +0800, Fam Zheng wrote:
> > +/* create a point-in-time snapshot BDS from an existing BDS */
> > +static BlockDriverState *nbd_create_snapshot(BlockDriverState *orig_bs)
> > +{
> > + int ret;
> > + char filename[1024];
> > + BlockDriver *drv;
> > + BlockDriverState *bs;
> > + QEMUOptionParameter *options;
> > + Error *local_err = NULL;
> > +
> > + bs = bdrv_new("");
> > + ret = get_tmp_filename(filename, sizeof(filename));
> > + if (ret < 0) {
> > + goto err;
>
> unlink(filename) is not safe if this function returns an error.
>
> It is simpler if you get the temporary filename first and then do
> bdrv_new().
>
> > + }
> > + drv = bdrv_find_format("qcow2");
> > + if (drv < 0) {
> > + goto err;
> > + }
> > + options = parse_option_parameters("", drv->create_options, NULL);
> > + set_option_parameter_int(options, BLOCK_OPT_SIZE, bdrv_getlength(orig_bs));
> > +
> > + ret = bdrv_create(drv, filename, options);
>
> This is handy but only works if the QEMU process has permission to
> create temporary files.
>
Yes, this is a shortcut, it has this limitation, but the good side is
it's easy to get and no other dependency.
To avoid creating file, we'll need blockdev-add to override backing_hd,
and blockdev-backup to use an existing BDS as target, then we simply use
current nbd-server-add to export it.
This series is still RFC, with above said, we still need to decide which
is the way we (QEMU and libvirt) want for 1.7. any thoughts?
Thanks
Fam
next prev parent reply other threads:[~2013-08-22 8:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-29 4:25 [Qemu-devel] [RFC PATCH 0/4] hmp/qmp: add snapshot option to nbd export Fam Zheng
2013-07-29 4:25 ` [Qemu-devel] [RFC PATCH 1/4] block/backup: delete target after completion callback Fam Zheng
2013-08-21 18:37 ` Eric Blake
2013-07-29 4:25 ` [Qemu-devel] [RFC PATCH 2/4] nbd: call drive_put_ref() only if dinfo exists Fam Zheng
2013-08-21 12:47 ` Stefan Hajnoczi
2013-07-29 4:25 ` [Qemu-devel] [RFC PATCH 3/4] qmp: Add "snapshot=" option to nbd-server-add Fam Zheng
2013-08-21 13:02 ` Stefan Hajnoczi
2013-08-21 18:40 ` Eric Blake
2013-08-22 8:53 ` Fam Zheng [this message]
2013-08-22 9:22 ` Paolo Bonzini
2013-08-22 9:42 ` Fam Zheng
2013-08-26 8:07 ` Fam Zheng
2013-08-21 18:42 ` Eric Blake
2013-07-29 4:25 ` [Qemu-devel] [RFC PATCH 4/4] hmp: add -s switch to nbd_server_add Fam Zheng
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=20130822085320.GA14691@T430s.nay.redhat.com \
--to=famz@redhat.com \
--cc=imain@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.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).