From patchwork Fri Jan 18 23:05:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 156100 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3797260jaa; Fri, 18 Jan 2019 15:06:00 -0800 (PST) X-Google-Smtp-Source: ALg8bN6lwy8AxKOPLb+jpx+k+q82UF1557Tjxe7wJGRbi+ztDuSTD5ZR992KTyx5ygc8fR0CVlMd X-Received: by 2002:a05:620a:9:: with SMTP id j9mr16954672qki.144.1547852760628; Fri, 18 Jan 2019 15:06:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547852760; cv=none; d=google.com; s=arc-20160816; b=dt4VqBLA1mnjg8CD6E2lcwvLNViWWD3dAJCOd4zx311Sgk50ol+7vZS7TJNH020Bbx AnRxJ6jYBWaAOb+blk3UZjGWg/E/vmlKf0kHe0RumJkZBCWoRI14eryOx39lm6zpXe65 W6HP4HCbJoExupdKD3JROC9PoeYwvKggZ/k+yXBz7YelkrJnhFlglJW6h0RWQmZfsKW4 G/d14LrISTrwNHIUSIhCGN4S0QMwur+z3gL9VC/Fz2i1Ppj4yaDOIMKqUd/dTYpqAgwo cGgxozdwClyU5vk7gAqAiUDTua70dOLbH+dyjCeGnG+mocgjzFzGaNUwlAWTdF8lTwS8 hUfg== 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=zgj8u1879UxJxs9z2lgl4gECNzwwbhvDPkMSXIPiKxg=; b=h6hfInrpYP3cbOJs/PD1ZS7ZYFzC/1cVvphsteam8qO+xASJspslLtN3bJZNo9LMpo lr/JZNVePL6E6bOdJcqv/qIHO1HW6iOmynk0RziL4XIOxfRBv1XaVerwY4S4/yOwMcsJ JEU72zwcD1XO6Gb4PKIAqsni6H9QNvxEknsEpTGt45Wv3xY0yMkIc/gkVMQK/huJcBVr fcEIs2+vuPPhnrHauFqfc7ZiGTHAee+22PtTppexAaiGAGnuZyRVyiHgDo2ldN4edrPE s/V+PglOX8lDHhkW9HW3tL+dy9m4DrZ6uOSYRtzv3lKticgCVxt6CIqdeUUcNBePwiZW Kwnw== 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 c69si4410907qkg.91.2019.01.18.15.06.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jan 2019 15:06:00 -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-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 3614537EE0; Fri, 18 Jan 2019 23:05:59 +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 E3D21101E597; Fri, 18 Jan 2019 23:05:58 +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 97C601803398; Fri, 18 Jan 2019 23:05:58 +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 x0IN5bE2008680 for ; Fri, 18 Jan 2019 18:05:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8EF7C600C2; Fri, 18 Jan 2019 23:05:37 +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 1E10E600CC; Fri, 18 Jan 2019 23:05:37 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 18 Jan 2019 18:05:25 -0500 Message-Id: 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 07/10] 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.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.29]); Fri, 18 Jan 2019 23:05:59 +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 | 24 +++++++++++------------- src/conf/domain_conf.h | 9 +++++++-- src/libvirt_private.syms | 1 - src/qemu/qemu_command.c | 26 ++++++++++++-------------- src/qemu/qemu_domain.c | 29 +++++++++++++---------------- src/qemu/qemu_domain_address.c | 12 ++++++------ 6 files changed, 49 insertions(+), 52 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 9b651d06b6..4e0e7eabe6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -441,7 +441,14 @@ VIR_ENUM_IMPL(virDomainNetModel, VIR_DOMAIN_NET_MODEL_LAST, "netfront", "rtl8139", "virtio", - "e1000") + "e1000", + "e1000e", + "virtio-transitional", + "virtio-non-transitional", + "usb-net", + "spapr-vlan", + "lan9118", + "scm91c111") VIR_ENUM_IMPL(virDomainNetBackend, VIR_DOMAIN_NET_BACKEND_TYPE_LAST, "default", @@ -29873,15 +29880,6 @@ virDomainNetSetModelString(virDomainNetDefPtr iface, return 0; } -int -virDomainNetStreqModelString(const virDomainNetDef *iface, - const char *model) -{ - if (iface->model) - return iface->model == virDomainNetModelTypeFromString(model); - return STREQ_NULLABLE(iface->modelstr, model); -} - int virDomainNetStrcaseeqModelString(const virDomainNetDef *iface, const char *model) @@ -29895,9 +29893,9 @@ virDomainNetStrcaseeqModelString(const virDomainNetDef *iface, bool virDomainNetHasVirtioModel(const virDomainNetDef *iface) { - return (virDomainNetStreqModelString(iface, "virtio") || - virDomainNetStreqModelString(iface, "virtio-transitional") || - virDomainNetStreqModelString(iface, "virtio-non-transitional")); + return (iface->model == VIR_DOMAIN_NET_MODEL_VIRTIO || + iface->model == VIR_DOMAIN_NET_MODEL_VIRTIO_TRANSITIONAL || + iface->model == VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2e1235a993..4c42bd18cf 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; @@ -3286,8 +3293,6 @@ bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface); const char *virDomainNetGetModelString(const virDomainNetDef *iface); int virDomainNetSetModelString(virDomainNetDefPtr iface, const char *model); -int virDomainNetStreqModelString(const virDomainNetDef *iface, - const char *model); int virDomainNetStrcaseeqModelString(const virDomainNetDef *iface, const char *model); bool virDomainNetHasVirtioModel(const virDomainNetDef *iface); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d802535fa0..3ed0b3b11c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -485,7 +485,6 @@ virDomainNetResolveActualType; virDomainNetSetDeviceImpl; virDomainNetSetModelString; virDomainNetStrcaseeqModelString; -virDomainNetStreqModelString; virDomainNetTypeFromString; virDomainNetTypeSharesHostView; virDomainNetTypeToString; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 83222dd0be..48e8b7a9bf 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -449,7 +449,6 @@ qemuBuildVirtioTransitional(virBufferPtr buf, virQEMUCapsPtr qemuCaps, virDomainDeviceAddressType type, int model, - const char *modelstr, virDomainDeviceType devtype) { int tmodel_cap, ntmodel_cap; @@ -466,8 +465,8 @@ qemuBuildVirtioTransitional(virBufferPtr buf, ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_NET: - has_tmodel = STREQ(modelstr, "virtio-transitional"); - has_ntmodel = STREQ(modelstr, "virtio-non-transitional"); + has_tmodel = model == VIR_DOMAIN_NET_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = model == VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL; tmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_NET_TRANSITIONAL; ntmodel_cap = QEMU_CAPS_DEVICE_VIRTIO_NET_NON_TRANSITIONAL; break; @@ -2186,7 +2185,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, case VIR_DOMAIN_DISK_BUS_VIRTIO: if (qemuBuildVirtioTransitional(&opt, "virtio-blk", qemuCaps, disk->info.type, - disk->model, NULL, + disk->model, VIR_DOMAIN_DEVICE_DISK) < 0) goto error; @@ -2778,7 +2777,7 @@ qemuBuildFSDevStr(const virDomainDef *def, if (qemuBuildVirtioTransitional(&opt, "virtio-9p", qemuCaps, fs->info.type, - fs->model, NULL, + fs->model, VIR_DOMAIN_DEVICE_FS) < 0) goto error; @@ -2989,7 +2988,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: if (qemuBuildVirtioTransitional(&buf, "virtio-scsi", qemuCaps, def->info.type, - def->model, NULL, + def->model, VIR_DOMAIN_DEVICE_CONTROLLER) < 0) { goto error; } @@ -3034,7 +3033,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: if (qemuBuildVirtioTransitional(&buf, "virtio-serial", qemuCaps, def->info.type, - def->model, NULL, + def->model, VIR_DOMAIN_DEVICE_CONTROLLER) < 0) goto error; @@ -3806,8 +3805,7 @@ qemuBuildNicDevStr(virDomainDefPtr def, if (virDomainNetHasVirtioModel(net)) { if (qemuBuildVirtioTransitional(&buf, "virtio-net", qemuCaps, - net->info.type, 0, - virDomainNetGetModelString(net), + net->info.type, net->model, VIR_DOMAIN_DEVICE_NET) < 0) goto error; @@ -4204,7 +4202,7 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd, if (qemuBuildVirtioTransitional(&buf, "virtio-balloon", qemuCaps, def->memballoon->info.type, - def->memballoon->model, NULL, + def->memballoon->model, VIR_DOMAIN_DEVICE_MEMBALLOON) < 0) { goto error; } @@ -4317,7 +4315,7 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def, case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH: if (qemuBuildVirtioTransitional(&buf, "virtio-input-host", qemuCaps, dev->info.type, - dev->model, NULL, + dev->model, VIR_DOMAIN_DEVICE_INPUT) < 0) goto error; break; @@ -5085,7 +5083,7 @@ qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def, if (qemuBuildVirtioTransitional(&buf, "vhost-scsi", qemuCaps, dev->info->type, - hostsrc->model, NULL, + hostsrc->model, VIR_DOMAIN_DEVICE_HOSTDEV) < 0) goto cleanup; @@ -6044,7 +6042,7 @@ qemuBuildRNGDevStr(const virDomainDef *def, if (qemuBuildVirtioTransitional(&buf, "virtio-rng", qemuCaps, dev->info.type, - dev->model, NULL, + dev->model, VIR_DOMAIN_DEVICE_RNG) < 0) goto error; @@ -10510,7 +10508,7 @@ qemuBuildVsockDevStr(virDomainDefPtr def, if (qemuBuildVirtioTransitional(&buf, "vhost-vsock", qemuCaps, vsock->info.type, - vsock->model, NULL, + vsock->model, VIR_DOMAIN_DEVICE_VSOCK) < 0) goto cleanup; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 38e86b8ad1..44d43a85c9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6067,49 +6067,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; } @@ -6565,11 +6565,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 c0843bdad6..0cb557b2ab 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) @@ -694,18 +694,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;