[libvirt] [PATCH] qemu: Forbid snapshot names starting with '.'

Martin Kletzander mkletzan at redhat.com
Tue Jan 22 10:31:47 UTC 2013


On 01/21/2013 10:10 PM, Peter Krempa wrote:
> Forbid the names to match the loading procedure of snapshots.
> ---
>  src/qemu/qemu_driver.c | 24 +++++++++++++++++-------
>  1 file changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 3a54228..8286334 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -11348,13 +11348,23 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
>          goto cleanup;
> 
>      /* reject snapshot names containing slashes as snapshot definitions are
> -     * saved in files containing the name */
> -    if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) &&
> -        strchr(def->name, '/')) {
> -        virReportError(VIR_ERR_XML_DETAIL,
> -                       _("invalid snapshot name '%s': name can't contain '/'"),
> -                       def->name);
> -        goto cleanup;
> +     * saved in files containing the name and names starting with dots */
> +    if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
> +        if (strchr(def->name, '/')) {
> +            virReportError(VIR_ERR_XML_DETAIL,
> +                           _("invalid snapshot name '%s': "
> +                             "name can't contain '/'"),
> +                           def->name);
> +            goto cleanup;
> +        }
> +
> +        if (def->name[0] == '.') {
> +            virReportError(VIR_ERR_XML_DETAIL,
> +                           _("invalid snapshot name '%s': "
> +                             "name can't start with '.'"),
> +                           def->name);
> +            goto cleanup;
> +        }
>      }
> 
>      /* reject the VIR_DOMAIN_SNAPSHOT_CREATE_LIVE flag where not supported */
> 

I'd change the comment to something more readable, like "reject snapshot
names containing slashes or starting with dot as snapshot definitions
are saved in files containing the name" for example, but it's just a
comment, so ACK either way.

Martin




More information about the libvir-list mailing list