Re: [PATCH v3] libxl: add discard support to libxl_device_disk

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

 



Olaf Hering wrote:
> Translate libvirt discard settings into libxl-4.5 discard settings.
>
> Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
> ---
> v3:
>  passing discard= with old libxl is now a fatal error
> v2:
>  add cast to switch variable to let compiler check if the code handles
>  all enum values
>   

Thanks for addressing the comments.

>  src/libxl/libxl_conf.c | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
>
> diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
> index 8eeaf82..538cfa4 100644
> --- a/src/libxl/libxl_conf.c
> +++ b/src/libxl/libxl_conf.c
> @@ -715,6 +715,35 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
>      return -1;
>  }
>  
> +static int
> +libxlDiskSetDiscard(libxl_device_disk *x_disk, int discard)
> +{
> +    if (!x_disk->readwrite)
> +        return 0;
> +#if defined(LIBXL_HAVE_LIBXL_DEVICE_DISK_DISCARD_ENABLE)
> +    switch ((enum virDomainDiskDiscard)discard) {
> +    case VIR_DOMAIN_DISK_DISCARD_DEFAULT:
> +    case VIR_DOMAIN_DISK_DISCARD_LAST:
> +        break;
> +    case VIR_DOMAIN_DISK_DISCARD_UNMAP:
> +        libxl_defbool_set(&x_disk->discard_enable, true);
> +        break;
> +    case VIR_DOMAIN_DISK_DISCARD_IGNORE:
> +        libxl_defbool_set(&x_disk->discard_enable, false);
> +        break;
> +    }
> +    return 0;
> +#else
> +    if (discard == VIR_DOMAIN_DISK_DISCARD_DEFAULT)
> +        return 0;
> +    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +                   _("This version of libxenlight does not support "
> +                     "disk 'discard' option passing"));
>   

Fails 'make syntax-check', but otherwise ACK.  I squashed in the below
fix and pushed.

Regards,
Jim

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 22ab902..0b4a0b5 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -736,7 +736,7 @@ libxlDiskSetDiscard(libxl_device_disk *x_disk, int
discard)
 #else
     if (discard == VIR_DOMAIN_DISK_DISCARD_DEFAULT)
         return 0;
-    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                    _("This version of libxenlight does not support "
                      "disk 'discard' option passing"));
     return -1;

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