Fix autostart of domains with virtual networks used

This commit is contained in:
Daniel P. Berrange 2008-12-08 11:18:47 +00:00
parent 73bc9c163c
commit abb02bd18b
3 changed files with 30 additions and 2 deletions

View File

@ -1,3 +1,9 @@
Mon Dec 8 11:17:53 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
* src/qemu_driver.c, src/uml_driver.c: Fix guest autostart
to have a virConnect object available to allow query of
virtual networks
Sun Dec 7 20:44:53 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
* src/test.c: Fix integer long long overflow. Fix NULL defernce

View File

@ -146,13 +146,22 @@ static struct qemud_driver *qemu_driver = NULL;
static void
qemudAutostartConfigs(struct qemud_driver *driver) {
unsigned int i;
/* XXX: Figure out a better way todo this. The domain
* startup code needs a connection handle in order
* to lookup the bridge associated with a virtual
* network
*/
virConnectPtr conn = virConnectOpen(getuid() ?
"qemu:///session" :
"qemu:///system");
/* Ignoring NULL conn which is mostly harmless here */
for (i = 0 ; i < driver->domains.count ; i++) {
virDomainObjPtr vm = driver->domains.objs[i];
virDomainObjLock(vm);
if (vm->autostart &&
!virDomainIsActive(vm)) {
int ret = qemudStartVMDaemon(NULL, driver, vm, NULL);
int ret = qemudStartVMDaemon(conn, driver, vm, NULL);
if (ret < 0) {
virErrorPtr err = virGetLastError();
qemudLog(QEMUD_ERR, _("Failed to autostart VM '%s': %s\n"),
@ -169,6 +178,8 @@ qemudAutostartConfigs(struct qemud_driver *driver) {
}
virDomainObjUnlock(vm);
}
virConnectClose(conn);
}
/**

View File

@ -126,16 +126,27 @@ static struct uml_driver *uml_driver = NULL;
static void
umlAutostartConfigs(struct uml_driver *driver) {
unsigned int i;
/* XXX: Figure out a better way todo this. The domain
* startup code needs a connection handle in order
* to lookup the bridge associated with a virtual
* network
*/
virConnectPtr conn = virConnectOpen(getuid() ?
"uml:///session" :
"uml:///system");
/* Ignoring NULL conn which is mostly harmless here */
for (i = 0 ; i < driver->domains.count ; i++) {
if (driver->domains.objs[i]->autostart &&
!virDomainIsActive(driver->domains.objs[i]) &&
umlStartVMDaemon(NULL, driver, driver->domains.objs[i]) < 0) {
umlStartVMDaemon(conn, driver, driver->domains.objs[i]) < 0) {
virErrorPtr err = virGetLastError();
umlLog(UML_ERR, _("Failed to autostart VM '%s': %s\n"),
driver->domains.objs[i]->def->name, err->message);
}
}
virConnectClose(conn);
}