From patchwork Wed Mar 13 15:51:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 160243 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp14474114jad; Wed, 13 Mar 2019 08:51:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGSbDuakeCX7Yu65ejxa18ao+a7Z6t8cOf0K/3qbZpVDFMYmmw1pudBILaCWi3fGHCIoXj X-Received: by 2002:ac8:3653:: with SMTP id n19mr11400100qtb.95.1552492308225; Wed, 13 Mar 2019 08:51:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552492308; cv=none; d=google.com; s=arc-20160816; b=nDOD7snsVbqLnybb7ZtSKf2GIUR++4/Kg5V5Q7csNbvi/yK+Xd7pIK3dz2fNzPhOWL hv+o1QJXY0M7I8cvSZVtJKzKgBC0GNSMkzwxccxfohaJnlkVZK/NNhvP+2Ka2HLN8Aho er849lor6gjPOtYZEn1vDnu0Uk5qLQXIZ6kDgBz94vcSTQHdvDVdag/C3gZMzyXBENEM igj7qOLlV7IJneSO3waPomNJSs6Xfyb37PZiHiHFs15BKY/GFUweZbODhRl/xkgQI5Nh nizmlfcLj0Fls5aJigUsMue3+Mte99peqn68GUXbdu1OJO5aWdXmC/CyJH02UcXIiBM3 UkFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=BMt0KqxB5y9crSCUscIS+R8urGSPPO3ERLN2SyNWmBE=; b=C4ZSv6hpEWhJi9Fs3YRzbnioRdmQSDoRFvhJeWfgr2qqwdRSn5H9KrDcXe8rUUb3Pv C6K1BT5qaH6EVWs1At7e2vEjMqDBBTagOA5l6/QFPPu3cAAuodjdKStQeI+P0W/3pdeY OGjvSBpgP2DJSvnJfDBQc1AZtVErk3BGs6ktvlX7H7FflsCkUWDgIVrR9eXUQ4appNqA TWI0CLNwatbqWFhkV0ism9CBgWojjRxfBZCX3YPDHHZnffRLek5/sL+xZh83T/gWUJiT XNCdWeL9IJYfoIyEs72F/KcoN4uCRYMLelh/ouuXaLGLIzT06cP/cZhUlQI6zfhmVk2k CHbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id g29si958459qte.166.2019.03.13.08.51.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 08:51:48 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 AD043118ED0; Wed, 13 Mar 2019 15:51: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 84DEF60F89; Wed, 13 Mar 2019 15:51: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 4776E181A268; Wed, 13 Mar 2019 15:51:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2DFpajn001444 for ; Wed, 13 Mar 2019 11:51:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id DF5336B8CD; Wed, 13 Mar 2019 15:51:36 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-124-40.rdu2.redhat.com [10.10.124.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 760836B8CF; Wed, 13 Mar 2019 15:51:36 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 13 Mar 2019 11:51:18 -0400 Message-Id: <25414814764f4db9d126521cea4b89b801794e8e.1552492022.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 09/11] 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: , 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.38]); Wed, 13 Mar 2019 15:51:47 +0000 (UTC) Convert the vmware/vmx driver to net model enum, which requires adding enum values for vlance, vmxnet, vmxnet2, and vmxnet3. Signed-off-by: Cole Robinson --- src/conf/domain_conf.c | 4 ++++ src/conf/domain_conf.h | 4 ++++ src/vmx/vmx.c | 52 ++++++++++++++++++++++-------------------- 3 files changed, 35 insertions(+), 25 deletions(-) -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 93b511d9bc..3b5f27300e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -485,6 +485,10 @@ VIR_ENUM_IMPL(virDomainNetModel, VIR_DOMAIN_NET_MODEL_LAST, "spapr-vlan", "lan9118", "scm91c111", + "vlance", + "vmxnet", + "vmxnet2", + "vmxnet3", ); VIR_ENUM_IMPL(virDomainNetBackend, VIR_DOMAIN_NET_BACKEND_TYPE_LAST, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ed95deebf1..71ab8e5bf4 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, VIR_DOMAIN_NET_MODEL_LAST } virDomainNetModelType; diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 7a557847ba..eb68c3acc4 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2546,6 +2546,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) char networkName_name[48] = ""; char *networkName = NULL; + int netmodel = VIR_DOMAIN_NET_MODEL_UNKNOWN; + if (def == NULL || *def != NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); return -1; @@ -2630,11 +2632,17 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) } if (virtualDev != NULL) { - if (STRCASENEQ(virtualDev, "vlance") && - STRCASENEQ(virtualDev, "vmxnet") && - STRCASENEQ(virtualDev, "vmxnet3") && - STRCASENEQ(virtualDev, "e1000") && - STRCASENEQ(virtualDev, "e1000e")) { + if (STRCASEEQ(virtualDev, "vlance")) { + netmodel = VIR_DOMAIN_NET_MODEL_VLANCE; + } else if (STRCASEEQ(virtualDev, "vmxnet")) { + netmodel = VIR_DOMAIN_NET_MODEL_VMXNET; + } else if (STRCASEEQ(virtualDev, "vmxnet3")) { + netmodel = VIR_DOMAIN_NET_MODEL_VMXNET3; + } else if (STRCASEEQ(virtualDev, "e1000")) { + netmodel = VIR_DOMAIN_NET_MODEL_E1000; + } else if (STRCASEEQ(virtualDev, "e1000e")) { + netmodel = 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'"), @@ -2642,12 +2650,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) goto cleanup; } - if (STRCASEEQ(virtualDev, "vmxnet") && features == 15) { - VIR_FREE(virtualDev); - - if (VIR_STRDUP(virtualDev, "vmxnet2") < 0) - goto cleanup; - } + if (netmodel == VIR_DOMAIN_NET_MODEL_VMXNET && features == 15) + netmodel = VIR_DOMAIN_NET_MODEL_VMXNET2; } /* vmx:networkName -> def:data.bridge.brname */ @@ -2697,10 +2701,7 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) goto cleanup; } - if (virDomainNetSetModelString((*def), virtualDev) < 0) - goto cleanup; - VIR_FREE(virtualDev); - + (*def)->model = netmodel; result = 0; cleanup: @@ -3738,29 +3739,30 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int controller, virBufferAsprintf(buffer, "ethernet%d.present = \"true\"\n", controller); /* 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 != VIR_DOMAIN_NET_MODEL_VLANCE && + def->model != VIR_DOMAIN_NET_MODEL_VMXNET && + def->model != VIR_DOMAIN_NET_MODEL_VMXNET2 && + def->model != VIR_DOMAIN_NET_MODEL_VMXNET3 && + def->model != VIR_DOMAIN_NET_MODEL_E1000 && + def->model != VIR_DOMAIN_NET_MODEL_E1000E) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Expecting domain XML entry 'devices/interface/model' " "to be 'vlance' or 'vmxnet' or 'vmxnet2' or 'vmxnet3' " "or 'e1000' or 'e1000e' but found '%s'"), - virDomainNetGetModelString(def)); + virDomainNetModelTypeToString(def->model)); return -1; } - if (virDomainNetStrcaseeqModelString(def, "vmxnet2")) { + if (def->model == VIR_DOMAIN_NET_MODEL_VMXNET2) { virBufferAsprintf(buffer, "ethernet%d.virtualDev = \"vmxnet\"\n", controller); virBufferAsprintf(buffer, "ethernet%d.features = \"15\"\n", controller); } else { virBufferAsprintf(buffer, "ethernet%d.virtualDev = \"%s\"\n", - controller, virDomainNetGetModelString(def)); + controller, + virDomainNetModelTypeToString(def->model)); } }