if (qemuDomainObjInitJob(priv) < 0)
goto error;
+ if (!(priv->cons = virConsoleAlloc()))
+ goto error;
+
priv->migMaxBandwidth = QEMU_DOMAIN_DEFAULT_MIG_BANDWIDTH_MAX;
return priv;
VIR_FREE(priv->lockState);
VIR_FREE(priv->origname);
+ virConsoleFree(priv->cons);
+
/* This should never be non-NULL if we get here, but just in case... */
if (priv->mon) {
VIR_ERROR(_("Unexpected QEMU monitor still active during domain deletion"));
# include "qemu_agent.h"
# include "qemu_conf.h"
# include "bitmap.h"
+# include "virconsole.h"
# define QEMU_EXPECTED_VIRT_TYPES \
((1 << VIR_DOMAIN_VIRT_QEMU) | \
unsigned long migMaxBandwidth;
char *origname;
+
+ virConsolesPtr cons;
};
struct qemuDomainWatchdogEvent
int ret = -1;
int i;
virDomainChrDefPtr chr = NULL;
+ qemuDomainObjPrivatePtr priv;
- virCheckFlags(0, -1);
+ virCheckFlags(VIR_DOMAIN_CONSOLE_SAFE |
+ VIR_DOMAIN_CONSOLE_FORCE, -1);
qemuDriverLock(driver);
virUUIDFormat(dom->uuid, uuidstr);
goto cleanup;
}
+ priv = vm->privateData;
+
if (dev_name) {
for (i = 0 ; !chr && i < vm->def->nconsoles ; i++) {
if (vm->def->consoles[i]->info.alias &&
goto cleanup;
}
- if (virFDStreamOpenFile(st, chr->source.data.file.path,
- 0, 0, O_RDWR) < 0)
- goto cleanup;
+ /* handle mutually exclusive access to console devices */
+ ret = virConsoleOpen(priv->cons,
+ chr->source.data.file.path,
+ st,
+ (flags & VIR_DOMAIN_CONSOLE_FORCE) != 0);
+
+ if (ret == 1) {
+ qemuReportError(VIR_ERR_OPERATION_FAILED,
+ _("Active console session exists for this domain"));
+ ret = -1;
+ }
- ret = 0;
cleanup:
if (vm)
virDomainObjUnlock(vm);