From patchwork Fri Jan 18 23:05:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 156103 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3797363jaa; Fri, 18 Jan 2019 15:06:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN6oWjfxItXc6yZlJRg8gdIW2Fv2u0pkBI0zQu/9iD5EuihBkQvj1DPRwxsnOwlpbTXgPjCs X-Received: by 2002:a0c:88a8:: with SMTP id 37mr17013846qvn.63.1547852765491; Fri, 18 Jan 2019 15:06:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547852765; cv=none; d=google.com; s=arc-20160816; b=qz/xDBBP1VrIztPEGiRdTGrI0mJiXDTts5hX2qY5Ze7y+h05g9rBD305LR1qPnwfr4 aDXoavCtZI67PI0x/UaJg6AlGgNRCVAomdWd4U/SMdPEu5k85X3bZnWzPGLqUB0RX/QC GOW6OgqL+GdRzbIxAyN9uKV1XkvQzP2ePVEvLTXoALhdDyH/assyHFUbBOZ9m8gHsbZ0 4jmGJKMwsVqd8Gl17iWAIk0opZuQj5HfIiQBlAFUgIDQBCEdlU8+ZNeFCbeBgvshCwWB BEmfmWqrXOFtsQ6VD6dwUdH732d5aQYZ9KxXiDkROm/WToUmWe/e3uX91W6CpwrWqphm dTqw== 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=pQ1rRYMlUpwMUhnX+JSS8FrSxVwEkXb5O35Hr42DmJw=; b=dlNjusUAamzjNfL/UjCnlGjpemeIGRI0xGw9kyc8G//LYMl87JeDKc59i8E4qLpmLO lZV9H8k82cKCgNlM+VlGzxuyQiOEFysE36QzRWI7WyqLHhm3J301/Q6SmYdxDEy/MNH4 7F390w43FF7wlnH0/Eyc835TkeRlKJQ2Cu9IAQfsaW6cVLfrXnwzxrsNDB3+GCbMkQrs 9FEu3va+AYAAgQ/e7KtL33upyaJc1MDnuH8Sr6VnndBM5oBYs+CeIABP/o0n7NDyWV19 5sDCAgtjaSCLqfDHf0kVXV8xaUC3zBNgqxRhv4RTeusr0JyRlvAN7tnIhbvls36brDb/ EYuA== 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 h4si2742934qtm.381.2019.01.18.15.06.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jan 2019 15:06:05 -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-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03BC596E9; Fri, 18 Jan 2019 23:06:04 +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 ABC0761D1A; Fri, 18 Jan 2019 23:06:03 +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 240CB18033CA; Fri, 18 Jan 2019 23:06:03 +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 x0IN5anc008658 for ; Fri, 18 Jan 2019 18:05:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 46BE1600D6; Fri, 18 Jan 2019 23:05:36 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-125-139.rdu2.redhat.com [10.10.125.139]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF3F5600C2; Fri, 18 Jan 2019 23:05:35 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 18 Jan 2019 18:05:23 -0500 Message-Id: <8f79ddeb607669441bc0d93325ddf1b27ded8b2d.1547851897.git.crobinso@redhat.com> 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 05/10] vz: 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 18 Jan 2019 23:06:04 +0000 (UTC) The vz driver only handles three models: virtio, e1000, and rtl8139. Add enum values for those models, and convert the vz driver to handling net->model natively Signed-off-by: Cole Robinson --- src/conf/domain_conf.c | 5 ++++- src/conf/domain_conf.h | 3 +++ src/vz/vz_driver.c | 7 +++---- src/vz/vz_sdk.c | 17 +++++++---------- 4 files changed, 17 insertions(+), 15 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 129e16bd0b..9b651d06b6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -438,7 +438,10 @@ VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST, VIR_ENUM_IMPL(virDomainNetModel, VIR_DOMAIN_NET_MODEL_LAST, "unknown", - "netfront") + "netfront", + "rtl8139", + "virtio", + "e1000") 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 e26b885508..2e1235a993 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -964,6 +964,9 @@ typedef enum { typedef enum { VIR_DOMAIN_NET_MODEL_UNKNOWN, VIR_DOMAIN_NET_MODEL_NETFRONT, + VIR_DOMAIN_NET_MODEL_RTL8139, + VIR_DOMAIN_NET_MODEL_VIRTIO, + VIR_DOMAIN_NET_MODEL_E1000, VIR_DOMAIN_NET_MODEL_LAST } virDomainNetModelType; diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index eab2953759..10fba0efb7 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -269,10 +269,9 @@ vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, if (dev->type == VIR_DOMAIN_DEVICE_NET && (dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK || dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) && - !virDomainNetGetModelString(dev->data.net) && - def->os.type == VIR_DOMAIN_OSTYPE_HVM && - virDomainNetSetModelString(dev->data.net, "e1000") < 0) - return -1; + dev->data.net->model == VIR_DOMAIN_NET_MODEL_UNKNOWN && + def->os.type == VIR_DOMAIN_OSTYPE_HVM) + dev->data.net->model = VIR_DOMAIN_NET_MODEL_E1000; return 0; } diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 60681591c6..13f18cbc19 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1105,16 +1105,13 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr net, bool isCt) switch ((int)type) { case PNT_RTL: - if (virDomainNetSetModelString(net, "rtl8139") < 0) - goto cleanup; + net->model = VIR_DOMAIN_NET_MODEL_RTL8139; break; case PNT_E1000: - if (virDomainNetSetModelString(net, "e1000") < 0) - goto cleanup; + net->model = VIR_DOMAIN_NET_MODEL_E1000; break; case PNT_VIRTIO: - if (virDomainNetSetModelString(net, "virtio") < 0) - goto cleanup; + net->model = VIR_DOMAIN_NET_MODEL_VIRTIO; break; default: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3378,15 +3375,15 @@ static int prlsdkConfigureNet(vzDriverPtr driver ATTRIBUTE_UNUSED, goto cleanup; if (isCt) { - if (virDomainNetGetModelString(net)) + if (net->model != VIR_DOMAIN_NET_MODEL_UNKNOWN) VIR_WARN("Setting network adapter for containers is not " "supported by vz driver."); } else { - if (virDomainNetStreqModelString(net, "rtl8139")) { + if (net->model == VIR_DOMAIN_NET_MODEL_RTL8139) { pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_RTL); - } else if (virDomainNetStreqModelString(net, "e1000")) { + } else if (net->model == VIR_DOMAIN_NET_MODEL_E1000) { pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_E1000); - } else if (virDomainNetStreqModelString(net, "virtio")) { + } else if (net->model == VIR_DOMAIN_NET_MODEL_VIRTIO) { pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_VIRTIO); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",