[sheepdog-users] Error in processing snapshot name in dog vdi command

Hitoshi Mitake mitake.hitoshi at gmail.com
Sat Apr 19 06:49:36 CEST 2014


At Fri, 18 Apr 2014 16:15:50 -0500,
Scott Devoid wrote:
> 
> I am getting an error with the following command:
> vdi snapshot -s 87cfe950-fada-4cd8-960d-17d9227ff74a_disk_tmp
> a68a173e-e6f0-414c-b036-c7a09abacbbb -a localhost -p 7000
> 
> Stderr: 'Please specify a non-integer value for a snapshot tag name'
> 
> This is with the 0.6.0 version which has the following for the vdi_parser
> function (collie/vdi.c):
>     case 's':
>         vdi_cmd_data.snapshot_id = strtol(opt, &p, 10);
>         if (opt == p) {
>             vdi_cmd_data.snapshot_id = 0;
>             pstrcpy(vdi_cmd_data.snapshot_tag,
>                 sizeof(vdi_cmd_data.snapshot_tag), opt);
>         } else if (vdi_cmd_data.snapshot_id == 0) {
>             fprintf(stderr,
>                 "The snapshot id must be larger than zero\n");
>             exit(EXIT_FAILURE);
>         }
>         break;
> 
> 
> The current version looks like this (dog/vdi.c):
>     case 's':
>         vdi_cmd_data.snapshot_id = strtol(opt, &p, 10);
>         if (opt == p || *p != '\0') {
>             vdi_cmd_data.snapshot_id = 0;
>             pstrcpy(vdi_cmd_data.snapshot_tag,
>                 sizeof(vdi_cmd_data.snapshot_tag), opt);
>         } else if (vdi_cmd_data.snapshot_id == 0) {
>             fprintf(stderr,
>                 "The snapshot id must be larger than zero\n");
>             exit(EXIT_FAILURE);
>         }
>         break;
> 
> Based on my reading, this will still have the problem, although my C is
> quite rusty.

The problem is removed in the commit 669ca92c5bf2 (it is already
backported to stable-0.7 and stable-0.8). The commit is for snapshot
tags which start with decimal number like your case.

In such a case, the condition *p != '\0' will be true and opt is used
as vdi_cmd_data.snapshot_tag.

Thanks,
Hitoshi



More information about the sheepdog-users mailing list