diff mbox

[bugfix] snapshot: fix referencing wrong variable in while loop in do_delvm

Message ID 201409291512397046850@sangfor.com
State New
Headers show

Commit Message

Zhang Haoyu Sept. 29, 2014, 7:12 a.m. UTC
The while loop variabal is "bs1", but "bs" is always passed to bdrv_snapshot_delete_by_id_or_name.

Signed-off-by: Zhang Haoyu <zhanghy@sangfor.com>
---
 savevm.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Markus Armbruster Sept. 29, 2014, 8:14 a.m. UTC | #1
"Zhang Haoyu" <zhanghy@sangfor.com> writes:

> The while loop variabal is "bs1", but "bs" is always passed to bdrv_snapshot_delete_by_id_or_name.

Please limit commit message line length to around 70 characters.

>
> Signed-off-by: Zhang Haoyu <zhanghy@sangfor.com>
> ---
>  savevm.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/savevm.c b/savevm.c
> index e19ae0a..2d8eb96 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -1245,19 +1245,18 @@ int load_vmstate(const char *name)
>  
>  void do_delvm(Monitor *mon, const QDict *qdict)
>  {
> -    BlockDriverState *bs, *bs1;
> +    BlockDriverState *bs;
>      Error *err = NULL;
>      const char *name = qdict_get_str(qdict, "name");
>  
> -    bs = find_vmstate_bs();
> -    if (!bs) {
> +    if (!find_vmstate_bs()) {
>          monitor_printf(mon, "No block device supports snapshots\n");
>          return;
>      }
>  
> -    bs1 = NULL;
> -    while ((bs1 = bdrv_next(bs1))) {
> -        if (bdrv_can_snapshot(bs1)) {
> +    bs = NULL;
> +    while ((bs = bdrv_next(bs))) {
> +        if (bdrv_can_snapshot(bs)) {
>              bdrv_snapshot_delete_by_id_or_name(bs, name, &err);
>              if (err) {
>                  monitor_printf(mon,

Ouch!

Broken in commit a89d89d, v1.7.0.  If you add that to your commit
message, you can also add

Reviewed-by: Markus Armbruster <armbru@redhat.com>
diff mbox

Patch

diff --git a/savevm.c b/savevm.c
index e19ae0a..2d8eb96 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1245,19 +1245,18 @@  int load_vmstate(const char *name)
 
 void do_delvm(Monitor *mon, const QDict *qdict)
 {
-    BlockDriverState *bs, *bs1;
+    BlockDriverState *bs;
     Error *err = NULL;
     const char *name = qdict_get_str(qdict, "name");
 
-    bs = find_vmstate_bs();
-    if (!bs) {
+    if (!find_vmstate_bs()) {
         monitor_printf(mon, "No block device supports snapshots\n");
         return;
     }
 
-    bs1 = NULL;
-    while ((bs1 = bdrv_next(bs1))) {
-        if (bdrv_can_snapshot(bs1)) {
+    bs = NULL;
+    while ((bs = bdrv_next(bs))) {
+        if (bdrv_can_snapshot(bs)) {
             bdrv_snapshot_delete_by_id_or_name(bs, name, &err);
             if (err) {
                 monitor_printf(mon,