On Mon, Jul 13, 2026 at 12:14:49 +0200, Radosław Śmigielski via Devel wrote:
> From: Radoslaw Smigielski <[email protected]>
>
> The '--format' option of 'domxml-from-native' command specifies the
> native guest configuration format to import.
>
> Partially-fixes: https://gitlab.com/libvirt/libvirt/-/work_items/9
> Signed-off-by: Radoslaw Smigielski <[email protected]>
> ---
> tools/virsh-completer-domain.c | 36 ++++++++++++++++++++++++++++++++++
> tools/virsh-completer-domain.h | 5 +++++
> tools/virsh-domain.c | 1 +
> 3 files changed, 42 insertions(+)
>
> diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c
> index afb080b868d7..65b02488bb39 100644
> --- a/tools/virsh-completer-domain.c
> +++ b/tools/virsh-completer-domain.c
> @@ -1144,3 +1144,39 @@ virshDomainDisplayTypeCompleter(vshControl *ctl
> G_GNUC_UNUSED,
> return vshEnumComplete(VIR_DOMAIN_GRAPHICS_TYPE_LAST,
> virDomainGraphicsTypeToString);
> }
> +
> +
> +char **
> +virshDomainXMLNativeFormatCompleter(vshControl *ctl,
> + const vshCmd *cmd G_GNUC_UNUSED,
> + unsigned int flags)
Since you've made this reusable also for the 'domxml-to-native' command
...
> +{
> + virshControl *priv = ctl->privData;
> + const char *hvType = NULL;
> + const char **formats = NULL;
> + static const char *xenFormats[] = {"xen-xl", "xen-xm", NULL};
> + static const char *lxcFormats[] = {"lxc-tools", NULL};
> + static const char *vmxFormats[] = {"vmware-vmx", NULL};
> + static const char *bhyveFormats[] = {"bhyve-argv", NULL};
... it's missing support for 'qemu' and 'qemu-argv'.
> +
> + virCheckFlags(0, NULL);
> +
> + if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
> + return NULL;
> +
> + if (!(hvType = virConnectGetType(priv->conn)))
> + return NULL;
> +
> + if (STREQ(hvType, "Xen"))
> + formats = xenFormats;
> + else if (STREQ(hvType, "LXC"))
> + formats = lxcFormats;
> + else if (STREQ(hvType, "VMware") || STREQ(hvType, "ESX"))
> + formats = vmxFormats;
> + else if (STREQ(hvType, "BHYVE"))
> + formats = bhyveFormats;
> + else
> + return NULL;
> +
> + return vshCommaStringListComplete(NULL, formats);
> +}
> diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h
> index 3aab7bedae20..40de90afb79f 100644
> --- a/tools/virsh-completer-domain.h
> +++ b/tools/virsh-completer-domain.h
> @@ -209,3 +209,8 @@ char **
> virshDomainDisplayTypeCompleter(vshControl *ctl,
> const vshCmd *cmd,
> unsigned int flags);
> +
> +char **
> +virshDomainXMLNativeFormatCompleter(vshControl *ctl,
> + const vshCmd *cmd,
> + unsigned int flags);
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index f15f686c7908..c1c27433b0bf 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -10917,6 +10917,7 @@ static const vshCmdOptDef opts_domxmlfromnative[] = {
> .type = VSH_OT_STRING,
> .positional = true,
> .required = true,
> + .completer = virshDomainXMLNativeFormatCompleter,
> .help = N_("source config data format")
I'd be better to populate domxml-to-native here too instead of randomly
putting it into another patch,