I realized that PATCH 10/10 would cause the build to fail if someone
did a build --with-qemu but --without-network. I'm squashing the
following into the original patch to remedy that.
I'm not really a fan of putting #if all over the place, but this is
similar to what's done with WITH_MACVTAP, so at least there's
precedence. (This is necessary because this new "backend API" to the
network driver isn't called via a pointer table filled in at runtime,
as is done with the public API).
---
src/qemu/qemu_command.c | 5 ++++-
src/qemu/qemu_hotplug.c | 8 ++++++--
src/qemu/qemu_process.c | 8 ++++++--
tests/Makefile.am | 7 +++++--
4 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d6a0c6d..0b957cb 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3678,13 +3678,14 @@ qemuBuildCommandLine(virConnectPtr conn,
else
vlan = i;
+#if WITH_NETWORK
/* If appropriate, grab a physical device from the configured
* network's pool of devices, or resolve bridge device name
* to the one defined in the network definition.
*/
if (networkAllocateActualDevice(net) < 0)
goto error;
-
+#endif
actualType = virDomainNetGetActualType(net);
if (actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) {
@@ -4682,8 +4683,10 @@ qemuBuildCommandLine(virConnectPtr conn,
virReportOOMError();
error:
/* free up any resources in the network driver */
+#if WITH_NETWORK
for (i = 0 ; i < def->nnets ; i++)
networkReleaseActualDevice(def->nets[i]);
+#endif
for (i = 0; i <= last_good_net; i++)
virDomainConfNWFilterTeardown(def->nets[i]);
virBufferFreeAndReset(&rbd_hosts);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 37cfbef..5f1a424 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -613,13 +613,14 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
return -1;
}
+#if WITH_NETWORK
/* If appropriate, grab a physical device from the configured
* network's pool of devices, or resolve bridge device name
* to the one defined in the network definition.
*/
if (networkAllocateActualDevice(net) < 0)
goto cleanup;
-
+#endif
actualType = virDomainNetGetActualType(net);
if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
actualType == VIR_DOMAIN_NET_TYPE_NETWORK) {
@@ -761,7 +762,9 @@ cleanup:
if (iface_connected)
virDomainConfNWFilterTeardown(net);
+#if WITH_NETWORK
networkReleaseActualDevice(net);
+#endif
}
VIR_FREE(nicstr);
@@ -1644,8 +1647,9 @@ int qemuDomainDetachNetDevice(struct qemud_driver *driver,
}
}
+#if WITH_NETWORK
networkReleaseActualDevice(detach);
-
+#endif
if (vm->def->nnets > 1) {
memmove(vm->def->nets + i,
vm->def->nets + i + 1,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index f4a57ff..709f187 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2168,6 +2168,7 @@ int qemuProcessStopCPUs(struct qemud_driver *driver, virDomainObjPtr
vm,
+#if WITH_NETWORK
static int
qemuProcessNotifyNets(virDomainDefPtr def)
{
@@ -2180,7 +2181,7 @@ qemuProcessNotifyNets(virDomainDefPtr def)
}
return 0;
}
-
+#endif
static int
qemuProcessFiltersInstantiate(virConnectPtr conn,
@@ -2294,9 +2295,10 @@ qemuProcessReconnect(void *payload, const void *name
ATTRIBUTE_UNUSED, void *opa
if (virSecurityManagerReserveLabel(driver->securityManager, obj) < 0)
goto error;
+#if WITH_NETWORK
if (qemuProcessNotifyNets(obj->def) < 0)
goto error;
-
+#endif
if (qemuProcessFiltersInstantiate(conn, obj->def))
goto error;
@@ -2932,7 +2934,9 @@ void qemuProcessStop(struct qemud_driver *driver,
/* release the physical device (or any other resources used by
* this interface in the network driver
*/
+#if WITH_NETWORK
networkReleaseActualDevice(net);
+#endif
}
retry:
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a9ad759..6afec28 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -319,8 +319,11 @@ endif
if WITH_QEMU
-qemu_LDADDS = ../src/libvirt_driver_qemu.la \
- ../src/libvirt_driver_network.la
+qemu_LDADDS = ../src/libvirt_driver_qemu.la
+
+if WITH_NETWORK
+qemu_LDADDS += ../src/libvirt_driver_network.la
+endif
qemuxml2argvtest_SOURCES = \
qemuxml2argvtest.c testutilsqemu.c testutilsqemu.h \
--
1.7.3.4