From patchwork Wed Mar 13 15:51:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 160240 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp14474039jad; Wed, 13 Mar 2019 08:51:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqz960GeExPR7TKneWDI7AQFtpQwRa5mcTCvnlHDCgWxQd8vmLqXTLcWf4xPILnn4ZJRnEJK X-Received: by 2002:ac8:44c2:: with SMTP id b2mr17459879qto.191.1552492303466; Wed, 13 Mar 2019 08:51:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552492303; cv=none; d=google.com; s=arc-20160816; b=02osOIy6T0fKVNOC8tj15t2+bSkyvPEuItLWlDGLGKBP6ET0z/uhPSukeIaKCMKQlY U1zuHC5fgIDhiTVcvnGP3JPrOkVYPpab0UsFCYBnt58laSd37orMzpZVWN1A/7wMQOHo z7+Jrpa+hpRQkj1MBgsfPtfvkv61noxntUDPqcRr3GJEutKf3HUUPHJjIJzyjRbwDk8/ iQ1CxTjmtzp0KKs0t/95q7kqN5MDobkFadbVumPRfrr54yT3BzToXjTLG5n1V/ZrjwwN 9ZowAVaW17MJnspM5FHTFlNkWr4FNp5smHvhBJ9GgqfC0rY+QT8oRGeeSoAjeqUNRkzI ZVTw== 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=NmhgJ48HSviQVWMVCDMQ4Py01or5NlMk7Asb5n+OJio=; b=REfdEqorbZExDML/fbEUAlSV40dXW/caDXh5FhdlH7Dcm1ltjvwCF1mWAnrTeuZiIS WefxM149OetT8aIiiPxmnrYPOE0AE1zHDx831gn4MldljyK85Ou65DAiR3zErtdU9Efs fpnf+QiSnjH3AZvyepteRlCC6LmFf7+uKolvxIMLPQM2WQ0Mdv2KpqbEg7JM8ryvwhes 41dGB2DxcAudg1/ea3s59RdJIjc33mrr2ysHL83SKuVNnua48fyuK6ZDLYzNUCRBmA6n uN+dVco+hbf5Sr9XrtXAljpBQ0yhFhCO2agmV2JieY/PuUNdUl2bGIv/m5sTbvFI0F4F zeXg== 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 d30si482793qvb.208.2019.03.13.08.51.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 08:51:43 -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-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1B557308CF92; Wed, 13 Mar 2019 15:51:41 +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 E864E5D763; Wed, 13 Mar 2019 15:51:40 +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 9F6D14ED3A; Wed, 13 Mar 2019 15:51:40 +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 x2DFpaLk001433 for ; Wed, 13 Mar 2019 11:51:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2E1A36B8CE; 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 B77376B8C8; Wed, 13 Mar 2019 15:51:35 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 13 Mar 2019 11:51:17 -0400 Message-Id: <2397df40619875bb6e65040ce45880d59a035fca.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 08/11] conf: Make net model enum compare case insensitive 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 13 Mar 2019 15:51:42 +0000 (UTC) vbox and vmx drivers do net case insensitive net model comparisons, so for example 'VMXNET3' and 'vmxnet3' and 'VmxNeT3' in the XML will translate to the same driver configuration. To convert these drivers to use net model enum, we will need to do case insensitive comparisons as well. Essentially we implement virEnumToString, but with case insensitive comparison. XML will always be formatted with the enum model string we track internally, but we will accept any case insensitive variant. Signed-off-by: Cole Robinson --- src/conf/domain_conf.c | 12 +++++++++--- tests/qemuxml2argvdata/net-many-models.xml | 3 ++- 2 files changed, 11 insertions(+), 4 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 a5882f27d9..93b511d9bc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29401,14 +29401,20 @@ int virDomainNetSetModelString(virDomainNetDefPtr net, const char *model) { - VIR_FREE(net->modelstr); - if ((net->model = virDomainNetModelTypeFromString(model)) >= 0) - return 0; + size_t i; + VIR_FREE(net->modelstr); net->model = VIR_DOMAIN_NET_MODEL_UNKNOWN; if (!model) return 0; + for (i = 0; i < ARRAY_CARDINALITY(virDomainNetModelTypeList); i++) { + if (STRCASEEQ(virDomainNetModelTypeList[i], model)) { + net->model = i; + return 0; + } + } + if (strspn(model, NET_MODEL_CHARS) < strlen(model)) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("Model name contains invalid characters")); diff --git a/tests/qemuxml2argvdata/net-many-models.xml b/tests/qemuxml2argvdata/net-many-models.xml index 2b8f9b18eb..40fc5de06c 100644 --- a/tests/qemuxml2argvdata/net-many-models.xml +++ b/tests/qemuxml2argvdata/net-many-models.xml @@ -21,7 +21,8 @@ - + +