From patchwork Wed Mar 13 15:51:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 160238 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp14473984jad; Wed, 13 Mar 2019 08:51:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHOIbgrl47h18SbB8FjxkRfNiOEC2ZB8iEnr1HoBaKR17fO0WyyyXj2+Yf88sBCzOPj2Um X-Received: by 2002:ac8:2df8:: with SMTP id q53mr10734639qta.132.1552492299326; Wed, 13 Mar 2019 08:51:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552492299; cv=none; d=google.com; s=arc-20160816; b=yUM9WVWhhjFmh7gsqQEQALHtYNttNJUPyhqrnM/VXn1JD2cZ1YewKxN53V++Tc5wGR Lq4+z8UWRhavKbI1M8Is6E7NQSg2UcaKL0b8Gdgn+cHDK8hEVOzfS2fdP0xg0euqd53R QDORAbYaFBfvJB3bR3ZW+JsvdVNBTvumPsqSMX1FmFinzUJMLdMzwP5Ijxg3EYwBoKED 46PhWl/KcYHWHKtfv5/KIKO2md9eEzsoF+IgZmvwdVWNyYggnC8Iz83uqz1g51gN4Nnp FK0uNzSBx8h5aymwsuwIykJIkZXWG9FNZFu2tCYRoc1uJgJm18+BI3EgzNWrFCZzvN+2 lzIQ== 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=4Flh9xAx3WSssUj7Gv3eKSro9VfRvpmnXqzze9UtzUE=; b=A6kOwYJb/rxEe6v9iZrVGt5Um1fu17AD7z/R99bQxwoUoY9WtzZvlPDQUjK1R+Xbzo WIgLUy5vomCnaWe/20i7wXKzmwLW3ilHf8rcNLAm8+7Dhjm4svoJUSUb9/A1UWI0qZOc xVrInm4BgWsLzn9zv/VP2ujlMD3N0iIOJ18iZTpKOzDkEs4plFqiy0HPBkprn3RZ4H9F e7aGcr/BNAHNjGw4AvNRLdGYFU6BcOpXHeP5I98WZww7uzbcjnMbAmMSkZHGNl/VaHOC 7oaoDI+OkGevf/OHmHnGhZ7RpX63lg0tQqIC1TuZ2QhDADBrX4dHbeowg5BwDTdhQYAC 9q/Q== 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 c15si4833344qvo.99.2019.03.13.08.51.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 08:51:39 -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-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F62B30583D7; Wed, 13 Mar 2019 15:51:37 +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 7171761350; Wed, 13 Mar 2019 15:51:37 +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 36AF9181A13B; Wed, 13 Mar 2019 15:51:37 +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 x2DFpZbB001421 for ; Wed, 13 Mar 2019 11:51:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8895F6B8CD; Wed, 13 Mar 2019 15:51:35 +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 1749A6B8D4; Wed, 13 Mar 2019 15:51:33 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 13 Mar 2019 11:51:16 -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 07/11] qemu: Partially 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 13 Mar 2019 15:51:38 +0000 (UTC) This converts the qemu driver to the net model enum, for all the model values that we have hardcoded for various checks, which adds e1000e, virtio-transitional, virtio-non-transitional, usb-net, spapr-vlan, lan9118, smc91c111 Because the qemu driver has historically also allowed the raw model string onto the qemu command line, this isn't a full conversion. Unwinding that will require more thought. However for all new driver code we should be adding explicit enum values for any model name we have special handling for. Remove the now unused virDomainNetStreqModelString Signed-off-by: Cole Robinson --- src/conf/domain_conf.c | 22 ++++++++++------------ src/conf/domain_conf.h | 9 +++++++-- src/libvirt_private.syms | 1 - src/qemu/qemu_command.c | 6 ++---- src/qemu/qemu_domain.c | 29 +++++++++++++---------------- src/qemu/qemu_domain_address.c | 12 ++++++------ 6 files changed, 38 insertions(+), 41 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 854b8eb045..a5882f27d9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -478,6 +478,13 @@ VIR_ENUM_IMPL(virDomainNetModel, VIR_DOMAIN_NET_MODEL_LAST, "rtl8139", "virtio", "e1000", + "e1000e", + "virtio-transitional", + "virtio-non-transitional", + "usb-net", + "spapr-vlan", + "lan9118", + "scm91c111", ); VIR_ENUM_IMPL(virDomainNetBackend, VIR_DOMAIN_NET_BACKEND_TYPE_LAST, @@ -29413,15 +29420,6 @@ virDomainNetSetModelString(virDomainNetDefPtr net, return 0; } -int -virDomainNetStreqModelString(const virDomainNetDef *net, - const char *model) -{ - if (net->model) - return net->model == virDomainNetModelTypeFromString(model); - return STREQ_NULLABLE(net->modelstr, model); -} - int virDomainNetStrcaseeqModelString(const virDomainNetDef *net, const char *model) @@ -29434,9 +29432,9 @@ virDomainNetStrcaseeqModelString(const virDomainNetDef *net, bool virDomainNetIsVirtioModel(const virDomainNetDef *net) { - return (virDomainNetStreqModelString(net, "virtio") || - virDomainNetStreqModelString(net, "virtio-transitional") || - virDomainNetStreqModelString(net, "virtio-non-transitional")); + return (net->model == VIR_DOMAIN_NET_MODEL_VIRTIO || + net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_TRANSITIONAL || + net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 780f878fd8..ed95deebf1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -967,6 +967,13 @@ typedef enum { VIR_DOMAIN_NET_MODEL_RTL8139, VIR_DOMAIN_NET_MODEL_VIRTIO, VIR_DOMAIN_NET_MODEL_E1000, + VIR_DOMAIN_NET_MODEL_E1000E, + VIR_DOMAIN_NET_MODEL_VIRTIO_TRANSITIONAL, + VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL, + VIR_DOMAIN_NET_MODEL_USB_NET, + VIR_DOMAIN_NET_MODEL_SPAPR_VLAN, + VIR_DOMAIN_NET_MODEL_LAN9118, + VIR_DOMAIN_NET_MODEL_SMC91C111, VIR_DOMAIN_NET_MODEL_LAST } virDomainNetModelType; @@ -3329,8 +3336,6 @@ bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface); const char *virDomainNetGetModelString(const virDomainNetDef *net); int virDomainNetSetModelString(virDomainNetDefPtr et, const char *model); -int virDomainNetStreqModelString(const virDomainNetDef *net, - const char *model); int virDomainNetStrcaseeqModelString(const virDomainNetDef *net, const char *model); bool virDomainNetIsVirtioModel(const virDomainNetDef *net); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3a0699d724..2639446720 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -487,7 +487,6 @@ virDomainNetResolveActualType; virDomainNetSetDeviceImpl; virDomainNetSetModelString; virDomainNetStrcaseeqModelString; -virDomainNetStreqModelString; virDomainNetTypeFromString; virDomainNetTypeSharesHostView; virDomainNetTypeToString; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0388ebc5af..a5deffbef2 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -479,10 +479,8 @@ qemuBuildVirtioDevStr(virBufferPtr buf, break; case VIR_DOMAIN_DEVICE_NET: - has_tmodel = virDomainNetStreqModelString(device.data.net, - "virtio-transitional"); - has_ntmodel = virDomainNetStreqModelString(device.data.net, - "virtio-non-transitional"); + has_tmodel = device.data.net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device.data.net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_HOSTDEV: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 7b001bca52..6718dfbc22 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6230,49 +6230,49 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, * is NULL this function may return NULL if the default model depends on the * capabilities. */ -static const char * +static int qemuDomainDefaultNetModel(const virDomainDef *def, virQEMUCapsPtr qemuCaps) { if (ARCH_IS_S390(def->os.arch)) - return "virtio"; + return VIR_DOMAIN_NET_MODEL_VIRTIO; if (def->os.arch == VIR_ARCH_ARMV6L || def->os.arch == VIR_ARCH_ARMV7L || def->os.arch == VIR_ARCH_AARCH64) { if (STREQ(def->os.machine, "versatilepb")) - return "smc91c111"; + return VIR_DOMAIN_NET_MODEL_SMC91C111; if (qemuDomainIsARMVirt(def)) - return "virtio"; + return VIR_DOMAIN_NET_MODEL_VIRTIO; /* Incomplete. vexpress (and a few others) use this, but not all * arm boards */ - return "lan9118"; + return VIR_DOMAIN_NET_MODEL_LAN9118; } /* virtio is a sensible default for RISC-V virt guests */ if (qemuDomainIsRISCVVirt(def)) - return "virtio"; + return VIR_DOMAIN_NET_MODEL_VIRTIO; /* In all other cases the model depends on the capabilities. If they were * not provided don't report any default. */ if (!qemuCaps) - return NULL; + return VIR_DOMAIN_NET_MODEL_UNKNOWN; /* Try several network devices in turn; each of these devices is * less likely be supported out-of-the-box by the guest operating * system than the previous one */ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_RTL8139)) - return "rtl8139"; + return VIR_DOMAIN_NET_MODEL_RTL8139; else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_E1000)) - return "e1000"; + return VIR_DOMAIN_NET_MODEL_E1000; else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_NET)) - return "virtio"; + return VIR_DOMAIN_NET_MODEL_VIRTIO; /* We've had no luck detecting support for any network device, * but we have to return something: might as well be rtl8139 */ - return "rtl8139"; + return VIR_DOMAIN_NET_MODEL_RTL8139; } @@ -6727,11 +6727,8 @@ qemuDomainDeviceNetDefPostParse(virDomainNetDefPtr net, virQEMUCapsPtr qemuCaps) { if (net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV && - !virDomainNetGetModelString(net)) { - if (virDomainNetSetModelString(net, - qemuDomainDefaultNetModel(def, qemuCaps)) < 0) - return -1; - } + !virDomainNetGetModelString(net)) + net->model = qemuDomainDefaultNetModel(def, qemuCaps); return 0; } diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 380c5bffcc..976ddaf3e0 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -230,7 +230,7 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def) for (i = 0; i < def->nnets; i++) { virDomainNetDefPtr net = def->nets[i]; - if (virDomainNetStreqModelString(net, "spapr-vlan")) + if (net->model == VIR_DOMAIN_NET_MODEL_SPAPR_VLAN) net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; if (qemuDomainAssignSpaprVIOAddress(def, &net->info, VIO_ADDR_NET) < 0) @@ -715,18 +715,18 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, * addresses for other hostdev devices. */ if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV || - virDomainNetStreqModelString(net, "usb-net")) { + net->model == VIR_DOMAIN_NET_MODEL_USB_NET) { return 0; } - if (virDomainNetStreqModelString(net, "virtio") || - virDomainNetStreqModelString(net, "virtio-non-transitional")) + if (net->model == VIR_DOMAIN_NET_MODEL_VIRTIO || + net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL) return virtioFlags; - if (virDomainNetStreqModelString(net, "virtio-transitional")) + if (net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_TRANSITIONAL) return pciFlags; - if (virDomainNetStreqModelString(net, "e1000e")) + if (net->model == VIR_DOMAIN_NET_MODEL_E1000E) return pcieFlags; return pciFlags;