Skip to contentSkip to conversation

[6215] snapshot subcommand for qemu-img (Kevin Wolf)

Qemu-devel Applied Anthony Liguori 3 participants 5 messages Jan 7, 2009 – Jan 15, 2009

lore
Share & tools
lore
#0 lore raw

Revision: 6215

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6215
Author:   aliguori
Date:     2009-01-07 17:40:15 +0000 (Wed, 07 Jan 2009)

Log Message:
-----------
snapshot subcommand for qemu-img (Kevin Wolf)

Add snapshot subcommand to qemu-img which allows to list, create, apply and delete snapshots on qcow2 images.

Modified Paths:
--------------
trunk/osdep.h
trunk/qemu-img.c

Modified: trunk/osdep.h
===================================================================

osdep.h +4 -0
@@ -7,6 +7,10 @@
 #include <sys/signal.h>
 #endif
 
+#ifndef _WIN32
+#include <sys/time.h>
+#endif
+
 #ifndef glue
 #define xglue(x, y) x ## y
 #define glue(x, y) xglue(x, y)

Modified: trunk/qemu-img.c
===================================================================

qemu-img.c +121 -0

151 lines not on this page · raw message

#1 lore raw
Quoted 6 lines · Anthony Liguori
qemu-img.c +5 -0
+static void img_snapshot(int argc, char **argv)
+{
+    BlockDriverState *bs;
+    QEMUSnapshotInfo sn;
+    char *filename, *snapshot_name = NULL;

qemu-img.c line 763

Quoted 10 lines
qemu-img.c +10 -0
+    char c;
+    int ret;
+    int action = 0;
+    qemu_timeval tv;
+
+    /* Parse commandline parameters */
+    for(;;) {
+        c = getopt(argc, argv, "la:c:d:h");
+        if (c == -1)
+            break;

char's are not always signed so this code is incorrect. You should use an int instead. Can you send another patch fixing this please?

Regards,

Anthony Liguori

#2 lore raw

In message: <[email protected]>
Anthony Liguori <[email protected]> writes:
: Anthony Liguori wrote:
: > +static void img_snapshot(int argc, char **argv) : > +{

: > +    BlockDriverState *bs;
: > +    QEMUSnapshotInfo sn;
: > +    char *filename, *snapshot_name = NULL;
: > +    char c;
: > +    int ret;
: > +    int action = 0;
: > +    qemu_timeval tv;

: > +
: > + /* Parse commandline parameters */
: > + for(;;) {
: > + c = getopt(argc, argv, "la:c:d:h");
: > + if (c == -1)
: > + break;
: >
:
: char's are not always signed so this code is incorrect. You should use : an int instead. Can you send another patch fixing this please?

More importantly, getopt returns an 'int' not a 'signed char'. This means it can report values that can't be represented by a 'signed char'.

Warner

#3 lore raw

PATCH 1/1 qemu-img: Fix type of getopt return value

In reply to Anthony Liguori
Quoted 12 lines · Anthony Liguori
Quoted 11 lines · Anthony Liguori
(quoted diff) +11 -0
+static void img_snapshot(int argc, char **argv)
+{
+    BlockDriverState *bs;
+    QEMUSnapshotInfo sn;
+    char *filename, *snapshot_name = NULL;
+    char c;
+    int ret;
+    int action = 0;
+    qemu_timeval tv;
+
+    /* Parse commandline parameters */
Quoted 8 lines

Review

Quoted 5 lines
(quoted diff) +4 -0
+    for(;;) {
+        c = getopt(argc, argv, "la:c:d:h");
+        if (c == -1)
+            break;

char's are not always signed so this code is incorrect. You should use an int instead. Can you send another patch fixing this please?

You're right. I better should have copied not only the parsing but also the declarations... Patch is attached.

Kevin

Quoted 1 line

From 6fd77e3094a6bdd94e353ac7380cac70f5490024 Mon Sep 17 00:00:00 2001

From: Kevin Wolf <[email protected]>
Date: Wed, 14 Jan 2009 09:39:33 +0100
Subject: [PATCH] qemu-img: Fix type of getopt return value

getopt doesn't return a char but an int.

---
 qemu-img.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
qemu-img.c +1 -2
index 964b28b..ed61d3a 100644
@@ -751,8 +751,7 @@ static void img_snapshot(int argc, char **argv)
     BlockDriverState *bs;
     QEMUSnapshotInfo sn;
     char *filename, *snapshot_name = NULL;
-    char c;
-    int ret;
+    int c, ret;
     int action = 0;
     qemu_timeval tv;
 
Signature · 1 line
1.6.0.2
author Applied
#4 lore raw

[Qemu-devel] Re: [PATCH] qemu-img: Fix type of getopt return value

Quoted 25 lines · Kevin Wolf
Quoted 13 lines · Anthony Liguori
Quoted 11 lines · Anthony Liguori
(quoted diff) +11 -0
+static void img_snapshot(int argc, char **argv)
+{
+    BlockDriverState *bs;
+    QEMUSnapshotInfo sn;
+    char *filename, *snapshot_name = NULL;
+    char c;
+    int ret;
+    int action = 0;
+    qemu_timeval tv;
+
+    /* Parse commandline parameters */
Quoted 9 lines

Review

Quoted 6 lines
(quoted diff) +4 -0
+    for(;;) {
+        c = getopt(argc, argv, "la:c:d:h");
+        if (c == -1)
+            break;

char's are not always signed so this code is incorrect. You should use an int instead. Can you send another patch fixing this please?

Quoted 3 lines

You're right. I better should have copied not only the parsing but also the declarations... Patch is attached.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 2 lines

Kevin