Re: [PATCH] LXC: Fix the output units of ram filesystem size

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

 



On 10/08/2013 11:28 AM, Ján Tomko wrote:
> Commit 76b644c added support for adding RAM filesystems to LXC
> domains, with a syntax of:
> <source usage='10' unit='MiB'/>
> where default unit would be KiB per documentation, however the
> XML parser treated sizes without units as bytes.
> 
> When formatting the XML, this was divided by 1024, but the KiB units
> were put inside the 'units' attribute, as opposed to the 'unit'
> attribute the parser looks for.
> 
> The code generating the mount options assumed the size in the domain
> definition to be in KiB, despite it being parsed as B. This worked
> as long as exaclty one re-format of the XML happened (for domains that
> were just created).
> 
> Change the XML output to bytes and fix the documentation.

We still have libvirt in the wild that outputs bogus units= in the XML;
that should still pass the RelaxNG grammar even if it is otherwise ignored.

>          <code>name</code> attribute must be used with
>          <code>type='template'</code>, and the <code>dir</code> attribute must
>          be used with <code>type='mount'</code>. The <code>usage</code> attribute
> -        is used with <code>type='ram'</code> to set the memory limit in KB.
> +        is used with <code>type='ram'</code> to set the memory limit in bytes.

If the RelaxNG is fixed to parse the broken output, then this could
document that <code>units</code> is ignored.

> +++ b/src/conf/domain_conf.c
> @@ -14764,8 +14764,8 @@ virDomainFSDefFormat(virBufferPtr buf,
>          break;
>  
>      case VIR_DOMAIN_FS_TYPE_RAM:
> -        virBufferAsprintf(buf, "      <source usage='%lld' units='KiB'/>\n",
> -                          def->usage / 1024);
> +        virBufferAsprintf(buf, "      <source usage='%lld' unit='B'/>\n",
> +                          def->usage);

Wait.  This says older libvirt was outputting k, not bytes.  If that's
true, then we MUST continue to output k.

>          break;
>      }
>  
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index b1f429c..7c722cc 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -1428,7 +1428,7 @@ static int lxcContainerMountFSTmpfs(virDomainFSDefPtr fs,
>      VIR_DEBUG("usage=%lld sec=%s", fs->usage, sec_mount_options);
>  
>      if (virAsprintf(&data,
> -                    "size=%lldk%s", fs->usage, sec_mount_options) < 0)
> +                    "size=%lld%s", fs->usage, sec_mount_options) < 0)

I'm also not convince on this change - if the XML contains k by default,
then we must continue to pass k to the mount command.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
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]