From patchwork Wed Mar 13 15:51:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 160241 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp14474053jad; Wed, 13 Mar 2019 08:51:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHHDlSD6LGU33LAslmOypoKIZtT+qJ2qHt7DR89gbeOP2gTRdqq5FtxA/2gT3ScLKd5Dud X-Received: by 2002:a37:93c4:: with SMTP id v187mr29714902qkd.166.1552492304474; Wed, 13 Mar 2019 08:51:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552492304; cv=none; d=google.com; s=arc-20160816; b=gd0S7213PQ4a36K/2IS4R52znCz7FK6UYaKtv5JyqQLzY01tTvuGJNrb7coLwxGnJn kbkiDKr5Ihb3MNTBgCTZR0AYVXOv5FBJgoyuYoFq5WO58Y1uzlvo082ysHr8gY9+L7Wq vZE+d7MDld10LlB+lYSz+x5yVN59LtTO3te1W/f1sXvURPkPG+on/rzk5kFUXzwDJhF3 rsqnm8t/uV9bBVzWtTprkEwzOKdLh/pK71XurUSyivxmTdGnEA762Prmsx9j/gUvaEW1 aujR9hNSDtJXsj0uq40YUCotmGkzlPYDJ970FYETsxAj1ZcyO+SI76Jb/rlHgezgR80+ g0xw== 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=nLa/3zd/wchSVZBVmE4gEja1ErYKY8AJ5DOFRcN20A0=; b=bVjTE20K0ozIHQabCjoOxmNKaz4HJ/CYVBN4J78HEL7cZUxFtMWFzsD2xLoEjhODJ0 2Y/VOjGkubarwcnrKKw911WoZXzRtTZH/SdYFcA22C3U5JyObb5NMFqxzF0wXFR02WqO S68+UOPoJj/wwPcG4WFuP8h27Zz07WkiDwLanEH1gPJozoqJCGlsZraC2gdpabIKxgxt dpTdY2In6z02RP5F2hx8KFEE/8J8CEWdBe69RaympGDHUeOg2M6jpkoCpZiBAi8ZKGdv zfXEfNCpSQjU1Bu70GMHEo5UrFT6kr0AUJGylS3ddEEMCAASF4Y6YuUMCuAEfmEaOVne vgFA== 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 n57si959959qtn.205.2019.03.13.08.51.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 08:51:44 -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-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27EFFC130706; Wed, 13 Mar 2019 15:51:42 +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 EC5341001DE9; Wed, 13 Mar 2019 15:51:41 +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 A804C181A266; Wed, 13 Mar 2019 15:51:41 +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 x2DFpTHs001382 for ; Wed, 13 Mar 2019 11:51:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 729176B8C9; Wed, 13 Mar 2019 15:51:29 +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 095B36A96F; Wed, 13 Mar 2019 15:51:28 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 13 Mar 2019 11:51:15 -0400 Message-Id: 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 06/11] bhyve: 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 13 Mar 2019 15:51:43 +0000 (UTC) The bhyve driver only works with the virtio and e1000 models, which we already have in the enum. Some error reporting is slightly downgraded to avoid some subtle usage of modelstr Signed-off-by: Cole Robinson --- src/bhyve/bhyve_command.c | 15 ++++----------- src/bhyve/bhyve_parse_command.c | 10 ++++------ 2 files changed, 8 insertions(+), 17 deletions(-) -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index d3d790f6b6..219e2b8d9e 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -57,16 +57,10 @@ bhyveBuildNetArgStr(virConnectPtr conn, int ret = -1; virDomainNetType actualType = virDomainNetGetActualType(net); - if (!virDomainNetGetModelString(net)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("NIC model must be specified")); - return -1; - } - - if (virDomainNetStreqModelString(net, "virtio")) { + if (net->model == VIR_DOMAIN_NET_MODEL_VIRTIO) { if (VIR_STRDUP(nic_model, "virtio-net") < 0) return -1; - } else if (virDomainNetStreqModelString(net, "e1000")) { + } else if (net->model == VIR_DOMAIN_NET_MODEL_E1000) { if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_NET_E1000) != 0) { if (VIR_STRDUP(nic_model, "e1000") < 0) return -1; @@ -77,9 +71,8 @@ bhyveBuildNetArgStr(virConnectPtr conn, return -1; } } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("NIC model '%s' is not supported"), - virDomainNetGetModelString(net)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("NIC model is not supported")); return -1; } diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c index 60eb4c5412..490381688c 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -492,7 +492,7 @@ bhyveParsePCINet(virDomainDefPtr def, unsigned pcislot, unsigned pcibus, unsigned function, - const char *model, + int model, const char *config) { /* -s slot,virtio-net,tapN[,mac=xx:xx:xx:xx:xx:xx] */ @@ -511,9 +511,7 @@ bhyveParsePCINet(virDomainDefPtr def, if (VIR_STRDUP(net->data.bridge.brname, "virbr0") < 0) goto error; - if (virDomainNetSetModelString(net, model) < 0) - goto error; - + net->model = model; net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; net->info.addr.pci.slot = pcislot; net->info.addr.pci.bus = pcibus; @@ -621,10 +619,10 @@ bhyveParseBhyvePCIArg(virDomainDefPtr def, conf); else if (STREQ(emulation, "virtio-net")) bhyveParsePCINet(def, xmlopt, caps, pcislot, bus, function, - "virtio", conf); + VIR_DOMAIN_NET_MODEL_VIRTIO, conf); else if (STREQ(emulation, "e1000")) bhyveParsePCINet(def, xmlopt, caps, pcislot, bus, function, - "e1000", conf); + VIR_DOMAIN_NET_MODEL_E1000, conf); VIR_FREE(emulation); VIR_FREE(slotdef);