* [Qemu-devel] [PATCH] qemu-img rebase: Add -f option
@ 2010-03-02 11:14 Kevin Wolf
2010-03-03 8:24 ` [Qemu-devel] " Juan Quintela
2010-03-09 17:22 ` [Qemu-devel] " Anthony Liguori
0 siblings, 2 replies; 3+ messages in thread
From: Kevin Wolf @ 2010-03-02 11:14 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf
Allow the user to specify the format of the image to rebase.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qemu-img.c | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 258dc62..7fc980a 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1081,24 +1081,28 @@ static int img_snapshot(int argc, char **argv)
static int img_rebase(int argc, char **argv)
{
BlockDriverState *bs, *bs_old_backing, *bs_new_backing;
- BlockDriver *old_backing_drv, *new_backing_drv;
+ BlockDriver *drv, *old_backing_drv, *new_backing_drv;
char *filename;
- const char *out_basefmt, *out_baseimg;
+ const char *fmt, *out_basefmt, *out_baseimg;
int c, flags, ret;
int unsafe = 0;
/* Parse commandline parameters */
+ fmt = NULL;
out_baseimg = NULL;
out_basefmt = NULL;
for(;;) {
- c = getopt(argc, argv, "uhF:b:");
+ c = getopt(argc, argv, "uhf:F:b:");
if (c == -1)
break;
switch(c) {
case 'h':
help();
return 0;
+ case 'f':
+ fmt = optarg;
+ break;
case 'F':
out_basefmt = optarg;
break;
@@ -1125,8 +1129,16 @@ static int img_rebase(int argc, char **argv)
if (!bs)
error("Not enough memory");
+ drv = NULL;
+ if (fmt) {
+ drv = bdrv_find_format(fmt);
+ if (drv == NULL) {
+ error("Invalid format name: '%s'", fmt);
+ }
+ }
+
flags = BRDV_O_FLAGS | BDRV_O_RDWR | (unsafe ? BDRV_O_NO_BACKING : 0);
- if (bdrv_open2(bs, filename, flags, NULL) < 0) {
+ if (bdrv_open2(bs, filename, flags, drv) < 0) {
error("Could not open '%s'", filename);
}
--
1.6.6.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Qemu-devel] Re: [PATCH] qemu-img rebase: Add -f option
2010-03-02 11:14 [Qemu-devel] [PATCH] qemu-img rebase: Add -f option Kevin Wolf
@ 2010-03-03 8:24 ` Juan Quintela
2010-03-09 17:22 ` [Qemu-devel] " Anthony Liguori
1 sibling, 0 replies; 3+ messages in thread
From: Juan Quintela @ 2010-03-03 8:24 UTC (permalink / raw)
To: Kevin Wolf; +Cc: qemu-devel
Kevin Wolf <kwolf@redhat.com> wrote:
> Allow the user to specify the format of the image to rebase.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
This is needed to use rebase with qcow2 images on block devices.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-img rebase: Add -f option
2010-03-02 11:14 [Qemu-devel] [PATCH] qemu-img rebase: Add -f option Kevin Wolf
2010-03-03 8:24 ` [Qemu-devel] " Juan Quintela
@ 2010-03-09 17:22 ` Anthony Liguori
1 sibling, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2010-03-09 17:22 UTC (permalink / raw)
To: Kevin Wolf; +Cc: qemu-devel
On 03/02/2010 05:14 AM, Kevin Wolf wrote:
> Allow the user to specify the format of the image to rebase.
>
> Signed-off-by: Kevin Wolf<kwolf@redhat.com>
>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> qemu-img.c | 20 ++++++++++++++++----
> 1 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/qemu-img.c b/qemu-img.c
> index 258dc62..7fc980a 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -1081,24 +1081,28 @@ static int img_snapshot(int argc, char **argv)
> static int img_rebase(int argc, char **argv)
> {
> BlockDriverState *bs, *bs_old_backing, *bs_new_backing;
> - BlockDriver *old_backing_drv, *new_backing_drv;
> + BlockDriver *drv, *old_backing_drv, *new_backing_drv;
> char *filename;
> - const char *out_basefmt, *out_baseimg;
> + const char *fmt, *out_basefmt, *out_baseimg;
> int c, flags, ret;
> int unsafe = 0;
>
> /* Parse commandline parameters */
> + fmt = NULL;
> out_baseimg = NULL;
> out_basefmt = NULL;
>
> for(;;) {
> - c = getopt(argc, argv, "uhF:b:");
> + c = getopt(argc, argv, "uhf:F:b:");
> if (c == -1)
> break;
> switch(c) {
> case 'h':
> help();
> return 0;
> + case 'f':
> + fmt = optarg;
> + break;
> case 'F':
> out_basefmt = optarg;
> break;
> @@ -1125,8 +1129,16 @@ static int img_rebase(int argc, char **argv)
> if (!bs)
> error("Not enough memory");
>
> + drv = NULL;
> + if (fmt) {
> + drv = bdrv_find_format(fmt);
> + if (drv == NULL) {
> + error("Invalid format name: '%s'", fmt);
> + }
> + }
> +
> flags = BRDV_O_FLAGS | BDRV_O_RDWR | (unsafe ? BDRV_O_NO_BACKING : 0);
> - if (bdrv_open2(bs, filename, flags, NULL)< 0) {
> + if (bdrv_open2(bs, filename, flags, drv)< 0) {
> error("Could not open '%s'", filename);
> }
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-09 17:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-02 11:14 [Qemu-devel] [PATCH] qemu-img rebase: Add -f option Kevin Wolf
2010-03-03 8:24 ` [Qemu-devel] " Juan Quintela
2010-03-09 17:22 ` [Qemu-devel] " Anthony Liguori
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).