From patchwork Wed Jan 23 21:32:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 156397 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1201294jaa; Wed, 23 Jan 2019 13:33:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN4E5UPz0Y6itg8rXdR38/r9c8ZYOagprbbKZeYh4H1I/MIUQ7GpmorYcSGPNBTrojUV6mLL X-Received: by 2002:a37:6a42:: with SMTP id f63mr3362276qkc.224.1548279201934; Wed, 23 Jan 2019 13:33:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548279201; cv=none; d=google.com; s=arc-20160816; b=vv/EP28YHowmUX1myybamt3L7AwkEwhR0UASG0TXYuxwYeeZx5CDX/BuIPtMRJL9KS zsYov2G2sH1Q7L5Zs6zA9yUqijjUtyGLaTOWBHFbk5tJR1zMKdvq93q8WHDs6Pux/wgX 7N50AchXnPMBbpnOFtrvOCE0aHFpH4XQ5j5J4CXBinML7cnozHMSto3g4dQnkBdLsY// 9QcQZPX9G3oRd4PXZroHBuABEljFQKmSH+wLNn69bhkWSQT6Q3OAmxN5fn8l8Px3tP63 eZcNmcmlGRT6aZPn0uFpkgkK3PILhgtUEzS7olcHBDUrP4WJ33i3/7240reNlqtG1K1C Gnwg== 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=9xH3mvpp5TNJJoolG0cj+cbW+J6377byEkR58QTiKOA=; b=EBc1dNiVhr2nU+WcC9TWrnHhwdk1lFqzVgoglxA7DtUlhUI+QWk3UhF14JCJuh3UCF G/zPM+hM8mXVcbyhy2P1DYfkb+wMbwTDIgGEe56dL9QywPWmuBFE5Hvqb0Ke1yIToVXt sR5y09VC4hV0DieFP4keJTfHAzr5UyMxVyUxKLIdNqa6ey6iXkHDXiIl4a+FzG3Jrq0D psSyTCrgNaiJKJh3q3umy8DbmA9D1K22f3h+977Vj4wPNT04FGqah5iLgWA05mFFgK8C EDsbN5siZzX68xndmIUjB6/k2Fpw3pqUV95uC3Ta5BQzOO8y8vtzFgmYyrxGNFONSx5M j/6Q== 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 v63si1405251qkl.145.2019.01.23.13.33.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 13:33:21 -0800 (PST) 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-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 698CB2CD80F; Wed, 23 Jan 2019 21:33:20 +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 7C2BD26348; Wed, 23 Jan 2019 21:33:19 +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 9FC3E3F7D0; Wed, 23 Jan 2019 21:33:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0NLXFl1032243 for ; Wed, 23 Jan 2019 16:33:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 88CA1BA50; Wed, 23 Jan 2019 21:33:15 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-120-34.rdu2.redhat.com [10.10.120.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1AD167141; Wed, 23 Jan 2019 21:33:14 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 23 Jan 2019 16:32:29 -0500 Message-Id: <3ef0b006becbb1912099ab98ce77f5b4de7232bf.1548278585.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 01/25] conf: Set net->model 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 23 Jan 2019 21:33:21 +0000 (UTC) So later code can more easily access def->model Signed-off-by: Cole Robinson --- src/conf/domain_conf.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Andrea Bolognani diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 54d6364f4f..564248e021 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11305,6 +11305,22 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; } + /* NIC model (see -net nic,model=?). We only check that it looks + * reasonable, not that it is a supported NIC type. FWIW kvm + * supports these types as of April 2008: + * i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio + * QEMU PPC64 supports spapr-vlan + */ + if (model != NULL) { + if (strspn(model, NET_MODEL_CHARS) < strlen(model)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Model name contains invalid characters")); + goto error; + } + def->model = model; + model = NULL; + } + switch (def->type) { case VIR_DOMAIN_NET_TYPE_NETWORK: if (network == NULL) { @@ -11322,7 +11338,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, break; case VIR_DOMAIN_NET_TYPE_VHOSTUSER: - if (STRNEQ_NULLABLE(model, "virtio")) { + if (STRNEQ_NULLABLE(def->model, "virtio")) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Wrong or no 'type' attribute " "specified with . " @@ -11550,22 +11566,6 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, ifname_guest_actual = NULL; } - /* NIC model (see -net nic,model=?). We only check that it looks - * reasonable, not that it is a supported NIC type. FWIW kvm - * supports these types as of April 2008: - * i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio - * QEMU PPC64 supports spapr-vlan - */ - if (model != NULL) { - if (strspn(model, NET_MODEL_CHARS) < strlen(model)) { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("Model name contains invalid characters")); - goto error; - } - def->model = model; - model = NULL; - } - if (def->type != VIR_DOMAIN_NET_TYPE_HOSTDEV && STREQ_NULLABLE(def->model, "virtio")) { if (backend != NULL) {