From nobody Wed May 14 19:24:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522237233932521.778190693964; Wed, 28 Mar 2018 04:40:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 593497FDC3; Wed, 28 Mar 2018 11:40:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2E9B160C4E; Wed, 28 Mar 2018 11:40:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D0357181BA04; Wed, 28 Mar 2018 11:40:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2SBeULP021951 for ; Wed, 28 Mar 2018 07:40:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 150F8946A2; Wed, 28 Mar 2018 11:40:30 +0000 (UTC) Received: from thyrus.usersys.redhat.com (unknown [10.34.245.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 92A579C073 for ; Wed, 28 Mar 2018 11:40:29 +0000 (UTC) From: Pino Toscano To: libvir-list@redhat.com Date: Wed, 28 Mar 2018 13:40:21 +0200 Message-Id: <20180328114021.15169-5-ptoscano@redhat.com> In-Reply-To: <20180328114021.15169-1-ptoscano@redhat.com> References: <20180328114021.15169-1-ptoscano@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/4] vmx: convert any amount of NICs X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 28 Mar 2018 11:40:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Scan the parsed VMX file, and gather the biggest index of the network interfaces there: this way, it is possible to parse all the available network interfaces, instead of just 4 maximum. Add the VMX file attached to RHBZ#1560917 as testcase esx-in-the-wild-8. https://bugzilla.redhat.com/show_bug.cgi?id=3D1560917 Signed-off-by: Pino Toscano --- src/vmx/vmx.c | 43 +++++-- tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.vmx | 163 ++++++++++++++++++++= ++++ tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml | 89 +++++++++++++ tests/vmx2xmltest.c | 1 + 4 files changed, 288 insertions(+), 8 deletions(-) create mode 100644 tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.vmx create mode 100644 tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index fd9b55950..cd43d9c49 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1286,6 +1286,36 @@ virVMXGatherSCSIControllers(virVMXContext *ctx, virD= omainDefPtr def, return result; } =20 +struct virVMXConfigScanResults { + int networks_max_index; +}; + +static int +virVMXConfigScanResultsCollector(const char* name, + virConfValuePtr value ATTRIBUTE_UNUSED, + void *opaque) +{ + struct virVMXConfigScanResults *results =3D opaque; + + if (STRCASEPREFIX(name, "ethernet")) { + unsigned int idx; + char *p; + + if (virStrToLong_uip(name + 8, &p, 10, &idx) < 0 || + *p !=3D '.') { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to parse the index of the VMX key '%s= '"), + name); + return -1; + } + + if ((int) idx > results->networks_max_index) + results->networks_max_index =3D (int) idx; + } + + return 0; +} + =20 =20 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *= * * @@ -1322,6 +1352,7 @@ virVMXParseConfig(virVMXContext *ctx, bool hgfs_disabled =3D true; long long sharedFolder_maxNum =3D 0; int cpumasklen; + struct virVMXConfigScanResults results =3D { -1 }; =20 if (ctx->parseFileName =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -1357,6 +1388,9 @@ virVMXParseConfig(virVMXContext *ctx, goto cleanup; } =20 + if (virConfWalk(conf, virVMXConfigScanResultsCollector, &results) < 0) + goto cleanup; + /* Allocate domain def */ if (!(def =3D virDomainDefNew())) goto cleanup; @@ -1751,7 +1785,7 @@ virVMXParseConfig(virVMXContext *ctx, } =20 /* def:nets */ - for (controller =3D 0; controller < 4; ++controller) { + for (controller =3D 0; controller <=3D results.networks_max_index; ++c= ontroller) { virDomainNetDefPtr net =3D NULL; if (virVMXParseEthernet(conf, controller, &net) < 0) goto cleanup; @@ -2539,13 +2573,6 @@ virVMXParseEthernet(virConfPtr conf, int controller,= virDomainNetDefPtr *def) return -1; } =20 - if (controller < 0 || controller > 3) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Ethernet controller index %d out of [0..3] range= "), - controller); - return -1; - } - snprintf(prefix, sizeof(prefix), "ethernet%d", controller); =20 VMX_BUILD_NAME(present); diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.vmx b/tests/vmx2xm= ldata/vmx2xml-esx-in-the-wild-8.vmx new file mode 100644 index 000000000..1e3dbf23c --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.vmx @@ -0,0 +1,163 @@ +.encoding =3D "UTF-8" +config.version =3D "8" +virtualHW.version =3D "11" +vmci0.present =3D "TRUE" +svga.vramSize =3D "8388608" +memSize =3D "2048" +sched.cpu.units =3D "mhz" +tools.upgrade.policy =3D "manual" +scsi0.virtualDev =3D "pvscsi" +scsi0.present =3D "TRUE" +sata0.present =3D "TRUE" +sata0:0.deviceType =3D "cdrom-image" +sata0:0.fileName =3D "/vmfs/volumes/692eb778-2d4937fe/CentOS-4.7.ServerCD-= x86_64.iso" +sata0:0.present =3D "TRUE" +scsi0:0.deviceType =3D "scsi-hardDisk" +scsi0:0.fileName =3D "RHEL7_6.vmdk" +sched.scsi0:0.shares =3D "normal" +scsi0:0.present =3D "TRUE" +floppy0.startConnected =3D "FALSE" +floppy0.clientDevice =3D "TRUE" +floppy0.fileName =3D "vmware-null-remote-floppy" +ethernet0.virtualDev =3D "vmxnet3" +ethernet0.networkName =3D "VM Network" +ethernet0.addressType =3D "static" +ethernet0.address =3D "00:1a:4a:16:01:55" +ethernet0.present =3D "TRUE" +displayName =3D "RHEL7_10_NICs" +guestOS =3D "rhel7-64" +toolScripts.afterPowerOn =3D "TRUE" +toolScripts.afterResume =3D "TRUE" +toolScripts.beforeSuspend =3D "TRUE" +toolScripts.beforePowerOff =3D "TRUE" +tools.syncTime =3D "FALSE" +messageBus.tunnelEnabled =3D "FALSE" +uuid.bios =3D "42 35 94 20 99 dc 42 61-52 64 ba 58 dd ae 20 e4" +vc.uuid =3D "50 35 1d e6 7d 56 29 ab-9d 72 c7 f9 ea 3f cf d0" +sched.cpu.latencySensitivity =3D "normal" +tools.guest.desktop.autolock =3D "FALSE" +nvram =3D "RHEL7_6.nvram" +pciBridge0.present =3D "TRUE" +svga.present =3D "TRUE" +pciBridge4.present =3D "TRUE" +pciBridge4.virtualDev =3D "pcieRootPort" +pciBridge4.functions =3D "8" +pciBridge5.present =3D "TRUE" +pciBridge5.virtualDev =3D "pcieRootPort" +pciBridge5.functions =3D "8" +pciBridge6.present =3D "TRUE" +pciBridge6.virtualDev =3D "pcieRootPort" +pciBridge6.functions =3D "8" +pciBridge7.present =3D "TRUE" +pciBridge7.virtualDev =3D "pcieRootPort" +pciBridge7.functions =3D "8" +hpet0.present =3D "true" +sched.scsi0:0.throughputCap =3D "off" +ethernet0.uptCompatibility =3D "TRUE" +ethernet0.pciSlotNumber =3D "192" +monitor.phys_bits_used =3D "42" +pciBridge0.pciSlotNumber =3D "17" +pciBridge4.pciSlotNumber =3D "21" +pciBridge5.pciSlotNumber =3D "22" +pciBridge6.pciSlotNumber =3D "23" +pciBridge7.pciSlotNumber =3D "24" +replay.supported =3D "false" +sata0.pciSlotNumber =3D "33" +scsi0.pciSlotNumber =3D "160" +scsi0.sasWWID =3D "50 05 05 60 99 dc 42 60" +softPowerOff =3D "FALSE" +virtualHW.productCompatibility =3D "hosted" +vmci0.pciSlotNumber =3D "32" +vmotion.checkpointFBSize =3D "8388608" +vmotion.checkpointSVGAPrimarySize =3D "8388608" +tools.remindInstall =3D "FALSE" +toolsInstallManager.lastInstallError =3D "0" +toolsInstallManager.updateCounter =3D "1" +migrate.hostlog =3D "RHEL7_6-2a23b979.hlog" +sched.cpu.min =3D "0" +sched.cpu.shares =3D "normal" +sched.mem.min =3D "0" +sched.mem.minSize =3D "0" +sched.mem.shares =3D "normal" +scsi0:1.deviceType =3D "scsi-hardDisk" +scsi0:1.fileName =3D "RHEL7_6_1.vmdk" +scsi0:1.mode =3D "independent-nonpersistent" +sched.scsi0:1.shares =3D "normal" +sched.scsi0:1.throughputCap =3D "off" +scsi0:1.present =3D "TRUE" +scsi0:2.deviceType =3D "scsi-hardDisk" +scsi0:2.fileName =3D "/vmfs/volumes/5669422e-699d77db-c144-00e0815e303e/bl= ock4/block4.vmdk" +sched.scsi0:2.shares =3D "normal" +sched.scsi0:2.throughputCap =3D "off" +scsi0:2.present =3D "TRUE" +numvcpus =3D "8" +cpuid.coresPerSocket =3D "2" +sched.swap.derivedName =3D "/vmfs/volumes/29dcc8ec-e8d62d3b-0000-000000000= 000/RHEL7_6/RHEL7_6-05efff7d.vswp" +uuid.location =3D "56 4d d9 db b7 4e df ce-58 6a 77 56 82 53 aa 18" +replay.filename =3D "" +scsi0:2.redo =3D "" +scsi0:1.redo =3D "" +scsi0:0.redo =3D "" +vmci0.id =3D "-575790876" +cleanShutdown =3D "TRUE" +ethernet1.virtualDev =3D "e1000" +ethernet1.networkName =3D "VM Network" +ethernet1.addressType =3D "vpx" +ethernet1.generatedAddress =3D "00:1a:4a:16:21:85" +ethernet1.present =3D "TRUE" +ethernet2.virtualDev =3D "e1000e" +ethernet2.networkName =3D "VM Network" +ethernet2.addressType =3D "vpx" +ethernet2.generatedAddress =3D "00:1a:4a:16:21:82" +ethernet2.present =3D "TRUE" +ethernet3.virtualDev =3D "vmxnet3" +ethernet3.networkName =3D "VM Network" +ethernet3.addressType =3D "vpx" +ethernet3.generatedAddress =3D "00:1a:4a:16:21:69" +ethernet3.uptCompatibility =3D "TRUE" +ethernet3.present =3D "TRUE" +ethernet4.virtualDev =3D "vmxnet3" +ethernet4.networkName =3D "VM Network" +ethernet4.addressType =3D "vpx" +ethernet4.generatedAddress =3D "00:1a:4a:16:21:80" +ethernet4.uptCompatibility =3D "TRUE" +ethernet4.present =3D "TRUE" +ethernet5.virtualDev =3D "vmxnet3" +ethernet5.networkName =3D "VM Network" +ethernet5.addressType =3D "vpx" +ethernet5.generatedAddress =3D "00:1a:4a:16:21:a3" +ethernet5.uptCompatibility =3D "TRUE" +ethernet5.present =3D "TRUE" +ethernet6.virtualDev =3D "vmxnet3" +ethernet6.networkName =3D "VM Network" +ethernet6.addressType =3D "vpx" +ethernet6.generatedAddress =3D "00:1a:4a:16:21:a8" +ethernet6.uptCompatibility =3D "TRUE" +ethernet6.present =3D "TRUE" +ethernet7.virtualDev =3D "vmxnet3" +ethernet7.networkName =3D "VM Network" +ethernet7.addressType =3D "vpx" +ethernet7.generatedAddress =3D "00:1a:4a:16:21:a9" +ethernet7.uptCompatibility =3D "TRUE" +ethernet7.present =3D "TRUE" +ethernet8.virtualDev =3D "vmxnet3" +ethernet8.networkName =3D "VM Network" +ethernet8.addressType =3D "vpx" +ethernet8.generatedAddress =3D "00:1a:4a:16:21:78" +ethernet8.uptCompatibility =3D "TRUE" +ethernet8.present =3D "TRUE" +ethernet9.virtualDev =3D "vmxnet3" +ethernet9.networkName =3D "VM Network" +ethernet9.addressType =3D "vpx" +ethernet9.generatedAddress =3D "00:1a:4a:16:21:81" +ethernet9.uptCompatibility =3D "TRUE" +ethernet9.present =3D "TRUE" +ethernet1.pciSlotNumber =3D "34" +ethernet2.pciSlotNumber =3D "224" +ethernet3.pciSlotNumber =3D "256" +ethernet4.pciSlotNumber =3D "1184" +ethernet5.pciSlotNumber =3D "1216" +ethernet6.pciSlotNumber =3D "1248" +ethernet7.pciSlotNumber =3D "1280" +ethernet8.pciSlotNumber =3D "2208" +ethernet9.pciSlotNumber =3D "2240" diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml b/tests/vmx2xm= ldata/vmx2xml-esx-in-the-wild-8.xml new file mode 100644 index 000000000..c85ccf364 --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml @@ -0,0 +1,89 @@ + + RHEL7_10_NICs + 42359420-99dc-4261-5264-ba58ddae20e4 + 2097152 + 2097152 + 8 + + 8000 + + + hvm + + + destroy + restart + destroy + + + + +
+ + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index e0be64225..319bf345a 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -268,6 +268,7 @@ mymain(void) DO_TEST("esx-in-the-wild-5", "esx-in-the-wild-5"); DO_TEST("esx-in-the-wild-6", "esx-in-the-wild-6"); DO_TEST("esx-in-the-wild-7", "esx-in-the-wild-7"); + DO_TEST("esx-in-the-wild-8", "esx-in-the-wild-8"); =20 DO_TEST("gsx-in-the-wild-1", "gsx-in-the-wild-1"); DO_TEST("gsx-in-the-wild-2", "gsx-in-the-wild-2"); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list