@@ -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);
}
@@ -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);
@@ -485,7 +485,6 @@ virDomainNetResolveActualType;
virDomainNetSetDeviceImpl;
virDomainNetSetModelString;
virDomainNetStrcaseeqModelString;
-virDomainNetStreqModelString;
virDomainNetTypeFromString;
virDomainNetTypeSharesHostView;
virDomainNetTypeToString;
@@ -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;
@@ -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;
}
@@ -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;
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 <crobinso@redhat.com> --- 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