From patchwork Wed Mar 13 15:51:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 160242 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp14474097jad; Wed, 13 Mar 2019 08:51:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFijz9ztDNZbQvQNP+keaRUGaapUzEtFn95oIKQ4OPvPd5RmyCFH6YK/jW8mAirQhpf+aG X-Received: by 2002:a0c:9e45:: with SMTP id z5mr35175716qve.57.1552492306551; Wed, 13 Mar 2019 08:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552492306; cv=none; d=google.com; s=arc-20160816; b=e7ngcUtHTQJzFVBDLkFR2b2YfPXUhjVehT6ME05ZHpCadKjbebcfvqOr1NKiwUVg2k UyGibx7XFV+E6n84txAX0FKXKChVodyPcWjlnTNbByQz2GDX3oprnKWspXZMy5eT/GP0 xNfXjpHNy58gT4aaoD1ayh/SJGDWE1qHx+RK4PrwLItSx9AXvlq0p0obVFhcPZ9YjKUo t79Bc88irgf8XYooUyuX83uiGzC8168H/6YfhgQDRZ18dtECmulHMVq0w14xbWf9J2EQ QHOTN9Vud/28jQ0cVD5eYJpneVKeIpyij1OQgyIUd+DWVr8M9ZtE1vZdOvr+F6Y5O+xh gnUw== 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=qBtZqsjB3mfe507JyKDqWllQbRj9RD4TPLDp7NIvAQ4=; b=xQhJzb1ABmXRspRQ0R7H4L77/CwxrAw8kGaVongH/14VkLvb4SS44R+JX7SF+PglUD M2Az2PTH2OQmVjQ096oz7ZYUtH6juFPloQsWG1zQt1B/Jdw/PX/f4lZv0Tam3ER9/RBB aEqhm+469qFutBiVdAjVE0BBNFbgkS0WD/i57xgdMJg4qvcL+UXnAiyOGehHvpV6ahI1 vNb5MigEImkk6vWIE2714jnVO2oVYZb/ZQ/XhA4P2y7SJ4nvjr8FSQWjhI/TtfI7i7Ua 8eH2w5Hkz/Kh3zg20FQjmDAd4U1QDTWQFh/AWGI0qqxu89xakZZlGHFQONJejOKVjXZE Yhzw== 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 p38si6116762qve.171.2019.03.13.08.51.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 08:51:46 -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 BB2CA80E73; Wed, 13 Mar 2019 15:51:44 +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 8BE7F60F94; Wed, 13 Mar 2019 15:51:44 +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 545AA4EDDC; Wed, 13 Mar 2019 15:51:44 +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 x2DFpbtI001457 for ; Wed, 13 Mar 2019 11:51:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 91C906A97E; Wed, 13 Mar 2019 15:51:37 +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 226F56BF63; Wed, 13 Mar 2019 15:51:37 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 13 Mar 2019 11:51:19 -0400 Message-Id: <9a04cae6cf2dbe3a933c0d4a1c6a77649c69f660.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 10/11] vbox: Convert to net enum model 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.25]); Wed, 13 Mar 2019 15:51:45 +0000 (UTC) Convert the vbox driver to net model enum, which requires adding enum values for Am79C970A, Am79C973, 82540EM, 82545EM, 82543GC. We preserve the same casing that vbox historically used for these model names. Remove the now unused virDomainNetStrcaseeqModelString Signed-off-by: Cole Robinson --- src/conf/domain_conf.c | 14 +++++--------- src/conf/domain_conf.h | 7 +++++-- src/libvirt_private.syms | 1 - src/vbox/vbox_common.c | 31 ++++++++++++++----------------- 4 files changed, 24 insertions(+), 29 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 3b5f27300e..f58a6d77b9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -489,6 +489,11 @@ VIR_ENUM_IMPL(virDomainNetModel, VIR_DOMAIN_NET_MODEL_LAST, "vmxnet", "vmxnet2", "vmxnet3", + "Am79C970A", + "Am79C973", + "82540EM", + "82545EM", + "82543GC", ); VIR_ENUM_IMPL(virDomainNetBackend, VIR_DOMAIN_NET_BACKEND_TYPE_LAST, @@ -29430,15 +29435,6 @@ virDomainNetSetModelString(virDomainNetDefPtr net, return 0; } -int -virDomainNetStrcaseeqModelString(const virDomainNetDef *net, - const char *model) -{ - if (net->model) - return STRCASEEQ(virDomainNetModelTypeToString(net->model), model); - return net->modelstr && STRCASEEQ(net->modelstr, model); -} - bool virDomainNetIsVirtioModel(const virDomainNetDef *net) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 71ab8e5bf4..505982ec0e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -978,6 +978,11 @@ typedef enum { VIR_DOMAIN_NET_MODEL_VMXNET, VIR_DOMAIN_NET_MODEL_VMXNET2, VIR_DOMAIN_NET_MODEL_VMXNET3, + VIR_DOMAIN_NET_MODEL_AM79C970A, + VIR_DOMAIN_NET_MODEL_AM79C973, + VIR_DOMAIN_NET_MODEL_82540EM, + VIR_DOMAIN_NET_MODEL_82545EM, + VIR_DOMAIN_NET_MODEL_82543GC, VIR_DOMAIN_NET_MODEL_LAST } virDomainNetModelType; @@ -3340,8 +3345,6 @@ bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface); const char *virDomainNetGetModelString(const virDomainNetDef *net); int virDomainNetSetModelString(virDomainNetDefPtr et, const char *model); -int virDomainNetStrcaseeqModelString(const virDomainNetDef *net, - const char *model); bool virDomainNetIsVirtioModel(const virDomainNetDef *net); int virDomainNetAppendIPAddress(virDomainNetDefPtr def, const char *address, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2639446720..afb8cf92d8 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -486,7 +486,6 @@ virDomainNetRemoveHostdev; virDomainNetResolveActualType; virDomainNetSetDeviceImpl; virDomainNetSetModelString; -virDomainNetStrcaseeqModelString; virDomainNetTypeFromString; virDomainNetTypeSharesHostView; virDomainNetTypeToString; diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 8c28bba8ee..4612b1f6bd 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1309,7 +1309,7 @@ vboxAttachNetwork(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) macaddrvbox[VIR_MAC_STRING_BUFLEN - 6] = '\0'; VIR_DEBUG("NIC(%zu): Type: %d", i, def->nets[i]->type); - VIR_DEBUG("NIC(%zu): Model: %s", i, virDomainNetGetModelString(def->nets[i])); + VIR_DEBUG("NIC(%zu): Model: %s", i, virDomainNetModelTypeToString(def->nets[i]->model)); VIR_DEBUG("NIC(%zu): Mac: %s", i, macaddr); VIR_DEBUG("NIC(%zu): ifname: %s", i, def->nets[i]->ifname); if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_NETWORK) { @@ -1338,19 +1338,19 @@ vboxAttachNetwork(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) gVBoxAPI.UINetworkAdapter.SetEnabled(adapter, 1); - if (virDomainNetGetModelString(def->nets[i])) { - if (virDomainNetStrcaseeqModelString(def->nets[i], "Am79C970A")) { + if (def->nets[i]->model) { + if (def->nets[i]->model == VIR_DOMAIN_NET_MODEL_AM79C970A) { adapterType = NetworkAdapterType_Am79C970A; - } else if (virDomainNetStrcaseeqModelString(def->nets[i], "Am79C973")) { + } else if (def->nets[i]->model == VIR_DOMAIN_NET_MODEL_AM79C973) { adapterType = NetworkAdapterType_Am79C973; - } else if (virDomainNetStrcaseeqModelString(def->nets[i], "82540EM")) { + } else if (def->nets[i]->model == VIR_DOMAIN_NET_MODEL_82540EM) { adapterType = NetworkAdapterType_I82540EM; - } else if (virDomainNetStrcaseeqModelString(def->nets[i], "82545EM")) { + } else if (def->nets[i]->model == VIR_DOMAIN_NET_MODEL_82545EM) { adapterType = NetworkAdapterType_I82545EM; - } else if (virDomainNetStrcaseeqModelString(def->nets[i], "82543GC")) { + } else if (def->nets[i]->model == VIR_DOMAIN_NET_MODEL_82543GC) { adapterType = NetworkAdapterType_I82543GC; } else if (gVBoxAPI.APIVersion >= 3000051 && - virDomainNetStrcaseeqModelString(def->nets[i], "virtio")) { + def->nets[i]->model == VIR_DOMAIN_NET_MODEL_VIRTIO) { /* Only vbox 3.1 and later support NetworkAdapterType_Virto */ adapterType = NetworkAdapterType_Virtio; } @@ -3687,7 +3687,6 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter) { PRUint32 attachmentType = NetworkAttachmentType_Null; PRUint32 adapterType = NetworkAdapterType_Null; - const char *model = NULL; PRUnichar *utf16 = NULL; char *utf8 = NULL; virDomainNetDefPtr net = NULL; @@ -3742,28 +3741,26 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter) gVBoxAPI.UINetworkAdapter.GetAdapterType(adapter, &adapterType); switch (adapterType) { case NetworkAdapterType_Am79C970A: - model = "Am79C970A"; + net->model = VIR_DOMAIN_NET_MODEL_AM79C970A; break; case NetworkAdapterType_Am79C973: - model = "Am79C973"; + net->model = VIR_DOMAIN_NET_MODEL_AM79C973; break; case NetworkAdapterType_I82540EM: - model = "82540EM"; + net->model = VIR_DOMAIN_NET_MODEL_82540EM; break; case NetworkAdapterType_I82545EM: - model = "82545EM"; + net->model = VIR_DOMAIN_NET_MODEL_82545EM; break; case NetworkAdapterType_I82543GC: - model = "82543GC"; + net->model = VIR_DOMAIN_NET_MODEL_82543GC; break; case NetworkAdapterType_Virtio: /* Only vbox 3.1 and later support NetworkAdapterType_Virto */ if (gVBoxAPI.APIVersion >= 3000051) - model = "virtio"; + net->model = VIR_DOMAIN_NET_MODEL_VIRTIO; break; } - if (virDomainNetSetModelString(net, model) < 0) - goto error; gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &utf16); VBOX_UTF16_TO_UTF8(utf16, &utf8);