From nobody Tue Sep 22 08:01:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1783602730; cv=none; d=zohomail.com; s=zohoarc; b=eNbv1hMSMXWofC+zWym356wUmRwe6mJafUpU64nUsbhC28mmCSqrZkX4PnCdXF6ugD/CFRXq7aznJCS7W503ncMTIq1T7loIJz/tXUIHolGerS8fi/P5salegwHn6mf1NfQUdpNy5fjbSs7bNnBUQ89qVaiWNyICsP9yZyas6p4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783602730; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=/SfMlIRmjBhJsJ8Fqq/P0mEAwxMQMqh6kaqiGSK1LGA=; b=OAmS55fhb5dJgID7fnJok1F8oFgMRewTwQeoflAJhhlnCh3ArBb1Vi2adslndo7OzKs+8Hno4rfetsgIIKxRdkKbvmt+2tVmIR7UmZ60wf8irfksF56mEr+tN95vhKTAQCMRJDDa3Z88hKAT0cc2rVMQDy63/zNT+vz0nynMTO4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1783602730340951.2826030579739; Thu, 9 Jul 2026 06:12:10 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 24D4F41B4A; Thu, 9 Jul 2026 09:12:08 -0400 (EDT) Received: from [172.19.199.10] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 03AD942401; Thu, 9 Jul 2026 09:06:41 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id F254641D8D; Thu, 9 Jul 2026 09:06:15 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id C3D5241C5A for ; Thu, 9 Jul 2026 09:06:02 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-19-ePCflPUCPZGNAD6sG0z1tw-1; Thu, 09 Jul 2026 09:06:00 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0D66E1955F19 for ; Thu, 9 Jul 2026 13:06:00 +0000 (UTC) Received: from rsmigiel-thinkpadx1carbongen11-remote-csb.redhat.com (unknown [10.44.33.224]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1E9D436933; Thu, 9 Jul 2026 13:05:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783602362; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/SfMlIRmjBhJsJ8Fqq/P0mEAwxMQMqh6kaqiGSK1LGA=; b=G9xyB5rC8uVOoQRGh3NnFSIT5/EG/c15VxU/lMefpfbFWpxZi7Jz3Jwh2zDGmWGhLHM4LY F4I2Icu3PpnHNRxoijINIlSUuBs0c47NsTj+R3ofLUY6EGXlS8DWZYPkQRMu7fPrRnoXEc IneuMGWIykb1Ec0T54RWB8KGmMtKE40= X-MC-Unique: ePCflPUCPZGNAD6sG0z1tw-1 X-Mimecast-MFC-AGG-ID: ePCflPUCPZGNAD6sG0z1tw_1783602360 To: devel@lists.libvirt.org Subject: [PATCH 5/6] virsh: Add completer for '--format' option of 'domxml-from-native' command Date: Thu, 9 Jul 2026 15:01:01 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: oeXvi7UegLKw5dz7swt7gXh4a31pwBgjfkYQL6Tcmbg_1783602360 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: L4FEUYAZAQSK6JMHBERLJODGZAKBAXXO X-Message-ID-Hash: L4FEUYAZAQSK6JMHBERLJODGZAKBAXXO X-MailFrom: rsmigiel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Radoslaw Smigielski X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: =?utf-8?q?Rados=C5=82aw_=C5=9Amigielski_via_Devel?= Reply-To: rsmigiel@redhat.com X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1783602732297158501 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Radoslaw Smigielski 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 --- 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 4c0ddb01d855..8154ba8d622c 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -1145,3 +1145,39 @@ virshDomainDisplayTypeCompleter(vshControl *ctl G_GN= UC_UNUSED, =20 return vshCommaStringListComplete(NULL, types); } + + +char ** +virshDomainXMLNativeFormatCompleter(vshControl *ctl, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int flags) +{ + virshControl *priv =3D ctl->privData; + const char *hvType =3D NULL; + const char **formats =3D NULL; + static const char *xenFormats[] =3D {"xen-xl", "xen-xm", NULL}; + static const char *lxcFormats[] =3D {"lxc-tools", NULL}; + static const char *vmxFormats[] =3D {"vmware-vmx", NULL}; + static const char *bhyveFormats[] =3D {"bhyve-argv", NULL}; + + virCheckFlags(0, NULL); + + if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) + return NULL; + + if (!(hvType =3D virConnectGetType(priv->conn))) + return NULL; + + if (STREQ(hvType, "Xen")) + formats =3D xenFormats; + else if (STREQ(hvType, "LXC")) + formats =3D lxcFormats; + else if (STREQ(hvType, "VMware") || STREQ(hvType, "ESX")) + formats =3D vmxFormats; + else if (STREQ(hvType, "BHYVE")) + formats =3D 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 a546532b7dd2..abe3d0b3451e 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -10916,6 +10916,7 @@ static const vshCmdOptDef opts_domxmlfromnative[] = =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, + .completer =3D virshDomainXMLNativeFormatCompleter, .help =3D N_("source config data format") }, {.name =3D "config", --=20 2.54.0