Re: [PATCH v2 5/6] storage: add support for creating qcow3 images

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 05, 2013 at 12:56:16PM +0100, Ján Tomko wrote:
> diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
> index f9e604a..e4c586d 100644
> --- a/src/storage/storage_backend.c
> +++ b/src/storage/storage_backend.c
> @@ -654,6 +654,75 @@ cleanup:
>      return ret;
>  }
>  
> +static int virStorageBackendQEMUImgOpts(const char *qemuimg, virBitmapPtr opts)
> +{
> +    char *buf = NULL;
> +    char *p, *q = NULL, *r;
> +    int ret = -1;
> +    int val;
> +    virCommandPtr cmd = virCommandNewArgList(qemuimg, "create", "-o", "?",
> +                                             "-f", "qcow2", "/dev/null", NULL);
> +

I can understand why you're doing this, but gives me a really bad
feeling. After 5 years we've finally stopped parsing -help from
the QEMU binary...only to start doing the same for qemu-img.


> +    virCommandAddEnvString(cmd, "LC_ALL=C");
> +    virCommandSetOutputBuffer(cmd, &buf);
> +
> +    if (virCommandRun(cmd, NULL) < 0)
> +        goto cleanup;
> +
> +
> +    q = strchr(buf, '\n');
> +    while (q) {
> +        p = q + 1;
> +        q = strchr(p, '\n');
> +        if (STRPREFIX(p, "compat ")) {
> +            ret = 1;
> +            if (opts)
> +                continue;
> +            else
> +                goto cleanup;
> +        }
> +        r = strchr(p, ' ');
> +        if (!r)
> +            goto cleanup;
> +        *r = '\0';
> +        val = virStorageFileFeaturesQcow3TypeFromString(p);
> +        if (val >= 0)
> +            ignore_value(virBitmapSetBit(opts, val));
> +    }
> +
> +    if (ret < 0)
> +        ret = 0;
> +
> +cleanup:
> +    virCommandFree(cmd);
> +    VIR_FREE(buf);
> +    return ret;
> +}

IMHO we should just invoke qemu-img with the feature list we have, and
rely on it to report any unsupported features itself, rather than trying
to pre-detect them ourselves.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]