From a0824823b7e99e1df839f0dbec1cf1d54dc7eb57 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Mon, 15 Feb 2016 11:44:21 -0500 Subject: [PATCH] qemu: Move qemuDomainSupports* functions Move qemuDomainSupportsNicdev and qemuDomainSupportsNetdev into qemu_domain.c and expose from there. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 29 ----------------------------- src/qemu/qemu_domain.c | 29 +++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 11 ++++++++++- 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 427af6f6c6..ef961d9645 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -153,35 +153,6 @@ VIR_ENUM_IMPL(qemuNumaPolicy, VIR_DOMAIN_NUMATUNE_MEM_LAST, "preferred", "interleave"); -static bool -qemuDomainSupportsNicdev(virDomainDefPtr def, - virQEMUCapsPtr qemuCaps, - virDomainNetDefPtr net) -{ - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) - return false; - - /* non-virtio ARM nics require legacy -net nic */ - if (((def->os.arch == VIR_ARCH_ARMV7L) || - (def->os.arch == VIR_ARCH_AARCH64)) && - net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO && - net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) - return false; - - return true; -} - -static bool -qemuDomainSupportsNetdev(virDomainDefPtr def, - virQEMUCapsPtr qemuCaps, - virDomainNetDefPtr net) -{ - if (!qemuDomainSupportsNicdev(def, qemuCaps, net)) - return false; - return virQEMUCapsGet(qemuCaps, QEMU_CAPS_NETDEV); -} - - static int qemuBuildObjectCommandLinePropsInternal(const char *key, const virJSONValue *value, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4219773964..4e9a737ac8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4399,3 +4399,32 @@ qemuDomainDetectVcpuPids(virQEMUDriverPtr driver, priv->vcpupids = cpupids; return ncpupids; } + + +bool +qemuDomainSupportsNicdev(virDomainDefPtr def, + virQEMUCapsPtr qemuCaps, + virDomainNetDefPtr net) +{ + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) + return false; + + /* non-virtio ARM nics require legacy -net nic */ + if (((def->os.arch == VIR_ARCH_ARMV7L) || + (def->os.arch == VIR_ARCH_AARCH64)) && + net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO && + net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) + return false; + + return true; +} + +bool +qemuDomainSupportsNetdev(virDomainDefPtr def, + virQEMUCapsPtr qemuCaps, + virDomainNetDefPtr net) +{ + if (!qemuDomainSupportsNicdev(def, qemuCaps, net)) + return false; + return virQEMUCapsGet(qemuCaps, QEMU_CAPS_NETDEV); +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 285af8c563..59875c1334 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1,7 +1,7 @@ /* * qemu_domain.h: QEMU domain private state * - * Copyright (C) 2006-2014 Red Hat, Inc. + * Copyright (C) 2006-2016 Red Hat, Inc. * Copyright (C) 2006 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -513,4 +513,13 @@ pid_t qemuDomainGetVcpuPid(virDomainObjPtr vm, unsigned int vcpu); int qemuDomainDetectVcpuPids(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob); +bool qemuDomainSupportsNicdev(virDomainDefPtr def, + virQEMUCapsPtr qemuCaps, + virDomainNetDefPtr net); + +bool qemuDomainSupportsNetdev(virDomainDefPtr def, + virQEMUCapsPtr qemuCaps, + virDomainNetDefPtr net); + + #endif /* __QEMU_DOMAIN_H__ */