From nobody Sun Feb 8 10:43:54 2026 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1547852770829293.4306270878666; Fri, 18 Jan 2019 15:06:10 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4ED513697F; Fri, 18 Jan 2019 23:06:08 +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 15E5E5D991; Fri, 18 Jan 2019 23:06:08 +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 B5E493F608; Fri, 18 Jan 2019 23:06:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0IN5cUv008687 for ; Fri, 18 Jan 2019 18:05:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3203A600D7; Fri, 18 Jan 2019 23:05:38 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-125-139.rdu2.redhat.com [10.10.125.139]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA512600C2; Fri, 18 Jan 2019 23:05:37 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 18 Jan 2019 18:05:26 -0500 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/10] vmx: convert to net model enum 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: , 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 18 Jan 2019 23:06:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Convert the vmware/vmx driver to net model enum, which requires adding enum values for vlance, vmxnet, vmxnet2, and vmxnet3. Previously vmx would accept case insensitive network model names via the domain XML, but now it will require names to exactly match the enum case. For reading from vmx files this won't matter as the parser does case-insensitive comparison. But if a user attempts to define/create a VM via custom XML with the wrong case, it will be rejected. I don't know if that's actually a usecase here so maybe it doesn't matter. Signed-off-by: Cole Robinson --- src/conf/domain_conf.c | 6 ++++- src/conf/domain_conf.h | 4 ++++ src/vmx/vmx.c | 52 ++++++++++++++++++++++-------------------- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4e0e7eabe6..b040b7b983 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -448,7 +448,11 @@ VIR_ENUM_IMPL(virDomainNetModel, VIR_DOMAIN_NET_MODEL_= LAST, "usb-net", "spapr-vlan", "lan9118", - "scm91c111") + "scm91c111", + "vlance", + "vmxnet", + "vmxnet2", + "vmxnet3") =20 VIR_ENUM_IMPL(virDomainNetBackend, VIR_DOMAIN_NET_BACKEND_TYPE_LAST, "default", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4c42bd18cf..e144d2c87c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -974,6 +974,10 @@ typedef enum { VIR_DOMAIN_NET_MODEL_SPAPR_VLAN, VIR_DOMAIN_NET_MODEL_LAN9118, VIR_DOMAIN_NET_MODEL_SMC91C111, + VIR_DOMAIN_NET_MODEL_VLANCE, + VIR_DOMAIN_NET_MODEL_VMXNET, + VIR_DOMAIN_NET_MODEL_VMXNET2, + VIR_DOMAIN_NET_MODEL_VMXNET3, =20 VIR_DOMAIN_NET_MODEL_LAST } virDomainNetModelType; diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 7f8357211c..ae0373dad2 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2545,6 +2545,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, = virDomainNetDefPtr *def) char networkName_name[48] =3D ""; char *networkName =3D NULL; =20 + int netmodel =3D VIR_DOMAIN_NET_MODEL_UNKNOWN; + if (def =3D=3D NULL || *def !=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); return -1; @@ -2629,11 +2631,17 @@ virVMXParseEthernet(virConfPtr conf, int controller= , virDomainNetDefPtr *def) } =20 if (virtualDev !=3D NULL) { - if (STRCASENEQ(virtualDev, "vlance") && - STRCASENEQ(virtualDev, "vmxnet") && - STRCASENEQ(virtualDev, "vmxnet3") && - STRCASENEQ(virtualDev, "e1000") && - STRCASENEQ(virtualDev, "e1000e")) { + if (STRCASEEQ(virtualDev, "vlance")) { + netmodel =3D VIR_DOMAIN_NET_MODEL_VLANCE; + } else if (STRCASEEQ(virtualDev, "vmxnet")) { + netmodel =3D VIR_DOMAIN_NET_MODEL_VMXNET; + } else if (STRCASEEQ(virtualDev, "vmxnet3")) { + netmodel =3D VIR_DOMAIN_NET_MODEL_VMXNET3; + } else if (STRCASEEQ(virtualDev, "e1000")) { + netmodel =3D VIR_DOMAIN_NET_MODEL_E1000; + } else if (STRCASEEQ(virtualDev, "e1000e")) { + netmodel =3D VIR_DOMAIN_NET_MODEL_E1000E; + } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("Expecting VMX entry '%s' to be 'vlance' or '= vmxnet' or " "'vmxnet3' or 'e1000' or 'e1000e' but found '= %s'"), @@ -2641,12 +2649,8 @@ virVMXParseEthernet(virConfPtr conf, int controller,= virDomainNetDefPtr *def) goto cleanup; } =20 - if (STRCASEEQ(virtualDev, "vmxnet") && features =3D=3D 15) { - VIR_FREE(virtualDev); - - if (VIR_STRDUP(virtualDev, "vmxnet2") < 0) - goto cleanup; - } + if (netmodel =3D=3D VIR_DOMAIN_NET_MODEL_VMXNET && features =3D=3D= 15) + netmodel =3D VIR_DOMAIN_NET_MODEL_VMXNET2; } =20 /* vmx:networkName -> def:data.bridge.brname */ @@ -2696,10 +2700,7 @@ virVMXParseEthernet(virConfPtr conf, int controller,= virDomainNetDefPtr *def) goto cleanup; } =20 - if (virDomainNetSetModelString((*def), virtualDev) < 0) - goto cleanup; - VIR_FREE(virtualDev); - + (*def)->model =3D netmodel; result =3D 0; =20 cleanup: @@ -3737,29 +3738,30 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int co= ntroller, virBufferAsprintf(buffer, "ethernet%d.present =3D \"true\"\n", control= ler); =20 /* def:model -> vmx:virtualDev, vmx:features */ - if (virDomainNetGetModelString(def)) { - if (!virDomainNetStrcaseeqModelString(def, "vlance") && - !virDomainNetStrcaseeqModelString(def, "vmxnet") && - !virDomainNetStrcaseeqModelString(def, "vmxnet2") && - !virDomainNetStrcaseeqModelString(def, "vmxnet3") && - !virDomainNetStrcaseeqModelString(def, "e1000") && - !virDomainNetStrcaseeqModelString(def, "e1000e")) { + if (def->model) { + if (def->model !=3D VIR_DOMAIN_NET_MODEL_VLANCE && + def->model !=3D VIR_DOMAIN_NET_MODEL_VMXNET && + def->model !=3D VIR_DOMAIN_NET_MODEL_VMXNET2 && + def->model !=3D VIR_DOMAIN_NET_MODEL_VMXNET3 && + def->model !=3D VIR_DOMAIN_NET_MODEL_E1000 && + def->model !=3D VIR_DOMAIN_NET_MODEL_E1000E) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Expecting domain XML entry 'devices/interfac= e/model' " "to be 'vlance' or 'vmxnet' or 'vmxnet2' or '= vmxnet3' " "or 'e1000' or 'e1000e' but found '%s'"), - virDomainNetGetModelString(def)); + virDomainNetModelTypeToString(def->model)); return -1; } =20 - if (virDomainNetStrcaseeqModelString(def, "vmxnet2")) { + if (def->model =3D=3D VIR_DOMAIN_NET_MODEL_VMXNET2) { virBufferAsprintf(buffer, "ethernet%d.virtualDev =3D \"vmxnet\= "\n", controller); virBufferAsprintf(buffer, "ethernet%d.features =3D \"15\"\n", controller); } else { virBufferAsprintf(buffer, "ethernet%d.virtualDev =3D \"%s\"\n", - controller, virDomainNetGetModelString(def)); + controller, + virDomainNetModelTypeToString(def->model)); } } =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list