From nobody Sun Feb 8 05:47:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1660742848; cv=none; d=zohomail.com; s=zohoarc; b=fXd8Y44YBq67sWK4LELcjBpNgN3wUK2dZ2hhO6iQkDgrtEYnRn0hbp+ychmbnI2GAffuQDKTeGMMrLsGFoydrTi4gn+R8khHjNkqfm+aTE5GpbO/MLgaqM8Fq1SLwj1gC43vkqQTC+hvMNbk6N36Mj7dSvM8do84hBzoydZxu3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660742848; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mfKZKgTlHHCEV4od7ArYUjlsFGo63S4YDmIbYjiC0sw=; b=RJCG0Lmz/aZpE2W1R1/ZgYUD8KjH/XoyVlXM5iouwbZJTtXV/Icu9qp2/fL8zg52hybymIdLDRTY6b+Ofllfao32ZKl5lJIRH/SlUu9hQ7znwdvnFZwlFR5Z4OHZLoqv21D9vdWV76Z5bM6vlpYrpeO085QQ7FUpy5wfWCVWG+c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1660742848867925.4498866981336; Wed, 17 Aug 2022 06:27:28 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-31-G0IcRpA6ME6TANqE_JT16Q-1; Wed, 17 Aug 2022 09:27:26 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 71CE729DD9BA; Wed, 17 Aug 2022 13:27:23 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0048C1121314; Wed, 17 Aug 2022 13:27:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B8100193F6F6; Wed, 17 Aug 2022 13:27:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C69611946A40 for ; Wed, 17 Aug 2022 12:50:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A98512166B2B; Wed, 17 Aug 2022 12:50:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A61DA2166B2A for ; Wed, 17 Aug 2022 12:50:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8FDC085A588 for ; Wed, 17 Aug 2022 12:50:53 +0000 (UTC) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-278-9FpZg-qkP6-I6EpKPZAidw-1; Wed, 17 Aug 2022 08:50:47 -0400 Received: by mail-ed1-f71.google.com with SMTP id z3-20020a056402274300b0043d4da3b4b5so8646825edd.12 for ; Wed, 17 Aug 2022 05:50:47 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id r2-20020a1709061ba200b0073087f7dfe2sm6742601ejg.125.2022.08.17.05.50.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 05:50:46 -0700 (PDT) Received: from wheatley.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 9C9078F2D64D for ; Wed, 17 Aug 2022 14:50:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660742847; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mfKZKgTlHHCEV4od7ArYUjlsFGo63S4YDmIbYjiC0sw=; b=U05nO5N9kcq2mV/zgzlRe463SGCccrPwGqAkqYAJSrQUU/EkGtv3+STW3wsaEPSJ7LNJ3i S8V46x+byysefvZ3SG64C99/VIZ+06GGtzzHBXlGesF40MeMMPchOB+aSnIDbKFW7nthZf thi1NA0VWSqnqyGdCA7jWTV0nXD/xew= X-MC-Unique: G0IcRpA6ME6TANqE_JT16Q-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 9FpZg-qkP6-I6EpKPZAidw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=mfKZKgTlHHCEV4od7ArYUjlsFGo63S4YDmIbYjiC0sw=; b=uVj9ZrOc1LxnzPfDLA5QRNRy7juIaErTz+vPX7IYoCWI0o2LTOZkn2kMIGEkLeWPQq SA4mVg4OKfGCOtAGZV3UaMQ5rmnOXQDy6+swqVtQIvM7MjbMCF9xSR19Gl0c6AhDX+Lt rPFonCvZ5p84j+M8Qs/9pokJ5bxMl6osWM7Pau6Ke76hjgSAC1gop6RQtn+TFEs6rftd Qz4KZDrja3mUAoxJGGK6HVlqbnEkaaUaL5yOS2wbt8+82qBL+wTvEEuJ5HxtSy9THpTg q/PGoY+VlTZRe5lmsq0VROut35IDcNXeXP5gAZnrhb8t00TjiVCdY/pps7F/kYg5mCIb NOlw== X-Gm-Message-State: ACgBeo3ogmfdaadtNr/QQt+/ieF/rqiN30oZBbF8YENczn31C2dCHjpS BiQRjwKFxAwY4sH8tctToh8BTMjMfDbiI13j62/c8nexp7WA1f08SY4VmYLW5GfkN/lMbgWWi7J YJLfzybGEQiEEg5MWbp3LP6A5TC/TcwfkCdwl2LfOWifIyIvv+5npYQFqGowSaqWh6+902iw= X-Received: by 2002:a05:6402:248a:b0:440:9709:df09 with SMTP id q10-20020a056402248a00b004409709df09mr22867872eda.42.1660740646727; Wed, 17 Aug 2022 05:50:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR4WKk7sw0YIHXbQ1s24Tsk+8DZMKHdTyCXRaFrQJMdRR5iXuiFn4XZIfqhECEyKZwIFCJl1rQ== X-Received: by 2002:a05:6402:248a:b0:440:9709:df09 with SMTP id q10-20020a056402248a00b004409709df09mr22867849eda.42.1660740646476; Wed, 17 Aug 2022 05:50:46 -0700 (PDT) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 5/5] vmx: Add support for VDS interface Date: Wed, 17 Aug 2022 14:50:40 +0200 Message-Id: <1544c90ecc65e8b38fc2e628c4e0ea2128104245.1660740500.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1660742850521100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Since we cannot properly plug a new VM into the distributed switch, we can = at least report the provided pieces of information, so that XML editing still = works even for VMs with such interfaces. https://bugzilla.redhat.com/show_bug.cgi?id=3D1988211 Signed-off-by: Martin Kletzander --- src/vmx/vmx.c | 76 ++++++++++++++++++---- tests/vmx2xmldata/ethernet-vds.vmx | 11 ++++ tests/vmx2xmldata/ethernet-vds.xml | 24 +++++++ tests/vmx2xmltest.c | 1 + tests/xml2vmxdata/xml2vmx-ethernet-vds.vmx | 18 +++++ tests/xml2vmxdata/xml2vmx-ethernet-vds.xml | 15 +++++ tests/xml2vmxtest.c | 1 + 7 files changed, 133 insertions(+), 13 deletions(-) create mode 100644 tests/vmx2xmldata/ethernet-vds.vmx create mode 100644 tests/vmx2xmldata/ethernet-vds.xml create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-vds.vmx create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-vds.xml diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index b7b997e83540..9ad463658aa8 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2700,6 +2700,13 @@ virVMXParseEthernet(virConf *conf, int controller, v= irDomainNetDef **def) char networkName_name[48] =3D ""; char *networkName =3D NULL; =20 + char switchId_name[48] =3D ""; + char *switchId =3D NULL; + + char portId_name[48] =3D ""; + char portgroupId_name[48] =3D ""; + char connectionId_name[48] =3D ""; + int netmodel =3D VIR_DOMAIN_NET_MODEL_UNKNOWN; =20 if (def =3D=3D NULL || *def !=3D NULL) { @@ -2721,6 +2728,13 @@ virVMXParseEthernet(virConf *conf, int controller, v= irDomainNetDef **def) VMX_BUILD_NAME(networkName); VMX_BUILD_NAME(vnet); =20 + g_snprintf(prefix, sizeof(prefix), "ethernet%d.dvs", controller); + + VMX_BUILD_NAME(switchId); + VMX_BUILD_NAME(portId); + VMX_BUILD_NAME(portgroupId); + VMX_BUILD_NAME(connectionId); + /* vmx:present */ if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) = < 0) return -1; @@ -2836,19 +2850,36 @@ virVMXParseEthernet(virConf *conf, int controller, = virDomainNetDef **def) goto cleanup; } =20 + if (virVMXGetConfigString(conf, switchId_name, &switchId, true) < 0) + goto cleanup; + /* Setup virDomainNetDef */ - if (connectionType =3D=3D NULL && networkName =3D=3D NULL) { - /* - * Having neither a connectionType nor a network name can mean two - * things: - * - * 1) there is no connection of that nic - * 2) the nic is connected to VMWare Distributed Switch - * - * But we do not see any difference between these and hence we rep= ort - * the closest thing to at least make virt-v2v and others work whe= n they - * read the domain XML. - */ + if (switchId) { + (*def)->type =3D VIR_DOMAIN_NET_TYPE_VDS; + + if (virUUIDParse(switchId, (*def)->data.vds.switch_id) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not parse UUID from string '%s'"), + switchId); + goto cleanup; + } + + if (virVMXGetConfigString(conf, + portgroupId_name, + &(*def)->data.vds.portgroup_id, + false) < 0 || + virVMXGetConfigLong(conf, + portId_name, + &(*def)->data.vds.port_id, + 0, + false) < 0 || + virVMXGetConfigLong(conf, + connectionId_name, + &(*def)->data.vds.connection_id, + 0, + false) < 0) + goto cleanup; + } else if (connectionType =3D=3D NULL && networkName =3D=3D NULL) { (*def)->type =3D VIR_DOMAIN_NET_TYPE_DUMMY; } else if (connectionType =3D=3D NULL || STRCASEEQ(connectionType, "br= idged")) { (*def)->type =3D VIR_DOMAIN_NET_TYPE_BRIDGE; @@ -3962,6 +3993,26 @@ virVMXFormatEthernet(virDomainNetDef *def, int contr= oller, case VIR_DOMAIN_NET_TYPE_DUMMY: break; =20 + case VIR_DOMAIN_NET_TYPE_VDS: { + unsigned char *uuid =3D def->data.vds.switch_id; + + virBufferAsprintf(buffer, "ethernet%d.dvs.switchId =3D \"%02x %02x= %02x %02x %02x " + "%02x %02x %02x-%02x %02x %02x %02x %02x %02x %0= 2x %02x\"\n", + controller, uuid[0], uuid[1], uuid[2], uuid[3], = uuid[4], + uuid[5], uuid[6], uuid[7], uuid[8], uuid[9], uui= d[10], + uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]= ); + + virBufferAsprintf(buffer, "ethernet%d.dvs.portId =3D \"%lld\"\n", + controller, def->data.vds.port_id); + + virBufferAsprintf(buffer, "ethernet%d.dvs.", controller); + virBufferEscapeString(buffer, "portgroupId =3D \"%s\"\n", def->dat= a.vds.portgroup_id); + + virBufferAsprintf(buffer, "ethernet%d.dvs.connectionId =3D \"%lld\= "\n", + controller, def->data.vds.connection_id); + break; + } + case VIR_DOMAIN_NET_TYPE_ETHERNET: case VIR_DOMAIN_NET_TYPE_VHOSTUSER: case VIR_DOMAIN_NET_TYPE_SERVER: @@ -3973,7 +4024,6 @@ virVMXFormatEthernet(virDomainNetDef *def, int contro= ller, case VIR_DOMAIN_NET_TYPE_HOSTDEV: case VIR_DOMAIN_NET_TYPE_UDP: case VIR_DOMAIN_NET_TYPE_VDPA: - case VIR_DOMAIN_NET_TYPE_VDS: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported net type= '%s'"), virDomainNetTypeToString(def->type)); return -1; diff --git a/tests/vmx2xmldata/ethernet-vds.vmx b/tests/vmx2xmldata/etherne= t-vds.vmx new file mode 100644 index 000000000000..f68587bcf181 --- /dev/null +++ b/tests/vmx2xmldata/ethernet-vds.vmx @@ -0,0 +1,11 @@ +config.version =3D "8" +virtualHW.version =3D "4" +ethernet0.present =3D "true" +ethernet0.virtualDev =3D "e1000e" +ethernet0.addressType =3D "vpx" +ethernet0.generatedAddress =3D "00:50:56:87:65:43" +ethernet0.dvs.switchId =3D "50 34 26 b2 94 e9 3b 16-1d 68 87 bf ff 4a 54 4= 0" +ethernet0.dvs.portId =3D "5" +ethernet0.dvs.portgroupId =3D "dvportgroup-1285" +ethernet0.dvs.connectionId =3D "408217997" +displayName =3D "test" diff --git a/tests/vmx2xmldata/ethernet-vds.xml b/tests/vmx2xmldata/etherne= t-vds.xml new file mode 100644 index 000000000000..ab842b168c9b --- /dev/null +++ b/tests/vmx2xmldata/ethernet-vds.xml @@ -0,0 +1,24 @@ + + test + 00000000-0000-0000-0000-000000000000 + 32768 + 32768 + 1 + + hvm + + + destroy + restart + destroy + + + + + + + + + diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 3ab39148e0a4..07d7bf24c2b3 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -237,6 +237,7 @@ mymain(void) DO_TEST("ethernet-vpx"); DO_TEST("ethernet-other"); DO_TEST("ethernet-dummy"); + DO_TEST("ethernet-vds"); =20 DO_TEST("serial-file"); DO_TEST("serial-device"); diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-vds.vmx b/tests/xml2vmxdata= /xml2vmx-ethernet-vds.vmx new file mode 100644 index 000000000000..bcc04bc21a6e --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ethernet-vds.vmx @@ -0,0 +1,18 @@ +.encoding =3D "UTF-8" +config.version =3D "8" +virtualHW.version =3D "4" +guestOS =3D "other" +uuid.bios =3D "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15" +displayName =3D "ethernet-vpx" +memsize =3D "4" +numvcpus =3D "1" +floppy0.present =3D "false" +floppy1.present =3D "false" +ethernet0.present =3D "true" +ethernet0.virtualDev =3D "e1000e" +ethernet0.dvs.switchId =3D "50 34 26 b2 94 e9 3b 16-1d 68 87 bf ff 4a 54 4= 0" +ethernet0.dvs.portId =3D "5" +ethernet0.dvs.portgroupId =3D "dvportgroup-1285" +ethernet0.dvs.connectionId =3D "408217997" +ethernet0.addressType =3D "vpx" +ethernet0.generatedAddress =3D "00:50:56:87:65:43" diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-vds.xml b/tests/xml2vmxdata= /xml2vmx-ethernet-vds.xml new file mode 100644 index 000000000000..69d44a62da1c --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ethernet-vds.xml @@ -0,0 +1,15 @@ + + ethernet-vpx + 564d9bef-acd9-b4e0-c8f0-aea8b9103515 + 4096 + + hvm + + + + + + + + + diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 7723c1efabdd..c921c8a3b0eb 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -226,6 +226,7 @@ mymain(void) DO_TEST("ethernet-mac-type", "ethernet-mac-type", 4); =20 DO_TEST("ethernet-dummy", "ethernet-dummy", 4); + DO_TEST("ethernet-vds", "ethernet-vds", 4); =20 DO_TEST("serial-file", "serial-file", 4); DO_TEST("serial-device", "serial-device", 4); --=20 2.37.2