virDomainXMLOptionPtr xmlopt,
unsigned int expectedVirtTypes,
unsigned int flags);
+virDomainObjPtr virDomainObjParseFile(const char *filename,
+ virCapsPtr caps,
+ virDomainXMLOptionPtr xmlopt,
+ unsigned int expectedVirtTypes,
+ unsigned int flags);
bool virDomainDefCheckABIStability(virDomainDefPtr src,
virDomainDefPtr dst);
typedef virLXCController *virLXCControllerPtr;
struct _virLXCController {
char *name;
+ virDomainObjPtr vm;
virDomainDefPtr def;
int handshakeFd;
ctrl->name)) == NULL)
goto error;
- if ((ctrl->def = virDomainDefParseFile(configFile,
- caps, xmlopt,
- 1 << VIR_DOMAIN_VIRT_LXC,
- 0)) == NULL)
+ if ((ctrl->vm = virDomainObjParseFile(configFile,
+ caps, xmlopt,
+ 1 << VIR_DOMAIN_VIRT_LXC,
+ 0)) == NULL)
goto error;
+ ctrl->def = ctrl->vm->def;
if ((ctrl->timerShutdown = virEventAddTimeout(-1,
virLXCControllerQuitTimer, ctrl,
VIR_FREE(ctrl->devptmx);
- virDomainDefFree(ctrl->def);
+ virObjectUnref(ctrl->vm);
VIR_FREE(ctrl->name);
if (ctrl->timerShutdown != -1)
virCommandSetPidFile(cmd, pidfile);
virCommandSetOutputFD(cmd, &logfd);
virCommandSetErrorFD(cmd, &logfd);
+ /* So we can pause before exec'ing the controller to
+ * write the live domain status XML with the PID */
+ virCommandRequireHandshake(cmd);
return cmd;
cleanup:
if (virLXCProcessSetupInterfaces(conn, vm->def, &nveths, &veths) < 0)
goto cleanup;
- /* Save the configuration for the controller */
- if (virDomainSaveConfig(cfg->stateDir, vm->def) < 0)
- goto cleanup;
-
if ((logfd = open(logfile, O_WRONLY | O_APPEND | O_CREAT,
S_IRUSR|S_IWUSR)) < 0) {
virReportSystemError(errno,
goto error;
}
+ if (VIR_CLOSE(handshakefds[1]) < 0) {
+ virReportSystemError(errno, "%s", _("could not close handshake fd"));
+ goto error;
+ }
+
+ if (virCommandHandshakeWait(cmd) < 0)
+ goto error;
+
+ /* Write domain status to disk for the controller to
+ * read when it starts */
+ if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
+ goto error;
+
+ /* Allow the child to exec the controller */
+ if (virCommandHandshakeNotify(cmd) < 0)
+ goto error;
+
if (virAtomicIntInc(&driver->nactive) == 1 && driver->inhibitCallback)
driver->inhibitCallback(true, driver->inhibitOpaque);
/* We don't need the temporary NIC names anymore, clear them */
virLXCProcessCleanInterfaces(vm->def);
- /* Write domain status to disk.
- *
- * XXX: Earlier we wrote the plain "live" domain XML to this
- * location for the benefit of libvirt_lxc. We're now overwriting
- * it with the live status XML instead. This is a (currently
- * harmless) inconsistency we should fix one day */
- if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
- goto error;
-
/* finally we can call the 'started' hook script if any */
if (virHookPresent(VIR_HOOK_DRIVER_LXC)) {
char *xml = virDomainDefFormat(vm->def, 0);