Hi,
I'm using libvirt 0.5.0 to manage my kvm domains. Everything works fine except
autostarting vms which use a network device not directly bridged to hw. I
have the following net defined (and set to autostart):
<network>
<name>local</name>
<uuid>7ec7a457-0b8e-4670-3b4a-2d0914288daa</uuid>
<bridge stp='on' forwardDelay='0' />
<ip address='192.168.100.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.100.128' end='192.168.100.254' />
</dhcp>
</ip>
</network>
When a vm using this net is autostarted I get the following error:
libvir: error : invalid connection pointer in virNetworkLookupByName
libvir: QEMU error : internal error Network 'local' not found
Failed to autostart VM 'testlocalnet': internal error Network 'local' not
found
I took a dive into the code and found two problems causing this:
1. initialization order:
qemuStateDriver is registered (and thus initialized) before
networkStateDriver. This means the network is not up yet when qemu does it's
autostart.
I could fix this with the attached patch.
2. missing virConnectPtr during autostart of the vm:
in src/qemu_driver.c:145, qemudAutostartConfigs() you can find this call:
int ret = qemudStartVMDaemon(NULL, driver, vm, NULL);
This means virConnectPtr conn is NULL within qemudStartVMDaemon().
Following the calls:
qemudStartVMDaemon()
-> qemudBuildCommandLine()
-> qemudNetworkIfaceConnect()
-> virNetworkLookupByName()
virNetworkLookupByName bails out if called with invalid virConnectPtr. This
means starting this vm fails.
Currently I'm not familiar enough with the libvirt structures to come up with
an idea how to fix this.
Could anybody with a deeper knowledge of the code take a look at this? Thank
you very much.
Kind regards,
Gerd
diff -r -u libvirt-0.5.0.orig/qemud/qemud.c libvirt-0.5.0/qemud/qemud.c
--- libvirt-0.5.0.orig/qemud/qemud.c 2008-11-21 13:47:32.000000000 +0100
+++ libvirt-0.5.0/qemud/qemud.c 2008-11-30 21:27:06.000000000 +0100
@@ -761,22 +761,13 @@
* If they try to use a open a connection for a module that
* is not loaded they'll get a suitable error at that point
*/
- virDriverLoadModule("qemu");
- virDriverLoadModule("lxc");
- virDriverLoadModule("uml");
virDriverLoadModule("network");
virDriverLoadModule("storage");
virDriverLoadModule("nodedev");
+ virDriverLoadModule("qemu");
+ virDriverLoadModule("lxc");
+ virDriverLoadModule("uml");
#else
-#ifdef WITH_QEMU
- qemuRegister();
-#endif
-#ifdef WITH_LXC
- lxcRegister();
-#endif
-#ifdef WITH_UML
- umlRegister();
-#endif
#ifdef WITH_NETWORK
networkRegister();
#endif
@@ -786,6 +777,15 @@
#if defined(HAVE_HAL) || defined(HAVE_DEVKIT)
nodedevRegister();
#endif
+#ifdef WITH_QEMU
+ qemuRegister();
+#endif
+#ifdef WITH_LXC
+ lxcRegister();
+#endif
+#ifdef WITH_UML
+ umlRegister();
+#endif
#endif
virEventRegisterImpl(virEventAddHandleImpl,
--
Address (better: trap) for people I really don't want to get mail from:
james(a)cactusamerica.com