From nobody Fri May 3 22:53:12 2024 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 1522237232461185.85886846079984; Wed, 28 Mar 2018 04:40:32 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DDF823DD47; Wed, 28 Mar 2018 11:40:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9CB0F600CC; Wed, 28 Mar 2018 11:40:30 +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 F0C6B4CA99; Wed, 28 Mar 2018 11:40:28 +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 w2SBeSPn021926 for ; Wed, 28 Mar 2018 07:40:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id F25199C073; Wed, 28 Mar 2018 11:40:27 +0000 (UTC) Received: from thyrus.usersys.redhat.com (unknown [10.34.245.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7BA92946A2 for ; Wed, 28 Mar 2018 11:40:27 +0000 (UTC) From: Pino Toscano To: libvir-list@redhat.com Date: Wed, 28 Mar 2018 13:40:18 +0200 Message-Id: <20180328114021.15169-2-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 1/4] vmx: check for present/enabled devices earlier 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 28 Mar 2018 11:40:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When parsing filesystems, network interfaces, serial ports, and parallel ports, check earlier whether they are present/enabled, delaying the allocation of the objects. This is mostly a small optimization, with no behaviour change. Signed-off-by: Pino Toscano --- src/vmx/vmx.c | 92 +++++++++++++++++++------------------------------------= ---- 1 file changed, 30 insertions(+), 62 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 3b0c16d5a..ba47a87b7 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2439,11 +2439,6 @@ int virVMXParseFileSystem(virConfPtr conf, int numbe= r, virDomainFSDefPtr *def) return -1; } =20 - if (!(*def =3D virDomainFSDefNew())) - return -1; - - (*def)->type =3D VIR_DOMAIN_FS_TYPE_MOUNT; - snprintf(prefix, sizeof(prefix), "sharedFolder%d", number); =20 VMX_BUILD_NAME(present); @@ -2454,14 +2449,19 @@ int virVMXParseFileSystem(virConfPtr conf, int numb= er, virDomainFSDefPtr *def) =20 /* vmx:present */ if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) = < 0) - goto cleanup; + return -1; =20 /* vmx:enabled */ if (virVMXGetConfigBoolean(conf, enabled_name, &enabled, false, true) = < 0) - goto cleanup; + return -1; =20 if (!(present && enabled)) - goto ignore; + return 0; + + if (!(*def =3D virDomainFSDefNew())) + return -1; + + (*def)->type =3D VIR_DOMAIN_FS_TYPE_MOUNT; =20 /* vmx:hostPath */ if (virVMXGetConfigString(conf, hostPath_name, &hostPath, false) < 0) @@ -2497,14 +2497,6 @@ int virVMXParseFileSystem(virConfPtr conf, int numbe= r, virDomainFSDefPtr *def) VIR_FREE(guestName); =20 return result; - - ignore: - virDomainFSDefFree(*def); - *def =3D NULL; - - result =3D 0; - - goto cleanup; } =20 =20 @@ -2557,9 +2549,6 @@ virVMXParseEthernet(virConfPtr conf, int controller, = virDomainNetDefPtr *def) return -1; } =20 - if (VIR_ALLOC(*def) < 0) - return -1; - snprintf(prefix, sizeof(prefix), "ethernet%d", controller); =20 VMX_BUILD_NAME(present); @@ -2575,17 +2564,20 @@ virVMXParseEthernet(virConfPtr conf, int controller= , virDomainNetDefPtr *def) =20 /* vmx:present */ if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) = < 0) - goto cleanup; + return -1; =20 /* vmx:startConnected */ if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected, true, true) < 0) { - goto cleanup; + return -1; } =20 /* FIXME: Need to distiguish between active and inactive domains here = */ if (! present/* && ! startConnected*/) - goto ignore; + return 0; + + if (VIR_ALLOC(*def) < 0) + return -1; =20 /* vmx:connectionType -> def:type */ if (virVMXGetConfigString(conf, connectionType_name, &connectionType, @@ -2726,14 +2718,6 @@ virVMXParseEthernet(virConfPtr conf, int controller,= virDomainNetDefPtr *def) VIR_FREE(vnet); =20 return result; - - ignore: - virDomainNetDefFree(*def); - *def =3D NULL; - - result =3D 0; - - goto cleanup; } =20 =20 @@ -2773,11 +2757,6 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr con= f, int port, return -1; } =20 - if (!(*def =3D virDomainChrDefNew(NULL))) - return -1; - - (*def)->deviceType =3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; - snprintf(prefix, sizeof(prefix), "serial%d", port); =20 VMX_BUILD_NAME(present); @@ -2788,17 +2767,22 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr co= nf, int port, =20 /* vmx:present */ if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) = < 0) - goto cleanup; + return -1; =20 /* vmx:startConnected */ if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected, true, true) < 0) { - goto cleanup; + return -1; } =20 /* FIXME: Need to distiguish between active and inactive domains here = */ if (! present/* && ! startConnected*/) - goto ignore; + return 0; + + if (!(*def =3D virDomainChrDefNew(NULL))) + return -1; + + (*def)->deviceType =3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; =20 /* vmx:fileType -> def:type */ if (virVMXGetConfigString(conf, fileType_name, &fileType, true) < 0) @@ -2919,14 +2903,6 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr con= f, int port, virURIFree(parsedUri); =20 return result; - - ignore: - virDomainChrDefFree(*def); - *def =3D NULL; - - result =3D 0; - - goto cleanup; } =20 =20 @@ -2961,11 +2937,6 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr c= onf, int port, return -1; } =20 - if (!(*def =3D virDomainChrDefNew(NULL))) - return -1; - - (*def)->deviceType =3D VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; - snprintf(prefix, sizeof(prefix), "parallel%d", port); =20 VMX_BUILD_NAME(present); @@ -2975,17 +2946,22 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr = conf, int port, =20 /* vmx:present */ if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) = < 0) - goto cleanup; + return -1; =20 /* vmx:startConnected */ if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected, true, true) < 0) { - goto cleanup; + return -1; } =20 /* FIXME: Need to distiguish between active and inactive domains here = */ if (! present/* && ! startConnected*/) - goto ignore; + return 0; + + if (!(*def =3D virDomainChrDefNew(NULL))) + return -1; + + (*def)->deviceType =3D VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; =20 /* vmx:fileType -> def:type */ if (virVMXGetConfigString(conf, fileType_name, &fileType, false) < 0) @@ -3029,14 +3005,6 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr c= onf, int port, VIR_FREE(fileName); =20 return result; - - ignore: - virDomainChrDefFree(*def); - *def =3D NULL; - - result =3D 0; - - goto cleanup; } =20 =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 22:53:12 2024 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 1522237248462581.8819469574161; Wed, 28 Mar 2018 04:40:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 056DE7F3EC; Wed, 28 Mar 2018 11:40:47 +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 C7BCE63146; Wed, 28 Mar 2018 11:40:46 +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 821AA180BAD3; Wed, 28 Mar 2018 11:40:46 +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 w2SBeSuM021932 for ; Wed, 28 Mar 2018 07:40:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 92BF8D7E0C; Wed, 28 Mar 2018 11:40:28 +0000 (UTC) Received: from thyrus.usersys.redhat.com (unknown [10.34.245.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 390A9946A2 for ; Wed, 28 Mar 2018 11:40:28 +0000 (UTC) From: Pino Toscano To: libvir-list@redhat.com Date: Wed, 28 Mar 2018 13:40:19 +0200 Message-Id: <20180328114021.15169-3-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 2/4] vmx: allocate space for network interfaces if needed 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 28 Mar 2018 11:40:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Dynamically grow the array of network interfaces for each interface read, instead of using a single array of size 4. This way, in the future it will be easier to not limit the number of network interfaces (which this patch still does not change). Signed-off-by: Pino Toscano --- src/vmx/vmx.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index ba47a87b7..fd9b55950 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1751,19 +1751,16 @@ virVMXParseConfig(virVMXContext *ctx, } =20 /* def:nets */ - if (VIR_ALLOC_N(def->nets, 4) < 0) - goto cleanup; - - def->nnets =3D 0; - for (controller =3D 0; controller < 4; ++controller) { - if (virVMXParseEthernet(conf, controller, - &def->nets[def->nnets]) < 0) { + virDomainNetDefPtr net =3D NULL; + if (virVMXParseEthernet(conf, controller, &net) < 0) goto cleanup; - } =20 - if (def->nets[def->nnets] !=3D NULL) - ++def->nnets; + if (!net) + continue; + + if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0) + goto cleanup; } =20 /* def:inputs */ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 22:53:12 2024 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 152223724858579.0493096897419; Wed, 28 Mar 2018 04:40:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F40417B005; Wed, 28 Mar 2018 11:40:46 +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 CBFCC600CC; Wed, 28 Mar 2018 11:40:46 +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 8248D180BAD4; Wed, 28 Mar 2018 11:40:46 +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 w2SBeTPt021941 for ; Wed, 28 Mar 2018 07:40:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 32E1A9C073; Wed, 28 Mar 2018 11:40:29 +0000 (UTC) Received: from thyrus.usersys.redhat.com (unknown [10.34.245.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCAE6946A2 for ; Wed, 28 Mar 2018 11:40:28 +0000 (UTC) From: Pino Toscano To: libvir-list@redhat.com Date: Wed, 28 Mar 2018 13:40:20 +0200 Message-Id: <20180328114021.15169-4-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 3/4] internal: add STRCASEPREFIX 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 28 Mar 2018 11:40:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Simple macro to check the prefix of a string in a case-insensitive way. Signed-off-by: Pino Toscano --- src/internal.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/internal.h b/src/internal.h index 589503041..1760e3b69 100644 --- a/src/internal.h +++ b/src/internal.h @@ -75,6 +75,7 @@ # define STRNEQLEN(a, b, n) (strncmp(a, b, n) !=3D 0) # define STRCASENEQLEN(a, b, n) (c_strncasecmp(a, b, n) !=3D 0) # define STRPREFIX(a, b) (strncmp(a, b, strlen(b)) =3D=3D 0) +# define STRCASEPREFIX(a, b) (c_strncasecmp(a, b, strlen(b)) =3D=3D 0) # define STRSKIP(a, b) (STRPREFIX(a, b) ? (a) + strlen(b) : NULL) =20 # define STREQ_NULLABLE(a, b) \ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 22:53:12 2024 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