[libvirt PATCH 06/51] conf/domain_conf: Update format strings in translated messages

Daniel P. Berrangé berrange at redhat.com
Mon Mar 27 14:02:06 UTC 2023


On Fri, Mar 10, 2023 at 05:09:22PM +0100, Jiri Denemark wrote:
> Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> ---
>  src/conf/domain_conf.c | 874 ++++++++++++++++++-----------------------
>  1 file changed, 391 insertions(+), 483 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 783d3a5fff..00c3b11dc2 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c

> @@ -19585,8 +19570,7 @@ virDomainDeviceInfoCheckABIStability(virDomainDeviceInfo *src,
>              src->addr.pci.slot != dst->addr.pci.slot ||
>              src->addr.pci.function != dst->addr.pci.function) {
>              virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> -                           _("Target device PCI address " VIR_PCI_DEVICE_ADDRESS_FMT
> -                             "does not match source " VIR_PCI_DEVICE_ADDRESS_FMT),
> +                           _("Target device PCI address %1$04x:%2$02x:%3$02x.%4$d does not match source %5$04x:%6$02x:%7$02x.%8$d"),

This is an unusal case

The current msgid was completely broken as xgettext does not cope with macro expansion,
thus libvirt.pot merely contains  "Target device PCI address " !!

At the end of the series though there are still some places which are using this
format which are translatable:

$ git grep VIR_PCI_DEVICE_ADDRESS_FMT
src/libxl/libxl_driver.c:                       _("target pci device " VIR_PCI_DEVICE_ADDRESS_FMT
src/libxl/libxl_driver.c:                         VIR_PCI_DEVICE_ADDRESS_FMT),
src/libxl/libxl_driver.c:                       _("host pci device " VIR_PCI_DEVICE_ADDRESS_FMT
src/libxl/libxl_driver.c:                         VIR_PCI_DEVICE_ADDRESS_FMT),
src/libxl/libxl_driver.c:                         VIR_PCI_DEVICE_ADDRESS_FMT),
src/qemu/qemu_command.c:    g_autofree char *host = g_strdup_printf(VIR_PCI_DEVICE_ADDRESS_FMT,
src/qemu/qemu_hotplug.c:                           _("host pci device " VIR_PCI_DEVICE_ADDRESS_FMT
src/util/virpci.c:    return g_strdup_printf(VIR_PCI_DEVICE_ADDRESS_FMT, addr->domain,
src/util/virpci.c:    pcidir = g_strdup_printf("/sys/bus/pci/devices/" VIR_PCI_DEVICE_ADDRESS_FMT,
src/util/virpci.c:    groupPath = g_strdup_printf(PCI_SYSFS "devices/" VIR_PCI_DEVICE_ADDRESS_FMT "/iommu_group/devices",
src/util/virpci.c:        VIR_DEBUG("PF for VF device '%s': " VIR_PCI_DEVICE_ADDRESS_FMT,
src/util/virpci.c:    *pci_sysfs_device_link = g_strdup_printf(PCI_SYSFS "devices/" VIR_PCI_DEVICE_ADDRESS_FMT, addr->domain,
src/util/virpci.h:#define VIR_PCI_DEVICE_ADDRESS_FMT "%04x:%02x:%02x.%d"

the virpci.c hits are safe as they're for filenames.  The qemu_hotplug.c and
libxl_driver.c files need changing though.

I think ideally we would make  VIR_PCI_DEVICE_ADDRESS_FMT private to virpci.c,
and add a helper to virpci.c that can be used from qemu_command.c, so we
avoid introducing more usage of this in translations. eg  virPCIAddressFormat(....)

Likewise add a helper for VIR_CCW_DEVICE_ADDRESS_FMT, which fortunately is
not (yet) used in any translations.

I think this ought to all be done in a commit at the start of this series,
so this patch is merely adding format positions.

>                             dst->addr.pci.domain, dst->addr.pci.bus,
>                             dst->addr.pci.slot, dst->addr.pci.function,
>                             src->addr.pci.domain, src->addr.pci.bus,

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


More information about the libvir-list mailing list