[Libvir] PATCH: 14/16: disk partition backend

Jim Meyering jim at meyering.net
Fri Feb 15 18:52:37 UTC 2008


"Daniel P. Berrange" <berrange at redhat.com> wrote:
> +static int virStorageBackendDiskCreateVol(virConnectPtr conn,
> +                                          virStoragePoolObjPtr pool,
> +                                          virStorageVolDefPtr vol)
> +{
> +    int i;
> +    char start[100], end[100];
> +    unsigned long long startOffset, endOffset, smallestSize = 0, smallestExtent = -1;

[Past column 80 -> harder to spot]
unsigned... = -1; ?

How about this instead, since smallestExtent only ever
gets set to values stored in "i" (an int)?

    int smallestExtent = -1;

> +    virStoragePoolSourceDevicePtr dev = &pool->def->source.devices[0];
> +    /* XXX customizable partition types */
> +    const char *cmdargv[] = {
> +        PARTED,
> +        pool->def->source.devices[0].path,
> +        "mkpart",
> +        "--script",
> +        "ext2",
> +        start,
> +        end,
> +        NULL
> +    };
> +
> +    for (i = 0 ; i < dev->nfreeExtent ; i++) {
> +        unsigned long long size =
> +            dev->freeExtents[i].end -
> +            dev->freeExtents[i].start;

Shouldn't size be 1 larger?  i.e.,

        unsigned long long size =
            dev->freeExtents[i].end -
            dev->freeExtents[i].start + 1;




More information about the libvir-list mailing list